avorelo 0.3.8 → 0.4.0-rc.2
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 +16 -23
- package/README.md +62 -72
- package/bin/avorelo +9 -0
- package/package.json +147 -139
- package/scripts/README.md +40 -0
- package/scripts/avorelo-session-collision-guard.js +540 -0
- package/scripts/avorelo-workstream-preflight.js +918 -0
- package/scripts/cco-dashboard.js +346 -0
- package/scripts/cco-posttooluse.js +504 -0
- package/scripts/cco-pretooluse.js +381 -0
- package/scripts/cco-status.js +540 -0
- package/scripts/cco-stop.js +77 -0
- package/scripts/cco-userprompt-submit.js +83 -0
- package/scripts/lib/activation/account-state.js +37 -0
- package/scripts/lib/activation/activate-command.js +114 -0
- package/scripts/lib/activation/activation-runner.js +607 -0
- package/scripts/lib/activation/activation-self-healing.js +481 -0
- package/scripts/lib/activation/activation-state.js +96 -0
- package/scripts/lib/activation/activation-summary.js +241 -0
- package/scripts/lib/activation/adapters/claude-code.js +77 -0
- package/scripts/lib/activation/adapters/codex-cli.js +52 -0
- package/scripts/lib/activation/adapters/cursor.js +37 -0
- package/scripts/lib/activation/adapters/github-agent.js +39 -0
- package/scripts/lib/activation/adapters/terminal.js +42 -0
- package/scripts/lib/activation/adapters/vscode.js +39 -0
- package/scripts/lib/activation/adapters/windsurf.js +37 -0
- package/scripts/lib/activation/ai-surface-detector.js +151 -0
- package/scripts/lib/activation/connect-account.js +145 -0
- package/scripts/lib/activation/detect-environment.js +75 -0
- package/scripts/lib/activation/detect-hosts.js +62 -0
- package/scripts/lib/activation/format-activation-output.js +109 -0
- package/scripts/lib/activation/next-action.js +43 -0
- package/scripts/lib/activation/repair-engine.js +219 -0
- package/scripts/lib/activation/run-entry.js +346 -0
- package/scripts/lib/activation-distribution-readiness.js +507 -0
- package/scripts/lib/adapter-conformance.js +176 -0
- package/scripts/lib/adapter-readiness.js +428 -0
- package/scripts/lib/adapter-safety-boundaries.js +335 -0
- package/scripts/lib/adapter-technical-readiness-gate.js +205 -0
- package/scripts/lib/agent-access-governance.js +455 -0
- package/scripts/lib/agent-activation-readiness.js +878 -0
- package/scripts/lib/agent-enforcement.js +765 -0
- package/scripts/lib/agent-evolution-loop.js +479 -0
- package/scripts/lib/agent-policy-profile.js +210 -0
- package/scripts/lib/agent-security/action-evaluator.js +507 -0
- package/scripts/lib/agent-security/adapter-registry.js +98 -0
- package/scripts/lib/agent-security/auto-policy.js +139 -0
- package/scripts/lib/agent-security/bounded-scan.js +93 -0
- package/scripts/lib/agent-security/enforcement-adapter.js +174 -0
- package/scripts/lib/agent-security/enforcement-engine.js +1129 -0
- package/scripts/lib/agent-security/file-write-adapter.js +183 -0
- package/scripts/lib/agent-security/file-write-rules.js +178 -0
- package/scripts/lib/agent-security/index.js +3342 -0
- package/scripts/lib/agent-security/instruction-risk.js +181 -0
- package/scripts/lib/agent-security/mcp-action-adapter.js +185 -0
- package/scripts/lib/agent-security/mcp-action-rules.js +184 -0
- package/scripts/lib/agent-security/package-action-adapter.js +175 -0
- package/scripts/lib/agent-security/package-action-rules.js +233 -0
- package/scripts/lib/agent-security/performance.js +148 -0
- package/scripts/lib/agent-security/permission-minimizer.js +403 -0
- package/scripts/lib/agent-security/scan-cache.js +74 -0
- package/scripts/lib/agent-security/source-trust.js +146 -0
- package/scripts/lib/ai-efficiency-dogfood-pack.js +437 -0
- package/scripts/lib/ai-efficiency-eval.js +207 -0
- package/scripts/lib/ai-efficiency-guard-contract.js +209 -0
- package/scripts/lib/ai-efficiency-measured-value.js +106 -0
- package/scripts/lib/ai-install-prompt.js +293 -0
- package/scripts/lib/ai-task-inference.js +155 -0
- package/scripts/lib/ai-value-ledger.js +121 -0
- package/scripts/lib/ai-value-proof-table.js +151 -0
- package/scripts/lib/ai-work-efficiency-routing.js +623 -0
- package/scripts/lib/ai-workspace-hygiene.js +1499 -0
- package/scripts/lib/alpha-activation.js +520 -0
- package/scripts/lib/alpha-feedback.js +263 -0
- package/scripts/lib/alpha-readiness-gate.js +332 -0
- package/scripts/lib/anti-gaming.js +169 -0
- package/scripts/lib/artifact-health.js +431 -0
- package/scripts/lib/artifact-receipt-hygiene.js +619 -0
- package/scripts/lib/attribution.js +180 -0
- package/scripts/lib/audit.js +289 -0
- package/scripts/lib/avorelo-skill-registry.js +810 -0
- package/scripts/lib/batch-jobs.js +71 -0
- package/scripts/lib/brain-pack.js +578 -0
- package/scripts/lib/brand-boundary.js +424 -0
- package/scripts/lib/brand.js +74 -0
- package/scripts/lib/browser-capability.js +1048 -0
- package/scripts/lib/browser-proof-governed-workflow.js +1020 -0
- package/scripts/lib/browser-proof-preflight.js +321 -0
- package/scripts/lib/cache-readiness.js +296 -0
- package/scripts/lib/canonical-reentry.js +162 -0
- package/scripts/lib/capability-contract-validator.js +177 -0
- package/scripts/lib/capability-hygiene.js +504 -0
- package/scripts/lib/capability-intake-quarantine.js +789 -0
- package/scripts/lib/capability-kernel-registry.js +566 -0
- package/scripts/lib/capability-kernel.js +202 -0
- package/scripts/lib/capability-manifest.js +255 -0
- package/scripts/lib/capability-outcome-normalizer.js +104 -0
- package/scripts/lib/capability-packs.js +314 -0
- package/scripts/lib/capability-recommender.js +513 -0
- package/scripts/lib/capability-registry.js +1062 -0
- package/scripts/lib/carry-forward-surfacing.js +194 -0
- package/scripts/lib/ccusage-adapter.js +188 -0
- package/scripts/lib/claude-session-evidence/index.js +1027 -0
- package/scripts/lib/cli-output-sanitizer.js +118 -0
- package/scripts/lib/company-loop.js +1149 -0
- package/scripts/lib/config.js +641 -0
- package/scripts/lib/context-acquisition-plan.js +359 -0
- package/scripts/lib/context-authority-rules.js +138 -0
- package/scripts/lib/context-budget-guard.js +170 -0
- package/scripts/lib/context-budget-scanner.js +257 -0
- package/scripts/lib/context-budget.js +167 -0
- package/scripts/lib/context-claim-safety.js +116 -0
- package/scripts/lib/context-compiler.js +236 -0
- package/scripts/lib/context-optimizer.js +715 -0
- package/scripts/lib/context-packet.js +121 -0
- package/scripts/lib/context-receipt.js +57 -0
- package/scripts/lib/context-reduction-plan.js +179 -0
- package/scripts/lib/context-safety.js +88 -0
- package/scripts/lib/context-savings-engine.js +158 -0
- package/scripts/lib/context-source-registry.js +393 -0
- package/scripts/lib/context-task-profiles.js +147 -0
- package/scripts/lib/cost-abuse-guard.js +975 -0
- package/scripts/lib/cost-evidence.js +287 -0
- package/scripts/lib/cost-to-outcome-signals.js +639 -0
- package/scripts/lib/cross-host-install-plan.js +308 -0
- package/scripts/lib/cross-host-install-readiness.js +242 -0
- package/scripts/lib/cross-host-value-flow.js +268 -0
- package/scripts/lib/dashboard.js +1056 -0
- package/scripts/lib/data-permissions-guard.js +1187 -0
- package/scripts/lib/deployment-environment-guard.js +1236 -0
- package/scripts/lib/design-partner-feedback.js +346 -0
- package/scripts/lib/dogfood-evidence-freshness.js +567 -0
- package/scripts/lib/efficiency-receipt.js +354 -0
- package/scripts/lib/entitlements.js +100 -0
- package/scripts/lib/execution-packet.js +559 -0
- package/scripts/lib/execution-route-governor.js +179 -0
- package/scripts/lib/experimentation-events.js +547 -0
- package/scripts/lib/external-capability-compliance.js +107 -0
- package/scripts/lib/external-readiness/ai-visibility/ai-visibility-runner.js +322 -0
- package/scripts/lib/external-readiness/calibration/benchmark-site-catalog.js +121 -0
- package/scripts/lib/external-readiness/calibration/completion-gate.js +112 -0
- package/scripts/lib/external-readiness/calibration/real-site-benchmark-runner.js +284 -0
- package/scripts/lib/external-readiness/drift-detector.js +100 -0
- package/scripts/lib/external-readiness/endpoint-prober.js +332 -0
- package/scripts/lib/external-readiness/external-readiness-runner.js +112 -0
- package/scripts/lib/external-readiness/full-agent-readiness-scorer.js +220 -0
- package/scripts/lib/external-readiness/golden-path-runner.js +333 -0
- package/scripts/lib/external-readiness/inside-out-runner.js +118 -0
- package/scripts/lib/external-readiness/proof-receipt-writer.js +112 -0
- package/scripts/lib/external-readiness/safe-fix-executor.js +117 -0
- package/scripts/lib/external-readiness/skills/category-boundary-guard.js +30 -0
- package/scripts/lib/external-readiness/skills/pmm-positioning-guard.js +69 -0
- package/scripts/lib/external-readiness/skills/safe-fix-policy.js +35 -0
- package/scripts/lib/external-user-simulation.js +166 -0
- package/scripts/lib/failure-recovery-readiness.js +81 -0
- package/scripts/lib/failure-recovery.js +419 -0
- package/scripts/lib/feedback-intelligence.js +537 -0
- package/scripts/lib/feedback-signals.js +205 -0
- package/scripts/lib/file-integrity.js +68 -0
- package/scripts/lib/fsx.js +129 -0
- package/scripts/lib/full-readiness-gate.js +451 -0
- package/scripts/lib/governed-action-exposure-primitives.js +1514 -0
- package/scripts/lib/governed-exposure-planner.js +186 -0
- package/scripts/lib/governed-workspace-hygiene.js +946 -0
- package/scripts/lib/guard-suite-common.js +412 -0
- package/scripts/lib/guidance-builder.js +174 -0
- package/scripts/lib/hook-apply.js +1075 -0
- package/scripts/lib/hook-baseline.js +310 -0
- package/scripts/lib/hook-config-preview.js +275 -0
- package/scripts/lib/hook-contracts.js +290 -0
- package/scripts/lib/hook-safety-boundary-readiness.js +80 -0
- package/scripts/lib/host-capability-matrix.js +351 -0
- package/scripts/lib/host-support-context.js +254 -0
- package/scripts/lib/http-hook-action.js +538 -0
- package/scripts/lib/install-ai-readiness.js +84 -0
- package/scripts/lib/install-intake-risk.js +1051 -0
- package/scripts/lib/install-journey-intelligence.js +329 -0
- package/scripts/lib/intervention-guidance.js +57 -0
- package/scripts/lib/known-limitations.js +115 -0
- package/scripts/lib/l8-path-truth.js +146 -0
- package/scripts/lib/launch-hardening-gate.js +436 -0
- package/scripts/lib/launch-readiness.js +635 -0
- package/scripts/lib/learning-experimentation-foundation.js +1484 -0
- package/scripts/lib/learning-memory.js +686 -0
- package/scripts/lib/lifecycle-hooks.js +982 -0
- package/scripts/lib/local-package-smoke.js +436 -0
- package/scripts/lib/local-pricing.js +299 -0
- package/scripts/lib/mcp-enforcement.js +311 -0
- package/scripts/lib/mcp-least-privilege-policy.js +303 -0
- package/scripts/lib/mcp-tool-inventory.js +388 -0
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +335 -0
- package/scripts/lib/metrics.js +699 -0
- package/scripts/lib/micro-proof.js +133 -0
- package/scripts/lib/model-work-class-routing.js +79 -0
- package/scripts/lib/next-run-context.js +436 -0
- package/scripts/lib/next-run-continuity.js +1207 -0
- package/scripts/lib/observability-recovery-guard.js +1030 -0
- package/scripts/lib/operating-value.js +1662 -0
- package/scripts/lib/optimization-v3.js +122 -0
- package/scripts/lib/orchestration/adapters/_shared.js +49 -0
- package/scripts/lib/orchestration/adapters/aider.js +18 -0
- package/scripts/lib/orchestration/adapters/claude-code.js +35 -0
- package/scripts/lib/orchestration/adapters/codex.js +35 -0
- package/scripts/lib/orchestration/adapters/gemini-cli.js +18 -0
- package/scripts/lib/orchestration/adapters/git.js +25 -0
- package/scripts/lib/orchestration/adapters/index.js +31 -0
- package/scripts/lib/orchestration/adapters/lm-studio.js +18 -0
- package/scripts/lib/orchestration/adapters/ollama.js +18 -0
- package/scripts/lib/orchestration/adapters/opencode.js +18 -0
- package/scripts/lib/orchestration/adapters/openrouter.js +18 -0
- package/scripts/lib/orchestration/adapters/test-runner.js +25 -0
- package/scripts/lib/orchestration/cli.js +438 -0
- package/scripts/lib/orchestration/execution-manager.js +279 -0
- package/scripts/lib/orchestration/handoff.js +314 -0
- package/scripts/lib/orchestration/index.js +456 -0
- package/scripts/lib/orchestration/inventory.js +47 -0
- package/scripts/lib/orchestration/model-discovery.js +498 -0
- package/scripts/lib/orchestration/model-profiler.js +170 -0
- package/scripts/lib/orchestration/model-profiles.js +252 -0
- package/scripts/lib/orchestration/model-refresh-policy.js +72 -0
- package/scripts/lib/orchestration/proof-writer.js +349 -0
- package/scripts/lib/orchestration/provider-discovery/aider.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +56 -0
- package/scripts/lib/orchestration/provider-discovery/codex.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/common.js +186 -0
- package/scripts/lib/orchestration/provider-discovery/gemini.js +106 -0
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +118 -0
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +12 -0
- package/scripts/lib/orchestration/provider-discovery/ollama.js +100 -0
- package/scripts/lib/orchestration/provider-discovery/opencode.js +47 -0
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +44 -0
- package/scripts/lib/orchestration/risk-classifier.js +130 -0
- package/scripts/lib/orchestration/routing-policy.js +486 -0
- package/scripts/lib/orchestration/settings.js +95 -0
- package/scripts/lib/orchestration/state.js +165 -0
- package/scripts/lib/orchestration/verification-manager.js +138 -0
- package/scripts/lib/outcome-evidence-stack.js +1083 -0
- package/scripts/lib/output-profiles.js +146 -0
- package/scripts/lib/package-content-audit.js +368 -0
- package/scripts/lib/package-runtime.js +278 -0
- package/scripts/lib/plan-surface.js +53 -0
- package/scripts/lib/plans.js +2327 -0
- package/scripts/lib/policy-provider.js +27 -0
- package/scripts/lib/prelaunch-activation-readiness.js +409 -0
- package/scripts/lib/prelaunch-evidence-store.js +816 -0
- package/scripts/lib/prelaunch-intelligence.js +869 -0
- package/scripts/lib/pricing-experiment.js +118 -0
- package/scripts/lib/pro-moment-events.js +77 -0
- package/scripts/lib/pro-moment-state.js +227 -0
- package/scripts/lib/pro-moments.js +1216 -0
- package/scripts/lib/product-home-receipt.js +1790 -0
- package/scripts/lib/product-learning-events.js +696 -0
- package/scripts/lib/production-confidence-control-tower.js +1209 -0
- package/scripts/lib/production-confidence.js +1858 -0
- package/scripts/lib/project-profile.js +555 -0
- package/scripts/lib/prompt-compiler-plan.js +94 -0
- package/scripts/lib/prompt-compiler.js +280 -0
- package/scripts/lib/prompt-lint.js +32 -0
- package/scripts/lib/prompt-suggestions.js +52 -0
- package/scripts/lib/proof-canonical.js +398 -0
- package/scripts/lib/proof-drilldown.js +383 -0
- package/scripts/lib/proof-e2e/promise-completion.js +141 -0
- package/scripts/lib/proof-e2e/promise-dashboard-claims.js +135 -0
- package/scripts/lib/proof-e2e/promise-local-proof.js +156 -0
- package/scripts/lib/proof-e2e/promise-provider-neutral.js +136 -0
- package/scripts/lib/proof-e2e/promise-registry.js +219 -0
- package/scripts/lib/proof-e2e/promise-security-trust.js +141 -0
- package/scripts/lib/proof-e2e/promise-skills-risk.js +163 -0
- package/scripts/lib/proof-e2e/promise-token-savings.js +112 -0
- package/scripts/lib/proof-e2e/promise-work-management.js +126 -0
- package/scripts/lib/proof-events.js +342 -0
- package/scripts/lib/proof-history.js +243 -0
- package/scripts/lib/proof-metrics.js +296 -0
- package/scripts/lib/proof-outcome-evidence.js +134 -0
- package/scripts/lib/proof-receipt.js +335 -0
- package/scripts/lib/proof-record.js +461 -0
- package/scripts/lib/proof-savings-report.js +1549 -0
- package/scripts/lib/public-activation-distribution-gate.js +266 -0
- package/scripts/lib/public-cli.js +5631 -0
- package/scripts/lib/public-distribution-truth.js +211 -0
- package/scripts/lib/public-distribution.js +73 -0
- package/scripts/lib/public-install-claim-checker.js +300 -0
- package/scripts/lib/publish-provenance-readiness.js +287 -0
- package/scripts/lib/readiness-delta.js +218 -0
- package/scripts/lib/readiness-evidence-closure.js +196 -0
- package/scripts/lib/reentry-memory-capture.js +241 -0
- package/scripts/lib/reentry-memory-retrieval.js +302 -0
- package/scripts/lib/reentry-memory-status.js +147 -0
- package/scripts/lib/reentry-memory-store.js +183 -0
- package/scripts/lib/reentry-state.js +66 -0
- package/scripts/lib/release-candidate-bundle.js +166 -0
- package/scripts/lib/remediation.js +81 -0
- package/scripts/lib/repo-map.js +391 -0
- package/scripts/lib/run-action-policy.js +104 -0
- package/scripts/lib/run-contract-receipt.js +48 -0
- package/scripts/lib/run-contract.js +288 -0
- package/scripts/lib/run-cost-to-verified-outcome.js +87 -0
- package/scripts/lib/run-improvements-lifecycle.js +330 -0
- package/scripts/lib/run-improvements.js +789 -0
- package/scripts/lib/run-proof-contract.js +116 -0
- package/scripts/lib/run-risk-classifier.js +131 -0
- package/scripts/lib/run-task-classifier.js +216 -0
- package/scripts/lib/runtime-decision-policy.js +387 -0
- package/scripts/lib/safe-path-engine.js +705 -0
- package/scripts/lib/safe-repair.js +877 -0
- package/scripts/lib/safe-run-controller.js +887 -0
- package/scripts/lib/scope-repair-before-approval.js +865 -0
- package/scripts/lib/score.js +262 -0
- package/scripts/lib/seamless-enforcement.js +329 -0
- package/scripts/lib/seamless-outcome.js +689 -0
- package/scripts/lib/seamless-reality-gate.js +5053 -0
- package/scripts/lib/security-confidence/activation-safety.js +78 -0
- package/scripts/lib/security-confidence/adapters/adapter-contract.js +125 -0
- package/scripts/lib/security-confidence/adapters/mock-claude-bughunter-adapter.js +36 -0
- package/scripts/lib/security-confidence/adapters/mock-decepticon-adapter.js +34 -0
- package/scripts/lib/security-confidence/adapters/mock-mcp-scan-adapter.js +35 -0
- package/scripts/lib/security-confidence/adapters/mock-snyk-agent-scan-adapter.js +35 -0
- package/scripts/lib/security-confidence/adapters/mock-tank-adapter.js +34 -0
- package/scripts/lib/security-confidence/adapters/reference-registry.js +63 -0
- package/scripts/lib/security-confidence/auth-rbac-plan.js +39 -0
- package/scripts/lib/security-confidence/component-inventory.js +151 -0
- package/scripts/lib/security-confidence/constants.js +191 -0
- package/scripts/lib/security-confidence/dependency-script-risk.js +95 -0
- package/scripts/lib/security-confidence/evidence-hygiene.js +127 -0
- package/scripts/lib/security-confidence/feature-impact-classifier.js +80 -0
- package/scripts/lib/security-confidence/file-utils.js +161 -0
- package/scripts/lib/security-confidence/finding-triage.js +90 -0
- package/scripts/lib/security-confidence/findings.js +115 -0
- package/scripts/lib/security-confidence/index.js +29 -0
- package/scripts/lib/security-confidence/permission-budget.js +93 -0
- package/scripts/lib/security-confidence/redaction.js +82 -0
- package/scripts/lib/security-confidence/redteam-fixtures.js +53 -0
- package/scripts/lib/security-confidence/reference-adoption.js +229 -0
- package/scripts/lib/security-confidence/reference-taxonomy.js +155 -0
- package/scripts/lib/security-confidence/report-quality.js +99 -0
- package/scripts/lib/security-confidence/report-writer.js +79 -0
- package/scripts/lib/security-confidence/risk-classifier.js +187 -0
- package/scripts/lib/security-confidence/runner.js +179 -0
- package/scripts/lib/security-confidence/schema.js +188 -0
- package/scripts/lib/security-confidence/secret-safety.js +74 -0
- package/scripts/lib/security-confidence/security-capability-router.js +98 -0
- package/scripts/lib/security-confidence/web-security-smoke-plan.js +46 -0
- package/scripts/lib/security-risk-classifier.js +511 -0
- package/scripts/lib/security-scan.js +396 -0
- package/scripts/lib/session-context-optimizer.js +1211 -0
- package/scripts/lib/session-timing.js +322 -0
- package/scripts/lib/skill-hygiene.js +805 -0
- package/scripts/lib/skill-packs.js +161 -0
- package/scripts/lib/skills-operating-layer-v1.js +1023 -0
- package/scripts/lib/skills-operating-layer.js +629 -0
- package/scripts/lib/smallest-safe-plan.js +214 -0
- package/scripts/lib/smart-routing-plan.js +115 -0
- package/scripts/lib/smart-work-routing.js +768 -0
- package/scripts/lib/source-catalog.js +1022 -0
- package/scripts/lib/status-value-summary.js +32 -0
- package/scripts/lib/supply-chain-dependency-guard.js +1333 -0
- package/scripts/lib/supply-chain-guard.js +219 -0
- package/scripts/lib/support-bundle.js +561 -0
- package/scripts/lib/support-redaction.js +66 -0
- package/scripts/lib/task-continuation.js +440 -0
- package/scripts/lib/test-helpers.js +15 -0
- package/scripts/lib/tier.js +38 -0
- package/scripts/lib/token-context-quality-gate.js +370 -0
- package/scripts/lib/token-cost-capture.js +187 -0
- package/scripts/lib/token-cost-evidence.js +862 -0
- package/scripts/lib/token-cost-intelligence.js +358 -0
- package/scripts/lib/token-efficiency-evidence.js +213 -0
- package/scripts/lib/token-efficiency-map.js +110 -0
- package/scripts/lib/token-evidence.js +703 -0
- package/scripts/lib/tokenish.js +17 -0
- package/scripts/lib/tool-output-sandbox.js +559 -0
- package/scripts/lib/trust-audit.js +136 -0
- package/scripts/lib/unified-events.js +396 -0
- package/scripts/lib/upgrade-interruption-recovery.js +407 -0
- package/scripts/lib/usage-ledger.js +201 -0
- package/scripts/lib/value-ledger.js +130 -0
- package/scripts/lib/value-proof-calibration.js +531 -0
- package/scripts/lib/visual-qa.js +231 -0
- package/scripts/lib/voice-alpha.js +29 -0
- package/scripts/lib/webhook-idempotency-guard.js +990 -0
- package/scripts/lib/work-aware-orchestration.js +976 -0
- package/scripts/lib/work-control-receipts.js +577 -0
- package/scripts/lib/work-ledger.js +1123 -0
- package/scripts/lib/work-panel-preview.js +352 -0
- package/scripts/lib/workflow-discipline.js +280 -0
- package/scripts/lib/workflow-intelligence-radar.js +804 -0
- package/scripts/lib/workflow-signals.js +419 -0
- package/scripts/lib/workspace-map.js +281 -0
- package/scripts/lib/workspace-registry.js +1367 -0
- package/scripts/lib/workspace-resolver.js +542 -0
- package/scripts/wuz-doctor.js +315 -0
- package/bin/avorelo.mjs +0 -7
- package/dist/avorelo.mjs +0 -24678
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function numberOrNull(value) {
|
|
4
|
+
const number = Number(value);
|
|
5
|
+
return Number.isFinite(number) ? number : null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function preferred(value, fallback = null) {
|
|
9
|
+
if (value === undefined || value === null || value === "") return fallback;
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function inferExecutionPath(input = {}) {
|
|
14
|
+
const existing = objectOrNull(input.attribution) || {};
|
|
15
|
+
const explicit = preferred(input.executionPath ?? existing.executionPath ?? input.meta?.executionPath, null);
|
|
16
|
+
if (explicit) return String(explicit);
|
|
17
|
+
|
|
18
|
+
const tool = String(input.tool || "");
|
|
19
|
+
const event = String(input.event || "");
|
|
20
|
+
const meta = input.meta || {};
|
|
21
|
+
const hasModelEvidence =
|
|
22
|
+
preferred(input.provider ?? existing.provider ?? meta.provider, null)
|
|
23
|
+
|| preferred(input.model ?? existing.model ?? meta.model, null)
|
|
24
|
+
|| numberOrNull(input.tokenUsage ?? existing.tokenUsage ?? meta.totalTokens ?? meta.tokenUsage) !== null
|
|
25
|
+
|| numberOrNull(input.cost ?? existing.cost ?? meta.totalCost ?? meta.cost) !== null;
|
|
26
|
+
if (tool === "ccusage" || event === "CcusageSync" || event === "CloudSync") return "deterministic";
|
|
27
|
+
if (tool === "Bash" || tool === "Read" || tool === "Grep" || tool === "Glob" || tool === "Write" || tool === "Edit") return "deterministic";
|
|
28
|
+
if (event === "BatchJob") return "llm";
|
|
29
|
+
if (tool === "Agent" || hasModelEvidence) return "llm";
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function objectOrNull(value) {
|
|
34
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function pickFromCandidates(candidates, keys, transform = (value) => value) {
|
|
38
|
+
for (const candidate of candidates) {
|
|
39
|
+
const obj = objectOrNull(candidate);
|
|
40
|
+
if (!obj) continue;
|
|
41
|
+
for (const key of keys) {
|
|
42
|
+
if (!(key in obj)) continue;
|
|
43
|
+
const transformed = transform(obj[key]);
|
|
44
|
+
if (transformed !== null && transformed !== undefined && transformed !== "") return transformed;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function sumTokenParts(candidates) {
|
|
51
|
+
let sawAny = false;
|
|
52
|
+
let total = 0;
|
|
53
|
+
for (const candidate of candidates) {
|
|
54
|
+
const obj = objectOrNull(candidate);
|
|
55
|
+
if (!obj) continue;
|
|
56
|
+
const inputTokens = numberOrNull(obj.inputTokens ?? obj.input_tokens ?? obj.promptTokens ?? obj.prompt_tokens);
|
|
57
|
+
const outputTokens = numberOrNull(obj.outputTokens ?? obj.output_tokens ?? obj.completionTokens ?? obj.completion_tokens);
|
|
58
|
+
if (inputTokens !== null) {
|
|
59
|
+
sawAny = true;
|
|
60
|
+
total += inputTokens;
|
|
61
|
+
}
|
|
62
|
+
if (outputTokens !== null) {
|
|
63
|
+
sawAny = true;
|
|
64
|
+
total += outputTokens;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return sawAny ? total : null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function extractRuntimeEvidence(params = {}) {
|
|
71
|
+
const toolInput = objectOrNull(params.toolInput) || {};
|
|
72
|
+
const toolResponse = objectOrNull(params.toolResponse) || {};
|
|
73
|
+
const candidates = [
|
|
74
|
+
params,
|
|
75
|
+
toolInput,
|
|
76
|
+
toolInput.metadata,
|
|
77
|
+
toolInput.usage,
|
|
78
|
+
toolResponse,
|
|
79
|
+
toolResponse.metadata,
|
|
80
|
+
toolResponse.metrics,
|
|
81
|
+
toolResponse.usage,
|
|
82
|
+
toolResponse.result,
|
|
83
|
+
objectOrNull(toolResponse.result)?.metadata,
|
|
84
|
+
objectOrNull(toolResponse.result)?.metrics,
|
|
85
|
+
objectOrNull(toolResponse.result)?.usage,
|
|
86
|
+
toolResponse.response,
|
|
87
|
+
objectOrNull(toolResponse.response)?.metadata,
|
|
88
|
+
objectOrNull(toolResponse.response)?.metrics,
|
|
89
|
+
objectOrNull(toolResponse.response)?.usage,
|
|
90
|
+
toolResponse.data,
|
|
91
|
+
objectOrNull(toolResponse.data)?.metadata,
|
|
92
|
+
objectOrNull(toolResponse.data)?.metrics,
|
|
93
|
+
objectOrNull(toolResponse.data)?.usage,
|
|
94
|
+
].filter(Boolean);
|
|
95
|
+
|
|
96
|
+
const provider = pickFromCandidates(candidates, ["provider", "providerName", "provider_name"], (value) => preferred(value, null));
|
|
97
|
+
const model = pickFromCandidates(candidates, ["model", "modelName", "model_name"], (value) => preferred(value, null));
|
|
98
|
+
const tokenUsage =
|
|
99
|
+
pickFromCandidates(
|
|
100
|
+
candidates,
|
|
101
|
+
["tokenUsage", "token_usage", "totalTokens", "total_tokens", "tokens"],
|
|
102
|
+
(value) => numberOrNull(value)
|
|
103
|
+
) ?? sumTokenParts(candidates);
|
|
104
|
+
const cost = pickFromCandidates(
|
|
105
|
+
candidates,
|
|
106
|
+
["cost", "totalCost", "total_cost", "measuredCost", "measured_cost"],
|
|
107
|
+
(value) => numberOrNull(value)
|
|
108
|
+
);
|
|
109
|
+
const latencyMs = pickFromCandidates(
|
|
110
|
+
candidates,
|
|
111
|
+
["latencyMs", "latency_ms", "durationMs", "duration_ms", "elapsedMs", "elapsed_ms"],
|
|
112
|
+
(value) => numberOrNull(value)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
if ([provider, model, tokenUsage, cost, latencyMs].every((value) => value === null)) return null;
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
provider: provider ? String(provider) : null,
|
|
119
|
+
model: model ? String(model) : null,
|
|
120
|
+
tokenUsage,
|
|
121
|
+
cost,
|
|
122
|
+
costSource: cost !== null && cost > 0 ? "measured" : "unavailable",
|
|
123
|
+
latencyMs,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function normalizeAttribution(input = {}) {
|
|
128
|
+
const existing = objectOrNull(input.attribution) || {};
|
|
129
|
+
const meta = input.meta || {};
|
|
130
|
+
const provider = preferred(input.provider ?? existing.provider ?? meta.provider, null);
|
|
131
|
+
const model = preferred(input.model ?? existing.model ?? meta.model, null);
|
|
132
|
+
const tokenUsage = numberOrNull(input.tokenUsage ?? existing.tokenUsage ?? meta.totalTokens ?? meta.tokenUsage);
|
|
133
|
+
const cost = numberOrNull(input.cost ?? existing.cost ?? meta.totalCost ?? meta.cost);
|
|
134
|
+
const latencyMs = numberOrNull(input.latencyMs ?? existing.latencyMs ?? meta.latencyMs);
|
|
135
|
+
|
|
136
|
+
const attribution = {
|
|
137
|
+
sessionId: preferred(input.sessionId ?? existing.sessionId, "unknown"),
|
|
138
|
+
featureId: preferred(input.featureId ?? existing.featureId ?? meta.featureId, null),
|
|
139
|
+
componentId: preferred(input.componentId ?? existing.componentId ?? meta.componentId ?? input.event, null),
|
|
140
|
+
workerId: preferred(input.workerId ?? existing.workerId ?? meta.workerId, null),
|
|
141
|
+
routeId: preferred(input.routeId ?? existing.routeId ?? meta.routeId, null),
|
|
142
|
+
stepId: preferred(input.stepId ?? existing.stepId ?? meta.stepId, null),
|
|
143
|
+
actionType: preferred(input.actionType ?? existing.actionType ?? meta.actionType ?? input.action, null),
|
|
144
|
+
executionPath: inferExecutionPath(input),
|
|
145
|
+
provider: provider ? String(provider) : null,
|
|
146
|
+
model: model ? String(model) : null,
|
|
147
|
+
tokenUsage,
|
|
148
|
+
cost,
|
|
149
|
+
costSource: cost !== null && cost > 0 ? "measured" : preferred(input.costSource ?? existing.costSource ?? meta.costSource, "unavailable"),
|
|
150
|
+
latencyMs,
|
|
151
|
+
status: preferred(input.status ?? existing.status ?? meta.status ?? input.action, null),
|
|
152
|
+
timestamp: preferred(input.timestamp ?? existing.timestamp ?? input.ts, null),
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return Object.values(attribution).some((value) => value !== null && value !== undefined && value !== "")
|
|
156
|
+
? attribution
|
|
157
|
+
: null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function inferValueUnit(metric = {}, attribution = null, measured, counterfactual) {
|
|
161
|
+
if (attribution?.cost !== null && attribution?.cost !== undefined) return "currency";
|
|
162
|
+
if (attribution?.tokenUsage !== null && attribution?.tokenUsage !== undefined) return "tokens";
|
|
163
|
+
|
|
164
|
+
const meta = metric.meta || {};
|
|
165
|
+
if (numberOrNull(meta.totalCost) !== null) return "currency";
|
|
166
|
+
if (numberOrNull(meta.totalTokens) !== null) return "tokens";
|
|
167
|
+
if (numberOrNull(meta.bytes) !== null) return "bytes";
|
|
168
|
+
|
|
169
|
+
const numericMeasured = numberOrNull(measured);
|
|
170
|
+
const numericCounterfactual = numberOrNull(counterfactual);
|
|
171
|
+
if (metric.category === "loop_detected" && (numericMeasured !== null || numericCounterfactual !== null)) return "minutes";
|
|
172
|
+
if (numericMeasured !== null || numericCounterfactual !== null) return "count";
|
|
173
|
+
return "unknown";
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
module.exports = {
|
|
177
|
+
normalizeAttribution,
|
|
178
|
+
inferValueUnit,
|
|
179
|
+
extractRuntimeEvidence,
|
|
180
|
+
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const SEVERITY_WEIGHT = {
|
|
7
|
+
high: 3,
|
|
8
|
+
medium: 2,
|
|
9
|
+
low: 1,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const REASON_MAP = {
|
|
13
|
+
SEC_PRIVATE_KEY: {
|
|
14
|
+
title: "Remove embedded private key material",
|
|
15
|
+
suggestedFix: "Delete key material from repository files, rotate the key, and move secrets to secure storage.",
|
|
16
|
+
actionPath: "security -> secret rotation -> /cco-audit",
|
|
17
|
+
},
|
|
18
|
+
SEC_GH_TOKEN: {
|
|
19
|
+
title: "Rotate exposed GitHub token",
|
|
20
|
+
suggestedFix: "Remove token-like values, rotate credentials, and enforce local secret scanning before commit.",
|
|
21
|
+
actionPath: "security -> credential hygiene -> /cco-audit",
|
|
22
|
+
},
|
|
23
|
+
SEC_CURL_PIPE_SH: {
|
|
24
|
+
title: "Eliminate remote shell piping",
|
|
25
|
+
suggestedFix: "Download scripts first, verify checksum/signature, then run from reviewed local files.",
|
|
26
|
+
actionPath: "security -> safe execution defaults -> /cco-remediate",
|
|
27
|
+
},
|
|
28
|
+
SEC_REMOTE_FETCH: {
|
|
29
|
+
title: "Pin and verify remote fetch sources",
|
|
30
|
+
suggestedFix: "Restrict remote fetches to trusted pinned sources and verify checksums before use.",
|
|
31
|
+
actionPath: "security -> fetch controls -> /cco-remediate",
|
|
32
|
+
},
|
|
33
|
+
SEC_REMOTE_INCLUDE: {
|
|
34
|
+
title: "Replace remote includes with local pinned artifacts",
|
|
35
|
+
suggestedFix: "Vendor includes locally or pin immutable references and require explicit review.",
|
|
36
|
+
actionPath: "security -> include controls -> /cco-remediate",
|
|
37
|
+
},
|
|
38
|
+
SEC_UNPINNED_GIT_DEP: {
|
|
39
|
+
title: "Pin git dependencies",
|
|
40
|
+
suggestedFix: "Use immutable commit SHAs instead of floating refs (main/master/latest).",
|
|
41
|
+
actionPath: "security -> dependency pinning -> /cco-remediate",
|
|
42
|
+
},
|
|
43
|
+
SEC_OVERBROAD_PERMISSION: {
|
|
44
|
+
title: "Tighten permission budget",
|
|
45
|
+
suggestedFix: "Replace broad permissions with least-privilege scope for skills and agents.",
|
|
46
|
+
actionPath: "security -> permission budget -> /cco-settings scope=team",
|
|
47
|
+
},
|
|
48
|
+
SEC_BIDI_UNICODE: {
|
|
49
|
+
title: "Remove bidirectional unicode control characters",
|
|
50
|
+
suggestedFix: "Replace hidden directional characters and review suspicious text blocks.",
|
|
51
|
+
actionPath: "security -> content integrity -> /cco-audit",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function clamp(n, min, max) {
|
|
56
|
+
return Math.max(min, Math.min(max, n));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function severityRank(sev) {
|
|
60
|
+
if (sev === "high") return 3;
|
|
61
|
+
if (sev === "medium") return 2;
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function scoreFinding(finding, recencyWeight) {
|
|
66
|
+
const sevWeight = SEVERITY_WEIGHT[finding.severity] || 1;
|
|
67
|
+
const confidence = Number.isFinite(Number(finding.confidence)) ? Number(finding.confidence) : 0.5;
|
|
68
|
+
const recency = Number.isFinite(Number(recencyWeight)) ? Number(recencyWeight) : 1;
|
|
69
|
+
return Number((sevWeight * confidence * recency).toFixed(6));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function loadJson(absPath, fallback = null) {
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(fs.readFileSync(absPath, "utf8"));
|
|
75
|
+
} catch {
|
|
76
|
+
return fallback;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function listJsonArtifacts(absDir, filterFn = null) {
|
|
81
|
+
try {
|
|
82
|
+
return fs
|
|
83
|
+
.readdirSync(absDir)
|
|
84
|
+
.filter((name) => name.endsWith(".json"))
|
|
85
|
+
.filter((name) => (typeof filterFn === "function" ? filterFn(name) : true))
|
|
86
|
+
.map((name) => {
|
|
87
|
+
const absPath = path.join(absDir, name);
|
|
88
|
+
const st = fs.statSync(absPath);
|
|
89
|
+
return {
|
|
90
|
+
name,
|
|
91
|
+
absPath,
|
|
92
|
+
relPath: path.posix.join(path.relative(process.cwd(), absDir).replace(/\\/g, "/"), name),
|
|
93
|
+
mtimeMs: st.mtimeMs,
|
|
94
|
+
data: loadJson(absPath, {}),
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
98
|
+
} catch {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function reasonDetails(reasonCode) {
|
|
104
|
+
return (
|
|
105
|
+
REASON_MAP[reasonCode] || {
|
|
106
|
+
title: `Review finding ${reasonCode}`,
|
|
107
|
+
suggestedFix: "Review the highlighted line, apply least-privilege changes, and re-run /cco-audit.",
|
|
108
|
+
actionPath: "security -> /cco-audit",
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function remediationJobByReason(cwd) {
|
|
114
|
+
const jobsDir = path.join(cwd, ".claude", "cco", "patches", "jobs");
|
|
115
|
+
const jobs = listJsonArtifacts(jobsDir);
|
|
116
|
+
const map = new Map();
|
|
117
|
+
|
|
118
|
+
jobs.forEach((jobArt) => {
|
|
119
|
+
const patches = Array.isArray(jobArt.data?.patches) ? jobArt.data.patches : [];
|
|
120
|
+
patches.forEach((patch) => {
|
|
121
|
+
const reasonCode = String(patch.reasonCode || "");
|
|
122
|
+
if (!reasonCode) return;
|
|
123
|
+
if (!map.has(reasonCode)) {
|
|
124
|
+
map.set(reasonCode, patch.path || jobArt.relPath);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return map;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function normalizeHighlightsFromArtifacts(artifacts, cwd) {
|
|
133
|
+
const jobMap = remediationJobByReason(cwd);
|
|
134
|
+
const normalized = [];
|
|
135
|
+
|
|
136
|
+
artifacts.forEach((artifact, idx) => {
|
|
137
|
+
const highlights = Array.isArray(artifact.data?.highlights) ? artifact.data.highlights : [];
|
|
138
|
+
const artifactRecencyWeight = clamp(1 - idx * 0.03, 0.7, 1);
|
|
139
|
+
|
|
140
|
+
highlights.forEach((h, hIdx) => {
|
|
141
|
+
const reasonCode = String(h.id || "SEC_UNKNOWN");
|
|
142
|
+
const severity = ["high", "medium", "low"].includes(String(h.severity || "")) ? String(h.severity) : "low";
|
|
143
|
+
const confidence = Number.isFinite(Number(h.confidence)) ? Number(h.confidence) : 0.5;
|
|
144
|
+
const suppressed = h.suppressed === true;
|
|
145
|
+
const details = reasonDetails(reasonCode);
|
|
146
|
+
const normalizedFinding = {
|
|
147
|
+
findingId: `${artifact.name}:${hIdx + 1}:${reasonCode}`,
|
|
148
|
+
reasonCode,
|
|
149
|
+
severity,
|
|
150
|
+
confidence,
|
|
151
|
+
rationale: String(h.rationale || "No rationale provided."),
|
|
152
|
+
path: String(h.path || artifact.relPath),
|
|
153
|
+
line: Number.isFinite(Number(h.line)) ? Number(h.line) : 1,
|
|
154
|
+
snippet: String(h.snippet || ""),
|
|
155
|
+
suppressed,
|
|
156
|
+
sourceArtifact: artifact.relPath,
|
|
157
|
+
suggestedFix: details.suggestedFix,
|
|
158
|
+
actionPath: details.actionPath,
|
|
159
|
+
jobPath: jobMap.get(reasonCode) || null,
|
|
160
|
+
recencyWeight: artifactRecencyWeight,
|
|
161
|
+
};
|
|
162
|
+
normalizedFinding.rankScore = scoreFinding(normalizedFinding, artifactRecencyWeight);
|
|
163
|
+
normalized.push(normalizedFinding);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
return normalized;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function compareFindings(a, b) {
|
|
171
|
+
if (b.rankScore !== a.rankScore) return b.rankScore - a.rankScore;
|
|
172
|
+
if (severityRank(b.severity) !== severityRank(a.severity)) return severityRank(b.severity) - severityRank(a.severity);
|
|
173
|
+
if (b.confidence !== a.confidence) return b.confidence - a.confidence;
|
|
174
|
+
if (a.reasonCode !== b.reasonCode) return a.reasonCode.localeCompare(b.reasonCode);
|
|
175
|
+
if (a.path !== b.path) return a.path.localeCompare(b.path);
|
|
176
|
+
return a.line - b.line;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function topReasonCodesFromFindings(findings, limit = 5) {
|
|
180
|
+
const counts = {};
|
|
181
|
+
findings.forEach((f) => {
|
|
182
|
+
counts[f.reasonCode] = (counts[f.reasonCode] || 0) + 1;
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return Object.keys(counts)
|
|
186
|
+
.sort((a, b) => {
|
|
187
|
+
if (counts[b] !== counts[a]) return counts[b] - counts[a];
|
|
188
|
+
return a.localeCompare(b);
|
|
189
|
+
})
|
|
190
|
+
.slice(0, limit);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function riskLevelFromFindings(activeFindings) {
|
|
194
|
+
if (!activeFindings.length) return "low";
|
|
195
|
+
if (activeFindings.some((f) => f.severity === "high")) return "high";
|
|
196
|
+
if (activeFindings.some((f) => f.severity === "medium")) return "medium";
|
|
197
|
+
return "low";
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function toTopFindingView(finding) {
|
|
201
|
+
return {
|
|
202
|
+
reasonCode: finding.reasonCode,
|
|
203
|
+
severity: finding.severity,
|
|
204
|
+
confidence: finding.confidence,
|
|
205
|
+
rationale: finding.rationale,
|
|
206
|
+
path: finding.path,
|
|
207
|
+
line: finding.line,
|
|
208
|
+
suggestedFix: finding.suggestedFix,
|
|
209
|
+
actionPath: finding.actionPath,
|
|
210
|
+
jobPath: finding.jobPath,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function toTopRecommendedFixes(activeFindings, limit = 5) {
|
|
215
|
+
const seen = new Set();
|
|
216
|
+
const out = [];
|
|
217
|
+
|
|
218
|
+
activeFindings.forEach((f) => {
|
|
219
|
+
if (seen.has(f.reasonCode)) return;
|
|
220
|
+
seen.add(f.reasonCode);
|
|
221
|
+
out.push({
|
|
222
|
+
reasonCode: f.reasonCode,
|
|
223
|
+
title: reasonDetails(f.reasonCode).title,
|
|
224
|
+
text: f.suggestedFix,
|
|
225
|
+
confidence: f.confidence,
|
|
226
|
+
actionPath: f.actionPath,
|
|
227
|
+
jobPath: f.jobPath,
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
return out.slice(0, limit);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function computeNextBestAction(activeFindings) {
|
|
235
|
+
if (!activeFindings.length) {
|
|
236
|
+
return "No active security findings. Keep current defaults and run /cco-audit after meaningful code or skill changes.";
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const top = activeFindings[0];
|
|
240
|
+
if (top.severity === "high") {
|
|
241
|
+
return `Address high-risk finding ${top.reasonCode} first, apply manual remediation, then re-run /cco-audit.`;
|
|
242
|
+
}
|
|
243
|
+
return `Address ${top.reasonCode} next, then run /cco-audit to verify reduced risk.`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function buildAuditSummary(cwd) {
|
|
247
|
+
const securityDir = path.join(cwd, ".claude", "cco", "security");
|
|
248
|
+
const securityArtifacts = listJsonArtifacts(
|
|
249
|
+
securityDir,
|
|
250
|
+
(name) => name.endsWith("-file-scan.json") || name.endsWith("-prerun-scan.json") || name.endsWith("-scan.json")
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
const normalized = normalizeHighlightsFromArtifacts(securityArtifacts, cwd).sort(compareFindings);
|
|
254
|
+
const activeFindings = normalized.filter((f) => !f.suppressed);
|
|
255
|
+
const suppressedFindings = normalized.filter((f) => f.suppressed);
|
|
256
|
+
|
|
257
|
+
const topFindings = activeFindings.slice(0, 5).map(toTopFindingView);
|
|
258
|
+
const topRecommendedFixes = toTopRecommendedFixes(activeFindings, 5);
|
|
259
|
+
const topReasonCodes = topReasonCodesFromFindings(activeFindings, 5);
|
|
260
|
+
|
|
261
|
+
const summary = {
|
|
262
|
+
riskLevel: riskLevelFromFindings(activeFindings),
|
|
263
|
+
activeFindings: activeFindings.length,
|
|
264
|
+
suppressedFindings: suppressedFindings.length,
|
|
265
|
+
topReasonCodes,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
auditVersion: 1,
|
|
270
|
+
what: "Security audit completed.",
|
|
271
|
+
why: "Shows deterministic high-signal security findings and manual remediation suggestions for this repo.",
|
|
272
|
+
summary,
|
|
273
|
+
topFindings,
|
|
274
|
+
topRecommendedFixes,
|
|
275
|
+
nextBestAction: computeNextBestAction(activeFindings),
|
|
276
|
+
attribution: {
|
|
277
|
+
foundBy: "Skill Security Scout",
|
|
278
|
+
builtBy: "Security Engineer",
|
|
279
|
+
designedBy: "UX Lead",
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
module.exports = {
|
|
285
|
+
buildAuditSummary,
|
|
286
|
+
topReasonCodesFromFindings,
|
|
287
|
+
riskLevelFromFindings,
|
|
288
|
+
compareFindings,
|
|
289
|
+
};
|