sdtk-code-kit 0.3.4 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@ For the full end-user guide, use:
17
17
  ## Public Package Truth
18
18
 
19
19
  - package: `sdtk-code-kit`
20
- - version in this source snapshot: `0.1.3`
20
+ - version in this source snapshot: `0.4.2`
21
21
  - command: `sdtk-code`
22
22
  - latest published version lookup: `npm view sdtk-code-kit version`
23
23
  - primary workflow-first surface:
@@ -194,6 +194,18 @@ Important boundary:
194
194
  - the review packet is an evidence package for downstream QA/controller review
195
195
  - it does not replace QA release authority and it is not a final approval artifact
196
196
 
197
+ ## Sleep Mode (free readiness gate + Pro unattended execution)
198
+
199
+ Free (dry-run, nothing is executed):
200
+ - `sdtk-code sleep plan --feature-key <KEY>` assembles a bounded plan from the CODE_HANDOFF. Declare the file scope the run may touch with `--allowed <glob>` / `--blocked <glob>` (repeatable) or `--scope-file <path>` (a JSON `{ "allowed_file_scopes": [...], "blocked_file_scopes": [...] }`).
201
+ - `sdtk-code sleep report --feature-key <KEY>` grades the plan `READY_TO_SLEEP` or `NOT_READY` with the blocker/warning list.
202
+
203
+ Pro (entitlement-gated, capability `code.sleep.execute`):
204
+ - `sdtk-code sleep authorize --feature-key <KEY>` is the attended consent step. It requires an active Pro entitlement, a `READY_TO_SLEEP` plan/report, a bounded declared scope, and an exact typed confirmation on an interactive TTY. It writes `.sdtk/trust/sleep-authorization.json`, cryptographically bound (sha256) to the exact sleep-plan bytes and pinned scope, with budget caps and a TTL (defaults: 3 iterations / $3.00 / 8h; per-authorization raisable up to 10 / $10.00 / 24h).
205
+ - `sdtk-code sleep execute --feature-key <KEY>` runs the bounded session headlessly against a valid, unexpired authorization — the actual "work while you are away" capability. It reuses the same stop conditions, budgets, and doc-class patch guards as the attended `agent-team sleep-execute` preview. Editing the plan, broadening the scope, or letting the authorization expire invalidates it and the run fails closed.
206
+
207
+ Boundaries: v1 authorizes doc-class patches only (`docs/**.md`, `governance/**.md`, `README.md`, `AGENTS.md`). The **CLI** exposes no unattended path without an active Pro entitlement and the installed `sleep-execute-pro` pack. The engine function itself ships in the public kit, so a caller who can already run arbitrary Node on the machine can invoke it directly — but any such call is still bounded by the same envelope every path enforces: doc-class patch guard, hard ceilings (10 iterations / $10.00 / 24h TTL), per-iteration readiness re-check, pinned scope, and worktree isolation with no auto-merge. Entitlement is a licensing/honesty boundary, not a defense against local code execution. Model/API cost is user-provided via your own provider key, not SDTK-hosted.
208
+
197
209
  ## References
198
210
 
199
211
  - Canonical end-user guide:
@@ -0,0 +1,9 @@
1
+ -----BEGIN PUBLIC KEY-----
2
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuxpjOnU2tGqY4jqQIWWQ
3
+ mMTStgAAri8UguT+okkLEOjPav+bnHU2brobXadkVvsiX5P0cSjvjKSCdxjD97uM
4
+ MCRhCzhSJ27cHkWdXzlREpI2xUaQK78Mmv712zuCzoQbNp4cKcDTxXFsaAdJd5S8
5
+ 0S88lPdiWFv6DI+tN1t0U7Lv3v3iIEtHdzRkYNxX958tHHuZWIrvJ6oQushZLngy
6
+ /WpD9L3/ZraAtf+eBcK4bVc5nvcdvoQx+OEygr0tfRJlFqRp/cHkz/MyHSu7yXWa
7
+ NtUD/zYb9jnN/DmG5O3kTD8iIQYzBErAzQ9bfMGm0J4QgTctxZLdDCy9zpBeNXva
8
+ QwIDAQAB
9
+ -----END PUBLIC KEY-----
@@ -1,12 +1,17 @@
1
1
  {
2
- "version": "0.3.4",
3
- "sourceCommit": "375b27555f8dfc0ac32a3f6479b7158c17ca03cc",
2
+ "version": "0.4.2",
3
+ "sourceCommit": "e872c6b7d09a3b2658e26a63d3ff6366e7430f82",
4
4
  "fileCount": 29,
5
5
  "files": [
6
6
  {
7
7
  "path": "toolkit/AGENTS.md",
8
- "sha256": "0871c6d46c64a093fc5f9d06af373db8143943cd27f144957dad0cc86893dc62",
9
- "size": 15069
8
+ "sha256": "5c76955ecabfae64759c11a3ee0fa777b1e0c0f78bdd177ae8f04340cd572e4b",
9
+ "size": 16469
10
+ },
11
+ {
12
+ "path": "toolkit/SDTKCODE_TOOLKIT.md",
13
+ "sha256": "9269a5afe88ce97885d054f5a78d496c1aafa50097f581d070e34dceb597c8fe",
14
+ "size": 6945
10
15
  },
11
16
  {
12
17
  "path": "toolkit/install.ps1",
@@ -35,34 +40,29 @@
35
40
  },
36
41
  {
37
42
  "path": "toolkit/sdtk-spec.config.json",
38
- "sha256": "ce760f639a09913b236be6dde6c692ea19ee92eb1d9e63d10dcdeb398e7ed2fb",
39
- "size": 1209
43
+ "sha256": "712382d838a18b6cc6a5285b3c536fac74138c752a3fa1fd318828b19ece6b8f",
44
+ "size": 1231
40
45
  },
41
46
  {
42
47
  "path": "toolkit/sdtk-spec.config.profiles.example.json",
43
- "sha256": "e04ea5e3f72510e569ab849ebef3dea4a8728c2996c485e997d3e13a6c4f1f86",
44
- "size": 1495
45
- },
46
- {
47
- "path": "toolkit/SDTKCODE_TOOLKIT.md",
48
- "sha256": "9269a5afe88ce97885d054f5a78d496c1aafa50097f581d070e34dceb597c8fe",
49
- "size": 6945
48
+ "sha256": "2a306c1609499fb4910b86d5ec6e8c796e0cdf72c5f97fe3df9c1388ac62b913",
49
+ "size": 2134
50
50
  },
51
51
  {
52
52
  "path": "toolkit/skills/code-brainstorm/SKILL.md",
53
53
  "sha256": "d797d707dc34d299dbac13f09f3bc8cc42759cb69a9fa5b2cb2269e4c246061e",
54
54
  "size": 2215
55
55
  },
56
- {
57
- "path": "toolkit/skills/code-debug/references/root-cause-tracing.md",
58
- "sha256": "698c89de9a0586e83ee52147adf345fa2ab813a06b454ca50e9c69e423f0a910",
59
- "size": 2206
60
- },
61
56
  {
62
57
  "path": "toolkit/skills/code-debug/SKILL.md",
63
58
  "sha256": "7e18869c8cd9ad1637bede13bc6449beec545eee115517a19d691817e5cda9cb",
64
59
  "size": 9988
65
60
  },
61
+ {
62
+ "path": "toolkit/skills/code-debug/references/root-cause-tracing.md",
63
+ "sha256": "698c89de9a0586e83ee52147adf345fa2ab813a06b454ca50e9c69e423f0a910",
64
+ "size": 2206
65
+ },
66
66
  {
67
67
  "path": "toolkit/skills/code-discover/SKILL.md",
68
68
  "sha256": "d871b5147e894b47fb5aeae43f5b677a3e61ecda94c74ff40a5a4c46092c3e6e",
@@ -78,6 +78,11 @@
78
78
  "sha256": "5e352fb1739cf0b9297f34e49ae01d8b0c0ed57448c3c8f3b286d12e1177a130",
79
79
  "size": 4260
80
80
  },
81
+ {
82
+ "path": "toolkit/skills/code-parallel/SKILL.md",
83
+ "sha256": "393edd1c3ef6ff936c5ec6e2e739d3c02f1e6370e5a72872f186b5d2971d37b7",
84
+ "size": 2691
85
+ },
81
86
  {
82
87
  "path": "toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md",
83
88
  "sha256": "5fec663aa52b7fd2b942f71a0755f0cd109d2273a5cd21c7c24eeed7684a4cc9",
@@ -93,16 +98,16 @@
93
98
  "sha256": "b22d3262f252f7cc994d13bfe16c7103f3afe1e66c255090d88e53fbd68a0f82",
94
99
  "size": 1993
95
100
  },
96
- {
97
- "path": "toolkit/skills/code-parallel/SKILL.md",
98
- "sha256": "393edd1c3ef6ff936c5ec6e2e739d3c02f1e6370e5a72872f186b5d2971d37b7",
99
- "size": 2691
100
- },
101
101
  {
102
102
  "path": "toolkit/skills/code-plan/SKILL.md",
103
103
  "sha256": "7fe115e27a83d04243401bb628ae4246a323246c972fd54890fe4a7e97926bbf",
104
104
  "size": 3391
105
105
  },
106
+ {
107
+ "path": "toolkit/skills/code-review/SKILL.md",
108
+ "sha256": "4d10ec40ae8ca87de03b2724b90c91053bf756c880a67d8f9a79aabd948f49b5",
109
+ "size": 2723
110
+ },
106
111
  {
107
112
  "path": "toolkit/skills/code-review/references/checklist.md",
108
113
  "sha256": "4612b4e40992f594b577146ac14f1ff13c1812e8e9da64b07eb1e2de5363af5d",
@@ -113,26 +118,21 @@
113
118
  "sha256": "7f5328dca12cb200005ae9d4386f63a9b0acb735ece57f82db206b4a3189ccae",
114
119
  "size": 3385
115
120
  },
116
- {
117
- "path": "toolkit/skills/code-review/SKILL.md",
118
- "sha256": "4d10ec40ae8ca87de03b2724b90c91053bf756c880a67d8f9a79aabd948f49b5",
119
- "size": 2723
120
- },
121
121
  {
122
122
  "path": "toolkit/skills/code-ship/SKILL.md",
123
123
  "sha256": "c8dbbae4f8ed65b00e38a386cb9adba340c90dc7fd0dd8257f3c1fea37322558",
124
124
  "size": 2123
125
125
  },
126
- {
127
- "path": "toolkit/skills/code-tdd/references/testing-anti-patterns.md",
128
- "sha256": "a85c93883197eef41f5392875b41a19b8cdeb3b14b3c6fb5a6dbfb6f21a1b825",
129
- "size": 8194
130
- },
131
126
  {
132
127
  "path": "toolkit/skills/code-tdd/SKILL.md",
133
128
  "sha256": "967ec7e8a0a7951e3423c4e0f92c7471912e3a03ea23dc572c392e5a37edc266",
134
129
  "size": 10326
135
130
  },
131
+ {
132
+ "path": "toolkit/skills/code-tdd/references/testing-anti-patterns.md",
133
+ "sha256": "a85c93883197eef41f5392875b41a19b8cdeb3b14b3c6fb5a6dbfb6f21a1b825",
134
+ "size": 8194
135
+ },
136
136
  {
137
137
  "path": "toolkit/skills/code-verify/SKILL.md",
138
138
  "sha256": "6df69cf2db69d13672b3e73a2c25aca48791e9ea912c1e1fbc3ce7734399c346",
@@ -1,29 +1,29 @@
1
- 0871c6d46c64a093fc5f9d06af373db8143943cd27f144957dad0cc86893dc62 toolkit/AGENTS.md
1
+ 5c76955ecabfae64759c11a3ee0fa777b1e0c0f78bdd177ae8f04340cd572e4b toolkit/AGENTS.md
2
+ 9269a5afe88ce97885d054f5a78d496c1aafa50097f581d070e34dceb597c8fe toolkit/SDTKCODE_TOOLKIT.md
2
3
  dd7ffbd69c29f76d67f65c3e857ba241e92908931b2e93a9b9c503542e43f35c toolkit/install.ps1
3
4
  720990cc979cdbca776bbe21eaeee0a73c5dd698ac6c8df430c7f22826ec9219 toolkit/scripts/install-claude-skills.ps1
4
5
  7d61249db7eee6185e5454f7427b808c79d5e564e0d2214ee5f92fa105effb04 toolkit/scripts/install-codex-skills.ps1
5
6
  148ddfc5a79a9dd6d7fa5b926c5511a5e4d458fa31003217cdc2eefcbe966cc2 toolkit/scripts/uninstall-claude-skills.ps1
6
7
  0fd11650bd445fad37c728471872b99bfb8bd17dfb95e62431ceccfad7f0852f toolkit/scripts/uninstall-codex-skills.ps1
7
- ce760f639a09913b236be6dde6c692ea19ee92eb1d9e63d10dcdeb398e7ed2fb toolkit/sdtk-spec.config.json
8
- e04ea5e3f72510e569ab849ebef3dea4a8728c2996c485e997d3e13a6c4f1f86 toolkit/sdtk-spec.config.profiles.example.json
9
- 9269a5afe88ce97885d054f5a78d496c1aafa50097f581d070e34dceb597c8fe toolkit/SDTKCODE_TOOLKIT.md
8
+ 712382d838a18b6cc6a5285b3c536fac74138c752a3fa1fd318828b19ece6b8f toolkit/sdtk-spec.config.json
9
+ 2a306c1609499fb4910b86d5ec6e8c796e0cdf72c5f97fe3df9c1388ac62b913 toolkit/sdtk-spec.config.profiles.example.json
10
10
  d797d707dc34d299dbac13f09f3bc8cc42759cb69a9fa5b2cb2269e4c246061e toolkit/skills/code-brainstorm/SKILL.md
11
- 698c89de9a0586e83ee52147adf345fa2ab813a06b454ca50e9c69e423f0a910 toolkit/skills/code-debug/references/root-cause-tracing.md
12
11
  7e18869c8cd9ad1637bede13bc6449beec545eee115517a19d691817e5cda9cb toolkit/skills/code-debug/SKILL.md
12
+ 698c89de9a0586e83ee52147adf345fa2ab813a06b454ca50e9c69e423f0a910 toolkit/skills/code-debug/references/root-cause-tracing.md
13
13
  d871b5147e894b47fb5aeae43f5b677a3e61ecda94c74ff40a5a4c46092c3e6e toolkit/skills/code-discover/SKILL.md
14
14
  8627a8c33cd170cc8009feb2b6ab7bf2bc4be91daa3609dc331a554ba41b1b3d toolkit/skills/code-execute/SKILL.md
15
15
  5e352fb1739cf0b9297f34e49ae01d8b0c0ed57448c3c8f3b286d12e1177a130 toolkit/skills/code-finish/SKILL.md
16
+ 393edd1c3ef6ff936c5ec6e2e739d3c02f1e6370e5a72872f186b5d2971d37b7 toolkit/skills/code-parallel/SKILL.md
16
17
  5fec663aa52b7fd2b942f71a0755f0cd109d2273a5cd21c7c24eeed7684a4cc9 toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md
17
18
  10bc07e6498e6a1e54805cce4d964545f2c1614e6679b0c1c4eb7d17b894e3a6 toolkit/skills/code-parallel/references/implementer-prompt.md
18
19
  b22d3262f252f7cc994d13bfe16c7103f3afe1e66c255090d88e53fbd68a0f82 toolkit/skills/code-parallel/references/spec-reviewer-prompt.md
19
- 393edd1c3ef6ff936c5ec6e2e739d3c02f1e6370e5a72872f186b5d2971d37b7 toolkit/skills/code-parallel/SKILL.md
20
20
  7fe115e27a83d04243401bb628ae4246a323246c972fd54890fe4a7e97926bbf toolkit/skills/code-plan/SKILL.md
21
+ 4d10ec40ae8ca87de03b2724b90c91053bf756c880a67d8f9a79aabd948f49b5 toolkit/skills/code-review/SKILL.md
21
22
  4612b4e40992f594b577146ac14f1ff13c1812e8e9da64b07eb1e2de5363af5d toolkit/skills/code-review/references/checklist.md
22
23
  7f5328dca12cb200005ae9d4386f63a9b0acb735ece57f82db206b4a3189ccae toolkit/skills/code-review/references/code-reviewer.md
23
- 4d10ec40ae8ca87de03b2724b90c91053bf756c880a67d8f9a79aabd948f49b5 toolkit/skills/code-review/SKILL.md
24
24
  c8dbbae4f8ed65b00e38a386cb9adba340c90dc7fd0dd8257f3c1fea37322558 toolkit/skills/code-ship/SKILL.md
25
- a85c93883197eef41f5392875b41a19b8cdeb3b14b3c6fb5a6dbfb6f21a1b825 toolkit/skills/code-tdd/references/testing-anti-patterns.md
26
25
  967ec7e8a0a7951e3423c4e0f92c7471912e3a03ea23dc572c392e5a37edc266 toolkit/skills/code-tdd/SKILL.md
26
+ a85c93883197eef41f5392875b41a19b8cdeb3b14b3c6fb5a6dbfb6f21a1b825 toolkit/skills/code-tdd/references/testing-anti-patterns.md
27
27
  6df69cf2db69d13672b3e73a2c25aca48791e9ea912c1e1fbc3ce7734399c346 toolkit/skills/code-verify/SKILL.md
28
28
  194cf6ec70eae013c03d06f397d4bbaca73256ad69be681ad14812493a3d1962 toolkit/skills/code-worktree/SKILL.md
29
29
  7b3e27b56153160b44b5813e63ee8f762ee6f4338157480934ec4860f4914884 toolkit/templates/CODE_WORKFLOW_TEMPLATE.md
@@ -1,5 +1,10 @@
1
1
  # SDTK Orchestrator Routing Contract
2
2
 
3
+ Version: 2.0
4
+ Last Updated: 2026-07-14
5
+
6
+ This file is the single source of the SDTK routing contract. `CLAUDE.md` and `CODEX.md` are thin runtime adapters that defer to it; when they appear to disagree with this file, this file wins.
7
+
3
8
  Goal: use the SDTK Suite as a coordinated operating model:
4
9
  - `SDTK-SPEC` governs upstream discovery, planning, design, traceability, and release gates.
5
10
  - `SDTK-CODE` is the default downstream system for implementation, bug fixing, refactoring, verification, and ship-ready code changes.
@@ -19,16 +24,21 @@ Orchestrator Intake is the always-winning front door for every unprefixed reques
19
24
  - Read stack and command configuration from `sdtk-spec.config.json` in the project root.
20
25
  - For VI/JP source requirements, keep original text in an appendix and add literal English translation for traceability.
21
26
  - `/dev` stops at `FEATURE_IMPL_PLAN + CODE_HANDOFF`; SDTK-CODE is the default downstream coding system.
22
- - Verification-before-completion: no phase may declare done, pass, or handoff-ready without fresh command evidence per `governance/ai/core/SDTK_VERIFICATION_BEFORE_COMPLETION_POLICY.md`.
27
+ - Verification-before-completion: no phase may declare done, pass, or handoff-ready without fresh command evidence — run the relevant verification commands in this session and quote their real output in the phase artifact; assumed, remembered, or stale results do not count.
23
28
  - `toolkit/skills/skills.catalog.yaml` is the inventory source of truth for the 14 core SDTK-SPEC skills, including the bounded `mailbox-dispatch` controller skill.
24
29
 
25
30
  ## 2) Session Bootstrap Protocol
26
31
  When starting a new session, read context in this order when the files exist:
27
32
  1. `AGENTS.md`
28
- 2. `governance/ai/session/SDTK_ACTIVE_BOOTSTRAP.md`
29
- 3. `governance/ai/session/SDTK_AGENT_WORKING_RULES.md`
30
- 4. `governance/ai/core/IMPROVEMENT_BACKLOG.md`
31
- 5. issue-specific controller spec and implementation plan
33
+ 2. `.sdtk/evolve/LEARNED.md` — locally learned, owner-approved lessons (managed by the evolve skill + `sdtk evolve`; never edit it directly)
34
+ 3. `governance/ai/session/SDTK_ACTIVE_BOOTSTRAP.md`
35
+ 4. `governance/ai/session/SDTK_AGENT_WORKING_RULES.md`
36
+ 5. `governance/ai/core/IMPROVEMENT_BACKLOG.md`
37
+ 6. issue-specific controller spec and implementation plan
38
+
39
+ Orientation and health:
40
+ - If `.sdtk/wiki/` exists, it is the project's committed memory layer: orient with `sdtk-wiki search "<topic>"` (entry points: `.sdtk/wiki/pages/_index.md`, the atlas summary) before falling back to repo-wide searching.
41
+ - If any `sdtk-*` CLI behaves unexpectedly (missing verbs, stale help, wrong version), run `sdtk doctor` to detect version fragmentation before debugging further.
32
42
 
33
43
  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
44
 
@@ -60,9 +70,11 @@ Use this compact matrix during intake so the agent picks the smallest sufficient
60
70
  | Formal feature delivery | `SDTK-SPEC` pipeline | PM -> BA -> ARCH -> DEV planning -> CODE handoff -> QA |
61
71
  | Build, fix, or refactor implementation | `SDTK-CODE` | code-brainstorm (when slice is ambiguous) -> start -> plan -> build -> verify -> ship |
62
72
  | Debug failure or unexpected behavior | `SDTK-CODE` debug | Root cause, bounded fix, regression verification |
73
+ | Screen/layout design, visual tokens, or prototype evidence before coding | `SDTK-DESIGN` | Reviewable screens/prototype plus a design handoff into SDTK-CODE |
63
74
  | Deployment, release, infra, or CI/CD work | `SDTK-OPS` | ops-plan -> ops-deploy/ops-incident/ops-monitor -> ops-verify |
64
75
  | Code review or spec review | Review / QA workflow | Findings, risks, blockers, acceptance signal |
65
76
  | 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 |
77
+ | Question about existing project knowledge or docs | `sdtk-wiki search` (free) or `sdtk-wiki ask` when available | Grounded answer citing project pages before any repo-wide scan |
66
78
  | SDTK-WIKI Ask | `sdtk-wiki ask` | Grounded answer when `.sdtk/wiki/graph` plus `wiki.ask` entitlement/runtime preconditions are present, otherwise explicit blocker |
67
79
  | 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
80
  | 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` |
@@ -165,7 +177,7 @@ Cross-cutting capabilities (not a linear lane; usable across every phase):
165
177
  - surface: `sdtk-agent run start|continue|status|report`, `gate approve|reject`, `workflow validate`, `adapter hermes-kanban plan`
166
178
  - 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
179
  - 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)
180
+ - the CLI is runtime-neutral and installs no skills; the engine is Free; the hermes-kanban adapter defaults to dry-run and live dispatch stays fail-closed behind explicit configuration plus per-run confirmation
169
181
 
170
182
  If the current project only has `SDTK-SPEC` runtime assets installed:
171
183
  - keep `/dev` bounded to planning and `CODE_HANDOFF`
@@ -186,7 +198,7 @@ If the current project only has `SDTK-SPEC` runtime assets installed:
186
198
  - For Codex runtimes: project-local skills require the explicit local `CODEX_HOME=<project>/.codex` contract; native `.codex/skills` auto-discovery is not claimed.
187
199
  - 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
200
  - `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.
201
+ - The `sdtk-agent` hermes-kanban adapter defaults to dry-run. Live dispatch exists but is fail-closed behind explicit adapter configuration (`mode: live` plus `live_ack`) and a per-run `--confirm`, and it remains an attended, validation-gated capability. Never claim, enable, or attempt live dispatch on the user's behalf.
190
202
 
191
203
  ## 11) Discovery And PM Readiness
192
204
  - PM initiation starts only after `docs/discovery/REQUIREMENT_[FEATURE_KEY].md` is marked `READY_FOR_PM_INITIATION`.
@@ -1,7 +1,8 @@
1
1
  {
2
+ "schemaVersion": 1,
2
3
  "docs": {
3
4
  "artifactsLanguage": "EN",
4
- "guidanceLanguage": "VI",
5
+ "guidanceLanguage": "EN",
5
6
  "preserveOriginalInput": true,
6
7
  "appendixIncludeEnglishTranslation": true,
7
8
  "aiPeerReviewAllowed": true
@@ -1,5 +1,26 @@
1
1
  {
2
2
  "profiles": {
3
+ "php-laravel": {
4
+ "orchestration": {
5
+ "apiDesignDetailMode": "auto",
6
+ "testCaseSpecMode": "auto"
7
+ },
8
+ "stack": {
9
+ "backend": "PHP 8.3 + Laravel 11",
10
+ "frontend": "Blade + Vite (or Livewire)",
11
+ "mobile": "N/A",
12
+ "database": "MySQL 8",
13
+ "auth": "Laravel Sanctum"
14
+ },
15
+ "commands": {
16
+ "backendTests": "php artisan test",
17
+ "backendTypecheck": "vendor/bin/phpstan analyse",
18
+ "backendLint": "vendor/bin/pint --test",
19
+ "frontendTests": "npm run test",
20
+ "frontendLint": "npm run lint",
21
+ "e2eTests": "npm run e2e"
22
+ }
23
+ },
3
24
  "django-react": {
4
25
  "orchestration": {
5
26
  "apiDesignDetailMode": "auto",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdtk-code-kit",
3
- "version": "0.3.4",
3
+ "version": "0.4.2",
4
4
  "description": "Workflow-first coding process toolkit: start, plan, build, verify, ship, and runtime setup.",
5
5
  "bin": {
6
6
  "sdtk-code": "bin/sdtk-code.js"
@@ -20,6 +20,7 @@ function cmdHelp() {
20
20
  " init Initialize SDTK-CODE workspace",
21
21
  " runtime Manage runtime asset installation (install, uninstall, status)",
22
22
  " agent-team Plan/preview/export/evidence plus bounded docs/governance Markdown execute/author/sleep-execute",
23
+ " sleep Sleep Mode: plan/report readiness dry-run (free) + authorize/execute (Pro, entitlement-gated)",
23
24
  "",
24
25
  "Workflow status:",
25
26
  " Implemented now: start, plan, build, verify, ship, status, doctor, resume",
@@ -176,6 +177,15 @@ function cmdHelp() {
176
177
  " implementation correctness. Human review required before acting on this verdict.",
177
178
  " run is not available in this phase; execute never spawns LLM agents and never auto-merges.",
178
179
  " No .codex/agents or .claude files are written.",
180
+ "",
181
+ "Sleep Mode:",
182
+ " sdtk-code sleep plan --feature-key <KEY> [--allowed <glob>]... [--blocked <glob>]... [--scope-file <path>] [--max-actions <n>] [--max-iterations <n>] [--project-path <path>]",
183
+ " sdtk-code sleep report --feature-key <KEY> [--project-path <path>]",
184
+ " sdtk-code sleep authorize --feature-key <KEY> [--max-iterations <n>] [--max-cost-usd <x>] [--ttl-hours <h>] [--project-path <path>]",
185
+ " sdtk-code sleep execute --feature-key <KEY> [--session-id <id>] [--project-path <path>]",
186
+ " plan/report are the free dry-run readiness gate; nothing is executed by them.",
187
+ " authorize is the attended Pro step: an exact typed TTY confirmation writes a sha256-bound, TTL-limited sleep-authorization artifact (doc-class patches only in v1).",
188
+ " execute is Pro and entitlement-gated (capability code.sleep.execute): it runs the bounded Phase E session headlessly, ONLY against a valid unexpired authorization, inside the same stop conditions, budgets, and patch guards; editing the plan or scope after authorize invalidates the artifact.",
179
189
  "",
180
190
  "Runtime options:",
181
191
  " --runtime <codex|claude> Target runtime (required)",
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
+ const fs = require("fs");
3
4
  const path = require("path");
5
+ const readline = require("readline");
4
6
  const { parseFlags, requireFlag } = require("../lib/args");
5
7
  const { ValidationError } = require("../lib/errors");
6
8
  const { assembleSleepPlan, writeSleepPlan } = require("../lib/sleep-plan");
@@ -11,6 +13,15 @@ const {
11
13
  renderSleepReportMarkdown,
12
14
  writeSleepReport,
13
15
  } = require("../lib/sleep-report");
16
+ const { createSleepAuthorization, authorizationPath } = require("../lib/sleep-authorization");
17
+ const {
18
+ checkSleepExecuteCapability,
19
+ loadSleepExecuteHandler,
20
+ SLEEP_EXECUTE_CAPABILITY,
21
+ } = require("../lib/code-premium-loader");
22
+ const { executeSleepSession } = require("../lib/agent-team-sleep-execute");
23
+ const { loadExecuteContext } = require("../lib/agent-team-execute");
24
+ const { pinScope } = require("../lib/agent-team-sleep-session");
14
25
  const { appendEvent } = require("../lib/trust-events");
15
26
 
16
27
  const FLAG_DEFS = {
@@ -18,8 +29,74 @@ const FLAG_DEFS = {
18
29
  "project-path": { type: "string" },
19
30
  "max-actions": { type: "string" },
20
31
  "max-iterations": { type: "string" },
32
+ // BK-340 W1: declare file scopes at plan time from the CLI (previously the
33
+ // only path was hand-editing optional CODE_HANDOFF JSON fields).
34
+ "allowed": { type: "string", multiple: true },
35
+ "blocked": { type: "string", multiple: true },
36
+ "scope-file": { type: "string" },
21
37
  };
22
38
 
39
+ const AUTHORIZE_FLAG_DEFS = {
40
+ "feature-key": { type: "string" },
41
+ "project-path": { type: "string" },
42
+ "max-iterations": { type: "string" },
43
+ "max-cost-usd": { type: "string" },
44
+ "ttl-hours": { type: "string" },
45
+ };
46
+
47
+ const EXECUTE_FLAG_DEFS = {
48
+ "feature-key": { type: "string" },
49
+ "project-path": { type: "string" },
50
+ "session-id": { type: "string" },
51
+ };
52
+
53
+ function readLineFromStdin(promptText) {
54
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
55
+ return new Promise((resolve) => {
56
+ rl.question(promptText, (answer) => {
57
+ rl.close();
58
+ resolve(answer);
59
+ });
60
+ });
61
+ }
62
+
63
+ // BK-340 W1: read declared scopes from --allowed/--blocked flags or a JSON
64
+ // --scope-file ({"allowed_file_scopes": [...], "blocked_file_scopes": [...]}).
65
+ // Returns undefined when neither is used so assembleSleepPlan falls back to
66
+ // the CODE_HANDOFF-declared scopes exactly as before.
67
+ function resolveScopeFlags(flags) {
68
+ const inlineAllowed = Array.isArray(flags.allowed) ? flags.allowed : [];
69
+ const inlineBlocked = Array.isArray(flags.blocked) ? flags.blocked : [];
70
+ const hasInline = inlineAllowed.length > 0 || inlineBlocked.length > 0;
71
+ const scopeFile = flags["scope-file"];
72
+
73
+ if (scopeFile && hasInline) {
74
+ throw new ValidationError(
75
+ "Use either --scope-file or inline --allowed/--blocked flags, not both."
76
+ );
77
+ }
78
+ if (scopeFile) {
79
+ let parsed;
80
+ try {
81
+ parsed = JSON.parse(fs.readFileSync(path.resolve(scopeFile), "utf8"));
82
+ } catch (err) {
83
+ throw new ValidationError(`--scope-file could not be read as JSON: ${err.message}`);
84
+ }
85
+ const allowed = Array.isArray(parsed.allowed_file_scopes) ? parsed.allowed_file_scopes : [];
86
+ const blocked = Array.isArray(parsed.blocked_file_scopes) ? parsed.blocked_file_scopes : [];
87
+ if (allowed.length === 0 && blocked.length === 0) {
88
+ throw new ValidationError(
89
+ "--scope-file must declare allowed_file_scopes and/or blocked_file_scopes arrays."
90
+ );
91
+ }
92
+ return { allowed, blocked };
93
+ }
94
+ if (hasInline) {
95
+ return { allowed: inlineAllowed, blocked: inlineBlocked };
96
+ }
97
+ return undefined;
98
+ }
99
+
23
100
  function cmdSleepPlan(args) {
24
101
  const { flags, positional } = parseFlags(args, FLAG_DEFS);
25
102
  if (positional.length > 0) {
@@ -40,6 +117,10 @@ function cmdSleepPlan(args) {
40
117
  if (flags["max-iterations"] !== undefined) {
41
118
  opts.maxIterations = flags["max-iterations"];
42
119
  }
120
+ const scopes = resolveScopeFlags(flags);
121
+ if (scopes !== undefined) {
122
+ opts.scopes = scopes;
123
+ }
43
124
 
44
125
  const plan = assembleSleepPlan(projectPath, featureKey, opts);
45
126
  const outPath = writeSleepPlan(projectPath, plan);
@@ -108,10 +189,140 @@ function cmdSleepReport(args) {
108
189
  return 0;
109
190
  }
110
191
 
192
+ // BK-340 — attended authorization step. Requires an active Pro entitlement
193
+ // (checked up front for honest UX), a READY_TO_SLEEP plan/report, a pinned
194
+ // bounded agent-team scope, and an exact typed TTY confirmation. Writes the
195
+ // sha256-bound, TTL'd sleep-authorization artifact that `sleep execute`
196
+ // (the Pro pack) validates headlessly.
197
+ async function cmdSleepAuthorize(args) {
198
+ const { flags, positional } = parseFlags(args, AUTHORIZE_FLAG_DEFS);
199
+ if (positional.length > 0) {
200
+ throw new ValidationError(
201
+ 'Unexpected positional arguments. Use flags only for "sleep authorize".'
202
+ );
203
+ }
204
+
205
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
206
+ const projectPath = flags["project-path"]
207
+ ? path.resolve(flags["project-path"])
208
+ : process.cwd();
209
+
210
+ const capabilityCheck = checkSleepExecuteCapability();
211
+ if (!capabilityCheck.ok) {
212
+ throw new ValidationError(capabilityCheck.message);
213
+ }
214
+
215
+ const { outPath, authorization } = await createSleepAuthorization(projectPath, featureKey, {
216
+ maxIterations: flags["max-iterations"],
217
+ maxCostUsd: flags["max-cost-usd"],
218
+ ttlHours: flags["ttl-hours"],
219
+ confirmInput: {
220
+ isTTY: process.stdin.isTTY === true,
221
+ readLine: readLineFromStdin,
222
+ },
223
+ });
224
+
225
+ appendEvent(projectPath, {
226
+ toolkit: "sdtk-code",
227
+ event_type: "sleep_authorize",
228
+ command: `sdtk-code sleep authorize --feature-key ${featureKey}`,
229
+ status: "ok",
230
+ feature_key: featureKey,
231
+ output_path: outPath,
232
+ expires_at: authorization.expires_at,
233
+ max_iterations: authorization.budgets.max_iterations,
234
+ max_cost_usd: authorization.budgets.max_cost_usd,
235
+ patch_class: authorization.patch_class,
236
+ });
237
+
238
+ console.log(`sleep-authorization written: ${outPath}`);
239
+ console.log(` feature_key: ${authorization.feature_key}`);
240
+ console.log(` expires_at: ${authorization.expires_at}`);
241
+ console.log(` max_iterations: ${authorization.budgets.max_iterations}`);
242
+ console.log(` max_cost_usd: $${authorization.budgets.max_cost_usd.toFixed(2)}`);
243
+ console.log(` patch_class: ${authorization.patch_class}`);
244
+ console.log(` plan_sha256: ${authorization.plan_sha256}`);
245
+ console.log("Next: sdtk-code sleep execute --feature-key " + featureKey);
246
+ return 0;
247
+ }
248
+
249
+ // BK-340 — Pro headless execution. The premium loader is the ONLY path to a
250
+ // non-TTY sleep session: it verifies the signed entitlement + pack integrity,
251
+ // and the pack validates the authorization artifact (expiry, plan/scope
252
+ // sha256 binding, budget ceilings) before driving the unchanged Phase E
253
+ // engine with a pre-authorized confirm strategy.
254
+ async function cmdSleepExecute(args) {
255
+ const { flags, positional } = parseFlags(args, EXECUTE_FLAG_DEFS);
256
+ if (positional.length > 0) {
257
+ throw new ValidationError(
258
+ 'Unexpected positional arguments. Use flags only for "sleep execute".'
259
+ );
260
+ }
261
+
262
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
263
+ const projectPath = flags["project-path"]
264
+ ? path.resolve(flags["project-path"])
265
+ : process.cwd();
266
+
267
+ const loaded = await loadSleepExecuteHandler();
268
+ if (!loaded.ok) {
269
+ appendEvent(projectPath, {
270
+ toolkit: "sdtk-code",
271
+ event_type: "sleep_execute",
272
+ command: `sdtk-code sleep execute --feature-key ${featureKey}`,
273
+ status: "blocked",
274
+ feature_key: featureKey,
275
+ capability: SLEEP_EXECUTE_CAPABILITY,
276
+ reason: loaded.message,
277
+ });
278
+ console.error(loaded.message);
279
+ return loaded.exitCode;
280
+ }
281
+
282
+ const result = await loaded.handler({
283
+ projectPath,
284
+ featureKey,
285
+ options: {
286
+ sessionId: flags["session-id"],
287
+ },
288
+ deps: {
289
+ executeSleepSession,
290
+ loadExecuteContext,
291
+ pinScope,
292
+ authorizationPath,
293
+ },
294
+ });
295
+
296
+ appendEvent(projectPath, {
297
+ toolkit: "sdtk-code",
298
+ event_type: "sleep_execute",
299
+ command: `sdtk-code sleep execute --feature-key ${featureKey}`,
300
+ status: result.status,
301
+ feature_key: result.feature_key,
302
+ run_id: result.run_id,
303
+ session_id: result.session_id,
304
+ readiness_verdict: result.readiness_verdict,
305
+ stop_condition_hit: result.stop_condition_hit,
306
+ worktree_path: result.worktree_path,
307
+ actions_executed: result.actions_executed,
308
+ execution_mode: result.execution_mode,
309
+ authorization_expires_at: result.authorization_expires_at,
310
+ session_cost_usd: result.session_cost_usd,
311
+ session_output_tokens: result.session_output_tokens,
312
+ });
313
+
314
+ console.log(result.stdout || `Sleep Execute: ${result.status}`);
315
+ return result.exitCode === undefined ? 0 : result.exitCode;
316
+ }
317
+
111
318
  function cmdSleep(args) {
112
319
  if (!args || args.length === 0) {
113
320
  throw new ValidationError(
114
- 'Usage: sdtk-code sleep <subcommand> [flags]\nSubcommands: plan, report'
321
+ 'Usage: sdtk-code sleep <subcommand> [flags]\nSubcommands: plan, report, authorize, execute\n' +
322
+ ' plan Assemble the dry-run sleep plan (free). Declare scope with --allowed/--blocked or --scope-file.\n' +
323
+ ' report Grade READY_TO_SLEEP / NOT_READY (free, dry-run preflight).\n' +
324
+ ' authorize Attended Pro step: typed TTY confirmation writes a sha256-bound, TTL-limited authorization artifact.\n' +
325
+ ' execute Pro, entitlement-gated: run the bounded sleep session headlessly against a valid authorization.'
115
326
  );
116
327
  }
117
328
 
@@ -122,9 +333,13 @@ function cmdSleep(args) {
122
333
  return cmdSleepPlan(rest);
123
334
  case "report":
124
335
  return cmdSleepReport(rest);
336
+ case "authorize":
337
+ return cmdSleepAuthorize(rest);
338
+ case "execute":
339
+ return cmdSleepExecute(rest);
125
340
  default:
126
341
  throw new ValidationError(
127
- `Unknown sleep subcommand: "${subcommand}". Available: plan, report`
342
+ `Unknown sleep subcommand: "${subcommand}". Available: plan, report, authorize, execute`
128
343
  );
129
344
  }
130
345
  }
@@ -290,13 +290,28 @@ async function executeSleepSession(projectPath, featureKey, opts) {
290
290
  const { plan: sleepPlan } = loadSleepPlan(ctx.projectPath, ctx.featureKey);
291
291
  const sessionId = options.sessionId ? safeSegment(options.sessionId, "session_id") : `${ctx.runId}_sleep`;
292
292
  const pinnedScope = pinScope(ctx);
293
+ // BK-340: custom budgets are only reachable through an authorization-backed
294
+ // confirm strategy (the Pro pack). The free TTY phrase pins the 3/$3.00
295
+ // defaults and must never silently understate a larger authorized budget.
296
+ if (options.budgets !== undefined && typeof options.confirmStrategy !== "function") {
297
+ throw new ValidationError("FAIL_BUDGET_REQUIRES_AUTHORIZATION: custom session budgets require an authorization-backed confirm strategy.");
298
+ }
293
299
  const session = createSleepSession({
294
300
  featureKey: ctx.featureKey,
295
301
  sessionId,
296
302
  pinnedScope,
297
303
  nowMs: options.nowMs,
304
+ budgets: options.budgets,
298
305
  });
299
- await confirmSleepExecute(options.confirmInput || {}, ctx.featureKey, session.session_id);
306
+ // BK-340 seam: an injected confirm strategy (supplied only by the Pro
307
+ // sleep-execute pack after validating a pre-declared attended authorization
308
+ // artifact) replaces the interactive TTY confirmation. Default behavior —
309
+ // the Phase E attended TTY phrase — is unchanged when no strategy is given.
310
+ if (typeof options.confirmStrategy === "function") {
311
+ await options.confirmStrategy({ featureKey: ctx.featureKey, sessionId: session.session_id });
312
+ } else {
313
+ await confirmSleepExecute(options.confirmInput || {}, ctx.featureKey, session.session_id);
314
+ }
300
315
 
301
316
  return withSessionLease(session.session_id, async () => {
302
317
  let created = null;