@clawplays/ospec-cli 0.1.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 (191) hide show
  1. package/.ospec/templates/hooks/post-merge +8 -0
  2. package/.ospec/templates/hooks/pre-commit +8 -0
  3. package/LICENSE +21 -0
  4. package/README.md +549 -0
  5. package/README.zh-CN.md +549 -0
  6. package/assets/for-ai/en-US/ai-guide.md +98 -0
  7. package/assets/for-ai/en-US/execution-protocol.md +64 -0
  8. package/assets/for-ai/zh-CN/ai-guide.md +102 -0
  9. package/assets/for-ai/zh-CN/execution-protocol.md +68 -0
  10. package/assets/git-hooks/post-merge +12 -0
  11. package/assets/git-hooks/pre-commit +12 -0
  12. package/assets/global-skills/claude/ospec-change/SKILL.md +116 -0
  13. package/assets/global-skills/codex/ospec-change/SKILL.md +117 -0
  14. package/assets/global-skills/codex/ospec-change/agents/openai.yaml +7 -0
  15. package/assets/global-skills/codex/ospec-change/skill.yaml +19 -0
  16. package/assets/project-conventions/en-US/development-guide.md +32 -0
  17. package/assets/project-conventions/en-US/naming-conventions.md +51 -0
  18. package/assets/project-conventions/en-US/skill-conventions.md +40 -0
  19. package/assets/project-conventions/en-US/workflow-conventions.md +70 -0
  20. package/assets/project-conventions/zh-CN/development-guide.md +32 -0
  21. package/assets/project-conventions/zh-CN/naming-conventions.md +51 -0
  22. package/assets/project-conventions/zh-CN/skill-conventions.md +40 -0
  23. package/assets/project-conventions/zh-CN/workflow-conventions.md +74 -0
  24. package/dist/adapters/codex-stitch-adapter.js +420 -0
  25. package/dist/adapters/gemini-stitch-adapter.js +408 -0
  26. package/dist/adapters/playwright-checkpoint-adapter.js +2260 -0
  27. package/dist/advanced/BatchOperations.d.ts +36 -0
  28. package/dist/advanced/BatchOperations.js +159 -0
  29. package/dist/advanced/CachingLayer.d.ts +66 -0
  30. package/dist/advanced/CachingLayer.js +136 -0
  31. package/dist/advanced/FeatureUpdater.d.ts +46 -0
  32. package/dist/advanced/FeatureUpdater.js +151 -0
  33. package/dist/advanced/PerformanceMonitor.d.ts +52 -0
  34. package/dist/advanced/PerformanceMonitor.js +129 -0
  35. package/dist/advanced/StatePersistence.d.ts +61 -0
  36. package/dist/advanced/StatePersistence.js +168 -0
  37. package/dist/advanced/index.d.ts +14 -0
  38. package/dist/advanced/index.js +22 -0
  39. package/dist/cli/commands/config.d.ts +5 -0
  40. package/dist/cli/commands/config.js +6 -0
  41. package/dist/cli/commands/feature.d.ts +5 -0
  42. package/dist/cli/commands/feature.js +6 -0
  43. package/dist/cli/commands/index.d.ts +5 -0
  44. package/dist/cli/commands/index.js +6 -0
  45. package/dist/cli/commands/project.d.ts +5 -0
  46. package/dist/cli/commands/project.js +6 -0
  47. package/dist/cli/commands/validate.d.ts +5 -0
  48. package/dist/cli/commands/validate.js +6 -0
  49. package/dist/cli/index.d.ts +5 -0
  50. package/dist/cli/index.js +6 -0
  51. package/dist/cli.d.ts +3 -0
  52. package/dist/cli.js +1007 -0
  53. package/dist/commands/ArchiveCommand.d.ts +14 -0
  54. package/dist/commands/ArchiveCommand.js +241 -0
  55. package/dist/commands/BaseCommand.d.ts +33 -0
  56. package/dist/commands/BaseCommand.js +46 -0
  57. package/dist/commands/BatchCommand.d.ts +5 -0
  58. package/dist/commands/BatchCommand.js +42 -0
  59. package/dist/commands/ChangesCommand.d.ts +3 -0
  60. package/dist/commands/ChangesCommand.js +71 -0
  61. package/dist/commands/DocsCommand.d.ts +5 -0
  62. package/dist/commands/DocsCommand.js +118 -0
  63. package/dist/commands/FinalizeCommand.d.ts +3 -0
  64. package/dist/commands/FinalizeCommand.js +24 -0
  65. package/dist/commands/IndexCommand.d.ts +5 -0
  66. package/dist/commands/IndexCommand.js +57 -0
  67. package/dist/commands/InitCommand.d.ts +5 -0
  68. package/dist/commands/InitCommand.js +65 -0
  69. package/dist/commands/NewCommand.d.ts +11 -0
  70. package/dist/commands/NewCommand.js +262 -0
  71. package/dist/commands/PluginsCommand.d.ts +58 -0
  72. package/dist/commands/PluginsCommand.js +2491 -0
  73. package/dist/commands/ProgressCommand.d.ts +5 -0
  74. package/dist/commands/ProgressCommand.js +103 -0
  75. package/dist/commands/QueueCommand.d.ts +10 -0
  76. package/dist/commands/QueueCommand.js +147 -0
  77. package/dist/commands/RunCommand.d.ts +13 -0
  78. package/dist/commands/RunCommand.js +200 -0
  79. package/dist/commands/SkillCommand.d.ts +31 -0
  80. package/dist/commands/SkillCommand.js +1216 -0
  81. package/dist/commands/SkillsCommand.d.ts +5 -0
  82. package/dist/commands/SkillsCommand.js +68 -0
  83. package/dist/commands/StatusCommand.d.ts +6 -0
  84. package/dist/commands/StatusCommand.js +140 -0
  85. package/dist/commands/UpdateCommand.d.ts +8 -0
  86. package/dist/commands/UpdateCommand.js +251 -0
  87. package/dist/commands/VerifyCommand.d.ts +5 -0
  88. package/dist/commands/VerifyCommand.js +278 -0
  89. package/dist/commands/WorkflowCommand.d.ts +12 -0
  90. package/dist/commands/WorkflowCommand.js +150 -0
  91. package/dist/commands/index.d.ts +43 -0
  92. package/dist/commands/index.js +85 -0
  93. package/dist/core/constants.d.ts +41 -0
  94. package/dist/core/constants.js +73 -0
  95. package/dist/core/errors.d.ts +36 -0
  96. package/dist/core/errors.js +72 -0
  97. package/dist/core/index.d.ts +7 -0
  98. package/dist/core/index.js +23 -0
  99. package/dist/core/types.d.ts +369 -0
  100. package/dist/core/types.js +3 -0
  101. package/dist/index.d.ts +11 -0
  102. package/dist/index.js +27 -0
  103. package/dist/presets/ProjectPresets.d.ts +41 -0
  104. package/dist/presets/ProjectPresets.js +190 -0
  105. package/dist/scaffolds/ProjectScaffoldPresets.d.ts +20 -0
  106. package/dist/scaffolds/ProjectScaffoldPresets.js +151 -0
  107. package/dist/services/ConfigManager.d.ts +14 -0
  108. package/dist/services/ConfigManager.js +386 -0
  109. package/dist/services/FeatureManager.d.ts +5 -0
  110. package/dist/services/FeatureManager.js +6 -0
  111. package/dist/services/FileService.d.ts +21 -0
  112. package/dist/services/FileService.js +152 -0
  113. package/dist/services/IndexBuilder.d.ts +12 -0
  114. package/dist/services/IndexBuilder.js +130 -0
  115. package/dist/services/Logger.d.ts +20 -0
  116. package/dist/services/Logger.js +48 -0
  117. package/dist/services/ProjectAssetRegistry.d.ts +12 -0
  118. package/dist/services/ProjectAssetRegistry.js +96 -0
  119. package/dist/services/ProjectAssetService.d.ts +49 -0
  120. package/dist/services/ProjectAssetService.js +223 -0
  121. package/dist/services/ProjectScaffoldCommandService.d.ts +73 -0
  122. package/dist/services/ProjectScaffoldCommandService.js +159 -0
  123. package/dist/services/ProjectScaffoldService.d.ts +44 -0
  124. package/dist/services/ProjectScaffoldService.js +507 -0
  125. package/dist/services/ProjectService.d.ts +209 -0
  126. package/dist/services/ProjectService.js +13239 -0
  127. package/dist/services/QueueService.d.ts +17 -0
  128. package/dist/services/QueueService.js +142 -0
  129. package/dist/services/RunService.d.ts +40 -0
  130. package/dist/services/RunService.js +420 -0
  131. package/dist/services/SkillParser.d.ts +30 -0
  132. package/dist/services/SkillParser.js +88 -0
  133. package/dist/services/StateManager.d.ts +16 -0
  134. package/dist/services/StateManager.js +127 -0
  135. package/dist/services/TemplateEngine.d.ts +43 -0
  136. package/dist/services/TemplateEngine.js +119 -0
  137. package/dist/services/TemplateGenerator.d.ts +40 -0
  138. package/dist/services/TemplateGenerator.js +273 -0
  139. package/dist/services/ValidationService.d.ts +19 -0
  140. package/dist/services/ValidationService.js +44 -0
  141. package/dist/services/Validator.d.ts +5 -0
  142. package/dist/services/Validator.js +6 -0
  143. package/dist/services/index.d.ts +52 -0
  144. package/dist/services/index.js +91 -0
  145. package/dist/services/templates/ExecutionTemplateBuilder.d.ts +12 -0
  146. package/dist/services/templates/ExecutionTemplateBuilder.js +300 -0
  147. package/dist/services/templates/ProjectTemplateBuilder.d.ts +38 -0
  148. package/dist/services/templates/ProjectTemplateBuilder.js +1897 -0
  149. package/dist/services/templates/TemplateBuilderBase.d.ts +19 -0
  150. package/dist/services/templates/TemplateBuilderBase.js +60 -0
  151. package/dist/services/templates/TemplateInputFactory.d.ts +16 -0
  152. package/dist/services/templates/TemplateInputFactory.js +298 -0
  153. package/dist/services/templates/templateTypes.d.ts +90 -0
  154. package/dist/services/templates/templateTypes.js +3 -0
  155. package/dist/tools/build-index.js +632 -0
  156. package/dist/utils/DateUtils.d.ts +18 -0
  157. package/dist/utils/DateUtils.js +40 -0
  158. package/dist/utils/PathUtils.d.ts +9 -0
  159. package/dist/utils/PathUtils.js +66 -0
  160. package/dist/utils/StringUtils.d.ts +26 -0
  161. package/dist/utils/StringUtils.js +47 -0
  162. package/dist/utils/helpers.d.ts +5 -0
  163. package/dist/utils/helpers.js +6 -0
  164. package/dist/utils/index.d.ts +7 -0
  165. package/dist/utils/index.js +23 -0
  166. package/dist/utils/logger.d.ts +5 -0
  167. package/dist/utils/logger.js +6 -0
  168. package/dist/utils/path.d.ts +5 -0
  169. package/dist/utils/path.js +6 -0
  170. package/dist/utils/subcommandHelp.d.ts +11 -0
  171. package/dist/utils/subcommandHelp.js +119 -0
  172. package/dist/workflow/ArchiveGate.d.ts +30 -0
  173. package/dist/workflow/ArchiveGate.js +93 -0
  174. package/dist/workflow/ConfigurableWorkflow.d.ts +89 -0
  175. package/dist/workflow/ConfigurableWorkflow.js +186 -0
  176. package/dist/workflow/HookSystem.d.ts +38 -0
  177. package/dist/workflow/HookSystem.js +66 -0
  178. package/dist/workflow/IndexRegenerator.d.ts +49 -0
  179. package/dist/workflow/IndexRegenerator.js +147 -0
  180. package/dist/workflow/PluginWorkflowComposer.d.ts +138 -0
  181. package/dist/workflow/PluginWorkflowComposer.js +239 -0
  182. package/dist/workflow/SkillUpdateEngine.d.ts +26 -0
  183. package/dist/workflow/SkillUpdateEngine.js +113 -0
  184. package/dist/workflow/VerificationSystem.d.ts +24 -0
  185. package/dist/workflow/VerificationSystem.js +116 -0
  186. package/dist/workflow/WorkflowEngine.d.ts +15 -0
  187. package/dist/workflow/WorkflowEngine.js +57 -0
  188. package/dist/workflow/index.d.ts +19 -0
  189. package/dist/workflow/index.js +32 -0
  190. package/package.json +78 -0
  191. package/scripts/postinstall.js +43 -0
@@ -0,0 +1,386 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ConfigManager = void 0;
37
+ exports.createConfigManager = createConfigManager;
38
+ const path = __importStar(require("path"));
39
+ const constants_1 = require("../core/constants");
40
+ const errors_1 = require("../core/errors");
41
+ const ConfigurableWorkflow_1 = require("../workflow/ConfigurableWorkflow");
42
+ const PluginWorkflowComposer_1 = require("../workflow/PluginWorkflowComposer");
43
+ class ConfigManager {
44
+ constructor(fileService) {
45
+ this.fileService = fileService;
46
+ }
47
+ async loadConfig(rootDir) {
48
+ const configPath = path.join(rootDir, constants_1.FILE_NAMES.SKILLRC);
49
+ try {
50
+ return this.normalizeConfig(await this.fileService.readJSON(configPath));
51
+ }
52
+ catch {
53
+ throw new errors_1.ProjectNotInitializedError(`Cannot load .skillrc from ${rootDir}`);
54
+ }
55
+ }
56
+ async saveConfig(rootDir, config) {
57
+ const configPath = path.join(rootDir, constants_1.FILE_NAMES.SKILLRC);
58
+ await this.fileService.writeJSON(configPath, config);
59
+ }
60
+ async getMode(rootDir) {
61
+ const config = await this.loadConfig(rootDir);
62
+ return config.mode;
63
+ }
64
+ async isInitialized(rootDir) {
65
+ const configPath = path.join(rootDir, constants_1.FILE_NAMES.SKILLRC);
66
+ return this.fileService.exists(configPath);
67
+ }
68
+ async createDefaultConfig(mode = 'full') {
69
+ const workflow = ConfigurableWorkflow_1.WORKFLOW_PRESETS[mode];
70
+ const defaultPolicy = mode === 'lite' ? 'off' : 'error';
71
+ return {
72
+ version: '4.0',
73
+ mode,
74
+ hooks: {
75
+ 'pre-commit': true,
76
+ 'post-merge': true,
77
+ 'spec-check': defaultPolicy,
78
+ 'change-check': defaultPolicy,
79
+ 'index-check': defaultPolicy,
80
+ },
81
+ index: {
82
+ exclude: ['node_modules/**', 'dist/**', '*.test.*'],
83
+ },
84
+ plugins: this.createDefaultPluginsConfig(),
85
+ workflow,
86
+ };
87
+ }
88
+ createDefaultPluginsConfig() {
89
+ return JSON.parse(JSON.stringify({
90
+ stitch: PluginWorkflowComposer_1.DEFAULT_STITCH_PLUGIN_CONFIG,
91
+ checkpoint: PluginWorkflowComposer_1.DEFAULT_CHECKPOINT_PLUGIN_CONFIG,
92
+ }));
93
+ }
94
+ normalizePluginsConfig(plugins) {
95
+ const defaults = this.createDefaultPluginsConfig();
96
+ const stitch = plugins?.stitch && typeof plugins.stitch === 'object' ? plugins.stitch : {};
97
+ const checkpoint = plugins?.checkpoint && typeof plugins.checkpoint === 'object' ? plugins.checkpoint : {};
98
+ const legacyGemini = plugins?.['stitch-gemini'] && typeof plugins['stitch-gemini'] === 'object' ? plugins['stitch-gemini'] : {};
99
+ const legacyCodex = plugins?.['stitch-codex'] && typeof plugins['stitch-codex'] === 'object' ? plugins['stitch-codex'] : {};
100
+ const mergedStitch = {
101
+ ...legacyGemini,
102
+ ...legacyCodex,
103
+ ...stitch,
104
+ project: {
105
+ ...(legacyGemini.project || {}),
106
+ ...(legacyCodex.project || {}),
107
+ ...(stitch.project || {}),
108
+ },
109
+ runner: {
110
+ ...(legacyGemini.runner || {}),
111
+ ...(legacyCodex.runner || {}),
112
+ ...(stitch.runner || {}),
113
+ },
114
+ gemini: {
115
+ ...(legacyGemini.gemini || {}),
116
+ ...(stitch.gemini || {}),
117
+ },
118
+ codex: {
119
+ ...(legacyCodex.codex || {}),
120
+ ...(stitch.codex || {}),
121
+ },
122
+ capabilities: {
123
+ page_design_review: {
124
+ ...((legacyGemini.capabilities && legacyGemini.capabilities.page_design_review) || {}),
125
+ ...((legacyCodex.capabilities && legacyCodex.capabilities.page_design_review) || {}),
126
+ ...((stitch.capabilities && stitch.capabilities.page_design_review) || {}),
127
+ },
128
+ },
129
+ };
130
+ const stitchProject = mergedStitch.project || {};
131
+ const stitchGemini = mergedStitch.gemini || {};
132
+ const stitchCodexConfig = mergedStitch.codex || {};
133
+ const stitchRunner = mergedStitch.runner || {};
134
+ const pageDesignReview = mergedStitch.capabilities?.page_design_review || {};
135
+ const checkpointRuntime = checkpoint.runtime && typeof checkpoint.runtime === 'object' ? checkpoint.runtime : {};
136
+ const checkpointStartup = checkpointRuntime.startup && typeof checkpointRuntime.startup === 'object' ? checkpointRuntime.startup : {};
137
+ const checkpointReadiness = checkpointRuntime.readiness && typeof checkpointRuntime.readiness === 'object' ? checkpointRuntime.readiness : {};
138
+ const checkpointAuth = checkpointRuntime.auth && typeof checkpointRuntime.auth === 'object' ? checkpointRuntime.auth : {};
139
+ const checkpointShutdown = checkpointRuntime.shutdown && typeof checkpointRuntime.shutdown === 'object' ? checkpointRuntime.shutdown : {};
140
+ const checkpointRunner = checkpoint.runner && typeof checkpoint.runner === 'object' ? checkpoint.runner : {};
141
+ const checkpointCapabilities = checkpoint.capabilities && typeof checkpoint.capabilities === 'object' ? checkpoint.capabilities : {};
142
+ const checkpointUiReview = checkpointCapabilities.ui_review && typeof checkpointCapabilities.ui_review === 'object' ? checkpointCapabilities.ui_review : {};
143
+ const checkpointFlowCheck = checkpointCapabilities.flow_check && typeof checkpointCapabilities.flow_check === 'object' ? checkpointCapabilities.flow_check : {};
144
+ const checkpointStitchIntegration = checkpoint.stitch_integration && typeof checkpoint.stitch_integration === 'object' ? checkpoint.stitch_integration : {};
145
+ const activateWhenFlags = Array.isArray(pageDesignReview.activate_when_flags)
146
+ ? Array.from(new Set(pageDesignReview.activate_when_flags
147
+ .map(flag => String(flag).trim())
148
+ .filter(Boolean)))
149
+ : [...defaults.stitch.capabilities.page_design_review.activate_when_flags];
150
+ const checkpointUiFlags = Array.isArray(checkpointUiReview.activate_when_flags)
151
+ ? Array.from(new Set(checkpointUiReview.activate_when_flags
152
+ .map(flag => String(flag).trim())
153
+ .filter(Boolean)))
154
+ : [...defaults.checkpoint.capabilities.ui_review.activate_when_flags];
155
+ const checkpointFlowFlags = Array.isArray(checkpointFlowCheck.activate_when_flags)
156
+ ? Array.from(new Set(checkpointFlowCheck.activate_when_flags
157
+ .map(flag => String(flag).trim())
158
+ .filter(Boolean)))
159
+ : [...defaults.checkpoint.capabilities.flow_check.activate_when_flags];
160
+ const normalizedProvider = typeof mergedStitch.provider === 'string' && mergedStitch.provider.trim().length > 0
161
+ ? mergedStitch.provider.trim().toLowerCase()
162
+ : defaults.stitch.provider;
163
+ const provider = normalizedProvider === 'codex' ? 'codex' : 'gemini';
164
+ const defaultRunnerArgs = provider === 'codex'
165
+ ? ['${ospec_package_path}/dist/adapters/codex-stitch-adapter.js', '--change', '${change_path}', '--project', '${project_path}']
166
+ : [...defaults.stitch.runner.args];
167
+ const runnerArgs = Array.isArray(stitchRunner.args)
168
+ ? stitchRunner.args.map(arg => String(arg)).filter(arg => arg.length > 0)
169
+ : defaultRunnerArgs;
170
+ const runnerExtraEnv = stitchRunner.extra_env && typeof stitchRunner.extra_env === 'object'
171
+ ? Object.fromEntries(Object.entries(stitchRunner.extra_env)
172
+ .map(([key, value]) => [String(key).trim(), String(value ?? '')])
173
+ .filter(([key]) => key.length > 0))
174
+ : { ...defaults.stitch.runner.extra_env };
175
+ const checkpointRunnerArgs = Array.isArray(checkpointRunner.args)
176
+ ? checkpointRunner.args.map(arg => String(arg)).filter(arg => arg.length > 0)
177
+ : [...defaults.checkpoint.runner.args];
178
+ const checkpointRunnerExtraEnv = checkpointRunner.extra_env && typeof checkpointRunner.extra_env === 'object'
179
+ ? Object.fromEntries(Object.entries(checkpointRunner.extra_env)
180
+ .map(([key, value]) => [String(key).trim(), String(value ?? '')])
181
+ .filter(([key]) => key.length > 0))
182
+ : { ...defaults.checkpoint.runner.extra_env };
183
+ const runnerTimeout = Number.isFinite(stitchRunner.timeout_ms) && stitchRunner.timeout_ms > 0
184
+ ? Math.floor(stitchRunner.timeout_ms)
185
+ : defaults.stitch.runner.timeout_ms;
186
+ const checkpointRunnerTimeout = Number.isFinite(checkpointRunner.timeout_ms) && checkpointRunner.timeout_ms > 0
187
+ ? Math.floor(checkpointRunner.timeout_ms)
188
+ : defaults.checkpoint.runner.timeout_ms;
189
+ const normalizeCommandArgs = (value, fallback) => Array.isArray(value)
190
+ ? value.map(arg => String(arg)).filter(arg => arg.length > 0)
191
+ : [...fallback];
192
+ const normalizeCommandTimeout = (value, fallback) => Number.isFinite(value) && value > 0
193
+ ? Math.floor(value)
194
+ : fallback;
195
+ return {
196
+ stitch: {
197
+ enabled: mergedStitch.enabled === true,
198
+ blocking: mergedStitch.blocking !== false,
199
+ project: {
200
+ project_id: typeof stitchProject.project_id === 'string'
201
+ ? stitchProject.project_id.trim()
202
+ : defaults.stitch.project.project_id,
203
+ project_url: typeof stitchProject.project_url === 'string'
204
+ ? stitchProject.project_url.trim()
205
+ : defaults.stitch.project.project_url,
206
+ save_on_first_run: stitchProject.save_on_first_run !== false,
207
+ enforce_single_project: stitchProject.enforce_single_project !== false,
208
+ },
209
+ provider,
210
+ gemini: {
211
+ model: typeof stitchGemini.model === 'string' && stitchGemini.model.trim().length > 0
212
+ ? stitchGemini.model.trim()
213
+ : defaults.stitch.gemini.model,
214
+ auto_switch_on_limit: stitchGemini.auto_switch_on_limit !== false,
215
+ save_on_fallback: stitchGemini.save_on_fallback !== false,
216
+ },
217
+ codex: {
218
+ model: typeof stitchCodexConfig.model === 'string'
219
+ ? stitchCodexConfig.model.trim()
220
+ : defaults.stitch.codex.model,
221
+ mcp_server: typeof stitchCodexConfig.mcp_server === 'string' && stitchCodexConfig.mcp_server.trim().length > 0
222
+ ? stitchCodexConfig.mcp_server.trim()
223
+ : defaults.stitch.codex.mcp_server,
224
+ },
225
+ runner: {
226
+ mode: stitchRunner.mode === 'command' ? 'command' : defaults.stitch.runner.mode,
227
+ command: typeof stitchRunner.command === 'string'
228
+ ? stitchRunner.command.trim()
229
+ : defaults.stitch.runner.command,
230
+ args: runnerArgs,
231
+ cwd: typeof stitchRunner.cwd === 'string'
232
+ ? stitchRunner.cwd.trim()
233
+ : defaults.stitch.runner.cwd,
234
+ timeout_ms: runnerTimeout,
235
+ token_env: typeof stitchRunner.token_env === 'string'
236
+ ? stitchRunner.token_env.trim()
237
+ : defaults.stitch.runner.token_env,
238
+ extra_env: runnerExtraEnv,
239
+ },
240
+ capabilities: {
241
+ page_design_review: {
242
+ enabled: pageDesignReview.enabled === true,
243
+ step: typeof pageDesignReview.step === 'string' && pageDesignReview.step.trim().length > 0
244
+ ? pageDesignReview.step.trim()
245
+ : defaults.stitch.capabilities.page_design_review.step,
246
+ activate_when_flags: activateWhenFlags,
247
+ },
248
+ },
249
+ },
250
+ checkpoint: {
251
+ enabled: checkpoint.enabled === true,
252
+ blocking: checkpoint.blocking !== false,
253
+ runtime: {
254
+ base_url: typeof checkpointRuntime.base_url === 'string'
255
+ ? checkpointRuntime.base_url.trim()
256
+ : defaults.checkpoint.runtime.base_url,
257
+ startup: {
258
+ command: typeof checkpointStartup.command === 'string'
259
+ ? checkpointStartup.command.trim()
260
+ : defaults.checkpoint.runtime.startup.command,
261
+ args: normalizeCommandArgs(checkpointStartup.args, defaults.checkpoint.runtime.startup.args),
262
+ cwd: typeof checkpointStartup.cwd === 'string'
263
+ ? checkpointStartup.cwd.trim()
264
+ : defaults.checkpoint.runtime.startup.cwd,
265
+ timeout_ms: normalizeCommandTimeout(checkpointStartup.timeout_ms, defaults.checkpoint.runtime.startup.timeout_ms),
266
+ },
267
+ readiness: {
268
+ type: typeof checkpointReadiness.type === 'string' && checkpointReadiness.type.trim().length > 0
269
+ ? checkpointReadiness.type.trim()
270
+ : defaults.checkpoint.runtime.readiness.type,
271
+ url: typeof checkpointReadiness.url === 'string'
272
+ ? checkpointReadiness.url.trim()
273
+ : defaults.checkpoint.runtime.readiness.url,
274
+ timeout_ms: normalizeCommandTimeout(checkpointReadiness.timeout_ms, defaults.checkpoint.runtime.readiness.timeout_ms),
275
+ },
276
+ auth: {
277
+ command: typeof checkpointAuth.command === 'string'
278
+ ? checkpointAuth.command.trim()
279
+ : defaults.checkpoint.runtime.auth.command,
280
+ args: normalizeCommandArgs(checkpointAuth.args, defaults.checkpoint.runtime.auth.args),
281
+ cwd: typeof checkpointAuth.cwd === 'string'
282
+ ? checkpointAuth.cwd.trim()
283
+ : defaults.checkpoint.runtime.auth.cwd,
284
+ timeout_ms: normalizeCommandTimeout(checkpointAuth.timeout_ms, defaults.checkpoint.runtime.auth.timeout_ms),
285
+ when: typeof checkpointAuth.when === 'string' && checkpointAuth.when.trim().length > 0
286
+ ? checkpointAuth.when.trim()
287
+ : defaults.checkpoint.runtime.auth.when,
288
+ },
289
+ shutdown: {
290
+ command: typeof checkpointShutdown.command === 'string'
291
+ ? checkpointShutdown.command.trim()
292
+ : defaults.checkpoint.runtime.shutdown.command,
293
+ args: normalizeCommandArgs(checkpointShutdown.args, defaults.checkpoint.runtime.shutdown.args),
294
+ cwd: typeof checkpointShutdown.cwd === 'string'
295
+ ? checkpointShutdown.cwd.trim()
296
+ : defaults.checkpoint.runtime.shutdown.cwd,
297
+ timeout_ms: normalizeCommandTimeout(checkpointShutdown.timeout_ms, defaults.checkpoint.runtime.shutdown.timeout_ms),
298
+ },
299
+ storage_state: typeof checkpointRuntime.storage_state === 'string'
300
+ ? checkpointRuntime.storage_state.trim()
301
+ : defaults.checkpoint.runtime.storage_state,
302
+ },
303
+ runner: {
304
+ mode: checkpointRunner.mode === 'command' ? 'command' : defaults.checkpoint.runner.mode,
305
+ command: typeof checkpointRunner.command === 'string'
306
+ ? checkpointRunner.command.trim()
307
+ : defaults.checkpoint.runner.command,
308
+ args: checkpointRunnerArgs,
309
+ cwd: typeof checkpointRunner.cwd === 'string'
310
+ ? checkpointRunner.cwd.trim()
311
+ : defaults.checkpoint.runner.cwd,
312
+ timeout_ms: checkpointRunnerTimeout,
313
+ token_env: typeof checkpointRunner.token_env === 'string'
314
+ ? checkpointRunner.token_env.trim()
315
+ : defaults.checkpoint.runner.token_env,
316
+ extra_env: checkpointRunnerExtraEnv,
317
+ },
318
+ capabilities: {
319
+ ui_review: {
320
+ enabled: checkpointUiReview.enabled === true,
321
+ step: typeof checkpointUiReview.step === 'string' && checkpointUiReview.step.trim().length > 0
322
+ ? checkpointUiReview.step.trim()
323
+ : defaults.checkpoint.capabilities.ui_review.step,
324
+ activate_when_flags: checkpointUiFlags,
325
+ },
326
+ flow_check: {
327
+ enabled: checkpointFlowCheck.enabled === true,
328
+ step: typeof checkpointFlowCheck.step === 'string' && checkpointFlowCheck.step.trim().length > 0
329
+ ? checkpointFlowCheck.step.trim()
330
+ : defaults.checkpoint.capabilities.flow_check.step,
331
+ activate_when_flags: checkpointFlowFlags,
332
+ },
333
+ },
334
+ stitch_integration: {
335
+ enabled: checkpointStitchIntegration.enabled !== false,
336
+ auto_pass_stitch_review: checkpointStitchIntegration.auto_pass_stitch_review !== false,
337
+ },
338
+ },
339
+ };
340
+ }
341
+ normalizeConfig(config) {
342
+ const mode = ['lite', 'standard', 'full'].includes(config.mode) ? config.mode : 'full';
343
+ const hooks = config.hooks || {
344
+ 'pre-commit': true,
345
+ 'post-merge': true,
346
+ 'spec-check': 'error',
347
+ };
348
+ const fallbackPolicy = hooks['spec-check'] ?? 'error';
349
+ const normalizedHooks = {
350
+ 'pre-commit': hooks['pre-commit'] !== false,
351
+ 'post-merge': hooks['post-merge'] !== false,
352
+ 'spec-check': fallbackPolicy,
353
+ 'change-check': hooks['change-check'] ?? fallbackPolicy,
354
+ 'index-check': hooks['index-check'] ?? fallbackPolicy,
355
+ };
356
+ const legacyWarnDefaults = config.version === '3.0' &&
357
+ config.mode !== 'lite' &&
358
+ normalizedHooks['pre-commit'] &&
359
+ normalizedHooks['post-merge'] &&
360
+ normalizedHooks['spec-check'] === 'warn' &&
361
+ normalizedHooks['change-check'] === 'warn' &&
362
+ normalizedHooks['index-check'] === 'warn';
363
+ return {
364
+ ...config,
365
+ version: config.version === '3.0' ? '4.0' : config.version,
366
+ mode,
367
+ hooks: {
368
+ ...normalizedHooks,
369
+ ...(legacyWarnDefaults
370
+ ? {
371
+ 'spec-check': 'error',
372
+ 'change-check': 'error',
373
+ 'index-check': 'error',
374
+ }
375
+ : {}),
376
+ },
377
+ plugins: this.normalizePluginsConfig(config.plugins),
378
+ workflow: config.workflow || ConfigurableWorkflow_1.WORKFLOW_PRESETS[mode],
379
+ };
380
+ }
381
+ }
382
+ exports.ConfigManager = ConfigManager;
383
+ function createConfigManager(fileService) {
384
+ return new ConfigManager(fileService);
385
+ }
386
+ //# sourceMappingURL=ConfigManager.js.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Feature 管理服务
3
+ * TODO: 实现 feature 生命周期管理
4
+ */
5
+ //# sourceMappingURL=FeatureManager.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Feature 管理服务
4
+ * TODO: 实现 feature 生命周期管理
5
+ */
6
+ //# sourceMappingURL=FeatureManager.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 文件操作服务
3
+ */
4
+ import * as fs from 'fs-extra';
5
+ export declare class FileService {
6
+ readFile(filePath: string): Promise<string>;
7
+ writeFile(filePath: string, content: string): Promise<void>;
8
+ readJSON<T = any>(filePath: string): Promise<T>;
9
+ writeJSON(filePath: string, data: any): Promise<void>;
10
+ readYAML<T = any>(filePath: string): Promise<T>;
11
+ writeYAML(filePath: string, data: any): Promise<void>;
12
+ ensureDir(dirPath: string): Promise<void>;
13
+ exists(filePath: string): Promise<boolean>;
14
+ remove(filePath: string): Promise<void>;
15
+ copy(src: string, dest: string): Promise<void>;
16
+ move(src: string, dest: string): Promise<void>;
17
+ readDir(dirPath: string): Promise<string[]>;
18
+ stat(filePath: string): Promise<fs.Stats>;
19
+ }
20
+ export declare const fileService: FileService;
21
+ //# sourceMappingURL=FileService.d.ts.map
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ /**
3
+ * 文件操作服务
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.fileService = exports.FileService = void 0;
40
+ const fs = __importStar(require("fs-extra"));
41
+ const path = __importStar(require("path"));
42
+ const yaml = __importStar(require("js-yaml"));
43
+ const errors_1 = require("../core/errors");
44
+ class FileService {
45
+ async readFile(filePath) {
46
+ try {
47
+ return await fs.readFile(filePath, 'utf-8');
48
+ }
49
+ catch (error) {
50
+ throw new errors_1.FileOperationError(`Failed to read file: ${filePath}`, { error });
51
+ }
52
+ }
53
+ async writeFile(filePath, content) {
54
+ try {
55
+ await fs.ensureDir(path.dirname(filePath));
56
+ await fs.writeFile(filePath, content, 'utf-8');
57
+ }
58
+ catch (error) {
59
+ throw new errors_1.FileOperationError(`Failed to write file: ${filePath}`, { error });
60
+ }
61
+ }
62
+ async readJSON(filePath) {
63
+ try {
64
+ const content = await this.readFile(filePath);
65
+ return JSON.parse(content.replace(/^\uFEFF/, ''));
66
+ }
67
+ catch (error) {
68
+ throw new errors_1.FileOperationError(`Failed to parse JSON: ${filePath}`, { error });
69
+ }
70
+ }
71
+ async writeJSON(filePath, data) {
72
+ try {
73
+ const content = JSON.stringify(data, null, 2);
74
+ await this.writeFile(filePath, content);
75
+ }
76
+ catch (error) {
77
+ throw new errors_1.FileOperationError(`Failed to write JSON: ${filePath}`, { error });
78
+ }
79
+ }
80
+ async readYAML(filePath) {
81
+ try {
82
+ const content = await this.readFile(filePath);
83
+ return yaml.load(content);
84
+ }
85
+ catch (error) {
86
+ throw new errors_1.FileOperationError(`Failed to parse YAML: ${filePath}`, { error });
87
+ }
88
+ }
89
+ async writeYAML(filePath, data) {
90
+ try {
91
+ const content = yaml.dump(data);
92
+ await this.writeFile(filePath, content);
93
+ }
94
+ catch (error) {
95
+ throw new errors_1.FileOperationError(`Failed to write YAML: ${filePath}`, { error });
96
+ }
97
+ }
98
+ async ensureDir(dirPath) {
99
+ try {
100
+ await fs.ensureDir(dirPath);
101
+ }
102
+ catch (error) {
103
+ throw new errors_1.FileOperationError(`Failed to ensure directory: ${dirPath}`, { error });
104
+ }
105
+ }
106
+ async exists(filePath) {
107
+ return fs.pathExists(filePath);
108
+ }
109
+ async remove(filePath) {
110
+ try {
111
+ await fs.remove(filePath);
112
+ }
113
+ catch (error) {
114
+ throw new errors_1.FileOperationError(`Failed to remove: ${filePath}`, { error });
115
+ }
116
+ }
117
+ async copy(src, dest) {
118
+ try {
119
+ await fs.copy(src, dest);
120
+ }
121
+ catch (error) {
122
+ throw new errors_1.FileOperationError(`Failed to copy from ${src} to ${dest}`, { error });
123
+ }
124
+ }
125
+ async move(src, dest) {
126
+ try {
127
+ await fs.move(src, dest);
128
+ }
129
+ catch (error) {
130
+ throw new errors_1.FileOperationError(`Failed to move from ${src} to ${dest}`, { error });
131
+ }
132
+ }
133
+ async readDir(dirPath) {
134
+ try {
135
+ return await fs.readdir(dirPath);
136
+ }
137
+ catch (error) {
138
+ throw new errors_1.FileOperationError(`Failed to read directory: ${dirPath}`, { error });
139
+ }
140
+ }
141
+ async stat(filePath) {
142
+ try {
143
+ return await fs.stat(filePath);
144
+ }
145
+ catch (error) {
146
+ throw new errors_1.FileOperationError(`Failed to stat: ${filePath}`, { error });
147
+ }
148
+ }
149
+ }
150
+ exports.FileService = FileService;
151
+ exports.fileService = new FileService();
152
+ //# sourceMappingURL=FileService.js.map
@@ -0,0 +1,12 @@
1
+ import { SkillIndex } from '../core/types';
2
+ import { SkillParser } from './SkillParser';
3
+ export declare class IndexBuilder {
4
+ private skillParser;
5
+ constructor(skillParser: SkillParser);
6
+ build(rootDir: string): Promise<SkillIndex>;
7
+ write(rootDir: string): Promise<SkillIndex>;
8
+ createEmpty(rootDir: string): Promise<SkillIndex>;
9
+ private stripVolatileFields;
10
+ }
11
+ export declare const createIndexBuilder: (skillParser: SkillParser) => IndexBuilder;
12
+ //# sourceMappingURL=IndexBuilder.d.ts.map