sdtk-spec-kit 0.3.9
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 +190 -0
- package/assets/manifest/toolkit-bundle.manifest.json +483 -0
- package/assets/manifest/toolkit-bundle.sha256.txt +95 -0
- package/assets/toolkit/toolkit/AGENTS.md +137 -0
- package/assets/toolkit/toolkit/install.ps1 +310 -0
- package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +54 -0
- package/assets/toolkit/toolkit/runtimes/codex/CODEX_TEMPLATE.md +32 -0
- package/assets/toolkit/toolkit/scripts/generate-code-handoff.ps1 +246 -0
- package/assets/toolkit/toolkit/scripts/init-feature.ps1 +261 -0
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +169 -0
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +189 -0
- package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +139 -0
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +116 -0
- package/assets/toolkit/toolkit/sdtk-spec.config.json +28 -0
- package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +50 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/SKILL.md +84 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/API_DESIGN_CREATION_RULES.md +22 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +468 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/FLOWCHART_CREATION_RULES.md +20 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/scripts/generate_api_design_detail.py +732 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-doc/SKILL.md +43 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +468 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/FLOWCHART_CREATION_RULES.md +20 -0
- package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/YAML_CREATION_RULES.md +128 -0
- package/assets/toolkit/toolkit/skills/sdtk-arch/SKILL.md +83 -0
- package/assets/toolkit/toolkit/skills/sdtk-arch/references/API_DESIGN_CREATION_RULES.md +22 -0
- package/assets/toolkit/toolkit/skills/sdtk-arch/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +468 -0
- package/assets/toolkit/toolkit/skills/sdtk-arch/references/FLOWCHART_CREATION_RULES.md +20 -0
- package/assets/toolkit/toolkit/skills/sdtk-arch/references/FLOW_ACTION_SPEC_CREATION_RULES.md +220 -0
- package/assets/toolkit/toolkit/skills/sdtk-arch/references/YAML_CREATION_RULES.md +128 -0
- package/assets/toolkit/toolkit/skills/sdtk-ba/SKILL.md +29 -0
- package/assets/toolkit/toolkit/skills/sdtk-design-layout/SKILL.md +52 -0
- package/assets/toolkit/toolkit/skills/sdtk-design-layout/scripts/render_design_layout_images.py +246 -0
- package/assets/toolkit/toolkit/skills/sdtk-dev/SKILL.md +98 -0
- package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/code-quality-reviewer.md +35 -0
- package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/implementer.md +61 -0
- package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/spec-reviewer.md +42 -0
- package/assets/toolkit/toolkit/skills/sdtk-dev-backend/SKILL.md +21 -0
- package/assets/toolkit/toolkit/skills/sdtk-dev-frontend/SKILL.md +19 -0
- package/assets/toolkit/toolkit/skills/sdtk-orchestrator/SKILL.md +81 -0
- package/assets/toolkit/toolkit/skills/sdtk-pm/SKILL.md +30 -0
- package/assets/toolkit/toolkit/skills/sdtk-qa/SKILL.md +52 -0
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/SKILL.md +86 -0
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/FLOW_ACTION_SPEC_CREATION_RULES.md +220 -0
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/excel-image-export.md +51 -0
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/figma-mcp.md +54 -0
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/numbering-rules.md +28 -0
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/scripts/renumber_flow_action_spec_global.py +136 -0
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/scripts/validate_flow_action_spec_numbering.py +414 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/SKILL.md +74 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/references/TEST_CASE_CREATION_RULES.md +129 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/scripts/validate_test_case_spec.py +97 -0
- package/assets/toolkit/toolkit/skills/skills.catalog.yaml +303 -0
- package/assets/toolkit/toolkit/skills-claude/api-design-spec/SKILL.md +90 -0
- package/assets/toolkit/toolkit/skills-claude/api-doc/SKILL.md +47 -0
- package/assets/toolkit/toolkit/skills-claude/arch/SKILL.md +59 -0
- package/assets/toolkit/toolkit/skills-claude/ba/SKILL.md +50 -0
- package/assets/toolkit/toolkit/skills-claude/design-layout/SKILL.md +57 -0
- package/assets/toolkit/toolkit/skills-claude/dev/SKILL.md +54 -0
- package/assets/toolkit/toolkit/skills-claude/dev-backend/SKILL.md +20 -0
- package/assets/toolkit/toolkit/skills-claude/dev-frontend/SKILL.md +18 -0
- package/assets/toolkit/toolkit/skills-claude/orchestrator/SKILL.md +63 -0
- package/assets/toolkit/toolkit/skills-claude/pm/SKILL.md +52 -0
- package/assets/toolkit/toolkit/skills-claude/qa/SKILL.md +50 -0
- package/assets/toolkit/toolkit/skills-claude/screen-design-spec/SKILL.md +90 -0
- package/assets/toolkit/toolkit/skills-claude/test-case-spec/SKILL.md +61 -0
- package/assets/toolkit/toolkit/templates/QUALITY_CHECKLIST.md +121 -0
- package/assets/toolkit/toolkit/templates/README.md +63 -0
- package/assets/toolkit/toolkit/templates/SHARED_PLANNING.md +81 -0
- package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md +22 -0
- package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_DETAIL_TEMPLATE.md +67 -0
- package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md +468 -0
- package/assets/toolkit/toolkit/templates/docs/api/API_ENDPOINTS_TEMPLATE.md +229 -0
- package/assets/toolkit/toolkit/templates/docs/api/FEATURE_API_TEMPLATE.yaml +20 -0
- package/assets/toolkit/toolkit/templates/docs/api/FLOWCHART_CREATION_RULES.md +20 -0
- package/assets/toolkit/toolkit/templates/docs/api/YAML_CREATION_RULES.md +128 -0
- package/assets/toolkit/toolkit/templates/docs/api/feature_api_flow_list_TEMPLATE.txt +12 -0
- package/assets/toolkit/toolkit/templates/docs/architecture/ARCH_DESIGN_TEMPLATE.md +109 -0
- package/assets/toolkit/toolkit/templates/docs/database/DATABASE_SPEC_TEMPLATE.md +175 -0
- package/assets/toolkit/toolkit/templates/docs/design/DESIGN_LAYOUT_TEMPLATE.md +60 -0
- package/assets/toolkit/toolkit/templates/docs/dev/FEATURE_IMPL_PLAN_TEMPLATE.md +93 -0
- package/assets/toolkit/toolkit/templates/docs/product/BACKLOG_TEMPLATE.md +50 -0
- package/assets/toolkit/toolkit/templates/docs/product/PRD_TEMPLATE.md +66 -0
- package/assets/toolkit/toolkit/templates/docs/product/PROJECT_INITIATION_TEMPLATE.md +98 -0
- package/assets/toolkit/toolkit/templates/docs/qa/QA_RELEASE_REPORT_TEMPLATE.md +61 -0
- package/assets/toolkit/toolkit/templates/docs/qa/TEST_CASE_CREATION_RULES.md +129 -0
- package/assets/toolkit/toolkit/templates/docs/qa/TEST_CASE_TEMPLATE.md +104 -0
- package/assets/toolkit/toolkit/templates/docs/specs/BA_SPEC_TEMPLATE.md +139 -0
- package/assets/toolkit/toolkit/templates/docs/specs/FLOW_ACTION_SPEC_CREATION_RULES.md +220 -0
- package/assets/toolkit/toolkit/templates/docs/specs/FLOW_ACTION_SPEC_TEMPLATE.md +197 -0
- package/assets/toolkit/toolkit/templates/handoffs/ARCH_TO_DEV.md +31 -0
- package/assets/toolkit/toolkit/templates/handoffs/BA_TO_ARCH.md +28 -0
- package/assets/toolkit/toolkit/templates/handoffs/DEV_STAGE1_SPEC_REVIEW.md +26 -0
- package/assets/toolkit/toolkit/templates/handoffs/DEV_STAGE2_CODE_QUALITY_REVIEW.md +20 -0
- package/assets/toolkit/toolkit/templates/handoffs/DEV_TO_QA.md +29 -0
- package/assets/toolkit/toolkit/templates/handoffs/DEV_TO_SDTK_CODE.md +29 -0
- package/assets/toolkit/toolkit/templates/handoffs/PM_TO_BA.md +26 -0
- package/assets/toolkit/toolkit/templates/handoffs/QA_RELEASE_DECISION.md +21 -0
- package/bin/sdtk.js +15 -0
- package/package.json +48 -0
- package/src/commands/auth.js +85 -0
- package/src/commands/generate.js +177 -0
- package/src/commands/help.js +101 -0
- package/src/commands/init.js +97 -0
- package/src/commands/runtime.js +217 -0
- package/src/index.js +59 -0
- package/src/lib/args.js +116 -0
- package/src/lib/errors.js +41 -0
- package/src/lib/github-access.js +68 -0
- package/src/lib/powershell.js +85 -0
- package/src/lib/scope.js +68 -0
- package/src/lib/state.js +83 -0
- package/src/lib/toolkit-payload.js +99 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[Parameter(Mandatory = $true)]
|
|
3
|
+
[string]$FeatureKey,
|
|
4
|
+
|
|
5
|
+
[Parameter(Mandatory = $true)]
|
|
6
|
+
[ValidateSet('READY_FOR_SDTK_CODE', 'BLOCKED_FOR_SDTK_CODE')]
|
|
7
|
+
[string]$HandoffStatus,
|
|
8
|
+
|
|
9
|
+
[Parameter(Mandatory = $true)]
|
|
10
|
+
[ValidateSet('feature', 'bugfix')]
|
|
11
|
+
[string]$RecommendedLane,
|
|
12
|
+
|
|
13
|
+
[Parameter(Mandatory = $true)]
|
|
14
|
+
[string]$FeatureImplPlanPath,
|
|
15
|
+
|
|
16
|
+
[Parameter(Mandatory = $true)]
|
|
17
|
+
[string]$RepoConfigRef,
|
|
18
|
+
|
|
19
|
+
[string[]]$RequiredRef = @(),
|
|
20
|
+
[string[]]$OptionalRef = @(),
|
|
21
|
+
[string[]]$OpenBlocker = @(),
|
|
22
|
+
[string[]]$ImplementationSlice = @(),
|
|
23
|
+
[string[]]$TestObligation = @(),
|
|
24
|
+
[string]$ProjectPath,
|
|
25
|
+
[switch]$Force,
|
|
26
|
+
[switch]$ValidateOnly
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
$ErrorActionPreference = 'Stop'
|
|
30
|
+
Set-StrictMode -Version Latest
|
|
31
|
+
|
|
32
|
+
function Assert-ForwardSlashRelativePath {
|
|
33
|
+
param(
|
|
34
|
+
[Parameter(Mandatory = $true)][string]$PathValue,
|
|
35
|
+
[Parameter(Mandatory = $true)][string]$Label
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if (-not $PathValue) {
|
|
39
|
+
throw "$Label is empty."
|
|
40
|
+
}
|
|
41
|
+
if ($PathValue.Contains('\')) {
|
|
42
|
+
throw "$Label must use repo-relative forward-slash paths: $PathValue"
|
|
43
|
+
}
|
|
44
|
+
if ($PathValue.StartsWith('/')) {
|
|
45
|
+
throw "$Label must be repo-relative, not absolute: $PathValue"
|
|
46
|
+
}
|
|
47
|
+
if ($PathValue -match '^[A-Za-z]:') {
|
|
48
|
+
throw "$Label must be repo-relative, not drive-qualified: $PathValue"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function Get-CanonicalStringArray {
|
|
53
|
+
param([AllowNull()][string[]]$Items)
|
|
54
|
+
|
|
55
|
+
if ($null -eq $Items) {
|
|
56
|
+
return [string[]]@()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
$result = New-Object System.Collections.Generic.List[string]
|
|
60
|
+
foreach ($item in $Items) {
|
|
61
|
+
if ($null -eq $item) {
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
foreach ($part in ($item -split ',')) {
|
|
65
|
+
$trimmed = $part.Trim()
|
|
66
|
+
if ($trimmed.Length -eq 0) {
|
|
67
|
+
continue
|
|
68
|
+
}
|
|
69
|
+
if (-not $result.Contains($trimmed)) {
|
|
70
|
+
$result.Add($trimmed) | Out-Null
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [string[]]$result.ToArray()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function Assert-PathExistsInProject {
|
|
78
|
+
param(
|
|
79
|
+
[Parameter(Mandatory = $true)][string]$RelativePath,
|
|
80
|
+
[Parameter(Mandatory = $true)][string]$ProjectRoot,
|
|
81
|
+
[Parameter(Mandatory = $true)][string]$Label
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
Assert-ForwardSlashRelativePath -PathValue $RelativePath -Label $Label
|
|
85
|
+
$fullPath = Join-Path $ProjectRoot ($RelativePath -replace '/', [System.IO.Path]::DirectorySeparatorChar)
|
|
86
|
+
if (-not (Test-Path -LiteralPath $fullPath)) {
|
|
87
|
+
throw "$Label does not exist: $RelativePath"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function Assert-RequiredRefCoverage {
|
|
92
|
+
param(
|
|
93
|
+
[Parameter(Mandatory = $true)][string[]]$RequiredRefs,
|
|
94
|
+
[AllowNull()][string[]]$ImplementationSlices,
|
|
95
|
+
[Parameter(Mandatory = $true)][string]$FeatureKey
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
$archPath = "docs/architecture/ARCH_DESIGN_${FeatureKey}.md"
|
|
99
|
+
$backlogPath = "docs/product/BACKLOG_${FeatureKey}.md"
|
|
100
|
+
foreach ($mustHave in @($archPath, $backlogPath)) {
|
|
101
|
+
if ($RequiredRefs -notcontains $mustHave) {
|
|
102
|
+
throw "Required refs must include: $mustHave"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
$sliceText = (($ImplementationSlices | ForEach-Object { $_.ToLowerInvariant() }) -join ' || ')
|
|
107
|
+
if (-not $sliceText) {
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if ($sliceText -match '\b(api|endpoint|contract|service|backend)\b') {
|
|
112
|
+
if (-not ($RequiredRefs | Where-Object { $_ -like 'docs/api/*' })) {
|
|
113
|
+
throw "Implementation slices reference API or backend scope, so required_refs must include at least one docs/api/* source."
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if ($sliceText -match '\b(database|migration|schema|table|sql|db)\b') {
|
|
118
|
+
if (-not ($RequiredRefs | Where-Object { $_ -like 'docs/database/*' })) {
|
|
119
|
+
throw "Implementation slices reference database scope, so required_refs must include at least one docs/database/* source."
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if ($sliceText -match '\b(ui|screen|frontend|page|form|layout)\b') {
|
|
124
|
+
if (-not ($RequiredRefs | Where-Object { $_ -like 'docs/design/*' })) {
|
|
125
|
+
throw "Implementation slices reference UI scope, so required_refs must include at least one docs/design/* source."
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ($sliceText -match '\b(flow|interaction)\b') {
|
|
130
|
+
if (-not ($RequiredRefs | Where-Object { $_ -like 'docs/specs/*_FLOW_ACTION_SPEC.md' })) {
|
|
131
|
+
throw "Implementation slices reference flow scope, so required_refs must include docs/specs/[FEATURE_KEY]_FLOW_ACTION_SPEC.md."
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if ($ProjectPath) {
|
|
137
|
+
if (-not (Test-Path -LiteralPath $ProjectPath)) {
|
|
138
|
+
New-Item -ItemType Directory -Force -Path $ProjectPath | Out-Null
|
|
139
|
+
}
|
|
140
|
+
$projectRoot = Resolve-Path -LiteralPath $ProjectPath
|
|
141
|
+
} else {
|
|
142
|
+
$toolkitRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
|
|
143
|
+
$projectRoot = Resolve-Path (Join-Path $toolkitRoot '..')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
$FeatureKey = $FeatureKey.Trim()
|
|
147
|
+
if ($FeatureKey -notmatch '^[A-Z][A-Z0-9_]*$') {
|
|
148
|
+
throw "Invalid FeatureKey. Use UPPER_SNAKE_CASE (A-Z, 0-9, _)."
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if ($RepoConfigRef -ne 'sdtk-spec.config.json') {
|
|
152
|
+
throw "RepoConfigRef must be exactly 'sdtk-spec.config.json'."
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
$FeatureImplPlanPath = $FeatureImplPlanPath.Trim()
|
|
156
|
+
$RequiredRefs = @(Get-CanonicalStringArray -Items $RequiredRef)
|
|
157
|
+
$OptionalRefs = @(Get-CanonicalStringArray -Items $OptionalRef)
|
|
158
|
+
$OpenBlockers = @(Get-CanonicalStringArray -Items $OpenBlocker)
|
|
159
|
+
$ImplementationSlices = @(Get-CanonicalStringArray -Items $ImplementationSlice)
|
|
160
|
+
$TestObligations = @(Get-CanonicalStringArray -Items $TestObligation)
|
|
161
|
+
|
|
162
|
+
Assert-PathExistsInProject -RelativePath $RepoConfigRef -ProjectRoot $projectRoot -Label 'RepoConfigRef'
|
|
163
|
+
Assert-PathExistsInProject -RelativePath $FeatureImplPlanPath -ProjectRoot $projectRoot -Label 'FeatureImplPlanPath'
|
|
164
|
+
|
|
165
|
+
$expectedPlanPath = "docs/dev/FEATURE_IMPL_PLAN_${FeatureKey}.md"
|
|
166
|
+
if ($FeatureImplPlanPath -ne $expectedPlanPath) {
|
|
167
|
+
throw "FeatureImplPlanPath must match the current feature key: $expectedPlanPath"
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
foreach ($pathValue in $RequiredRefs) {
|
|
171
|
+
Assert-PathExistsInProject -RelativePath $pathValue -ProjectRoot $projectRoot -Label 'RequiredRef'
|
|
172
|
+
}
|
|
173
|
+
foreach ($pathValue in $OptionalRefs) {
|
|
174
|
+
Assert-ForwardSlashRelativePath -PathValue $pathValue -Label 'OptionalRef'
|
|
175
|
+
$fullPath = Join-Path $projectRoot ($pathValue -replace '/', [System.IO.Path]::DirectorySeparatorChar)
|
|
176
|
+
if (-not (Test-Path -LiteralPath $fullPath)) {
|
|
177
|
+
throw "OptionalRef does not exist: $pathValue"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
Assert-RequiredRefCoverage -RequiredRefs $RequiredRefs -ImplementationSlices $ImplementationSlices -FeatureKey $FeatureKey
|
|
182
|
+
|
|
183
|
+
if ($HandoffStatus -eq 'READY_FOR_SDTK_CODE') {
|
|
184
|
+
if ($OpenBlockers.Count -ne 0) {
|
|
185
|
+
throw "READY_FOR_SDTK_CODE requires an empty open_blockers list."
|
|
186
|
+
}
|
|
187
|
+
if ($ImplementationSlices.Count -eq 0) {
|
|
188
|
+
throw "READY_FOR_SDTK_CODE requires at least one implementation slice."
|
|
189
|
+
}
|
|
190
|
+
if ($TestObligations.Count -eq 0) {
|
|
191
|
+
throw "READY_FOR_SDTK_CODE requires at least one test obligation."
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
if ($OpenBlockers.Count -eq 0) {
|
|
195
|
+
throw "BLOCKED_FOR_SDTK_CODE requires at least one open blocker."
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
$docsDevDir = Join-Path $projectRoot 'docs\dev'
|
|
200
|
+
if (-not (Test-Path -LiteralPath $docsDevDir)) {
|
|
201
|
+
New-Item -ItemType Directory -Force -Path $docsDevDir | Out-Null
|
|
202
|
+
}
|
|
203
|
+
$handoffRelPath = "docs/dev/CODE_HANDOFF_${FeatureKey}.json"
|
|
204
|
+
$handoffFullPath = Join-Path $projectRoot ($handoffRelPath -replace '/', [System.IO.Path]::DirectorySeparatorChar)
|
|
205
|
+
|
|
206
|
+
if ((Test-Path -LiteralPath $handoffFullPath) -and -not $Force -and -not $ValidateOnly) {
|
|
207
|
+
throw "Refusing to overwrite existing CODE_HANDOFF file (use -Force): $handoffRelPath"
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
$generatedAt = (Get-Date).ToString('yyyy-MM-ddTHH:mm:sszzz')
|
|
211
|
+
$payload = [ordered]@{
|
|
212
|
+
schema_version = '0.1'
|
|
213
|
+
feature_key = $FeatureKey
|
|
214
|
+
generated_by = 'sdtk-dev'
|
|
215
|
+
generated_at = $generatedAt
|
|
216
|
+
handoff_status = $HandoffStatus
|
|
217
|
+
recommended_lane = $RecommendedLane
|
|
218
|
+
feature_impl_plan_path = $FeatureImplPlanPath
|
|
219
|
+
required_refs = @($RequiredRefs)
|
|
220
|
+
optional_refs = @($OptionalRefs)
|
|
221
|
+
open_blockers = @($OpenBlockers)
|
|
222
|
+
implementation_slices = @($ImplementationSlices)
|
|
223
|
+
test_obligations = @($TestObligations)
|
|
224
|
+
repo_config_ref = $RepoConfigRef
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if ($ValidateOnly) {
|
|
228
|
+
Write-Host "Validation only: SDTK-CODE handoff contract is valid."
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
|
|
233
|
+
$json = $payload | ConvertTo-Json -Depth 5
|
|
234
|
+
[System.IO.File]::WriteAllText($handoffFullPath, $json + [Environment]::NewLine, $utf8NoBom)
|
|
235
|
+
|
|
236
|
+
Write-Host "SDTK-CODE handoff status: $HandoffStatus"
|
|
237
|
+
if ($HandoffStatus -eq 'READY_FOR_SDTK_CODE') {
|
|
238
|
+
Write-Host 'Suggested next step:'
|
|
239
|
+
Write-Host "sdtk-code start --feature-key $FeatureKey --lane $RecommendedLane --project-path ."
|
|
240
|
+
} else {
|
|
241
|
+
Write-Host 'SDTK-CODE handoff blockers:'
|
|
242
|
+
foreach ($blocker in $OpenBlockers) {
|
|
243
|
+
Write-Host "- $blocker"
|
|
244
|
+
}
|
|
245
|
+
Write-Host 'No SDTK-CODE start command is suggested until blockers are resolved.'
|
|
246
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[Parameter(Mandatory = $true)]
|
|
3
|
+
[string]$FeatureKey,
|
|
4
|
+
|
|
5
|
+
[Parameter(Mandatory = $true)]
|
|
6
|
+
[string]$FeatureName,
|
|
7
|
+
|
|
8
|
+
[string]$ProjectPath,
|
|
9
|
+
|
|
10
|
+
[switch]$Force,
|
|
11
|
+
|
|
12
|
+
[switch]$ValidateOnly
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
$ErrorActionPreference = 'Stop'
|
|
16
|
+
Set-StrictMode -Version Latest
|
|
17
|
+
|
|
18
|
+
function ConvertTo-PascalCase {
|
|
19
|
+
param([Parameter(Mandatory = $true)][string]$Text)
|
|
20
|
+
|
|
21
|
+
$parts = $Text -split '[^A-Za-z0-9]+' | Where-Object { $_ -and $_.Trim().Length -gt 0 }
|
|
22
|
+
if (-not $parts -or $parts.Count -eq 0) {
|
|
23
|
+
return ''
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return ($parts | ForEach-Object {
|
|
27
|
+
if ($_.Length -eq 1) { $_.Substring(0, 1).ToUpper() }
|
|
28
|
+
else { $_.Substring(0, 1).ToUpper() + $_.Substring(1) }
|
|
29
|
+
}) -join ''
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function Render-Template {
|
|
33
|
+
param(
|
|
34
|
+
[Parameter(Mandatory = $true)][string]$TemplatePath,
|
|
35
|
+
[Parameter(Mandatory = $true)][hashtable]$Tokens
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
$content = Get-Content -Raw -Path $TemplatePath -Encoding UTF8
|
|
39
|
+
# Strip BOM if present (Windows PowerShell 5.1 may read BOM into string)
|
|
40
|
+
if ($content.Length -gt 0 -and $content[0] -eq [char]0xFEFF) {
|
|
41
|
+
$content = $content.Substring(1)
|
|
42
|
+
}
|
|
43
|
+
foreach ($key in $Tokens.Keys) {
|
|
44
|
+
$content = $content.Replace("{{${key}}}", [string]$Tokens[$key])
|
|
45
|
+
}
|
|
46
|
+
return $content
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function Write-RenderedFile {
|
|
50
|
+
param(
|
|
51
|
+
[Parameter(Mandatory = $true)][string]$DestinationPath,
|
|
52
|
+
[Parameter(Mandatory = $true)][string]$TemplatePath,
|
|
53
|
+
[Parameter(Mandatory = $true)][hashtable]$Tokens,
|
|
54
|
+
[Parameter(Mandatory = $true)][bool]$Overwrite
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if ((Test-Path -LiteralPath $DestinationPath) -and -not $Overwrite) {
|
|
58
|
+
throw "Refusing to overwrite existing file (use -Force): $DestinationPath"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
$parent = Split-Path -Parent $DestinationPath
|
|
62
|
+
if ($parent -and -not (Test-Path -LiteralPath $parent)) {
|
|
63
|
+
New-Item -ItemType Directory -Force -Path $parent | Out-Null
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$rendered = Render-Template -TemplatePath $TemplatePath -Tokens $Tokens
|
|
67
|
+
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
|
|
68
|
+
[System.IO.File]::WriteAllText($DestinationPath, $rendered, $utf8NoBom)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
$config = $null
|
|
72
|
+
function Get-StringOrDefault {
|
|
73
|
+
param(
|
|
74
|
+
[AllowNull()][object]$Value,
|
|
75
|
+
[Parameter(Mandatory = $true)][string]$Default
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
if ($null -eq $Value) {
|
|
79
|
+
return $Default
|
|
80
|
+
}
|
|
81
|
+
$text = ([string]$Value).Trim()
|
|
82
|
+
if ($text.Length -eq 0) {
|
|
83
|
+
return $Default
|
|
84
|
+
}
|
|
85
|
+
return $text
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function Get-PropValue {
|
|
89
|
+
param(
|
|
90
|
+
[AllowNull()][object]$Object,
|
|
91
|
+
[Parameter(Mandatory = $true)][string]$Name
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if ($null -eq $Object) {
|
|
95
|
+
return $null
|
|
96
|
+
}
|
|
97
|
+
$prop = $Object.PSObject.Properties[$Name]
|
|
98
|
+
if ($null -eq $prop) {
|
|
99
|
+
return $null
|
|
100
|
+
}
|
|
101
|
+
return $prop.Value
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
$toolkitRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
|
|
105
|
+
|
|
106
|
+
if ($ProjectPath) {
|
|
107
|
+
if (-not (Test-Path -LiteralPath $ProjectPath)) {
|
|
108
|
+
New-Item -ItemType Directory -Force -Path $ProjectPath | Out-Null
|
|
109
|
+
}
|
|
110
|
+
$projectRoot = Resolve-Path -LiteralPath $ProjectPath
|
|
111
|
+
} else {
|
|
112
|
+
$projectRoot = Resolve-Path (Join-Path $toolkitRoot '..')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# Warn if legacy Docs/ compatibility folder exists at project root
|
|
116
|
+
$legacyDocs = Join-Path $projectRoot 'Docs'
|
|
117
|
+
if ((Test-Path -LiteralPath $legacyDocs) -and ($env:OS -eq 'Windows_NT')) {
|
|
118
|
+
Write-Host "[WARN] Legacy 'Docs/' folder detected at project root." -ForegroundColor Yellow
|
|
119
|
+
Write-Host " On Windows, 'docs/' and 'Docs/' resolve to same folder." -ForegroundColor Yellow
|
|
120
|
+
Write-Host " Consider: git mv Docs tmp-docs && git mv tmp-docs docs" -ForegroundColor Yellow
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
$templateRoot = Join-Path $toolkitRoot 'templates'
|
|
124
|
+
|
|
125
|
+
if (-not (Test-Path -LiteralPath $templateRoot)) {
|
|
126
|
+
throw "Missing templates directory: $templateRoot"
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
$configPath = Join-Path $projectRoot 'sdtk-spec.config.json'
|
|
130
|
+
if (-not (Test-Path -LiteralPath $configPath)) {
|
|
131
|
+
$configPath = Join-Path $toolkitRoot 'sdtk-spec.config.json'
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (Test-Path -LiteralPath $configPath) {
|
|
135
|
+
try {
|
|
136
|
+
$config = Get-Content -Raw -LiteralPath $configPath | ConvertFrom-Json
|
|
137
|
+
} catch {
|
|
138
|
+
throw "Failed to parse config file: $configPath`n$($_.Exception.Message)"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
$FeatureKey = $FeatureKey.Trim()
|
|
143
|
+
$FeatureName = $FeatureName.Trim()
|
|
144
|
+
|
|
145
|
+
if (-not $FeatureKey) { throw "FeatureKey is empty." }
|
|
146
|
+
if ($FeatureKey -notmatch '^[A-Z][A-Z0-9_]*$') {
|
|
147
|
+
throw "Invalid FeatureKey. Use UPPER_SNAKE_CASE (A-Z, 0-9, _)."
|
|
148
|
+
}
|
|
149
|
+
if (-not $FeatureName) { throw "FeatureName is empty." }
|
|
150
|
+
|
|
151
|
+
$now = Get-Date
|
|
152
|
+
$date = $now.ToString('yyyy-MM-dd')
|
|
153
|
+
$dateTime = $now.ToString('yyyy-MM-dd HH:mm')
|
|
154
|
+
|
|
155
|
+
$featureSnake = $FeatureKey.ToLower()
|
|
156
|
+
$featurePascal = ConvertTo-PascalCase -Text $FeatureName
|
|
157
|
+
if (-not $featurePascal) {
|
|
158
|
+
$featurePascal = ConvertTo-PascalCase -Text $FeatureKey
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
$stack = Get-PropValue -Object $config -Name 'stack'
|
|
162
|
+
$commands = Get-PropValue -Object $config -Name 'commands'
|
|
163
|
+
|
|
164
|
+
$stackBackend = Get-StringOrDefault -Value (Get-PropValue -Object $stack -Name 'backend') -Default 'TBD'
|
|
165
|
+
$stackFrontend = Get-StringOrDefault -Value (Get-PropValue -Object $stack -Name 'frontend') -Default 'TBD'
|
|
166
|
+
$stackMobile = Get-StringOrDefault -Value (Get-PropValue -Object $stack -Name 'mobile') -Default 'TBD'
|
|
167
|
+
$stackDatabase = Get-StringOrDefault -Value (Get-PropValue -Object $stack -Name 'database') -Default 'TBD'
|
|
168
|
+
$stackAuth = Get-StringOrDefault -Value (Get-PropValue -Object $stack -Name 'auth') -Default 'TBD'
|
|
169
|
+
|
|
170
|
+
$cmdBackendTests = Get-StringOrDefault -Value (Get-PropValue -Object $commands -Name 'backendTests') -Default 'TBD'
|
|
171
|
+
$cmdBackendTypecheck = Get-StringOrDefault -Value (Get-PropValue -Object $commands -Name 'backendTypecheck') -Default 'TBD'
|
|
172
|
+
$cmdBackendLint = Get-StringOrDefault -Value (Get-PropValue -Object $commands -Name 'backendLint') -Default 'TBD'
|
|
173
|
+
$cmdFrontendTests = Get-StringOrDefault -Value (Get-PropValue -Object $commands -Name 'frontendTests') -Default 'TBD'
|
|
174
|
+
$cmdFrontendLint = Get-StringOrDefault -Value (Get-PropValue -Object $commands -Name 'frontendLint') -Default 'TBD'
|
|
175
|
+
$cmdE2eTests = Get-StringOrDefault -Value (Get-PropValue -Object $commands -Name 'e2eTests') -Default 'TBD'
|
|
176
|
+
|
|
177
|
+
$tokens = @{
|
|
178
|
+
FEATURE_KEY = $FeatureKey
|
|
179
|
+
FEATURE_NAME = $FeatureName
|
|
180
|
+
FEATURE_PASCAL = $featurePascal
|
|
181
|
+
FEATURE_SNAKE = $featureSnake
|
|
182
|
+
DATE = $date
|
|
183
|
+
DATETIME = $dateTime
|
|
184
|
+
|
|
185
|
+
STACK_BACKEND = $stackBackend
|
|
186
|
+
STACK_FRONTEND = $stackFrontend
|
|
187
|
+
STACK_MOBILE = $stackMobile
|
|
188
|
+
STACK_DATABASE = $stackDatabase
|
|
189
|
+
STACK_AUTH = $stackAuth
|
|
190
|
+
|
|
191
|
+
CMD_BACKEND_TESTS = $cmdBackendTests
|
|
192
|
+
CMD_BACKEND_TYPECHECK = $cmdBackendTypecheck
|
|
193
|
+
CMD_BACKEND_LINT = $cmdBackendLint
|
|
194
|
+
CMD_FRONTEND_TESTS = $cmdFrontendTests
|
|
195
|
+
CMD_FRONTEND_LINT = $cmdFrontendLint
|
|
196
|
+
CMD_E2E_TESTS = $cmdE2eTests
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
$outputs = @(
|
|
200
|
+
@{ Dest = (Join-Path $projectRoot 'SHARED_PLANNING.md'); Template = (Join-Path $templateRoot 'SHARED_PLANNING.md') },
|
|
201
|
+
@{ Dest = (Join-Path $projectRoot 'QUALITY_CHECKLIST.md'); Template = (Join-Path $templateRoot 'QUALITY_CHECKLIST.md') },
|
|
202
|
+
|
|
203
|
+
@{ Dest = (Join-Path $projectRoot "docs/product/PROJECT_INITIATION_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/product/PROJECT_INITIATION_TEMPLATE.md') },
|
|
204
|
+
@{ Dest = (Join-Path $projectRoot "docs/specs/BA_SPEC_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/specs/BA_SPEC_TEMPLATE.md') },
|
|
205
|
+
@{ Dest = (Join-Path $projectRoot "docs/specs/${FeatureKey}_FLOW_ACTION_SPEC.md"); Template = (Join-Path $templateRoot 'docs/specs/FLOW_ACTION_SPEC_TEMPLATE.md') },
|
|
206
|
+
@{ Dest = (Join-Path $projectRoot "docs/product/PRD_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/product/PRD_TEMPLATE.md') },
|
|
207
|
+
@{ Dest = (Join-Path $projectRoot "docs/product/BACKLOG_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/product/BACKLOG_TEMPLATE.md') },
|
|
208
|
+
@{ Dest = (Join-Path $projectRoot "docs/architecture/ARCH_DESIGN_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/architecture/ARCH_DESIGN_TEMPLATE.md') },
|
|
209
|
+
@{ Dest = (Join-Path $projectRoot "docs/database/DATABASE_SPEC_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/database/DATABASE_SPEC_TEMPLATE.md') },
|
|
210
|
+
|
|
211
|
+
@{ Dest = (Join-Path $projectRoot "docs/api/${featurePascal}_API.yaml"); Template = (Join-Path $templateRoot 'docs/api/FEATURE_API_TEMPLATE.yaml') },
|
|
212
|
+
@{ Dest = (Join-Path $projectRoot "docs/api/${FeatureKey}_ENDPOINTS.md"); Template = (Join-Path $templateRoot 'docs/api/API_ENDPOINTS_TEMPLATE.md') },
|
|
213
|
+
@{ Dest = (Join-Path $projectRoot "docs/api/${FeatureKey}_API_DESIGN_DETAIL.md"); Template = (Join-Path $templateRoot 'docs/api/API_DESIGN_DETAIL_TEMPLATE.md') },
|
|
214
|
+
@{ Dest = (Join-Path $projectRoot "docs/api/${featureSnake}_api_flow_list.txt"); Template = (Join-Path $templateRoot 'docs/api/feature_api_flow_list_TEMPLATE.txt') },
|
|
215
|
+
@{ Dest = (Join-Path $projectRoot "docs/design/DESIGN_LAYOUT_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/design/DESIGN_LAYOUT_TEMPLATE.md') },
|
|
216
|
+
|
|
217
|
+
@{ Dest = (Join-Path $projectRoot "docs/dev/FEATURE_IMPL_PLAN_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/dev/FEATURE_IMPL_PLAN_TEMPLATE.md') },
|
|
218
|
+
@{ Dest = (Join-Path $projectRoot "docs/qa/${FeatureKey}_TEST_CASE.md"); Template = (Join-Path $templateRoot 'docs/qa/TEST_CASE_TEMPLATE.md') },
|
|
219
|
+
@{ Dest = (Join-Path $projectRoot "docs/qa/QA_RELEASE_REPORT_$FeatureKey.md"); Template = (Join-Path $templateRoot 'docs/qa/QA_RELEASE_REPORT_TEMPLATE.md') }
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
if ($ValidateOnly) {
|
|
223
|
+
foreach ($item in $outputs) {
|
|
224
|
+
$tmpl = [string]$item.Template
|
|
225
|
+
if (-not (Test-Path -LiteralPath $tmpl)) {
|
|
226
|
+
throw "Missing template file: $tmpl"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
Write-Host "Validation only: inputs and templates are valid."
|
|
231
|
+
Write-Host "No files were written because -ValidateOnly was specified."
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
$created = New-Object System.Collections.Generic.List[string]
|
|
236
|
+
foreach ($item in $outputs) {
|
|
237
|
+
$dest = [string]$item.Dest
|
|
238
|
+
$tmpl = [string]$item.Template
|
|
239
|
+
if (-not (Test-Path -LiteralPath $tmpl)) {
|
|
240
|
+
throw "Missing template file: $tmpl"
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
$willOverwrite = (Test-Path -LiteralPath $dest)
|
|
244
|
+
Write-RenderedFile -DestinationPath $dest -TemplatePath $tmpl -Tokens $tokens -Overwrite ([bool]$Force)
|
|
245
|
+
if (-not $willOverwrite) {
|
|
246
|
+
$created.Add($dest) | Out-Null
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
Write-Host "Initialized feature: $FeatureKey ($FeatureName)"
|
|
251
|
+
Write-Host "FeaturePascal: $featurePascal"
|
|
252
|
+
Write-Host "FeatureSnake: $featureSnake"
|
|
253
|
+
|
|
254
|
+
if ($created.Count -gt 0) {
|
|
255
|
+
Write-Host ""
|
|
256
|
+
Write-Host "Created files:"
|
|
257
|
+
$created | ForEach-Object { Write-Host " - $_" }
|
|
258
|
+
} else {
|
|
259
|
+
Write-Host ""
|
|
260
|
+
Write-Host "No new files created (all existed); use -Force to overwrite if needed."
|
|
261
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[string]$ProjectPath,
|
|
3
|
+
[ValidateSet('project', 'user')]
|
|
4
|
+
[string]$Scope = 'project',
|
|
5
|
+
[switch]$Force
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
$ErrorActionPreference = 'Stop'
|
|
9
|
+
Set-StrictMode -Version Latest
|
|
10
|
+
|
|
11
|
+
function Copy-File {
|
|
12
|
+
param(
|
|
13
|
+
[Parameter(Mandatory = $true)][string]$SourcePath,
|
|
14
|
+
[Parameter(Mandatory = $true)][string]$DestinationPath,
|
|
15
|
+
[Parameter(Mandatory = $true)][bool]$Overwrite
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
if (-not (Test-Path -LiteralPath $SourcePath)) {
|
|
19
|
+
throw "Missing source: $SourcePath"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (Test-Path -LiteralPath $DestinationPath) {
|
|
23
|
+
if (-not $Overwrite) {
|
|
24
|
+
Write-Warning "Already exists (skipping). Use -Force to overwrite: $DestinationPath"
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$parent = Split-Path -Parent $DestinationPath
|
|
30
|
+
if ($parent -and -not (Test-Path -LiteralPath $parent)) {
|
|
31
|
+
New-Item -ItemType Directory -Force -Path $parent | Out-Null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Copy-Item -LiteralPath $SourcePath -Destination $DestinationPath -Force
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Install-ClaudeSkillDirectory {
|
|
38
|
+
param(
|
|
39
|
+
[Parameter(Mandatory = $true)][System.IO.DirectoryInfo]$SkillDir,
|
|
40
|
+
[Parameter(Mandatory = $true)][string]$SkillsDest,
|
|
41
|
+
[Parameter(Mandatory = $true)][string]$ToolkitRoot,
|
|
42
|
+
[Parameter(Mandatory = $true)][bool]$Overwrite
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
$destDir = Join-Path $SkillsDest $SkillDir.Name
|
|
46
|
+
if (Test-Path -LiteralPath $destDir) {
|
|
47
|
+
if (-not $Overwrite) {
|
|
48
|
+
Write-Warning "Already exists (skipping). Use -Force to overwrite: $destDir"
|
|
49
|
+
return $true
|
|
50
|
+
}
|
|
51
|
+
Remove-Item -LiteralPath $destDir -Recurse -Force
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
$parent = Split-Path -Parent $destDir
|
|
55
|
+
if ($parent -and -not (Test-Path -LiteralPath $parent)) {
|
|
56
|
+
New-Item -ItemType Directory -Force -Path $parent | Out-Null
|
|
57
|
+
}
|
|
58
|
+
Copy-Item -LiteralPath $SkillDir.FullName -Destination $destDir -Recurse -Force
|
|
59
|
+
|
|
60
|
+
$canonicalSkillDir = Join-Path $ToolkitRoot "skills/sdtk-$($SkillDir.Name)"
|
|
61
|
+
foreach ($subDirName in @('scripts', 'prompts')) {
|
|
62
|
+
$srcSubDir = Join-Path $canonicalSkillDir $subDirName
|
|
63
|
+
$destSubDir = Join-Path $destDir $subDirName
|
|
64
|
+
if (-not (Test-Path -LiteralPath $srcSubDir)) {
|
|
65
|
+
continue
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (Test-Path -LiteralPath $destSubDir) {
|
|
69
|
+
Remove-Item -LiteralPath $destSubDir -Recurse -Force
|
|
70
|
+
}
|
|
71
|
+
Copy-Item -LiteralPath $srcSubDir -Destination $destSubDir -Recurse -Force
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return $true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
$toolkitRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
|
|
78
|
+
|
|
79
|
+
# Resolve destination based on scope
|
|
80
|
+
if ($Scope -eq 'user') {
|
|
81
|
+
$skillsDest = Join-Path $HOME '.claude/skills'
|
|
82
|
+
Write-Host "Scope: user (installing to $skillsDest)"
|
|
83
|
+
} else {
|
|
84
|
+
if (-not $ProjectPath) {
|
|
85
|
+
$ProjectPath = (Resolve-Path (Join-Path $toolkitRoot '..')).Path
|
|
86
|
+
}
|
|
87
|
+
$projectRoot = Resolve-Path -LiteralPath $ProjectPath
|
|
88
|
+
$skillsDest = Join-Path $projectRoot '.claude/skills'
|
|
89
|
+
Write-Host "Scope: project (installing to $skillsDest)"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
$skillsSource = Join-Path $toolkitRoot 'skills-claude'
|
|
93
|
+
if (-not (Test-Path -LiteralPath $skillsSource)) {
|
|
94
|
+
throw "Claude skills source not found: $skillsSource"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
$skillCount = 0
|
|
98
|
+
foreach ($skillDir in (Get-ChildItem -Path $skillsSource -Directory)) {
|
|
99
|
+
$srcFile = Join-Path $skillDir.FullName 'SKILL.md'
|
|
100
|
+
if (-not (Test-Path -LiteralPath $srcFile)) { continue }
|
|
101
|
+
|
|
102
|
+
if (Install-ClaudeSkillDirectory -SkillDir $skillDir -SkillsDest $skillsDest -ToolkitRoot $toolkitRoot -Overwrite ([bool]$Force)) {
|
|
103
|
+
$skillCount++
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# Install reference files
|
|
108
|
+
$refDest = Join-Path $skillsDest 'references'
|
|
109
|
+
if (-not (Test-Path -LiteralPath $refDest)) {
|
|
110
|
+
New-Item -ItemType Directory -Force -Path $refDest | Out-Null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
$refCount = 0
|
|
114
|
+
$missingRefs = @()
|
|
115
|
+
|
|
116
|
+
# 6 files from toolkit/templates/docs/
|
|
117
|
+
$templateRefs = @(
|
|
118
|
+
@{ Src = 'templates/docs/api/YAML_CREATION_RULES.md' },
|
|
119
|
+
@{ Src = 'templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md' },
|
|
120
|
+
@{ Src = 'templates/docs/api/FLOWCHART_CREATION_RULES.md' },
|
|
121
|
+
@{ Src = 'templates/docs/api/API_DESIGN_CREATION_RULES.md' },
|
|
122
|
+
@{ Src = 'templates/docs/specs/FLOW_ACTION_SPEC_CREATION_RULES.md' },
|
|
123
|
+
@{ Src = 'templates/docs/qa/TEST_CASE_CREATION_RULES.md' }
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
foreach ($ref in $templateRefs) {
|
|
127
|
+
$srcPath = Join-Path $toolkitRoot $ref.Src
|
|
128
|
+
$fileName = Split-Path -Leaf $srcPath
|
|
129
|
+
$destPath = Join-Path $refDest $fileName
|
|
130
|
+
if (Test-Path -LiteralPath $srcPath) {
|
|
131
|
+
Copy-File -SourcePath $srcPath -DestinationPath $destPath -Overwrite ([bool]$Force)
|
|
132
|
+
$refCount++
|
|
133
|
+
} else {
|
|
134
|
+
$missingRefs += $srcPath
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# 3 files from toolkit/skills/sdtk-screen-design-spec/references/
|
|
139
|
+
$screenRefs = @('numbering-rules.md', 'figma-mcp.md', 'excel-image-export.md')
|
|
140
|
+
foreach ($fileName in $screenRefs) {
|
|
141
|
+
$srcPath = Join-Path $toolkitRoot "skills/sdtk-screen-design-spec/references/$fileName"
|
|
142
|
+
$destPath = Join-Path $refDest $fileName
|
|
143
|
+
if (Test-Path -LiteralPath $srcPath) {
|
|
144
|
+
Copy-File -SourcePath $srcPath -DestinationPath $destPath -Overwrite ([bool]$Force)
|
|
145
|
+
$refCount++
|
|
146
|
+
} else {
|
|
147
|
+
$missingRefs += $srcPath
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# Fail-fast: abort if any reference files are missing
|
|
152
|
+
if ($missingRefs.Count -gt 0) {
|
|
153
|
+
$list = ($missingRefs | ForEach-Object { " - $_" }) -join "`n"
|
|
154
|
+
throw "Claude install failed. Missing reference files:`n$list"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
# Strict count assertions
|
|
158
|
+
$expectedSkills = 13
|
|
159
|
+
$expectedRefs = 9
|
|
160
|
+
if ($skillCount -ne $expectedSkills) {
|
|
161
|
+
throw "Claude install failed. Expected $expectedSkills skills but installed $skillCount."
|
|
162
|
+
}
|
|
163
|
+
if ($refCount -ne $expectedRefs) {
|
|
164
|
+
throw "Claude install failed. Expected $expectedRefs reference files but installed $refCount."
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
Write-Host " Skills installed: $skillCount"
|
|
168
|
+
Write-Host " Reference files : $refCount"
|
|
169
|
+
Write-Host " Destination : $skillsDest"
|