sdtk-spec-kit 0.4.15 → 0.6.0
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/assets/manifest/toolkit-bundle.manifest.json +25 -15
- package/assets/manifest/toolkit-bundle.sha256.txt +8 -6
- package/assets/toolkit/toolkit/AGENTS.md +31 -0
- package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +17 -7
- package/assets/toolkit/toolkit/runtimes/codex/CODEX_TEMPLATE.md +15 -7
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +7 -2
- package/assets/toolkit/toolkit/sdtk-spec.config.json +11 -1
- package/assets/toolkit/toolkit/skills/sdtk-evolve/SKILL.md +67 -0
- package/assets/toolkit/toolkit/skills/skills.catalog.yaml +22 -0
- package/assets/toolkit/toolkit/skills-claude/evolve/SKILL.md +64 -0
- package/package.json +1 -1
- package/src/commands/help.js +16 -1
- package/src/commands/init.js +36 -1
- package/src/commands/project.js +6 -2
- package/src/lib/project-audit.js +3 -0
- package/src/lib/project-config.js +36 -1
- package/src/lib/project-ingest.js +3 -0
- package/src/lib/project-promote.js +137 -0
- package/src/lib/project-refresh.js +3 -0
- package/src/lib/scope.js +4 -4
- package/src/lib/stack-detector.js +289 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"sourceCommit": "
|
|
4
|
-
"fileCount":
|
|
2
|
+
"version": "0.6.0",
|
|
3
|
+
"sourceCommit": "c0dd62d02e1ed12e1c87c01051a10ebb545e6857",
|
|
4
|
+
"fileCount": 100,
|
|
5
5
|
"files": [
|
|
6
6
|
{
|
|
7
7
|
"path": "toolkit/AGENTS.md",
|
|
8
|
-
"sha256": "
|
|
9
|
-
"size":
|
|
8
|
+
"sha256": "0871c6d46c64a093fc5f9d06af373db8143943cd27f144957dad0cc86893dc62",
|
|
9
|
+
"size": 15069
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"path": "toolkit/install.ps1",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
"path": "toolkit/runtimes/claude/CLAUDE_TEMPLATE.md",
|
|
23
|
-
"sha256": "
|
|
24
|
-
"size":
|
|
23
|
+
"sha256": "5b013dde057ed5487b3c9859775bf751306123a4af30e7077811271aa1a1b842",
|
|
24
|
+
"size": 6486
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": "toolkit/runtimes/codex/CODEX_TEMPLATE.md",
|
|
28
|
-
"sha256": "
|
|
29
|
-
"size":
|
|
28
|
+
"sha256": "17420748e1812278fe31a82a5df366dad67331363daf3b250c79af0f5358de2b",
|
|
29
|
+
"size": 4841
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"path": "toolkit/scripts/agents/run-claude-task.ps1",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"path": "toolkit/scripts/install-claude-skills.ps1",
|
|
58
|
-
"sha256": "
|
|
59
|
-
"size":
|
|
58
|
+
"sha256": "8455f08e24e38c78aad925c36ebc3605983f1c7f9782190233402858be77b0c6",
|
|
59
|
+
"size": 6551
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"path": "toolkit/scripts/install-codex-skills.ps1",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
"path": "toolkit/sdtk-spec.config.json",
|
|
83
|
-
"sha256": "
|
|
84
|
-
"size":
|
|
83
|
+
"sha256": "ce760f639a09913b236be6dde6c692ea19ee92eb1d9e63d10dcdeb398e7ed2fb",
|
|
84
|
+
"size": 1209
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
"path": "toolkit/sdtk-spec.config.profiles.example.json",
|
|
@@ -138,6 +138,11 @@
|
|
|
138
138
|
"sha256": "a4f326e2cafff865aaaed8f8de9407f3baa3cfebe33979528a15eb26d2e8482b",
|
|
139
139
|
"size": 3915
|
|
140
140
|
},
|
|
141
|
+
{
|
|
142
|
+
"path": "toolkit/skills-claude/evolve/SKILL.md",
|
|
143
|
+
"sha256": "ddf304f49b53dd1980241b8e231bdfbcfb781d11e6d6bc0cef843b1552af0577",
|
|
144
|
+
"size": 6396
|
|
145
|
+
},
|
|
141
146
|
{
|
|
142
147
|
"path": "toolkit/skills-claude/mailbox-dispatch/SKILL.md",
|
|
143
148
|
"sha256": "6fa2283aa1ebb7bf5b6e84d5d5d9d9ddf71082091b108bd46895923a5fca3e09",
|
|
@@ -233,6 +238,11 @@
|
|
|
233
238
|
"sha256": "749f0ff0865d8940cec9b16859706fd46f111a4d9bf54b6ccba381fe9db7a90e",
|
|
234
239
|
"size": 9409
|
|
235
240
|
},
|
|
241
|
+
{
|
|
242
|
+
"path": "toolkit/skills/sdtk-evolve/SKILL.md",
|
|
243
|
+
"sha256": "e37ed094bc30e76b49f460acb428705af54e4b5925921d5d5bcd5d3aed72aeed",
|
|
244
|
+
"size": 6792
|
|
245
|
+
},
|
|
236
246
|
{
|
|
237
247
|
"path": "toolkit/skills/sdtk-mailbox-dispatch/SKILL.md",
|
|
238
248
|
"sha256": "df593d5ab4e7c5f4b05ac9ddb5078189b25bd954e546ab65c0147d024e4f4d59",
|
|
@@ -300,8 +310,8 @@
|
|
|
300
310
|
},
|
|
301
311
|
{
|
|
302
312
|
"path": "toolkit/skills/skills.catalog.yaml",
|
|
303
|
-
"sha256": "
|
|
304
|
-
"size":
|
|
313
|
+
"sha256": "ef4a40b0095556de4ba608de713cf327e126f9a04ea75b99f3de4588037e82e6",
|
|
314
|
+
"size": 14330
|
|
305
315
|
},
|
|
306
316
|
{
|
|
307
317
|
"path": "toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md",
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
0871c6d46c64a093fc5f9d06af373db8143943cd27f144957dad0cc86893dc62 toolkit/AGENTS.md
|
|
2
2
|
52bdc750984ee3c3598c1f1838cf3d72b2fc0ed06fca173ec3da79929b10f20c toolkit/install.ps1
|
|
3
3
|
0218dea84f0f9a25ddd2e68c6ae9995685ec471ff0950bd17d1eddcaa99f3e0e toolkit/README.md
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
5b013dde057ed5487b3c9859775bf751306123a4af30e7077811271aa1a1b842 toolkit/runtimes/claude/CLAUDE_TEMPLATE.md
|
|
5
|
+
17420748e1812278fe31a82a5df366dad67331363daf3b250c79af0f5358de2b toolkit/runtimes/codex/CODEX_TEMPLATE.md
|
|
6
6
|
8616291be4aaa4fb5cb0f1f4c738c108ab79090bf767ee2b4403d6d582c150c7 toolkit/scripts/agents/run-claude-task.ps1
|
|
7
7
|
4996e8e7aa50283dbf52c473c4e315af7ee951ebddb671ff59cc4bcde9843907 toolkit/scripts/agents/run-codex-task.ps1
|
|
8
8
|
6bcebe5fdb87451a7260101eaed32c6b61a2cf07832be754790f5432e028a503 toolkit/scripts/agents/validate-mailbox-formal-artifact.py
|
|
9
9
|
b9bdb2489c2881d03e965c7dd849468f797e2070d30e6730ab9ddf37b54b7879 toolkit/scripts/generate-code-handoff.ps1
|
|
10
10
|
2b456e0e9ebeb948db9bdd1a905195285a8ae44839b09b5f0bbefac597cfd67a toolkit/scripts/init-feature.ps1
|
|
11
|
-
|
|
11
|
+
8455f08e24e38c78aad925c36ebc3605983f1c7f9782190233402858be77b0c6 toolkit/scripts/install-claude-skills.ps1
|
|
12
12
|
3191823ec5a481c34128ef645e8103e3ee526a74dd108ba2206878edd7b50cda toolkit/scripts/install-codex-skills.ps1
|
|
13
13
|
f925a58e0cc92addc542762c2bf5f60be2d538dcca88e15de0b628b3a57048b1 toolkit/scripts/uninstall-claude-skills.ps1
|
|
14
14
|
db0e580a20b43bb0af399ff3e4f7f2d826423d67bd2fa9a8121a384337a47de1 toolkit/scripts/uninstall-codex-skills.ps1
|
|
15
15
|
dec335148e1bc721eee6ddae82417f344cc74345771da1328c7af54deee0c812 toolkit/SDTK_TOOLKIT.md
|
|
16
|
-
|
|
16
|
+
ce760f639a09913b236be6dde6c692ea19ee92eb1d9e63d10dcdeb398e7ed2fb toolkit/sdtk-spec.config.json
|
|
17
17
|
e04ea5e3f72510e569ab849ebef3dea4a8728c2996c485e997d3e13a6c4f1f86 toolkit/sdtk-spec.config.profiles.example.json
|
|
18
18
|
ab376df00d0fe92307ff862bac0ffe431254903cf9ccac00117d979ddc9c7f88 toolkit/session/SDTK_ACTIVE_BOOTSTRAP.md
|
|
19
19
|
fba56394ff7cae3ab8cd510b4bfb5b299df9f4f1a3e59be9bbcd573e3df477ae toolkit/session/SDTK_AGENT_WORKING_RULES.md
|
|
@@ -25,6 +25,7 @@ c17bb4faff318032ee99ead56e5fa182811c7bcaa176e463d0377cefde213ac1 toolkit/skills
|
|
|
25
25
|
b4de86bc4730c4fcfe4f1bde8f9f64f03fd517825bb699e911199825cc3d4249 toolkit/skills-claude/dev-backend/SKILL.md
|
|
26
26
|
37b3ae11db18bc3f64a76b22bca95cea778d6cfbb8b038d46851bd44ff8ff8f1 toolkit/skills-claude/dev-frontend/SKILL.md
|
|
27
27
|
a4f326e2cafff865aaaed8f8de9407f3baa3cfebe33979528a15eb26d2e8482b toolkit/skills-claude/dev/SKILL.md
|
|
28
|
+
ddf304f49b53dd1980241b8e231bdfbcfb781d11e6d6bc0cef843b1552af0577 toolkit/skills-claude/evolve/SKILL.md
|
|
28
29
|
6fa2283aa1ebb7bf5b6e84d5d5d9d9ddf71082091b108bd46895923a5fca3e09 toolkit/skills-claude/mailbox-dispatch/SKILL.md
|
|
29
30
|
aa086be1038e34b1b29f7f65bacf254b5c1bfdc1203bd3e643c27acca4f9c2fa toolkit/skills-claude/orchestrator/SKILL.md
|
|
30
31
|
e9e346ff0e1fc66236ceabf64a043c9a28926e7ff06296b26dd5836cf045802a toolkit/skills-claude/pm/SKILL.md
|
|
@@ -44,6 +45,7 @@ ce5af79e5c4902b9c8ceb7e8dae848a6a5a26d5b845eee94ee8aafff88990256 toolkit/skills
|
|
|
44
45
|
6c866b7f8dec193a4c26066e8ac43004ff809f6407ead467a3cb72d90425af52 toolkit/skills/sdtk-dev/prompts/implementer.md
|
|
45
46
|
55dd53b1ccbedd271ad23ca8df01afc317eced27ee17af3b37f31f0b9176ca8b toolkit/skills/sdtk-dev/prompts/spec-reviewer.md
|
|
46
47
|
749f0ff0865d8940cec9b16859706fd46f111a4d9bf54b6ccba381fe9db7a90e toolkit/skills/sdtk-dev/SKILL.md
|
|
48
|
+
e37ed094bc30e76b49f460acb428705af54e4b5925921d5d5bcd5d3aed72aeed toolkit/skills/sdtk-evolve/SKILL.md
|
|
47
49
|
df593d5ab4e7c5f4b05ac9ddb5078189b25bd954e546ab65c0147d024e4f4d59 toolkit/skills/sdtk-mailbox-dispatch/SKILL.md
|
|
48
50
|
66ddb66fee3b12b008ea269baa57acde77f8614ac15a9f87cc994eae64ca63dc toolkit/skills/sdtk-orchestrator/SKILL.md
|
|
49
51
|
ae53d96b6a4fb4ea60fb5de6578b2620c3adb43e1d722a0469cdfa5a90b92903 toolkit/skills/sdtk-pm/SKILL.md
|
|
@@ -57,7 +59,7 @@ cad3bda4560548c329041c403edf3192c6e3864f47d56736fa02690ab175964c toolkit/skills
|
|
|
57
59
|
5ecd672a24dbe6fb845102e7a1986b876f4727bb77671233243814dfb2cc103e toolkit/skills/sdtk-screen-design-spec/SKILL.md
|
|
58
60
|
cd8e2801cdd7d5f931af4fa29e1a854cddf158629a06201f34ba19d4747dcb2f toolkit/skills/sdtk-test-case-spec/scripts/validate_test_case_spec.py
|
|
59
61
|
0782e52954f7268152f0ff2954b7c71773879cdc429d0cb367330e77d4f92c50 toolkit/skills/sdtk-test-case-spec/SKILL.md
|
|
60
|
-
|
|
62
|
+
ef4a40b0095556de4ba608de713cf327e126f9a04ea75b99f3de4588037e82e6 toolkit/skills/skills.catalog.yaml
|
|
61
63
|
b569125ca6f341cbf8e982fd0bbabe2adcf2b4de9773f515544e9bd7c5551b34 toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md
|
|
62
64
|
e34569c7721929c9ca14b5d2a4390fdb69d7ac766dfdb81b52683710fb2953e8 toolkit/templates/docs/api/API_DESIGN_DETAIL_TEMPLATE.md
|
|
63
65
|
3c583826dae1e31f13ef5c439154f3e58dad7cb149d9929134e9c4327fb5235d toolkit/templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md
|
|
@@ -32,6 +32,8 @@ When starting a new session, read context in this order when the files exist:
|
|
|
32
32
|
|
|
33
33
|
Do not read the entire historical session archive by default. Use `SDTK_SESSION_MEMORY_*.md` only when chronology or past acceptance details are required.
|
|
34
34
|
|
|
35
|
+
Active orchestration check: if `.sdtk/agent-runtime/runs/` holds a run whose state is not terminal (`running` or `waiting_for_approval`), surface it in one line (run id plus the blocking gate, if any) and offer `sdtk-agent run continue` before starting unrelated work, the same way `.sdtk/handoff/` items are surfaced.
|
|
36
|
+
|
|
35
37
|
## 3) Orchestrator-First Intake Protocol
|
|
36
38
|
For every unprefixed user request:
|
|
37
39
|
1. Classify the request intent before selecting PM/BA/ARCH/DEV/QA or a downstream product lane.
|
|
@@ -63,6 +65,7 @@ Use this compact matrix during intake so the agent picks the smallest sufficient
|
|
|
63
65
|
| Atlas graph build or viewer work | `sdtk-spec atlas` compatibility workflow or `sdtk-wiki atlas` for canonical SDTK-WIKI work | Local `.sdtk/atlas` compatibility graph or `.sdtk/wiki` SDTK-WIKI result |
|
|
64
66
|
| SDTK-WIKI Ask | `sdtk-wiki ask` | Grounded answer when `.sdtk/wiki/graph` plus `wiki.ask` entitlement/runtime preconditions are present, otherwise explicit blocker |
|
|
65
67
|
| Existing project scan: project ingest, project refresh, or project audit | Matching premium project workflow | Project-local foundation, refresh, or audit result without overclaiming entitlement |
|
|
68
|
+
| Multi-step durable workflow: 3+ dependent steps, human gates between steps, must survive a pause, or spans multiple lanes/sessions | Propose `sdtk-agent` orchestration (opt-in, token-aware, see the orchestration cost gate in section 5) | `.sdtk/agent-runtime/runs/<run_id>/` ledger plus `reports/final_report.md` |
|
|
66
69
|
| "what should we do next" | Orchestrator state review | Recommended next action with rationale and lane choice |
|
|
67
70
|
|
|
68
71
|
Guardrails:
|
|
@@ -78,6 +81,7 @@ Ask clarification when:
|
|
|
78
81
|
3. the target repo, project, or path is missing
|
|
79
82
|
4. implementation is requested without an acceptance boundary
|
|
80
83
|
5. the next command could mutate external state
|
|
84
|
+
6. the next step would spawn multiple sub-agents or incur significant token cost, such as dispatching an `sdtk-agent` run
|
|
81
85
|
|
|
82
86
|
Proceed when:
|
|
83
87
|
1. the intent and target are clear
|
|
@@ -85,6 +89,16 @@ Proceed when:
|
|
|
85
89
|
3. the user already approved the relevant plan or spec
|
|
86
90
|
4. the requested change is bounded and verifiable
|
|
87
91
|
|
|
92
|
+
### 5.1) Orchestration Cost Gate (sdtk-agent)
|
|
93
|
+
`sdtk-agent` chains multiple steps and dispatches each ready task through an adapter, so a single run can spawn many sub-agents and consume significant token budget. Because of that cost, orchestration is always opt-in:
|
|
94
|
+
|
|
95
|
+
1. Never auto-start an `sdtk-agent` run on the user's behalf. Only propose it.
|
|
96
|
+
2. Propose only when a routing trigger is hit (the multi-step row in section 4) and the workflow clears the minimum size (default: 3 dependent steps). One- or two-step bounded tasks route straight to a lane instead of orchestration.
|
|
97
|
+
3. When proposing, state the trade-off concretely and let the user decide, defaulting to "no / run inline". Run `sdtk-agent workflow validate` first (it does not spawn anything) to count tasks, human gates, and adapter dispatches, then quote a cost band: dispatch count 3 or fewer is Low, 4-8 is Medium, more than 8 or any loop/retry is High. Example:
|
|
98
|
+
> This request fits sdtk-agent: durable, resumable, with hard approval gates, but it will spawn several agents and cost more tokens than an inline run. Estimate: 9 steps, 3 gates, 11 dispatches (token cost: HIGH). Use sdtk-agent for this, or run it inline? (default: inline)
|
|
99
|
+
4. `run start` only creates the ledger and never spawns; treat it as the safe preview point. Dispatch happens on `run continue`, which is an explicit user action. Before a `run continue` that would dispatch several ready tasks at once, report how many tasks and which adapters are about to run, and let the user confirm or step through one task at a time.
|
|
100
|
+
5. Honor `.sdtk/agent-runtime/config.json` `orchestration.confirmationMode` (`always` by default): no mode ever allows dispatch without at least one confirmation per run.
|
|
101
|
+
|
|
88
102
|
## 6) Clarification Protocol
|
|
89
103
|
Apply for all roles (`/pm`, `/ba`, `/arch`, `/dev`, `/qa`):
|
|
90
104
|
1. If there is ambiguity or missing data, log `Open Questions` as `OQ-xx` in the current phase artifact.
|
|
@@ -122,6 +136,9 @@ Use the suite products according to task intent:
|
|
|
122
136
|
- requirements, BA, PRD, backlog, architecture, QA artifacts
|
|
123
137
|
- handoff generation and release-gate traceability
|
|
124
138
|
- entry: `/orchestrator` (recommended), `/pm`, `/ba`, `/arch`, `/dev`, `/qa`
|
|
139
|
+
- `SDTK-DESIGN`
|
|
140
|
+
- screen/layout design, visual tokens, prototype evidence, design handoff before coding
|
|
141
|
+
- use before `SDTK-CODE` when implementation needs reviewable screens or a design handoff
|
|
125
142
|
- `SDTK-CODE`
|
|
126
143
|
- build a feature
|
|
127
144
|
- fix a bug
|
|
@@ -138,6 +155,18 @@ Use the suite products according to task intent:
|
|
|
138
155
|
- monitoring, incident response, security-infra, backup, compliance
|
|
139
156
|
- entry: `ops-discover` (when boundary is unclear), `ops-plan`, `ops-deploy`, `ops-incident`, `ops-monitor`, `ops-backup`, `ops-verify`, `ops-debug`
|
|
140
157
|
|
|
158
|
+
Cross-cutting capabilities (not a linear lane; usable across every phase):
|
|
159
|
+
|
|
160
|
+
- `SDTK-WIKI` (memory)
|
|
161
|
+
- project knowledge graph, docs view, and grounded `sdtk-wiki ask`
|
|
162
|
+
- any lane may read from it for recall; build with `sdtk-wiki atlas build`
|
|
163
|
+
- `SDTK-AGENT` (orchestration)
|
|
164
|
+
- a durable, file-driven DAG controller that sits above `sdtk-code` agent-team; it does not own a phase, it chains steps across lanes
|
|
165
|
+
- surface: `sdtk-agent run start|continue|status|report`, `gate approve|reject`, `workflow validate`, `adapter hermes-kanban plan`
|
|
166
|
+
- use only when a workflow has 3+ dependent steps, needs human gates between steps, or must survive a pause; otherwise route straight to a lane
|
|
167
|
+
- opt-in and token-aware: always propose-then-confirm before dispatch (see the orchestration cost gate in section 5)
|
|
168
|
+
- the CLI is runtime-neutral and installs no skills; the engine is Free, and live external dispatch is not part of this release (hermes-kanban is dry-run only)
|
|
169
|
+
|
|
141
170
|
If the current project only has `SDTK-SPEC` runtime assets installed:
|
|
142
171
|
- keep `/dev` bounded to planning and `CODE_HANDOFF`
|
|
143
172
|
- do not overclaim that SDTK-CODE or SDTK-OPS runtime assets are already installed
|
|
@@ -156,6 +185,8 @@ If the current project only has `SDTK-SPEC` runtime assets installed:
|
|
|
156
185
|
- For SDTK-SPEC-only installs: keep `/dev` bounded to planning and `CODE_HANDOFF`; do not claim SDTK-CODE or SDTK-OPS are installed.
|
|
157
186
|
- For Codex runtimes: project-local skills require the explicit local `CODEX_HOME=<project>/.codex` contract; native `.codex/skills` auto-discovery is not claimed.
|
|
158
187
|
- Use `ops-parallel` or `code-parallel` only for truly independent slices. If parallel dispatch is unavailable in the active runtime, execute them sequentially in one controller session.
|
|
188
|
+
- `SDTK-AGENT` is runtime-neutral: it installs no skills and behaves identically on Claude and Codex. It is CLI-only, so do not invent a slash command for it.
|
|
189
|
+
- The `sdtk-agent` hermes-kanban adapter is dry-run only in this release; it never calls a live gateway or creates a real card. Live dispatch is a future Pro capability, so do not claim it.
|
|
159
190
|
|
|
160
191
|
## 11) Discovery And PM Readiness
|
|
161
192
|
- PM initiation starts only after `docs/discovery/REQUIREMENT_[FEATURE_KEY].md` is marked `READY_FOR_PM_INITIATION`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# CLAUDE.md
|
|
2
2
|
|
|
3
|
-
Version: 2.
|
|
4
|
-
Last Updated: 2026-
|
|
3
|
+
Version: 2.3
|
|
4
|
+
Last Updated: 2026-07-01
|
|
5
5
|
Owner: SDTK-SPEC Core Team
|
|
6
6
|
|
|
7
7
|
This file defines runtime guidance for Claude Code sessions in projects using the SDTK Suite.
|
|
@@ -14,10 +14,14 @@ This file defines runtime guidance for Claude Code sessions in projects using th
|
|
|
14
14
|
5. `sdtk-spec.config.json`
|
|
15
15
|
|
|
16
16
|
## 2) Runtime Model
|
|
17
|
-
- Suite routing:
|
|
17
|
+
- Suite routing (lanes, by task intent):
|
|
18
18
|
- `SDTK-SPEC`: orchestration, specs, planning, architecture, QA artifacts
|
|
19
|
+
- `SDTK-DESIGN`: screen/layout design, visual tokens, prototype evidence, design handoff before coding
|
|
19
20
|
- `SDTK-CODE`: implementation, bug fixing, refactoring, verification, ship flow; workflow `start->plan->build->verify->ship`; entry for ambiguous slices: `code-brainstorm`
|
|
20
21
|
- `SDTK-OPS`: deploy, infra, CI/CD, monitoring, incident, ops verification
|
|
22
|
+
- Cross-cutting capabilities (not a lane; usable across every phase):
|
|
23
|
+
- `SDTK-WIKI`: memory layer — knowledge graph, docs view, grounded `sdtk-wiki ask`
|
|
24
|
+
- `SDTK-AGENT`: orchestration layer — a durable, file-driven DAG controller above `sdtk-code` agent-team; chains multi-step runs with human gates. CLI-only (installs no skills, no slash command). Opt-in and token-aware: a run can spawn many sub-agents, so always propose-then-confirm before dispatch; never auto-start a run. See the orchestration cost gate in `AGENTS.md`.
|
|
21
25
|
- Default unprefixed entry point: Orchestrator Intake.
|
|
22
26
|
- Orchestrator classifies the user request before selecting a role, product lane, or skill.
|
|
23
27
|
- `SDTK-SPEC` phase workflow remains: PM -> BA -> ARCH -> DEV -> QA after intake decides formal feature delivery is ready.
|
|
@@ -32,9 +36,10 @@ This file defines runtime guidance for Claude Code sessions in projects using th
|
|
|
32
36
|
## 2.1) Claude Session Start Checklist
|
|
33
37
|
Read these in order when they exist:
|
|
34
38
|
1. `AGENTS.md`
|
|
35
|
-
2.
|
|
36
|
-
3. `governance/ai/session/
|
|
37
|
-
4.
|
|
39
|
+
2. `.sdtk/evolve/LEARNED.md` — locally learned, owner-approved lessons (managed by `/evolve` + `sdtk evolve`; never edit it directly)
|
|
40
|
+
3. `governance/ai/session/SDTK_ACTIVE_BOOTSTRAP.md`
|
|
41
|
+
4. `governance/ai/session/SDTK_AGENT_WORKING_RULES.md`
|
|
42
|
+
5. issue-specific controller spec and implementation plan
|
|
38
43
|
|
|
39
44
|
Routing rules:
|
|
40
45
|
- Raw idea -> brainstorm / requirement clarification, then create or update `docs/discovery/REQUIREMENT_[FEATURE_KEY].md` before PM initiation
|
|
@@ -44,8 +49,11 @@ Routing rules:
|
|
|
44
49
|
- Atlas graph/viewer, SDTK-WIKI Ask boundary, project ingest, project refresh, and project audit -> matching SDTK command or workflow
|
|
45
50
|
- "what should we do next" -> Orchestrator state review using the smallest sufficient workflow
|
|
46
51
|
|
|
52
|
+
Active orchestration check:
|
|
53
|
+
- If `.sdtk/agent-runtime/runs/` holds a run whose state is not terminal (`running` or `waiting_for_approval`), surface it in one line (run id plus the blocking gate, if any) and offer `sdtk-agent run continue` before starting unrelated work.
|
|
54
|
+
|
|
47
55
|
Proceed-vs-ask summary:
|
|
48
|
-
- Ask clarification when the outcome is ambiguous, the target path/repo is missing, there is no acceptance boundary for implementation,
|
|
56
|
+
- Ask clarification when the outcome is ambiguous, the target path/repo is missing, there is no acceptance boundary for implementation, the next step could mutate external state, or the next step would spawn multiple sub-agents / incur significant token cost (such as dispatching an `sdtk-agent` run).
|
|
49
57
|
- Proceed when intent and target are clear, the task is read-only analysis, the plan/spec is already approved, or the change is bounded and verifiable.
|
|
50
58
|
|
|
51
59
|
If only SPEC runtime assets are installed:
|
|
@@ -88,6 +96,8 @@ Skills are installed at `.claude/skills/` and provide slash commands:
|
|
|
88
96
|
|
|
89
97
|
Specialist rule reference files are installed inside each skill directory when that skill needs them (for example `.claude/skills/api-doc/references/`).
|
|
90
98
|
|
|
99
|
+
`sdtk-agent` is CLI-only: it installs no skill and has no slash command. Drive it through the `sdtk-agent` CLI (`run start|continue|status|report`, `gate approve|reject`, `workflow validate`), never a `/agent` command.
|
|
100
|
+
|
|
91
101
|
## 5) References
|
|
92
102
|
- `sdtk-spec.config.json`
|
|
93
103
|
- `governance/ai/session/SDTK_ACTIVE_BOOTSTRAP.md`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# CODEX.md
|
|
2
2
|
|
|
3
|
-
Version: 1.
|
|
4
|
-
Last Updated: 2026-
|
|
3
|
+
Version: 1.3
|
|
4
|
+
Last Updated: 2026-07-01
|
|
5
5
|
Owner: SDTK-SPEC Core Team
|
|
6
6
|
|
|
7
7
|
This file defines runtime guidance for Codex sessions in projects using the SDTK Suite.
|
|
@@ -14,10 +14,14 @@ This file defines runtime guidance for Codex sessions in projects using the SDTK
|
|
|
14
14
|
5. Other supporting docs
|
|
15
15
|
|
|
16
16
|
## 2) Runtime Model
|
|
17
|
-
- Suite routing:
|
|
17
|
+
- Suite routing (lanes, by task intent):
|
|
18
18
|
- `SDTK-SPEC`: orchestration, specs, planning, architecture, QA artifacts
|
|
19
|
+
- `SDTK-DESIGN`: screen/layout design, visual tokens, prototype evidence, design handoff before coding
|
|
19
20
|
- `SDTK-CODE`: implementation, bug fixing, refactoring, verification, ship flow; workflow `start->plan->build->verify->ship`; entry for ambiguous slices: `code-brainstorm`
|
|
20
21
|
- `SDTK-OPS`: deploy, infra, CI/CD, monitoring, incident, ops verification
|
|
22
|
+
- Cross-cutting capabilities (not a lane; usable across every phase):
|
|
23
|
+
- `SDTK-WIKI`: memory layer — knowledge graph, docs view, grounded `sdtk-wiki ask`
|
|
24
|
+
- `SDTK-AGENT`: orchestration layer — a durable, file-driven DAG controller above `sdtk-code` agent-team; chains multi-step runs with human gates. Runtime-neutral and CLI-only (installs no skills, no slash command). Opt-in and token-aware: a run can spawn many sub-agents, so always propose-then-confirm before dispatch; never auto-start a run. See the orchestration cost gate in `AGENTS.md`.
|
|
21
25
|
- Default unprefixed entry point: Orchestrator Intake.
|
|
22
26
|
- Orchestrator classifies the user request before selecting a role, product lane, or skill.
|
|
23
27
|
- `SDTK-SPEC` phase workflow remains: PM -> BA -> ARCH -> DEV -> QA after intake decides formal feature delivery is ready.
|
|
@@ -30,9 +34,10 @@ This file defines runtime guidance for Codex sessions in projects using the SDTK
|
|
|
30
34
|
## 2.1) Codex Session Start Checklist
|
|
31
35
|
Read these in order when they exist:
|
|
32
36
|
1. `AGENTS.md`
|
|
33
|
-
2.
|
|
34
|
-
3. `governance/ai/session/
|
|
35
|
-
4.
|
|
37
|
+
2. `.sdtk/evolve/LEARNED.md` — locally learned, owner-approved lessons (managed by the `sdtk-evolve` skill + `sdtk evolve`; never edit it directly)
|
|
38
|
+
3. `governance/ai/session/SDTK_ACTIVE_BOOTSTRAP.md`
|
|
39
|
+
4. `governance/ai/session/SDTK_AGENT_WORKING_RULES.md`
|
|
40
|
+
5. issue-specific controller spec and implementation plan
|
|
36
41
|
|
|
37
42
|
Routing rules:
|
|
38
43
|
- Raw idea -> brainstorm / requirement clarification, then create or update `docs/discovery/REQUIREMENT_[FEATURE_KEY].md` before PM initiation
|
|
@@ -42,8 +47,11 @@ Routing rules:
|
|
|
42
47
|
- Atlas graph/viewer, SDTK-WIKI Ask boundary, project ingest, project refresh, and project audit -> matching SDTK command or workflow
|
|
43
48
|
- "what should we do next" -> Orchestrator state review using the smallest sufficient workflow
|
|
44
49
|
|
|
50
|
+
Active orchestration check:
|
|
51
|
+
- If `.sdtk/agent-runtime/runs/` holds a run whose state is not terminal (`running` or `waiting_for_approval`), surface it in one line (run id plus the blocking gate, if any) and offer `sdtk-agent run continue` before starting unrelated work.
|
|
52
|
+
|
|
45
53
|
Proceed-vs-ask summary:
|
|
46
|
-
- Ask clarification when the outcome is ambiguous, the target path/repo is missing, there is no acceptance boundary for implementation,
|
|
54
|
+
- Ask clarification when the outcome is ambiguous, the target path/repo is missing, there is no acceptance boundary for implementation, the next step could mutate external state, or the next step would spawn multiple sub-agents / incur significant token cost (such as dispatching an `sdtk-agent` run).
|
|
47
55
|
- Proceed when intent and target are clear, the task is read-only analysis, the plan/spec is already approved, or the change is bounded and verifiable.
|
|
48
56
|
|
|
49
57
|
If only SPEC runtime assets are installed:
|
|
@@ -165,8 +165,13 @@ foreach ($skillName in @('arch', 'api-doc', 'api-design-spec', 'screen-design-sp
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
# Strict count assertions
|
|
169
|
-
|
|
168
|
+
# Strict count assertions. Expected skills derive from the payload source of
|
|
169
|
+
# truth (dirs shipping a SKILL.md) so the integrity check still catches copy
|
|
170
|
+
# failures without drifting every time a skill is added (BK-316 fix; the old
|
|
171
|
+
# hard-coded 14 broke install when the 15th skill landed).
|
|
172
|
+
$expectedSkills = @(Get-ChildItem -Path $skillsSource -Directory | Where-Object {
|
|
173
|
+
Test-Path -LiteralPath (Join-Path $_.FullName 'SKILL.md')
|
|
174
|
+
}).Count
|
|
170
175
|
$expectedManagedRefs = 12
|
|
171
176
|
if ($skillCount -ne $expectedSkills) {
|
|
172
177
|
throw "Claude install failed. Expected $expectedSkills skills but installed $skillCount."
|
|
@@ -15,7 +15,17 @@
|
|
|
15
15
|
"frontend": "Set your frontend stack (example: React + Vite)",
|
|
16
16
|
"mobile": "N/A",
|
|
17
17
|
"database": "Set your database (example: PostgreSQL 15)",
|
|
18
|
-
"auth": "Set your auth strategy (example: JWT/OAuth2)"
|
|
18
|
+
"auth": "Set your auth strategy (example: JWT/OAuth2)",
|
|
19
|
+
"detection": {
|
|
20
|
+
"language": null,
|
|
21
|
+
"framework": null,
|
|
22
|
+
"frameworkVersion": null,
|
|
23
|
+
"packageManager": null,
|
|
24
|
+
"confidence": "low",
|
|
25
|
+
"evidence": [],
|
|
26
|
+
"detectedAt": null,
|
|
27
|
+
"method": "static"
|
|
28
|
+
}
|
|
19
29
|
},
|
|
20
30
|
"commands": {
|
|
21
31
|
"backendTests": "UPDATE_ME: set backend test command",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdtk-evolve
|
|
3
|
+
description: "Local self-improvement loop for SDTK (BK-316). Harvest the operator's own past agent sessions for recurring friction, score adopted lessons by recurrence, and stage at most 4 bounded, evidence-backed lesson edits to .sdtk/evolve/LEARNED.md for explicit human adoption. Use at the end of a substantial work session, when the same correction keeps repeating, or when the operator asks to evolve/learn from this."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SDTK Evolve — learn from your own sessions, behind a human gate
|
|
7
|
+
|
|
8
|
+
Every turn produced while executing this skill is part of an **SDTK-EVOLVE CYCLE**. Begin your first reply with the literal marker line `SDTK-EVOLVE CYCLE` — future harvests use it to skip evolve-generated content, so the loop never mines itself.
|
|
9
|
+
|
|
10
|
+
## Critical Constraints
|
|
11
|
+
- I propose **at most 4** bounded edits per cycle — `add`, `delete`, or `replace` of single bullets — and I never rewrite the learned document wholesale.
|
|
12
|
+
- I **never edit** `.sdtk/evolve/LEARNED.md`, `state.json`, or any live file myself. `sdtk evolve stage` is the only writer of staging; only the human's `sdtk evolve adopt` applies it (there is **no auto-adopt** — the flag does not exist), and `sdtk evolve revert` restores the pre-adopt backup.
|
|
13
|
+
- Every proposed edit carries **evidence** (which sessions, how many occurrences) and a pre-registered falsifiable **bet** ("friction signature X stops appearing"). No measurable bet → the edit is dropped, not softened.
|
|
14
|
+
- Redaction is **fail-closed**: secrets, tokens, PII, prompts, and full transcripts never enter a draft. When unsure whether content is sensitive, describe it — never copy it. (`sdtk evolve stage` re-scans and refuses on any hit.)
|
|
15
|
+
- I never guess the Codex session-log format: the Codex harvest path follows the **issue #247** validated format only. Until that report is merged, Codex harvest is marked *pending #247* and skipped — the Claude Code path (when its transcripts exist on this machine) proceeds regardless.
|
|
16
|
+
- Opinion-only lessons (no falsifiable claim) may enter only as preference bullets and never override correctness lessons.
|
|
17
|
+
|
|
18
|
+
## When to run
|
|
19
|
+
- End of a substantial session, especially one where the operator corrected you more than once.
|
|
20
|
+
- The operator says some variant of "I told you this before".
|
|
21
|
+
- `sdtk evolve status` reports unharvested sessions or a due dogfood checkpoint.
|
|
22
|
+
|
|
23
|
+
## Procedure
|
|
24
|
+
|
|
25
|
+
1. **Load state.** Run `sdtk evolve status`. Read `.sdtk/evolve/state.json` (last harvest time, adopted lessons with signatures) and `.sdtk/evolve/LEARNED.md` (current lessons + line count vs the **150**-line cap). If the CLI is unavailable, stop and tell the operator to update `sdtk-kit` (the `evolve` CLI ships with sdtk-kit ≥ 1.16.0) — do **not** hand-write staging files.
|
|
26
|
+
2. **Harvest.** Scan sessions since the last harvest:
|
|
27
|
+
- **Claude Code (if present on this machine):** `~/.claude/projects/<project-slug>/*.jsonl` — extract per-session digests: user intents, tool usage, and correction signals (negative: "vẫn sai", "làm lại", "that's wrong", "I told you", "again"; positive: "perfect", "đúng rồi", "great").
|
|
28
|
+
- **Codex:** *pending #247* — once `SDTK_BK316_CODEX_HARVEST_VALIDATION_R1_*.md` is merged, harvest Codex session logs per its validated format; until then, note "codex: skipped (pending #247)" in the report.
|
|
29
|
+
- **Filters (both sources):** skip meta prompts (bare skill invocations, pasted-text stubs, system noise) and skip any content carrying the `SDTK-EVOLVE CYCLE` marker (self-pollution guard).
|
|
30
|
+
3. **Score recurrence** for every adopted lesson: did its signature re-appear in post-adoption sessions? Render the verdict table — `WORKING` (no recurrence) or `FAILING` (recurred). A lesson FAILING for 2 consecutive cycles **must** get a `replace` or `delete` proposal before any new `add`. The same rule applies when `LEARNED.md` is over the 150-line cap.
|
|
31
|
+
4. **Reflect.** From the harvested friction, draft **at most 4** edits targeting the lane sections of `LEARNED.md` (`## Chung`, `## SPEC`, `## CODE`, `## OPS`, `## DESIGN`). Prefer one excellent lesson over four mediocre ones. Write the draft to a scratch file using this contract:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"schema": "sdtk.evolve-draft.v1",
|
|
36
|
+
"generated_at": "<ISO-8601 UTC>",
|
|
37
|
+
"harvest": { "sources": ["claude"], "sessions_scanned": 0, "since": "<ISO-8601 or null>", "codex": "skipped (pending #247)" },
|
|
38
|
+
"recurrence": [
|
|
39
|
+
{ "lesson_id": "L-001", "signature": "<toolkit:area:slug>", "before": "4/10", "after": "0/14", "verdict": "WORKING" }
|
|
40
|
+
],
|
|
41
|
+
"edits": [
|
|
42
|
+
{
|
|
43
|
+
"op": "add",
|
|
44
|
+
"lane": "CODE",
|
|
45
|
+
"content": "<one bullet, imperative, self-contained>",
|
|
46
|
+
"anchor": "<required for delete/replace: substring of the target bullet>",
|
|
47
|
+
"evidence": ["<session/date>: <what happened>, <N> occurrences"],
|
|
48
|
+
"bet": "<friction signature that should stop appearing>",
|
|
49
|
+
"signature": "<toolkit:area:slug>"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
5. **Stage.** Run `sdtk evolve stage --from <draft-path>`. The CLI validates the draft (budget, ops, lanes, required `evidence`/`bet`/`signature` fields), runs the fail-closed redaction scan, and writes `.sdtk/evolve/staging/<ts>/` (`proposal.md`, `edits.json`, `report.md` with the recurrence table and scorecard).
|
|
56
|
+
6. **Present and stop.** Show the operator: the recurrence verdict table, each proposed edit with its evidence and bet, and the exact next commands — `sdtk evolve adopt` to apply (backup taken automatically) or discard the staging folder; `sdtk evolve revert` undoes the last adopt. **Do not adopt on the operator's behalf. End the cycle here.**
|
|
57
|
+
|
|
58
|
+
## What LEARNED.md is (and is not)
|
|
59
|
+
- It is the operator-approved, locally learned layer that sessions read at start (the AGENTS.md/CODEX template carries the pointer). It survives `sdtk update` and re-init because it lives outside every kit-managed file.
|
|
60
|
+
- It is **not** yours to edit directly, not a scratchpad, not a place for secrets or project data — lessons are about *how to work*, not *what the code is*.
|
|
61
|
+
- Git posture is the operator's choice (commit to share with a team, ignore for personal habits); `sdtk evolve status` shows the current posture.
|
|
62
|
+
|
|
63
|
+
## Runtime Entrypoint Truth (Codex)
|
|
64
|
+
- Project-local Codex support is bounded to explicit `CODEX_HOME=<project>/.codex`; presence of `sdtk-evolve` under `.codex/skills` does not prove direct built-in exposure. Invoke via "Use the sdtk-evolve skill." when no direct syntax is validated.
|
|
65
|
+
|
|
66
|
+
## Effectiveness discipline (BK-316 §8)
|
|
67
|
+
The loop measures itself: recurrence verdicts are the metric, FAILING lessons get culled, and `sdtk evolve status` reminds the operator when the dogfood checkpoint (4 weeks / 20 sessions) is due. Never claim a lesson "works" without the recurrence evidence — flat/noisy results are reported as exactly that.
|
|
@@ -328,3 +328,25 @@ skills:
|
|
|
328
328
|
runtime_support: [claude, codex]
|
|
329
329
|
dependencies: [sdtk-qa, sdtk-screen-design-spec]
|
|
330
330
|
pack: core
|
|
331
|
+
- name: sdtk-evolve
|
|
332
|
+
phase: orchestration
|
|
333
|
+
role_tag: /evolve
|
|
334
|
+
use_when: Harvest the operator's own past agent sessions for recurring friction, score adopted lessons by recurrence, and stage at most 4 bounded evidence-backed lesson edits to .sdtk/evolve/LEARNED.md for explicit human adoption.
|
|
335
|
+
primary_inputs:
|
|
336
|
+
- .sdtk/evolve/state.json
|
|
337
|
+
- .sdtk/evolve/LEARNED.md
|
|
338
|
+
- local agent session logs (Claude Code transcripts; Codex per issue #247 validation)
|
|
339
|
+
primary_outputs:
|
|
340
|
+
- .sdtk/evolve/staging/<ts>/proposal.md
|
|
341
|
+
- .sdtk/evolve/staging/<ts>/edits.json
|
|
342
|
+
- .sdtk/evolve/staging/<ts>/report.md
|
|
343
|
+
hard_gates:
|
|
344
|
+
- Never edit LEARNED.md or state.json directly; staging comes only from `sdtk evolve stage`, and only the human's `sdtk evolve adopt` applies it (no auto-adopt exists).
|
|
345
|
+
- At most 4 bounded add|delete|replace edits per cycle, each with evidence and a pre-registered falsifiable bet; redaction is fail-closed.
|
|
346
|
+
- Never guess the Codex session-log format; harvest Codex only per the issue #247 validated format.
|
|
347
|
+
references: []
|
|
348
|
+
prompts: []
|
|
349
|
+
scripts: []
|
|
350
|
+
runtime_support: [claude, codex]
|
|
351
|
+
dependencies: []
|
|
352
|
+
pack: core
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: evolve
|
|
3
|
+
description: Local self-improvement loop for SDTK (BK-316). Harvest the operator's own past agent sessions for recurring friction, score adopted lessons by recurrence, and stage at most 4 bounded, evidence-backed lesson edits to .sdtk/evolve/LEARNED.md for explicit human adoption. Use at the end of a substantial work session, when the same correction keeps repeating, or when the operator asks to "evolve"/"learn from this".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SDTK Evolve — learn from your own sessions, behind a human gate
|
|
7
|
+
|
|
8
|
+
Every turn produced while executing this skill is part of an **SDTK-EVOLVE CYCLE**. Begin your first reply with the literal marker line `SDTK-EVOLVE CYCLE` — future harvests use it to skip evolve-generated content, so the loop never mines itself.
|
|
9
|
+
|
|
10
|
+
## Critical Constraints
|
|
11
|
+
- I propose **at most 4** bounded edits per cycle — `add`, `delete`, or `replace` of single bullets — and I never rewrite the learned document wholesale.
|
|
12
|
+
- I **never edit** `.sdtk/evolve/LEARNED.md`, `state.json`, or any live file myself. `sdtk evolve stage` is the only writer of staging; only the human's `sdtk evolve adopt` applies it (there is **no auto-adopt** — the flag does not exist), and `sdtk evolve revert` restores the pre-adopt backup.
|
|
13
|
+
- Every proposed edit carries **evidence** (which sessions, how many occurrences) and a pre-registered falsifiable **bet** ("friction signature X stops appearing"). No measurable bet → the edit is dropped, not softened.
|
|
14
|
+
- Redaction is **fail-closed**: secrets, tokens, PII, prompts, and full transcripts never enter a draft. When unsure whether content is sensitive, describe it — never copy it. (`sdtk evolve stage` re-scans and refuses on any hit.)
|
|
15
|
+
- I never guess the Codex session-log format: the Codex harvest path follows the **issue #247** validated format only. Until that report is merged, Codex harvest is marked *pending #247* and skipped — the Claude path proceeds regardless.
|
|
16
|
+
- Opinion-only lessons (no falsifiable claim) may enter only as preference bullets and never override correctness lessons.
|
|
17
|
+
|
|
18
|
+
## When to run
|
|
19
|
+
- End of a substantial session, especially one where the operator corrected you more than once.
|
|
20
|
+
- The operator says some variant of "I told you this before".
|
|
21
|
+
- `sdtk evolve status` reports unharvested sessions or a due dogfood checkpoint.
|
|
22
|
+
|
|
23
|
+
## Procedure
|
|
24
|
+
|
|
25
|
+
1. **Load state.** Run `sdtk evolve status`. Read `.sdtk/evolve/state.json` (last harvest time, adopted lessons with signatures) and `.sdtk/evolve/LEARNED.md` (current lessons + line count vs the **150**-line cap). If the CLI is unavailable, stop and tell the operator to update `sdtk-kit` (the `evolve` CLI ships with sdtk-kit ≥ 1.16.0) — do **not** hand-write staging files.
|
|
26
|
+
2. **Harvest.** Scan sessions since the last harvest:
|
|
27
|
+
- **Claude Code:** `~/.claude/projects/<project-slug>/*.jsonl` — extract per-session digests: user intents, tool usage, and correction signals (negative: "vẫn sai", "làm lại", "that's wrong", "I told you", "again"; positive: "perfect", "đúng rồi", "great").
|
|
28
|
+
- **Codex:** *pending #247* — once `SDTK_BK316_CODEX_HARVEST_VALIDATION_R1_*.md` is merged, harvest per its validated format; until then, note "codex: skipped (pending #247)" in the report.
|
|
29
|
+
- **Filters (both sources):** skip meta prompts (bare slash commands, pasted-text stubs, system noise) and skip any content carrying the `SDTK-EVOLVE CYCLE` marker (self-pollution guard).
|
|
30
|
+
3. **Score recurrence** for every adopted lesson: did its signature re-appear in post-adoption sessions? Render the verdict table — `WORKING` (no recurrence) or `FAILING` (recurred). A lesson FAILING for 2 consecutive cycles **must** get a `replace` or `delete` proposal before any new `add`. The same rule applies when `LEARNED.md` is over the 150-line cap.
|
|
31
|
+
4. **Reflect.** From the harvested friction, draft **at most 4** edits targeting the lane sections of `LEARNED.md` (`## Chung`, `## SPEC`, `## CODE`, `## OPS`, `## DESIGN`). Prefer one excellent lesson over four mediocre ones. Write the draft to a scratch file using this contract:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"schema": "sdtk.evolve-draft.v1",
|
|
36
|
+
"generated_at": "<ISO-8601 UTC>",
|
|
37
|
+
"harvest": { "sources": ["claude"], "sessions_scanned": 0, "since": "<ISO-8601 or null>", "codex": "skipped (pending #247)" },
|
|
38
|
+
"recurrence": [
|
|
39
|
+
{ "lesson_id": "L-001", "signature": "<toolkit:area:slug>", "before": "4/10", "after": "0/14", "verdict": "WORKING" }
|
|
40
|
+
],
|
|
41
|
+
"edits": [
|
|
42
|
+
{
|
|
43
|
+
"op": "add",
|
|
44
|
+
"lane": "CODE",
|
|
45
|
+
"content": "<one bullet, imperative, self-contained>",
|
|
46
|
+
"anchor": "<required for delete/replace: substring of the target bullet>",
|
|
47
|
+
"evidence": ["<session/date>: <what happened>, <N> occurrences"],
|
|
48
|
+
"bet": "<friction signature that should stop appearing>",
|
|
49
|
+
"signature": "<toolkit:area:slug>"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
5. **Stage.** Run `sdtk evolve stage --from <draft-path>`. The CLI validates the draft (budget, ops, lanes, required `evidence`/`bet`/`signature` fields), runs the fail-closed redaction scan, and writes `.sdtk/evolve/staging/<ts>/` (`proposal.md`, `edits.json`, `report.md` with the recurrence table and scorecard).
|
|
56
|
+
6. **Present and stop.** Show the operator: the recurrence verdict table, each proposed edit with its evidence and bet, and the exact next commands — `sdtk evolve adopt` to apply (backup taken automatically) or discard the staging folder; `sdtk evolve revert` undoes the last adopt. **Do not adopt on the operator's behalf. End the cycle here.**
|
|
57
|
+
|
|
58
|
+
## What LEARNED.md is (and is not)
|
|
59
|
+
- It is the operator-approved, locally learned layer that sessions read at start (the CLAUDE.md template carries the pointer). It survives `sdtk update` and re-init because it lives outside every kit-managed file.
|
|
60
|
+
- It is **not** yours to edit directly, not a scratchpad, not a place for secrets or project data — lessons are about *how to work*, not *what the code is*.
|
|
61
|
+
- Git posture is the operator's choice (commit to share with a team, ignore for personal habits); `sdtk evolve status` shows the current posture.
|
|
62
|
+
|
|
63
|
+
## Effectiveness discipline (BK-316 §8)
|
|
64
|
+
The loop measures itself: recurrence verdicts are the metric, FAILING lessons get culled, and `sdtk evolve status` reminds the operator when the dogfood checkpoint (4 weeks / 20 sessions) is due. Never claim a lesson "works" without the recurrence evidence — flat/noisy results are reported as exactly that.
|
package/package.json
CHANGED
package/src/commands/help.js
CHANGED
|
@@ -110,10 +110,11 @@ function cmdHelp() {
|
|
|
110
110
|
" sdtk-spec atlas watch Watch for markdown changes and rebuild automatically",
|
|
111
111
|
" sdtk-spec atlas status Show initialization state and last build summary",
|
|
112
112
|
"",
|
|
113
|
-
"Project subcommands
|
|
113
|
+
"Project subcommands:",
|
|
114
114
|
" sdtk-spec project ingest Build reusable project census and profile foundation from an existing repo (Pro)",
|
|
115
115
|
" sdtk-spec project audit Read-only audit: readiness score, gap list, risk list, next steps (Pro)",
|
|
116
116
|
" sdtk-spec project refresh Incremental managed refresh of .sdtk/project/ artifacts (Pro)",
|
|
117
|
+
" sdtk-spec project promote Publish reviewed staged docs into /docs/ for sdtk-wiki (free; dry-run by default)",
|
|
117
118
|
"",
|
|
118
119
|
"Atlas options (init):",
|
|
119
120
|
" --project-path <path> Target project directory (default: cwd)",
|
|
@@ -202,6 +203,20 @@ function cmdHelp() {
|
|
|
202
203
|
" - project refresh does not perform a read-only audit; use 'project audit' for that.",
|
|
203
204
|
" - Maintainer-root guard: project refresh refuses the SDTK maintainer monorepo root as a refresh target.",
|
|
204
205
|
"",
|
|
206
|
+
"Project promote options (free):",
|
|
207
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
208
|
+
" --output-dir <path> Foundation read path (default: <project>/.sdtk/project)",
|
|
209
|
+
" --apply Perform the copy (default is a dry-run plan only)",
|
|
210
|
+
" --force Overwrite existing live docs (default: skip existing)",
|
|
211
|
+
" --json Print the promote plan/result as JSON",
|
|
212
|
+
"",
|
|
213
|
+
"Project promote notes:",
|
|
214
|
+
" - project promote is free; it publishes reviewed staged docs into <project>/docs/.",
|
|
215
|
+
" - Source: <project>/.sdtk/project/DOC_SYNTHESIS_BASELINE/docs/ (run 'project ingest' first).",
|
|
216
|
+
" - Default is a dry-run that prints the plan and writes nothing; add --apply to publish.",
|
|
217
|
+
" - Existing live docs are skipped unless --force is given (human-review-first).",
|
|
218
|
+
" - After promote, run 'sdtk-wiki atlas build' to index the docs into the knowledge graph.",
|
|
219
|
+
"",
|
|
205
220
|
"Generate behavior:",
|
|
206
221
|
" The generate command creates the standard 17-file scaffold with TBD placeholders.",
|
|
207
222
|
" Scaffolds define document structure for each SDLC phase.",
|
package/src/commands/init.js
CHANGED
|
@@ -7,6 +7,7 @@ const { runScript } = require("../lib/powershell");
|
|
|
7
7
|
const { ValidationError } = require("../lib/errors");
|
|
8
8
|
const { VALID_SCOPES, defaultScope, isProjectScopeSupported } = require("../lib/scope");
|
|
9
9
|
const { assertProjectRefreshTargetAllowed } = require("../lib/project-target-guard");
|
|
10
|
+
const { detectAndMergeConfig } = require("../lib/stack-detector");
|
|
10
11
|
|
|
11
12
|
const FLAG_DEFS = {
|
|
12
13
|
runtime: { type: "string" },
|
|
@@ -15,6 +16,7 @@ const FLAG_DEFS = {
|
|
|
15
16
|
force: { type: "boolean" },
|
|
16
17
|
"skip-skills": { type: "boolean" },
|
|
17
18
|
"skip-runtime-assets": { type: "boolean" },
|
|
19
|
+
"skip-stack-detect": { type: "boolean" },
|
|
18
20
|
verbose: { type: "boolean" },
|
|
19
21
|
};
|
|
20
22
|
|
|
@@ -90,6 +92,20 @@ async function cmdInit(args) {
|
|
|
90
92
|
);
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
// Static stack detection: populate sdtk-spec.config.json so downstream
|
|
96
|
+
// commands (project ingest/audit/refresh) and the 17-file scaffold know the
|
|
97
|
+
// project stack without manual entry. Best-effort: never fail init.
|
|
98
|
+
let stackSummary = null;
|
|
99
|
+
if (!flags["skip-stack-detect"]) {
|
|
100
|
+
try {
|
|
101
|
+
stackSummary = detectAndMergeConfig(projectPath);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
if (flags.verbose) {
|
|
104
|
+
console.warn(`Warning: stack detection skipped: ${err.message}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
93
109
|
console.log("");
|
|
94
110
|
console.log("SDTK-SPEC workspace initialized successfully.");
|
|
95
111
|
if (runtime === "codex" && scope === "project") {
|
|
@@ -97,8 +113,27 @@ async function cmdInit(args) {
|
|
|
97
113
|
console.log("Launch Codex with CODEX_HOME=<project>/.codex to activate that local runtime home.");
|
|
98
114
|
}
|
|
99
115
|
console.log("");
|
|
116
|
+
if (stackSummary && stackSummary.written && stackSummary.summary) {
|
|
117
|
+
const d = stackSummary.detected.detection;
|
|
118
|
+
const s = stackSummary.summary;
|
|
119
|
+
const fw = d.framework
|
|
120
|
+
? `${d.framework}${d.frameworkVersion ? " " + d.frameworkVersion : ""}`
|
|
121
|
+
: d.language || "unknown";
|
|
122
|
+
console.log(`Detected stack: ${fw} (confidence: ${d.confidence}).`);
|
|
123
|
+
if (s.written.length) {
|
|
124
|
+
console.log(` Auto-filled in sdtk-spec.config.json: ${s.written.join(", ")}.`);
|
|
125
|
+
}
|
|
126
|
+
if (s.preserved.length) {
|
|
127
|
+
console.log(` Kept your existing values: ${s.preserved.join(", ")}.`);
|
|
128
|
+
}
|
|
129
|
+
if (s.unknown.length) {
|
|
130
|
+
console.log(` Could not detect (please set manually): ${s.unknown.join(", ")}.`);
|
|
131
|
+
}
|
|
132
|
+
console.log("");
|
|
133
|
+
}
|
|
134
|
+
|
|
100
135
|
console.log("Next steps:");
|
|
101
|
-
console.log(" 1. Review
|
|
136
|
+
console.log(" 1. Review sdtk-spec.config.json (stack auto-detected where possible; fill any remaining placeholders).");
|
|
102
137
|
console.log(" 2. Review bootstrap guidance:");
|
|
103
138
|
console.log(` ${path.join(projectPath, "AGENTS.md")}`);
|
|
104
139
|
if (runtime === "claude") {
|
package/src/commands/project.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
const { runProjectIngest } = require("../lib/project-ingest");
|
|
4
4
|
const { runProjectAudit } = require("../lib/project-audit");
|
|
5
5
|
const { runProjectRefresh } = require("../lib/project-refresh");
|
|
6
|
+
const { runProjectPromote } = require("../lib/project-promote");
|
|
6
7
|
const { ValidationError } = require("../lib/errors");
|
|
7
8
|
|
|
8
|
-
const PROJECT_SUBCOMMANDS = new Set(["ingest", "audit", "refresh"]);
|
|
9
|
+
const PROJECT_SUBCOMMANDS = new Set(["ingest", "audit", "refresh", "promote"]);
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Top-level dispatcher for `sdtk-spec project <subcommand>`.
|
|
@@ -26,6 +27,7 @@ async function cmdProject(args) {
|
|
|
26
27
|
if (!args || args.length === 0) {
|
|
27
28
|
console.error("[project] Usage: sdtk-spec project <subcommand> [options]");
|
|
28
29
|
console.error(" Premium subcommands: ingest, audit, refresh (requires Pro entitlement)");
|
|
30
|
+
console.error(" Free subcommand: promote (publish reviewed staged docs into /docs/)");
|
|
29
31
|
console.error(" Run 'sdtk-spec --help' for full usage.");
|
|
30
32
|
return 1;
|
|
31
33
|
}
|
|
@@ -34,7 +36,7 @@ async function cmdProject(args) {
|
|
|
34
36
|
|
|
35
37
|
if (!PROJECT_SUBCOMMANDS.has(subcommand)) {
|
|
36
38
|
throw new ValidationError(
|
|
37
|
-
`Unknown project subcommand: "${subcommand}". Valid subcommands: ingest, audit, refresh.`
|
|
39
|
+
`Unknown project subcommand: "${subcommand}". Valid subcommands: ingest, audit, refresh, promote.`
|
|
38
40
|
);
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -45,6 +47,8 @@ async function cmdProject(args) {
|
|
|
45
47
|
return runProjectAudit(rest);
|
|
46
48
|
case "refresh":
|
|
47
49
|
return runProjectRefresh(rest);
|
|
50
|
+
case "promote":
|
|
51
|
+
return runProjectPromote(rest);
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
|
package/src/lib/project-audit.js
CHANGED
|
@@ -295,6 +295,9 @@ async function runProjectAudit(args) {
|
|
|
295
295
|
docBaselineDir: config.docBaselineDir,
|
|
296
296
|
docBaselineDocsRoot: config.docBaselineDocsRoot,
|
|
297
297
|
docSynthesisStatePath: config.docSynthesisStatePath,
|
|
298
|
+
excludes: config.excludes,
|
|
299
|
+
stack: config.stack,
|
|
300
|
+
commands: config.commands,
|
|
298
301
|
hasCachedFoundation,
|
|
299
302
|
hasStagedDocsBaseline,
|
|
300
303
|
json: !!flags.json,
|
|
@@ -22,11 +22,39 @@ const DEFAULT_EXCLUDES = [
|
|
|
22
22
|
"target",
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Best-effort read of the project's sdtk-spec.config.json `stack` and
|
|
27
|
+
* `commands` blocks. Returns nulls when the file is missing or unparseable —
|
|
28
|
+
* never throws, so ingest/audit/refresh keep working without a config.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} projectPath
|
|
31
|
+
* @returns {{ stack: object|null, commands: object|null }}
|
|
32
|
+
*/
|
|
33
|
+
function readSpecConfig(projectPath) {
|
|
34
|
+
const specConfigPath = path.join(projectPath, "sdtk-spec.config.json");
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(fs.readFileSync(specConfigPath, "utf8"));
|
|
37
|
+
if (!parsed || typeof parsed !== "object") {
|
|
38
|
+
return { stack: null, commands: null };
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
stack: parsed.stack && typeof parsed.stack === "object" ? parsed.stack : null,
|
|
42
|
+
commands:
|
|
43
|
+
parsed.commands && typeof parsed.commands === "object"
|
|
44
|
+
? parsed.commands
|
|
45
|
+
: null,
|
|
46
|
+
};
|
|
47
|
+
} catch (_e) {
|
|
48
|
+
return { stack: null, commands: null };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
25
52
|
/**
|
|
26
53
|
* Resolve and validate project path and output directory from parsed flags.
|
|
27
54
|
*
|
|
28
55
|
* Returns the canonical set of output paths for the .sdtk/project foundation
|
|
29
|
-
* and the BK-084 staged doc synthesis workspace
|
|
56
|
+
* and the BK-084 staged doc synthesis workspace, plus the project's declared
|
|
57
|
+
* stack/commands (best-effort) so premium handlers can use them.
|
|
30
58
|
*
|
|
31
59
|
* @param {{ "project-path"?: string, "output-dir"?: string }} flags
|
|
32
60
|
* @returns {{
|
|
@@ -45,6 +73,8 @@ const DEFAULT_EXCLUDES = [
|
|
|
45
73
|
* docBaselineDocsRoot: string,
|
|
46
74
|
* docSynthesisStatePath: string,
|
|
47
75
|
* excludes: string[],
|
|
76
|
+
* stack: object|null,
|
|
77
|
+
* commands: object|null,
|
|
48
78
|
* }}
|
|
49
79
|
*/
|
|
50
80
|
function resolveProjectConfig(flags) {
|
|
@@ -64,9 +94,13 @@ function resolveProjectConfig(flags) {
|
|
|
64
94
|
|
|
65
95
|
const docBaselineDir = path.join(outputDir, "DOC_SYNTHESIS_BASELINE");
|
|
66
96
|
|
|
97
|
+
const { stack, commands } = readSpecConfig(projectPath);
|
|
98
|
+
|
|
67
99
|
return {
|
|
68
100
|
projectPath,
|
|
69
101
|
outputDir,
|
|
102
|
+
stack,
|
|
103
|
+
commands,
|
|
70
104
|
configPath: path.join(outputDir, "config.json"),
|
|
71
105
|
statePath: path.join(outputDir, "INGEST_STATE.json"),
|
|
72
106
|
refreshStatePath: path.join(outputDir, "REFRESH_STATE.json"),
|
|
@@ -104,5 +138,6 @@ function writeProjectConfig(config) {
|
|
|
104
138
|
module.exports = {
|
|
105
139
|
resolveProjectConfig,
|
|
106
140
|
writeProjectConfig,
|
|
141
|
+
readSpecConfig,
|
|
107
142
|
DEFAULT_EXCLUDES,
|
|
108
143
|
};
|
|
@@ -280,6 +280,9 @@ async function runProjectIngest(args) {
|
|
|
280
280
|
docBaselineDir: config.docBaselineDir,
|
|
281
281
|
docBaselineDocsRoot: config.docBaselineDocsRoot,
|
|
282
282
|
docSynthesisStatePath: config.docSynthesisStatePath,
|
|
283
|
+
excludes: config.excludes,
|
|
284
|
+
stack: config.stack,
|
|
285
|
+
commands: config.commands,
|
|
283
286
|
json: !!flags.json,
|
|
284
287
|
argv: args,
|
|
285
288
|
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { parseFlags } = require("./args");
|
|
6
|
+
const { resolveProjectConfig } = require("./project-config");
|
|
7
|
+
|
|
8
|
+
const PROMOTE_FLAG_DEFS = {
|
|
9
|
+
"project-path": { type: "string" },
|
|
10
|
+
"output-dir": { type: "string" },
|
|
11
|
+
apply: { type: "boolean" },
|
|
12
|
+
force: { type: "boolean" },
|
|
13
|
+
json: { type: "boolean" },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Recursively list files under root, returning paths relative to root (posix).
|
|
18
|
+
*/
|
|
19
|
+
function listFilesRel(root) {
|
|
20
|
+
const out = [];
|
|
21
|
+
const stack = [root];
|
|
22
|
+
while (stack.length) {
|
|
23
|
+
const dir = stack.pop();
|
|
24
|
+
let entries;
|
|
25
|
+
try {
|
|
26
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
27
|
+
} catch (_e) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
for (const ent of entries) {
|
|
31
|
+
const abs = path.join(dir, ent.name);
|
|
32
|
+
if (ent.isDirectory()) stack.push(abs);
|
|
33
|
+
else if (ent.isFile()) out.push(path.relative(root, abs).split(path.sep).join("/"));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
out.sort();
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Promote reviewed staged docs (.sdtk/project/DOC_SYNTHESIS_BASELINE/docs/**)
|
|
42
|
+
* into the live <project>/docs/** tree so sdtk-wiki can index them.
|
|
43
|
+
*
|
|
44
|
+
* Safety model (human-review-first):
|
|
45
|
+
* - Default is a dry-run: prints the plan, writes nothing.
|
|
46
|
+
* - --apply performs the copy of NEW files only.
|
|
47
|
+
* - --force additionally overwrites existing live docs.
|
|
48
|
+
*
|
|
49
|
+
* @param {string[]} args - Remaining argv after "project promote"
|
|
50
|
+
* @returns {Promise<number>} CLI exit code
|
|
51
|
+
*/
|
|
52
|
+
async function runProjectPromote(args) {
|
|
53
|
+
const { flags } = parseFlags(args, PROMOTE_FLAG_DEFS);
|
|
54
|
+
|
|
55
|
+
let config;
|
|
56
|
+
try {
|
|
57
|
+
config = resolveProjectConfig(flags);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
console.error(`[project promote] ${err.message}`);
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const stagedDocsRoot = config.docBaselineDocsRoot;
|
|
64
|
+
if (!fs.existsSync(stagedDocsRoot) || !fs.statSync(stagedDocsRoot).isDirectory()) {
|
|
65
|
+
console.error(
|
|
66
|
+
`[project promote] No staged docs found at ${stagedDocsRoot}. ` +
|
|
67
|
+
`Run "sdtk-spec project ingest" first.`
|
|
68
|
+
);
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const liveDocsRoot = path.join(config.projectPath, "docs");
|
|
73
|
+
const relFiles = listFilesRel(stagedDocsRoot);
|
|
74
|
+
|
|
75
|
+
const plan = { create: [], overwrite: [], skipExisting: [] };
|
|
76
|
+
for (const rel of relFiles) {
|
|
77
|
+
const target = path.join(liveDocsRoot, rel);
|
|
78
|
+
if (!fs.existsSync(target)) plan.create.push(rel);
|
|
79
|
+
else if (flags.force) plan.overwrite.push(rel);
|
|
80
|
+
else plan.skipExisting.push(rel);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const apply = !!flags.apply;
|
|
84
|
+
const written = [];
|
|
85
|
+
if (apply) {
|
|
86
|
+
const toWrite = plan.create.concat(plan.overwrite);
|
|
87
|
+
for (const rel of toWrite) {
|
|
88
|
+
const src = path.join(stagedDocsRoot, rel);
|
|
89
|
+
const dest = path.join(liveDocsRoot, rel);
|
|
90
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
91
|
+
fs.copyFileSync(src, dest);
|
|
92
|
+
written.push(rel);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (flags.json) {
|
|
97
|
+
console.log(
|
|
98
|
+
JSON.stringify({
|
|
99
|
+
stagedDocsRoot,
|
|
100
|
+
liveDocsRoot,
|
|
101
|
+
applied: apply,
|
|
102
|
+
plan,
|
|
103
|
+
written,
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Human-readable report
|
|
110
|
+
console.log(`Project promote — staged → live docs`);
|
|
111
|
+
console.log(` Staged: ${stagedDocsRoot}`);
|
|
112
|
+
console.log(` Live: ${liveDocsRoot}`);
|
|
113
|
+
console.log("");
|
|
114
|
+
console.log(` New files: ${plan.create.length}`);
|
|
115
|
+
plan.create.forEach((r) => console.log(` + docs/${r}`));
|
|
116
|
+
if (plan.skipExisting.length) {
|
|
117
|
+
console.log(` Existing (skipped, use --force to overwrite): ${plan.skipExisting.length}`);
|
|
118
|
+
plan.skipExisting.forEach((r) => console.log(` = docs/${r}`));
|
|
119
|
+
}
|
|
120
|
+
if (flags.force && plan.overwrite.length) {
|
|
121
|
+
console.log(` Will overwrite: ${plan.overwrite.length}`);
|
|
122
|
+
plan.overwrite.forEach((r) => console.log(` ~ docs/${r}`));
|
|
123
|
+
}
|
|
124
|
+
console.log("");
|
|
125
|
+
|
|
126
|
+
if (!apply) {
|
|
127
|
+
console.log("Dry run only — nothing was written.");
|
|
128
|
+
console.log("Re-run with --apply to publish (add --force to overwrite existing docs).");
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(`Promoted ${written.length} file(s) into ${liveDocsRoot}.`);
|
|
133
|
+
console.log('Next: run "sdtk-wiki atlas build" to index the docs into the knowledge graph.');
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = { runProjectPromote };
|
|
@@ -494,6 +494,9 @@ async function runProjectRefresh(args) {
|
|
|
494
494
|
docBaselineDir: config.docBaselineDir,
|
|
495
495
|
docBaselineDocsRoot: config.docBaselineDocsRoot,
|
|
496
496
|
docSynthesisStatePath: config.docSynthesisStatePath,
|
|
497
|
+
excludes: config.excludes,
|
|
498
|
+
stack: config.stack,
|
|
499
|
+
commands: config.commands,
|
|
497
500
|
json: !!flags.json,
|
|
498
501
|
argv: args,
|
|
499
502
|
};
|
package/src/lib/scope.js
CHANGED
|
@@ -56,15 +56,15 @@ function resolveSkillsDir(runtime, scope, projectPath) {
|
|
|
56
56
|
const MANAGED_CODEX_SKILLS = [
|
|
57
57
|
"sdtk-api-design-spec", "sdtk-api-doc", "sdtk-arch", "sdtk-ba",
|
|
58
58
|
"sdtk-design-layout", "sdtk-dev", "sdtk-dev-backend", "sdtk-dev-frontend",
|
|
59
|
-
"sdtk-
|
|
60
|
-
"sdtk-test-case-spec",
|
|
59
|
+
"sdtk-evolve", "sdtk-orchestrator", "sdtk-pm", "sdtk-qa",
|
|
60
|
+
"sdtk-screen-design-spec", "sdtk-test-case-spec",
|
|
61
61
|
];
|
|
62
62
|
|
|
63
63
|
const MANAGED_CLAUDE_SKILLS = [
|
|
64
64
|
"api-design-spec", "api-doc", "arch", "ba",
|
|
65
65
|
"design-layout", "dev", "dev-backend", "dev-frontend",
|
|
66
|
-
"
|
|
67
|
-
"test-case-spec",
|
|
66
|
+
"evolve", "orchestrator", "pm", "qa",
|
|
67
|
+
"screen-design-spec", "test-case-spec",
|
|
68
68
|
];
|
|
69
69
|
|
|
70
70
|
function managedSkillNames(runtime) {
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Deterministic, static project stack detection (free; no network, no AI).
|
|
5
|
+
*
|
|
6
|
+
* v1 is Laravel-first: it recognises PHP/Laravel projects with high confidence
|
|
7
|
+
* and makes a best-effort attempt at the JS frontend toolchain and database.
|
|
8
|
+
* Other ecosystems are recognised at lower confidence or left for v2.
|
|
9
|
+
*
|
|
10
|
+
* The result feeds two consumers:
|
|
11
|
+
* 1. sdtk init -> merge into sdtk-spec.config.json (human strings + detection block)
|
|
12
|
+
* 2. sdtk-spec project ingest -> passed into the premium pack context (PART E)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const path = require("path");
|
|
17
|
+
|
|
18
|
+
function readJsonSafe(filePath) {
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
21
|
+
} catch (_e) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function fileExists(p) {
|
|
27
|
+
try {
|
|
28
|
+
return fs.existsSync(p);
|
|
29
|
+
} catch (_e) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Strip composer/npm version range operators to a readable version string.
|
|
36
|
+
* "^11.9" -> "11.9", ">=8.2" -> "8.2", "~5.0" -> "5.0".
|
|
37
|
+
*/
|
|
38
|
+
function normalizeVersion(raw) {
|
|
39
|
+
if (typeof raw !== "string") return null;
|
|
40
|
+
const m = raw.match(/(\d+(?:\.\d+)*)/);
|
|
41
|
+
return m ? m[1] : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Detect the JS frontend framework from a merged dependency map.
|
|
46
|
+
* Returns { label, evidence[] } or null.
|
|
47
|
+
*/
|
|
48
|
+
function detectFrontend(deps) {
|
|
49
|
+
if (!deps || typeof deps !== "object") return null;
|
|
50
|
+
const checks = [
|
|
51
|
+
{ dep: "next", label: "Next.js" },
|
|
52
|
+
{ dep: "nuxt", label: "Nuxt" },
|
|
53
|
+
{ dep: "@angular/core", label: "Angular" },
|
|
54
|
+
{ dep: "react", label: "React" },
|
|
55
|
+
{ dep: "vue", label: "Vue" },
|
|
56
|
+
{ dep: "svelte", label: "Svelte" },
|
|
57
|
+
{ dep: "alpinejs", label: "Alpine.js" },
|
|
58
|
+
];
|
|
59
|
+
for (const c of checks) {
|
|
60
|
+
if (deps[c.dep]) {
|
|
61
|
+
const ver = normalizeVersion(deps[c.dep]);
|
|
62
|
+
return {
|
|
63
|
+
label: ver ? `${c.label} ${ver}` : c.label,
|
|
64
|
+
evidence: [`package.json:dependencies.${c.dep}`],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Detect database from Laravel .env (DB_CONNECTION). Best-effort, v1.
|
|
73
|
+
* Returns { label, evidence[] } or null.
|
|
74
|
+
*/
|
|
75
|
+
function detectDatabase(projectPath) {
|
|
76
|
+
const envPath = path.join(projectPath, ".env");
|
|
77
|
+
let content;
|
|
78
|
+
try {
|
|
79
|
+
content = fs.readFileSync(envPath, "utf8");
|
|
80
|
+
} catch (_e) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const m = content.match(/^\s*DB_CONNECTION\s*=\s*(.+)\s*$/m);
|
|
84
|
+
if (!m) return null;
|
|
85
|
+
const value = m[1].trim().replace(/^["']|["']$/g, "").toLowerCase();
|
|
86
|
+
const map = {
|
|
87
|
+
mysql: "MySQL",
|
|
88
|
+
mariadb: "MariaDB",
|
|
89
|
+
pgsql: "PostgreSQL",
|
|
90
|
+
postgres: "PostgreSQL",
|
|
91
|
+
sqlite: "SQLite",
|
|
92
|
+
sqlsrv: "SQL Server",
|
|
93
|
+
};
|
|
94
|
+
const label = map[value] || value;
|
|
95
|
+
return { label, evidence: [".env:DB_CONNECTION"] };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Detect the project stack from static signals under projectPath.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} projectPath - absolute path to the project root
|
|
102
|
+
* @returns {{
|
|
103
|
+
* stack: { backend: string|null, frontend: string|null, database: string|null },
|
|
104
|
+
* detection: {
|
|
105
|
+
* language: string|null, framework: string|null, frameworkVersion: string|null,
|
|
106
|
+
* packageManager: string|null, confidence: "low"|"medium"|"high",
|
|
107
|
+
* evidence: string[], detectedAt: string, method: "static"
|
|
108
|
+
* }
|
|
109
|
+
* }}
|
|
110
|
+
*/
|
|
111
|
+
function detectStack(projectPath) {
|
|
112
|
+
const evidence = [];
|
|
113
|
+
let language = null;
|
|
114
|
+
let framework = null;
|
|
115
|
+
let frameworkVersion = null;
|
|
116
|
+
let packageManager = null;
|
|
117
|
+
let backend = null;
|
|
118
|
+
let frontend = null;
|
|
119
|
+
let database = null;
|
|
120
|
+
let confidence = "low";
|
|
121
|
+
|
|
122
|
+
const composer = readJsonSafe(path.join(projectPath, "composer.json"));
|
|
123
|
+
const hasArtisan = fileExists(path.join(projectPath, "artisan"));
|
|
124
|
+
|
|
125
|
+
// --- PHP / Laravel (primary v1 target) ---------------------------------
|
|
126
|
+
if (composer) {
|
|
127
|
+
language = "php";
|
|
128
|
+
packageManager = "composer";
|
|
129
|
+
const req = Object.assign({}, composer.require, composer["require-dev"]);
|
|
130
|
+
const laravelVer = req["laravel/framework"];
|
|
131
|
+
const phpVer =
|
|
132
|
+
(composer.require && composer.require.php) ||
|
|
133
|
+
(composer.config &&
|
|
134
|
+
composer.config.platform &&
|
|
135
|
+
composer.config.platform.php);
|
|
136
|
+
|
|
137
|
+
if (laravelVer) {
|
|
138
|
+
framework = "laravel";
|
|
139
|
+
frameworkVersion = normalizeVersion(laravelVer);
|
|
140
|
+
confidence = "high";
|
|
141
|
+
evidence.push("composer.json:require.laravel/framework");
|
|
142
|
+
if (hasArtisan) evidence.push("artisan");
|
|
143
|
+
} else {
|
|
144
|
+
confidence = "medium";
|
|
145
|
+
evidence.push("composer.json");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const phpLabel = phpVer ? `PHP ${normalizeVersion(phpVer)}` : "PHP";
|
|
149
|
+
if (phpVer) evidence.push("composer.json:require.php");
|
|
150
|
+
backend =
|
|
151
|
+
framework === "laravel"
|
|
152
|
+
? `${phpLabel} + Laravel${frameworkVersion ? " " + frameworkVersion : ""}`
|
|
153
|
+
: `${phpLabel} (composer project)`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// --- JS toolchain / frontend ------------------------------------------
|
|
157
|
+
const pkg = readJsonSafe(path.join(projectPath, "package.json"));
|
|
158
|
+
if (pkg) {
|
|
159
|
+
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
|
|
160
|
+
const fe = detectFrontend(deps);
|
|
161
|
+
if (fe) {
|
|
162
|
+
frontend = fe.label;
|
|
163
|
+
evidence.push(...fe.evidence);
|
|
164
|
+
}
|
|
165
|
+
if (!packageManager) {
|
|
166
|
+
packageManager = fileExists(path.join(projectPath, "package-lock.json"))
|
|
167
|
+
? "npm"
|
|
168
|
+
: "node";
|
|
169
|
+
}
|
|
170
|
+
if (!language) language = "javascript";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Blade fallback when Laravel project has no JS framework
|
|
174
|
+
if (framework === "laravel" && !frontend) {
|
|
175
|
+
if (fileExists(path.join(projectPath, "resources", "views"))) {
|
|
176
|
+
frontend = "Blade (Laravel views)";
|
|
177
|
+
evidence.push("resources/views");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// --- Database ----------------------------------------------------------
|
|
182
|
+
const db = detectDatabase(projectPath);
|
|
183
|
+
if (db) {
|
|
184
|
+
database = db.label;
|
|
185
|
+
evidence.push(...db.evidence);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
stack: { backend, frontend, database },
|
|
190
|
+
detection: {
|
|
191
|
+
language,
|
|
192
|
+
framework,
|
|
193
|
+
frameworkVersion,
|
|
194
|
+
packageManager,
|
|
195
|
+
confidence,
|
|
196
|
+
evidence,
|
|
197
|
+
detectedAt: new Date().toISOString(),
|
|
198
|
+
method: "static",
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
// Config merge
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
const PLACEHOLDER_RE = /^(set your |update_me|n\/a$|tbd$)/i;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A stack string field is "replaceable" when empty or still a template
|
|
211
|
+
* placeholder. User-authored values are preserved.
|
|
212
|
+
*/
|
|
213
|
+
function isPlaceholder(value) {
|
|
214
|
+
if (value === null || value === undefined) return true;
|
|
215
|
+
if (typeof value !== "string") return false;
|
|
216
|
+
const t = value.trim();
|
|
217
|
+
if (t === "") return true;
|
|
218
|
+
return PLACEHOLDER_RE.test(t);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Merge a detection result into a parsed sdtk-spec.config.json object.
|
|
223
|
+
*
|
|
224
|
+
* - Human-readable stack strings (backend/frontend/database) are filled only
|
|
225
|
+
* when missing or placeholder (never clobber user edits).
|
|
226
|
+
* - The machine-readable stack.detection block is always (re)written.
|
|
227
|
+
*
|
|
228
|
+
* @returns {{ config: object, summary: { written: string[], preserved: string[], unknown: string[] } }}
|
|
229
|
+
*/
|
|
230
|
+
function mergeStackIntoConfig(config, detected) {
|
|
231
|
+
const next = config && typeof config === "object" ? config : {};
|
|
232
|
+
if (!next.stack || typeof next.stack !== "object") next.stack = {};
|
|
233
|
+
|
|
234
|
+
const summary = { written: [], preserved: [], unknown: [] };
|
|
235
|
+
const fields = ["backend", "frontend", "database"];
|
|
236
|
+
|
|
237
|
+
for (const field of fields) {
|
|
238
|
+
const detectedValue = detected.stack[field];
|
|
239
|
+
const currentValue = next.stack[field];
|
|
240
|
+
if (detectedValue) {
|
|
241
|
+
if (isPlaceholder(currentValue)) {
|
|
242
|
+
next.stack[field] = detectedValue;
|
|
243
|
+
summary.written.push(field);
|
|
244
|
+
} else {
|
|
245
|
+
summary.preserved.push(field);
|
|
246
|
+
}
|
|
247
|
+
} else if (isPlaceholder(currentValue)) {
|
|
248
|
+
summary.unknown.push(field);
|
|
249
|
+
} else {
|
|
250
|
+
summary.preserved.push(field);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
next.stack.detection = detected.detection;
|
|
255
|
+
return { config: next, summary };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Detect the stack and merge into sdtk-spec.config.json on disk.
|
|
260
|
+
* No-op-safe: if the config file is missing it is left untouched and the
|
|
261
|
+
* detection is still returned for callers that want to act on it.
|
|
262
|
+
*
|
|
263
|
+
* @param {string} projectPath
|
|
264
|
+
* @param {{ configPath?: string }} [opts]
|
|
265
|
+
* @returns {{ detected: object, summary: object|null, configPath: string, written: boolean }}
|
|
266
|
+
*/
|
|
267
|
+
function detectAndMergeConfig(projectPath, opts) {
|
|
268
|
+
const configPath =
|
|
269
|
+
(opts && opts.configPath) ||
|
|
270
|
+
path.join(projectPath, "sdtk-spec.config.json");
|
|
271
|
+
const detected = detectStack(projectPath);
|
|
272
|
+
|
|
273
|
+
const config = readJsonSafe(configPath);
|
|
274
|
+
if (config === null) {
|
|
275
|
+
return { detected, summary: null, configPath, written: false };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const { config: merged, summary } = mergeStackIntoConfig(config, detected);
|
|
279
|
+
fs.writeFileSync(configPath, JSON.stringify(merged, null, 2) + "\n", "utf8");
|
|
280
|
+
return { detected, summary, configPath, written: true };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
module.exports = {
|
|
284
|
+
detectStack,
|
|
285
|
+
mergeStackIntoConfig,
|
|
286
|
+
detectAndMergeConfig,
|
|
287
|
+
isPlaceholder,
|
|
288
|
+
normalizeVersion,
|
|
289
|
+
};
|