sdtk-code-kit 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +17 -0
  2. package/assets/manifest/toolkit-bundle.manifest.json +147 -147
  3. package/assets/manifest/toolkit-bundle.sha256.txt +10 -10
  4. package/assets/toolkit/toolkit/AGENTS.md +219 -219
  5. package/assets/toolkit/toolkit/install.ps1 +156 -156
  6. package/assets/toolkit/toolkit/sdtk-spec.config.json +6 -6
  7. package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +295 -295
  8. package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +54 -54
  9. package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +377 -377
  10. package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +215 -215
  11. package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +28 -0
  12. package/package.json +44 -44
  13. package/src/commands/doctor.js +52 -0
  14. package/src/commands/guardrails.js +215 -0
  15. package/src/commands/help.js +244 -220
  16. package/src/commands/init.js +98 -98
  17. package/src/commands/readiness.js +77 -0
  18. package/src/commands/resume.js +62 -0
  19. package/src/commands/sleep.js +132 -0
  20. package/src/commands/status.js +78 -0
  21. package/src/commands/update.js +11 -11
  22. package/src/commands/verify.js +5 -0
  23. package/src/index.js +108 -73
  24. package/src/lib/project-target-guard.js +53 -53
  25. package/src/lib/ship-readiness.js +281 -0
  26. package/src/lib/sleep-plan.js +175 -0
  27. package/src/lib/sleep-report.js +229 -0
  28. package/src/lib/trust-events.js +166 -0
  29. package/src/lib/trust-file-scope.js +154 -0
  30. package/src/lib/trust-policy.js +212 -0
  31. package/src/lib/trust-redact.js +35 -0
  32. package/src/lib/trust-trace.js +179 -0
  33. package/src/lib/update.js +344 -344
  34. package/src/lib/workflow-artifact.js +9 -2
  35. package/src/lib/workflow-doctor.js +84 -0
  36. package/src/lib/workflow-handoff.js +111 -19
  37. package/src/lib/workflow-review-packet.js +650 -561
  38. package/src/lib/workflow-state.js +439 -0
  39. package/src/lib/workflow-verify.js +393 -356
@@ -1,228 +1,228 @@
1
1
  ---
2
- name: code-worktree
3
- description: Git worktrees for feature isolation. Use when starting feature work that needs isolation -- creates isolated worktrees with safety verification.
4
- ---
5
-
6
- # Code Worktree
7
-
8
- ## Critical Constraints
9
- - I do not create a project-local worktree until I verify the target directory is ignored.
10
- - I do not start feature work in a new worktree without checking the baseline setup and tests.
11
-
12
-
13
- ## Overview
14
- Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
15
-
16
- **Core principle:** Systematic directory selection + safety verification = reliable isolation.
17
-
18
- **Announce at start:** "I'm using the code-worktree skill to set up an isolated workspace."
19
-
20
- ## Procedure
21
- 1. Choose the worktree location using the documented priority order.
22
- 2. Verify project-local directories are ignored before creation.
23
- 3. Create the worktree and run repository setup commands.
24
- 4. Confirm the baseline tests pass before implementation begins.
25
-
26
- ## Directory Selection Process
27
-
28
- Follow this priority order:
29
-
30
- ### 1. Check Existing Directories
31
-
32
- ```bash
33
- # Check in priority order
34
- ls -d .worktrees 2>/dev/null # Preferred (hidden)
35
- ls -d worktrees 2>/dev/null # Alternative
36
- ```
37
-
38
- **If found:** Use that directory. If both exist, `.worktrees` wins.
39
-
2
+ name: code-worktree
3
+ description: Git worktrees for feature isolation. Use when starting feature work that needs isolation -- creates isolated worktrees with safety verification.
4
+ ---
5
+
6
+ # Code Worktree
7
+
8
+ ## Critical Constraints
9
+ - I do not create a project-local worktree until I verify the target directory is ignored.
10
+ - I do not start feature work in a new worktree without checking the baseline setup and tests.
11
+
12
+
13
+ ## Overview
14
+ Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
15
+
16
+ **Core principle:** Systematic directory selection + safety verification = reliable isolation.
17
+
18
+ **Announce at start:** "I'm using the code-worktree skill to set up an isolated workspace."
19
+
20
+ ## Procedure
21
+ 1. Choose the worktree location using the documented priority order.
22
+ 2. Verify project-local directories are ignored before creation.
23
+ 3. Create the worktree and run repository setup commands.
24
+ 4. Confirm the baseline tests pass before implementation begins.
25
+
26
+ ## Directory Selection Process
27
+
28
+ Follow this priority order:
29
+
30
+ ### 1. Check Existing Directories
31
+
32
+ ```bash
33
+ # Check in priority order
34
+ ls -d .worktrees 2>/dev/null # Preferred (hidden)
35
+ ls -d worktrees 2>/dev/null # Alternative
36
+ ```
37
+
38
+ **If found:** Use that directory. If both exist, `.worktrees` wins.
39
+
40
40
  ### 2. Check Repository Guidance
41
41
 
42
42
  ```bash
43
43
  rg -n -i "worktree|worktrees|\\.worktrees" AGENTS.md 2>/dev/null
44
44
  ```
45
-
46
- **If preference specified:** Use it without asking.
47
-
48
- ### 3. Ask User
49
-
45
+
46
+ **If preference specified:** Use it without asking.
47
+
48
+ ### 3. Ask User
49
+
50
50
  If no directory exists and no repository guidance preference:
51
-
52
- ```
53
- No worktree directory found. Where should I create worktrees?
54
-
55
- 1. .worktrees/ (project-local, hidden)
56
- 2. ~/.config/sdtk-code/worktrees/<project-name>/ (global location)
57
-
58
- Which would you prefer?
59
- ```
60
-
61
- ## Safety Verification
62
-
63
- ### For Project-Local Directories (.worktrees or worktrees)
64
-
65
- **MUST verify directory is ignored before creating worktree:**
66
-
67
- ```bash
68
- # Check if directory is ignored (respects local, global, and system gitignore)
69
- git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
70
- ```
71
-
72
- **If NOT ignored:**
73
-
51
+
52
+ ```
53
+ No worktree directory found. Where should I create worktrees?
54
+
55
+ 1. .worktrees/ (project-local, hidden)
56
+ 2. ~/.config/sdtk-code/worktrees/<project-name>/ (global location)
57
+
58
+ Which would you prefer?
59
+ ```
60
+
61
+ ## Safety Verification
62
+
63
+ ### For Project-Local Directories (.worktrees or worktrees)
64
+
65
+ **MUST verify directory is ignored before creating worktree:**
66
+
67
+ ```bash
68
+ # Check if directory is ignored (respects local, global, and system gitignore)
69
+ git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
70
+ ```
71
+
72
+ **If NOT ignored:**
73
+
74
74
  Per SDTK repository hygiene:
75
- 1. Add appropriate line to .gitignore
76
- 2. Commit the change
77
- 3. Proceed with worktree creation
78
-
79
- **Why critical:** Prevents accidentally committing worktree contents to repository.
80
-
81
- ### For Global Directory (~/.config/sdtk-code/worktrees)
82
-
83
- No .gitignore verification needed - outside project entirely.
84
-
85
- ## Creation Steps
86
-
87
- ### 1. Detect Project Name
88
-
89
- ```bash
90
- project=$(basename "$(git rev-parse --show-toplevel)")
91
- ```
92
-
93
- ### 2. Create Worktree
94
-
95
- ```bash
96
- # Determine full path
97
- case $LOCATION in
98
- .worktrees|worktrees)
99
- path="$LOCATION/$BRANCH_NAME"
100
- ;;
101
- ~/.config/sdtk-code/worktrees/*)
102
- path="~/.config/sdtk-code/worktrees/$project/$BRANCH_NAME"
103
- ;;
104
- esac
105
-
106
- # Create worktree with new branch
107
- git worktree add "$path" -b "$BRANCH_NAME"
108
- cd "$path"
109
- ```
110
-
111
- ### 3. Run Project Setup
112
-
113
- Auto-detect and run appropriate setup:
114
-
115
- ```bash
116
- # Node.js
117
- if [ -f package.json ]; then npm install; fi
118
-
119
- # Rust
120
- if [ -f Cargo.toml ]; then cargo build; fi
121
-
122
- # Python
123
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
124
- if [ -f pyproject.toml ]; then poetry install; fi
125
-
126
- # Go
127
- if [ -f go.mod ]; then go mod download; fi
128
- ```
129
-
130
- ### 4. Verify Clean Baseline
131
-
132
- Run tests to ensure worktree starts clean:
133
-
134
- ```bash
135
- # Examples - use project-appropriate command
136
- npm test
137
- cargo test
138
- pytest
139
- go test ./...
140
- ```
141
-
142
- **If tests fail:** Report failures, ask whether to proceed or investigate.
143
-
144
- **If tests pass:** Report ready.
145
-
146
- ### 5. Report Location
147
-
148
- ```
149
- Worktree ready at <full-path>
150
- Tests passing (<N> tests, 0 failures)
151
- Ready to implement <feature-name>
152
- ```
153
-
154
- ## Quick Reference
155
-
156
- | Situation | Action |
157
- |-----------|--------|
158
- | `.worktrees/` exists | Use it (verify ignored) |
159
- | `worktrees/` exists | Use it (verify ignored) |
160
- | Both exist | Use `.worktrees/` |
75
+ 1. Add appropriate line to .gitignore
76
+ 2. Commit the change
77
+ 3. Proceed with worktree creation
78
+
79
+ **Why critical:** Prevents accidentally committing worktree contents to repository.
80
+
81
+ ### For Global Directory (~/.config/sdtk-code/worktrees)
82
+
83
+ No .gitignore verification needed - outside project entirely.
84
+
85
+ ## Creation Steps
86
+
87
+ ### 1. Detect Project Name
88
+
89
+ ```bash
90
+ project=$(basename "$(git rev-parse --show-toplevel)")
91
+ ```
92
+
93
+ ### 2. Create Worktree
94
+
95
+ ```bash
96
+ # Determine full path
97
+ case $LOCATION in
98
+ .worktrees|worktrees)
99
+ path="$LOCATION/$BRANCH_NAME"
100
+ ;;
101
+ ~/.config/sdtk-code/worktrees/*)
102
+ path="~/.config/sdtk-code/worktrees/$project/$BRANCH_NAME"
103
+ ;;
104
+ esac
105
+
106
+ # Create worktree with new branch
107
+ git worktree add "$path" -b "$BRANCH_NAME"
108
+ cd "$path"
109
+ ```
110
+
111
+ ### 3. Run Project Setup
112
+
113
+ Auto-detect and run appropriate setup:
114
+
115
+ ```bash
116
+ # Node.js
117
+ if [ -f package.json ]; then npm install; fi
118
+
119
+ # Rust
120
+ if [ -f Cargo.toml ]; then cargo build; fi
121
+
122
+ # Python
123
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
124
+ if [ -f pyproject.toml ]; then poetry install; fi
125
+
126
+ # Go
127
+ if [ -f go.mod ]; then go mod download; fi
128
+ ```
129
+
130
+ ### 4. Verify Clean Baseline
131
+
132
+ Run tests to ensure worktree starts clean:
133
+
134
+ ```bash
135
+ # Examples - use project-appropriate command
136
+ npm test
137
+ cargo test
138
+ pytest
139
+ go test ./...
140
+ ```
141
+
142
+ **If tests fail:** Report failures, ask whether to proceed or investigate.
143
+
144
+ **If tests pass:** Report ready.
145
+
146
+ ### 5. Report Location
147
+
148
+ ```
149
+ Worktree ready at <full-path>
150
+ Tests passing (<N> tests, 0 failures)
151
+ Ready to implement <feature-name>
152
+ ```
153
+
154
+ ## Quick Reference
155
+
156
+ | Situation | Action |
157
+ |-----------|--------|
158
+ | `.worktrees/` exists | Use it (verify ignored) |
159
+ | `worktrees/` exists | Use it (verify ignored) |
160
+ | Both exist | Use `.worktrees/` |
161
161
  | Neither exists | Check AGENTS.md -> Ask user |
162
- | Directory not ignored | Add to .gitignore + commit |
163
- | Tests fail during baseline | Report failures + ask |
164
- | No package.json/Cargo.toml | Skip dependency install |
165
-
166
- ## Common Mistakes
167
-
168
- ### Skipping ignore verification
169
-
170
- - **Problem:** Worktree contents get tracked, pollute git status
171
- - **Fix:** Always use `git check-ignore` before creating project-local worktree
172
-
173
- ### Assuming directory location
174
-
175
- - **Problem:** Creates inconsistency, violates project conventions
162
+ | Directory not ignored | Add to .gitignore + commit |
163
+ | Tests fail during baseline | Report failures + ask |
164
+ | No package.json/Cargo.toml | Skip dependency install |
165
+
166
+ ## Common Mistakes
167
+
168
+ ### Skipping ignore verification
169
+
170
+ - **Problem:** Worktree contents get tracked, pollute git status
171
+ - **Fix:** Always use `git check-ignore` before creating project-local worktree
172
+
173
+ ### Assuming directory location
174
+
175
+ - **Problem:** Creates inconsistency, violates project conventions
176
176
  - **Fix:** Follow priority: existing > AGENTS.md > ask
177
-
178
- ### Proceeding with failing tests
179
-
180
- - **Problem:** Can't distinguish new bugs from pre-existing issues
181
- - **Fix:** Report failures, get explicit permission to proceed
182
-
183
- ### Hardcoding setup commands
184
-
185
- - **Problem:** Breaks on projects using different tools
186
- - **Fix:** Auto-detect from project files (package.json, etc.)
187
-
188
- ## Example Workflow
189
-
190
- ```
191
- You: I'm using the code-worktree skill to set up an isolated workspace.
192
-
193
- [Check .worktrees/ - exists]
194
- [Verify ignored - git check-ignore confirms .worktrees/ is ignored]
195
- [Create worktree: git worktree add .worktrees/auth -b feature/auth]
196
- [Run npm install]
197
- [Run npm test - 47 passing]
198
-
177
+
178
+ ### Proceeding with failing tests
179
+
180
+ - **Problem:** Can't distinguish new bugs from pre-existing issues
181
+ - **Fix:** Report failures, get explicit permission to proceed
182
+
183
+ ### Hardcoding setup commands
184
+
185
+ - **Problem:** Breaks on projects using different tools
186
+ - **Fix:** Auto-detect from project files (package.json, etc.)
187
+
188
+ ## Example Workflow
189
+
190
+ ```
191
+ You: I'm using the code-worktree skill to set up an isolated workspace.
192
+
193
+ [Check .worktrees/ - exists]
194
+ [Verify ignored - git check-ignore confirms .worktrees/ is ignored]
195
+ [Create worktree: git worktree add .worktrees/auth -b feature/auth]
196
+ [Run npm install]
197
+ [Run npm test - 47 passing]
198
+
199
199
  Worktree ready at /Users/example/myproject/.worktrees/auth
200
- Tests passing (47 tests, 0 failures)
201
- Ready to implement auth feature
202
- ```
203
-
204
- ## Red Flags
205
-
206
- **Never:**
207
- - Create worktree without verifying it's ignored (project-local)
208
- - Skip baseline test verification
209
- - Proceed with failing tests without asking
210
- - Assume directory location when ambiguous
200
+ Tests passing (47 tests, 0 failures)
201
+ Ready to implement auth feature
202
+ ```
203
+
204
+ ## Red Flags
205
+
206
+ **Never:**
207
+ - Create worktree without verifying it's ignored (project-local)
208
+ - Skip baseline test verification
209
+ - Proceed with failing tests without asking
210
+ - Assume directory location when ambiguous
211
211
  - Skip repository guidance check
212
-
213
- **Always:**
212
+
213
+ **Always:**
214
214
  - Follow directory priority: existing > AGENTS.md > ask
215
- - Verify directory is ignored for project-local
216
- - Auto-detect and run project setup
217
- - Verify clean test baseline
218
-
219
- ## Integration
220
-
221
- **Called by:**
222
- - **code-brainstorm** (Phase 4) - REQUIRED when design is approved and implementation follows
223
- - **code-parallel** - REQUIRED before executing any tasks
224
- - **code-execute** - REQUIRED before executing any tasks
225
- - Any skill needing isolated workspace
226
-
227
- **Pairs with:**
228
- - **code-finish** - REQUIRED for cleanup after work complete
215
+ - Verify directory is ignored for project-local
216
+ - Auto-detect and run project setup
217
+ - Verify clean test baseline
218
+
219
+ ## Integration
220
+
221
+ **Called by:**
222
+ - **code-brainstorm** (Phase 4) - REQUIRED when design is approved and implementation follows
223
+ - **code-parallel** - REQUIRED before executing any tasks
224
+ - **code-execute** - REQUIRED before executing any tasks
225
+ - Any skill needing isolated workspace
226
+
227
+ **Pairs with:**
228
+ - **code-finish** - REQUIRED for cleanup after work complete
@@ -43,6 +43,34 @@ __MISSING_INPUTS__
43
43
  - No additional planning notes recorded.
44
44
  <!-- SDTK-CODE:PLAN:END -->
45
45
 
46
+
47
+ ## Provenance
48
+
49
+ When external references are consulted for this workflow batch, include the full provenance log below:
50
+
51
+ ### Source References Consulted
52
+ | # | Source | URL or Path | Consulted Date | Purpose |
53
+ |---|---|---|---|---|
54
+ | 1 | <reference name> | <url or relative path> | <YYYY-MM-DD> | <why consulted> |
55
+
56
+ ### Behavioral Ideas Extracted
57
+ | # | Source Ref | Behavioral Idea Extracted | SDTK-Native Contract Written | High-Risk Material? |
58
+ |---|---|---|---|---|
59
+ | 1 | <ref #> | <plain description of idea> | <yes/no + what was written> | <yes/no> |
60
+
61
+ ### High-Risk Surfaces Reviewed
62
+ | # | Source Ref | Material Reviewed | Decision | Reason |
63
+ |---|---|---|---|---|
64
+ | 1 | <ref #> | <what was reviewed> | REJECTED / REDESIGNED | <reason> |
65
+
66
+ ### Controller Provenance Sign-Off
67
+ - Reviewed by: <controller name or alias>
68
+ - Date: <YYYY-MM-DD>
69
+ - Decision: APPROVED / NEEDS REVISION
70
+ - Notes: <any additional controller notes>
71
+
72
+ If no external material was consulted, keep this section and record only the no-reference declaration:
73
+ - No external source references were consulted for this batch.
46
74
  <!-- SDTK-CODE:BUILD:START -->
47
75
  ### Build Progress
48
76
  - Build status: `pending`
package/package.json CHANGED
@@ -1,44 +1,44 @@
1
- {
2
- "name": "sdtk-code-kit",
3
- "version": "0.1.3",
4
- "description": "Workflow-first coding process toolkit: start, plan, build, verify, ship, and runtime setup.",
5
- "bin": {
6
- "sdtk-code": "./bin/sdtk-code.js"
7
- },
8
- "main": "src/index.js",
9
- "type": "commonjs",
10
- "files": [
11
- "bin/",
12
- "src/",
13
- "assets/"
14
- ],
15
- "scripts": {
16
- "test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest tests.test_sdtk_code_cli tests.test_sdtk_code_product tests.test_sdtk_code_workflow_regressions\"",
17
- "build:payload": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; & 'scripts/sync-toolkit-assets.ps1'; & 'scripts/build-toolkit-manifest.ps1'\"",
18
- "verify:payload": "node -e \"require('./src/lib/toolkit-payload').verify()\"",
19
- "pack:smoke": "npm pack --dry-run",
20
- "pack:release": "npm pack",
21
- "prepublishOnly": "node -e \"require('./src/lib/toolkit-payload').verify()\""
22
- },
23
- "engines": {
24
- "node": ">=18.13.0"
25
- },
26
- "keywords": [
27
- "sdtk-code",
28
- "cli",
29
- "toolkit"
30
- ],
31
- "license": "MIT",
32
- "repository": {
33
- "type": "git",
34
- "url": "https://github.com/codexsdtk/sdtk-toolkit.git",
35
- "directory": "products/sdtk-code/distribution/sdtk-code-kit"
36
- },
37
- "homepage": "https://github.com/codexsdtk/sdtk-toolkit/tree/main/products/sdtk-code/distribution/sdtk-code-kit",
38
- "bugs": {
39
- "url": "https://github.com/codexsdtk/sdtk-toolkit/issues"
40
- },
41
- "publishConfig": {
42
- "access": "public"
43
- }
44
- }
1
+ {
2
+ "name": "sdtk-code-kit",
3
+ "version": "0.2.1",
4
+ "description": "Workflow-first coding process toolkit: start, plan, build, verify, ship, and runtime setup.",
5
+ "bin": {
6
+ "sdtk-code": "bin/sdtk-code.js"
7
+ },
8
+ "main": "src/index.js",
9
+ "type": "commonjs",
10
+ "files": [
11
+ "bin/",
12
+ "src/",
13
+ "assets/"
14
+ ],
15
+ "scripts": {
16
+ "test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest tests.test_sdtk_code_cli tests.test_sdtk_code_product tests.test_sdtk_code_workflow_regressions tests.test_sdtk_code_trust_events tests.test_sdtk_code_guardrails tests.test_sdtk_code_file_scope tests.test_sdtk_code_trust_trace tests.test_sdtk_code_readiness tests.test_sdtk_code_guardrails_scope_trace tests.test_sdtk_code_sleep tests.test_sdtk_code_sleep_report\"",
17
+ "build:payload": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; & 'scripts/sync-toolkit-assets.ps1'; & 'scripts/build-toolkit-manifest.ps1'\"",
18
+ "verify:payload": "node -e \"require('./src/lib/toolkit-payload').verify()\"",
19
+ "pack:smoke": "npm pack --dry-run",
20
+ "pack:release": "npm pack",
21
+ "prepublishOnly": "node -e \"require('./src/lib/toolkit-payload').verify()\""
22
+ },
23
+ "engines": {
24
+ "node": ">=18.13.0"
25
+ },
26
+ "keywords": [
27
+ "sdtk-code",
28
+ "cli",
29
+ "toolkit"
30
+ ],
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/codexsdtk/sdtk-toolkit.git",
35
+ "directory": "products/sdtk-code/distribution/sdtk-code-kit"
36
+ },
37
+ "homepage": "https://github.com/codexsdtk/sdtk-toolkit/tree/main/products/sdtk-code/distribution/sdtk-code-kit",
38
+ "bugs": {
39
+ "url": "https://github.com/codexsdtk/sdtk-toolkit/issues"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ }
44
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
+ const { ValidationError } = require("../lib/errors");
6
+ const { runWorkflowDoctor } = require("../lib/workflow-doctor");
7
+
8
+ const FLAG_DEFS = {
9
+ "feature-key": { type: "string" },
10
+ "project-path": { type: "string" },
11
+ };
12
+
13
+ const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
14
+
15
+ function cmdDoctor(args) {
16
+ const { flags, positional } = parseFlags(args, FLAG_DEFS);
17
+ if (positional.length > 0) {
18
+ throw new ValidationError('Unexpected positional arguments. Use flags only for "doctor".');
19
+ }
20
+
21
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
22
+ validatePattern(
23
+ featureKey,
24
+ FEATURE_KEY_RE,
25
+ "feature-key",
26
+ "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
27
+ );
28
+
29
+ const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
30
+ const report = runWorkflowDoctor(projectPath, featureKey);
31
+
32
+ console.log("SDTK-CODE workflow doctor");
33
+ console.log(` Feature key: ${featureKey}`);
34
+ console.log(` Artifact: ${report.state.exists ? report.state.artifactPath : "missing"}`);
35
+ console.log(` Result: ${report.result}`);
36
+
37
+ if (report.issues.length === 0) {
38
+ console.log(" Issues: none");
39
+ return 0;
40
+ }
41
+
42
+ report.issues.forEach((issue, index) => {
43
+ console.log(` Issue ${index + 1}: ${issue}`);
44
+ });
45
+
46
+ console.log(" Repair: diagnostic only in BK-047-lite (no auto-repair)");
47
+ return 1;
48
+ }
49
+
50
+ module.exports = {
51
+ cmdDoctor,
52
+ };