@gong-ym/ai-spec-auto 0.2.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/.agents/commands/README.md +33 -0
- package/.agents/commands/claude/spec-start-review.md +88 -0
- package/.agents/commands/codex/spec-continue.md +74 -0
- package/.agents/commands/codex/spec-orchestrate.md +35 -0
- package/.agents/commands/codex/spec-start-review.md +88 -0
- package/.agents/commands/codex/spec-start.md +67 -0
- package/.agents/commands/codex/spec-status.md +22 -0
- package/.agents/commands/codex/spec-stop.md +29 -0
- package/.agents/commands/codex/spec-update.md +40 -0
- package/.agents/commands/common/branch-review.md +117 -0
- package/.agents/commands/common/project-init.md +25 -0
- package/.agents/commands/common/spec-continue.md +74 -0
- package/.agents/commands/common/spec-orchestrate.md +35 -0
- package/.agents/commands/common/spec-start-review.md +82 -0
- package/.agents/commands/common/spec-start.md +67 -0
- package/.agents/commands/common/spec-status.md +22 -0
- package/.agents/commands/common/spec-stop.md +29 -0
- package/.agents/commands/common/spec-update.md +40 -0
- package/.agents/commands/cursor/opsx-apply.md +55 -0
- package/.agents/commands/cursor/opsx-archive.md +48 -0
- package/.agents/commands/cursor/opsx-explore.md +45 -0
- package/.agents/commands/cursor/opsx-propose.md +59 -0
- package/.agents/commands/cursor/spec-continue.md +63 -0
- package/.agents/commands/cursor/spec-orchestrate.md +53 -0
- package/.agents/commands/cursor/spec-start-review.md +78 -0
- package/.agents/commands/cursor/spec-start.md +59 -0
- package/.agents/commands/cursor/spec-status.md +30 -0
- package/.agents/commands/cursor/spec-stop.md +29 -0
- package/.agents/commands/cursor/spec-update.md +41 -0
- package/.agents/flows/FRONTMATTER.md +263 -0
- package/.agents/flows/RUN_OUTPUT.md +263 -0
- package/.agents/flows/common/README.md +29 -0
- package/.agents/flows/common/bugfix-to-verification.md +95 -0
- package/.agents/flows/common/change-to-architecture-review.md +89 -0
- package/.agents/flows/common/change-to-release.md +94 -0
- package/.agents/flows/common/prd-to-delivery.md +184 -0
- package/.agents/flows/common/requirement-to-observability.md +97 -0
- package/.agents/orchestration/README.md +22 -0
- package/.agents/orchestration/expert-dispatch-spec.md +155 -0
- package/.agents/orchestration/expert-executor-spec.md +84 -0
- package/.agents/orchestration/expert-runtime-action-spec.md +73 -0
- package/.agents/orchestration/runtime-state-handoff-spec.md +264 -0
- package/.agents/orchestration/task-anchor-spec.md +212 -0
- package/.agents/orchestration/task-orchestrator-adapter-payload.md +153 -0
- package/.agents/orchestration/task-orchestrator-bootstrap-payload.md +145 -0
- package/.agents/orchestration/task-orchestrator-output-extractor-spec.md +93 -0
- package/.agents/orchestration/task-orchestrator-run-plan-template.md +312 -0
- package/.agents/orchestration/task-orchestrator-runtime-hooks.md +214 -0
- package/.agents/registry/README.md +63 -0
- package/.agents/registry/flows.json +125 -0
- package/.agents/registry/profiles.json +101 -0
- package/.agents/registry/roles.json +1266 -0
- package/.agents/registry/rules.json +148 -0
- package/.agents/registry/scenario-packages.json +123 -0
- package/.agents/registry/skills.json +130 -0
- package/.agents/roles/INDEX.md +346 -0
- package/.agents/roles/common/README.md +76 -0
- package/.agents/roles/common/archive-change.md +80 -0
- package/.agents/roles/common/backend-implementer.md +92 -0
- package/.agents/roles/common/code-guardian.md +151 -0
- package/.agents/roles/common/frontend-implementer.md +146 -0
- package/.agents/roles/common/requirement-analyst.md +138 -0
- package/.agents/roles/common/task-orchestrator-routing.md +301 -0
- package/.agents/roles/common/task-orchestrator.md +224 -0
- package/.agents/roles/common/tooling-implementer.md +92 -0
- package/.agents/roles/domains/README.md +35 -0
- package/.agents/roles/domains/delivery/README.md +11 -0
- package/.agents/roles/domains/delivery/container-specialist.md +50 -0
- package/.agents/roles/domains/delivery/deployment-specialist.md +50 -0
- package/.agents/roles/domains/delivery/pipeline-specialist.md +50 -0
- package/.agents/roles/domains/demand-design/README.md +16 -0
- package/.agents/roles/domains/demand-design/api-contract-specialist.md +52 -0
- package/.agents/roles/domains/demand-design/design-collaborator.md +58 -0
- package/.agents/roles/domains/documentation/README.md +11 -0
- package/.agents/roles/domains/documentation/api-doc-specialist.md +50 -0
- package/.agents/roles/domains/documentation/component-doc-specialist.md +49 -0
- package/.agents/roles/domains/documentation/technical-writing-specialist.md +48 -0
- package/.agents/roles/domains/engineering/README.md +17 -0
- package/.agents/roles/domains/engineering/architecture-advisor.md +53 -0
- package/.agents/roles/domains/engineering/build-specialist.md +51 -0
- package/.agents/roles/domains/engineering/dependency-governor.md +52 -0
- package/.agents/roles/domains/governance/README.md +17 -0
- package/.agents/roles/domains/governance/api-governance-specialist.md +51 -0
- package/.agents/roles/domains/governance/lint-policy-specialist.md +49 -0
- package/.agents/roles/domains/governance/route-governance-specialist.md +52 -0
- package/.agents/roles/domains/observability/README.md +11 -0
- package/.agents/roles/domains/observability/error-tracker.md +50 -0
- package/.agents/roles/domains/observability/event-instrumentation-specialist.md +51 -0
- package/.agents/roles/domains/observability/rum-analyst.md +50 -0
- package/.agents/roles/domains/performance/README.md +11 -0
- package/.agents/roles/domains/performance/asset-optimizer.md +50 -0
- package/.agents/roles/domains/performance/performance-auditor.md +56 -0
- package/.agents/roles/domains/performance/vitals-analyst.md +50 -0
- package/.agents/roles/domains/security-a11y/README.md +11 -0
- package/.agents/roles/domains/security-a11y/a11y-auditor.md +50 -0
- package/.agents/roles/domains/security-a11y/aria-specialist.md +51 -0
- package/.agents/roles/domains/security-a11y/security-reviewer.md +49 -0
- package/.agents/roles/domains/testing/README.md +12 -0
- package/.agents/roles/domains/testing/coverage-analyst.md +50 -0
- package/.agents/roles/domains/testing/e2e-test-specialist.md +51 -0
- package/.agents/roles/domains/testing/unit-test-specialist.md +56 -0
- package/.agents/roles/domains/testing/verification-reviewer.md +67 -0
- package/.agents/rules/README.md +87 -0
- package/.agents/rules/common/02-/347/274/226/347/240/201/350/247/204/350/214/203.md +45 -0
- package/.agents/rules/common/08-/351/200/232/347/224/250/347/272/246/346/235/237.md +63 -0
- package/.agents/rules/common/10-/346/226/207/346/241/243/350/247/204/350/214/203.md +101 -0
- package/.agents/rules/common/12-Superpowers/346/211/247/350/241/214/350/247/204/350/214/203.md +46 -0
- package/.agents/rules/common/14-/345/256/241/350/256/241/346/261/207/346/212/245/350/247/204/350/214/203.md +107 -0
- package/.agents/rules/common/15-visual-gate-wait.md +90 -0
- package/.agents/rules/profiles/nestjs/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +27 -0
- package/.agents/rules/profiles/nestjs/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +20 -0
- package/.agents/rules/profiles/nestjs/04-/346/250/241/345/235/227/347/273/223/346/236/204/350/247/204/350/214/203.md +24 -0
- package/.agents/rules/profiles/nestjs/05-/346/216/245/345/217/243/344/270/216/345/245/221/347/272/246/350/247/204/350/214/203.md +24 -0
- package/.agents/rules/profiles/nestjs/06-/346/225/260/346/215/256/350/256/277/351/227/256/350/247/204/350/214/203.md +24 -0
- package/.agents/rules/profiles/nestjs/07-/351/205/215/347/275/256/344/270/216/350/277/220/350/241/214/346/227/266/350/247/204/350/214/203.md +20 -0
- package/.agents/rules/profiles/nestjs/09-/345/274/202/345/270/270/344/270/216/346/227/245/345/277/227/350/247/204/350/214/203.md +20 -0
- package/.agents/rules/profiles/nestjs/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +24 -0
- package/.agents/rules/profiles/nestjs/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +20 -0
- package/.agents/rules/profiles/node-tooling/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +30 -0
- package/.agents/rules/profiles/node-tooling/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +37 -0
- package/.agents/rules/profiles/node-tooling/04-CLI/344/270/216/346/250/241/345/235/227/350/247/204/350/214/203.md +42 -0
- package/.agents/rules/profiles/node-tooling/05-Contract/344/270/216Schema/350/247/204/350/214/203.md +42 -0
- package/.agents/rules/profiles/node-tooling/06-/350/277/220/350/241/214/346/227/266/346/226/207/344/273/266/350/247/204/350/214/203.md +30 -0
- package/.agents/rules/profiles/node-tooling/07-/346/227/245/345/277/227/344/270/216/351/224/231/350/257/257/345/244/204/347/220/206/350/247/204/350/214/203.md +60 -0
- package/.agents/rules/profiles/node-tooling/09-/350/204/232/346/234/254/344/270/216/345/205/245/345/217/243/350/247/204/350/214/203.md +45 -0
- package/.agents/rules/profiles/node-tooling/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +41 -0
- package/.agents/rules/profiles/node-tooling/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +55 -0
- package/.agents/rules/profiles/react/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +29 -0
- package/.agents/rules/profiles/react/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +104 -0
- package/.agents/rules/profiles/react/04-/347/273/204/344/273/266/350/247/204/350/214/203.md +46 -0
- package/.agents/rules/profiles/react/05-API/350/247/204/350/214/203.md +67 -0
- package/.agents/rules/profiles/react/06-/350/267/257/347/224/261/350/247/204/350/214/203.md +54 -0
- package/.agents/rules/profiles/react/07-/347/212/266/346/200/201/347/256/241/347/220/206.md +226 -0
- package/.agents/rules/profiles/react/09-/346/240/267/345/274/217/350/247/204/350/214/203.md +71 -0
- package/.agents/rules/profiles/react/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +80 -0
- package/.agents/rules/profiles/react/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +159 -0
- package/.agents/rules/profiles/springboot/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +31 -0
- package/.agents/rules/profiles/springboot/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +37 -0
- package/.agents/rules/profiles/springboot/04-/345/210/206/345/261/202/350/247/204/350/214/203.md +33 -0
- package/.agents/rules/profiles/springboot/05-/346/216/245/345/217/243/344/270/216/345/245/221/347/272/246/350/247/204/350/214/203.md +51 -0
- package/.agents/rules/profiles/springboot/06-/346/225/260/346/215/256/350/256/277/351/227/256/350/247/204/350/214/203.md +34 -0
- package/.agents/rules/profiles/springboot/07-/351/205/215/347/275/256/344/270/216/350/277/220/350/241/214/346/227/266/350/247/204/350/214/203.md +38 -0
- package/.agents/rules/profiles/springboot/09-/345/274/202/345/270/270/344/270/216/346/227/245/345/277/227/350/247/204/350/214/203.md +48 -0
- package/.agents/rules/profiles/springboot/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +43 -0
- package/.agents/rules/profiles/springboot/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +48 -0
- package/.agents/rules/profiles/vue/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +47 -0
- package/.agents/rules/profiles/vue/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +106 -0
- package/.agents/rules/profiles/vue/04-/347/273/204/344/273/266/350/247/204/350/214/203.md +61 -0
- package/.agents/rules/profiles/vue/05-API/350/247/204/350/214/203.md +67 -0
- package/.agents/rules/profiles/vue/06-/350/267/257/347/224/261/350/247/204/350/214/203.md +69 -0
- package/.agents/rules/profiles/vue/07-/347/212/266/346/200/201/347/256/241/347/220/206.md +93 -0
- package/.agents/rules/profiles/vue/09-/346/240/267/345/274/217/350/247/204/350/214/203.md +67 -0
- package/.agents/rules/profiles/vue/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +80 -0
- package/.agents/rules/profiles/vue/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +159 -0
- package/.agents/skills/README.md +171 -0
- package/.agents/skills/common/archive-change/SKILL.md +180 -0
- package/.agents/skills/common/branch-code-reviewer/SKILL.md +459 -0
- package/.agents/skills/common/branch-code-reviewer/references/business-risk-guide.md +293 -0
- package/.agents/skills/common/branch-code-reviewer/references/html-template-guide.md +121 -0
- package/.agents/skills/common/config-and-secret-scan/SKILL.md +99 -0
- package/.agents/skills/common/create-proposal/SKILL.md +192 -0
- package/.agents/skills/common/create-proposal/evals/evals.json +16 -0
- package/.agents/skills/common/create-proposal/evals/train_queries.json +18 -0
- package/.agents/skills/common/create-proposal/evals/validation_queries.json +18 -0
- package/.agents/skills/common/create-proposal/references/interaction-spec-template.md +42 -0
- package/.agents/skills/common/create-test/SKILL.md +292 -0
- package/.agents/skills/common/dependency-impact-graph/SKILL.md +80 -0
- package/.agents/skills/common/execute-task/SKILL.md +206 -0
- package/.agents/skills/common/execute-task/evals/evals.json +16 -0
- package/.agents/skills/common/execute-task/evals/train_queries.json +18 -0
- package/.agents/skills/common/execute-task/evals/validation_queries.json +18 -0
- package/.agents/skills/common/find-skills/SKILL.md +144 -0
- package/.agents/skills/common/install-ai-spec-auto/SKILL.md +260 -0
- package/.agents/skills/common/install-ai-spec-auto/evals/evals.json +17 -0
- package/.agents/skills/common/install-ai-spec-auto/evals/train_queries.json +18 -0
- package/.agents/skills/common/install-ai-spec-auto/evals/validation_queries.json +18 -0
- package/.agents/skills/common/project-init/SKILL.md +178 -0
- package/.agents/skills/common/project-init/evals/evals.json +16 -0
- package/.agents/skills/common/project-init/evals/train_queries.json +18 -0
- package/.agents/skills/common/project-init/evals/validation_queries.json +18 -0
- package/.agents/skills/common/project-init/references/custom-rule-generation.md +89 -0
- package/.agents/skills/common/project-init/references/deep-scan-rules.md +67 -0
- package/.agents/skills/common/project-init/references/output-contracts.md +71 -0
- package/.agents/skills/common/project-init/references/repo-fact-gathering.md +83 -0
- package/.agents/skills/common/project-init/references/scope-resolution.md +76 -0
- package/.agents/skills/common/project-init/scripts/inspect-project.js +112 -0
- package/.agents/skills/common/skill-creator/LICENSE.txt +202 -0
- package/.agents/skills/common/skill-creator/SKILL.md +370 -0
- package/.agents/skills/common/skill-creator/evals/evals.json +16 -0
- package/.agents/skills/common/skill-creator/evals/train_queries.json +18 -0
- package/.agents/skills/common/skill-creator/evals/validation_queries.json +18 -0
- package/.agents/skills/common/skill-creator/references/output-patterns.md +82 -0
- package/.agents/skills/common/skill-creator/references/workflows.md +28 -0
- package/.agents/skills/common/skill-creator/scripts/init_skill.py +209 -0
- package/.agents/skills/common/skill-creator/scripts/package_skill.py +110 -0
- package/.agents/skills/common/skill-creator/scripts/quick_validate.py +51 -0
- package/.agents/skills/common/skill-optimizer/SKILL.md +102 -0
- package/.agents/skills/common/skill-optimizer/evals/evals.json +16 -0
- package/.agents/skills/common/skill-optimizer/evals/train_queries.json +18 -0
- package/.agents/skills/common/skill-optimizer/evals/validation_queries.json +18 -0
- package/.agents/skills/common/skill-optimizer/references/design-patterns.md +26 -0
- package/.agents/skills/common/skill-optimizer/references/review-checklist.md +22 -0
- package/.agents/skills/common/using-superpowers/SKILL.md +151 -0
- package/.agents/skills/common/wait-for-gate-signal/SKILL.md +85 -0
- package/.agents/skills/domains/README.md +19 -0
- package/.agents/skills/domains/ui-ux-pro-max/SKILL.md +58 -0
- package/.agents/skills/domains/web/design-analysis/SKILL.md +89 -0
- package/.agents/skills/domains/web/design-analysis/rules/analysis-order.md +61 -0
- package/.agents/skills/domains/web/design-analysis/rules/analysis-priorities.md +136 -0
- package/.agents/skills/domains/web/design-analysis/rules/checklist-common-misses.md +107 -0
- package/.agents/skills/domains/web/design-analysis/rules/implementation-common-errors.md +204 -0
- package/.agents/skills/domains/web/design-analysis/rules/implementation-guidelines.md +211 -0
- package/.agents/skills/domains/web/design-analysis/rules/output-analysis-checklist.md +247 -0
- package/.agents/skills/domains/web/design-analysis/rules/tools-design-guidelines.md +108 -0
- package/.agents/skills/domains/web/design-analysis/rules/workflow-element-extraction.md +162 -0
- package/.agents/skills/domains/web/design-analysis/rules/workflow-layout-map.md +131 -0
- package/.agents/skills/domains/web/design-analysis/rules/workflow-output-checklist.md +70 -0
- package/.agents/skills/domains/web/design-analysis/rules/workflow-style-summary.md +91 -0
- package/.agents/skills/domains/web/route-permission-map/SKILL.md +103 -0
- package/.agents/skills/domains/web/ui-verification/SKILL.md +114 -0
- package/.agents/skills/domains/web/ui-verification/evals/evals.json +16 -0
- package/.agents/skills/domains/web/ui-verification/evals/train_queries.json +18 -0
- package/.agents/skills/domains/web/ui-verification/evals/validation_queries.json +18 -0
- package/.agents/skills/domains/web/ui-verification/rules/comparison-content-image.md +34 -0
- package/.agents/skills/domains/web/ui-verification/rules/comparison-content-text.md +30 -0
- package/.agents/skills/domains/web/ui-verification/rules/comparison-hierarchy.md +33 -0
- package/.agents/skills/domains/web/ui-verification/rules/comparison-layout.md +35 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-alignment.md +42 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-button-dimensions.md +28 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-button-position.md +25 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-css-priority.md +50 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-flex-column-width.md +46 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-flex-layout.md +46 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-grid-container-width.md +44 -0
- package/.agents/skills/domains/web/ui-verification/rules/errors-page-container-width.md +39 -0
- package/.agents/skills/domains/web/ui-verification/rules/tools-browser-navigation.md +53 -0
- package/.agents/skills/domains/web/ui-verification/rules/tools-design-guidelines.md +53 -0
- package/.agents/skills/domains/web/ui-verification/rules/workflow-checklist.md +27 -0
- package/.agents/skills/domains/web/ui-verification/rules/workflow-problem-list.md +56 -0
- package/.agents/skills/domains/web/ui-verification/rules/workflow-reflection.md +44 -0
- package/.agents/skills/domains/web/ui-verification/rules/writing-alignment.md +44 -0
- package/.agents/skills/domains/web/ui-verification/rules/writing-element-completeness.md +63 -0
- package/.agents/skills/domains/web/ui-verification/rules/writing-list-layout.md +75 -0
- package/.agents/skills/domains/web/ui-verification/rules/writing-page-container-width.md +37 -0
- package/.agents/skills/domains/web/web-design-guidelines/SKILL.md +40 -0
- package/.agents/skills/profiles/nestjs/README.md +4 -0
- package/.agents/skills/profiles/node-tooling/README.md +9 -0
- package/.agents/skills/profiles/react/create-api/SKILL.md +145 -0
- package/.agents/skills/profiles/react/create-component/SKILL.md +160 -0
- package/.agents/skills/profiles/react/create-route/SKILL.md +168 -0
- package/.agents/skills/profiles/react/create-store/SKILL.md +262 -0
- package/.agents/skills/profiles/react/theme-variables/SKILL.md +82 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/AGENTS.md +899 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/SKILL.md +81 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/state-context-interface.md +191 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/state-lift-state.md +125 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/AGENTS.md +2934 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/SKILL.md +136 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/.agents/skills/profiles/springboot/README.md +10 -0
- package/.agents/skills/profiles/vue/create-api/SKILL.md +105 -0
- package/.agents/skills/profiles/vue/create-component/SKILL.md +76 -0
- package/.agents/skills/profiles/vue/create-route/SKILL.md +141 -0
- package/.agents/skills/profiles/vue/create-store/SKILL.md +97 -0
- package/.agents/skills/profiles/vue/create-view/SKILL.md +81 -0
- package/.agents/skills/profiles/vue/theme-variables/SKILL.md +73 -0
- package/.agents/skills/profiles/vue/vue-best-practices/SKILL.md +166 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/animation-class-based-technique.md +254 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/animation-state-driven-technique.md +291 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-async.md +97 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-data-flow.md +307 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-fallthrough-attrs.md +174 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-keep-alive.md +137 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-slots.md +216 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-suspense.md +228 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-teleport.md +108 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-transition-group.md +128 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-transition.md +125 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/composables.md +290 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/directives.md +162 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/perf-avoid-component-abstraction-in-lists.md +159 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/perf-v-once-v-memo-directives.md +182 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/perf-virtualize-large-lists.md +187 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/plugins.md +166 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/reactivity.md +344 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/render-functions.md +201 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/sfc.md +310 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/state-management.md +135 -0
- package/.agents/skills/profiles/vue/vue-best-practices/references/updated-hook-performance.md +187 -0
- package/.agents/templates/common/README.md +23 -0
- package/.agents/templates/common/bugfix.md +22 -0
- package/.agents/templates/common/create-expert-package.md +458 -0
- package/.agents/templates/common/mock-page.md +28 -0
- package/.agents/templates/common/new-component.md +25 -0
- package/.agents/templates/common/new-page.md +31 -0
- package/.cursor/mcp.json +36 -0
- package/.qoder/README.md +114 -0
- package/.qoder/commands +1 -0
- package/.qoder/mcp.json +26 -0
- package/.qoder/rules +1 -0
- package/.qoder/skills +1 -0
- package/LICENSE +21 -0
- package/README.md +433 -0
- package/bin/archive-change.js +474 -0
- package/bin/check-command.js +62 -0
- package/bin/cli.js +295 -0
- package/bin/command-template-renderer.js +40 -0
- package/bin/context-command.js +102 -0
- package/bin/demo-runtime-smoke.js +760 -0
- package/bin/execution-semantics.js +821 -0
- package/bin/executor-command.js +93 -0
- package/bin/expert-dispatch.js +334 -0
- package/bin/expert-executor.js +1148 -0
- package/bin/guard-command.js +52 -0
- package/bin/hub-command.js +876 -0
- package/bin/ide-command.js +242 -0
- package/bin/init-command.js +193 -0
- package/bin/install-workflow.js +2983 -0
- package/bin/manifest-export.js +34 -0
- package/bin/profile-registry.js +90 -0
- package/bin/protocol-workflow.js +446 -0
- package/bin/repair-command.js +161 -0
- package/bin/repo-map.js +177 -0
- package/bin/report-command.js +236 -0
- package/bin/runtime-bootstrap.js +428 -0
- package/bin/runtime-embedded.js +101 -0
- package/bin/runtime-fallback.js +106 -0
- package/bin/runtime-launcher.js +116 -0
- package/bin/runtime-paths.js +177 -0
- package/bin/runtime-registry.js +289 -0
- package/bin/runtime-state.js +2541 -0
- package/bin/scan.js +96 -0
- package/bin/self-upgrade.js +206 -0
- package/bin/skill-spec-validator.js +457 -0
- package/bin/spec-command.js +366 -0
- package/bin/superpowers.js +384 -0
- package/bin/sync-command.js +59 -0
- package/bin/sync.js +1904 -0
- package/bin/task-orchestrator-adapter.js +341 -0
- package/bin/task-orchestrator-extractor.js +274 -0
- package/bin/task-orchestrator-runner.js +1208 -0
- package/bin/telemetry/README.md +66 -0
- package/bin/telemetry/aspect.js +153 -0
- package/bin/telemetry/collect.js +67 -0
- package/bin/telemetry/config.js +114 -0
- package/bin/telemetry/defaults.json +5 -0
- package/bin/telemetry/healthcheck.js +195 -0
- package/bin/telemetry/identity.js +53 -0
- package/bin/telemetry/index.js +25 -0
- package/bin/telemetry/reporter.js +83 -0
- package/bin/telemetry/safe.js +39 -0
- package/bin/validate-registry.js +740 -0
- package/bin/visual-bridge-config.js +117 -0
- package/bin/visual-bridge.js +287 -0
- package/bin/visual-command.js +432 -0
- package/bin/worktree-command.js +194 -0
- package/configs/common/.editorconfig +15 -0
- package/configs/common/.husky/commit-msg +4 -0
- package/configs/common/.husky/pre-commit +4 -0
- package/configs/common/.lintstagedrc +11 -0
- package/configs/common/.prettierignore +11 -0
- package/configs/common/.prettierrc.json +11 -0
- package/configs/common/.stylelintignore +14 -0
- package/configs/common/.stylelintrc.json +21 -0
- package/configs/common/commitlint.config.js +3 -0
- package/configs/profiles/nestjs/.gitkeep +1 -0
- package/configs/profiles/node-tooling/.gitkeep +1 -0
- package/configs/profiles/react/.eslintignore +6 -0
- package/configs/profiles/react/.eslintrc.js +16 -0
- package/configs/profiles/react/.stylelintrc.json +18 -0
- package/configs/profiles/springboot/.gitkeep +1 -0
- package/configs/profiles/vue/.eslintignore +7 -0
- package/configs/profiles/vue/.eslintrc.cjs +17 -0
- package/contracts/README.md +28 -0
- package/contracts/fixtures/asset-package.fixture.json +26 -0
- package/contracts/fixtures/asset-usage-feedback.fixture.json +14 -0
- package/contracts/fixtures/evidence-report.fixture.json +28 -0
- package/contracts/fixtures/manifest.fixture.json +20 -0
- package/contracts/fixtures/run-event.fixture.json +15 -0
- package/contracts/schemas/asset-package.schema.json +76 -0
- package/contracts/schemas/asset-usage-feedback.schema.json +57 -0
- package/contracts/schemas/evidence-report.schema.json +60 -0
- package/contracts/schemas/manifest.schema.json +63 -0
- package/contracts/schemas/run-event.schema.json +72 -0
- package/install.ps1 +35 -0
- package/install.sh +17 -0
- package/internal/ai-protocol-workflow.js +5600 -0
- package/internal/hub-client.js +98 -0
- package/internal/hub-sync-selection.js +69 -0
- package/internal/visual-hooks/README.md +481 -0
- package/internal/visual-hooks/config-loader.js +218 -0
- package/internal/visual-hooks/control-puller.js +206 -0
- package/internal/visual-hooks/gate-signal.js +150 -0
- package/internal/visual-hooks/inbox-consumer.js +469 -0
- package/internal/visual-hooks/index.js +197 -0
- package/internal/visual-hooks/push-client.js +189 -0
- package/internal/visual-hooks/receipt-pusher.js +176 -0
- package/internal/visual-hooks/runtime-state-pusher.js +128 -0
- package/openspec/changes/.gitkeep +0 -0
- package/openspec/changes/archive/.gitkeep +0 -0
- package/openspec/config.yaml.template +52 -0
- package/openspec/schemas/expert-delivery/schema.yaml +68 -0
- package/openspec/schemas/expert-delivery/templates/checklist.md +39 -0
- package/openspec/schemas/expert-delivery/templates/design.md +61 -0
- package/openspec/schemas/expert-delivery/templates/iterations.md +25 -0
- package/openspec/schemas/expert-delivery/templates/proposal.md +45 -0
- package/openspec/schemas/expert-delivery/templates/spec.md +29 -0
- package/openspec/schemas/expert-delivery/templates/tasks.md +24 -0
- package/openspec/specs/.gitkeep +0 -0
- package/package.json +73 -0
- package/scripts/acceptance-zero-intrusion.sh +168 -0
- package/scripts/hub-sync-assets.config.example.json +296 -0
- package/scripts/hub-sync-assets.js +2038 -0
- package/scripts/local-verify.sh +280 -0
- package/scripts/post-publish-auto-fix-check.js +404 -0
- package/scripts/post-publish-verify.sh +175 -0
- package/scripts/setup-cursor-manual-test.sh +107 -0
- package/scripts/setup-cursor-spec-archive-test.sh +111 -0
- package/scripts/setup-visual-integration.sh +225 -0
- package/scripts/test-integration.sh +176 -0
- package/scripts/update-test-project.sh +93 -0
- package/scripts/upload-four-web.sh +57 -0
- package/scripts/verify-install-ps1-bom.js +26 -0
- package/src/agent/agent-context.js +259 -0
- package/src/agent/agent-profile.js +185 -0
- package/src/agent/agent-templates.js +161 -0
- package/src/agent/agent-types.js +108 -0
- package/src/agent/collaboration-protocol.js +333 -0
- package/src/agent/conflict-handler.js +364 -0
- package/src/agent/file-permission.js +121 -0
- package/src/agent/index.js +38 -0
- package/src/agent/permission-audit.js +151 -0
- package/src/agent/review-repair-loop.js +270 -0
- package/src/agent/tool-permission.js +101 -0
- package/src/asset/asset-dependency.js +322 -0
- package/src/asset/asset-feedback.js +350 -0
- package/src/asset/asset-fork.js +300 -0
- package/src/asset/asset-install.js +278 -0
- package/src/asset/asset-installer.js +497 -0
- package/src/asset/asset-lifecycle.js +324 -0
- package/src/asset/asset-manager.js +245 -0
- package/src/asset/asset-package-manager.js +349 -0
- package/src/asset/asset-package.js +186 -0
- package/src/asset/asset-quality.js +262 -0
- package/src/asset/asset-registry.js +387 -0
- package/src/asset/asset-version.js +293 -0
- package/src/asset/index.js +86 -0
- package/src/cache/agent-profile-cache.js +59 -0
- package/src/cache/asset-cache.js +63 -0
- package/src/cache/global-cache.js +61 -0
- package/src/cache/manifest-cache.js +30 -0
- package/src/check/check-service.js +32 -0
- package/src/config/config-layer.js +343 -0
- package/src/config/config-loader.js +60 -0
- package/src/config/defaults.js +49 -0
- package/src/connectors/hub/asset-package.js +72 -0
- package/src/connectors/hub/asset-usage-feedback.js +46 -0
- package/src/connectors/hub/hub-connector.js +44 -0
- package/src/connectors/hub/index.js +21 -0
- package/src/connectors/visual/evidence-report.js +49 -0
- package/src/connectors/visual/index.js +15 -0
- package/src/connectors/visual/queue.js +41 -0
- package/src/connectors/visual/run-event.js +81 -0
- package/src/connectors/visual/visual-connector.js +77 -0
- package/src/context/context-budget.js +59 -0
- package/src/context/context-builder.js +285 -0
- package/src/context/context-loader.js +116 -0
- package/src/context/context-planner.js +158 -0
- package/src/context/types.js +96 -0
- package/src/contracts/index.js +63 -0
- package/src/executor/executor-registry.js +78 -0
- package/src/executor/executor-result-parser.js +44 -0
- package/src/executor/executor-runner.js +141 -0
- package/src/executor/executor-selector.js +139 -0
- package/src/executor/executor-timeout.js +36 -0
- package/src/executor/providers/base-provider-utils.js +189 -0
- package/src/executor/providers/claude-code-executor-provider.js +128 -0
- package/src/executor/providers/codex-executor-provider.js +126 -0
- package/src/executor/providers/cursor-executor-provider.js +99 -0
- package/src/executor/types.js +137 -0
- package/src/git/branch-manager.js +71 -0
- package/src/git/dirty-checker.js +43 -0
- package/src/git/dirty-strategy-handler.js +29 -0
- package/src/git/git-command.js +37 -0
- package/src/git/git-repository-detector.js +45 -0
- package/src/git/multi-repo-worktree-planner.js +88 -0
- package/src/git/policy.js +19 -0
- package/src/git/strategies/block-dirty-strategy.js +34 -0
- package/src/git/strategies/ignore-dirty-strategy.js +33 -0
- package/src/git/strategies/patch-snapshot-strategy.js +53 -0
- package/src/git/strategies/wip-commit-strategy.js +38 -0
- package/src/git/types.js +71 -0
- package/src/git/worktree-manager.js +85 -0
- package/src/governance/asset-review.js +351 -0
- package/src/governance/audit-log.js +368 -0
- package/src/governance/gray-release.js +312 -0
- package/src/governance/index.js +31 -0
- package/src/governance/policy-types.js +56 -0
- package/src/governance/rbac-types.js +171 -0
- package/src/governance/rbac.js +382 -0
- package/src/governance/rollback.js +360 -0
- package/src/governance/security-policy.js +354 -0
- package/src/hook/hook-config-writer.js +125 -0
- package/src/hub/hub-client.js +186 -0
- package/src/hub/hub-config.js +39 -0
- package/src/hub/project-facts.js +31 -0
- package/src/hub/runtime-feedback-reporter.js +55 -0
- package/src/ide/adapters/adapter-protocol.js +385 -0
- package/src/ide/adapters/claude-adapter.js +419 -0
- package/src/ide/adapters/codex-adapter.js +60 -0
- package/src/ide/adapters/cursor-adapter.js +484 -0
- package/src/ide/adapters/index.js +24 -0
- package/src/ide/anchors/markdown-anchor-writer.js +152 -0
- package/src/ide/ide-service.js +270 -0
- package/src/ide/ide-types.js +94 -0
- package/src/ide/links/link-mode-resolver.js +160 -0
- package/src/ide/registry/ide-registry-builder.js +165 -0
- package/src/incident/incident-writer.js +47 -0
- package/src/incident/types.js +22 -0
- package/src/init/ide-linker.js +126 -0
- package/src/init/ide-pointer-injector.js +75 -0
- package/src/init/init-applier.js +197 -0
- package/src/init/init-plan.js +294 -0
- package/src/init/init-service.js +65 -0
- package/src/init/manifest-installer.js +302 -0
- package/src/init/types.js +26 -0
- package/src/project/config-writer.js +83 -0
- package/src/project/context-index-writer.js +82 -0
- package/src/project/json-utils.js +72 -0
- package/src/project/local-state-writer.js +50 -0
- package/src/project/lock-file-writer.js +98 -0
- package/src/project/manifest-writer.js +126 -0
- package/src/project/policy-config-writer.js +91 -0
- package/src/project/project-config-writer.js +74 -0
- package/src/project/project-files.js +39 -0
- package/src/project/registry-index-writer.js +43 -0
- package/src/project/workspace-config-writer.js +63 -0
- package/src/run/index.js +11 -0
- package/src/run/run-id.js +32 -0
- package/src/run/run-service.js +269 -0
- package/src/run/run-store.js +80 -0
- package/src/scanner/aggregator/detection-aggregator.js +23 -0
- package/src/scanner/boundary/boundary-resolver.js +229 -0
- package/src/scanner/detectors/detector-registry.js +44 -0
- package/src/scanner/detectors/fastapi-detector.js +46 -0
- package/src/scanner/detectors/go-detector.js +46 -0
- package/src/scanner/detectors/nestjs-detector.js +57 -0
- package/src/scanner/detectors/nextjs-detector.js +52 -0
- package/src/scanner/detectors/react-vite-detector.js +52 -0
- package/src/scanner/detectors/react-webpack-detector.js +57 -0
- package/src/scanner/detectors/springboot-detector.js +46 -0
- package/src/scanner/detectors/springcloud-detector.js +46 -0
- package/src/scanner/detectors/springmvc-detector.js +46 -0
- package/src/scanner/detectors/vue-vite-detector.js +52 -0
- package/src/scanner/engine.js +72 -0
- package/src/scanner/facts/fact-extractor.js +211 -0
- package/src/scanner/types.js +30 -0
- package/src/security/asset-tamper-checker.js +188 -0
- package/src/security/checksum.js +40 -0
- package/src/spec/spec-writer.js +302 -0
- package/src/state-machine/circuit-breaker.js +112 -0
- package/src/state-machine/escape-hatch.js +49 -0
- package/src/state-machine/stage-runner.js +281 -0
- package/src/state-machine/state-machine.js +24 -0
- package/src/state-machine/transition-guard.js +36 -0
- package/src/state-machine/types.js +37 -0
- package/src/sync/sync-service.js +192 -0
- package/src/visual/agent-visual.js +142 -0
- package/src/visual/event-gateway.js +357 -0
- package/src/visual/event-mapper.js +128 -0
- package/src/visual/hook-dashboard.js +216 -0
- package/src/visual/index.js +27 -0
- package/src/visual/metrics.js +287 -0
- package/src/visual/privacy-filter.js +100 -0
- package/src/visual/risk-board.js +252 -0
- package/src/visual/timeline.js +245 -0
- package/src/visual/visual-client.js +94 -0
- package/src/visual/visual-config.js +40 -0
- package/src/visual/visual-reporter.js +88 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AgentVisual — Agent 协作可视化
|
|
5
|
+
* 展示 Agent 调用、handoff、冲突、人工门禁和结论
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const AGENT_EVENT_TYPES = [
|
|
9
|
+
'agent.started', 'agent.completed', 'agent.escalated', 'agent.blocked',
|
|
10
|
+
'agent.handoff', 'agent.tool_denied', 'agent.file_scope', 'agent.max_iterations',
|
|
11
|
+
'agent.human_gate'
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
class AgentVisual {
|
|
15
|
+
/**
|
|
16
|
+
* 构建 Agent 时间线
|
|
17
|
+
* @param {object[]} events
|
|
18
|
+
* @returns {object}
|
|
19
|
+
*/
|
|
20
|
+
buildAgentTimeline(events) {
|
|
21
|
+
const all = (events || []).filter(e => AGENT_EVENT_TYPES.includes(e.eventType));
|
|
22
|
+
const agentMap = new Map();
|
|
23
|
+
|
|
24
|
+
for (const e of all) {
|
|
25
|
+
const agentId = e.metadata?.agentId || e.runId || 'unknown';
|
|
26
|
+
if (!agentMap.has(agentId)) {
|
|
27
|
+
agentMap.set(agentId, {
|
|
28
|
+
agentId,
|
|
29
|
+
role: e.metadata?.role || 'agent',
|
|
30
|
+
events: [],
|
|
31
|
+
startedAt: null,
|
|
32
|
+
completedAt: null,
|
|
33
|
+
toolCalls: 0,
|
|
34
|
+
status: 'completed'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const agent = agentMap.get(agentId);
|
|
38
|
+
agent.events.push(e);
|
|
39
|
+
|
|
40
|
+
if (e.eventType === 'agent.started') {
|
|
41
|
+
agent.startedAt = e.timestamp;
|
|
42
|
+
agent.status = 'running';
|
|
43
|
+
}
|
|
44
|
+
if (e.eventType === 'agent.completed') {
|
|
45
|
+
agent.completedAt = e.timestamp;
|
|
46
|
+
agent.status = 'completed';
|
|
47
|
+
}
|
|
48
|
+
if (e.eventType === 'agent.escalated') {
|
|
49
|
+
agent.status = 'escalated';
|
|
50
|
+
}
|
|
51
|
+
if (e.eventType === 'agent.blocked') {
|
|
52
|
+
agent.status = 'blocked';
|
|
53
|
+
}
|
|
54
|
+
if (e.metadata?.toolCalls) {
|
|
55
|
+
agent.toolCalls = e.metadata.toolCalls;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
agents: Array.from(agentMap.values()).map(a => ({
|
|
61
|
+
agentId: a.agentId,
|
|
62
|
+
role: a.role,
|
|
63
|
+
startedAt: a.startedAt,
|
|
64
|
+
completedAt: a.completedAt,
|
|
65
|
+
toolCalls: a.toolCalls,
|
|
66
|
+
status: a.status,
|
|
67
|
+
eventCount: a.events.length
|
|
68
|
+
})),
|
|
69
|
+
handoffs: this.getHandoffView(events),
|
|
70
|
+
disputes: this.getDisputeView(events),
|
|
71
|
+
humanGates: this.getHumanGateView(events)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 获取 handoff 视图(Agent 间交接)
|
|
77
|
+
* @param {object[]} events
|
|
78
|
+
* @returns {object[]}
|
|
79
|
+
*/
|
|
80
|
+
getHandoffView(events) {
|
|
81
|
+
return (events || [])
|
|
82
|
+
.filter(e => e.eventType === 'agent.handoff')
|
|
83
|
+
.map(e => ({
|
|
84
|
+
fromAgent: e.metadata?.fromAgent || 'unknown',
|
|
85
|
+
toAgent: e.metadata?.toAgent || 'unknown',
|
|
86
|
+
reason: e.message || '',
|
|
87
|
+
timestamp: e.timestamp
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 获取冲突视图(权限冲突/工具拒绝)
|
|
93
|
+
* @param {object[]} events
|
|
94
|
+
* @returns {object[]}
|
|
95
|
+
*/
|
|
96
|
+
getDisputeView(events) {
|
|
97
|
+
return (events || [])
|
|
98
|
+
.filter(e =>
|
|
99
|
+
e.eventType === 'agent.tool_denied' ||
|
|
100
|
+
e.eventType === 'agent.file_scope' ||
|
|
101
|
+
e.eventType === 'agent.max_iterations'
|
|
102
|
+
)
|
|
103
|
+
.map(e => ({
|
|
104
|
+
agentId: e.metadata?.agentId || 'unknown',
|
|
105
|
+
type: e.eventType.replace('agent.', ''),
|
|
106
|
+
detail: e.message || '',
|
|
107
|
+
timestamp: e.timestamp
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 获取人工门禁视图
|
|
113
|
+
* @param {object[]} events
|
|
114
|
+
* @returns {object[]}
|
|
115
|
+
*/
|
|
116
|
+
getHumanGateView(events) {
|
|
117
|
+
return (events || [])
|
|
118
|
+
.filter(e => e.eventType === 'agent.human_gate')
|
|
119
|
+
.map(e => ({
|
|
120
|
+
gateId: e.metadata?.gateId || e.eventId,
|
|
121
|
+
agentId: e.metadata?.agentId || 'unknown',
|
|
122
|
+
reason: e.message || '',
|
|
123
|
+
decision: e.metadata?.decision || 'pending',
|
|
124
|
+
timestamp: e.timestamp
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 工厂函数
|
|
131
|
+
* @param {object} [options]
|
|
132
|
+
* @returns {AgentVisual}
|
|
133
|
+
*/
|
|
134
|
+
function createAgentVisual(options = {}) {
|
|
135
|
+
return new AgentVisual(options);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = {
|
|
139
|
+
AGENT_EVENT_TYPES,
|
|
140
|
+
AgentVisual,
|
|
141
|
+
createAgentVisual
|
|
142
|
+
};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const { redactSensitive, redactObject } = require('../governance/audit-log');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Run Event 标准化 Schema
|
|
10
|
+
* eventId: 自增 ID
|
|
11
|
+
* runId: 运行 ID
|
|
12
|
+
* projectId: 项目 ID
|
|
13
|
+
* eventType: 事件类型 (hook.failed / test.passed / repair.attempt / agent.handoff / ...)
|
|
14
|
+
* stage: 阶段 (pre-task / pre-edit / post-edit / pre-test / post-test / repair / archive)
|
|
15
|
+
* status: 状态 (success / failed / blocked / skipped)
|
|
16
|
+
* severity: 严重级别 (info / warn / error / blocking)
|
|
17
|
+
* message: 脱敏后消息
|
|
18
|
+
* timestamp: ISO 时间
|
|
19
|
+
* metadata: 脱敏后元数据
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const VALID_SEVERITY = ['info', 'warn', 'error', 'blocking'];
|
|
23
|
+
const VALID_STATUS = ['success', 'failed', 'blocked', 'skipped'];
|
|
24
|
+
const VALID_STAGES = [
|
|
25
|
+
'pre-task', 'pre-edit', 'post-edit', 'pre-test', 'post-test', 'repair', 'archive'
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const REQUIRED_FIELDS = ['eventType', 'stage', 'status', 'severity'];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 校验单条原始事件
|
|
32
|
+
* @param {object} raw
|
|
33
|
+
* @returns {{ valid: boolean, errors: string[] }}
|
|
34
|
+
*/
|
|
35
|
+
function validateEvent(raw) {
|
|
36
|
+
const errors = [];
|
|
37
|
+
if (!raw || typeof raw !== 'object') {
|
|
38
|
+
return { valid: false, errors: ['事件必须是非空对象'] };
|
|
39
|
+
}
|
|
40
|
+
for (const field of REQUIRED_FIELDS) {
|
|
41
|
+
if (!raw[field] || typeof raw[field] !== 'string') {
|
|
42
|
+
errors.push(`缺少必填字段: ${field}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (raw.severity && !VALID_SEVERITY.includes(raw.severity)) {
|
|
46
|
+
errors.push(`非法 severity: ${raw.severity},允许值: ${VALID_SEVERITY.join(', ')}`);
|
|
47
|
+
}
|
|
48
|
+
if (raw.status && !VALID_STATUS.includes(raw.status)) {
|
|
49
|
+
errors.push(`非法 status: ${raw.status},允许值: ${VALID_STATUS.join(', ')}`);
|
|
50
|
+
}
|
|
51
|
+
if (raw.stage && !VALID_STAGES.includes(raw.stage)) {
|
|
52
|
+
errors.push(`非法 stage: ${raw.stage},允许值: ${VALID_STAGES.join(', ')}`);
|
|
53
|
+
}
|
|
54
|
+
return { valid: errors.length === 0, errors };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 对事件消息和元数据进行红脱
|
|
59
|
+
* @param {object} raw
|
|
60
|
+
* @returns {object}
|
|
61
|
+
*/
|
|
62
|
+
function redactEvent(raw) {
|
|
63
|
+
const message = raw.message ? redactSensitive(String(raw.message)) : '';
|
|
64
|
+
const metadata = raw.metadata ? redactObject(raw.metadata) : {};
|
|
65
|
+
return { ...raw, message, metadata };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* EventGateway — 本地事件网关
|
|
70
|
+
* 负责事件接收、校验、脱敏、NDJSON 持久化、查询和统计
|
|
71
|
+
*/
|
|
72
|
+
class EventGateway {
|
|
73
|
+
/**
|
|
74
|
+
* @param {object} options
|
|
75
|
+
* @param {string} [options.storagePath] — NDJSON 存储路径
|
|
76
|
+
* @param {number} [options.maxEvents] — 最大事件数(内存)
|
|
77
|
+
* @param {string} [options.projectId] — 项目 ID
|
|
78
|
+
* @param {boolean} [options.throwOnWriteError] — 写入失败时是否抛出异常
|
|
79
|
+
*/
|
|
80
|
+
constructor(options = {}) {
|
|
81
|
+
const { storagePath, maxEvents = 10000, projectId = 'default', throwOnWriteError = false } = options;
|
|
82
|
+
this._projectId = projectId;
|
|
83
|
+
this._maxEvents = maxEvents;
|
|
84
|
+
this._events = [];
|
|
85
|
+
this._nextId = 1;
|
|
86
|
+
this._loadErrors = [];
|
|
87
|
+
this._writeErrors = [];
|
|
88
|
+
this._throwOnWriteError = throwOnWriteError === true;
|
|
89
|
+
|
|
90
|
+
if (storagePath) {
|
|
91
|
+
this._storagePath = path.resolve(storagePath);
|
|
92
|
+
this._storageDir = path.dirname(this._storagePath);
|
|
93
|
+
this._ensureStorageDir();
|
|
94
|
+
this._loadFromFile();
|
|
95
|
+
} else {
|
|
96
|
+
this._storagePath = null;
|
|
97
|
+
this._storageDir = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 确保存储目录存在
|
|
103
|
+
*/
|
|
104
|
+
_ensureStorageDir() {
|
|
105
|
+
if (this._storageDir && !fs.existsSync(this._storageDir)) {
|
|
106
|
+
fs.mkdirSync(this._storageDir, { recursive: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 从 NDJSON 文件加载已有事件
|
|
112
|
+
*/
|
|
113
|
+
_loadFromFile() {
|
|
114
|
+
if (!this._storagePath || !fs.existsSync(this._storagePath)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const content = fs.readFileSync(this._storagePath, 'utf8');
|
|
119
|
+
const lines = content.split('\n').filter(line => line.trim());
|
|
120
|
+
lines.forEach((line, index) => {
|
|
121
|
+
try {
|
|
122
|
+
const event = JSON.parse(line);
|
|
123
|
+
this._events.push(event);
|
|
124
|
+
// 恢复自增 ID
|
|
125
|
+
const idNum = parseInt(event.eventId?.replace('evt-', ''), 10);
|
|
126
|
+
if (!isNaN(idNum) && idNum >= this._nextId) {
|
|
127
|
+
this._nextId = idNum + 1;
|
|
128
|
+
}
|
|
129
|
+
} catch (err) {
|
|
130
|
+
this._loadErrors.push({
|
|
131
|
+
type: 'parse_error',
|
|
132
|
+
message: err.message || 'JSON 解析失败',
|
|
133
|
+
timestamp: new Date().toISOString(),
|
|
134
|
+
lineNumber: index + 1,
|
|
135
|
+
line: line.length > 200 ? line.slice(0, 200) + '...' : line
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
} catch (err) {
|
|
140
|
+
this._loadErrors.push({
|
|
141
|
+
type: 'file_read_error',
|
|
142
|
+
message: err.message || '文件读取失败',
|
|
143
|
+
timestamp: new Date().toISOString(),
|
|
144
|
+
lineNumber: 0,
|
|
145
|
+
line: ''
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 追加写入单条事件到 NDJSON 文件
|
|
152
|
+
* @param {object} event
|
|
153
|
+
*/
|
|
154
|
+
_appendToFile(event) {
|
|
155
|
+
if (!this._storagePath) return;
|
|
156
|
+
try {
|
|
157
|
+
this._ensureStorageDir();
|
|
158
|
+
fs.appendFileSync(this._storagePath, JSON.stringify(event) + '\n', 'utf8');
|
|
159
|
+
} catch (err) {
|
|
160
|
+
const writeError = {
|
|
161
|
+
type: 'write_error',
|
|
162
|
+
message: err.message || '写入失败',
|
|
163
|
+
timestamp: new Date().toISOString()
|
|
164
|
+
};
|
|
165
|
+
this._writeErrors.push(writeError);
|
|
166
|
+
if (this._throwOnWriteError) {
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 接收原始事件 → 校验 → 脱敏 → 存储 → 返回标准化事件
|
|
174
|
+
* @param {object} rawEvent
|
|
175
|
+
* @returns {{ success: boolean, event?: object, errors?: string[] }}
|
|
176
|
+
*/
|
|
177
|
+
ingest(rawEvent) {
|
|
178
|
+
const { valid, errors } = validateEvent(rawEvent);
|
|
179
|
+
if (!valid) {
|
|
180
|
+
return { success: false, errors };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const redacted = redactEvent(rawEvent);
|
|
184
|
+
const event = {
|
|
185
|
+
eventId: `evt-${this._nextId++}`,
|
|
186
|
+
runId: redacted.runId || '',
|
|
187
|
+
projectId: redacted.projectId || this._projectId,
|
|
188
|
+
eventType: redacted.eventType,
|
|
189
|
+
stage: redacted.stage,
|
|
190
|
+
status: redacted.status,
|
|
191
|
+
severity: redacted.severity,
|
|
192
|
+
message: redacted.message,
|
|
193
|
+
timestamp: redacted.timestamp || new Date().toISOString(),
|
|
194
|
+
metadata: redacted.metadata
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
this._events.push(event);
|
|
198
|
+
this._appendToFile(event);
|
|
199
|
+
|
|
200
|
+
// 超过最大事件数时裁剪内存(文件保留完整)
|
|
201
|
+
if (this._events.length > this._maxEvents) {
|
|
202
|
+
this._events = this._events.slice(-this._maxEvents);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return { success: true, event };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 多维查询
|
|
210
|
+
* @param {object} [filters]
|
|
211
|
+
* @param {string} [filters.eventType]
|
|
212
|
+
* @param {string} [filters.stage]
|
|
213
|
+
* @param {string} [filters.severity]
|
|
214
|
+
* @param {string} [filters.runId]
|
|
215
|
+
* @param {string} [filters.from] — ISO 时间下限
|
|
216
|
+
* @param {string} [filters.to] — ISO 时间上限
|
|
217
|
+
* @param {number} [filters.limit]
|
|
218
|
+
* @returns {object[]}
|
|
219
|
+
*/
|
|
220
|
+
query(filters = {}) {
|
|
221
|
+
let results = [...this._events];
|
|
222
|
+
|
|
223
|
+
if (filters.eventType) {
|
|
224
|
+
results = results.filter(e => e.eventType === filters.eventType);
|
|
225
|
+
}
|
|
226
|
+
if (filters.stage) {
|
|
227
|
+
results = results.filter(e => e.stage === filters.stage);
|
|
228
|
+
}
|
|
229
|
+
if (filters.severity) {
|
|
230
|
+
results = results.filter(e => e.severity === filters.severity);
|
|
231
|
+
}
|
|
232
|
+
if (filters.runId) {
|
|
233
|
+
results = results.filter(e => e.runId === filters.runId);
|
|
234
|
+
}
|
|
235
|
+
if (filters.from) {
|
|
236
|
+
results = results.filter(e => e.timestamp >= filters.from);
|
|
237
|
+
}
|
|
238
|
+
if (filters.to) {
|
|
239
|
+
results = results.filter(e => e.timestamp <= filters.to);
|
|
240
|
+
}
|
|
241
|
+
if (typeof filters.limit === 'number' && filters.limit > 0) {
|
|
242
|
+
results = results.slice(-filters.limit);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return results;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 统计:按 type / stage / severity 分组计数
|
|
250
|
+
* @returns {object}
|
|
251
|
+
*/
|
|
252
|
+
getStats() {
|
|
253
|
+
const byType = {};
|
|
254
|
+
const byStage = {};
|
|
255
|
+
const bySeverity = {};
|
|
256
|
+
const byStatus = {};
|
|
257
|
+
|
|
258
|
+
for (const e of this._events) {
|
|
259
|
+
byType[e.eventType] = (byType[e.eventType] || 0) + 1;
|
|
260
|
+
byStage[e.stage] = (byStage[e.stage] || 0) + 1;
|
|
261
|
+
bySeverity[e.severity] = (bySeverity[e.severity] || 0) + 1;
|
|
262
|
+
byStatus[e.status] = (byStatus[e.status] || 0) + 1;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
total: this._events.length,
|
|
267
|
+
byType,
|
|
268
|
+
byStage,
|
|
269
|
+
bySeverity,
|
|
270
|
+
byStatus
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* 导出为 JSON 或 NDJSON
|
|
276
|
+
* @param {'json'|'ndjson'} [format='json']
|
|
277
|
+
* @returns {string}
|
|
278
|
+
*/
|
|
279
|
+
export(format = 'json') {
|
|
280
|
+
if (format === 'ndjson') {
|
|
281
|
+
return this._events.map(e => JSON.stringify(e)).join('\n');
|
|
282
|
+
}
|
|
283
|
+
return JSON.stringify(this._events, null, 2);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 清空事件
|
|
288
|
+
* @param {object} [options]
|
|
289
|
+
* @param {boolean} [options.clearFile] — 是否同时清空持久化文件
|
|
290
|
+
*/
|
|
291
|
+
clear(options = {}) {
|
|
292
|
+
this._events = [];
|
|
293
|
+
this._nextId = 1;
|
|
294
|
+
if (options.clearFile && this._storagePath) {
|
|
295
|
+
try {
|
|
296
|
+
fs.writeFileSync(this._storagePath, '', 'utf8');
|
|
297
|
+
} catch (err) {
|
|
298
|
+
const writeError = {
|
|
299
|
+
type: 'clear_file_error',
|
|
300
|
+
message: err.message || '清空文件失败',
|
|
301
|
+
timestamp: new Date().toISOString()
|
|
302
|
+
};
|
|
303
|
+
this._writeErrors.push(writeError);
|
|
304
|
+
if (this._throwOnWriteError) {
|
|
305
|
+
throw err;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* 获取加载错误列表(副本)
|
|
313
|
+
* @returns {object[]}
|
|
314
|
+
*/
|
|
315
|
+
getLoadErrors() {
|
|
316
|
+
return [...this._loadErrors];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 获取写入错误列表(副本)
|
|
321
|
+
* @returns {object[]}
|
|
322
|
+
*/
|
|
323
|
+
getWriteErrors() {
|
|
324
|
+
return [...this._writeErrors];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* 当前事件数量
|
|
329
|
+
* @returns {number}
|
|
330
|
+
*/
|
|
331
|
+
get size() {
|
|
332
|
+
return this._events.length;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* 工厂函数
|
|
338
|
+
* @param {object} [options]
|
|
339
|
+
* @param {string} [options.storagePath]
|
|
340
|
+
* @param {number} [options.maxEvents]
|
|
341
|
+
* @param {string} [options.projectId]
|
|
342
|
+
* @returns {EventGateway}
|
|
343
|
+
*/
|
|
344
|
+
function createEventGateway(options) {
|
|
345
|
+
return new EventGateway(options);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
module.exports = {
|
|
349
|
+
VALID_SEVERITY,
|
|
350
|
+
VALID_STATUS,
|
|
351
|
+
VALID_STAGES,
|
|
352
|
+
REQUIRED_FIELDS,
|
|
353
|
+
validateEvent,
|
|
354
|
+
redactEvent,
|
|
355
|
+
EventGateway,
|
|
356
|
+
createEventGateway
|
|
357
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const crypto = require('crypto');
|
|
2
|
+
const { readProjectState } = require('../project/project-files');
|
|
3
|
+
const { createPrivacy } = require('./privacy-filter');
|
|
4
|
+
|
|
5
|
+
function stableHash(value, length = 16) {
|
|
6
|
+
return crypto.createHash('sha256').update(String(value || '')).digest('hex').slice(0, length);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function asObject(value) {
|
|
10
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getVisualProjectContext(rootDir) {
|
|
14
|
+
const state = readProjectState(rootDir);
|
|
15
|
+
const project = state.project || {};
|
|
16
|
+
const workspace = state.files && state.files.project ? readOptionalWorkspace(rootDir) : null;
|
|
17
|
+
return {
|
|
18
|
+
projectId: project.projectId || state.lock?.projectId || '',
|
|
19
|
+
workspaceId: workspace?.workspaceId || state.lock?.workspaceId || '',
|
|
20
|
+
projectName: project.projectName || '',
|
|
21
|
+
projectType: project.projectType || 'single',
|
|
22
|
+
projectHash: project.projectId ? `sha256:${stableHash(project.projectId, 32)}` : '',
|
|
23
|
+
techProfile: asObject(project.techProfile),
|
|
24
|
+
manifest: asObject(project.manifest),
|
|
25
|
+
packages: Array.isArray(workspace?.packages) ? workspace.packages : [],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function readOptionalWorkspace(rootDir) {
|
|
30
|
+
try {
|
|
31
|
+
const { readJsonFile } = require('../project/project-files');
|
|
32
|
+
const path = require('path');
|
|
33
|
+
return readJsonFile(path.join(rootDir, '.ai-spec/workspace.json'));
|
|
34
|
+
} catch (_error) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function manifestForRun(rootDir, run = {}) {
|
|
40
|
+
const state = readProjectState(rootDir);
|
|
41
|
+
return asObject(run.manifest || state.project?.manifest || state.lock?.manifest);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function buildProjectStatePayload(rootDir, options = {}) {
|
|
45
|
+
const context = getVisualProjectContext(rootDir);
|
|
46
|
+
const reportedAt = options.reportedAt || new Date().toISOString();
|
|
47
|
+
return {
|
|
48
|
+
eventId: options.eventId || `project-state:${context.projectId}:${stableHash(reportedAt.slice(0, 10), 8)}`,
|
|
49
|
+
projectId: context.projectId,
|
|
50
|
+
workspaceId: context.workspaceId,
|
|
51
|
+
projectHash: context.projectHash,
|
|
52
|
+
name: context.projectName,
|
|
53
|
+
type: context.projectType === 'package' ? 'workspace' : 'single',
|
|
54
|
+
techProfile: context.techProfile,
|
|
55
|
+
manifest: context.manifest || {},
|
|
56
|
+
packages: context.packages,
|
|
57
|
+
privacy: createPrivacy(),
|
|
58
|
+
reportedAt,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function buildRunEventPayload(rootDir, run = {}, event = {}, options = {}) {
|
|
63
|
+
const context = getVisualProjectContext(rootDir);
|
|
64
|
+
const occurredAt = options.occurredAt || event.createdAt || new Date().toISOString();
|
|
65
|
+
const type = options.type || event.type || 'runtime_event';
|
|
66
|
+
const eventIndex = typeof options.eventIndex === 'number' ? options.eventIndex : (run.events || []).length;
|
|
67
|
+
return {
|
|
68
|
+
eventId: options.eventId || `${run.runId || 'run'}:${type}:${eventIndex}`,
|
|
69
|
+
runId: run.runId || '',
|
|
70
|
+
projectId: context.projectId,
|
|
71
|
+
workspaceId: context.workspaceId,
|
|
72
|
+
type,
|
|
73
|
+
state: options.state || run.state || '',
|
|
74
|
+
stage: options.stage || run.stage || '',
|
|
75
|
+
level: options.level || 'info',
|
|
76
|
+
executor: options.executor || run.executor?.type || '',
|
|
77
|
+
manifest: manifestForRun(rootDir, run),
|
|
78
|
+
payload: options.payload || event.detail || {},
|
|
79
|
+
occurredAt,
|
|
80
|
+
privacy: createPrivacy(),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function buildHistoryPayload(rootDir, run = {}, options = {}) {
|
|
85
|
+
const context = getVisualProjectContext(rootDir);
|
|
86
|
+
const createdAt = options.createdAt || new Date().toISOString();
|
|
87
|
+
const changedFiles = options.changedFiles || run.executor?.lastResult?.changedFiles || [];
|
|
88
|
+
return {
|
|
89
|
+
historyId: options.historyId || `history:${run.runId || 'run'}:${run.state || 'state'}`,
|
|
90
|
+
runId: run.runId || '',
|
|
91
|
+
projectId: context.projectId,
|
|
92
|
+
title: run.requirement?.summary || '未命名需求',
|
|
93
|
+
summary: options.summary || `Run ${run.runId || ''} 当前状态:${run.state || ''}`,
|
|
94
|
+
changedFiles,
|
|
95
|
+
assetsUsed: options.assetsUsed || [],
|
|
96
|
+
verificationSummary: run.executor?.lastResult?.verification || {},
|
|
97
|
+
createdAt,
|
|
98
|
+
privacy: createPrivacy(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function buildIncidentPayload(rootDir, incident = {}, options = {}) {
|
|
103
|
+
const context = getVisualProjectContext(rootDir);
|
|
104
|
+
return {
|
|
105
|
+
incidentId: incident.incidentId || '',
|
|
106
|
+
runId: incident.runId || '',
|
|
107
|
+
projectId: context.projectId,
|
|
108
|
+
type: incident.type || 'unknown',
|
|
109
|
+
level: incident.level || 'error',
|
|
110
|
+
stage: incident.stage || '',
|
|
111
|
+
message: incident.message || '',
|
|
112
|
+
suggestion: incident.suggestion || '',
|
|
113
|
+
diagnoseResult: options.diagnoseResult || {},
|
|
114
|
+
recoveryAction: options.recoveryAction || {},
|
|
115
|
+
status: options.status || 'open',
|
|
116
|
+
createdAt: incident.createdAt || new Date().toISOString(),
|
|
117
|
+
privacy: createPrivacy(),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = {
|
|
122
|
+
buildHistoryPayload,
|
|
123
|
+
buildIncidentPayload,
|
|
124
|
+
buildProjectStatePayload,
|
|
125
|
+
buildRunEventPayload,
|
|
126
|
+
getVisualProjectContext,
|
|
127
|
+
stableHash,
|
|
128
|
+
};
|