@tekyzinc/gsd-t 3.29.11 → 4.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/bin/gsd-t-parallel.cjs +64 -13
  3. package/bin/gsd-t.js +48 -376
  4. package/bin/journey-coverage.cjs +6 -3
  5. package/bin/parallel-cli.cjs +13 -1
  6. package/commands/gsd-t-complete-milestone.md +6 -12
  7. package/commands/gsd-t-debug.md +47 -533
  8. package/commands/gsd-t-design-decompose.md +24 -497
  9. package/commands/gsd-t-doc-ripple.md +23 -139
  10. package/commands/gsd-t-execute.md +41 -958
  11. package/commands/gsd-t-feature.md +2 -6
  12. package/commands/gsd-t-gap-analysis.md +3 -6
  13. package/commands/gsd-t-help.md +2 -4
  14. package/commands/gsd-t-impact.md +26 -295
  15. package/commands/gsd-t-init-scan-setup.md +7 -7
  16. package/commands/gsd-t-integrate.md +44 -369
  17. package/commands/gsd-t-milestone.md +25 -124
  18. package/commands/gsd-t-partition.md +28 -539
  19. package/commands/gsd-t-plan.md +26 -472
  20. package/commands/gsd-t-prd.md +25 -311
  21. package/commands/gsd-t-quick.md +1 -1
  22. package/commands/gsd-t-resume.md +0 -33
  23. package/commands/gsd-t-scan.md +45 -652
  24. package/commands/gsd-t-verify.md +52 -569
  25. package/commands/gsd-t-wave.md +41 -430
  26. package/package.json +1 -1
  27. package/scripts/gsd-t-calibration-hook.js +3 -1
  28. package/scripts/hooks/pre-commit-journey-coverage +0 -2
  29. package/scripts/hooks/pre-commit-playwright-gate +0 -2
  30. package/templates/CLAUDE-global.md +44 -173
  31. package/templates/CLAUDE-project.md +118 -104
  32. package/templates/prompts/design-verify-subagent.md +3 -0
  33. package/templates/prompts/qa-subagent.md +3 -0
  34. package/templates/prompts/red-team-subagent.md +5 -2
  35. package/templates/workflows/_lib.js +176 -0
  36. package/templates/workflows/gsd-t-debug.workflow.js +86 -0
  37. package/templates/workflows/gsd-t-execute.workflow.js +206 -0
  38. package/templates/workflows/gsd-t-integrate.workflow.js +71 -0
  39. package/templates/workflows/gsd-t-phase.workflow.js +94 -0
  40. package/templates/workflows/gsd-t-quick.workflow.js +72 -0
  41. package/templates/workflows/gsd-t-scan.workflow.js +711 -0
  42. package/templates/workflows/gsd-t-verify.workflow.js +348 -0
  43. package/templates/workflows/gsd-t-wave.workflow.js +43 -0
  44. package/bin/check-headless-sessions.js +0 -140
  45. package/bin/context-budget-audit.cjs +0 -447
  46. package/bin/context-meter-config.cjs +0 -101
  47. package/bin/context-meter-config.test.cjs +0 -101
  48. package/bin/event-stream.cjs +0 -205
  49. package/bin/gsd-t-benchmark-orchestrator.js +0 -437
  50. package/bin/gsd-t-capture-lint.cjs +0 -440
  51. package/bin/gsd-t-economics.cjs +0 -315
  52. package/bin/gsd-t-in-session-usage.cjs +0 -213
  53. package/bin/gsd-t-orchestrator-config.cjs +0 -161
  54. package/bin/gsd-t-orchestrator-queue.cjs +0 -180
  55. package/bin/gsd-t-orchestrator-recover.cjs +0 -231
  56. package/bin/gsd-t-orchestrator-worker.cjs +0 -219
  57. package/bin/gsd-t-orchestrator.js +0 -535
  58. package/bin/gsd-t-parallel-probe.cjs +0 -132
  59. package/bin/gsd-t-ratelimit-probe-worker.cjs +0 -237
  60. package/bin/gsd-t-ratelimit-probe.cjs +0 -648
  61. package/bin/gsd-t-report-tokens.cjs +0 -549
  62. package/bin/gsd-t-stream-feed-client.cjs +0 -151
  63. package/bin/gsd-t-token-backfill.cjs +0 -366
  64. package/bin/gsd-t-token-capture.cjs +0 -321
  65. package/bin/gsd-t-token-dashboard.cjs +0 -353
  66. package/bin/gsd-t-token-regenerate-log.cjs +0 -129
  67. package/bin/gsd-t-tool-attribution.cjs +0 -377
  68. package/bin/gsd-t-tool-cost.cjs +0 -195
  69. package/bin/gsd-t-transcript-tee.cjs +0 -246
  70. package/bin/gsd-t-unattended-heartbeat.cjs +0 -188
  71. package/bin/gsd-t-unattended-platform.cjs +0 -551
  72. package/bin/gsd-t-unattended-platform.js +0 -381
  73. package/bin/gsd-t-unattended-safety.cjs +0 -773
  74. package/bin/gsd-t-unattended-safety.js +0 -788
  75. package/bin/gsd-t-unattended.cjs +0 -2109
  76. package/bin/gsd-t-unattended.js +0 -1367
  77. package/bin/gsd-t-worker-dispatch.cjs +0 -211
  78. package/bin/handoff-lock.cjs +0 -249
  79. package/bin/handoff-lock.js +0 -249
  80. package/bin/headless-auto-spawn.cjs +0 -711
  81. package/bin/headless-auto-spawn.js +0 -373
  82. package/bin/headless-exit-codes.cjs +0 -67
  83. package/bin/live-activity-report.cjs +0 -615
  84. package/bin/log-tail.cjs +0 -81
  85. package/bin/m44-proof-measure.cjs +0 -285
  86. package/bin/m46-iter-proof.cjs +0 -149
  87. package/bin/m46-worker-proof.cjs +0 -201
  88. package/bin/m55-substrate-proof.cjs +0 -134
  89. package/bin/metrics-rollup.js +0 -200
  90. package/bin/model-windows.cjs +0 -99
  91. package/bin/model-windows.test.cjs +0 -75
  92. package/bin/parallelism-report.cjs +0 -535
  93. package/bin/runway-estimator.cjs +0 -242
  94. package/bin/spawn-plan-derive.cjs +0 -163
  95. package/bin/spawn-plan-status-updater.cjs +0 -292
  96. package/bin/spawn-plan-writer.cjs +0 -204
  97. package/bin/supervisor-pid-fingerprint.cjs +0 -126
  98. package/bin/token-budget.cjs +0 -265
  99. package/bin/unattended-watch-format.cjs +0 -178
  100. package/bin/watch-progress.js +0 -155
  101. package/commands/gsd-t-unattended-stop.md +0 -85
  102. package/commands/gsd-t-unattended-watch.md +0 -465
  103. package/commands/gsd-t-unattended.md +0 -476
  104. package/commands/gsd-t-visualize.md +0 -116
  105. package/scripts/gsd-t-context-meter.e2e.test.js +0 -364
  106. package/scripts/gsd-t-context-meter.js +0 -341
  107. package/scripts/gsd-t-context-meter.test.js +0 -471
  108. package/scripts/gsd-t-dashboard-server.js +0 -1203
  109. package/scripts/gsd-t-post-commit-spawn-plan.sh +0 -86
  110. package/scripts/gsd-t-transcript.html +0 -1821
  111. package/scripts/hooks/gsd-t-conversation-capture.js +0 -439
  112. package/scripts/hooks/gsd-t-in-session-usage-hook.js +0 -84
  113. package/scripts/spawn-plan-fmt-tokens.cjs +0 -80
  114. package/templates/hooks/post-commit-spawn-plan.sh +0 -85
@@ -1,560 +1,49 @@
1
1
  # GSD-T: Partition Work into Domains
2
2
 
3
- You are the lead agent in a contract-driven development workflow. Your job is to decompose the current milestone into independent domains with explicit boundaries and contracts.
3
+ You are the lead agent. Decompose the current milestone into independent domains by invoking the generic upper-stage Workflow at `templates/workflows/gsd-t-phase.workflow.js` with `phase: "partition"`.
4
4
 
5
- ## Model Assignment
5
+ ## What this command does
6
6
 
7
- Per `.gsd-t/contracts/model-selection-contract.md` v1.0.0.
7
+ Runs the partition phase as a deterministic Workflow:
8
8
 
9
- - **Default**: `opus` (`selectModel({phase: "partition"})`) — domain decomposition is architectural reasoning. High stakes.
10
- - **Escalation**: already at opus; there is no stronger tier. Partition decisions are always made at full quality.
11
-
12
- ## Step 0.5: Scan Freshness Auto-Refresh
13
-
14
- ```bash
15
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 0 --step-label ".5: Scan Freshness Auto-Refresh" 2>/dev/null || true
16
- ```
17
-
18
- Before reading scan data, check if scan docs are stale and auto-refresh if needed. This ensures partition decisions are based on current code — no warnings, no user involvement.
19
-
20
- If `.gsd-t/scan/.cache.json` exists:
21
- 1. Read the cache and check `dimensions.quality.scannedAt` and `dimensions.architecture.scannedAt`
22
- 2. Count commits since the scan: `git rev-list --count --after="{scannedAt}" HEAD`
23
- 3. If **>10 commits since scan** OR **scan is older than 14 days**:
24
- - Log: "Auto-refreshing scan docs (stale by {N} commits / {N} days)..."
25
- - Re-run only the stale dimensions by spawning the relevant scan teammates:
26
- - If `quality.md` stale → spawn quality teammate (model: sonnet)
27
- - If `architecture.md` stale → spawn architecture teammate (model: haiku)
28
- - Update `.gsd-t/scan/.cache.json` after refresh
29
- 4. If fresh → proceed silently
30
-
31
- If `.gsd-t/scan/` doesn't exist at all → skip (no scan data to refresh).
32
-
33
- ## Step 1: Understand the Project
34
-
35
- ```bash
36
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 1 --step-label "Understand the Project" 2>/dev/null || true
37
- ```
38
-
39
- Read these files in order:
40
- 1. `CLAUDE.md` — project conventions and context
41
- 2. `.gsd-t/progress.md` — current state (if exists)
42
- 3. `docs/` — all available documentation (requirements, architecture, schema, design)
43
- 4. `.gsd-t/scan/quality.md` (if exists) — extract the "Consumer Surfaces Detected" and "Shared Service Candidates" tables. These pre-populate Step 1.6 with scan-discovered data and eliminate re-research.
44
- 5. `.gsd-t/contracts/shared-services-contract.md` (if exists) — a SharedCore domain was previously identified. Its listed operations are pre-confirmed shared and carry forward automatically to Step 1.6.2.
45
-
46
- If `.gsd-t/` doesn't exist, create the full directory structure:
47
- ```
48
- .gsd-t/
49
- ├── contracts/
50
- ├── domains/
51
- └── progress.md
52
- ```
53
-
54
- <!-- M56-D3: brief wire-in -->
55
- **M56 Context-Brief (replaces 30–60k context re-read with ≤2,500-token JSON snapshot):**
56
-
57
- ```bash
58
- SPAWN_ID="partition-${MILESTONE:-default}-$(date -u +%Y%m%dT%H%M%SZ)"
59
- gsd-t brief --kind partition --spawn-id "${SPAWN_ID}" --out ".gsd-t/briefs/${SPAWN_ID}.json" || true
60
- export BRIEF_PATH=".gsd-t/briefs/${SPAWN_ID}.json"
61
- ```
62
-
63
- Pass `$BRIEF_PATH` into any worker prompts spawned downstream so they grep the brief instead of re-walking the repo.
64
- <!-- /M56-D3: brief wire-in -->
65
-
66
- ## Step 1.5: Assumption Audit (MANDATORY — complete before domain work begins)
67
-
68
- ```bash
69
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 1 --step-label ".5: Assumption Audit (MANDATORY — complete before domain work begins)" 2>/dev/null || true
70
- ```
71
-
72
- Before partitioning, surface and lock down all assumptions baked into the requirements. Unexamined assumptions become architectural decisions no one approved.
73
-
74
- Work through each category below. For every match found, write the explicit disposition into the affected domain's `constraints.md` and into the Decision Log in `.gsd-t/progress.md`.
75
-
76
- ---
77
-
78
- ### Category 1: External Reference Assumptions
79
-
80
- Scan requirements for any external project, file, component, library, or URL mentioned by name or path. For each one found, explicitly confirm which disposition applies — and lock it in the contract before any domain touches it:
81
-
82
- | Disposition | Meaning |
83
- |-------------|---------|
84
- | `USE` | Import and depend on it — treat as a dependency |
85
- | `INSPECT` | Read source for patterns only — do not import or copy code |
86
- | `BUILD` | Build equivalent functionality from scratch — do not read or use it |
87
-
88
- **No external reference survives partition without a locked disposition.**
89
-
90
- Trigger phrases to watch for: "reference X", "like X", "similar to Y", "see W for how it handles Z", any file path or project name, any URL.
91
-
92
- > If Level 3 (Full Auto): state the inferred disposition and reason; lock it unless it's ambiguous.
93
- > If ambiguous (e.g., "reference X" could mean USE or INSPECT): pause and ask the user before proceeding.
94
-
95
- ---
96
-
97
- ### Category 3: Black Box Assumptions
98
-
99
- Any component, module, or library **not written in this milestone** that a domain will call, import, or depend on → the agent that executes that domain must read its source before treating it as correct. This includes internal project modules written in a previous milestone.
100
-
101
- For each such component identified:
102
- 1. Name it explicitly in the domain's `constraints.md` under a `## Must Read Before Using` section
103
- 2. List the specific functions or behaviors the domain depends on
104
- 3. The execute agent is prohibited from treating it as a black box — it must read the listed items before implementing
105
-
106
- ---
107
-
108
- ### Category 4: User Intent Assumptions
109
-
110
- Scan requirements for ambiguous language. Flag every instance where intent could be interpreted more than one way. Common patterns:
111
-
112
- - "like X" / "similar to Y" — does this mean the same UX, the same architecture, or just the same concept?
113
- - "the way X handles it" — inspiration, direct port, or behavioral equivalent?
114
- - "reference Z" — does this mean read it, use it, or replicate it?
115
- - "build something that does W" — from scratch, or using an existing library?
116
- - Any requirement where a reasonable developer could make two different implementation choices
117
-
118
- For each ambiguous item:
119
- 1. State the two (or more) possible interpretations explicitly
120
- 2. State which interpretation you are locking in and why
121
- 3. If genuinely unclear: pause and ask the user — do not infer and proceed
122
-
123
- > **Rule**: Ambiguous intent that reaches execute unresolved becomes a wrong assumption. Resolve it here or pay for it in debug sessions.
124
-
125
- ---
126
-
127
- ## Step 1.55: Graph-Enhanced Boundary Detection (if available)
128
-
129
- ```bash
130
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 1 --step-label ".55: Graph-Enhanced Boundary Detection (if available)" 2>/dev/null || true
131
- ```
132
-
133
- If `.gsd-t/graph/meta.json` exists, query the graph to inform domain decomposition:
134
-
135
- 1. **Entity-to-file mapping**: `query('getEntities', { file })` for each source file — understand what functions/classes exist where
136
- 2. **Import graph**: `query('getImports', { file })` — see the dependency structure between files
137
- 3. **Surface consumers**: `query('getSurfaceConsumers', { entity })` — which surfaces already consume each function (auto-populates Step 1.6)
138
- 4. **Domain boundary violations**: `query('getDomainBoundaryViolations', {})` — existing cross-domain access patterns to inform boundaries
139
- 5. **Shared operation detection**: If multiple surfaces consume the same entity, it's a SharedCore candidate
140
-
141
- Use graph results to **propose initial domain boundaries** based on actual code structure, not just file paths. The graph reveals natural boundaries that directory structure may not show (e.g., two files in the same folder that never import each other belong to different domains).
142
-
143
- ## Step 1.6: Consumer Surface Identification (MANDATORY — complete before domain work)
144
-
145
- ```bash
146
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 1 --step-label ".6: Consumer Surface Identification (MANDATORY — complete before domain work)" 2>/dev/null || true
147
- ```
148
-
149
- 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.
150
-
151
- Skipping this step leads to duplicated backend logic when a second consumer is added later.
152
-
153
- ---
154
-
155
- ### 1.6.1 — Enumerate Surfaces
156
-
157
- For each surface that will consume this system, capture:
158
-
159
- ```markdown
160
- ## Consumer Surfaces
161
-
162
- | Surface | Type | Operations Needed |
163
- |---------|------|------------------|
164
- | {Web App} | web | login, list-items, get-item, update-progress, search |
165
- | {Mobile App} | mobile | login, list-items, get-item, update-progress, offline-sync |
166
- | {CLI} | cli | import-data, export-data, list-items |
167
- ```
168
-
169
- **Surface types**: `web`, `mobile`, `cli`, `external-api`, `admin`, `background-worker`, `other`
170
-
171
- **Existing System Check**: This milestone may be adding a NEW surface to a system that already has existing consumer surfaces. Before concluding surface enumeration, scan `.gsd-t/progress.md` completed milestones and look for directories or route files indicating prior client surfaces (`web/`, `mobile/`, `app/`, `cli/`, `client/`, `routes/web.js`, `routes/mobile.js`). Add any discovered existing surfaces to the table above.
172
-
173
- > ⚠️ **New-client signal**: If this milestone adds a consumer surface to a system that already has one or more other consumer surfaces, SharedCore evaluation is MANDATORY regardless of shared operation count.
174
-
175
- If only one surface exists and no prior surfaces were found → mark "Single consumer — SharedCore not needed" and proceed to Step 2.
176
-
177
- ---
178
-
179
- ### 1.6.2 — Identify Shared Operations
180
-
181
- Compare the "Operations Needed" column across all surfaces. Flag every operation that appears in 2 or more surfaces:
182
-
183
- ```markdown
184
- ## Shared Operations (candidates for SharedCore)
185
-
186
- | Operation | Surfaces That Need It | Shared? |
187
- |------------------|-----------------------|---------|
188
- | login | web, mobile | ✅ |
189
- | list-items | web, mobile, cli | ✅ |
190
- | get-item | web, mobile | ✅ |
191
- | update-progress | web, mobile | ✅ |
192
- | offline-sync | mobile only | ❌ |
193
- | export-data | cli only | ❌ |
194
- ```
195
-
196
- ---
197
-
198
- ### 1.6.3 — Auto-Suggest SharedCore Domain
199
-
200
- **If 2 or more shared operations exist, OR if this milestone adds a new consumer surface to a system that already has other surfaces (detected in the Existing System Check above):**
201
-
202
- > ⚠️ **SharedCore recommended** — {N} operations are needed by {M} consumer surfaces.
203
- > A `shared-core` domain will be added to own these functions.
204
- > Surfaces get thin adapter layers that call SharedCore — not duplicate implementations.
205
-
206
- Add `shared-core` to the domain list before running Step 2. The `shared-core` domain:
207
- - Owns: the shared operation implementations
208
- - Consumed by: all surface-specific adapter domains
209
- - Contract: `shared-services-contract.md` (use the template from `templates/shared-services-contract.md`)
210
-
211
- **If only 1 shared operation exists AND this is not a new-client-to-existing-system scenario:**
212
-
213
- > ℹ️ {N} shared operations found. Inline sharing is sufficient — no separate SharedCore domain needed. Document shared functions in the relevant domain's constraints.md.
214
-
215
- ---
216
-
217
- ### 1.6.4 — Write the Shared Services Contract
218
-
219
- If SharedCore was created, populate `.gsd-t/contracts/shared-services-contract.md` using the template from `templates/shared-services-contract.md`.
220
-
221
- ---
222
-
223
- ## Step 2: Identify Domains
224
-
225
- ```bash
226
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 2 --step-label "Identify Domains" 2>/dev/null || true
227
- ```
228
-
229
- Decompose the milestone into 2-5 independent domains. Each domain should:
230
- - Own a distinct area of functionality
231
- - Have minimal overlap with other domains
232
- - Map to a clear set of files/directories it will own
233
- - Be executable by a single agent without needing another domain's internals
234
-
235
- For each domain, create `.gsd-t/domains/{domain-name}/`:
236
- ```
237
- .gsd-t/domains/{domain-name}/
238
- ├── scope.md — what this domain owns (files, directories, responsibilities)
239
- ├── tasks.md — (empty for now, filled during plan phase)
240
- └── constraints.md — patterns to follow, files NOT to touch, conventions
241
9
  ```
242
-
243
- ### scope.md format:
244
- ```markdown
245
- # Domain: {name}
246
-
247
- ## Responsibility
248
- {What this domain is responsible for}
249
-
250
- ## Owned Files/Directories
251
- - src/{path}/ — {description}
252
- - src/{path}/ — {description}
253
-
254
- ## NOT Owned (do not modify)
255
- - {files owned by other domains}
256
- ```
257
-
258
- ### constraints.md format:
259
- ```markdown
260
- # Constraints: {domain-name}
261
-
262
- ## Must Follow
263
- - {pattern or convention from CLAUDE.md}
264
- - {specific technical constraint}
265
-
266
- ## Must Not
267
- - Modify files outside owned scope
268
- - Create new database tables (data-layer domain owns schema)
269
- - {other boundaries}
270
-
271
- ## Dependencies
272
- - Depends on: {other domain} for {what}
273
- - Depended on by: {other domain} for {what}
274
- ```
275
-
276
- ## Step 3: Write Contracts
277
-
278
- ```bash
279
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 3 --step-label "Write Contracts" 2>/dev/null || true
280
- ```
281
-
282
- Contracts define HOW domains interact. Create files in `.gsd-t/contracts/`:
283
-
284
- For each boundary between domains, write a contract:
285
-
286
- ### API contracts (`api-contract.md`):
287
- ```markdown
288
- # API Contract
289
-
290
- ## POST /api/auth/login
291
- Request: { email: string, password: string }
292
- Response: { token: string, user: { id: string, email: string, role: string } }
293
- Errors: 401 { error: "invalid_credentials" }
294
- Owner: auth domain
295
- Consumers: ui domain
296
-
297
- ## GET /api/users/:id
298
- ...
299
- ```
300
-
301
- ### Schema contracts (`schema-contract.md`):
302
- ```markdown
303
- # Schema Contract
304
-
305
- ## Users Table
306
- | Column | Type | Constraints |
307
- |--------|------|------------|
308
- | id | uuid | PK, auto |
309
- | email | varchar(255) | unique, not null |
310
- ...
311
-
312
- Owner: data-layer domain
313
- Consumers: auth domain, ui domain
314
- ```
315
-
316
- ### Component contracts (`component-contract.md`):
317
- ```markdown
318
- # Component Contract
319
-
320
- ## LoginForm
321
- Props: { onSuccess: (user: User) => void, onError: (msg: string) => void }
322
- Events: Calls POST /api/auth/login per api-contract
323
- Owner: ui domain
324
- ```
325
-
326
- ### Integration points (`integration-points.md`):
327
- ```markdown
328
- # Integration Points
329
-
330
- ## Auth → Data Layer
331
- - Auth domain reads Users table (schema-contract.md)
332
- - Auth domain calls data-layer's user lookup function
333
- - Checkpoint: data-layer must complete Task 2 before auth starts Task 3
334
-
335
- ## UI → Auth
336
- - UI calls auth endpoints per api-contract.md
337
- - Checkpoint: auth must complete Task 2 before UI starts Task 4
338
- ```
339
-
340
- ## Step 3.5: Design Brief Detection (UI Projects Only)
341
-
342
- ```bash
343
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 3 --step-label ".5: Design Brief Detection (UI Projects Only)" 2>/dev/null || true
344
- ```
345
-
346
- After writing contracts, check for UI/frontend signals. If found, generate `.gsd-t/contracts/design-brief.md` to give all subagents a consistent visual language reference.
347
-
348
- **Skip this step entirely if no UI signals are detected.**
349
-
350
- ### Detection — check for ANY of the following
351
-
352
- | Signal | How to check |
353
- |--------|-------------|
354
- | React in stack | `"react"` in `package.json` `dependencies` or `devDependencies` |
355
- | Vue in stack | `"vue"` in `package.json` dependencies |
356
- | Svelte in stack | `"svelte"` in `package.json` dependencies |
357
- | Next.js in stack | `"next"` in `package.json` dependencies |
358
- | Flutter project | `pubspec.yaml` exists |
359
- | CSS/SCSS files in scope | `.css`, `.scss`, or `.sass` files present in the codebase |
360
- | Component files in scope | `.jsx`, `.tsx`, `.svelte`, or `.vue` files present |
361
- | Tailwind config exists | `tailwind.config.js` or `tailwind.config.ts` exists |
362
-
363
- If NONE of the above match → skip this step entirely. Log: "Design brief: skipped — no UI signals detected."
364
-
365
- **If `.gsd-t/contracts/design-brief.md` already exists → do NOT overwrite. Log: "Design brief: skipped — existing brief preserved." and continue.**
366
-
367
- ### Generate `.gsd-t/contracts/design-brief.md`
368
-
369
- Source priority (use first source that provides a value):
370
- 1. **Tailwind config** (`tailwind.config.js/ts`) — extract `theme.colors`, `theme.fontFamily`, `theme.spacing`
371
- 2. **Design token files** (`theme.ts`, `tokens.css`, `design-tokens.json`) — extract token values
372
- 3. **Quality North Star** (read `## Quality North Star` from `CLAUDE.md`) — use for Tone & Voice section (skip gracefully if absent)
373
- 4. **Defaults** — sensible web defaults if no signals found (Tailwind defaults, system fonts, 4px spacing)
374
-
375
- Generate the file using this format:
376
-
377
- ```markdown
378
- # Design Brief
379
-
380
- ## Project
381
- {project name}
382
-
383
- ## Color Palette
384
- | Role | Value | Usage |
385
- |------------|---------|------------------------|
386
- | Primary | #000000 | CTA buttons, links |
387
- | Secondary | #000000 | Secondary actions |
388
- | Background | #ffffff | Page background |
389
- | Surface | #f5f5f5 | Cards, panels |
390
- | Error | #ef4444 | Error states |
391
- | Success | #22c55e | Success states |
392
-
393
- ## Typography
394
- | Role | Family | Size | Weight |
395
- |-----------|-----------|----------|--------|
396
- | Heading 1 | {font} | 2rem | 700 |
397
- | Heading 2 | {font} | 1.5rem | 600 |
398
- | Body | {font} | 1rem | 400 |
399
- | Caption | {font} | 0.875rem | 400 |
400
- | Code | monospace | 0.875rem | 400 |
401
-
402
- ## Spacing System
403
- - Base unit: 4px
404
- - Scale: 4, 8, 12, 16, 24, 32, 48, 64, 96
405
-
406
- ## Component Patterns
407
- - {e.g., "Use shadcn/ui primitives for all interactive elements"}
408
- - {e.g., "Card pattern: rounded-lg border shadow-sm p-4"}
409
- - {e.g., "Form pattern: label above input, error below"}
410
-
411
- ## Layout Principles
412
- - {e.g., "Max content width: 1280px, centered"}
413
- - {e.g., "Mobile-first: stack to horizontal at md breakpoint"}
414
-
415
- ## Interaction Patterns
416
- - {e.g., "Loading: skeleton screens, not spinners"}
417
- - {e.g., "Transitions: 150ms ease for state changes"}
418
-
419
- ## Tone & Voice
420
- {Derived from Quality North Star or brand voice — e.g., "Professional but approachable. Error messages are friendly and actionable."}
421
- ```
422
-
423
- Log in `.gsd-t/progress.md` Decision Log: `- {date}: Design brief generated at .gsd-t/contracts/design-brief.md — UI signals detected: {list of signals}`
424
-
425
- ## Step 3.6: Design Contract Bootstrap (Figma/Design Reference Detection)
426
-
427
- ```bash
428
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 3 --step-label ".6: Design Contract Bootstrap (Figma/Design Reference Detection)" 2>/dev/null || true
429
- ```
430
-
431
- After the design brief, check whether this project has a design reference (Figma, images, prototypes). If found, create `.gsd-t/contracts/design-contract.md` to activate the design-to-code stack rule during execute.
432
-
433
- **Skip this step if `.gsd-t/contracts/design-contract.md` already exists.**
434
-
435
- ### Detection — check for ANY of the following
436
-
437
- | Signal | How to check |
438
- |--------|-------------|
439
- | Figma URL in requirements | `docs/requirements.md` contains `figma.com/design/` or `figma.com/file/` |
440
- | Figma URL in CLAUDE.md | `CLAUDE.md` contains `figma.com/design/` or `figma.com/file/` |
441
- | Figma MCP configured | `~/.claude/settings.json` has `mcpServers.figma` |
442
- | Figma config files | `.figmarc` or `figma.config.json` exists |
443
- | Design token files | `design-tokens.json` or `design-tokens/` directory exists |
444
- | Design images in docs | `docs/designs/`, `designs/`, or `mockups/` directory exists with image files |
445
- | Design references in requirements | `docs/requirements.md` contains "design", "mockup", "pixel-perfect", or "Figma" |
446
-
447
- If NONE of the above match → skip this step. Log: "Design contract: skipped — no design references detected."
448
-
449
- ### Generate `.gsd-t/contracts/design-contract.md`
450
-
451
- 1. Copy the design contract template from the GSD-T package:
452
- ```bash
453
- GSD_T_DIR=$(npm root -g 2>/dev/null)/@tekyzinc/gsd-t
454
- TEMPLATE="$GSD_T_DIR/templates/design-contract.md"
455
- if [ -f "$TEMPLATE" ]; then cp "$TEMPLATE" .gsd-t/contracts/design-contract.md; fi
456
- ```
457
-
458
- 2. If a Figma URL was found, populate the Source section:
459
- - Set `Source Type` to `Figma MCP` (if MCP configured) or `Screenshot` (if not)
460
- - Set `Source Reference` to the Figma URL
461
- - Set `Precision Level` to `Exact (MCP)` or `Estimated (visual analysis)`
462
-
463
- 3. If Figma MCP is available, use `get_design_context` or `get_metadata` to pre-populate:
464
- - Color palette from design variables/styles
465
- - Typography from text styles
466
- - Spacing from auto-layout values
467
-
468
- **This file activates the design-to-code stack rule during execute**, ensuring:
469
- - Design tokens are extracted before coding
470
- - Every CSS value traces to the contract
471
- - Visual verification loop runs after implementation
472
- - Stack capability is evaluated before implementation begins
473
-
474
- Log in `.gsd-t/progress.md` Decision Log: `- {date}: Design contract created at .gsd-t/contracts/design-contract.md — design reference detected: {source type + URL or signal}`
475
-
476
- ## Step 4: Initialize Progress
477
-
478
- ```bash
479
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 4 --step-label "Initialize Progress" 2>/dev/null || true
10
+ preflight → brief (kind=partition) → partition agent (opus, with phase protocol)
480
11
  ```
481
12
 
482
- Write `.gsd-t/progress.md`:
483
- ```markdown
484
- # GSD-T Progress
13
+ The agent decomposes the milestone into 2–5 file-disjoint domains, writes `.gsd-t/domains/{domain}/{scope,constraints,tasks}.md`, and records cross-domain contracts under `.gsd-t/contracts/`. The brief (M55-D2) is generated once so the agent doesn't re-walk the repo.
485
14
 
486
- ## Milestone: {name}
487
- ## Status: PARTITIONED
488
- ## Date: {today}
489
-
490
- ## Domains
491
- | Domain | Status | Tasks | Completed |
492
- |--------|--------|-------|-----------|
493
- | {name} | partitioned | 0 | 0 |
494
-
495
- ## Contracts
496
- - [ ] api-contract.md
497
- - [ ] schema-contract.md
498
- - [x] {any completed ones}
499
-
500
- ## Integration Checkpoints
501
- - [ ] {checkpoint description} — blocks {domain} task {N}
502
-
503
- ## Decision Log
504
- - {date}: {decision and rationale}
505
- ```
506
-
507
- ## Step 5: Document Ripple
508
-
509
- ```bash
510
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 5 --step-label "Document Ripple" 2>/dev/null || true
511
- ```
512
-
513
- After creating domains and contracts, update affected documentation:
514
-
515
- ### Always update:
516
- 1. **`.gsd-t/progress.md`** — Already updated in Step 4, but verify Decision Log includes partition rationale
517
-
518
- ### Check if affected:
519
- 2. **`docs/architecture.md`** — If the partition defines new component boundaries or clarifies the system structure, update it
520
- 3. **`docs/requirements.md`** — If partitioning revealed that requirements need clarification or splitting by domain, update them
521
- 4. **`CLAUDE.md`** — If the partition establishes new file ownership conventions or domain-specific patterns, add them
522
-
523
- ### Skip what's not affected.
524
-
525
- ## Step 6: Test Verification
526
-
527
- ```bash
528
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 6 --step-label "Test Verification" 2>/dev/null || true
529
- ```
15
+ ## Step 1: Read the current milestone state
530
16
 
531
- Before finalizing the partition:
17
+ Read `.gsd-t/progress.md` to determine the active milestone and its defined scope. If a scan exists and is stale (>10 commits or >14 days), the agent refreshes the relevant dimensions before partitioning.
532
18
 
533
- 1. **Run existing tests**: Execute the full test suite to confirm codebase is clean before domain work begins
534
- 2. **Verify passing**: If any tests fail, assign them to the appropriate domain as pre-existing issues
535
- 3. **Map tests to domains**: Note which test files belong to which domain — this informs task planning
19
+ ## Step 2: Invoke the phase Workflow
536
20
 
537
- ## Step 7: Validate
21
+ Call the `Workflow` tool with:
538
22
 
539
- ```bash
540
- node scripts/gsd-t-watch-state.js advance --agent-id "$GSD_T_AGENT_ID" --parent-id "${GSD_T_PARENT_AGENT_ID:-null}" --command gsd-t-partition --step 7 --step-label "Validate" 2>/dev/null || true
23
+ ```js
24
+ {
25
+ scriptPath: "templates/workflows/gsd-t-phase.workflow.js",
26
+ args: {
27
+ phase: "partition",
28
+ milestone: "M{NN}",
29
+ projectDir: ".",
30
+ userInput: "$ARGUMENTS"
31
+ }
32
+ }
541
33
  ```
542
34
 
543
- Before finishing, verify:
544
- - [ ] Every file in `src/` is owned by exactly one domain
545
- - [ ] No domain scope overlaps with another
546
- - [ ] Every dependency between domains has a contract
547
- - [ ] Every contract has an owner and at least one consumer
548
- - [ ] Integration checkpoints are identified for all cross-domain dependencies
35
+ ## Step 3: Interpret the result
549
36
 
550
- ### Autonomy Behavior
37
+ The Workflow returns `{ status, artifacts, summary, decisions }`.
551
38
 
552
- **Level 3 (Full Auto)**: Log a brief status line (e.g., "✅ Partition complete — {N} domains defined, {N} contracts written") and auto-advance to the next phase. Do NOT wait for user input.
39
+ - `status === "complete"`: domains scoped, contracts drafted. Auto-advance to `/gsd-t-plan`.
40
+ - `status === "partial" | "blocked"`: read `summary` for what's missing (e.g. ambiguous scope needing discussion).
41
+ - `status === "failed"`: preflight blocked or the agent could not decompose. Read `summary`.
553
42
 
554
- **Level 1–2**: Report the partition to the user with a summary of domains, contracts, and any decisions that need input. Wait for confirmation before proceeding.
43
+ ## Document Ripple
555
44
 
556
- $ARGUMENTS
45
+ The partition agent writes domain scope/constraints/tasks and a Decision Log entry. Verify `.gsd-t/contracts/m{NN}-integration-points.md` reflects the wave sequencing.
557
46
 
558
- ## Auto-Clear
47
+ ## Next Up
559
48
 
560
- All work is committed to project files. Execute `/clear` to free the context window for the next command.
49
+ `/gsd-t-plan` write per-domain `tasks.md` with file-disjointness validation. (`/gsd-t-discuss` first if the milestone is architecturally complex.)