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