@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
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version Manager - 版本管理器
|
|
3
|
-
*
|
|
4
|
-
* 实现版本标签管理、回滚逻辑、历史查询
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import os from 'os';
|
|
10
|
-
import {
|
|
11
|
-
GLOBAL_AUTOSPEC_DIR,
|
|
12
|
-
KNOWLEDGE_SCOPE
|
|
13
|
-
} from '../install/constants.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 获取全局技能目录
|
|
17
|
-
* @returns {string} 全局技能目录
|
|
18
|
-
*/
|
|
19
|
-
function getGlobalSkillsDir() {
|
|
20
|
-
return path.join(os.homedir(), GLOBAL_AUTOSPEC_DIR, 'skills');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 获取组织技能目录
|
|
25
|
-
* @param {string} orgName - 组织名称
|
|
26
|
-
* @returns {string} 组织技能目录
|
|
27
|
-
*/
|
|
28
|
-
function getOrgSkillsDir(orgName) {
|
|
29
|
-
return path.join(os.homedir(), '.claude/autospec/orgs', orgName, 'skills');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 安全地读取 JSON 文件
|
|
34
|
-
* @param {string} filePath - 文件路径
|
|
35
|
-
* @param {any} defaultValue - 默认值
|
|
36
|
-
* @returns {any} 解析后的数据
|
|
37
|
-
*/
|
|
38
|
-
function safeReadJson(filePath, defaultValue = null) {
|
|
39
|
-
try {
|
|
40
|
-
if (!fs.existsSync(filePath)) {
|
|
41
|
-
return defaultValue;
|
|
42
|
-
}
|
|
43
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
44
|
-
return JSON.parse(content);
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return defaultValue;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 安全地写入 JSON 文件
|
|
52
|
-
* @param {string} filePath - 文件路径
|
|
53
|
-
* @param {any} data - 数据
|
|
54
|
-
* @returns {boolean} 是否成功
|
|
55
|
-
*/
|
|
56
|
-
function safeWriteJson(filePath, data) {
|
|
57
|
-
try {
|
|
58
|
-
const dir = path.dirname(filePath);
|
|
59
|
-
if (!fs.existsSync(dir)) {
|
|
60
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
61
|
-
}
|
|
62
|
-
fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
63
|
-
return true;
|
|
64
|
-
} catch (e) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 解析版本号
|
|
71
|
-
* @param {string} version - 版本号字符串
|
|
72
|
-
* @returns {Object} 解析结果 { major, minor, patch, raw }
|
|
73
|
-
*/
|
|
74
|
-
function parseVersion(version) {
|
|
75
|
-
const match = version.match(/^v?(\d+)\.(\d+)\.(\d+)$/);
|
|
76
|
-
if (match) {
|
|
77
|
-
return {
|
|
78
|
-
major: parseInt(match[1], 10),
|
|
79
|
-
minor: parseInt(match[2], 10),
|
|
80
|
-
patch: parseInt(match[3], 10),
|
|
81
|
-
raw: version
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return { major: 0, minor: 0, patch: 0, raw: version };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 比较版本号
|
|
89
|
-
* @param {string} v1 - 版本1
|
|
90
|
-
* @param {string} v2 - 版本2
|
|
91
|
-
* @returns {number} -1: v1 < v2, 0: v1 = v2, 1: v1 > v2
|
|
92
|
-
*/
|
|
93
|
-
function compareVersions(v1, v2) {
|
|
94
|
-
const p1 = parseVersion(v1);
|
|
95
|
-
const p2 = parseVersion(v2);
|
|
96
|
-
|
|
97
|
-
if (p1.major !== p2.major) return p1.major - p2.major;
|
|
98
|
-
if (p1.minor !== p2.minor) return p1.minor - p2.minor;
|
|
99
|
-
return p1.patch - p2.patch;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 获取技能版本目录
|
|
104
|
-
* @param {string} skillName - 技能名称
|
|
105
|
-
* @param {string} scope - 作用域
|
|
106
|
-
* @param {string} orgName - 组织名称
|
|
107
|
-
* @returns {string} 技能版本目录
|
|
108
|
-
*/
|
|
109
|
-
function getSkillVersionDir(skillName, scope, orgName = null) {
|
|
110
|
-
const baseDir = scope === KNOWLEDGE_SCOPE.ORG
|
|
111
|
-
? getOrgSkillsDir(orgName)
|
|
112
|
-
: getGlobalSkillsDir();
|
|
113
|
-
|
|
114
|
-
return path.join(baseDir, skillName);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* 发布技能新版本
|
|
119
|
-
*
|
|
120
|
-
* @param {string} skillName - 技能名称
|
|
121
|
-
* @param {string} content - 技能内容
|
|
122
|
-
* @param {Object} options - 选项
|
|
123
|
-
* @returns {Object} 发布结果 { success, version, path }
|
|
124
|
-
*/
|
|
125
|
-
export function publishSkillVersion(skillName, content, options = {}) {
|
|
126
|
-
const { scope = KNOWLEDGE_SCOPE.GLOBAL, orgName = null, version = null, message = '' } = options;
|
|
127
|
-
|
|
128
|
-
const versionDir = getSkillVersionDir(skillName, scope, orgName);
|
|
129
|
-
|
|
130
|
-
// 确定版本号
|
|
131
|
-
const newVersion = version || getNextVersion(skillName, scope, orgName);
|
|
132
|
-
const versionPath = path.join(versionDir, `v${newVersion}`);
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
// 创建版本目录
|
|
136
|
-
if (!fs.existsSync(versionPath)) {
|
|
137
|
-
fs.mkdirSync(versionPath, { recursive: true });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 写入技能文件
|
|
141
|
-
const skillFilePath = path.join(versionPath, 'SKILL.md');
|
|
142
|
-
fs.writeFileSync(skillFilePath, content);
|
|
143
|
-
|
|
144
|
-
// 更新版本历史
|
|
145
|
-
const historyFilePath = path.join(versionDir, 'versions.json');
|
|
146
|
-
const history = safeReadJson(historyFilePath, { versions: [], latest: null });
|
|
147
|
-
|
|
148
|
-
history.versions = history.versions || [];
|
|
149
|
-
history.versions.push({
|
|
150
|
-
version: newVersion,
|
|
151
|
-
releasedAt: new Date().toISOString(),
|
|
152
|
-
message: message || `Release v${newVersion}`
|
|
153
|
-
});
|
|
154
|
-
history.latest = newVersion;
|
|
155
|
-
|
|
156
|
-
safeWriteJson(historyFilePath, history);
|
|
157
|
-
|
|
158
|
-
// 更新 latest 符号链接
|
|
159
|
-
const latestLink = path.join(versionDir, 'latest');
|
|
160
|
-
if (fs.existsSync(latestLink)) {
|
|
161
|
-
fs.unlinkSync(latestLink);
|
|
162
|
-
}
|
|
163
|
-
// 注意:符号链接创建可能需要管理员权限,这里用副本代替
|
|
164
|
-
fs.copyFileSync(skillFilePath, path.join(versionDir, 'SKILL.md'));
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
success: true,
|
|
168
|
-
version: newVersion,
|
|
169
|
-
path: skillFilePath
|
|
170
|
-
};
|
|
171
|
-
} catch (e) {
|
|
172
|
-
return {
|
|
173
|
-
success: false,
|
|
174
|
-
error: e.message
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 获取下一个版本号
|
|
181
|
-
* @param {string} skillName - 技能名称
|
|
182
|
-
* @param {string} scope - 作用域
|
|
183
|
-
* @param {string} orgName - 组织名称
|
|
184
|
-
* @returns {string} 下一个版本号
|
|
185
|
-
*/
|
|
186
|
-
function getNextVersion(skillName, scope, orgName = null) {
|
|
187
|
-
const versionDir = getSkillVersionDir(skillName, scope, orgName);
|
|
188
|
-
const historyFilePath = path.join(versionDir, 'versions.json');
|
|
189
|
-
const history = safeReadJson(historyFilePath, { versions: [] });
|
|
190
|
-
|
|
191
|
-
if (!history.versions || history.versions.length === 0) {
|
|
192
|
-
return '1.0.0';
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// 获取最新版本
|
|
196
|
-
const latestVersion = history.versions[history.versions.length - 1].version;
|
|
197
|
-
const parsed = parseVersion(latestVersion);
|
|
198
|
-
|
|
199
|
-
// 递增 patch 版本
|
|
200
|
-
parsed.patch += 1;
|
|
201
|
-
|
|
202
|
-
return `${parsed.major}.${parsed.minor}.${parsed.patch}`;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* 回滚到指定版本
|
|
207
|
-
*
|
|
208
|
-
* @param {string} skillName - 技能名称
|
|
209
|
-
* @param {string} targetVersion - 目标版本
|
|
210
|
-
* @param {Object} options - 选项
|
|
211
|
-
* @returns {Object} 回滚结果 { success, version }
|
|
212
|
-
*/
|
|
213
|
-
export function rollbackSkillVersion(skillName, targetVersion, options = {}) {
|
|
214
|
-
const { scope = KNOWLEDGE_SCOPE.GLOBAL, orgName = null } = options;
|
|
215
|
-
|
|
216
|
-
const versionDir = getSkillVersionDir(skillName, scope, orgName);
|
|
217
|
-
const versionPath = path.join(versionDir, `v${targetVersion}`);
|
|
218
|
-
const skillFilePath = path.join(versionPath, 'SKILL.md');
|
|
219
|
-
|
|
220
|
-
if (!fs.existsSync(skillFilePath)) {
|
|
221
|
-
return { success: false, error: `版本 v${targetVersion} 不存在` };
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
try {
|
|
225
|
-
// 读取目标版本内容
|
|
226
|
-
const content = fs.readFileSync(skillFilePath, 'utf-8');
|
|
227
|
-
|
|
228
|
-
// 写入当前版本(覆盖 latest)
|
|
229
|
-
const latestPath = path.join(versionDir, 'SKILL.md');
|
|
230
|
-
fs.writeFileSync(latestPath, content);
|
|
231
|
-
|
|
232
|
-
// 记录回滚历史
|
|
233
|
-
const historyFilePath = path.join(versionDir, 'versions.json');
|
|
234
|
-
const history = safeReadJson(historyFilePath, { versions: [], latest: null });
|
|
235
|
-
|
|
236
|
-
history.versions.push({
|
|
237
|
-
version: targetVersion,
|
|
238
|
-
action: 'rollback',
|
|
239
|
-
rolledBackAt: new Date().toISOString()
|
|
240
|
-
});
|
|
241
|
-
history.latest = targetVersion;
|
|
242
|
-
|
|
243
|
-
safeWriteJson(historyFilePath, history);
|
|
244
|
-
|
|
245
|
-
return {
|
|
246
|
-
success: true,
|
|
247
|
-
version: targetVersion
|
|
248
|
-
};
|
|
249
|
-
} catch (e) {
|
|
250
|
-
return {
|
|
251
|
-
success: false,
|
|
252
|
-
error: e.message
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* 获取版本历史
|
|
259
|
-
*
|
|
260
|
-
* @param {string} skillName - 技能名称
|
|
261
|
-
* @param {Object} options - 选项
|
|
262
|
-
* @returns {Object} 版本历史
|
|
263
|
-
*/
|
|
264
|
-
export function getVersionHistory(skillName, options = {}) {
|
|
265
|
-
const { scope = KNOWLEDGE_SCOPE.GLOBAL, orgName = null } = options;
|
|
266
|
-
|
|
267
|
-
const versionDir = getSkillVersionDir(skillName, scope, orgName);
|
|
268
|
-
const historyFilePath = path.join(versionDir, 'versions.json');
|
|
269
|
-
|
|
270
|
-
return safeReadJson(historyFilePath, { versions: [], latest: null });
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* 获取所有版本列表
|
|
275
|
-
*
|
|
276
|
-
* @param {string} skillName - 技能名称
|
|
277
|
-
* @param {Object} options - 选项
|
|
278
|
-
* @returns {Array} 版本列表
|
|
279
|
-
*/
|
|
280
|
-
export function listSkillVersions(skillName, options = {}) {
|
|
281
|
-
const { scope = KNOWLEDGE_SCOPE.GLOBAL, orgName = null } = options;
|
|
282
|
-
|
|
283
|
-
const versionDir = getSkillVersionDir(skillName, scope, orgName);
|
|
284
|
-
|
|
285
|
-
if (!fs.existsSync(versionDir)) {
|
|
286
|
-
return [];
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const entries = fs.readdirSync(versionDir, { withFileTypes: true });
|
|
290
|
-
const versions = [];
|
|
291
|
-
|
|
292
|
-
for (const entry of entries) {
|
|
293
|
-
if (entry.isDirectory() && entry.name.startsWith('v')) {
|
|
294
|
-
const versionPath = path.join(versionDir, entry.name, 'SKILL.md');
|
|
295
|
-
if (fs.existsSync(versionPath)) {
|
|
296
|
-
const stats = fs.statSync(versionPath);
|
|
297
|
-
versions.push({
|
|
298
|
-
version: entry.name.substring(1), // 去掉 'v' 前缀
|
|
299
|
-
path: versionPath,
|
|
300
|
-
releasedAt: stats.mtime.toISOString()
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// 按版本号排序
|
|
307
|
-
return versions.sort((a, b) => compareVersions(b.version, a.version));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* 获取指定版本内容
|
|
312
|
-
*
|
|
313
|
-
* @param {string} skillName - 技能名称
|
|
314
|
-
* @param {string} version - 版本号
|
|
315
|
-
* @param {Object} options - 选项
|
|
316
|
-
* @returns {string|null} 技能内容
|
|
317
|
-
*/
|
|
318
|
-
export function getSkillVersion(skillName, version, options = {}) {
|
|
319
|
-
const { scope = KNOWLEDGE_SCOPE.GLOBAL, orgName = null } = options;
|
|
320
|
-
|
|
321
|
-
const versionDir = getSkillVersionDir(skillName, scope, orgName);
|
|
322
|
-
const skillFilePath = path.join(versionDir, `v${version}`, 'SKILL.md');
|
|
323
|
-
|
|
324
|
-
try {
|
|
325
|
-
if (fs.existsSync(skillFilePath)) {
|
|
326
|
-
return fs.readFileSync(skillFilePath, 'utf-8');
|
|
327
|
-
}
|
|
328
|
-
return null;
|
|
329
|
-
} catch (e) {
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* 获取最新版本内容
|
|
336
|
-
*
|
|
337
|
-
* @param {string} skillName - 技能名称
|
|
338
|
-
* @param {Object} options - 选项
|
|
339
|
-
* @returns {string|null} 技能内容
|
|
340
|
-
*/
|
|
341
|
-
export function getLatestSkillVersion(skillName, options = {}) {
|
|
342
|
-
const { scope = KNOWLEDGE_SCOPE.GLOBAL, orgName = null } = options;
|
|
343
|
-
|
|
344
|
-
const versionDir = getSkillVersionDir(skillName, scope, orgName);
|
|
345
|
-
const latestPath = path.join(versionDir, 'SKILL.md');
|
|
346
|
-
|
|
347
|
-
try {
|
|
348
|
-
if (fs.existsSync(latestPath)) {
|
|
349
|
-
return fs.readFileSync(latestPath, 'utf-8');
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// 尝试从 versions.json 获取最新版本
|
|
353
|
-
const history = getVersionHistory(skillName, { scope, orgName });
|
|
354
|
-
if (history.latest) {
|
|
355
|
-
return getSkillVersion(skillName, history.latest, { scope, orgName });
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return null;
|
|
359
|
-
} catch (e) {
|
|
360
|
-
return null;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export default {
|
|
365
|
-
publishSkillVersion,
|
|
366
|
-
rollbackSkillVersion,
|
|
367
|
-
getVersionHistory,
|
|
368
|
-
listSkillVersions,
|
|
369
|
-
getSkillVersion,
|
|
370
|
-
getLatestSkillVersion
|
|
371
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/knowledge/{guides/stages/requirement-reviewer.md → 03-guides/09-review-requirement.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/knowledge/{guides/stages/consistency-checker.md → 03-guides/14-check-consistency.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/knowledge/{guides/stages/test-context-analyzer.md → 03-guides/17-analyze-test-context.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/knowledge/{guides/support/component-discovery.md → 03-guides/25-discover-component.md}
RENAMED
|
File without changes
|
/package/knowledge/{guides/support/environment-scanner.md → 03-guides/27-scan-environment.md}
RENAMED
|
File without changes
|
/package/knowledge/{guides/support/environment-validator.md → 03-guides/28-validate-environment.md}
RENAMED
|
File without changes
|
/package/knowledge/{guides/support/knowledge-generator.md → 03-guides/29-generate-knowledge.md}
RENAMED
|
File without changes
|
|
File without changes
|
/package/knowledge/{guides/support/ai-component-analyzer.md → 03-guides/31-analyze-ai-component.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/knowledge/{guides/support/ai-pipeline-evaluator.md → 03-guides/35-evaluate-ai-pipeline.md}
RENAMED
|
File without changes
|
/package/knowledge/{guides/support/ai-artifact-evaluator.md → 03-guides/36-evaluate-ai-artifact.md}
RENAMED
|
File without changes
|
/package/knowledge/{guides/support/ai-evaluation-planner.md → 03-guides/37-plan-ai-evaluation.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/knowledge/{guides/support/ai-anomaly-analyzer.md → 03-guides/40-detect-ai-anomaly.md}
RENAMED
|
File without changes
|
/package/knowledge/{guides/support/ai-test-diagnostics.md → 03-guides/41-diagnose-ai-test.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|