@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,767 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan simulation v2.
|
|
3
|
+
*
|
|
4
|
+
* Loads a saved generation plan (v1 or v2), reconstructs the virtual
|
|
5
|
+
* post-apply file state (best-effort), classifies each operation's outcome,
|
|
6
|
+
* and reports apply readiness, boundary impact, policy impact, ownership
|
|
7
|
+
* review, public-API touch, likely tests, required validations, and
|
|
8
|
+
* affected constructs/playbooks.
|
|
9
|
+
*
|
|
10
|
+
* Read-only. No source writes.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
13
|
+
import * as nodePath from 'node:path';
|
|
14
|
+
import { evaluateBoundaries, loadTsconfigPaths, scanImports, } from '@shrkcrft/boundaries';
|
|
15
|
+
import { planGeneration, verifyPlan, } from '@shrkcrft/generator';
|
|
16
|
+
import { reviewSavedPlan } from "./plan-review.js";
|
|
17
|
+
import { loadOwnershipRules, impactFor as ownershipImpactFor } from "./ownership.js";
|
|
18
|
+
import { listConstructs, loadConstructs } from "./construct-registry.js";
|
|
19
|
+
import { listPlaybooks, recommendPlaybooks } from "./playbook-registry.js";
|
|
20
|
+
export const PLAN_SIMULATION_SCHEMA = 'sharkcraft.plan-simulation/v1';
|
|
21
|
+
export var PlanSimulationOperationOutcome;
|
|
22
|
+
(function (PlanSimulationOperationOutcome) {
|
|
23
|
+
PlanSimulationOperationOutcome["Ready"] = "ready";
|
|
24
|
+
PlanSimulationOperationOutcome["SkipIdempotent"] = "skip-idempotent";
|
|
25
|
+
PlanSimulationOperationOutcome["Conflict"] = "conflict";
|
|
26
|
+
PlanSimulationOperationOutcome["ModifiesExisting"] = "modifies-existing";
|
|
27
|
+
PlanSimulationOperationOutcome["CreatesNew"] = "creates-new";
|
|
28
|
+
})(PlanSimulationOperationOutcome || (PlanSimulationOperationOutcome = {}));
|
|
29
|
+
export var PlanApplyReadiness;
|
|
30
|
+
(function (PlanApplyReadiness) {
|
|
31
|
+
PlanApplyReadiness["Ready"] = "ready";
|
|
32
|
+
PlanApplyReadiness["ReadyWithReview"] = "ready-with-review";
|
|
33
|
+
PlanApplyReadiness["BlockedConflicts"] = "blocked-conflicts";
|
|
34
|
+
PlanApplyReadiness["BlockedPolicy"] = "blocked-policy";
|
|
35
|
+
PlanApplyReadiness["BlockedBoundary"] = "blocked-boundary";
|
|
36
|
+
PlanApplyReadiness["BlockedSignature"] = "blocked-signature";
|
|
37
|
+
PlanApplyReadiness["BlockedMissingReview"] = "blocked-missing-review";
|
|
38
|
+
})(PlanApplyReadiness || (PlanApplyReadiness = {}));
|
|
39
|
+
function readExistingFile(projectRoot, relativePath) {
|
|
40
|
+
try {
|
|
41
|
+
const abs = nodePath.resolve(projectRoot, relativePath);
|
|
42
|
+
if (!existsSync(abs))
|
|
43
|
+
return null;
|
|
44
|
+
return readFileSync(abs, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Minimal unified-diff renderer for two strings. Not a full LCS — uses a
|
|
52
|
+
* simple longest-common-subsequence on lines via dynamic programming with
|
|
53
|
+
* a guard against huge inputs. For huge inputs falls back to a summary.
|
|
54
|
+
*/
|
|
55
|
+
function unifiedDiff(beforeText, afterText, opts) {
|
|
56
|
+
const context = opts.context ?? 3;
|
|
57
|
+
const maxLines = opts.maxLines ?? 80;
|
|
58
|
+
const before = beforeText.split('\n');
|
|
59
|
+
const after = afterText.split('\n');
|
|
60
|
+
// Bail out if either side is huge — emit a summary line instead.
|
|
61
|
+
const LIMIT = 4000;
|
|
62
|
+
if (before.length > LIMIT || after.length > LIMIT) {
|
|
63
|
+
return {
|
|
64
|
+
body: `--- a/${opts.relativePath}\n+++ b/${opts.relativePath}\n@@ summary @@\n- ${before.length} line(s)\n+ ${after.length} line(s)\n(diff omitted — file too large for inline preview)\n`,
|
|
65
|
+
truncated: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// LCS table
|
|
69
|
+
const n = before.length;
|
|
70
|
+
const m = after.length;
|
|
71
|
+
const dp = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
|
|
72
|
+
for (let i = n - 1; i >= 0; i -= 1) {
|
|
73
|
+
for (let j = m - 1; j >= 0; j -= 1) {
|
|
74
|
+
dp[i][j] = before[i] === after[j] ? (dp[i + 1][j + 1] ?? 0) + 1 : Math.max(dp[i + 1][j] ?? 0, dp[i][j + 1] ?? 0);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const edits = [];
|
|
78
|
+
let i = 0;
|
|
79
|
+
let j = 0;
|
|
80
|
+
while (i < n && j < m) {
|
|
81
|
+
if (before[i] === after[j]) {
|
|
82
|
+
edits.push({ op: '=', line: before[i] });
|
|
83
|
+
i += 1;
|
|
84
|
+
j += 1;
|
|
85
|
+
}
|
|
86
|
+
else if ((dp[i + 1][j] ?? 0) >= (dp[i][j + 1] ?? 0)) {
|
|
87
|
+
edits.push({ op: '-', line: before[i] });
|
|
88
|
+
i += 1;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
edits.push({ op: '+', line: after[j] });
|
|
92
|
+
j += 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
while (i < n)
|
|
96
|
+
edits.push({ op: '-', line: before[i++] });
|
|
97
|
+
while (j < m)
|
|
98
|
+
edits.push({ op: '+', line: after[j++] });
|
|
99
|
+
// Group into hunks with context lines.
|
|
100
|
+
const lines = [];
|
|
101
|
+
lines.push(`--- a/${opts.relativePath}`);
|
|
102
|
+
lines.push(`+++ b/${opts.relativePath}`);
|
|
103
|
+
let pos = 0;
|
|
104
|
+
let aPos = 1;
|
|
105
|
+
let bPos = 1;
|
|
106
|
+
while (pos < edits.length) {
|
|
107
|
+
// skip leading equals
|
|
108
|
+
while (pos < edits.length && edits[pos].op === '=') {
|
|
109
|
+
pos += 1;
|
|
110
|
+
aPos += 1;
|
|
111
|
+
bPos += 1;
|
|
112
|
+
}
|
|
113
|
+
if (pos >= edits.length)
|
|
114
|
+
break;
|
|
115
|
+
const hunkStart = Math.max(0, pos - context);
|
|
116
|
+
// Find end of hunk — extend until we see `context` consecutive '=' lines
|
|
117
|
+
let end = pos;
|
|
118
|
+
let runEq = 0;
|
|
119
|
+
while (end < edits.length && runEq < context * 2) {
|
|
120
|
+
if (edits[end].op === '=')
|
|
121
|
+
runEq += 1;
|
|
122
|
+
else
|
|
123
|
+
runEq = 0;
|
|
124
|
+
end += 1;
|
|
125
|
+
}
|
|
126
|
+
const hunkEnd = Math.min(edits.length, end + context);
|
|
127
|
+
// Compute hunk header (1-based line numbers)
|
|
128
|
+
let aStart = aPos;
|
|
129
|
+
let bStart = bPos;
|
|
130
|
+
for (let k = hunkStart; k < pos; k += 1) {
|
|
131
|
+
if (edits[k].op !== '+')
|
|
132
|
+
aStart -= 1;
|
|
133
|
+
if (edits[k].op !== '-')
|
|
134
|
+
bStart -= 1;
|
|
135
|
+
}
|
|
136
|
+
let aCount = 0;
|
|
137
|
+
let bCount = 0;
|
|
138
|
+
for (let k = hunkStart; k < hunkEnd; k += 1) {
|
|
139
|
+
const o = edits[k].op;
|
|
140
|
+
if (o === '=' || o === '-')
|
|
141
|
+
aCount += 1;
|
|
142
|
+
if (o === '=' || o === '+')
|
|
143
|
+
bCount += 1;
|
|
144
|
+
}
|
|
145
|
+
lines.push(`@@ -${aStart},${aCount} +${bStart},${bCount} @@`);
|
|
146
|
+
for (let k = hunkStart; k < hunkEnd; k += 1) {
|
|
147
|
+
const e = edits[k];
|
|
148
|
+
lines.push((e.op === '=' ? ' ' : e.op) + e.line);
|
|
149
|
+
if (e.op !== '+')
|
|
150
|
+
aPos += 1;
|
|
151
|
+
if (e.op !== '-')
|
|
152
|
+
bPos += 1;
|
|
153
|
+
}
|
|
154
|
+
pos = hunkEnd;
|
|
155
|
+
}
|
|
156
|
+
// Truncate.
|
|
157
|
+
let truncated = false;
|
|
158
|
+
if (lines.length > maxLines + 2) {
|
|
159
|
+
const head = lines.slice(0, maxLines + 2);
|
|
160
|
+
head.push(`… (${lines.length - maxLines - 2} more line(s) omitted) …`);
|
|
161
|
+
truncated = true;
|
|
162
|
+
return { body: head.join('\n') + '\n', truncated };
|
|
163
|
+
}
|
|
164
|
+
return { body: lines.join('\n') + '\n', truncated };
|
|
165
|
+
}
|
|
166
|
+
function operationExplain(c) {
|
|
167
|
+
switch (c.type) {
|
|
168
|
+
case 'append':
|
|
169
|
+
return c.reason?.includes('already present') ? 'append marker found (idempotent skip)' : 'append snippet will be added at end-of-file';
|
|
170
|
+
case 'insert-after':
|
|
171
|
+
return c.reason?.includes('anchor not found')
|
|
172
|
+
? 'insert-after: anchor missing'
|
|
173
|
+
: c.reason?.includes('multiple sites')
|
|
174
|
+
? 'insert-after: anchor is ambiguous (multiple matches)'
|
|
175
|
+
: 'insert-after: anchor found exactly once';
|
|
176
|
+
case 'insert-before':
|
|
177
|
+
return c.reason?.includes('anchor not found')
|
|
178
|
+
? 'insert-before: anchor missing'
|
|
179
|
+
: c.reason?.includes('multiple sites')
|
|
180
|
+
? 'insert-before: anchor is ambiguous (multiple matches)'
|
|
181
|
+
: 'insert-before: anchor found exactly once';
|
|
182
|
+
case 'replace':
|
|
183
|
+
return c.reason?.includes('already applied')
|
|
184
|
+
? 'replace: already applied (idempotent)'
|
|
185
|
+
: c.reason?.includes('expected')
|
|
186
|
+
? 'replace: match-count mismatch'
|
|
187
|
+
: c.reason?.includes('not found')
|
|
188
|
+
? 'replace: find text not found'
|
|
189
|
+
: 'replace: 1 match found';
|
|
190
|
+
case 'export':
|
|
191
|
+
return c.reason?.includes('already present')
|
|
192
|
+
? 'export: already present in barrel'
|
|
193
|
+
: c.reason?.includes('does not exist')
|
|
194
|
+
? 'export: barrel file missing'
|
|
195
|
+
: 'export: will append new export line';
|
|
196
|
+
case 'create':
|
|
197
|
+
return c.reason?.includes('identical')
|
|
198
|
+
? 'create: identical existing file (skip)'
|
|
199
|
+
: c.reason?.includes('overwrite')
|
|
200
|
+
? 'create: conflict — file already exists'
|
|
201
|
+
: 'create: new file';
|
|
202
|
+
default:
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function isPublicApiPath(p) {
|
|
207
|
+
return p.endsWith('/index.ts') || p.includes('plugin-api/') || p.includes('public-api/');
|
|
208
|
+
}
|
|
209
|
+
function isBarrelExportPath(p) {
|
|
210
|
+
return p.endsWith('/index.ts') || p.endsWith('index.tsx');
|
|
211
|
+
}
|
|
212
|
+
function isAdapterPath(p) {
|
|
213
|
+
return p.includes('/adapters/') || p.includes('adapter');
|
|
214
|
+
}
|
|
215
|
+
function detectMarker(contents, markers) {
|
|
216
|
+
if (!contents)
|
|
217
|
+
return false;
|
|
218
|
+
return markers.some((m) => contents.includes(m));
|
|
219
|
+
}
|
|
220
|
+
function outcomeFor(type) {
|
|
221
|
+
switch (type) {
|
|
222
|
+
case 'skip':
|
|
223
|
+
return PlanSimulationOperationOutcome.SkipIdempotent;
|
|
224
|
+
case 'conflict':
|
|
225
|
+
return PlanSimulationOperationOutcome.Conflict;
|
|
226
|
+
case 'create':
|
|
227
|
+
return PlanSimulationOperationOutcome.CreatesNew;
|
|
228
|
+
case 'update':
|
|
229
|
+
case 'append':
|
|
230
|
+
case 'insert-after':
|
|
231
|
+
case 'insert-before':
|
|
232
|
+
case 'replace':
|
|
233
|
+
case 'export':
|
|
234
|
+
return PlanSimulationOperationOutcome.ModifiesExisting;
|
|
235
|
+
default:
|
|
236
|
+
return PlanSimulationOperationOutcome.Ready;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function collectPlannedEdges(changes) {
|
|
240
|
+
const edges = [];
|
|
241
|
+
const REGEXES = [
|
|
242
|
+
/(?:^|\s)(?:import|export)\s+[^'"`]*?from\s+['"]([^'"`]+)['"]/g,
|
|
243
|
+
/(?:^|\s)import\s+['"]([^'"`]+)['"]/g,
|
|
244
|
+
/\bimport\s*\(\s*['"]([^'"`]+)['"]\s*\)/g,
|
|
245
|
+
/\brequire\s*\(\s*['"]([^'"`]+)['"]\s*\)/g,
|
|
246
|
+
];
|
|
247
|
+
for (const c of changes) {
|
|
248
|
+
if (!/\.(ts|tsx|js|jsx|mjs|cjs)$/.test(c.relativePath))
|
|
249
|
+
continue;
|
|
250
|
+
if (!c.contents || c.contents.length === 0)
|
|
251
|
+
continue;
|
|
252
|
+
const source = c.contents;
|
|
253
|
+
for (const re of REGEXES) {
|
|
254
|
+
re.lastIndex = 0;
|
|
255
|
+
let m;
|
|
256
|
+
while ((m = re.exec(source)) !== null) {
|
|
257
|
+
const line = source.slice(0, m.index).split('\n').length;
|
|
258
|
+
edges.push({
|
|
259
|
+
from: c.relativePath,
|
|
260
|
+
importSpecifier: m[1],
|
|
261
|
+
line,
|
|
262
|
+
kind: m[1].startsWith('.') ? 'internal' : 'external',
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return edges;
|
|
268
|
+
}
|
|
269
|
+
export async function simulatePlan(inspection, planPath, options = {}) {
|
|
270
|
+
const limitations = [];
|
|
271
|
+
const raw = readFileSync(planPath, 'utf8');
|
|
272
|
+
const plan = JSON.parse(raw);
|
|
273
|
+
const planSchema = String(plan.schema ?? 'unknown');
|
|
274
|
+
// Reuse the existing plan review for signature/boundary/path heuristics.
|
|
275
|
+
let review;
|
|
276
|
+
try {
|
|
277
|
+
review = reviewSavedPlan(inspection, planPath);
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
limitations.push(`Plan review failed: ${e.message}`);
|
|
281
|
+
}
|
|
282
|
+
// Re-render the template to recover virtual contents (when available).
|
|
283
|
+
let liveChanges = [];
|
|
284
|
+
if (plan.templateId) {
|
|
285
|
+
const template = inspection.templateRegistry.get(plan.templateId);
|
|
286
|
+
if (template) {
|
|
287
|
+
try {
|
|
288
|
+
const dry = planGeneration(template, {
|
|
289
|
+
templateId: plan.templateId,
|
|
290
|
+
...(plan.name ? { name: plan.name } : {}),
|
|
291
|
+
variables: plan.variables ?? {},
|
|
292
|
+
projectRoot: inspection.projectRoot,
|
|
293
|
+
});
|
|
294
|
+
liveChanges = dry.plan.changes;
|
|
295
|
+
}
|
|
296
|
+
catch (e) {
|
|
297
|
+
limitations.push(`Template re-render failed: ${e.message}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
limitations.push(`Template "${plan.templateId}" not found in the live registry — virtual contents not reconstructed.`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
limitations.push('Plan has no templateId — virtual contents not reconstructed.');
|
|
306
|
+
}
|
|
307
|
+
const expected = plan.expectedChanges ?? [];
|
|
308
|
+
const sourceList = liveChanges.length > 0
|
|
309
|
+
? liveChanges.map((c) => ({
|
|
310
|
+
type: String(c.type),
|
|
311
|
+
relativePath: c.relativePath,
|
|
312
|
+
sizeBytes: c.sizeBytes,
|
|
313
|
+
contents: c.contents,
|
|
314
|
+
reason: c.reason,
|
|
315
|
+
}))
|
|
316
|
+
: expected.map((c) => ({
|
|
317
|
+
type: String(c.type),
|
|
318
|
+
relativePath: c.relativePath,
|
|
319
|
+
sizeBytes: Number(c.sizeBytes ?? 0),
|
|
320
|
+
}));
|
|
321
|
+
// Marker-driven detection. Project-specific markers identify pack-owned regions.
|
|
322
|
+
// Markers come from registered lifecycle profiles. The engine ships only
|
|
323
|
+
// generic naming conventions.
|
|
324
|
+
const baseKeyTableMarkers = ['PluginKey', 'pluginKeys'];
|
|
325
|
+
const profileKeyMarkers = [];
|
|
326
|
+
try {
|
|
327
|
+
const { listPluginLifecycleProfiles } = await import("./plugin-lifecycle-profile-registry.js");
|
|
328
|
+
const profiles = await listPluginLifecycleProfiles(inspection);
|
|
329
|
+
for (const entry of profiles) {
|
|
330
|
+
if (entry.profile.keyTable?.path) {
|
|
331
|
+
const base = entry.profile.keyTable.path.split('/').pop()?.replace(/\.\w+$/, '');
|
|
332
|
+
if (base)
|
|
333
|
+
profileKeyMarkers.push(base);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// best-effort
|
|
339
|
+
}
|
|
340
|
+
const KEY_TABLE_MARKERS = [...baseKeyTableMarkers, ...profileKeyMarkers];
|
|
341
|
+
const EVENT_REGISTRY_MARKERS = ['EventRegistry', 'EVENTS', 'eventRegistry', 'events.ts'];
|
|
342
|
+
const TOKEN_REGISTRY_MARKERS = ['TokenRegistry', 'TOKENS', 'tokenRegistry', 'tokens.ts'];
|
|
343
|
+
const maxDiffLines = options.maxDiffLines ?? 80;
|
|
344
|
+
const wantDiff = options.diff === true;
|
|
345
|
+
const files = sourceList.map((c) => {
|
|
346
|
+
const tpa = isPublicApiPath(c.relativePath);
|
|
347
|
+
const tbe = isBarrelExportPath(c.relativePath);
|
|
348
|
+
const tad = isAdapterPath(c.relativePath);
|
|
349
|
+
const tpk = detectMarker(c.contents, KEY_TABLE_MARKERS) || /plugin[-_]?keys?/i.test(c.relativePath);
|
|
350
|
+
const ter = detectMarker(c.contents, EVENT_REGISTRY_MARKERS) || /events?\.(ts|tsx)$/.test(c.relativePath);
|
|
351
|
+
const ttr = detectMarker(c.contents, TOKEN_REGISTRY_MARKERS) || /tokens?\.(ts|tsx)$/.test(c.relativePath);
|
|
352
|
+
const out = {
|
|
353
|
+
relativePath: c.relativePath,
|
|
354
|
+
changeType: c.type,
|
|
355
|
+
outcome: outcomeFor(c.type),
|
|
356
|
+
sizeBytes: c.sizeBytes,
|
|
357
|
+
touchesPublicApi: tpa,
|
|
358
|
+
touchesBarrelExport: tbe,
|
|
359
|
+
touchesPluginKeys: tpk,
|
|
360
|
+
touchesEventRegistry: ter,
|
|
361
|
+
touchesTokenRegistry: ttr,
|
|
362
|
+
touchesAdapter: tad,
|
|
363
|
+
};
|
|
364
|
+
if (c.reason !== undefined)
|
|
365
|
+
out.reason = c.reason;
|
|
366
|
+
if (c.contents !== undefined)
|
|
367
|
+
out.finalContents = c.contents;
|
|
368
|
+
const explain = operationExplain({ type: c.type, ...(c.reason ? { reason: c.reason } : {}) });
|
|
369
|
+
if (explain)
|
|
370
|
+
out.operationDetail = explain;
|
|
371
|
+
// Compute before/after line counts and diff when we have virtual content.
|
|
372
|
+
if (c.contents !== undefined) {
|
|
373
|
+
const existing = readExistingFile(inspection.projectRoot, c.relativePath);
|
|
374
|
+
const beforeText = existing ?? '';
|
|
375
|
+
const afterText = c.contents;
|
|
376
|
+
out.beforeLineCount = existing === null ? 0 : beforeText.split('\n').length;
|
|
377
|
+
out.afterLineCount = afterText.split('\n').length;
|
|
378
|
+
if (wantDiff && c.type !== 'conflict' && c.type !== 'skip') {
|
|
379
|
+
const diff = unifiedDiff(beforeText, afterText, {
|
|
380
|
+
maxLines: maxDiffLines,
|
|
381
|
+
relativePath: c.relativePath,
|
|
382
|
+
});
|
|
383
|
+
out.diffPreview = diff.body;
|
|
384
|
+
if (diff.truncated)
|
|
385
|
+
out.diffTruncated = true;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return out;
|
|
389
|
+
});
|
|
390
|
+
const publicApiTouched = files.some((f) => f.touchesPublicApi);
|
|
391
|
+
const barrelExportTouched = files.some((f) => f.touchesBarrelExport);
|
|
392
|
+
const pluginKeysTouched = files.some((f) => f.touchesPluginKeys);
|
|
393
|
+
const eventRegistryTouched = files.some((f) => f.touchesEventRegistry);
|
|
394
|
+
const tokenRegistryTouched = files.some((f) => f.touchesTokenRegistry);
|
|
395
|
+
const adapterBoundaryTouched = files.some((f) => f.touchesAdapter);
|
|
396
|
+
// Signature
|
|
397
|
+
let signature = 'absent';
|
|
398
|
+
let signatureMessage;
|
|
399
|
+
if (plan.signature) {
|
|
400
|
+
signature = 'present';
|
|
401
|
+
const v = verifyPlan(plan);
|
|
402
|
+
if (!v.ok) {
|
|
403
|
+
signature = 'invalid';
|
|
404
|
+
signatureMessage = v.message;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
signatureMessage = 'verified';
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
// Boundary impact — current state on planned paths.
|
|
411
|
+
const potentialBoundaryConcerns = [];
|
|
412
|
+
const planIntroducedBoundaryConcerns = [];
|
|
413
|
+
if (options.includeBoundaries !== false && inspection.boundaryRegistry.size() > 0 && files.length > 0) {
|
|
414
|
+
const tsconfigPaths = loadTsconfigPaths(inspection.projectRoot);
|
|
415
|
+
const aliasOpts = tsconfigPaths.aliases.size > 0 ? { tsconfigPaths } : {};
|
|
416
|
+
try {
|
|
417
|
+
const scan = scanImports({ projectRoot: inspection.projectRoot });
|
|
418
|
+
const evalResult = evaluateBoundaries(scan, inspection.boundaryRegistry.list(), aliasOpts);
|
|
419
|
+
const targetSet = new Set(files.map((f) => f.relativePath));
|
|
420
|
+
for (const v of evalResult.violations) {
|
|
421
|
+
if (!targetSet.has(v.file))
|
|
422
|
+
continue;
|
|
423
|
+
potentialBoundaryConcerns.push({
|
|
424
|
+
file: v.file,
|
|
425
|
+
ruleId: v.ruleId,
|
|
426
|
+
importSpecifier: v.importSpecifier,
|
|
427
|
+
line: v.line,
|
|
428
|
+
severity: v.severity,
|
|
429
|
+
message: v.message,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
catch (e) {
|
|
434
|
+
limitations.push(`Boundary scan failed: ${e.message}`);
|
|
435
|
+
}
|
|
436
|
+
if (liveChanges.length > 0) {
|
|
437
|
+
try {
|
|
438
|
+
const plannedEdges = collectPlannedEdges(liveChanges);
|
|
439
|
+
const evalResult = evaluateBoundaries({ filesScanned: liveChanges.length, edges: plannedEdges, warnings: [] }, inspection.boundaryRegistry.list(), aliasOpts);
|
|
440
|
+
for (const v of evalResult.violations) {
|
|
441
|
+
planIntroducedBoundaryConcerns.push({
|
|
442
|
+
file: v.file,
|
|
443
|
+
ruleId: v.ruleId,
|
|
444
|
+
importSpecifier: v.importSpecifier,
|
|
445
|
+
line: v.line,
|
|
446
|
+
severity: v.severity,
|
|
447
|
+
message: v.message,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
catch (e) {
|
|
452
|
+
limitations.push(`Planned-content boundary scan failed: ${e.message}`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
limitations.push('Virtual file contents unavailable — planned-content boundary scan skipped.');
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// Ownership review.
|
|
460
|
+
const ownershipReviewFiles = [];
|
|
461
|
+
let ownershipReviewRequired = false;
|
|
462
|
+
if (options.includeOwnership !== false) {
|
|
463
|
+
try {
|
|
464
|
+
const own = await loadOwnershipRules(inspection.projectRoot);
|
|
465
|
+
const rules = own.rules;
|
|
466
|
+
if (rules.length > 0) {
|
|
467
|
+
const impact = ownershipImpactFor(files.map((f) => f.relativePath), rules);
|
|
468
|
+
ownershipReviewRequired = impact.requiredReviewFiles.length > 0;
|
|
469
|
+
for (const f of impact.requiredReviewFiles)
|
|
470
|
+
ownershipReviewFiles.push(f);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
catch (e) {
|
|
474
|
+
limitations.push(`Ownership impact failed: ${e.message}`);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
// Policy concerns (lightweight): we surface boundary errors as policy-relevant.
|
|
478
|
+
const policyConcerns = [];
|
|
479
|
+
if (options.includePolicies !== false) {
|
|
480
|
+
for (const v of planIntroducedBoundaryConcerns.concat(potentialBoundaryConcerns)) {
|
|
481
|
+
if (v.severity === 'error')
|
|
482
|
+
policyConcerns.push(`${v.ruleId} (${v.file})`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
const policyOwnedAreaTouched = policyConcerns.length > 0;
|
|
486
|
+
// Likely tests.
|
|
487
|
+
const likelyTests = [];
|
|
488
|
+
if (options.includeTests !== false) {
|
|
489
|
+
const allPaths = new Set(files.map((f) => f.relativePath));
|
|
490
|
+
for (const f of files) {
|
|
491
|
+
if (!/\.(ts|tsx)$/.test(f.relativePath))
|
|
492
|
+
continue;
|
|
493
|
+
if (f.relativePath.includes('/tests/') || f.relativePath.endsWith('.spec.ts'))
|
|
494
|
+
continue;
|
|
495
|
+
if (!f.relativePath.startsWith('src/') && !f.relativePath.startsWith('packages/'))
|
|
496
|
+
continue;
|
|
497
|
+
const candidate = f.relativePath
|
|
498
|
+
.replace(/^src\//, 'tests/')
|
|
499
|
+
.replace(/\.tsx?$/, '.spec.ts');
|
|
500
|
+
if (!allPaths.has(candidate))
|
|
501
|
+
likelyTests.push(`${f.relativePath} → expected ${candidate}`);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
// Required validations.
|
|
505
|
+
const requiredValidations = new Set([
|
|
506
|
+
'bun x tsc -p tsconfig.base.json --noEmit',
|
|
507
|
+
'bun test',
|
|
508
|
+
'shrk doctor',
|
|
509
|
+
'shrk check boundaries',
|
|
510
|
+
]);
|
|
511
|
+
if (publicApiTouched || barrelExportTouched)
|
|
512
|
+
requiredValidations.add('shrk api report --all --public-only');
|
|
513
|
+
if (pluginKeysTouched)
|
|
514
|
+
requiredValidations.add('shrk packs doctor --release');
|
|
515
|
+
if (adapterBoundaryTouched)
|
|
516
|
+
requiredValidations.add('shrk architecture violations');
|
|
517
|
+
if (potentialBoundaryConcerns.length > 0 || planIntroducedBoundaryConcerns.length > 0) {
|
|
518
|
+
requiredValidations.add('shrk architecture violations');
|
|
519
|
+
}
|
|
520
|
+
// Affected constructs / playbooks (lightweight).
|
|
521
|
+
await loadConstructs(inspection);
|
|
522
|
+
const constructList = listConstructs(inspection) ?? [];
|
|
523
|
+
const affectedConstructs = [];
|
|
524
|
+
for (const c of constructList) {
|
|
525
|
+
if (files.some((f) => f.relativePath.toLowerCase().includes(c.id.toLowerCase()))) {
|
|
526
|
+
affectedConstructs.push(c.id);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
const playbooks = await listPlaybooks(inspection);
|
|
530
|
+
const playbookHints = recommendPlaybooks(playbooks, plan.templateId ?? plan.name ?? planPath)
|
|
531
|
+
.slice(0, 5)
|
|
532
|
+
.map((p) => p.playbook.id);
|
|
533
|
+
// Apply readiness.
|
|
534
|
+
const reasons = [];
|
|
535
|
+
let readiness;
|
|
536
|
+
if (signature === 'invalid') {
|
|
537
|
+
readiness = PlanApplyReadiness.BlockedSignature;
|
|
538
|
+
reasons.push(`Signature invalid: ${signatureMessage ?? 'verification failed'}.`);
|
|
539
|
+
}
|
|
540
|
+
else if (files.some((f) => f.outcome === PlanSimulationOperationOutcome.Conflict)) {
|
|
541
|
+
readiness = PlanApplyReadiness.BlockedConflicts;
|
|
542
|
+
reasons.push('At least one operation is a conflict.');
|
|
543
|
+
}
|
|
544
|
+
else if (planIntroducedBoundaryConcerns.some((v) => v.severity === 'error')) {
|
|
545
|
+
readiness = PlanApplyReadiness.BlockedBoundary;
|
|
546
|
+
reasons.push('Plan introduces a boundary error.');
|
|
547
|
+
}
|
|
548
|
+
else if (policyConcerns.length > 0 && options.strict === true) {
|
|
549
|
+
readiness = PlanApplyReadiness.BlockedPolicy;
|
|
550
|
+
reasons.push('Policy concerns and --strict requested.');
|
|
551
|
+
}
|
|
552
|
+
else if (ownershipReviewRequired || publicApiTouched) {
|
|
553
|
+
readiness = PlanApplyReadiness.ReadyWithReview;
|
|
554
|
+
if (ownershipReviewRequired)
|
|
555
|
+
reasons.push('Ownership-protected files touched.');
|
|
556
|
+
if (publicApiTouched)
|
|
557
|
+
reasons.push('Public API touched — API review required.');
|
|
558
|
+
}
|
|
559
|
+
else if (signature === 'absent' && options.strict === true) {
|
|
560
|
+
readiness = PlanApplyReadiness.BlockedMissingReview;
|
|
561
|
+
reasons.push('Plan unsigned and --strict requested.');
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
readiness = PlanApplyReadiness.Ready;
|
|
565
|
+
}
|
|
566
|
+
const memoryHints = [];
|
|
567
|
+
if (options.includeMemory) {
|
|
568
|
+
memoryHints.push('Memory index (if built) can highlight historically risky files in this plan.');
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
schema: PLAN_SIMULATION_SCHEMA,
|
|
572
|
+
generatedAt: new Date().toISOString(),
|
|
573
|
+
source: planPath,
|
|
574
|
+
...(plan.templateId ? { templateId: plan.templateId } : {}),
|
|
575
|
+
planSchema,
|
|
576
|
+
signature,
|
|
577
|
+
...(signatureMessage ? { signatureMessage } : {}),
|
|
578
|
+
files,
|
|
579
|
+
affectedAreas: [],
|
|
580
|
+
affectedPathConventions: review?.affectedPaths ?? [],
|
|
581
|
+
publicApiTouched,
|
|
582
|
+
barrelExportTouched,
|
|
583
|
+
pluginKeysTouched,
|
|
584
|
+
eventRegistryTouched,
|
|
585
|
+
tokenRegistryTouched,
|
|
586
|
+
adapterBoundaryTouched,
|
|
587
|
+
policyOwnedAreaTouched,
|
|
588
|
+
ownershipReviewRequired,
|
|
589
|
+
ownershipReviewFiles,
|
|
590
|
+
likelyTests,
|
|
591
|
+
requiredValidations: [...requiredValidations],
|
|
592
|
+
affectedConstructs,
|
|
593
|
+
affectedPlaybooks: playbookHints,
|
|
594
|
+
potentialBoundaryConcerns,
|
|
595
|
+
planIntroducedBoundaryConcerns,
|
|
596
|
+
policyConcerns,
|
|
597
|
+
applyReadiness: readiness,
|
|
598
|
+
applyReadinessReasons: reasons,
|
|
599
|
+
humanApprovalReminder: 'MCP never writes. A human must run `shrk apply <plan> --verify-signature` after reviewing this simulation.',
|
|
600
|
+
memoryHints,
|
|
601
|
+
...(review ? { reviewPacket: review } : {}),
|
|
602
|
+
limitations,
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function listLines(title, items) {
|
|
606
|
+
if (items.length === 0)
|
|
607
|
+
return '';
|
|
608
|
+
return `${title}:\n${items.map((i) => ` • ${i}`).join('\n')}\n\n`;
|
|
609
|
+
}
|
|
610
|
+
export function renderPlanSimulationText(r) {
|
|
611
|
+
let out = `=== Plan simulation ===\n`;
|
|
612
|
+
out += ` source ${r.source}\n`;
|
|
613
|
+
if (r.templateId)
|
|
614
|
+
out += ` template ${r.templateId}\n`;
|
|
615
|
+
out += ` plan schema ${r.planSchema}\n`;
|
|
616
|
+
out += ` signature ${r.signature}${r.signatureMessage ? ' — ' + r.signatureMessage : ''}\n`;
|
|
617
|
+
out += ` readiness ${r.applyReadiness}\n`;
|
|
618
|
+
out += ` files ${r.files.length}\n\n`;
|
|
619
|
+
if (r.files.length > 0) {
|
|
620
|
+
out += `Files:\n`;
|
|
621
|
+
for (const f of r.files) {
|
|
622
|
+
const flags = [];
|
|
623
|
+
if (f.touchesPublicApi)
|
|
624
|
+
flags.push('public-api');
|
|
625
|
+
if (f.touchesBarrelExport)
|
|
626
|
+
flags.push('barrel');
|
|
627
|
+
if (f.touchesPluginKeys)
|
|
628
|
+
flags.push('plugin-keys');
|
|
629
|
+
if (f.touchesEventRegistry)
|
|
630
|
+
flags.push('events');
|
|
631
|
+
if (f.touchesTokenRegistry)
|
|
632
|
+
flags.push('tokens');
|
|
633
|
+
if (f.touchesAdapter)
|
|
634
|
+
flags.push('adapter');
|
|
635
|
+
const counts = f.beforeLineCount !== undefined && f.afterLineCount !== undefined
|
|
636
|
+
? ` (${f.beforeLineCount}→${f.afterLineCount} lines)`
|
|
637
|
+
: '';
|
|
638
|
+
out += ` [${f.outcome.padEnd(18)}] ${f.changeType.padEnd(14)} ${f.relativePath}${flags.length ? ' (' + flags.join(', ') + ')' : ''}${counts}\n`;
|
|
639
|
+
if (f.operationDetail)
|
|
640
|
+
out += ` • ${f.operationDetail}\n`;
|
|
641
|
+
if (f.diffPreview) {
|
|
642
|
+
for (const line of f.diffPreview.split('\n')) {
|
|
643
|
+
if (!line)
|
|
644
|
+
continue;
|
|
645
|
+
out += ` ${line}\n`;
|
|
646
|
+
}
|
|
647
|
+
if (f.diffTruncated)
|
|
648
|
+
out += ` … (diff truncated; raise --max-diff-lines)\n`;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
out += `\n`;
|
|
652
|
+
}
|
|
653
|
+
if (r.applyReadinessReasons.length)
|
|
654
|
+
out += listLines('Readiness reasons', r.applyReadinessReasons);
|
|
655
|
+
if (r.potentialBoundaryConcerns.length) {
|
|
656
|
+
out += `Existing boundary concerns:\n`;
|
|
657
|
+
for (const v of r.potentialBoundaryConcerns)
|
|
658
|
+
out += ` ${v.severity.toUpperCase().padEnd(8)} ${v.file}:${v.line} ${v.importSpecifier} (${v.ruleId})\n`;
|
|
659
|
+
out += `\n`;
|
|
660
|
+
}
|
|
661
|
+
if (r.planIntroducedBoundaryConcerns.length) {
|
|
662
|
+
out += `Plan-introduced boundary concerns:\n`;
|
|
663
|
+
for (const v of r.planIntroducedBoundaryConcerns)
|
|
664
|
+
out += ` ${v.severity.toUpperCase().padEnd(8)} ${v.file}:${v.line} ${v.importSpecifier} (${v.ruleId})\n`;
|
|
665
|
+
out += `\n`;
|
|
666
|
+
}
|
|
667
|
+
if (r.ownershipReviewFiles.length)
|
|
668
|
+
out += listLines('Ownership review files', r.ownershipReviewFiles);
|
|
669
|
+
if (r.likelyTests.length)
|
|
670
|
+
out += listLines('Likely tests', r.likelyTests);
|
|
671
|
+
if (r.requiredValidations.length)
|
|
672
|
+
out += listLines('Required validations', r.requiredValidations);
|
|
673
|
+
if (r.affectedConstructs.length)
|
|
674
|
+
out += listLines('Affected constructs', r.affectedConstructs);
|
|
675
|
+
if (r.affectedPlaybooks.length)
|
|
676
|
+
out += listLines('Recommended playbooks', r.affectedPlaybooks);
|
|
677
|
+
if (r.policyConcerns.length)
|
|
678
|
+
out += listLines('Policy concerns', r.policyConcerns);
|
|
679
|
+
if (r.limitations.length)
|
|
680
|
+
out += listLines('Limitations', r.limitations);
|
|
681
|
+
out += `\n${r.humanApprovalReminder}\n`;
|
|
682
|
+
return out;
|
|
683
|
+
}
|
|
684
|
+
function mdList(title, items) {
|
|
685
|
+
if (items.length === 0)
|
|
686
|
+
return '';
|
|
687
|
+
return `## ${title}\n${items.map((i) => `- ${i}`).join('\n')}\n\n`;
|
|
688
|
+
}
|
|
689
|
+
export function renderPlanSimulationMarkdown(r) {
|
|
690
|
+
let out = `# Plan simulation\n\n`;
|
|
691
|
+
out += `- **source**: ${r.source}\n`;
|
|
692
|
+
if (r.templateId)
|
|
693
|
+
out += `- **template**: ${r.templateId}\n`;
|
|
694
|
+
out += `- **plan schema**: ${r.planSchema}\n`;
|
|
695
|
+
out += `- **signature**: ${r.signature}${r.signatureMessage ? ' — ' + r.signatureMessage : ''}\n`;
|
|
696
|
+
out += `- **readiness**: ${r.applyReadiness}\n`;
|
|
697
|
+
out += `- **generated**: ${r.generatedAt}\n\n`;
|
|
698
|
+
if (r.files.length > 0) {
|
|
699
|
+
out += `## Files\n\n`;
|
|
700
|
+
out += `| Outcome | Change | Path | Lines | Flags | Detail |\n| --- | --- | --- | --- | --- | --- |\n`;
|
|
701
|
+
for (const f of r.files) {
|
|
702
|
+
const flags = [];
|
|
703
|
+
if (f.touchesPublicApi)
|
|
704
|
+
flags.push('public-api');
|
|
705
|
+
if (f.touchesBarrelExport)
|
|
706
|
+
flags.push('barrel');
|
|
707
|
+
if (f.touchesPluginKeys)
|
|
708
|
+
flags.push('plugin-keys');
|
|
709
|
+
if (f.touchesEventRegistry)
|
|
710
|
+
flags.push('events');
|
|
711
|
+
if (f.touchesTokenRegistry)
|
|
712
|
+
flags.push('tokens');
|
|
713
|
+
if (f.touchesAdapter)
|
|
714
|
+
flags.push('adapter');
|
|
715
|
+
const counts = f.beforeLineCount !== undefined && f.afterLineCount !== undefined
|
|
716
|
+
? `${f.beforeLineCount}→${f.afterLineCount}`
|
|
717
|
+
: '—';
|
|
718
|
+
out += `| ${f.outcome} | ${f.changeType} | \`${f.relativePath}\` | ${counts} | ${flags.join(', ') || '—'} | ${f.operationDetail ?? ''} |\n`;
|
|
719
|
+
}
|
|
720
|
+
out += `\n`;
|
|
721
|
+
// Diff blocks
|
|
722
|
+
const diffs = r.files.filter((f) => f.diffPreview);
|
|
723
|
+
if (diffs.length > 0) {
|
|
724
|
+
out += `## Diff previews\n\n`;
|
|
725
|
+
for (const f of diffs) {
|
|
726
|
+
out += `### \`${f.relativePath}\`\n\n`;
|
|
727
|
+
out += '```diff\n' + f.diffPreview + '```\n';
|
|
728
|
+
if (f.diffTruncated)
|
|
729
|
+
out += `_diff truncated — raise \`--max-diff-lines\`._\n`;
|
|
730
|
+
out += '\n';
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
out += mdList('Readiness reasons', r.applyReadinessReasons);
|
|
735
|
+
out += mdList('Existing boundary concerns', r.potentialBoundaryConcerns.map((v) => `${v.severity.toUpperCase()} ${v.file}:${v.line} ${v.importSpecifier} (${v.ruleId})`));
|
|
736
|
+
out += mdList('Plan-introduced boundary concerns', r.planIntroducedBoundaryConcerns.map((v) => `${v.severity.toUpperCase()} ${v.file}:${v.line} ${v.importSpecifier} (${v.ruleId})`));
|
|
737
|
+
out += mdList('Ownership review files', r.ownershipReviewFiles);
|
|
738
|
+
out += mdList('Likely tests', r.likelyTests);
|
|
739
|
+
out += mdList('Required validations', r.requiredValidations);
|
|
740
|
+
out += mdList('Affected constructs', r.affectedConstructs);
|
|
741
|
+
out += mdList('Recommended playbooks', r.affectedPlaybooks);
|
|
742
|
+
out += mdList('Policy concerns', r.policyConcerns);
|
|
743
|
+
out += mdList('Limitations', r.limitations);
|
|
744
|
+
out += `\n> ${r.humanApprovalReminder}\n`;
|
|
745
|
+
return out;
|
|
746
|
+
}
|
|
747
|
+
function htmlEscape(s) {
|
|
748
|
+
return s
|
|
749
|
+
.replace(/&/g, '&')
|
|
750
|
+
.replace(/</g, '<')
|
|
751
|
+
.replace(/>/g, '>')
|
|
752
|
+
.replace(/"/g, '"')
|
|
753
|
+
.replace(/'/g, ''');
|
|
754
|
+
}
|
|
755
|
+
export function renderPlanSimulationHtml(r) {
|
|
756
|
+
const md = renderPlanSimulationMarkdown(r);
|
|
757
|
+
// Strip the diff blocks from the markdown and re-render them as collapsible
|
|
758
|
+
// <details> sections so large diffs don't blow out the page.
|
|
759
|
+
const baseMd = md.replace(/## Diff previews[\s\S]*$/m, '').trimEnd();
|
|
760
|
+
let details = '';
|
|
761
|
+
for (const f of r.files) {
|
|
762
|
+
if (!f.diffPreview)
|
|
763
|
+
continue;
|
|
764
|
+
details += `<details><summary>Diff: ${htmlEscape(f.relativePath)}${f.diffTruncated ? ' (truncated)' : ''}</summary><pre><code>${htmlEscape(f.diffPreview)}</code></pre></details>\n`;
|
|
765
|
+
}
|
|
766
|
+
return `<!doctype html><html><head><meta charset="utf-8"><title>Plan simulation</title></head><body><pre>${htmlEscape(baseMd)}</pre>\n${details}</body></html>\n`;
|
|
767
|
+
}
|