all-for-claudecode 2.5.0 → 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 +2 -2
- package/.claude-plugin/plugin.json +4 -2
- package/README.md +15 -3
- package/agents/afc-architect.md +1 -1
- package/agents/afc-security.md +1 -1
- package/commands/analyze.md +1 -1
- package/commands/architect.md +1 -1
- package/commands/auto.md +2 -2
- package/commands/checkpoint.md +1 -1
- package/commands/clarify.md +1 -1
- package/commands/clean.md +126 -0
- package/commands/consult.md +1 -1
- package/commands/debug.md +1 -1
- package/commands/doctor.md +64 -23
- package/commands/ideate.md +1 -1
- package/commands/implement.md +1 -1
- package/commands/init.md +10 -6
- package/commands/launch.md +1 -1
- package/commands/plan.md +1 -1
- package/commands/pr-comment.md +1 -1
- package/commands/principles.md +1 -1
- package/commands/qa.md +191 -0
- package/commands/release-notes.md +1 -1
- package/commands/research.md +1 -1
- package/commands/resume.md +2 -2
- package/commands/review.md +1 -1
- package/commands/security.md +1 -1
- package/commands/spec.md +1 -1
- package/commands/tasks.md +1 -1
- package/commands/test.md +1 -1
- package/commands/triage.md +1 -1
- package/commands/validate.md +1 -1
- package/docs/phase-gate-protocol.md +1 -1
- package/hooks/hooks.json +1 -0
- package/package.json +5 -3
- package/schemas/hooks.schema.json +4 -0
- package/schemas/plugin.schema.json +5 -1
- package/scripts/afc-bash-guard.sh +3 -3
- package/scripts/afc-config-change.sh +8 -0
- package/scripts/afc-consistency-check.sh +58 -19
- package/scripts/afc-dag-validate.sh +1 -1
- package/scripts/afc-doctor.sh +445 -0
- package/scripts/afc-failure-hint.sh +24 -2
- package/scripts/afc-qa-audit.sh +536 -0
- package/scripts/afc-state.sh +3 -3
- package/scripts/afc-sync-cache.sh +49 -0
- package/scripts/afc-triage.sh +14 -3
- package/scripts/afc-user-prompt-submit.sh +98 -13
- package/scripts/pre-compact-checkpoint.sh +2 -2
- package/scripts/session-start-context.sh +39 -10
- package/scripts/track-afc-changes.sh +3 -3
package/commands/qa.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: afc:qa
|
|
3
|
+
description: "Project quality audit — use when the user asks for a quality audit, QA check, test confidence assessment, or wants to detect gaps in error handling and code health"
|
|
4
|
+
argument-hint: "[scope: all, tests, errors, coverage, or specific concern]"
|
|
5
|
+
user-invocable: true
|
|
6
|
+
context: fork
|
|
7
|
+
allowed-tools:
|
|
8
|
+
- Read
|
|
9
|
+
- Grep
|
|
10
|
+
- Glob
|
|
11
|
+
- Bash
|
|
12
|
+
model: sonnet
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# /afc:qa — Project Quality Audit
|
|
16
|
+
|
|
17
|
+
> Detects quality gaps between structural correctness and actual runtime behavior.
|
|
18
|
+
> **Read-only** — does not modify any files. Reports findings to console only.
|
|
19
|
+
|
|
20
|
+
## Arguments
|
|
21
|
+
|
|
22
|
+
- `$ARGUMENTS` — (optional) scope of audit. Defaults to `all`.
|
|
23
|
+
- `all` — run all 5 categories
|
|
24
|
+
- `tests` — category A only (Test Confidence)
|
|
25
|
+
- `errors` — category B only (Error Resilience)
|
|
26
|
+
- `coverage` — categories A + D (Test Confidence + API & Contract Safety)
|
|
27
|
+
- Or a free-form concern (e.g., "are error messages user-friendly", "check for dead exports")
|
|
28
|
+
|
|
29
|
+
## Config Load
|
|
30
|
+
|
|
31
|
+
**Always** read `.claude/afc.config.md` first. This file contains free-form markdown sections:
|
|
32
|
+
- `## Architecture` — architecture pattern, layers, import rules
|
|
33
|
+
- `## Code Style` — language, naming conventions, lint rules
|
|
34
|
+
- `## CI Commands` — test, lint, gate commands (YAML)
|
|
35
|
+
- `## Project Context` — framework, state management, testing strategy
|
|
36
|
+
|
|
37
|
+
If config file is missing: read `CLAUDE.md` for project info. Proceed without config if neither exists.
|
|
38
|
+
|
|
39
|
+
## Audit Categories
|
|
40
|
+
|
|
41
|
+
### A. Test Confidence
|
|
42
|
+
|
|
43
|
+
Evaluate whether the test suite actually catches regressions.
|
|
44
|
+
|
|
45
|
+
Checks:
|
|
46
|
+
- **Assertion density**: ratio of assertions to test functions (low ratio = weak tests)
|
|
47
|
+
- **Test-to-code ratio**: test LOC vs source LOC per layer (guided by `{config.architecture}`)
|
|
48
|
+
- **Mock overuse**: tests that mock so much they only test the mock setup
|
|
49
|
+
- **Runtime verification**: execute `{config.test}` and analyze output (pass/fail counts, skipped tests, timing)
|
|
50
|
+
- **Missing coverage**: source files/modules with zero test coverage
|
|
51
|
+
|
|
52
|
+
### B. Error Resilience
|
|
53
|
+
|
|
54
|
+
Evaluate whether errors are handled consistently and helpfully.
|
|
55
|
+
|
|
56
|
+
Checks:
|
|
57
|
+
- **Catch consistency**: unhandled promise rejections, empty catch blocks, swallowed errors
|
|
58
|
+
- **Error propagation**: errors that lose context through the call chain
|
|
59
|
+
- **User-facing messages**: cryptic error strings, raw stack traces exposed to users
|
|
60
|
+
- **Boundary validation**: missing input validation at API/CLI/form boundaries
|
|
61
|
+
- Apply `{config.code_style}` error handling rules if available
|
|
62
|
+
|
|
63
|
+
### C. Build & CI Integrity
|
|
64
|
+
|
|
65
|
+
Evaluate whether CI pipeline is healthy and reproducible.
|
|
66
|
+
|
|
67
|
+
Checks:
|
|
68
|
+
- **CI execution**: run `{config.ci}` and `{config.gate}` commands, verify they pass
|
|
69
|
+
- **Lock file integrity**: lock file present, consistent with manifest (package.json vs lock, etc.)
|
|
70
|
+
- **Unused dependencies**: declared but never imported packages
|
|
71
|
+
- **Build reproducibility**: environment-dependent paths, hardcoded secrets, missing env vars
|
|
72
|
+
|
|
73
|
+
### D. API & Contract Safety
|
|
74
|
+
|
|
75
|
+
Evaluate whether interfaces between modules are sound.
|
|
76
|
+
|
|
77
|
+
Checks:
|
|
78
|
+
- **Type mismatches**: function signatures vs actual usage at call sites
|
|
79
|
+
- **Dead exports**: exported symbols never imported elsewhere
|
|
80
|
+
- **Deprecated usage**: calls to deprecated APIs (internal or external)
|
|
81
|
+
- **Layer boundary violations**: imports that cross architecture boundaries (guided by `{config.architecture}`)
|
|
82
|
+
|
|
83
|
+
### E. Code Health Signals
|
|
84
|
+
|
|
85
|
+
Evaluate general code quality indicators.
|
|
86
|
+
|
|
87
|
+
Checks:
|
|
88
|
+
- **Complexity hotspots**: deeply nested logic, functions exceeding ~50 LOC
|
|
89
|
+
- **Duplication**: near-identical code blocks across files
|
|
90
|
+
- **Magic numbers/strings**: unexplained literals in logic
|
|
91
|
+
- **TODO/FIXME accumulation**: stale markers (count, age if git history available)
|
|
92
|
+
- Compare against `{config.code_style}` rules if available
|
|
93
|
+
|
|
94
|
+
## Execution Steps
|
|
95
|
+
|
|
96
|
+
### 1. Load Config
|
|
97
|
+
|
|
98
|
+
Read `.claude/afc.config.md` (or fallback to `CLAUDE.md`). Extract:
|
|
99
|
+
- Test command (`{config.test}`)
|
|
100
|
+
- CI/gate commands (`{config.ci}`, `{config.gate}`)
|
|
101
|
+
- Architecture layers (`{config.architecture}`)
|
|
102
|
+
- Code style rules (`{config.code_style}`)
|
|
103
|
+
|
|
104
|
+
### 2. Parse Scope
|
|
105
|
+
|
|
106
|
+
Interpret `$ARGUMENTS` to determine which categories to run:
|
|
107
|
+
|
|
108
|
+
| Argument | Categories |
|
|
109
|
+
|----------|-----------|
|
|
110
|
+
| `all` or empty | A, B, C, D, E |
|
|
111
|
+
| `tests` | A |
|
|
112
|
+
| `errors` | B |
|
|
113
|
+
| `coverage` | A, D |
|
|
114
|
+
| free-form text | best-matching subset |
|
|
115
|
+
|
|
116
|
+
### 3. Lightweight Runtime
|
|
117
|
+
|
|
118
|
+
Run commands that produce real output:
|
|
119
|
+
- `{config.test}` — capture pass/fail/skip counts and timing
|
|
120
|
+
- `{config.gate}` or `{config.ci}` — capture exit code and output
|
|
121
|
+
|
|
122
|
+
Only run commands that exist in config. Skip gracefully if not configured.
|
|
123
|
+
|
|
124
|
+
### 4. Codebase Scan
|
|
125
|
+
|
|
126
|
+
For each active category:
|
|
127
|
+
1. Use Glob to discover relevant files
|
|
128
|
+
2. Use Grep for pattern-based detection (empty catches, TODO markers, etc.)
|
|
129
|
+
3. Use Read for targeted inspection of flagged files
|
|
130
|
+
4. Cross-reference findings against `{config.architecture}` layer structure
|
|
131
|
+
|
|
132
|
+
### 5. Critic Loop
|
|
133
|
+
|
|
134
|
+
Apply `docs/critic-loop-rules.md` with **safety cap: 3 rounds**.
|
|
135
|
+
|
|
136
|
+
Focus the critic on:
|
|
137
|
+
- Are the findings actionable or just noise?
|
|
138
|
+
- Did I miss obvious quality gaps?
|
|
139
|
+
- Are severity ratings justified by evidence?
|
|
140
|
+
|
|
141
|
+
### 6. Console Report
|
|
142
|
+
|
|
143
|
+
Output the final report in this format:
|
|
144
|
+
|
|
145
|
+
```markdown
|
|
146
|
+
## QA Audit: {project name or directory}
|
|
147
|
+
|
|
148
|
+
### Category A: Test Confidence
|
|
149
|
+
{findings with file:line references}
|
|
150
|
+
Verdict: PASS | WARN | FAIL
|
|
151
|
+
|
|
152
|
+
### Category B: Error Resilience
|
|
153
|
+
{findings with file:line references}
|
|
154
|
+
Verdict: PASS | WARN | FAIL
|
|
155
|
+
|
|
156
|
+
### Category C: Build & CI Integrity
|
|
157
|
+
{findings with file:line references}
|
|
158
|
+
Verdict: PASS | WARN | FAIL
|
|
159
|
+
|
|
160
|
+
### Category D: API & Contract Safety
|
|
161
|
+
{findings with file:line references}
|
|
162
|
+
Verdict: PASS | WARN | FAIL
|
|
163
|
+
|
|
164
|
+
### Category E: Code Health Signals
|
|
165
|
+
{findings with file:line references}
|
|
166
|
+
Verdict: PASS | WARN | FAIL
|
|
167
|
+
|
|
168
|
+
### Summary
|
|
169
|
+
├─ A: Test Confidence — {PASS|WARN|FAIL} {(N issues) if any}
|
|
170
|
+
├─ B: Error Resilience — {PASS|WARN|FAIL} {(N issues) if any}
|
|
171
|
+
├─ C: Build & CI — {PASS|WARN|FAIL} {(N issues) if any}
|
|
172
|
+
├─ D: API & Contract — {PASS|WARN|FAIL} {(N issues) if any}
|
|
173
|
+
└─ E: Code Health — {PASS|WARN|FAIL} {(N issues) if any}
|
|
174
|
+
|
|
175
|
+
Total: {N} PASS, {N} WARN, {N} FAIL
|
|
176
|
+
Priority fixes: {top 3 most impactful issues}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Verdict Criteria
|
|
180
|
+
|
|
181
|
+
- **PASS** — no issues found, or only cosmetic observations
|
|
182
|
+
- **WARN** — issues found but not blocking; quality could degrade over time
|
|
183
|
+
- **FAIL** — critical gaps that likely cause bugs, outages, or security issues
|
|
184
|
+
|
|
185
|
+
## Notes
|
|
186
|
+
|
|
187
|
+
- **Read-only**: Do not modify any files. Report only.
|
|
188
|
+
- **Evidence-based**: Every finding must include a `file:line` reference or command output.
|
|
189
|
+
- **Config-aware**: Adapt checks to the project's declared architecture and conventions.
|
|
190
|
+
- **Scope discipline**: Only run categories matching the requested scope.
|
|
191
|
+
- **Not a linter**: Focus on semantic quality gaps that automated tools miss.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:release-notes
|
|
3
|
-
description: "Generate user-facing release notes from git history"
|
|
3
|
+
description: "Generate user-facing release notes from git history — use when the user asks to write release notes, summarize changes between versions, or generate a changelog"
|
|
4
4
|
argument-hint: "[v1.0.0..v2.0.0 | v2.0.0 | --post]"
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
package/commands/research.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:research
|
|
3
|
-
description: "Technical research"
|
|
3
|
+
description: "Technical research — use when the user asks to research a topic, investigate a technology, compare libraries, or explore options before deciding"
|
|
4
4
|
argument-hint: "[research topic]"
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
package/commands/resume.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:resume
|
|
3
|
-
description: "Restore session"
|
|
3
|
+
description: "Restore session — use when the user asks to resume a previous session, restore saved state, or continue where they left off"
|
|
4
4
|
argument-hint: "[no arguments]"
|
|
5
5
|
model: haiku
|
|
6
6
|
allowed-tools:
|
|
@@ -22,7 +22,7 @@ allowed-tools:
|
|
|
22
22
|
### 1. Load Checkpoint
|
|
23
23
|
|
|
24
24
|
Read `.claude/afc/memory/checkpoint.md`:
|
|
25
|
-
- If not found: check **auto-memory fallback** — read `~/.claude/projects/{ENCODED_PATH}/
|
|
25
|
+
- If not found: check **auto-memory fallback** — read `~/.claude/projects/{ENCODED_PATH}/memory/checkpoint.md` (where `ENCODED_PATH` = project path with `/` replaced by `-`):
|
|
26
26
|
- If fallback found: use it as the checkpoint source (auto-memory is written by `pre-compact-checkpoint.sh` during context compaction)
|
|
27
27
|
- If fallback also not found: output "No saved checkpoint found. Use `/afc:checkpoint` to create one, or checkpoints are created automatically on context compaction." then **stop**
|
|
28
28
|
- If found: parse the full contents (extract branch, commit hash, pipeline feature, task progress, modified files)
|
package/commands/review.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:review
|
|
3
|
-
description: "Code review"
|
|
3
|
+
description: "Code review — use when the user asks to review code, analyze a PR diff, do a code review, or evaluate code quality and correctness"
|
|
4
4
|
argument-hint: "[scope: file path, PR number, or staged]"
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
package/commands/security.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:security
|
|
3
|
-
description: "Security scan (read-only)"
|
|
3
|
+
description: "Security scan (read-only) — use when the user asks for a security scan, security review, vulnerability check, or threat assessment"
|
|
4
4
|
argument-hint: "[scan scope: file/directory path or full]"
|
|
5
5
|
context: fork
|
|
6
6
|
agent: afc-security
|
package/commands/spec.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:spec
|
|
3
|
-
description: "Generate feature specification"
|
|
3
|
+
description: "Generate feature specification — use when the user asks to write a spec, define requirements, create acceptance criteria, or specify a feature"
|
|
4
4
|
argument-hint: "[feature description in natural language]"
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
package/commands/tasks.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:tasks
|
|
3
|
-
description: "Task decomposition"
|
|
3
|
+
description: "Task decomposition — auto-invoked during implement phase to break down plan into executable tasks with dependency tracking"
|
|
4
4
|
argument-hint: "[constraints/priority directives]"
|
|
5
5
|
user-invocable: false
|
|
6
6
|
allowed-tools:
|
package/commands/test.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:test
|
|
3
|
-
description: "Test strategy planning and test writing"
|
|
3
|
+
description: "Test strategy planning and test writing — use when the user asks to write tests, add test coverage, improve coverage, create unit/integration/e2e tests, or plan a testing strategy"
|
|
4
4
|
argument-hint: "[target: file path, feature name, or coverage]"
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
package/commands/triage.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:triage
|
|
3
|
-
description: "Parallel triage of open PRs and issues"
|
|
3
|
+
description: "Parallel triage of open PRs and issues — use when the user asks to triage PRs, review open issues, or prioritize the backlog of pull requests and issues"
|
|
4
4
|
argument-hint: "[scope: --pr, --issue, --all (default), or specific numbers]"
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
package/commands/validate.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:validate
|
|
3
|
-
description: "Artifact consistency validation (read-only)"
|
|
3
|
+
description: "Artifact consistency validation (read-only) — auto-invoked to verify spec, plan, and task artifacts are consistent with each other"
|
|
4
4
|
argument-hint: "[validation scope: spec-plan, tasks-only]"
|
|
5
5
|
user-invocable: false
|
|
6
6
|
context: fork
|
|
@@ -34,7 +34,7 @@ Quantitatively inspect changed files within the Phase against `{config.code_styl
|
|
|
34
34
|
After passing the Phase gate, automatically save session state:
|
|
35
35
|
|
|
36
36
|
1. Create `.claude/afc/memory/` directory if it does not exist
|
|
37
|
-
2. Write/update `.claude/afc/memory/checkpoint.md` **and** `~/.claude/projects/{ENCODED_PATH}/
|
|
37
|
+
2. Write/update `.claude/afc/memory/checkpoint.md` **and** `~/.claude/projects/{ENCODED_PATH}/memory/checkpoint.md` (dual-write for compaction resilience — `ENCODED_PATH` = project path with `/` replaced by `-`):
|
|
38
38
|
|
|
39
39
|
```markdown
|
|
40
40
|
# Phase Gate Checkpoint
|
package/hooks/hooks.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "all-for-claudecode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Claude Code plugin that automates the full dev cycle — spec, plan, implement, review, clean.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"all-for-claudecode": "bin/cli.mjs"
|
|
@@ -35,9 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"lint": "shellcheck -x --source-path=scripts --severity=warning scripts/*.sh && bash scripts/afc-schema-validate.sh --all && bash scripts/afc-consistency-check.sh",
|
|
38
|
+
"qa": "bash scripts/afc-qa-audit.sh",
|
|
38
39
|
"test": "vendor/shellspec/shellspec",
|
|
39
|
-
"test:all": "npm run lint && npm run test",
|
|
40
|
-
"setup:test": "bash scripts/install-shellspec.sh"
|
|
40
|
+
"test:all": "npm run lint && npm run qa && npm run test",
|
|
41
|
+
"setup:test": "bash scripts/install-shellspec.sh",
|
|
42
|
+
"sync:cache": "bash scripts/afc-sync-cache.sh"
|
|
41
43
|
},
|
|
42
44
|
"engines": {
|
|
43
45
|
"node": ">=18"
|
|
@@ -45,9 +45,13 @@
|
|
|
45
45
|
"type": "string",
|
|
46
46
|
"description": "Path to commands directory"
|
|
47
47
|
},
|
|
48
|
+
"agents": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Path to agents directory"
|
|
51
|
+
},
|
|
48
52
|
"hooks": {
|
|
49
53
|
"type": "string",
|
|
50
|
-
"description": "Path to hooks
|
|
54
|
+
"description": "Path to hooks configuration file"
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -14,15 +14,15 @@ cleanup() {
|
|
|
14
14
|
}
|
|
15
15
|
trap cleanup EXIT
|
|
16
16
|
|
|
17
|
+
# Consume stdin immediately (prevents SIGPIPE if exiting early)
|
|
18
|
+
INPUT=$(cat)
|
|
19
|
+
|
|
17
20
|
# If pipeline is inactive -> allow
|
|
18
21
|
if ! afc_state_is_active; then
|
|
19
22
|
printf '{"hookSpecificOutput":{"permissionDecision":"allow"}}\n'
|
|
20
23
|
exit 0
|
|
21
24
|
fi
|
|
22
25
|
|
|
23
|
-
# Parse tool input from stdin
|
|
24
|
-
INPUT=$(cat)
|
|
25
|
-
|
|
26
26
|
# If stdin is empty -> allow
|
|
27
27
|
if [ -z "$INPUT" ]; then
|
|
28
28
|
printf '{"hookSpecificOutput":{"permissionDecision":"allow"}}\n'
|
|
@@ -48,6 +48,14 @@ FILE_PATH=$(printf '%s' "$FILE_PATH" | head -1 | tr -d '\n\r' | cut -c1-500)
|
|
|
48
48
|
|
|
49
49
|
TIMESTAMP="$(date '+%Y-%m-%d %H:%M:%S')"
|
|
50
50
|
|
|
51
|
+
# Auto-rotate if audit log exceeds 1 MB
|
|
52
|
+
if [ -f "$AUDIT_LOG" ]; then
|
|
53
|
+
LOG_SIZE=$(wc -c < "$AUDIT_LOG" | tr -d ' ')
|
|
54
|
+
if [ "$LOG_SIZE" -ge 1048576 ]; then
|
|
55
|
+
mv "$AUDIT_LOG" "${AUDIT_LOG}.1"
|
|
56
|
+
fi
|
|
57
|
+
fi
|
|
58
|
+
|
|
51
59
|
# policy_settings changes are logged only (not blocked)
|
|
52
60
|
if [ "$SOURCE" = "policy_settings" ]; then
|
|
53
61
|
printf '[%s] source=%s path=%s\n' "$TIMESTAMP" "$SOURCE" "$FILE_PATH" >> "$AUDIT_LOG"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
4
|
# afc-consistency-check.sh — Cross-reference validation for project consistency
|
|
5
|
-
# Checks: config placeholders, agent names, hook scripts, test coverage
|
|
5
|
+
# Checks: config placeholders, agent names, hook scripts, test coverage, command docs
|
|
6
6
|
# Run as part of: npm run lint
|
|
7
7
|
|
|
8
8
|
# shellcheck disable=SC2329
|
|
@@ -32,6 +32,15 @@ ok() {
|
|
|
32
32
|
printf "[afc:consistency] ✓ %s\n" "$1"
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
# Extract a field value from command file YAML frontmatter
|
|
36
|
+
get_cmd_field() {
|
|
37
|
+
local file="$1" field="$2"
|
|
38
|
+
awk '/^---$/{n++; next} n==1{print} n>=2{exit}' "$file" \
|
|
39
|
+
| grep "^${field}:" \
|
|
40
|
+
| sed "s/^${field}:[[:space:]]*//" \
|
|
41
|
+
| tr -d '"' | head -1 || true
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
# --- Check 1: Config Placeholder Validation ---
|
|
36
45
|
# Verify all {config.*} references in commands/ and docs/ map to known config keys
|
|
37
46
|
|
|
@@ -240,30 +249,59 @@ check_phase_ssot() {
|
|
|
240
249
|
fi
|
|
241
250
|
done
|
|
242
251
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
252
|
+
if [ "$issues" -eq 0 ]; then
|
|
253
|
+
ok "Phase SSOT: no hardcoded phase lists in scripts"
|
|
254
|
+
fi
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
# --- Check 7: Command Documentation Cross-Reference ---
|
|
258
|
+
# Verify commands are documented in README.md, init.md, and CLAUDE.md
|
|
259
|
+
|
|
260
|
+
check_command_docs() {
|
|
247
261
|
local commands_dir="$PROJECT_DIR/commands"
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
262
|
+
[ -d "$commands_dir" ] || return
|
|
263
|
+
|
|
264
|
+
local readme="$PROJECT_DIR/README.md"
|
|
265
|
+
local init_cmd="$commands_dir/init.md"
|
|
266
|
+
local claude_md="$PROJECT_DIR/CLAUDE.md"
|
|
267
|
+
local issues=0
|
|
268
|
+
|
|
269
|
+
for cmd_file in "$commands_dir"/*.md; do
|
|
270
|
+
[ -f "$cmd_file" ] || continue
|
|
271
|
+
local cmd_name
|
|
272
|
+
cmd_name=$(basename "$cmd_file" .md)
|
|
273
|
+
|
|
274
|
+
# Sub-check A: README.md should mention /afc:{name}
|
|
275
|
+
if [ -f "$readme" ]; then
|
|
276
|
+
if ! grep -qE "/afc:${cmd_name}([^a-z0-9-]|$)" "$readme" 2>/dev/null; then
|
|
277
|
+
warn "Command '$cmd_name' missing from README.md command table"
|
|
278
|
+
issues=$((issues + 1))
|
|
256
279
|
fi
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
280
|
+
fi
|
|
281
|
+
|
|
282
|
+
# Sub-check B: init.md should mention afc:{name} for user-invocable commands
|
|
283
|
+
local invocable
|
|
284
|
+
invocable=$(get_cmd_field "$cmd_file" "user-invocable")
|
|
285
|
+
if [ "$invocable" != "false" ] && [ -f "$init_cmd" ]; then
|
|
286
|
+
if ! grep -qE "afc:${cmd_name}([^a-z0-9-]|$)" "$init_cmd" 2>/dev/null; then
|
|
287
|
+
warn "Command '$cmd_name' missing from init.md skill routing"
|
|
260
288
|
issues=$((issues + 1))
|
|
261
289
|
fi
|
|
262
|
-
|
|
263
|
-
|
|
290
|
+
fi
|
|
291
|
+
|
|
292
|
+
# Sub-check C: CLAUDE.md fork list for context:fork commands
|
|
293
|
+
local ctx
|
|
294
|
+
ctx=$(get_cmd_field "$cmd_file" "context")
|
|
295
|
+
if [ "$ctx" = "fork" ] && [ -f "$claude_md" ]; then
|
|
296
|
+
if ! grep "context: fork" "$claude_md" 2>/dev/null | grep -qE "([(, ])${cmd_name}([,) ]|$)"; then
|
|
297
|
+
warn "Command '$cmd_name' (context:fork) missing from CLAUDE.md fork list"
|
|
298
|
+
issues=$((issues + 1))
|
|
299
|
+
fi
|
|
300
|
+
fi
|
|
301
|
+
done
|
|
264
302
|
|
|
265
303
|
if [ "$issues" -eq 0 ]; then
|
|
266
|
-
ok "
|
|
304
|
+
ok "Command docs: all commands referenced in README.md, init.md, CLAUDE.md"
|
|
267
305
|
fi
|
|
268
306
|
}
|
|
269
307
|
|
|
@@ -277,6 +315,7 @@ check_hook_scripts
|
|
|
277
315
|
check_test_coverage
|
|
278
316
|
check_version_sync
|
|
279
317
|
check_phase_ssot
|
|
318
|
+
check_command_docs
|
|
280
319
|
|
|
281
320
|
printf "\n[afc:consistency] Done: %d errors, %d warnings\n" "$ERRORS" "$WARNINGS"
|
|
282
321
|
|
|
@@ -100,7 +100,7 @@ dfs_check() {
|
|
|
100
100
|
if [ "$color" = "0" ]; then
|
|
101
101
|
printf '1' > "$color_file"
|
|
102
102
|
|
|
103
|
-
neighbors="$(grep -E "^${current}
|
|
103
|
+
neighbors="$(grep -E "^${current} " "$EDGES_FILE" | cut -f2 || true)"
|
|
104
104
|
if [ -n "$neighbors" ]; then
|
|
105
105
|
while IFS= read -r neighbor; do
|
|
106
106
|
[ -z "$neighbor" ] && continue
|