knowzcode 0.3.6 → 0.4.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.
Files changed (79) hide show
  1. package/.claude-plugin/marketplace.json +61 -61
  2. package/.claude-plugin/plugin.json +8 -8
  3. package/LICENSE +121 -121
  4. package/README.md +354 -320
  5. package/agents/analyst.md +114 -114
  6. package/agents/architect.md +200 -200
  7. package/agents/builder.md +104 -104
  8. package/agents/closer.md +177 -95
  9. package/agents/context-scout.md +54 -54
  10. package/agents/knowledge-migrator.md +349 -349
  11. package/agents/knowz-scout.md +83 -83
  12. package/agents/knowz-scribe.md +180 -180
  13. package/agents/microfix-specialist.md +135 -135
  14. package/agents/project-advisor.md +111 -111
  15. package/agents/reviewer.md +172 -172
  16. package/agents/security-officer.md +194 -194
  17. package/agents/test-advisor.md +162 -162
  18. package/agents/update-coordinator.md +394 -394
  19. package/bin/knowzcode.mjs +1199 -956
  20. package/commands/audit.md +328 -328
  21. package/commands/connect-mcp.md +549 -549
  22. package/commands/fix.md +107 -107
  23. package/commands/init.md +500 -439
  24. package/commands/learn.md +332 -332
  25. package/commands/plan.md +272 -272
  26. package/commands/register.md +733 -733
  27. package/commands/status.md +309 -309
  28. package/commands/telemetry-setup.md +368 -368
  29. package/commands/telemetry.md +188 -188
  30. package/commands/work.md +1204 -1170
  31. package/knowzcode/automation_manifest.md +59 -59
  32. package/knowzcode/claude_code_execution.md +431 -420
  33. package/knowzcode/copilot_execution.md +231 -231
  34. package/knowzcode/enterprise/compliance_manifest.md +137 -137
  35. package/knowzcode/enterprise/compliance_status.md +30 -30
  36. package/knowzcode/enterprise/guidelines/code-quality.md +67 -67
  37. package/knowzcode/enterprise/guidelines/security.md +355 -355
  38. package/knowzcode/enterprise/templates/guideline-template.md +55 -55
  39. package/knowzcode/gitignore.template +13 -13
  40. package/knowzcode/knowzcode_architecture.md +51 -51
  41. package/knowzcode/knowzcode_log.md +142 -142
  42. package/knowzcode/knowzcode_loop.md +596 -593
  43. package/knowzcode/knowzcode_orchestration.md +66 -66
  44. package/knowzcode/knowzcode_project.md +48 -48
  45. package/knowzcode/knowzcode_tracker.md +40 -40
  46. package/knowzcode/knowzcode_vaults.md +257 -257
  47. package/knowzcode/mcp_config.md +191 -191
  48. package/knowzcode/planning/Readme.md +6 -6
  49. package/knowzcode/platform_adapters.md +1260 -1047
  50. package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
  51. package/knowzcode/prompts/Investigate_Codebase.md +227 -227
  52. package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
  53. package/knowzcode/prompts/Refactor_Node.md +72 -72
  54. package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
  55. package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
  56. package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
  57. package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
  58. package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
  59. package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
  60. package/knowzcode/specs/Readme.md +10 -10
  61. package/knowzcode/telemetry_config.md +89 -89
  62. package/knowzcode/user_preferences.md +120 -120
  63. package/package.json +53 -53
  64. package/skills/alias-resolver.json +15 -15
  65. package/skills/architecture-diff.json +12 -12
  66. package/skills/check-installation-status.json +14 -14
  67. package/skills/continue.md +126 -126
  68. package/skills/environment-guard.json +12 -12
  69. package/skills/generate-workgroup-id.json +25 -25
  70. package/skills/install-knowzcode.json +21 -21
  71. package/skills/load-core-context.json +18 -18
  72. package/skills/log-entry-builder.json +15 -15
  73. package/skills/spec-quality-check.json +14 -14
  74. package/skills/spec-template.json +15 -15
  75. package/skills/spec-validator.json +25 -25
  76. package/skills/start-work.md +224 -224
  77. package/skills/tracker-scan.json +12 -12
  78. package/skills/tracker-update.json +28 -28
  79. package/skills/validate-installation.json +14 -14
package/commands/audit.md CHANGED
@@ -1,328 +1,328 @@
1
- ---
2
- description: "Run KnowzCode quality audits (spec, architecture, security, integration, compliance)"
3
- argument-hint: "[audit_type]"
4
- ---
5
-
6
- # Run KnowzCode Audit
7
-
8
- Run specialized audit workflows.
9
-
10
- **Usage**: `/kc:audit [audit_type]`
11
- **Example**: `/kc:audit spec` or `/kc:audit security`
12
-
13
- **Audit Type**: $ARGUMENTS
14
-
15
- ---
16
-
17
- ## Audit Types
18
-
19
- | Type | Focus |
20
- |------|-------|
21
- | **spec** | Specification quality and completeness |
22
- | **architecture** | Architecture health and drift |
23
- | **security** | OWASP vulnerability scanning |
24
- | **integration** | Cross-component consistency |
25
- | **compliance** | Enterprise guideline compliance (if configured, experimental) |
26
- | *(no argument)* | Full parallel audit of all types |
27
-
28
- ---
29
-
30
- ## Step 1: Load Context
31
-
32
- Read:
33
- - `knowzcode/knowzcode_tracker.md`
34
- - `knowzcode/knowzcode_architecture.md`
35
- - `knowzcode/knowzcode_project.md`
36
- - `knowzcode/knowzcode_orchestration.md` (if exists)
37
-
38
- ## Step 1.1: Parse Orchestration Config (Optional)
39
-
40
- If `knowzcode/knowzcode_orchestration.md` exists, parse its YAML blocks:
41
-
42
- 1. `SCOUT_MODE` = `scout_mode` value (default: "full")
43
- 2. `DEFAULT_SPECIALISTS` = `default_specialists` value (default: [])
44
- 3. `MCP_AGENTS_ENABLED` = `mcp_agents_enabled` value (default: true)
45
-
46
- Apply flag overrides (flags win over config):
47
- - `--no-scouts` in `$ARGUMENTS` → override `SCOUT_MODE = "none"`
48
- - `--no-specialists` in `$ARGUMENTS` → override `DEFAULT_SPECIALISTS = []`
49
- - `--no-mcp` in `$ARGUMENTS` → override `MCP_AGENTS_ENABLED = false`
50
-
51
- If the file doesn't exist, use hardcoded defaults (current behavior).
52
-
53
- ## Step 2: Set Up Execution Mode
54
-
55
- Attempt `TeamCreate(team_name="kc-audit-{timestamp}")`:
56
-
57
- - **If TeamCreate succeeds** → Agent Teams mode:
58
- 1. Announce: `**Execution Mode: Agent Teams** — created team kc-audit-{timestamp}`
59
- 2. Read `knowzcode/claude_code_execution.md` for team conventions.
60
- 3. You are the **team lead** — coordinate the audit and present results.
61
-
62
- - **If TeamCreate fails** (error, unrecognized tool, timeout) → Subagent Delegation:
63
- - Announce: `**Execution Mode: Subagent Delegation** — Agent Teams not available, using Task() fallback`
64
-
65
- The user MUST see the execution mode announcement before audit work begins.
66
-
67
- ## Step 3: Execute Audit
68
-
69
- ### MCP Probe
70
-
71
- Before spawning agents, determine vault availability:
72
- 1. Read `knowzcode/knowzcode_vaults.md` — partition entries into CONFIGURED (non-empty ID) and UNCREATED (empty ID)
73
- 2. Call `list_vaults(includeStats=true)` **always** — regardless of whether any IDs exist in the file
74
- 3. If `list_vaults()` fails → set `MCP_ACTIVE = false`, announce `**MCP Status: Not connected**`, skip vault setup
75
- 4. If `list_vaults()` succeeds AND UNCREATED list is non-empty → present the **Vault Creation Prompt**:
76
-
77
- ```markdown
78
- ## Vault Setup
79
-
80
- Your Knowz API key is valid and MCP is connected, but {N} default vault(s) haven't been created yet.
81
- Creating vaults enables knowledge capture throughout the workflow:
82
-
83
- | Vault | Type | Description | Written During |
84
- |-------|------|-------------|----------------|
85
- ```
86
-
87
- Build table rows dynamically from the UNCREATED entries only. Derive "Written During" from each vault's Write Conditions field in `knowzcode_vaults.md`.
88
-
89
- Then present options:
90
- ```
91
- Options:
92
- **A) Create all {N} vaults** (recommended)
93
- **B) Select which to create**
94
- **C) Skip** — proceed without vaults (can create later with `/kc:connect-mcp --configure-vaults`)
95
- ```
96
-
97
- 5. Handle user selection:
98
- - **A**: For each UNCREATED entry, call MCP `create_vault(name, description)`. If `create_vault` is not available, fall back to matching by name against `list_vaults()` results. Update `knowzcode_vaults.md`: fill ID field, change H3 heading from `(not created)` to vault ID. Report any failures.
99
- - **B**: Ask which vaults to create, then create only selected ones.
100
- - **C**: Log `"Vault creation skipped — knowledge capture disabled."` Continue.
101
- 6. After resolution, set:
102
- - `MCP_ACTIVE = true` (MCP works regardless of vault creation outcome)
103
- - `VAULTS_CONFIGURED = true` if at least 1 vault now has a valid ID, else `false`
104
- - Announce: `**MCP Status: Connected — N vault(s) available**` or `**MCP Status: Connected — no vaults configured (knowledge capture disabled)**`
105
-
106
- ### Agent Teams Mode
107
-
108
- #### Specific Audit Type (argument provided)
109
-
110
- `TaskCreate("Audit: {audit_type}")` → `TaskUpdate(owner: "reviewer")`.
111
-
112
- Spawn a single `reviewer` teammate:
113
- > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
114
- > You are the **reviewer** running a {audit_type} audit.
115
- > Read `agents/reviewer.md` for your role definition.
116
- > Read `knowzcode/claude_code_execution.md` for team conventions.
117
- >
118
- > **Audit scope**: {audit_type}
119
- > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
120
- > **Specs directory**: knowzcode/specs/
121
- >
122
- > Deliverable: Audit report with health scores, critical issues, recommendations.
123
-
124
- Wait for completion. Shut down teammate. Clean up the team.
125
-
126
- The reviewer focuses on the requested type with type-specific depth:
127
- - **spec**: Validates 4-section format, VERIFY statement count, consolidation opportunities
128
- - **architecture**: Checks layer violations, drift, pattern consistency
129
- - **security**: OWASP Top 10 scanning with concrete detection patterns
130
- - **integration**: API contracts, dependency graph, orphaned code, data flow
131
- - **compliance**: Enterprise guideline enforcement levels
132
-
133
- #### Full Audit (no argument — DEFAULT)
134
-
135
- Create tasks first, pre-assign, then spawn with task IDs:
136
- - `TaskCreate("Audit: spec + architecture")` → `TaskUpdate(owner: "reviewer-spec-arch")`
137
- - `TaskCreate("Audit: security + integration")` → `TaskUpdate(owner: "reviewer-sec-int")`
138
- - (Optional) `TaskCreate("Audit: compliance")` → `TaskUpdate(owner: "reviewer-compliance")` (if enterprise configured)
139
- - `TaskCreate("Scout: vault standards")` → `TaskUpdate(owner: "knowz-scout")` (if `VAULTS_CONFIGURED = true`)
140
-
141
- Spawn reviewers with their task IDs:
142
-
143
- 1. Spawn `reviewer` teammate (name: `reviewer-spec-arch`):
144
- > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
145
- > You are the **reviewer** running a targeted audit.
146
- > Read `agents/reviewer.md` for your role definition.
147
- > Read `knowzcode/claude_code_execution.md` for team conventions.
148
- >
149
- > **Audit scope**: Specification quality AND architecture health ONLY.
150
- > Do NOT audit security or integration — another reviewer handles those.
151
- > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
152
- > **Specs directory**: knowzcode/specs/
153
- >
154
- > Deliverable: Audit report with spec quality scores, architecture health, critical issues.
155
-
156
- 2. Spawn `reviewer` teammate (name: `reviewer-sec-int`):
157
- > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
158
- > You are the **reviewer** running a targeted audit.
159
- > Read `agents/reviewer.md` for your role definition.
160
- > Read `knowzcode/claude_code_execution.md` for team conventions.
161
- >
162
- > **Audit scope**: Security vulnerability scan AND integration consistency ONLY.
163
- > Do NOT audit specs or architecture — another reviewer handles those.
164
- > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
165
- > **Specs directory**: knowzcode/specs/
166
- >
167
- > Deliverable: Audit report with security posture, integration health, critical issues.
168
-
169
- 3. (Optional) If enterprise compliance configured, spawn `reviewer` (name: `reviewer-compliance`):
170
- > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
171
- > **Audit scope**: Enterprise compliance ONLY.
172
- > Check against guidelines in `knowzcode/enterprise/compliance_manifest.md`.
173
-
174
- 4. If `VAULTS_CONFIGURED = true` AND `MCP_AGENTS_ENABLED = true`, spawn `knowz-scout` for standards lookup in parallel with reviewers:
175
- > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
176
- > Read `knowzcode/knowzcode_vaults.md` to resolve vault IDs by type. Query for team standards: `ask_question({vault matching "ecosystem" type}, "standards for {project_type}", researchMode=true)`
177
-
178
- Wait for all to complete.
179
-
180
- #### Specialist Integration (Optional)
181
-
182
- Initialize `AUDIT_SPECIALISTS = DEFAULT_SPECIALISTS` (from orchestration config, default: []).
183
-
184
- If `$ARGUMENTS` contains `--specialists` (or `--specialists=security`, `--specialists=test`, `--specialists=security,test`):
185
- - `--specialists` → enable all applicable: `[security-officer, test-advisor]`
186
- - `--specialists=csv` → enable specified subset
187
- - `--no-specialists` → clear to `[]` (overrides config defaults)
188
-
189
- If neither `--specialists` nor `--no-specialists` is present, use `DEFAULT_SPECIALISTS` from config.
190
-
191
- Parse which specialists to enable. Then spawn alongside reviewers:
192
-
193
- 1. **security-officer** (if enabled) — spawn alongside `reviewer-sec-int` for deeper security scanning:
194
- - `TaskCreate("Security officer: deep security audit")` → `TaskUpdate(owner: "security-officer")`
195
- - Spawn `security-officer` teammate:
196
- > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
197
- > You are the **security-officer** running a deep security audit.
198
- > Read `agents/security-officer.md` for your role definition.
199
- > Read `knowzcode/claude_code_execution.md` for team conventions.
200
- >
201
- > **Audit scope**: Full codebase security scan — vulnerability patterns, hardcoded secrets, injection vectors, auth bypass, SSRF, path traversal.
202
- > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
203
- > **Specs directory**: knowzcode/specs/
204
- >
205
- > Deliverable: Security finding report with severity ratings. Tag CRITICAL/HIGH findings with `[SECURITY-BLOCK]`.
206
- > If `knowzcode/enterprise/compliance_manifest.md` exists and `compliance_enabled: true`, also cross-reference findings with enterprise guideline IDs.
207
-
208
- 2. **test-advisor** (if enabled) — spawn alongside reviewers for test quality assessment:
209
- - `TaskCreate("Test advisor: test quality audit")` → `TaskUpdate(owner: "test-advisor")`
210
- - Spawn `test-advisor` teammate:
211
- > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
212
- > You are the **test-advisor** running a test quality audit.
213
- > Read `agents/test-advisor.md` for your role definition.
214
- > Read `knowzcode/claude_code_execution.md` for team conventions.
215
- >
216
- > **Audit scope**: Test coverage, TDD compliance, assertion quality, edge case coverage, test isolation.
217
- > **Context files**: knowzcode_tracker.md, knowzcode_project.md
218
- >
219
- > Deliverable: Test quality report with coverage metrics, TDD compliance, and improvement recommendations.
220
- > If `knowzcode/enterprise/compliance_manifest.md` exists and `compliance_enabled: true`, also check enterprise ARC criteria for test coverage.
221
-
222
- Wait for all reviewers and specialists to complete. Synthesize results in Step 4.
223
-
224
- ### Subagent Mode
225
-
226
- #### Specific Audit Type
227
-
228
- Launch scouts + reviewer in parallel via `Task()`:
229
-
230
- 1. **context-scout** — Local context (if `SCOUT_MODE != "none"`):
231
- - `SCOUT_MODE = "full"` (default): 3 parallel instances:
232
- - `Task(subagent_type="context-scout", name="context-scout-specs", description="Scout: specs context", prompt="Research audit scope: {audit_type}. Focus: knowzcode/specs/*.md — scan existing specifications for relevant NodeIDs, status, VERIFY criteria. Max 10 tool calls. Write findings to a concise summary.")`
233
- - `Task(subagent_type="context-scout", name="context-scout-workgroups", description="Scout: workgroups context", prompt="Research audit scope: {audit_type}. Focus: knowzcode/workgroups/*.md — scan previous WorkGroups for related audit findings. Max 10 tool calls. Write findings to a concise summary.")`
234
- - `Task(subagent_type="context-scout", name="context-scout-backlog", description="Scout: backlog context", prompt="Research audit scope: {audit_type}. Focus: knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md — scan for active WIP, prior audit results, architecture health. Max 10 tool calls. Write findings to a concise summary.")`
235
- - `SCOUT_MODE = "minimal"`: 1 combined instance:
236
- - `Task(subagent_type="context-scout", name="context-scout", description="Scout: combined context", prompt="Research audit scope: {audit_type}. Focus: ALL local context — knowzcode/specs/*.md, knowzcode/workgroups/*.md, knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md. Max 10 tool calls. Write findings to a concise summary.")`
237
-
238
- 2. **knowz-scout** — MCP knowledge (if `VAULTS_CONFIGURED = true` AND `MCP_AGENTS_ENABLED = true`):
239
- - `Task(subagent_type="knowz-scout", description="Scout: vault standards", prompt="Research audit scope: {audit_type}. Read knowzcode/knowzcode_vaults.md to discover configured vaults. Query for team standards, conventions, and past audit decisions. Max 10 tool calls. Write findings to a concise summary.")`
240
-
241
- 3. **reviewer** — The audit itself:
242
- - `subagent_type`: `"reviewer"`
243
- - `prompt`: Task-specific context only (role definition is auto-loaded from `agents/reviewer.md`):
244
- > **Audit scope**: {audit_type}
245
- > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
246
- > **Specs directory**: knowzcode/specs/
247
- >
248
- > Deliverable: Audit report with health scores, critical issues, recommendations.
249
- - `description`: `"Audit: {audit_type}"`
250
-
251
- All launched in parallel. Synthesize scout findings alongside reviewer results.
252
-
253
- #### Full Audit
254
-
255
- Launch scouts + parallel reviewers via `Task()`:
256
-
257
- 1. **context-scout** — Local context (if `SCOUT_MODE != "none"`):
258
- - `SCOUT_MODE = "full"` (default): 3 parallel instances:
259
- - `Task(subagent_type="context-scout", name="context-scout-specs", description="Scout: specs context", prompt="Research for comprehensive audit. Focus: knowzcode/specs/*.md — scan all specifications for quality, completeness, VERIFY criteria. Max 10 tool calls. Write findings to a concise summary.")`
260
- - `Task(subagent_type="context-scout", name="context-scout-workgroups", description="Scout: workgroups context", prompt="Research for comprehensive audit. Focus: knowzcode/workgroups/*.md — scan all WorkGroups for patterns, recurring issues, audit history. Max 10 tool calls. Write findings to a concise summary.")`
261
- - `Task(subagent_type="context-scout", name="context-scout-backlog", description="Scout: backlog context", prompt="Research for comprehensive audit. Focus: knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md — scan for WIP status, prior audit results, architecture health. Max 10 tool calls. Write findings to a concise summary.")`
262
- - `SCOUT_MODE = "minimal"`: 1 combined instance:
263
- - `Task(subagent_type="context-scout", name="context-scout", description="Scout: combined context", prompt="Research for comprehensive audit. Focus: ALL local context — knowzcode/specs/*.md, knowzcode/workgroups/*.md, knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md. Max 10 tool calls. Write findings to a concise summary.")`
264
-
265
- 2. **knowz-scout** — MCP knowledge (if `VAULTS_CONFIGURED = true` AND `MCP_AGENTS_ENABLED = true`):
266
- - `Task(subagent_type="knowz-scout", description="Scout: vault standards", prompt="Research for comprehensive audit. Read knowzcode/knowzcode_vaults.md to discover configured vaults. Query for team standards, conventions, security policies, and compliance requirements. Max 10 tool calls. Write findings to a concise summary.")`
267
-
268
- 3. **Parallel reviewers**:
269
- - `Task(subagent_type="reviewer", description="Audit: spec + architecture", prompt="Audit scope: Specification quality AND architecture health ONLY. ...")`
270
- - `Task(subagent_type="reviewer", description="Audit: security + integration", prompt="Audit scope: Security vulnerability scan AND integration consistency ONLY. ...")`
271
- - `Task(subagent_type="reviewer", description="Audit: compliance", prompt="Audit scope: Enterprise compliance ONLY. ...")` (if enterprise configured)
272
-
273
- Synthesize scout context alongside reviewer results.
274
-
275
- #### Specialist Integration (Subagent Mode — Optional)
276
-
277
- Initialize `AUDIT_SPECIALISTS = DEFAULT_SPECIALISTS` (from orchestration config, default: []).
278
-
279
- If `$ARGUMENTS` contains `--specialists` (or `--specialists=security`, `--specialists=test`, `--specialists=security,test`):
280
- - `--specialists` → enable all applicable
281
- - `--specialists=csv` → enable specified subset
282
- - `--no-specialists` → clear to `[]`
283
-
284
- If `AUDIT_SPECIALISTS` is non-empty, launch specialist `Task()` calls in parallel with reviewers:
285
-
286
- 1. **security-officer** (if enabled):
287
- - `Task(subagent_type="security-officer", description="Security officer: deep security audit", prompt="Audit scope: Full codebase security scan. Context files: knowzcode_tracker.md, knowzcode_architecture.md. Specs: knowzcode/specs/. Deliverable: Security finding report with severity ratings. Tag CRITICAL/HIGH with [SECURITY-BLOCK]. If knowzcode/enterprise/compliance_manifest.md exists and compliance_enabled: true, also cross-reference findings with enterprise guideline IDs.")`
288
-
289
- 2. **test-advisor** (if enabled):
290
- - `Task(subagent_type="test-advisor", description="Test advisor: test quality audit", prompt="Audit scope: Test coverage, TDD compliance, assertion quality, edge cases. Context files: knowzcode_tracker.md. Deliverable: Test quality report with coverage metrics and recommendations. If knowzcode/enterprise/compliance_manifest.md exists and compliance_enabled: true, also check enterprise ARC criteria for test coverage.")`
291
-
292
- Synthesize specialist findings alongside reviewer results.
293
-
294
- ## Step 4: Present Results
295
-
296
- ```markdown
297
- ## KnowzCode Audit Results
298
-
299
- **Timestamp**: {timestamp}
300
- **Audit Type**: {type or "Comprehensive"}
301
-
302
- ### Summary Scores
303
- | Area | Health Score | Critical Issues |
304
- |------|-------------|-----------------|
305
- | Spec Quality | {score}% | {count} |
306
- | Architecture | {score}% | {count} |
307
- | Security | {score}% | {count} |
308
- | Integration | {score}% | {count} |
309
-
310
- ### Critical Issues
311
- {sorted by severity}
312
-
313
- ### Recommendations
314
- {prioritized action items}
315
-
316
- ### Specialist Reports [only when --specialists active]
317
- **Security Officer**: {finding count, severity breakdown, SECURITY-BLOCK tags}
318
- **Test Advisor**: {coverage %, TDD compliance, quality assessment}
319
- ```
320
-
321
- ## Step 5: Log Audit
322
-
323
- Log to `knowzcode/knowzcode_log.md`:
324
- ```markdown
325
- | {timestamp} | AUDIT | {audit_type} | {summary} |
326
- ```
327
-
328
- If MCP is configured and enterprise vault exists: push audit results via `create_knowledge` for team audit trail.
1
+ ---
2
+ description: "Run KnowzCode quality audits (spec, architecture, security, integration, compliance)"
3
+ argument-hint: "[audit_type]"
4
+ ---
5
+
6
+ # Run KnowzCode Audit
7
+
8
+ Run specialized audit workflows.
9
+
10
+ **Usage**: `/kc:audit [audit_type]`
11
+ **Example**: `/kc:audit spec` or `/kc:audit security`
12
+
13
+ **Audit Type**: $ARGUMENTS
14
+
15
+ ---
16
+
17
+ ## Audit Types
18
+
19
+ | Type | Focus |
20
+ |------|-------|
21
+ | **spec** | Specification quality and completeness |
22
+ | **architecture** | Architecture health and drift |
23
+ | **security** | OWASP vulnerability scanning |
24
+ | **integration** | Cross-component consistency |
25
+ | **compliance** | Enterprise guideline compliance (if configured, experimental) |
26
+ | *(no argument)* | Full parallel audit of all types |
27
+
28
+ ---
29
+
30
+ ## Step 1: Load Context
31
+
32
+ Read:
33
+ - `knowzcode/knowzcode_tracker.md`
34
+ - `knowzcode/knowzcode_architecture.md`
35
+ - `knowzcode/knowzcode_project.md`
36
+ - `knowzcode/knowzcode_orchestration.md` (if exists)
37
+
38
+ ## Step 1.1: Parse Orchestration Config (Optional)
39
+
40
+ If `knowzcode/knowzcode_orchestration.md` exists, parse its YAML blocks:
41
+
42
+ 1. `SCOUT_MODE` = `scout_mode` value (default: "full")
43
+ 2. `DEFAULT_SPECIALISTS` = `default_specialists` value (default: [])
44
+ 3. `MCP_AGENTS_ENABLED` = `mcp_agents_enabled` value (default: true)
45
+
46
+ Apply flag overrides (flags win over config):
47
+ - `--no-scouts` in `$ARGUMENTS` → override `SCOUT_MODE = "none"`
48
+ - `--no-specialists` in `$ARGUMENTS` → override `DEFAULT_SPECIALISTS = []`
49
+ - `--no-mcp` in `$ARGUMENTS` → override `MCP_AGENTS_ENABLED = false`
50
+
51
+ If the file doesn't exist, use hardcoded defaults (current behavior).
52
+
53
+ ## Step 2: Set Up Execution Mode
54
+
55
+ Attempt `TeamCreate(team_name="kc-audit-{timestamp}")`:
56
+
57
+ - **If TeamCreate succeeds** → Agent Teams mode:
58
+ 1. Announce: `**Execution Mode: Agent Teams** — created team kc-audit-{timestamp}`
59
+ 2. Read `knowzcode/claude_code_execution.md` for team conventions.
60
+ 3. You are the **team lead** — coordinate the audit and present results.
61
+
62
+ - **If TeamCreate fails** (error, unrecognized tool, timeout) → Subagent Delegation:
63
+ - Announce: `**Execution Mode: Subagent Delegation** — Agent Teams not available, using Task() fallback`
64
+
65
+ The user MUST see the execution mode announcement before audit work begins.
66
+
67
+ ## Step 3: Execute Audit
68
+
69
+ ### MCP Probe
70
+
71
+ Before spawning agents, determine vault availability:
72
+ 1. Read `knowzcode/knowzcode_vaults.md` — partition entries into CONFIGURED (non-empty ID) and UNCREATED (empty ID)
73
+ 2. Call `list_vaults(includeStats=true)` **always** — regardless of whether any IDs exist in the file
74
+ 3. If `list_vaults()` fails → set `MCP_ACTIVE = false`, announce `**MCP Status: Not connected**`, skip vault setup
75
+ 4. If `list_vaults()` succeeds AND UNCREATED list is non-empty → present the **Vault Creation Prompt**:
76
+
77
+ ```markdown
78
+ ## Vault Setup
79
+
80
+ Your Knowz API key is valid and MCP is connected, but {N} default vault(s) haven't been created yet.
81
+ Creating vaults enables knowledge capture throughout the workflow:
82
+
83
+ | Vault | Type | Description | Written During |
84
+ |-------|------|-------------|----------------|
85
+ ```
86
+
87
+ Build table rows dynamically from the UNCREATED entries only. Derive "Written During" from each vault's Write Conditions field in `knowzcode_vaults.md`.
88
+
89
+ Then present options:
90
+ ```
91
+ Options:
92
+ **A) Create all {N} vaults** (recommended)
93
+ **B) Select which to create**
94
+ **C) Skip** — proceed without vaults (can create later with `/kc:connect-mcp --configure-vaults`)
95
+ ```
96
+
97
+ 5. Handle user selection:
98
+ - **A**: For each UNCREATED entry, call MCP `create_vault(name, description)`. If `create_vault` is not available, fall back to matching by name against `list_vaults()` results. Update `knowzcode_vaults.md`: fill ID field, change H3 heading from `(not created)` to vault ID. Report any failures.
99
+ - **B**: Ask which vaults to create, then create only selected ones.
100
+ - **C**: Log `"Vault creation skipped — knowledge capture disabled."` Continue.
101
+ 6. After resolution, set:
102
+ - `MCP_ACTIVE = true` (MCP works regardless of vault creation outcome)
103
+ - `VAULTS_CONFIGURED = true` if at least 1 vault now has a valid ID, else `false`
104
+ - Announce: `**MCP Status: Connected — N vault(s) available**` or `**MCP Status: Connected — no vaults configured (knowledge capture disabled)**`
105
+
106
+ ### Agent Teams Mode
107
+
108
+ #### Specific Audit Type (argument provided)
109
+
110
+ `TaskCreate("Audit: {audit_type}")` → `TaskUpdate(owner: "reviewer")`.
111
+
112
+ Spawn a single `reviewer` teammate:
113
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
114
+ > You are the **reviewer** running a {audit_type} audit.
115
+ > Read `agents/reviewer.md` for your role definition.
116
+ > Read `knowzcode/claude_code_execution.md` for team conventions.
117
+ >
118
+ > **Audit scope**: {audit_type}
119
+ > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
120
+ > **Specs directory**: knowzcode/specs/
121
+ >
122
+ > Deliverable: Audit report with health scores, critical issues, recommendations.
123
+
124
+ Wait for completion. Shut down teammate. Clean up the team.
125
+
126
+ The reviewer focuses on the requested type with type-specific depth:
127
+ - **spec**: Validates 4-section format, VERIFY statement count, consolidation opportunities
128
+ - **architecture**: Checks layer violations, drift, pattern consistency
129
+ - **security**: OWASP Top 10 scanning with concrete detection patterns
130
+ - **integration**: API contracts, dependency graph, orphaned code, data flow
131
+ - **compliance**: Enterprise guideline enforcement levels
132
+
133
+ #### Full Audit (no argument — DEFAULT)
134
+
135
+ Create tasks first, pre-assign, then spawn with task IDs:
136
+ - `TaskCreate("Audit: spec + architecture")` → `TaskUpdate(owner: "reviewer-spec-arch")`
137
+ - `TaskCreate("Audit: security + integration")` → `TaskUpdate(owner: "reviewer-sec-int")`
138
+ - (Optional) `TaskCreate("Audit: compliance")` → `TaskUpdate(owner: "reviewer-compliance")` (if enterprise configured)
139
+ - `TaskCreate("Scout: vault standards")` → `TaskUpdate(owner: "knowz-scout")` (if `VAULTS_CONFIGURED = true`)
140
+
141
+ Spawn reviewers with their task IDs:
142
+
143
+ 1. Spawn `reviewer` teammate (name: `reviewer-spec-arch`):
144
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
145
+ > You are the **reviewer** running a targeted audit.
146
+ > Read `agents/reviewer.md` for your role definition.
147
+ > Read `knowzcode/claude_code_execution.md` for team conventions.
148
+ >
149
+ > **Audit scope**: Specification quality AND architecture health ONLY.
150
+ > Do NOT audit security or integration — another reviewer handles those.
151
+ > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
152
+ > **Specs directory**: knowzcode/specs/
153
+ >
154
+ > Deliverable: Audit report with spec quality scores, architecture health, critical issues.
155
+
156
+ 2. Spawn `reviewer` teammate (name: `reviewer-sec-int`):
157
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
158
+ > You are the **reviewer** running a targeted audit.
159
+ > Read `agents/reviewer.md` for your role definition.
160
+ > Read `knowzcode/claude_code_execution.md` for team conventions.
161
+ >
162
+ > **Audit scope**: Security vulnerability scan AND integration consistency ONLY.
163
+ > Do NOT audit specs or architecture — another reviewer handles those.
164
+ > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
165
+ > **Specs directory**: knowzcode/specs/
166
+ >
167
+ > Deliverable: Audit report with security posture, integration health, critical issues.
168
+
169
+ 3. (Optional) If enterprise compliance configured, spawn `reviewer` (name: `reviewer-compliance`):
170
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
171
+ > **Audit scope**: Enterprise compliance ONLY.
172
+ > Check against guidelines in `knowzcode/enterprise/compliance_manifest.md`.
173
+
174
+ 4. If `VAULTS_CONFIGURED = true` AND `MCP_AGENTS_ENABLED = true`, spawn `knowz-scout` for standards lookup in parallel with reviewers:
175
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
176
+ > Read `knowzcode/knowzcode_vaults.md` to resolve vault IDs by type. Query for team standards: `ask_question({vault matching "ecosystem" type}, "standards for {project_type}", researchMode=true)`
177
+
178
+ Wait for all to complete.
179
+
180
+ #### Specialist Integration (Optional)
181
+
182
+ Initialize `AUDIT_SPECIALISTS = DEFAULT_SPECIALISTS` (from orchestration config, default: []).
183
+
184
+ If `$ARGUMENTS` contains `--specialists` (or `--specialists=security`, `--specialists=test`, `--specialists=security,test`):
185
+ - `--specialists` → enable all applicable: `[security-officer, test-advisor]`
186
+ - `--specialists=csv` → enable specified subset
187
+ - `--no-specialists` → clear to `[]` (overrides config defaults)
188
+
189
+ If neither `--specialists` nor `--no-specialists` is present, use `DEFAULT_SPECIALISTS` from config.
190
+
191
+ Parse which specialists to enable. Then spawn alongside reviewers:
192
+
193
+ 1. **security-officer** (if enabled) — spawn alongside `reviewer-sec-int` for deeper security scanning:
194
+ - `TaskCreate("Security officer: deep security audit")` → `TaskUpdate(owner: "security-officer")`
195
+ - Spawn `security-officer` teammate:
196
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
197
+ > You are the **security-officer** running a deep security audit.
198
+ > Read `agents/security-officer.md` for your role definition.
199
+ > Read `knowzcode/claude_code_execution.md` for team conventions.
200
+ >
201
+ > **Audit scope**: Full codebase security scan — vulnerability patterns, hardcoded secrets, injection vectors, auth bypass, SSRF, path traversal.
202
+ > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
203
+ > **Specs directory**: knowzcode/specs/
204
+ >
205
+ > Deliverable: Security finding report with severity ratings. Tag CRITICAL/HIGH findings with `[SECURITY-BLOCK]`.
206
+ > If `knowzcode/enterprise/compliance_manifest.md` exists and `compliance_enabled: true`, also cross-reference findings with enterprise guideline IDs.
207
+
208
+ 2. **test-advisor** (if enabled) — spawn alongside reviewers for test quality assessment:
209
+ - `TaskCreate("Test advisor: test quality audit")` → `TaskUpdate(owner: "test-advisor")`
210
+ - Spawn `test-advisor` teammate:
211
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
212
+ > You are the **test-advisor** running a test quality audit.
213
+ > Read `agents/test-advisor.md` for your role definition.
214
+ > Read `knowzcode/claude_code_execution.md` for team conventions.
215
+ >
216
+ > **Audit scope**: Test coverage, TDD compliance, assertion quality, edge case coverage, test isolation.
217
+ > **Context files**: knowzcode_tracker.md, knowzcode_project.md
218
+ >
219
+ > Deliverable: Test quality report with coverage metrics, TDD compliance, and improvement recommendations.
220
+ > If `knowzcode/enterprise/compliance_manifest.md` exists and `compliance_enabled: true`, also check enterprise ARC criteria for test coverage.
221
+
222
+ Wait for all reviewers and specialists to complete. Synthesize results in Step 4.
223
+
224
+ ### Subagent Mode
225
+
226
+ #### Specific Audit Type
227
+
228
+ Launch scouts + reviewer in parallel via `Task()`:
229
+
230
+ 1. **context-scout** — Local context (if `SCOUT_MODE != "none"`):
231
+ - `SCOUT_MODE = "full"` (default): 3 parallel instances:
232
+ - `Task(subagent_type="context-scout", name="context-scout-specs", description="Scout: specs context", prompt="Research audit scope: {audit_type}. Focus: knowzcode/specs/*.md — scan existing specifications for relevant NodeIDs, status, VERIFY criteria. Max 10 tool calls. Write findings to a concise summary.")`
233
+ - `Task(subagent_type="context-scout", name="context-scout-workgroups", description="Scout: workgroups context", prompt="Research audit scope: {audit_type}. Focus: knowzcode/workgroups/*.md — scan previous WorkGroups for related audit findings. Max 10 tool calls. Write findings to a concise summary.")`
234
+ - `Task(subagent_type="context-scout", name="context-scout-backlog", description="Scout: backlog context", prompt="Research audit scope: {audit_type}. Focus: knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md — scan for active WIP, prior audit results, architecture health. Max 10 tool calls. Write findings to a concise summary.")`
235
+ - `SCOUT_MODE = "minimal"`: 1 combined instance:
236
+ - `Task(subagent_type="context-scout", name="context-scout", description="Scout: combined context", prompt="Research audit scope: {audit_type}. Focus: ALL local context — knowzcode/specs/*.md, knowzcode/workgroups/*.md, knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md. Max 10 tool calls. Write findings to a concise summary.")`
237
+
238
+ 2. **knowz-scout** — MCP knowledge (if `VAULTS_CONFIGURED = true` AND `MCP_AGENTS_ENABLED = true`):
239
+ - `Task(subagent_type="knowz-scout", description="Scout: vault standards", prompt="Research audit scope: {audit_type}. Read knowzcode/knowzcode_vaults.md to discover configured vaults. Query for team standards, conventions, and past audit decisions. Max 10 tool calls. Write findings to a concise summary.")`
240
+
241
+ 3. **reviewer** — The audit itself:
242
+ - `subagent_type`: `"reviewer"`
243
+ - `prompt`: Task-specific context only (role definition is auto-loaded from `agents/reviewer.md`):
244
+ > **Audit scope**: {audit_type}
245
+ > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
246
+ > **Specs directory**: knowzcode/specs/
247
+ >
248
+ > Deliverable: Audit report with health scores, critical issues, recommendations.
249
+ - `description`: `"Audit: {audit_type}"`
250
+
251
+ All launched in parallel. Synthesize scout findings alongside reviewer results.
252
+
253
+ #### Full Audit
254
+
255
+ Launch scouts + parallel reviewers via `Task()`:
256
+
257
+ 1. **context-scout** — Local context (if `SCOUT_MODE != "none"`):
258
+ - `SCOUT_MODE = "full"` (default): 3 parallel instances:
259
+ - `Task(subagent_type="context-scout", name="context-scout-specs", description="Scout: specs context", prompt="Research for comprehensive audit. Focus: knowzcode/specs/*.md — scan all specifications for quality, completeness, VERIFY criteria. Max 10 tool calls. Write findings to a concise summary.")`
260
+ - `Task(subagent_type="context-scout", name="context-scout-workgroups", description="Scout: workgroups context", prompt="Research for comprehensive audit. Focus: knowzcode/workgroups/*.md — scan all WorkGroups for patterns, recurring issues, audit history. Max 10 tool calls. Write findings to a concise summary.")`
261
+ - `Task(subagent_type="context-scout", name="context-scout-backlog", description="Scout: backlog context", prompt="Research for comprehensive audit. Focus: knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md — scan for WIP status, prior audit results, architecture health. Max 10 tool calls. Write findings to a concise summary.")`
262
+ - `SCOUT_MODE = "minimal"`: 1 combined instance:
263
+ - `Task(subagent_type="context-scout", name="context-scout", description="Scout: combined context", prompt="Research for comprehensive audit. Focus: ALL local context — knowzcode/specs/*.md, knowzcode/workgroups/*.md, knowzcode/knowzcode_tracker.md, knowzcode/knowzcode_log.md, knowzcode/knowzcode_architecture.md. Max 10 tool calls. Write findings to a concise summary.")`
264
+
265
+ 2. **knowz-scout** — MCP knowledge (if `VAULTS_CONFIGURED = true` AND `MCP_AGENTS_ENABLED = true`):
266
+ - `Task(subagent_type="knowz-scout", description="Scout: vault standards", prompt="Research for comprehensive audit. Read knowzcode/knowzcode_vaults.md to discover configured vaults. Query for team standards, conventions, security policies, and compliance requirements. Max 10 tool calls. Write findings to a concise summary.")`
267
+
268
+ 3. **Parallel reviewers**:
269
+ - `Task(subagent_type="reviewer", description="Audit: spec + architecture", prompt="Audit scope: Specification quality AND architecture health ONLY. ...")`
270
+ - `Task(subagent_type="reviewer", description="Audit: security + integration", prompt="Audit scope: Security vulnerability scan AND integration consistency ONLY. ...")`
271
+ - `Task(subagent_type="reviewer", description="Audit: compliance", prompt="Audit scope: Enterprise compliance ONLY. ...")` (if enterprise configured)
272
+
273
+ Synthesize scout context alongside reviewer results.
274
+
275
+ #### Specialist Integration (Subagent Mode — Optional)
276
+
277
+ Initialize `AUDIT_SPECIALISTS = DEFAULT_SPECIALISTS` (from orchestration config, default: []).
278
+
279
+ If `$ARGUMENTS` contains `--specialists` (or `--specialists=security`, `--specialists=test`, `--specialists=security,test`):
280
+ - `--specialists` → enable all applicable
281
+ - `--specialists=csv` → enable specified subset
282
+ - `--no-specialists` → clear to `[]`
283
+
284
+ If `AUDIT_SPECIALISTS` is non-empty, launch specialist `Task()` calls in parallel with reviewers:
285
+
286
+ 1. **security-officer** (if enabled):
287
+ - `Task(subagent_type="security-officer", description="Security officer: deep security audit", prompt="Audit scope: Full codebase security scan. Context files: knowzcode_tracker.md, knowzcode_architecture.md. Specs: knowzcode/specs/. Deliverable: Security finding report with severity ratings. Tag CRITICAL/HIGH with [SECURITY-BLOCK]. If knowzcode/enterprise/compliance_manifest.md exists and compliance_enabled: true, also cross-reference findings with enterprise guideline IDs.")`
288
+
289
+ 2. **test-advisor** (if enabled):
290
+ - `Task(subagent_type="test-advisor", description="Test advisor: test quality audit", prompt="Audit scope: Test coverage, TDD compliance, assertion quality, edge cases. Context files: knowzcode_tracker.md. Deliverable: Test quality report with coverage metrics and recommendations. If knowzcode/enterprise/compliance_manifest.md exists and compliance_enabled: true, also check enterprise ARC criteria for test coverage.")`
291
+
292
+ Synthesize specialist findings alongside reviewer results.
293
+
294
+ ## Step 4: Present Results
295
+
296
+ ```markdown
297
+ ## KnowzCode Audit Results
298
+
299
+ **Timestamp**: {timestamp}
300
+ **Audit Type**: {type or "Comprehensive"}
301
+
302
+ ### Summary Scores
303
+ | Area | Health Score | Critical Issues |
304
+ |------|-------------|-----------------|
305
+ | Spec Quality | {score}% | {count} |
306
+ | Architecture | {score}% | {count} |
307
+ | Security | {score}% | {count} |
308
+ | Integration | {score}% | {count} |
309
+
310
+ ### Critical Issues
311
+ {sorted by severity}
312
+
313
+ ### Recommendations
314
+ {prioritized action items}
315
+
316
+ ### Specialist Reports [only when --specialists active]
317
+ **Security Officer**: {finding count, severity breakdown, SECURITY-BLOCK tags}
318
+ **Test Advisor**: {coverage %, TDD compliance, quality assessment}
319
+ ```
320
+
321
+ ## Step 5: Log Audit
322
+
323
+ Log to `knowzcode/knowzcode_log.md`:
324
+ ```markdown
325
+ | {timestamp} | AUDIT | {audit_type} | {summary} |
326
+ ```
327
+
328
+ If MCP is configured and enterprise vault exists: push audit results via `create_knowledge` for team audit trail.