@chongyan/autospec 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +472 -0
- package/README.md +476 -0
- package/bin/autospec.js +3 -0
- package/knowledge/README.md +144 -0
- package/knowledge/checklists/code.md +182 -0
- package/knowledge/checklists/design.md +196 -0
- package/knowledge/checklists/release.md +70 -0
- package/knowledge/checklists/requirement.md +169 -0
- package/knowledge/checklists/test.md +46 -0
- package/knowledge/config/README.en.md +44 -0
- package/knowledge/config/README.md +44 -0
- package/knowledge/config/role-composition.yaml +98 -0
- package/knowledge/config/role-extensions.yaml +140 -0
- package/knowledge/config/skill-compositions.yaml +142 -0
- package/knowledge/config/team-stage.yaml +95 -0
- package/knowledge/config/team-tasks.yaml +139 -0
- package/knowledge/config/team-triggers.yaml +198 -0
- package/knowledge/config/validation-patterns.yaml +137 -0
- package/knowledge/domain/README.md +115 -0
- package/knowledge/domain/flows/README.md +194 -0
- package/knowledge/domain/glossary.md +143 -0
- package/knowledge/domain/rules.md +138 -0
- package/knowledge/environment/README.en.md +36 -0
- package/knowledge/environment/README.md +87 -0
- package/knowledge/environment/component-knowledge.md +316 -0
- package/knowledge/environment/detection-patterns.yaml +502 -0
- package/knowledge/environment/middleware-knowledge.md +237 -0
- package/knowledge/environment/template-registry.md +321 -0
- package/knowledge/guides/domain-driven-design.md +345 -0
- package/knowledge/guides/knowledge-management.md +369 -0
- package/knowledge/guides/requirement-engineering.md +329 -0
- package/knowledge/guides/stages/ai-effect-evaluator.md +93 -0
- package/knowledge/guides/stages/code-implementer.md +205 -0
- package/knowledge/guides/stages/code-reviewer.md +111 -0
- package/knowledge/guides/stages/consistency-checker.md +177 -0
- package/knowledge/guides/stages/design-planner.md +401 -0
- package/knowledge/guides/stages/design-reviewer.md +83 -0
- package/knowledge/guides/stages/integration-test-runner.md +105 -0
- package/knowledge/guides/stages/release-checker.md +205 -0
- package/knowledge/guides/stages/requirement-analyzer.md +195 -0
- package/knowledge/guides/stages/requirement-reviewer.md +83 -0
- package/knowledge/guides/stages/security-reviewer.md +89 -0
- package/knowledge/guides/stages/test-context-analyzer.md +250 -0
- package/knowledge/guides/stages/test-generator.md +241 -0
- package/knowledge/guides/stages/test-planner.md +183 -0
- package/knowledge/guides/stages/test-reviewer.md +76 -0
- package/knowledge/guides/stages/unit-test-runner.md +83 -0
- package/knowledge/guides/support/ai-agent-analyzer.md +362 -0
- package/knowledge/guides/support/ai-anomaly-analyzer.md +213 -0
- package/knowledge/guides/support/ai-artifact-evaluator.md +192 -0
- package/knowledge/guides/support/ai-capability-analyzer.md +193 -0
- package/knowledge/guides/support/ai-component-analyzer.md +169 -0
- package/knowledge/guides/support/ai-data-validator.md +276 -0
- package/knowledge/guides/support/ai-evaluation-planner.md +374 -0
- package/knowledge/guides/support/ai-path-evaluator.md +274 -0
- package/knowledge/guides/support/ai-pipeline-evaluator.md +219 -0
- package/knowledge/guides/support/ai-rag-analyzer.md +339 -0
- package/knowledge/guides/support/ai-task-assessor.md +418 -0
- package/knowledge/guides/support/ai-test-diagnostics.md +133 -0
- package/knowledge/guides/support/complexity-assessor.md +268 -0
- package/knowledge/guides/support/component-discovery.md +183 -0
- package/knowledge/guides/support/environment-scanner.md +207 -0
- package/knowledge/guides/support/environment-validator.md +207 -0
- package/knowledge/guides/support/knowledge-generator.md +234 -0
- package/knowledge/guides/support/methodology-extractor.md +55 -0
- package/knowledge/guides/support/pipeline-protocol.md +438 -0
- package/knowledge/guides/support/practice-logger.md +359 -0
- package/knowledge/guides/support/scope-inference.md +174 -0
- package/knowledge/guides/support/skill-distiller.md +91 -0
- package/knowledge/guides/support/skill-updater.md +45 -0
- package/knowledge/guides/support/skill-validator.md +72 -0
- package/knowledge/guides/support/team-orchestrator.md +323 -0
- package/knowledge/guides/support/tech-stack-analyzer.md +139 -0
- package/knowledge/guides/support/test-runner.md +254 -0
- package/knowledge/guides/system-design.md +352 -0
- package/knowledge/organization/ai-native-team.md +318 -0
- package/knowledge/organization/team-metrics.md +228 -0
- package/knowledge/principles/constitution.md +134 -0
- package/knowledge/principles/core-principles.md +368 -0
- package/knowledge/principles/design-philosophy.md +877 -0
- package/knowledge/principles/evolution.md +553 -0
- package/knowledge/process/01-requirement.md +113 -0
- package/knowledge/process/02-design.md +123 -0
- package/knowledge/process/03-implementation.md +90 -0
- package/knowledge/process/04-review.md +80 -0
- package/knowledge/process/05-testing.md +90 -0
- package/knowledge/process/06-delivery.md +88 -0
- package/knowledge/process/README.en.md +38 -0
- package/knowledge/process/README.md +48 -0
- package/knowledge/process/ai-sdlc.md +475 -0
- package/knowledge/process/overview.md +319 -0
- package/knowledge/standards/code-review.md +876 -0
- package/knowledge/standards/coding-style.md +940 -0
- package/knowledge/standards/data-consistency.md +1085 -0
- package/knowledge/standards/document-versioning.md +210 -0
- package/knowledge/standards/risk-detection.md +186 -0
- package/knowledge/templates/ai-evaluation.md +150 -0
- package/knowledge/templates/api-design.md +117 -0
- package/knowledge/templates/database-design.md +132 -0
- package/knowledge/templates/domain-driven-design.md +321 -0
- package/knowledge/templates/product-proposal.md +201 -0
- package/knowledge/templates/system-design.md +227 -0
- package/knowledge/templates/task-breakdown.md +107 -0
- package/knowledge/templates/test-case.md +170 -0
- package/package.json +53 -0
- package/plugins/.claude-plugin/plugin.json +134 -0
- package/plugins/agents/roles/ai-engineer.md +129 -0
- package/plugins/agents/roles/backend-engineer.md +165 -0
- package/plugins/agents/roles/ceo.md +94 -0
- package/plugins/agents/roles/data-engineer.md +135 -0
- package/plugins/agents/roles/devops-engineer.md +181 -0
- package/plugins/agents/roles/frontend-engineer.md +129 -0
- package/plugins/agents/roles/product-owner.md +98 -0
- package/plugins/agents/roles/quality-engineer.md +129 -0
- package/plugins/agents/roles/security-engineer.md +180 -0
- package/plugins/agents/roles/tech-lead.md +97 -0
- package/plugins/agents/support/blind-comparator.md +88 -0
- package/plugins/agents/support/consistency-checker.md +103 -0
- package/plugins/agents/support/failure-diagnostician.md +141 -0
- package/plugins/agents/support/independent-reviewer.md +80 -0
- package/plugins/agents/support/safety-auditor.md +121 -0
- package/plugins/agents/support/skill-benchmarker.md +86 -0
- package/plugins/agents/support/skill-forger.md +105 -0
- package/plugins/agents/support/stage-gate-evaluator.md +121 -0
- package/plugins/agents/support/test-coverage-reviewer.md +73 -0
- package/plugins/benchmarks/templates/README.md +44 -0
- package/plugins/benchmarks/templates/commands/explore-template.yaml +48 -0
- package/plugins/benchmarks/templates/pipeline/agile-template.yaml +84 -0
- package/plugins/benchmarks/templates/pipeline/waterfall-template.yaml +106 -0
- package/plugins/benchmarks/templates/skills/requirement-analyzer-template.yaml +48 -0
- package/plugins/commands/README.en.md +96 -0
- package/plugins/commands/README.md +96 -0
- package/plugins/commands/apply.md +191 -0
- package/plugins/commands/archive.md +76 -0
- package/plugins/commands/env-export.md +79 -0
- package/plugins/commands/env-sync.md +640 -0
- package/plugins/commands/env-template.md +223 -0
- package/plugins/commands/env-update.md +264 -0
- package/plugins/commands/env-validate.md +176 -0
- package/plugins/commands/env.md +79 -0
- package/plugins/commands/explore.md +76 -0
- package/plugins/commands/field-evolve.md +536 -0
- package/plugins/commands/memory.md +249 -0
- package/plugins/commands/project-evolve.md +821 -0
- package/plugins/commands/propose.md +93 -0
- package/plugins/commands/review.md +140 -0
- package/plugins/commands/run.md +224 -0
- package/plugins/commands/status.md +62 -0
- package/plugins/commands/validate.md +108 -0
- package/plugins/hooks/README.en.md +56 -0
- package/plugins/hooks/README.md +56 -0
- package/plugins/hooks/ai-project-guard.js +329 -0
- package/plugins/hooks/artifact-evaluation-hook.js +237 -0
- package/plugins/hooks/constitution-guard.js +211 -0
- package/plugins/hooks/environment-autocommit.js +264 -0
- package/plugins/hooks/environment-manager.js +778 -0
- package/plugins/hooks/execution-tracker.js +354 -0
- package/plugins/hooks/frozen-zone-guard.js +140 -0
- package/plugins/hooks/layer1-validator.js +423 -0
- package/plugins/hooks/lib/artifact-evaluator.js +414 -0
- package/plugins/hooks/lib/benchmarks/change-detector.js +390 -0
- package/plugins/hooks/lib/benchmarks/evaluator.js +605 -0
- package/plugins/hooks/lib/benchmarks/integration-example.js +169 -0
- package/plugins/hooks/lib/data-and-ai-detector.js +275 -0
- package/plugins/hooks/lib/detection-pattern-loader.js +865 -0
- package/plugins/hooks/lib/directory-discovery.js +395 -0
- package/plugins/hooks/lib/environment-config-loader.js +341 -0
- package/plugins/hooks/lib/environment-detector.js +553 -0
- package/plugins/hooks/lib/environment-evolver.js +564 -0
- package/plugins/hooks/lib/environment-registry.js +813 -0
- package/plugins/hooks/lib/execution-path.js +427 -0
- package/plugins/hooks/lib/hook-error-recorder.js +245 -0
- package/plugins/hooks/lib/hook-logger.js +538 -0
- package/plugins/hooks/lib/hook-runner.js +97 -0
- package/plugins/hooks/lib/hook-runner.sh +44 -0
- package/plugins/hooks/lib/hook-state-manager.js +480 -0
- package/plugins/hooks/lib/memory-extractor.js +377 -0
- package/plugins/hooks/lib/memory-manager.js +673 -0
- package/plugins/hooks/lib/metrics-analyzer.js +489 -0
- package/plugins/hooks/lib/project-evolution/auto-fixer.js +511 -0
- package/plugins/hooks/lib/project-evolution/memory-manager.js +346 -0
- package/plugins/hooks/lib/project-evolution/pattern-detector.js +476 -0
- package/plugins/hooks/lib/project-evolution/semantic-indexer.js +480 -0
- package/plugins/hooks/lib/project-structure-detector.js +326 -0
- package/plugins/hooks/lib/rollback-tracker.js +346 -0
- package/plugins/hooks/lib/source-code-scanner.js +596 -0
- package/plugins/hooks/lib/technology-stack-detector.js +374 -0
- package/plugins/hooks/lib/test-failure-analyzer.js +375 -0
- package/plugins/hooks/lib/test-failure-fixer.js +268 -0
- package/plugins/hooks/lib/trace-context.js +277 -0
- package/plugins/hooks/lib/validation-patterns.js +415 -0
- package/plugins/hooks/memory-sync.js +171 -0
- package/plugins/hooks/pipeline-observer.js +413 -0
- package/plugins/hooks/scope-sentinel.js +204 -0
- package/plugins/hooks/trace-initialization.js +169 -0
- package/plugins/memory/templates/code-quality.yaml +149 -0
- package/plugins/memory/templates/multi-system.yaml +155 -0
- package/plugins/memory/templates/team-habits.yaml +119 -0
- package/plugins/memory/templates/testing.yaml +121 -0
- package/plugins/skills/README.en.md +47 -0
- package/plugins/skills/README.md +104 -0
- package/plugins/skills/benchmark-executor/README.md +93 -0
- package/plugins/skills/benchmark-executor/SKILL.md +647 -0
- package/plugins/skills/benchmark-generator/SKILL.md +349 -0
- package/plugins/skills/delivery-stage/SKILL.md +203 -0
- package/plugins/skills/design-stage/SKILL.md +216 -0
- package/plugins/skills/evolution-process/SKILL.md +291 -0
- package/plugins/skills/exploration-phase/SKILL.md +133 -0
- package/plugins/skills/implementation-stage/SKILL.md +179 -0
- package/plugins/skills/layer1-validation/SKILL.md +79 -0
- package/plugins/skills/pending-dashboard/SKILL.md +109 -0
- package/plugins/skills/project-evolution/SKILL.md +847 -0
- package/plugins/skills/requirement-stage/SKILL.md +183 -0
- package/plugins/skills/skill-forge/SKILL.md +223 -0
- package/plugins/skills/skill-forge/references/description-guide.md +92 -0
- package/plugins/skills/skill-forge/references/quality-rubric.md +104 -0
- package/plugins/skills/skill-forge/references/skill-template.md +106 -0
- package/plugins/skills/startup-guard/SKILL.md +38 -0
- package/plugins/skills/testing-stage/SKILL.md +195 -0
- package/scripts/cli/global-init.js +288 -0
- package/scripts/cli/global.js +324 -0
- package/scripts/cli/index.js +55 -0
- package/scripts/cli/init.js +382 -0
- package/scripts/cli/list.js +69 -0
- package/scripts/cli/org.js +340 -0
- package/scripts/cli/update.js +44 -0
- package/scripts/config/commands.config.js +145 -0
- package/scripts/config/hooks.config.js +197 -0
- package/scripts/evolution/evolution-router.js +273 -0
- package/scripts/evolution/evolution-signal-collector.js +307 -0
- package/scripts/evolution/knowledge-loader.js +346 -0
- package/scripts/evolution/marketplace.js +317 -0
- package/scripts/evolution/version-manager.js +371 -0
- package/scripts/install/agents.js +106 -0
- package/scripts/install/commands.js +133 -0
- package/scripts/install/constants.js +424 -0
- package/scripts/install/hook-logger.js +536 -0
- package/scripts/install/hooks.js +110 -0
- package/scripts/install/index.js +39 -0
- package/scripts/install/skills.js +95 -0
- package/scripts/postinstall.js +25 -0
- package/scripts/state.js +376 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 检测规则配置加载器
|
|
3
|
+
*
|
|
4
|
+
* 从 YAML 配置文件加载检测规则,支持热重载和默认值
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
|
|
10
|
+
// 配置缓存
|
|
11
|
+
let configCache = null;
|
|
12
|
+
let configPath = null;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 解析简单的 YAML 文件(不依赖第三方库)
|
|
16
|
+
* 支持基本的键值对、列表和嵌套结构
|
|
17
|
+
*/
|
|
18
|
+
function parseSimpleYaml(content) {
|
|
19
|
+
const result = {};
|
|
20
|
+
let currentKey = null;
|
|
21
|
+
let currentSection = null;
|
|
22
|
+
let indentStack = [{ level: 0, obj: result }];
|
|
23
|
+
let inList = false;
|
|
24
|
+
|
|
25
|
+
const lines = content.split('\n');
|
|
26
|
+
|
|
27
|
+
for (let i = 0; i < lines.length; i++) {
|
|
28
|
+
const line = lines[i];
|
|
29
|
+
const trimmed = line.trimEnd();
|
|
30
|
+
|
|
31
|
+
// 跳过空行和注释
|
|
32
|
+
if (trimmed === '' || trimmed.startsWith('#')) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 计算缩进级别
|
|
37
|
+
const indent = line.length - line.trimStart().length;
|
|
38
|
+
const indentLevel = Math.floor(indent / 2);
|
|
39
|
+
|
|
40
|
+
// 处理列表项
|
|
41
|
+
if (trimmed.startsWith('- ')) {
|
|
42
|
+
const value = trimmed.substring(2).trim();
|
|
43
|
+
|
|
44
|
+
// 找到当前应该添加列表的对象
|
|
45
|
+
while (indentStack.length > 1 && indentStack[indentStack.length - 1].level >= indentLevel) {
|
|
46
|
+
indentStack.pop();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const current = indentStack[indentStack.length - 1].obj;
|
|
50
|
+
|
|
51
|
+
// 确保当前键存在且是数组
|
|
52
|
+
if (currentKey && !Array.isArray(current[currentKey])) {
|
|
53
|
+
current[currentKey] = [];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 解析列表项值
|
|
57
|
+
if (value.includes(':')) {
|
|
58
|
+
// 列表项是对象
|
|
59
|
+
const obj = {};
|
|
60
|
+
const [subKey, subValue] = value.split(':').map(s => s.trim());
|
|
61
|
+
if (subValue) {
|
|
62
|
+
obj[subKey] = parseValue(subValue);
|
|
63
|
+
}
|
|
64
|
+
current[currentKey].push(obj);
|
|
65
|
+
// 如果下一行缩进更深,可能还有更多属性
|
|
66
|
+
if (i + 1 < lines.length) {
|
|
67
|
+
const nextLine = lines[i + 1];
|
|
68
|
+
const nextIndent = nextLine.length - nextLine.trimStart().length;
|
|
69
|
+
if (nextIndent > indent) {
|
|
70
|
+
indentStack.push({ level: indentLevel + 1, obj });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
// 简单值
|
|
75
|
+
current[currentKey].push(parseValue(value));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
inList = true;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 处理键值对
|
|
83
|
+
const colonIndex = trimmed.indexOf(':');
|
|
84
|
+
if (colonIndex === -1) continue;
|
|
85
|
+
|
|
86
|
+
const key = trimmed.substring(0, colonIndex).trim();
|
|
87
|
+
let value = trimmed.substring(colonIndex + 1).trim();
|
|
88
|
+
|
|
89
|
+
// 调整缩进栈
|
|
90
|
+
while (indentStack.length > 1 && indentStack[indentStack.length - 1].level >= indentLevel) {
|
|
91
|
+
indentStack.pop();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const current = indentStack[indentStack.length - 1].obj;
|
|
95
|
+
|
|
96
|
+
if (value === '' || value === '|' || value === '>') {
|
|
97
|
+
// 嵌套对象或多行字符串
|
|
98
|
+
current[key] = value === '|' || value === '>' ? '' : {};
|
|
99
|
+
currentKey = key;
|
|
100
|
+
inList = false;
|
|
101
|
+
|
|
102
|
+
if (typeof current[key] === 'object') {
|
|
103
|
+
indentStack.push({ level: indentLevel + 1, obj: current[key] });
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
// 简单值
|
|
107
|
+
current[key] = parseValue(value);
|
|
108
|
+
currentKey = key;
|
|
109
|
+
inList = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 解析 YAML 值
|
|
118
|
+
*/
|
|
119
|
+
function parseValue(value) {
|
|
120
|
+
// 移除引号
|
|
121
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
122
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
123
|
+
return value.slice(1, -1);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 布尔值
|
|
127
|
+
if (value === 'true') return true;
|
|
128
|
+
if (value === 'false') return false;
|
|
129
|
+
|
|
130
|
+
// 数字
|
|
131
|
+
if (/^-?\d+$/.test(value)) return parseInt(value, 10);
|
|
132
|
+
if (/^-?\d+\.\d+$/.test(value)) return parseFloat(value);
|
|
133
|
+
|
|
134
|
+
// 数组(方括号语法)
|
|
135
|
+
if (value.startsWith('[') && value.endsWith(']')) {
|
|
136
|
+
return value.slice(1, -1).split(',').map(s => parseValue(s.trim()));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 查找配置文件
|
|
144
|
+
*/
|
|
145
|
+
function findConfigFile(filename) {
|
|
146
|
+
const searchPaths = [
|
|
147
|
+
process.cwd(),
|
|
148
|
+
path.join(process.cwd(), '.autospec'),
|
|
149
|
+
path.join(process.cwd(), 'framework'),
|
|
150
|
+
path.join(process.cwd(), 'framework', 'environment'),
|
|
151
|
+
path.join(process.cwd(), 'framework', 'config'),
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
// 如果是框架内部运行,添加框架路径
|
|
155
|
+
try {
|
|
156
|
+
const frameworkRoot = path.dirname(path.dirname(path.dirname(import.meta.url.replace('file://', ''))));
|
|
157
|
+
searchPaths.push(frameworkRoot);
|
|
158
|
+
searchPaths.push(path.join(frameworkRoot, 'framework', 'environment'));
|
|
159
|
+
searchPaths.push(path.join(frameworkRoot, 'framework', 'config'));
|
|
160
|
+
} catch (e) {
|
|
161
|
+
// 忽略
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
for (const searchPath of searchPaths) {
|
|
165
|
+
const fullPath = path.join(searchPath, filename);
|
|
166
|
+
if (fs.existsSync(fullPath)) {
|
|
167
|
+
return fullPath;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 加载检测规则配置
|
|
176
|
+
* @param {boolean} forceReload - 强制重新加载
|
|
177
|
+
* @returns {Object} 配置对象
|
|
178
|
+
*/
|
|
179
|
+
export function loadDetectionConfig(forceReload = false) {
|
|
180
|
+
if (configCache && !forceReload) {
|
|
181
|
+
return configCache;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const configFile = findConfigFile('detection-patterns.yaml');
|
|
185
|
+
|
|
186
|
+
if (!configFile) {
|
|
187
|
+
console.warn('[config-loader] Detection patterns config not found, using defaults');
|
|
188
|
+
return getDefaultConfig();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
const content = fs.readFileSync(configFile, 'utf-8');
|
|
193
|
+
configCache = parseSimpleYaml(content);
|
|
194
|
+
configPath = configFile;
|
|
195
|
+
return configCache;
|
|
196
|
+
} catch (err) {
|
|
197
|
+
console.warn('[config-loader] Failed to load config:', err.message);
|
|
198
|
+
return getDefaultConfig();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 加载验证模式配置
|
|
204
|
+
*/
|
|
205
|
+
export function loadValidationConfig() {
|
|
206
|
+
const configFile = findConfigFile('validation-patterns.yaml');
|
|
207
|
+
|
|
208
|
+
if (!configFile) {
|
|
209
|
+
console.warn('[config-loader] Validation patterns config not found, using defaults');
|
|
210
|
+
return getDefaultValidationConfig();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
try {
|
|
214
|
+
const content = fs.readFileSync(configFile, 'utf-8');
|
|
215
|
+
return parseSimpleYaml(content);
|
|
216
|
+
} catch (err) {
|
|
217
|
+
console.warn('[config-loader] Failed to load validation config:', err.message);
|
|
218
|
+
return getDefaultValidationConfig();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 获取默认配置(fallback)
|
|
224
|
+
*/
|
|
225
|
+
function getDefaultConfig() {
|
|
226
|
+
return {
|
|
227
|
+
buildFiles: {
|
|
228
|
+
'package.json': { buildTool: 'npm/yarn/pnpm', lang: 'javascript', parser: 'packageJson' },
|
|
229
|
+
'pom.xml': { buildTool: 'maven', lang: 'java', parser: 'pomXml' },
|
|
230
|
+
'go.mod': { buildTool: 'go-modules', lang: 'go', parser: 'goMod' },
|
|
231
|
+
'Cargo.toml': { buildTool: 'cargo', lang: 'rust', parser: 'cargoToml' },
|
|
232
|
+
'pyproject.toml': { buildTool: 'poetry/pdm', lang: 'python', parser: 'pyprojectToml' },
|
|
233
|
+
'requirements.txt': { buildTool: 'pip', lang: 'python', parser: 'requirements' }
|
|
234
|
+
},
|
|
235
|
+
frameworks: {
|
|
236
|
+
javascript: [
|
|
237
|
+
{ deps: ['react'], framework: 'React', type: 'frontend' },
|
|
238
|
+
{ deps: ['vue'], framework: 'Vue', type: 'frontend' },
|
|
239
|
+
{ deps: ['express'], framework: 'Express', type: 'backend' },
|
|
240
|
+
{ deps: ['nestjs'], framework: 'NestJS', type: 'backend' }
|
|
241
|
+
],
|
|
242
|
+
python: [
|
|
243
|
+
{ deps: ['django'], framework: 'Django', type: 'backend' },
|
|
244
|
+
{ deps: ['fastapi'], framework: 'FastAPI', type: 'backend' },
|
|
245
|
+
{ deps: ['flask'], framework: 'Flask', type: 'backend' },
|
|
246
|
+
{ deps: ['torch'], framework: 'PyTorch', type: 'ai' },
|
|
247
|
+
{ deps: ['langchain'], framework: 'LangChain', type: 'llm' }
|
|
248
|
+
],
|
|
249
|
+
java: [
|
|
250
|
+
{ deps: ['spring-boot'], framework: 'Spring Boot', type: 'backend' }
|
|
251
|
+
]
|
|
252
|
+
},
|
|
253
|
+
ignoreDirectories: [
|
|
254
|
+
'node_modules', '.git', 'dist', 'build', '__pycache__',
|
|
255
|
+
'venv', '.venv', '.idea', '.vscode', '.claude', '.autospec'
|
|
256
|
+
]
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 获取默认验证配置(fallback)
|
|
262
|
+
*/
|
|
263
|
+
function getDefaultValidationConfig() {
|
|
264
|
+
return {
|
|
265
|
+
validationCommands: {
|
|
266
|
+
test: { pattern: '\\b(npm test|pytest|go test|cargo test)\\b' },
|
|
267
|
+
build: { pattern: '\\b(npm run build|cargo build|go build)\\b' },
|
|
268
|
+
lint: { pattern: '\\b(eslint|tslint)\\b' },
|
|
269
|
+
typecheck: { pattern: '\\b(npx tsc|mypy)\\b' }
|
|
270
|
+
},
|
|
271
|
+
frozenPatterns: [
|
|
272
|
+
{ pattern: 'constitution\\.md$' },
|
|
273
|
+
{ pattern: 'evolution\\.md$' },
|
|
274
|
+
{ pattern: 'pipeline/overview\\.md$' }
|
|
275
|
+
]
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 清除配置缓存
|
|
281
|
+
*/
|
|
282
|
+
export function clearConfigCache() {
|
|
283
|
+
configCache = null;
|
|
284
|
+
configPath = null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* 获取忽略目录列表
|
|
289
|
+
*/
|
|
290
|
+
export function getIgnoreDirectories() {
|
|
291
|
+
const config = loadDetectionConfig();
|
|
292
|
+
return config.ignoreDirectories || getDefaultConfig().ignoreDirectories;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 获取构建文件规则
|
|
297
|
+
*/
|
|
298
|
+
export function getBuildFileRules() {
|
|
299
|
+
const config = loadDetectionConfig();
|
|
300
|
+
return config.buildFiles || getDefaultConfig().buildFiles;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 获取框架识别规则
|
|
305
|
+
*/
|
|
306
|
+
export function getFrameworkRules() {
|
|
307
|
+
const config = loadDetectionConfig();
|
|
308
|
+
return config.frameworks || getDefaultConfig().frameworks;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* 获取数据组件检测规则
|
|
313
|
+
*/
|
|
314
|
+
export function getDataComponentRules() {
|
|
315
|
+
const config = loadDetectionConfig();
|
|
316
|
+
return config.dataComponents || {};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 获取 AI 组件检测规则
|
|
321
|
+
*/
|
|
322
|
+
export function getAIComponentRules() {
|
|
323
|
+
const config = loadDetectionConfig();
|
|
324
|
+
return config.aiComponents || {};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* 获取入口文件模式
|
|
329
|
+
*/
|
|
330
|
+
export function getEntryPointPatterns() {
|
|
331
|
+
const config = loadDetectionConfig();
|
|
332
|
+
return config.entryPoints || {};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* 获取源码目录模式
|
|
337
|
+
*/
|
|
338
|
+
export function getSourceDirectoryPatterns() {
|
|
339
|
+
const config = loadDetectionConfig();
|
|
340
|
+
return config.sourceDirectories || {};
|
|
341
|
+
}
|