@drafthq/draft 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +38 -0
- package/.claude-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +272 -0
- package/bin/README.md +49 -0
- package/cli/bin/draft.js +13 -0
- package/cli/src/cli.js +113 -0
- package/cli/src/hosts/claude-code.js +46 -0
- package/cli/src/hosts/codex.js +33 -0
- package/cli/src/hosts/cursor.js +50 -0
- package/cli/src/hosts/index.js +24 -0
- package/cli/src/hosts/opencode.js +39 -0
- package/cli/src/installer.js +61 -0
- package/cli/src/lib/fsx.js +34 -0
- package/cli/src/lib/graph.js +23 -0
- package/cli/src/lib/log.js +32 -0
- package/cli/src/lib/paths.js +14 -0
- package/core/agents/architect.md +338 -0
- package/core/agents/debugger.md +193 -0
- package/core/agents/ops.md +104 -0
- package/core/agents/planner.md +158 -0
- package/core/agents/rca.md +314 -0
- package/core/agents/reviewer.md +256 -0
- package/core/agents/writer.md +110 -0
- package/core/guardrails/README.md +4 -0
- package/core/guardrails/code-quality.md +4 -0
- package/core/guardrails/dependency-triage.md +4 -0
- package/core/guardrails/design-norms.md +4 -0
- package/core/guardrails/language-standards.md +4 -0
- package/core/guardrails/review-checks.md +4 -0
- package/core/guardrails/secure-patterns.md +4 -0
- package/core/guardrails/security.md +4 -0
- package/core/guardrails.md +22 -0
- package/core/knowledge-base.md +127 -0
- package/core/methodology.md +1221 -0
- package/core/shared/condensation.md +224 -0
- package/core/shared/context-verify.md +44 -0
- package/core/shared/cross-skill-dispatch.md +127 -0
- package/core/shared/discovery-schema.md +75 -0
- package/core/shared/draft-context-loading.md +282 -0
- package/core/shared/git-report-metadata.md +106 -0
- package/core/shared/graph-query.md +239 -0
- package/core/shared/graph-usage-report.md +22 -0
- package/core/shared/jira-sync.md +170 -0
- package/core/shared/parallel-analysis.md +386 -0
- package/core/shared/parallel-fanout.md +10 -0
- package/core/shared/pattern-learning.md +146 -0
- package/core/shared/red-flags.md +58 -0
- package/core/shared/template-contract.md +22 -0
- package/core/shared/template-hygiene.md +10 -0
- package/core/shared/tool-resolver.md +10 -0
- package/core/shared/vcs-commands.md +97 -0
- package/core/shared/verification-gates.md +47 -0
- package/core/templates/CHANGELOG.md +70 -0
- package/core/templates/ai-context-export.md +8 -0
- package/core/templates/ai-context.md +270 -0
- package/core/templates/ai-profile.md +41 -0
- package/core/templates/architecture.md +203 -0
- package/core/templates/dependency-graph.md +103 -0
- package/core/templates/discovery.md +79 -0
- package/core/templates/guardrails.md +143 -0
- package/core/templates/hld.md +327 -0
- package/core/templates/intake-questions.md +403 -0
- package/core/templates/jira.md +119 -0
- package/core/templates/lld.md +283 -0
- package/core/templates/metadata.json +66 -0
- package/core/templates/plan.md +130 -0
- package/core/templates/product.md +110 -0
- package/core/templates/rca.md +86 -0
- package/core/templates/root-architecture.md +127 -0
- package/core/templates/root-product.md +53 -0
- package/core/templates/root-tech-stack.md +117 -0
- package/core/templates/service-index.md +55 -0
- package/core/templates/session-summary.md +8 -0
- package/core/templates/spec.md +165 -0
- package/core/templates/tech-matrix.md +101 -0
- package/core/templates/tech-stack.md +169 -0
- package/core/templates/track-architecture.md +311 -0
- package/core/templates/workflow.md +187 -0
- package/integrations/agents/AGENTS.md +24384 -0
- package/integrations/copilot/.github/copilot-instructions.md +24384 -0
- package/integrations/gemini/.gemini.md +26 -0
- package/package.json +53 -0
- package/scripts/fetch-memory-engine.sh +116 -0
- package/scripts/lib.sh +256 -0
- package/scripts/tools/_lib.sh +220 -0
- package/scripts/tools/adr-index.sh +117 -0
- package/scripts/tools/check-graph-usage-report.sh +95 -0
- package/scripts/tools/check-scope-conflicts.sh +139 -0
- package/scripts/tools/check-skill-line-caps.sh +115 -0
- package/scripts/tools/check-template-noop.sh +87 -0
- package/scripts/tools/check-track-hygiene.sh +230 -0
- package/scripts/tools/classify-files.sh +231 -0
- package/scripts/tools/cycle-detect.sh +75 -0
- package/scripts/tools/detect-test-framework.sh +135 -0
- package/scripts/tools/diff-templates-vs-tracks.sh +176 -0
- package/scripts/tools/emit-skill-metrics.sh +71 -0
- package/scripts/tools/fix-whitespace.sh +192 -0
- package/scripts/tools/freshness-check.sh +143 -0
- package/scripts/tools/git-metadata.sh +203 -0
- package/scripts/tools/graph-callers.sh +74 -0
- package/scripts/tools/graph-impact.sh +93 -0
- package/scripts/tools/graph-snapshot.sh +102 -0
- package/scripts/tools/hotspot-rank.sh +75 -0
- package/scripts/tools/manage-symlinks.sh +85 -0
- package/scripts/tools/mermaid-from-graph.sh +92 -0
- package/scripts/tools/migrate-track-frontmatter.sh +241 -0
- package/scripts/tools/parse-git-log.sh +135 -0
- package/scripts/tools/parse-reports.sh +114 -0
- package/scripts/tools/render-track.sh +145 -0
- package/scripts/tools/run-coverage.sh +153 -0
- package/scripts/tools/scan-markers.sh +144 -0
- package/scripts/tools/skill-caps.conf +24 -0
- package/scripts/tools/validate-frontmatter.sh +125 -0
- package/scripts/tools/verify-citations.sh +250 -0
- package/scripts/tools/verify-doc-anchors.sh +204 -0
- package/scripts/tools/verify-graph-binary.sh +154 -0
- package/skills/GRAPH.md +332 -0
- package/skills/adr/SKILL.md +374 -0
- package/skills/assist-review/SKILL.md +49 -0
- package/skills/bughunt/SKILL.md +668 -0
- package/skills/bughunt/references/regression-tests.md +399 -0
- package/skills/change/SKILL.md +267 -0
- package/skills/coverage/SKILL.md +336 -0
- package/skills/debug/SKILL.md +201 -0
- package/skills/decompose/SKILL.md +656 -0
- package/skills/deep-review/SKILL.md +326 -0
- package/skills/deploy-checklist/SKILL.md +254 -0
- package/skills/discover/SKILL.md +66 -0
- package/skills/docs/SKILL.md +42 -0
- package/skills/documentation/SKILL.md +197 -0
- package/skills/draft/SKILL.md +177 -0
- package/skills/draft/context-files.md +57 -0
- package/skills/draft/intent-mapping.md +37 -0
- package/skills/draft/quality-guide.md +51 -0
- package/skills/graph/SKILL.md +107 -0
- package/skills/impact/SKILL.md +86 -0
- package/skills/implement/SKILL.md +794 -0
- package/skills/incident-response/SKILL.md +245 -0
- package/skills/index/SKILL.md +848 -0
- package/skills/init/SKILL.md +1784 -0
- package/skills/init/references/architecture-spec.md +1259 -0
- package/skills/integrations/SKILL.md +53 -0
- package/skills/jira/SKILL.md +577 -0
- package/skills/jira/references/review.md +1322 -0
- package/skills/learn/SKILL.md +478 -0
- package/skills/new-track/SKILL.md +841 -0
- package/skills/ops/SKILL.md +57 -0
- package/skills/plan/SKILL.md +60 -0
- package/skills/quick-review/SKILL.md +216 -0
- package/skills/revert/SKILL.md +178 -0
- package/skills/review/SKILL.md +1114 -0
- package/skills/standup/SKILL.md +183 -0
- package/skills/status/SKILL.md +183 -0
- package/skills/tech-debt/SKILL.md +318 -0
- package/skills/testing-strategy/SKILL.md +195 -0
- package/skills/tour/SKILL.md +38 -0
- package/skills/upload/SKILL.md +117 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
## Regression Test Generation
|
|
2
|
+
|
|
3
|
+
For each verified bug, generate a regression test in the **project's native test framework** that would expose the bug as a failing test. **Before writing any new test**, first discover the project's language/framework and whether existing tests already cover (or partially cover) the bug scenario.
|
|
4
|
+
|
|
5
|
+
### Step 1: Detect Language & Test Framework
|
|
6
|
+
|
|
7
|
+
Identify the project's language(s) and test framework by examining the codebase:
|
|
8
|
+
|
|
9
|
+
| Signal | Language | Test Framework | Build/Run Command |
|
|
10
|
+
|--------|----------|---------------|-------------------|
|
|
11
|
+
| `BUILD`/`WORKSPACE`/`MODULE.bazel` + `.cpp`/`.cc`/`.h` | C/C++ | GTest | `bazel build` / `bazel test` |
|
|
12
|
+
| `CMakeLists.txt` + `.cpp`/`.cc` | C/C++ | GTest | `cmake --build` / `ctest` |
|
|
13
|
+
| `go.mod` or `go.sum` | Go | `testing` (stdlib) | `go test` |
|
|
14
|
+
| `pytest.ini`/`pyproject.toml`/`setup.py`/`conftest.py` | Python | pytest | `pytest` |
|
|
15
|
+
| `requirements.txt` + `unittest` imports | Python | unittest | `python -m pytest` |
|
|
16
|
+
| `package.json` + Jest config | JavaScript/TypeScript | Jest | `npx jest` / `npm test` |
|
|
17
|
+
| `package.json` + Vitest config | JavaScript/TypeScript | Vitest | `npx vitest` |
|
|
18
|
+
| `package.json` + Mocha config | JavaScript/TypeScript | Mocha | `npx mocha` |
|
|
19
|
+
| `Cargo.toml` | Rust | built-in `#[test]` | `cargo test` |
|
|
20
|
+
| `pom.xml` | Java | JUnit | `mvn test` |
|
|
21
|
+
| `build.gradle`/`build.gradle.kts` | Java/Kotlin | JUnit | `gradle test` |
|
|
22
|
+
|
|
23
|
+
**Resolution order:**
|
|
24
|
+
1. Check `draft/tech-stack.md` first — it may explicitly state the test framework
|
|
25
|
+
2. Look for existing test files and match their import/framework patterns
|
|
26
|
+
3. Fall back to build system signals above
|
|
27
|
+
|
|
28
|
+
If the project is **polyglot** (multiple languages), detect per-component and generate tests in the matching language for each bug.
|
|
29
|
+
|
|
30
|
+
**If no test framework is detected:** Mark all bugs with `Regression Test Status: N/A — no test framework detected` and proceed with bug reporting. **Do not skip bugs because tests cannot be written.** The regression test section is supplementary — the primary deliverable is the bug report.
|
|
31
|
+
|
|
32
|
+
Record the detected configuration:
|
|
33
|
+
```
|
|
34
|
+
Language: [detected | none]
|
|
35
|
+
Test Framework: [detected | none]
|
|
36
|
+
Build System: [detected | none]
|
|
37
|
+
Test Command: [detected | N/A]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Step 2: Existing Test Discovery (REQUIRED per bug, skip if no test framework)
|
|
41
|
+
|
|
42
|
+
For each verified bug, search the codebase for existing tests before generating new ones:
|
|
43
|
+
|
|
44
|
+
1. **Locate test files for the buggy module** using language-appropriate patterns:
|
|
45
|
+
|
|
46
|
+
| Language | Search Patterns |
|
|
47
|
+
|----------|----------------|
|
|
48
|
+
| C/C++ | `*_test.cpp`, `*_test.cc`, `test_*.cpp`; patterns: `TEST(`, `TEST_F(`, `TEST_P(` |
|
|
49
|
+
| Go | `*_test.go` in same package; patterns: `func Test`, `func Benchmark` |
|
|
50
|
+
| Python | `test_*.py`, `*_test.py` in `tests/`; patterns: `def test_`, `class Test` |
|
|
51
|
+
| JS/TS | `*.test.ts`, `*.spec.ts`, `__tests__/*.ts`; patterns: `describe(`, `it(`, `test(` |
|
|
52
|
+
| Rust | `#[cfg(test)]` in same file, or `tests/*.rs`; patterns: `#[test]`, `fn test_` |
|
|
53
|
+
| Java | `*Test.java`, `*Tests.java` in `src/test/`; patterns: `@Test`, `@ParameterizedTest` |
|
|
54
|
+
|
|
55
|
+
2. **Analyze existing test coverage**
|
|
56
|
+
- Read each related test file found
|
|
57
|
+
- Check if any test exercises the **exact code path** that triggers the bug
|
|
58
|
+
- Check if any test covers the **same function/method** but misses the specific edge case
|
|
59
|
+
- Check if a test exists but has a **wrong assertion** (asserts buggy behavior as correct)
|
|
60
|
+
|
|
61
|
+
3. **Classify the coverage status** — one of:
|
|
62
|
+
|
|
63
|
+
| Status | Meaning | Action |
|
|
64
|
+
|--------|---------|--------|
|
|
65
|
+
| **COVERED** | Existing test already catches this bug (test fails on buggy code) | Report the existing test — no new test needed |
|
|
66
|
+
| **PARTIAL** | Test exists for the function but misses this specific scenario | Add the missing case to the existing test file |
|
|
67
|
+
| **WRONG_ASSERTION** | Test exists but asserts the buggy behavior as correct | Fix the assertion in the existing test |
|
|
68
|
+
| **NO_COVERAGE** | No test exists for this code path | Generate a new test |
|
|
69
|
+
| **N/A** | Bug is in non-testable code (config, markdown, LLM workflow) | Write `N/A — [reason]` |
|
|
70
|
+
|
|
71
|
+
4. **Document discovery results** in the bug report's Regression Test field
|
|
72
|
+
|
|
73
|
+
**Example Existing Test Discovery:**
|
|
74
|
+
```
|
|
75
|
+
1. Bug location: src/parser.cpp:145 — off-by-one in tokenize()
|
|
76
|
+
2. Grep: `rg 'tokenize' tests/` → found tests/parser_test.cpp
|
|
77
|
+
3. Read tests/parser_test.cpp:
|
|
78
|
+
- TEST(Parser, TokenizeSimpleInput) — tests basic input ✓
|
|
79
|
+
- TEST(Parser, TokenizeEmptyString) — tests empty string ✓
|
|
80
|
+
- No test for boundary input length (the bug trigger)
|
|
81
|
+
4. Status: PARTIAL — parser_test.cpp covers tokenize() but misses boundary case
|
|
82
|
+
5. Action: Add new TEST case to existing tests/parser_test.cpp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step 3: Generate or Modify Test Cases
|
|
86
|
+
|
|
87
|
+
Based on discovery results, generate tests in the project's native framework:
|
|
88
|
+
|
|
89
|
+
#### When status is COVERED
|
|
90
|
+
```
|
|
91
|
+
**Regression Test:**
|
|
92
|
+
**Status:** COVERED — existing test already catches this bug
|
|
93
|
+
**Existing Test:** `tests/parser_test.cpp:45` — `TEST(Parser, TokenizeBoundary)`
|
|
94
|
+
No new test needed.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### When status is PARTIAL — add to existing test file
|
|
98
|
+
#### When status is WRONG_ASSERTION — fix assertion in existing test
|
|
99
|
+
#### When status is NO_COVERAGE — generate new test
|
|
100
|
+
|
|
101
|
+
### Test Case Requirements (all languages)
|
|
102
|
+
|
|
103
|
+
Each new test MUST:
|
|
104
|
+
|
|
105
|
+
1. **Target exactly one bug** — One test per finding, named after the bug
|
|
106
|
+
2. **Use descriptive test names** — Language-idiomatic naming (see templates below)
|
|
107
|
+
3. **Include the bug setup** — Reproduce the preconditions that trigger the bug
|
|
108
|
+
4. **Assert the expected (correct) behavior** — The test should FAIL against the current buggy code
|
|
109
|
+
5. **Comment the expected vs actual** — Explain what the test expects and what currently happens
|
|
110
|
+
6. **Be self-contained** — Include necessary imports, minimal fixtures, no external dependencies beyond the test framework and project modules
|
|
111
|
+
7. **Specify target file** — State whether this goes in an existing test file or a new one
|
|
112
|
+
|
|
113
|
+
### Language-Specific Test Templates
|
|
114
|
+
|
|
115
|
+
#### C/C++ (GTest)
|
|
116
|
+
|
|
117
|
+
```cpp
|
|
118
|
+
#include <gtest/gtest.h>
|
|
119
|
+
// #include "relevant/project/header.h"
|
|
120
|
+
|
|
121
|
+
// Bug: [SEVERITY] Category: Brief Title
|
|
122
|
+
// Location: path/to/file.cpp:line
|
|
123
|
+
// This test FAILS against current code, PASSES after fix
|
|
124
|
+
|
|
125
|
+
TEST(BugCategory, BriefBugTitle) {
|
|
126
|
+
// Setup
|
|
127
|
+
// Act
|
|
128
|
+
// Assert
|
|
129
|
+
EXPECT_EQ(actual, expected) << "Description of what should happen";
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Python (pytest)
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
# Bug: [SEVERITY] Category: Brief Title
|
|
137
|
+
# Location: path/to/file.py:line
|
|
138
|
+
# This test FAILS against current code, PASSES after fix
|
|
139
|
+
|
|
140
|
+
import pytest
|
|
141
|
+
from module.under.test import function_under_test
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_brief_bug_title():
|
|
145
|
+
"""[Category] Brief description of the bug scenario."""
|
|
146
|
+
# Setup
|
|
147
|
+
# Act
|
|
148
|
+
result = function_under_test(input)
|
|
149
|
+
# Assert
|
|
150
|
+
assert result == expected, "Description of what should happen"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Go (testing)
|
|
154
|
+
|
|
155
|
+
```go
|
|
156
|
+
package package_name
|
|
157
|
+
|
|
158
|
+
import (
|
|
159
|
+
"testing"
|
|
160
|
+
// project imports
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
// Bug: [SEVERITY] Category: Brief Title
|
|
164
|
+
// Location: path/to/file.go:line
|
|
165
|
+
// This test FAILS against current code, PASSES after fix
|
|
166
|
+
|
|
167
|
+
func TestBriefBugTitle(t *testing.T) {
|
|
168
|
+
// Setup
|
|
169
|
+
// Act
|
|
170
|
+
got := FunctionUnderTest(input)
|
|
171
|
+
// Assert
|
|
172
|
+
if got != expected {
|
|
173
|
+
t.Errorf("FunctionUnderTest() = %v, want %v", got, expected)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### JavaScript/TypeScript (Jest/Vitest)
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// Bug: [SEVERITY] Category: Brief Title
|
|
182
|
+
// Location: path/to/file.ts:line
|
|
183
|
+
// This test FAILS against current code, PASSES after fix
|
|
184
|
+
|
|
185
|
+
import { functionUnderTest } from './module-under-test';
|
|
186
|
+
|
|
187
|
+
describe('BugCategory', () => {
|
|
188
|
+
it('should brief bug title', () => {
|
|
189
|
+
// Setup
|
|
190
|
+
// Act
|
|
191
|
+
const result = functionUnderTest(input);
|
|
192
|
+
// Assert
|
|
193
|
+
expect(result).toBe(expected);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Rust (#[test])
|
|
199
|
+
|
|
200
|
+
```rust
|
|
201
|
+
// Bug: [SEVERITY] Category: Brief Title
|
|
202
|
+
// Location: path/to/file.rs:line
|
|
203
|
+
// This test FAILS against current code, PASSES after fix
|
|
204
|
+
|
|
205
|
+
#[cfg(test)]
|
|
206
|
+
mod bug_regression_tests {
|
|
207
|
+
use super::*;
|
|
208
|
+
|
|
209
|
+
#[test]
|
|
210
|
+
fn test_brief_bug_title() {
|
|
211
|
+
// Setup
|
|
212
|
+
// Act
|
|
213
|
+
let result = function_under_test(input);
|
|
214
|
+
// Assert
|
|
215
|
+
assert_eq!(result, expected, "Description of what should happen");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Java (JUnit 5)
|
|
221
|
+
|
|
222
|
+
```java
|
|
223
|
+
// Bug: [SEVERITY] Category: Brief Title
|
|
224
|
+
// Location: path/to/File.java:line
|
|
225
|
+
// This test FAILS against current code, PASSES after fix
|
|
226
|
+
|
|
227
|
+
import org.junit.jupiter.api.Test;
|
|
228
|
+
import static org.junit.jupiter.api.Assertions.*;
|
|
229
|
+
|
|
230
|
+
class BugCategoryTest {
|
|
231
|
+
@Test
|
|
232
|
+
void briefBugTitle() {
|
|
233
|
+
// Setup
|
|
234
|
+
// Act
|
|
235
|
+
var result = classUnderTest.methodUnderTest(input);
|
|
236
|
+
// Assert
|
|
237
|
+
assertEquals(expected, result, "Description of what should happen");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Consolidated Test File
|
|
243
|
+
|
|
244
|
+
After all bugs are documented, collect all test cases into a single consolidated section in the report (see Report Generation). Group by discovery status so the reader knows which tests are new vs modifications to existing tests.
|
|
245
|
+
|
|
246
|
+
### Step 4: Test Infrastructure Discovery
|
|
247
|
+
|
|
248
|
+
Before writing any test files, discover the project's test infrastructure and conventions:
|
|
249
|
+
|
|
250
|
+
1. **Detect Build System & Test Runner**
|
|
251
|
+
|
|
252
|
+
| Language | Build System Signals | Test Runner |
|
|
253
|
+
|----------|---------------------|-------------|
|
|
254
|
+
| C/C++ | `WORKSPACE`/`MODULE.bazel` → Bazel; `CMakeLists.txt` → CMake | `bazel test` / `ctest` |
|
|
255
|
+
| Go | `go.mod` (always present) | `go test ./...` |
|
|
256
|
+
| Python | `pyproject.toml` / `setup.cfg` / `tox.ini` / bare | `pytest` (prefer) / `python -m unittest` |
|
|
257
|
+
| JS/TS | `package.json` → check `scripts.test` and devDeps | `npx jest` / `npx vitest` / `npm test` |
|
|
258
|
+
| Rust | `Cargo.toml` (always present) | `cargo test` |
|
|
259
|
+
| Java | `pom.xml` → Maven; `build.gradle` → Gradle | `mvn test` / `gradle test` |
|
|
260
|
+
|
|
261
|
+
If no recognized build system is found, inform user and keep report-only test output:
|
|
262
|
+
`"No recognized build/test system detected. Regression tests are included in the report only."`
|
|
263
|
+
|
|
264
|
+
2. **Map Source Files to Test Locations**
|
|
265
|
+
For each buggy source file, determine where its tests live (or should live):
|
|
266
|
+
|
|
267
|
+
| Language | Common Conventions |
|
|
268
|
+
|----------|--------------------|
|
|
269
|
+
| C/C++ (Bazel) | Co-located `foo_test.cpp` or separate `tests/` tree; check `cc_test` in BUILD |
|
|
270
|
+
| Go | Same directory: `foo.go` → `foo_test.go` (always co-located) |
|
|
271
|
+
| Python | `src/auth/handler.py` → `tests/auth/test_handler.py` or `tests/test_auth_handler.py` |
|
|
272
|
+
| JS/TS | `src/auth/handler.ts` → `src/auth/handler.test.ts` or `__tests__/handler.test.ts` |
|
|
273
|
+
| Rust | In-file `#[cfg(test)]` module, or `tests/` directory for integration tests |
|
|
274
|
+
| Java | `src/main/java/com/...` → `src/test/java/com/...` (Maven convention) |
|
|
275
|
+
|
|
276
|
+
- If tests exist: record the directory, naming convention, and any build config
|
|
277
|
+
- If no tests exist: adopt the project's dominant convention
|
|
278
|
+
- If no convention exists: default to a `tests/` directory mirroring the source tree
|
|
279
|
+
|
|
280
|
+
3. **Identify Test Dependencies** (language-specific)
|
|
281
|
+
|
|
282
|
+
| Language | What to Find |
|
|
283
|
+
|----------|-------------|
|
|
284
|
+
| C/C++ (Bazel) | GTest dep label: `@com_google_googletest//:gtest_main`; source `cc_library` targets |
|
|
285
|
+
| Go | No extra deps needed (`testing` is stdlib) |
|
|
286
|
+
| Python | Check if `pytest` is in `requirements*.txt` / `pyproject.toml`; add if missing |
|
|
287
|
+
| JS/TS | Check if test framework is in `devDependencies`; identify import style |
|
|
288
|
+
| Rust | No extra deps for unit tests; `dev-dependencies` for integration test crates |
|
|
289
|
+
| Java | JUnit version in `pom.xml` / `build.gradle` dependencies |
|
|
290
|
+
|
|
291
|
+
### Step 5: Write Test Files (only for testable bugs)
|
|
292
|
+
|
|
293
|
+
**Skip this step entirely if no test framework was detected in Step 1.**
|
|
294
|
+
|
|
295
|
+
For bugs with status NO_COVERAGE, PARTIAL, or WRONG_ASSERTION, write the actual test files. Bugs with COVERED or N/A status do not need action here — they are still included in the final report:
|
|
296
|
+
|
|
297
|
+
#### NO_COVERAGE — Create new test file
|
|
298
|
+
|
|
299
|
+
1. **Create directory** if it doesn't exist:
|
|
300
|
+
```bash
|
|
301
|
+
mkdir -p <test_directory>/
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
2. **Write the test file** using the language-appropriate template:
|
|
305
|
+
|
|
306
|
+
| Language | Example Target File |
|
|
307
|
+
|----------|-------------------|
|
|
308
|
+
| C/C++ | `tests/auth/login_handler_test.cpp` |
|
|
309
|
+
| Go | `auth/login_handler_test.go` (same package) |
|
|
310
|
+
| Python | `tests/auth/test_login_handler.py` |
|
|
311
|
+
| JS/TS | `src/auth/login_handler.test.ts` or `__tests__/auth/login_handler.test.ts` |
|
|
312
|
+
| Rust | `tests/login_handler_test.rs` or `#[cfg(test)]` in source |
|
|
313
|
+
| Java | `src/test/java/com/example/auth/LoginHandlerTest.java` |
|
|
314
|
+
|
|
315
|
+
3. **Create or update build config** (if required by the build system):
|
|
316
|
+
|
|
317
|
+
**C/C++ (Bazel)** — add `cc_test` to BUILD:
|
|
318
|
+
```python
|
|
319
|
+
cc_test(
|
|
320
|
+
name = "<source_filename>_test",
|
|
321
|
+
srcs = ["<source_filename>_test.cpp"],
|
|
322
|
+
deps = [
|
|
323
|
+
"//src/<component>:<library_target>",
|
|
324
|
+
"@com_google_googletest//:gtest_main",
|
|
325
|
+
],
|
|
326
|
+
)
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Java (Maven)** — no build config change needed (convention-based discovery)
|
|
330
|
+
**Java (Gradle)** — no build config change needed
|
|
331
|
+
**Go** — no build config change needed (`go test` discovers `_test.go` automatically)
|
|
332
|
+
**Python** — no build config change needed (`pytest` discovers `test_*.py` automatically)
|
|
333
|
+
**JS/TS** — no build config change needed (Jest/Vitest discover `*.test.*` automatically)
|
|
334
|
+
**Rust** — no build config change needed (`cargo test` discovers `#[test]` automatically)
|
|
335
|
+
|
|
336
|
+
4. If multiple bugs affect different files in the same component, create one test file per source file (not one per bug). Group related bug tests into the same file.
|
|
337
|
+
|
|
338
|
+
#### PARTIAL — Add test case to existing file
|
|
339
|
+
|
|
340
|
+
1. Read the existing test file
|
|
341
|
+
2. Append the new test at the idiomatic location:
|
|
342
|
+
- **C/C++:** Before closing namespace brace
|
|
343
|
+
- **Go:** End of file (same package)
|
|
344
|
+
- **Python:** End of file or within existing test class
|
|
345
|
+
- **JS/TS:** Inside the relevant `describe()` block, or at end of file
|
|
346
|
+
- **Rust:** Inside existing `#[cfg(test)]` module
|
|
347
|
+
- **Java:** Inside existing test class, before closing brace
|
|
348
|
+
3. No build config changes needed
|
|
349
|
+
|
|
350
|
+
#### WRONG_ASSERTION — Fix assertion in existing file
|
|
351
|
+
|
|
352
|
+
1. Read the existing test file
|
|
353
|
+
2. Locate the wrong assertion
|
|
354
|
+
3. Replace with the corrected assertion
|
|
355
|
+
4. No build config changes needed
|
|
356
|
+
|
|
357
|
+
**Constraints:**
|
|
358
|
+
- **Never modify production source code** — only test files and their build configs
|
|
359
|
+
- Each test file must be valid for the project's test runner
|
|
360
|
+
- Use the project's actual import paths, module names, and namespace conventions
|
|
361
|
+
- Match existing test style (fixtures, helpers, naming conventions)
|
|
362
|
+
|
|
363
|
+
### Step 6: Build & Syntax Validation
|
|
364
|
+
|
|
365
|
+
After writing all test files, validate them using the project's native toolchain.
|
|
366
|
+
|
|
367
|
+
1. **Validate each new/modified test** using the language-appropriate command:
|
|
368
|
+
|
|
369
|
+
| Language | Validation Command | What It Checks |
|
|
370
|
+
|----------|-------------------|----------------|
|
|
371
|
+
| C/C++ (Bazel) | `bazel build //tests/<component>:<target>_test` | Compilation + linking |
|
|
372
|
+
| C/C++ (CMake) | `cmake --build <build_dir> --target <target>_test` | Compilation + linking |
|
|
373
|
+
| Go | `go vet ./path/to/package/...` | Syntax + type checking (no execution) |
|
|
374
|
+
| Python | `python -m py_compile tests/path/test_file.py` | Syntax validation |
|
|
375
|
+
| JS/TS | `npx tsc --noEmit tests/path/file.test.ts` (TS) or `node --check tests/path/file.test.js` (JS) | Type check / syntax |
|
|
376
|
+
| Rust | `cargo check --tests` | Type check + borrow check (no execution) |
|
|
377
|
+
| Java (Maven) | `mvn test-compile` | Compilation only |
|
|
378
|
+
| Java (Gradle) | `gradle testClasses` | Compilation only |
|
|
379
|
+
|
|
380
|
+
2. **Handle validation results:**
|
|
381
|
+
|
|
382
|
+
| Result | Action |
|
|
383
|
+
|--------|--------|
|
|
384
|
+
| **Succeeds** | Mark as `BUILD_OK` in report |
|
|
385
|
+
| **Fails — import/include error** | Fix the import path, retry (up to 2 retries) |
|
|
386
|
+
| **Fails — missing dep** | Add the dependency, retry (up to 2 retries) |
|
|
387
|
+
| **Fails — type/API mismatch** | Fix the test to match actual API signatures, retry (up to 2 retries) |
|
|
388
|
+
| **Persistent failure (3 attempts)** | Mark as `BUILD_FAILED` with the error message in report. Delete the broken test file and note in the report: "Test file removed due to persistent build failure." |
|
|
389
|
+
|
|
390
|
+
3. **Do NOT run the tests.** The tests are designed to **FAIL** against the current buggy code — that's the point. Validation checks only syntax, types, and linking. Running them would produce expected failures that aren't useful here.
|
|
391
|
+
|
|
392
|
+
**Exception for Go:** `go vet` is preferred over `go build` for test files because Go compiles tests as part of `go test` only. `go vet` catches type errors and common issues without executing.
|
|
393
|
+
|
|
394
|
+
4. **Validation summary** — Record results for the report:
|
|
395
|
+
```
|
|
396
|
+
BUILD_OK: 3 targets
|
|
397
|
+
BUILD_FAILED: 1 target (tests/config/test_loader.py — ImportError: no module named 'config.loader')
|
|
398
|
+
SKIPPED: 1 target (N/A — race condition not reliably testable)
|
|
399
|
+
```
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: change
|
|
3
|
+
description: Handle mid-track requirement changes. Analyzes impact on completed and pending tasks, proposes amendments to spec.md and plan.md before applying.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Course Correction
|
|
7
|
+
|
|
8
|
+
You are handling a mid-track requirement change using Draft's Context-Driven Development methodology.
|
|
9
|
+
|
|
10
|
+
## Red Flags - STOP if you're:
|
|
11
|
+
|
|
12
|
+
- Applying changes to spec.md or plan.md without showing the user what will change first
|
|
13
|
+
- Invalidating `[x]` completed tasks without flagging them explicitly
|
|
14
|
+
- Proceeding past the CHECKPOINT without user confirmation
|
|
15
|
+
- Editing files when the user said "no" or "edit"
|
|
16
|
+
|
|
17
|
+
**Show impact before applying. Always confirm.**
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Step 0: Verify Draft Context
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ls draft/tracks.md 2>/dev/null
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If `draft/` does not exist: **STOP** — "No Draft context found. Run `/draft:init` first."
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Step 1: Parse Arguments
|
|
32
|
+
|
|
33
|
+
Extract from `$ARGUMENTS`:
|
|
34
|
+
|
|
35
|
+
- **Change description** — free text describing what needs to change (required)
|
|
36
|
+
- **Track specifier** — optional `track <id>` prefix to target a specific track
|
|
37
|
+
|
|
38
|
+
### Default Behavior
|
|
39
|
+
|
|
40
|
+
If no `track <id>` specified:
|
|
41
|
+
- Auto-detect the active `[~]` In Progress track from `draft/tracks.md`
|
|
42
|
+
- If no `[~]` track, find the first `[ ]` Pending track
|
|
43
|
+
- Display: `Auto-detected track: <id> - <name>` before proceeding
|
|
44
|
+
|
|
45
|
+
If no change description provided:
|
|
46
|
+
- Error: "Usage: `/draft:change <description>` or `/draft:change track <id> <description>`"
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Step 2: Load Context
|
|
51
|
+
|
|
52
|
+
1. Read `draft/tracks/<id>/spec.md` — extract requirements and acceptance criteria
|
|
53
|
+
2. Read `draft/tracks/<id>/plan.md` — extract all tasks with their current status (`[ ]`, `[~]`, `[x]`, `[!]`)
|
|
54
|
+
3. Read `draft/tracks/<id>/metadata.json` — for track type and status
|
|
55
|
+
4. Read `draft/tracks/<id>/hld.md` if present — extract Architecture, Detailed Design components, Dependencies, Checklist sections, and Approvals table (signed/unsigned)
|
|
56
|
+
5. Read `draft/tracks/<id>/lld.md` if present — extract Classes/Interfaces, Data Model, Algorithms, Error Handling sections
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Step 3: Analyze Spec / HLD / LLD Impact
|
|
61
|
+
|
|
62
|
+
Analyze the change description against the loaded spec, HLD, and LLD.
|
|
63
|
+
|
|
64
|
+
**Code-grounded impact (Ground-Truth Discipline G1, G2, G4):** Classification ("Modified", "Unaffected", etc.) must be informed by the current code, not just the prior spec text. For each requirement / AC you're about to mark **Unaffected**, confirm the code path it depends on still behaves as the spec claims — Read the cited file or a representative file in the affected module before stamping Unaffected. Specs and implementations drift; "spec text unchanged" ≠ "behavior unchanged."
|
|
65
|
+
|
|
66
|
+
For each requirement and acceptance criterion, classify the effect:
|
|
67
|
+
|
|
68
|
+
| Classification | Meaning |
|
|
69
|
+
|---|---|
|
|
70
|
+
| **Added** | New requirement or AC introduced by this change |
|
|
71
|
+
| **Modified** | Existing requirement or AC needs updating |
|
|
72
|
+
| **Removed** | Existing requirement or AC is no longer needed |
|
|
73
|
+
| **Unaffected** | No change needed |
|
|
74
|
+
|
|
75
|
+
Produce a concise impact list. Example:
|
|
76
|
+
```
|
|
77
|
+
Spec impact:
|
|
78
|
+
- AC #2 "User can export to CSV" → Modified (now also requires JSON format)
|
|
79
|
+
- AC #5 "Export limited to 1000 rows" → Removed (no row limit)
|
|
80
|
+
- NEW: AC #6 "Export progress indicator for large datasets"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**HLD impact** (only when `hld.md` exists):
|
|
84
|
+
- §Architecture / Component Diagram — does the change introduce new modules or alter integration edges?
|
|
85
|
+
- §Detailed Design — does any per-component subsection need updating, or are new components introduced?
|
|
86
|
+
- §Dependencies — new/removed dependent components?
|
|
87
|
+
- §Checklist (Performance, Scale, Security, Resiliency, Multi-tenancy, Upgrade, Cost) — do any answers need re-evaluation?
|
|
88
|
+
- §IP / TPT — does the change introduce new third-party technology or invention disclosure?
|
|
89
|
+
- §Deployment — does the deployment surface change?
|
|
90
|
+
|
|
91
|
+
**LLD impact** (only when `lld.md` exists):
|
|
92
|
+
- §Classes and Interfaces — signatures added/modified/removed?
|
|
93
|
+
- §Data Model — schema changes? New fields? Migration required?
|
|
94
|
+
- §Key Algorithms and Workflows — algorithm changes? New sequence diagrams needed?
|
|
95
|
+
- §Error Handling — new error classes or retry policy changes?
|
|
96
|
+
- §Observability — new metrics or alert thresholds?
|
|
97
|
+
|
|
98
|
+
**Re-approval flag:** If the HLD Approvals table has any signed rows (Date column populated) AND the change touches HLD structural sections (Architecture, Detailed Design, Dependencies, Checklist, IP, Deployment), surface this warning prominently:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
⚠️ HLD modified after sign-off — Approvals table requires re-circulation.
|
|
102
|
+
Signed rows: [list which roles signed and when]
|
|
103
|
+
Changed sections: [list of HLD sections impacted]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Same logic applies to LLD Approvals when LLD §Classes/Interfaces, §Data Model, or §Key Algorithms change.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Step 4: Map Impact to Plan Tasks
|
|
111
|
+
|
|
112
|
+
For each task in `plan.md`, determine if the spec change affects it:
|
|
113
|
+
|
|
114
|
+
- **`[x]` completed tasks** that are now invalidated by the change → flag as:
|
|
115
|
+
`⚠️ [task description] — may need rework`
|
|
116
|
+
|
|
117
|
+
- **`[ ]` pending tasks** that need updating → show the proposed new task text
|
|
118
|
+
|
|
119
|
+
- **`[~]` in-progress tasks** that are affected → flag as:
|
|
120
|
+
`⚠️ IN PROGRESS: [task description] — review before continuing`
|
|
121
|
+
|
|
122
|
+
- **`[!]` blocked tasks** that are affected → flag as:
|
|
123
|
+
`⚠️ BLOCKED: [task description] — re-evaluate; requirement change may alter blocking condition or resolution path`
|
|
124
|
+
|
|
125
|
+
- **Unaffected tasks** — skip, do not mention
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Step 5: Present Impact Summary
|
|
130
|
+
|
|
131
|
+
Display a clear summary before proposing any file changes:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
Change: [change description]
|
|
135
|
+
Track: <track_id> — <track_name>
|
|
136
|
+
|
|
137
|
+
Spec impact:
|
|
138
|
+
- [classification] [requirement/AC]
|
|
139
|
+
- [classification] [requirement/AC]
|
|
140
|
+
|
|
141
|
+
Plan impact:
|
|
142
|
+
- ⚠️ [N] completed task(s) may need rework
|
|
143
|
+
- [M] pending task(s) need updating
|
|
144
|
+
- [K] in-progress task(s) need review
|
|
145
|
+
- [B] blocked task(s) need re-evaluation
|
|
146
|
+
|
|
147
|
+
Completed tasks that may need rework:
|
|
148
|
+
- [x] [task description] (commit: abc1234)
|
|
149
|
+
|
|
150
|
+
Pending tasks with proposed changes:
|
|
151
|
+
Before: - [ ] [original task text]
|
|
152
|
+
After: - [ ] [proposed new task text]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Step 6: Show Proposed Amendments
|
|
158
|
+
|
|
159
|
+
Display only the changed sections of each file (not full rewrites):
|
|
160
|
+
|
|
161
|
+
### Proposed spec.md changes
|
|
162
|
+
|
|
163
|
+
Show the diff as before/after for each modified section. Do not rewrite unchanged sections.
|
|
164
|
+
|
|
165
|
+
### Proposed plan.md changes
|
|
166
|
+
|
|
167
|
+
Show each task that would be modified as before/after. Do not rewrite the full plan.
|
|
168
|
+
|
|
169
|
+
### Proposed hld.md changes (when HLD exists and is impacted)
|
|
170
|
+
|
|
171
|
+
Show before/after for each impacted HLD section. Preserve §Approvals table verbatim — do not modify Approvals as part of the spec amendment; re-circulation is the author's manual step. Surface a "Sections changed" list at the top of the diff so reviewers can see scope at a glance.
|
|
172
|
+
|
|
173
|
+
### Proposed lld.md changes (when LLD exists and is impacted)
|
|
174
|
+
|
|
175
|
+
Show before/after for each impacted LLD section. Preserve §Approvals verbatim. Flag schema changes (Data Model) for migration consideration.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Step 7: CHECKPOINT
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
Apply these changes to spec.md and plan.md? [yes / no / edit]
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- **`yes`** — proceed to Step 8
|
|
186
|
+
- **`no`** — discard all proposed changes, announce "No changes applied." and stop
|
|
187
|
+
- **`edit`** — let the user describe adjustments to the proposed amendments, then revise and re-present the CHECKPOINT again. The loop continues until the user selects `yes` or `no`.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Step 8: Apply Changes and Log
|
|
192
|
+
|
|
193
|
+
1. Apply the agreed amendments to `spec.md`, `plan.md`, and (when impacted) `hld.md` / `lld.md`. Preserve §Approvals tables in HLD/LLD verbatim — re-approval is a manual author step, not an automated edit.
|
|
194
|
+
|
|
195
|
+
2. Update `draft/tracks/<id>/metadata.json`:
|
|
196
|
+
- Set `updated` to current ISO timestamp
|
|
197
|
+
- Recalculate `tasks.total` by counting all `- [ ]`, `- [~]`, `- [x]`, and `- [!]` lines in the updated `plan.md`. Update `tasks.completed` by counting only `- [x]` lines.
|
|
198
|
+
|
|
199
|
+
3. Append a Change Log entry (with current git SHA (obtain via `git rev-parse --short HEAD`) and timestamp) to `plan.md`. If a `## Change Log` section does not exist, add it at the bottom:
|
|
200
|
+
|
|
201
|
+
```markdown
|
|
202
|
+
## Change Log
|
|
203
|
+
|
|
204
|
+
| Date | Description | Impact |
|
|
205
|
+
|------|-------------|--------|
|
|
206
|
+
| [ISO date] | [change description] | [N completed may need rework, M pending updated] |
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
4. Announce:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
Changes applied: <track_id>
|
|
213
|
+
|
|
214
|
+
Updated:
|
|
215
|
+
- draft/tracks/<id>/spec.md
|
|
216
|
+
- draft/tracks/<id>/plan.md
|
|
217
|
+
[when HLD impacted:]
|
|
218
|
+
- draft/tracks/<id>/hld.md
|
|
219
|
+
[when LLD impacted:]
|
|
220
|
+
- draft/tracks/<id>/lld.md
|
|
221
|
+
|
|
222
|
+
[If completed tasks flagged:]
|
|
223
|
+
⚠️ Review N completed task(s) — they may not align with the updated spec.
|
|
224
|
+
Re-run /draft:implement to address rework, or /draft:review to assess.
|
|
225
|
+
|
|
226
|
+
[If HLD/LLD modified after sign-off:]
|
|
227
|
+
⚠️ HLD/LLD modified after sign-off — re-circulate to approvers listed in §Approvals.
|
|
228
|
+
/draft:upload will block git upload for high-criticality tracks until re-signed.
|
|
229
|
+
|
|
230
|
+
Next: /draft:implement to continue, or /draft:review to assess current state.
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Error Handling
|
|
236
|
+
|
|
237
|
+
### Track Not Found
|
|
238
|
+
```
|
|
239
|
+
Error: Track '<id>' not found.
|
|
240
|
+
Run /draft:status to see available tracks.
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### No Active Track
|
|
244
|
+
```
|
|
245
|
+
Error: No active track found.
|
|
246
|
+
Use: /draft:change track <id> <description>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### No Spec or Plan
|
|
250
|
+
```
|
|
251
|
+
Error: Missing spec.md or plan.md for track <id>.
|
|
252
|
+
Cannot perform change analysis without both files.
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Examples
|
|
258
|
+
|
|
259
|
+
### Change description for active track
|
|
260
|
+
```bash
|
|
261
|
+
/draft:change the export format should support JSON in addition to CSV
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Targeting a specific track
|
|
265
|
+
```bash
|
|
266
|
+
/draft:change track add-export-feature also require a progress indicator for exports over 500 rows
|
|
267
|
+
```
|