@chongyan/autospec 1.0.1 → 1.0.3

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 (595) hide show
  1. package/LICENSE +242 -21
  2. package/README.md +54 -476
  3. package/dist/README.md +54 -0
  4. package/dist/adapters/claude-code/README.md.enc +6 -0
  5. package/dist/adapters/claude-code/agents.js +1 -0
  6. package/dist/adapters/claude-code/commands.config.js +1 -0
  7. package/dist/adapters/claude-code/commands.js +1 -0
  8. package/dist/adapters/claude-code/hooks.config.js +2 -0
  9. package/dist/adapters/claude-code/hooks.js +1 -0
  10. package/dist/adapters/claude-code/install.js +1 -0
  11. package/dist/adapters/claude-code/skills.js +1 -0
  12. package/dist/adapters/codex/README.md.enc +6 -0
  13. package/dist/adapters/codex/hooks/pre-commit.sh +10 -0
  14. package/dist/adapters/codex/install.js +1 -0
  15. package/dist/adapters/codex/prompts/env-learn.md.enc +6 -0
  16. package/dist/adapters/codex/prompts/review.md.enc +6 -0
  17. package/dist/adapters/codex/wrappers/autospec-cli.sh +118 -0
  18. package/dist/adapters/codex/wrappers/parallel.sh +20 -0
  19. package/dist/adapters/codex/wrappers/post-task.sh +138 -0
  20. package/dist/bin/autospec.js +2 -0
  21. package/dist/knowledge/README.en.md.enc +6 -0
  22. package/dist/knowledge/README.md.enc +6 -0
  23. package/dist/knowledge/change-management.md.enc +6 -0
  24. package/dist/knowledge/cognition-engine.md.enc +6 -0
  25. package/dist/knowledge/config/baseline-permissions.md.enc +6 -0
  26. package/dist/knowledge/config/external-mounts.yaml.enc +6 -0
  27. package/dist/knowledge/config/model-profiles.yaml.enc +6 -0
  28. package/dist/knowledge/config/role-composition.yaml.enc +6 -0
  29. package/dist/knowledge/config/token-optimization.yaml.enc +6 -0
  30. package/dist/knowledge/config/validation-patterns.yaml.enc +6 -0
  31. package/dist/knowledge/constitution.md.enc +6 -0
  32. package/dist/knowledge/core-rules.md.enc +6 -0
  33. package/dist/knowledge/environment/adapters/README.md.enc +6 -0
  34. package/dist/knowledge/environment/detection-patterns.yaml.enc +6 -0
  35. package/dist/knowledge/environment/failure-patterns.json +223 -0
  36. package/dist/knowledge/environment/repair-strategies.json +206 -0
  37. package/dist/knowledge/memory/README.md.enc +6 -0
  38. package/dist/knowledge/memory/field/README.md.enc +6 -0
  39. package/dist/knowledge/memory/project/decisions/README.md.enc +6 -0
  40. package/dist/knowledge/memory/project/evolution-log.md.enc +6 -0
  41. package/dist/knowledge/memory/project/health-metrics.md.enc +6 -0
  42. package/dist/knowledge/memory/team/best-practices.md.enc +6 -0
  43. package/dist/knowledge/pipeline/code.md.enc +6 -0
  44. package/dist/knowledge/pipeline/explore.md.enc +6 -0
  45. package/dist/knowledge/pipeline/plan.md.enc +6 -0
  46. package/dist/knowledge/pipeline/protocol.md.enc +6 -0
  47. package/dist/knowledge/protocol/capabilities.yaml.enc +6 -0
  48. package/dist/knowledge/protocol/evolve-integration.md.enc +6 -0
  49. package/dist/knowledge/skills/README.md.enc +6 -0
  50. package/dist/knowledge/skills/adversarial-review.md.enc +6 -0
  51. package/dist/knowledge/skills/analyze-requirement.md.enc +6 -0
  52. package/dist/knowledge/skills/channel-operations.md.enc +6 -0
  53. package/dist/knowledge/skills/content-operations.md.enc +6 -0
  54. package/dist/knowledge/skills/content-prompts.md.enc +6 -0
  55. package/dist/knowledge/skills/conversion-optimization.md.enc +6 -0
  56. package/dist/knowledge/skills/data-operations.md.enc +6 -0
  57. package/dist/knowledge/skills/design-solution.md.enc +6 -0
  58. package/dist/knowledge/skills/growth-strategies.md.enc +6 -0
  59. package/dist/knowledge/skills/implement-code.md.enc +6 -0
  60. package/dist/knowledge/skills/knowledge-distill.md.enc +6 -0
  61. package/dist/knowledge/skills/parallel-dev.md.enc +6 -0
  62. package/dist/knowledge/skills/private-domain-traffic.md.enc +6 -0
  63. package/dist/knowledge/skills/skill-format.md.enc +6 -0
  64. package/dist/knowledge/skills/social-commerce.md.enc +6 -0
  65. package/dist/knowledge/skills/team-orchestration.md.enc +6 -0
  66. package/dist/knowledge/skills/unified-review.md.enc +6 -0
  67. package/dist/knowledge/skills/user-operations.md.enc +6 -0
  68. package/dist/knowledge/templates/autospec-config.yaml.enc +6 -0
  69. package/dist/knowledge/templates/smoke-test.md.enc +6 -0
  70. package/dist/knowledge/templates/spec/SPEC.md.enc +6 -0
  71. package/dist/knowledge/templates/spec/layers/delta.md.enc +6 -0
  72. package/dist/knowledge/templates/spec/layers/how.md.enc +6 -0
  73. package/dist/knowledge/templates/spec/layers/plan.md.enc +6 -0
  74. package/dist/knowledge/templates/spec/layers/what.md.enc +6 -0
  75. package/dist/knowledge/templates/spec/layers/why.md.enc +6 -0
  76. package/dist/knowledge/templates/wiki/catalog.yaml.enc +6 -0
  77. package/dist/knowledge/templates/wiki/content.md.enc +6 -0
  78. package/dist/knowledge/templates/wiki/meta.yaml.enc +6 -0
  79. package/dist/package.json +62 -0
  80. package/dist/plugins/.claude-plugin/plugin.json +671 -0
  81. package/dist/plugins/agents/roles/ai-engineer.md.enc +6 -0
  82. package/dist/plugins/agents/roles/backend-engineer.md.enc +6 -0
  83. package/dist/plugins/agents/roles/ceo.md.enc +6 -0
  84. package/dist/plugins/agents/roles/channel-ops.md.enc +6 -0
  85. package/dist/plugins/agents/roles/content-ops.md.enc +6 -0
  86. package/dist/plugins/agents/roles/conversion-ops.md.enc +6 -0
  87. package/dist/plugins/agents/roles/data-engineer.md.enc +6 -0
  88. package/dist/plugins/agents/roles/data-ops.md.enc +6 -0
  89. package/dist/plugins/agents/roles/devops-engineer.md.enc +6 -0
  90. package/dist/plugins/agents/roles/frontend-engineer.md.enc +6 -0
  91. package/dist/plugins/agents/roles/marketing-director.md.enc +6 -0
  92. package/dist/plugins/agents/roles/operations-director.md.enc +6 -0
  93. package/dist/plugins/agents/roles/private-traffic.md.enc +6 -0
  94. package/dist/plugins/agents/roles/product-owner.md.enc +6 -0
  95. package/dist/plugins/agents/roles/quality-engineer.md.enc +6 -0
  96. package/dist/plugins/agents/roles/security-engineer.md.enc +6 -0
  97. package/dist/plugins/agents/roles/tech-lead.md.enc +6 -0
  98. package/dist/plugins/agents/roles/user-ops.md.enc +6 -0
  99. package/dist/plugins/agents/support/blind-comparator.md.enc +6 -0
  100. package/dist/plugins/agents/support/consistency-checker.md.enc +6 -0
  101. package/dist/plugins/agents/support/experiment-evaluator.md.enc +6 -0
  102. package/dist/plugins/agents/support/failure-diagnostician.md.enc +6 -0
  103. package/dist/plugins/agents/support/independent-reviewer.md.enc +6 -0
  104. package/dist/plugins/agents/support/memory-curator.md.enc +6 -0
  105. package/dist/plugins/agents/support/monitoring-agent.md.enc +6 -0
  106. package/dist/plugins/agents/support/safety-auditor.md.enc +6 -0
  107. package/dist/plugins/agents/support/skill-benchmarker.md.enc +6 -0
  108. package/dist/plugins/agents/support/skill-forger.md.enc +6 -0
  109. package/dist/plugins/agents/support/stage-gate-evaluator.md.enc +6 -0
  110. package/dist/plugins/agents/support/team-orchestrator.md.enc +6 -0
  111. package/dist/plugins/agents/support/test-coverage-reviewer.md.enc +6 -0
  112. package/dist/plugins/benchmarks/templates/README.en.md.enc +6 -0
  113. package/dist/plugins/benchmarks/templates/README.md.enc +6 -0
  114. package/dist/plugins/benchmarks/templates/commands/code-template.yaml.enc +6 -0
  115. package/dist/plugins/benchmarks/templates/commands/explore-template.yaml.enc +6 -0
  116. package/dist/plugins/benchmarks/templates/commands/field-evolve-template.yaml.enc +6 -0
  117. package/dist/plugins/benchmarks/templates/commands/plan-template.yaml.enc +6 -0
  118. package/dist/plugins/benchmarks/templates/commands/project-evolve-template.yaml.enc +6 -0
  119. package/dist/plugins/benchmarks/templates/commands/review-template.yaml.enc +6 -0
  120. package/dist/plugins/benchmarks/templates/commands/run-template.yaml.enc +6 -0
  121. package/dist/plugins/benchmarks/templates/skills/benchmark-executor-template.yaml.enc +6 -0
  122. package/dist/plugins/benchmarks/templates/skills/benchmark-generator-template.yaml.enc +6 -0
  123. package/dist/plugins/benchmarks/templates/skills/delivery-stage-template.yaml.enc +6 -0
  124. package/dist/plugins/benchmarks/templates/skills/design-stage-template.yaml.enc +6 -0
  125. package/dist/plugins/benchmarks/templates/skills/exploration-phase-template.yaml.enc +6 -0
  126. package/dist/plugins/benchmarks/templates/skills/field-evolve-analyzer-template.yaml.enc +6 -0
  127. package/dist/plugins/benchmarks/templates/skills/field-evolve-distiller-template.yaml.enc +6 -0
  128. package/dist/plugins/benchmarks/templates/skills/field-evolve-executor-template.yaml.enc +6 -0
  129. package/dist/plugins/benchmarks/templates/skills/field-evolve-fixer-template.yaml.enc +6 -0
  130. package/dist/plugins/benchmarks/templates/skills/field-evolve-learner-template.yaml.enc +6 -0
  131. package/dist/plugins/benchmarks/templates/skills/field-evolve-scanner-template.yaml.enc +6 -0
  132. package/dist/plugins/benchmarks/templates/skills/field-evolve-template.yaml.enc +6 -0
  133. package/dist/plugins/benchmarks/templates/skills/field-evolve-verifier-template.yaml.enc +6 -0
  134. package/dist/plugins/benchmarks/templates/skills/implementation-stage-template.yaml.enc +6 -0
  135. package/dist/plugins/benchmarks/templates/skills/layer1-validation-template.yaml.enc +6 -0
  136. package/dist/plugins/benchmarks/templates/skills/project-evolve-analyzer-template.yaml.enc +6 -0
  137. package/dist/plugins/benchmarks/templates/skills/project-evolve-fixer-template.yaml.enc +6 -0
  138. package/dist/plugins/benchmarks/templates/skills/project-evolve-generator-template.yaml.enc +6 -0
  139. package/dist/plugins/benchmarks/templates/skills/project-evolve-learner-template.yaml.enc +6 -0
  140. package/dist/plugins/benchmarks/templates/skills/project-evolve-reviewer-template.yaml.enc +6 -0
  141. package/dist/plugins/benchmarks/templates/skills/project-evolve-scanner-template.yaml.enc +6 -0
  142. package/dist/plugins/benchmarks/templates/skills/project-evolve-template.yaml.enc +6 -0
  143. package/dist/plugins/benchmarks/templates/skills/project-evolve-verifier-template.yaml.enc +6 -0
  144. package/dist/plugins/benchmarks/templates/skills/requirement-analyzer-template.yaml.enc +6 -0
  145. package/dist/plugins/benchmarks/templates/skills/skill-forge-template.yaml.enc +6 -0
  146. package/dist/plugins/benchmarks/templates/skills/startup-guard-template.yaml.enc +6 -0
  147. package/dist/plugins/benchmarks/templates/skills/testing-stage-template.yaml.enc +6 -0
  148. package/dist/plugins/commands/README.en.md.enc +6 -0
  149. package/dist/plugins/commands/README.md.enc +6 -0
  150. package/dist/plugins/commands/automation.md.enc +6 -0
  151. package/dist/plugins/commands/code.md.enc +6 -0
  152. package/dist/plugins/commands/contribute.md.enc +6 -0
  153. package/dist/plugins/commands/dashboard.md.enc +6 -0
  154. package/dist/plugins/commands/env.md.enc +6 -0
  155. package/dist/plugins/commands/explore.md.enc +6 -0
  156. package/dist/plugins/commands/field-evolve.md.enc +6 -0
  157. package/dist/plugins/commands/global.md.enc +6 -0
  158. package/dist/plugins/commands/init.md.enc +6 -0
  159. package/dist/plugins/commands/list.md.enc +6 -0
  160. package/dist/plugins/commands/memory.md.enc +6 -0
  161. package/dist/plugins/commands/monitor.md.enc +6 -0
  162. package/dist/plugins/commands/org.md.enc +6 -0
  163. package/dist/plugins/commands/persist.md.enc +6 -0
  164. package/dist/plugins/commands/plan.md.enc +6 -0
  165. package/dist/plugins/commands/plugin.md.enc +6 -0
  166. package/dist/plugins/commands/project-evolve.md.enc +6 -0
  167. package/dist/plugins/commands/review.md.enc +6 -0
  168. package/dist/plugins/commands/run.md.enc +6 -0
  169. package/dist/plugins/commands/status.md.enc +6 -0
  170. package/dist/plugins/commands/sync.md.enc +6 -0
  171. package/dist/plugins/commands/update.md.enc +6 -0
  172. package/dist/plugins/env-capabilities/env-core/plugin.json +33 -0
  173. package/dist/plugins/hooks/README.en.md.enc +6 -0
  174. package/dist/plugins/hooks/README.md.enc +6 -0
  175. package/dist/plugins/hooks/artifact-evaluation-hook.js +2 -0
  176. package/dist/plugins/hooks/cognitive-dreamer.js +2 -0
  177. package/dist/plugins/hooks/cognitive-sync.js +2 -0
  178. package/dist/plugins/hooks/cognitive-tracker.js +2 -0
  179. package/dist/plugins/hooks/config/detection-patterns.yaml.enc +6 -0
  180. package/dist/plugins/hooks/constitution-guard.js +2 -0
  181. package/dist/plugins/hooks/do-review-separation-guard.js +2 -0
  182. package/dist/plugins/hooks/environment-autocommit.js +2 -0
  183. package/dist/plugins/hooks/environment-doctor.js +1 -0
  184. package/dist/plugins/hooks/environment-startup-scan.js +2 -0
  185. package/dist/plugins/hooks/execution-tracker.js +2 -0
  186. package/dist/plugins/hooks/frozen-zone-guard.js +2 -0
  187. package/dist/plugins/hooks/layer1-validator.js +2 -0
  188. package/dist/plugins/hooks/lib/artifact-evaluator.js +1 -0
  189. package/dist/plugins/hooks/lib/auto-fix-loop.js +1 -0
  190. package/dist/plugins/hooks/lib/benchmarks/change-detector.js +1 -0
  191. package/dist/plugins/hooks/lib/benchmarks/evaluator.js +1 -0
  192. package/dist/plugins/hooks/lib/benchmarks/integration-example.js +1 -0
  193. package/dist/plugins/hooks/lib/cognitive/adaptive-matcher.js +1 -0
  194. package/dist/plugins/hooks/lib/cognitive/base-store.js +1 -0
  195. package/dist/plugins/hooks/lib/cognitive/causal-engine.js +1 -0
  196. package/dist/plugins/hooks/lib/cognitive/cognitive-config.js +1 -0
  197. package/dist/plugins/hooks/lib/cognitive/cognitive-fingerprint.js +1 -0
  198. package/dist/plugins/hooks/lib/cognitive/collective-sync.js +1 -0
  199. package/dist/plugins/hooks/lib/cognitive/confidence-engine.js +1 -0
  200. package/dist/plugins/hooks/lib/cognitive/dream-engine.js +1 -0
  201. package/dist/plugins/hooks/lib/cognitive/episodic-store.js +1 -0
  202. package/dist/plugins/hooks/lib/cognitive/index.js +1 -0
  203. package/dist/plugins/hooks/lib/cognitive/kernel.js +1 -0
  204. package/dist/plugins/hooks/lib/cognitive/knowledge-distiller.js +1 -0
  205. package/dist/plugins/hooks/lib/cognitive/memory-transport.js +1 -0
  206. package/dist/plugins/hooks/lib/cognitive/persistence-manager.js +1 -0
  207. package/dist/plugins/hooks/lib/cognitive/priority-store.js +1 -0
  208. package/dist/plugins/hooks/lib/cognitive/procedural-store.js +1 -0
  209. package/dist/plugins/hooks/lib/cognitive/semantic-store.js +1 -0
  210. package/dist/plugins/hooks/lib/cognitive/skill-tuner.js +1 -0
  211. package/dist/plugins/hooks/lib/cognitive/wiki-materializer.js +1 -0
  212. package/dist/plugins/hooks/lib/detection-pattern-loader.js +1 -0
  213. package/dist/plugins/hooks/lib/directory-discovery.js +1 -0
  214. package/dist/plugins/hooks/lib/environment-capability-package.js +1 -0
  215. package/dist/plugins/hooks/lib/environment-capability-probe.js +1 -0
  216. package/dist/plugins/hooks/lib/environment-config-loader.js +1 -0
  217. package/dist/plugins/hooks/lib/environment-executor.js +1 -0
  218. package/dist/plugins/hooks/lib/environment-feedback.js +1 -0
  219. package/dist/plugins/hooks/lib/environment-health-monitor.js +1 -0
  220. package/dist/plugins/hooks/lib/environment-knowledge-synthesizer.js +1 -0
  221. package/dist/plugins/hooks/lib/environment-knowledge-validator.js +1 -0
  222. package/dist/plugins/hooks/lib/environment-learning-discoverer.js +1 -0
  223. package/dist/plugins/hooks/lib/environment-learning-engine.js +1 -0
  224. package/dist/plugins/hooks/lib/environment-module-repository.js +1 -0
  225. package/dist/plugins/hooks/lib/environment-planner.js +1 -0
  226. package/dist/plugins/hooks/lib/environment-plugin-registry.js +1 -0
  227. package/dist/plugins/hooks/lib/environment-readiness.js +1 -0
  228. package/dist/plugins/hooks/lib/environment-route-ranking.js +1 -0
  229. package/dist/plugins/hooks/lib/environment-strategy-overlay.js +1 -0
  230. package/dist/plugins/hooks/lib/execution-path.js +1 -0
  231. package/dist/plugins/hooks/lib/external-mount-adapter.js +1 -0
  232. package/dist/plugins/hooks/lib/external-scanner.js +1 -0
  233. package/dist/plugins/hooks/lib/hook-error-recorder.js +1 -0
  234. package/dist/plugins/hooks/lib/hook-logger.js +1 -0
  235. package/dist/plugins/hooks/lib/hook-runner.js +2 -0
  236. package/dist/plugins/hooks/lib/hook-state-manager.js +1 -0
  237. package/dist/plugins/hooks/lib/memory-extractor.js +1 -0
  238. package/dist/plugins/hooks/lib/memory-manager.js +1 -0
  239. package/dist/plugins/hooks/lib/metrics-analyzer.js +1 -0
  240. package/dist/plugins/hooks/lib/mount-manager.js +1 -0
  241. package/dist/plugins/hooks/lib/plugin-activation-registry.js +1 -0
  242. package/dist/plugins/hooks/lib/plugin-selector.js +1 -0
  243. package/dist/plugins/hooks/lib/plugin-source-registry.js +1 -0
  244. package/dist/plugins/hooks/lib/plugin-workspace-registry.js +1 -0
  245. package/dist/plugins/hooks/lib/project-evolution/auto-fixer.js +1 -0
  246. package/dist/plugins/hooks/lib/project-evolution/memory-manager.js +1 -0
  247. package/dist/plugins/hooks/lib/project-evolution/pattern-detector.js +1 -0
  248. package/dist/plugins/hooks/lib/project-evolution/semantic-indexer.js +1 -0
  249. package/dist/plugins/hooks/lib/rollback-tracker.js +1 -0
  250. package/dist/plugins/hooks/lib/source-code-scanner.js +1 -0
  251. package/dist/plugins/hooks/lib/technology-stack-detector.js +1 -0
  252. package/dist/plugins/hooks/lib/test-failure-analyzer.js +1 -0
  253. package/dist/plugins/hooks/lib/test-failure-fixer.js +1 -0
  254. package/dist/plugins/hooks/lib/trace-context.js +1 -0
  255. package/dist/plugins/hooks/lib/validation-patterns.js +1 -0
  256. package/dist/plugins/hooks/memory-sync.js +1 -0
  257. package/dist/plugins/hooks/pipeline-observer.js +2 -0
  258. package/dist/plugins/hooks/retry-limit-guard.js +2 -0
  259. package/dist/plugins/hooks/scope-sentinel.js +2 -0
  260. package/dist/plugins/hooks/secret-scanner.js +2 -0
  261. package/dist/plugins/hooks/stop-evolve-prompt.js +1 -0
  262. package/dist/plugins/hooks/trace-initialization.js +2 -0
  263. package/dist/plugins/hooks/version-checker.js +2 -0
  264. package/dist/plugins/memory/templates/code-quality.yaml.enc +6 -0
  265. package/dist/plugins/memory/templates/multi-system.yaml.enc +6 -0
  266. package/dist/plugins/memory/templates/team-habits.yaml.enc +6 -0
  267. package/dist/plugins/memory/templates/testing.yaml.enc +6 -0
  268. package/dist/plugins/skills/README.en.md.enc +6 -0
  269. package/dist/plugins/skills/README.md.enc +6 -0
  270. package/dist/plugins/skills/ab-test-executor/SKILL.md.enc +6 -0
  271. package/dist/plugins/skills/benchmark-executor/SKILL.md.enc +6 -0
  272. package/dist/plugins/skills/benchmark-generator/SKILL.md.enc +6 -0
  273. package/dist/plugins/skills/content-prompts/SKILL.md.enc +6 -0
  274. package/dist/plugins/skills/delivery-stage/SKILL.md.enc +6 -0
  275. package/dist/plugins/skills/design-stage/SKILL.md.enc +6 -0
  276. package/dist/plugins/skills/environment-learning/SKILL.md.enc +6 -0
  277. package/dist/plugins/skills/environment-resilience/build-failure-doctor.md.enc +6 -0
  278. package/dist/plugins/skills/environment-resilience/environment-repair.md.enc +6 -0
  279. package/dist/plugins/skills/environment-resilience/pre-flight-check.md.enc +6 -0
  280. package/dist/plugins/skills/experiment-evaluator/SKILL.md.enc +6 -0
  281. package/dist/plugins/skills/exploration-phase/SKILL.md.enc +6 -0
  282. package/dist/plugins/skills/field-evolve-analyzer/SKILL.md.enc +6 -0
  283. package/dist/plugins/skills/field-evolve-distiller/SKILL.md.enc +6 -0
  284. package/dist/plugins/skills/field-evolve-executor/SKILL.md.enc +6 -0
  285. package/dist/plugins/skills/field-evolve-executor/executor.js +2 -0
  286. package/dist/plugins/skills/field-evolve-fixer/SKILL.md.enc +6 -0
  287. package/dist/plugins/skills/field-evolve-learner/SKILL.md.enc +6 -0
  288. package/dist/plugins/skills/field-evolve-scanner/SKILL.md.enc +6 -0
  289. package/dist/plugins/skills/field-evolve-scanner/scripts/fallback-scanner.js +2 -0
  290. package/dist/plugins/skills/field-evolve-verifier/SKILL.md.enc +6 -0
  291. package/dist/plugins/skills/heartbeat-monitor/SKILL.md.enc +6 -0
  292. package/dist/plugins/skills/implementation-stage/SKILL.md.enc +6 -0
  293. package/dist/plugins/skills/layer1-validation/SKILL.md.enc +6 -0
  294. package/dist/plugins/skills/multi-role-orchestration/SKILL.md.enc +6 -0
  295. package/dist/plugins/skills/ops-content-marketing/SKILL.md.enc +6 -0
  296. package/dist/plugins/skills/ops-conversion/SKILL.md.enc +6 -0
  297. package/dist/plugins/skills/ops-data-driven/SKILL.md.enc +6 -0
  298. package/dist/plugins/skills/ops-growth-strategies/SKILL.md.enc +6 -0
  299. package/dist/plugins/skills/ops-private-domain/SKILL.md.enc +6 -0
  300. package/dist/plugins/skills/ops-social-commerce/SKILL.md.enc +6 -0
  301. package/dist/plugins/skills/ops-user-growth/SKILL.md.enc +6 -0
  302. package/dist/plugins/skills/pending-dashboard/SKILL.md.enc +6 -0
  303. package/dist/plugins/skills/project-evolve-analyzer/SKILL.md.enc +6 -0
  304. package/dist/plugins/skills/project-evolve-fixer/SKILL.md.enc +6 -0
  305. package/dist/plugins/skills/project-evolve-generator/SKILL.md.enc +6 -0
  306. package/dist/plugins/skills/project-evolve-learner/SKILL.md.enc +6 -0
  307. package/dist/plugins/skills/project-evolve-reviewer/SKILL.md.enc +6 -0
  308. package/dist/plugins/skills/project-evolve-scanner/SKILL.md.enc +6 -0
  309. package/dist/plugins/skills/project-evolve-scanner/scripts/dependency-reuse-checker.js +2 -0
  310. package/dist/plugins/skills/project-evolve-scanner/scripts/subsystem-coverage.js +2 -0
  311. package/dist/plugins/skills/project-evolve-verifier/SKILL.md.enc +6 -0
  312. package/dist/plugins/skills/requirement-stage/SKILL.md.enc +6 -0
  313. package/dist/plugins/skills/secret-scanner/SKILL.md.enc +6 -0
  314. package/dist/plugins/skills/skill-forge/SKILL.md.enc +6 -0
  315. package/dist/plugins/skills/skill-forge/references/description-guide.md.enc +6 -0
  316. package/dist/plugins/skills/skill-forge/references/quality-rubric.md.enc +6 -0
  317. package/dist/plugins/skills/skill-forge/references/skill-template.md.enc +6 -0
  318. package/dist/plugins/skills/startup-guard/SKILL.md.enc +6 -0
  319. package/dist/plugins/skills/tdd-workflow/SKILL.md.enc +6 -0
  320. package/dist/plugins/skills/testing-stage/SKILL.md.enc +6 -0
  321. package/dist/plugins/skills/tracking-validator/SKILL.md.enc +6 -0
  322. package/dist/scripts/build-crypto.js +2 -0
  323. package/dist/scripts/cli/contribute.js +1 -0
  324. package/dist/scripts/cli/dashboard.js +1 -0
  325. package/dist/scripts/cli/env.js +1 -0
  326. package/dist/scripts/cli/global-init.js +1 -0
  327. package/dist/scripts/cli/global.js +1 -0
  328. package/dist/scripts/cli/index.js +1 -0
  329. package/dist/scripts/cli/init.js +1 -0
  330. package/dist/scripts/cli/list.js +1 -0
  331. package/dist/scripts/cli/memory.js +1 -0
  332. package/dist/scripts/cli/org.js +1 -0
  333. package/dist/scripts/cli/plugin.js +1 -0
  334. package/dist/scripts/cli/practice-report.js +1 -0
  335. package/dist/scripts/cli/runtime-governance.js +1 -0
  336. package/dist/scripts/cli/system.js +1 -0
  337. package/dist/scripts/cli/update.js +1 -0
  338. package/dist/scripts/commands/catalog.js +1 -0
  339. package/dist/scripts/commands/slash-command-docs.js +1 -0
  340. package/dist/scripts/config/external-mounts.config.js +2 -0
  341. package/dist/scripts/heartbeat/check.js +2 -0
  342. package/dist/scripts/heartbeat/setup-cron.js +2 -0
  343. package/dist/scripts/install/adapters.js +1 -0
  344. package/dist/scripts/install/constants.js +1 -0
  345. package/dist/scripts/install/file-reader.js +1 -0
  346. package/dist/scripts/install/index.js +1 -0
  347. package/dist/scripts/install/shards/constants-shard.js +1 -0
  348. package/dist/scripts/install/shards/crypto-config-shard.js +1 -0
  349. package/dist/scripts/install/shards/error-messages-shard.js +1 -0
  350. package/dist/scripts/install/shards/reassemble.js +1 -0
  351. package/dist/scripts/install/shards/utils-shard.js +1 -0
  352. package/dist/scripts/install/shards/version-info-shard.js +1 -0
  353. package/dist/scripts/postinstall.js +1 -0
  354. package/dist/scripts/state.js +1 -0
  355. package/package.json +21 -12
  356. package/README.en.md +0 -472
  357. package/bin/autospec.js +0 -3
  358. package/knowledge/README.md +0 -144
  359. package/knowledge/checklists/code.md +0 -182
  360. package/knowledge/checklists/design.md +0 -196
  361. package/knowledge/checklists/release.md +0 -70
  362. package/knowledge/checklists/requirement.md +0 -169
  363. package/knowledge/checklists/test.md +0 -46
  364. package/knowledge/config/README.en.md +0 -44
  365. package/knowledge/config/README.md +0 -44
  366. package/knowledge/config/role-composition.yaml +0 -98
  367. package/knowledge/config/role-extensions.yaml +0 -140
  368. package/knowledge/config/skill-compositions.yaml +0 -142
  369. package/knowledge/config/team-stage.yaml +0 -95
  370. package/knowledge/config/team-tasks.yaml +0 -139
  371. package/knowledge/config/team-triggers.yaml +0 -198
  372. package/knowledge/config/validation-patterns.yaml +0 -137
  373. package/knowledge/domain/README.md +0 -115
  374. package/knowledge/domain/flows/README.md +0 -194
  375. package/knowledge/domain/glossary.md +0 -143
  376. package/knowledge/domain/rules.md +0 -138
  377. package/knowledge/environment/README.en.md +0 -36
  378. package/knowledge/environment/README.md +0 -87
  379. package/knowledge/environment/component-knowledge.md +0 -316
  380. package/knowledge/environment/detection-patterns.yaml +0 -502
  381. package/knowledge/environment/middleware-knowledge.md +0 -237
  382. package/knowledge/environment/template-registry.md +0 -321
  383. package/knowledge/guides/domain-driven-design.md +0 -345
  384. package/knowledge/guides/knowledge-management.md +0 -369
  385. package/knowledge/guides/requirement-engineering.md +0 -329
  386. package/knowledge/guides/stages/ai-effect-evaluator.md +0 -93
  387. package/knowledge/guides/stages/code-implementer.md +0 -205
  388. package/knowledge/guides/stages/code-reviewer.md +0 -111
  389. package/knowledge/guides/stages/consistency-checker.md +0 -177
  390. package/knowledge/guides/stages/design-planner.md +0 -401
  391. package/knowledge/guides/stages/design-reviewer.md +0 -83
  392. package/knowledge/guides/stages/integration-test-runner.md +0 -105
  393. package/knowledge/guides/stages/release-checker.md +0 -205
  394. package/knowledge/guides/stages/requirement-analyzer.md +0 -195
  395. package/knowledge/guides/stages/requirement-reviewer.md +0 -83
  396. package/knowledge/guides/stages/security-reviewer.md +0 -89
  397. package/knowledge/guides/stages/test-context-analyzer.md +0 -250
  398. package/knowledge/guides/stages/test-generator.md +0 -241
  399. package/knowledge/guides/stages/test-planner.md +0 -183
  400. package/knowledge/guides/stages/test-reviewer.md +0 -76
  401. package/knowledge/guides/stages/unit-test-runner.md +0 -83
  402. package/knowledge/guides/support/ai-agent-analyzer.md +0 -362
  403. package/knowledge/guides/support/ai-anomaly-analyzer.md +0 -213
  404. package/knowledge/guides/support/ai-artifact-evaluator.md +0 -192
  405. package/knowledge/guides/support/ai-capability-analyzer.md +0 -193
  406. package/knowledge/guides/support/ai-component-analyzer.md +0 -169
  407. package/knowledge/guides/support/ai-data-validator.md +0 -276
  408. package/knowledge/guides/support/ai-evaluation-planner.md +0 -374
  409. package/knowledge/guides/support/ai-path-evaluator.md +0 -274
  410. package/knowledge/guides/support/ai-pipeline-evaluator.md +0 -219
  411. package/knowledge/guides/support/ai-rag-analyzer.md +0 -339
  412. package/knowledge/guides/support/ai-task-assessor.md +0 -418
  413. package/knowledge/guides/support/ai-test-diagnostics.md +0 -133
  414. package/knowledge/guides/support/complexity-assessor.md +0 -268
  415. package/knowledge/guides/support/component-discovery.md +0 -183
  416. package/knowledge/guides/support/environment-scanner.md +0 -207
  417. package/knowledge/guides/support/environment-validator.md +0 -207
  418. package/knowledge/guides/support/knowledge-generator.md +0 -234
  419. package/knowledge/guides/support/methodology-extractor.md +0 -55
  420. package/knowledge/guides/support/pipeline-protocol.md +0 -438
  421. package/knowledge/guides/support/practice-logger.md +0 -359
  422. package/knowledge/guides/support/scope-inference.md +0 -174
  423. package/knowledge/guides/support/skill-distiller.md +0 -91
  424. package/knowledge/guides/support/skill-updater.md +0 -45
  425. package/knowledge/guides/support/skill-validator.md +0 -72
  426. package/knowledge/guides/support/team-orchestrator.md +0 -323
  427. package/knowledge/guides/support/tech-stack-analyzer.md +0 -139
  428. package/knowledge/guides/support/test-runner.md +0 -254
  429. package/knowledge/guides/system-design.md +0 -352
  430. package/knowledge/organization/ai-native-team.md +0 -318
  431. package/knowledge/organization/team-metrics.md +0 -228
  432. package/knowledge/principles/constitution.md +0 -134
  433. package/knowledge/principles/core-principles.md +0 -368
  434. package/knowledge/principles/design-philosophy.md +0 -877
  435. package/knowledge/principles/evolution.md +0 -553
  436. package/knowledge/process/01-requirement.md +0 -113
  437. package/knowledge/process/02-design.md +0 -123
  438. package/knowledge/process/03-implementation.md +0 -90
  439. package/knowledge/process/04-review.md +0 -80
  440. package/knowledge/process/05-testing.md +0 -90
  441. package/knowledge/process/06-delivery.md +0 -88
  442. package/knowledge/process/README.en.md +0 -38
  443. package/knowledge/process/README.md +0 -48
  444. package/knowledge/process/ai-sdlc.md +0 -475
  445. package/knowledge/process/overview.md +0 -319
  446. package/knowledge/standards/code-review.md +0 -876
  447. package/knowledge/standards/coding-style.md +0 -940
  448. package/knowledge/standards/data-consistency.md +0 -1085
  449. package/knowledge/standards/document-versioning.md +0 -210
  450. package/knowledge/standards/risk-detection.md +0 -186
  451. package/knowledge/templates/ai-evaluation.md +0 -150
  452. package/knowledge/templates/api-design.md +0 -117
  453. package/knowledge/templates/database-design.md +0 -132
  454. package/knowledge/templates/domain-driven-design.md +0 -321
  455. package/knowledge/templates/product-proposal.md +0 -201
  456. package/knowledge/templates/system-design.md +0 -227
  457. package/knowledge/templates/task-breakdown.md +0 -107
  458. package/knowledge/templates/test-case.md +0 -170
  459. package/plugins/.claude-plugin/plugin.json +0 -134
  460. package/plugins/agents/roles/ai-engineer.md +0 -129
  461. package/plugins/agents/roles/backend-engineer.md +0 -165
  462. package/plugins/agents/roles/ceo.md +0 -94
  463. package/plugins/agents/roles/data-engineer.md +0 -135
  464. package/plugins/agents/roles/devops-engineer.md +0 -181
  465. package/plugins/agents/roles/frontend-engineer.md +0 -129
  466. package/plugins/agents/roles/product-owner.md +0 -98
  467. package/plugins/agents/roles/quality-engineer.md +0 -129
  468. package/plugins/agents/roles/security-engineer.md +0 -180
  469. package/plugins/agents/roles/tech-lead.md +0 -97
  470. package/plugins/agents/support/blind-comparator.md +0 -88
  471. package/plugins/agents/support/consistency-checker.md +0 -103
  472. package/plugins/agents/support/failure-diagnostician.md +0 -141
  473. package/plugins/agents/support/independent-reviewer.md +0 -80
  474. package/plugins/agents/support/safety-auditor.md +0 -121
  475. package/plugins/agents/support/skill-benchmarker.md +0 -86
  476. package/plugins/agents/support/skill-forger.md +0 -105
  477. package/plugins/agents/support/stage-gate-evaluator.md +0 -121
  478. package/plugins/agents/support/test-coverage-reviewer.md +0 -73
  479. package/plugins/benchmarks/templates/README.md +0 -44
  480. package/plugins/benchmarks/templates/commands/explore-template.yaml +0 -48
  481. package/plugins/benchmarks/templates/pipeline/agile-template.yaml +0 -84
  482. package/plugins/benchmarks/templates/pipeline/waterfall-template.yaml +0 -106
  483. package/plugins/benchmarks/templates/skills/requirement-analyzer-template.yaml +0 -48
  484. package/plugins/commands/README.en.md +0 -96
  485. package/plugins/commands/README.md +0 -96
  486. package/plugins/commands/apply.md +0 -191
  487. package/plugins/commands/archive.md +0 -76
  488. package/plugins/commands/env-export.md +0 -79
  489. package/plugins/commands/env-sync.md +0 -640
  490. package/plugins/commands/env-template.md +0 -223
  491. package/plugins/commands/env-update.md +0 -264
  492. package/plugins/commands/env-validate.md +0 -176
  493. package/plugins/commands/env.md +0 -79
  494. package/plugins/commands/explore.md +0 -76
  495. package/plugins/commands/field-evolve.md +0 -536
  496. package/plugins/commands/memory.md +0 -249
  497. package/plugins/commands/project-evolve.md +0 -821
  498. package/plugins/commands/propose.md +0 -93
  499. package/plugins/commands/review.md +0 -140
  500. package/plugins/commands/run.md +0 -224
  501. package/plugins/commands/status.md +0 -62
  502. package/plugins/commands/validate.md +0 -108
  503. package/plugins/hooks/README.en.md +0 -56
  504. package/plugins/hooks/README.md +0 -56
  505. package/plugins/hooks/ai-project-guard.js +0 -329
  506. package/plugins/hooks/artifact-evaluation-hook.js +0 -237
  507. package/plugins/hooks/constitution-guard.js +0 -211
  508. package/plugins/hooks/environment-autocommit.js +0 -264
  509. package/plugins/hooks/environment-manager.js +0 -778
  510. package/plugins/hooks/execution-tracker.js +0 -354
  511. package/plugins/hooks/frozen-zone-guard.js +0 -140
  512. package/plugins/hooks/layer1-validator.js +0 -423
  513. package/plugins/hooks/lib/artifact-evaluator.js +0 -414
  514. package/plugins/hooks/lib/benchmarks/change-detector.js +0 -390
  515. package/plugins/hooks/lib/benchmarks/evaluator.js +0 -605
  516. package/plugins/hooks/lib/benchmarks/integration-example.js +0 -169
  517. package/plugins/hooks/lib/data-and-ai-detector.js +0 -275
  518. package/plugins/hooks/lib/detection-pattern-loader.js +0 -865
  519. package/plugins/hooks/lib/directory-discovery.js +0 -395
  520. package/plugins/hooks/lib/environment-config-loader.js +0 -341
  521. package/plugins/hooks/lib/environment-detector.js +0 -553
  522. package/plugins/hooks/lib/environment-evolver.js +0 -564
  523. package/plugins/hooks/lib/environment-registry.js +0 -813
  524. package/plugins/hooks/lib/execution-path.js +0 -427
  525. package/plugins/hooks/lib/hook-error-recorder.js +0 -245
  526. package/plugins/hooks/lib/hook-logger.js +0 -538
  527. package/plugins/hooks/lib/hook-runner.js +0 -97
  528. package/plugins/hooks/lib/hook-state-manager.js +0 -480
  529. package/plugins/hooks/lib/memory-extractor.js +0 -377
  530. package/plugins/hooks/lib/memory-manager.js +0 -673
  531. package/plugins/hooks/lib/metrics-analyzer.js +0 -489
  532. package/plugins/hooks/lib/project-evolution/auto-fixer.js +0 -511
  533. package/plugins/hooks/lib/project-evolution/memory-manager.js +0 -346
  534. package/plugins/hooks/lib/project-evolution/pattern-detector.js +0 -476
  535. package/plugins/hooks/lib/project-evolution/semantic-indexer.js +0 -480
  536. package/plugins/hooks/lib/project-structure-detector.js +0 -326
  537. package/plugins/hooks/lib/rollback-tracker.js +0 -346
  538. package/plugins/hooks/lib/source-code-scanner.js +0 -596
  539. package/plugins/hooks/lib/technology-stack-detector.js +0 -374
  540. package/plugins/hooks/lib/test-failure-analyzer.js +0 -375
  541. package/plugins/hooks/lib/test-failure-fixer.js +0 -268
  542. package/plugins/hooks/lib/trace-context.js +0 -277
  543. package/plugins/hooks/lib/validation-patterns.js +0 -415
  544. package/plugins/hooks/memory-sync.js +0 -171
  545. package/plugins/hooks/pipeline-observer.js +0 -413
  546. package/plugins/hooks/scope-sentinel.js +0 -204
  547. package/plugins/hooks/trace-initialization.js +0 -169
  548. package/plugins/memory/templates/code-quality.yaml +0 -149
  549. package/plugins/memory/templates/multi-system.yaml +0 -155
  550. package/plugins/memory/templates/team-habits.yaml +0 -119
  551. package/plugins/memory/templates/testing.yaml +0 -121
  552. package/plugins/skills/README.en.md +0 -47
  553. package/plugins/skills/README.md +0 -104
  554. package/plugins/skills/benchmark-executor/README.md +0 -93
  555. package/plugins/skills/benchmark-executor/SKILL.md +0 -647
  556. package/plugins/skills/benchmark-generator/SKILL.md +0 -349
  557. package/plugins/skills/delivery-stage/SKILL.md +0 -203
  558. package/plugins/skills/design-stage/SKILL.md +0 -216
  559. package/plugins/skills/evolution-process/SKILL.md +0 -291
  560. package/plugins/skills/exploration-phase/SKILL.md +0 -133
  561. package/plugins/skills/implementation-stage/SKILL.md +0 -179
  562. package/plugins/skills/layer1-validation/SKILL.md +0 -79
  563. package/plugins/skills/pending-dashboard/SKILL.md +0 -109
  564. package/plugins/skills/project-evolution/SKILL.md +0 -847
  565. package/plugins/skills/requirement-stage/SKILL.md +0 -183
  566. package/plugins/skills/skill-forge/SKILL.md +0 -223
  567. package/plugins/skills/skill-forge/references/description-guide.md +0 -92
  568. package/plugins/skills/skill-forge/references/quality-rubric.md +0 -104
  569. package/plugins/skills/skill-forge/references/skill-template.md +0 -106
  570. package/plugins/skills/startup-guard/SKILL.md +0 -38
  571. package/plugins/skills/testing-stage/SKILL.md +0 -195
  572. package/scripts/cli/global-init.js +0 -288
  573. package/scripts/cli/global.js +0 -324
  574. package/scripts/cli/index.js +0 -55
  575. package/scripts/cli/init.js +0 -382
  576. package/scripts/cli/list.js +0 -69
  577. package/scripts/cli/org.js +0 -340
  578. package/scripts/cli/update.js +0 -44
  579. package/scripts/config/commands.config.js +0 -145
  580. package/scripts/config/hooks.config.js +0 -197
  581. package/scripts/evolution/evolution-router.js +0 -273
  582. package/scripts/evolution/evolution-signal-collector.js +0 -307
  583. package/scripts/evolution/knowledge-loader.js +0 -346
  584. package/scripts/evolution/marketplace.js +0 -317
  585. package/scripts/evolution/version-manager.js +0 -371
  586. package/scripts/install/agents.js +0 -106
  587. package/scripts/install/commands.js +0 -133
  588. package/scripts/install/constants.js +0 -424
  589. package/scripts/install/hook-logger.js +0 -536
  590. package/scripts/install/hooks.js +0 -110
  591. package/scripts/install/index.js +0 -39
  592. package/scripts/install/skills.js +0 -95
  593. package/scripts/postinstall.js +0 -25
  594. package/scripts/state.js +0 -376
  595. /package/{plugins → dist/plugins}/hooks/lib/hook-runner.sh +0 -0
@@ -1,536 +0,0 @@
1
- /**
2
- * AutoSpec Hooks Utilities
3
- * Shared utilities for all hook scripts
4
- *
5
- * This file is self-contained for hooks to work independently after being copied to target projects.
6
- */
7
-
8
- // ============================================================
9
- // Global error handlers (防止未捕获的错误导致 hook 静默失败)
10
- // ============================================================
11
-
12
- // 只注册一次
13
- let globalHandlersRegistered = false;
14
-
15
- /**
16
- * 注册全局错误处理器
17
- * 防止 uncaughtException 和 unhandledRejection 导致 hook 静默失败
18
- */
19
- function registerGlobalErrorHandlers() {
20
- if (globalHandlersRegistered) return;
21
- globalHandlersRegistered = true;
22
-
23
- process.on('uncaughtException', (err) => {
24
- console.error('[AutoSpec Hook] Uncaught exception:', err.message);
25
- if (process.env.VERBOSE || process.env.DEBUG) {
26
- console.error(err.stack);
27
- }
28
- process.exit(0); // 允许操作继续,但至少记录了错误
29
- });
30
-
31
- process.on('unhandledRejection', (reason, promise) => {
32
- const message = reason instanceof Error ? reason.message : String(reason);
33
- console.error('[AutoSpec Hook] Unhandled rejection:', message);
34
- if (process.env.VERBOSE || process.env.DEBUG && reason instanceof Error) {
35
- console.error(reason.stack);
36
- }
37
- process.exit(0);
38
- });
39
- }
40
-
41
- // 自动注册全局错误处理器
42
- registerGlobalErrorHandlers();
43
-
44
- // ============================================================
45
- // Logger utilities
46
- // ============================================================
47
-
48
- export const LOG_LEVELS = {
49
- ERROR: 0,
50
- WARN: 1,
51
- INFO: 2,
52
- DEBUG: 3
53
- };
54
-
55
- let currentLevel = LOG_LEVELS.INFO;
56
- let isVerbose = false;
57
-
58
- /**
59
- * Set log level
60
- */
61
- export function setLogLevel(level) {
62
- if (typeof level === 'string') {
63
- currentLevel = LOG_LEVELS[level.toUpperCase()] ?? LOG_LEVELS.INFO;
64
- } else {
65
- currentLevel = level;
66
- }
67
- }
68
-
69
- /**
70
- * Enable verbose mode
71
- */
72
- export function setVerbose(verbose) {
73
- isVerbose = verbose;
74
- if (verbose) {
75
- currentLevel = LOG_LEVELS.DEBUG;
76
- }
77
- }
78
-
79
- /**
80
- * Check if verbose mode is enabled
81
- */
82
- export function isVerboseMode() {
83
- return isVerbose || currentLevel >= LOG_LEVELS.DEBUG;
84
- }
85
-
86
- /**
87
- * Format log message with timestamp and level
88
- */
89
- function formatMessage(level, message, meta = {}) {
90
- const timestamp = new Date().toISOString();
91
- const levelStr = Object.keys(LOG_LEVELS).find(k => LOG_LEVELS[k] === level) || 'UNKNOWN';
92
-
93
- let output = `[${timestamp}] [${levelStr}] ${message}`;
94
-
95
- if (Object.keys(meta).length > 0) {
96
- output += '\n' + Object.entries(meta)
97
- .map(([k, v]) => ` ${k}: ${typeof v === 'object' ? JSON.stringify(v) : v}`)
98
- .join('\n');
99
- }
100
-
101
- return output;
102
- }
103
-
104
- /**
105
- * Log error message
106
- */
107
- export function error(message, meta = {}) {
108
- if (currentLevel >= LOG_LEVELS.ERROR) {
109
- console.error(formatMessage(LOG_LEVELS.ERROR, message, meta));
110
- }
111
- }
112
-
113
- /**
114
- * Log warning message
115
- */
116
- export function warn(message, meta = {}) {
117
- if (currentLevel >= LOG_LEVELS.WARN) {
118
- console.warn(formatMessage(LOG_LEVELS.WARN, message, meta));
119
- }
120
- }
121
-
122
- /**
123
- * Log info message
124
- */
125
- export function info(message, meta = {}) {
126
- if (currentLevel >= LOG_LEVELS.INFO) {
127
- console.log(formatMessage(LOG_LEVELS.INFO, message, meta));
128
- }
129
- }
130
-
131
- /**
132
- * Log debug message (only in verbose mode)
133
- */
134
- export function debug(message, meta = {}) {
135
- if (currentLevel >= LOG_LEVELS.DEBUG) {
136
- console.log(formatMessage(LOG_LEVELS.DEBUG, message, meta));
137
- }
138
- }
139
-
140
- /**
141
- * Create a hook-specific logger
142
- */
143
- export function createHookLogger(hookName) {
144
- return {
145
- error: (msg, meta) => error(`[${hookName}] ${msg}`, meta),
146
- warn: (msg, meta) => warn(`[${hookName}] ${msg}`, meta),
147
- info: (msg, meta) => info(`[${hookName}] ${msg}`, meta),
148
- debug: (msg, meta) => debug(`[${hookName}] ${msg}`, meta)
149
- };
150
- }
151
-
152
- // ============================================================
153
- // Hook error classification and security levels
154
- // ============================================================
155
-
156
- /**
157
- * Hook 错误类型枚举
158
- */
159
- export const HookErrorType = {
160
- // 可恢复错误 - hook 逻辑自身无法处理,但不影响操作
161
- RECOVERABLE: {
162
- code: 'RECOVERABLE',
163
- severity: 'low',
164
- failStrategy: 'open', // 允许操作继续
165
- shouldAlert: false,
166
- shouldLog: true
167
- },
168
-
169
- // 输入解析错误 - 输入数据格式问题
170
- PARSE_ERROR: {
171
- code: 'PARSE_ERROR',
172
- severity: 'medium',
173
- failStrategy: 'open', // 允许操作继续(无法解析则跳过检查)
174
- shouldAlert: true,
175
- shouldLog: true
176
- },
177
-
178
- // 权限错误 - 文件系统权限问题
179
- PERMISSION_ERROR: {
180
- code: 'PERMISSION_ERROR',
181
- severity: 'high',
182
- failStrategy: 'open', // 允许操作继续,但必须告警
183
- shouldAlert: true,
184
- shouldLog: true
185
- },
186
-
187
- // 运行时错误 - hook 内部逻辑错误
188
- RUNTIME_ERROR: {
189
- code: 'RUNTIME_ERROR',
190
- severity: 'high',
191
- failStrategy: 'context', // 根据 hook 类型决定
192
- shouldAlert: true,
193
- shouldLog: true
194
- },
195
-
196
- // 关键错误 - 必须阻止操作
197
- CRITICAL_ERROR: {
198
- code: 'CRITICAL_ERROR',
199
- severity: 'critical',
200
- failStrategy: 'closed', // 阻止操作
201
- shouldAlert: true,
202
- shouldLog: true
203
- }
204
- };
205
-
206
- /**
207
- * 根据 hook 名称获取其安全级别
208
- */
209
- export const HookSecurityLevel = {
210
- 'frozen-zone-guard': 'critical', // 关键安全 hook
211
- 'layer1-validator': 'critical', // 流程门禁 hook
212
- 'constitution-guard': 'high',
213
- 'scope-sentinel': 'medium',
214
- 'execution-tracker': 'low',
215
- 'pipeline-observer': 'low',
216
- 'trace-initialization': 'low',
217
- 'artifact-evaluation-hook': 'medium',
218
- 'environment-manager': 'medium',
219
- 'ai-project-guard': 'medium'
220
- };
221
-
222
- /**
223
- * 分类错误
224
- * @param {Error} err - 错误对象
225
- * @param {string} hookName - Hook 名称
226
- * @returns {Object} 错误类型
227
- */
228
- export function classifyError(err, hookName) {
229
- // 权限错误
230
- if (err.code === 'EACCES' ||
231
- err.message?.includes('permission denied') ||
232
- err.message?.includes('ENOENT')) {
233
- return HookErrorType.PERMISSION_ERROR;
234
- }
235
-
236
- // 解析错误
237
- if (err.message?.includes('JSON') ||
238
- err.message?.includes('parse') ||
239
- err.message?.includes('Unexpected token')) {
240
- return HookErrorType.PARSE_ERROR;
241
- }
242
-
243
- // 根据 hook 安全级别和错误上下文判断
244
- const securityLevel = HookSecurityLevel[hookName] || 'low';
245
-
246
- // 关键 hook 的任何错误都视为严重
247
- if (securityLevel === 'critical') {
248
- return {
249
- ...HookErrorType.RUNTIME_ERROR,
250
- failStrategy: 'closed' // 覆盖为 fail-closed
251
- };
252
- }
253
-
254
- return HookErrorType.RUNTIME_ERROR;
255
- }
256
-
257
- /**
258
- * Handle hook errors gracefully
259
- * 增强版错误处理:分类错误、记录日志、决定是否阻止操作
260
- * @param {string} hookName - Hook 名称
261
- * @param {Error} err - 错误对象
262
- * @param {Object} context - 上下文信息(包含 eventName, projectRoot, input 等)
263
- * @returns {Object} 输出对象,包含是否应该阻止操作
264
- */
265
- export function handleHookError(hookName, err, context = {}) {
266
- const errorType = classifyError(err, hookName);
267
- const securityLevel = HookSecurityLevel[hookName] || 'low';
268
-
269
- // 构建详细的错误信息
270
- const errorInfo = {
271
- hookName,
272
- errorType: errorType.code,
273
- errorMessage: err.message,
274
- errorCode: err.code,
275
- severity: errorType.severity,
276
- timestamp: new Date().toISOString(),
277
- context
278
- };
279
-
280
- // 记录到控制台
281
- const errorMeta = {
282
- hook: hookName,
283
- error: err.message,
284
- code: err.code,
285
- type: errorType.code,
286
- severity: errorType.severity,
287
- stack: isVerbose ? err.stack : undefined
288
- };
289
- error(`Hook execution failed`, errorMeta);
290
-
291
- // 记录到 hook 错误日志(如果有 projectRoot)
292
- if (context.projectRoot) {
293
- try {
294
- // 动态导入避免循环依赖
295
- import('./hook-error-recorder.js').then(({ recordHookError }) => {
296
- recordHookError(context.projectRoot, errorInfo);
297
- }).catch(() => {
298
- // 忽略导入错误
299
- });
300
- } catch {
301
- // 忽略错误
302
- }
303
- }
304
-
305
- // 决定是否阻止操作
306
- let permissionDecision = 'allow';
307
- let permissionDecisionReason = null;
308
-
309
- if (errorType.failStrategy === 'closed' ||
310
- (errorType.failStrategy === 'context' && securityLevel === 'critical')) {
311
- permissionDecision = 'deny';
312
- permissionDecisionReason =
313
- `[AutoSpec] 🚨 HOOK ERROR - Operation Blocked\n` +
314
- `Hook: ${hookName}\n` +
315
- `Error Type: ${errorType.code}\n` +
316
- `Reason: ${err.message}\n\n` +
317
- `This is a critical hook that protects the project. ` +
318
- `When it fails, the operation must be blocked for safety.\n` +
319
- `Please check the error and try again.`;
320
- }
321
-
322
- // 构建用户提示
323
- let additionalContext = buildUserMessage(hookName, errorType, err);
324
-
325
- return {
326
- hookSpecificOutput: {
327
- hookEventName: context.eventName || 'Unknown',
328
- permissionDecision,
329
- permissionDecisionReason,
330
- additionalContext
331
- },
332
- // 返回错误分类信息供调用者使用
333
- errorType,
334
- shouldBlock: permissionDecision === 'deny'
335
- };
336
- }
337
-
338
- /**
339
- * 构建用户提示信息
340
- */
341
- function buildUserMessage(hookName, errorType, err) {
342
- // 权限错误的特殊处理
343
- if (errorType.code === 'PERMISSION_ERROR') {
344
- return `[AutoSpec] ⚠️ 权限错误: ${hookName} 无法写入文件
345
-
346
- 可能原因:.autospec 或 .claude 目录由 root 创建
347
-
348
- 修复方法:运行以下命令修复权限
349
- sudo chown -R $(whoami) .autospec .claude
350
-
351
- 或者重新初始化(不使用 sudo):
352
- rm -rf .autospec .claude CLAUDE.md
353
- autospec init`;
354
- }
355
-
356
- // 其他错误的通用提示
357
- const severity = errorType.severity;
358
- const icon = severity === 'critical' ? '🚨' :
359
- severity === 'high' ? '⚠️' : 'ℹ️';
360
-
361
- return `[AutoSpec] ${icon} Hook '${hookName}' encountered an error (${errorType.code})
362
-
363
- Error: ${err.message}
364
-
365
- ${errorType.failStrategy === 'closed' ?
366
- 'This operation has been blocked for safety.' :
367
- 'The operation was allowed to continue. Use --verbose for details.'}`;
368
- }
369
-
370
- /**
371
- * Safe JSON parse with logging
372
- */
373
- export function safeJsonParse(str, defaultValue = null, context = '') {
374
- try {
375
- return JSON.parse(str);
376
- } catch (err) {
377
- debug(`JSON parse failed${context ? ` (${context})` : ''}`, {
378
- error: err.message,
379
- input: str?.slice(0, 200) // Log truncated input
380
- });
381
- return defaultValue;
382
- }
383
- }
384
-
385
- // ============================================================
386
- // Common utilities
387
- // ============================================================
388
-
389
- /**
390
- * Read stdin safely with timeout
391
- */
392
- export function readStdin(timeout = 1000) {
393
- return new Promise((resolve) => {
394
- let data = '';
395
- process.stdin.setEncoding('utf8');
396
-
397
- const timeoutId = setTimeout(() => {
398
- cleanup();
399
- resolve(data);
400
- }, timeout);
401
-
402
- function cleanup() {
403
- clearTimeout(timeoutId);
404
- process.stdin.removeListener('data', onData);
405
- process.stdin.removeListener('end', onEnd);
406
- }
407
-
408
- function onData(chunk) {
409
- data += chunk;
410
- }
411
-
412
- function onEnd() {
413
- cleanup();
414
- resolve(data);
415
- }
416
-
417
- process.stdin.on('data', onData);
418
- process.stdin.on('end', onEnd);
419
- });
420
- }
421
-
422
- /**
423
- * Find project root by searching upward for .autospec directory
424
- */
425
- export function findProjectRoot(startDir) {
426
- const fs = require('fs');
427
- const path = require('path');
428
-
429
- let dir = path.resolve(startDir);
430
- const root = path.parse(dir).root;
431
-
432
- while (dir !== root) {
433
- if (fs.existsSync(path.join(dir, '.autospec'))) {
434
- return dir;
435
- }
436
- dir = path.dirname(dir);
437
- }
438
-
439
- return null;
440
- }
441
-
442
- /**
443
- * Async version of findProjectRoot
444
- */
445
- export async function findProjectRootAsync(startDir) {
446
- const { default: fs } = await import('fs');
447
- const { default: path } = await import('path');
448
-
449
- let dir = path.resolve(startDir);
450
- const root = path.parse(dir).root;
451
-
452
- while (dir !== root) {
453
- try {
454
- await fs.promises.access(path.join(dir, '.autospec'));
455
- return dir;
456
- } catch {
457
- dir = path.dirname(dir);
458
- }
459
- }
460
-
461
- return null;
462
- }
463
-
464
- /**
465
- * Simple in-memory cache for hooks
466
- */
467
- export class HookCache {
468
- constructor(maxSize = 100) {
469
- this.cache = new Map();
470
- this.maxSize = maxSize;
471
- }
472
-
473
- get(key) {
474
- const item = this.cache.get(key);
475
- if (item && Date.now() - item.timestamp < item.ttl) {
476
- return item.value;
477
- }
478
- this.cache.delete(key);
479
- return undefined;
480
- }
481
-
482
- set(key, value, ttlMs = 60000) {
483
- if (this.cache.size >= this.maxSize) {
484
- const firstKey = this.cache.keys().next().value;
485
- this.cache.delete(firstKey);
486
- }
487
-
488
- this.cache.set(key, {
489
- value,
490
- timestamp: Date.now(),
491
- ttl: ttlMs
492
- });
493
- }
494
-
495
- clear() {
496
- this.cache.clear();
497
- }
498
- }
499
-
500
- /**
501
- * 全局单例缓存实例
502
- * 供所有 hook 统一使用,避免各自实例化
503
- */
504
- export const globalHookCache = new HookCache(200);
505
-
506
- /**
507
- * Check if path matches any pattern
508
- */
509
- export function matchesAnyPattern(path, patterns) {
510
- return patterns.some(pattern => pattern.test(path));
511
- }
512
-
513
- /**
514
- * Safe file existence check
515
- */
516
- export async function fileExists(path) {
517
- const { default: fs } = await import('fs');
518
- try {
519
- await fs.promises.access(path);
520
- return true;
521
- } catch {
522
- return false;
523
- }
524
- }
525
-
526
- /**
527
- * Safe directory sync check
528
- */
529
- export function directoryExistsSync(path) {
530
- const fs = require('fs');
531
- try {
532
- return fs.existsSync(path) && fs.statSync(path).isDirectory();
533
- } catch {
534
- return false;
535
- }
536
- }
@@ -1,110 +0,0 @@
1
- /**
2
- * Hooks generator for Claude Code integration
3
- *
4
- * Generates hooks configuration for deterministic guardrails
5
- * (frozen zone, Layer 1, practice log, etc.)
6
- *
7
- * Note: Hook scripts are in plugins/hooks/ and are copied
8
- * as part of the init process.
9
- *
10
- * Using inline bash command to support working from subdirectories.
11
- */
12
-
13
- import fs from 'fs';
14
- import path from 'path';
15
- import { HOOKS_CONFIG } from '../config/hooks.config.js';
16
-
17
- /**
18
- * Generate hooks configuration using declarative config
19
- * @param {string} claudeDir - Target .claude directory path
20
- * @param {string} autospecDir - Target .autospec directory path
21
- */
22
- export function generateHooksConfig(claudeDir, autospecDir) {
23
- const settingsPath = path.join(claudeDir, 'settings.json');
24
-
25
- let settings = {};
26
- if (fs.existsSync(settingsPath)) {
27
- try {
28
- settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
29
- } catch {
30
- settings = {};
31
- }
32
- }
33
-
34
- if (!settings.hooks) settings.hooks = {};
35
-
36
- for (const [eventName, hooks] of Object.entries(HOOKS_CONFIG)) {
37
- if (!settings.hooks[eventName]) {
38
- settings.hooks[eventName] = [];
39
- }
40
-
41
- for (const hook of hooks) {
42
- const hookName = extractHookName(hook.script);
43
- // 使用内联 bash 命令,从当前目录向上查找 .autospec 目录
44
- // 这样可以支持在子目录中工作
45
- const command = buildHookCommand(hookName);
46
-
47
- upsertHookByName(
48
- settings.hooks[eventName],
49
- hook.matcher || '',
50
- command,
51
- hook.name
52
- );
53
- }
54
- }
55
-
56
- fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf-8');
57
- }
58
-
59
- /**
60
- * 构建 hook 命令 - 支持从子目录执行
61
- * @param {string} hookName - Hook 名称
62
- * @returns {string} 完整的命令字符串
63
- */
64
- function buildHookCommand(hookName) {
65
- // 使用内联 bash 命令:
66
- // 1. 从当前目录向上查找 .autospec 目录
67
- // 2. 找到后执行对应的 hook 脚本
68
- return `bash -c 'DIR=$(pwd); while [ "$DIR" != "/" ] && [ ! -d "$DIR/.autospec" ]; do DIR=$(dirname "$DIR"); done; [ -d "$DIR/.autospec" ] && node "$DIR/.autospec/plugins/hooks/lib/hook-runner.js" ${hookName} || true'`;
69
- }
70
-
71
- /**
72
- * 从脚本路径提取 hook 名称
73
- * 例如: 'plugins/hooks/pipeline-observer.js' -> 'pipeline-observer'
74
- */
75
- function extractHookName(scriptPath) {
76
- const filename = path.basename(scriptPath, '.js');
77
- return filename;
78
- }
79
-
80
- /**
81
- * Add or update a named hook entry
82
- * @param {Array} hookArray - Array of hook configurations
83
- * @param {string} matcher - Tool matcher pattern
84
- * @param {string} command - Hook command to execute
85
- * @param {string} name - Hook name for identification
86
- */
87
- function upsertHookByName(hookArray, matcher, command, name) {
88
- const existing = hookArray.findIndex(h =>
89
- h.hooks?.some(hook =>
90
- (typeof hook === 'string' ? hook : hook.command || '').includes(name)
91
- )
92
- );
93
-
94
- const entry = {
95
- matcher,
96
- hooks: [{ type: 'command', command }]
97
- };
98
-
99
- if (existing >= 0) {
100
- hookArray[existing] = entry;
101
- } else {
102
- hookArray.push(entry);
103
- }
104
- }
105
-
106
- /**
107
- * Note: copyHookScripts function has been removed.
108
- * Hook scripts are now in plugins/hooks/ and are copied
109
- * as part of the init process.
110
- */
@@ -1,39 +0,0 @@
1
- /**
2
- * Generators module
3
- *
4
- * Exports all generator functions for Claude Code integration.
5
- */
6
-
7
- import path from 'path';
8
- import { generateSkills } from './skills.js';
9
- import { generateAgents } from './agents.js';
10
- import { generateHooksConfig } from './hooks.js';
11
-
12
- export { generateSkills } from './skills.js';
13
- export { generateAgents } from './agents.js';
14
- export { generateHooksConfig } from './hooks.js';
15
-
16
- // Re-export commands module
17
- export {
18
- generateCommands,
19
- clearTemplateCache,
20
- getTemplateCacheStats,
21
- getInternalCommandNames,
22
- generateInternalCommands
23
- } from './commands.js';
24
-
25
- /**
26
- * Generate all Claude Code integration files (skills + agents + hooks)
27
- * This is the main entry point for generating Claude Code integration.
28
- *
29
- * Note: Hook scripts are in plugins/hooks/ and are copied
30
- * as part of the init process.
31
- */
32
- export function generateIntegration(targetDir) {
33
- const claudeDir = path.join(targetDir, '.claude');
34
- const autospecDir = path.join(targetDir, '.autospec');
35
-
36
- generateSkills(claudeDir);
37
- generateAgents(claudeDir);
38
- generateHooksConfig(claudeDir, autospecDir);
39
- }