@chongyan/autospec 1.0.1 → 1.0.2
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/LICENSE +21 -21
- package/README.en.md +447 -321
- package/README.md +418 -286
- package/knowledge/01-principles/00-principles-hierarchy.md +247 -0
- package/knowledge/01-principles/01-first-principles.md +241 -0
- package/knowledge/01-principles/02-strategic-principles.md +286 -0
- package/knowledge/01-principles/03-tactical-principles.md +385 -0
- package/knowledge/01-principles/04-operational-principles.md +275 -0
- package/knowledge/01-principles/05-domain-principles.md +539 -0
- package/knowledge/01-principles/06-methodology-principles.md +281 -0
- package/knowledge/01-principles/07-cognitive-principles.md +277 -0
- package/knowledge/01-principles/08-auto-fix-principles.md +320 -0
- package/knowledge/01-principles/09-constitution.md +220 -0
- package/knowledge/{principles/evolution.md → 01-principles/10-evolution-mechanism.md} +160 -14
- package/knowledge/01-principles/README.en.md +385 -0
- package/knowledge/01-principles/README.md +385 -0
- package/knowledge/{process/overview.md → 02-process/00-overview.md} +90 -5
- package/knowledge/02-process/README.en.md +143 -0
- package/knowledge/02-process/README.md +186 -0
- package/knowledge/{guides/support/pipeline-protocol.md → 03-guides/00-pipeline-protocol.md} +10 -10
- package/knowledge/{guides/support/team-orchestrator.md → 03-guides/01-team-orchestrator.md} +53 -8
- package/knowledge/{guides/stages/requirement-analyzer.md → 03-guides/02-analyze-requirement.md} +3 -3
- package/knowledge/{guides/stages/ai-effect-evaluator.md → 03-guides/08-evaluate-ai-effect.md} +14 -7
- package/knowledge/{guides/support/skill-distiller.md → 03-guides/19-distill-skill.md} +3 -3
- package/knowledge/{guides/support/skill-updater.md → 03-guides/20-update-skill.md} +1 -1
- package/knowledge/{guides/support/methodology-extractor.md → 03-guides/22-extract-methodology.md} +2 -2
- package/knowledge/{guides/support/complexity-assessor.md → 03-guides/24-assess-complexity.md} +6 -4
- package/knowledge/{guides/support/tech-stack-analyzer.md → 03-guides/26-analyze-tech-stack.md} +1 -1
- package/knowledge/{guides/domain-driven-design.md → 03-guides/42-apply-ddd.md} +1 -1
- package/knowledge/{process/ai-sdlc.md → 03-guides/43-run-ai-sdlc.md} +1 -1
- package/knowledge/{guides/knowledge-management.md → 03-guides/44-manage-knowledge.md} +4 -4
- package/knowledge/03-guides/README.en.md +212 -0
- package/knowledge/03-guides/README.md +212 -0
- package/knowledge/{checklists/requirement.md → 04-checklists/00-requirement.md} +1 -1
- package/knowledge/{checklists/design.md → 04-checklists/01-design.md} +1 -1
- package/knowledge/{checklists/code.md → 04-checklists/02-code.md} +16 -1
- package/knowledge/{checklists/release.md → 04-checklists/04-release.md} +1 -1
- package/knowledge/04-checklists/README.en.md +119 -0
- package/knowledge/04-checklists/README.md +123 -0
- package/knowledge/{config/validation-patterns.yaml → 05-config/00-validation-patterns.yaml} +1 -1
- package/knowledge/{config/team-tasks.yaml → 05-config/02-team-tasks.yaml} +2 -2
- package/knowledge/05-config/03-role-composition.yaml +346 -0
- package/knowledge/{config/skill-compositions.yaml → 05-config/05-skill-compositions.yaml} +24 -24
- package/knowledge/05-config/README.en.md +54 -0
- package/knowledge/05-config/README.md +132 -0
- package/knowledge/06-environment/00-template-registry.md +310 -0
- package/knowledge/06-environment/01-detection-patterns.yaml +1692 -0
- package/knowledge/{environment → 06-environment}/README.en.md +4 -0
- package/knowledge/{environment → 06-environment}/README.md +66 -25
- package/knowledge/{standards/coding-style.md → 07-standards/00-coding-style.md} +123 -4
- package/knowledge/{standards/code-review.md → 07-standards/01-code-review.md} +3 -3
- package/knowledge/{standards/data-consistency.md → 07-standards/02-data-consistency.md} +1 -1
- package/knowledge/{standards/document-versioning.md → 07-standards/03-document-versioning.md} +1 -1
- package/knowledge/{standards/risk-detection.md → 07-standards/04-risk-detection.md} +5 -5
- package/knowledge/07-standards/README.en.md +119 -0
- package/knowledge/07-standards/README.md +123 -0
- package/knowledge/08-organization/00-vision-mission.md +113 -0
- package/knowledge/{organization/ai-native-team.md → 08-organization/01-ai-native-culture.md} +1 -1
- package/knowledge/{organization/team-metrics.md → 08-organization/02-team-metrics.md} +1 -1
- package/knowledge/08-organization/03-committee-structure.md +54 -0
- package/knowledge/08-organization/04-governance-metrics.md +55 -0
- package/knowledge/08-organization/05-improvement-process.md +71 -0
- package/knowledge/08-organization/README.en.md +165 -0
- package/knowledge/08-organization/README.md +165 -0
- package/knowledge/09-templates/00-requirement-proposal.md +344 -0
- package/knowledge/09-templates/01-architecture-design.md +494 -0
- package/knowledge/09-templates/02-api-design.md +408 -0
- package/knowledge/09-templates/03-database-design.md +313 -0
- package/knowledge/09-templates/04-product-design.md +237 -0
- package/knowledge/09-templates/05-domain-business.md +388 -0
- package/knowledge/09-templates/06-test-design.md +268 -0
- package/knowledge/09-templates/07-evaluation-design.md +372 -0
- package/knowledge/09-templates/08-component-knowledge.md +272 -0
- package/knowledge/09-templates/09-best-practices.md +218 -0
- package/knowledge/{environment/middleware-knowledge.md → 09-templates/10-middleware-knowledge.md} +106 -1
- package/knowledge/09-templates/README.en.md +222 -0
- package/knowledge/09-templates/README.md +216 -0
- package/knowledge/README.en.md +372 -0
- package/knowledge/README.md +354 -99
- package/package.json +1 -1
- package/plugins/.claude-plugin/plugin.json +460 -81
- package/plugins/agents/roles/ceo.md +1 -1
- package/plugins/agents/roles/product-owner.md +1 -1
- package/plugins/agents/roles/tech-lead.md +1 -1
- package/plugins/agents/support/consistency-checker.md +36 -3
- package/plugins/agents/support/monitoring-agent.md +215 -0
- package/plugins/agents/support/safety-auditor.md +2 -2
- package/plugins/agents/support/stage-gate-evaluator.md +95 -11
- package/plugins/agents/support/test-coverage-reviewer.md +1 -1
- package/plugins/benchmarks/templates/README.md +165 -13
- package/plugins/benchmarks/templates/commands/apply-template.yaml +108 -0
- package/plugins/benchmarks/templates/commands/archive-template.yaml +65 -0
- package/plugins/benchmarks/templates/commands/env-export-template.yaml +64 -0
- package/plugins/benchmarks/templates/commands/env-sync-template.yaml +104 -0
- package/plugins/benchmarks/templates/commands/env-template-template.yaml +96 -0
- package/plugins/benchmarks/templates/commands/env-template.yaml +58 -0
- package/plugins/benchmarks/templates/commands/env-update-template.yaml +110 -0
- package/plugins/benchmarks/templates/commands/env-validate-template.yaml +95 -0
- package/plugins/benchmarks/templates/commands/field-evolve-template.yaml +104 -0
- package/plugins/benchmarks/templates/commands/project-evolve-template.yaml +104 -0
- package/plugins/benchmarks/templates/commands/propose-template.yaml +88 -0
- package/plugins/benchmarks/templates/commands/review-template.yaml +124 -0
- package/plugins/benchmarks/templates/commands/run-template.yaml +127 -0
- package/plugins/benchmarks/templates/commands/test-template.yaml +149 -0
- package/plugins/benchmarks/templates/pipeline/experiment-template.yaml +92 -0
- package/plugins/benchmarks/templates/pipeline/hotfix-template.yaml +81 -0
- package/plugins/benchmarks/templates/skills/agile-iteration-template.yaml +78 -0
- package/plugins/benchmarks/templates/skills/benchmark-executor-template.yaml +114 -0
- package/plugins/benchmarks/templates/skills/benchmark-generator-template.yaml +52 -0
- package/plugins/benchmarks/templates/skills/delivery-stage-template.yaml +130 -0
- package/plugins/benchmarks/templates/skills/design-stage-template.yaml +131 -0
- package/plugins/benchmarks/templates/skills/experiment-iteration-template.yaml +60 -0
- package/plugins/benchmarks/templates/skills/exploration-phase-template.yaml +114 -0
- package/plugins/benchmarks/templates/skills/field-evolve-analyzer-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/field-evolve-distiller-template.yaml +34 -0
- package/plugins/benchmarks/templates/skills/field-evolve-executor-template.yaml +50 -0
- package/plugins/benchmarks/templates/skills/field-evolve-fixer-template.yaml +52 -0
- package/plugins/benchmarks/templates/skills/field-evolve-learner-template.yaml +33 -0
- package/plugins/benchmarks/templates/skills/field-evolve-scanner-template.yaml +74 -0
- package/plugins/benchmarks/templates/skills/field-evolve-template.yaml +71 -0
- package/plugins/benchmarks/templates/skills/field-evolve-verifier-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/hotfix-iteration-template.yaml +54 -0
- package/plugins/benchmarks/templates/skills/implementation-stage-template.yaml +127 -0
- package/plugins/benchmarks/templates/skills/layer1-validation-template.yaml +121 -0
- package/plugins/benchmarks/templates/skills/project-evolve-analyzer-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/project-evolve-fixer-template.yaml +52 -0
- package/plugins/benchmarks/templates/skills/project-evolve-generator-template.yaml +34 -0
- package/plugins/benchmarks/templates/skills/project-evolve-learner-template.yaml +50 -0
- package/plugins/benchmarks/templates/skills/project-evolve-reviewer-template.yaml +50 -0
- package/plugins/benchmarks/templates/skills/project-evolve-scanner-template.yaml +75 -0
- package/plugins/benchmarks/templates/skills/project-evolve-template.yaml +72 -0
- package/plugins/benchmarks/templates/skills/project-evolve-verifier-template.yaml +51 -0
- package/plugins/benchmarks/templates/skills/skill-forge-template.yaml +117 -0
- package/plugins/benchmarks/templates/skills/startup-guard-template.yaml +103 -0
- package/plugins/benchmarks/templates/skills/testing-stage-template.yaml +146 -0
- package/plugins/benchmarks/templates/skills/waterfall-iteration-template.yaml +55 -0
- package/plugins/commands/README.en.md +2 -2
- package/plugins/commands/README.md +2 -2
- package/plugins/commands/apply.md +102 -16
- package/plugins/commands/archive.md +60 -4
- package/plugins/commands/env-sync.md +1047 -406
- package/plugins/commands/env-template.md +11 -135
- package/plugins/commands/env-update.md +1 -1
- package/plugins/commands/env-validate.md +3 -3
- package/plugins/commands/explore.md +118 -1
- package/plugins/commands/field-evolve.md +51 -175
- package/plugins/commands/project-evolve.md +167 -68
- package/plugins/commands/propose.md +97 -6
- package/plugins/commands/review.md +5 -5
- package/plugins/commands/run.md +841 -13
- package/plugins/commands/status.md +138 -17
- package/plugins/commands/test.md +389 -0
- package/plugins/hooks/constitution-guard.js +1 -1
- package/plugins/hooks/environment-autocommit.js +366 -24
- package/plugins/hooks/environment-manager.js +3 -2
- package/plugins/hooks/execution-tracker.js +109 -4
- package/plugins/hooks/layer1-validator.js +117 -1
- package/plugins/hooks/lib/auto-fix-loop.js +605 -0
- package/plugins/hooks/lib/environment-config-loader.js +11 -7
- package/plugins/hooks/lib/hook-state-manager.js +98 -0
- package/plugins/hooks/lib/memory-extractor.js +27 -5
- package/plugins/hooks/lib/memory-manager.js +1 -1
- package/plugins/hooks/lib/test-auto-fix.test.js +194 -0
- package/plugins/hooks/monitoring-trigger.js +467 -0
- package/plugins/skills/README.en.md +15 -3
- package/plugins/skills/README.md +21 -11
- package/plugins/skills/agile-iteration/SKILL.md +187 -0
- package/plugins/skills/delivery-stage/SKILL.md +133 -12
- package/plugins/skills/design-stage/SKILL.md +103 -12
- package/plugins/skills/experiment-evaluator/SKILL.md +271 -0
- package/plugins/skills/experiment-iteration/SKILL.md +154 -0
- package/plugins/skills/exploration-phase/SKILL.md +93 -10
- package/plugins/skills/field-evolve-analyzer/SKILL.md +65 -0
- package/plugins/skills/field-evolve-distiller/SKILL.md +66 -0
- package/plugins/skills/field-evolve-executor/SKILL.md +94 -0
- package/plugins/skills/field-evolve-executor/executor.js +342 -0
- package/plugins/skills/field-evolve-fixer/SKILL.md +69 -0
- package/plugins/skills/field-evolve-learner/SKILL.md +65 -0
- package/plugins/skills/field-evolve-scanner/SKILL.md +87 -0
- package/plugins/skills/field-evolve-scanner/scripts/fallback-scanner.js +288 -0
- package/plugins/skills/field-evolve-verifier/SKILL.md +64 -0
- package/plugins/skills/hotfix-iteration/SKILL.md +279 -0
- package/plugins/skills/implementation-stage/SKILL.md +156 -15
- package/plugins/skills/layer1-validation/SKILL.md +1 -1
- package/plugins/skills/pending-dashboard/SKILL.md +9 -8
- package/plugins/skills/project-evolve-analyzer/SKILL.md +95 -0
- package/plugins/skills/project-evolve-fixer/SKILL.md +99 -0
- package/plugins/skills/project-evolve-generator/SKILL.md +149 -0
- package/plugins/skills/project-evolve-learner/SKILL.md +103 -0
- package/plugins/skills/project-evolve-reviewer/SKILL.md +104 -0
- package/plugins/skills/project-evolve-scanner/SKILL.md +95 -0
- package/plugins/skills/project-evolve-scanner/scripts/dependency-reuse-checker.js +395 -0
- package/plugins/skills/project-evolve-scanner/scripts/subsystem-coverage.js +315 -0
- package/plugins/skills/project-evolve-verifier/SKILL.md +105 -0
- package/plugins/skills/requirement-stage/SKILL.md +47 -13
- package/plugins/skills/skill-forge/SKILL.md +2 -2
- package/plugins/skills/testing-stage/SKILL.md +583 -8
- package/plugins/skills/waterfall-iteration/SKILL.md +115 -0
- package/scripts/cli/index.js +1 -1
- package/scripts/cli/init.js +30 -4
- package/scripts/cli/list.js +3 -2
- package/scripts/config/commands.config.js +8 -8
- package/scripts/config/hooks.config.js +1 -1
- package/scripts/install/constants.js +204 -165
- package/scripts/state.js +210 -1
- package/knowledge/config/README.en.md +0 -44
- package/knowledge/config/README.md +0 -44
- package/knowledge/config/role-composition.yaml +0 -98
- package/knowledge/config/team-triggers.yaml +0 -198
- package/knowledge/domain/README.md +0 -115
- package/knowledge/domain/flows/README.md +0 -194
- package/knowledge/domain/glossary.md +0 -143
- package/knowledge/domain/rules.md +0 -138
- package/knowledge/environment/component-knowledge.md +0 -316
- package/knowledge/environment/detection-patterns.yaml +0 -502
- package/knowledge/environment/template-registry.md +0 -321
- package/knowledge/guides/requirement-engineering.md +0 -329
- package/knowledge/guides/system-design.md +0 -352
- package/knowledge/principles/constitution.md +0 -134
- package/knowledge/principles/core-principles.md +0 -368
- package/knowledge/principles/design-philosophy.md +0 -877
- package/knowledge/process/README.en.md +0 -38
- package/knowledge/process/README.md +0 -48
- package/knowledge/templates/ai-evaluation.md +0 -150
- package/knowledge/templates/api-design.md +0 -117
- package/knowledge/templates/database-design.md +0 -132
- package/knowledge/templates/domain-driven-design.md +0 -321
- package/knowledge/templates/product-proposal.md +0 -201
- package/knowledge/templates/system-design.md +0 -227
- package/knowledge/templates/task-breakdown.md +0 -107
- package/knowledge/templates/test-case.md +0 -170
- package/plugins/commands/validate.md +0 -108
- package/plugins/skills/benchmark-executor/README.md +0 -93
- package/plugins/skills/evolution-process/SKILL.md +0 -291
- package/plugins/skills/project-evolution/SKILL.md +0 -847
- package/scripts/evolution/evolution-router.js +0 -273
- package/scripts/evolution/evolution-signal-collector.js +0 -307
- package/scripts/evolution/knowledge-loader.js +0 -346
- package/scripts/evolution/marketplace.js +0 -317
- package/scripts/evolution/version-manager.js +0 -371
- /package/knowledge/{process → 02-process}/01-requirement.md +0 -0
- /package/knowledge/{process → 02-process}/02-design.md +0 -0
- /package/knowledge/{process → 02-process}/03-implementation.md +0 -0
- /package/knowledge/{process → 02-process}/04-review.md +0 -0
- /package/knowledge/{process → 02-process}/05-testing.md +0 -0
- /package/knowledge/{process → 02-process}/06-delivery.md +0 -0
- /package/knowledge/{guides/stages/design-planner.md → 03-guides/03-design-solution.md} +0 -0
- /package/knowledge/{guides/stages/code-implementer.md → 03-guides/04-implement-code.md} +0 -0
- /package/knowledge/{guides/stages/test-planner.md → 03-guides/05-plan-testing.md} +0 -0
- /package/knowledge/{guides/stages/test-generator.md → 03-guides/06-generate-tests.md} +0 -0
- /package/knowledge/{guides/stages/release-checker.md → 03-guides/07-check-release.md} +0 -0
- /package/knowledge/{guides/stages/requirement-reviewer.md → 03-guides/09-review-requirement.md} +0 -0
- /package/knowledge/{guides/stages/design-reviewer.md → 03-guides/10-review-design.md} +0 -0
- /package/knowledge/{guides/stages/code-reviewer.md → 03-guides/11-review-code.md} +0 -0
- /package/knowledge/{guides/stages/test-reviewer.md → 03-guides/12-review-testing.md} +0 -0
- /package/knowledge/{guides/stages/security-reviewer.md → 03-guides/13-audit-security.md} +0 -0
- /package/knowledge/{guides/stages/consistency-checker.md → 03-guides/14-check-consistency.md} +0 -0
- /package/knowledge/{guides/stages/unit-test-runner.md → 03-guides/15-run-unit-tests.md} +0 -0
- /package/knowledge/{guides/stages/integration-test-runner.md → 03-guides/16-run-integration-tests.md} +0 -0
- /package/knowledge/{guides/stages/test-context-analyzer.md → 03-guides/17-analyze-test-context.md} +0 -0
- /package/knowledge/{guides/support/practice-logger.md → 03-guides/18-log-practice.md} +0 -0
- /package/knowledge/{guides/support/skill-validator.md → 03-guides/21-validate-skill.md} +0 -0
- /package/knowledge/{guides/support/scope-inference.md → 03-guides/23-infer-scope.md} +0 -0
- /package/knowledge/{guides/support/component-discovery.md → 03-guides/25-discover-component.md} +0 -0
- /package/knowledge/{guides/support/environment-scanner.md → 03-guides/27-scan-environment.md} +0 -0
- /package/knowledge/{guides/support/environment-validator.md → 03-guides/28-validate-environment.md} +0 -0
- /package/knowledge/{guides/support/knowledge-generator.md → 03-guides/29-generate-knowledge.md} +0 -0
- /package/knowledge/{guides/support/ai-capability-analyzer.md → 03-guides/30-analyze-ai-capability.md} +0 -0
- /package/knowledge/{guides/support/ai-component-analyzer.md → 03-guides/31-analyze-ai-component.md} +0 -0
- /package/knowledge/{guides/support/ai-agent-analyzer.md → 03-guides/32-analyze-ai-agent.md} +0 -0
- /package/knowledge/{guides/support/ai-rag-analyzer.md → 03-guides/33-analyze-ai-rag.md} +0 -0
- /package/knowledge/{guides/support/ai-task-assessor.md → 03-guides/34-assess-ai-task.md} +0 -0
- /package/knowledge/{guides/support/ai-pipeline-evaluator.md → 03-guides/35-evaluate-ai-pipeline.md} +0 -0
- /package/knowledge/{guides/support/ai-artifact-evaluator.md → 03-guides/36-evaluate-ai-artifact.md} +0 -0
- /package/knowledge/{guides/support/ai-evaluation-planner.md → 03-guides/37-plan-ai-evaluation.md} +0 -0
- /package/knowledge/{guides/support/ai-path-evaluator.md → 03-guides/38-evaluate-ai-path.md} +0 -0
- /package/knowledge/{guides/support/ai-data-validator.md → 03-guides/39-validate-ai-data.md} +0 -0
- /package/knowledge/{guides/support/ai-anomaly-analyzer.md → 03-guides/40-detect-ai-anomaly.md} +0 -0
- /package/knowledge/{guides/support/ai-test-diagnostics.md → 03-guides/41-diagnose-ai-test.md} +0 -0
- /package/knowledge/{guides/support/test-runner.md → 03-guides/45-test-runner.md} +0 -0
- /package/knowledge/{checklists/test.md → 04-checklists/03-test.md} +0 -0
- /package/knowledge/{config/team-stage.yaml → 05-config/01-team-stage.yaml} +0 -0
- /package/knowledge/{config/role-extensions.yaml → 05-config/04-role-extensions.yaml} +0 -0
|
@@ -200,6 +200,104 @@ export function hasLayer1Execution(projectRoot, stageKey) {
|
|
|
200
200
|
return stageData?.layer1Results && Object.keys(stageData.layer1Results).length > 0;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* 获取当前阶段的子系统列表
|
|
205
|
+
* @param {string} projectRoot - 项目根目录
|
|
206
|
+
* @returns {Array} 子系统状态数组
|
|
207
|
+
*/
|
|
208
|
+
export function getCurrentStageSubsystems(projectRoot) {
|
|
209
|
+
const state = getState(projectRoot, true);
|
|
210
|
+
if (!state?.stages?.[state.currentStage]?.subsystems) {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
return state.stages[state.currentStage].subsystems;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 获取子系统状态
|
|
218
|
+
* @param {string} projectRoot - 项目根目录
|
|
219
|
+
* @param {string} subsystemName - 子系统名称
|
|
220
|
+
* @returns {Object|null} 子系统状态
|
|
221
|
+
*/
|
|
222
|
+
export function getSubsystemState(projectRoot, subsystemName) {
|
|
223
|
+
const subsystems = getCurrentStageSubsystems(projectRoot);
|
|
224
|
+
return subsystems.find(s => s.name === subsystemName) || null;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 更新子系统状态
|
|
229
|
+
* @param {string} projectRoot - 项目根目录
|
|
230
|
+
* @param {string} subsystemName - 子系统名称
|
|
231
|
+
* @param {Object} updates - 状态更新
|
|
232
|
+
* @returns {boolean} 是否成功
|
|
233
|
+
*/
|
|
234
|
+
export function updateSubsystemState(projectRoot, subsystemName, updates) {
|
|
235
|
+
const state = getState(projectRoot, false);
|
|
236
|
+
if (!state?.stages?.[state.currentStage]?.subsystems) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const subsystem = state.stages[state.currentStage].subsystems.find(s => s.name === subsystemName);
|
|
241
|
+
if (!subsystem) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
Object.assign(subsystem, updates);
|
|
246
|
+
return updateState(projectRoot, state);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 检测命令是否针对特定子系统
|
|
251
|
+
* @param {string} command - Bash 命令
|
|
252
|
+
* @param {Array} subsystems - 子系统配置
|
|
253
|
+
* @returns {string|null} 匹配的系统名称或 null
|
|
254
|
+
*/
|
|
255
|
+
export function detectSubsystemFromCommand(command, subsystems) {
|
|
256
|
+
if (!command || !subsystems || subsystems.length === 0) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// 检测模式:支持 Maven, npm, Gradle, Go, Python
|
|
261
|
+
const patterns = [
|
|
262
|
+
// Maven
|
|
263
|
+
/-f\s+([^/\s]+)\/pom\.xml/i, // mvn -f backend/pom.xml
|
|
264
|
+
/--file\s+([^/\s]+)\/pom\.xml/i, // mvn --file backend/pom.xml
|
|
265
|
+
|
|
266
|
+
// Gradle
|
|
267
|
+
/-p\s+([^/\s]+)/i, // gradle -p backend
|
|
268
|
+
/--project-dir\s+([^/\s]+)/i, // gradle --project-dir backend
|
|
269
|
+
/--build-file\s+([^/\s]+)/i, // gradle --build-file backend/build.gradle
|
|
270
|
+
|
|
271
|
+
// npm
|
|
272
|
+
/--prefix\s+([^/\s]+)/i, // npm --prefix frontend
|
|
273
|
+
|
|
274
|
+
// Go
|
|
275
|
+
/-C\s+([^/\s]+)/i, // go -C backend build
|
|
276
|
+
|
|
277
|
+
// cd 命令(通用)
|
|
278
|
+
/cd\s+([^/\s]+)\s*&&/i, // cd ai &&
|
|
279
|
+
/cd\s+([^/\s]+)\s*;/i, // cd ai;
|
|
280
|
+
|
|
281
|
+
// 路径前缀(通用)
|
|
282
|
+
/^([^/\s]+)\//, // backend/src/...
|
|
283
|
+
];
|
|
284
|
+
|
|
285
|
+
for (const pattern of patterns) {
|
|
286
|
+
const match = command.match(pattern);
|
|
287
|
+
if (match) {
|
|
288
|
+
const pathPrefix = match[1];
|
|
289
|
+
const matchedSubsystem = subsystems.find(s =>
|
|
290
|
+
s.path === pathPrefix || s.name === pathPrefix || s.path.endsWith('/' + pathPrefix)
|
|
291
|
+
);
|
|
292
|
+
if (matchedSubsystem) {
|
|
293
|
+
return matchedSubsystem.name;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
|
|
203
301
|
// ============================================================
|
|
204
302
|
// Metrics 操作
|
|
205
303
|
// ============================================================
|
|
@@ -23,37 +23,59 @@ import {
|
|
|
23
23
|
} from './memory-manager.js';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* 提取模式定义(支持中英文)
|
|
27
27
|
*/
|
|
28
28
|
const EXTRACTION_PATTERNS = {
|
|
29
29
|
// 目标/指标相关 → 项目北极星
|
|
30
30
|
goals: [
|
|
31
|
+
// 中文模式
|
|
31
32
|
{ patterns: [/我们的目标是/, /项目目标/, /产品目标/], type: 'mission' },
|
|
32
33
|
{ patterns: [/北极星指标/, /核心指标/, /关键指标/], type: 'northStarMetric' },
|
|
33
34
|
{ patterns: [/关键结果/, /KR\d*/, /里程碑/], type: 'keyResult' },
|
|
34
|
-
{ patterns: [/愿景/, /未来展望/, /长期目标/], type: 'vision' }
|
|
35
|
+
{ patterns: [/愿景/, /未来展望/, /长期目标/], type: 'vision' },
|
|
36
|
+
// 英文模式
|
|
37
|
+
{ patterns: [/our goal is/, /project goal/, /product goal/i], type: 'mission' },
|
|
38
|
+
{ patterns: [/north star/, /northstar/, /key metric/, /core metric/i], type: 'northStarMetric' },
|
|
39
|
+
{ patterns: [/key result/, /KR\d*/, /milestone/i], type: 'keyResult' },
|
|
40
|
+
{ patterns: [/vision/, /future/, /long-term goal/i], type: 'vision' }
|
|
35
41
|
],
|
|
36
42
|
|
|
37
43
|
// 偏好相关 → 全局/项目偏好
|
|
38
44
|
preferences: [
|
|
45
|
+
// 中文模式
|
|
39
46
|
{ patterns: [/我们偏好/, /我们喜欢/, /倾向于/], type: 'preference' },
|
|
40
47
|
{ patterns: [/不要/, /禁止/, /不允许/, /不能/], type: 'constraint' },
|
|
41
48
|
{ patterns: [/默认使用/, /默认配置/, /标准做法/], type: 'default' },
|
|
42
|
-
{ patterns: [/风格/, /习惯/, /惯例/], type: 'style' }
|
|
49
|
+
{ patterns: [/风格/, /习惯/, /惯例/], type: 'style' },
|
|
50
|
+
// 英文模式
|
|
51
|
+
{ patterns: [/we prefer/, /we like/, /倾向/], type: 'preference' },
|
|
52
|
+
{ patterns: [/don't/, /do not/, /not allowed/, /forbidden/], type: 'constraint' },
|
|
53
|
+
{ patterns: [/default to/, /default use/, /standard practice/], type: 'default' },
|
|
54
|
+
{ patterns: [/style/, /convention/, /habit/], type: 'style' }
|
|
43
55
|
],
|
|
44
56
|
|
|
45
57
|
// 决策相关 → 项目架构记录
|
|
46
58
|
decisions: [
|
|
59
|
+
// 中文模式
|
|
47
60
|
{ patterns: [/决定采用/, /选择使用/, /选定/, /最终方案/], type: 'decision' },
|
|
48
61
|
{ patterns: [/权衡后/, /综合考虑/, /对比之后/], type: 'tradeoff' },
|
|
49
|
-
{ patterns: [/放弃/, /不采用/, /排除/], type: 'rejected' }
|
|
62
|
+
{ patterns: [/放弃/, /不采用/, /排除/], type: 'rejected' },
|
|
63
|
+
// 英文模式
|
|
64
|
+
{ patterns: [/decided to/, /choosing/, /selected/, /final decision/], type: 'decision' },
|
|
65
|
+
{ patterns: [/trade-off/, /tradeoff/, /balanced/, /considering/], type: 'tradeoff' },
|
|
66
|
+
{ patterns: [/abandoned/, /not using/, /rejected/, /excluded/], type: 'rejected' }
|
|
50
67
|
],
|
|
51
68
|
|
|
52
69
|
// 技术栈相关 → 项目技术栈
|
|
53
70
|
techStack: [
|
|
71
|
+
// 中文模式
|
|
54
72
|
{ patterns: [/使用.*框架/, /技术栈/, /技术选型/], type: 'framework' },
|
|
55
73
|
{ patterns: [/部署到/, /运行环境/, /基础设施/], type: 'environment' },
|
|
56
|
-
{ patterns: [/依赖/, /库/, /包/], type: 'dependency' }
|
|
74
|
+
{ patterns: [/依赖/, /库/, /包/], type: 'dependency' },
|
|
75
|
+
// 英文模式
|
|
76
|
+
{ patterns: [/using.*framework/, /tech stack/, /technology stack/], type: 'framework' },
|
|
77
|
+
{ patterns: [/deployed to/, /hosted on/, /infrastructure/], type: 'environment' },
|
|
78
|
+
{ patterns: [/dependenc/, /library/, /package/], type: 'dependency' }
|
|
57
79
|
]
|
|
58
80
|
};
|
|
59
81
|
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AutoSpec 自主修复机制测试脚本
|
|
5
|
+
*
|
|
6
|
+
* 用于验证 auto-fix-loop 模块的基本功能
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { dirname, join } from 'path';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
// projectRoot = plugins/hooks/lib/../../.. = 项目根目录
|
|
16
|
+
const projectRoot = join(__dirname, '../../..');
|
|
17
|
+
|
|
18
|
+
// 导入 auto-fix-loop 模块
|
|
19
|
+
const { autoFixLoop, analyzeErrorType, getRepairZone, REPAIR_ZONES, ERROR_TYPES, isFrozenFile } =
|
|
20
|
+
await import('./auto-fix-loop.js');
|
|
21
|
+
|
|
22
|
+
console.log('=== AutoSpec 自主修复机制测试 ===\n');
|
|
23
|
+
|
|
24
|
+
let passed = 0;
|
|
25
|
+
let failed = 0;
|
|
26
|
+
|
|
27
|
+
function test(name, actual, expected) {
|
|
28
|
+
const pass = actual === expected;
|
|
29
|
+
if (pass) {
|
|
30
|
+
console.log(`✓ ${name}`);
|
|
31
|
+
passed++;
|
|
32
|
+
} else {
|
|
33
|
+
console.log(`✗ ${name}`);
|
|
34
|
+
console.log(` 期望:${expected}`);
|
|
35
|
+
console.log(` 实际:${actual}`);
|
|
36
|
+
failed++;
|
|
37
|
+
}
|
|
38
|
+
return pass;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 测试 1: 错误类型分析
|
|
42
|
+
console.log('--- 测试 1: 错误类型分析 ---');
|
|
43
|
+
|
|
44
|
+
test(
|
|
45
|
+
'依赖错误 - npm',
|
|
46
|
+
analyzeErrorType({ errorOutput: 'Cannot find module "lodash"' }),
|
|
47
|
+
ERROR_TYPES.DEPENDENCY
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
test(
|
|
51
|
+
'依赖错误 - Maven',
|
|
52
|
+
analyzeErrorType({ errorOutput: 'package com.enterprise.tracer does not exist' }),
|
|
53
|
+
ERROR_TYPES.DEPENDENCY
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
test(
|
|
57
|
+
'配置错误 - JSON',
|
|
58
|
+
analyzeErrorType({ errorOutput: 'Invalid JSON configuration' }),
|
|
59
|
+
ERROR_TYPES.CONFIG
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
test(
|
|
63
|
+
'代码错误 - 语法',
|
|
64
|
+
analyzeErrorType({ errorOutput: 'SyntaxError: Unexpected token' }),
|
|
65
|
+
ERROR_TYPES.CODE
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
test(
|
|
69
|
+
'资源错误 - 文件不存在',
|
|
70
|
+
analyzeErrorType({ errorOutput: 'ENOENT: no such file or directory' }),
|
|
71
|
+
ERROR_TYPES.RESOURCE
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
test(
|
|
75
|
+
'验证错误 - 测试失败',
|
|
76
|
+
analyzeErrorType({ command: 'npm test', errorOutput: '1 failing' }),
|
|
77
|
+
ERROR_TYPES.VALIDATION
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
test(
|
|
81
|
+
'逻辑错误 - 默认',
|
|
82
|
+
analyzeErrorType({ errorOutput: 'Business logic error' }),
|
|
83
|
+
ERROR_TYPES.LOGIC
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// 测试 2: 修复区域判断
|
|
87
|
+
console.log('\n--- 测试 2: 修复区域判断 ---');
|
|
88
|
+
|
|
89
|
+
test(
|
|
90
|
+
'冻结区 - constitution.md',
|
|
91
|
+
getRepairZone('knowledge/01-principles/09-constitution.md', ERROR_TYPES.CONFIG),
|
|
92
|
+
REPAIR_ZONES.FROZEN
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
test(
|
|
96
|
+
'冻结区 - evolution.md',
|
|
97
|
+
getRepairZone('knowledge/01-principles/10-evolution-mechanism.md', ERROR_TYPES.CODE),
|
|
98
|
+
REPAIR_ZONES.FROZEN
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
test(
|
|
102
|
+
'自由区 - 依赖错误',
|
|
103
|
+
getRepairZone(null, ERROR_TYPES.DEPENDENCY),
|
|
104
|
+
REPAIR_ZONES.FREE
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
test(
|
|
108
|
+
'自由区 - 配置错误',
|
|
109
|
+
getRepairZone('.env', ERROR_TYPES.CONFIG),
|
|
110
|
+
REPAIR_ZONES.FREE
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
test(
|
|
114
|
+
'受控区 - 逻辑错误',
|
|
115
|
+
getRepairZone('src/service.js', ERROR_TYPES.LOGIC),
|
|
116
|
+
REPAIR_ZONES.CONTROLLED
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// 测试 3: 冻结文件检测
|
|
120
|
+
console.log('\n--- 测试 3: 冻结文件检测 ---');
|
|
121
|
+
|
|
122
|
+
test(
|
|
123
|
+
'冻结文件 - constitution.md',
|
|
124
|
+
isFrozenFile('knowledge/01-principles/09-constitution.md'),
|
|
125
|
+
true
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
test(
|
|
129
|
+
'冻结文件 - evolution.md',
|
|
130
|
+
isFrozenFile('knowledge/01-principles/10-evolution-mechanism.md'),
|
|
131
|
+
true
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
test(
|
|
135
|
+
'非冻结文件 - index.js',
|
|
136
|
+
isFrozenFile('src/index.js'),
|
|
137
|
+
false
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
test(
|
|
141
|
+
'非冻结文件 - pom.xml',
|
|
142
|
+
isFrozenFile('pom.xml'),
|
|
143
|
+
false
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// 测试 4: 自主修复循环(模拟)
|
|
147
|
+
console.log('\n--- 测试 4: 自主修复循环(模拟)---');
|
|
148
|
+
|
|
149
|
+
// 模拟冻结区文件修改尝试
|
|
150
|
+
const frozenResult = await autoFixLoop({
|
|
151
|
+
errorType: ERROR_TYPES.CODE,
|
|
152
|
+
errorMessage: 'Cannot modify constitution',
|
|
153
|
+
errorLocation: 'knowledge/01-principles/09-constitution.md',
|
|
154
|
+
retryCount: 0
|
|
155
|
+
}, projectRoot, null);
|
|
156
|
+
|
|
157
|
+
test(
|
|
158
|
+
'冻结区修复被阻止',
|
|
159
|
+
frozenResult.status,
|
|
160
|
+
'blocked'
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
test(
|
|
164
|
+
'冻结区阻止原因',
|
|
165
|
+
frozenResult.reason,
|
|
166
|
+
'frozen_zone'
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
// 模拟逻辑错误(需要人工确认)
|
|
170
|
+
const logicResult = await autoFixLoop({
|
|
171
|
+
errorType: ERROR_TYPES.LOGIC,
|
|
172
|
+
errorMessage: 'Business logic unclear',
|
|
173
|
+
retryCount: 0
|
|
174
|
+
}, projectRoot, null);
|
|
175
|
+
|
|
176
|
+
test(
|
|
177
|
+
'逻辑错误需要人工确认',
|
|
178
|
+
logicResult.status,
|
|
179
|
+
'needs_human'
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// 总结
|
|
183
|
+
console.log('\n=== 测试总结 ===');
|
|
184
|
+
console.log(`通过:${passed}`);
|
|
185
|
+
console.log(`失败:${failed}`);
|
|
186
|
+
console.log(`总计:${passed + failed}`);
|
|
187
|
+
|
|
188
|
+
if (failed > 0) {
|
|
189
|
+
console.log('\n❌ 部分测试失败');
|
|
190
|
+
process.exit(1);
|
|
191
|
+
} else {
|
|
192
|
+
console.log('\n✅ 所有测试通过');
|
|
193
|
+
process.exit(0);
|
|
194
|
+
}
|