@shrkcrft/inspector 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/acceptance-replay.d.ts +63 -0
- package/dist/acceptance-replay.d.ts.map +1 -0
- package/dist/acceptance-replay.js +240 -0
- package/dist/action-hint-diagnostics.d.ts +32 -0
- package/dist/action-hint-diagnostics.d.ts.map +1 -0
- package/dist/action-hint-diagnostics.js +133 -0
- package/dist/adoption-check.d.ts +28 -0
- package/dist/adoption-check.d.ts.map +1 -0
- package/dist/adoption-check.js +181 -0
- package/dist/adoption-checkpoint.d.ts +97 -0
- package/dist/adoption-checkpoint.d.ts.map +1 -0
- package/dist/adoption-checkpoint.js +209 -0
- package/dist/adoption-merge-preview.d.ts +28 -0
- package/dist/adoption-merge-preview.d.ts.map +1 -0
- package/dist/adoption-merge-preview.js +254 -0
- package/dist/adoption-report-renderer.d.ts +33 -0
- package/dist/adoption-report-renderer.d.ts.map +1 -0
- package/dist/adoption-report-renderer.js +257 -0
- package/dist/adoption-state.d.ts +100 -0
- package/dist/adoption-state.d.ts.map +1 -0
- package/dist/adoption-state.js +296 -0
- package/dist/adoption-three-way.d.ts +46 -0
- package/dist/adoption-three-way.d.ts.map +1 -0
- package/dist/adoption-three-way.js +181 -0
- package/dist/agent-brief.d.ts +77 -0
- package/dist/agent-brief.d.ts.map +1 -0
- package/dist/agent-brief.js +490 -0
- package/dist/agent-contract-gate.d.ts +108 -0
- package/dist/agent-contract-gate.d.ts.map +1 -0
- package/dist/agent-contract-gate.js +412 -0
- package/dist/agent-contract-templates.d.ts +63 -0
- package/dist/agent-contract-templates.d.ts.map +1 -0
- package/dist/agent-contract-templates.js +346 -0
- package/dist/agent-contract.d.ts +65 -0
- package/dist/agent-contract.d.ts.map +1 -0
- package/dist/agent-contract.js +555 -0
- package/dist/agent-handoff.d.ts +123 -0
- package/dist/agent-handoff.d.ts.map +1 -0
- package/dist/agent-handoff.js +470 -0
- package/dist/agent-instructions.d.ts +2 -0
- package/dist/agent-instructions.d.ts.map +1 -0
- package/dist/agent-instructions.js +21 -0
- package/dist/agent-orchestration.d.ts +61 -0
- package/dist/agent-orchestration.d.ts.map +1 -0
- package/dist/agent-orchestration.js +285 -0
- package/dist/agent-task-prep.d.ts +31 -0
- package/dist/agent-task-prep.d.ts.map +1 -0
- package/dist/agent-task-prep.js +73 -0
- package/dist/ai-readiness.d.ts +30 -0
- package/dist/ai-readiness.d.ts.map +1 -0
- package/dist/ai-readiness.js +279 -0
- package/dist/api-report.d.ts +51 -0
- package/dist/api-report.d.ts.map +1 -0
- package/dist/api-report.js +254 -0
- package/dist/apply-dispatch-trace.d.ts +93 -0
- package/dist/apply-dispatch-trace.d.ts.map +1 -0
- package/dist/apply-dispatch-trace.js +283 -0
- package/dist/apply-gate-result.d.ts +52 -0
- package/dist/apply-gate-result.d.ts.map +1 -0
- package/dist/apply-gate-result.js +44 -0
- package/dist/architecture-map.d.ts +118 -0
- package/dist/architecture-map.d.ts.map +1 -0
- package/dist/architecture-map.js +543 -0
- package/dist/area-explore.d.ts +75 -0
- package/dist/area-explore.d.ts.map +1 -0
- package/dist/area-explore.js +438 -0
- package/dist/area-map.d.ts +57 -0
- package/dist/area-map.d.ts.map +1 -0
- package/dist/area-map.js +214 -0
- package/dist/asset-provenance.d.ts +123 -0
- package/dist/asset-provenance.d.ts.map +1 -0
- package/dist/asset-provenance.js +209 -0
- package/dist/barrel-operations.d.ts +45 -0
- package/dist/barrel-operations.d.ts.map +1 -0
- package/dist/barrel-operations.js +159 -0
- package/dist/boundaries-changed-only.d.ts +62 -0
- package/dist/boundaries-changed-only.d.ts.map +1 -0
- package/dist/boundaries-changed-only.js +97 -0
- package/dist/boundary-suggestions.d.ts +20 -0
- package/dist/boundary-suggestions.d.ts.map +1 -0
- package/dist/boundary-suggestions.js +51 -0
- package/dist/bundle-diff.d.ts +98 -0
- package/dist/bundle-diff.d.ts.map +1 -0
- package/dist/bundle-diff.js +531 -0
- package/dist/bundle-replay.d.ts +68 -0
- package/dist/bundle-replay.d.ts.map +1 -0
- package/dist/bundle-replay.js +273 -0
- package/dist/bundle-validate-html.d.ts +11 -0
- package/dist/bundle-validate-html.d.ts.map +1 -0
- package/dist/bundle-validate-html.js +60 -0
- package/dist/change-intent.d.ts +36 -0
- package/dist/change-intent.d.ts.map +1 -0
- package/dist/change-intent.js +259 -0
- package/dist/changed-preflight.d.ts +59 -0
- package/dist/changed-preflight.d.ts.map +1 -0
- package/dist/changed-preflight.js +358 -0
- package/dist/changed-scope.d.ts +112 -0
- package/dist/changed-scope.d.ts.map +1 -0
- package/dist/changed-scope.js +172 -0
- package/dist/changes-summary.d.ts +87 -0
- package/dist/changes-summary.d.ts.map +1 -0
- package/dist/changes-summary.js +323 -0
- package/dist/check-result-v1.d.ts +90 -0
- package/dist/check-result-v1.d.ts.map +1 -0
- package/dist/check-result-v1.js +335 -0
- package/dist/ci-integrity-report.d.ts +38 -0
- package/dist/ci-integrity-report.d.ts.map +1 -0
- package/dist/ci-integrity-report.js +324 -0
- package/dist/ci-permissions-fix.d.ts +38 -0
- package/dist/ci-permissions-fix.d.ts.map +1 -0
- package/dist/ci-permissions-fix.js +382 -0
- package/dist/ci-permissions.d.ts +51 -0
- package/dist/ci-permissions.d.ts.map +1 -0
- package/dist/ci-permissions.js +431 -0
- package/dist/ci-predict.d.ts +42 -0
- package/dist/ci-predict.d.ts.map +1 -0
- package/dist/ci-predict.js +300 -0
- package/dist/ci-scaffold.d.ts +47 -0
- package/dist/ci-scaffold.d.ts.map +1 -0
- package/dist/ci-scaffold.js +638 -0
- package/dist/codemod-assist.d.ts +97 -0
- package/dist/codemod-assist.d.ts.map +1 -0
- package/dist/codemod-assist.js +261 -0
- package/dist/command-recommender.d.ts +25 -0
- package/dist/command-recommender.d.ts.map +1 -0
- package/dist/command-recommender.js +145 -0
- package/dist/command-suggester.d.ts +61 -0
- package/dist/command-suggester.d.ts.map +1 -0
- package/dist/command-suggester.js +159 -0
- package/dist/command-taxonomy.d.ts +38 -0
- package/dist/command-taxonomy.d.ts.map +1 -0
- package/dist/command-taxonomy.js +164 -0
- package/dist/compliance-evidence.d.ts +58 -0
- package/dist/compliance-evidence.d.ts.map +1 -0
- package/dist/compliance-evidence.js +260 -0
- package/dist/compliance-profiles.d.ts +42 -0
- package/dist/compliance-profiles.d.ts.map +1 -0
- package/dist/compliance-profiles.js +171 -0
- package/dist/construct-adoption-diff.d.ts +55 -0
- package/dist/construct-adoption-diff.d.ts.map +1 -0
- package/dist/construct-adoption-diff.js +331 -0
- package/dist/construct-adoption.d.ts +71 -0
- package/dist/construct-adoption.d.ts.map +1 -0
- package/dist/construct-adoption.js +331 -0
- package/dist/construct-inference.d.ts +44 -0
- package/dist/construct-inference.d.ts.map +1 -0
- package/dist/construct-inference.js +391 -0
- package/dist/construct-registry.d.ts +32 -0
- package/dist/construct-registry.d.ts.map +1 -0
- package/dist/construct-registry.js +198 -0
- package/dist/contract-file-rule.d.ts +37 -0
- package/dist/contract-file-rule.d.ts.map +1 -0
- package/dist/contract-file-rule.js +99 -0
- package/dist/contract-template-registry.d.ts +28 -0
- package/dist/contract-template-registry.d.ts.map +1 -0
- package/dist/contract-template-registry.js +161 -0
- package/dist/contradictions.d.ts +52 -0
- package/dist/contradictions.d.ts.map +1 -0
- package/dist/contradictions.js +391 -0
- package/dist/convention-registry.d.ts +44 -0
- package/dist/convention-registry.d.ts.map +1 -0
- package/dist/convention-registry.js +195 -0
- package/dist/coverage-report.d.ts +25 -0
- package/dist/coverage-report.d.ts.map +1 -0
- package/dist/coverage-report.js +190 -0
- package/dist/custom-checks.d.ts +146 -0
- package/dist/custom-checks.d.ts.map +1 -0
- package/dist/custom-checks.js +260 -0
- package/dist/dashboard/dashboard-data.d.ts +59 -0
- package/dist/dashboard/dashboard-data.d.ts.map +1 -0
- package/dist/dashboard/dashboard-data.js +653 -0
- package/dist/dashboard-export.d.ts +67 -0
- package/dist/dashboard-export.d.ts.map +1 -0
- package/dist/dashboard-export.js +203 -0
- package/dist/decision-records.d.ts +47 -0
- package/dist/decision-records.d.ts.map +1 -0
- package/dist/decision-records.js +255 -0
- package/dist/demo-package.d.ts +49 -0
- package/dist/demo-package.d.ts.map +1 -0
- package/dist/demo-package.js +305 -0
- package/dist/demo-script.d.ts +25 -0
- package/dist/demo-script.d.ts.map +1 -0
- package/dist/demo-script.js +198 -0
- package/dist/demo-workflow.d.ts +28 -0
- package/dist/demo-workflow.d.ts.map +1 -0
- package/dist/demo-workflow.js +178 -0
- package/dist/dev-cycle.d.ts +41 -0
- package/dist/dev-cycle.d.ts.map +1 -0
- package/dist/dev-cycle.js +94 -0
- package/dist/dev-session-html.d.ts +13 -0
- package/dist/dev-session-html.d.ts.map +1 -0
- package/dist/dev-session-html.js +223 -0
- package/dist/dev-session-report.d.ts +11 -0
- package/dist/dev-session-report.d.ts.map +1 -0
- package/dist/dev-session-report.js +206 -0
- package/dist/dev-session.d.ts +257 -0
- package/dist/dev-session.d.ts.map +1 -0
- package/dist/dev-session.js +568 -0
- package/dist/diagnostics-suggest.d.ts +17 -0
- package/dist/diagnostics-suggest.d.ts.map +1 -0
- package/dist/diagnostics-suggest.js +69 -0
- package/dist/docs-check.d.ts +40 -0
- package/dist/docs-check.d.ts.map +1 -0
- package/dist/docs-check.js +221 -0
- package/dist/doctor-acknowledgements.d.ts +69 -0
- package/dist/doctor-acknowledgements.d.ts.map +1 -0
- package/dist/doctor-acknowledgements.js +150 -0
- package/dist/doctor-result.d.ts +51 -0
- package/dist/doctor-result.d.ts.map +1 -0
- package/dist/doctor-result.js +7 -0
- package/dist/doctor-suppressions.d.ts +91 -0
- package/dist/doctor-suppressions.d.ts.map +1 -0
- package/dist/doctor-suppressions.js +238 -0
- package/dist/drift-baseline.d.ts +29 -0
- package/dist/drift-baseline.d.ts.map +1 -0
- package/dist/drift-baseline.js +80 -0
- package/dist/drift.d.ts +38 -0
- package/dist/drift.d.ts.map +1 -0
- package/dist/drift.js +107 -0
- package/dist/entrypoint-matrix.d.ts +61 -0
- package/dist/entrypoint-matrix.d.ts.map +1 -0
- package/dist/entrypoint-matrix.js +221 -0
- package/dist/examples-check.d.ts +36 -0
- package/dist/examples-check.d.ts.map +1 -0
- package/dist/examples-check.js +168 -0
- package/dist/execution-graph.d.ts +98 -0
- package/dist/execution-graph.d.ts.map +1 -0
- package/dist/execution-graph.js +484 -0
- package/dist/export-bundle.d.ts +10 -0
- package/dist/export-bundle.d.ts.map +1 -0
- package/dist/export-bundle.js +90 -0
- package/dist/failure-diagnostics.d.ts +63 -0
- package/dist/failure-diagnostics.d.ts.map +1 -0
- package/dist/failure-diagnostics.js +243 -0
- package/dist/feature-bundle.d.ts +111 -0
- package/dist/feature-bundle.d.ts.map +1 -0
- package/dist/feature-bundle.js +211 -0
- package/dist/feedback-actions-v2.d.ts +65 -0
- package/dist/feedback-actions-v2.d.ts.map +1 -0
- package/dist/feedback-actions-v2.js +183 -0
- package/dist/feedback-ingestion.d.ts +96 -0
- package/dist/feedback-ingestion.d.ts.map +1 -0
- package/dist/feedback-ingestion.js +400 -0
- package/dist/fix-preview.d.ts +82 -0
- package/dist/fix-preview.d.ts.map +1 -0
- package/dist/fix-preview.js +365 -0
- package/dist/fuzzy-impact.d.ts +50 -0
- package/dist/fuzzy-impact.d.ts.map +1 -0
- package/dist/fuzzy-impact.js +446 -0
- package/dist/generated-code.d.ts +97 -0
- package/dist/generated-code.d.ts.map +1 -0
- package/dist/generated-code.js +395 -0
- package/dist/git-helpers.d.ts +38 -0
- package/dist/git-helpers.d.ts.map +1 -0
- package/dist/git-helpers.js +173 -0
- package/dist/golden-output.d.ts +33 -0
- package/dist/golden-output.d.ts.map +1 -0
- package/dist/golden-output.js +92 -0
- package/dist/grounding/build-grounding.d.ts +53 -0
- package/dist/grounding/build-grounding.d.ts.map +1 -0
- package/dist/grounding/build-grounding.js +51 -0
- package/dist/grounding/nx-projects.d.ts +29 -0
- package/dist/grounding/nx-projects.d.ts.map +1 -0
- package/dist/grounding/nx-projects.js +109 -0
- package/dist/grounding/validate-extracted-plan.d.ts +20 -0
- package/dist/grounding/validate-extracted-plan.d.ts.map +1 -0
- package/dist/grounding/validate-extracted-plan.js +127 -0
- package/dist/healing-plan.d.ts +33 -0
- package/dist/healing-plan.d.ts.map +1 -0
- package/dist/healing-plan.js +346 -0
- package/dist/helper-registry.d.ts +90 -0
- package/dist/helper-registry.d.ts.map +1 -0
- package/dist/helper-registry.js +529 -0
- package/dist/impact-analysis.d.ts +150 -0
- package/dist/impact-analysis.d.ts.map +1 -0
- package/dist/impact-analysis.js +697 -0
- package/dist/impact-graph-render.d.ts +51 -0
- package/dist/impact-graph-render.d.ts.map +1 -0
- package/dist/impact-graph-render.js +139 -0
- package/dist/impact-graph.d.ts +17 -0
- package/dist/impact-graph.d.ts.map +1 -0
- package/dist/impact-graph.js +119 -0
- package/dist/impact-render.d.ts +22 -0
- package/dist/impact-render.d.ts.map +1 -0
- package/dist/impact-render.js +422 -0
- package/dist/import-graph-analysis.d.ts +28 -0
- package/dist/import-graph-analysis.d.ts.map +1 -0
- package/dist/import-graph-analysis.js +193 -0
- package/dist/import-hygiene.d.ts +93 -0
- package/dist/import-hygiene.d.ts.map +1 -0
- package/dist/import-hygiene.js +366 -0
- package/dist/index.d.ts +224 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +234 -0
- package/dist/ingest-adoption.d.ts +50 -0
- package/dist/ingest-adoption.d.ts.map +1 -0
- package/dist/ingest-adoption.js +183 -0
- package/dist/ingest-apply.d.ts +80 -0
- package/dist/ingest-apply.d.ts.map +1 -0
- package/dist/ingest-apply.js +227 -0
- package/dist/ingest-body-extractor.d.ts +28 -0
- package/dist/ingest-body-extractor.d.ts.map +1 -0
- package/dist/ingest-body-extractor.js +129 -0
- package/dist/ingest-drafts.d.ts +16 -0
- package/dist/ingest-drafts.d.ts.map +1 -0
- package/dist/ingest-drafts.js +482 -0
- package/dist/inspector-cache.d.ts +41 -0
- package/dist/inspector-cache.d.ts.map +1 -0
- package/dist/inspector-cache.js +104 -0
- package/dist/install-smoke.d.ts +44 -0
- package/dist/install-smoke.d.ts.map +1 -0
- package/dist/install-smoke.js +31 -0
- package/dist/knowledge-authoring.d.ts +151 -0
- package/dist/knowledge-authoring.d.ts.map +1 -0
- package/dist/knowledge-authoring.js +586 -0
- package/dist/knowledge-graph.d.ts +76 -0
- package/dist/knowledge-graph.d.ts.map +1 -0
- package/dist/knowledge-graph.js +336 -0
- package/dist/knowledge-lint.d.ts +97 -0
- package/dist/knowledge-lint.d.ts.map +1 -0
- package/dist/knowledge-lint.js +302 -0
- package/dist/knowledge-rename.d.ts +38 -0
- package/dist/knowledge-rename.d.ts.map +1 -0
- package/dist/knowledge-rename.js +88 -0
- package/dist/knowledge-stale.d.ts +124 -0
- package/dist/knowledge-stale.d.ts.map +1 -0
- package/dist/knowledge-stale.js +892 -0
- package/dist/languages/command-inference.d.ts +27 -0
- package/dist/languages/command-inference.d.ts.map +1 -0
- package/dist/languages/command-inference.js +214 -0
- package/dist/languages/dependency-scan.d.ts +33 -0
- package/dist/languages/dependency-scan.d.ts.map +1 -0
- package/dist/languages/dependency-scan.js +343 -0
- package/dist/languages/index.d.ts +14 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +13 -0
- package/dist/languages/language-boundaries.d.ts +30 -0
- package/dist/languages/language-boundaries.d.ts.map +1 -0
- package/dist/languages/language-boundaries.js +176 -0
- package/dist/languages/language-cache.d.ts +54 -0
- package/dist/languages/language-cache.d.ts.map +1 -0
- package/dist/languages/language-cache.js +236 -0
- package/dist/languages/language-detection.d.ts +30 -0
- package/dist/languages/language-detection.d.ts.map +1 -0
- package/dist/languages/language-detection.js +584 -0
- package/dist/languages/language-id.d.ts +15 -0
- package/dist/languages/language-id.d.ts.map +1 -0
- package/dist/languages/language-id.js +15 -0
- package/dist/languages/language-runner.d.ts +90 -0
- package/dist/languages/language-runner.d.ts.map +1 -0
- package/dist/languages/language-runner.js +346 -0
- package/dist/languages/polyglot-boundary.d.ts +80 -0
- package/dist/languages/polyglot-boundary.d.ts.map +1 -0
- package/dist/languages/polyglot-boundary.js +373 -0
- package/dist/languages/polyglot-ci.d.ts +25 -0
- package/dist/languages/polyglot-ci.d.ts.map +1 -0
- package/dist/languages/polyglot-ci.js +278 -0
- package/dist/languages/test-impact.d.ts +19 -0
- package/dist/languages/test-impact.d.ts.map +1 -0
- package/dist/languages/test-impact.js +157 -0
- package/dist/loader-diagnostics.d.ts +40 -0
- package/dist/loader-diagnostics.d.ts.map +1 -0
- package/dist/loader-diagnostics.js +49 -0
- package/dist/memory-diff.d.ts +60 -0
- package/dist/memory-diff.d.ts.map +1 -0
- package/dist/memory-diff.js +302 -0
- package/dist/migration-profile-registry.d.ts +26 -0
- package/dist/migration-profile-registry.d.ts.map +1 -0
- package/dist/migration-profile-registry.js +135 -0
- package/dist/migration-readiness.d.ts +101 -0
- package/dist/migration-readiness.d.ts.map +1 -0
- package/dist/migration-readiness.js +253 -0
- package/dist/monorepo-onboarding.d.ts +51 -0
- package/dist/monorepo-onboarding.d.ts.map +1 -0
- package/dist/monorepo-onboarding.js +235 -0
- package/dist/onboarding-adoption-diff.d.ts +53 -0
- package/dist/onboarding-adoption-diff.d.ts.map +1 -0
- package/dist/onboarding-adoption-diff.js +285 -0
- package/dist/onboarding-adoption.d.ts +136 -0
- package/dist/onboarding-adoption.d.ts.map +1 -0
- package/dist/onboarding-adoption.js +702 -0
- package/dist/onboarding-agent-import.d.ts +40 -0
- package/dist/onboarding-agent-import.d.ts.map +1 -0
- package/dist/onboarding-agent-import.js +114 -0
- package/dist/onboarding-diff.d.ts +39 -0
- package/dist/onboarding-diff.d.ts.map +1 -0
- package/dist/onboarding-diff.js +240 -0
- package/dist/onboarding-drafts-merge.d.ts +71 -0
- package/dist/onboarding-drafts-merge.d.ts.map +1 -0
- package/dist/onboarding-drafts-merge.js +174 -0
- package/dist/onboarding-drafts.d.ts +42 -0
- package/dist/onboarding-drafts.d.ts.map +1 -0
- package/dist/onboarding-drafts.js +268 -0
- package/dist/onboarding-report.d.ts +8 -0
- package/dist/onboarding-report.d.ts.map +1 -0
- package/dist/onboarding-report.js +239 -0
- package/dist/onboarding.d.ts +134 -0
- package/dist/onboarding.d.ts.map +1 -0
- package/dist/onboarding.js +729 -0
- package/dist/ownership.d.ts +38 -0
- package/dist/ownership.d.ts.map +1 -0
- package/dist/ownership.js +102 -0
- package/dist/pack-author-ux.d.ts +58 -0
- package/dist/pack-author-ux.d.ts.map +1 -0
- package/dist/pack-author-ux.js +219 -0
- package/dist/pack-author.d.ts +94 -0
- package/dist/pack-author.d.ts.map +1 -0
- package/dist/pack-author.js +208 -0
- package/dist/pack-compatibility.d.ts +21 -0
- package/dist/pack-compatibility.d.ts.map +1 -0
- package/dist/pack-compatibility.js +114 -0
- package/dist/pack-contributions-inventory.d.ts +121 -0
- package/dist/pack-contributions-inventory.d.ts.map +1 -0
- package/dist/pack-contributions-inventory.js +732 -0
- package/dist/pack-docs.d.ts +11 -0
- package/dist/pack-docs.d.ts.map +1 -0
- package/dist/pack-docs.js +101 -0
- package/dist/pack-doctor.d.ts +50 -0
- package/dist/pack-doctor.d.ts.map +1 -0
- package/dist/pack-doctor.js +302 -0
- package/dist/pack-helper-registry.d.ts +29 -0
- package/dist/pack-helper-registry.d.ts.map +1 -0
- package/dist/pack-helper-registry.js +144 -0
- package/dist/pack-pending.d.ts +68 -0
- package/dist/pack-pending.d.ts.map +1 -0
- package/dist/pack-pending.js +189 -0
- package/dist/pack-quality-score.d.ts +44 -0
- package/dist/pack-quality-score.d.ts.map +1 -0
- package/dist/pack-quality-score.js +155 -0
- package/dist/pack-release-check.d.ts +24 -0
- package/dist/pack-release-check.d.ts.map +1 -0
- package/dist/pack-release-check.js +258 -0
- package/dist/pack-signature-status.d.ts +72 -0
- package/dist/pack-signature-status.d.ts.map +1 -0
- package/dist/pack-signature-status.js +222 -0
- package/dist/pack-symbol-compat.d.ts +73 -0
- package/dist/pack-symbol-compat.d.ts.map +1 -0
- package/dist/pack-symbol-compat.js +519 -0
- package/dist/pack-test-runner.d.ts +59 -0
- package/dist/pack-test-runner.d.ts.map +1 -0
- package/dist/pack-test-runner.js +211 -0
- package/dist/pipeline-command-dictionary.d.ts +2 -0
- package/dist/pipeline-command-dictionary.d.ts.map +1 -0
- package/dist/pipeline-command-dictionary.js +20 -0
- package/dist/pipeline-lint.d.ts +30 -0
- package/dist/pipeline-lint.d.ts.map +1 -0
- package/dist/pipeline-lint.js +134 -0
- package/dist/plan-dependency-graph.d.ts +25 -0
- package/dist/plan-dependency-graph.d.ts.map +1 -0
- package/dist/plan-dependency-graph.js +195 -0
- package/dist/plan-review.d.ts +64 -0
- package/dist/plan-review.d.ts.map +1 -0
- package/dist/plan-review.js +242 -0
- package/dist/plan-simulation.d.ts +108 -0
- package/dist/plan-simulation.d.ts.map +1 -0
- package/dist/plan-simulation.js +767 -0
- package/dist/playbook-registry.d.ts +25 -0
- package/dist/playbook-registry.d.ts.map +1 -0
- package/dist/playbook-registry.js +148 -0
- package/dist/playbook-script.d.ts +60 -0
- package/dist/playbook-script.d.ts.map +1 -0
- package/dist/playbook-script.js +161 -0
- package/dist/plugin-lifecycle-profile-registry.d.ts +52 -0
- package/dist/plugin-lifecycle-profile-registry.d.ts.map +1 -0
- package/dist/plugin-lifecycle-profile-registry.js +202 -0
- package/dist/plugin-lifecycle.d.ts +132 -0
- package/dist/plugin-lifecycle.d.ts.map +1 -0
- package/dist/plugin-lifecycle.js +477 -0
- package/dist/policy-engine.d.ts +101 -0
- package/dist/policy-engine.d.ts.map +1 -0
- package/dist/policy-engine.js +321 -0
- package/dist/policy-override-audit.d.ts +18 -0
- package/dist/policy-override-audit.d.ts.map +1 -0
- package/dist/policy-override-audit.js +54 -0
- package/dist/policy-overrides.d.ts +35 -0
- package/dist/policy-overrides.d.ts.map +1 -0
- package/dist/policy-overrides.js +84 -0
- package/dist/policy-test.d.ts +83 -0
- package/dist/policy-test.d.ts.map +1 -0
- package/dist/policy-test.js +342 -0
- package/dist/pr-summary.d.ts +34 -0
- package/dist/pr-summary.d.ts.map +1 -0
- package/dist/pr-summary.js +220 -0
- package/dist/product-coherence.d.ts +21 -0
- package/dist/product-coherence.d.ts.map +1 -0
- package/dist/product-coherence.js +158 -0
- package/dist/profile-registry.d.ts +42 -0
- package/dist/profile-registry.d.ts.map +1 -0
- package/dist/profile-registry.js +104 -0
- package/dist/project-coupling-audit.d.ts +64 -0
- package/dist/project-coupling-audit.d.ts.map +1 -0
- package/dist/project-coupling-audit.js +282 -0
- package/dist/project-overview.d.ts +14 -0
- package/dist/project-overview.d.ts.map +1 -0
- package/dist/project-overview.js +27 -0
- package/dist/propose-knowledge.d.ts +64 -0
- package/dist/propose-knowledge.d.ts.map +1 -0
- package/dist/propose-knowledge.js +367 -0
- package/dist/quality-baseline.d.ts +123 -0
- package/dist/quality-baseline.d.ts.map +1 -0
- package/dist/quality-baseline.js +433 -0
- package/dist/quality-html.d.ts +7 -0
- package/dist/quality-html.d.ts.map +1 -0
- package/dist/quality-html.js +64 -0
- package/dist/quality-report.d.ts +49 -0
- package/dist/quality-report.d.ts.map +1 -0
- package/dist/quality-report.js +296 -0
- package/dist/query-resolver.d.ts +38 -0
- package/dist/query-resolver.d.ts.map +1 -0
- package/dist/query-resolver.js +163 -0
- package/dist/ranker-explainability.d.ts +91 -0
- package/dist/ranker-explainability.d.ts.map +1 -0
- package/dist/ranker-explainability.js +550 -0
- package/dist/reference-lookup.d.ts +8 -0
- package/dist/reference-lookup.d.ts.map +1 -0
- package/dist/reference-lookup.js +18 -0
- package/dist/registration-hint-registry.d.ts +55 -0
- package/dist/registration-hint-registry.d.ts.map +1 -0
- package/dist/registration-hint-registry.js +327 -0
- package/dist/registry-lifecycle.d.ts +47 -0
- package/dist/registry-lifecycle.d.ts.map +1 -0
- package/dist/registry-lifecycle.js +214 -0
- package/dist/release-readiness.d.ts +64 -0
- package/dist/release-readiness.d.ts.map +1 -0
- package/dist/release-readiness.js +456 -0
- package/dist/release-smoke.d.ts +138 -0
- package/dist/release-smoke.d.ts.map +1 -0
- package/dist/release-smoke.js +459 -0
- package/dist/release-train.d.ts +33 -0
- package/dist/release-train.d.ts.map +1 -0
- package/dist/release-train.js +104 -0
- package/dist/repo-memory.d.ts +95 -0
- package/dist/repo-memory.d.ts.map +1 -0
- package/dist/repo-memory.js +614 -0
- package/dist/report-site.d.ts +92 -0
- package/dist/report-site.d.ts.map +1 -0
- package/dist/report-site.js +658 -0
- package/dist/reposet.d.ts +56 -0
- package/dist/reposet.d.ts.map +1 -0
- package/dist/reposet.js +160 -0
- package/dist/repository-intelligence.d.ts +145 -0
- package/dist/repository-intelligence.d.ts.map +1 -0
- package/dist/repository-intelligence.js +729 -0
- package/dist/repository-knowledge-model.d.ts +218 -0
- package/dist/repository-knowledge-model.d.ts.map +1 -0
- package/dist/repository-knowledge-model.js +939 -0
- package/dist/repository-map.d.ts +72 -0
- package/dist/repository-map.d.ts.map +1 -0
- package/dist/repository-map.js +332 -0
- package/dist/repository-stats.d.ts +66 -0
- package/dist/repository-stats.d.ts.map +1 -0
- package/dist/repository-stats.js +329 -0
- package/dist/review-comment-renderer.d.ts +59 -0
- package/dist/review-comment-renderer.d.ts.map +1 -0
- package/dist/review-comment-renderer.js +181 -0
- package/dist/review-comment-v2.d.ts +9 -0
- package/dist/review-comment-v2.d.ts.map +1 -0
- package/dist/review-comment-v2.js +178 -0
- package/dist/review-html.d.ts +13 -0
- package/dist/review-html.d.ts.map +1 -0
- package/dist/review-html.js +79 -0
- package/dist/review-packet-v2.d.ts +29 -0
- package/dist/review-packet-v2.d.ts.map +1 -0
- package/dist/review-packet-v2.js +81 -0
- package/dist/review-packet-v3.d.ts +22 -0
- package/dist/review-packet-v3.d.ts.map +1 -0
- package/dist/review-packet-v3.js +181 -0
- package/dist/review-packet.d.ts +49 -0
- package/dist/review-packet.d.ts.map +1 -0
- package/dist/review-packet.js +129 -0
- package/dist/risk-signals.d.ts +28 -0
- package/dist/risk-signals.d.ts.map +1 -0
- package/dist/risk-signals.js +68 -0
- package/dist/role-views.d.ts +50 -0
- package/dist/role-views.d.ts.map +1 -0
- package/dist/role-views.js +334 -0
- package/dist/rounds.d.ts +52 -0
- package/dist/rounds.d.ts.map +1 -0
- package/dist/rounds.js +172 -0
- package/dist/rule-drift.d.ts +42 -0
- package/dist/rule-drift.d.ts.map +1 -0
- package/dist/rule-drift.js +148 -0
- package/dist/rule-quality.d.ts +73 -0
- package/dist/rule-quality.d.ts.map +1 -0
- package/dist/rule-quality.js +356 -0
- package/dist/rule-scaffold.d.ts +71 -0
- package/dist/rule-scaffold.d.ts.map +1 -0
- package/dist/rule-scaffold.js +258 -0
- package/dist/safety-audit-deep.d.ts +38 -0
- package/dist/safety-audit-deep.d.ts.map +1 -0
- package/dist/safety-audit-deep.js +162 -0
- package/dist/safety-audit.d.ts +91 -0
- package/dist/safety-audit.d.ts.map +1 -0
- package/dist/safety-audit.js +138 -0
- package/dist/safety-html.d.ts +7 -0
- package/dist/safety-html.d.ts.map +1 -0
- package/dist/safety-html.js +70 -0
- package/dist/scaffold-coverage.d.ts +46 -0
- package/dist/scaffold-coverage.d.ts.map +1 -0
- package/dist/scaffold-coverage.js +273 -0
- package/dist/scaffold-patterns.d.ts +38 -0
- package/dist/scaffold-patterns.d.ts.map +1 -0
- package/dist/scaffold-patterns.js +282 -0
- package/dist/schema-inventory.d.ts +55 -0
- package/dist/schema-inventory.d.ts.map +1 -0
- package/dist/schema-inventory.js +301 -0
- package/dist/search-index.d.ts +75 -0
- package/dist/search-index.d.ts.map +1 -0
- package/dist/search-index.js +531 -0
- package/dist/search-tuning-explain.d.ts +68 -0
- package/dist/search-tuning-explain.d.ts.map +1 -0
- package/dist/search-tuning-explain.js +207 -0
- package/dist/search-tuning-registry.d.ts +54 -0
- package/dist/search-tuning-registry.d.ts.map +1 -0
- package/dist/search-tuning-registry.js +303 -0
- package/dist/self-audit.d.ts +59 -0
- package/dist/self-audit.d.ts.map +1 -0
- package/dist/self-audit.js +192 -0
- package/dist/self-config-doctor-v2.d.ts +57 -0
- package/dist/self-config-doctor-v2.d.ts.map +1 -0
- package/dist/self-config-doctor-v2.js +653 -0
- package/dist/self-config-doctor.d.ts +47 -0
- package/dist/self-config-doctor.d.ts.map +1 -0
- package/dist/self-config-doctor.js +432 -0
- package/dist/sharkcraft-inspector.d.ts +73 -0
- package/dist/sharkcraft-inspector.d.ts.map +1 -0
- package/dist/sharkcraft-inspector.js +745 -0
- package/dist/spec/spec-cross-validate.d.ts +17 -0
- package/dist/spec/spec-cross-validate.d.ts.map +1 -0
- package/dist/spec/spec-cross-validate.js +53 -0
- package/dist/spec/spec-discovery.d.ts +27 -0
- package/dist/spec/spec-discovery.d.ts.map +1 -0
- package/dist/spec/spec-discovery.js +78 -0
- package/dist/spec/spec-review.d.ts +36 -0
- package/dist/spec/spec-review.d.ts.map +1 -0
- package/dist/spec/spec-review.js +37 -0
- package/dist/stability-map.d.ts +62 -0
- package/dist/stability-map.d.ts.map +1 -0
- package/dist/stability-map.js +404 -0
- package/dist/start-here.d.ts +49 -0
- package/dist/start-here.d.ts.map +1 -0
- package/dist/start-here.js +259 -0
- package/dist/surface-profile-detect.d.ts +42 -0
- package/dist/surface-profile-detect.d.ts.map +1 -0
- package/dist/surface-profile-detect.js +76 -0
- package/dist/symbol-index.d.ts +108 -0
- package/dist/symbol-index.d.ts.map +1 -0
- package/dist/symbol-index.js +483 -0
- package/dist/task-decompose.d.ts +38 -0
- package/dist/task-decompose.d.ts.map +1 -0
- package/dist/task-decompose.js +154 -0
- package/dist/task-packet.d.ts +104 -0
- package/dist/task-packet.d.ts.map +1 -0
- package/dist/task-packet.js +156 -0
- package/dist/task-ranker.d.ts +51 -0
- package/dist/task-ranker.d.ts.map +1 -0
- package/dist/task-ranker.js +410 -0
- package/dist/task-risk.d.ts +84 -0
- package/dist/task-risk.d.ts.map +1 -0
- package/dist/task-risk.js +731 -0
- package/dist/task-routing-hint-registry.d.ts +36 -0
- package/dist/task-routing-hint-registry.d.ts.map +1 -0
- package/dist/task-routing-hint-registry.js +186 -0
- package/dist/template-authoring.d.ts +113 -0
- package/dist/template-authoring.d.ts.map +1 -0
- package/dist/template-authoring.js +521 -0
- package/dist/template-body-inference-v2.d.ts +19 -0
- package/dist/template-body-inference-v2.d.ts.map +1 -0
- package/dist/template-body-inference-v2.js +468 -0
- package/dist/template-body-inference.d.ts +59 -0
- package/dist/template-body-inference.d.ts.map +1 -0
- package/dist/template-body-inference.js +277 -0
- package/dist/template-drift.d.ts +39 -0
- package/dist/template-drift.d.ts.map +1 -0
- package/dist/template-drift.js +353 -0
- package/dist/template-lint.d.ts +31 -0
- package/dist/template-lint.d.ts.map +1 -0
- package/dist/template-lint.js +113 -0
- package/dist/test-definitions.d.ts +41 -0
- package/dist/test-definitions.d.ts.map +1 -0
- package/dist/test-definitions.js +6 -0
- package/dist/test-impact.d.ts +30 -0
- package/dist/test-impact.d.ts.map +1 -0
- package/dist/test-impact.js +173 -0
- package/dist/test-runner.d.ts +87 -0
- package/dist/test-runner.d.ts.map +1 -0
- package/dist/test-runner.js +560 -0
- package/dist/uncertainty-report.d.ts +46 -0
- package/dist/uncertainty-report.d.ts.map +1 -0
- package/dist/uncertainty-report.js +108 -0
- package/dist/uncertainty.d.ts +38 -0
- package/dist/uncertainty.d.ts.map +1 -0
- package/dist/uncertainty.js +115 -0
- package/dist/universal-search.d.ts +64 -0
- package/dist/universal-search.d.ts.map +1 -0
- package/dist/universal-search.js +347 -0
- package/dist/upgrade-advisor.d.ts +22 -0
- package/dist/upgrade-advisor.d.ts.map +1 -0
- package/dist/upgrade-advisor.js +109 -0
- package/dist/why-file.d.ts +75 -0
- package/dist/why-file.d.ts.map +1 -0
- package/dist/why-file.js +202 -0
- package/dist/workflow-simulation.d.ts +46 -0
- package/dist/workflow-simulation.d.ts.map +1 -0
- package/dist/workflow-simulation.js +154 -0
- package/package.json +65 -0
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import * as nodePath from 'node:path';
|
|
4
|
+
import { buildAdoptionState, readAdoptionState, writeAdoptionState } from "./adoption-state.js";
|
|
5
|
+
export var AdoptionCategory;
|
|
6
|
+
(function (AdoptionCategory) {
|
|
7
|
+
AdoptionCategory["SafeToAdopt"] = "safe-to-adopt";
|
|
8
|
+
AdoptionCategory["ManualReview"] = "manual-review";
|
|
9
|
+
AdoptionCategory["LowConfidence"] = "low-confidence";
|
|
10
|
+
AdoptionCategory["Conflict"] = "conflict";
|
|
11
|
+
AdoptionCategory["AlreadyCovered"] = "already-covered";
|
|
12
|
+
AdoptionCategory["Skipped"] = "skipped";
|
|
13
|
+
})(AdoptionCategory || (AdoptionCategory = {}));
|
|
14
|
+
export var AdoptionKind;
|
|
15
|
+
(function (AdoptionKind) {
|
|
16
|
+
AdoptionKind["Rule"] = "rule";
|
|
17
|
+
AdoptionKind["Path"] = "path";
|
|
18
|
+
AdoptionKind["Verification"] = "verification";
|
|
19
|
+
AdoptionKind["Template"] = "template";
|
|
20
|
+
AdoptionKind["Boundary"] = "boundary";
|
|
21
|
+
AdoptionKind["Pipeline"] = "pipeline";
|
|
22
|
+
})(AdoptionKind || (AdoptionKind = {}));
|
|
23
|
+
const ALL_KINDS = [
|
|
24
|
+
AdoptionKind.Rule,
|
|
25
|
+
AdoptionKind.Path,
|
|
26
|
+
AdoptionKind.Verification,
|
|
27
|
+
AdoptionKind.Template,
|
|
28
|
+
AdoptionKind.Boundary,
|
|
29
|
+
AdoptionKind.Pipeline,
|
|
30
|
+
];
|
|
31
|
+
const DEFAULT_KINDS = [
|
|
32
|
+
AdoptionKind.Rule,
|
|
33
|
+
AdoptionKind.Path,
|
|
34
|
+
AdoptionKind.Verification,
|
|
35
|
+
AdoptionKind.Pipeline,
|
|
36
|
+
];
|
|
37
|
+
function emptySummary() {
|
|
38
|
+
return {
|
|
39
|
+
[AdoptionCategory.SafeToAdopt]: 0,
|
|
40
|
+
[AdoptionCategory.ManualReview]: 0,
|
|
41
|
+
[AdoptionCategory.LowConfidence]: 0,
|
|
42
|
+
[AdoptionCategory.Conflict]: 0,
|
|
43
|
+
[AdoptionCategory.AlreadyCovered]: 0,
|
|
44
|
+
[AdoptionCategory.Skipped]: 0,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function emptyByCategory() {
|
|
48
|
+
return {
|
|
49
|
+
[AdoptionCategory.SafeToAdopt]: [],
|
|
50
|
+
[AdoptionCategory.ManualReview]: [],
|
|
51
|
+
[AdoptionCategory.LowConfidence]: [],
|
|
52
|
+
[AdoptionCategory.Conflict]: [],
|
|
53
|
+
[AdoptionCategory.AlreadyCovered]: [],
|
|
54
|
+
[AdoptionCategory.Skipped]: [],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function thresholdConfidence(input) {
|
|
58
|
+
if (input === 'high')
|
|
59
|
+
return { allow: new Set(['high']) };
|
|
60
|
+
if (input === 'medium')
|
|
61
|
+
return { allow: new Set(['high', 'medium']) };
|
|
62
|
+
return { allow: new Set(['high', 'medium', 'low']) };
|
|
63
|
+
}
|
|
64
|
+
function classifyRule(r, inspection) {
|
|
65
|
+
const existing = inspection.ruleService.get(r.id);
|
|
66
|
+
if (existing) {
|
|
67
|
+
return { category: AdoptionCategory.AlreadyCovered, reason: 'rule id already registered' };
|
|
68
|
+
}
|
|
69
|
+
if (r.source === 'agents-md') {
|
|
70
|
+
return {
|
|
71
|
+
category: AdoptionCategory.ManualReview,
|
|
72
|
+
reason: 'imported from AGENTS.md / CLAUDE.md — review wording before adoption',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (r.priority === 'critical' || r.priority === 'high') {
|
|
76
|
+
return { category: AdoptionCategory.SafeToAdopt, reason: `inferred from ${r.source}` };
|
|
77
|
+
}
|
|
78
|
+
if (r.priority === 'medium') {
|
|
79
|
+
return { category: AdoptionCategory.ManualReview, reason: 'medium-priority inference' };
|
|
80
|
+
}
|
|
81
|
+
return { category: AdoptionCategory.LowConfidence, reason: 'low-priority inference' };
|
|
82
|
+
}
|
|
83
|
+
function classifyPath(p, inspection) {
|
|
84
|
+
if (inspection.pathService.get(p.id)) {
|
|
85
|
+
return { category: AdoptionCategory.AlreadyCovered, reason: 'path id already registered' };
|
|
86
|
+
}
|
|
87
|
+
return { category: AdoptionCategory.SafeToAdopt, reason: 'path convention not yet defined' };
|
|
88
|
+
}
|
|
89
|
+
function classifyVerification(v, inspection) {
|
|
90
|
+
const registered = inspection.config?.verificationCommands ?? [];
|
|
91
|
+
if (registered.some((c) => c.id === v.id)) {
|
|
92
|
+
return { category: AdoptionCategory.AlreadyCovered, reason: 'verification id already registered' };
|
|
93
|
+
}
|
|
94
|
+
if (!v.trusted) {
|
|
95
|
+
return {
|
|
96
|
+
category: AdoptionCategory.ManualReview,
|
|
97
|
+
reason: 'verification command not marked trusted — review before opt-in',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return { category: AdoptionCategory.SafeToAdopt, reason: 'trusted verification' };
|
|
101
|
+
}
|
|
102
|
+
function classifyTemplate(t, inspection) {
|
|
103
|
+
if (inspection.templateRegistry.get(t.id)) {
|
|
104
|
+
return { category: AdoptionCategory.AlreadyCovered, reason: 'template id already registered' };
|
|
105
|
+
}
|
|
106
|
+
if (t.confidence === 'high' && t.scaffold) {
|
|
107
|
+
return { category: AdoptionCategory.SafeToAdopt, reason: 'high-confidence runnable scaffold' };
|
|
108
|
+
}
|
|
109
|
+
if (t.confidence === 'high' || t.confidence === 'medium') {
|
|
110
|
+
return {
|
|
111
|
+
category: AdoptionCategory.ManualReview,
|
|
112
|
+
reason: 'template body must be reviewed — generated drafts may need edits',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return { category: AdoptionCategory.LowConfidence, reason: 'low-confidence template candidate' };
|
|
116
|
+
}
|
|
117
|
+
function classifyBoundary(b, inspection) {
|
|
118
|
+
if (inspection.boundaryRegistry.list().some((r) => r.id === b.id)) {
|
|
119
|
+
return { category: AdoptionCategory.AlreadyCovered, reason: 'boundary id already registered' };
|
|
120
|
+
}
|
|
121
|
+
if (b.severity === 'error') {
|
|
122
|
+
return {
|
|
123
|
+
category: AdoptionCategory.ManualReview,
|
|
124
|
+
reason: 'error-severity boundary rules need explicit review before adoption',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return { category: AdoptionCategory.SafeToAdopt, reason: 'warning-severity boundary' };
|
|
128
|
+
}
|
|
129
|
+
function classifyPipeline(p, inspection) {
|
|
130
|
+
if (inspection.pipelineRegistry.get(p.id)) {
|
|
131
|
+
return { category: AdoptionCategory.AlreadyCovered, reason: 'pipeline id already registered' };
|
|
132
|
+
}
|
|
133
|
+
return { category: AdoptionCategory.SafeToAdopt, reason: 'pipeline not yet defined' };
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Build an adoption plan from an onboarding plan. Pure: no IO. The plan
|
|
137
|
+
* classifies every inferred item into one of the AdoptionCategory buckets and
|
|
138
|
+
* records the threshold/include/exclude inputs so it's reproducible.
|
|
139
|
+
*/
|
|
140
|
+
export function buildOnboardingAdoptionPlan(input) {
|
|
141
|
+
const confidence = input.confidence ?? 'high';
|
|
142
|
+
const threshold = thresholdConfidence(confidence);
|
|
143
|
+
const include = input.include && input.include.length > 0 ? input.include : DEFAULT_KINDS;
|
|
144
|
+
const exclude = input.exclude ?? [];
|
|
145
|
+
const enabled = new Set(include);
|
|
146
|
+
for (const e of exclude)
|
|
147
|
+
enabled.delete(e);
|
|
148
|
+
const treatImportedAsManual = input.treatImportedAgentRulesAsManualReview ?? true;
|
|
149
|
+
const items = [];
|
|
150
|
+
const onb = input.plan;
|
|
151
|
+
const pushItem = (item) => {
|
|
152
|
+
items.push(item);
|
|
153
|
+
};
|
|
154
|
+
if (enabled.has(AdoptionKind.Rule)) {
|
|
155
|
+
for (const r of onb.inferredRules) {
|
|
156
|
+
let { category, reason } = classifyRule(r, input.inspection);
|
|
157
|
+
// Hard guard: imported agent rules → manual-review unless user lowered the bar.
|
|
158
|
+
if (treatImportedAsManual && r.source === 'agents-md') {
|
|
159
|
+
category = AdoptionCategory.ManualReview;
|
|
160
|
+
reason = 'imported from AGENTS.md / CLAUDE.md — manual review';
|
|
161
|
+
}
|
|
162
|
+
// Confidence threshold downgrade — if the item's confidence is below the
|
|
163
|
+
// user-selected threshold, demote to low-confidence.
|
|
164
|
+
const fakeConf = r.priority === 'critical' || r.priority === 'high' ? 'high' : r.priority === 'medium' ? 'medium' : 'low';
|
|
165
|
+
if (!threshold.allow.has(fakeConf) && category === AdoptionCategory.SafeToAdopt) {
|
|
166
|
+
category = AdoptionCategory.LowConfidence;
|
|
167
|
+
reason = `below confidence threshold (${fakeConf} < ${confidence})`;
|
|
168
|
+
}
|
|
169
|
+
pushItem({
|
|
170
|
+
kind: AdoptionKind.Rule,
|
|
171
|
+
id: r.id,
|
|
172
|
+
title: r.title,
|
|
173
|
+
category,
|
|
174
|
+
reason,
|
|
175
|
+
draftFile: 'inferred-rules.draft.ts',
|
|
176
|
+
preview: r.title,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (enabled.has(AdoptionKind.Path)) {
|
|
181
|
+
for (const p of onb.inferredPathConventions) {
|
|
182
|
+
const { category, reason } = classifyPath(p, input.inspection);
|
|
183
|
+
pushItem({
|
|
184
|
+
kind: AdoptionKind.Path,
|
|
185
|
+
id: p.id,
|
|
186
|
+
title: p.title,
|
|
187
|
+
category,
|
|
188
|
+
reason,
|
|
189
|
+
draftFile: 'inferred-paths.draft.ts',
|
|
190
|
+
preview: p.title,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (enabled.has(AdoptionKind.Verification)) {
|
|
195
|
+
for (const v of onb.inferredVerificationCommands) {
|
|
196
|
+
const { category, reason } = classifyVerification(v, input.inspection);
|
|
197
|
+
pushItem({
|
|
198
|
+
kind: AdoptionKind.Verification,
|
|
199
|
+
id: v.id,
|
|
200
|
+
title: v.label,
|
|
201
|
+
category,
|
|
202
|
+
reason,
|
|
203
|
+
draftFile: 'onboarding-report.md',
|
|
204
|
+
preview: v.command,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (enabled.has(AdoptionKind.Template)) {
|
|
209
|
+
for (const t of onb.inferredTemplateCandidates) {
|
|
210
|
+
let { category, reason } = classifyTemplate(t, input.inspection);
|
|
211
|
+
if (!threshold.allow.has(t.confidence) && category === AdoptionCategory.SafeToAdopt) {
|
|
212
|
+
category = AdoptionCategory.LowConfidence;
|
|
213
|
+
reason = `below confidence threshold (${t.confidence} < ${confidence})`;
|
|
214
|
+
}
|
|
215
|
+
pushItem({
|
|
216
|
+
kind: AdoptionKind.Template,
|
|
217
|
+
id: t.id,
|
|
218
|
+
title: t.name,
|
|
219
|
+
category,
|
|
220
|
+
reason,
|
|
221
|
+
draftFile: 'inferred-templates.draft.ts',
|
|
222
|
+
preview: t.description,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (enabled.has(AdoptionKind.Boundary)) {
|
|
227
|
+
for (const b of onb.inferredBoundaryRules) {
|
|
228
|
+
const { category, reason } = classifyBoundary(b, input.inspection);
|
|
229
|
+
pushItem({
|
|
230
|
+
kind: AdoptionKind.Boundary,
|
|
231
|
+
id: b.id,
|
|
232
|
+
title: b.title,
|
|
233
|
+
category,
|
|
234
|
+
reason,
|
|
235
|
+
draftFile: 'inferred-boundaries.draft.ts',
|
|
236
|
+
preview: b.suggestedFix,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (enabled.has(AdoptionKind.Pipeline)) {
|
|
241
|
+
for (const p of onb.inferredPipelines) {
|
|
242
|
+
const { category, reason } = classifyPipeline(p, input.inspection);
|
|
243
|
+
pushItem({
|
|
244
|
+
kind: AdoptionKind.Pipeline,
|
|
245
|
+
id: p.id,
|
|
246
|
+
title: p.title,
|
|
247
|
+
category,
|
|
248
|
+
reason,
|
|
249
|
+
draftFile: 'inferred-pipelines.draft.ts',
|
|
250
|
+
preview: p.description,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// Items the user explicitly excluded — only annotate when the inference
|
|
255
|
+
// produced them so adoption review can show "skipped because excluded".
|
|
256
|
+
for (const excluded of exclude) {
|
|
257
|
+
for (const item of itemsForKind(onb, excluded)) {
|
|
258
|
+
items.push({
|
|
259
|
+
kind: excluded,
|
|
260
|
+
id: item.id,
|
|
261
|
+
title: item.title,
|
|
262
|
+
category: AdoptionCategory.Skipped,
|
|
263
|
+
reason: 'kind excluded via --exclude',
|
|
264
|
+
draftFile: defaultDraftFile(excluded),
|
|
265
|
+
preview: item.preview,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const summary = emptySummary();
|
|
270
|
+
const byCategory = emptyByCategory();
|
|
271
|
+
for (const it of items) {
|
|
272
|
+
summary[it.category] += 1;
|
|
273
|
+
byCategory[it.category].push(it);
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
confidence,
|
|
277
|
+
included: [...enabled],
|
|
278
|
+
excluded: exclude,
|
|
279
|
+
items,
|
|
280
|
+
summary,
|
|
281
|
+
byCategory,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function itemsForKind(plan, kind) {
|
|
285
|
+
switch (kind) {
|
|
286
|
+
case AdoptionKind.Rule:
|
|
287
|
+
return plan.inferredRules.map((r) => ({ id: r.id, title: r.title, preview: r.title }));
|
|
288
|
+
case AdoptionKind.Path:
|
|
289
|
+
return plan.inferredPathConventions.map((p) => ({ id: p.id, title: p.title, preview: p.title }));
|
|
290
|
+
case AdoptionKind.Verification:
|
|
291
|
+
return plan.inferredVerificationCommands.map((v) => ({
|
|
292
|
+
id: v.id,
|
|
293
|
+
title: v.label,
|
|
294
|
+
preview: v.command,
|
|
295
|
+
}));
|
|
296
|
+
case AdoptionKind.Template:
|
|
297
|
+
return plan.inferredTemplateCandidates.map((t) => ({
|
|
298
|
+
id: t.id,
|
|
299
|
+
title: t.name,
|
|
300
|
+
preview: t.description,
|
|
301
|
+
}));
|
|
302
|
+
case AdoptionKind.Boundary:
|
|
303
|
+
return plan.inferredBoundaryRules.map((b) => ({
|
|
304
|
+
id: b.id,
|
|
305
|
+
title: b.title,
|
|
306
|
+
preview: b.suggestedFix,
|
|
307
|
+
}));
|
|
308
|
+
case AdoptionKind.Pipeline:
|
|
309
|
+
return plan.inferredPipelines.map((p) => ({
|
|
310
|
+
id: p.id,
|
|
311
|
+
title: p.title,
|
|
312
|
+
preview: p.description,
|
|
313
|
+
}));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function defaultDraftFile(kind) {
|
|
317
|
+
switch (kind) {
|
|
318
|
+
case AdoptionKind.Rule:
|
|
319
|
+
return 'inferred-rules.draft.ts';
|
|
320
|
+
case AdoptionKind.Path:
|
|
321
|
+
return 'inferred-paths.draft.ts';
|
|
322
|
+
case AdoptionKind.Verification:
|
|
323
|
+
return 'onboarding-report.md';
|
|
324
|
+
case AdoptionKind.Template:
|
|
325
|
+
return 'inferred-templates.draft.ts';
|
|
326
|
+
case AdoptionKind.Boundary:
|
|
327
|
+
return 'inferred-boundaries.draft.ts';
|
|
328
|
+
case AdoptionKind.Pipeline:
|
|
329
|
+
return 'inferred-pipelines.draft.ts';
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// ─── Patch / plan rendering ──────────────────────────────────────────────────
|
|
333
|
+
export function renderAdoptionPlanMarkdown(plan) {
|
|
334
|
+
const lines = [];
|
|
335
|
+
lines.push('# SharkCraft onboarding — adoption plan');
|
|
336
|
+
lines.push('');
|
|
337
|
+
lines.push(`Confidence threshold: \`${plan.confidence}\``);
|
|
338
|
+
lines.push(`Included kinds: ${plan.included.map((k) => '`' + k + '`').join(', ') || '_(none)_'}`);
|
|
339
|
+
if (plan.excluded.length > 0) {
|
|
340
|
+
lines.push(`Excluded kinds: ${plan.excluded.map((k) => '`' + k + '`').join(', ')}`);
|
|
341
|
+
}
|
|
342
|
+
lines.push('');
|
|
343
|
+
lines.push('## Summary');
|
|
344
|
+
lines.push('');
|
|
345
|
+
for (const cat of Object.values(AdoptionCategory)) {
|
|
346
|
+
lines.push(`- **${cat}**: ${plan.summary[cat]}`);
|
|
347
|
+
}
|
|
348
|
+
lines.push('');
|
|
349
|
+
for (const cat of Object.values(AdoptionCategory)) {
|
|
350
|
+
const items = plan.byCategory[cat];
|
|
351
|
+
if (items.length === 0)
|
|
352
|
+
continue;
|
|
353
|
+
lines.push(`## ${cat}`);
|
|
354
|
+
lines.push('');
|
|
355
|
+
for (const it of items) {
|
|
356
|
+
lines.push(`- **${it.kind}** \`${it.id}\` — ${it.title}`);
|
|
357
|
+
lines.push(` - reason: ${it.reason}`);
|
|
358
|
+
lines.push(` - draft: \`sharkcraft/onboarding/${it.draftFile}\``);
|
|
359
|
+
}
|
|
360
|
+
lines.push('');
|
|
361
|
+
}
|
|
362
|
+
lines.push('## How to apply');
|
|
363
|
+
lines.push('');
|
|
364
|
+
lines.push('```');
|
|
365
|
+
lines.push('# Apply only the safe-to-adopt blocks (review first):');
|
|
366
|
+
lines.push('git apply sharkcraft/onboarding/adoption/adopt.patch');
|
|
367
|
+
lines.push('');
|
|
368
|
+
lines.push('# Or inspect items by category:');
|
|
369
|
+
lines.push('shrk onboard adopt review');
|
|
370
|
+
lines.push('```');
|
|
371
|
+
return lines.join('\n') + '\n';
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Render an adoption patch. Defaults to the conservative 'pseudo' format
|
|
375
|
+
* (sentinel-marked append block). 'unified' produces real `git apply`
|
|
376
|
+
* patches: full-file create for missing targets, append-at-EOF hunk for
|
|
377
|
+
* existing targets with a small leading context window so git can find the
|
|
378
|
+
* insertion point reliably.
|
|
379
|
+
*
|
|
380
|
+
* The patch is always append-only and intentionally never overwrites
|
|
381
|
+
* existing content. Output lives under sharkcraft/onboarding/adoption/.
|
|
382
|
+
*/
|
|
383
|
+
export function renderAdoptionPatchDetailed(plan, options = {}) {
|
|
384
|
+
const format = options.format ?? 'pseudo';
|
|
385
|
+
const adopt = plan.byCategory[AdoptionCategory.SafeToAdopt];
|
|
386
|
+
if (adopt.length === 0) {
|
|
387
|
+
return {
|
|
388
|
+
body: '# No safe-to-adopt items in this plan — nothing to patch.\n',
|
|
389
|
+
targets: [],
|
|
390
|
+
format,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
const byKind = new Map();
|
|
394
|
+
for (const it of adopt) {
|
|
395
|
+
const arr = byKind.get(it.kind) ?? [];
|
|
396
|
+
arr.push(it);
|
|
397
|
+
byKind.set(it.kind, arr);
|
|
398
|
+
}
|
|
399
|
+
const targets = [];
|
|
400
|
+
const renderTarget = (relativePath, body) => {
|
|
401
|
+
if (format === 'pseudo') {
|
|
402
|
+
targets.push({ relativePath, existed: false, bytesAdded: body.length });
|
|
403
|
+
return renderPseudoBlock(relativePath, body);
|
|
404
|
+
}
|
|
405
|
+
return renderUnifiedHunk(relativePath, body, options.projectRoot, targets);
|
|
406
|
+
};
|
|
407
|
+
const lines = [];
|
|
408
|
+
lines.push('# SharkCraft onboarding adoption patch');
|
|
409
|
+
lines.push('# Generated by `shrk onboard adopt --write-patch`.');
|
|
410
|
+
lines.push(`# Format: ${format}`);
|
|
411
|
+
lines.push('#');
|
|
412
|
+
lines.push(format === 'unified'
|
|
413
|
+
? '# This is a git-apply-compatible unified diff. Review before applying:'
|
|
414
|
+
: '# This is a pseudo-patch. The `@@ append @@` markers are sentinels:');
|
|
415
|
+
lines.push(format === 'unified'
|
|
416
|
+
? '# git apply sharkcraft/onboarding/adoption/adopt.patch'
|
|
417
|
+
: '# inspect adopt.patch, then copy each append block into the target file');
|
|
418
|
+
lines.push('#');
|
|
419
|
+
lines.push('# This patch ONLY appends. It does not overwrite existing entries.');
|
|
420
|
+
lines.push('# Review every block before applying.');
|
|
421
|
+
lines.push('');
|
|
422
|
+
if (byKind.has(AdoptionKind.Rule)) {
|
|
423
|
+
lines.push(...renderTarget('sharkcraft/rules.ts', renderRuleBlock(byKind.get(AdoptionKind.Rule))));
|
|
424
|
+
}
|
|
425
|
+
if (byKind.has(AdoptionKind.Path)) {
|
|
426
|
+
lines.push(...renderTarget('sharkcraft/paths.ts', renderPathBlock(byKind.get(AdoptionKind.Path))));
|
|
427
|
+
}
|
|
428
|
+
if (byKind.has(AdoptionKind.Verification)) {
|
|
429
|
+
lines.push(...renderTarget('sharkcraft/sharkcraft.config.ts', renderVerificationBlock(byKind.get(AdoptionKind.Verification))));
|
|
430
|
+
}
|
|
431
|
+
if (byKind.has(AdoptionKind.Pipeline)) {
|
|
432
|
+
lines.push(...renderTarget('sharkcraft/pipelines.ts', renderPipelineBlock(byKind.get(AdoptionKind.Pipeline))));
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
body: lines.join('\n') + '\n',
|
|
436
|
+
targets,
|
|
437
|
+
format,
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
/** Back-compat wrapper that returns just the patch body. */
|
|
441
|
+
export function renderAdoptionPatch(plan) {
|
|
442
|
+
return renderAdoptionPatchDetailed(plan).body;
|
|
443
|
+
}
|
|
444
|
+
function renderPseudoBlock(targetRel, body) {
|
|
445
|
+
const lines = [];
|
|
446
|
+
lines.push(`--- a/${targetRel}`);
|
|
447
|
+
lines.push(`+++ b/${targetRel}`);
|
|
448
|
+
lines.push('@@ append @@');
|
|
449
|
+
for (const l of body.split('\n'))
|
|
450
|
+
lines.push(`+${l}`);
|
|
451
|
+
lines.push('');
|
|
452
|
+
return lines;
|
|
453
|
+
}
|
|
454
|
+
function renderUnifiedHunk(targetRel, body, projectRoot, targets) {
|
|
455
|
+
const lines = [];
|
|
456
|
+
const fullPath = projectRoot ? nodePath.resolve(projectRoot, targetRel) : null;
|
|
457
|
+
const exists = fullPath !== null && existsSync(fullPath);
|
|
458
|
+
const addedLines = body.split('\n');
|
|
459
|
+
// Trim trailing newline lines (we add the LF separator ourselves).
|
|
460
|
+
while (addedLines.length > 0 && addedLines[addedLines.length - 1] === '') {
|
|
461
|
+
addedLines.pop();
|
|
462
|
+
}
|
|
463
|
+
const bytesAdded = addedLines.reduce((s, l) => s + l.length + 1, 0);
|
|
464
|
+
if (!exists) {
|
|
465
|
+
// New file: emit a 'new file' unified diff with the full body in a single hunk.
|
|
466
|
+
lines.push(`diff --git a/${targetRel} b/${targetRel}`);
|
|
467
|
+
lines.push('new file mode 100644');
|
|
468
|
+
lines.push('--- /dev/null');
|
|
469
|
+
lines.push(`+++ b/${targetRel}`);
|
|
470
|
+
lines.push(`@@ -0,0 +1,${addedLines.length} @@`);
|
|
471
|
+
for (const l of addedLines)
|
|
472
|
+
lines.push(`+${l}`);
|
|
473
|
+
lines.push('');
|
|
474
|
+
targets.push({ relativePath: targetRel, existed: false, bytesAdded });
|
|
475
|
+
return lines;
|
|
476
|
+
}
|
|
477
|
+
const existing = readFileSync(fullPath, 'utf8');
|
|
478
|
+
const beforeHash = createHash('sha256').update(existing).digest('hex');
|
|
479
|
+
const existingLines = existing.split('\n');
|
|
480
|
+
// Files conventionally end with a trailing newline → last entry is empty.
|
|
481
|
+
const hasTrailingNewline = existingLines[existingLines.length - 1] === '';
|
|
482
|
+
if (hasTrailingNewline)
|
|
483
|
+
existingLines.pop();
|
|
484
|
+
const beforeLineCount = existingLines.length;
|
|
485
|
+
// Context window: last 3 lines (or all of them if file is short).
|
|
486
|
+
const contextStart = Math.max(0, beforeLineCount - 3);
|
|
487
|
+
const contextLines = existingLines.slice(contextStart);
|
|
488
|
+
// The unified hunk spans from `contextStart+1` to the end of the new file.
|
|
489
|
+
const afterLineCount = beforeLineCount + addedLines.length;
|
|
490
|
+
const oldStart = contextStart + 1;
|
|
491
|
+
const oldRange = contextLines.length;
|
|
492
|
+
const newStart = contextStart + 1;
|
|
493
|
+
const newRange = contextLines.length + addedLines.length;
|
|
494
|
+
lines.push(`diff --git a/${targetRel} b/${targetRel}`);
|
|
495
|
+
lines.push(`--- a/${targetRel}`);
|
|
496
|
+
lines.push(`+++ b/${targetRel}`);
|
|
497
|
+
lines.push(`@@ -${oldStart},${oldRange} +${newStart},${newRange} @@`);
|
|
498
|
+
for (const c of contextLines)
|
|
499
|
+
lines.push(` ${c}`);
|
|
500
|
+
for (const a of addedLines)
|
|
501
|
+
lines.push(`+${a}`);
|
|
502
|
+
lines.push('');
|
|
503
|
+
void afterLineCount;
|
|
504
|
+
targets.push({ relativePath: targetRel, existed: true, beforeHash, bytesAdded });
|
|
505
|
+
return lines;
|
|
506
|
+
}
|
|
507
|
+
function renderRuleBlock(items) {
|
|
508
|
+
const lines = [];
|
|
509
|
+
lines.push('// ─── Adopted from `shrk onboard adopt` ─── start');
|
|
510
|
+
for (const it of items) {
|
|
511
|
+
lines.push(`// rule: ${it.id} — ${it.title}`);
|
|
512
|
+
}
|
|
513
|
+
lines.push('// ─── Adopted from `shrk onboard adopt` ─── end');
|
|
514
|
+
return lines.join('\n');
|
|
515
|
+
}
|
|
516
|
+
function renderPathBlock(items) {
|
|
517
|
+
const lines = [];
|
|
518
|
+
lines.push('// ─── Adopted from `shrk onboard adopt` ─── start');
|
|
519
|
+
for (const it of items) {
|
|
520
|
+
lines.push(`// path convention: ${it.id} — ${it.title}`);
|
|
521
|
+
}
|
|
522
|
+
lines.push('// ─── Adopted from `shrk onboard adopt` ─── end');
|
|
523
|
+
return lines.join('\n');
|
|
524
|
+
}
|
|
525
|
+
function renderVerificationBlock(items) {
|
|
526
|
+
const lines = [];
|
|
527
|
+
lines.push('// ─── Adopted verification commands — start');
|
|
528
|
+
for (const it of items) {
|
|
529
|
+
lines.push(`// { id: '${it.id}', label: '${it.title}', command: '<edit>', trusted: true },`);
|
|
530
|
+
}
|
|
531
|
+
lines.push('// ─── Adopted verification commands — end');
|
|
532
|
+
return lines.join('\n');
|
|
533
|
+
}
|
|
534
|
+
function renderPipelineBlock(items) {
|
|
535
|
+
const lines = [];
|
|
536
|
+
lines.push('// ─── Adopted pipelines — start');
|
|
537
|
+
for (const it of items) {
|
|
538
|
+
lines.push(`// pipeline: ${it.id} — ${it.title}`);
|
|
539
|
+
}
|
|
540
|
+
lines.push('// ─── Adopted pipelines — end');
|
|
541
|
+
return lines.join('\n');
|
|
542
|
+
}
|
|
543
|
+
export function writeAdoptionPatch(input) {
|
|
544
|
+
const outDir = nodePath.resolve(input.projectRoot, 'sharkcraft', 'onboarding', 'adoption');
|
|
545
|
+
if (!existsSync(outDir))
|
|
546
|
+
mkdirSync(outDir, { recursive: true });
|
|
547
|
+
// Detect whether the prior patch is stale relative to current targets/drafts
|
|
548
|
+
// BEFORE we overwrite the state file. We do the actual archival via a small
|
|
549
|
+
// helper imported below to avoid a circular import.
|
|
550
|
+
const wasStale = detectPreviousStale(input.projectRoot);
|
|
551
|
+
const autoRegenerate = input.autoRegenerate !== false && input.noAutoRegenerate !== true;
|
|
552
|
+
const archived = [];
|
|
553
|
+
if (wasStale && autoRegenerate) {
|
|
554
|
+
archived.push(...archiveAdoptionOutputs(input.projectRoot));
|
|
555
|
+
}
|
|
556
|
+
const files = [];
|
|
557
|
+
const write = (name, body) => {
|
|
558
|
+
const full = nodePath.join(outDir, name);
|
|
559
|
+
if (!full.startsWith(outDir + nodePath.sep)) {
|
|
560
|
+
throw new Error(`adoption path escapes outDir: ${name}`);
|
|
561
|
+
}
|
|
562
|
+
writeFileSync(full, body, 'utf8');
|
|
563
|
+
files.push({ path: full, bytes: Buffer.byteLength(body, 'utf8') });
|
|
564
|
+
};
|
|
565
|
+
write('adoption-plan.md', renderAdoptionPlanMarkdown(input.plan));
|
|
566
|
+
const patch = renderAdoptionPatchDetailed(input.plan, {
|
|
567
|
+
format: input.format ?? 'pseudo',
|
|
568
|
+
projectRoot: input.projectRoot,
|
|
569
|
+
});
|
|
570
|
+
write('adopt.patch', patch.body);
|
|
571
|
+
write('adopt-summary.json', JSON.stringify({
|
|
572
|
+
confidence: input.plan.confidence,
|
|
573
|
+
summary: input.plan.summary,
|
|
574
|
+
items: input.plan.items,
|
|
575
|
+
format: patch.format,
|
|
576
|
+
targets: patch.targets,
|
|
577
|
+
}, null, 2) + '\n');
|
|
578
|
+
const statePath = persistAdoptionState({
|
|
579
|
+
projectRoot: input.projectRoot,
|
|
580
|
+
plan: input.plan,
|
|
581
|
+
targets: patch.targets,
|
|
582
|
+
diffFormat: patch.format,
|
|
583
|
+
patchPath: nodePath.join(outDir, 'adopt.patch'),
|
|
584
|
+
summaryPath: nodePath.join(outDir, 'adopt-summary.json'),
|
|
585
|
+
generatedFiles: files.map((f) => f.path),
|
|
586
|
+
command: input.format
|
|
587
|
+
? `shrk onboard adopt --write-patch --diff-format ${input.format}`
|
|
588
|
+
: 'shrk onboard adopt --write-patch',
|
|
589
|
+
warnings: wasStale && autoRegenerate ? ['previous patch was stale; archived to history/'] : [],
|
|
590
|
+
});
|
|
591
|
+
return {
|
|
592
|
+
outDir,
|
|
593
|
+
files,
|
|
594
|
+
format: patch.format,
|
|
595
|
+
targets: patch.targets,
|
|
596
|
+
statePath,
|
|
597
|
+
archived,
|
|
598
|
+
wasStale,
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
// ─── Helpers used by writeAdoptionPatch ──────────────────────────────────────
|
|
602
|
+
//
|
|
603
|
+
// These are intentionally small wrappers that defer the actual work to
|
|
604
|
+
// `adoption-state.ts`. The functions are imported lazily inside writeAdoptionPatch
|
|
605
|
+
// to avoid a top-level circular import cycle (adoption-state imports types
|
|
606
|
+
// from this module).
|
|
607
|
+
function detectPreviousStale(projectRoot) {
|
|
608
|
+
const statePath = nodePath.join(projectRoot, 'sharkcraft', 'onboarding', 'adoption', 'adoption-state.json');
|
|
609
|
+
if (!existsSync(statePath))
|
|
610
|
+
return false;
|
|
611
|
+
try {
|
|
612
|
+
const state = JSON.parse(readFileSync(statePath, 'utf8'));
|
|
613
|
+
if (!state.targetFiles)
|
|
614
|
+
return false;
|
|
615
|
+
for (const t of state.targetFiles) {
|
|
616
|
+
const full = nodePath.resolve(projectRoot, t.relativePath);
|
|
617
|
+
if (!existsSync(full)) {
|
|
618
|
+
if (t.hash !== '(missing)')
|
|
619
|
+
return true;
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
const body = readFileSync(full, 'utf8');
|
|
623
|
+
const cur = createHash('sha256').update(body).digest('hex');
|
|
624
|
+
if (t.hash === '(missing)')
|
|
625
|
+
return true;
|
|
626
|
+
if (cur !== t.hash)
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
catch {
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function archiveAdoptionOutputs(projectRoot) {
|
|
636
|
+
const dir = nodePath.join(projectRoot, 'sharkcraft', 'onboarding', 'adoption');
|
|
637
|
+
if (!existsSync(dir))
|
|
638
|
+
return [];
|
|
639
|
+
const history = nodePath.join(dir, 'history');
|
|
640
|
+
if (!existsSync(history))
|
|
641
|
+
mkdirSync(history, { recursive: true });
|
|
642
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
643
|
+
const archived = [];
|
|
644
|
+
for (const name of ['adoption-state.json', 'adopt.patch', 'adoption-plan.md', 'adopt-summary.json']) {
|
|
645
|
+
const src = nodePath.join(dir, name);
|
|
646
|
+
if (!existsSync(src))
|
|
647
|
+
continue;
|
|
648
|
+
const dest = nodePath.join(history, `${timestamp}-${name}`);
|
|
649
|
+
if (existsSync(dest))
|
|
650
|
+
continue;
|
|
651
|
+
try {
|
|
652
|
+
const body = readFileSync(src, 'utf8');
|
|
653
|
+
writeFileSync(dest, body, 'utf8');
|
|
654
|
+
archived.push(dest);
|
|
655
|
+
}
|
|
656
|
+
catch {
|
|
657
|
+
// ignore
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
return archived;
|
|
661
|
+
}
|
|
662
|
+
function persistAdoptionState(input) {
|
|
663
|
+
const previous = readAdoptionState(input.projectRoot);
|
|
664
|
+
const state = buildAdoptionState({
|
|
665
|
+
projectRoot: input.projectRoot,
|
|
666
|
+
command: input.command,
|
|
667
|
+
patchPath: input.patchPath,
|
|
668
|
+
summaryPath: input.summaryPath,
|
|
669
|
+
diffFormat: input.diffFormat,
|
|
670
|
+
plan: input.plan,
|
|
671
|
+
targets: input.targets,
|
|
672
|
+
generatedFiles: input.generatedFiles,
|
|
673
|
+
warnings: input.warnings,
|
|
674
|
+
...(previous ? { previousCreatedAt: previous.createdAt } : {}),
|
|
675
|
+
});
|
|
676
|
+
return writeAdoptionState(input.projectRoot, state);
|
|
677
|
+
}
|
|
678
|
+
/** Validate that the targets in a previously-written summary still match the
|
|
679
|
+
* current files on disk. Used by `shrk onboard adopt review` to warn when
|
|
680
|
+
* the target files changed between plan-time and review-time. */
|
|
681
|
+
export function validatePatchTargets(projectRoot, targets) {
|
|
682
|
+
const changed = [];
|
|
683
|
+
const ok = [];
|
|
684
|
+
for (const t of targets) {
|
|
685
|
+
if (!t.beforeHash) {
|
|
686
|
+
ok.push(t);
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
const full = nodePath.resolve(projectRoot, t.relativePath);
|
|
690
|
+
if (!existsSync(full)) {
|
|
691
|
+
// Target disappeared since plan-time.
|
|
692
|
+
changed.push(t);
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
const cur = createHash('sha256').update(readFileSync(full, 'utf8')).digest('hex');
|
|
696
|
+
if (cur !== t.beforeHash)
|
|
697
|
+
changed.push(t);
|
|
698
|
+
else
|
|
699
|
+
ok.push(t);
|
|
700
|
+
}
|
|
701
|
+
return { changed, ok };
|
|
702
|
+
}
|