@specpow/framework 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +307 -0
- package/LICENSE +21 -0
- package/README.md +557 -0
- package/agents/controller/sdd-controller.md +55 -0
- package/agents/execution/java-codegen-agent.md +39 -0
- package/agents/execution/ui-codegen-agent.md +32 -0
- package/agents/ops/deploy-agent.md +181 -0
- package/agents/planning/db-designer-agent.md +30 -0
- package/agents/planning/prd-agent.md +31 -0
- package/agents/quality/review-agent.md +36 -0
- package/agents/quality/test-agent.md +33 -0
- package/bin/specpow.js +10 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +444 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/apply.d.ts +14 -0
- package/dist/commands/apply.d.ts.map +1 -0
- package/dist/commands/apply.js +195 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/archive.d.ts +30 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/archive.js +141 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/channel.d.ts +61 -0
- package/dist/commands/channel.d.ts.map +1 -0
- package/dist/commands/channel.js +613 -0
- package/dist/commands/channel.js.map +1 -0
- package/dist/commands/config.d.ts +40 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +130 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/debug.d.ts +45 -0
- package/dist/commands/debug.d.ts.map +1 -0
- package/dist/commands/debug.js +167 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/doctor.d.ts +20 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +121 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/execute.d.ts +25 -0
- package/dist/commands/execute.d.ts.map +1 -0
- package/dist/commands/execute.js +120 -0
- package/dist/commands/execute.js.map +1 -0
- package/dist/commands/explore.d.ts +71 -0
- package/dist/commands/explore.d.ts.map +1 -0
- package/dist/commands/explore.js +481 -0
- package/dist/commands/explore.js.map +1 -0
- package/dist/commands/init.d.ts +20 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +146 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/memory.d.ts +32 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +455 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/propose.d.ts +13 -0
- package/dist/commands/propose.d.ts.map +1 -0
- package/dist/commands/propose.js +193 -0
- package/dist/commands/propose.js.map +1 -0
- package/dist/commands/review.d.ts +50 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +198 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/schema.d.ts +22 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +79 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/status.d.ts +11 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +130 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/store.d.ts +31 -0
- package/dist/commands/store.d.ts.map +1 -0
- package/dist/commands/store.js +109 -0
- package/dist/commands/store.js.map +1 -0
- package/dist/commands/update.d.ts +42 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +239 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/verify.d.ts +39 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +386 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/workflow/index.d.ts +12 -0
- package/dist/commands/workflow/index.d.ts.map +1 -0
- package/dist/commands/workflow/index.js +435 -0
- package/dist/commands/workflow/index.js.map +1 -0
- package/dist/core/agent-contract.d.ts +133 -0
- package/dist/core/agent-contract.d.ts.map +1 -0
- package/dist/core/agent-contract.js +71 -0
- package/dist/core/agent-contract.js.map +1 -0
- package/dist/core/archive/delta-merger.d.ts +101 -0
- package/dist/core/archive/delta-merger.d.ts.map +1 -0
- package/dist/core/archive/delta-merger.js +398 -0
- package/dist/core/archive/delta-merger.js.map +1 -0
- package/dist/core/archive/delta-parser.d.ts +48 -0
- package/dist/core/archive/delta-parser.d.ts.map +1 -0
- package/dist/core/archive/delta-parser.js +193 -0
- package/dist/core/archive/delta-parser.js.map +1 -0
- package/dist/core/archive/engine.d.ts +136 -0
- package/dist/core/archive/engine.d.ts.map +1 -0
- package/dist/core/archive/engine.js +506 -0
- package/dist/core/archive/engine.js.map +1 -0
- package/dist/core/archive/index.d.ts +11 -0
- package/dist/core/archive/index.d.ts.map +1 -0
- package/dist/core/archive/index.js +9 -0
- package/dist/core/archive/index.js.map +1 -0
- package/dist/core/artifact-graph/graph.d.ts +48 -0
- package/dist/core/artifact-graph/graph.d.ts.map +1 -0
- package/dist/core/artifact-graph/graph.js +170 -0
- package/dist/core/artifact-graph/graph.js.map +1 -0
- package/dist/core/artifact-graph/index.d.ts +13 -0
- package/dist/core/artifact-graph/index.d.ts.map +1 -0
- package/dist/core/artifact-graph/index.js +12 -0
- package/dist/core/artifact-graph/index.js.map +1 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +60 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts.map +1 -0
- package/dist/core/artifact-graph/instruction-loader.js +166 -0
- package/dist/core/artifact-graph/instruction-loader.js.map +1 -0
- package/dist/core/artifact-graph/outputs.d.ts +17 -0
- package/dist/core/artifact-graph/outputs.d.ts.map +1 -0
- package/dist/core/artifact-graph/outputs.js +27 -0
- package/dist/core/artifact-graph/outputs.js.map +1 -0
- package/dist/core/artifact-graph/resolver.d.ts +34 -0
- package/dist/core/artifact-graph/resolver.d.ts.map +1 -0
- package/dist/core/artifact-graph/resolver.js +99 -0
- package/dist/core/artifact-graph/resolver.js.map +1 -0
- package/dist/core/artifact-graph/state.d.ts +54 -0
- package/dist/core/artifact-graph/state.d.ts.map +1 -0
- package/dist/core/artifact-graph/state.js +149 -0
- package/dist/core/artifact-graph/state.js.map +1 -0
- package/dist/core/artifact-graph/types.d.ts +151 -0
- package/dist/core/artifact-graph/types.d.ts.map +1 -0
- package/dist/core/artifact-graph/types.js +44 -0
- package/dist/core/artifact-graph/types.js.map +1 -0
- package/dist/core/channel/channel-event-log.d.ts +81 -0
- package/dist/core/channel/channel-event-log.d.ts.map +1 -0
- package/dist/core/channel/channel-event-log.js +177 -0
- package/dist/core/channel/channel-event-log.js.map +1 -0
- package/dist/core/channel/channel-inbox.d.ts +70 -0
- package/dist/core/channel/channel-inbox.d.ts.map +1 -0
- package/dist/core/channel/channel-inbox.js +122 -0
- package/dist/core/channel/channel-inbox.js.map +1 -0
- package/dist/core/channel/channel-runtime.d.ts +81 -0
- package/dist/core/channel/channel-runtime.d.ts.map +1 -0
- package/dist/core/channel/channel-runtime.js +291 -0
- package/dist/core/channel/channel-runtime.js.map +1 -0
- package/dist/core/channel/channel-supervisor.d.ts +72 -0
- package/dist/core/channel/channel-supervisor.d.ts.map +1 -0
- package/dist/core/channel/channel-supervisor.js +189 -0
- package/dist/core/channel/channel-supervisor.js.map +1 -0
- package/dist/core/channel/channel-types.d.ts +169 -0
- package/dist/core/channel/channel-types.d.ts.map +1 -0
- package/dist/core/channel/channel-types.js +26 -0
- package/dist/core/channel/channel-types.js.map +1 -0
- package/dist/core/channel/index.d.ts +21 -0
- package/dist/core/channel/index.d.ts.map +1 -0
- package/dist/core/channel/index.js +23 -0
- package/dist/core/channel/index.js.map +1 -0
- package/dist/core/command-generation/index.d.ts +225 -0
- package/dist/core/command-generation/index.d.ts.map +1 -0
- package/dist/core/command-generation/index.js +462 -0
- package/dist/core/command-generation/index.js.map +1 -0
- package/dist/core/config/config-schema.d.ts +745 -0
- package/dist/core/config/config-schema.d.ts.map +1 -0
- package/dist/core/config/config-schema.js +108 -0
- package/dist/core/config/config-schema.js.map +1 -0
- package/dist/core/config/global-config.d.ts +73 -0
- package/dist/core/config/global-config.d.ts.map +1 -0
- package/dist/core/config/global-config.js +225 -0
- package/dist/core/config/global-config.js.map +1 -0
- package/dist/core/config/index.d.ts +8 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +8 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/hooks/hook-registry.d.ts +55 -0
- package/dist/core/hooks/hook-registry.d.ts.map +1 -0
- package/dist/core/hooks/hook-registry.js +172 -0
- package/dist/core/hooks/hook-registry.js.map +1 -0
- package/dist/core/hooks/hook-types.d.ts +87 -0
- package/dist/core/hooks/hook-types.d.ts.map +1 -0
- package/dist/core/hooks/hook-types.js +11 -0
- package/dist/core/hooks/hook-types.js.map +1 -0
- package/dist/core/hooks/index.d.ts +28 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/index.js +28 -0
- package/dist/core/hooks/index.js.map +1 -0
- package/dist/core/hooks/post-tool-call-hook.d.ts +21 -0
- package/dist/core/hooks/post-tool-call-hook.d.ts.map +1 -0
- package/dist/core/hooks/post-tool-call-hook.js +191 -0
- package/dist/core/hooks/post-tool-call-hook.js.map +1 -0
- package/dist/core/hooks/pre-tool-call-hook.d.ts +31 -0
- package/dist/core/hooks/pre-tool-call-hook.d.ts.map +1 -0
- package/dist/core/hooks/pre-tool-call-hook.js +122 -0
- package/dist/core/hooks/pre-tool-call-hook.js.map +1 -0
- package/dist/core/hooks/session-start-hook.d.ts +25 -0
- package/dist/core/hooks/session-start-hook.d.ts.map +1 -0
- package/dist/core/hooks/session-start-hook.js +226 -0
- package/dist/core/hooks/session-start-hook.js.map +1 -0
- package/dist/core/hooks/workflow-state-hook.d.ts +18 -0
- package/dist/core/hooks/workflow-state-hook.d.ts.map +1 -0
- package/dist/core/hooks/workflow-state-hook.js +181 -0
- package/dist/core/hooks/workflow-state-hook.js.map +1 -0
- package/dist/core/init/engine.d.ts +69 -0
- package/dist/core/init/engine.d.ts.map +1 -0
- package/dist/core/init/engine.js +211 -0
- package/dist/core/init/engine.js.map +1 -0
- package/dist/core/init/template-hash.d.ts +86 -0
- package/dist/core/init/template-hash.d.ts.map +1 -0
- package/dist/core/init/template-hash.js +228 -0
- package/dist/core/init/template-hash.js.map +1 -0
- package/dist/core/memory/adapters/json-adapter.d.ts +50 -0
- package/dist/core/memory/adapters/json-adapter.d.ts.map +1 -0
- package/dist/core/memory/adapters/json-adapter.js +273 -0
- package/dist/core/memory/adapters/json-adapter.js.map +1 -0
- package/dist/core/memory/adapters/sqlite-adapter.d.ts +26 -0
- package/dist/core/memory/adapters/sqlite-adapter.d.ts.map +1 -0
- package/dist/core/memory/adapters/sqlite-adapter.js +230 -0
- package/dist/core/memory/adapters/sqlite-adapter.js.map +1 -0
- package/dist/core/memory/index.d.ts +38 -0
- package/dist/core/memory/index.d.ts.map +1 -0
- package/dist/core/memory/index.js +40 -0
- package/dist/core/memory/index.js.map +1 -0
- package/dist/core/memory/memory-indexer.d.ts +39 -0
- package/dist/core/memory/memory-indexer.d.ts.map +1 -0
- package/dist/core/memory/memory-indexer.js +213 -0
- package/dist/core/memory/memory-indexer.js.map +1 -0
- package/dist/core/memory/memory-manager.d.ts +59 -0
- package/dist/core/memory/memory-manager.d.ts.map +1 -0
- package/dist/core/memory/memory-manager.js +194 -0
- package/dist/core/memory/memory-manager.js.map +1 -0
- package/dist/core/memory/memory-store.d.ts +31 -0
- package/dist/core/memory/memory-store.d.ts.map +1 -0
- package/dist/core/memory/memory-store.js +148 -0
- package/dist/core/memory/memory-store.js.map +1 -0
- package/dist/core/memory/memory-types.d.ts +154 -0
- package/dist/core/memory/memory-types.d.ts.map +1 -0
- package/dist/core/memory/memory-types.js +13 -0
- package/dist/core/memory/memory-types.js.map +1 -0
- package/dist/core/migration/index.d.ts +80 -0
- package/dist/core/migration/index.d.ts.map +1 -0
- package/dist/core/migration/index.js +361 -0
- package/dist/core/migration/index.js.map +1 -0
- package/dist/core/parsers/index.d.ts +95 -0
- package/dist/core/parsers/index.d.ts.map +1 -0
- package/dist/core/parsers/index.js +367 -0
- package/dist/core/parsers/index.js.map +1 -0
- package/dist/core/sdd-engine/ai-caller.d.ts +118 -0
- package/dist/core/sdd-engine/ai-caller.d.ts.map +1 -0
- package/dist/core/sdd-engine/ai-caller.js +624 -0
- package/dist/core/sdd-engine/ai-caller.js.map +1 -0
- package/dist/core/sdd-engine/controller.d.ts +107 -0
- package/dist/core/sdd-engine/controller.d.ts.map +1 -0
- package/dist/core/sdd-engine/controller.js +357 -0
- package/dist/core/sdd-engine/controller.js.map +1 -0
- package/dist/core/sdd-engine/dispatcher.d.ts +69 -0
- package/dist/core/sdd-engine/dispatcher.d.ts.map +1 -0
- package/dist/core/sdd-engine/dispatcher.js +146 -0
- package/dist/core/sdd-engine/dispatcher.js.map +1 -0
- package/dist/core/sdd-engine/git-ops.d.ts +73 -0
- package/dist/core/sdd-engine/git-ops.d.ts.map +1 -0
- package/dist/core/sdd-engine/git-ops.js +326 -0
- package/dist/core/sdd-engine/git-ops.js.map +1 -0
- package/dist/core/sdd-engine/index.d.ts +17 -0
- package/dist/core/sdd-engine/index.d.ts.map +1 -0
- package/dist/core/sdd-engine/index.js +15 -0
- package/dist/core/sdd-engine/index.js.map +1 -0
- package/dist/core/sdd-engine/ledger.d.ts +92 -0
- package/dist/core/sdd-engine/ledger.d.ts.map +1 -0
- package/dist/core/sdd-engine/ledger.js +273 -0
- package/dist/core/sdd-engine/ledger.js.map +1 -0
- package/dist/core/sdd-engine/model-selector.d.ts +49 -0
- package/dist/core/sdd-engine/model-selector.d.ts.map +1 -0
- package/dist/core/sdd-engine/model-selector.js +76 -0
- package/dist/core/sdd-engine/model-selector.js.map +1 -0
- package/dist/core/sdd-engine/parallel-dispatcher.d.ts +99 -0
- package/dist/core/sdd-engine/parallel-dispatcher.d.ts.map +1 -0
- package/dist/core/sdd-engine/parallel-dispatcher.js +350 -0
- package/dist/core/sdd-engine/parallel-dispatcher.js.map +1 -0
- package/dist/core/sdd-engine/review-loop.d.ts +61 -0
- package/dist/core/sdd-engine/review-loop.d.ts.map +1 -0
- package/dist/core/sdd-engine/review-loop.js +139 -0
- package/dist/core/sdd-engine/review-loop.js.map +1 -0
- package/dist/core/sdd-engine/types.d.ts +104 -0
- package/dist/core/sdd-engine/types.d.ts.map +1 -0
- package/dist/core/sdd-engine/types.js +7 -0
- package/dist/core/sdd-engine/types.js.map +1 -0
- package/dist/core/store/index.d.ts +78 -0
- package/dist/core/store/index.d.ts.map +1 -0
- package/dist/core/store/index.js +182 -0
- package/dist/core/store/index.js.map +1 -0
- package/dist/core/templates/index.d.ts +58 -0
- package/dist/core/templates/index.d.ts.map +1 -0
- package/dist/core/templates/index.js +158 -0
- package/dist/core/templates/index.js.map +1 -0
- package/dist/core/validation/index.d.ts +34 -0
- package/dist/core/validation/index.d.ts.map +1 -0
- package/dist/core/validation/index.js +153 -0
- package/dist/core/validation/index.js.map +1 -0
- package/dist/core/workflow-state.d.ts +96 -0
- package/dist/core/workflow-state.d.ts.map +1 -0
- package/dist/core/workflow-state.js +284 -0
- package/dist/core/workflow-state.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/index.d.ts +48 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +119 -0
- package/dist/utils/index.js.map +1 -0
- package/hooks/hooks.json +30 -0
- package/hooks/run-hook.cmd +19 -0
- package/hooks/session-start +62 -0
- package/hooks/workflow-state +150 -0
- package/package.json +122 -0
- package/schemas/bug-fix/schema.yaml +64 -0
- package/schemas/bug-fix/templates/analysis.md +43 -0
- package/schemas/bug-fix/templates/fix-plan.md +19 -0
- package/schemas/bug-fix/templates/proposal.md +30 -0
- package/schemas/crud-module/schema.yaml +65 -0
- package/schemas/crud-module/templates/design.md +36 -0
- package/schemas/crud-module/templates/proposal.md +30 -0
- package/schemas/crud-module/templates/spec.md +33 -0
- package/schemas/crud-module/templates/tasks.md +57 -0
- package/schemas/spec-driven/schema.yaml +87 -0
- package/schemas/spec-driven/templates/design.md +54 -0
- package/schemas/spec-driven/templates/proposal.md +31 -0
- package/schemas/spec-driven/templates/spec.md +44 -0
- package/schemas/spec-driven/templates/tasks.md +98 -0
- package/skills/business-code-review/SKILL.md +78 -0
- package/skills/business-db-design/SKILL.md +74 -0
- package/skills/business-deploy-check/SKILL.md +72 -0
- package/skills/business-doc-sync/SKILL.md +72 -0
- package/skills/business-java-codegen/SKILL.md +97 -0
- package/skills/business-menu-register/SKILL.md +63 -0
- package/skills/business-prd-writer/SKILL.md +80 -0
- package/skills/business-test-gen/SKILL.md +82 -0
- package/skills/business-ui-codegen/SKILL.md +104 -0
- package/skills/execution-finish-branch/SKILL.md +58 -0
- package/skills/execution-git-worktrees/SKILL.md +48 -0
- package/skills/execution-parallel-agents/SKILL.md +51 -0
- package/skills/execution-receiving-review/SKILL.md +47 -0
- package/skills/execution-requesting-review/SKILL.md +51 -0
- package/skills/execution-subagent-driven-dev/SKILL.md +148 -0
- package/skills/execution-systematic-debugging/SKILL.md +95 -0
- package/skills/execution-tdd/SKILL.md +74 -0
- package/skills/execution-verification-before-completion/SKILL.md +75 -0
- package/skills/meta-create-skill/SKILL.md +374 -0
- package/skills/meta-using-skills/SKILL.md +97 -0
- package/skills/meta-writing-skills/SKILL.md +66 -0
- package/skills/planning-apply-change/SKILL.md +199 -0
- package/skills/planning-archive-change/SKILL.md +43 -0
- package/skills/planning-explore/SKILL.md +108 -0
- package/skills/planning-onboard/SKILL.md +60 -0
- package/skills/planning-propose/SKILL.md +145 -0
- package/skills/planning-update-change/SKILL.md +45 -0
- package/skills/planning-verify-change/SKILL.md +58 -0
- package/skills/planning-write-design/SKILL.md +59 -0
- package/skills/planning-write-plans/SKILL.md +55 -0
- package/skills/planning-write-specs/SKILL.md +73 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用工具函数
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
/**
|
|
8
|
+
* 查找项目根目录(包含 package.json 或 .git 的最近父目录)
|
|
9
|
+
*/
|
|
10
|
+
export function findProjectRoot(startDir = process.cwd()) {
|
|
11
|
+
let dir = path.resolve(startDir);
|
|
12
|
+
while (true) {
|
|
13
|
+
if (fs.existsSync(path.join(dir, 'package.json')) || fs.existsSync(path.join(dir, '.git'))) {
|
|
14
|
+
return dir;
|
|
15
|
+
}
|
|
16
|
+
const parent = path.dirname(dir);
|
|
17
|
+
if (parent === dir) {
|
|
18
|
+
throw new Error('无法找到项目根目录(未找到 package.json 或 .git)');
|
|
19
|
+
}
|
|
20
|
+
dir = parent;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 安全读取 JSON 文件
|
|
25
|
+
*/
|
|
26
|
+
export function readJsonSafe(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
if (!fs.existsSync(filePath))
|
|
29
|
+
return null;
|
|
30
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 确保目录存在
|
|
38
|
+
*/
|
|
39
|
+
export function ensureDir(dirPath) {
|
|
40
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 复制目录(递归)
|
|
44
|
+
*/
|
|
45
|
+
export function copyDir(src, dest) {
|
|
46
|
+
ensureDir(dest);
|
|
47
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
48
|
+
for (const entry of entries) {
|
|
49
|
+
const srcPath = path.join(src, entry.name);
|
|
50
|
+
const destPath = path.join(dest, entry.name);
|
|
51
|
+
if (entry.isDirectory()) {
|
|
52
|
+
copyDir(srcPath, destPath);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
fs.copyFileSync(srcPath, destPath);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 列出目录下所有文件(递归)
|
|
61
|
+
*/
|
|
62
|
+
export function listFilesRecursive(dir, pattern) {
|
|
63
|
+
const results = [];
|
|
64
|
+
if (!fs.existsSync(dir))
|
|
65
|
+
return results;
|
|
66
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
const fullPath = path.join(dir, entry.name);
|
|
69
|
+
if (entry.isDirectory()) {
|
|
70
|
+
results.push(...listFilesRecursive(fullPath, pattern));
|
|
71
|
+
}
|
|
72
|
+
else if (!pattern || pattern.test(entry.name)) {
|
|
73
|
+
results.push(fullPath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return results;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 生成变更 ID(基于标题的 slug)
|
|
80
|
+
*/
|
|
81
|
+
export function generateChangeId(title) {
|
|
82
|
+
return title
|
|
83
|
+
.toLowerCase()
|
|
84
|
+
.replace(/[^\w\u4e00-\u9fff\s-]/g, '')
|
|
85
|
+
.replace(/[\s_]+/g, '-')
|
|
86
|
+
.replace(/^-+|-+$/g, '')
|
|
87
|
+
.substring(0, 50) || `change-${Date.now()}`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 格式化时间戳
|
|
91
|
+
*/
|
|
92
|
+
export function formatTimestamp(date = new Date()) {
|
|
93
|
+
return date.toISOString().replace('T', ' ').substring(0, 19);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 打印成功消息
|
|
97
|
+
*/
|
|
98
|
+
export function success(msg) {
|
|
99
|
+
console.log(chalk.green('✓') + ' ' + msg);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 打印错误消息
|
|
103
|
+
*/
|
|
104
|
+
export function error(msg) {
|
|
105
|
+
console.log(chalk.red('✗') + ' ' + msg);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 打印警告消息
|
|
109
|
+
*/
|
|
110
|
+
export function warn(msg) {
|
|
111
|
+
console.log(chalk.yellow('!') + ' ' + msg);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 打印信息消息
|
|
115
|
+
*/
|
|
116
|
+
export function info(msg) {
|
|
117
|
+
console.log(chalk.blue('i') + ' ' + msg);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,WAAmB,OAAO,CAAC,GAAG,EAAE;IAC9D,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YAC3F,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QACD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAI,QAAgB;IAC9C,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;QAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,IAAY;IAC/C,SAAS,CAAC,IAAI,CAAC,CAAC;IAChB,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,OAAgB;IAC9D,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAExC,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC;aAAM,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK;SACT,WAAW,EAAE;SACb,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC;SACrC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,UAAU,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAAa,IAAI,IAAI,EAAE;IACrD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;AAC3C,CAAC"}
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start",
|
|
10
|
+
"shell": "bash",
|
|
11
|
+
"async": false
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"UserPromptSubmit": [
|
|
17
|
+
{
|
|
18
|
+
"matcher": "",
|
|
19
|
+
"hooks": [
|
|
20
|
+
{
|
|
21
|
+
"type": "command",
|
|
22
|
+
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" workflow-state",
|
|
23
|
+
"shell": "bash",
|
|
24
|
+
"async": false
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
REM SpecPow Hook Runner for Windows
|
|
3
|
+
REM Usage: run-hook.cmd <hook-name>
|
|
4
|
+
REM
|
|
5
|
+
REM P2-11: 支持 SessionStart 和 WorkflowState 两种 Hook
|
|
6
|
+
|
|
7
|
+
set HOOK_NAME=%1
|
|
8
|
+
set SCRIPT_DIR=%~dp0
|
|
9
|
+
|
|
10
|
+
if "%HOOK_NAME%"=="session-start" (
|
|
11
|
+
bash "%SCRIPT_DIR%session-start"
|
|
12
|
+
) else if "%HOOK_NAME%"=="workflow-state" (
|
|
13
|
+
REM WorkflowState Hook: 注入当前工作流状态
|
|
14
|
+
REM 通过 Node.js 调用 TypeScript Hook 模块
|
|
15
|
+
node -e "import('file:///%SCRIPT_DIR:~0,-1%/../dist/core/hooks/index.js').then(m => m.executeUserPromptSubmit(process.cwd(), '', 'claude').then(c => { if(c) console.log(JSON.stringify({hookSpecificOutput:{hookEventName:'UserPromptSubmit',additionalContext:c}})); else process.exit(0); }))"
|
|
16
|
+
) else (
|
|
17
|
+
echo Unknown hook: %HOOK_NAME%
|
|
18
|
+
exit /b 1
|
|
19
|
+
)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# SpecPow Session Start Hook
|
|
3
|
+
#
|
|
4
|
+
# 在每次会话开始时注入 using-skills 技能内容到 AI 代理上下文
|
|
5
|
+
# 兼容 Claude Code、Cursor、Copilot CLI 等平台
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
# Determine plugin root directory
|
|
10
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
+
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
12
|
+
|
|
13
|
+
# Read using-skills content
|
|
14
|
+
using_skills_content=$(cat "${PLUGIN_ROOT}/skills/meta-using-skills/SKILL.md" 2>&1 || echo "Error reading using-skills skill")
|
|
15
|
+
|
|
16
|
+
# Escape string for JSON embedding
|
|
17
|
+
escape_for_json() {
|
|
18
|
+
local s="$1"
|
|
19
|
+
s="${s//\\/\\\\}"
|
|
20
|
+
s="${s//\"/\\\"}"
|
|
21
|
+
s="${s//$'\n'/\\n}"
|
|
22
|
+
s="${s//$'\r'/\\r}"
|
|
23
|
+
s="${s//$'\t'/\\t}"
|
|
24
|
+
printf '%s' "$s"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
using_skills_escaped=$(escape_for_json "$using_skills_content")
|
|
28
|
+
|
|
29
|
+
# Check for OpenSpec context
|
|
30
|
+
openspec_context=""
|
|
31
|
+
if [ -f "${PLUGIN_ROOT}/../openspec/specs" ] 2>/dev/null || [ -d "${PLUGIN_ROOT}/../openspec/specs" ] 2>/dev/null; then
|
|
32
|
+
# Detect active changes
|
|
33
|
+
active_changes=""
|
|
34
|
+
if [ -d "${PLUGIN_ROOT}/../openspec/changes" ] 2>/dev/null; then
|
|
35
|
+
changes_count=$(find "${PLUGIN_ROOT}/../openspec/changes" -maxdepth 1 -mindepth 1 -type d ! -name 'archive' 2>/dev/null | wc -l | tr -d ' ')
|
|
36
|
+
if [ "$changes_count" -gt 0 ] 2>/dev/null; then
|
|
37
|
+
active_changes_list=$(find "${PLUGIN_ROOT}/../openspec/changes" -maxdepth 1 -mindepth 1 -type d ! -name 'archive' 2>/dev/null | while read d; do basename "$d"; done | tr '\n' ', ' | sed 's/, $//')
|
|
38
|
+
active_changes="\nActive changes (${changes_count}): ${active_changes_list}\nUse 'specpow status' to inspect."
|
|
39
|
+
fi
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
openspec_context="\nOpenSpec structure detected in this project. Follow the spec-driven workflow:\n1. Explore → planning-explore skill\n2. Propose → planning-propose skill\n3. Write Specs/Design/Tasks → planning-write-* skills\n4. Implement → execution-* skills (SDD engine)\n5. Verify → execution-verification-before-completion\n6. Archive → specpow archive\n${active_changes}\n"
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
session_context="<EXTREMELY_IMPORTANT>\nYou have specpow — a spec-powered AI development framework. It combines OpenSpec's spec-driven planning with Superpowers' subagent-driven execution.\n\n**Below is the full content of your 'specpow:meta-using-skills' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${using_skills_escaped}\n\n${openspec_context}\n\nAvailable skill categories:\n- Planning: planning-explore, planning-propose, planning-write-plans, planning-write-specs, planning-write-design\n- Execution: planning-apply-change, execution-subagent-driven-dev, execution-tdd, execution-systematic-debugging, execution-parallel-agents\n- Quality: execution-requesting-review, execution-receiving-review, execution-verification-before-completion, planning-verify-change\n- Business: business-java-codegen, business-ui-codegen, business-test-gen, business-code-review, business-db-design, business-prd-writer, business-deploy-check\n\nRemember: Check for relevant skills BEFORE any action.\n</EXTREMELY_IMPORTANT>"
|
|
46
|
+
|
|
47
|
+
# Output context injection as JSON
|
|
48
|
+
# Cursor hooks expect additional_context (snake_case)
|
|
49
|
+
# Claude Code hooks expect hookSpecificOutput.additionalContext (nested)
|
|
50
|
+
# Copilot CLI (v1.0.11+) and others expect additionalContext (top-level, SDK standard)
|
|
51
|
+
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
|
|
52
|
+
# Cursor sets CURSOR_PLUGIN_ROOT (may also set CLAUDE_PLUGIN_ROOT)
|
|
53
|
+
printf '{\n "additional_context": "%s"\n}\n' "$session_context" | cat
|
|
54
|
+
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -z "${COPILOT_CLI:-}" ]; then
|
|
55
|
+
# Claude Code sets CLAUDE_PLUGIN_ROOT without COPILOT_CLI
|
|
56
|
+
printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context" | cat
|
|
57
|
+
else
|
|
58
|
+
# Copilot CLI (sets COPILOT_CLI=1) or unknown platform — SDK standard format
|
|
59
|
+
printf '{\n "additionalContext": "%s"\n}\n' "$session_context" | cat
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
exit 0
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# SpecPow Workflow State Hook
|
|
3
|
+
#
|
|
4
|
+
# 在用户提交提示时注入当前工作流状态
|
|
5
|
+
# 兼容 Claude Code、Cursor、Copilot CLI 等平台
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
# Determine plugin root directory
|
|
10
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
+
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
12
|
+
PROJECT_ROOT="$(cd "${PLUGIN_ROOT}/.." 2>/dev/null && pwd || echo "${PLUGIN_ROOT}")"
|
|
13
|
+
|
|
14
|
+
# Escape string for JSON embedding
|
|
15
|
+
escape_for_json() {
|
|
16
|
+
local s="$1"
|
|
17
|
+
s="${s//\\/\\\\}"
|
|
18
|
+
s="${s//\"/\\\"}"
|
|
19
|
+
s="${s//$'\n'/\\n}"
|
|
20
|
+
s="${s//$'\r'/\\r}"
|
|
21
|
+
s="${s//$'\t'/\\t}"
|
|
22
|
+
printf '%s' "$s"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Detect active change
|
|
26
|
+
detect_active_change() {
|
|
27
|
+
local changes_dir="${PROJECT_ROOT}/openspec/changes"
|
|
28
|
+
if [ ! -d "$changes_dir" ]; then
|
|
29
|
+
echo ""
|
|
30
|
+
return
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Find first active change (excluding archive)
|
|
34
|
+
local change_name=""
|
|
35
|
+
for dir in "$changes_dir"/*/; do
|
|
36
|
+
local basename=$(basename "$dir")
|
|
37
|
+
if [ "$basename" != "archive" ] && [ -d "$dir" ]; then
|
|
38
|
+
change_name="$basename"
|
|
39
|
+
break
|
|
40
|
+
fi
|
|
41
|
+
done
|
|
42
|
+
|
|
43
|
+
if [ -z "$change_name" ]; then
|
|
44
|
+
echo ""
|
|
45
|
+
return
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
echo "$change_name"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Infer workflow stage from change directory contents
|
|
52
|
+
infer_stage() {
|
|
53
|
+
local change_name="$1"
|
|
54
|
+
local change_dir="${PROJECT_ROOT}/openspec/changes/${change_name}"
|
|
55
|
+
|
|
56
|
+
if [ ! -d "$change_dir" ]; then
|
|
57
|
+
echo "idle"
|
|
58
|
+
return
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
# Check for verify/review files
|
|
62
|
+
if ls "$change_dir"/*verify* 2>/dev/null | head -1 > /dev/null || \
|
|
63
|
+
ls "$change_dir"/*review* 2>/dev/null | head -1 > /dev/null; then
|
|
64
|
+
echo "verify"
|
|
65
|
+
return
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Check for tasks files
|
|
69
|
+
if ls "$change_dir"/*tasks* 2>/dev/null | head -1 > /dev/null; then
|
|
70
|
+
echo "apply"
|
|
71
|
+
return
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# Check for spec/design files
|
|
75
|
+
if ls "$change_dir"/*spec* 2>/dev/null | head -1 > /dev/null || \
|
|
76
|
+
ls "$change_dir"/*design* 2>/dev/null | head -1 > /dev/null; then
|
|
77
|
+
echo "propose"
|
|
78
|
+
return
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
echo "explore"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Main logic
|
|
85
|
+
change_name=$(detect_active_change)
|
|
86
|
+
|
|
87
|
+
if [ -z "$change_name" ]; then
|
|
88
|
+
# No active change, no context to inject
|
|
89
|
+
exit 0
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
stage=$(infer_stage "$change_name")
|
|
93
|
+
|
|
94
|
+
# Build workflow context
|
|
95
|
+
workflow_context="<!-- workflow-state: ${stage} -->\n<!-- active-change: ${change_name} -->"
|
|
96
|
+
|
|
97
|
+
# Add stage hint
|
|
98
|
+
case "$stage" in
|
|
99
|
+
explore)
|
|
100
|
+
workflow_context="${workflow_context}\n🔍 当前阶段: EXPLORE — 使用 planning-explore 技能理解需求"
|
|
101
|
+
;;
|
|
102
|
+
propose)
|
|
103
|
+
workflow_context="${workflow_context}\n📝 当前阶段: PROPOSE — 使用 planning-propose 创建变更提案"
|
|
104
|
+
;;
|
|
105
|
+
apply)
|
|
106
|
+
workflow_context="${workflow_context}\n⚙️ 当前阶段: APPLY — 使用 planning-apply-change 执行实现"
|
|
107
|
+
;;
|
|
108
|
+
verify)
|
|
109
|
+
workflow_context="${workflow_context}\n✅ 当前阶段: VERIFY — 使用 planning-verify-change 验证规范"
|
|
110
|
+
;;
|
|
111
|
+
archive)
|
|
112
|
+
workflow_context="${workflow_context}\n📦 当前阶段: ARCHIVE — 运行 specpow archive 合并到主规范"
|
|
113
|
+
;;
|
|
114
|
+
esac
|
|
115
|
+
|
|
116
|
+
# Check progress
|
|
117
|
+
change_dir="${PROJECT_ROOT}/openspec/changes/${change_name}"
|
|
118
|
+
progress=""
|
|
119
|
+
if ls "$change_dir"/*proposal* 2>/dev/null | head -1 > /dev/null; then
|
|
120
|
+
progress="${progress}✓ proposal"
|
|
121
|
+
fi
|
|
122
|
+
if ls "$change_dir"/*spec* 2>/dev/null | head -1 > /dev/null; then
|
|
123
|
+
[ -n "$progress" ] && progress="${progress}, "
|
|
124
|
+
progress="${progress}✓ specs"
|
|
125
|
+
fi
|
|
126
|
+
if ls "$change_dir"/*tasks* 2>/dev/null | head -1 > /dev/null; then
|
|
127
|
+
[ -n "$progress" ] && progress="${progress}, "
|
|
128
|
+
progress="${progress}✓ tasks"
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
if [ -n "$progress" ]; then
|
|
132
|
+
workflow_context="${workflow_context}\n进度: ${progress}"
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
# Escape for JSON
|
|
136
|
+
workflow_context_escaped=$(escape_for_json "$workflow_context")
|
|
137
|
+
|
|
138
|
+
# Output based on platform
|
|
139
|
+
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
|
|
140
|
+
# Cursor format
|
|
141
|
+
printf '{\n "additional_context": "%s"\n}\n' "$workflow_context_escaped" | cat
|
|
142
|
+
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -z "${COPILOT_CLI:-}" ]; then
|
|
143
|
+
# Claude Code format
|
|
144
|
+
printf '{\n "hookSpecificOutput": {\n "hookEventName": "UserPromptSubmit",\n "additionalContext": "%s"\n }\n}\n' "$workflow_context_escaped" | cat
|
|
145
|
+
else
|
|
146
|
+
# Copilot CLI or unknown platform
|
|
147
|
+
printf '{\n "additionalContext": "%s"\n}\n' "$workflow_context_escaped" | cat
|
|
148
|
+
fi
|
|
149
|
+
|
|
150
|
+
exit 0
|
package/package.json
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@specpow/framework",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Spec-Powered AI Development Framework - 融合 OpenSpec 规范驱动 + Superpowers 执行引擎的企业级 AI 辅助编程框架",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./sdd": {
|
|
14
|
+
"types": "./dist/core/sdd-engine/index.d.ts",
|
|
15
|
+
"import": "./dist/core/sdd-engine/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./artifact-graph": {
|
|
18
|
+
"types": "./dist/core/artifact-graph/index.d.ts",
|
|
19
|
+
"import": "./dist/core/artifact-graph/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./archive": {
|
|
22
|
+
"types": "./dist/core/archive/index.d.ts",
|
|
23
|
+
"import": "./dist/core/archive/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./hooks": {
|
|
26
|
+
"types": "./dist/core/hooks/index.d.ts",
|
|
27
|
+
"import": "./dist/core/hooks/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./memory": {
|
|
30
|
+
"types": "./dist/core/memory/index.d.ts",
|
|
31
|
+
"import": "./dist/core/memory/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./channel": {
|
|
34
|
+
"types": "./dist/core/channel/index.d.ts",
|
|
35
|
+
"import": "./dist/core/channel/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./workflow-state": {
|
|
38
|
+
"types": "./dist/core/workflow-state.d.ts",
|
|
39
|
+
"import": "./dist/core/workflow-state.js"
|
|
40
|
+
},
|
|
41
|
+
"./config": {
|
|
42
|
+
"types": "./dist/core/config/index.d.ts",
|
|
43
|
+
"import": "./dist/core/config/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./command-generation": {
|
|
46
|
+
"types": "./dist/core/command-generation/index.d.ts",
|
|
47
|
+
"import": "./dist/core/command-generation/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"bin": {
|
|
51
|
+
"specpow": "bin/specpow.js"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=20.19.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "node build.js",
|
|
58
|
+
"dev": "tsc --watch",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest",
|
|
61
|
+
"lint": "eslint src/ --ext .ts",
|
|
62
|
+
"clean": "rimraf dist",
|
|
63
|
+
"prepublishOnly": "npm run build"
|
|
64
|
+
},
|
|
65
|
+
"keywords": [
|
|
66
|
+
"ai",
|
|
67
|
+
"coding",
|
|
68
|
+
"spec-driven",
|
|
69
|
+
"subagent-driven-development",
|
|
70
|
+
"claude-code",
|
|
71
|
+
"cursor",
|
|
72
|
+
"copilot",
|
|
73
|
+
"workflow",
|
|
74
|
+
"agent",
|
|
75
|
+
"skills",
|
|
76
|
+
"pi-package"
|
|
77
|
+
],
|
|
78
|
+
"files": [
|
|
79
|
+
"dist/",
|
|
80
|
+
"bin/",
|
|
81
|
+
"skills/",
|
|
82
|
+
"agents/",
|
|
83
|
+
"schemas/",
|
|
84
|
+
"hooks/",
|
|
85
|
+
"README.md",
|
|
86
|
+
"CHANGELOG.md",
|
|
87
|
+
"LICENSE"
|
|
88
|
+
],
|
|
89
|
+
"author": "buchengjin",
|
|
90
|
+
"license": "MIT",
|
|
91
|
+
"repository": {
|
|
92
|
+
"type": "git",
|
|
93
|
+
"url": "http://git.gj.com/ai/specpow.git"
|
|
94
|
+
},
|
|
95
|
+
"homepage": "http://git.gj.com/ai/specpow#readme",
|
|
96
|
+
"bugs": {
|
|
97
|
+
"url": "http://git.gj.com/ai/specpow/issues"
|
|
98
|
+
},
|
|
99
|
+
"dependencies": {
|
|
100
|
+
"better-sqlite3": "^13.0.3",
|
|
101
|
+
"chalk": "^5.3.0",
|
|
102
|
+
"commander": "^12.1.0",
|
|
103
|
+
"glob": "^10.3.10",
|
|
104
|
+
"ora": "^8.0.1",
|
|
105
|
+
"yaml": "^2.3.4",
|
|
106
|
+
"zod": "^3.22.4"
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@types/better-sqlite3": "^9.6.0",
|
|
110
|
+
"@types/node": "^20.11.0",
|
|
111
|
+
"eslint": "^8.56.0",
|
|
112
|
+
"rimraf": "^5.0.5",
|
|
113
|
+
"typescript": "^5.3.3",
|
|
114
|
+
"vitest": "^1.2.0"
|
|
115
|
+
},
|
|
116
|
+
"packageManager": "pnpm@9.15.9",
|
|
117
|
+
"pi": {
|
|
118
|
+
"skills": [
|
|
119
|
+
"./skills"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Bug 修复 Schema
|
|
2
|
+
# 用于快速定位和修复 Bug 的工件流
|
|
3
|
+
|
|
4
|
+
name: bug-fix
|
|
5
|
+
description: 系统化定位和修复 Bug
|
|
6
|
+
|
|
7
|
+
apply:
|
|
8
|
+
requires:
|
|
9
|
+
- tasks
|
|
10
|
+
|
|
11
|
+
artifacts:
|
|
12
|
+
- id: proposal
|
|
13
|
+
name: Bug 描述
|
|
14
|
+
description: 描述 Bug 现象和复现步骤
|
|
15
|
+
requires: []
|
|
16
|
+
template: templates/proposal.md
|
|
17
|
+
instruction: |
|
|
18
|
+
记录 Bug 信息:
|
|
19
|
+
- Bug 标题
|
|
20
|
+
- 复现步骤(Step 1, 2, 3...)
|
|
21
|
+
- 预期行为
|
|
22
|
+
- 实际行为
|
|
23
|
+
- 环境信息
|
|
24
|
+
- 影响范围
|
|
25
|
+
output: proposal.md
|
|
26
|
+
|
|
27
|
+
- id: analysis
|
|
28
|
+
name: 根因分析
|
|
29
|
+
description: 分析 Bug 根因
|
|
30
|
+
requires: [proposal]
|
|
31
|
+
template: templates/analysis.md
|
|
32
|
+
instruction: |
|
|
33
|
+
根因分析(4 阶段):
|
|
34
|
+
1. 调查 — 收集日志、堆栈、复现
|
|
35
|
+
2. 模式分析 — 识别错误模式
|
|
36
|
+
3. 假设 — 提出根因假设
|
|
37
|
+
4. 验证 — 验证假设正确性
|
|
38
|
+
output: analysis.md
|
|
39
|
+
|
|
40
|
+
- id: fix-plan
|
|
41
|
+
name: 修复计划
|
|
42
|
+
description: 制定修复方案
|
|
43
|
+
requires: [analysis]
|
|
44
|
+
template: templates/fix-plan.md
|
|
45
|
+
instruction: |
|
|
46
|
+
修复方案:
|
|
47
|
+
- 修复策略(热修复/正常修复/重构修复)
|
|
48
|
+
- 修改文件列表
|
|
49
|
+
- 回归测试计划
|
|
50
|
+
output: fix-plan.md
|
|
51
|
+
|
|
52
|
+
- id: tasks
|
|
53
|
+
name: 修复任务
|
|
54
|
+
description: 修复步骤拆分
|
|
55
|
+
requires: [fix-plan]
|
|
56
|
+
template: templates/tasks.md
|
|
57
|
+
instruction: |
|
|
58
|
+
修复任务拆分:
|
|
59
|
+
1. 编写失败测试(复现 Bug)
|
|
60
|
+
2. 修复代码
|
|
61
|
+
3. 验证测试通过
|
|
62
|
+
4. 回归测试
|
|
63
|
+
5. 更新文档
|
|
64
|
+
output: tasks.md
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 根因分析
|
|
2
|
+
|
|
3
|
+
## 1. 调查
|
|
4
|
+
|
|
5
|
+
### 错误日志
|
|
6
|
+
```
|
|
7
|
+
(关键错误日志)
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### 堆栈跟踪
|
|
11
|
+
```
|
|
12
|
+
(关键堆栈)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 复现结果
|
|
16
|
+
- 是否可稳定复现: 是/否
|
|
17
|
+
- 复现频率:
|
|
18
|
+
|
|
19
|
+
## 2. 模式分析
|
|
20
|
+
|
|
21
|
+
### 错误模式
|
|
22
|
+
- 错误类型:
|
|
23
|
+
- 涉及模块:
|
|
24
|
+
- 最近变更:
|
|
25
|
+
|
|
26
|
+
## 3. 假设
|
|
27
|
+
|
|
28
|
+
### 假设 1: [描述]
|
|
29
|
+
- 证据:
|
|
30
|
+
- 验证方法:
|
|
31
|
+
|
|
32
|
+
### 假设 2: [描述]
|
|
33
|
+
- 证据:
|
|
34
|
+
- 验证方法:
|
|
35
|
+
|
|
36
|
+
## 4. 结论
|
|
37
|
+
|
|
38
|
+
### 根因
|
|
39
|
+
[确认的根因描述]
|
|
40
|
+
|
|
41
|
+
### 影响分析
|
|
42
|
+
- 直接影响:
|
|
43
|
+
- 间接影响:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Bug 描述
|
|
2
|
+
|
|
3
|
+
## Bug 标题
|
|
4
|
+
{{bugTitle}}
|
|
5
|
+
|
|
6
|
+
## 复现步骤
|
|
7
|
+
1.
|
|
8
|
+
2.
|
|
9
|
+
3.
|
|
10
|
+
|
|
11
|
+
## 预期行为
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 实际行为
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 环境信息
|
|
18
|
+
- 环境:
|
|
19
|
+
- 版本:
|
|
20
|
+
- 浏览器/客户端:
|
|
21
|
+
|
|
22
|
+
## 影响范围
|
|
23
|
+
- 影响用户:
|
|
24
|
+
- 影响功能:
|
|
25
|
+
- 严重程度: Critical / Major / Minor
|
|
26
|
+
|
|
27
|
+
## 相关日志
|
|
28
|
+
```
|
|
29
|
+
(粘贴错误日志)
|
|
30
|
+
```
|