@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.
- package/.ospec/templates/hooks/post-merge +8 -0
- package/.ospec/templates/hooks/pre-commit +8 -0
- package/LICENSE +21 -0
- package/README.md +549 -0
- package/README.zh-CN.md +549 -0
- package/assets/for-ai/en-US/ai-guide.md +98 -0
- package/assets/for-ai/en-US/execution-protocol.md +64 -0
- package/assets/for-ai/zh-CN/ai-guide.md +102 -0
- package/assets/for-ai/zh-CN/execution-protocol.md +68 -0
- package/assets/git-hooks/post-merge +12 -0
- package/assets/git-hooks/pre-commit +12 -0
- package/assets/global-skills/claude/ospec-change/SKILL.md +116 -0
- package/assets/global-skills/codex/ospec-change/SKILL.md +117 -0
- package/assets/global-skills/codex/ospec-change/agents/openai.yaml +7 -0
- package/assets/global-skills/codex/ospec-change/skill.yaml +19 -0
- package/assets/project-conventions/en-US/development-guide.md +32 -0
- package/assets/project-conventions/en-US/naming-conventions.md +51 -0
- package/assets/project-conventions/en-US/skill-conventions.md +40 -0
- package/assets/project-conventions/en-US/workflow-conventions.md +70 -0
- package/assets/project-conventions/zh-CN/development-guide.md +32 -0
- package/assets/project-conventions/zh-CN/naming-conventions.md +51 -0
- package/assets/project-conventions/zh-CN/skill-conventions.md +40 -0
- package/assets/project-conventions/zh-CN/workflow-conventions.md +74 -0
- package/dist/adapters/codex-stitch-adapter.js +420 -0
- package/dist/adapters/gemini-stitch-adapter.js +408 -0
- package/dist/adapters/playwright-checkpoint-adapter.js +2260 -0
- package/dist/advanced/BatchOperations.d.ts +36 -0
- package/dist/advanced/BatchOperations.js +159 -0
- package/dist/advanced/CachingLayer.d.ts +66 -0
- package/dist/advanced/CachingLayer.js +136 -0
- package/dist/advanced/FeatureUpdater.d.ts +46 -0
- package/dist/advanced/FeatureUpdater.js +151 -0
- package/dist/advanced/PerformanceMonitor.d.ts +52 -0
- package/dist/advanced/PerformanceMonitor.js +129 -0
- package/dist/advanced/StatePersistence.d.ts +61 -0
- package/dist/advanced/StatePersistence.js +168 -0
- package/dist/advanced/index.d.ts +14 -0
- package/dist/advanced/index.js +22 -0
- package/dist/cli/commands/config.d.ts +5 -0
- package/dist/cli/commands/config.js +6 -0
- package/dist/cli/commands/feature.d.ts +5 -0
- package/dist/cli/commands/feature.js +6 -0
- package/dist/cli/commands/index.d.ts +5 -0
- package/dist/cli/commands/index.js +6 -0
- package/dist/cli/commands/project.d.ts +5 -0
- package/dist/cli/commands/project.js +6 -0
- package/dist/cli/commands/validate.d.ts +5 -0
- package/dist/cli/commands/validate.js +6 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +1007 -0
- package/dist/commands/ArchiveCommand.d.ts +14 -0
- package/dist/commands/ArchiveCommand.js +241 -0
- package/dist/commands/BaseCommand.d.ts +33 -0
- package/dist/commands/BaseCommand.js +46 -0
- package/dist/commands/BatchCommand.d.ts +5 -0
- package/dist/commands/BatchCommand.js +42 -0
- package/dist/commands/ChangesCommand.d.ts +3 -0
- package/dist/commands/ChangesCommand.js +71 -0
- package/dist/commands/DocsCommand.d.ts +5 -0
- package/dist/commands/DocsCommand.js +118 -0
- package/dist/commands/FinalizeCommand.d.ts +3 -0
- package/dist/commands/FinalizeCommand.js +24 -0
- package/dist/commands/IndexCommand.d.ts +5 -0
- package/dist/commands/IndexCommand.js +57 -0
- package/dist/commands/InitCommand.d.ts +5 -0
- package/dist/commands/InitCommand.js +65 -0
- package/dist/commands/NewCommand.d.ts +11 -0
- package/dist/commands/NewCommand.js +262 -0
- package/dist/commands/PluginsCommand.d.ts +58 -0
- package/dist/commands/PluginsCommand.js +2491 -0
- package/dist/commands/ProgressCommand.d.ts +5 -0
- package/dist/commands/ProgressCommand.js +103 -0
- package/dist/commands/QueueCommand.d.ts +10 -0
- package/dist/commands/QueueCommand.js +147 -0
- package/dist/commands/RunCommand.d.ts +13 -0
- package/dist/commands/RunCommand.js +200 -0
- package/dist/commands/SkillCommand.d.ts +31 -0
- package/dist/commands/SkillCommand.js +1216 -0
- package/dist/commands/SkillsCommand.d.ts +5 -0
- package/dist/commands/SkillsCommand.js +68 -0
- package/dist/commands/StatusCommand.d.ts +6 -0
- package/dist/commands/StatusCommand.js +140 -0
- package/dist/commands/UpdateCommand.d.ts +8 -0
- package/dist/commands/UpdateCommand.js +251 -0
- package/dist/commands/VerifyCommand.d.ts +5 -0
- package/dist/commands/VerifyCommand.js +278 -0
- package/dist/commands/WorkflowCommand.d.ts +12 -0
- package/dist/commands/WorkflowCommand.js +150 -0
- package/dist/commands/index.d.ts +43 -0
- package/dist/commands/index.js +85 -0
- package/dist/core/constants.d.ts +41 -0
- package/dist/core/constants.js +73 -0
- package/dist/core/errors.d.ts +36 -0
- package/dist/core/errors.js +72 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +23 -0
- package/dist/core/types.d.ts +369 -0
- package/dist/core/types.js +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +27 -0
- package/dist/presets/ProjectPresets.d.ts +41 -0
- package/dist/presets/ProjectPresets.js +190 -0
- package/dist/scaffolds/ProjectScaffoldPresets.d.ts +20 -0
- package/dist/scaffolds/ProjectScaffoldPresets.js +151 -0
- package/dist/services/ConfigManager.d.ts +14 -0
- package/dist/services/ConfigManager.js +386 -0
- package/dist/services/FeatureManager.d.ts +5 -0
- package/dist/services/FeatureManager.js +6 -0
- package/dist/services/FileService.d.ts +21 -0
- package/dist/services/FileService.js +152 -0
- package/dist/services/IndexBuilder.d.ts +12 -0
- package/dist/services/IndexBuilder.js +130 -0
- package/dist/services/Logger.d.ts +20 -0
- package/dist/services/Logger.js +48 -0
- package/dist/services/ProjectAssetRegistry.d.ts +12 -0
- package/dist/services/ProjectAssetRegistry.js +96 -0
- package/dist/services/ProjectAssetService.d.ts +49 -0
- package/dist/services/ProjectAssetService.js +223 -0
- package/dist/services/ProjectScaffoldCommandService.d.ts +73 -0
- package/dist/services/ProjectScaffoldCommandService.js +159 -0
- package/dist/services/ProjectScaffoldService.d.ts +44 -0
- package/dist/services/ProjectScaffoldService.js +507 -0
- package/dist/services/ProjectService.d.ts +209 -0
- package/dist/services/ProjectService.js +13239 -0
- package/dist/services/QueueService.d.ts +17 -0
- package/dist/services/QueueService.js +142 -0
- package/dist/services/RunService.d.ts +40 -0
- package/dist/services/RunService.js +420 -0
- package/dist/services/SkillParser.d.ts +30 -0
- package/dist/services/SkillParser.js +88 -0
- package/dist/services/StateManager.d.ts +16 -0
- package/dist/services/StateManager.js +127 -0
- package/dist/services/TemplateEngine.d.ts +43 -0
- package/dist/services/TemplateEngine.js +119 -0
- package/dist/services/TemplateGenerator.d.ts +40 -0
- package/dist/services/TemplateGenerator.js +273 -0
- package/dist/services/ValidationService.d.ts +19 -0
- package/dist/services/ValidationService.js +44 -0
- package/dist/services/Validator.d.ts +5 -0
- package/dist/services/Validator.js +6 -0
- package/dist/services/index.d.ts +52 -0
- package/dist/services/index.js +91 -0
- package/dist/services/templates/ExecutionTemplateBuilder.d.ts +12 -0
- package/dist/services/templates/ExecutionTemplateBuilder.js +300 -0
- package/dist/services/templates/ProjectTemplateBuilder.d.ts +38 -0
- package/dist/services/templates/ProjectTemplateBuilder.js +1897 -0
- package/dist/services/templates/TemplateBuilderBase.d.ts +19 -0
- package/dist/services/templates/TemplateBuilderBase.js +60 -0
- package/dist/services/templates/TemplateInputFactory.d.ts +16 -0
- package/dist/services/templates/TemplateInputFactory.js +298 -0
- package/dist/services/templates/templateTypes.d.ts +90 -0
- package/dist/services/templates/templateTypes.js +3 -0
- package/dist/tools/build-index.js +632 -0
- package/dist/utils/DateUtils.d.ts +18 -0
- package/dist/utils/DateUtils.js +40 -0
- package/dist/utils/PathUtils.d.ts +9 -0
- package/dist/utils/PathUtils.js +66 -0
- package/dist/utils/StringUtils.d.ts +26 -0
- package/dist/utils/StringUtils.js +47 -0
- package/dist/utils/helpers.d.ts +5 -0
- package/dist/utils/helpers.js +6 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +23 -0
- package/dist/utils/logger.d.ts +5 -0
- package/dist/utils/logger.js +6 -0
- package/dist/utils/path.d.ts +5 -0
- package/dist/utils/path.js +6 -0
- package/dist/utils/subcommandHelp.d.ts +11 -0
- package/dist/utils/subcommandHelp.js +119 -0
- package/dist/workflow/ArchiveGate.d.ts +30 -0
- package/dist/workflow/ArchiveGate.js +93 -0
- package/dist/workflow/ConfigurableWorkflow.d.ts +89 -0
- package/dist/workflow/ConfigurableWorkflow.js +186 -0
- package/dist/workflow/HookSystem.d.ts +38 -0
- package/dist/workflow/HookSystem.js +66 -0
- package/dist/workflow/IndexRegenerator.d.ts +49 -0
- package/dist/workflow/IndexRegenerator.js +147 -0
- package/dist/workflow/PluginWorkflowComposer.d.ts +138 -0
- package/dist/workflow/PluginWorkflowComposer.js +239 -0
- package/dist/workflow/SkillUpdateEngine.d.ts +26 -0
- package/dist/workflow/SkillUpdateEngine.js +113 -0
- package/dist/workflow/VerificationSystem.d.ts +24 -0
- package/dist/workflow/VerificationSystem.js +116 -0
- package/dist/workflow/WorkflowEngine.d.ts +15 -0
- package/dist/workflow/WorkflowEngine.js +57 -0
- package/dist/workflow/index.d.ts +19 -0
- package/dist/workflow/index.js +32 -0
- package/package.json +78 -0
- package/scripts/postinstall.js +43 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 可配置工作流系统
|
|
4
|
+
* 基于 OSpec 官方规范实现
|
|
5
|
+
* 支持核心步骤 + 可选步骤 + Feature Flags
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ConfigurableWorkflow = exports.WORKFLOW_PRESETS = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* 3种预定义工作流模板
|
|
11
|
+
*/
|
|
12
|
+
exports.WORKFLOW_PRESETS = {
|
|
13
|
+
lite: {
|
|
14
|
+
core_required: ['proposal', 'tasks', 'state', 'verification', 'skill_update', 'index_regenerated'],
|
|
15
|
+
optional_steps: {
|
|
16
|
+
code_review: { enabled: true, when: ['high_risk', 'multi_file_change'] },
|
|
17
|
+
design_doc: { enabled: false, when: [] },
|
|
18
|
+
plan_doc: { enabled: false, when: [] },
|
|
19
|
+
security_review: { enabled: false, when: [] },
|
|
20
|
+
adr: { enabled: false, when: [] },
|
|
21
|
+
db_change_doc: { enabled: false, when: [] },
|
|
22
|
+
api_change_doc: { enabled: false, when: [] },
|
|
23
|
+
},
|
|
24
|
+
archive_gate: {
|
|
25
|
+
require_verification: true,
|
|
26
|
+
require_skill_update: true,
|
|
27
|
+
require_index_regenerated: true,
|
|
28
|
+
require_optional_steps_passed: true,
|
|
29
|
+
},
|
|
30
|
+
feature_flags: {
|
|
31
|
+
supported: ['high_risk', 'multi_file_change'],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
standard: {
|
|
35
|
+
core_required: ['proposal', 'tasks', 'state', 'verification', 'skill_update', 'index_regenerated'],
|
|
36
|
+
optional_steps: {
|
|
37
|
+
code_review: { enabled: true, when: ['high_risk', 'multi_file_change'] },
|
|
38
|
+
design_doc: { enabled: true, when: ['cross_module', 'complex_feature'] },
|
|
39
|
+
plan_doc: { enabled: true, when: ['large_feature', 'multi_phase'] },
|
|
40
|
+
security_review: { enabled: true, when: ['security_related', 'auth', 'payment'] },
|
|
41
|
+
adr: { enabled: false, when: [] },
|
|
42
|
+
db_change_doc: { enabled: false, when: [] },
|
|
43
|
+
api_change_doc: { enabled: true, when: ['public_api_change'] },
|
|
44
|
+
},
|
|
45
|
+
archive_gate: {
|
|
46
|
+
require_verification: true,
|
|
47
|
+
require_skill_update: true,
|
|
48
|
+
require_index_regenerated: true,
|
|
49
|
+
require_optional_steps_passed: true,
|
|
50
|
+
},
|
|
51
|
+
feature_flags: {
|
|
52
|
+
supported: [
|
|
53
|
+
'cross_module', 'complex_feature', 'large_feature', 'multi_phase',
|
|
54
|
+
'high_risk', 'multi_file_change', 'security_related', 'auth', 'payment', 'public_api_change',
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
full: {
|
|
59
|
+
core_required: ['proposal', 'tasks', 'state', 'verification', 'skill_update', 'index_regenerated'],
|
|
60
|
+
optional_steps: {
|
|
61
|
+
code_review: { enabled: true, when: ['high_risk', 'cross_module', 'multi_file_change'] },
|
|
62
|
+
design_doc: { enabled: true, when: ['cross_module', 'complex_feature', 'architecture_change'] },
|
|
63
|
+
plan_doc: { enabled: true, when: ['large_feature', 'multi_phase', 'important_decision'] },
|
|
64
|
+
security_review: { enabled: true, when: ['security_related', 'auth', 'payment', 'external_api'] },
|
|
65
|
+
adr: { enabled: true, when: ['architecture_change', 'important_decision'] },
|
|
66
|
+
db_change_doc: { enabled: true, when: ['db_schema_change'] },
|
|
67
|
+
api_change_doc: { enabled: true, when: ['public_api_change'] },
|
|
68
|
+
},
|
|
69
|
+
archive_gate: {
|
|
70
|
+
require_verification: true,
|
|
71
|
+
require_skill_update: true,
|
|
72
|
+
require_index_regenerated: true,
|
|
73
|
+
require_optional_steps_passed: true,
|
|
74
|
+
},
|
|
75
|
+
feature_flags: {
|
|
76
|
+
supported: [
|
|
77
|
+
'cross_module', 'complex_feature', 'large_feature', 'multi_phase',
|
|
78
|
+
'architecture_change', 'important_decision', 'multi_file_change',
|
|
79
|
+
'security_related', 'auth', 'payment', 'external_api',
|
|
80
|
+
'db_schema_change', 'public_api_change', 'high_risk',
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
class ConfigurableWorkflow {
|
|
86
|
+
constructor(mode) {
|
|
87
|
+
this.mode = mode;
|
|
88
|
+
this.config = exports.WORKFLOW_PRESETS[mode];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 根据 feature flags 确定激活的可选步骤
|
|
92
|
+
*/
|
|
93
|
+
getActivatedSteps(featureFlags) {
|
|
94
|
+
const activated = [];
|
|
95
|
+
for (const [stepName, stepConfig] of Object.entries(this.config.optional_steps)) {
|
|
96
|
+
if (!stepConfig.enabled)
|
|
97
|
+
continue;
|
|
98
|
+
// 检查 feature flags 与 step.when 是否有交集
|
|
99
|
+
const hasMatch = stepConfig.when.some(flag => featureFlags.includes(flag));
|
|
100
|
+
if (hasMatch) {
|
|
101
|
+
activated.push(stepName);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return activated;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 获取完整的工作流步骤(核心 + 激活的可选)
|
|
108
|
+
*/
|
|
109
|
+
getFullWorkflow(featureFlags) {
|
|
110
|
+
const activated = this.getActivatedSteps(featureFlags);
|
|
111
|
+
return [...this.config.core_required, ...activated];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 获取核心步骤
|
|
115
|
+
*/
|
|
116
|
+
getCoreSteps() {
|
|
117
|
+
return this.config.core_required;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 获取所有支持的 feature flags
|
|
121
|
+
*/
|
|
122
|
+
getSupportedFlags() {
|
|
123
|
+
return this.config.feature_flags.supported;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 验证 feature flags
|
|
127
|
+
*/
|
|
128
|
+
validateFlags(flags) {
|
|
129
|
+
const supported = new Set(this.config.feature_flags.supported);
|
|
130
|
+
const unsupported = flags.filter(flag => !supported.has(flag));
|
|
131
|
+
return {
|
|
132
|
+
valid: unsupported.length === 0,
|
|
133
|
+
unsupported,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 获取步骤的依赖关系
|
|
138
|
+
*/
|
|
139
|
+
getStepDependencies(step) {
|
|
140
|
+
const dependencies = {
|
|
141
|
+
code_review: ['verify'],
|
|
142
|
+
design_doc: ['proposal'],
|
|
143
|
+
plan_doc: ['proposal'],
|
|
144
|
+
security_review: ['verify'],
|
|
145
|
+
adr: ['proposal'],
|
|
146
|
+
db_change_doc: ['verify'],
|
|
147
|
+
api_change_doc: ['verify'],
|
|
148
|
+
};
|
|
149
|
+
return dependencies[step] || [];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 获取工作流配置
|
|
153
|
+
*/
|
|
154
|
+
getConfig() {
|
|
155
|
+
return this.config;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 获取存档门禁配置
|
|
159
|
+
*/
|
|
160
|
+
getArchiveGate() {
|
|
161
|
+
return this.config.archive_gate;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 生成工作流摘要
|
|
165
|
+
*/
|
|
166
|
+
getSummary(featureFlags) {
|
|
167
|
+
const activated = this.getActivatedSteps(featureFlags);
|
|
168
|
+
const validation = this.validateFlags(featureFlags);
|
|
169
|
+
return {
|
|
170
|
+
mode: this.mode,
|
|
171
|
+
coreSteps: this.config.core_required.length,
|
|
172
|
+
optionalSteps: activated,
|
|
173
|
+
totalSteps: this.config.core_required.length + activated.length,
|
|
174
|
+
flags: featureFlags,
|
|
175
|
+
unsupportedFlags: validation.unsupported,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* 获取当前模式
|
|
180
|
+
*/
|
|
181
|
+
getMode() {
|
|
182
|
+
return this.mode;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.ConfigurableWorkflow = ConfigurableWorkflow;
|
|
186
|
+
//# sourceMappingURL=ConfigurableWorkflow.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 钩子系统
|
|
3
|
+
* 执行工作流前后的回调
|
|
4
|
+
*/
|
|
5
|
+
export type HookEvent = 'pre-init' | 'post-init' | 'pre-new' | 'post-new' | 'pre-verify' | 'post-verify' | 'pre-archive' | 'post-archive' | 'pre-commit' | 'post-merge';
|
|
6
|
+
export interface Hook {
|
|
7
|
+
event: HookEvent;
|
|
8
|
+
handler: (context: any) => Promise<void> | void;
|
|
9
|
+
priority?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class HookSystem {
|
|
12
|
+
private hooks;
|
|
13
|
+
/**
|
|
14
|
+
* 注册钩子
|
|
15
|
+
*/
|
|
16
|
+
register(event: HookEvent, handler: (context: any) => Promise<void> | void, priority?: number): void;
|
|
17
|
+
/**
|
|
18
|
+
* 执行钩子
|
|
19
|
+
*/
|
|
20
|
+
execute(event: HookEvent, context?: any): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* 移除钩子
|
|
23
|
+
*/
|
|
24
|
+
unregister(event: HookEvent, handler: (context: any) => Promise<void> | void): void;
|
|
25
|
+
/**
|
|
26
|
+
* 清空所有钩子
|
|
27
|
+
*/
|
|
28
|
+
clear(): void;
|
|
29
|
+
/**
|
|
30
|
+
* 获取已注册的钩子列表
|
|
31
|
+
*/
|
|
32
|
+
getHooks(event?: HookEvent): {
|
|
33
|
+
event: HookEvent;
|
|
34
|
+
count: number;
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
export declare const hookSystem: HookSystem;
|
|
38
|
+
//# sourceMappingURL=HookSystem.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 钩子系统
|
|
4
|
+
* 执行工作流前后的回调
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.hookSystem = exports.HookSystem = void 0;
|
|
8
|
+
class HookSystem {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.hooks = new Map();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 注册钩子
|
|
14
|
+
*/
|
|
15
|
+
register(event, handler, priority = 0) {
|
|
16
|
+
if (!this.hooks.has(event)) {
|
|
17
|
+
this.hooks.set(event, []);
|
|
18
|
+
}
|
|
19
|
+
const hookList = this.hooks.get(event);
|
|
20
|
+
hookList.push({ event, handler, priority });
|
|
21
|
+
// 按优先级排序(降序)
|
|
22
|
+
hookList.sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 执行钩子
|
|
26
|
+
*/
|
|
27
|
+
async execute(event, context = {}) {
|
|
28
|
+
const hookList = this.hooks.get(event) || [];
|
|
29
|
+
for (const hook of hookList) {
|
|
30
|
+
await Promise.resolve(hook.handler(context));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 移除钩子
|
|
35
|
+
*/
|
|
36
|
+
unregister(event, handler) {
|
|
37
|
+
if (!this.hooks.has(event))
|
|
38
|
+
return;
|
|
39
|
+
const hookList = this.hooks.get(event);
|
|
40
|
+
const index = hookList.findIndex(h => h.handler === handler);
|
|
41
|
+
if (index >= 0) {
|
|
42
|
+
hookList.splice(index, 1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 清空所有钩子
|
|
47
|
+
*/
|
|
48
|
+
clear() {
|
|
49
|
+
this.hooks.clear();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 获取已注册的钩子列表
|
|
53
|
+
*/
|
|
54
|
+
getHooks(event) {
|
|
55
|
+
if (event) {
|
|
56
|
+
const count = this.hooks.get(event)?.length || 0;
|
|
57
|
+
return [{ event, count }];
|
|
58
|
+
}
|
|
59
|
+
return Array.from(this.hooks.entries())
|
|
60
|
+
.map(([event, hooks]) => ({ event, count: hooks.length }))
|
|
61
|
+
.filter(h => h.count > 0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.HookSystem = HookSystem;
|
|
65
|
+
exports.hookSystem = new HookSystem();
|
|
66
|
+
//# sourceMappingURL=HookSystem.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 索引再生成引擎
|
|
3
|
+
* 重新生成项目的功能索引
|
|
4
|
+
*/
|
|
5
|
+
export interface IndexEntry {
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
status: string;
|
|
9
|
+
lastUpdated: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface ProjectIndex {
|
|
13
|
+
version: string;
|
|
14
|
+
generated: string;
|
|
15
|
+
features: IndexEntry[];
|
|
16
|
+
stats: {
|
|
17
|
+
total: number;
|
|
18
|
+
draft: number;
|
|
19
|
+
active: number;
|
|
20
|
+
completed: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare class IndexRegenerator {
|
|
24
|
+
/**
|
|
25
|
+
* 生成完整索引
|
|
26
|
+
*/
|
|
27
|
+
regenerateIndex(projectDir: string): Promise<ProjectIndex>;
|
|
28
|
+
/**
|
|
29
|
+
* 保存索引文件
|
|
30
|
+
*/
|
|
31
|
+
private saveIndex;
|
|
32
|
+
/**
|
|
33
|
+
* 读取现有索引
|
|
34
|
+
*/
|
|
35
|
+
readIndex(projectDir: string): Promise<ProjectIndex | null>;
|
|
36
|
+
/**
|
|
37
|
+
* 获取索引统计
|
|
38
|
+
*/
|
|
39
|
+
getIndexStats(projectDir: string): Promise<ProjectIndex['stats']>;
|
|
40
|
+
/**
|
|
41
|
+
* 验证索引完整性
|
|
42
|
+
*/
|
|
43
|
+
validateIndex(projectDir: string): Promise<{
|
|
44
|
+
valid: boolean;
|
|
45
|
+
errors: string[];
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export declare const indexRegenerator: IndexRegenerator;
|
|
49
|
+
//# sourceMappingURL=IndexRegenerator.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 索引再生成引擎
|
|
4
|
+
* 重新生成项目的功能索引
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.indexRegenerator = exports.IndexRegenerator = void 0;
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const services_1 = require("../services");
|
|
43
|
+
const constants_1 = require("../core/constants");
|
|
44
|
+
class IndexRegenerator {
|
|
45
|
+
/**
|
|
46
|
+
* 生成完整索引
|
|
47
|
+
*/
|
|
48
|
+
async regenerateIndex(projectDir) {
|
|
49
|
+
const featuresDir = path.join(projectDir, 'features');
|
|
50
|
+
const features = [];
|
|
51
|
+
try {
|
|
52
|
+
const featureFolders = await services_1.services.fileService.readDir(featuresDir);
|
|
53
|
+
for (const featureName of featureFolders) {
|
|
54
|
+
const featurePath = path.join(featuresDir, featureName);
|
|
55
|
+
const stat = await services_1.services.fileService.stat(featurePath);
|
|
56
|
+
if (!stat.isDirectory())
|
|
57
|
+
continue;
|
|
58
|
+
try {
|
|
59
|
+
const statePath = path.join(featurePath, constants_1.FILE_NAMES.STATE);
|
|
60
|
+
const state = await services_1.services.fileService.readJSON(statePath);
|
|
61
|
+
features.push({
|
|
62
|
+
name: featureName,
|
|
63
|
+
path: featurePath,
|
|
64
|
+
status: state.status || 'unknown',
|
|
65
|
+
lastUpdated: state.last_updated || new Date().toISOString(),
|
|
66
|
+
tags: state.tags || [],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
// 如果没有状态文件,跳过
|
|
71
|
+
services_1.services.logger.warn(`No state file for feature: ${featureName}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
services_1.services.logger.warn(`Features directory not found: ${featuresDir}`);
|
|
77
|
+
}
|
|
78
|
+
// 生成统计数据
|
|
79
|
+
const stats = {
|
|
80
|
+
total: features.length,
|
|
81
|
+
draft: features.filter(f => f.status === 'draft').length,
|
|
82
|
+
active: features.filter(f => f.status === 'active').length,
|
|
83
|
+
completed: features.filter(f => f.status === 'completed').length,
|
|
84
|
+
};
|
|
85
|
+
const index = {
|
|
86
|
+
version: '1.0',
|
|
87
|
+
generated: new Date().toISOString(),
|
|
88
|
+
features: features.sort((a, b) => a.name.localeCompare(b.name)),
|
|
89
|
+
stats,
|
|
90
|
+
};
|
|
91
|
+
// 保存索引文件
|
|
92
|
+
await this.saveIndex(projectDir, index);
|
|
93
|
+
return index;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 保存索引文件
|
|
97
|
+
*/
|
|
98
|
+
async saveIndex(projectDir, index) {
|
|
99
|
+
const indexPath = path.join(projectDir, constants_1.FILE_NAMES.INDEX);
|
|
100
|
+
await services_1.services.fileService.writeJSON(indexPath, index);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 读取现有索引
|
|
104
|
+
*/
|
|
105
|
+
async readIndex(projectDir) {
|
|
106
|
+
try {
|
|
107
|
+
const indexPath = path.join(projectDir, constants_1.FILE_NAMES.INDEX);
|
|
108
|
+
return await services_1.services.fileService.readJSON(indexPath);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 获取索引统计
|
|
116
|
+
*/
|
|
117
|
+
async getIndexStats(projectDir) {
|
|
118
|
+
const index = await this.readIndex(projectDir);
|
|
119
|
+
return index?.stats || { total: 0, draft: 0, active: 0, completed: 0 };
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 验证索引完整性
|
|
123
|
+
*/
|
|
124
|
+
async validateIndex(projectDir) {
|
|
125
|
+
const index = await this.readIndex(projectDir);
|
|
126
|
+
const errors = [];
|
|
127
|
+
if (!index) {
|
|
128
|
+
errors.push('Index file not found');
|
|
129
|
+
return { valid: false, errors };
|
|
130
|
+
}
|
|
131
|
+
// 验证所有条目
|
|
132
|
+
for (const entry of index.features) {
|
|
133
|
+
const statePath = path.join(entry.path, constants_1.FILE_NAMES.STATE);
|
|
134
|
+
const exists = await services_1.services.fileService.exists(statePath);
|
|
135
|
+
if (!exists) {
|
|
136
|
+
errors.push(`State file missing for feature: ${entry.name}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
valid: errors.length === 0,
|
|
141
|
+
errors,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.IndexRegenerator = IndexRegenerator;
|
|
146
|
+
exports.indexRegenerator = new IndexRegenerator();
|
|
147
|
+
//# sourceMappingURL=IndexRegenerator.js.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { SkillrcConfig } from '../core/types';
|
|
2
|
+
export declare const DEFAULT_STITCH_PLUGIN_CONFIG: {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
blocking: boolean;
|
|
5
|
+
project: {
|
|
6
|
+
project_id: string;
|
|
7
|
+
project_url: string;
|
|
8
|
+
save_on_first_run: boolean;
|
|
9
|
+
enforce_single_project: boolean;
|
|
10
|
+
};
|
|
11
|
+
gemini: {
|
|
12
|
+
model: string;
|
|
13
|
+
auto_switch_on_limit: boolean;
|
|
14
|
+
save_on_fallback: boolean;
|
|
15
|
+
};
|
|
16
|
+
codex: {
|
|
17
|
+
model: string;
|
|
18
|
+
mcp_server: string;
|
|
19
|
+
};
|
|
20
|
+
runner: {
|
|
21
|
+
mode: string;
|
|
22
|
+
command: string;
|
|
23
|
+
args: string[];
|
|
24
|
+
cwd: string;
|
|
25
|
+
timeout_ms: number;
|
|
26
|
+
token_env: string;
|
|
27
|
+
extra_env: {};
|
|
28
|
+
};
|
|
29
|
+
provider: string;
|
|
30
|
+
capabilities: {
|
|
31
|
+
page_design_review: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
step: string;
|
|
34
|
+
activate_when_flags: string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const DEFAULT_CHECKPOINT_PLUGIN_CONFIG: {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
blocking: boolean;
|
|
41
|
+
runtime: {
|
|
42
|
+
base_url: string;
|
|
43
|
+
startup: {
|
|
44
|
+
command: string;
|
|
45
|
+
args: never[];
|
|
46
|
+
cwd: string;
|
|
47
|
+
timeout_ms: number;
|
|
48
|
+
};
|
|
49
|
+
readiness: {
|
|
50
|
+
type: string;
|
|
51
|
+
url: string;
|
|
52
|
+
timeout_ms: number;
|
|
53
|
+
};
|
|
54
|
+
shutdown: {
|
|
55
|
+
command: string;
|
|
56
|
+
args: never[];
|
|
57
|
+
cwd: string;
|
|
58
|
+
timeout_ms: number;
|
|
59
|
+
};
|
|
60
|
+
storage_state: string;
|
|
61
|
+
};
|
|
62
|
+
runner: {
|
|
63
|
+
mode: string;
|
|
64
|
+
command: string;
|
|
65
|
+
args: string[];
|
|
66
|
+
cwd: string;
|
|
67
|
+
timeout_ms: number;
|
|
68
|
+
token_env: string;
|
|
69
|
+
extra_env: {};
|
|
70
|
+
};
|
|
71
|
+
capabilities: {
|
|
72
|
+
ui_review: {
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
step: string;
|
|
75
|
+
activate_when_flags: string[];
|
|
76
|
+
};
|
|
77
|
+
flow_check: {
|
|
78
|
+
enabled: boolean;
|
|
79
|
+
step: string;
|
|
80
|
+
activate_when_flags: string[];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
stitch_integration: {
|
|
84
|
+
enabled: boolean;
|
|
85
|
+
auto_pass_stitch_review: boolean;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export interface EnabledPluginSummary {
|
|
89
|
+
name: string;
|
|
90
|
+
blocking: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface PluginCapabilitySummary {
|
|
93
|
+
plugin: string;
|
|
94
|
+
capability: string;
|
|
95
|
+
step: string;
|
|
96
|
+
activateWhenFlags: string[];
|
|
97
|
+
blocking: boolean;
|
|
98
|
+
}
|
|
99
|
+
export declare class PluginWorkflowComposer {
|
|
100
|
+
private config;
|
|
101
|
+
constructor(config: SkillrcConfig);
|
|
102
|
+
private getBaseConfig;
|
|
103
|
+
getCoreSteps(): string[];
|
|
104
|
+
getBaseOptionalSteps(): Record<string, {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
when: string[];
|
|
107
|
+
}>;
|
|
108
|
+
getActivatedBaseSteps(featureFlags: string[]): string[];
|
|
109
|
+
getEnabledPlugins(): EnabledPluginSummary[];
|
|
110
|
+
getStitchCapabilities(): PluginCapabilitySummary[];
|
|
111
|
+
getCheckpointCapabilities(): PluginCapabilitySummary[];
|
|
112
|
+
getPluginCapabilities(): PluginCapabilitySummary[];
|
|
113
|
+
getPluginContributedSteps(): string[];
|
|
114
|
+
getActivatedPluginSteps(featureFlags: string[]): string[];
|
|
115
|
+
getActivatedSteps(featureFlags: string[]): string[];
|
|
116
|
+
getSupportedFlags(): string[];
|
|
117
|
+
getArchiveGate(): {
|
|
118
|
+
require_verification: boolean;
|
|
119
|
+
require_skill_update: boolean;
|
|
120
|
+
require_index_regenerated: boolean;
|
|
121
|
+
require_optional_steps_passed: boolean;
|
|
122
|
+
};
|
|
123
|
+
validateFlags(flags: string[]): {
|
|
124
|
+
valid: boolean;
|
|
125
|
+
unsupported: string[];
|
|
126
|
+
};
|
|
127
|
+
getSummary(featureFlags: string[]): {
|
|
128
|
+
mode: string;
|
|
129
|
+
coreSteps: number;
|
|
130
|
+
optionalSteps: string[];
|
|
131
|
+
pluginSteps: string[];
|
|
132
|
+
totalSteps: number;
|
|
133
|
+
enabledPlugins: string[];
|
|
134
|
+
flags: string[];
|
|
135
|
+
unsupportedFlags: string[];
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=PluginWorkflowComposer.d.ts.map
|