@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,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndexCommand = void 0;
4
+ const services_1 = require("../services");
5
+ const subcommandHelp_1 = require("../utils/subcommandHelp");
6
+ const BaseCommand_1 = require("./BaseCommand");
7
+ class IndexCommand extends BaseCommand_1.BaseCommand {
8
+ async execute(action = 'check', projectPath) {
9
+ try {
10
+ if ((0, subcommandHelp_1.isHelpAction)(action)) {
11
+ this.info((0, subcommandHelp_1.getIndexHelpText)());
12
+ return;
13
+ }
14
+ const targetPath = projectPath || process.cwd();
15
+ switch (action) {
16
+ case 'build': {
17
+ const index = await services_1.services.projectService.rebuildIndex(targetPath);
18
+ this.success(`Index rebuilt at ${index.path}`);
19
+ if (index.stats) {
20
+ this.info(` Files: ${index.stats.totalFiles}, Modules: ${index.stats.totalModules}, Sections: ${index.stats.totalSections}`);
21
+ }
22
+ break;
23
+ }
24
+ case 'check': {
25
+ const index = await services_1.services.projectService.getIndexStatus(targetPath);
26
+ console.log('\nIndex Status');
27
+ console.log('============\n');
28
+ console.log(`Present: ${index.exists ? 'yes' : 'no'}`);
29
+ console.log(`Path: ${index.path}`);
30
+ console.log(`Updated: ${index.updatedAt ?? 'unknown'}`);
31
+ console.log(`Needs rebuild: ${index.needsRebuild ? 'yes' : 'no'}`);
32
+ console.log(`Stale: ${index.stale ? 'yes' : 'no'}`);
33
+ console.log(`Latest source update: ${index.latestSourceUpdatedAt ?? 'unknown'}`);
34
+ if (index.stats) {
35
+ console.log(`Stats: ${index.stats.totalFiles} files, ${index.stats.totalModules} modules, ${index.stats.totalSections} sections`);
36
+ }
37
+ if (index.reasons.length > 0) {
38
+ console.log('Reasons:');
39
+ for (const reason of index.reasons) {
40
+ console.log(` - ${reason}`);
41
+ }
42
+ }
43
+ console.log('');
44
+ break;
45
+ }
46
+ default:
47
+ this.info((0, subcommandHelp_1.getIndexHelpText)());
48
+ }
49
+ }
50
+ catch (error) {
51
+ this.error(`Index command failed: ${error}`);
52
+ throw error;
53
+ }
54
+ }
55
+ }
56
+ exports.IndexCommand = IndexCommand;
57
+ //# sourceMappingURL=IndexCommand.js.map
@@ -0,0 +1,5 @@
1
+ import { BaseCommand } from './BaseCommand';
2
+ export declare class InitCommand extends BaseCommand {
3
+ execute(rootDir?: string): Promise<void>;
4
+ }
5
+ //# sourceMappingURL=InitCommand.d.ts.map
@@ -0,0 +1,65 @@
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.InitCommand = void 0;
37
+ const path = __importStar(require("path"));
38
+ const services_1 = require("../services");
39
+ const BaseCommand_1 = require("./BaseCommand");
40
+ class InitCommand extends BaseCommand_1.BaseCommand {
41
+ async execute(rootDir) {
42
+ try {
43
+ const targetDir = rootDir || process.cwd();
44
+ this.logger.info(`Initializing OSpec project at ${targetDir}`);
45
+ const structure = await services_1.services.projectService.detectProjectStructure(targetDir);
46
+ if (structure.initialized) {
47
+ this.warn('Project already initialized');
48
+ return;
49
+ }
50
+ const config = await services_1.services.configManager.createDefaultConfig('full');
51
+ await services_1.services.projectService.initializeProtocolShellProject(targetDir, config.mode, {
52
+ projectName: path.basename(targetDir),
53
+ });
54
+ this.success(`${structure.initialized ? 'Protocol shell refreshed' : 'Protocol shell initialized'} at ${targetDir}`);
55
+ this.info(` Created OSpec protocol shell for ${path.basename(targetDir)}`);
56
+ this.info(' Added .skillrc, changes/, .ospec/, for-ai protocol docs, root SKILL.md, and SKILL.index.json');
57
+ }
58
+ catch (error) {
59
+ this.error(`Failed to initialize project: ${error}`);
60
+ throw error;
61
+ }
62
+ }
63
+ }
64
+ exports.InitCommand = InitCommand;
65
+ //# sourceMappingURL=InitCommand.js.map
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from './BaseCommand';
2
+ export interface NewCommandOptions {
3
+ flags?: string[];
4
+ placement?: 'active' | 'queued';
5
+ source?: string;
6
+ }
7
+ export declare class NewCommand extends BaseCommand {
8
+ execute(featureName: string, rootDir?: string, options?: NewCommandOptions): Promise<void>;
9
+ private normalizeFlags;
10
+ }
11
+ //# sourceMappingURL=NewCommand.d.ts.map
@@ -0,0 +1,262 @@
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.NewCommand = void 0;
37
+ const path = __importStar(require("path"));
38
+ const constants_1 = require("../core/constants");
39
+ const services_1 = require("../services");
40
+ const PathUtils_1 = require("../utils/PathUtils");
41
+ const PluginWorkflowComposer_1 = require("../workflow/PluginWorkflowComposer");
42
+ const BaseCommand_1 = require("./BaseCommand");
43
+ class NewCommand extends BaseCommand_1.BaseCommand {
44
+ async execute(featureName, rootDir, options = {}) {
45
+ try {
46
+ this.validateArgs([featureName], 1);
47
+ services_1.services.validationService.validateFeatureName(featureName);
48
+ const targetDir = rootDir || process.cwd();
49
+ const placement = options.placement === constants_1.DIR_NAMES.QUEUED ? constants_1.DIR_NAMES.QUEUED : constants_1.DIR_NAMES.ACTIVE;
50
+ const featureDir = PathUtils_1.PathUtils.getChangeDir(targetDir, placement, featureName);
51
+ this.logger.info(`Creating ${placement === constants_1.DIR_NAMES.QUEUED ? 'queued change' : 'change'}: ${featureName}`);
52
+ await this.ensureChangeNameAvailable(targetDir, featureName);
53
+ await services_1.services.fileService.ensureDir(path.join(targetDir, constants_1.DIR_NAMES.CHANGES, placement));
54
+ await services_1.services.fileService.ensureDir(featureDir);
55
+ const config = await services_1.services.configManager.loadConfig(targetDir);
56
+ const composer = new PluginWorkflowComposer_1.PluginWorkflowComposer(config);
57
+ const flags = this.normalizeFlags(options.flags);
58
+ const activatedSteps = composer.getActivatedSteps(flags);
59
+ const validation = composer.validateFlags(flags);
60
+ if (validation.unsupported.length > 0) {
61
+ this.warn(`Unsupported workflow flags: ${validation.unsupported.join(', ')}`);
62
+ }
63
+ const projectContext = await services_1.services.projectService.getFeatureProjectContext(targetDir, []);
64
+ const documentLanguage = await this.resolveDocumentLanguage(targetDir, config);
65
+ await services_1.services.fileService.writeJSON(path.join(featureDir, constants_1.FILE_NAMES.STATE), services_1.services.stateManager.createInitialState(featureName, [], config.mode, placement === constants_1.DIR_NAMES.QUEUED
66
+ ? {
67
+ queued: true,
68
+ source: options.source,
69
+ }
70
+ : undefined));
71
+ await services_1.services.fileService.writeFile(path.join(featureDir, constants_1.FILE_NAMES.PROPOSAL), services_1.services.templateEngine.generateProposalTemplate({
72
+ feature: featureName,
73
+ mode: config.mode,
74
+ placement,
75
+ projectContext,
76
+ flags,
77
+ optionalSteps: activatedSteps,
78
+ documentLanguage,
79
+ }));
80
+ await services_1.services.fileService.writeFile(path.join(featureDir, constants_1.FILE_NAMES.TASKS), services_1.services.templateEngine.generateTasksTemplate({
81
+ feature: featureName,
82
+ mode: config.mode,
83
+ placement,
84
+ projectContext,
85
+ flags,
86
+ optionalSteps: activatedSteps,
87
+ documentLanguage,
88
+ }));
89
+ await services_1.services.fileService.writeFile(path.join(featureDir, constants_1.FILE_NAMES.VERIFICATION), services_1.services.templateEngine.generateVerificationTemplate({
90
+ feature: featureName,
91
+ mode: config.mode,
92
+ placement,
93
+ projectContext,
94
+ flags,
95
+ optionalSteps: activatedSteps,
96
+ documentLanguage,
97
+ }));
98
+ await services_1.services.fileService.writeFile(path.join(featureDir, constants_1.FILE_NAMES.REVIEW), services_1.services.templateEngine.generateReviewTemplate({
99
+ feature: featureName,
100
+ mode: config.mode,
101
+ placement,
102
+ projectContext,
103
+ flags,
104
+ optionalSteps: activatedSteps,
105
+ documentLanguage,
106
+ }));
107
+ await this.writePluginArtifacts(featureDir, activatedSteps);
108
+ this.success(`${placement === constants_1.DIR_NAMES.QUEUED ? 'Queued change' : 'Change'} ${featureName} created at ${featureDir}`);
109
+ if (flags.length > 0) {
110
+ this.info(` Flags: ${flags.join(', ')}`);
111
+ }
112
+ if (activatedSteps.length > 0) {
113
+ this.info(` Activated optional steps: ${activatedSteps.join(', ')}`);
114
+ }
115
+ }
116
+ catch (error) {
117
+ this.error(`Failed to create change: ${error}`);
118
+ throw error;
119
+ }
120
+ }
121
+ async resolveDocumentLanguage(targetDir, config) {
122
+ const configLanguage = this.normalizeDocumentLanguage(config?.documentLanguage);
123
+ if (configLanguage) {
124
+ return configLanguage;
125
+ }
126
+ const manifestLanguage = await this.readDocumentLanguageFromAssetManifest(targetDir);
127
+ if (manifestLanguage) {
128
+ return manifestLanguage;
129
+ }
130
+ const guideLanguage = await this.readDocumentLanguageFromAiGuide(targetDir);
131
+ if (guideLanguage) {
132
+ return guideLanguage;
133
+ }
134
+ return 'zh-CN';
135
+ }
136
+ normalizeDocumentLanguage(input) {
137
+ return input === 'en-US' || input === 'zh-CN' ? input : null;
138
+ }
139
+ async readDocumentLanguageFromAssetManifest(targetDir) {
140
+ const manifestPath = path.join(targetDir, '.ospec', 'asset-sources.json');
141
+ if (!(await services_1.services.fileService.exists(manifestPath))) {
142
+ return null;
143
+ }
144
+ try {
145
+ const manifest = await services_1.services.fileService.readJSON(manifestPath);
146
+ const manifestLanguage = this.normalizeDocumentLanguage(manifest?.documentLanguage);
147
+ if (manifestLanguage) {
148
+ return manifestLanguage;
149
+ }
150
+ const assets = Array.isArray(manifest?.assets) ? manifest.assets : [];
151
+ for (const targetRelativePath of ['for-ai/ai-guide.md', 'for-ai/execution-protocol.md']) {
152
+ const asset = assets.find(item => item?.targetRelativePath === targetRelativePath);
153
+ const sourceRelativePath = typeof asset?.sourceRelativePath === 'string' ? asset.sourceRelativePath : '';
154
+ if (sourceRelativePath.includes('/en-US/')) {
155
+ return 'en-US';
156
+ }
157
+ if (sourceRelativePath.includes('/zh-CN/')) {
158
+ return 'zh-CN';
159
+ }
160
+ }
161
+ }
162
+ catch {
163
+ return null;
164
+ }
165
+ return null;
166
+ }
167
+ async readDocumentLanguageFromAiGuide(targetDir) {
168
+ const aiGuidePath = path.join(targetDir, 'for-ai', 'ai-guide.md');
169
+ if (!(await services_1.services.fileService.exists(aiGuidePath))) {
170
+ return null;
171
+ }
172
+ try {
173
+ const content = await services_1.services.fileService.readFile(aiGuidePath);
174
+ if (/[一-龥]/.test(content)) {
175
+ return 'zh-CN';
176
+ }
177
+ if (/[A-Za-z]/.test(content)) {
178
+ return 'en-US';
179
+ }
180
+ }
181
+ catch {
182
+ return null;
183
+ }
184
+ return null;
185
+ }
186
+ async ensureChangeNameAvailable(targetDir, featureName) {
187
+ const activeDir = PathUtils_1.PathUtils.getChangeDir(targetDir, constants_1.DIR_NAMES.ACTIVE, featureName);
188
+ const queuedDir = PathUtils_1.PathUtils.getChangeDir(targetDir, constants_1.DIR_NAMES.QUEUED, featureName);
189
+ const conflicts = [];
190
+ if (await services_1.services.fileService.exists(activeDir)) {
191
+ conflicts.push('changes/active');
192
+ }
193
+ if (await services_1.services.fileService.exists(queuedDir)) {
194
+ conflicts.push('changes/queued');
195
+ }
196
+ if (conflicts.length === 0) {
197
+ return;
198
+ }
199
+ throw new Error(`Change ${featureName} already exists in ${conflicts.join(' and ')}. Continue the existing change instead of creating a duplicate.`);
200
+ }
201
+ async writePluginArtifacts(featureDir, activatedSteps) {
202
+ const checkpointSteps = activatedSteps.filter(step => step === 'checkpoint_ui_review' || step === 'checkpoint_flow_check');
203
+ if (checkpointSteps.length > 0) {
204
+ const checkpointDir = path.join(featureDir, 'artifacts', 'checkpoint');
205
+ await services_1.services.fileService.ensureDir(checkpointDir);
206
+ await services_1.services.fileService.ensureDir(path.join(checkpointDir, 'screenshots'));
207
+ await services_1.services.fileService.ensureDir(path.join(checkpointDir, 'diffs'));
208
+ await services_1.services.fileService.ensureDir(path.join(checkpointDir, 'traces'));
209
+ await services_1.services.fileService.writeJSON(path.join(checkpointDir, 'gate.json'), {
210
+ plugin: 'checkpoint',
211
+ status: 'pending',
212
+ blocking: true,
213
+ executed_at: '',
214
+ steps: Object.fromEntries(checkpointSteps.map(step => [step, {
215
+ status: 'pending',
216
+ issues: [],
217
+ }])),
218
+ stitch_sync: {
219
+ attempted: false,
220
+ status: 'skipped',
221
+ message: '',
222
+ },
223
+ issues: [],
224
+ });
225
+ await services_1.services.fileService.writeJSON(path.join(checkpointDir, 'result.json'), {
226
+ plugin: 'checkpoint',
227
+ status: 'pending',
228
+ executed_at: '',
229
+ active_steps: checkpointSteps,
230
+ output: {},
231
+ });
232
+ await services_1.services.fileService.writeFile(path.join(checkpointDir, 'summary.md'), '# Checkpoint Summary\n\n- Status: pending\n- The checkpoint runner has not been executed yet.\n');
233
+ }
234
+ if (!activatedSteps.includes('stitch_design_review')) {
235
+ return;
236
+ }
237
+ const stitchDir = path.join(featureDir, 'artifacts', 'stitch');
238
+ await services_1.services.fileService.ensureDir(stitchDir);
239
+ await services_1.services.fileService.writeJSON(path.join(stitchDir, 'approval.json'), {
240
+ plugin: 'stitch',
241
+ capability: 'page_design_review',
242
+ step: 'stitch_design_review',
243
+ status: 'pending',
244
+ blocking: true,
245
+ preview_url: '',
246
+ submitted_at: '',
247
+ reviewed_at: '',
248
+ reviewer: '',
249
+ notes: '',
250
+ });
251
+ }
252
+ normalizeFlags(flags) {
253
+ if (!Array.isArray(flags)) {
254
+ return [];
255
+ }
256
+ return Array.from(new Set(flags
257
+ .map(flag => String(flag).trim())
258
+ .filter(Boolean)));
259
+ }
260
+ }
261
+ exports.NewCommand = NewCommand;
262
+ //# sourceMappingURL=NewCommand.js.map
@@ -0,0 +1,58 @@
1
+ import { BaseCommand } from './BaseCommand';
2
+ export declare class PluginsCommand extends BaseCommand {
3
+ execute(action: string, ...args: string[]): Promise<void>;
4
+ private listPlugins;
5
+ private showStatus;
6
+ private setPluginEnabled;
7
+ private doctorPlugin;
8
+ private doctorStitch;
9
+ private doctorCheckpoint;
10
+ private checkCommandAvailability;
11
+ private inspectGeminiCliStitch;
12
+ private runPlugin;
13
+ private runCheckpoint;
14
+ private runStitch;
15
+ private setPluginApproval;
16
+ private getChangeRuntimePaths;
17
+ private findProjectRoot;
18
+ private readVerification;
19
+ private syncVerificationOptionalStep;
20
+ private loadOrCreateStitchApproval;
21
+ private parseCheckpointRunnerOutput;
22
+ private normalizeCheckpointRunnerResult;
23
+ private buildCheckpointSummaryMarkdown;
24
+ private writeCheckpointArtifacts;
25
+ private syncCheckpointOptionalSteps;
26
+ private applyCheckpointStitchIntegration;
27
+ private parsePluginProjectArgs;
28
+ private isHttpUrl;
29
+ private ensureFileIfMissing;
30
+ private ensureGitkeep;
31
+ private ensureStitchWorkspaceScaffold;
32
+ private ensureCheckpointWorkspaceScaffold;
33
+ private resolveRunnerCommand;
34
+ private resolveReferencedPath;
35
+ private replaceRunnerTokens;
36
+ private parseStitchRunnerOutput;
37
+ private normalizeRunnerResult;
38
+ private extractStitchProjectRef;
39
+ private normalizeRunnerArtifacts;
40
+ private createDefaultCheckpointPluginConfig;
41
+ private createDefaultStitchPluginConfig;
42
+ private getDefaultCheckpointRunnerArgs;
43
+ private getDefaultRunnerArgs;
44
+ private getStitchProvider;
45
+ private getStitchGeminiConfig;
46
+ private getStitchCodexConfig;
47
+ private inspectCodexCliStitch;
48
+ private getGeminiModelCandidates;
49
+ private classifyStitchRunnerFailure;
50
+ private isGeminiModelFallbackEligible;
51
+ private getEffectiveStitchRunnerConfig;
52
+ private isBuiltInGeminiRunner;
53
+ private isBuiltInCodexRunner;
54
+ private getEffectiveCheckpointRunnerConfig;
55
+ private isBuiltInCheckpointRunner;
56
+ private getPluginEntries;
57
+ }
58
+ //# sourceMappingURL=PluginsCommand.d.ts.map