@tekyzinc/gsd-t 2.31.18 → 2.33.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,6 +7,7 @@ A methodology for reliable, parallelizable development using Claude Code with op
7
7
  **Maintains test coverage** — automatically keeps tests aligned with code changes.
8
8
  **Catches downstream effects** — analyzes impact before changes break things.
9
9
  **Protects existing work** — destructive action guard prevents schema drops, architecture replacements, and data loss without explicit approval.
10
+ **Visualizes execution in real time** — live browser dashboard renders agent hierarchy, tool activity, and phase progression from the event stream.
10
11
 
11
12
  ---
12
13
 
@@ -18,7 +19,7 @@ A methodology for reliable, parallelizable development using Claude Code with op
18
19
  npx @tekyzinc/gsd-t install
19
20
  ```
20
21
 
21
- This installs 42 GSD-T commands + 4 utility commands (46 total) to `~/.claude/commands/` and the global CLAUDE.md to `~/.claude/CLAUDE.md`. Works on Windows, Mac, and Linux.
22
+ This installs 44 GSD-T commands + 4 utility commands (48 total) to `~/.claude/commands/` and the global CLAUDE.md to `~/.claude/CLAUDE.md`. Works on Windows, Mac, and Linux.
22
23
 
23
24
  ### Start Using It
24
25
 
@@ -144,6 +145,8 @@ This will replace changed command files, back up your CLAUDE.md if customized, a
144
145
  | `/user:gsd-t-status` | Cross-domain progress view | Manual |
145
146
  | `/user:gsd-t-resume` | Restore context, continue | Manual |
146
147
  | `/user:gsd-t-quick` | Fast task with GSD-T guarantees | Manual |
148
+ | `/user:gsd-t-reflect` | Generate retrospective from event stream, propose memory updates | Manual |
149
+ | `/user:gsd-t-visualize` | Launch browser dashboard — SSE server + React Flow agent visualization | Manual |
147
150
  | `/user:gsd-t-debug` | Systematic debugging with state | Manual |
148
151
  | `/user:gsd-t-health` | Validate .gsd-t/ structure, optionally repair | Manual |
149
152
  | `/user:gsd-t-pause` | Save exact position for reliable resume | Manual |
@@ -230,6 +233,8 @@ your-project/
230
233
  │ │ ├── scope.md
231
234
  │ │ ├── tasks.md
232
235
  │ │ └── constraints.md
236
+ │ ├── events/ # Execution event stream (JSONL, daily-rotated)
237
+ │ ├── retrospectives/ # Retrospective reports from gsd-t-reflect
233
238
  │ ├── milestones/ # Archived completed milestones
234
239
  │ │ └── {milestone-name}-{date}/
235
240
  │ └── scan/ # Codebase analysis outputs
@@ -247,6 +252,7 @@ your-project/
247
252
  5. **State survives sessions.** Everything is in `.gsd-t/`.
248
253
  6. **Plan is single-brain, execute is multi-brain.** Planning and integration always solo; execution and verification can parallelize.
249
254
  7. **Every decision is logged.** The Decision Log captures why, not just what.
255
+ 8. **Agents learn from experience.** Every command invocation, phase transition, and subagent spawn is captured as a structured event. Past failures surface before each task (Reflexion pattern). Distillation converts repeated patterns into lasting CLAUDE.md rules.
250
256
 
251
257
  ---
252
258
 
@@ -298,8 +304,8 @@ get-stuff-done-teams/
298
304
  ├── LICENSE
299
305
  ├── bin/
300
306
  │ └── gsd-t.js # CLI installer
301
- ├── commands/ # 46 slash commands
302
- │ ├── gsd-t-*.md # 42 GSD-T workflow commands
307
+ ├── commands/ # 48 slash commands
308
+ │ ├── gsd-t-*.md # 44 GSD-T workflow commands
303
309
  │ ├── gsd.md # GSD-T smart router
304
310
  │ ├── branch.md # Git branch helper
305
311
  │ ├── checkin.md # Auto-version + commit/push helper
@@ -314,6 +320,12 @@ get-stuff-done-teams/
314
320
  │ ├── progress.md
315
321
  │ ├── backlog.md
316
322
  │ └── backlog-settings.md
323
+ ├── scripts/ # Runtime utility scripts (installed to ~/.claude/scripts/)
324
+ │ ├── gsd-t-tools.js # State CLI (get/set/validate/list)
325
+ │ ├── gsd-t-statusline.js # Context usage bar
326
+ │ ├── gsd-t-event-writer.js # Structured JSONL event writer
327
+ │ ├── gsd-t-dashboard-server.js # Zero-dep SSE server for dashboard
328
+ │ └── gsd-t-dashboard.html # React Flow + Dagre real-time dashboard
317
329
  ├── examples/
318
330
  │ ├── settings.json
319
331
  │ └── .gsd-t/
package/bin/gsd-t.js CHANGED
@@ -518,7 +518,7 @@ function configureAutoRouteHook(scriptPath) {
518
518
 
519
519
  // ─── Utility Scripts ─────────────────────────────────────────────────────────
520
520
 
521
- const UTILITY_SCRIPTS = ["gsd-t-tools.js", "gsd-t-statusline.js"];
521
+ const UTILITY_SCRIPTS = ["gsd-t-tools.js", "gsd-t-statusline.js", "gsd-t-event-writer.js", "gsd-t-dashboard-server.js", "gsd-t-dashboard.html"];
522
522
 
523
523
  function installUtilityScripts() {
524
524
  ensureDir(SCRIPTS_DIR);
@@ -84,26 +84,42 @@ If mode is unclear, ask: "What kind of thinking would be most useful right now
84
84
  4. When energy shifts to a new idea, follow it
85
85
  5. Periodically collect the best ideas into a running list
86
86
 
87
- ### Team Mode (if enabled and user requests):
87
+ ### Deep Research Phase (MANDATORY always runs before Step 5):
88
+
89
+ Before drawing any conclusions or presenting final insights, spawn a team of parallel research agents. **This is not optional.** No brainstorm session may land (Step 5) until this research phase is complete. The purpose is to ensure conclusions are grounded in evidence — not just intuition — so the brainstorm surfaces the genuinely best path forward and avoids going down the wrong path.
88
90
 
89
91
  **OBSERVABILITY LOGGING (MANDATORY):**
90
92
  Before spawning the team — run via Bash:
91
93
  `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
92
94
 
93
95
  ```
94
- Create an agent team for brainstorming:
95
-
96
- - Teammate "visionary": Push boundaries. What's the most ambitious
97
- version? What would make this remarkable? Think in terms of
98
- possibilities, not constraints.
99
-
100
- - Teammate "pragmatist": Keep it real. What can we actually build?
101
- What's the shortest path to value? Where are the hidden costs?
102
-
103
- - Teammate "devil's advocate": Challenge everything. Why might this
104
- fail? What are we not seeing? Which assumptions are weakest?
105
-
106
- Lead: Synthesize the best insights from all three perspectives.
96
+ Spawn a deep research team (run all three in parallel):
97
+
98
+ - Teammate "researcher-landscape": Search external sources, docs, and
99
+ prior art. What solutions already exist for this problem or idea?
100
+ What have others tried? What are the known pitfalls? What does the
101
+ current state of the art look like? Produce a research brief with
102
+ concrete findings and citations.
103
+
104
+ - Teammate "researcher-alternatives": Enumerate 3–5 fundamentally
105
+ different technical or architectural approaches to this problem.
106
+ For each: what are the trade-offs, risks, costs, and prerequisites?
107
+ Which is most promising and why? Consider approaches that might
108
+ require a completely different direction from the current thinking.
109
+
110
+ - Teammate "researcher-analogies": Look outside the immediate domain.
111
+ How have adjacent industries, other products, or different technical
112
+ domains solved similar problems? Find non-obvious analogies and
113
+ extract transferable insights that the team may not have considered.
114
+
115
+ Lead: Wait for all three researchers to report before proceeding.
116
+ Then synthesize:
117
+ 1. What did we learn that changes or validates the initial thinking?
118
+ 2. Which ideas from the brainstorm are supported by research findings?
119
+ 3. Which ideas should be reconsidered or ruled out based on evidence?
120
+ 4. What is the most promising path forward, and what is the evidence for it?
121
+
122
+ Do NOT proceed to Step 5 until this synthesis is complete.
107
123
  ```
108
124
 
109
125
  After team completes — run via Bash:
@@ -112,7 +128,7 @@ Compute tokens and compaction:
112
128
  - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
113
129
  - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
114
130
  Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted |` if missing):
115
- `| {DT_START} | {DT_END} | gsd-t-brainstorm | Step 3 | sonnet | {DURATION}s | team brainstorm: {topic summary} | {TOKENS} | {COMPACTED} |`
131
+ `| {DT_START} | {DT_END} | gsd-t-brainstorm | Step 3 | sonnet | {DURATION}s | deep research: {topic summary} | {TOKENS} | {COMPACTED} |`
116
132
 
117
133
  ## Step 4: Capture the Sparks
118
134
 
@@ -57,6 +57,27 @@ After verification passes, run a gap analysis against `docs/requirements.md` sco
57
57
 
58
58
  This is a **mandatory gate** — the milestone cannot be archived with known gaps against its requirements.
59
59
 
60
+ ## Step 2.5: Distillation — Extract Milestone Patterns
61
+
62
+ Before archiving, extract learning from the event stream to improve future runs.
63
+
64
+ 1. Check if `.gsd-t/events/` exists and has any `.jsonl` files for this milestone period
65
+ - If no events files found: skip distillation (log "No events recorded — distillation skipped"), continue to Step 3
66
+ - If event-writer not installed (`node ~/.claude/scripts/gsd-t-event-writer.js 2>/dev/null || true`): skip gracefully
67
+
68
+ 2. Parse events: scan `.gsd-t/events/*.jsonl` for events with `"outcome":"failure"` or `"outcome":"learning"`
69
+
70
+ 3. Group by `reasoning` field value — count occurrences of each distinct reasoning string
71
+
72
+ 4. For each group with ≥ 3 occurrences:
73
+ - Formulate a concrete rule (e.g., "Always read X before modifying Y — failed 4 times without this")
74
+ - Present to user: "Pattern found {N} times: {reasoning}. Proposed rule: '{rule}'. Add to CLAUDE.md? [y/n]"
75
+ - **Wait for user confirmation before writing** (Destructive Action Guard — CLAUDE.md changes require approval)
76
+ - If approved: append the rule to CLAUDE.md under the relevant section
77
+ - Write event: `node ~/.claude/scripts/gsd-t-event-writer.js --type distillation --command gsd-t-complete-milestone --reasoning "{rule}" --outcome success || true`
78
+
79
+ 5. If no patterns found (fewer than 3 occurrences): log "Distillation complete — no repeating patterns found", continue to Step 3
80
+
60
81
  ## Step 3: Gather Milestone Artifacts
61
82
 
62
83
  Collect all files related to this milestone:
@@ -168,7 +189,8 @@ None — ready for next milestone
168
189
  | {previous} | {version} | {date} | v{version} |
169
190
 
170
191
  ## Decision Log
171
- {Keep the decision logit's valuable context}
192
+ - {date}: [success] Milestone "{name}" completed {summary of what was built}. v{version}
193
+ {Keep all prior decision log entries — they are valuable context}
172
194
  ```
173
195
 
174
196
  ## Step 8: Update README.md
@@ -41,6 +41,107 @@ Read:
41
41
  3. `.gsd-t/contracts/` — all contracts
42
42
  4. `.gsd-t/domains/*/scope.md` — domain boundaries
43
43
 
44
+ ## Step 1.5: Debug Loop Detection (MANDATORY)
45
+
46
+ Before attempting any fix, check whether this issue has been through multiple failed debug sessions. This prevents the 10–20 attempt death spiral that happens when the same approach is retried repeatedly.
47
+
48
+ **Detection:**
49
+ 1. Scan `.gsd-t/progress.md` Decision Log for `[debug]` entries related to this issue (match by keyword, error name, or component)
50
+ 2. Count distinct debug sessions that attempted to fix this issue
51
+ 3. Check `.gsd-t/deferred-items.md` for any entries matching this issue
52
+
53
+ **If 3 or more prior sessions found → Enter Deep Research Mode (below). Do NOT attempt another fix with the same approach.**
54
+
55
+ **If fewer than 3 sessions → Proceed to Step 2 normally.**
56
+
57
+ ---
58
+
59
+ ### Deep Research Mode (triggered when debug loop detected)
60
+
61
+ The current approach has failed 3+ times. This means the root cause is not yet understood. A different strategy — possibly a fundamentally different technical approach — is required.
62
+
63
+ **OBSERVABILITY LOGGING (MANDATORY):**
64
+ Before spawning — run via Bash:
65
+ `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
66
+
67
+ ```
68
+ Spawn a deep research team (run all three in parallel):
69
+
70
+ - Teammate "researcher-root-cause": Take the broadest possible look at
71
+ the problem. Ignore prior fix attempts. Read the full component,
72
+ its dependencies, contracts, and all error traces from scratch.
73
+ What is the actual root cause — not the symptom? Consider that the
74
+ real issue may be architectural, not in the code being patched.
75
+
76
+ - Teammate "researcher-alternatives": Enumerate 3–5 fundamentally
77
+ different ways to solve this problem. Include approaches that would
78
+ require refactoring or changing the technical direction entirely.
79
+ For each: what are the trade-offs, effort, and risk?
80
+
81
+ - Teammate "researcher-prior-art": Search external sources, docs,
82
+ GitHub issues, and known patterns for this class of bug. Has this
83
+ problem been documented elsewhere? What did others find? Are there
84
+ framework-specific pitfalls or known workarounds?
85
+
86
+ Lead: Wait for all three researchers to complete. Then synthesize:
87
+ 1. What is the true root cause based on full investigation?
88
+ 2. What are the viable solution paths (ranked by confidence)?
89
+ 3. Does any path require a different technical approach than what has been tried?
90
+ 4. What is the recommended path and why?
91
+ ```
92
+
93
+ After team completes — run via Bash:
94
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
95
+ Compute tokens and compaction:
96
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
97
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
98
+ Append to `.gsd-t/token-log.md`:
99
+ `| {DT_START} | {DT_END} | gsd-t-debug | Step 1.5 | sonnet | {DURATION}s | deep research loop break: {issue summary} | {TOKENS} | {COMPACTED} |`
100
+
101
+ **STOP. Present findings to the user before making any changes:**
102
+
103
+ ```
104
+ ## Debug Loop Break — Research Findings
105
+
106
+ **Issue**: {issue summary}
107
+ **Prior sessions**: {count} failed attempts
108
+
109
+ **Root Cause (revised)**: {finding from researcher-root-cause}
110
+
111
+ **Solution Options**:
112
+ | # | Approach | Effort | Risk | Notes |
113
+ |---|----------|--------|------|-------|
114
+ | 1 | {option} | {effort} | {risk} | {notes} |
115
+ | 2 | {option} | {effort} | {risk} | {notes} |
116
+ | 3 | {option} | {effort} | {risk} | {notes} |
117
+
118
+ **Recommendation**: {recommended option and rationale}
119
+
120
+ **Does this require a different technical direction?** {Yes/No — explain}
121
+
122
+ Please select an option (or provide your own direction) before I proceed.
123
+ ```
124
+
125
+ **Wait for explicit user selection/approval.** Do NOT proceed with any fix until the user confirms the chosen approach. If the recommendation requires refactoring or changing technical direction, the Destructive Action Guard applies — present the full migration path and wait for approval.
126
+
127
+ ---
128
+
129
+ ## Step 1.7: Experience Retrieval
130
+
131
+ Before proceeding to classification and fix, retrieve relevant past failures from the Decision Log.
132
+
133
+ Run via Bash:
134
+ `grep -i "\[failure\]\|\[learning\]" .gsd-t/progress.md | tail -10`
135
+
136
+ If results found:
137
+ - Display a `## ⚠️ Relevant Past Failures` block showing matching entries (max 5 lines)
138
+ - Pass this block as context to any debug subagent spawned in Step 3
139
+ - Write event via Bash: `node ~/.claude/scripts/gsd-t-event-writer.js --type experience_retrieval --command gsd-t-debug --reasoning "{N entries found}" --outcome null || true`
140
+
141
+ If no results found: proceed normally to Step 2.
142
+
143
+ ---
144
+
44
145
  ## Step 2: Classify the Bug
45
146
 
46
147
  Based on the user's description ($ARGUMENTS), determine:
@@ -102,7 +203,7 @@ When you encounter unexpected situations during the fix:
102
203
  3. **Blocker (missing file, wrong API response)** → Fix blocker and continue. Log if non-trivial.
103
204
  4. **Architectural change required to fix correctly** → STOP. Explain what exists, what needs to change, what breaks, and a migration path. Wait for user approval. Never self-approve.
104
205
 
105
- **3-attempt limit**: If your fix doesn't work after 3 attempts, log to `.gsd-t/deferred-items.md` and stop trying.
206
+ **3-attempt limit**: If your fix doesn't work after 3 attempts within this session, treat it as a loop. Do NOT keep trying the same approach. Log the attempt to `.gsd-t/progress.md` Decision Log with a `[failure]` prefix, then return to Step 1.5 and run Deep Research Mode before any further attempts. Present findings and options to the user before proceeding.
106
207
 
107
208
  ### Solo Mode
108
209
  1. Reproduce the issue — **reproduction script must exist before step 2** (see Step 2.5)
@@ -132,7 +233,11 @@ First to find root cause: message the lead with findings.
132
233
  After fixing, assess what documentation was affected by the change and update ALL relevant files:
133
234
 
134
235
  ### Always check:
135
- 1. **`.gsd-t/progress.md`** — Add to Decision Log: what broke, why, and the fix
236
+ 1. **`.gsd-t/progress.md`** — Add to Decision Log: what broke, why, and the fix. Prefix the entry with an outcome tag:
237
+ - Debug session start → prefix `[debug]`
238
+ - Fix succeeded → prefix `[success]`
239
+ - Fix failed → prefix `[failure]`
240
+ - Issue deferred → prefix `[deferred]`
136
241
  2. **`.gsd-t/contracts/`** — Update any contract if the fix changed an interface, schema, or API shape
137
242
  3. **Domain `constraints.md`** — Add a "must not" rule if the bug was caused by a pattern that should be avoided
138
243
 
@@ -70,6 +70,16 @@ Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime
70
70
 
71
71
  **For each domain (in wave order), spawn:**
72
72
 
73
+ **Pre-task experience retrieval (before spawning each domain subagent):**
74
+ Run via Bash:
75
+ `grep -i "\[failure\]\|\[learning\]" .gsd-t/progress.md | grep -i "{domain-name}" | tail -5`
76
+
77
+ If results found:
78
+ - Prepend a `## ⚠️ Past Failures (retrieve before acting)` block to the subagent prompt (max 5 lines from results)
79
+ - Write event via Bash: `node ~/.claude/scripts/gsd-t-event-writer.js --type experience_retrieval --command gsd-t-execute --reasoning "{N past failures found for {domain-name}}" --outcome null || true`
80
+
81
+ If no results found: proceed normally (no warning block, no event write).
82
+
73
83
  ```
74
84
  Task subagent (general-purpose, model: sonnet, mode: bypassPermissions):
75
85
  "You are executing all tasks for the {domain-name} domain.
@@ -98,7 +108,11 @@ Execute each incomplete task in order:
98
108
  7. Run ALL tests — unit, integration, Playwright. Fix failures (up to 2 attempts)
99
109
  8. Run Pre-Commit Gate checklist from CLAUDE.md — update all affected docs BEFORE committing
100
110
  9. Commit immediately: feat({domain-name}/task-{N}): {description}
101
- 10. Update .gsd-t/progress.md — mark task complete
111
+ 10. Update .gsd-t/progress.md — mark task complete; prefix the Decision Log entry with an outcome tag based on how the task completed:
112
+ - Task completed successfully on first attempt → prefix `[success]`
113
+ - Task completed after a fix (required debugging or correction) → prefix `[learning]`
114
+ - Task deferred to .gsd-t/deferred-items.md → prefix `[deferred]`
115
+ - Task failed after 3 attempts → prefix `[failure]`
102
116
  11. Spawn QA subagent (model: haiku) after each task:
103
117
  'Run the full test suite. Read .gsd-t/contracts/ for definitions.
104
118
  Report: pass/fail counts and coverage gaps.'
@@ -51,6 +51,8 @@ UTILITIES Manual
51
51
  status Cross-domain progress view
52
52
  resume Restore context after break
53
53
  quick Fast task with GSD-T guarantees
54
+ reflect Generate retrospective from event stream, propose memory updates
55
+ visualize Launch browser dashboard (SSE server + React Flow)
54
56
  debug Systematic debugging with state
55
57
  health Validate .gsd-t/ structure, optionally repair missing files
56
58
  pause Save exact position for reliable resume later
@@ -299,6 +301,20 @@ Use these when user asks for help on a specific command:
299
301
  - **Creates**: Quick task record
300
302
  - **Use when**: Small tasks that don't need full planning
301
303
 
304
+ ### reflect
305
+ - **Summary**: Generate a structured retrospective from the event stream for the current milestone, then propose CLAUDE.md/constraints.md rule additions based on recurring patterns
306
+ - **Auto-invoked**: No
307
+ - **Reads**: `.gsd-t/events/*.jsonl`, `.gsd-t/progress.md`, `CLAUDE.md`
308
+ - **Creates**: `.gsd-t/retrospectives/YYYY-MM-DD-{milestone}.md`
309
+ - **Use when**: After completing a milestone or mid-milestone to surface what's working, what's failing, and what patterns should become permanent rules
310
+
311
+ ### visualize
312
+ - **Summary**: Launch the real-time agent dashboard — starts the SSE server (if not running) and opens the React Flow visualization in a browser
313
+ - **Auto-invoked**: No
314
+ - **Reads**: `.gsd-t/dashboard.pid`, `.gsd-t/events/*.jsonl` (via server)
315
+ - **Creates**: `.gsd-t/dashboard.pid` (when starting server)
316
+ - **Use when**: Monitoring live agent activity during execute/wave phases; run `gsd-t-visualize stop` to stop the server
317
+
302
318
  ### debug
303
319
  - **Summary**: Systematic debugging with persistent state
304
320
  - **Auto-invoked**: No
@@ -54,6 +54,7 @@ Skip the copy (step 2) silently if the target already exists.
54
54
  │ └── .gitkeep
55
55
  ├── domains/
56
56
  │ └── .gitkeep
57
+ ├── events/
57
58
  ├── backlog.md
58
59
  ├── backlog-settings.md
59
60
  ├── progress.md
@@ -61,6 +62,8 @@ Skip the copy (step 2) silently if the target already exists.
61
62
  └── qa-issues.md
62
63
  ```
63
64
 
65
+ Create `.gsd-t/events/` directory (empty — populated at runtime by heartbeat and event writer).
66
+
64
67
  Create `token-log.md` with header row:
65
68
  ```
66
69
  | Date | Command | Step | Model | Duration(s) | Notes |
@@ -0,0 +1,134 @@
1
+ # GSD-T: Reflect — Generate Retrospective from Event Stream
2
+
3
+ You are generating a structured retrospective for the current (or specified) milestone by reading the JSONL event stream and proposing memory updates.
4
+
5
+ ## Step 0: Launch via Subagent
6
+
7
+ When invoked directly by the user, spawn yourself as a Task subagent for a fresh context window.
8
+
9
+ **OBSERVABILITY LOGGING — before spawning:**
10
+
11
+ Run via Bash:
12
+ `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
13
+
14
+ ```
15
+ Task subagent (general-purpose, model: sonnet):
16
+ "Run the GSD-T reflect command. Read commands/gsd-t-reflect.md for your full instructions.
17
+ Arguments: {$ARGUMENTS}
18
+ Skip Step 0 — you are already the subagent."
19
+ ```
20
+
21
+ **OBSERVABILITY LOGGING — after subagent returns:**
22
+
23
+ Run via Bash:
24
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
25
+
26
+ Compute tokens:
27
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
28
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
29
+
30
+ Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted |` if missing):
31
+ `| {DT_START} | {DT_END} | gsd-t-reflect | Step 0 | sonnet | {DURATION}s | retrospective generated | {TOKENS} | {COMPACTED} |`
32
+
33
+ Return the subagent's output and stop. Only skip Step 0 if you are already running as a subagent.
34
+
35
+ ## Step 1: Load State
36
+
37
+ Read:
38
+ 1. `CLAUDE.md` — project context
39
+ 2. `.gsd-t/progress.md` — current milestone name and start date
40
+ 3. `.gsd-t/contracts/event-schema-contract.md` — event fields available for reading
41
+
42
+ Identify the current milestone name and its start date from the `## Current Milestone` table in `progress.md`.
43
+
44
+ If `$ARGUMENTS` is provided, treat it as a milestone name filter — search for a past milestone matching that name in the `## Completed Milestones` table and use its completion date as the date boundary instead.
45
+
46
+ ## Step 2: Find Events
47
+
48
+ Look for `.gsd-t/events/*.jsonl` files.
49
+
50
+ If no `.gsd-t/events/` directory or no `.jsonl` files exist:
51
+ ```
52
+ No events recorded for this milestone yet.
53
+ Events are written during execute/wave/debug phases once the event-writer is installed.
54
+ ```
55
+ Stop and exit.
56
+
57
+ Filter events by milestone period: include only JSONL lines with `"ts"` values on or after the milestone start date (from Step 1). Read all matching `.jsonl` files and collect the event objects.
58
+
59
+ ## Step 3: Generate Retrospective
60
+
61
+ Parse the collected events and categorize:
62
+
63
+ **By outcome:**
64
+ - `success` events — commands/phases that completed successfully
65
+ - `failure` events — commands/phases that failed (capture `reasoning` field)
66
+ - `learning` events — insights captured during execution (capture `reasoning`)
67
+ - `deferred` events — items postponed (capture `reasoning`)
68
+
69
+ **Command patterns:**
70
+ - Which `command` values appear most in failure events
71
+ - Which `phase` values appear most in failure events
72
+
73
+ **Repeating patterns (threshold ≥ 2):**
74
+ - Group events by `reasoning` field value (exact string match)
75
+ - Identify any `reasoning` string that appears in 2 or more events
76
+
77
+ **Summary:**
78
+ - What worked: `command`/`phase` values that have only `success` outcomes
79
+ - What failed: failure events with their `reasoning` and `command`
80
+ - What was learned: `learning` outcome events and their `reasoning`
81
+
82
+ ## Step 4: Write Retrospective File
83
+
84
+ Create `.gsd-t/retrospectives/` directory if it does not exist.
85
+
86
+ Determine the output filename:
87
+ - Current milestone: `{YYYY-MM-DD}-{milestone-name-kebab-case}.md` (today's date)
88
+ - Past milestone (from $ARGUMENTS): use that milestone's completion date
89
+
90
+ Write the retrospective file:
91
+
92
+ ```markdown
93
+ # Retrospective: {Milestone Name}
94
+ **Generated**: {YYYY-MM-DD}
95
+ **Milestone period**: {start date} → {end date}
96
+ **Events analyzed**: {N}
97
+
98
+ ## What Worked
99
+ {List each command/phase that had only success outcomes — one per line}
100
+ {If none: _No commands with exclusively success outcomes recorded._}
101
+
102
+ ## What Failed
103
+ {For each failure event: `- [{command}] {reasoning}`}
104
+ {If none: _No failure events recorded._}
105
+
106
+ ## Patterns Found
107
+ {For each reasoning string with ≥ 2 occurrences: `- ({N}×) {reasoning}`}
108
+ {If none: _No repeating patterns found (threshold: 2 occurrences)._}
109
+
110
+ ## Proposed Memory Updates
111
+ {For each pattern found: suggest a concrete rule}
112
+ {Format: `- Pattern ({N}×): "{reasoning}" → Rule: "Always/Never {concrete action}"`}
113
+ {If none: _No patterns met the threshold for a proposed rule._}
114
+ ```
115
+
116
+ ## Step 5: Present Proposed Memory Updates
117
+
118
+ For each item in the **Proposed Memory Updates** section:
119
+
120
+ 1. Present to user: `"Proposed rule (seen {N} times): '{rule}'. Add to CLAUDE.md? [y/n]"`
121
+ 2. **Wait for user confirmation before writing** (Destructive Action Guard — CLAUDE.md changes require explicit approval)
122
+ 3. If approved: append the rule to `CLAUDE.md` under the relevant section
123
+ 4. If none to propose: report "No repeating patterns found — no memory updates proposed."
124
+
125
+ ## Document Ripple
126
+
127
+ Update `.gsd-t/progress.md` Decision Log:
128
+ - Add entry: `- {YYYY-MM-DD HH:MM}: [learning] gsd-t-reflect run — retrospective written to .gsd-t/retrospectives/{filename}.md; {N} events analyzed, {N} patterns found, {N} rules proposed`
129
+
130
+ $ARGUMENTS
131
+
132
+ ## Auto-Clear
133
+
134
+ All work is committed to project files. Execute `/clear` to free the context window for the next command.
@@ -0,0 +1,104 @@
1
+ # GSD-T: Visualize — Launch Real-Time Agent Dashboard
2
+
3
+ You are launching the GSD-T real-time agent dashboard — an SSE-backed browser visualization of agent activity.
4
+
5
+ ## Step 0: Launch via Subagent
6
+
7
+ When invoked directly by the user, spawn yourself as a Task subagent for a fresh context window.
8
+
9
+ **OBSERVABILITY LOGGING — before spawning:**
10
+
11
+ Run via Bash:
12
+ `T_START=$(date +%s) && DT_START=$(date +"%Y-%m-%d %H:%M") && TOK_START=${CLAUDE_CONTEXT_TOKENS_USED:-0} && TOK_MAX=${CLAUDE_CONTEXT_TOKENS_MAX:-200000}`
13
+
14
+ ```
15
+ Task subagent (general-purpose, model: sonnet):
16
+ "Run the GSD-T visualize command. Read commands/gsd-t-visualize.md for your full instructions.
17
+ Arguments: {$ARGUMENTS}
18
+ Skip Step 0 — you are already the subagent."
19
+ ```
20
+
21
+ **OBSERVABILITY LOGGING — after subagent returns:**
22
+
23
+ Run via Bash:
24
+ `T_END=$(date +%s) && DT_END=$(date +"%Y-%m-%d %H:%M") && TOK_END=${CLAUDE_CONTEXT_TOKENS_USED:-0} && DURATION=$((T_END-T_START))`
25
+
26
+ Compute tokens:
27
+ - No compaction (TOK_END >= TOK_START): `TOKENS=$((TOK_END-TOK_START))`, COMPACTED=null
28
+ - Compaction detected (TOK_END < TOK_START): `TOKENS=$(((TOK_MAX-TOK_START)+TOK_END))`, COMPACTED=$DT_END
29
+
30
+ Append to `.gsd-t/token-log.md` (create with header `| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted |` if missing):
31
+ `| {DT_START} | {DT_END} | gsd-t-visualize | Step 0 | sonnet | {DURATION}s | dashboard launched | {TOKENS} | {COMPACTED} |`
32
+
33
+ Return the subagent's output and stop. Only skip Step 0 if you are already running as a subagent.
34
+
35
+ ## Step 1: Write command_invoked Event
36
+
37
+ Run via Bash:
38
+ ```bash
39
+ node ~/.claude/scripts/gsd-t-event-writer.js --type command_invoked --command gsd-t-visualize --reasoning "Launching dashboard" || true
40
+ ```
41
+
42
+ ## Step 2: Check $ARGUMENTS for "stop"
43
+
44
+ If `$ARGUMENTS` contains "stop", skip to **Step 5**. Otherwise continue to Step 3.
45
+
46
+ ## Step 3: Check if Server is Already Running
47
+
48
+ Run via Bash:
49
+ ```bash
50
+ if [ -f .gsd-t/dashboard.pid ]; then
51
+ PID=$(cat .gsd-t/dashboard.pid)
52
+ curl -sf http://localhost:7433/ping 2>/dev/null | grep -q '"ok"' && echo "SERVER_RUNNING=true" || echo "SERVER_RUNNING=false"
53
+ else
54
+ echo "SERVER_RUNNING=false"
55
+ fi
56
+ ```
57
+
58
+ If output is `SERVER_RUNNING=true`, skip Step 3a and go directly to Step 4.
59
+
60
+ ### Step 3a: Start Server if Not Running
61
+
62
+ Run via Bash:
63
+ ```bash
64
+ node ~/.claude/scripts/gsd-t-dashboard-server.js --detach || true
65
+ for i in 1 2 3 4 5; do
66
+ curl -sf http://localhost:7433/ping 2>/dev/null | grep -q '"ok"' && break
67
+ sleep 1
68
+ done
69
+ ```
70
+
71
+ ## Step 4: Open Browser
72
+
73
+ Run via Bash:
74
+ ```bash
75
+ node -e "const {execFileSync}=require('child_process'); const url='http://localhost:7433'; try { if(process.platform==='win32'){execFileSync('cmd',['/c','start','',url],{stdio:'ignore'})}else{execFileSync(process.platform==='darwin'?'open':'xdg-open',[url],{stdio:'ignore'})} } catch(e) { console.error('Could not open browser:', e.message); }" || true
76
+ ```
77
+
78
+ Report to the user: "Dashboard is running at http://localhost:7433 — browser opened."
79
+
80
+ ## Step 5: Stop Handler
81
+
82
+ Run only when `$ARGUMENTS` contains "stop".
83
+
84
+ Run via Bash:
85
+ ```bash
86
+ if [ -f .gsd-t/dashboard.pid ]; then
87
+ PID=$(cat .gsd-t/dashboard.pid)
88
+ curl -sf http://localhost:7433/stop 2>/dev/null || kill $PID 2>/dev/null || true
89
+ rm -f .gsd-t/dashboard.pid
90
+ echo "Dashboard server stopped"
91
+ else
92
+ echo "No dashboard server running (no .gsd-t/dashboard.pid found)"
93
+ fi
94
+ ```
95
+
96
+ ## Document Ripple
97
+
98
+ Note: All 4 reference files (README.md, docs/GSD-T-README.md, templates/CLAUDE-global.md, commands/gsd-t-help.md) are updated in Task 3 of Milestone 15, not here.
99
+
100
+ $ARGUMENTS
101
+
102
+ ## Auto-Clear
103
+
104
+ All work is committed to project files. Execute `/clear` to free the context window for the next command.
@@ -142,7 +142,27 @@ After each agent completes, run this spot-check before proceeding:
142
142
  ✅ {Phase} complete — {agent's one-line summary}
143
143
  📋 Spot-check: {N} commits | {N} output files verified | no FAILED markers
144
144
  ```
145
- 5. If spot-check fails: report the discrepancy, re-spawn the phase agent once to correct it, then re-verify. If still failing: stop and report to user.
145
+ 5. If spot-check fails: write failure event via Bash, then report the discrepancy, re-spawn the phase agent once to correct it, then re-verify. If still failing: stop and report to user.
146
+ ```bash
147
+ node ~/.claude/scripts/gsd-t-event-writer.js \
148
+ --type phase_transition \
149
+ --command gsd-t-wave \
150
+ --phase {COMPLETED_PHASE} \
151
+ --reasoning "Spot-check failed: {one-line discrepancy summary}" \
152
+ --outcome failure \
153
+ --agent-id "${CLAUDE_SESSION_ID:-unknown}" || true
154
+ ```
155
+ 5a. After spot-check passes, write success event via Bash:
156
+ ```bash
157
+ node ~/.claude/scripts/gsd-t-event-writer.js \
158
+ --type phase_transition \
159
+ --command gsd-t-wave \
160
+ --phase {COMPLETED_PHASE} \
161
+ --reasoning "Phase complete: {one-line spot-check summary}" \
162
+ --outcome success \
163
+ --agent-id "${CLAUDE_SESSION_ID:-unknown}" || true
164
+ ```
165
+ The `|| true` ensures event write failure never blocks wave execution.
146
166
  6. Proceed to next phase
147
167
 
148
168
  ## Step 4: Autonomy Behavior