@akjamie/agentic-sdlc 1.11.1 → 1.12.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/README.md +2 -2
- package/assets/commands/asdlc-apply.md +5 -2
- package/assets/commands/asdlc-impl-review.md +28 -0
- package/assets/commands/asdlc-new.md +1 -1
- package/assets/commands/asdlc-spec-review.md +26 -0
- package/assets/commands/asdlc-status.md +4 -0
- package/assets/commands/asdlc-verify.md +8 -6
- package/assets/skills/asdlc-apply/SKILL.md +23 -2
- package/assets/skills/asdlc-impl-review/SKILL.md +23 -2
- package/assets/skills/asdlc-new/SKILL.md +2 -2
- package/assets/skills/asdlc-pr/SKILL.md +2 -2
- package/assets/skills/asdlc-spec-review/SKILL.md +2 -1
- package/assets/skills/asdlc-status/SKILL.md +15 -0
- package/assets/skills/asdlc-verify/SKILL.md +20 -18
- package/assets/templates/asdlc-ai-review.yml +55 -0
- package/package.json +1 -1
- package/src/commands/apply.js +134 -13
- package/src/commands/lint.js +9 -0
- package/src/commands/test.js +2 -23
- package/src/lib/tasks-gen.js +123 -0
- package/src/lib/tools.js +53 -6
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# agentic-sdlc
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@akjamie/agentic-sdlc)
|
|
4
|
-
[](package.json)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
|
-
[](#development--verification)
|
|
8
8
|
[](#adaptive-risk-tiered-governance-l0l3)
|
|
9
9
|
|
|
10
10
|
> **The Intelligent Governance Engine for Autonomous AI Coding.**
|
|
@@ -10,7 +10,7 @@ Launch task-level Test-Driven Development (TDD) loop from `tasks.md`.
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
asdlc apply <CHANGE_ID> [--from-pr <pr>] [--auto-pr] [--target-branch <branch>]
|
|
13
|
+
asdlc apply <CHANGE_ID> --agent [--from-pr <pr>] [--auto-pr] [--target-branch <branch>]
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Behavior
|
|
@@ -21,4 +21,7 @@ asdlc apply <CHANGE_ID> [--from-pr <pr>] [--auto-pr] [--target-branch <branch>]
|
|
|
21
21
|
- GREEN: Implement minimal production code to pass the tests.
|
|
22
22
|
- REFACTOR: Clean code structure without altering behavior.
|
|
23
23
|
- EVIDENCE: Record passing test evidence.
|
|
24
|
-
3. **
|
|
24
|
+
3. **Autonomous PR Review Triage (`--from-pr <pr>`)**:
|
|
25
|
+
- Classifies unresolved review threads into `SUGGESTION_BLOCK`, `ACTION_REQUIRED`, `INFORMATIONAL_QUESTION`, or `NON_ACTIONABLE`.
|
|
26
|
+
- Applies fixes with `(ref: #<threadId>)` commit trailers; replies without mutating code for questions; never mutates locked specs or self-resolves disputed spec-conflict threads (`asdlc:needs-human-arbitration`).
|
|
27
|
+
4. **Anti-Hallucination & Anti-Drift Guard**: Prevents modifying locked specification paths during code implementation.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: asdlc-impl-review
|
|
3
|
+
description: "Stage 6.5: Independent AI Implementation Review & 3-Round Audit (Player != Referee)"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /asdlc-impl-review - Independent Implementation Review
|
|
7
|
+
|
|
8
|
+
Evaluate an Implementation PR or local change in an isolated session (`Player != Referee`) against the locked base-branch specification, `REVIEW.md`, and test evidence.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
Provide a PR URL, PR number, or local `<CHANGE_ID>` inside your AI Agent session:
|
|
13
|
+
|
|
14
|
+
- `/asdlc-impl-review https://github.com/<org>/<repo>/pull/<N>`
|
|
15
|
+
- `/asdlc-impl-review #<N>`
|
|
16
|
+
- `/asdlc-impl-review <CHANGE_ID>`
|
|
17
|
+
|
|
18
|
+
## Behavior
|
|
19
|
+
|
|
20
|
+
1. **Trusted Base-Branch Grounding**: Read approved specs and `REVIEW.md` from `origin/<baseBranch>` (never from untrusted PR `HEAD`).
|
|
21
|
+
2. **Incremental Diff on Rounds 2–3**: Extract the previous `lastReviewedSha` / `<!-- asdlc:review-round:N -->` anchor and inspect `git diff <lastReviewedSha>...HEAD`, rendering a `Re-Review Accounting` table.
|
|
22
|
+
3. **5-Dimension Audit (D1–D5) & Defect Attribution**:
|
|
23
|
+
- Audit spec conformance (AC matrix), code quality, test fidelity (`asdlc test <ID> --json`), production readiness, and security hygiene.
|
|
24
|
+
- Distinguish `🔴 [Blocker: Introduced]` / `🟡 [Major: Introduced]` from non-blocking `⚪ [Tech Debt: Pre-existing]`.
|
|
25
|
+
4. **3-Round Cap & Delivery**:
|
|
26
|
+
- Include `<!-- asdlc:review-round:<N> -->` at the top of PR comments.
|
|
27
|
+
- Submit formal GitHub PR Review (`gh api repos/$REPO/pulls/$PR/reviews`) or `gh pr comment` + `asdlc/impl-ai-review` commit status (`success` or `failure`).
|
|
28
|
+
- Escalate with `asdlc:needs-human-arbitration` if unresolved after Round 3.
|
|
@@ -10,7 +10,7 @@ Start a new spec-driven change in the repository using the Agentic SDLC workflow
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
asdlc new "<requirement>" [--from-file <path>] [--from-issue <id> | --ticket <id>] [--batch-grill] [--no-grill]
|
|
13
|
+
asdlc new "<requirement>" --agent [--from-file <path>] [--from-issue <id> | --ticket <id>] [--batch-grill] [--no-grill]
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Workflow Sequence
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: asdlc-spec-review
|
|
3
|
+
description: "Stage 3: Independent AI Spec & Architecture Review (Player != Referee)"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /asdlc-spec-review - Independent Spec & Architecture Review
|
|
7
|
+
|
|
8
|
+
Evaluate a Spec PR, RFC, `proposal.md`, `design.md`, and `specs/**` in an isolated session (`Player != Referee`) before human Tech Lead approval.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
Provide a PR URL, PR number, or local `<CHANGE_ID>` inside your AI Agent session:
|
|
13
|
+
|
|
14
|
+
- `/asdlc-spec-review https://github.com/<org>/<repo>/pull/<N>`
|
|
15
|
+
- `/asdlc-spec-review #<N>`
|
|
16
|
+
- `/asdlc-spec-review <CHANGE_ID>`
|
|
17
|
+
|
|
18
|
+
## Behavior
|
|
19
|
+
|
|
20
|
+
1. **Trusted Grounding**: Inspect `proposal.md`, `design.md`, `clarifications.md`, `specs/**`, and `explore.md`. When reviewing a PR, read `REVIEW.md` / `.sdlc/policy.yaml` from `origin/<baseBranch>`.
|
|
21
|
+
2. **7-Dimension Audit (D1–D7)**:
|
|
22
|
+
- Completeness, ambiguity/contradiction, cross-repo consistency, contract impact, testability, security/privacy, and UI/API design soundness.
|
|
23
|
+
3. **Structured Output & Round Anchor**:
|
|
24
|
+
- Include `<!-- asdlc:review-round:<N> -->` at the top of PR comments for deterministic round tracking.
|
|
25
|
+
- In **PR Mode**, post the review comment directly via `gh pr comment` and set the `asdlc/spec-ai-review` commit status (`success` or `failure`).
|
|
26
|
+
- In **Local Mode**, print the formatted review report directly without posting to GitHub.
|
|
@@ -15,9 +15,13 @@ asdlc status [--json]
|
|
|
15
15
|
|
|
16
16
|
# Single change status
|
|
17
17
|
asdlc status <CHANGE_ID> [--json]
|
|
18
|
+
|
|
19
|
+
# Team governance & gate friction metrics (last 30 days by default)
|
|
20
|
+
asdlc status --metrics [--days <count>] [--json]
|
|
18
21
|
```
|
|
19
22
|
|
|
20
23
|
## Output
|
|
21
24
|
|
|
22
25
|
- In portfolio mode: outputs compact single-line table with `CHANGE`, `LEVEL`, `STAGE`, and `NEXT COMMAND` (strictly excludes archived changes).
|
|
23
26
|
- In single-change mode: outputs completed artifacts, stage progression, and next exact command.
|
|
27
|
+
- In `--metrics` mode: outputs local gate friction leaderboard (`.sdlc/events.jsonl`), 3-round PR convergence rates, stage lead times (P50/P90), and L0–L3 risk tier breakdown.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: asdlc-verify
|
|
3
|
-
description: "Stage 6: Verify implementation against all
|
|
3
|
+
description: "Stage 6: Verify implementation against all deterministic & AI quality gates"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# /asdlc-verify - Enterprise Quality Gates Audit
|
|
7
7
|
|
|
8
|
-
Audit the implementation diff against all
|
|
8
|
+
Audit the implementation diff against all deterministic and AI quality gates before merging to main.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ Audit the implementation diff against all 12 deterministic quality gates before
|
|
|
13
13
|
asdlc verify <CHANGE_ID> [--repo <name>] [--json]
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Core Quality Gates
|
|
17
17
|
|
|
18
18
|
1. `level-integrity`: Validates declared risk level matches change topology.
|
|
19
19
|
2. `pr-type`: Classifies PR type (normal vs. spec vs. impl).
|
|
@@ -22,8 +22,10 @@ asdlc verify <CHANGE_ID> [--repo <name>] [--json]
|
|
|
22
22
|
5. `spec-tamper`: Enforces that locked spec files were not modified during implementation.
|
|
23
23
|
6. `flow-state`: Validates `READY_FOR_IMPL` transition.
|
|
24
24
|
7. `risk-escape`: Detects unannounced API/DDL escalations.
|
|
25
|
-
8. `human-gate`: Validates mandatory Tech Lead approval for L2/L3 changes.
|
|
25
|
+
8. `human-gate`: Validates mandatory Tech Lead approval for L2/L3 (and supervised) changes.
|
|
26
26
|
9. `tasks-complete`: Verifies all tasks in `tasks.md` are checked off.
|
|
27
27
|
10. `test-presence`: Enforces that source code changes are paired with test changes.
|
|
28
|
-
11. `
|
|
29
|
-
12. `
|
|
28
|
+
11. `anti-test-weakening`: Blocks deleted tests or newly introduced `.skip` / `@Disabled` / `@pytest.mark.skip` bypasses.
|
|
29
|
+
12. `tdd-evidence`: Verifies red-green-refactor execution log.
|
|
30
|
+
13. `BDD + acceptance criteria`: Deterministic R0–R8 quality lint clean.
|
|
31
|
+
14. `openspec-validate` / `schema-managed` / `acceptance-tests` / `AI verification`: Schema compliance, mapped AC test execution, and independent referee verification.
|
|
@@ -22,7 +22,7 @@ This skill executes **Stage 5 (Apply)** of the Agentic SDLC. It enforces strict
|
|
|
22
22
|
Before editing any implementation or test code, run the apply guard:
|
|
23
23
|
|
|
24
24
|
```powershell
|
|
25
|
-
asdlc apply <CHANGE_ID> [--auto-pr] [--target-branch <ref>]
|
|
25
|
+
asdlc apply <CHANGE_ID> [--auto-pr] [--target-branch <ref>] --agent
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
`asdlc apply` deterministically verifies Git-anchored preconditions:
|
|
@@ -123,7 +123,7 @@ If any check fails, resolve the issue locally within the TDD loop and re-run `as
|
|
|
123
123
|
|
|
124
124
|
### Step 5: Implementation Complete & Submission Protocol (Dual-Mode Authority)
|
|
125
125
|
|
|
126
|
-
Once all tasks in `tasks.md` are marked complete with captured evidence and local `asdlc verify <CHANGE_ID>` passes (all
|
|
126
|
+
Once all tasks in `tasks.md` are marked complete with captured evidence and local `asdlc verify <CHANGE_ID>` passes (all verification gates exit 0), determine the submission path based on explicit authority:
|
|
127
127
|
|
|
128
128
|
#### Path A: Default Local Mode (Safe Default, `autoPr: false` or unspecified)
|
|
129
129
|
> [!CAUTION]
|
|
@@ -151,3 +151,24 @@ Once all tasks in `tasks.md` are marked complete with captured evidence and loca
|
|
|
151
151
|
> asdlc pr <CHANGE_ID> <targetBranch>
|
|
152
152
|
> ```
|
|
153
153
|
> 3. Provide the resulting PR link to the user and announce readiness for AI / Human Implementation Review.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Workflow B: Autonomous PR Review Feedback Loop (`--from-pr`)
|
|
158
|
+
|
|
159
|
+
When the user asks to fix PR review comments (e.g., `"fix comments on PR #44"` or `/asdlc:apply <CHANGE_ID> --from-pr 44`), execute the 4-way semantic triage protocol:
|
|
160
|
+
|
|
161
|
+
1. **Fetch & Triage Unresolved Threads**:
|
|
162
|
+
```powershell
|
|
163
|
+
asdlc apply <CHANGE_ID> --from-pr #<PR_NUMBER> --agent
|
|
164
|
+
```
|
|
165
|
+
This fetches GraphQL `reviewThreads`, PR comments, and `reviewDecision`, and computes the current round (`Round <N> of 3`) from `<!-- asdlc:review-round:<N> -->` anchors and `(ref: #PRRT_...)` commit trailers.
|
|
166
|
+
2. **Execute Per-Category Actions**:
|
|
167
|
+
- **`SUGGESTION_BLOCK` (Category B)**: Apply the exact ```suggestion diff, run tests, commit with `fix(review): <summary> (ref: #<threadId>)`, and resolve the thread with the commit SHA.
|
|
168
|
+
- **`ACTION_REQUIRED` (Category A)**: Enter the TDD loop (add/update test assertions, fix implementation, run `asdlc verify <CHANGE_ID>`), commit with `(ref: #<threadId>)`, and reply with the commit SHA before resolving.
|
|
169
|
+
- **`INFORMATIONAL_QUESTION` (Category C)**: Formulate a technical answer grounded in `design.md` / `specs/**` and reply directly to the thread. **Do NOT mutate code and do NOT resolve the thread.**
|
|
170
|
+
- **`NON_ACTIONABLE` (Category D)**: Safely ignore pure praise/acknowledgments without empty commits.
|
|
171
|
+
3. **Constitutional Guard (`SPEC_CONFLICT` / Disputed Threads)**:
|
|
172
|
+
- If a review comment contradicts the locked (`specSha`) specification in `proposal.md` or `specs/**`:
|
|
173
|
+
- **STRICTLY FORBIDDEN** from editing locked specs or self-resolving the thread (`Player != Referee`).
|
|
174
|
+
- Reply citing the exact approved spec section, leave the thread **unresolved** (`disputed: true`), and attach the `asdlc:needs-human-arbitration` label so the human Tech Lead arbitrates.
|
|
@@ -227,7 +227,27 @@ Every finding must follow a structured schema with explicit defect attribution s
|
|
|
227
227
|
|
|
228
228
|
Compose the review using the markdown format below, then deliver it according to the invocation mode:
|
|
229
229
|
|
|
230
|
-
- **If reviewing a PR** (PR URL, PR number, or CI PR trigger): **Post the
|
|
230
|
+
- **If reviewing a PR** (PR URL, PR number, or CI PR trigger): **Post the review directly** without asking the user for confirmation:
|
|
231
|
+
- **Preferred (when inline file/line findings exist or reviewing a teammate's PR)**: Submit a formal GitHub PR Review via `gh api repos/$REPO/pulls/$PR_NUMBER/reviews --input -` (note: GitHub forbids `APPROVE`/`REQUEST_CHANGES` on your own PR — in that case, use `event: "COMMENT"` or fall back to `gh pr comment`):
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
gh api repos/$REPO/pulls/$PR_NUMBER/reviews --input - <<'EOF'
|
|
235
|
+
{
|
|
236
|
+
"commit_id": "<headRefOid>",
|
|
237
|
+
"event": "REQUEST_CHANGES",
|
|
238
|
+
"body": "<!-- asdlc:review-round:<round> -->\n## 🤖 AI Implementation Review — `<CHANGE_ID>`\n...",
|
|
239
|
+
"comments": [
|
|
240
|
+
{
|
|
241
|
+
"path": "src/example.js",
|
|
242
|
+
"line": 42,
|
|
243
|
+
"side": "RIGHT",
|
|
244
|
+
"body": "**[Blocker: Introduced]** `R<round>-#1`: <defect and required fix>"
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
EOF
|
|
249
|
+
```
|
|
250
|
+
- **Standard / Fallback**: Post the structured review as a PR comment:
|
|
231
251
|
|
|
232
252
|
```bash
|
|
233
253
|
gh pr comment $PR_NUMBER --repo $REPO --body "$(cat <<'EOF'
|
|
@@ -238,9 +258,10 @@ EOF
|
|
|
238
258
|
|
|
239
259
|
- **If reviewing locally** (`<CHANGE_ID>` only, no PR): **Print the formatted review markdown directly** in your response and skip `gh pr comment` and Step 6.
|
|
240
260
|
|
|
241
|
-
Format the comment body strictly as:
|
|
261
|
+
Format the comment body strictly as (keeping the hidden `<!-- asdlc:review-round:<round> -->` anchor on line 1 for deterministic triage round tracking):
|
|
242
262
|
|
|
243
263
|
~~~markdown
|
|
264
|
+
<!-- asdlc:review-round:<round> -->
|
|
244
265
|
## 🤖 AI Implementation Review — `<CHANGE_ID>`
|
|
245
266
|
|
|
246
267
|
> **Reviewer**: AI Independent Implementation Reviewer (`asdlc-impl-review`)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: asdlc-new
|
|
3
|
-
description: "Start a new spec-driven change: derives change slug from natural language requirement, grounds in knowledge graph (explore.md), runs
|
|
3
|
+
description: "Start a new spec-driven change: derives change slug from natural language requirement, grounds in knowledge graph (explore.md), runs grill-me (or --batch-grill) interview, and drafts initial proposal, technical design (design.md), and spec deltas."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# /asdlc:new - Start Feature & Batch-Grill Author
|
|
@@ -33,7 +33,7 @@ When the user invokes `/asdlc:new` or provides a task with `--from-file`/`--file
|
|
|
33
33
|
When the grounded requirement is established:
|
|
34
34
|
|
|
35
35
|
```powershell
|
|
36
|
-
asdlc new "<requirement>" [--from-file <path>] [--from-issue <id> | --ticket <id>] [--batch-grill] [--no-grill]
|
|
36
|
+
asdlc new "<requirement>" --agent [--from-file <path>] [--from-issue <id> | --ticket <id>] [--batch-grill] [--no-grill]
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
The CLI:
|
|
@@ -25,7 +25,7 @@ asdlc pr <CHANGE_ID> [targetBranch]
|
|
|
25
25
|
| PR Type | Track & Moment | Pre-Flight Guard | Auto Labels | Review Automation Trigger |
|
|
26
26
|
| :--- | :--- | :--- | :--- | :--- |
|
|
27
27
|
| **Spec PR** | **Track A** Stage 3 (L2/L3/`spec-first` after drafting proposal & specs) | **`asdlc lint <ID>`**<br>(0 blocking BDD/AC issues) | `asdlc:spec-review`<br>`spec` | Runs `asdlc lint` + routes to **Independent Spec AI Review** (`asdlc-spec-review`) |
|
|
28
|
-
| **Impl / Single PR** | **Track A** Stage 6.5 or **Track B** (L0/L1 Single-PR after TDD & tasks complete) | **`asdlc verify <ID>`**<br>(
|
|
28
|
+
| **Impl / Single PR** | **Track A** Stage 6.5 or **Track B** (L0/L1 Single-PR after TDD & tasks complete) | **`asdlc verify <ID>`**<br>(all verification gates pass) | `asdlc:impl-review`<br>`impl` | Runs `asdlc verify` + routes to **Independent Impl AI Review** (`asdlc-impl-review`) |
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -44,7 +44,7 @@ asdlc pr <CHANGE_ID> [targetBranch]
|
|
|
44
44
|
|
|
45
45
|
2. **Pre-flight Quality Gate**:
|
|
46
46
|
- **Spec PR**: runs `asdlc lint <ID>`. Fails fast if any blocking BDD or acceptance criteria findings exist.
|
|
47
|
-
- **Impl PR**: runs `asdlc verify <ID>`. Fails fast if any
|
|
47
|
+
- **Impl PR**: runs `asdlc verify <ID>`. Fails fast if any verification checks fail.
|
|
48
48
|
|
|
49
49
|
3. **Title & Body Extraction**:
|
|
50
50
|
- **Spec PR**: derives clean title (`spec(<slug>): <title>`) and embeds proposal intent.
|
|
@@ -141,9 +141,10 @@ EOF
|
|
|
141
141
|
|
|
142
142
|
- **If reviewing locally** (`<CHANGE_ID>` only, no PR): **Print the formatted review markdown directly** in your response and skip `gh pr comment` and Step 6.
|
|
143
143
|
|
|
144
|
-
Format the comment body strictly as:
|
|
144
|
+
Format the comment body strictly as (keeping the hidden `<!-- asdlc:review-round:<round> -->` anchor on line 1 for deterministic round tracking):
|
|
145
145
|
|
|
146
146
|
~~~markdown
|
|
147
|
+
<!-- asdlc:review-round:<round> -->
|
|
147
148
|
## 🤖 AI Spec Review — `<CHANGE_ID>`
|
|
148
149
|
|
|
149
150
|
> **Reviewer**: AI Independent Spec Reviewer (`asdlc-spec-review`)
|
|
@@ -47,3 +47,18 @@ Render a dashboard of all active changes:
|
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
Offer to drill down into any change or start a new one with `/asdlc:new "<requirement>"`.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
### Case C: Team Governance & Observability Metrics (`/asdlc:status --metrics`)
|
|
54
|
+
Run:
|
|
55
|
+
|
|
56
|
+
```powershell
|
|
57
|
+
asdlc status --metrics [--days 30] [--json]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Displays the **ASDLC Harness Observability** dashboard:
|
|
61
|
+
1. **Gate Friction Leaderboard**: Top local gate failures & failure patterns from `.sdlc/events.jsonl`.
|
|
62
|
+
2. **Autonomous PR Convergence (3-Round Cap)**: Round 1/2/3 pass rates and human escalations derived from Git archive history and `(ref: #PRRT_...)` commit trailers.
|
|
63
|
+
3. **Stage Lead Time (P50 / P90)**: Spec phase (`new -> approve`) and TDD phase (`apply -> verify`) durations via Git provenance.
|
|
64
|
+
4. **Risk Tier Breakdown**: Count of `L0`–`L3` changes tracked over the selected window.
|
|
@@ -11,20 +11,21 @@ This skill executes **Stage 6 (Verify)** of the Agentic SDLC. It runs the full s
|
|
|
11
11
|
|
|
12
12
|
## What this skill verifies
|
|
13
13
|
|
|
14
|
-
`asdlc verify` executes
|
|
15
|
-
1. **`
|
|
16
|
-
2. **`
|
|
17
|
-
3. **`
|
|
18
|
-
4. **`spec
|
|
19
|
-
5. **`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
`asdlc verify` executes coordinated deterministic and AI quality gates:
|
|
15
|
+
1. **`level-integrity`**: Validates declared risk level matches change topology and hash-chain history.
|
|
16
|
+
2. **`pr-type`**: Discriminates PR type based strictly on paths.
|
|
17
|
+
3. **`artifacts`**: Checks presence of `proposal.md`, `specs/**`, `review.md`, `explore.md`, `tasks.md`.
|
|
18
|
+
4. **`approved-spec`**: Verifies that the spec commit is merged into target branch and matches declared `specSha`.
|
|
19
|
+
5. **`spec-tamper`**: Enforces that locked spec files (`proposal.md`, `specs/**`) are 100% unmodified in the Impl PR diff.
|
|
20
|
+
6. **`flow-state`**: Verifies status is `READY_FOR_IMPL` (stamped by `asdlc approve` or single-PR `apply`).
|
|
21
|
+
7. **`risk-escape`**: Detects unannounced API/DDL escalations that cross risk boundaries.
|
|
22
|
+
8. **`human-gate`**: Validates mandatory Tech Lead approval for L2/L3 (and `supervised`) changes.
|
|
23
|
+
9. **`tasks-complete`**: Confirms zero unchecked task boxes (`- [ ]`) in `tasks.md`.
|
|
24
|
+
10. **`test-presence`**: Enforces that any production code diff is accompanied by test diffs.
|
|
25
|
+
11. **`anti-test-weakening`**: Blocks deleted tests or newly injected `.skip` / `@Disabled` / `@pytest.mark.skip` bypasses.
|
|
26
|
+
12. **`tdd-evidence`**: Confirms that completed tasks record verification commands and test execution outputs.
|
|
27
|
+
13. **`BDD + acceptance criteria`**: Confirms all Acceptance Criteria test targets exist on disk and pass R0–R8 linting.
|
|
28
|
+
14. **`openspec-validate` / `schema-managed` / `acceptance-tests` / `external` / `AI verification`**: Strict OpenSpec schema validation, BU-managed schema pin check, spec-mapped AC test execution (`asdlc test`), external CI checks, and independent referee verification.
|
|
28
29
|
|
|
29
30
|
---
|
|
30
31
|
|
|
@@ -41,10 +42,11 @@ asdlc verify <CHANGE_ID>
|
|
|
41
42
|
If any check outputs `[FAIL]`:
|
|
42
43
|
- **`approved-spec`**: The spec is not yet merged on the protected branch. Guide the user: merge the spec PR, then run `asdlc approve <CHANGE_ID>`.
|
|
43
44
|
- **`test-presence`**: Source code was changed with zero test files. Guide the user: write corresponding unit/integration tests following TDD.
|
|
45
|
+
- **`anti-test-weakening`**: Existing tests were deleted or `.skip` / `@Disabled` / `@pytest.mark.skip` markers were added. Restore the tests and fix the underlying behavior.
|
|
44
46
|
- **`tdd-evidence`**: Tasks were checked without test run output. Guide the user: paste test execution results under tasks in `tasks.md`.
|
|
45
47
|
- **`tasks-complete`**: Unchecked tasks remain. Guide the user to finish implementing remaining tasks.
|
|
46
|
-
- **`BDD +
|
|
47
|
-
- **`external` (unit tests)**: Run the failing test command, debug the failure, fix the code, and re-run.
|
|
48
|
+
- **`BDD + acceptance criteria`**: An acceptance criterion points to a test file that does not exist. Create the missing test file.
|
|
49
|
+
- **`acceptance-tests` / `external` (unit tests)**: Run the failing test command, debug the failure, fix the code, and re-run.
|
|
48
50
|
|
|
49
51
|
### Step 3: Next Actions (Depending on Lifecycle Stage)
|
|
50
52
|
When all checks output `[PASS]` and verify succeeds:
|
|
@@ -52,7 +54,7 @@ When all checks output `[PASS]` and verify succeeds:
|
|
|
52
54
|
- **Scenario A: Pre-PR Local Implementation Verification (Stage 6)**
|
|
53
55
|
If running on a feature branch before opening the Implementation PR:
|
|
54
56
|
Inform the developer:
|
|
55
|
-
> "🎉 Local verification passed! All
|
|
57
|
+
> "🎉 Local verification passed! All verification gates satisfied.
|
|
56
58
|
> When you are ready to submit this implementation for CI AI review and team approval, run:
|
|
57
59
|
> `asdlc pr <CHANGE_ID> <targetBranch>` (or trigger `/asdlc:pr`).
|
|
58
60
|
> *(The agent will NOT automatically open a PR without your explicit command).* "
|
|
@@ -60,6 +62,6 @@ When all checks output `[PASS]` and verify succeeds:
|
|
|
60
62
|
- **Scenario B: Post-Merge Trunk Verification (Stage 6 -> Stage 7)**
|
|
61
63
|
If running after the Implementation PR has been approved and merged into the protected target branch (`main`):
|
|
62
64
|
Inform the developer:
|
|
63
|
-
> "🎉 Post-merge verification passed! All
|
|
65
|
+
> "🎉 Post-merge verification passed! All verification gates verified on the target branch.
|
|
64
66
|
> To close out and archive this change into the master specification catalog, run:
|
|
65
67
|
> `asdlc archive <CHANGE_ID>` (or trigger `/asdlc:archive`)."
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: ASDLC Governance & AI Review
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, synchronize, labeled]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
pull-requests: write
|
|
10
|
+
statuses: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
asdlc-gates:
|
|
14
|
+
name: ASDLC Deterministic Gates
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
|
|
22
|
+
- name: Set up Node.js
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '20.x'
|
|
26
|
+
|
|
27
|
+
- name: Install agentic-sdlc
|
|
28
|
+
run: npm install -g @akjamie/agentic-sdlc@latest
|
|
29
|
+
|
|
30
|
+
- name: Detect active change and run Spec/Impl gates
|
|
31
|
+
env:
|
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
33
|
+
run: |
|
|
34
|
+
set -e
|
|
35
|
+
LABELS='${{ join(github.event.pull_request.labels.*.name, ',') }}'
|
|
36
|
+
CHANGE_ID=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -oE 'openspec/changes/[^/]+' | grep -v '/archive$' | head -n1 | cut -d/ -f3 || true)
|
|
37
|
+
if [ -z "$CHANGE_ID" ]; then
|
|
38
|
+
echo "No openspec/changes/<id> touched; skipping asdlc gate."
|
|
39
|
+
exit 0
|
|
40
|
+
fi
|
|
41
|
+
if echo "$LABELS" | grep -q "asdlc:spec-review"; then
|
|
42
|
+
asdlc lint "$CHANGE_ID"
|
|
43
|
+
fi
|
|
44
|
+
if echo "$LABELS" | grep -q "asdlc:impl-review"; then
|
|
45
|
+
asdlc verify "$CHANGE_ID" --protected-branch "origin/${{ github.base_ref }}"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Optional: configure repository variable ASDLC_AI_REVIEW_CMD + LLM secret to run a headless review agent
|
|
49
|
+
- name: Optional Headless AI Review Runner
|
|
50
|
+
if: ${{ vars.ASDLC_AI_REVIEW_CMD != '' }}
|
|
51
|
+
env:
|
|
52
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
53
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
54
|
+
run: |
|
|
55
|
+
${{ vars.ASDLC_AI_REVIEW_CMD }}
|
package/package.json
CHANGED
package/src/commands/apply.js
CHANGED
|
@@ -3,15 +3,60 @@ import { spawnSync } from 'node:child_process';
|
|
|
3
3
|
import { Option } from 'commander';
|
|
4
4
|
import { exists, readText, writeText } from '../lib/fs.js';
|
|
5
5
|
import { changeDir } from '../lib/paths.js';
|
|
6
|
-
import { requireRepo, toChangeSlug, requireAgentRuntime } from '../lib/cliutil.js';
|
|
7
|
-
import { lastCommitTouching, git, resolveDefaultBranch } from '../lib/git.js';
|
|
6
|
+
import { requireRepo, toChangeSlug, requireAgentRuntime, jsonOut } from '../lib/cliutil.js';
|
|
7
|
+
import { lastCommitTouching, git, resolveDefaultBranch, headSha } from '../lib/git.js';
|
|
8
8
|
import { fail } from '../lib/errors.js';
|
|
9
9
|
import { log } from '../lib/log.js';
|
|
10
10
|
import { isSinglePrLevel, readEffectiveLevel } from '../lib/level.js';
|
|
11
11
|
import { resolveWorkflowMode } from '../lib/config.js';
|
|
12
12
|
import { assess } from '../assess/index.js';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
triagePullRequest,
|
|
15
|
+
PULL_REQUEST_THREADS_QUERY,
|
|
16
|
+
checkAntiThrashingCircuitBreaker,
|
|
17
|
+
buildThreadResolutionPlan,
|
|
18
|
+
} from '../lib/triage.js';
|
|
14
19
|
import { recordEvent } from '../lib/telemetry.js';
|
|
20
|
+
import { generateTasksFromSpecs } from '../lib/tasks-gen.js';
|
|
21
|
+
|
|
22
|
+
function runGhGraphql(repoRoot, mutation) {
|
|
23
|
+
return spawnSync('gh', [
|
|
24
|
+
'api', 'graphql',
|
|
25
|
+
'-f', `query=${mutation.query}`,
|
|
26
|
+
...Object.entries(mutation.variables || {}).flatMap(([k, v]) => ['-F', `${k}=${v}`]),
|
|
27
|
+
], { cwd: repoRoot, encoding: 'utf8', timeout: 8000 });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function postBreakerEscalation(repoRoot, prRef, breaker) {
|
|
31
|
+
spawnSync('gh', ['pr', 'comment', prRef, '--body', breaker.synthesisReport], {
|
|
32
|
+
cwd: repoRoot,
|
|
33
|
+
encoding: 'utf8',
|
|
34
|
+
timeout: 8000,
|
|
35
|
+
});
|
|
36
|
+
spawnSync('gh', ['pr', 'edit', prRef, '--add-label', breaker.label], {
|
|
37
|
+
cwd: repoRoot,
|
|
38
|
+
encoding: 'utf8',
|
|
39
|
+
timeout: 8000,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function printTriageThreads(triage, prRef) {
|
|
44
|
+
const sections = [
|
|
45
|
+
['SUGGESTION_BLOCK', triage.suggestionThreads],
|
|
46
|
+
['ACTION_REQUIRED', triage.actionableThreads],
|
|
47
|
+
['INFORMATIONAL_QUESTION', triage.questionThreads],
|
|
48
|
+
];
|
|
49
|
+
for (const [label, threads] of sections) {
|
|
50
|
+
for (const t of threads) {
|
|
51
|
+
const loc = t.path ? `${t.path}${t.line ? `:${t.line}` : ''}` : 'PR';
|
|
52
|
+
const snippet = String(t.latestBody || t.body || '').replace(/\s+/g, ' ').slice(0, 140);
|
|
53
|
+
log.info(` [${label}] ${t.id || 'n/a'} (${loc}) @${t.latestAuthor || 'reviewer'}: ${snippet}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (triage.unaddressedCount > 0) {
|
|
57
|
+
log.info(` -> After fixing & committing with '(ref: #<threadId>)', resolve via: asdlc apply <ID> --from-pr ${prRef} --resolve-thread <threadId>`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
15
60
|
|
|
16
61
|
// Guard before implementing: the spec must be APPROVED on the target branch
|
|
17
62
|
// (i.e. the Spec PR has been merged into targetBranch, locking proposal.md & specs/**).
|
|
@@ -84,6 +129,7 @@ export function applyGuard(changeId, opts = {}) {
|
|
|
84
129
|
}
|
|
85
130
|
}
|
|
86
131
|
|
|
132
|
+
const emit = (fn, msg) => { if (!opts.json) fn(msg); };
|
|
87
133
|
const isSinglePr = isSinglePrLevel(effectiveLevel) && resolvedMode !== 'spec-first' && meta.workflowMode !== 'spec-first';
|
|
88
134
|
let approvedSha = null;
|
|
89
135
|
|
|
@@ -98,9 +144,9 @@ export function applyGuard(changeId, opts = {}) {
|
|
|
98
144
|
};
|
|
99
145
|
metaText = upsertKey(metaText, 'status', 'ready_for_impl');
|
|
100
146
|
writeText(metaPath, metaText);
|
|
101
|
-
log.ok
|
|
147
|
+
emit(log.ok, `${slug}: marked status=ready_for_impl (no separate Spec PR in Single-PR mode; human sign-off happens on the final PR)`);
|
|
102
148
|
}
|
|
103
|
-
log.ok
|
|
149
|
+
emit(log.ok, `${slug}: governance level is ${effectiveLevel} (Single PR mode: direct local implementation permitted)`);
|
|
104
150
|
} else {
|
|
105
151
|
// L2 / L3 Two-phase Spec-first flow
|
|
106
152
|
// 2. Multi-tenant path-isolated approval detection
|
|
@@ -150,7 +196,7 @@ export function applyGuard(changeId, opts = {}) {
|
|
|
150
196
|
}
|
|
151
197
|
writeText(metaPath, metaText);
|
|
152
198
|
}
|
|
153
|
-
log.ok
|
|
199
|
+
emit(log.ok, `${slug}: recognized PR approval on ${branch} (synced state to ready_for_impl @ ${approvedSha.slice(0, 8)})`);
|
|
154
200
|
}
|
|
155
201
|
}
|
|
156
202
|
|
|
@@ -175,18 +221,23 @@ export function applyGuard(changeId, opts = {}) {
|
|
|
175
221
|
writeText(metaPath, metaText);
|
|
176
222
|
}
|
|
177
223
|
|
|
178
|
-
// 7. Tasks checklist presence
|
|
224
|
+
// 7. Tasks checklist presence (auto-compile from spec ACs if missing)
|
|
179
225
|
const tasksPath = path.join(cdir, 'tasks.md');
|
|
180
226
|
if (!exists(tasksPath)) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
227
|
+
const gen = generateTasksFromSpecs(repoRoot, slug);
|
|
228
|
+
if (gen.generated) {
|
|
229
|
+
emit(log.ok, `auto-generated tasks.md (${gen.taskCount} TDD tasks from ${gen.acCount} spec AC(s))`);
|
|
230
|
+
} else {
|
|
231
|
+
fail(`'${slug}' missing tasks.md`, {
|
|
232
|
+
code: 'TASKS_MISSING',
|
|
233
|
+
hint: 'author tasks.md with TDD verification tasks (or add AC<n>: ... (test: <path>) to specs) before running apply',
|
|
234
|
+
});
|
|
235
|
+
}
|
|
185
236
|
}
|
|
186
237
|
|
|
187
238
|
const isAutoPr = opts.autoPr === true || (opts.autoPr === undefined && meta.autoPr === 'true');
|
|
188
239
|
const shaDisplay = approvedSha ? ` (specSha: ${approvedSha.slice(0, 8)}, state: ready_for_impl)` : ` (state: ready_for_impl)`;
|
|
189
|
-
log.ok
|
|
240
|
+
emit(log.ok, `${slug} is READY FOR IMPLEMENTATION on ${branch}${shaDisplay}`);
|
|
190
241
|
|
|
191
242
|
if (opts.fromPr) {
|
|
192
243
|
const prRef = String(opts.fromPr).replace(/^#/, '');
|
|
@@ -242,7 +293,19 @@ export function applyGuard(changeId, opts = {}) {
|
|
|
242
293
|
commitMessages = recentLog.split(/\r?\n\r?\n/).filter(Boolean);
|
|
243
294
|
} catch {}
|
|
244
295
|
const triage = triagePullRequest(prCtx || {}, { commitMessages });
|
|
245
|
-
|
|
296
|
+
const unresolvedThreads = [
|
|
297
|
+
...triage.actionableThreads,
|
|
298
|
+
...triage.suggestionThreads,
|
|
299
|
+
...triage.questionThreads,
|
|
300
|
+
];
|
|
301
|
+
const breaker = checkAntiThrashingCircuitBreaker({
|
|
302
|
+
currentRound: triage.round,
|
|
303
|
+
maxRounds: triage.maxRounds,
|
|
304
|
+
unresolvedThreads,
|
|
305
|
+
changeId: slug,
|
|
306
|
+
prNumber: Number.isFinite(prNum) ? prNum : null,
|
|
307
|
+
});
|
|
308
|
+
|
|
246
309
|
recordEvent('pr.triage', {
|
|
247
310
|
stage: 'apply',
|
|
248
311
|
change: slug,
|
|
@@ -257,7 +320,59 @@ export function applyGuard(changeId, opts = {}) {
|
|
|
257
320
|
suggestionCount: triage.suggestionThreads.length,
|
|
258
321
|
round: triage.round,
|
|
259
322
|
maxRounds: triage.maxRounds,
|
|
323
|
+
circuitBreakerTripped: breaker.tripped,
|
|
260
324
|
}, { repoRoot });
|
|
325
|
+
|
|
326
|
+
if (opts.resolveThread) {
|
|
327
|
+
const matchedThread = unresolvedThreads.find((t) => t.id === opts.resolveThread) || { id: opts.resolveThread };
|
|
328
|
+
const plan = buildThreadResolutionPlan(matchedThread, {
|
|
329
|
+
commitSha: opts.commit || headSha(repoRoot) || 'HEAD',
|
|
330
|
+
summary: opts.reply || '',
|
|
331
|
+
disputed: Boolean(opts.dispute),
|
|
332
|
+
specRef: typeof opts.dispute === 'string' ? opts.dispute : null,
|
|
333
|
+
});
|
|
334
|
+
if (!opts.dryRun && !opts.prContext) {
|
|
335
|
+
if (plan.replyMutation) runGhGraphql(repoRoot, plan.replyMutation);
|
|
336
|
+
if (plan.shouldResolve && plan.resolveMutation) {
|
|
337
|
+
runGhGraphql(repoRoot, plan.resolveMutation);
|
|
338
|
+
} else if (plan.disputed) {
|
|
339
|
+
spawnSync('gh', ['pr', 'edit', prRef, '--add-label', 'asdlc:needs-human-arbitration'], {
|
|
340
|
+
cwd: repoRoot,
|
|
341
|
+
encoding: 'utf8',
|
|
342
|
+
timeout: 8000,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (opts.json) {
|
|
347
|
+
jsonOut({ changeId: slug, pr: prNum, resolutionPlan: plan });
|
|
348
|
+
} else {
|
|
349
|
+
log.ok(plan.shouldResolve
|
|
350
|
+
? `[PR #${prRef}] Thread ${opts.resolveThread} replied & resolved (${plan.commitMessage}).`
|
|
351
|
+
: `[PR #${prRef}] Thread ${opts.resolveThread} marked DISPUTED — escalated for human arbitration (resolve blocked).`);
|
|
352
|
+
}
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (breaker.tripped) {
|
|
357
|
+
if (!opts.dryRun && !opts.prContext) {
|
|
358
|
+
postBreakerEscalation(repoRoot, prRef, breaker);
|
|
359
|
+
}
|
|
360
|
+
if (opts.json) {
|
|
361
|
+
jsonOut({ changeId: slug, pr: prNum, triage, circuitBreaker: breaker });
|
|
362
|
+
} else {
|
|
363
|
+
log.error(`[PR #${prRef}] Anti-Thrashing Circuit Breaker tripped (Round ${triage.round}/${triage.maxRounds}). Automated edits halted.`);
|
|
364
|
+
log.info(breaker.synthesisReport);
|
|
365
|
+
}
|
|
366
|
+
return breaker.exitCode;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (opts.json) {
|
|
370
|
+
jsonOut({ changeId: slug, pr: prNum, triage, circuitBreaker: breaker });
|
|
371
|
+
return 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
log.info(`[PR #${prRef}] Triaged review feedback (Round ${triage.round}/${triage.maxRounds}): ${triage.actionableThreads.length} actionable, ${triage.questionThreads.length} question(s), ${triage.suggestionThreads.length} suggestion(s).`);
|
|
375
|
+
printTriageThreads(triage, prRef);
|
|
261
376
|
}
|
|
262
377
|
|
|
263
378
|
if (isAutoPr) {
|
|
@@ -277,6 +392,12 @@ export function register(program) {
|
|
|
277
392
|
.option('--target-branch <ref>', 'target branch to merge into')
|
|
278
393
|
.option('--mode <mode>', 'workflow mode: supervised (default) | spec-first | auto')
|
|
279
394
|
.option('--from-pr <pr>', 'triage review comments from a GitHub PR number or #N')
|
|
395
|
+
.option('--resolve-thread <threadId>', 'reply and resolve a PR review thread (or escalate via --dispute)')
|
|
396
|
+
.option('--commit <sha>', 'commit SHA to cite when resolving a review thread')
|
|
397
|
+
.option('--reply <text>', 'reply summary when resolving a review thread')
|
|
398
|
+
.option('--dispute <reason>', 'mark thread as spec-conflict (forbids auto-resolve and attaches human arbitration label)')
|
|
399
|
+
.option('--dry-run', 'compute triage or resolution plan without calling gh mutations')
|
|
400
|
+
.option('--json', 'output triage or resolution plan as structured JSON')
|
|
280
401
|
.option('--auto-pr', 'explicitly delegate authority to automatically open Implementation PR after verification passes')
|
|
281
402
|
.option('--no-auto-pr', 'disable automatic Implementation PR creation (default)')
|
|
282
403
|
.option('--guard-only', 'only run pre-implementation guard checks in terminal without starting the AI TDD loop')
|
package/src/commands/lint.js
CHANGED
|
@@ -7,6 +7,7 @@ import { assess } from '../assess/index.js';
|
|
|
7
7
|
import { resolveWorkflowMode } from '../lib/config.js';
|
|
8
8
|
import { log, dim } from '../lib/log.js';
|
|
9
9
|
import { recordEvent, getChangeIteration, writeGitHubStepSummary } from '../lib/telemetry.js';
|
|
10
|
+
import { generateTasksFromSpecs } from '../lib/tasks-gen.js';
|
|
10
11
|
|
|
11
12
|
// THE spec check (v10: lint absorbed review). Deterministic:
|
|
12
13
|
// - required artifacts (explore.md + proposal.md + >=1 spec delta)
|
|
@@ -242,6 +243,13 @@ export function runLint(changeId, opts = {}) {
|
|
|
242
243
|
}
|
|
243
244
|
add('BDD + acceptance criteria', blockers === 0 ? 'pass' : 'fail', bddDetail);
|
|
244
245
|
|
|
246
|
+
if (opts.genTasks && blockers === 0) {
|
|
247
|
+
const gen = generateTasksFromSpecs(repoRoot, slug);
|
|
248
|
+
if (gen.generated && !opts.json) {
|
|
249
|
+
log.ok(`generated tasks.md (${gen.taskCount} TDD tasks from ${gen.acCount} spec AC(s))`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
245
253
|
return finish(results, { json: opts.json, changeId: slug, repoRoot, startTime, iteration });
|
|
246
254
|
}
|
|
247
255
|
|
|
@@ -251,6 +259,7 @@ export function register(program) {
|
|
|
251
259
|
.description('check the spec: artifacts + review record + BDD/acceptance criteria')
|
|
252
260
|
.option('--repo-root <path>')
|
|
253
261
|
.option('--mode <mode>', 'workflow mode: supervised (default) | spec-first | auto')
|
|
262
|
+
.option('--gen-tasks', 'auto-generate tasks.md from spec ACs if missing and lint passes')
|
|
254
263
|
.option('--json', 'stable JSON output for CI')
|
|
255
264
|
.action((changeId, opts) => {
|
|
256
265
|
process.exitCode = runLint(changeId, opts);
|
package/src/commands/test.js
CHANGED
|
@@ -6,30 +6,9 @@ import { runShell } from '../lib/exec.js';
|
|
|
6
6
|
import { fail } from '../lib/errors.js';
|
|
7
7
|
import { log } from '../lib/log.js';
|
|
8
8
|
import { readYaml } from '../lib/yaml.js';
|
|
9
|
+
import { parseSpecAcceptanceCriteria } from '../lib/tasks-gen.js';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
const acs = [];
|
|
12
|
-
const lines = specText.split('\n');
|
|
13
|
-
let currentReq = '';
|
|
14
|
-
|
|
15
|
-
for (const line of lines) {
|
|
16
|
-
const reqMatch = line.match(/^###\s+Requirement:\s*(.+?)\s*$/);
|
|
17
|
-
if (reqMatch) {
|
|
18
|
-
currentReq = reqMatch[1];
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const acMatch = line.match(/^\s*-\s*\[[ xX]\]\s*(AC\d+)\s*:\s*(.+)$/);
|
|
22
|
-
if (!acMatch) continue;
|
|
23
|
-
const testMatch = line.match(/\(test:\s*([^)]+?)\s*\)/i);
|
|
24
|
-
acs.push({
|
|
25
|
-
id: acMatch[1],
|
|
26
|
-
requirement: currentReq,
|
|
27
|
-
text: acMatch[2].replace(/\(test:.*$/i, '').trim(),
|
|
28
|
-
testPath: testMatch ? testMatch[1].trim() : null,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return acs;
|
|
32
|
-
}
|
|
11
|
+
export { parseSpecAcceptanceCriteria };
|
|
33
12
|
|
|
34
13
|
export function runTests(changeId, opts = {}) {
|
|
35
14
|
const repoRoot = requireRepo(opts);
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { exists, readText, writeText, walkFiles } from './fs.js';
|
|
3
|
+
import { changeDir } from './paths.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse `- [ ] ACn: <description> (test: <path>)` acceptance criteria grouped by Requirement.
|
|
7
|
+
*/
|
|
8
|
+
export function parseSpecAcceptanceCriteria(specText) {
|
|
9
|
+
const acs = [];
|
|
10
|
+
const lines = String(specText ?? '').split(/\r?\n/);
|
|
11
|
+
let currentReq = '';
|
|
12
|
+
|
|
13
|
+
for (const line of lines) {
|
|
14
|
+
const reqMatch = line.match(/^###\s+Requirement:\s*(.+?)\s*$/);
|
|
15
|
+
if (reqMatch) {
|
|
16
|
+
currentReq = reqMatch[1];
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const acMatch = line.match(/^\s*-\s*\[[ xX]\]\s*(AC\d+)\s*:\s*(.+)$/);
|
|
20
|
+
if (!acMatch) continue;
|
|
21
|
+
const testMatch = line.match(/\(test:\s*([^)]+?)\s*\)/i);
|
|
22
|
+
acs.push({
|
|
23
|
+
id: acMatch[1],
|
|
24
|
+
requirement: currentReq,
|
|
25
|
+
text: acMatch[2].replace(/\(test:.*$/i, '').trim(),
|
|
26
|
+
testPath: testMatch ? testMatch[1].trim() : null,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return acs;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function hasUiSurface(designText, specEntries) {
|
|
33
|
+
if (designText && /(UI\/UX|Visual|Breakpoints|Loading\s+Skeleton|Empty\s+State|Component)/i.test(designText)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return specEntries.some(({ content }) => /(Playwright|responsive\s+breakpoint|Empty,\s*Loading,\s*Error)/i.test(content));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Compile `openspec/changes/<slug>/tasks.md` deterministically from spec ACs.
|
|
41
|
+
* Idempotent: never overwrites an existing non-empty `tasks.md`.
|
|
42
|
+
* Fails closed (`generated: false`) if no valid ACs exist in specs.
|
|
43
|
+
*/
|
|
44
|
+
export function generateTasksFromSpecs(repoRoot, slug) {
|
|
45
|
+
const cdir = changeDir(repoRoot, slug);
|
|
46
|
+
const tasksPath = path.join(cdir, 'tasks.md');
|
|
47
|
+
|
|
48
|
+
if (exists(tasksPath) && readText(tasksPath).trim().length > 0) {
|
|
49
|
+
return { generated: false, reason: 'already_exists', path: tasksPath };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const specsDir = path.join(cdir, 'specs');
|
|
53
|
+
if (!exists(specsDir)) {
|
|
54
|
+
return { generated: false, reason: 'no_specs', path: tasksPath };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const specFiles = walkFiles(specsDir).filter((f) => f.endsWith('spec.md'));
|
|
58
|
+
const specEntries = specFiles.map((rel) => {
|
|
59
|
+
const content = readText(path.join(specsDir, rel));
|
|
60
|
+
return { rel: rel.replace(/\\/g, '/'), content, acs: parseSpecAcceptanceCriteria(content) };
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const allAcs = specEntries.flatMap((e) => e.acs.map((ac) => ({ ...ac, specFile: e.rel })));
|
|
64
|
+
if (allAcs.length === 0) {
|
|
65
|
+
return { generated: false, reason: 'no_acs', path: tasksPath };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const designPath = path.join(cdir, 'design.md');
|
|
69
|
+
const designText = exists(designPath) ? readText(designPath) : '';
|
|
70
|
+
const uiTasksIncluded = hasUiSurface(designText, specEntries);
|
|
71
|
+
|
|
72
|
+
const lines = [
|
|
73
|
+
`# Tasks: ${slug}`,
|
|
74
|
+
'',
|
|
75
|
+
'> Auto-generated from capability specs (mutable during implementation: refine, split, or append TDD tasks as needed).',
|
|
76
|
+
'> Follow strict task-level TDD loop (RED -> GREEN -> REFACTOR -> EVIDENCE).',
|
|
77
|
+
'',
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
let taskCount = 0;
|
|
81
|
+
|
|
82
|
+
if (uiTasksIncluded) {
|
|
83
|
+
lines.push('## 0. UI/UX Foundation & Component States (`design.md`)');
|
|
84
|
+
lines.push('- [ ] 0.1 [UI/DESIGN] Establish design tokens, responsive layout containers, and theme styles');
|
|
85
|
+
lines.push('- [ ] 0.2 [UI/COMPONENTS] Implement Empty, Loading, Error, and Success states with component render tests');
|
|
86
|
+
lines.push('');
|
|
87
|
+
taskCount += 2;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const groups = new Map();
|
|
91
|
+
for (const ac of allAcs) {
|
|
92
|
+
const key = `${ac.specFile}::${ac.requirement || 'General'}`;
|
|
93
|
+
if (!groups.has(key)) {
|
|
94
|
+
groups.set(key, { specFile: ac.specFile, requirement: ac.requirement || 'Capability Requirements', acs: [] });
|
|
95
|
+
}
|
|
96
|
+
groups.get(key).acs.push(ac);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let sectionNum = 1;
|
|
100
|
+
for (const group of groups.values()) {
|
|
101
|
+
lines.push(`## ${sectionNum}. ${group.requirement} (\`specs/${group.specFile}\`)`);
|
|
102
|
+
let subNum = 1;
|
|
103
|
+
for (const ac of group.acs) {
|
|
104
|
+
const testRef = ac.testPath ? ` (\`${ac.testPath}\`)` : '';
|
|
105
|
+
lines.push(`- [ ] ${sectionNum}.${subNum} [TEST] Write failing test for ${ac.id}: ${ac.text}${testRef}`);
|
|
106
|
+
subNum += 1;
|
|
107
|
+
lines.push(`- [ ] ${sectionNum}.${subNum} [IMPL] Implement minimal code to satisfy ${ac.id}${testRef}`);
|
|
108
|
+
subNum += 1;
|
|
109
|
+
taskCount += 2;
|
|
110
|
+
}
|
|
111
|
+
lines.push('');
|
|
112
|
+
sectionNum += 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
writeText(tasksPath, `${lines.join('\n').trimEnd()}\n`);
|
|
116
|
+
return {
|
|
117
|
+
generated: true,
|
|
118
|
+
taskCount,
|
|
119
|
+
acCount: allAcs.length,
|
|
120
|
+
uiTasksIncluded,
|
|
121
|
+
path: tasksPath,
|
|
122
|
+
};
|
|
123
|
+
}
|
package/src/lib/tools.js
CHANGED
|
@@ -285,8 +285,12 @@ export function installCommands(repoRoot, tools = []) {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
function normalizeLf(text) {
|
|
289
|
+
return String(text ?? '').replace(/\r\n/g, '\n');
|
|
290
|
+
}
|
|
291
|
+
|
|
288
292
|
/**
|
|
289
|
-
* Audit tool health for asdlc doctor
|
|
293
|
+
* Audit tool health for asdlc doctor (checks presence and normalized skill/command drift)
|
|
290
294
|
*/
|
|
291
295
|
export function checkToolHealth(repoRoot, toolId) {
|
|
292
296
|
const def = TOOL_REGISTRY[toolId];
|
|
@@ -295,21 +299,63 @@ export function checkToolHealth(repoRoot, toolId) {
|
|
|
295
299
|
const skillsPath = path.join(repoRoot, def.skillsDir);
|
|
296
300
|
const commandsPath = path.join(repoRoot, def.commandsDir);
|
|
297
301
|
|
|
298
|
-
const
|
|
299
|
-
|
|
302
|
+
const missingCommands = [];
|
|
303
|
+
if (exists(commandsAssetDir)) {
|
|
304
|
+
const bundledCommands = listDir(commandsAssetDir).filter((f) => !f.isDirectory() && f.name.endsWith('.md'));
|
|
305
|
+
for (const cmd of bundledCommands) {
|
|
306
|
+
const baseName = cmd.name.replace(/\.md$/, '');
|
|
307
|
+
if (!exists(path.join(commandsPath, `${baseName}${def.commandExt}`))) {
|
|
308
|
+
missingCommands.push(`${baseName}${def.commandExt}`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const missingSkills = [];
|
|
314
|
+
const staleSkills = [];
|
|
315
|
+
const deprecatedSkills = [];
|
|
316
|
+
if (exists(skillsAssetDir)) {
|
|
317
|
+
const bundledSkills = listDir(skillsAssetDir).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
318
|
+
for (const skillName of bundledSkills) {
|
|
319
|
+
const bundledFile = path.join(skillsAssetDir, skillName, 'SKILL.md');
|
|
320
|
+
const installedFile = path.join(skillsPath, skillName, 'SKILL.md');
|
|
321
|
+
if (!exists(installedFile)) {
|
|
322
|
+
missingSkills.push(skillName);
|
|
323
|
+
} else if (exists(bundledFile) && normalizeLf(readText(installedFile)) !== normalizeLf(readText(bundledFile))) {
|
|
324
|
+
staleSkills.push(skillName);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
for (const dep of DEPRECATED_SKILLS) {
|
|
328
|
+
if (exists(path.join(skillsPath, dep))) {
|
|
329
|
+
deprecatedSkills.push(dep);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const hasSkillsDir = exists(skillsPath) && listDir(skillsPath).length > 0;
|
|
335
|
+
const hasCommandsDir = exists(commandsPath) && listDir(commandsPath).length > 0;
|
|
336
|
+
const skillsOk = hasSkillsDir && missingSkills.length === 0 && staleSkills.length === 0 && deprecatedSkills.length === 0;
|
|
337
|
+
const commandsOk = hasCommandsDir && missingCommands.length === 0;
|
|
300
338
|
|
|
301
339
|
let status = 'pass';
|
|
302
340
|
let detail = `skills + commands installed (${def.commandsDir})`;
|
|
303
341
|
|
|
304
|
-
if (!
|
|
342
|
+
if (!hasSkillsDir && !hasCommandsDir) {
|
|
305
343
|
status = 'warn';
|
|
306
344
|
detail = 'missing skills and commands (run `asdlc init`)';
|
|
307
|
-
} else if (!
|
|
345
|
+
} else if (!hasSkillsDir) {
|
|
308
346
|
status = 'warn';
|
|
309
347
|
detail = `missing skills in ${def.skillsDir} (run 'asdlc init')`;
|
|
310
|
-
} else if (!
|
|
348
|
+
} else if (!hasCommandsDir) {
|
|
311
349
|
status = 'warn';
|
|
312
350
|
detail = `missing commands in ${def.commandsDir} (run 'asdlc init')`;
|
|
351
|
+
} else if (!skillsOk || !commandsOk) {
|
|
352
|
+
status = 'warn';
|
|
353
|
+
const reasons = [];
|
|
354
|
+
if (missingCommands.length > 0) reasons.push(`${missingCommands.length} missing command(s)`);
|
|
355
|
+
if (missingSkills.length > 0) reasons.push(`${missingSkills.length} missing skill(s)`);
|
|
356
|
+
if (staleSkills.length > 0) reasons.push(`${staleSkills.length} stale skill(s)`);
|
|
357
|
+
if (deprecatedSkills.length > 0) reasons.push(`${deprecatedSkills.length} deprecated skill(s)`);
|
|
358
|
+
detail = `stale or missing skills/commands (${reasons.join(', ')}; run 'asdlc update' or 'asdlc doctor --fix')`;
|
|
313
359
|
}
|
|
314
360
|
|
|
315
361
|
return {
|
|
@@ -319,5 +365,6 @@ export function checkToolHealth(repoRoot, toolId) {
|
|
|
319
365
|
detail,
|
|
320
366
|
skillsOk,
|
|
321
367
|
commandsOk,
|
|
368
|
+
drift: { missingCommands, missingSkills, staleSkills, deprecatedSkills },
|
|
322
369
|
};
|
|
323
370
|
}
|