knowzcode 0.1.0 → 0.3.1

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 (64) hide show
  1. package/.claude-plugin/marketplace.json +9 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +170 -73
  4. package/agents/analyst.md +24 -62
  5. package/agents/architect.md +60 -48
  6. package/agents/builder.md +35 -86
  7. package/agents/closer.md +29 -87
  8. package/agents/context-scout.md +54 -0
  9. package/agents/knowledge-migrator.md +7 -7
  10. package/agents/knowz-scout.md +83 -0
  11. package/agents/knowz-scribe.md +155 -0
  12. package/agents/microfix-specialist.md +1 -6
  13. package/agents/project-advisor.md +110 -0
  14. package/agents/reviewer.md +43 -91
  15. package/agents/security-officer.md +194 -0
  16. package/agents/test-advisor.md +162 -0
  17. package/agents/update-coordinator.md +7 -18
  18. package/bin/knowzcode.mjs +94 -7
  19. package/commands/audit.md +245 -25
  20. package/commands/connect-mcp.md +525 -507
  21. package/commands/fix.md +8 -8
  22. package/commands/init.md +125 -6
  23. package/commands/learn.md +327 -308
  24. package/commands/plan.md +173 -26
  25. package/commands/register.md +21 -12
  26. package/commands/status.md +309 -291
  27. package/commands/telemetry.md +188 -188
  28. package/commands/work.md +764 -114
  29. package/knowzcode/automation_manifest.md +59 -59
  30. package/knowzcode/claude_code_execution.md +291 -22
  31. package/knowzcode/copilot_execution.md +231 -0
  32. package/knowzcode/enterprise/compliance_manifest.md +5 -0
  33. package/knowzcode/knowzcode_loop.md +114 -46
  34. package/knowzcode/knowzcode_orchestration.md +66 -0
  35. package/knowzcode/knowzcode_project.md +48 -233
  36. package/knowzcode/knowzcode_vaults.md +183 -54
  37. package/knowzcode/mcp_config.md +72 -47
  38. package/knowzcode/platform_adapters.md +630 -29
  39. package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
  40. package/knowzcode/prompts/Investigate_Codebase.md +227 -227
  41. package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
  42. package/knowzcode/prompts/Refactor_Node.md +72 -72
  43. package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
  44. package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
  45. package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
  46. package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
  47. package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
  48. package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
  49. package/package.json +1 -1
  50. package/skills/alias-resolver.json +1 -1
  51. package/skills/architecture-diff.json +1 -1
  52. package/skills/check-installation-status.json +1 -1
  53. package/skills/continue.md +25 -4
  54. package/skills/environment-guard.json +1 -1
  55. package/skills/generate-workgroup-id.json +1 -1
  56. package/skills/install-knowzcode.json +1 -1
  57. package/skills/load-core-context.json +1 -1
  58. package/skills/log-entry-builder.json +1 -1
  59. package/skills/spec-quality-check.json +1 -1
  60. package/skills/spec-template.json +1 -1
  61. package/skills/spec-validator.json +1 -1
  62. package/skills/tracker-scan.json +1 -1
  63. package/skills/tracker-update.json +1 -1
  64. package/skills/validate-installation.json +1 -1
@@ -173,7 +173,6 @@ Before any changes:
173
173
 
174
174
  ```markdown
175
175
  1. Create timestamped backup:
176
- .claude.backup.{timestamp}/
177
176
  knowzcode.backup.{timestamp}/
178
177
 
179
178
  2. Store backup manifest:
@@ -237,7 +236,6 @@ Create `knowzcode/update_manifest.md`:
237
236
  ✅ Project metadata: Preserved
238
237
 
239
238
  ### Backup Location
240
- `.claude.backup.20250104_200000/`
241
239
  `knowzcode.backup.20250104_200000/`
242
240
 
243
241
  ### Version Update
@@ -276,7 +274,7 @@ After update completion:
276
274
 
277
275
  ## Update Instructions
278
276
 
279
- When invoked via `/kc-update [source_path]`:
277
+ When invoked (see "How to Invoke" below), provide the source path as context:
280
278
 
281
279
  ```markdown
282
280
  1. Validate inputs:
@@ -286,7 +284,6 @@ When invoked via `/kc-update [source_path]`:
286
284
  - No active WorkGroups blocking update
287
285
 
288
286
  2. Create backups:
289
- - Backup .claude/ directory
290
287
  - Backup knowzcode/ directory
291
288
  - Create backup manifest
292
289
 
@@ -368,27 +365,19 @@ After successful update:
368
365
 
369
366
  3. Recommend next steps:
370
367
  - Review any .new files
371
- - Test orchestration: /kc-step 1A (dry run)
368
+ - Test orchestration: run /kc:work on a small task to verify
372
369
  - Check for deprecated features
373
370
  - Read changelog if provided
374
371
  ```
375
372
 
376
- ## Usage Examples
373
+ ## How to Invoke
377
374
 
378
- **Basic Update**:
379
- ```
380
- /kc-update /path/to/newer/knowzcode
381
- ```
375
+ This agent is invoked manually by name (e.g., spawned as a teammate or via `Task()` with `subagent_type: "update-coordinator"`). There is no dedicated slash command yet — a `/kc:update` command may be added in a future release.
382
376
 
383
- **Update with Conflict Strategy**:
384
- ```
385
- /kc-update /path/to/newer/knowzcode strategy=preserve-custom
386
- ```
377
+ **Provide the source path in the spawn prompt:**
378
+ > Update KnowzCode from `/path/to/newer/knowzcode`. Use conflict strategy: preserve-custom.
387
379
 
388
- **Update with Dry Run**:
389
- ```
390
- /kc-update /path/to/newer/knowzcode --dry-run
391
- ```
380
+ **Dry run** add `--dry-run` to the prompt to preview changes without writing files.
392
381
 
393
382
  ## Critical Safety Rules
394
383
 
package/bin/knowzcode.mjs CHANGED
@@ -195,6 +195,65 @@ function listFilesRecursive(dir, base = dir) {
195
195
  return files;
196
196
  }
197
197
 
198
+ // ─── Marketplace Config ──────────────────────────────────────────────────────
199
+
200
+ function setMarketplaceConfig(claudeDir) {
201
+ ensureDir(claudeDir);
202
+ const settingsFile = join(claudeDir, 'settings.json');
203
+ let settings = {};
204
+
205
+ if (existsSync(settingsFile)) {
206
+ try {
207
+ settings = JSON.parse(readFileSync(settingsFile, 'utf8'));
208
+ } catch {
209
+ settings = {};
210
+ }
211
+ }
212
+
213
+ if (!settings.extraKnownMarketplaces) settings.extraKnownMarketplaces = {};
214
+ settings.extraKnownMarketplaces.knowzcode = {
215
+ source: { source: 'github', repo: 'knowz-io/knowzcode' },
216
+ };
217
+
218
+ writeFileSync(settingsFile, JSON.stringify(settings, null, 2) + '\n');
219
+ }
220
+
221
+ function removeMarketplaceConfig(claudeDir) {
222
+ const settingsFile = join(claudeDir, 'settings.json');
223
+ if (!existsSync(settingsFile)) return;
224
+
225
+ try {
226
+ const settings = JSON.parse(readFileSync(settingsFile, 'utf8'));
227
+ if (settings.extraKnownMarketplaces && settings.extraKnownMarketplaces.knowzcode) {
228
+ delete settings.extraKnownMarketplaces.knowzcode;
229
+ writeFileSync(settingsFile, JSON.stringify(settings, null, 2) + '\n');
230
+ }
231
+ } catch {
232
+ // Ignore parse errors
233
+ }
234
+ }
235
+
236
+ // ─── Stale File Cleanup ─────────────────────────────────────────────────────
237
+
238
+ function removeStaleFiles(sourceDir, targetDir) {
239
+ if (!existsSync(targetDir) || !existsSync(sourceDir)) return;
240
+
241
+ const sourceFiles = new Set(
242
+ readdirSync(sourceDir)
243
+ .filter((f) => f.endsWith('.md'))
244
+ );
245
+
246
+ for (const entry of readdirSync(targetDir)) {
247
+ if (entry.endsWith('.md') && !sourceFiles.has(entry)) {
248
+ const stale = join(targetDir, entry);
249
+ if (existsSync(stale) && statSync(stale).isFile()) {
250
+ log.info(`Removing stale file: ${stale}`);
251
+ rmSync(stale, { force: true });
252
+ }
253
+ }
254
+ }
255
+ }
256
+
198
257
  // ─── Tracker & Log Initializers ──────────────────────────────────────────────
199
258
 
200
259
  function initTracker(filePath) {
@@ -311,10 +370,9 @@ async function promptConfirm(message) {
311
370
 
312
371
  // ─── Agent Teams Enablement ──────────────────────────────────────────────────
313
372
 
314
- function enableAgentTeams(dir) {
315
- const claudeDir = join(dir, '.claude');
373
+ function enableAgentTeams(claudeDir, isGlobal) {
316
374
  ensureDir(claudeDir);
317
- const settingsFile = join(claudeDir, 'settings.local.json');
375
+ const settingsFile = join(claudeDir, isGlobal ? 'settings.json' : 'settings.local.json');
318
376
 
319
377
  let settings = {};
320
378
  if (existsSync(settingsFile)) {
@@ -329,7 +387,7 @@ function enableAgentTeams(dir) {
329
387
  settings.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS = '1';
330
388
 
331
389
  writeFileSync(settingsFile, JSON.stringify(settings, null, 2) + '\n');
332
- log.ok('Agent Teams enabled in .claude/settings.local.json');
390
+ log.ok(`Agent Teams enabled in ${settingsFile}`);
333
391
  }
334
392
 
335
393
  // ─── Commands ────────────────────────────────────────────────────────────────
@@ -475,9 +533,21 @@ async function cmdInstall(opts) {
475
533
  const claudeDir = opts.global ? join(process.env.HOME || process.env.USERPROFILE || '~', '.claude') : join(dir, '.claude');
476
534
 
477
535
  log.info(`Installing Claude Code components to ${claudeDir}/`);
536
+
537
+ // Remove stale files before copying on --force
538
+ if (opts.force) {
539
+ removeStaleFiles(join(PKG_ROOT, 'commands'), join(claudeDir, 'commands'));
540
+ removeStaleFiles(join(PKG_ROOT, 'agents'), join(claudeDir, 'agents'));
541
+ removeStaleFiles(join(PKG_ROOT, 'skills'), join(claudeDir, 'skills'));
542
+ }
543
+
478
544
  copyDirContents(join(PKG_ROOT, 'commands'), join(claudeDir, 'commands'));
479
545
  copyDirContents(join(PKG_ROOT, 'agents'), join(claudeDir, 'agents'));
480
546
  copyDirContents(join(PKG_ROOT, 'skills'), join(claudeDir, 'skills'));
547
+
548
+ // Pre-register marketplace in settings.json
549
+ setMarketplaceConfig(claudeDir);
550
+
481
551
  adapterFiles.push(claudeDir + '/commands/', claudeDir + '/agents/', claudeDir + '/skills/');
482
552
  } else {
483
553
  // Other platforms: extract template and write adapter file
@@ -496,9 +566,12 @@ async function cmdInstall(opts) {
496
566
  }
497
567
 
498
568
  // 4. Agent Teams enablement
569
+ const agentTeamsClaudeDir = opts.global
570
+ ? join(process.env.HOME || process.env.USERPROFILE || '~', '.claude')
571
+ : join(dir, '.claude');
499
572
  let agentTeamsEnabled = false;
500
573
  if (opts.agentTeams) {
501
- enableAgentTeams(dir);
574
+ enableAgentTeams(agentTeamsClaudeDir, opts.global);
502
575
  agentTeamsEnabled = true;
503
576
  } else if (selectedPlatforms.includes('claude') && !opts.force) {
504
577
  // Interactive prompt for Claude Code users
@@ -507,7 +580,7 @@ async function cmdInstall(opts) {
507
580
  console.log(`teammates handle each workflow phase. ${c.dim}(experimental)${c.reset}`);
508
581
  const wantTeams = await promptConfirm('Enable Agent Teams? (recommended for Claude Code)');
509
582
  if (wantTeams) {
510
- enableAgentTeams(dir);
583
+ enableAgentTeams(agentTeamsClaudeDir, opts.global);
511
584
  agentTeamsEnabled = true;
512
585
  }
513
586
  }
@@ -531,7 +604,12 @@ async function cmdInstall(opts) {
531
604
  console.log(' 1. Edit knowzcode/knowzcode_project.md — set project name, stack, standards');
532
605
  console.log(' 2. Edit knowzcode/environment_context.md — configure build/test commands');
533
606
  if (selectedPlatforms.includes('claude')) {
534
- console.log(' 3. Start building: /kc:work "Your first feature"');
607
+ console.log(' 3. Install the KnowzCode plugin (recommended):');
608
+ console.log(' /plugin install kc@knowzcode');
609
+ console.log(' 4. Start building:');
610
+ console.log(' /kc:work "Your first feature"');
611
+ console.log('');
612
+ console.log(' Note: Commands also work without plugin as /work, /plan, /fix, etc.');
535
613
  } else {
536
614
  console.log(' 3. Start building: use knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md');
537
615
  }
@@ -624,6 +702,9 @@ async function cmdUninstall(opts) {
624
702
  }
625
703
  }
626
704
 
705
+ // Clean up marketplace config from settings.json
706
+ removeMarketplaceConfig(claudeDir);
707
+
627
708
  console.log('');
628
709
  log.ok('Uninstall complete');
629
710
  console.log(' Removed:');
@@ -716,9 +797,15 @@ async function cmdUpgrade(opts) {
716
797
  const claudeDir = join(dir, '.claude');
717
798
  if (existsSync(join(claudeDir, 'commands')) || existsSync(join(claudeDir, 'agents'))) {
718
799
  log.info('Updating Claude Code components...');
800
+ // Remove stale files before copying
801
+ removeStaleFiles(join(PKG_ROOT, 'commands'), join(claudeDir, 'commands'));
802
+ removeStaleFiles(join(PKG_ROOT, 'agents'), join(claudeDir, 'agents'));
803
+ removeStaleFiles(join(PKG_ROOT, 'skills'), join(claudeDir, 'skills'));
719
804
  copyDirContents(join(PKG_ROOT, 'commands'), join(claudeDir, 'commands'));
720
805
  copyDirContents(join(PKG_ROOT, 'agents'), join(claudeDir, 'agents'));
721
806
  copyDirContents(join(PKG_ROOT, 'skills'), join(claudeDir, 'skills'));
807
+ // Ensure marketplace config is up to date
808
+ setMarketplaceConfig(claudeDir);
722
809
  }
723
810
 
724
811
  // Regenerate adapters for detected platforms
package/commands/audit.md CHANGED
@@ -22,7 +22,7 @@ Run specialized audit workflows.
22
22
  | **architecture** | Architecture health and drift |
23
23
  | **security** | OWASP vulnerability scanning |
24
24
  | **integration** | Cross-component consistency |
25
- | **compliance** | Enterprise guideline compliance (if configured) |
25
+ | **compliance** | Enterprise guideline compliance (if configured, experimental) |
26
26
  | *(no argument)* | Full parallel audit of all types |
27
27
 
28
28
  ---
@@ -33,40 +33,95 @@ Read:
33
33
  - `knowzcode/knowzcode_tracker.md`
34
34
  - `knowzcode/knowzcode_architecture.md`
35
35
  - `knowzcode/knowzcode_project.md`
36
+ - `knowzcode/knowzcode_orchestration.md` (if exists)
36
37
 
37
- ## Step 2: Execute Audit
38
+ ## Step 1.1: Parse Orchestration Config (Optional)
38
39
 
39
- ### Agent Teams Mode (if available)
40
+ If `knowzcode/knowzcode_orchestration.md` exists, parse its YAML blocks:
40
41
 
41
- Spawn a `reviewer` teammate:
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.
42
114
  > You are the **reviewer** running a {audit_type} audit.
43
115
  > Read `agents/reviewer.md` for your role definition.
44
116
  > Read `knowzcode/claude_code_execution.md` for team conventions.
45
117
  >
46
- > **Audit scope**: {audit_type or "comprehensive — all types"}
118
+ > **Audit scope**: {audit_type}
47
119
  > **Context files**: knowzcode_tracker.md, knowzcode_architecture.md, knowzcode_project.md
48
120
  > **Specs directory**: knowzcode/specs/
49
121
  >
50
122
  > Deliverable: Audit report with health scores, critical issues, recommendations.
51
123
 
52
- Create task and assign. Wait for completion. Shut down teammate.
53
-
54
- ### Subagent Mode (fallback)
55
-
56
- Delegate to the **reviewer** agent via `Task()`. Pass the audit type and context file paths.
57
-
58
- ### Full Audit (no argument — DEFAULT)
59
-
60
- The reviewer performs a comprehensive quality audit covering:
61
- - Specification quality (all specs in `knowzcode/specs/`)
62
- - Architecture health (`knowzcode/knowzcode_architecture.md`)
63
- - Security vulnerability scan (OWASP Top 10)
64
- - Integration consistency (cross-component patterns)
65
- - Enterprise compliance (if `knowzcode/enterprise/` configured)
66
-
67
- If MCP is configured: `ask_question(research_vault, "standards for {project_type}", researchMode=true)` to check against documented team standards.
68
-
69
- ### Specific Audit Type
124
+ Wait for completion. Shut down teammate. Clean up the team.
70
125
 
71
126
  The reviewer focuses on the requested type with type-specific depth:
72
127
  - **spec**: Validates 4-section format, VERIFY statement count, consolidation opportunities
@@ -75,7 +130,168 @@ The reviewer focuses on the requested type with type-specific depth:
75
130
  - **integration**: API contracts, dependency graph, orphaned code, data flow
76
131
  - **compliance**: Enterprise guideline enforcement levels
77
132
 
78
- ## Step 3: Present Results
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
79
295
 
80
296
  ```markdown
81
297
  ## KnowzCode Audit Results
@@ -96,9 +312,13 @@ The reviewer focuses on the requested type with type-specific depth:
96
312
 
97
313
  ### Recommendations
98
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}
99
319
  ```
100
320
 
101
- ## Step 4: Log Audit
321
+ ## Step 5: Log Audit
102
322
 
103
323
  Log to `knowzcode/knowzcode_log.md`:
104
324
  ```markdown