@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.
Files changed (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +472 -0
  3. package/README.md +476 -0
  4. package/bin/autospec.js +3 -0
  5. package/knowledge/README.md +144 -0
  6. package/knowledge/checklists/code.md +182 -0
  7. package/knowledge/checklists/design.md +196 -0
  8. package/knowledge/checklists/release.md +70 -0
  9. package/knowledge/checklists/requirement.md +169 -0
  10. package/knowledge/checklists/test.md +46 -0
  11. package/knowledge/config/README.en.md +44 -0
  12. package/knowledge/config/README.md +44 -0
  13. package/knowledge/config/role-composition.yaml +98 -0
  14. package/knowledge/config/role-extensions.yaml +140 -0
  15. package/knowledge/config/skill-compositions.yaml +142 -0
  16. package/knowledge/config/team-stage.yaml +95 -0
  17. package/knowledge/config/team-tasks.yaml +139 -0
  18. package/knowledge/config/team-triggers.yaml +198 -0
  19. package/knowledge/config/validation-patterns.yaml +137 -0
  20. package/knowledge/domain/README.md +115 -0
  21. package/knowledge/domain/flows/README.md +194 -0
  22. package/knowledge/domain/glossary.md +143 -0
  23. package/knowledge/domain/rules.md +138 -0
  24. package/knowledge/environment/README.en.md +36 -0
  25. package/knowledge/environment/README.md +87 -0
  26. package/knowledge/environment/component-knowledge.md +316 -0
  27. package/knowledge/environment/detection-patterns.yaml +502 -0
  28. package/knowledge/environment/middleware-knowledge.md +237 -0
  29. package/knowledge/environment/template-registry.md +321 -0
  30. package/knowledge/guides/domain-driven-design.md +345 -0
  31. package/knowledge/guides/knowledge-management.md +369 -0
  32. package/knowledge/guides/requirement-engineering.md +329 -0
  33. package/knowledge/guides/stages/ai-effect-evaluator.md +93 -0
  34. package/knowledge/guides/stages/code-implementer.md +205 -0
  35. package/knowledge/guides/stages/code-reviewer.md +111 -0
  36. package/knowledge/guides/stages/consistency-checker.md +177 -0
  37. package/knowledge/guides/stages/design-planner.md +401 -0
  38. package/knowledge/guides/stages/design-reviewer.md +83 -0
  39. package/knowledge/guides/stages/integration-test-runner.md +105 -0
  40. package/knowledge/guides/stages/release-checker.md +205 -0
  41. package/knowledge/guides/stages/requirement-analyzer.md +195 -0
  42. package/knowledge/guides/stages/requirement-reviewer.md +83 -0
  43. package/knowledge/guides/stages/security-reviewer.md +89 -0
  44. package/knowledge/guides/stages/test-context-analyzer.md +250 -0
  45. package/knowledge/guides/stages/test-generator.md +241 -0
  46. package/knowledge/guides/stages/test-planner.md +183 -0
  47. package/knowledge/guides/stages/test-reviewer.md +76 -0
  48. package/knowledge/guides/stages/unit-test-runner.md +83 -0
  49. package/knowledge/guides/support/ai-agent-analyzer.md +362 -0
  50. package/knowledge/guides/support/ai-anomaly-analyzer.md +213 -0
  51. package/knowledge/guides/support/ai-artifact-evaluator.md +192 -0
  52. package/knowledge/guides/support/ai-capability-analyzer.md +193 -0
  53. package/knowledge/guides/support/ai-component-analyzer.md +169 -0
  54. package/knowledge/guides/support/ai-data-validator.md +276 -0
  55. package/knowledge/guides/support/ai-evaluation-planner.md +374 -0
  56. package/knowledge/guides/support/ai-path-evaluator.md +274 -0
  57. package/knowledge/guides/support/ai-pipeline-evaluator.md +219 -0
  58. package/knowledge/guides/support/ai-rag-analyzer.md +339 -0
  59. package/knowledge/guides/support/ai-task-assessor.md +418 -0
  60. package/knowledge/guides/support/ai-test-diagnostics.md +133 -0
  61. package/knowledge/guides/support/complexity-assessor.md +268 -0
  62. package/knowledge/guides/support/component-discovery.md +183 -0
  63. package/knowledge/guides/support/environment-scanner.md +207 -0
  64. package/knowledge/guides/support/environment-validator.md +207 -0
  65. package/knowledge/guides/support/knowledge-generator.md +234 -0
  66. package/knowledge/guides/support/methodology-extractor.md +55 -0
  67. package/knowledge/guides/support/pipeline-protocol.md +438 -0
  68. package/knowledge/guides/support/practice-logger.md +359 -0
  69. package/knowledge/guides/support/scope-inference.md +174 -0
  70. package/knowledge/guides/support/skill-distiller.md +91 -0
  71. package/knowledge/guides/support/skill-updater.md +45 -0
  72. package/knowledge/guides/support/skill-validator.md +72 -0
  73. package/knowledge/guides/support/team-orchestrator.md +323 -0
  74. package/knowledge/guides/support/tech-stack-analyzer.md +139 -0
  75. package/knowledge/guides/support/test-runner.md +254 -0
  76. package/knowledge/guides/system-design.md +352 -0
  77. package/knowledge/organization/ai-native-team.md +318 -0
  78. package/knowledge/organization/team-metrics.md +228 -0
  79. package/knowledge/principles/constitution.md +134 -0
  80. package/knowledge/principles/core-principles.md +368 -0
  81. package/knowledge/principles/design-philosophy.md +877 -0
  82. package/knowledge/principles/evolution.md +553 -0
  83. package/knowledge/process/01-requirement.md +113 -0
  84. package/knowledge/process/02-design.md +123 -0
  85. package/knowledge/process/03-implementation.md +90 -0
  86. package/knowledge/process/04-review.md +80 -0
  87. package/knowledge/process/05-testing.md +90 -0
  88. package/knowledge/process/06-delivery.md +88 -0
  89. package/knowledge/process/README.en.md +38 -0
  90. package/knowledge/process/README.md +48 -0
  91. package/knowledge/process/ai-sdlc.md +475 -0
  92. package/knowledge/process/overview.md +319 -0
  93. package/knowledge/standards/code-review.md +876 -0
  94. package/knowledge/standards/coding-style.md +940 -0
  95. package/knowledge/standards/data-consistency.md +1085 -0
  96. package/knowledge/standards/document-versioning.md +210 -0
  97. package/knowledge/standards/risk-detection.md +186 -0
  98. package/knowledge/templates/ai-evaluation.md +150 -0
  99. package/knowledge/templates/api-design.md +117 -0
  100. package/knowledge/templates/database-design.md +132 -0
  101. package/knowledge/templates/domain-driven-design.md +321 -0
  102. package/knowledge/templates/product-proposal.md +201 -0
  103. package/knowledge/templates/system-design.md +227 -0
  104. package/knowledge/templates/task-breakdown.md +107 -0
  105. package/knowledge/templates/test-case.md +170 -0
  106. package/package.json +53 -0
  107. package/plugins/.claude-plugin/plugin.json +134 -0
  108. package/plugins/agents/roles/ai-engineer.md +129 -0
  109. package/plugins/agents/roles/backend-engineer.md +165 -0
  110. package/plugins/agents/roles/ceo.md +94 -0
  111. package/plugins/agents/roles/data-engineer.md +135 -0
  112. package/plugins/agents/roles/devops-engineer.md +181 -0
  113. package/plugins/agents/roles/frontend-engineer.md +129 -0
  114. package/plugins/agents/roles/product-owner.md +98 -0
  115. package/plugins/agents/roles/quality-engineer.md +129 -0
  116. package/plugins/agents/roles/security-engineer.md +180 -0
  117. package/plugins/agents/roles/tech-lead.md +97 -0
  118. package/plugins/agents/support/blind-comparator.md +88 -0
  119. package/plugins/agents/support/consistency-checker.md +103 -0
  120. package/plugins/agents/support/failure-diagnostician.md +141 -0
  121. package/plugins/agents/support/independent-reviewer.md +80 -0
  122. package/plugins/agents/support/safety-auditor.md +121 -0
  123. package/plugins/agents/support/skill-benchmarker.md +86 -0
  124. package/plugins/agents/support/skill-forger.md +105 -0
  125. package/plugins/agents/support/stage-gate-evaluator.md +121 -0
  126. package/plugins/agents/support/test-coverage-reviewer.md +73 -0
  127. package/plugins/benchmarks/templates/README.md +44 -0
  128. package/plugins/benchmarks/templates/commands/explore-template.yaml +48 -0
  129. package/plugins/benchmarks/templates/pipeline/agile-template.yaml +84 -0
  130. package/plugins/benchmarks/templates/pipeline/waterfall-template.yaml +106 -0
  131. package/plugins/benchmarks/templates/skills/requirement-analyzer-template.yaml +48 -0
  132. package/plugins/commands/README.en.md +96 -0
  133. package/plugins/commands/README.md +96 -0
  134. package/plugins/commands/apply.md +191 -0
  135. package/plugins/commands/archive.md +76 -0
  136. package/plugins/commands/env-export.md +79 -0
  137. package/plugins/commands/env-sync.md +640 -0
  138. package/plugins/commands/env-template.md +223 -0
  139. package/plugins/commands/env-update.md +264 -0
  140. package/plugins/commands/env-validate.md +176 -0
  141. package/plugins/commands/env.md +79 -0
  142. package/plugins/commands/explore.md +76 -0
  143. package/plugins/commands/field-evolve.md +536 -0
  144. package/plugins/commands/memory.md +249 -0
  145. package/plugins/commands/project-evolve.md +821 -0
  146. package/plugins/commands/propose.md +93 -0
  147. package/plugins/commands/review.md +140 -0
  148. package/plugins/commands/run.md +224 -0
  149. package/plugins/commands/status.md +62 -0
  150. package/plugins/commands/validate.md +108 -0
  151. package/plugins/hooks/README.en.md +56 -0
  152. package/plugins/hooks/README.md +56 -0
  153. package/plugins/hooks/ai-project-guard.js +329 -0
  154. package/plugins/hooks/artifact-evaluation-hook.js +237 -0
  155. package/plugins/hooks/constitution-guard.js +211 -0
  156. package/plugins/hooks/environment-autocommit.js +264 -0
  157. package/plugins/hooks/environment-manager.js +778 -0
  158. package/plugins/hooks/execution-tracker.js +354 -0
  159. package/plugins/hooks/frozen-zone-guard.js +140 -0
  160. package/plugins/hooks/layer1-validator.js +423 -0
  161. package/plugins/hooks/lib/artifact-evaluator.js +414 -0
  162. package/plugins/hooks/lib/benchmarks/change-detector.js +390 -0
  163. package/plugins/hooks/lib/benchmarks/evaluator.js +605 -0
  164. package/plugins/hooks/lib/benchmarks/integration-example.js +169 -0
  165. package/plugins/hooks/lib/data-and-ai-detector.js +275 -0
  166. package/plugins/hooks/lib/detection-pattern-loader.js +865 -0
  167. package/plugins/hooks/lib/directory-discovery.js +395 -0
  168. package/plugins/hooks/lib/environment-config-loader.js +341 -0
  169. package/plugins/hooks/lib/environment-detector.js +553 -0
  170. package/plugins/hooks/lib/environment-evolver.js +564 -0
  171. package/plugins/hooks/lib/environment-registry.js +813 -0
  172. package/plugins/hooks/lib/execution-path.js +427 -0
  173. package/plugins/hooks/lib/hook-error-recorder.js +245 -0
  174. package/plugins/hooks/lib/hook-logger.js +538 -0
  175. package/plugins/hooks/lib/hook-runner.js +97 -0
  176. package/plugins/hooks/lib/hook-runner.sh +44 -0
  177. package/plugins/hooks/lib/hook-state-manager.js +480 -0
  178. package/plugins/hooks/lib/memory-extractor.js +377 -0
  179. package/plugins/hooks/lib/memory-manager.js +673 -0
  180. package/plugins/hooks/lib/metrics-analyzer.js +489 -0
  181. package/plugins/hooks/lib/project-evolution/auto-fixer.js +511 -0
  182. package/plugins/hooks/lib/project-evolution/memory-manager.js +346 -0
  183. package/plugins/hooks/lib/project-evolution/pattern-detector.js +476 -0
  184. package/plugins/hooks/lib/project-evolution/semantic-indexer.js +480 -0
  185. package/plugins/hooks/lib/project-structure-detector.js +326 -0
  186. package/plugins/hooks/lib/rollback-tracker.js +346 -0
  187. package/plugins/hooks/lib/source-code-scanner.js +596 -0
  188. package/plugins/hooks/lib/technology-stack-detector.js +374 -0
  189. package/plugins/hooks/lib/test-failure-analyzer.js +375 -0
  190. package/plugins/hooks/lib/test-failure-fixer.js +268 -0
  191. package/plugins/hooks/lib/trace-context.js +277 -0
  192. package/plugins/hooks/lib/validation-patterns.js +415 -0
  193. package/plugins/hooks/memory-sync.js +171 -0
  194. package/plugins/hooks/pipeline-observer.js +413 -0
  195. package/plugins/hooks/scope-sentinel.js +204 -0
  196. package/plugins/hooks/trace-initialization.js +169 -0
  197. package/plugins/memory/templates/code-quality.yaml +149 -0
  198. package/plugins/memory/templates/multi-system.yaml +155 -0
  199. package/plugins/memory/templates/team-habits.yaml +119 -0
  200. package/plugins/memory/templates/testing.yaml +121 -0
  201. package/plugins/skills/README.en.md +47 -0
  202. package/plugins/skills/README.md +104 -0
  203. package/plugins/skills/benchmark-executor/README.md +93 -0
  204. package/plugins/skills/benchmark-executor/SKILL.md +647 -0
  205. package/plugins/skills/benchmark-generator/SKILL.md +349 -0
  206. package/plugins/skills/delivery-stage/SKILL.md +203 -0
  207. package/plugins/skills/design-stage/SKILL.md +216 -0
  208. package/plugins/skills/evolution-process/SKILL.md +291 -0
  209. package/plugins/skills/exploration-phase/SKILL.md +133 -0
  210. package/plugins/skills/implementation-stage/SKILL.md +179 -0
  211. package/plugins/skills/layer1-validation/SKILL.md +79 -0
  212. package/plugins/skills/pending-dashboard/SKILL.md +109 -0
  213. package/plugins/skills/project-evolution/SKILL.md +847 -0
  214. package/plugins/skills/requirement-stage/SKILL.md +183 -0
  215. package/plugins/skills/skill-forge/SKILL.md +223 -0
  216. package/plugins/skills/skill-forge/references/description-guide.md +92 -0
  217. package/plugins/skills/skill-forge/references/quality-rubric.md +104 -0
  218. package/plugins/skills/skill-forge/references/skill-template.md +106 -0
  219. package/plugins/skills/startup-guard/SKILL.md +38 -0
  220. package/plugins/skills/testing-stage/SKILL.md +195 -0
  221. package/scripts/cli/global-init.js +288 -0
  222. package/scripts/cli/global.js +324 -0
  223. package/scripts/cli/index.js +55 -0
  224. package/scripts/cli/init.js +382 -0
  225. package/scripts/cli/list.js +69 -0
  226. package/scripts/cli/org.js +340 -0
  227. package/scripts/cli/update.js +44 -0
  228. package/scripts/config/commands.config.js +145 -0
  229. package/scripts/config/hooks.config.js +197 -0
  230. package/scripts/evolution/evolution-router.js +273 -0
  231. package/scripts/evolution/evolution-signal-collector.js +307 -0
  232. package/scripts/evolution/knowledge-loader.js +346 -0
  233. package/scripts/evolution/marketplace.js +317 -0
  234. package/scripts/evolution/version-manager.js +371 -0
  235. package/scripts/install/agents.js +106 -0
  236. package/scripts/install/commands.js +133 -0
  237. package/scripts/install/constants.js +424 -0
  238. package/scripts/install/hook-logger.js +536 -0
  239. package/scripts/install/hooks.js +110 -0
  240. package/scripts/install/index.js +39 -0
  241. package/scripts/install/skills.js +95 -0
  242. package/scripts/postinstall.js +25 -0
  243. package/scripts/state.js +376 -0
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Agents generator for Claude Code integration
3
+ *
4
+ * Generates agent files from templates directory with variable replacement.
5
+ * Source: plugins/agents/
6
+ * Target: .claude/agents/
7
+ */
8
+
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ // ESM __dirname equivalent
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = path.dirname(__filename);
16
+
17
+ /**
18
+ * Replace template variables in content
19
+ * @param {string} content - Template content
20
+ * @returns {string} - Content with variables replaced
21
+ */
22
+ function replaceVariables(content) {
23
+ // Replace ${FW} with .autospec/knowledge (backward compat)
24
+ // Replace ${KNOWLEDGE} with .autospec/knowledge
25
+ return content
26
+ .replace(/\$\{FW\}/g, '.autospec/knowledge')
27
+ .replace(/\$\{KNOWLEDGE\}/g, '.autospec/knowledge');
28
+ }
29
+
30
+ /**
31
+ * Generate all agent files from templates
32
+ * @param {string} claudeDir - Target .claude directory path
33
+ */
34
+ export function generateAgents(claudeDir) {
35
+ const agentsDir = path.join(claudeDir, 'agents');
36
+ fs.mkdirSync(agentsDir, { recursive: true });
37
+
38
+ // Get templates directory path (relative to this file)
39
+ // __dirname is scripts/install/, templates are in ../../plugins/agents/
40
+ const templatesDir = path.join(__dirname, '../../plugins/agents');
41
+
42
+ // Check if templates directory exists
43
+ if (!fs.existsSync(templatesDir)) {
44
+ console.warn('Warning: plugins/agents/ directory not found, skipping agent generation');
45
+ return;
46
+ }
47
+
48
+ // Process roles directory
49
+ const rolesDir = path.join(templatesDir, 'roles');
50
+ if (fs.existsSync(rolesDir)) {
51
+ const roleAgents = fs.readdirSync(rolesDir).filter(f => f.endsWith('.md'));
52
+ for (const file of roleAgents) {
53
+ const sourcePath = path.join(rolesDir, file);
54
+ const content = fs.readFileSync(sourcePath, 'utf-8');
55
+ const processed = replaceVariables(content);
56
+ const targetPath = path.join(agentsDir, file);
57
+ fs.writeFileSync(targetPath, processed, 'utf-8');
58
+ }
59
+ }
60
+
61
+ // Process support directory
62
+ const supportDir = path.join(templatesDir, 'support');
63
+ if (fs.existsSync(supportDir)) {
64
+ const supportAgents = fs.readdirSync(supportDir).filter(f => f.endsWith('.md'));
65
+ for (const file of supportAgents) {
66
+ const sourcePath = path.join(supportDir, file);
67
+ const content = fs.readFileSync(sourcePath, 'utf-8');
68
+ const processed = replaceVariables(content);
69
+ const targetPath = path.join(agentsDir, file);
70
+ fs.writeFileSync(targetPath, processed, 'utf-8');
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Get list of available agent names
77
+ * @returns {string[]} - Array of agent names
78
+ */
79
+ export function getAvailableAgents() {
80
+ const templatesDir = path.join(__dirname, '../../plugins/agents');
81
+ const agents = [];
82
+
83
+ if (!fs.existsSync(templatesDir)) {
84
+ return agents;
85
+ }
86
+
87
+ // Get agents from roles directory
88
+ const rolesDir = path.join(templatesDir, 'roles');
89
+ if (fs.existsSync(rolesDir)) {
90
+ const roleAgents = fs.readdirSync(rolesDir)
91
+ .filter(f => f.endsWith('.md'))
92
+ .map(f => f.replace('.md', ''));
93
+ agents.push(...roleAgents);
94
+ }
95
+
96
+ // Get agents from support directory
97
+ const supportDir = path.join(templatesDir, 'support');
98
+ if (fs.existsSync(supportDir)) {
99
+ const supportAgents = fs.readdirSync(supportDir)
100
+ .filter(f => f.endsWith('.md'))
101
+ .map(f => f.replace('.md', ''));
102
+ agents.push(...supportAgents);
103
+ }
104
+
105
+ return agents;
106
+ }
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Generates Claude Code slash command files (.claude/commands/autospec/)
3
+ */
4
+
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ import { COMMAND_DEFINITIONS } from '../config/commands.config.js';
9
+
10
+ // ESM __dirname equivalent
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ // Template cache to avoid repeated file reads
15
+ const templateCache = new Map();
16
+
17
+ /**
18
+ * Load template from file with caching
19
+ */
20
+ function loadTemplate(templateFile) {
21
+ // Check cache first
22
+ if (templateCache.has(templateFile)) {
23
+ return templateCache.get(templateFile);
24
+ }
25
+
26
+ // Resolve template path (templates are in plugins/commands/)
27
+ // __dirname is scripts/install/, so we need ../../plugins/commands/
28
+ const templatePath = path.join(__dirname, '../../plugins/commands', templateFile);
29
+
30
+ if (!fs.existsSync(templatePath)) {
31
+ throw new Error(`Template file not found: ${templatePath}`);
32
+ }
33
+
34
+ const content = fs.readFileSync(templatePath, 'utf-8');
35
+
36
+ // Cache the template
37
+ templateCache.set(templateFile, content);
38
+
39
+ return content;
40
+ }
41
+
42
+ /**
43
+ * Replace variables in template
44
+ */
45
+ function replaceVariables(template, variables) {
46
+ let result = template;
47
+ for (const [key, value] of Object.entries(variables)) {
48
+ const regex = new RegExp(`\\{\\{${key}\\}\\}`, 'g');
49
+ result = result.replace(regex, value);
50
+ }
51
+ return result;
52
+ }
53
+
54
+ /**
55
+ * Generate all Claude Code slash commands
56
+ */
57
+ export function generateCommands(commandsDir) {
58
+ if (!fs.existsSync(commandsDir)) {
59
+ fs.mkdirSync(commandsDir, { recursive: true });
60
+ }
61
+
62
+ // Use relative path (always forward slashes for cross-platform)
63
+ const knowledge = '.autospec/knowledge';
64
+ const variables = { knowledge, framework: knowledge }; // Keep framework for backward compat
65
+
66
+ // Generate all commands from configuration (skip internal commands)
67
+ for (const [name, config] of Object.entries(COMMAND_DEFINITIONS)) {
68
+ // Skip internal commands (only for AutoSpec itself)
69
+ if (config.internal) {
70
+ continue;
71
+ }
72
+ const content = generateCommandFromTemplate(config, variables);
73
+ writeCommand(commandsDir, name, content);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Generate a single command from template
79
+ */
80
+ function generateCommandFromTemplate(config, variables) {
81
+ const template = loadTemplate(config.templateFile);
82
+ return replaceVariables(template, variables);
83
+ }
84
+
85
+ function writeCommand(dir, name, content) {
86
+ fs.writeFileSync(path.join(dir, `${name}.md`), content, 'utf-8');
87
+ }
88
+
89
+ /**
90
+ * Clear template cache (useful for testing or when templates change)
91
+ */
92
+ export function clearTemplateCache() {
93
+ templateCache.clear();
94
+ }
95
+
96
+ /**
97
+ * Get cache stats for debugging
98
+ */
99
+ export function getTemplateCacheStats() {
100
+ return {
101
+ size: templateCache.size,
102
+ keys: Array.from(templateCache.keys())
103
+ };
104
+ }
105
+
106
+ /**
107
+ * Get list of internal command names
108
+ */
109
+ export function getInternalCommandNames() {
110
+ return Object.entries(COMMAND_DEFINITIONS)
111
+ .filter(([, config]) => config.internal)
112
+ .map(([name]) => name);
113
+ }
114
+
115
+ /**
116
+ * Generate internal commands (for AutoSpec itself)
117
+ */
118
+ export function generateInternalCommands(commandsDir) {
119
+ if (!fs.existsSync(commandsDir)) {
120
+ fs.mkdirSync(commandsDir, { recursive: true });
121
+ }
122
+
123
+ const knowledge = '.autospec/knowledge';
124
+ const variables = { knowledge, framework: knowledge };
125
+
126
+ // Generate only internal commands
127
+ for (const [name, config] of Object.entries(COMMAND_DEFINITIONS)) {
128
+ if (config.internal) {
129
+ const content = generateCommandFromTemplate(config, variables);
130
+ writeCommand(commandsDir, name, content);
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,424 @@
1
+ /**
2
+ * AutoSpec constants
3
+ */
4
+
5
+ // Knowledge source directory (relative to package root)
6
+ export const FRAMEWORK_SRC = 'knowledge';
7
+
8
+ // Knowledge target directory (in user's project)
9
+ export const FRAMEWORK_DEST = '.autospec/knowledge';
10
+
11
+ // Autospec internal directories (relative to .autospec/)
12
+ export const AUTOSPEC_DIRS = {
13
+ RUNTIME: 'runtime', // Current pipeline state
14
+ ARCHIVES: 'archives', // Archived pipeline runs
15
+ EVOLUTION: 'evolution' // Self-evolution data
16
+ };
17
+
18
+ // Runtime files (relative to .autospec/runtime/)
19
+ export const RUNTIME_FILES = {
20
+ STATE: 'state.json',
21
+ METRICS: 'metrics.json',
22
+ CONFIG: 'config.json'
23
+ };
24
+
25
+ // Evolution files (relative to .autospec/evolution/)
26
+ export const EVOLUTION_FILES = {
27
+ PROPOSALS: 'proposals',
28
+ PRACTICE_LOG: 'practice-log',
29
+ LOG: 'evolution-log.json'
30
+ };
31
+
32
+ // Pipeline stages (ordered)
33
+ export const STAGES = [
34
+ { id: '01', name: 'require', file: '01-requirement.md', label: '需求分析', skill: 'requirement-analyzer', reviewer: 'requirement-reviewer' },
35
+ { id: '02', name: 'design', file: '02-design.md', label: '方案设计', skill: 'design-planner', reviewer: 'design-reviewer' },
36
+ { id: '03', name: 'implement', file: '03-implementation.md', label: '编码实现', skill: 'code-implementer', reviewer: 'code-reviewer' },
37
+ { id: '04', name: 'review', file: '04-review.md', label: '代码审查', skill: 'code-reviewer', reviewer: null },
38
+ { id: '05', name: 'test', file: '05-testing.md', label: 'QA测试', skill: 'test-generator', reviewer: 'test-reviewer' },
39
+ { id: '06', name: 'deliver', file: '06-delivery.md', label: '交付部署', skill: 'release-checker', reviewer: null }
40
+ ];
41
+
42
+ // Workflow templates (used as --workflow parameter values)
43
+ export const WORKFLOWS = {
44
+ waterfall: {
45
+ name: 'waterfall',
46
+ label: '瀑布迭代',
47
+ stages: ['01', '02', '03', '04', '05', '06'],
48
+ description: '完整6阶段研发流程,适用于新功能开发',
49
+ mode: 'waterfall'
50
+ },
51
+ agile: {
52
+ name: 'agile',
53
+ label: '敏捷迭代',
54
+ stages: ['01', '02', '03', '04', '05', '06'],
55
+ description: '需求拆分为用户故事,设计→编码→审查循环迭代,最后集成测试和交付',
56
+ mode: 'agile',
57
+ iterableStages: ['02', '03', '04'] // design-implement-review per story
58
+ },
59
+ experiment: {
60
+ name: 'experiment',
61
+ label: '实验模式',
62
+ stages: ['01', '02', '03'],
63
+ description: '需求+设计+原型,AI实验自动添加效果评测',
64
+ mode: 'experiment',
65
+ needsEvaluation: true // AI/ML experiment requires效果评测
66
+ },
67
+ hotfix: {
68
+ name: 'hotfix',
69
+ label: '热修复',
70
+ stages: ['01', '03', '04', '06'],
71
+ description: '跳过设计阶段的快速修复流程',
72
+ mode: 'waterfall'
73
+ }
74
+ };
75
+
76
+ // Verification levels (for Layer 1)
77
+ export const VERIFICATION_LEVELS = {
78
+ quick: {
79
+ name: 'quick',
80
+ label: '快速验证',
81
+ checks: ['compile', 'unit-test'],
82
+ description: '编译 + 单元测试,适用于编码阶段每次提交',
83
+ estimatedTime: 'seconds to minutes'
84
+ },
85
+ full: {
86
+ name: 'full',
87
+ label: '完整验证',
88
+ checks: ['compile', 'all-tests', 'lint', 'type-check'],
89
+ description: '编译 + 全量测试 + Lint + 类型检查,适用于阶段准出和交付前',
90
+ estimatedTime: 'minutes to tens of minutes'
91
+ }
92
+ };
93
+
94
+ // Execution modes
95
+ export const EXECUTION_MODES = {
96
+ interactive: {
97
+ name: 'interactive',
98
+ label: '交互模式',
99
+ description: '有人值守,可询问用户,允许阻塞等待输入',
100
+ blocking: true
101
+ },
102
+ unattended: {
103
+ name: 'unattended',
104
+ label: '自动模式',
105
+ description: '无人值守,全自动执行,禁止阻塞,使用推荐值+记录待确认',
106
+ blocking: false
107
+ }
108
+ };
109
+
110
+ // Issue classification for rollback decisions
111
+ export const ISSUE_CLASSIFICATION = {
112
+ AUTO_FIX: {
113
+ name: 'auto_fix',
114
+ label: '自动修复',
115
+ description: '两种模式都直接执行:格式、术语、拼写、缺失必填字段、引用错误',
116
+ requiresHuman: false
117
+ },
118
+ AUTO_DECIDE: {
119
+ name: 'auto_decide',
120
+ label: '自动决策',
121
+ description: '交互模式询问用户,自动模式用保守默认:安全、业务逻辑、性能、合规',
122
+ requiresHuman: 'interactive_only'
123
+ },
124
+ REQUIRE_REVIEW: {
125
+ name: 'require_review',
126
+ label: '人工审阅',
127
+ description: '两种模式都记录,自动模式不阻塞:架构变更、大重构、外部集成',
128
+ requiresHuman: true
129
+ }
130
+ };
131
+
132
+ // Default config
133
+ export const DEFAULT_CONFIG = {
134
+ workflow: 'waterfall',
135
+ roles: [],
136
+ frameworkDir: '.autospec'
137
+ };
138
+
139
+ // State file path (for backward compatibility, points to runtime/)
140
+ export const STATE_FILE = '.autospec/runtime/state.json';
141
+
142
+ // Metrics file path
143
+ export const METRICS_FILE = '.autospec/runtime/metrics.json';
144
+
145
+ // Skills paths (relative to knowledge/)
146
+ export const SKILLS = {
147
+ // Stage skills (做类 + 审类)
148
+ STAGES: {
149
+ REQUIREMENT_ANALYZER: 'guides/stages/requirement-analyzer.md',
150
+ REQUIREMENT_REVIEWER: 'guides/stages/requirement-reviewer.md',
151
+ DESIGN_PLANNER: 'guides/stages/design-planner.md',
152
+ DESIGN_REVIEWER: 'guides/stages/design-reviewer.md',
153
+ CODE_IMPLEMENTER: 'guides/stages/code-implementer.md',
154
+ CODE_REVIEWER: 'guides/stages/code-reviewer.md',
155
+ TEST_PLANNER: 'guides/stages/test-planner.md',
156
+ TEST_GENERATOR: 'guides/stages/test-generator.md',
157
+ TEST_REVIEWER: 'guides/stages/test-reviewer.md',
158
+ RELEASE_CHECKER: 'guides/stages/release-checker.md',
159
+ CONSISTENCY_CHECKER: 'guides/stages/consistency-checker.md',
160
+ },
161
+ // Support skills (流程增强 + AI专项)
162
+ SUPPORT: {
163
+ // Skill evolution
164
+ SKILL_DISTILLER: 'guides/support/skill-distiller.md',
165
+ SKILL_UPDATER: 'guides/support/skill-updater.md',
166
+ SKILL_VALIDATOR: 'guides/support/skill-validator.md',
167
+ METHODOLOGY_EXTRACTOR: 'guides/support/methodology-extractor.md',
168
+ PRACTICE_LOGGER: 'guides/support/practice-logger.md',
169
+ // Environment
170
+ ENVIRONMENT_SCANNER: 'guides/support/environment-scanner.md',
171
+ ENVIRONMENT_VALIDATOR: 'guides/support/environment-validator.md',
172
+ COMPONENT_DISCOVERY: 'guides/support/component-discovery.md',
173
+ TECH_STACK_ANALYZER: 'guides/support/tech-stack-analyzer.md',
174
+ AI_COMPONENT_ANALYZER: 'guides/support/ai-component-analyzer.md',
175
+ KNOWLEDGE_GENERATOR: 'guides/support/knowledge-generator.md',
176
+ // Protocol
177
+ PIPELINE_PROTOCOL: 'guides/support/pipeline-protocol.md',
178
+ SCOPE_INFERENCE: 'guides/support/scope-inference.md',
179
+ // Runner
180
+ TEST_RUNNER: 'guides/support/test-runner.md',
181
+ // AI
182
+ RAG_ANALYZER: 'guides/support/ai-rag-analyzer.md',
183
+ AGENT_ANALYZER: 'guides/support/ai-agent-analyzer.md',
184
+ EVALUATION_PLANNER: 'guides/support/ai-evaluation-planner.md',
185
+ AI_DATA_VALIDATOR: 'guides/support/ai-data-validator.md',
186
+ AI_TEST_DIAGNOSTICS: 'guides/support/ai-test-diagnostics.md',
187
+ }
188
+ };
189
+
190
+ // Knowledge paths (relative to .autospec/knowledge/)
191
+ export const FW_PATHS = {
192
+ CONSTITUTION: 'principles/constitution.md',
193
+ EVOLUTION: 'principles/evolution.md',
194
+ PIPELINE_DIR: 'process/',
195
+ CHECKLISTS_DIR: 'checklists/',
196
+ GUIDES_DIR: 'guides/',
197
+ ENVIRONMENT_DIR: 'environment/',
198
+ CONFIG_DIR: 'config/',
199
+ };
200
+
201
+ // ============================================================
202
+ // Environment Integration Protocol (环境衔接协议)
203
+ // ============================================================
204
+
205
+ // Environment directories (relative to .autospec/)
206
+ export const ENV_DIRS = {
207
+ ROOT: 'environment',
208
+ ENV_KNOWLEDGE: 'environment/env-knowledge',
209
+ MIDDLEWARE: 'environment/env-knowledge/middleware',
210
+ INFRASTRUCTURE: 'environment/env-knowledge/infrastructure',
211
+ ENV_VARIABLES: 'environment/env-knowledge/env-variables',
212
+ COMPONENT_LIB: 'environment/component-lib',
213
+ COMPONENTS: 'environment/component-lib/components',
214
+ BEST_PRACTICES: 'environment/component-lib/best-practices',
215
+ DOMAIN_MODELS: 'environment/component-lib/domain-models',
216
+ INTEGRATION: 'environment/integration',
217
+ CI_CD: 'environment/integration/ci-cd',
218
+ TESTING: 'environment/integration/testing',
219
+ DEPLOYMENT: 'environment/integration/deployment',
220
+ };
221
+
222
+ // Environment files (relative to .autospec/environment/)
223
+ export const ENV_FILES = {
224
+ REGISTRY: 'registry.json',
225
+ DETECTION_PATTERNS: 'detection-patterns.yaml',
226
+ ENVIRONMENT_CONTEXT: 'environment-context.json',
227
+ };
228
+
229
+ // Knowledge types for environment protocol
230
+ export const KNOWLEDGE_TYPES = {
231
+ MIDDLEWARE: 'MiddlewareKnowledge',
232
+ COMPONENT: 'ComponentKnowledge',
233
+ INTEGRATION: 'IntegrationKnowledge',
234
+ INFRASTRUCTURE: 'InfrastructureKnowledge',
235
+ BEST_PRACTICE: 'BestPracticeKnowledge',
236
+ };
237
+
238
+ // Knowledge evolution zones
239
+ export const KNOWLEDGE_ZONES = {
240
+ FROZEN: 'frozen', // 冻结区:人工变更(constitution, evolution, design-philosophy)
241
+ CONTROLLED: 'controlled', // 受控区:人工批准+自动验证(pipeline, roles, method skills)
242
+ FREE: 'free', // 自由区:自动进化(domain skills, decision trees)
243
+ };
244
+
245
+ // Knowledge scope (for global/org/project triple-layer)
246
+ export const KNOWLEDGE_SCOPE = {
247
+ GLOBAL: 'global', // 用户级全局知识 (~/.claude/autospec/)
248
+ ORG: 'org', // 组织级知识 (~/.claude/autospec/orgs/{org-name}/)
249
+ PROJECT: 'project' // 项目级知识 (.autospec/)
250
+ };
251
+
252
+ // Global autospec directories (in user home)
253
+ export const GLOBAL_AUTOSPEC_DIR = '.claude/autospec';
254
+ export const GLOBAL_AUTOSPEC_SUBDIRS = {
255
+ KNOWLEDGE: 'knowledge',
256
+ SKILLS: 'skills',
257
+ ROLES: 'roles',
258
+ ENVIRONMENT: 'environment',
259
+ EVOLUTION: 'evolution',
260
+ MEMORY: 'memory'
261
+ };
262
+
263
+ // Organization autospec directories
264
+ export const ORG_AUTOSPEC_DIR = '.claude/autospec/orgs';
265
+ export const ORG_AUTOSPEC_SUBDIRS = {
266
+ SKILLS: 'skills',
267
+ ROLES: 'roles',
268
+ ENVIRONMENT: 'environment',
269
+ EVOLUTION: 'evolution'
270
+ };
271
+
272
+ // Claude Code skills symlink path
273
+ export const CLAUDE_CODE_SKILLS_DIR = '.claude/skills';
274
+
275
+ // Environment knowledge schema version
276
+ export const ENV_KNOWLEDGE_API_VERSION = 'autospec/v1';
277
+
278
+ // Default environment registry
279
+ export const DEFAULT_ENV_REGISTRY = {
280
+ version: '1.0',
281
+ lastUpdated: new Date().toISOString().split('T')[0],
282
+ environmentKnowledge: {
283
+ middleware: [],
284
+ infrastructure: [],
285
+ },
286
+ componentKnowledge: {
287
+ components: [],
288
+ bestPractices: [],
289
+ domainModels: [],
290
+ },
291
+ integrationKnowledge: {
292
+ ci_cd: [],
293
+ testing: [],
294
+ deployment: [],
295
+ },
296
+ activeProfiles: {
297
+ environment: 'development',
298
+ middleware: [],
299
+ components: [],
300
+ ci_cd: null,
301
+ },
302
+ };
303
+
304
+ // ============================================================
305
+ // Memory System (记忆系统)
306
+ // ============================================================
307
+
308
+ // Global memory directory (in user home, for cross-project sharing)
309
+ export const GLOBAL_MEMORY_DIR = '.autospec-global/memory';
310
+
311
+ // Project memory directories (relative to .autospec/)
312
+ export const MEMORY_DIRS = {
313
+ ROOT: 'memory',
314
+ CORE: 'memory/core', // 热层:始终加载
315
+ WORKING: 'memory/working', // 温层:按任务加载
316
+ SESSIONS: 'memory/sessions', // 温层:跨任务保留
317
+ PROJECT: 'memory/project', // 冷层:长期存储
318
+ LEARNED_PATTERNS: 'memory/learned-patterns' // 跨项目学习模式
319
+ };
320
+
321
+ // Memory files (relative to memory root)
322
+ export const MEMORY_FILES = {
323
+ // Core layer (热层)
324
+ NORTH_STAR: 'core/north-star.json',
325
+ TEAM_PREFERENCES: 'core/team-preferences.json',
326
+ CONSTRAINTS: 'core/constraints.json',
327
+ // Working layer (温层)
328
+ CURRENT_CONTEXT: 'working/current-context.json',
329
+ SESSION_SUMMARY: 'working/session-summary.md',
330
+ // Sessions layer
331
+ SESSIONS_INDEX: 'sessions/index.json',
332
+ // Project layer (冷层)
333
+ TECH_STACK: 'project/tech-stack.json',
334
+ ARCHITECTURE: 'project/architecture.json',
335
+ MILESTONES: 'project/milestones.json',
336
+ LEARNED_PATTERNS: 'project/learned-patterns.json',
337
+ // Meta
338
+ MEMORY_META: 'memory-meta.json'
339
+ };
340
+
341
+ // Memory scope
342
+ export const MEMORY_SCOPE = {
343
+ GLOBAL: 'global', // ~/.autospec-global/memory/
344
+ PROJECT: 'project' // .autospec/memory/
345
+ };
346
+
347
+ // Memory TTL (days)
348
+ export const MEMORY_TTL = {
349
+ SESSION: 90, // 会话记忆保留90天
350
+ WORKING: 7, // 工作记忆保留7天
351
+ PROJECT: Infinity // 项目记忆永久保留
352
+ };
353
+
354
+ // Memory layers
355
+ export const MEMORY_LAYERS = {
356
+ CORE: 'core', // 热层:始终在上下文中
357
+ WORKING: 'working', // 温层:当前任务相关
358
+ SESSIONS: 'sessions',// 温层:跨任务保留
359
+ PROJECT: 'project' // 冷层:长期存储
360
+ };
361
+
362
+ // Default north star template
363
+ export const DEFAULT_NORTH_STAR = {
364
+ version: '1.0',
365
+ lastUpdated: new Date().toISOString(),
366
+ mission: '',
367
+ vision: '',
368
+ northStarMetric: {
369
+ name: '',
370
+ description: '',
371
+ target: '',
372
+ current: '',
373
+ updatedAt: new Date().toISOString().split('T')[0]
374
+ },
375
+ keyResults: [],
376
+ activeDecisions: []
377
+ };
378
+
379
+ // Default team preferences template
380
+ export const DEFAULT_TEAM_PREFERENCES = {
381
+ version: '1.0',
382
+ lastUpdated: new Date().toISOString(),
383
+ communicationStyle: {
384
+ language: 'zh-CN',
385
+ codeCommentsLanguage: 'en',
386
+ verbosity: 'concise', // verbose | normal | concise
387
+ confirmationLevel: 'low' // high | medium | low
388
+ },
389
+ technicalPreferences: {
390
+ frameworkMinded: 'prefer-existing', // prefer-existing | latest-stable | bleeding-edge
391
+ testPriority: 'high',
392
+ documentationLevel: 'essential', // comprehensive | standard | essential | minimal
393
+ errorHandling: 'defensive' // defensive | minimal | fail-fast
394
+ },
395
+ workflowPreferences: {
396
+ defaultWorkflow: 'waterfall',
397
+ stageGateEnabled: true,
398
+ autoFixRetryLimit: 3,
399
+ humanInterventionThreshold: 'medium'
400
+ },
401
+ projectSpecific: {}
402
+ };
403
+
404
+ // Default constraints template
405
+ export const DEFAULT_CONSTRAINTS = {
406
+ version: '1.0',
407
+ lastUpdated: new Date().toISOString(),
408
+ hardConstraints: [], // 不可违反的红线
409
+ softConstraints: [], // 建议遵守的规则
410
+ techDebtAllowance: [] // 允许的技术债务
411
+ };
412
+
413
+ // Memory meta template
414
+ export const DEFAULT_MEMORY_META = {
415
+ version: '1.0',
416
+ createdAt: new Date().toISOString(),
417
+ lastUpdated: new Date().toISOString(),
418
+ scope: 'project', // global | project
419
+ statistics: {
420
+ totalSessions: 0,
421
+ totalDecisions: 0,
422
+ lastSessionDate: null
423
+ }
424
+ };