@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,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoSpec init command
|
|
3
|
+
*
|
|
4
|
+
* Merged from src/cli/commands/init.js and src/core/init.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import { FRAMEWORK_SRC, FRAMEWORK_DEST } from '../install/constants.js';
|
|
12
|
+
import { generateCommands, generateIntegration } from '../install/index.js';
|
|
13
|
+
import { initGlobalMemory, initProjectMemory, hasGlobalMemory } from '../../plugins/hooks/lib/memory-manager.js';
|
|
14
|
+
|
|
15
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const PACKAGE_ROOT = path.resolve(__dirname, '..', '..');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Check if file should be excluded from copy
|
|
20
|
+
* Exclude README files to avoid noise in user projects
|
|
21
|
+
*/
|
|
22
|
+
function shouldExclude(filename) {
|
|
23
|
+
// Exclude all README files (README.md, README.en.md, README.zh-CN.md, etc.)
|
|
24
|
+
if (filename.startsWith('README')) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Copy directory recursively, excluding README files
|
|
32
|
+
*/
|
|
33
|
+
function copyDirSync(src, dest) {
|
|
34
|
+
if (!fs.existsSync(dest)) {
|
|
35
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
const srcPath = path.join(src, entry.name);
|
|
40
|
+
const destPath = path.join(dest, entry.name);
|
|
41
|
+
if (entry.isDirectory()) {
|
|
42
|
+
copyDirSync(srcPath, destPath);
|
|
43
|
+
} else {
|
|
44
|
+
// Skip README files
|
|
45
|
+
if (shouldExclude(entry.name)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
fs.copyFileSync(srcPath, destPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Initialize autospec in target project directory
|
|
55
|
+
*
|
|
56
|
+
* Init copies knowledge files and hooks, generates commands/skills/agents.
|
|
57
|
+
* Runtime directories (runtime/, evolution/, environment/) are auto-created
|
|
58
|
+
* by hooks when slash commands are executed in Claude Code.
|
|
59
|
+
*/
|
|
60
|
+
export function initProject(targetDir, options = {}) {
|
|
61
|
+
const knowledgeSrc = path.join(PACKAGE_ROOT, FRAMEWORK_SRC);
|
|
62
|
+
const knowledgeDest = path.join(targetDir, FRAMEWORK_DEST);
|
|
63
|
+
const pluginsSrc = path.join(PACKAGE_ROOT, 'plugins');
|
|
64
|
+
const pluginsDest = path.join(targetDir, '.autospec', 'plugins');
|
|
65
|
+
const commandsDir = path.join(targetDir, '.claude', 'commands', 'autospec');
|
|
66
|
+
|
|
67
|
+
const results = {
|
|
68
|
+
frameworkCopied: false,
|
|
69
|
+
pluginsCopied: false,
|
|
70
|
+
commandsGenerated: false,
|
|
71
|
+
integrationGenerated: false,
|
|
72
|
+
claudeMdUpdated: false,
|
|
73
|
+
globalMemoryInitialized: false,
|
|
74
|
+
projectMemoryInitialized: false,
|
|
75
|
+
errors: []
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// 1. Copy entire knowledge/ directory
|
|
79
|
+
try {
|
|
80
|
+
copyDirSync(knowledgeSrc, knowledgeDest);
|
|
81
|
+
results.frameworkCopied = true;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
results.errors.push(`Knowledge copy failed: ${e.message}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 1.5 Copy plugins/hooks/ directory (hooks need to be accessible at runtime)
|
|
87
|
+
try {
|
|
88
|
+
const hooksSrc = path.join(pluginsSrc, 'hooks');
|
|
89
|
+
const hooksDest = path.join(pluginsDest, 'hooks');
|
|
90
|
+
if (fs.existsSync(hooksSrc)) {
|
|
91
|
+
copyDirSync(hooksSrc, hooksDest);
|
|
92
|
+
results.pluginsCopied = true;
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {
|
|
95
|
+
results.errors.push(`Plugins copy failed: ${e.message}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 2. Generate Claude Code slash commands
|
|
99
|
+
try {
|
|
100
|
+
generateCommands(commandsDir);
|
|
101
|
+
results.commandsGenerated = true;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
results.errors.push(`Command generation failed: ${e.message}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 3. Generate Claude Code integration (skills + agents + hooks)
|
|
107
|
+
try {
|
|
108
|
+
generateIntegration(targetDir);
|
|
109
|
+
results.integrationGenerated = true;
|
|
110
|
+
} catch (e) {
|
|
111
|
+
results.errors.push(`Integration generation failed: ${e.message}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 4. Create/update CLAUDE.md
|
|
115
|
+
try {
|
|
116
|
+
updateClaudeMd(targetDir);
|
|
117
|
+
results.claudeMdUpdated = true;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
results.errors.push(`CLAUDE.md update failed: ${e.message}`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 5. Create .autospec directory (hooks will auto-create subdirectories when needed)
|
|
123
|
+
const autospecDir = path.join(targetDir, '.autospec');
|
|
124
|
+
if (!fs.existsSync(autospecDir)) {
|
|
125
|
+
fs.mkdirSync(autospecDir, { recursive: true });
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 6. Create .autospec/package.json with "type": "module" to support ESM hooks
|
|
129
|
+
const autospecPackageJson = path.join(autospecDir, 'package.json');
|
|
130
|
+
if (!fs.existsSync(autospecPackageJson)) {
|
|
131
|
+
fs.writeFileSync(autospecPackageJson, JSON.stringify({
|
|
132
|
+
name: 'autospec-config',
|
|
133
|
+
version: '1.0.0',
|
|
134
|
+
type: 'module',
|
|
135
|
+
description: 'AutoSpec configuration directory'
|
|
136
|
+
}, null, 2), 'utf-8');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 7. Initialize memory system (global + project)
|
|
140
|
+
try {
|
|
141
|
+
// Initialize global memory if not exists
|
|
142
|
+
if (!hasGlobalMemory()) {
|
|
143
|
+
initGlobalMemory();
|
|
144
|
+
results.globalMemoryInitialized = true;
|
|
145
|
+
}
|
|
146
|
+
} catch (e) {
|
|
147
|
+
results.errors.push(`Global memory init failed: ${e.message}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
// Initialize project memory
|
|
152
|
+
initProjectMemory(targetDir);
|
|
153
|
+
results.projectMemoryInitialized = true;
|
|
154
|
+
} catch (e) {
|
|
155
|
+
results.errors.push(`Project memory init failed: ${e.message}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return results;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function updateClaudeMd(targetDir) {
|
|
162
|
+
const claudeMd = path.join(targetDir, 'CLAUDE.md');
|
|
163
|
+
const block = `
|
|
164
|
+
# AutoSpec Integration
|
|
165
|
+
|
|
166
|
+
本项目使用 AutoSpec 自动化研发流程。
|
|
167
|
+
|
|
168
|
+
## 启动门禁
|
|
169
|
+
|
|
170
|
+
收到任何开发类任务时,**必须先执行启动门禁**(startup-guard skill 会自动提醒):
|
|
171
|
+
1. 读取 \`.autospec/knowledge/process/overview.md\`
|
|
172
|
+
2. 读取 \`.autospec/knowledge/principles/constitution.md\`
|
|
173
|
+
3. 确认执行模式(自主/交互)和工作流类型
|
|
174
|
+
4. 向用户确认任务范围
|
|
175
|
+
|
|
176
|
+
**违反 = 宪法违规 → 立即停止。**
|
|
177
|
+
|
|
178
|
+
## 命令速查
|
|
179
|
+
|
|
180
|
+
| 命令 | 说明 |
|
|
181
|
+
|------|------|
|
|
182
|
+
| \`/autospec:run\` | 全流程自主执行(推荐) |
|
|
183
|
+
| \`/autospec:explore\` | 需求探索 |
|
|
184
|
+
| \`/autospec:propose\` | 方案设计 |
|
|
185
|
+
| \`/autospec:apply\` | 实施(编码 + 审查 + 测试) |
|
|
186
|
+
| \`/autospec:archive\` | 交付归档 |
|
|
187
|
+
| \`/autospec:evolve\` | 自进化触发 |
|
|
188
|
+
| \`/autospec:status\` | 查看状态 |
|
|
189
|
+
| \`/autospec:validate\` | Layer 1 验证 |
|
|
190
|
+
|
|
191
|
+
**迭代模式选择**(通过 /autospec:run):
|
|
192
|
+
- \`--workflow=waterfall\` Waterfall (default)
|
|
193
|
+
- \`--workflow=agile\` Agile
|
|
194
|
+
- \`--workflow=experiment\` Experiment (AI/ML)
|
|
195
|
+
- \`--workflow=hotfix\` Hotfix
|
|
196
|
+
|
|
197
|
+
## 推荐组合
|
|
198
|
+
|
|
199
|
+
先探索后执行效果更佳:
|
|
200
|
+
1. /autospec:explore → 需求探索澄清
|
|
201
|
+
2. 将探索结果作为上下文输入 → /autospec:run <探索结果>
|
|
202
|
+
|
|
203
|
+
这样可以让 AI 更准确地理解需求,避免方向偏差。
|
|
204
|
+
|
|
205
|
+
**也可以直接运行**:直接使用 /autospec:run 时,AI 会通过内部 agent 对抗博弈自动整理需求,但可能不如先探索再运行准确。
|
|
206
|
+
|
|
207
|
+
## Skills(自动感知)
|
|
208
|
+
|
|
209
|
+
以下 skills 会根据场景自动触发,为 Claude 注入对应阶段的流程意识:
|
|
210
|
+
|
|
211
|
+
| Skill | 触发场景 |
|
|
212
|
+
|-------|---------|
|
|
213
|
+
| startup-guard | 检测到开发类任务 → 强制启动门禁 |
|
|
214
|
+
| layer1-validation | 代码变更后 → 提醒运行 Layer 1 验证 |
|
|
215
|
+
| requirement-stage | 需求分析场景 → 加载需求分析流程 |
|
|
216
|
+
| design-stage | 方案设计场景 → 加载设计流程 |
|
|
217
|
+
| implementation-stage | 编码实现场景 → 加载实现流程 |
|
|
218
|
+
| testing-stage | 测试场景 → 加载测试流程 |
|
|
219
|
+
| delivery-stage | 交付部署场景 → 加载交付流程 + 自动记录 practice-log + 进化扫描 |
|
|
220
|
+
| evolution-process | 框架进化场景 → 加载进化流程(强制执行 meta skills) |
|
|
221
|
+
| pending-dashboard | 新会话启动 → 扫描待处理提案/practice-log/中断流程 |
|
|
222
|
+
|
|
223
|
+
## 审查 Agent(做审分离)
|
|
224
|
+
|
|
225
|
+
Layer 2 审查使用独立 Agent,实现信息隔离(DP2):
|
|
226
|
+
|
|
227
|
+
| Agent | 用途 | 隔离方式 |
|
|
228
|
+
|-------|------|---------|
|
|
229
|
+
| independent-reviewer | 需求/设计/代码审查 | 只读权限,不知生产过程 |
|
|
230
|
+
| test-coverage-reviewer | 测试充分性审查 | 只读权限,独立评估覆盖度 |
|
|
231
|
+
| consistency-checker | 跨产物一致性检查(DP18) | 只读权限,六维检测 |
|
|
232
|
+
| ceo | CEO/战略视角需求探索 | 只读权限,聚焦商业价值 |
|
|
233
|
+
| product-owner | 产品落地挑战(与 CEO 博弈) | 只读权限,聚焦可行性 |
|
|
234
|
+
| stage-gate-evaluator | 自主阶段产出审批(替代人工确认) | 只读权限,客观评估产出质量 |
|
|
235
|
+
| safety-auditor | 不可逆操作安全审计(DB 迁移/部署) | 只读权限,安全风险评估 |
|
|
236
|
+
| failure-diagnostician | 自主故障诊断 | 只读权限,根因分析 + 决策 |
|
|
237
|
+
|
|
238
|
+
**CEO 探索机制**:需求分析阶段前置步骤。
|
|
239
|
+
- 自主模式:ceo + product-owner 自动对话博弈
|
|
240
|
+
- 交互模式:围绕 5 个战略维度与用户交互
|
|
241
|
+
|
|
242
|
+
调用方式:Agent 工具,只传入产出物 + 审查标准 + 上游契约,不传入生产过程上下文。
|
|
243
|
+
|
|
244
|
+
## Hooks
|
|
245
|
+
|
|
246
|
+
已配置确定性 hooks(见 .claude/settings.json):
|
|
247
|
+
- **frozen-zone-guard**: 阻止修改宪法/进化规则等冻结区文件
|
|
248
|
+
- **constitution-guard**: 提醒执行启动门禁协议(读取宪法 + 概述)
|
|
249
|
+
- **scope-sentinel**: 编码阶段偏航检测(修改范围外文件时三级递增提醒)
|
|
250
|
+
- **layer1-validator**: Layer 1 强制检查 + 结果捕获 + 质量指标追踪
|
|
251
|
+
- **environment-manager**: 环境知识验证 + 未注册中间件检测
|
|
252
|
+
- **ai-project-guard**: AI 项目安全检查 + 效果验证
|
|
253
|
+
- **execution-tracker**: 执行日志追踪(skill 加载、agent 调用、产物生成)
|
|
254
|
+
`;
|
|
255
|
+
|
|
256
|
+
if (fs.existsSync(claudeMd)) {
|
|
257
|
+
const content = fs.readFileSync(claudeMd, 'utf-8');
|
|
258
|
+
if (!content.includes('# AutoSpec Integration')) {
|
|
259
|
+
fs.appendFileSync(claudeMd, '\n' + block);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
fs.writeFileSync(claudeMd, block.trim() + '\n');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Check if running as root and warn user
|
|
268
|
+
*/
|
|
269
|
+
function checkRootPermission() {
|
|
270
|
+
if (process.getuid && process.getuid() === 0) {
|
|
271
|
+
console.log('');
|
|
272
|
+
console.log(chalk.bold.yellow(' ⚠️ 权限警告'));
|
|
273
|
+
console.log('');
|
|
274
|
+
console.log(' 正在以 root 身份运行 autospec init');
|
|
275
|
+
console.log(' 创建的 .autospec 和 .claude 目录将属于 root 用户');
|
|
276
|
+
console.log('');
|
|
277
|
+
console.log(chalk.bold(' 后续操作建议:'));
|
|
278
|
+
console.log('');
|
|
279
|
+
console.log(' 方案一:后续命令也用 sudo 运行');
|
|
280
|
+
console.log(chalk.dim(' sudo claude'));
|
|
281
|
+
console.log('');
|
|
282
|
+
console.log(' 方案二:修复权限后用普通用户运行');
|
|
283
|
+
console.log(chalk.dim(' sudo chown -R $(whoami) .autospec .claude CLAUDE.md'));
|
|
284
|
+
console.log('');
|
|
285
|
+
console.log(' 方案三:删除后不使用 sudo 重新初始化');
|
|
286
|
+
console.log(chalk.dim(' sudo rm -rf .autospec .claude CLAUDE.md'));
|
|
287
|
+
console.log(chalk.dim(' autospec init'));
|
|
288
|
+
console.log('');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function initCommand(options) {
|
|
293
|
+
const targetDir = process.cwd();
|
|
294
|
+
|
|
295
|
+
// Pass verbose option to initProject
|
|
296
|
+
if (options.verbose) {
|
|
297
|
+
process.env.AUTOSPEC_VERBOSE = 'true';
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
console.log(chalk.bold('\n AutoSpec Init\n'));
|
|
301
|
+
console.log(` Target: ${targetDir}`);
|
|
302
|
+
console.log(` Workflow: ${options.workflow}`);
|
|
303
|
+
console.log(` Roles: ${options.roles || '(none)'}`);
|
|
304
|
+
console.log(` Domain: ${options.domain}`);
|
|
305
|
+
if (options.verbose) {
|
|
306
|
+
console.log(chalk.dim(' Verbose: enabled'));
|
|
307
|
+
}
|
|
308
|
+
console.log();
|
|
309
|
+
|
|
310
|
+
const roles = options.roles ? options.roles.split(',').map(r => r.trim()) : [];
|
|
311
|
+
|
|
312
|
+
const result = initProject(targetDir, {
|
|
313
|
+
workflow: options.workflow,
|
|
314
|
+
roles,
|
|
315
|
+
domain: options.domain,
|
|
316
|
+
verbose: options.verbose
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// Results
|
|
320
|
+
if (result.frameworkCopied) {
|
|
321
|
+
console.log(chalk.green(' ✓') + ' Knowledge .autospec/knowledge/');
|
|
322
|
+
}
|
|
323
|
+
if (result.commandsGenerated) {
|
|
324
|
+
console.log(chalk.green(' ✓') + ' Commands (17) .claude/commands/autospec/');
|
|
325
|
+
}
|
|
326
|
+
if (result.integrationGenerated) {
|
|
327
|
+
console.log(chalk.green(' ✓') + ' Skills (9) .claude/skills/');
|
|
328
|
+
console.log(chalk.green(' ✓') + ' Agents (16) .claude/agents/');
|
|
329
|
+
console.log(chalk.green(' ✓') + ' Hooks .claude/settings.json');
|
|
330
|
+
}
|
|
331
|
+
if (result.claudeMdUpdated) {
|
|
332
|
+
console.log(chalk.green(' ✓') + ' CLAUDE.md updated');
|
|
333
|
+
}
|
|
334
|
+
if (result.globalMemoryInitialized) {
|
|
335
|
+
console.log(chalk.green(' ✓') + ' Global Memory ~/.autospec-global/memory/');
|
|
336
|
+
}
|
|
337
|
+
if (result.projectMemoryInitialized) {
|
|
338
|
+
console.log(chalk.green(' ✓') + ' Project Memory .autospec/memory/');
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (result.errors.length > 0) {
|
|
342
|
+
console.log(chalk.red('\n Errors:'));
|
|
343
|
+
result.errors.forEach(e => console.log(chalk.red(' ✗ ' + e)));
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// 使用指南
|
|
347
|
+
console.log(chalk.bold('\n 快速开始\n'));
|
|
348
|
+
|
|
349
|
+
console.log(chalk.cyan(' 自主模式(推荐)'));
|
|
350
|
+
console.log(' /autospec:run <任务描述> 启动完整流程,AI 自主执行');
|
|
351
|
+
console.log(' /autospec:run 基于已有探索上下文继续执行');
|
|
352
|
+
console.log('');
|
|
353
|
+
console.log(chalk.dim(' 💡 建议先执行需求探索,再启动自主运行,可以更精准地完成任务'));
|
|
354
|
+
console.log(chalk.dim(' /autospec:explore 需求探索 - 澄清需求、识别约束'));
|
|
355
|
+
console.log('');
|
|
356
|
+
|
|
357
|
+
console.log(chalk.cyan(' 交互模式'));
|
|
358
|
+
console.log(' 分阶段执行,每阶段人工确认:');
|
|
359
|
+
console.log('');
|
|
360
|
+
console.log(' /autospec:explore 需求探索 - 澄清需求、识别约束');
|
|
361
|
+
console.log(' /autospec:propose 方案设计 - 技术方案、任务拆分');
|
|
362
|
+
console.log(' /autospec:apply 实施 - 编码、审查、测试');
|
|
363
|
+
console.log(' /autospec:archive 交付归档 - 文档、部署、复盘');
|
|
364
|
+
console.log('');
|
|
365
|
+
|
|
366
|
+
console.log(chalk.cyan(' 环境同步'));
|
|
367
|
+
console.log(' /autospec:env-sync 同步环境知识到 AI 上下文');
|
|
368
|
+
console.log('');
|
|
369
|
+
|
|
370
|
+
console.log(chalk.cyan(' 记忆管理'));
|
|
371
|
+
console.log(' /autospec:memory status 查看记忆系统状态');
|
|
372
|
+
console.log(' /autospec:memory show core 显示北极星指标');
|
|
373
|
+
console.log('');
|
|
374
|
+
|
|
375
|
+
console.log(chalk.dim(' 更多命令: autospec list'));
|
|
376
|
+
console.log(chalk.dim(' 帮助信息: autospec help <command>'));
|
|
377
|
+
console.log('');
|
|
378
|
+
console.log(chalk.green(' 准备就绪,运行 /autospec:run <任务描述> 开始') + '\n');
|
|
379
|
+
|
|
380
|
+
// 权限检查:放在最后,确保用户能看到
|
|
381
|
+
checkRootPermission();
|
|
382
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* autospec list command - 显示所有可用的斜杠命令
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { COMMAND_DEFINITIONS } from '../config/commands.config.js';
|
|
7
|
+
|
|
8
|
+
export function listCommand() {
|
|
9
|
+
console.log(chalk.bold('\n AutoSpec 斜杠命令\n'));
|
|
10
|
+
|
|
11
|
+
// 核心流程命令
|
|
12
|
+
console.log(chalk.cyan(' 核心流程'));
|
|
13
|
+
console.log(' /autospec:run <任务> 启动完整流程(瀑布/敏捷/实验/热修复)');
|
|
14
|
+
console.log(' /autospec:run 基于已有探索上下文继续执行');
|
|
15
|
+
console.log(' /autospec:explore 需求探索阶段');
|
|
16
|
+
console.log(' /autospec:propose 方案设计阶段');
|
|
17
|
+
console.log(' /autospec:apply 实施阶段(编码+审查+测试)');
|
|
18
|
+
console.log(' /autospec:archive 交付归档阶段');
|
|
19
|
+
console.log(' /autospec:evolve 自进化循环');
|
|
20
|
+
console.log('');
|
|
21
|
+
|
|
22
|
+
// 状态与验证命令
|
|
23
|
+
console.log(chalk.cyan(' 状态与验证'));
|
|
24
|
+
console.log(' /autospec:status 查看流程状态');
|
|
25
|
+
console.log(' /autospec:validate Layer 1 确定性验证');
|
|
26
|
+
console.log(' /autospec:review 审查交付物');
|
|
27
|
+
console.log(' /autospec:evaluate 生成评测报告');
|
|
28
|
+
console.log('');
|
|
29
|
+
|
|
30
|
+
// 环境管理命令
|
|
31
|
+
console.log(chalk.cyan(' 环境管理'));
|
|
32
|
+
console.log(' /autospec:env 查看环境配置');
|
|
33
|
+
console.log(' /autospec:env-validate 验证环境配置');
|
|
34
|
+
console.log(' /autospec:env-sync 同步环境知识(含初始化)');
|
|
35
|
+
console.log(' /autospec:env-import 导入知识库');
|
|
36
|
+
console.log(' /autospec:env-export 导出知识库');
|
|
37
|
+
console.log('');
|
|
38
|
+
|
|
39
|
+
// 组件命令
|
|
40
|
+
console.log(chalk.cyan(' 组件管理'));
|
|
41
|
+
console.log(' /autospec:component 列出已注册组件');
|
|
42
|
+
console.log(' /autospec:component-add 添加组件知识');
|
|
43
|
+
console.log('');
|
|
44
|
+
|
|
45
|
+
// 迭代模式
|
|
46
|
+
console.log(chalk.cyan(' 迭代模式 (via /autospec:run)'));
|
|
47
|
+
console.log(' --workflow=waterfall 瀑布模式(默认)');
|
|
48
|
+
console.log(' --workflow=agile 敏捷模式');
|
|
49
|
+
console.log(' --workflow=experiment 实验模式(AI/ML)');
|
|
50
|
+
console.log(' --workflow=hotfix 热修复模式');
|
|
51
|
+
console.log('');
|
|
52
|
+
|
|
53
|
+
// 提示
|
|
54
|
+
console.log(chalk.dim(' 文档: .autospec/knowledge/'));
|
|
55
|
+
console.log(chalk.dim(' 配置: .claude/settings.json'));
|
|
56
|
+
console.log('');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 获取命令列表(供其他模块使用)
|
|
61
|
+
*/
|
|
62
|
+
export function getCommandList() {
|
|
63
|
+
return Object.entries(COMMAND_DEFINITIONS)
|
|
64
|
+
.filter(([, config]) => !config.internal)
|
|
65
|
+
.map(([name, config]) => ({
|
|
66
|
+
name: `/autospec:${name}`,
|
|
67
|
+
description: config.description
|
|
68
|
+
}));
|
|
69
|
+
}
|