@hongmaple0820/scale-engine 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/adapters/AiderAdapter.js +53 -53
  2. package/dist/adapters/AiderAdapter.js.map +1 -1
  3. package/dist/adapters/ClaudeCodeAdapter.js +2 -0
  4. package/dist/adapters/ClaudeCodeAdapter.js.map +1 -1
  5. package/dist/adapters/CodexAdapter.js +1 -1
  6. package/dist/adapters/CodexAdapter.js.map +1 -1
  7. package/dist/adapters/CursorAdapter.js +1 -1
  8. package/dist/adapters/CursorAdapter.js.map +1 -1
  9. package/dist/adapters/DeepSeekTuiAdapter.js +2 -0
  10. package/dist/adapters/DeepSeekTuiAdapter.js.map +1 -1
  11. package/dist/adapters/DoubaoAdapter.js +34 -34
  12. package/dist/adapters/DoubaoAdapter.js.map +1 -1
  13. package/dist/adapters/GeminiAdapter.js +1 -1
  14. package/dist/adapters/GeminiAdapter.js.map +1 -1
  15. package/dist/adapters/HermesAdapter.js +1 -1
  16. package/dist/adapters/HermesAdapter.js.map +1 -1
  17. package/dist/adapters/KimiAdapter.js +33 -33
  18. package/dist/adapters/KimiAdapter.js.map +1 -1
  19. package/dist/adapters/KiroAdapter.js +27 -27
  20. package/dist/adapters/KiroAdapter.js.map +1 -1
  21. package/dist/adapters/OpenClawAdapter.js +1 -1
  22. package/dist/adapters/OpenClawAdapter.js.map +1 -1
  23. package/dist/adapters/OpenCodeAdapter.js +1 -1
  24. package/dist/adapters/OpenCodeAdapter.js.map +1 -1
  25. package/dist/adapters/QCoderAdapter.js +1 -1
  26. package/dist/adapters/QCoderAdapter.js.map +1 -1
  27. package/dist/adapters/TraeAdapter.js +1 -1
  28. package/dist/adapters/TraeAdapter.js.map +1 -1
  29. package/dist/adapters/VSCAdapter.js +1 -1
  30. package/dist/adapters/VSCAdapter.js.map +1 -1
  31. package/dist/adapters/WindsurfAdapter.js +33 -33
  32. package/dist/adapters/WindsurfAdapter.js.map +1 -1
  33. package/dist/adapters/WorkBuddyAdapter.js +1 -1
  34. package/dist/adapters/WorkBuddyAdapter.js.map +1 -1
  35. package/dist/api/cli.js +365 -13
  36. package/dist/api/cli.js.map +1 -1
  37. package/dist/api/doctor.d.ts +1 -0
  38. package/dist/api/doctor.js +29 -0
  39. package/dist/api/doctor.js.map +1 -1
  40. package/dist/api/quickstart.d.ts +1 -0
  41. package/dist/api/quickstart.js +2 -2
  42. package/dist/api/quickstart.js.map +1 -1
  43. package/dist/cli/phaseCommands.d.ts +5 -0
  44. package/dist/cli/phaseCommands.js +149 -25
  45. package/dist/cli/phaseCommands.js.map +1 -1
  46. package/dist/skills/ExternalSkills.js +2 -0
  47. package/dist/skills/ExternalSkills.js.map +1 -1
  48. package/dist/skills/SkillCatalog.d.ts +13 -0
  49. package/dist/skills/SkillCatalog.js +184 -0
  50. package/dist/skills/SkillCatalog.js.map +1 -0
  51. package/dist/skills/SkillDoctor.d.ts +37 -0
  52. package/dist/skills/SkillDoctor.js +90 -0
  53. package/dist/skills/SkillDoctor.js.map +1 -0
  54. package/dist/skills/index.d.ts +1 -0
  55. package/dist/skills/index.js +1 -0
  56. package/dist/skills/index.js.map +1 -1
  57. package/dist/skills/routing/SkillGate.d.ts +2 -1
  58. package/dist/skills/routing/SkillGate.js +19 -2
  59. package/dist/skills/routing/SkillGate.js.map +1 -1
  60. package/dist/skills/routing/SkillPlanner.js +40 -40
  61. package/dist/skills/routing/SkillPolicy.js +39 -12
  62. package/dist/skills/routing/SkillPolicy.js.map +1 -1
  63. package/dist/workflow/GovernanceLock.d.ts +35 -0
  64. package/dist/workflow/GovernanceLock.js +58 -0
  65. package/dist/workflow/GovernanceLock.js.map +1 -0
  66. package/dist/workflow/GovernanceTemplatePacks.d.ts +24 -0
  67. package/dist/workflow/GovernanceTemplatePacks.js +128 -0
  68. package/dist/workflow/GovernanceTemplatePacks.js.map +1 -0
  69. package/dist/workflow/GovernanceTemplates.d.ts +6 -1
  70. package/dist/workflow/GovernanceTemplates.js +585 -414
  71. package/dist/workflow/GovernanceTemplates.js.map +1 -1
  72. package/dist/workflow/TaskArtifactScaffolder.js +17 -17
  73. package/dist/workflow/TaskArtifactScaffolder.js.map +1 -1
  74. package/dist/workflow/VerificationCommands.js +1 -8
  75. package/dist/workflow/VerificationCommands.js.map +1 -1
  76. package/dist/workflow/VerificationProfile.d.ts +1 -0
  77. package/dist/workflow/VerificationProfile.js +42 -5
  78. package/dist/workflow/VerificationProfile.js.map +1 -1
  79. package/dist/workflow/WorkflowEngine.d.ts +6 -3
  80. package/dist/workflow/WorkflowEngine.js +1 -1
  81. package/dist/workflow/WorkflowEngine.js.map +1 -1
  82. package/dist/workflow/WorkspaceLifecycle.d.ts +53 -0
  83. package/dist/workflow/WorkspaceLifecycle.js +285 -0
  84. package/dist/workflow/WorkspaceLifecycle.js.map +1 -0
  85. package/dist/workflow/WorkspaceTopology.d.ts +49 -0
  86. package/dist/workflow/WorkspaceTopology.js +125 -0
  87. package/dist/workflow/WorkspaceTopology.js.map +1 -0
  88. package/dist/workflow/index.d.ts +4 -0
  89. package/dist/workflow/index.js +4 -0
  90. package/dist/workflow/index.js.map +1 -1
  91. package/package.json +2 -2
@@ -1,29 +1,56 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { skillRoutingPolicyTemplate } from '../skills/routing/SkillPolicy.js';
4
+ import { readGovernanceLock, writeGovernanceLock } from './GovernanceLock.js';
5
+ import { resolveGovernanceTemplatePack, } from './GovernanceTemplatePacks.js';
4
6
  export function writeGovernanceTemplates(projectDir = process.cwd(), options = {}) {
5
7
  const mode = options.mode ?? 'standard';
6
8
  const projectName = options.projectName ?? 'Project';
9
+ const pack = resolveGovernanceTemplatePack(options.pack);
10
+ const packMode = pack.modeDefaults[mode];
11
+ const services = options.services ?? pack.defaultServices ?? [];
12
+ const exclude = options.exclude ?? pack.exclude ?? ['node_modules', 'dist', 'tmp', 'vendor'];
7
13
  const result = { created: [], skipped: [] };
8
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'README.md'), workflowReadme(projectName, mode));
9
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'explore.md'), governanceTemplateContent('explore.md'));
10
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'mini-prd.md'), governanceTemplateContent('mini-prd.md'));
11
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'skill-plan.md'), governanceTemplateContent('skill-plan.md'));
12
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'ui-spec.md'), governanceTemplateContent('ui-spec.md'));
13
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'visual-review.md'), governanceTemplateContent('visual-review.md'));
14
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'api-contract.md'), governanceTemplateContent('api-contract.md'));
15
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'security-review.md'), governanceTemplateContent('security-review.md'));
16
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'db-change-plan.md'), governanceTemplateContent('db-change-plan.md'));
17
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'e2e-plan.md'), governanceTemplateContent('e2e-plan.md'));
18
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'plan.md'), governanceTemplateContent('plan.md'));
19
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'verification.md'), governanceTemplateContent('verification.md'));
20
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'review.md'), governanceTemplateContent('review.md'));
21
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'summary.md'), governanceTemplateContent('summary.md'));
22
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'github-actions-scale-preflight.yml'), githubActionsPreflightTemplate());
23
- writeIfMissing(result, join(projectDir, 'docs', 'workflow', 'templates', 'pre-push-scale-preflight.sh'), prePushPreflightTemplate());
24
- writeIfMissing(result, join(projectDir, 'docs', 'worklog', 'metrics.md'), metricsTemplate());
25
- writeIfMissing(result, join(projectDir, '.scale', 'verification.json'), verificationMatrixTemplate(mode));
26
- writeIfMissing(result, join(projectDir, '.scale', 'skills.json'), skillRoutingPolicyTemplate(mode));
14
+ const lockFiles = new Map();
15
+ for (const file of readGovernanceLock(projectDir)?.files ?? []) {
16
+ lockFiles.set(file.path, file);
17
+ }
18
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/README.md', workflowReadme(projectName, mode, pack.id));
19
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/explore.md', governanceTemplateContent('explore.md'));
20
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/mini-prd.md', governanceTemplateContent('mini-prd.md'));
21
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/skill-plan.md', governanceTemplateContent('skill-plan.md'));
22
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/skill-evidence.md', governanceTemplateContent('skill-evidence.md'));
23
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/ui-spec.md', governanceTemplateContent('ui-spec.md'));
24
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/visual-review.md', governanceTemplateContent('visual-review.md'));
25
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/api-contract.md', governanceTemplateContent('api-contract.md'));
26
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/docs-impact.md', governanceTemplateContent('docs-impact.md'));
27
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/security-review.md', governanceTemplateContent('security-review.md'));
28
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/db-change-plan.md', governanceTemplateContent('db-change-plan.md'));
29
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/e2e-plan.md', governanceTemplateContent('e2e-plan.md'));
30
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/plan.md', governanceTemplateContent('plan.md'));
31
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/verification.md', governanceTemplateContent('verification.md'));
32
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/review.md', governanceTemplateContent('review.md'));
33
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/summary.md', governanceTemplateContent('summary.md'));
34
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/github-actions-scale-preflight.yml', githubActionsPreflightTemplate());
35
+ writeTracked(result, lockFiles, projectDir, 'docs/workflow/templates/pre-push-scale-preflight.sh', prePushPreflightTemplate());
36
+ writeTracked(result, lockFiles, projectDir, 'docs/worklog/metrics.md', metricsTemplate());
37
+ writeTracked(result, lockFiles, projectDir, '.scale/verification.json', verificationMatrixTemplate(mode, {
38
+ services,
39
+ exclude,
40
+ artifactGate: packMode.artifactGate,
41
+ }));
42
+ writeTracked(result, lockFiles, projectDir, '.scale/skills.json', skillRoutingPolicyTemplate(mode));
43
+ for (const file of pack.generatedFiles) {
44
+ writePackGeneratedFile(result, lockFiles, projectDir, pack.id, pack.version, file);
45
+ }
46
+ const lockPath = join(projectDir, '.scale', 'governance.lock.json');
47
+ writeGovernanceLock(projectDir, {
48
+ pack: pack.id,
49
+ packVersion: pack.version,
50
+ scaleVersion: packageVersion(),
51
+ files: [...lockFiles.values()],
52
+ });
53
+ result.created.push(lockPath);
27
54
  return result;
28
55
  }
29
56
  export function governanceTemplateContent(name) {
@@ -31,9 +58,11 @@ export function governanceTemplateContent(name) {
31
58
  case 'explore.md': return exploreTemplate();
32
59
  case 'mini-prd.md': return miniPrdTemplate();
33
60
  case 'skill-plan.md': return skillPlanTemplate();
61
+ case 'skill-evidence.md': return skillEvidenceTemplate();
34
62
  case 'ui-spec.md': return uiSpecTemplate();
35
63
  case 'visual-review.md': return visualReviewTemplate();
36
64
  case 'api-contract.md': return apiContractTemplate();
65
+ case 'docs-impact.md': return docsImpactTemplate();
37
66
  case 'security-review.md': return securityReviewTemplate();
38
67
  case 'db-change-plan.md': return dbChangePlanTemplate();
39
68
  case 'e2e-plan.md': return e2ePlanTemplate();
@@ -46,470 +75,612 @@ export function governanceTemplateContent(name) {
46
75
  function writeIfMissing(result, path, content) {
47
76
  if (existsSync(path)) {
48
77
  result.skipped.push(path);
49
- return;
78
+ return false;
50
79
  }
51
80
  const dir = path.split(/[\\/]/).slice(0, -1).join('/');
52
81
  if (dir && !existsSync(dir))
53
82
  mkdirSync(dir, { recursive: true });
54
83
  writeFileSync(path, content, 'utf-8');
55
84
  result.created.push(path);
85
+ return true;
86
+ }
87
+ function writeTracked(result, lockFiles, projectDir, relativePath, content) {
88
+ const created = writeIfMissing(result, join(projectDir, relativePath), content);
89
+ if (created)
90
+ lockFiles.set(relativePath, { path: relativePath, owned: true });
91
+ }
92
+ function writePackGeneratedFile(result, lockFiles, projectDir, packId, packVersion, file) {
93
+ const content = shouldUseGeneratedHeader(file)
94
+ ? generatedHeader(packId, packVersion) + file.content
95
+ : file.content;
96
+ const created = writeIfMissing(result, join(projectDir, file.path), content);
97
+ if (created)
98
+ lockFiles.set(file.path, { path: file.path, owned: file.owned });
99
+ }
100
+ function shouldUseGeneratedHeader(file) {
101
+ return file.kind === 'doc' || file.kind === 'template' || file.kind === 'script';
102
+ }
103
+ function generatedHeader(packId, packVersion) {
104
+ return `# Generated by scale-engine governance pack: ${packId}@${packVersion}
105
+ # Edit policy: prefer editing the pack in scale-engine; local overrides should be documented.
106
+
107
+ `;
56
108
  }
57
- function workflowReadme(projectName, mode) {
58
- return `# ${projectName} Workflow
59
-
60
- Governance mode: ${mode}
61
-
62
- ## Task Levels
63
-
64
- | Level | Use for | Required artifacts |
65
- | --- | --- | --- |
66
- | S | typo, comments, small local edits | relevant validation only |
67
- | M | bug fixes, new APIs, 2-5 files | explore, skill plan, plan, verification, review, summary |
68
- | L | cross-module or architecture changes | full artifacts plus human confirmation |
69
- | CRITICAL | auth, permissions, migrations, production config | rollback plan, security review, full verification |
70
-
71
- ## Standard Task Directory
72
-
73
- \`\`\`text
74
- docs/worklog/tasks/<yyyy-mm-dd>-<task-slug>/
75
- ├── explore.md
76
- ├── mini-prd.md
77
- ├── plan.md
78
- ├── verification.md
79
- ├── review.md
80
- └── summary.md
81
- \`\`\`
82
-
83
- ## Verification
84
-
85
- Use service-aware verification when configured:
86
-
87
- \`\`\`bash
88
- scale preflight --service all
89
- scale verify <task-id> --profile default
90
- scale verify <task-id> --service <service-name>
91
- scale verify <task-id> --artifact-gate warn
92
- scale verify <task-id> --artifact-gate block
93
- scale task-artifacts check --dir docs/worklog/tasks/<task-dir> --level L
94
- \`\`\`
95
-
96
- Keep \`.scale/verification.json\` as the source of truth for profiles and service commands.
97
- Keep \`.scale/skills.json\` as the source of truth for active skill routing policy.
98
- Use \`artifactGate: "warn"\` while introducing the workflow, then move M/L/CRITICAL work to \`"block"\` once templates and local gates are stable.
99
-
100
- ## Automation Templates
101
-
102
- Optional automation templates are generated under \`docs/workflow/templates/\`:
103
-
104
- - \`github-actions-scale-preflight.yml\`: CI workflow that runs \`scale preflight --service all\`.
105
- - \`pre-push-scale-preflight.sh\`: local pre-push hook template for the same checks.
106
-
107
- Keep these templates advisory until \`scale preflight --service all\` is reliable locally for the project.
109
+ function workflowReadme(projectName, mode, packId = 'standard') {
110
+ return `# ${projectName} Workflow
111
+
112
+ Governance mode: ${mode}
113
+ Governance pack: ${packId}
114
+
115
+ ## Task Levels
116
+
117
+ | Level | Use for | Required artifacts |
118
+ | --- | --- | --- |
119
+ | S | typo, comments, small local edits | relevant validation only |
120
+ | M | bug fixes, new APIs, 2-5 files | explore, skill plan, plan, verification, review, summary |
121
+ | L | cross-module or architecture changes | full artifacts plus human confirmation |
122
+ | CRITICAL | auth, permissions, migrations, production config | rollback plan, security review, full verification |
123
+
124
+ ## Standard Task Directory
125
+
126
+ \`\`\`text
127
+ docs/worklog/tasks/<yyyy-mm-dd>-<task-slug>/
128
+ ├── explore.md
129
+ ├── mini-prd.md
130
+ ├── plan.md
131
+ ├── verification.md
132
+ ├── review.md
133
+ └── summary.md
134
+ \`\`\`
135
+
136
+ ## Verification
137
+
138
+ Use service-aware verification when configured:
139
+
140
+ \`\`\`bash
141
+ scale preflight --service all
142
+ scale preflight --service all --preflight-profile full
143
+ scale verify <task-id> --profile default
144
+ scale verify <task-id> --service <service-name>
145
+ scale verify <task-id> --artifact-gate warn
146
+ scale verify <task-id> --artifact-gate block
147
+ scale verify <task-id> --require-installed-skills
148
+ scale task-artifacts check --dir docs/worklog/tasks/<task-dir> --level L
149
+ \`\`\`
150
+
151
+ Keep \`.scale/verification.json\` as the source of truth for profiles and service commands.
152
+ Keep \`.scale/skills.json\` as the source of truth for active skill routing policy.
153
+ Use \`artifactGate: "warn"\` while introducing the workflow, then move M/L/CRITICAL work to \`"block"\` once templates and local gates are stable.
154
+
155
+ ## Active Skill Routing
156
+
157
+ SCALE plans required skills from task description, service selection, and changed files. UI/API work requires a Mini-PRD plus domain evidence such as \`ui-spec.md\`, \`visual-review.md\`, or \`api-contract.md\`. Security and database work require explicit review or rollback artifacts.
158
+
159
+ When a task records \`servicesTouched\`, \`scale verify <task-id>\` uses those services automatically. You can still override selection with \`--service all\`, \`--service api\`, or \`--service api,gateway\`.
160
+
161
+ Before M/L work, check whether required workflow skills are physically installed:
162
+
163
+ \`\`\`bash
164
+ scale skill doctor --json
165
+ scale skill check --require-installed --json
166
+ \`\`\`
167
+
168
+ ## Workspace Lifecycle
169
+
170
+ Before finishing an agent-created branch or deleting a temporary worktree, inspect root and child repository state:
171
+
172
+ \`\`\`bash
173
+ scale workspace status --json
174
+ scale workspace finish --json
175
+ scale workspace cleanup --dir <temporary-worktree> --dry-run --json
176
+ scale workspace cleanup --dir <temporary-worktree> --apply --confirm <branch-or-head> --json
177
+ \`\`\`
178
+
179
+ Do not remove a temporary worktree while any submodule or nested repository has uncommitted or unpushed work. Child repositories must be committed and reviewed in their own remotes, then the root repository can record any required pointer or governance updates. Cleanup defaults to dry-run. Applying cleanup requires the reported confirmation token, normally the temporary branch name.
180
+
181
+ ## Automation Templates
182
+
183
+ Optional automation templates are generated under \`docs/workflow/templates/\`:
184
+
185
+ - \`github-actions-scale-preflight.yml\`: CI workflow that runs \`scale preflight --service all --preflight-profile ci\`.
186
+ - \`pre-push-scale-preflight.sh\`: local pre-push hook template that runs the default quick preflight.
187
+
188
+ Keep these templates advisory until \`scale preflight --service all --preflight-profile full\` is reliable locally for the project.
108
189
  `;
109
190
  }
110
191
  function exploreTemplate() {
111
- return `# Explore
112
-
113
- ## Files Read
114
-
115
- -
116
-
117
- ## Current Behavior
118
-
119
-
120
- ## Main Conflict
121
-
122
-
123
- ## Affected Modules
124
-
125
-
126
- ## Evidence
127
-
128
-
192
+ return `# Explore
193
+
194
+ ## Files Read
195
+
196
+ - TBD
197
+
198
+ ## Current Behavior
199
+
200
+ TBD
201
+
202
+ ## Main Conflict
203
+
204
+ TBD
205
+
206
+ ## Affected Modules
207
+
208
+ TBD
209
+
210
+ ## Evidence
211
+ TBD
129
212
  `;
130
213
  }
131
214
  function miniPrdTemplate() {
132
- return `# Mini-PRD
133
-
134
- ## Background
135
-
136
-
137
- ## Target Users
138
-
139
-
140
- ## Core Scenario
141
-
142
-
143
- ## Non-Goals
144
-
145
-
146
- ## User Path
147
-
148
-
149
- ## Permission Rules
150
-
151
-
152
- ## Data Impact
153
-
154
-
155
- ## Exception Scenarios
156
-
157
- 1.
158
- 2.
159
- 3.
160
-
161
- ## Acceptance Criteria
162
-
163
- - [ ]
164
-
165
- ## Rollback Or Disable Strategy
166
-
167
-
215
+ return `# Mini-PRD
216
+
217
+ ## Background
218
+
219
+ TBD
220
+
221
+ ## Target Users
222
+
223
+ TBD
224
+
225
+ ## Core Scenario
226
+
227
+ TBD
228
+
229
+ ## Non-Goals
230
+
231
+ TBD
232
+
233
+ ## User Path
234
+
235
+ TBD
236
+
237
+ ## Permission Rules
238
+
239
+ TBD
240
+
241
+ ## Data Impact
242
+
243
+ TBD
244
+
245
+ ## Exception Scenarios
246
+
247
+ 1. TBD
248
+ 2. TBD
249
+ 3. TBD
250
+
251
+ ## Acceptance Criteria
252
+
253
+ - [ ] TBD
254
+
255
+ ## Rollback Or Disable Strategy
256
+ TBD
168
257
  `;
169
258
  }
170
259
  function skillPlanTemplate() {
171
- return `# Skill Plan
172
-
173
- ## Detected Intents
174
-
175
- | Domain | Score | Evidence |
176
- | --- | ---: | --- |
177
- | | | |
178
-
179
- ## Required Skills
180
-
181
- -
182
-
183
- ## Recommended Skills
184
-
185
- -
186
-
187
- ## Required Artifacts
188
-
189
- -
190
-
191
- ## Required Verification Evidence
192
-
193
- -
194
-
195
- ## Skipped Skills
196
-
197
- | Skill | Reason | Fallback Evidence |
198
- | --- | --- | --- |
199
- | | | |
260
+ return `# Skill Plan
261
+
262
+ ## Detected Intents
263
+
264
+ | Domain | Score | Evidence |
265
+ | --- | ---: | --- |
266
+ | | | |
267
+
268
+ ## Required Skills
269
+
270
+ - TBD
271
+
272
+ ## Recommended Skills
273
+
274
+ - TBD
275
+
276
+ ## Required Artifacts
277
+
278
+ - TBD
279
+
280
+ ## Required Verification Evidence
281
+
282
+ - TBD
283
+
284
+ ## Skipped Skills
285
+
286
+ | Skill | Reason | Fallback Evidence |
287
+ | --- | --- | --- |
288
+ | | | |
289
+ `;
290
+ }
291
+ function skillEvidenceTemplate() {
292
+ return `# Skill Evidence
293
+
294
+ ## Planned Skills
295
+
296
+ - TBD
297
+
298
+ ## Used Skills
299
+
300
+ | Skill | Phase | Trigger | Evidence | Status |
301
+ | --- | --- | --- | --- | --- |
302
+ | skill-id | plan/build/verify/review | why it was selected | command, screenshot, report, or artifact path | executed/skipped/fallback |
303
+
304
+ ## Skipped Skills
305
+
306
+ | Skill | Reason | Fallback Evidence |
307
+ | --- | --- | --- |
308
+ | skill-id | why it could not run | manual review, alternate command, or explicit risk |
200
309
  `;
201
310
  }
202
311
  function uiSpecTemplate() {
203
- return `# UI Spec
204
-
205
- ## User Goal
206
-
207
-
208
- ## Primary Flow
209
-
210
-
211
- ## Interaction States
212
-
213
- - Default:
214
- - Loading:
215
- - Empty:
216
- - Error:
217
- - Success:
218
-
219
- ## Responsive Behavior
220
-
221
-
222
- ## Accessibility Requirements
223
-
224
-
225
- ## Acceptance Criteria
226
-
227
- - [ ]
312
+ return `# UI Spec
313
+
314
+ ## User Goal
315
+
316
+ TBD
317
+
318
+ ## Primary Flow
319
+
320
+ TBD
321
+
322
+ ## Interaction States
323
+
324
+ - Default:
325
+ - Loading:
326
+ - Empty:
327
+ - Error:
328
+ - Success:
329
+
330
+ ## Responsive Behavior
331
+
332
+ TBD
333
+
334
+ ## Accessibility Requirements
335
+
336
+ TBD
337
+
338
+ ## Acceptance Criteria
339
+
340
+ - [ ] TBD
228
341
  `;
229
342
  }
230
343
  function visualReviewTemplate() {
231
- return `# Visual Review
232
-
233
- ## Screenshots Or Evidence
234
-
235
-
236
- ## Layout And Responsiveness
237
-
238
-
239
- ## Text Fit And Overlap
240
-
241
-
242
- ## Accessibility Notes
243
-
244
-
245
- ## Final Verdict
246
-
247
-
344
+ return `# Visual Review
345
+
346
+ ## Screenshots Or Evidence
347
+
348
+ TBD
349
+
350
+ ## Layout And Responsiveness
351
+
352
+ TBD
353
+
354
+ ## Text Fit And Overlap
355
+
356
+ TBD
357
+
358
+ ## Accessibility Notes
359
+
360
+ TBD
361
+
362
+ ## Final Verdict
363
+ TBD
248
364
  `;
249
365
  }
250
366
  function apiContractTemplate() {
251
- return `# API Contract
252
-
253
- ## Endpoint Or Interface
254
-
255
-
256
- ## Request
257
-
258
-
259
- ## Response
260
-
261
-
262
- ## Errors
263
-
264
-
265
- ## Permission Rules
266
-
267
-
268
- ## Compatibility Notes
269
-
270
-
271
- ## Acceptance Criteria
272
-
273
- - [ ]
367
+ return `# API Contract
368
+
369
+ ## Endpoint Or Interface
370
+
371
+ TBD
372
+
373
+ ## Request
374
+
375
+ TBD
376
+
377
+ ## Response
378
+
379
+ TBD
380
+
381
+ ## Errors
382
+
383
+ TBD
384
+
385
+ ## Permission Rules
386
+
387
+ TBD
388
+
389
+ ## Compatibility Notes
390
+
391
+ TBD
392
+
393
+ ## Acceptance Criteria
394
+
395
+ - [ ] TBD
396
+ `;
397
+ }
398
+ function docsImpactTemplate() {
399
+ return `# Docs Impact
400
+
401
+ ## Code Changes Requiring Docs
402
+
403
+ - TBD
404
+
405
+ ## Documentation Updated
406
+
407
+ - TBD
408
+
409
+ ## No-Docs-Needed Rationale
410
+
411
+ TBD
412
+
413
+ ## Links Checked
414
+
415
+ - TBD
274
416
  `;
275
417
  }
276
418
  function securityReviewTemplate() {
277
- return `# Security Review
278
-
279
- ## Assets And Trust Boundaries
280
-
281
-
282
- ## Authorization Rules
283
-
284
-
285
- ## Abuse Cases
286
-
287
- 1.
288
- 2.
289
- 3.
290
-
291
- ## Sensitive Data Impact
292
-
293
-
294
- ## Rollback Or Disable Strategy
295
-
296
-
297
- ## Final Verdict
298
-
299
-
419
+ return `# Security Review
420
+
421
+ ## Assets And Trust Boundaries
422
+
423
+ TBD
424
+
425
+ ## Authorization Rules
426
+
427
+ TBD
428
+
429
+ ## Abuse Cases
430
+
431
+ 1. TBD
432
+ 2. TBD
433
+ 3. TBD
434
+
435
+ ## Sensitive Data Impact
436
+
437
+ TBD
438
+
439
+ ## Rollback Or Disable Strategy
440
+
441
+ TBD
442
+
443
+ ## Final Verdict
444
+ TBD
300
445
  `;
301
446
  }
302
447
  function dbChangePlanTemplate() {
303
- return `# DB Change Plan
304
-
305
- ## Schema Or Data Change
306
-
307
-
308
- ## Backward Compatibility
309
-
310
-
311
- ## Migration Steps
312
-
313
-
314
- ## Rollback Plan
315
-
316
-
317
- ## Verification
318
-
319
-
448
+ return `# DB Change Plan
449
+
450
+ ## Schema Or Data Change
451
+
452
+ TBD
453
+
454
+ ## Backward Compatibility
455
+
456
+ TBD
457
+
458
+ ## Migration Steps
459
+
460
+ TBD
461
+
462
+ ## Rollback Plan
463
+
464
+ TBD
465
+
466
+ ## Verification
467
+ TBD
320
468
  `;
321
469
  }
322
470
  function e2ePlanTemplate() {
323
- return `# E2E Plan
324
-
325
- ## User Paths
326
-
327
-
328
- ## Browser Coverage
329
-
330
-
331
- ## Test Data
332
-
333
-
334
- ## Assertions
335
-
336
-
337
- ## Evidence
338
-
339
-
471
+ return `# E2E Plan
472
+
473
+ ## User Paths
474
+
475
+ TBD
476
+
477
+ ## Browser Coverage
478
+
479
+ TBD
480
+
481
+ ## Test Data
482
+
483
+ TBD
484
+
485
+ ## Assertions
486
+
487
+ TBD
488
+
489
+ ## Evidence
490
+ TBD
340
491
  `;
341
492
  }
342
493
  function planTemplate() {
343
- return `# Plan
344
-
345
- ## Approach
346
-
347
-
348
- ## Boundaries
349
-
350
-
351
- ## Exception Contract
352
-
353
- 1.
354
- 2.
355
- 3.
356
-
357
- ## Rollback Plan
358
-
359
-
360
- ## Test Strategy
361
-
362
-
494
+ return `# Plan
495
+
496
+ ## Approach
497
+
498
+ TBD
499
+
500
+ ## Boundaries
501
+
502
+ TBD
503
+
504
+ ## Exception Contract
505
+
506
+ 1. TBD
507
+ 2. TBD
508
+ 3. TBD
509
+
510
+ ## Rollback Plan
511
+
512
+ TBD
513
+
514
+ ## Test Strategy
515
+ TBD
363
516
  `;
364
517
  }
365
518
  function verificationTemplate() {
366
- return `# Verification
367
-
368
- ## Commands Run
369
-
370
- | Command | Result | Notes |
371
- | --- | --- | --- |
372
- | | | |
373
-
374
- ## Output Summary
375
-
376
-
377
- ## Failures And Fixes
378
-
379
-
380
- ## Final Status
381
-
382
-
519
+ return `# Verification
520
+
521
+ ## Commands Run
522
+
523
+ | Command | Result | Notes |
524
+ | --- | --- | --- |
525
+ | | | |
526
+
527
+ ## Output Summary
528
+
529
+ TBD
530
+
531
+ ## Failures And Fixes
532
+
533
+ TBD
534
+
535
+ ## Final Status
536
+ TBD
383
537
  `;
384
538
  }
385
539
  function reviewTemplate() {
386
- return `# Review
387
-
388
- ## Code Review
389
-
390
-
391
- ## Security Review
392
-
393
-
394
- ## Same-Pattern Scan
395
-
396
-
397
- ## Residual Risks
398
-
399
-
540
+ return `# Review
541
+
542
+ ## Code Review
543
+
544
+ TBD
545
+
546
+ ## Security Review
547
+
548
+ TBD
549
+
550
+ ## Same-Pattern Scan
551
+
552
+ TBD
553
+
554
+ ## Residual Risks
555
+ TBD
400
556
  `;
401
557
  }
402
558
  function summaryTemplate() {
403
- return `# Summary
404
-
405
- ## Delivered Changes
406
-
407
-
408
- ## Remaining Risks
409
-
410
-
411
- ## Follow-Ups
412
-
413
-
414
- ## Metric Row
415
-
416
- | Date | Task | Level | Services | Files Changed | First Verification Pass | Fix Iterations | Artifact Complete | Residual Risk | Final Gate |
417
- | --- | --- | --- | --- | ---: | --- | ---: | --- | --- | --- |
418
- | | | | | | | | | | |
559
+ return `# Summary
560
+
561
+ ## Delivered Changes
562
+
563
+ TBD
564
+
565
+ ## Remaining Risks
566
+
567
+ TBD
568
+
569
+ ## Follow-Ups
570
+
571
+ TBD
572
+
573
+ ## Metric Row
574
+
575
+ | Date | Task | Level | Services | Files Changed | First Verification Pass | Fix Iterations | Artifact Complete | Residual Risk | Final Gate |
576
+ | --- | --- | --- | --- | ---: | --- | ---: | --- | --- | --- |
577
+ | | | | | | | | | | |
419
578
  `;
420
579
  }
421
580
  function metricsTemplate() {
422
- return `# Workflow Metrics
423
-
424
- <!-- SCALE_METRICS:START -->
425
- | Date | Task | Level | Services | Files Changed | First Verification Pass | Fix Iterations | Rework Needed | Artifact Complete | Residual Risk | Final Gate |
426
- | --- | --- | --- | --- | ---: | --- | ---: | --- | --- | --- | --- |
427
- | | | | | | | | | | | |
428
- <!-- SCALE_METRICS:END -->
429
-
430
- ## Monthly Review
431
-
432
- ### Repeated Failure Patterns
433
-
434
-
435
- ### Slowest Gates
436
-
437
-
438
- ### Documentation Gaps
439
-
440
-
441
- ### Product Design Misses
442
-
443
-
444
- ### Proposed Workflow Changes
445
-
446
-
581
+ return `# Workflow Metrics
582
+
583
+ <!-- SCALE_METRICS:START -->
584
+ | Date | Task | Level | Services | Files Changed | First Verification Pass | Fix Iterations | Rework Needed | Artifact Complete | Residual Risk | Final Gate |
585
+ | --- | --- | --- | --- | ---: | --- | ---: | --- | --- | --- | --- |
586
+ | | | | | | | | | | | |
587
+ <!-- SCALE_METRICS:END -->
588
+
589
+ ## Monthly Review
590
+
591
+ ### Repeated Failure Patterns
592
+
593
+ TBD
594
+
595
+ ### Slowest Gates
596
+
597
+ TBD
598
+
599
+ ### Documentation Gaps
600
+
601
+ TBD
602
+
603
+ ### Product Design Misses
604
+
605
+ TBD
606
+
607
+ ### Proposed Workflow Changes
608
+ TBD
447
609
  `;
448
610
  }
449
- function verificationMatrixTemplate(mode) {
611
+ function verificationMatrixTemplate(mode, options = {}) {
450
612
  return JSON.stringify({
451
613
  version: 1,
452
614
  defaultProfile: 'default',
453
615
  profiles: {
454
616
  default: {
455
617
  commands: {},
456
- services: [],
618
+ services: options.services?.filter(service => service.required !== false).map(service => service.name) ?? [],
457
619
  },
458
620
  },
459
- services: [],
460
- exclude: ['node_modules', 'dist', 'tmp', 'vendor'],
621
+ services: options.services ?? [],
622
+ exclude: options.exclude ?? ['node_modules', 'dist', 'tmp', 'vendor'],
461
623
  policy: {
462
624
  mode,
463
625
  optionalToolsWarnOnly: true,
464
- artifactGate: mode === 'critical' ? 'block' : 'warn',
626
+ artifactGate: options.artifactGate ?? (mode === 'critical' ? 'block' : 'warn'),
465
627
  artifactGateLevels: ['M', 'L', 'CRITICAL'],
466
628
  },
467
629
  }, null, 2) + '\n';
468
630
  }
631
+ function packageVersion() {
632
+ try {
633
+ const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf-8'));
634
+ return pkg.version ?? '0.0.0-dev';
635
+ }
636
+ catch {
637
+ return '0.0.0-dev';
638
+ }
639
+ }
469
640
  function githubActionsPreflightTemplate() {
470
- return `name: SCALE Preflight
471
-
472
- on:
473
- pull_request:
474
- push:
475
- branches:
476
- - main
477
- - master
478
-
479
- jobs:
480
- preflight:
481
- runs-on: ubuntu-latest
482
- steps:
483
- - name: Checkout
484
- uses: actions/checkout@v4
485
-
486
- - name: Setup Node.js
487
- uses: actions/setup-node@v4
488
- with:
489
- node-version: '20'
490
-
491
- - name: Install project dependencies when present
492
- shell: bash
493
- run: |
494
- if [ -f package-lock.json ]; then
495
- npm ci
496
- elif [ -f package.json ]; then
497
- npm install
498
- fi
499
-
500
- - name: Run SCALE preflight
501
- run: npx @hongmaple0820/scale-engine@latest preflight --service all
641
+ return `name: SCALE Preflight
642
+
643
+ on:
644
+ pull_request:
645
+ push:
646
+ branches:
647
+ - main
648
+ - master
649
+
650
+ jobs:
651
+ preflight:
652
+ runs-on: ubuntu-latest
653
+ steps:
654
+ - name: Checkout
655
+ uses: actions/checkout@v4
656
+
657
+ - name: Setup Node.js
658
+ uses: actions/setup-node@v4
659
+ with:
660
+ node-version: '20'
661
+
662
+ - name: Install project dependencies when present
663
+ shell: bash
664
+ run: |
665
+ if [ -f package-lock.json ]; then
666
+ npm ci
667
+ elif [ -f package.json ]; then
668
+ npm install
669
+ fi
670
+
671
+ - name: Run SCALE preflight
672
+ run: npx @hongmaple0820/scale-engine@latest preflight --service all --preflight-profile ci
502
673
  `;
503
674
  }
504
675
  function prePushPreflightTemplate() {
505
- return `#!/usr/bin/env sh
506
- set -eu
507
-
508
- if command -v scale >/dev/null 2>&1; then
509
- scale preflight --service all
510
- else
511
- npx @hongmaple0820/scale-engine@latest preflight --service all
512
- fi
676
+ return `#!/usr/bin/env sh
677
+ set -eu
678
+
679
+ if command -v scale >/dev/null 2>&1; then
680
+ scale preflight --service all
681
+ else
682
+ npx @hongmaple0820/scale-engine@latest preflight --service all
683
+ fi
513
684
  `;
514
685
  }
515
686
  //# sourceMappingURL=GovernanceTemplates.js.map