Enhance search functionality and indexing pipeline

- Updated `cmd_search` to include line numbers and content in search results.
- Modified `IndexingPipeline` to handle start and end line numbers for chunks.
- Enhanced `FTSEngine` to support storing line metadata in the database.
- Improved `SearchPipeline` to return line numbers and full content in search results.
- Added unit tests for bridge, FTS delete operations, metadata store, and watcher functionality.
- Introduced a `.gitignore` file to exclude specific directories.
This commit is contained in:
catlog22
2026-03-17 14:55:27 +08:00
parent bfe5426b7e
commit 0f02b75be1
25 changed files with 2014 additions and 1482 deletions

View File

@@ -36,6 +36,7 @@ allowed-tools: Tool1, Tool2 # Optional: restricted tool set
.claude/commands/deploy.md # Top-level command
.claude/commands/issue/create.md # Grouped command
~/.claude/commands/global-status.md # User-level command
.claude/skills/my-skill/SKILL.md # Skill file (see Skill Variant below)
```
## Content Structure
@@ -45,12 +46,60 @@ Commands use XML semantic tags with process steps inside `<process>`:
| Tag | Required | Purpose |
|-----|----------|---------|
| `<purpose>` | Yes | What + when + what it produces (2-3 sentences) |
| `<required_reading>` | Yes | @ file references loaded before execution |
| `<required_reading>` | Commands only | @ file references loaded before execution |
| `<process>` | Yes | Steps — numbered or named (see Step Styles below) |
| `<auto_mode>` | Optional | Behavior when `--auto` flag present |
| `<offer_next>` | Recommended | Formatted completion status + next actions |
| `<success_criteria>` | Yes | Checkbox list of verifiable conditions |
## Skill Variant
Skills (`.claude/skills/*/SKILL.md`) follow command structure with critical differences due to **progressive loading** — skills are loaded inline into the conversation context, NOT via file resolution.
### Key Differences: Skill vs Command
| Aspect | Command | Skill |
|--------|---------|-------|
| Location | `.claude/commands/` | `.claude/skills/*/SKILL.md` |
| Loading | Slash-command invocation, `@` refs resolved | Progressive inline loading into conversation |
| `<required_reading>` | Yes — `@path` refs auto-resolved | **NO**`@` refs do NOT work in skills |
| External file access | `@` references | `Read()` tool calls within `<process>` steps |
| Phase files | N/A | `Read("phases/01-xxx.md")` within process steps |
| Frontmatter | `name`, `description`, `argument-hint` | `name`, `description`, `allowed-tools` |
### Skill-Specific Rules
1. **NO `<required_reading>` tag** — Skills cannot use `@` file references. All external context must be loaded via `Read()` tool calls within `<process>` steps.
2. **Progressive phase loading** — For multi-phase skills with phase files in `phases/` subdirectory, use inline `Read()`:
```javascript
// Within process step: Load phase doc on-demand
Read("phases/01-session-discovery.md")
// Execute phase logic...
```
3. **Self-contained content** — All instructions, rules, and logic must be directly in the SKILL.md or loaded via `Read()` at runtime. No implicit file dependencies.
4. **Frontmatter uses `allowed-tools:`** instead of `argument-hint:`:
```yaml
---
name: my-skill
description: What this skill does
allowed-tools: Agent, Read, Write, Bash, Glob, Grep
---
```
### Skill Content Structure
| Tag | Required | Purpose |
|-----|----------|---------|
| `<purpose>` | Yes | What + when + what it produces (2-3 sentences) |
| `<process>` | Yes | Steps with inline `Read()` for external files |
| `<auto_mode>` | Optional | Behavior when `-y`/`--yes` flag present |
| `<success_criteria>` | Yes | Checkbox list of verifiable conditions |
**Note**: `<offer_next>` is less common in skills since skills often chain to other skills via `Skill()` calls.
## Step Styles
GSD uses two step styles. Choose based on command nature:

View File

@@ -36,6 +36,62 @@ Conversion Summary:
New sections added: {list of TODO sections}
```
## Artifact Type Detection
Before applying conversion rules, determine the source type:
| Source Location | Type |
|----------------|------|
| `.claude/commands/**/*.md` | command |
| `.claude/skills/*/SKILL.md` | skill |
| `.claude/agents/*.md` | agent |
**Skill detection signals**: `allowed-tools:` in frontmatter, located in `.claude/skills/` directory, progressive phase loading pattern (`Read("phases/...")`)
## Skill Conversion Rules
### Critical: No @ References
Skills are loaded **progressively inline** into the conversation context. They CANNOT use `@` file references — these only work in commands.
### Source Pattern → Target Pattern (Skill)
| Source Style | Target Style |
|-------------|-------------|
| `# Title` + flat markdown overview | `<purpose>` (2-3 sentences) |
| `## Implementation` / `## Execution Flow` / `## Phase Summary` | `<process>` with numbered `## N.` steps |
| Phase file references as prose | `Read("phases/...")` calls within process steps |
| `## Success Criteria` / `## Coordinator Checklist` | `<success_criteria>` with checkbox list |
| `## Auto Mode` / `## Auto Mode Defaults` | `<auto_mode>` section |
| `## Error Handling` | Preserve as-is within `<process>` or as standalone section |
| Code blocks, tables, ASCII diagrams | **Preserve exactly** |
### What NOT to Add (Skill-Specific)
| Element | Why NOT |
|---------|---------|
| `<required_reading>` | Skills cannot use `@` refs — progressive loading |
| `@specs/...` or `@phases/...` | `@` syntax not supported in skills |
| `<offer_next>` | Skills chain via `Skill()` calls, not offer menus |
### What to ADD (Skill-Specific)
| Missing Element | Add |
|----------------|-----|
| `<purpose>` | Extract from overview/description |
| `<process>` wrapper | Wrap implementation steps |
| `<success_criteria>` | Generate from coordinator checklist or existing content |
| `<auto_mode>` | If auto mode behavior exists, wrap in tag |
### Frontmatter Conversion (Skill)
| Source Field | Target Field | Transformation |
|-------------|-------------|----------------|
| `name` | `name` | Keep as-is |
| `description` | `description` | Keep as-is |
| `allowed-tools` | `allowed-tools` | Keep as-is |
| Missing `allowed-tools` | `allowed-tools` | Infer from content |
## Command Conversion Rules
### Source Pattern → Target Pattern