@tekyzinc/gsd-t 2.33.12 → 2.34.11

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.
@@ -74,6 +74,78 @@ For each ambiguous item:
74
74
 
75
75
  ---
76
76
 
77
+ ## Step 1.6: Consumer Surface Identification (MANDATORY — complete before domain work)
78
+
79
+ Before decomposing into domains, identify **every surface that will consume this system**. A surface is any client, app, or integration that calls your backend — web app, mobile app, CLI, external API, admin panel, background job, etc.
80
+
81
+ Skipping this step leads to duplicated backend logic when a second consumer is added later.
82
+
83
+ ---
84
+
85
+ ### 1.6.1 — Enumerate Surfaces
86
+
87
+ For each surface that will consume this system, capture:
88
+
89
+ ```markdown
90
+ ## Consumer Surfaces
91
+
92
+ | Surface | Type | Operations Needed |
93
+ |---------|------|------------------|
94
+ | {Web App} | web | login, list-items, get-item, update-progress, search |
95
+ | {Mobile App} | mobile | login, list-items, get-item, update-progress, offline-sync |
96
+ | {CLI} | cli | import-data, export-data, list-items |
97
+ ```
98
+
99
+ **Surface types**: `web`, `mobile`, `cli`, `external-api`, `admin`, `background-worker`, `other`
100
+
101
+ If only one surface exists → mark "Single consumer — SharedCore not needed" and proceed to Step 2.
102
+
103
+ ---
104
+
105
+ ### 1.6.2 — Identify Shared Operations
106
+
107
+ Compare the "Operations Needed" column across all surfaces. Flag every operation that appears in 2 or more surfaces:
108
+
109
+ ```markdown
110
+ ## Shared Operations (candidates for SharedCore)
111
+
112
+ | Operation | Surfaces That Need It | Shared? |
113
+ |------------------|-----------------------|---------|
114
+ | login | web, mobile | ✅ |
115
+ | list-items | web, mobile, cli | ✅ |
116
+ | get-item | web, mobile | ✅ |
117
+ | update-progress | web, mobile | ✅ |
118
+ | offline-sync | mobile only | ❌ |
119
+ | export-data | cli only | ❌ |
120
+ ```
121
+
122
+ ---
123
+
124
+ ### 1.6.3 — Auto-Suggest SharedCore Domain
125
+
126
+ **If 3 or more shared operations exist:**
127
+
128
+ > ⚠️ **SharedCore recommended** — {N} operations are needed by {M} consumer surfaces.
129
+ > A `shared-core` domain will be added to own these functions.
130
+ > Surfaces get thin adapter layers that call SharedCore — not duplicate implementations.
131
+
132
+ Add `shared-core` to the domain list before running Step 2. The `shared-core` domain:
133
+ - Owns: the shared operation implementations
134
+ - Consumed by: all surface-specific adapter domains
135
+ - Contract: `shared-services-contract.md` (use the template from `templates/shared-services-contract.md`)
136
+
137
+ **If fewer than 3 shared operations exist:**
138
+
139
+ > ℹ️ {N} shared operations found. Inline sharing is sufficient — no separate SharedCore domain needed. Document shared functions in the relevant domain's constraints.md.
140
+
141
+ ---
142
+
143
+ ### 1.6.4 — Write the Shared Services Contract
144
+
145
+ If SharedCore was created, populate `.gsd-t/contracts/shared-services-contract.md` using the template from `templates/shared-services-contract.md`.
146
+
147
+ ---
148
+
77
149
  ## Step 2: Identify Domains
78
150
 
79
151
  Decompose the milestone into 2-5 independent domains. Each domain should:
@@ -52,6 +52,37 @@ For each domain, write `.gsd-t/domains/{domain-name}/tasks.md`:
52
52
  5. **Ordered**: Tasks within a domain are numbered in execution order
53
53
  6. **No implicit knowledge**: Don't assume the executing agent remembers previous tasks — reference contracts and files explicitly
54
54
 
55
+ ### Cross-Domain Duplicate Operation Scan
56
+
57
+ After creating all domain task lists, scan for operations that appear in more than one domain.
58
+
59
+ **Check for duplicate task descriptions, function names, or operation verbs** across all `tasks.md` files:
60
+
61
+ ```
62
+ For each operation in each domain's task list:
63
+ Does this operation appear (by name or clear equivalent) in another domain's task list?
64
+ → YES → flag as duplicate candidate
65
+ ```
66
+
67
+ **If duplicates found:**
68
+
69
+ > ⚠️ **Duplicate operations detected** — the following operations appear in multiple domains:
70
+ > - `{operation}` — found in: {domain-A} Task {N}, {domain-B} Task {N}
71
+ > - `{operation}` — found in: {domain-A} Task {N}, {domain-C} Task {N}
72
+ >
73
+ > **Options:**
74
+ > 1. If a `shared-core` domain exists → reassign these tasks to shared-core
75
+ > 2. If no shared-core → extract to a new `shared-core` domain (go back to partition and add it)
76
+ > 3. If the operations are truly surface-specific variants → document the distinction explicitly in each domain's constraints.md to prevent future confusion
77
+
78
+ **Level 3 (Full Auto)**: If shared-core exists, move the duplicates there automatically. If not, add a task to the first affected domain's list: "Extract `{operation}` to shared-core — coordinate with {domain-B} before implementing".
79
+
80
+ **If no duplicates found:**
81
+
82
+ > ✅ No duplicate operations detected across domains.
83
+
84
+ ---
85
+
55
86
  ### REQ Traceability
56
87
 
57
88
  After creating task lists, append a traceability table to `docs/requirements.md`:
@@ -47,7 +47,9 @@ ALL TEAMMATES read first:
47
47
  - Teammate "security" (model: sonnet): Full security audit — auth, injection, exposure,
48
48
  dependencies. Write to .gsd-t/scan/security.md
49
49
  - Teammate "quality" (model: sonnet): Dead code, duplication, complexity, test gaps,
50
- performance, stale deps. Write to .gsd-t/scan/quality.md
50
+ performance, stale deps. Also: identify reusability candidates — functions or modules
51
+ that appear in multiple places doing similar work, and consumer surfaces (web/mobile/CLI/etc.)
52
+ that call the same backend operations independently. Write to .gsd-t/scan/quality.md
51
53
  - Teammate "contracts" (model: haiku): Compare .gsd-t/contracts/ to actual implementation,
52
54
  find drift and undocumented interfaces. Write to .gsd-t/scan/contract-drift.md
53
55
  (skip if no contracts exist)
@@ -158,6 +160,7 @@ Produce: `.gsd-t/scan/security.md`
158
160
  Check for:
159
161
  - **Dead code**: Unused functions, unreachable branches, commented-out blocks
160
162
  - **Duplication**: Copy-pasted logic that should be abstracted
163
+ - **Reusability / Shared Service Candidates**: Functions implementing the same operation in multiple modules; consumer surfaces (web, mobile, CLI) calling the same backend logic through separate implementations instead of a shared layer
161
164
  - **Complexity**: Functions with high cyclomatic complexity, deep nesting
162
165
  - **Error handling**: Missing try/catch, swallowed errors, inconsistent patterns
163
166
  - **Performance**: N+1 queries, missing indexes, unnecessary re-renders, large bundles
@@ -177,6 +180,27 @@ Produce: `.gsd-t/scan/quality.md`
177
180
  ## Duplication
178
181
  - {file-a} ↔ {file-b}: {description of duplicated logic}
179
182
 
183
+ ## Reusability Analysis
184
+
185
+ ### Consumer Surfaces Detected
186
+ | Surface | Type | Operations Used |
187
+ |---------|------|----------------|
188
+ | {module/app} | {web/mobile/cli/other} | {list of backend operations it calls} |
189
+
190
+ ### Shared Service Candidates
191
+ Operations implemented independently in 2+ places — candidates for extraction to a shared module:
192
+
193
+ | Operation | Found In | Recommendation |
194
+ |-----------|----------|----------------|
195
+ | {operation} | {file-a}, {file-b} | Extract to shared-core |
196
+ | {operation} | {file-a}, {file-b}, {file-c} | Extract to shared-core (high priority — 3 copies) |
197
+
198
+ If none found: `✅ No shared service candidates detected.`
199
+
200
+ > **Note**: These candidates should seed Step 1.6 (Consumer Surface Identification) the next
201
+ > time `/user:gsd-t-partition` is run. Copy the "Consumer Surfaces Detected" table into
202
+ > partition's Step 1.6.1 to skip re-research.
203
+
180
204
  ## Complexity Hotspots
181
205
  - {file}:{function} — complexity: {score/assessment} — {suggestion}
182
206
 
@@ -220,6 +244,21 @@ Produce: `.gsd-t/scan/contract-drift.md`
220
244
  - {endpoint/table/component}: {description}
221
245
  ```
222
246
 
247
+ ## Step 2.5: Schema Extraction
248
+
249
+ Run schema extraction on the scanned project to detect ORM/database schema files and parse entity definitions. This data feeds the database schema diagram in Step 3.5.
250
+
251
+ Using Bash tool:
252
+ ```
253
+ node -e "const {extractSchema}=require('./bin/scan-schema.js'); const r=extractSchema(process.argv[1]); process.stdout.write(JSON.stringify(r))" "$SCANNED_PROJECT_ROOT"
254
+ ```
255
+
256
+ Capture output as `schemaData`. Log:
257
+ - Detected ORM type: `schemaData.ormType`
258
+ - Entity count: `schemaData.entities.length`
259
+
260
+ If `schemaData.detected === false`, note: "No ORM/schema files detected — database diagram will use placeholder."
261
+
223
262
  ## Step 3: Build Tech Debt Register
224
263
 
225
264
  Synthesize ALL findings into `.gsd-t/techdebt.md`:
@@ -302,6 +341,25 @@ Nice-to-haves and cleanup.
302
341
  - Last scan: {previous date or "first scan"}
303
342
  ```
304
343
 
344
+ ## Step 3.5: Diagram Generation
345
+
346
+ Generate all 6 architectural diagrams using analysis data from Step 2 and schema data from Step 2.5.
347
+
348
+ Using Bash tool:
349
+ ```
350
+ node -e "
351
+ const {generateDiagrams}=require('./bin/scan-diagrams.js');
352
+ const analysisData=JSON.parse(process.argv[1]);
353
+ const schemaData=JSON.parse(process.argv[2]);
354
+ const r=generateDiagrams(analysisData, schemaData, {projectRoot: process.argv[3]});
355
+ process.stdout.write(JSON.stringify(r.map(d=>({type:d.type,rendered:d.rendered,rendererUsed:d.rendererUsed}))));
356
+ " "$ANALYSIS_JSON" "$SCHEMA_JSON" "$SCANNED_PROJECT_ROOT"
357
+ ```
358
+
359
+ Capture the full array as `diagrams`. Log:
360
+ - Diagrams rendered: count of `diagrams.filter(d => d.rendered).length` out of 6
361
+ - Renderer used per diagram: `diagrams.map(d => d.type + ': ' + d.rendererUsed).join(', ')`
362
+
305
363
  ## Step 4: Suggest Milestone Promotions
306
364
 
307
365
  Review all items marked `Milestone candidate: YES` and group them into logical milestones:
@@ -323,6 +381,12 @@ Can be scheduled: AFTER current feature work
323
381
  Combines: TD-020, dependency table items with breaking=yes
324
382
  Estimated effort: {assessment}
325
383
  Can be scheduled: During next maintenance window
384
+
385
+ ### Suggested: Shared Service Extraction (if candidates found)
386
+ Combines: all "Shared Service Candidates" from quality.md Reusability Analysis
387
+ Estimated effort: {assessment}
388
+ Should be prioritized: BEFORE adding new consumer surfaces to the system
389
+ Note: Use `/user:gsd-t-partition` Step 1.6 to design the SharedCore domain
326
390
  ```
327
391
 
328
392
  ## Step 5: Update Living Documents
@@ -419,6 +483,29 @@ All detailed findings are in `.gsd-t/scan/` for review.
419
483
 
420
484
  Ask: "Want to promote any tech debt items to milestones? Or address the critical items first?"
421
485
 
486
+ ### HTML Report Generation
487
+
488
+ After writing the text report to `.gsd-t/techdebt.md`, generate the self-contained HTML scan report:
489
+
490
+ Using Bash tool:
491
+ ```
492
+ node -e "
493
+ const {collectScanData}=require('./bin/scan-data-collector.js');
494
+ const {extractSchema}=require('./bin/scan-schema.js');
495
+ const {generateDiagrams}=require('./bin/scan-diagrams.js');
496
+ const {generateReport}=require('./bin/scan-report.js');
497
+ const root=process.argv[1];
498
+ const analysisData=collectScanData(root);
499
+ const schemaData=extractSchema(root);
500
+ const diagrams=generateDiagrams(analysisData, schemaData, {projectRoot:root});
501
+ const r=generateReport(analysisData, schemaData, diagrams, {projectRoot:root});
502
+ if (r.outputPath) console.log('HTML report:', r.outputPath, '| Diagrams rendered:', r.diagramsRendered + '/6');
503
+ else console.error('Report generation failed:', r.error);
504
+ " "$SCANNED_PROJECT_ROOT"
505
+ ```
506
+
507
+ Report the HTML output path and diagram render count to the user.
508
+
422
509
  ## Document Ripple
423
510
 
424
511
  Scan produces analysis files and updates living documents (Step 5 already covers most updates). Verify:
@@ -1,6 +1,6 @@
1
1
  # Architecture — GSD-T Framework (@tekyzinc/gsd-t)
2
2
 
3
- ## Last Updated: 2026-03-04 (M14 Complete — Execution Intelligence Layer)
3
+ ## Last Updated: 2026-03-09 (Scan #9, Post-M17)
4
4
 
5
5
  ## System Overview
6
6
 
@@ -23,7 +23,7 @@ The framework has no runtime — it is consumed entirely by Claude Code's slash
23
23
  ### Slash Commands (commands/*.md)
24
24
  - **Purpose**: Define the GSD-T methodology as executable workflows for Claude Code
25
25
  - **Location**: `commands/`
26
- - **Count**: 47 (43 GSD-T workflow + 4 utility: gsd, branch, checkin, Claude-md) — includes gsd-t-health and gsd-t-pause (M13), gsd-t-reflect (M14)
26
+ - **Count**: 48 (44 GSD-T workflow + 4 utility: gsd, branch, checkin, Claude-md) — includes gsd-t-health, gsd-t-pause (M13), gsd-t-reflect (M14), gsd-t-visualize (M15), gsd-t-prd (M16)
27
27
  - **Format**: Pure markdown with step-numbered instructions, team mode blocks, document ripple sections, and $ARGUMENTS terminator
28
28
 
29
29
  ### Templates (templates/*.md)
@@ -47,6 +47,20 @@ The framework has no runtime — it is consumed entirely by Claude Code's slash
47
47
  - **Distillation step (complete-milestone Step 2.5)**: Scans `.gsd-t/events/*.jsonl` for patterns seen ≥3 times, proposes CLAUDE.md / constraints.md rule additions, user confirms before write.
48
48
  - **`commands/gsd-t-reflect.md`**: On-demand retrospective command (47th command). Reads current milestone events, generates `.gsd-t/retrospectives/YYYY-MM-DD-{milestone}.md` with sections: What Worked, What Failed, Patterns Found, Proposed Memory Updates.
49
49
 
50
+ ### Auto-Route + Auto-Update Hooks (M16 — complete)
51
+ - **`scripts/gsd-t-auto-route.js`** (39 lines): UserPromptSubmit hook. Reads JSON from stdin (`{ prompt, cwd, session_id }`). If `.gsd-t/progress.md` does not exist in cwd → exits silently. If prompt starts with `/` → exits silently. If plain text in a GSD-T project → emits `[GSD-T AUTO-ROUTE]` signal to Claude's context, routing the message through `/user:gsd`. Catches all exceptions — never blocks the prompt.
52
+ - **`scripts/gsd-t-update-check.js`** (79 lines): SessionStart hook. Reads `~/.claude/.gsd-t-version`. Reads/refreshes `~/.claude/.gsd-t-update-check` cache (1h TTL). If newer version available: runs `npm install -g @tekyzinc/gsd-t@{latest}` + `gsd-t update-all` via execSync. Outputs `[GSD-T AUTO-UPDATE]`, `[GSD-T UPDATE]`, or `[GSD-T]` banner. NOTE: No module.exports — untestable as module (TD-081). Version string not validated before execSync (SEC-N28).
53
+
54
+ ### Scan Visual Output (M17 — complete v2.34.10)
55
+ - **`bin/scan-schema.js`** (77 lines): ORM detector + schema extractor. Detects 7 ORM types (Prisma, TypeORM, Drizzle, Mongoose, Sequelize, SQLAlchemy, raw-SQL). Delegates to scan-schema-parsers.js. Returns SchemaData: `{ detected, ormType, entities[], parseWarnings[] }`. Never throws.
56
+ - **`bin/scan-schema-parsers.js`** (199 lines): 7 parser functions (parsePrisma, parseTypeOrm, parseDrizzle, parseMongoose, parseSequelize, parseSqlAlchemy, parseRawSql). Returns Entity[] for each ORM type.
57
+ - **`bin/scan-diagrams.js`** (77 lines): Diagram orchestrator. Calls scan-diagrams-generators.js for each of 6 types. Calls scan-renderer.js to render Mermaid to SVG. Always returns exactly 6 DiagramResult objects. Failed diagrams get placeholder HTML.
58
+ - **`bin/scan-diagrams-generators.js`** (102 lines): Mermaid DSL source generators for 6 types: genSystemArchitecture, genAppArchitecture, genWorkflow, genDataFlow, genSequence, genDatabaseSchema. Falls back to generic diagram if analysisData lacks specific fields.
59
+ - **`bin/scan-renderer.js`** (92 lines): Sync render chain: tryMmdc() → tryD2() → placeholder. Also contains tryKroki() (async, currently dormant — never called in sync path). Uses execSync (not execFileSync — see TD-084/SEC-N30).
60
+ - **`bin/scan-report.js`** (116 lines): Generates self-contained HTML scan report. No external CSS/JS (all inline). Output: `{projectRoot}/scan-report.html` (see TD-092 for placement issue). Exports: generateReport(), buildCss(), buildSidebar(), buildHtmlSkeleton() + section builders.
61
+ - **`bin/scan-report-sections.js`** (74 lines): HTML section builders: buildMetricCards, buildDomainHealth, buildDiagramSection, buildTechDebt, buildFindings.
62
+ - **`bin/scan-export.js`** (49 lines): Export subcommand — DOCX via pandoc, PDF via md-to-pdf. Checks tool availability before attempting. Uses execSync (not execFileSync — see TD-084/SEC-N29).
63
+
50
64
  ### Real-Time Agent Dashboard (M15 — complete v2.33.10)
51
65
  - **`scripts/gsd-t-dashboard-server.js`** (141 lines, zero external deps): Node.js SSE server watching `.gsd-t/events/*.jsonl`. Exports: `startServer(port, eventsDir, htmlPath)`, `tailEventsFile(filePath, callback)`, `readExistingEvents(eventsDir, maxEvents)`, `parseEventLine(line)`, `findEventsDir(projectDir)`. HTTP endpoints: `GET /` (serve dashboard HTML), `GET /events` (SSE stream, max 500 events on connect + tail for new), `GET /ping` (health check), `GET /stop` (graceful shutdown). CLI: `--port`, `--events`, `--detach` (writes PID to `.gsd-t/dashboard.pid`), `--stop` (kills running server). Symlink protection via `lstatSync` pattern. 23 unit tests in `test/dashboard-server.test.js`.
52
66
  - **`scripts/gsd-t-dashboard.html`** (194 lines): React 17 + React Flow v11.11.4 + Dagre via CDN (no build step, no npm deps). Dark theme (`#0d1117`). Renders agent hierarchy as directed graph from `parent_agent_id` relationships. Live event feed (max 200, outcome color-coded). Auto-reconnects on SSE disconnect. Port configurable via `?port=` URL param.
@@ -1,6 +1,6 @@
1
1
  # Infrastructure — GSD-T Framework (@tekyzinc/gsd-t)
2
2
 
3
- ## Last Updated: 2026-02-18 (Post-M13, Scan #6)
3
+ ## Last Updated: 2026-03-09 (Scan #9, Post-M17)
4
4
 
5
5
  ## Quick Reference
6
6
 
@@ -30,7 +30,7 @@ node bin/gsd-t.js status
30
30
 
31
31
  ### Testing
32
32
  ```bash
33
- # Run automated test suite (125 tests, zero dependencies)
33
+ # Run automated test suite (205 tests, zero dependencies)
34
34
  npm test
35
35
 
36
36
  # Test CLI subcommands manually
@@ -40,12 +40,21 @@ node bin/gsd-t.js doctor
40
40
  node bin/gsd-t.js init test-project
41
41
 
42
42
  # Validate command files exist
43
- ls commands/*.md | wc -l # Should be 45
43
+ ls commands/*.md | wc -l # Should be 48
44
44
  ls templates/*.md | wc -l # Should be 9
45
45
 
46
46
  # Test new utility scripts
47
47
  node scripts/gsd-t-tools.js validate
48
48
  node scripts/gsd-t-tools.js git pre-commit-check
49
+
50
+ # Test scan visual output
51
+ node bin/gsd-t.js scan --export html
52
+ # Output: scan-report.html (self-contained, no external deps)
53
+
54
+ # Test dashboard server
55
+ node scripts/gsd-t-dashboard-server.js --port 7433 --detach
56
+ # Browser: http://localhost:7433
57
+ node scripts/gsd-t-dashboard-server.js --stop
49
58
  ```
50
59
 
51
60
  ### Scripts
@@ -54,8 +63,16 @@ node scripts/gsd-t-tools.js git pre-commit-check
54
63
  | `scripts/gsd-t-heartbeat.js` | Claude Code hook event logger (JSONL output, secret scrubbing) |
55
64
  | `scripts/npm-update-check.js` | Background npm registry version checker (path-validated) |
56
65
  | `scripts/gsd-t-fetch-version.js` | Synchronous npm registry fetch (5s timeout, 1MB limit) |
57
- | `scripts/gsd-t-tools.js` | State utility CLI — state get/set, validate, list, git check, template read (NEW M13) |
58
- | `scripts/gsd-t-statusline.js` | Context usage bar + project state for Claude Code statusLine setting (NEW M13) |
66
+ | `scripts/gsd-t-tools.js` | State utility CLI — state get/set, validate, list, git check, template read (M13) |
67
+ | `scripts/gsd-t-statusline.js` | Context usage bar + project state for Claude Code statusLine setting (M13) |
68
+ | `scripts/gsd-t-event-writer.js` | Structured JSONL event appender CLI — writes to .gsd-t/events/ (M14) |
69
+ | `scripts/gsd-t-dashboard-server.js` | Zero-dep SSE server for real-time dashboard — port 7433 (M15) |
70
+ | `scripts/gsd-t-auto-route.js` | UserPromptSubmit hook — auto-routes plain text via /gsd in GSD-T projects (M16) |
71
+ | `scripts/gsd-t-update-check.js` | SessionStart hook — fetches latest npm version, auto-updates GSD-T (M16) |
72
+ | `bin/scan-schema.js` | ORM/DB schema detector + extractor — 7 ORM types (M17) |
73
+ | `bin/scan-diagrams.js` | Diagram orchestrator — 6 diagram types, renders to SVG or placeholder (M17) |
74
+ | `bin/scan-report.js` | Self-contained HTML scan report generator (M17) |
75
+ | `bin/scan-export.js` | Export subcommand — DOCX (pandoc) + PDF (md-to-pdf) stubs (M17) |
59
76
 
60
77
  ## Distribution
61
78
 
@@ -68,7 +85,7 @@ node scripts/gsd-t-tools.js git pre-commit-check
68
85
  ### Installed Locations
69
86
  | What | Where |
70
87
  |------|-------|
71
- | Slash commands (45 files) | `~/.claude/commands/` |
88
+ | Slash commands (48 files) | `~/.claude/commands/` |
72
89
  | Global config | `~/.claude/CLAUDE.md` |
73
90
  | Heartbeat script | `~/.claude/scripts/gsd-t-heartbeat.js` |
74
91
  | State utility CLI | `~/.claude/scripts/gsd-t-tools.js` |
@@ -1,6 +1,6 @@
1
1
  # Requirements — GSD-T Framework (@tekyzinc/gsd-t)
2
2
 
3
- ## Last Updated: 2026-03-04 (M15 CompleteReal-Time Agent Dashboard v2.33.10)
3
+ ## Last Updated: 2026-03-09 (Scan #9M17 complete)
4
4
 
5
5
  ## Functional Requirements
6
6
 
@@ -29,6 +29,13 @@
29
29
  | REQ-021 | Milestone Distillation — complete-milestone runs a distillation step: scans the event stream for patterns found ≥3 times, proposes concrete constraints.md / CLAUDE.md rule additions, user confirms before write | P2 | complete (M14) | validated by use |
30
30
  | REQ-022 | gsd-t-reflect command — reads .gsd-t/events/*.jsonl for the current milestone, generates structured retrospective (what worked, what failed, patterns found, proposed memory updates), outputs to .gsd-t/retrospectives/YYYY-MM-DD-{milestone}.md | P2 | complete (M14) | validated by use |
31
31
  | REQ-023 | Real-Time Agent Dashboard — gsd-t-visualize command starts a zero-dependency SSE server watching .gsd-t/events/ and opens gsd-t-dashboard.html in the browser; dashboard renders agent hierarchy (React Flow + Dagre via CDN) with live event overlay; all 6 interaction patterns visualized (wave/execute, parallel domains, scan, brainstorm, debug, quick/error) | P2 | complete (M15) | test/dashboard-server.test.js (23 tests) |
32
+ | REQ-024 | Scan Schema Extraction — gsd-t-scan detects and parses ORM/schema definition files (TypeORM entities, Prisma schema, Drizzle schema, Mongoose models, SQLAlchemy models, raw SQL migrations) to extract: entity names, field names and types, primary/foreign keys, and relationships; outputs structured schema data consumed by REQ-025 ER diagram generation | P1 | complete (M17) | test/scan.test.js + verify-gates.js |
33
+ | REQ-025 | Scan Diagram Generation — gsd-t-scan generates Mermaid diagram definition files (.mmd) for 6 diagram types derived from codebase analysis: (1) System Architecture — C4-style context diagram of services, databases, queues, and external integrations; (2) Application Architecture — layered diagram showing framework layers (controllers/guards/services/repositories) and their boundaries; (3) Workflow Diagram — state machine derived from status enums and state transition logic; (4) Data Flow Diagram — flowchart tracing data from user input through validation, persistence, async queues, and workers; (5) Sequence Diagram — request/response flow for the most critical API endpoint detected; (6) Database Schema — ER diagram generated from REQ-024 schema extraction | P1 | complete (M17) | test/scan.test.js + verify-gates.js |
34
+ | REQ-026 | Scan Diagram Rendering — diagram definitions from REQ-025 are rendered to SVG using the configured backend (REQ-028); rendered SVGs are embedded inline in the HTML report; rendering backend is selected in priority order: Mermaid CLI → D2 → Kroki HTTP; if all backends fail a graceful fallback generates a "diagram unavailable" placeholder without blocking the report | P1 | complete (M17) | test/scan.test.js + verify-gates.js |
35
+ | REQ-027 | Scan HTML Report — gsd-t-scan generates a self-contained HTML report (scan-report.html) containing: (a) sidebar navigation with scrollspy; (b) summary metric cards (files scanned, LoC, tech debt count by severity, test coverage %, outdated deps, API endpoint count); (c) domain health cards with file inventory and health score; (d) 6 diagram sections (REQ-025/026) each with title, type badge, inline SVG, expand-to-fullscreen button with scroll-to-zoom, and descriptive note; (e) tech debt register table with severity badges; (f) key findings with actionable recommendations; report uses dark theme, no external CDN required after generation | P1 | complete (M17) | test/scan.test.js + verify-gates.js |
36
+ | REQ-028 | Scan Document Export — scan output exportable to two additional formats: (a) DOCX via Pandoc (GPL v2+) — converts scan-report.md + embedded images to .docx; upload to Google Drive auto-converts to Google Docs; (b) PDF via md-to-pdf (MIT) + Puppeteer — renders markdown with CSS styling to print-quality PDF; both export formats are triggered by optional flags (--export=docx, --export=pdf) and are independent of HTML report generation | P2 | complete (M17) | test/scan.test.js + verify-gates.js |
37
+ | REQ-029 | Diagram Rendering Toolchain — three rendering backends supported, each free and open source, selected automatically based on availability: (1) Primary — Mermaid CLI (mmdc, @mermaid-js/mermaid-cli, MIT, npm) renders .mmd files to SVG via headless Chromium; (2) Enhanced — D2 (MPL-2.0, terrastruct/d2, Go binary) as optional renderer for architecture and dataflow diagrams — uses dagre/ELK/neato layouts (TALA excluded, paid); (3) Fallback — Kroki HTTP API (MIT, yuzutech/kroki) renders any supported format via single HTTP POST to kroki.io (public free tier) or self-hosted Docker instance | P2 | complete (M17) | test/scan.test.js + verify-gates.js |
38
+ | REQ-030 | MCP Diagram Server Support — gsd-t-scan supports optional MCP-based diagram generation when registered MCP servers are detected in Claude Code settings: diagram-bridge-mcp (MIT, tohachan) selects optimal format and renders via Kroki; C4Diagrammer (MIT, jonverrier) specialized for existing codebase → C4 architecture diagrams; mcp-mermaid (MIT, hustcc) for 22 Mermaid diagram types; MCP path is preferred over CLI when available | P3 | complete (M17) | test/scan.test.js + verify-gates.js |
32
39
 
33
40
  ## Technical Requirements
34
41
 
@@ -42,6 +49,11 @@
42
49
  | TECH-006 | Symlink protection on all file write operations | P1 | complete |
43
50
  | TECH-007 | Input validation on project names, versions, paths, session IDs | P1 | complete |
44
51
  | TECH-008 | prepublishOnly gate — `npm test` runs before `npm publish` | P1 | complete (M8) |
52
+ | TECH-009 | Mermaid CLI (@mermaid-js/mermaid-cli, MIT) is the primary diagram renderer — requires Node.js (already required by GSD-T); installed on demand if absent; renders .mmd → SVG/PNG via headless Chromium (Puppeteer peer dependency) | P1 | complete (M17) |
53
+ | TECH-010 | D2 diagram renderer (MPL-2.0, terrastruct/d2) is optional — detected by `which d2`; used in preference to Mermaid CLI for architecture and dataflow diagram types when present; free layouts only: dagre, ELK, neato | P2 | complete (M17) |
54
+ | TECH-011 | Kroki HTTP API (MIT, yuzutech/kroki) is the zero-install fallback renderer — single HTTP POST, no local dependencies; defaults to public kroki.io; configurable to self-hosted instance via KROKI_URL env var | P2 | complete (M17) |
55
+ | TECH-012 | Pandoc (GPL v2+) used for DOCX and HTML document export; detected by `which pandoc`; --export flags silently skip if absent with a warning in report output | P2 | complete (M17) |
56
+ | TECH-013 | All diagram and export tooling must be free and open source (MIT, MPL-2.0, GPL, or equivalent OSI-approved license) with no paid tiers, subscriptions, or per-request API fees required for core functionality | P1 | complete (M17) |
45
57
 
46
58
  ## Non-Functional Requirements
47
59
 
@@ -52,6 +64,10 @@
52
64
  | NFR-003 | Command files are pure markdown (no frontmatter) | 100% compliance | complete |
53
65
  | NFR-004 | Heartbeat auto-cleanup prevents unbounded growth | 7-day TTL | complete |
54
66
  | NFR-005 | Update check is non-blocking after first run | background process | complete |
67
+ | NFR-006 | Scan HTML report renders all diagrams in browser within 5 seconds of opening | < 5s render | complete (M17) |
68
+ | NFR-007 | Scan HTML report is self-contained after generation — all SVG diagrams are embedded inline; no external CDN dependencies required to view the report | 100% offline-capable | complete (M17) |
69
+ | NFR-008 | Diagram generation degrades gracefully — if the primary renderer is unavailable the next backend is tried automatically; the scan report is always produced even if all renderers fail (placeholder shown instead of diagram) | zero blocking failures | complete (M17) |
70
+ | NFR-009 | Schema extraction completes within the scan time budget — ORM/schema file parsing adds no more than 10% to total scan duration | ≤ 10% overhead | complete (M17) |
55
71
 
56
72
  ## Test Coverage
57
73
 
@@ -75,11 +91,113 @@
75
91
  | REQ-022 | gsd-t-reflect command — retrospective from events/ | reflect | Task 2, Task 3 | complete |
76
92
  | REQ-023 | Real-Time Agent Dashboard — SSE server + React Flow dashboard + gsd-t-visualize command | server, dashboard, command | server T1, dashboard T1, command T1, T2, T3 | complete (M15) |
77
93
 
94
+ | REQ-024 | Scan Schema Extraction — ORM/schema parser → structured entity data | scan-schema | pending | planned |
95
+ | REQ-025 | Scan Diagram Generation — 6 diagram type .mmd files from codebase analysis | scan-diagrams | pending | planned |
96
+ | REQ-026 | Scan Diagram Rendering — .mmd → SVG via Mermaid CLI / D2 / Kroki | scan-diagrams | pending | planned |
97
+ | REQ-027 | Scan HTML Report — self-contained report with inline SVGs + all sections | scan-report | pending | planned |
98
+ | REQ-028 | Scan Document Export — DOCX (Pandoc) + PDF (md-to-pdf) export flags | scan-export | pending | planned |
99
+ | REQ-029 | Diagram Rendering Toolchain — Mermaid CLI → D2 → Kroki fallback chain | scan-diagrams | pending | planned |
100
+ | REQ-030 | MCP Diagram Server Support — diagram-bridge-mcp / C4Diagrammer / mcp-mermaid | scan-diagrams | pending | planned |
101
+
78
102
  **Orphaned requirements**: REQ-001 through REQ-017 (all M1–M13 deliverables, complete — not mapped to M14 tasks by design).
79
103
  **Unanchored tasks**: command Task 2 (bin/gsd-t.js installer update) and Task 3 (4 reference files) are infrastructure supporting REQ-023 — implicitly mapped.
80
104
 
81
105
  ---
82
106
 
107
+ ## M17: Scan Visual Output — Feature Specification
108
+
109
+ **Goal**: Transform `gsd-t-scan` from a text-only analysis tool into a rich visual report generator. Every scan produces a beautiful, self-contained HTML report with live diagrams, a tech debt register, and domain health scores — plus optional export to Google Docs via DOCX or PDF.
110
+
111
+ ### Scope
112
+
113
+ | Area | Description |
114
+ |------|-------------|
115
+ | Schema extraction | Detect and parse ORM/schema files to extract entity relationships |
116
+ | Diagram generation | Generate Mermaid (.mmd) diagram definitions for 6 diagram types |
117
+ | Diagram rendering | Render .mmd → SVG using Mermaid CLI, D2, or Kroki (auto-fallback) |
118
+ | HTML report | Self-contained dark-theme report with inline SVGs and expand-to-fullscreen |
119
+ | Document export | DOCX (Pandoc → Google Docs) and PDF (md-to-pdf) export via --export flag |
120
+ | MCP support | Optional MCP server integration when registered in Claude Code settings |
121
+
122
+ ### Diagram Types (REQ-025)
123
+
124
+ | # | Diagram | Source Analysis | Mermaid Syntax |
125
+ |---|---------|-----------------|----------------|
126
+ | 1 | System Architecture | Config files, imports, env vars, API clients | `C4Context` or `graph TB` |
127
+ | 2 | Application Architecture | Module/class structure, framework layers, routing | `graph TB` with subgraphs |
128
+ | 3 | Workflow | Status enums, state transition methods, FSM patterns | `stateDiagram-v2` |
129
+ | 4 | Data Flow | Request handlers, validation pipes, DB calls, queue producers | `flowchart TD` |
130
+ | 5 | Sequence | Critical API endpoint: auth flow or primary resource creation | `sequenceDiagram` |
131
+ | 6 | Database Schema | ORM entities / Prisma schema / SQL migrations (REQ-024) | `erDiagram` |
132
+
133
+ ### ORM Detection Matrix (REQ-024)
134
+
135
+ | ORM / Tool | Detection Signal | Schema Source |
136
+ |------------|-----------------|---------------|
137
+ | TypeORM | `@Entity()`, `typeorm` import | `*.entity.ts` files |
138
+ | Prisma | `prisma/schema.prisma` exists | `schema.prisma` |
139
+ | Drizzle | `drizzle-orm` import | `schema.ts` / `*.schema.ts` |
140
+ | Mongoose | `mongoose.Schema`, `new Schema` | `*.model.ts` / `*.schema.ts` |
141
+ | Sequelize | `DataTypes`, `Model.init` | `*.model.js/ts` |
142
+ | SQLAlchemy | `declarative_base`, `Column` | `models.py` / `*.model.py` |
143
+ | Raw SQL | `CREATE TABLE` in `.sql` files | `migrations/*.sql` |
144
+
145
+ ### Rendering Toolchain (REQ-029)
146
+
147
+ ```
148
+ RENDER REQUEST
149
+ ├── Is `mmdc` (Mermaid CLI) available?
150
+ │ YES → mmdc -i diagram.mmd -o diagram.svg -t dark (primary)
151
+ │ NO ↓
152
+ ├── Is `d2` available AND diagram type is arch/dataflow?
153
+ │ YES → d2 diagram.d2 diagram.svg --layout=dagre (enhanced)
154
+ │ NO ↓
155
+ ├── Is network available?
156
+ │ YES → POST diagram src to kroki.io → SVG response (fallback)
157
+ │ NO ↓
158
+ └── Embed "diagram unavailable" placeholder in report (graceful degrade)
159
+ ```
160
+
161
+ ### HTML Report Structure (REQ-027)
162
+
163
+ ```
164
+ scan-report.html
165
+ ├── Sidebar navigation (scrollspy, domain/diagram/analysis sections)
166
+ ├── Compact page header (project name, version, date, stack)
167
+ ├── Summary (metric cards: files, LoC, debt counts, coverage, deps, endpoints)
168
+ ├── Domains (health cards with file inventory and health % bar)
169
+ ├── Diagram sections × 6 (title bar + type badge + SVG + expand button + note)
170
+ ├── Tech Debt Register (table: severity badge, domain, issue, location, effort)
171
+ └── Key Findings (actionable cards: security, architecture, reliability, quality)
172
+ ```
173
+
174
+ ### Document Export (REQ-028)
175
+
176
+ | Flag | Tool | Output | Google Docs Path |
177
+ |------|------|--------|-----------------|
178
+ | `--export=docx` | Pandoc (GPL) | `scan-report.docx` | Upload to Drive → Open with Google Docs |
179
+ | `--export=pdf` | md-to-pdf (MIT) | `scan-report.pdf` | Upload to Drive → open directly |
180
+ | _(none)_ | — | `scan-report.html` | Copy/paste markdown, or File → Import |
181
+
182
+ ### Free & Open Source Toolchain Confirmation
183
+
184
+ | Tool | License | Free? | Paid Components |
185
+ |------|---------|-------|-----------------|
186
+ | Mermaid CLI (`@mermaid-js/mermaid-cli`) | MIT | Yes | None |
187
+ | D2 (terrastruct/d2) | MPL-2.0 | Yes | TALA layout only (excluded) |
188
+ | Kroki (yuzutech/kroki) | MIT | Yes | None (self-host or free kroki.io) |
189
+ | diagram-bridge-mcp (tohachan) | MIT | Yes | None |
190
+ | C4Diagrammer (jonverrier) | MIT | Yes | None |
191
+ | mcp-mermaid (hustcc) | MIT | Yes | None |
192
+ | Pandoc | GPL v2+ | Yes | None |
193
+ | md-to-pdf (simonhaenisch) | MIT | Yes | None |
194
+
195
+ ### Mock Reference
196
+
197
+ A reference implementation of the HTML report output is at `scan-report-mock.html` (project root). It demonstrates all 6 diagram types, the tech debt register, domain health cards, and the expand-to-fullscreen interaction. Use this as the visual specification for the HTML report (REQ-027).
198
+
199
+ ---
200
+
83
201
  ## Gaps Identified
84
202
 
85
203
  ### Open (Scan #6 — 2026-02-18, Post-M10-M13)
package/docs/workflows.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Workflows — GSD-T Framework (@tekyzinc/gsd-t)
2
2
 
3
- ## Last Updated: 2026-02-18 (Post-M13, Scan #6)
3
+ ## Last Updated: 2026-03-09 (Scan #9, Post-M17)
4
4
 
5
5
  ## User Workflows
6
6
 
@@ -158,3 +158,69 @@ Every commit must pass applicable checks:
158
158
  - **Trigger**: `gsd-t update-all` CLI command
159
159
  - **Flow**: Global update → iterate registered projects → inject Destructive Action Guard → create CHANGELOG → health check (Playwright, Swagger)
160
160
  - **Registry**: `~/.claude/.gsd-t-projects` (newline-separated absolute paths)
161
+
162
+ ### Real-Time Agent Dashboard (M14)
163
+
164
+ **Launch workflow** (`/gsd-t-visualize`):
165
+ 1. Check if server is running: `GET http://localhost:7433/ping`
166
+ 2. If not running: spawn `gsd-t-dashboard-server.js --detach` as background process; write PID to `.gsd-t/dashboard.pid`
167
+ 3. Open browser to `http://localhost:7433`
168
+ 4. Dashboard connects to `GET /events` (Server-Sent Events stream)
169
+
170
+ **Event stream flow**:
171
+ 1. Claude Code hook fires (any hook event)
172
+ 2. `gsd-t-event-writer.js` validates event fields and appends JSON line to `.gsd-t/events/YYYY-MM-DD.jsonl`
173
+ 3. Dashboard server (`gsd-t-dashboard-server.js`) detects file change via `fs.watchFile()`
174
+ 4. New event lines are broadcast as SSE: `data: {event-json}\n\n`
175
+ 5. Dashboard HTML (React app via CDN) renders event feed with agent hierarchy
176
+
177
+ **Stop workflow**:
178
+ 1. User runs `/gsd-t-visualize stop` or `GET /stop`
179
+ 2. Server reads PID file, sends SIGTERM, deletes PID file
180
+
181
+ **Note:** Server watches only the newest JSONL file at startup. Date rollover (midnight UTC) requires server restart to pick up new file (TD-085).
182
+
183
+ ### Auto-Update Workflow (M15)
184
+
185
+ 1. Claude Code SessionStart hook fires
186
+ 2. `gsd-t-update-check.js` reads `~/.claude/.gsd-t-version` (installed version)
187
+ 3. Reads cached version from `~/.claude/.gsd-t-update-check` (JSON: `{latest, timestamp}`)
188
+ 4. If cached version newer than installed: auto-runs `npm install -g @tekyzinc/gsd-t@{latest}` + `gsd-t update-all`
189
+ 5. Outputs `[GSD-T AUTO-UPDATE]`, `[GSD-T UPDATE]`, or `[GSD-T] v{ver}` to stdout
190
+ 6. Claude agent reads hook output from context and shows update status in first response
191
+
192
+ **Cache TTL**: 1 hour. After TTL, background `npm-update-check.js` refreshes async.
193
+
194
+ ### Auto-Route Workflow (M16)
195
+
196
+ 1. User types plain text in Claude Code in a GSD-T project directory
197
+ 2. `gsd-t-auto-route.js` UserPromptSubmit hook fires
198
+ 3. Script checks if `.gsd-t/progress.md` exists in cwd
199
+ 4. If yes: injects `[GSD-T AUTO-ROUTE]` signal into prompt context
200
+ 5. Claude agent sees signal and routes the plain text message through `/user:gsd {message}`
201
+ 6. Smart router interprets intent and launches appropriate GSD-T command
202
+
203
+ **Note:** Only fires in GSD-T projects (`.gsd-t/progress.md` must exist). Silently passes through in all other directories.
204
+
205
+ ### Scan Visual Output Workflow (M17)
206
+
207
+ 1. User runs `/gsd-t-scan` — scan subagent analyzes codebase (Steps 1-2)
208
+ 2. **Schema extraction** (Step 2.5): `bin/scan-schema.js` detects ORM/schema files
209
+ - Tries Prisma → TypeORM → Drizzle → Mongoose → Sequelize → SQLAlchemy → raw SQL
210
+ - Returns `SchemaData { detected, ormType, entities[], parseWarnings[] }`
211
+ 3. **Diagram generation** (Step 3.5): `bin/scan-diagrams.js` generates 6 Mermaid diagrams
212
+ - Types: system-architecture, app-architecture, workflow, data-flow, sequence, database-schema
213
+ - Renderer chain: mmdc (CLI) → d2 (CLI) → placeholder HTML
214
+ 4. **HTML report generation** (Step 8): `bin/scan-report.js` produces self-contained HTML
215
+ - Sidebar navigation with scrollspy, metric cards, domain health bars
216
+ - 6 diagram sections with expand-to-modal button
217
+ - Tech debt table, key findings
218
+ - Written to project root as `scan-report.html`
219
+ 5. **Export** (optional `--export` flag): `bin/scan-export.js` handles docx/pdf (stubs in v2.34.10)
220
+
221
+ **No external dependencies**: HTML report is fully self-contained (no CDN). All CSS/JS inlined.
222
+
223
+ ### npm Pre-Publish Gate (Updated)
224
+ - **Trigger**: `npm publish` (via `prepublishOnly`)
225
+ - **Gate**: `npm test` runs 205 tests (8 files including verify-gates.js)
226
+ - **Verify-gates checks**: file size compliance (all bin/*.js ≤ 200 lines), no CDN references in scan-report.html, has DOCTYPE, has 6 diagram sections, export format validation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekyzinc/gsd-t",
3
- "version": "2.33.12",
3
+ "version": "2.34.11",
4
4
  "description": "GSD-T: Contract-Driven Development for Claude Code — 48 slash commands with real-time agent dashboard, execution intelligence, backlog management, impact analysis, test sync, milestone archival, and PRD generation",
5
5
  "author": "Tekyz, Inc.",
6
6
  "license": "MIT",