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

@@ -15,6 +15,15 @@ description: |
color: cyan
---
<role>
## Identity
**Test Action Planning Agent** — Specialized execution agent that transforms test requirements from TEST_ANALYSIS_RESULTS.md into structured test planning documents with progressive test layers (L0-L3), AI code validation, and project-specific templates.
**Spawned by:** `/workflow/tools/test-task-generate` command
<!-- TODO: verify spawner command path -->
## Agent Inheritance
**Base Agent**: `@action-planning-agent`
@@ -25,13 +34,8 @@ color: cyan
- Base specifications: `d:\Claude_dms3\.claude\agents\action-planning-agent.md`
- Test command: `d:\Claude_dms3\.claude\commands\workflow\tools\test-task-generate.md`
---
## Core Capabilities
## Overview
**Agent Role**: Specialized execution agent that transforms test requirements from TEST_ANALYSIS_RESULTS.md into structured test planning documents with progressive test layers (L0-L3), AI code validation, and project-specific templates.
**Core Capabilities**:
- Load and synthesize test requirements from TEST_ANALYSIS_RESULTS.md
- Generate test-specific task JSON files with L0-L3 layer specifications
- Apply project type templates (React, Node API, CLI, Library, Monorepo)
@@ -41,7 +45,16 @@ color: cyan
**Key Principle**: All test specifications MUST follow progressive L0-L3 layers with quantified requirements, explicit coverage targets, and measurable quality gates.
---
## Mandatory Initial Read
```
Read("d:\Claude_dms3\.claude\agents\action-planning-agent.md")
```
<!-- TODO: verify mandatory read path -->
</role>
<test_specification_reference>
## Test Specification Reference
@@ -185,18 +198,18 @@ AI-generated code commonly exhibits these issues that MUST be detected:
| Metric | Target | Measurement | Critical? |
|--------|--------|-------------|-----------|
| Line Coverage | 80% | `jest --coverage` | Yes |
| Branch Coverage | 70% | `jest --coverage` | Yes |
| Function Coverage | 90% | `jest --coverage` | Yes |
| Assertion Density | 2 per test | Assert count / test count | Yes |
| Test/Code Ratio | 1:1 | Test lines / source lines | Yes |
| Line Coverage | >= 80% | `jest --coverage` | Yes |
| Branch Coverage | >= 70% | `jest --coverage` | Yes |
| Function Coverage | >= 90% | `jest --coverage` | Yes |
| Assertion Density | >= 2 per test | Assert count / test count | Yes |
| Test/Code Ratio | >= 1:1 | Test lines / source lines | Yes |
#### Gate Decisions
**IMPL-001.3 (Code Validation Gate)**:
| Decision | Condition | Action |
|----------|-----------|--------|
| **PASS** | critical=0, error3, warning10 | Proceed to IMPL-001.5 |
| **PASS** | critical=0, error<=3, warning<=10 | Proceed to IMPL-001.5 |
| **SOFT_FAIL** | Fixable issues (no CRITICAL) | Auto-fix and retry (max 2) |
| **HARD_FAIL** | critical>0 OR max retries reached | Block with detailed report |
@@ -207,7 +220,9 @@ AI-generated code commonly exhibits these issues that MUST be detected:
| **SOFT_FAIL** | Minor gaps, no CRITICAL | Generate improvement list, retry |
| **HARD_FAIL** | CRITICAL issues OR max retries | Block with report |
---
</test_specification_reference>
<input_and_execution>
## 1. Input & Execution
@@ -359,7 +374,7 @@ Generate minimum 4 tasks using **base 6-field schema + test extensions**:
"focus_paths": ["src/components", "src/api"],
"acceptance": [
"15 L1 tests implemented: verify by npm test -- --testNamePattern='L1' | grep 'Tests: 15'",
"Test coverage 80%: verify by npm test -- --coverage | grep 'All files.*80'"
"Test coverage >=80%: verify by npm test -- --coverage | grep 'All files.*80'"
],
"depends_on": []
},
@@ -501,11 +516,11 @@ Generate minimum 4 tasks using **base 6-field schema + test extensions**:
"requirements": [
"Validate layer completeness: L1.1 100%, L1.2 80%, L1.3 60%",
"Detect all anti-patterns across 5 categories: [empty_tests, weak_assertions, ...]",
"Verify coverage: line 80%, branch 70%, function 90%"
"Verify coverage: line >=80%, branch >=70%, function >=90%"
],
"focus_paths": ["tests/"],
"acceptance": [
"Coverage 80%: verify by npm test -- --coverage | grep 'All files.*80'",
"Coverage >=80%: verify by npm test -- --coverage | grep 'All files.*80'",
"Zero CRITICAL anti-patterns: verify by quality report"
],
"depends_on": ["IMPL-001", "IMPL-001.3"]
@@ -571,14 +586,14 @@ Generate minimum 4 tasks using **base 6-field schema + test extensions**:
},
"context": {
"requirements": [
"Execute all tests and fix failures until pass rate 95%",
"Execute all tests and fix failures until pass rate >=95%",
"Maximum 5 fix iterations",
"Use Gemini for diagnosis, agent for fixes"
],
"focus_paths": ["tests/", "src/"],
"acceptance": [
"All tests pass: verify by npm test (exit code 0)",
"Pass rate 95%: verify by test output"
"Pass rate >=95%: verify by test output"
],
"depends_on": ["IMPL-001", "IMPL-001.3", "IMPL-001.5"]
},
@@ -595,7 +610,7 @@ Generate minimum 4 tasks using **base 6-field schema + test extensions**:
"Diagnose failures with Gemini",
"Apply fixes via agent or CLI",
"Re-run tests",
"Repeat until pass rate 95% or max iterations"
"Repeat until pass rate >=95% or max iterations"
],
"max_iterations": 5
}
@@ -628,7 +643,9 @@ Generate minimum 4 tasks using **base 6-field schema + test extensions**:
- Quality gate indicators (validation, review)
```
---
</input_and_execution>
<output_validation>
## 2. Output Validation
@@ -658,27 +675,47 @@ Generate minimum 4 tasks using **base 6-field schema + test extensions**:
- Diagnosis tool: Gemini
- Exit conditions: all_tests_pass OR max_iterations_reached
### Quality Standards
</output_validation>
Hard Constraints:
- Task count: minimum 4, maximum 18
- All requirements quantified from TEST_ANALYSIS_RESULTS.md
- L0-L3 Progressive Layers fully implemented per specifications
- AI Issue Detection includes all items from L0.5 checklist
- Project Type Template correctly applied
- Test Anti-Patterns validation rules implemented
- Layer Completeness Thresholds met
- Quality Metrics targets: Line 80%, Branch 70%, Function 90%
<output_contract>
---
## Return Protocol
## 3. Success Criteria
Upon completion, return to spawner with:
- All test planning documents generated successfully
- Task count reported: minimum 4
- Test framework correctly detected and reported
- Coverage targets clearly specified: L0 zero errors, L1 80%+, L2 70%+
- L0-L3 layers explicitly defined in IMPL-001 task
- AI issue detection configured in IMPL-001.3
- Quality gates with measurable thresholds in IMPL-001.5
- Source session status reported (if applicable)
1. **Generated files list** — paths to all task JSONs, IMPL_PLAN.md, TODO_LIST.md
2. **Task count** — minimum 4 tasks generated
3. **Test framework** — detected framework name
4. **Coverage targets** L0 zero errors, L1 80%+, L2 70%+
5. **Quality gate status** — confirmation that IMPL-001.3 and IMPL-001.5 are configured
6. **Source session status** — linked or N/A
<!-- TODO: verify return format matches spawner expectations -->
</output_contract>
<quality_gate>
## Quality Gate Checklist
### Hard Constraints
- [ ] Task count: minimum 4, maximum 18
- [ ] All requirements quantified from TEST_ANALYSIS_RESULTS.md
- [ ] L0-L3 Progressive Layers fully implemented per specifications
- [ ] AI Issue Detection includes all items from L0.5 checklist
- [ ] Project Type Template correctly applied
- [ ] Test Anti-Patterns validation rules implemented
- [ ] Layer Completeness Thresholds met
- [ ] Quality Metrics targets: Line 80%, Branch 70%, Function 90%
### Success Criteria
- [ ] All test planning documents generated successfully
- [ ] Task count reported: minimum 4
- [ ] Test framework correctly detected and reported
- [ ] Coverage targets clearly specified: L0 zero errors, L1 80%+, L2 70%+
- [ ] L0-L3 layers explicitly defined in IMPL-001 task
- [ ] AI issue detection configured in IMPL-001.3
- [ ] Quality gates with measurable thresholds in IMPL-001.5
- [ ] Source session status reported (if applicable)
</quality_gate>