knowzcode 0.1.0 → 0.2.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.
- package/.claude-plugin/marketplace.json +6 -3
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +132 -73
- package/agents/analyst.md +24 -62
- package/agents/architect.md +34 -43
- package/agents/builder.md +35 -86
- package/agents/closer.md +29 -87
- package/agents/context-scout.md +54 -0
- package/agents/knowledge-migrator.md +7 -7
- package/agents/knowz-scout.md +83 -0
- package/agents/knowz-scribe.md +155 -0
- package/agents/microfix-specialist.md +1 -6
- package/agents/reviewer.md +43 -91
- package/agents/update-coordinator.md +7 -18
- package/bin/knowzcode.mjs +94 -7
- package/commands/audit.md +156 -25
- package/commands/connect-mcp.md +525 -507
- package/commands/fix.md +8 -8
- package/commands/init.md +9 -5
- package/commands/learn.md +327 -308
- package/commands/plan.md +160 -26
- package/commands/register.md +21 -12
- package/commands/status.md +309 -291
- package/commands/telemetry.md +188 -188
- package/commands/work.md +577 -114
- package/knowzcode/automation_manifest.md +59 -59
- package/knowzcode/claude_code_execution.md +228 -22
- package/knowzcode/enterprise/compliance_manifest.md +2 -0
- package/knowzcode/knowzcode_loop.md +111 -45
- package/knowzcode/knowzcode_project.md +48 -233
- package/knowzcode/knowzcode_vaults.md +183 -54
- package/knowzcode/mcp_config.md +72 -47
- package/knowzcode/platform_adapters.md +43 -4
- package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
- package/knowzcode/prompts/Investigate_Codebase.md +227 -227
- package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
- package/knowzcode/prompts/Refactor_Node.md +72 -72
- package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
- package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
- package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
- package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
- package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
- package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
- package/package.json +1 -1
- package/skills/alias-resolver.json +1 -1
- package/skills/architecture-diff.json +1 -1
- package/skills/check-installation-status.json +1 -1
- package/skills/continue.md +24 -4
- package/skills/environment-guard.json +1 -1
- package/skills/generate-workgroup-id.json +1 -1
- package/skills/install-knowzcode.json +1 -1
- package/skills/load-core-context.json +1 -1
- package/skills/log-entry-builder.json +1 -1
- package/skills/spec-quality-check.json +1 -1
- package/skills/spec-template.json +1 -1
- package/skills/spec-validator.json +1 -1
- package/skills/tracker-scan.json +1 -1
- package/skills/tracker-update.json +1 -1
- package/skills/validate-installation.json +1 -1
package/commands/work.md
CHANGED
|
@@ -30,30 +30,53 @@ If missing: inform user to run `/kc:init` first. STOP.
|
|
|
30
30
|
- `{slug}`: 2-4 word kebab-case from goal (remove common words: build, add, create, implement, the, a, with, for)
|
|
31
31
|
- Truncate slug to max 25 characters
|
|
32
32
|
|
|
33
|
-
## Step 2:
|
|
33
|
+
## Step 2: Select Execution Mode
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Determine the execution mode using try-then-fallback:
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
1. Note user preferences from `$ARGUMENTS`:
|
|
38
|
+
- `--sequential` → prefer Sequential Teams
|
|
39
|
+
- `--subagent` → force Subagent Delegation (skip team creation attempt)
|
|
40
|
+
|
|
41
|
+
2. **If `--subagent` NOT specified**, attempt `TeamCreate(team_name="kc-{wgid}")`:
|
|
42
|
+
- **If TeamCreate succeeds** → Agent Teams is available. Choose mode:
|
|
43
|
+
- `--sequential` or Tier 2 → **Sequential Teams**: `**Execution Mode: Sequential Teams** — created team kc-{wgid}`
|
|
44
|
+
- Otherwise → **Parallel Teams** (default for Tier 3): `**Execution Mode: Parallel Teams** — created team kc-{wgid}`
|
|
45
|
+
- **If TeamCreate fails** (error, unrecognized tool, timeout) → **Subagent Delegation**: `**Execution Mode: Subagent Delegation** — Agent Teams not available, using Task() fallback`
|
|
46
|
+
|
|
47
|
+
3. **If `--subagent` specified** → **Subagent Delegation** directly (no TeamCreate attempt):
|
|
48
|
+
- Announce: `**Execution Mode: Subagent Delegation** — per user request`
|
|
49
|
+
|
|
50
|
+
For all Agent Teams modes (Sequential and Parallel):
|
|
51
|
+
- You are the **team lead** in delegate mode — you coordinate phases, present quality gates, and manage the workflow. You NEVER write code, specs, or project files directly. All work is done by teammates. (Tip: the user can press Shift+Tab to system-enforce delegate mode.)
|
|
52
|
+
- After completion or if the user cancels, shut down all active teammates and clean up the team (see Cleanup section)
|
|
53
|
+
|
|
54
|
+
For Subagent Delegation:
|
|
55
|
+
- For each phase, delegate via `Task()` with the parameters specified in phase sections below
|
|
56
|
+
|
|
57
|
+
The user MUST see the execution mode announcement before any phase work begins. The phases, quality gates, and interactions are identical across all paths.
|
|
38
58
|
|
|
39
59
|
> **Note:** Agent Teams is experimental and the API may change.
|
|
40
60
|
|
|
41
|
-
|
|
61
|
+
## Step 2.5: Autonomous Mode Detection
|
|
62
|
+
|
|
63
|
+
Set `AUTONOMOUS_MODE = true` if ANY of these match:
|
|
64
|
+
|
|
65
|
+
a. **Flags**: `$ARGUMENTS` contains `--autonomous` or `--auto`
|
|
42
66
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
- Wait for the teammate to complete the task
|
|
49
|
-
- Review the teammate's output
|
|
50
|
-
- Present results at the quality gate for user approval
|
|
51
|
-
- Shut down the teammate before spawning the next phase's teammate
|
|
52
|
-
4. After Phase 3 completes or if the user cancels at any point, shut down all active teammates (see Cleanup section)
|
|
67
|
+
b. **Natural language** (case-insensitive match in `$ARGUMENTS` OR the user's preceding conversation message):
|
|
68
|
+
- Approval intent: "approve all", "pre-approve", "preapprove", "auto-approve"
|
|
69
|
+
- Mode intent: "autonomous mode", "autonomous", "unattended", "hands off", "hands-off"
|
|
70
|
+
- Proceed intent: "don't stop to ask", "don't ask me", "no approval needed", "just run through", "run it all", "run straight through", "proceed without asking", "skip the gates", "go all the way through"
|
|
71
|
+
- Delegation intent: "I trust your judgement", "use your best judgement", "defer to your judgement", "you decide"
|
|
53
72
|
|
|
54
|
-
|
|
73
|
+
c. **Contextual** — if the user's message conveys clear intent for the lead to operate without stopping (even if none of the exact phrases above match), interpret that as autonomous mode. The spirit of the instruction matters more than exact phrasing.
|
|
55
74
|
|
|
56
|
-
|
|
75
|
+
Default: `AUTONOMOUS_MODE = false`
|
|
76
|
+
|
|
77
|
+
If `AUTONOMOUS_MODE = true`, announce after the execution mode announcement:
|
|
78
|
+
> **Autonomous Mode: ACTIVE** — Gates presented for transparency but auto-approved.
|
|
79
|
+
> Safety exceptions still pause: critical blockers, HIGH/CRITICAL security findings, >3 same-phase failures, complex architecture discrepancies, >3 gap-fix iterations per partition.
|
|
57
80
|
|
|
58
81
|
## Step 3: Load Context Files (ONCE)
|
|
59
82
|
|
|
@@ -67,7 +90,7 @@ Read these files ONCE (do NOT re-read between phases):
|
|
|
67
90
|
|
|
68
91
|
If MCP is configured and enterprise compliance is enabled:
|
|
69
92
|
1. Check `knowzcode/enterprise/compliance_manifest.md` for `mcp_compliance_enabled: true`
|
|
70
|
-
2. If enabled: `ask_question(
|
|
93
|
+
2. If enabled: Read `knowzcode/knowzcode_vaults.md` to find vault matching type "enterprise", then `ask_question({resolved_enterprise_vault_id}, "team standards for {project_type}")`
|
|
71
94
|
3. Merge returned standards into WorkGroup context for quality gate criteria
|
|
72
95
|
|
|
73
96
|
If MCP is not configured or enterprise is not enabled, skip this step.
|
|
@@ -82,6 +105,7 @@ Create `knowzcode/workgroups/{WorkGroupID}.md`:
|
|
|
82
105
|
**Created**: {timestamp}
|
|
83
106
|
**Status**: Active
|
|
84
107
|
**Current Phase**: 1A - Impact Analysis
|
|
108
|
+
**Autonomous Mode**: Active/Inactive
|
|
85
109
|
|
|
86
110
|
## Change Set
|
|
87
111
|
(Populated after Phase 1A)
|
|
@@ -104,6 +128,108 @@ Create `knowzcode/workgroups/{WorkGroupID}.md`:
|
|
|
104
128
|
|
|
105
129
|
If ambiguous, proceed with implementation.
|
|
106
130
|
|
|
131
|
+
## Step 5.5: Complexity Classification
|
|
132
|
+
|
|
133
|
+
Assess the goal against the codebase to determine the appropriate workflow tier.
|
|
134
|
+
|
|
135
|
+
### Tier 1: Micro → redirect to `/kc:fix`
|
|
136
|
+
- Single file, <50 lines, no ripple effects
|
|
137
|
+
|
|
138
|
+
### Tier 2: Light (2-phase workflow)
|
|
139
|
+
ALL must be true:
|
|
140
|
+
- ≤3 files touched
|
|
141
|
+
- Single NodeID (1 new capability)
|
|
142
|
+
- No architectural changes
|
|
143
|
+
- No security-sensitive components (auth, payments, PII)
|
|
144
|
+
- No external API integrations
|
|
145
|
+
- Estimated <200 lines of change
|
|
146
|
+
|
|
147
|
+
### Tier 3: Full (5-phase workflow)
|
|
148
|
+
ANY triggers full:
|
|
149
|
+
- >3 files or >1 NodeID
|
|
150
|
+
- Architectural impact
|
|
151
|
+
- Security-sensitive scope
|
|
152
|
+
- External integrations
|
|
153
|
+
- User explicitly requests: `--tier full`
|
|
154
|
+
|
|
155
|
+
**Announce the detected tier to the user.** User can override:
|
|
156
|
+
- "use full" or `--tier full` → Tier 3
|
|
157
|
+
- "use light" or `--tier light` → Tier 2
|
|
158
|
+
|
|
159
|
+
If `$ARGUMENTS` contains `--tier light`, force Tier 2. If `--tier full`, force Tier 3.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Tier 2: Light Workflow (2-phase fast path)
|
|
164
|
+
|
|
165
|
+
When Tier 2 is selected, execute this streamlined workflow instead of the 5-phase Tier 3 below.
|
|
166
|
+
|
|
167
|
+
### Light Phase 1 (Inline — lead does this, no agent)
|
|
168
|
+
|
|
169
|
+
1. Quick impact scan: grep for related files, check existing specs
|
|
170
|
+
2. Propose a Change Set (typically 1 NodeID)
|
|
171
|
+
3. Draft a lightweight spec (or reference existing spec if found) — use the 4-section format from `knowzcode_loop.md` section 3.2. Minimum: 1 Rule, 1 Interface, 2 `VERIFY:` statements.
|
|
172
|
+
4. Present combined Change Set + Spec for approval:
|
|
173
|
+
|
|
174
|
+
```markdown
|
|
175
|
+
## Light Mode: Change Set + Spec Approval
|
|
176
|
+
|
|
177
|
+
**WorkGroupID**: {wgid}
|
|
178
|
+
**Tier**: 2 (Light)
|
|
179
|
+
**NodeID**: {NodeID} — {description}
|
|
180
|
+
**Affected Files**: {list}
|
|
181
|
+
|
|
182
|
+
**Spec Summary**:
|
|
183
|
+
- Rules: {key decisions}
|
|
184
|
+
- Interfaces: {public contracts}
|
|
185
|
+
- VERIFY: {criteria list}
|
|
186
|
+
|
|
187
|
+
Approve Change Set and spec to proceed to implementation?
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
5. **Autonomous Mode**: If `AUTONOMOUS_MODE = true`, log `[AUTO-APPROVED] Light mode gate` and proceed directly to implementation.
|
|
191
|
+
If `AUTONOMOUS_MODE = false`: If rejected — adjust based on feedback and re-present. If approved:
|
|
192
|
+
- Update `knowzcode_tracker.md` with NodeID status `[WIP]`
|
|
193
|
+
- Pre-implementation commit: `git add knowzcode/ && git commit -m "KnowzCode: Light spec approved for {wgid}"`
|
|
194
|
+
|
|
195
|
+
### Light Phase 2A: Implementation (Builder agent)
|
|
196
|
+
|
|
197
|
+
Spawn the builder using the standard Phase 2A prompt below (same for both tiers).
|
|
198
|
+
|
|
199
|
+
The builder self-verifies against spec VERIFY criteria — no separate audit phase.
|
|
200
|
+
|
|
201
|
+
### Light Phase 3 (Inline — lead does this, no agent)
|
|
202
|
+
|
|
203
|
+
After builder completes successfully:
|
|
204
|
+
1. Update spec to As-Built status
|
|
205
|
+
2. Update `knowzcode_tracker.md`: NodeID status `[WIP]` → `[VERIFIED]`
|
|
206
|
+
3. Write a brief log entry to `knowzcode_log.md`:
|
|
207
|
+
```markdown
|
|
208
|
+
---
|
|
209
|
+
**Type:** ARC-Completion
|
|
210
|
+
**Timestamp:** [timestamp]
|
|
211
|
+
**WorkGroupID:** [ID]
|
|
212
|
+
**NodeID(s):** [list]
|
|
213
|
+
**Logged By:** AI-Agent
|
|
214
|
+
**Details:** Light mode (Tier 2). {brief summary of implementation}.
|
|
215
|
+
---
|
|
216
|
+
```
|
|
217
|
+
4. Final commit: `git add knowzcode/ <changed files> && git commit -m "feat: {goal} (WorkGroup {wgid})"`
|
|
218
|
+
5. Report completion.
|
|
219
|
+
|
|
220
|
+
**DONE** — 3 agents skipped (analyst, architect, reviewer, closer).
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Tier 3: Full Workflow (5-phase)
|
|
225
|
+
|
|
226
|
+
The standard 5-phase workflow. Used when complexity warrants full analysis, specification, audit, and finalization.
|
|
227
|
+
|
|
228
|
+
Tier 3 supports three execution modes (determined in Step 2):
|
|
229
|
+
- **Parallel Teams** (default) — Stage 0-3 orchestration with concurrent agents
|
|
230
|
+
- **Sequential Teams** (`--sequential`) — one agent per phase, spawned and shut down sequentially
|
|
231
|
+
- **Subagent Delegation** — Task() calls, no persistent agents
|
|
232
|
+
|
|
107
233
|
## Step 6: Spec Detection (Optional Optimization)
|
|
108
234
|
|
|
109
235
|
Check for existing specs covering this work:
|
|
@@ -116,33 +242,340 @@ Check for existing specs covering this work:
|
|
|
116
242
|
|
|
117
243
|
If no matches found, proceed to Phase 1A.
|
|
118
244
|
|
|
245
|
+
### Refactor Task Check
|
|
246
|
+
|
|
247
|
+
Scan `knowzcode/knowzcode_tracker.md` for outstanding `REFACTOR_` tasks that overlap with the current goal's scope. If found, mention them to the user during Phase 1A so the analyst can factor them into the Change Set.
|
|
248
|
+
|
|
119
249
|
---
|
|
120
250
|
|
|
121
|
-
##
|
|
251
|
+
## Parallel Teams Orchestration (Tier 3 Default)
|
|
252
|
+
|
|
253
|
+
When Parallel Teams mode is active, follow these 4 stages instead of spawning one agent per phase sequentially. The same phase spawn prompts (defined in the Phase Reference sections below) are reused — what changes is WHEN agents are spawned and HOW MANY run concurrently.
|
|
254
|
+
|
|
255
|
+
### Stage 0: Team Creation + Parallel Discovery
|
|
256
|
+
|
|
257
|
+
1. Create team `kc-{wgid}`
|
|
258
|
+
2. Read knowzcode context files (lead does initial load for spawn prompts)
|
|
259
|
+
3. **MCP Probe** — determine vault availability BEFORE spawning:
|
|
260
|
+
a. Read `knowzcode/knowzcode_vaults.md` — partition entries into CONFIGURED (non-empty ID) and UNCREATED (empty ID)
|
|
261
|
+
b. Call `list_vaults(includeStats=true)` **always** — regardless of whether any IDs exist in the file
|
|
262
|
+
c. If `list_vaults()` fails → set `MCP_ACTIVE = false`, announce `**MCP Status: Not connected**`, skip to Step 4
|
|
263
|
+
d. If `list_vaults()` succeeds AND UNCREATED list is non-empty → present the **Vault Creation Prompt**:
|
|
264
|
+
|
|
265
|
+
```markdown
|
|
266
|
+
## Vault Setup
|
|
267
|
+
|
|
268
|
+
Your Knowz API key is valid and MCP is connected, but {N} default vault(s) haven't been created yet.
|
|
269
|
+
Creating vaults enables knowledge capture throughout the workflow:
|
|
270
|
+
|
|
271
|
+
| Vault | Type | Description | Written During |
|
|
272
|
+
|-------|------|-------------|----------------|
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Build table rows dynamically from the UNCREATED entries only. For each uncreated vault, derive the "Written During" column from its Write Conditions field in `knowzcode_vaults.md`. Example rows:
|
|
276
|
+
- `| Code Patterns | code | Learnings, gotchas, and architecture insights from the codebase | Phase 2A (implementation patterns), Phase 3 (workarounds, performance) |`
|
|
277
|
+
- `| Ecosystem Knowledge | ecosystem | Business rules, conventions, decisions, and cross-system details | Phase 1A (scope decisions), Phase 2B (security, quality), Phase 3 (conventions) |`
|
|
278
|
+
- `| Finalizations | finalizations | Final summaries documenting complete execution and outcomes | Phase 3 (completion record) |`
|
|
279
|
+
|
|
280
|
+
Then present options:
|
|
281
|
+
```
|
|
282
|
+
Options:
|
|
283
|
+
**A) Create all {N} vaults** (recommended)
|
|
284
|
+
**B) Select which to create**
|
|
285
|
+
**C) Skip** — proceed without vaults (can create later with `/kc:connect-mcp --configure-vaults`)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
e. Handle user selection:
|
|
289
|
+
- **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 the ID field with the server-returned vault ID and change the H3 heading from `(not created)` to the vault ID. If creation fails for some vaults, update only successful ones, report failures, and let user decide.
|
|
290
|
+
- **B**: Ask which vaults to create, then create only selected ones using the same process as A.
|
|
291
|
+
- **C**: Log `"Vault creation skipped — knowledge capture disabled."` Continue.
|
|
292
|
+
f. After resolution, set:
|
|
293
|
+
- `MCP_ACTIVE = true` (MCP works regardless of vault creation outcome)
|
|
294
|
+
- `VAULTS_CONFIGURED = true` if at least 1 vault now has a valid ID, else `false`
|
|
295
|
+
- Announce: `**MCP Status: Connected — N vault(s) available**` or `**MCP Status: Connected — no vaults configured (knowledge capture disabled)**`
|
|
296
|
+
4. **Spawn Group A** (always — 5 agents):
|
|
297
|
+
Create tasks first, pre-assign, then spawn with task IDs:
|
|
298
|
+
- `TaskCreate("Scout: specs context")` → `TaskUpdate(owner: "context-scout-specs")`
|
|
299
|
+
- `TaskCreate("Scout: workgroups context")` → `TaskUpdate(owner: "context-scout-workgroups")`
|
|
300
|
+
- `TaskCreate("Scout: backlog context")` → `TaskUpdate(owner: "context-scout-backlog")`
|
|
301
|
+
- `TaskCreate("Phase 1A: Impact analysis for {goal}")` → `TaskUpdate(owner: "analyst")`
|
|
302
|
+
- `TaskCreate("Pre-load architecture context")` → `TaskUpdate(owner: "architect")`
|
|
303
|
+
Spawn all 5 agents with their `{task-id}` in the spawn prompt (use spawn prompts from Phase Prompt Reference below).
|
|
304
|
+
5. **Spawn Group B** (MCP agents — same turn as Group A): If `VAULTS_CONFIGURED = true`:
|
|
305
|
+
Create tasks first, pre-assign, then spawn with task IDs:
|
|
306
|
+
- `TaskCreate("Knowz-scout: vault queries")` → `TaskUpdate(owner: "knowz-scout")`
|
|
307
|
+
- `TaskCreate("Knowz-scribe: listen")` → `TaskUpdate(owner: "knowz-scribe")`
|
|
308
|
+
Spawn both agents with their `{task-id}` in the spawn prompt.
|
|
309
|
+
If `VAULTS_CONFIGURED = false`, skip Group B and log: `Vault agents skipped — no vaults configured.`
|
|
310
|
+
6. **Roster confirmation** — lead lists every spawned agent by name to the user. If `VAULTS_CONFIGURED` was true but knowz-scout or knowz-scribe is missing from the roster, STOP and re-spawn the missing agent(s) before continuing.
|
|
311
|
+
7. All 5-7 agents work immediately in parallel (3 context scouts are cheap Sonnet read-only agents; knowz-scribe is a cheap Haiku agent)
|
|
312
|
+
8. Scouts broadcast findings → analyst and architect consume as messages
|
|
313
|
+
|
|
314
|
+
**Key**: The analyst does NOT wait for scouts to finish. It starts scanning the codebase immediately. Scout findings arrive as messages and enrich the analyst's work as they arrive.
|
|
315
|
+
|
|
316
|
+
### Stage 1: Analysis + Specification
|
|
317
|
+
|
|
318
|
+
1. Analyst completes Change Set (includes dependency map — see `agents/analyst.md`)
|
|
319
|
+
2. Lead reads analyst's task summary
|
|
320
|
+
3. Lead presents **Quality Gate #1** to user:
|
|
321
|
+
- Change Set with NodeIDs, descriptions, affected files
|
|
322
|
+
- Dependency map showing which NodeIDs can be implemented in parallel
|
|
323
|
+
- Risk assessment
|
|
324
|
+
4. User approves (or rejects → re-run analyst with feedback)
|
|
325
|
+
5. Lead sends DM to architect with the approved Change Set
|
|
326
|
+
6. Lead creates spec-drafting tasks for architect (1 task per NodeID, `addBlockedBy: [analysis-task-id]`):
|
|
327
|
+
- `TaskCreate("Spec: NodeID-X")` → `TaskUpdate(taskId, owner: "architect")`
|
|
328
|
+
- DM architect with task IDs: `"**New Tasks**: #{id-1} Spec: NodeID-A, #{id-2} Spec: NodeID-B. Approved Change Set: {summary}"`
|
|
329
|
+
- Architect is already warm (pre-loaded during Stage 0) → specs drafted FAST
|
|
330
|
+
- If Gate #1 rejected: shut down architect, re-run analyst with feedback, re-spawn architect after
|
|
331
|
+
7. Architect completes specs
|
|
332
|
+
8. Lead presents **Quality Gate #2** to user:
|
|
333
|
+
- Spec summaries with VERIFY criteria
|
|
334
|
+
9. User approves (or rejects → architect revises)
|
|
335
|
+
10. Pre-implementation commit: `git add knowzcode/ && git commit -m "KnowzCode: Specs approved for {wgid}"`
|
|
336
|
+
11. Shut down context-scouts (no longer needed after specs approved). Keep knowz-scout alive for vault queries during implementation.
|
|
337
|
+
12. Keep analyst alive briefly (available for scope questions during early implementation)
|
|
338
|
+
13. Keep architect alive through Stage 2 (consultative role — spec clarifications for builders, no code or spec edits)
|
|
339
|
+
|
|
340
|
+
### Stage 2: Parallel Implementation + Incremental Review
|
|
341
|
+
|
|
342
|
+
1. Lead examines dependency map from analyst:
|
|
343
|
+
- Group NodeIDs into independent partitions (no shared files between groups)
|
|
344
|
+
- Determine builder count: 1 builder per independent group, max 5
|
|
345
|
+
|
|
346
|
+
2. Create builder tasks and spawn:
|
|
347
|
+
- `TaskCreate("Implement NodeIDs [A, B]", addBlockedBy: [spec-task-id])` → `TaskUpdate(owner: "builder-1")`
|
|
348
|
+
- `TaskCreate("Implement NodeIDs [C]", addBlockedBy: [spec-task-id])` → `TaskUpdate(owner: "builder-2")`
|
|
349
|
+
- `TaskCreate("Implement NodeIDs [D, E]", addBlockedBy: [spec-task-id])` → `TaskUpdate(owner: "builder-3")`
|
|
350
|
+
Spawn each builder with its `{task-id}` in the spawn prompt.
|
|
351
|
+
Each builder gets its partition's specs + affected files list.
|
|
352
|
+
**NO TWO BUILDERS TOUCH THE SAME FILE**
|
|
353
|
+
|
|
354
|
+
3. Notify architect of builder spawn:
|
|
355
|
+
- Lead DMs architect: `"Builders spawned for Stage 2. Introduce yourself to: {builder-1, builder-2, ...}"`
|
|
356
|
+
- Architect sends brief availability message to each builder (see `agents/architect.md` — Proactive Availability)
|
|
357
|
+
|
|
358
|
+
4. Each builder creates subtasks per NodeID in the task list:
|
|
359
|
+
- `"TDD: NodeID-A tests"` → `"TDD: NodeID-A implementation"` → `"TDD: NodeID-A verify"`
|
|
360
|
+
- Builder works through subtasks, marks each complete with summary
|
|
361
|
+
|
|
362
|
+
5. Create reviewer tasks and spawn — one per builder partition:
|
|
363
|
+
- `TaskCreate("Audit partition 1: NodeIDs [A, B]", addBlockedBy: [implement-A-task-id])` → `TaskUpdate(owner: "reviewer-1")`
|
|
364
|
+
- `TaskCreate("Audit partition 2: NodeIDs [C]", addBlockedBy: [implement-C-task-id])` → `TaskUpdate(owner: "reviewer-2")`
|
|
365
|
+
- `TaskCreate("Audit partition 3: NodeIDs [D, E]", addBlockedBy: [implement-D-task-id])` → `TaskUpdate(owner: "reviewer-3")`
|
|
366
|
+
Spawn each reviewer with its `{task-id}` + partition's specs + VERIFY criteria.
|
|
367
|
+
Reviewer stays idle until its paired builder marks first NodeID implementation complete.
|
|
368
|
+
Each reviewer audits incrementally within its partition.
|
|
369
|
+
|
|
370
|
+
6. Gap flow (per-partition, parallel — persistent agents, DM messaging):
|
|
371
|
+
a. Each reviewer marks audit task complete with structured gap report in summary
|
|
372
|
+
b. Lead creates fix task and pre-assigns:
|
|
373
|
+
`TaskCreate("Fix gaps: NodeID-A", addBlockedBy: [audit-task-id])` → `TaskUpdate(owner: "builder-N")`
|
|
374
|
+
c. Lead sends DM to builder with task ID and gap details:
|
|
375
|
+
> **New Task**: #{fix-task-id} — Fix gaps: NodeID-A
|
|
376
|
+
> **Gaps**: {file path, VERIFY criterion not met, expected vs actual}
|
|
377
|
+
> Fix each gap, re-run affected tests, report completion.
|
|
378
|
+
d. Builder claims fix task, fixes gaps, re-runs tests, marks fix task complete
|
|
379
|
+
e. Lead creates re-audit task and pre-assigns:
|
|
380
|
+
`TaskCreate("Re-audit: NodeID-A", addBlockedBy: [gap-fix-task-id])` → `TaskUpdate(owner: "reviewer-N")`
|
|
381
|
+
f. Lead sends DM to reviewer: `"**New Task**: #{reaudit-task-id} — Re-audit: NodeID-A. {gap list}"`
|
|
382
|
+
g. Each builder-reviewer pair repeats independently until clean — no cross-partition blocking
|
|
383
|
+
— All builders and reviewers stay alive through the entire gap loop (no respawning)
|
|
384
|
+
|
|
385
|
+
7. Enterprise compliance (if enabled):
|
|
386
|
+
- Lead creates parallel compliance task for each reviewer (scoped to their partition)
|
|
387
|
+
- Reviewer checks compliance requirements from knowz-scout findings
|
|
388
|
+
- Runs alongside ARC audits
|
|
389
|
+
|
|
390
|
+
8. Inter-agent communication during Stage 2:
|
|
391
|
+
- builder → architect: Spec clarification requests (direct messages)
|
|
392
|
+
- architect → builder: Design guidance and spec intent responses (direct messages)
|
|
393
|
+
- builder ↔ builder: Dependency coordination (direct messages — "I changed the User interface, FYI")
|
|
394
|
+
- builder → reviewer (same partition): Implementation complete notifications (via task system)
|
|
395
|
+
- reviewer → lead: Gap reports per partition (structured format via task summaries)
|
|
396
|
+
- lead → builder: Fix tasks (via task creation + DM)
|
|
397
|
+
- lead → reviewer: Re-audit requests (via task creation + DM)
|
|
398
|
+
|
|
399
|
+
9. After all NodeIDs implemented + audited across all partitions:
|
|
400
|
+
- Lead consolidates audit results from all reviewers
|
|
401
|
+
- Lead presents **Quality Gate #3**:
|
|
402
|
+
- Per-NodeID ARC completion % (from each partition's reviewer)
|
|
403
|
+
- Combined security posture
|
|
404
|
+
- Combined integration health
|
|
405
|
+
- Enterprise compliance (if applicable)
|
|
406
|
+
- User decides: proceed / fix gaps / modify specs / cancel
|
|
407
|
+
|
|
408
|
+
10. Shut down analyst, architect, all builders, and all reviewers
|
|
409
|
+
|
|
410
|
+
### Stage 3: Finalization
|
|
411
|
+
|
|
412
|
+
1. `TaskCreate("Phase 3: Finalize {wgid}", addBlockedBy: [last-audit-task-id])` → `TaskUpdate(owner: "closer")`
|
|
413
|
+
Spawn `closer` with `{task-id}` in spawn prompt.
|
|
414
|
+
2. Closer tasks (can be parallel subtasks):
|
|
415
|
+
- Update all specs to FINAL as-built
|
|
416
|
+
- Update `knowzcode_tracker.md`: all NodeIDs `[WIP]` → `[VERIFIED]`
|
|
417
|
+
- Write ARC-Completion log entry
|
|
418
|
+
- Review architecture docs for discrepancies
|
|
419
|
+
- Schedule REFACTOR tasks for tech debt
|
|
420
|
+
- Send learnings to knowz-scribe (if active): `"Capture Phase 3: {wgid}"`. Knowz-scout remains available for vault queries during finalization.
|
|
421
|
+
- Create final atomic commit
|
|
422
|
+
3. Lead presents completion summary
|
|
423
|
+
4. Shut down knowz-scout, knowz-scribe (after Phase 3 capture completes), closer, and all remaining agents
|
|
424
|
+
5. Delete team
|
|
425
|
+
|
|
426
|
+
### WorkGroup File Format (Parallel Mode)
|
|
427
|
+
|
|
428
|
+
In Parallel Teams mode, the WorkGroup file uses per-NodeID phase tracking instead of a single `Current Phase`:
|
|
122
429
|
|
|
123
|
-
|
|
430
|
+
```markdown
|
|
431
|
+
## Change Set
|
|
432
|
+
| NodeID | Phase | Builder | Status | Timestamp |
|
|
433
|
+
|--------|-------|---------|--------|-----------|
|
|
434
|
+
| Authentication | 2A | builder-1 | Implementing | ... |
|
|
435
|
+
| UserProfile | 2B | builder-1 | Under review | ... |
|
|
436
|
+
| LIB_DateFormat | 2A | builder-2 | Tests passing | ... |
|
|
437
|
+
|
|
438
|
+
## Autonomous Mode
|
|
439
|
+
Active/Inactive
|
|
440
|
+
|
|
441
|
+
## Current Stage
|
|
442
|
+
Stage 2: Parallel Implementation + Incremental Review
|
|
443
|
+
```
|
|
124
444
|
|
|
125
|
-
|
|
445
|
+
### Task Dependency Graph
|
|
446
|
+
|
|
447
|
+
When creating tasks, model the dependency chain with `addBlockedBy` and pre-assign with `owner`:
|
|
448
|
+
|
|
449
|
+
| Task | Blocked By | Owner |
|
|
450
|
+
|------|-----------|-------|
|
|
451
|
+
| Scout: specs context | (none) | context-scout-specs |
|
|
452
|
+
| Scout: workgroups context | (none) | context-scout-workgroups |
|
|
453
|
+
| Scout: backlog context | (none) | context-scout-backlog |
|
|
454
|
+
| Knowz-scout: vault queries | (none — persistent) | knowz-scout |
|
|
455
|
+
| Knowz-scribe: listen | (none — persistent) | knowz-scribe |
|
|
456
|
+
| Phase 1A analysis | (none — scouts enrich via broadcast) | analyst |
|
|
457
|
+
| Architect pre-load | (none) | architect |
|
|
458
|
+
| Spec: NodeID-X | Phase 1A (gate approval) | architect |
|
|
459
|
+
| Implement: NodeID-X | Spec: NodeID-X | builder-N |
|
|
460
|
+
| Audit: NodeID-X | Implement: NodeID-X | reviewer-N |
|
|
461
|
+
| Fix gaps: NodeID-X round N | Audit: NodeID-X (or re-audit N-1) | builder-N |
|
|
462
|
+
| Re-audit: NodeID-X round N | Fix gaps round N | reviewer-N |
|
|
463
|
+
| Phase 3 finalization | All audits approved | closer |
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
## Sequential Teams / Subagent Flow (Tier 3 Fallback)
|
|
468
|
+
|
|
469
|
+
When using Sequential Teams (`--sequential`) or Subagent Delegation, follow the traditional one-agent-per-phase flow. For each phase below: spawn the agent, create a task, wait for completion, present quality gate, shut down agent, proceed to next phase.
|
|
470
|
+
|
|
471
|
+
---
|
|
126
472
|
|
|
473
|
+
## Phase Prompt Reference
|
|
474
|
+
|
|
475
|
+
The spawn prompts below are shared by all execution modes. In Parallel Teams mode, the lead uses these prompts when spawning agents at the appropriate stage. In Sequential Teams / Subagent mode, agents are spawned one at a time in phase order.
|
|
476
|
+
|
|
477
|
+
## Stage 0: Context Scouts (3 instances)
|
|
478
|
+
|
|
479
|
+
**Agent**: `context-scout` (x3) | Read-only local context researchers
|
|
480
|
+
|
|
481
|
+
Three instances of the same agent, each focused on a different local folder group:
|
|
482
|
+
|
|
483
|
+
**context-scout-specs spawn prompt**:
|
|
484
|
+
> You are `context-scout-specs` for WorkGroup `{wgid}`.
|
|
485
|
+
> Read `agents/context-scout.md` for your full role definition.
|
|
486
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
487
|
+
> **Focus area**: `knowzcode/specs/*.md` — scan existing specifications.
|
|
488
|
+
> **Goal**: {goal}
|
|
489
|
+
> **READ-ONLY.** Do NOT modify any files.
|
|
490
|
+
> **Deliverable**: Broadcast relevant spec findings (NodeIDs, status, VERIFY criteria overlapping with goal).
|
|
491
|
+
|
|
492
|
+
**context-scout-workgroups spawn prompt**:
|
|
493
|
+
> You are `context-scout-workgroups` for WorkGroup `{wgid}`.
|
|
494
|
+
> Read `agents/context-scout.md` for your full role definition.
|
|
495
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
496
|
+
> **Focus area**: `knowzcode/workgroups/*.md` — scan previous WorkGroups for similar goals.
|
|
497
|
+
> **Goal**: {goal}
|
|
498
|
+
> **READ-ONLY.** Do NOT modify any files.
|
|
499
|
+
> **Deliverable**: Broadcast prior WorkGroup context (what was tried, what succeeded/failed, patterns).
|
|
500
|
+
|
|
501
|
+
**context-scout-backlog spawn prompt**:
|
|
502
|
+
> You are `context-scout-backlog` for WorkGroup `{wgid}`.
|
|
503
|
+
> Read `agents/context-scout.md` for your full role definition.
|
|
504
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
505
|
+
> **Focus area**: `knowzcode/knowzcode_tracker.md`, `knowzcode/knowzcode_log.md`, `knowzcode/knowzcode_architecture.md`, `knowzcode/knowzcode_project.md`
|
|
506
|
+
> **Goal**: {goal}
|
|
507
|
+
> **READ-ONLY.** Do NOT modify any files.
|
|
508
|
+
> **Deliverable**: Broadcast active WIP, REFACTOR tasks, architecture summary, and recent log patterns relevant to goal.
|
|
509
|
+
|
|
510
|
+
**Dispatch**:
|
|
511
|
+
- *Parallel Teams*: All 3 context scouts spawned at Stage 0, no blockedBy. Shut down after Gate #2 (specs approved).
|
|
512
|
+
- *Sequential Teams*: Not applicable (scouts are Parallel Teams only).
|
|
513
|
+
- *Subagent*: `Task(subagent_type="context-scout", name="context-scout-specs", ...)`, `Task(subagent_type="context-scout", name="context-scout-workgroups", ...)`, `Task(subagent_type="context-scout", name="context-scout-backlog", ...)`
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Stage 0: Knowz Scout
|
|
518
|
+
|
|
519
|
+
**Agent**: `knowz-scout` | MCP vault researcher and knowledge agent
|
|
520
|
+
|
|
521
|
+
**Spawn prompt**:
|
|
522
|
+
> You are the **knowz-scout** for WorkGroup `{wgid}`.
|
|
523
|
+
> Read `agents/knowz-scout.md` for your full role definition.
|
|
524
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
525
|
+
> **Goal**: {goal}
|
|
526
|
+
> **Step 1**: Read `knowzcode/knowzcode_vaults.md` to discover configured vaults — their IDs, types, descriptions, and what knowledge each contains.
|
|
527
|
+
> **Step 2**: For each configured vault, construct goal-relevant queries using the vault's description to guide what to ask. If a single vault covers all knowledge, consolidate queries there.
|
|
528
|
+
> **Deliverable**: Broadcast vault knowledge findings to all teammates.
|
|
529
|
+
|
|
530
|
+
**Dispatch**:
|
|
531
|
+
- *Parallel Teams*: **Group B** — spawned at Stage 0 if `VAULTS_CONFIGURED = true`, no blockedBy. Persistent — stays alive through the entire workflow. Shut down after Phase 3 capture is complete.
|
|
532
|
+
- *Sequential Teams*: Not applicable (scouts are Parallel Teams only).
|
|
533
|
+
- *Subagent*: `Task(subagent_type="knowz-scout", description="Query vault for domain knowledge", prompt=<above>)` (only if MCP Probe passes)
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
## Stage 0: Knowz Scribe
|
|
538
|
+
|
|
539
|
+
**Agent**: `knowz-scribe` | Persistent vault write agent (Haiku)
|
|
540
|
+
|
|
541
|
+
**Spawn prompt**:
|
|
542
|
+
> You are the **knowz-scribe** for WorkGroup `{wgid}`.
|
|
543
|
+
> Read `agents/knowz-scribe.md` for your full role definition.
|
|
544
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
545
|
+
> **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
|
|
546
|
+
> **Vault config**: Read `knowzcode/knowzcode_vaults.md` to discover configured vaults and resolve vault IDs by type.
|
|
547
|
+
> **You are a message-driven agent.** Wait for capture messages from teammates (e.g., "Capture Phase 1A: {wgid}"). On each message, read the WorkGroup file, extract relevant learnings, and write to the appropriate vault.
|
|
548
|
+
> **Do NOT read or modify source code.** You only read knowzcode/ files and write to MCP vaults.
|
|
549
|
+
|
|
550
|
+
**Dispatch**:
|
|
551
|
+
- *Parallel Teams*: **Group B** — spawned at Stage 0 if `VAULTS_CONFIGURED = true`, no blockedBy. Persistent — stays alive through the entire workflow. Shut down after Phase 3 capture is complete.
|
|
552
|
+
- *Sequential Teams*: Not applicable (knowz-scribe is Parallel Teams only).
|
|
553
|
+
- *Subagent*: Not applicable — vault writes in subagent mode are handled inline by the lead.
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
## Phase 1A: Impact Analysis
|
|
558
|
+
|
|
559
|
+
**Agent**: `analyst` | **Loop.md**: Section 3.1
|
|
560
|
+
|
|
561
|
+
**Spawn prompt**:
|
|
127
562
|
> You are the **analyst** for WorkGroup `{wgid}`.
|
|
128
563
|
> Read `agents/analyst.md` for your full role definition.
|
|
129
|
-
> Read `knowzcode/claude_code_execution.md` for team conventions.
|
|
130
564
|
>
|
|
131
565
|
> **Goal**: {goal}
|
|
132
|
-
> **Context files**: `knowzcode/knowzcode_loop.md
|
|
566
|
+
> **Context files**: Read sections 1-2 and 3.1 of `knowzcode/knowzcode_loop.md` (skip other phases), `knowzcode/knowzcode_tracker.md`, `knowzcode/knowzcode_project.md`, `knowzcode/knowzcode_architecture.md`
|
|
133
567
|
> **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
|
|
134
568
|
>
|
|
135
|
-
> **
|
|
136
|
-
> **
|
|
137
|
-
|
|
138
|
-
Create task: `Phase 1A: Impact analysis for "{goal}"` and assign to the analyst.
|
|
139
|
-
Wait for task completion, then review the Change Set output.
|
|
140
|
-
|
|
141
|
-
### Subagent Mode
|
|
569
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
570
|
+
> **Conventions**: Update WorkGroup file with results (prefix entries with `KnowzCode:`). If blocked, report blocker and notify lead.
|
|
571
|
+
> **Deliverable**: Change Set proposal written to the WorkGroup file. Include NodeIDs, descriptions, affected files, risk assessment, and dependency map (for Parallel Teams mode).
|
|
142
572
|
|
|
143
|
-
|
|
573
|
+
**Dispatch**:
|
|
574
|
+
- *Parallel Teams*: Spawned at Stage 0 alongside scouts and architect. Starts immediately (no blockedBy).
|
|
575
|
+
- *Sequential Teams*: Spawn teammate `analyst`, create task `Phase 1A: Impact analysis for "{goal}"`, wait for completion.
|
|
576
|
+
- *Subagent*: `Task(subagent_type="analyst", description="Phase 1A impact analysis", prompt=<above>)`
|
|
144
577
|
|
|
145
|
-
### Quality Gate #1
|
|
578
|
+
### Quality Gate #1
|
|
146
579
|
|
|
147
580
|
Present the Change Set for user approval:
|
|
148
581
|
|
|
@@ -153,44 +586,52 @@ Present the Change Set for user approval:
|
|
|
153
586
|
**Proposed Change Set** ({N} nodes):
|
|
154
587
|
{NodeIDs with descriptions}
|
|
155
588
|
|
|
589
|
+
**Dependency Map** (Parallel Teams):
|
|
590
|
+
{NodeID parallelism groups}
|
|
591
|
+
|
|
156
592
|
**Risk Assessment**: {Low/Medium/High}
|
|
157
593
|
|
|
158
594
|
Approve this Change Set to proceed to specification?
|
|
159
595
|
```
|
|
160
596
|
|
|
161
|
-
|
|
597
|
+
**Autonomous Mode**: If `AUTONOMOUS_MODE = true`, present gate info for transparency, log `[AUTO-APPROVED] Gate #1`, and proceed immediately.
|
|
598
|
+
If `AUTONOMOUS_MODE = false`: If rejected — re-run analyst with user feedback. If approved — update tracker, proceed.
|
|
599
|
+
|
|
600
|
+
### MCP Learning Capture (Optional)
|
|
601
|
+
|
|
602
|
+
If MCP is configured and knowz-scribe is active, after Change Set approval:
|
|
603
|
+
- Send message to **knowz-scribe**: `"Capture Phase 1A: {wgid}"` — the scribe reads the WorkGroup file, extracts scope/risk/decision data, and writes to the appropriate vault
|
|
604
|
+
- `search_knowledge({resolved_domain_vault_id}, "patterns for {domain}")` — pull relevant past learnings to inform specification
|
|
605
|
+
- Share any relevant findings with the architect in the Phase 1B prompt
|
|
162
606
|
|
|
163
607
|
---
|
|
164
608
|
|
|
165
609
|
## Phase 1B: Specification
|
|
166
610
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
Spawn a teammate named `architect` with this prompt:
|
|
611
|
+
**Agent**: `architect` | **Loop.md**: Section 3.2
|
|
170
612
|
|
|
613
|
+
**Spawn prompt**:
|
|
171
614
|
> You are the **architect** for WorkGroup `{wgid}`.
|
|
172
615
|
> Read `agents/architect.md` for your full role definition.
|
|
173
|
-
> Read `knowzcode/claude_code_execution.md` for team conventions.
|
|
174
616
|
>
|
|
175
617
|
> **Goal**: {goal}
|
|
176
618
|
> **Approved Change Set**: {NodeIDs from Gate #1}
|
|
177
|
-
> **Context files**: `knowzcode/knowzcode_loop.md
|
|
619
|
+
> **Context files**: Read sections 1-2 and 3.2 of `knowzcode/knowzcode_loop.md` (skip other phases), `knowzcode/knowzcode_project.md`, `knowzcode/knowzcode_architecture.md`
|
|
178
620
|
> **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
|
|
179
621
|
> **Specs directory**: `knowzcode/specs/`
|
|
180
622
|
>
|
|
181
|
-
> **
|
|
623
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
624
|
+
> **Conventions**: Update WorkGroup file with results (prefix entries with `KnowzCode:`). If blocked, report blocker and notify lead.
|
|
182
625
|
> **Deliverable**: Finalized specs for all NodeIDs written to `knowzcode/specs/`.
|
|
183
|
-
> **Prefix rule**: All todo entries MUST start with `KnowzCode:`.
|
|
184
|
-
|
|
185
|
-
Create task: `Phase 1B: Draft specifications for {N} NodeIDs` and assign to the architect.
|
|
186
|
-
Wait for the architect to present their plan. Review and approve or request changes.
|
|
187
|
-
After plan approval, wait for task completion.
|
|
188
626
|
|
|
189
|
-
|
|
627
|
+
**Dispatch**:
|
|
628
|
+
- *Parallel Teams*: Architect is already warm from Stage 0 pre-load. Lead sends DM with approved Change Set, then creates spec-drafting tasks. **Plan approval enabled** — add to prompt: `Present your spec design for lead review BEFORE writing final specs. Wait for approval.` If `AUTONOMOUS_MODE = true`: auto-approve `plan_approval_request` immediately. Log `[AUTO-APPROVED] Architect plan`.
|
|
629
|
+
- *Sequential Teams*: Spawn teammate `architect`, create task `Phase 1B: Draft specifications for {N} NodeIDs`. **Plan approval enabled** — add to prompt: `Present your spec design for lead review BEFORE writing final specs. Wait for approval.` Wait for `plan_approval_request`, review, respond with `plan_approval_response`. If `AUTONOMOUS_MODE = true`: auto-approve immediately. Log `[AUTO-APPROVED] Architect plan`.
|
|
630
|
+
- *Subagent*: `Task(subagent_type="architect", description="Phase 1B specification drafting", prompt=<above> + "Present your spec design in your output for lead review.")`
|
|
190
631
|
|
|
191
|
-
|
|
632
|
+
> **Note:** Plan approval (agent pauses for lead review) only works in Agent Teams mode via `permissionMode: plan`. In subagent mode, the architect presents its design in the output for post-hoc review.
|
|
192
633
|
|
|
193
|
-
### Quality Gate #2
|
|
634
|
+
### Quality Gate #2
|
|
194
635
|
|
|
195
636
|
Present specs for batch approval:
|
|
196
637
|
|
|
@@ -205,7 +646,8 @@ Present specs for batch approval:
|
|
|
205
646
|
Review specs and approve to proceed to implementation?
|
|
206
647
|
```
|
|
207
648
|
|
|
208
|
-
If
|
|
649
|
+
**Autonomous Mode**: If `AUTONOMOUS_MODE = true`, present gate info for transparency, log `[AUTO-APPROVED] Gate #2`, and proceed immediately.
|
|
650
|
+
If `AUTONOMOUS_MODE = false`: If rejected — re-run specs needing revision. If approved — pre-implementation commit, proceed.
|
|
209
651
|
|
|
210
652
|
**Pre-Implementation Commit:**
|
|
211
653
|
```bash
|
|
@@ -217,67 +659,65 @@ git commit -m "KnowzCode: Specs approved for {WorkGroupID}"
|
|
|
217
659
|
|
|
218
660
|
## Phase 2A: Implementation
|
|
219
661
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
Spawn a teammate named `builder` with this prompt:
|
|
662
|
+
**Agent**: `builder` | **Loop.md**: Section 3.3
|
|
223
663
|
|
|
664
|
+
**Spawn prompt**:
|
|
224
665
|
> You are the **builder** for WorkGroup `{wgid}`.
|
|
225
666
|
> Read `agents/builder.md` for your full role definition.
|
|
226
|
-
> Read `knowzcode/claude_code_execution.md` for team conventions.
|
|
227
667
|
>
|
|
228
668
|
> **Goal**: {goal}
|
|
229
669
|
> **Approved Change Set**: {NodeIDs}
|
|
230
670
|
> **Specs**: {list of spec file paths from Phase 1B}
|
|
231
|
-
> **Context files**: `knowzcode/knowzcode_loop.md
|
|
671
|
+
> **Context files**: Read sections 1-2 and 3.3 of `knowzcode/knowzcode_loop.md` (skip other phases), `knowzcode/knowzcode_project.md`
|
|
232
672
|
> **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
|
|
233
673
|
>
|
|
234
|
-
> **
|
|
674
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
675
|
+
> **Conventions**: Update WorkGroup file with results (prefix entries with `KnowzCode:`). If blocked, report blocker and notify lead.
|
|
235
676
|
> **TDD mandatory**: Write failing tests first, then implement, then refactor. Every NodeID must have tests.
|
|
236
|
-
> **
|
|
237
|
-
> **
|
|
677
|
+
> **Blocker protocol**: If you hit a blocker, document it as a Blocker Report in the WorkGroup file (see loop.md Section 11 format) and report to the lead immediately instead of guessing.
|
|
678
|
+
> **Deliverable**: All NodeIDs implemented with passing tests.
|
|
238
679
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
680
|
+
**Dispatch**:
|
|
681
|
+
- *Parallel Teams*: Multiple builders spawned at Stage 2, one per partition from the dependency map. Each builder gets its partition's NodeIDs and specs. Builders create per-NodeID subtasks for visibility. **Plan approval enabled** — add to prompt: `Present your implementation approach for lead review BEFORE writing code. Wait for approval.` If `AUTONOMOUS_MODE = true`: auto-approve `plan_approval_request` immediately. Log `[AUTO-APPROVED] Builder plan`.
|
|
682
|
+
- *Sequential Teams*: Spawn teammate `builder`, create task `Phase 2A: Implement {N} NodeIDs with TDD`. **Plan approval enabled** — add to prompt: `Present your implementation approach for lead review BEFORE writing code. Wait for approval.` Wait for `plan_approval_request`, review, respond. If `AUTONOMOUS_MODE = true`: auto-approve immediately. Log `[AUTO-APPROVED] Builder plan`.
|
|
683
|
+
- *Subagent*: `Task(subagent_type="builder", description="Phase 2A TDD implementation", mode="bypassPermissions", prompt=<above>)`
|
|
242
684
|
|
|
243
|
-
###
|
|
685
|
+
### Phase 2A Output
|
|
244
686
|
|
|
245
|
-
|
|
687
|
+
When complete, present implementation summary including files changed, tests written, and test results.
|
|
246
688
|
|
|
247
|
-
###
|
|
689
|
+
### MCP Learning Capture (Optional)
|
|
248
690
|
|
|
249
|
-
|
|
691
|
+
If MCP is configured and knowz-scribe is active, after implementation completes:
|
|
692
|
+
- Send message to **knowz-scribe**: `"Capture Phase 2A: {wgid}"` — the scribe reads implementation results from the WorkGroup file and captures patterns, workarounds, and performance optimizations to the `code` vault
|
|
250
693
|
|
|
251
694
|
---
|
|
252
695
|
|
|
253
696
|
## Phase 2B: Completeness Audit
|
|
254
697
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
Spawn a teammate named `reviewer` with this prompt:
|
|
698
|
+
**Agent**: `reviewer` | **Loop.md**: Section 3.4
|
|
258
699
|
|
|
700
|
+
**Spawn prompt**:
|
|
259
701
|
> You are the **reviewer** for WorkGroup `{wgid}`.
|
|
260
702
|
> Read `agents/reviewer.md` for your full role definition.
|
|
261
|
-
> Read `knowzcode/claude_code_execution.md` for team conventions.
|
|
262
703
|
>
|
|
263
704
|
> **Goal**: {goal}
|
|
264
705
|
> **Change Set**: {NodeIDs}
|
|
265
706
|
> **Specs**: {list of spec file paths}
|
|
266
|
-
> **Context files**: `knowzcode/knowzcode_loop.md
|
|
707
|
+
> **Context files**: Read sections 1-2 and 3.4 of `knowzcode/knowzcode_loop.md` (skip other phases), `knowzcode/knowzcode_project.md`, `knowzcode/knowzcode_architecture.md`
|
|
267
708
|
> **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
|
|
268
709
|
>
|
|
710
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
711
|
+
> **Conventions**: Update WorkGroup file with results (prefix entries with `KnowzCode:`). If blocked, report blocker and notify lead.
|
|
269
712
|
> **This is a READ-ONLY audit.** Do not modify any source code or test files.
|
|
270
|
-
> **Deliverable**: Audit report with ARC completion %, security posture, and gap list.
|
|
271
|
-
> **Prefix rule**: All todo entries MUST start with `KnowzCode:`.
|
|
713
|
+
> **Deliverable**: Audit report with ARC completion %, security posture, and gap list.
|
|
272
714
|
|
|
273
|
-
|
|
274
|
-
|
|
715
|
+
**Dispatch**:
|
|
716
|
+
- *Parallel Teams*: One reviewer per builder partition, spawned at Stage 2. Each reviewer gets its partition's NodeIDs and specs. Audit tasks use `addBlockedBy` per implementation task. Each reviewer uses structured gap report format (see `agents/reviewer.md`).
|
|
717
|
+
- *Sequential Teams*: Spawn teammate `reviewer`, create task `Phase 2B: Completeness audit for {N} NodeIDs`, wait for completion.
|
|
718
|
+
- *Subagent*: `Task(subagent_type="reviewer", description="Phase 2B completeness audit", prompt=<above>)`
|
|
275
719
|
|
|
276
|
-
###
|
|
277
|
-
|
|
278
|
-
Delegate to the **reviewer** agent via `Task()`. Pass WorkGroupID, NodeIDs, spec file paths, and context file paths.
|
|
279
|
-
|
|
280
|
-
### Quality Gate #3 (both modes)
|
|
720
|
+
### Quality Gate #3
|
|
281
721
|
|
|
282
722
|
Present audit results:
|
|
283
723
|
|
|
@@ -293,57 +733,69 @@ Present audit results:
|
|
|
293
733
|
How would you like to proceed?
|
|
294
734
|
```
|
|
295
735
|
|
|
296
|
-
|
|
736
|
+
**Autonomous Mode**: If `AUTONOMOUS_MODE = true`:
|
|
737
|
+
- **Safety check**: If any security finding rated HIGH or CRITICAL → **PAUSE** autonomous mode for this gate. Announce: `> **Autonomous Mode Paused** — HIGH/CRITICAL security finding requires manual review.`
|
|
738
|
+
- **Safety check**: If ARC completion < 50% → **PAUSE** autonomous mode for this gate. Announce: `> **Autonomous Mode Paused** — ARC completion below 50% requires manual review.`
|
|
739
|
+
- If safety checks pass and gaps found → log `[AUTO-APPROVED] Gate #3 — proceeding to gap loop`, auto-proceed to gap loop.
|
|
740
|
+
- If safety checks pass and no gaps → log `[AUTO-APPROVED] Gate #3`, auto-proceed to Phase 3.
|
|
297
741
|
|
|
298
|
-
If
|
|
742
|
+
If `AUTONOMOUS_MODE = false`: User decides — proceed / fix gaps / modify specs / cancel.
|
|
299
743
|
|
|
300
|
-
|
|
744
|
+
### Gap Loop (when user chooses to fix gaps)
|
|
301
745
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
746
|
+
**Parallel Teams mode** (per-partition, persistent agents — no respawning):
|
|
747
|
+
1. Lead reads each reviewer's structured gap report from task summary
|
|
748
|
+
2. Lead creates fix task and pre-assigns:
|
|
749
|
+
`TaskCreate("Fix gaps: NodeID-X", addBlockedBy: [audit-task-id])` → `TaskUpdate(owner: "builder-N")`
|
|
750
|
+
3. Lead sends DM to builder with task ID and gap details:
|
|
751
|
+
`"**New Task**: #{fix-task-id} — Fix gaps: NodeID-X. {file path, VERIFY criterion, expected vs actual}"`
|
|
752
|
+
4. Builder claims fix task, fixes gaps, re-runs tests, marks fix task complete
|
|
753
|
+
5. Lead creates re-audit task and pre-assigns:
|
|
754
|
+
`TaskCreate("Re-audit: NodeID-X", addBlockedBy: [gap-fix-task-id])` → `TaskUpdate(owner: "reviewer-N")`
|
|
755
|
+
6. Lead sends DM to reviewer: `"**New Task**: #{reaudit-task-id} — Re-audit: NodeID-X. {gap list}"`
|
|
756
|
+
7. Each builder-reviewer pair repeats independently until clean — no cross-partition blocking
|
|
757
|
+
8. All builders and reviewers stay alive throughout
|
|
758
|
+
9. **3-iteration cap per partition**: If a partition exceeds 3 gap-fix iterations without resolution, **PAUSE** autonomous mode for that partition (even if `AUTONOMOUS_MODE = true`). Announce: `> **Autonomous Mode Paused** — Partition {N} failed 3 gap-fix iterations. Manual review required.`
|
|
759
|
+
|
|
760
|
+
**Sequential Teams mode**: Spawn a NEW `builder` with the standard Phase 2A prompt plus gap fix context. Then re-run Phase 2B (spawn a new reviewer). Repeat until user approves at Gate #3.
|
|
307
761
|
|
|
308
|
-
|
|
309
|
-
Wait for completion, then re-run Phase 2B (spawn a new reviewer).
|
|
762
|
+
**Subagent mode**: Launch parallel `Task()` calls — one for gap fix (builder), then one for re-audit (reviewer). Repeat as needed.
|
|
310
763
|
|
|
311
|
-
|
|
764
|
+
### MCP Learning Capture (Optional)
|
|
312
765
|
|
|
313
|
-
If
|
|
766
|
+
If MCP is configured and knowz-scribe is active, after audit approval:
|
|
767
|
+
- Send message to **knowz-scribe**: `"Capture Phase 2B: {wgid}"` — the scribe reads audit results from the WorkGroup file and writes findings to the appropriate vault
|
|
314
768
|
|
|
315
769
|
---
|
|
316
770
|
|
|
317
771
|
## Phase 3: Finalization
|
|
318
772
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
Spawn a teammate named `closer` with this prompt:
|
|
773
|
+
**Agent**: `closer` | **Loop.md**: Section 3.5
|
|
322
774
|
|
|
775
|
+
**Spawn prompt**:
|
|
323
776
|
> You are the **closer** for WorkGroup `{wgid}`.
|
|
324
777
|
> Read `agents/closer.md` for your full role definition.
|
|
325
|
-
> Read `knowzcode/claude_code_execution.md` for team conventions.
|
|
326
778
|
>
|
|
327
779
|
> **Goal**: {goal}
|
|
328
780
|
> **Change Set**: {NodeIDs}
|
|
329
781
|
> **Specs**: {list of spec file paths}
|
|
330
|
-
> **Context files**: `knowzcode/knowzcode_loop.md
|
|
782
|
+
> **Context files**: Read sections 1-2, 3.5, 6, and 7 of `knowzcode/knowzcode_loop.md` (skip other phases), `knowzcode/knowzcode_tracker.md`, `knowzcode/knowzcode_project.md`, `knowzcode/knowzcode_architecture.md`, `knowzcode/knowzcode_log.md`
|
|
331
783
|
> **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
|
|
332
784
|
>
|
|
333
|
-
> **
|
|
334
|
-
> **
|
|
785
|
+
> **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
|
|
786
|
+
> **Conventions**: Update WorkGroup file with results (prefix entries with `KnowzCode:`). If blocked, report blocker and notify lead.
|
|
787
|
+
> **Vault writes**: If knowz-scribe is active, send it `"Capture Phase 3: {wgid}"` to delegate learning capture and audit trail writes. Do NOT call `create_knowledge` directly.
|
|
788
|
+
> **Deliverable**: Atomic finalization — update specs to FINAL, update tracker, write log entry, update architecture if needed, delegate learning capture to knowz-scribe, and create final commit.
|
|
335
789
|
|
|
336
|
-
|
|
337
|
-
|
|
790
|
+
**Dispatch**:
|
|
791
|
+
- *Parallel Teams*: Spawned at Stage 3 (`addBlockedBy`: last audit/re-audit task). All other agents shut down before closer starts, except knowz-scout and knowz-scribe (stay alive for Phase 3 capture).
|
|
792
|
+
- *Sequential Teams*: Spawn teammate `closer`, create task `Phase 3: Finalize WorkGroup {wgid}`, wait for completion.
|
|
793
|
+
- *Subagent*: `Task(subagent_type="closer", description="Phase 3 finalization", prompt=<above>)`
|
|
338
794
|
|
|
339
|
-
###
|
|
795
|
+
### Phase 3 Output
|
|
340
796
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
### Phase 3 Output (both modes)
|
|
344
|
-
|
|
345
|
-
When complete, push completion record to MCP vault if configured:
|
|
346
|
-
- `create_knowledge` with WorkGroup summary, decisions, and outcomes
|
|
797
|
+
When complete, if MCP is configured and knowz-scribe is active:
|
|
798
|
+
- The closer sends a message to **knowz-scribe**: `"Capture Phase 3: {wgid}"` — the scribe reads the WorkGroup file, extracts learnings, decisions, and outcomes, and writes to the appropriate vaults
|
|
347
799
|
|
|
348
800
|
Update workgroup to "Closed" and report:
|
|
349
801
|
|
|
@@ -363,27 +815,38 @@ Update workgroup to "Closed" and report:
|
|
|
363
815
|
|
|
364
816
|
## Cleanup
|
|
365
817
|
|
|
366
|
-
After Phase 3
|
|
818
|
+
### After Phase 3 Completes
|
|
367
819
|
|
|
368
|
-
**Agent Teams Mode
|
|
820
|
+
**Agent Teams Mode** (Parallel or Sequential):
|
|
821
|
+
1. Shut down all active teammates. Wait for each to confirm shutdown.
|
|
822
|
+
2. Once all teammates have shut down, clean up the team (delete the `kc-{wgid}` team).
|
|
823
|
+
No teammates or team resources should remain after the workflow ends.
|
|
369
824
|
|
|
370
825
|
**Subagent Mode**: No cleanup needed — `Task()` calls are self-contained.
|
|
371
826
|
|
|
372
|
-
|
|
827
|
+
### If User Cancels Mid-Workflow
|
|
373
828
|
|
|
374
|
-
|
|
829
|
+
Follow the abandonment protocol from `knowzcode_loop.md` Section 12:
|
|
375
830
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
831
|
+
1. **Revert uncommitted changes** — if implementation was in progress, revert source code changes (keep knowzcode files)
|
|
832
|
+
2. **Update tracker** — set all affected NodeIDs back to their pre-WorkGroup status
|
|
833
|
+
3. **Log abandonment** — create a log entry with type `WorkGroup-Abandoned` including the reason and phase at abandonment
|
|
834
|
+
4. **Close WorkGroup file** — mark the WorkGroup as `Abandoned` with timestamp and reason
|
|
835
|
+
5. **Preserve learnings** — if any useful patterns were discovered, capture them before closing
|
|
836
|
+
6. **Team teardown** — (Agent Teams only) shut down all active teammates and delete the team
|
|
837
|
+
7. **Parallel mode**: If cancelled mid-Stage-2, revert uncommitted code changes and mark WorkGroup abandoned
|
|
838
|
+
|
|
839
|
+
The WorkGroup file remains in `knowzcode/workgroups/` for reference. It can be resumed later with `/kc:work` referencing the same goal.
|
|
840
|
+
|
|
841
|
+
---
|
|
379
842
|
|
|
380
843
|
## Handling Failures
|
|
381
844
|
|
|
382
845
|
- Phase 1A rejected: re-run analyst with feedback
|
|
383
|
-
- Phase 1B rejected: re-run architect with specific issues
|
|
384
|
-
- Phase 2A
|
|
846
|
+
- Phase 1B rejected: re-run architect with specific issues (Parallel Teams: architect is already warm)
|
|
847
|
+
- Phase 2A blocker encountered: present Blocker Report (per loop.md Section 11) to user with 5 recovery options: (1) modify spec, (2) change approach, (3) split WorkGroup, (4) accept partial with documented gap, (5) cancel WorkGroup
|
|
385
848
|
- Phase 2B audit shows gaps: return to 2A with gap list (see Gap Loop above)
|
|
386
|
-
- If >3 failures on same phase: PAUSE and ask user for direction
|
|
849
|
+
- If >3 failures on same phase: PAUSE and ask user for direction (applies even when `AUTONOMOUS_MODE = true` — this is a safety exception)
|
|
387
850
|
|
|
388
851
|
## KnowzCode: Prefix Enforcement
|
|
389
852
|
|