@shrkcrft/cli 0.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/asset-preview/apply-action-hint-stub.d.ts +28 -0
- package/dist/asset-preview/apply-action-hint-stub.d.ts.map +1 -0
- package/dist/asset-preview/apply-action-hint-stub.js +170 -0
- package/dist/asset-preview/apply-asset-preview.d.ts +31 -0
- package/dist/asset-preview/apply-asset-preview.d.ts.map +1 -0
- package/dist/asset-preview/apply-asset-preview.js +210 -0
- package/dist/asset-preview/apply-knowledge-stale-fix.d.ts +37 -0
- package/dist/asset-preview/apply-knowledge-stale-fix.d.ts.map +1 -0
- package/dist/asset-preview/apply-knowledge-stale-fix.js +344 -0
- package/dist/asset-preview/apply-missing-barrel.d.ts +15 -0
- package/dist/asset-preview/apply-missing-barrel.d.ts.map +1 -0
- package/dist/asset-preview/apply-missing-barrel.js +65 -0
- package/dist/asset-preview/apply-template-drift-fix.d.ts +21 -0
- package/dist/asset-preview/apply-template-drift-fix.d.ts.map +1 -0
- package/dist/asset-preview/apply-template-drift-fix.js +125 -0
- package/dist/asset-preview/apply-template-update.d.ts +43 -0
- package/dist/asset-preview/apply-template-update.d.ts.map +1 -0
- package/dist/asset-preview/apply-template-update.js +257 -0
- package/dist/asset-preview/entry-mutator.d.ts +106 -0
- package/dist/asset-preview/entry-mutator.d.ts.map +1 -0
- package/dist/asset-preview/entry-mutator.js +428 -0
- package/dist/authoring/authoring-kit.d.ts +36 -0
- package/dist/authoring/authoring-kit.d.ts.map +1 -0
- package/dist/authoring/authoring-kit.js +106 -0
- package/dist/command-registry.d.ts +158 -0
- package/dist/command-registry.d.ts.map +1 -0
- package/dist/command-registry.js +348 -0
- package/dist/commands/apply.command.d.ts +3 -0
- package/dist/commands/apply.command.d.ts.map +1 -0
- package/dist/commands/apply.command.js +879 -0
- package/dist/commands/architecture.command.d.ts +5 -0
- package/dist/commands/architecture.command.d.ts.map +1 -0
- package/dist/commands/architecture.command.js +141 -0
- package/dist/commands/ask.command.d.ts +3 -0
- package/dist/commands/ask.command.d.ts.map +1 -0
- package/dist/commands/ask.command.js +58 -0
- package/dist/commands/audit.command.d.ts +3 -0
- package/dist/commands/audit.command.d.ts.map +1 -0
- package/dist/commands/audit.command.js +141 -0
- package/dist/commands/biome.command.d.ts +7 -0
- package/dist/commands/biome.command.d.ts.map +1 -0
- package/dist/commands/biome.command.js +350 -0
- package/dist/commands/boundaries.command.d.ts +9 -0
- package/dist/commands/boundaries.command.d.ts.map +1 -0
- package/dist/commands/boundaries.command.js +314 -0
- package/dist/commands/brief.command.d.ts +3 -0
- package/dist/commands/brief.command.d.ts.map +1 -0
- package/dist/commands/brief.command.js +206 -0
- package/dist/commands/bundle.command.d.ts +3 -0
- package/dist/commands/bundle.command.d.ts.map +1 -0
- package/dist/commands/bundle.command.js +1183 -0
- package/dist/commands/changes.command.d.ts +3 -0
- package/dist/commands/changes.command.d.ts.map +1 -0
- package/dist/commands/changes.command.js +155 -0
- package/dist/commands/check.command.d.ts +3 -0
- package/dist/commands/check.command.d.ts.map +1 -0
- package/dist/commands/check.command.js +553 -0
- package/dist/commands/checks.command.d.ts +29 -0
- package/dist/commands/checks.command.d.ts.map +1 -0
- package/dist/commands/checks.command.js +521 -0
- package/dist/commands/ci.command.d.ts +3 -0
- package/dist/commands/ci.command.d.ts.map +1 -0
- package/dist/commands/ci.command.js +680 -0
- package/dist/commands/codemod.command.d.ts +3 -0
- package/dist/commands/codemod.command.d.ts.map +1 -0
- package/dist/commands/codemod.command.js +130 -0
- package/dist/commands/command-catalog.d.ts +265 -0
- package/dist/commands/command-catalog.d.ts.map +1 -0
- package/dist/commands/command-catalog.js +3242 -0
- package/dist/commands/commands.command.d.ts +92 -0
- package/dist/commands/commands.command.d.ts.map +1 -0
- package/dist/commands/commands.command.js +1208 -0
- package/dist/commands/constructs.command.d.ts +15 -0
- package/dist/commands/constructs.command.d.ts.map +1 -0
- package/dist/commands/constructs.command.js +669 -0
- package/dist/commands/context.command.d.ts +3 -0
- package/dist/commands/context.command.d.ts.map +1 -0
- package/dist/commands/context.command.js +120 -0
- package/dist/commands/contract-gate.command.d.ts +5 -0
- package/dist/commands/contract-gate.command.d.ts.map +1 -0
- package/dist/commands/contract-gate.command.js +208 -0
- package/dist/commands/contract-templates.command.d.ts +8 -0
- package/dist/commands/contract-templates.command.d.ts.map +1 -0
- package/dist/commands/contract-templates.command.js +151 -0
- package/dist/commands/contract.command.d.ts +3 -0
- package/dist/commands/contract.command.d.ts.map +1 -0
- package/dist/commands/contract.command.js +105 -0
- package/dist/commands/conventions.command.d.ts +8 -0
- package/dist/commands/conventions.command.d.ts.map +1 -0
- package/dist/commands/conventions.command.js +169 -0
- package/dist/commands/coverage.command.d.ts +3 -0
- package/dist/commands/coverage.command.d.ts.map +1 -0
- package/dist/commands/coverage.command.js +56 -0
- package/dist/commands/daily.commands.d.ts +5 -0
- package/dist/commands/daily.commands.d.ts.map +1 -0
- package/dist/commands/daily.commands.js +224 -0
- package/dist/commands/dashboard-export.command.d.ts +4 -0
- package/dist/commands/dashboard-export.command.d.ts.map +1 -0
- package/dist/commands/dashboard-export.command.js +86 -0
- package/dist/commands/dashboard.command.d.ts +3 -0
- package/dist/commands/dashboard.command.d.ts.map +1 -0
- package/dist/commands/dashboard.command.js +106 -0
- package/dist/commands/dev.command.d.ts +3 -0
- package/dist/commands/dev.command.d.ts.map +1 -0
- package/dist/commands/dev.command.js +1392 -0
- package/dist/commands/diagnostics.command.d.ts +5 -0
- package/dist/commands/diagnostics.command.d.ts.map +1 -0
- package/dist/commands/diagnostics.command.js +97 -0
- package/dist/commands/docs.command.d.ts +4 -0
- package/dist/commands/docs.command.d.ts.map +1 -0
- package/dist/commands/docs.command.js +34 -0
- package/dist/commands/doctor.command.d.ts +7 -0
- package/dist/commands/doctor.command.d.ts.map +1 -0
- package/dist/commands/doctor.command.js +681 -0
- package/dist/commands/drift.command.d.ts +3 -0
- package/dist/commands/drift.command.d.ts.map +1 -0
- package/dist/commands/drift.command.js +124 -0
- package/dist/commands/eslint.command.d.ts +7 -0
- package/dist/commands/eslint.command.d.ts.map +1 -0
- package/dist/commands/eslint.command.js +423 -0
- package/dist/commands/explore.command.d.ts +3 -0
- package/dist/commands/explore.command.d.ts.map +1 -0
- package/dist/commands/explore.command.js +65 -0
- package/dist/commands/export-bundle.command.d.ts +6 -0
- package/dist/commands/export-bundle.command.d.ts.map +1 -0
- package/dist/commands/export-bundle.command.js +96 -0
- package/dist/commands/export.command.d.ts +3 -0
- package/dist/commands/export.command.d.ts.map +1 -0
- package/dist/commands/export.command.js +83 -0
- package/dist/commands/feedback-dispatch.command.d.ts +12 -0
- package/dist/commands/feedback-dispatch.command.d.ts.map +1 -0
- package/dist/commands/feedback-dispatch.command.js +63 -0
- package/dist/commands/feedback.command.d.ts +11 -0
- package/dist/commands/feedback.command.d.ts.map +1 -0
- package/dist/commands/feedback.command.js +336 -0
- package/dist/commands/fix.command.d.ts +3 -0
- package/dist/commands/fix.command.d.ts.map +1 -0
- package/dist/commands/fix.command.js +776 -0
- package/dist/commands/gen.command.d.ts +3 -0
- package/dist/commands/gen.command.d.ts.map +1 -0
- package/dist/commands/gen.command.js +136 -0
- package/dist/commands/git.command.d.ts +6 -0
- package/dist/commands/git.command.d.ts.map +1 -0
- package/dist/commands/git.command.js +81 -0
- package/dist/commands/graph.command.d.ts +3 -0
- package/dist/commands/graph.command.d.ts.map +1 -0
- package/dist/commands/graph.command.js +287 -0
- package/dist/commands/grounding.command.d.ts +7 -0
- package/dist/commands/grounding.command.d.ts.map +1 -0
- package/dist/commands/grounding.command.js +54 -0
- package/dist/commands/help.command.d.ts +20 -0
- package/dist/commands/help.command.d.ts.map +1 -0
- package/dist/commands/help.command.js +127 -0
- package/dist/commands/helper.command.d.ts +6 -0
- package/dist/commands/helper.command.d.ts.map +1 -0
- package/dist/commands/helper.command.js +170 -0
- package/dist/commands/ide.command.d.ts +6 -0
- package/dist/commands/ide.command.d.ts.map +1 -0
- package/dist/commands/ide.command.js +340 -0
- package/dist/commands/impact.command.d.ts +3 -0
- package/dist/commands/impact.command.d.ts.map +1 -0
- package/dist/commands/impact.command.js +819 -0
- package/dist/commands/import.command.d.ts +3 -0
- package/dist/commands/import.command.d.ts.map +1 -0
- package/dist/commands/import.command.js +115 -0
- package/dist/commands/infer.command.d.ts +3 -0
- package/dist/commands/infer.command.d.ts.map +1 -0
- package/dist/commands/infer.command.js +227 -0
- package/dist/commands/ingest.command.d.ts +6 -0
- package/dist/commands/ingest.command.d.ts.map +1 -0
- package/dist/commands/ingest.command.js +532 -0
- package/dist/commands/init.command.d.ts +3 -0
- package/dist/commands/init.command.d.ts.map +1 -0
- package/dist/commands/init.command.js +301 -0
- package/dist/commands/inspect.command.d.ts +3 -0
- package/dist/commands/inspect.command.d.ts.map +1 -0
- package/dist/commands/inspect.command.js +122 -0
- package/dist/commands/knowledge-author.command.d.ts +22 -0
- package/dist/commands/knowledge-author.command.d.ts.map +1 -0
- package/dist/commands/knowledge-author.command.js +366 -0
- package/dist/commands/knowledge-propose.command.d.ts +3 -0
- package/dist/commands/knowledge-propose.command.d.ts.map +1 -0
- package/dist/commands/knowledge-propose.command.js +125 -0
- package/dist/commands/knowledge.command.d.ts +18 -0
- package/dist/commands/knowledge.command.d.ts.map +1 -0
- package/dist/commands/knowledge.command.js +538 -0
- package/dist/commands/languages.command.d.ts +3 -0
- package/dist/commands/languages.command.d.ts.map +1 -0
- package/dist/commands/languages.command.js +300 -0
- package/dist/commands/lint.command.d.ts +15 -0
- package/dist/commands/lint.command.d.ts.map +1 -0
- package/dist/commands/lint.command.js +194 -0
- package/dist/commands/mcp.command.d.ts +3 -0
- package/dist/commands/mcp.command.d.ts.map +1 -0
- package/dist/commands/mcp.command.js +74 -0
- package/dist/commands/memory.command.d.ts +11 -0
- package/dist/commands/memory.command.d.ts.map +1 -0
- package/dist/commands/memory.command.js +264 -0
- package/dist/commands/onboard.command.d.ts +3 -0
- package/dist/commands/onboard.command.d.ts.map +1 -0
- package/dist/commands/onboard.command.js +650 -0
- package/dist/commands/orchestrate.command.d.ts +3 -0
- package/dist/commands/orchestrate.command.d.ts.map +1 -0
- package/dist/commands/orchestrate.command.js +49 -0
- package/dist/commands/owners.command.d.ts +5 -0
- package/dist/commands/owners.command.d.ts.map +1 -0
- package/dist/commands/owners.command.js +113 -0
- package/dist/commands/ownership.command.d.ts +5 -0
- package/dist/commands/ownership.command.d.ts.map +1 -0
- package/dist/commands/ownership.command.js +117 -0
- package/dist/commands/pack-author.command.d.ts +30 -0
- package/dist/commands/pack-author.command.d.ts.map +1 -0
- package/dist/commands/pack-author.command.js +242 -0
- package/dist/commands/packs-new.d.ts +27 -0
- package/dist/commands/packs-new.d.ts.map +1 -0
- package/dist/commands/packs-new.js +805 -0
- package/dist/commands/packs.command.d.ts +15 -0
- package/dist/commands/packs.command.d.ts.map +1 -0
- package/dist/commands/packs.command.js +958 -0
- package/dist/commands/paths.command.d.ts +6 -0
- package/dist/commands/paths.command.d.ts.map +1 -0
- package/dist/commands/paths.command.js +97 -0
- package/dist/commands/pipelines.command.d.ts +9 -0
- package/dist/commands/pipelines.command.d.ts.map +1 -0
- package/dist/commands/pipelines.command.js +308 -0
- package/dist/commands/plan-check.command.d.ts +27 -0
- package/dist/commands/plan-check.command.d.ts.map +1 -0
- package/dist/commands/plan-check.command.js +150 -0
- package/dist/commands/plan-simulate.command.d.ts +3 -0
- package/dist/commands/plan-simulate.command.d.ts.map +1 -0
- package/dist/commands/plan-simulate.command.js +60 -0
- package/dist/commands/plan.command.d.ts +8 -0
- package/dist/commands/plan.command.d.ts.map +1 -0
- package/dist/commands/plan.command.js +139 -0
- package/dist/commands/playbooks.command.d.ts +10 -0
- package/dist/commands/playbooks.command.d.ts.map +1 -0
- package/dist/commands/playbooks.command.js +296 -0
- package/dist/commands/plugin.command.d.ts +11 -0
- package/dist/commands/plugin.command.d.ts.map +1 -0
- package/dist/commands/plugin.command.js +394 -0
- package/dist/commands/policy.command.d.ts +8 -0
- package/dist/commands/policy.command.d.ts.map +1 -0
- package/dist/commands/policy.command.js +451 -0
- package/dist/commands/pr.command.d.ts +3 -0
- package/dist/commands/pr.command.d.ts.map +1 -0
- package/dist/commands/pr.command.js +132 -0
- package/dist/commands/preflight.command.d.ts +3 -0
- package/dist/commands/preflight.command.d.ts.map +1 -0
- package/dist/commands/preflight.command.js +102 -0
- package/dist/commands/presets.command.d.ts +17 -0
- package/dist/commands/presets.command.d.ts.map +1 -0
- package/dist/commands/presets.command.js +647 -0
- package/dist/commands/profiles.command.d.ts +7 -0
- package/dist/commands/profiles.command.d.ts.map +1 -0
- package/dist/commands/profiles.command.js +151 -0
- package/dist/commands/provenance.command.d.ts +26 -0
- package/dist/commands/provenance.command.d.ts.map +1 -0
- package/dist/commands/provenance.command.js +237 -0
- package/dist/commands/quality.command.d.ts +5 -0
- package/dist/commands/quality.command.d.ts.map +1 -0
- package/dist/commands/quality.command.js +69 -0
- package/dist/commands/recommend.command.d.ts +4 -0
- package/dist/commands/recommend.command.d.ts.map +1 -0
- package/dist/commands/recommend.command.js +270 -0
- package/dist/commands/registrations.command.d.ts +3 -0
- package/dist/commands/registrations.command.d.ts.map +1 -0
- package/dist/commands/registrations.command.js +300 -0
- package/dist/commands/registry.command.d.ts +4 -0
- package/dist/commands/registry.command.d.ts.map +1 -0
- package/dist/commands/registry.command.js +37 -0
- package/dist/commands/release.command.d.ts +4 -0
- package/dist/commands/release.command.d.ts.map +1 -0
- package/dist/commands/release.command.js +639 -0
- package/dist/commands/repo.command.d.ts +3 -0
- package/dist/commands/repo.command.d.ts.map +1 -0
- package/dist/commands/repo.command.js +24 -0
- package/dist/commands/report.command.d.ts +3 -0
- package/dist/commands/report.command.d.ts.map +1 -0
- package/dist/commands/report.command.js +511 -0
- package/dist/commands/reposet.command.d.ts +6 -0
- package/dist/commands/reposet.command.d.ts.map +1 -0
- package/dist/commands/reposet.command.js +120 -0
- package/dist/commands/review.command.d.ts +3 -0
- package/dist/commands/review.command.d.ts.map +1 -0
- package/dist/commands/review.command.js +354 -0
- package/dist/commands/risk.command.d.ts +3 -0
- package/dist/commands/risk.command.d.ts.map +1 -0
- package/dist/commands/risk.command.js +56 -0
- package/dist/commands/rounds.command.d.ts +8 -0
- package/dist/commands/rounds.command.d.ts.map +1 -0
- package/dist/commands/rounds.command.js +180 -0
- package/dist/commands/rules.command.d.ts +49 -0
- package/dist/commands/rules.command.d.ts.map +1 -0
- package/dist/commands/rules.command.js +435 -0
- package/dist/commands/runtime.command.d.ts +3 -0
- package/dist/commands/runtime.command.d.ts.map +1 -0
- package/dist/commands/runtime.command.js +56 -0
- package/dist/commands/safety.command.d.ts +3 -0
- package/dist/commands/safety.command.d.ts.map +1 -0
- package/dist/commands/safety.command.js +117 -0
- package/dist/commands/scaffolds.command.d.ts +5 -0
- package/dist/commands/scaffolds.command.d.ts.map +1 -0
- package/dist/commands/scaffolds.command.js +122 -0
- package/dist/commands/schemas.command.d.ts +21 -0
- package/dist/commands/schemas.command.d.ts.map +1 -0
- package/dist/commands/schemas.command.js +296 -0
- package/dist/commands/search.command.d.ts +12 -0
- package/dist/commands/search.command.d.ts.map +1 -0
- package/dist/commands/search.command.js +275 -0
- package/dist/commands/self-config.command.d.ts +7 -0
- package/dist/commands/self-config.command.d.ts.map +1 -0
- package/dist/commands/self-config.command.js +156 -0
- package/dist/commands/self.command.d.ts +3 -0
- package/dist/commands/self.command.d.ts.map +1 -0
- package/dist/commands/self.command.js +117 -0
- package/dist/commands/simulate.command.d.ts +3 -0
- package/dist/commands/simulate.command.d.ts.map +1 -0
- package/dist/commands/simulate.command.js +54 -0
- package/dist/commands/spec.command.d.ts +29 -0
- package/dist/commands/spec.command.d.ts.map +1 -0
- package/dist/commands/spec.command.js +985 -0
- package/dist/commands/start-here.command.d.ts +3 -0
- package/dist/commands/start-here.command.d.ts.map +1 -0
- package/dist/commands/start-here.command.js +35 -0
- package/dist/commands/stats.command.d.ts +3 -0
- package/dist/commands/stats.command.d.ts.map +1 -0
- package/dist/commands/stats.command.js +88 -0
- package/dist/commands/surface.command.d.ts +15 -0
- package/dist/commands/surface.command.d.ts.map +1 -0
- package/dist/commands/surface.command.js +328 -0
- package/dist/commands/task-context.command.d.ts +7 -0
- package/dist/commands/task-context.command.d.ts.map +1 -0
- package/dist/commands/task-context.command.js +646 -0
- package/dist/commands/task.command.d.ts +3 -0
- package/dist/commands/task.command.d.ts.map +1 -0
- package/dist/commands/task.command.js +301 -0
- package/dist/commands/template-quality.command.d.ts +5 -0
- package/dist/commands/template-quality.command.d.ts.map +1 -0
- package/dist/commands/template-quality.command.js +128 -0
- package/dist/commands/templates.command.d.ts +26 -0
- package/dist/commands/templates.command.d.ts.map +1 -0
- package/dist/commands/templates.command.js +964 -0
- package/dist/commands/test.command.d.ts +3 -0
- package/dist/commands/test.command.d.ts.map +1 -0
- package/dist/commands/test.command.js +262 -0
- package/dist/commands/tests.command.d.ts +5 -0
- package/dist/commands/tests.command.d.ts.map +1 -0
- package/dist/commands/tests.command.js +97 -0
- package/dist/commands/trace.command.d.ts +3 -0
- package/dist/commands/trace.command.d.ts.map +1 -0
- package/dist/commands/trace.command.js +121 -0
- package/dist/commands/upgrade.command.d.ts +4 -0
- package/dist/commands/upgrade.command.d.ts.map +1 -0
- package/dist/commands/upgrade.command.js +43 -0
- package/dist/commands/version.command.d.ts +3 -0
- package/dist/commands/version.command.d.ts.map +1 -0
- package/dist/commands/version.command.js +10 -0
- package/dist/commands/why.command.d.ts +24 -0
- package/dist/commands/why.command.d.ts.map +1 -0
- package/dist/commands/why.command.js +119 -0
- package/dist/dashboard/dashboard-api-server.d.ts +21 -0
- package/dist/dashboard/dashboard-api-server.d.ts.map +1 -0
- package/dist/dashboard/dashboard-api-server.js +410 -0
- package/dist/dashboard/live-session-server.d.ts +18 -0
- package/dist/dashboard/live-session-server.d.ts.map +1 -0
- package/dist/dashboard/live-session-server.js +133 -0
- package/dist/diff/collect-changed-paths.d.ts +27 -0
- package/dist/diff/collect-changed-paths.d.ts.map +1 -0
- package/dist/diff/collect-changed-paths.js +68 -0
- package/dist/doctor/doctor-tags.d.ts +63 -0
- package/dist/doctor/doctor-tags.d.ts.map +1 -0
- package/dist/doctor/doctor-tags.js +146 -0
- package/dist/export/export-formats.d.ts +22 -0
- package/dist/export/export-formats.d.ts.map +1 -0
- package/dist/export/export-formats.js +135 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/init/detected-block.d.ts +57 -0
- package/dist/init/detected-block.d.ts.map +1 -0
- package/dist/init/detected-block.js +197 -0
- package/dist/init/gitignore.d.ts +30 -0
- package/dist/init/gitignore.d.ts.map +1 -0
- package/dist/init/gitignore.js +110 -0
- package/dist/init/init-templates.d.ts +6 -0
- package/dist/init/init-templates.d.ts.map +1 -0
- package/dist/init/init-templates.js +413 -0
- package/dist/main.d.ts +18 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +699 -0
- package/dist/output/failure-hints.d.ts +55 -0
- package/dist/output/failure-hints.d.ts.map +1 -0
- package/dist/output/failure-hints.js +159 -0
- package/dist/output/format-output.d.ts +9 -0
- package/dist/output/format-output.d.ts.map +1 -0
- package/dist/output/format-output.js +26 -0
- package/dist/output/print-error.d.ts +3 -0
- package/dist/output/print-error.d.ts.map +1 -0
- package/dist/output/print-error.js +14 -0
- package/dist/output/watch-loop.d.ts +37 -0
- package/dist/output/watch-loop.d.ts.map +1 -0
- package/dist/output/watch-loop.js +115 -0
- package/dist/schemas/json-schemas.d.ts +1630 -0
- package/dist/schemas/json-schemas.d.ts.map +1 -0
- package/dist/schemas/json-schemas.js +811 -0
- package/dist/surface/about.d.ts +10 -0
- package/dist/surface/about.d.ts.map +1 -0
- package/dist/surface/about.js +53 -0
- package/dist/surface/load-surface-context.d.ts +34 -0
- package/dist/surface/load-surface-context.d.ts.map +1 -0
- package/dist/surface/load-surface-context.js +100 -0
- package/dist/surface/no-args-landing.d.ts +7 -0
- package/dist/surface/no-args-landing.d.ts.map +1 -0
- package/dist/surface/no-args-landing.js +36 -0
- package/dist/surface/not-enabled-error.d.ts +24 -0
- package/dist/surface/not-enabled-error.d.ts.map +1 -0
- package/dist/surface/not-enabled-error.js +36 -0
- package/dist/surface/profiles.d.ts +37 -0
- package/dist/surface/profiles.d.ts.map +1 -0
- package/dist/surface/profiles.js +151 -0
- package/dist/surface/shape-defaults.d.ts +21 -0
- package/dist/surface/shape-defaults.d.ts.map +1 -0
- package/dist/surface/shape-defaults.js +50 -0
- package/dist/surface/spine-extractor.d.ts +38 -0
- package/dist/surface/spine-extractor.d.ts.map +1 -0
- package/dist/surface/spine-extractor.js +100 -0
- package/dist/surface/surface-config-writer.d.ts +59 -0
- package/dist/surface/surface-config-writer.d.ts.map +1 -0
- package/dist/surface/surface-config-writer.js +135 -0
- package/dist/surface/surface-summary.d.ts +66 -0
- package/dist/surface/surface-summary.d.ts.map +1 -0
- package/dist/surface/surface-summary.js +162 -0
- package/dist/surface/tier.d.ts +100 -0
- package/dist/surface/tier.d.ts.map +1 -0
- package/dist/surface/tier.js +172 -0
- package/dist/task-next/apply-batch-runner.d.ts +42 -0
- package/dist/task-next/apply-batch-runner.d.ts.map +1 -0
- package/dist/task-next/apply-batch-runner.js +192 -0
- package/dist/task-next/task-next-ranker.d.ts +75 -0
- package/dist/task-next/task-next-ranker.d.ts.map +1 -0
- package/dist/task-next/task-next-ranker.js +179 -0
- package/dist/usage/usage-log.d.ts +54 -0
- package/dist/usage/usage-log.d.ts.map +1 -0
- package/dist/usage/usage-log.js +105 -0
- package/dist/validation/run-validation-loop.d.ts +38 -0
- package/dist/validation/run-validation-loop.d.ts.map +1 -0
- package/dist/validation/run-validation-loop.js +100 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SharkCraft contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @shrkcrft/cli
|
|
2
|
+
|
|
3
|
+
SharkCraft CLI (`shrk`): structured project intelligence for AI coding agents.
|
|
4
|
+
|
|
5
|
+
Part of [SharkCraft](https://github.com/shrkcrft/sharkcraft) — a deterministic, local-first toolkit that gives AI coding agents durable project context. See the main repo for documentation, examples, and the `shrk` CLI.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add @shrkcrft/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface IActionHintStubInput {
|
|
2
|
+
readonly cwd: string;
|
|
3
|
+
readonly targetPath: string;
|
|
4
|
+
readonly entryId: string;
|
|
5
|
+
readonly write: boolean;
|
|
6
|
+
readonly allowDivergent?: boolean;
|
|
7
|
+
/** Override the default stub body. */
|
|
8
|
+
readonly stubBody?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IActionHintStubResult {
|
|
11
|
+
readonly ok: boolean;
|
|
12
|
+
readonly refusal?: string;
|
|
13
|
+
readonly targetAbs: string;
|
|
14
|
+
readonly entryId: string;
|
|
15
|
+
/** Line where the stub was inserted (1-indexed). */
|
|
16
|
+
readonly insertedAtLine?: number;
|
|
17
|
+
readonly originalLength: number;
|
|
18
|
+
readonly nextLength: number;
|
|
19
|
+
/** Full unified-diff body for human review. */
|
|
20
|
+
readonly diff?: string;
|
|
21
|
+
readonly wrote: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Compute the patched body. Pure — no IO. The caller persists when
|
|
25
|
+
* `input.write` is true.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyActionHintStub(input: IActionHintStubInput): IActionHintStubResult;
|
|
28
|
+
//# sourceMappingURL=apply-action-hint-stub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-action-hint-stub.d.ts","sourceRoot":"","sources":["../../src/asset-preview/apply-action-hint-stub.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,sCAAsC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AA0DD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,oBAAoB,GAC1B,qBAAqB,CAgGvB"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action-hint stub splicer.
|
|
3
|
+
*
|
|
4
|
+
* Inserts a commented `actionHints: { ... }` block into the matching
|
|
5
|
+
* knowledge entry in `sharkcraft/knowledge.ts`. The stub is the same
|
|
6
|
+
* shape that `fix --action-hints` previews today, but the splicer
|
|
7
|
+
* actually applies it in place rather than just writing a preview file
|
|
8
|
+
* under `.sharkcraft/fixes/`.
|
|
9
|
+
*
|
|
10
|
+
* Hard rules:
|
|
11
|
+
* - Refuses path-escape on target.
|
|
12
|
+
* - Refuses pack-contributed entries unless explicitly asked.
|
|
13
|
+
* - Refuses if the entry already has an `actionHints` field
|
|
14
|
+
* (idempotent).
|
|
15
|
+
* - Preview-first: callers must compute the patch first; the writer
|
|
16
|
+
* only persists when `write: true`.
|
|
17
|
+
* - Stubs are commented placeholders (`/* TODO: ... *\/`). Doctor
|
|
18
|
+
* continues to warn (now via `action-hint-quality`) until the
|
|
19
|
+
* placeholders are filled.
|
|
20
|
+
*/
|
|
21
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import * as nodePath from 'node:path';
|
|
23
|
+
import { findEntryRange as sharedFindEntryRange } from "./entry-mutator.js";
|
|
24
|
+
const DEFAULT_STUB_BODY = [
|
|
25
|
+
' // TODO(action-hints): fill the placeholders, then doctor warnings flip off.',
|
|
26
|
+
' actionHints: {',
|
|
27
|
+
' commands: [/* TODO: shrk commands an agent should run */],',
|
|
28
|
+
' mcpTools: [/* TODO: read-only MCP tool names */],',
|
|
29
|
+
' forbiddenActions: [/* TODO: things the agent must not do */],',
|
|
30
|
+
' verificationCommands: [/* TODO: ids from sharkcraft.config.ts verificationCommands[] */],',
|
|
31
|
+
" writePolicy: 'preview-only' /* TODO: 'preview-only' | 'cli-only' | 'plan-first' */,",
|
|
32
|
+
' },',
|
|
33
|
+
].join('\n');
|
|
34
|
+
function escapesCwd(cwd, absPath) {
|
|
35
|
+
const rel = nodePath.relative(cwd, absPath);
|
|
36
|
+
return rel.startsWith('..') || nodePath.isAbsolute(rel);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* `findEntryRange` lives in `entry-mutator.ts` so the four apply paths
|
|
40
|
+
* (action-hint, knowledge-stale, template-drift, templates-update)
|
|
41
|
+
* share the same primitive. This wrapper preserves the call-site name.
|
|
42
|
+
*/
|
|
43
|
+
const findEntryRange = sharedFindEntryRange;
|
|
44
|
+
function entryHasActionHints(body, range) {
|
|
45
|
+
const slice = body.slice(range.open, range.close + 1);
|
|
46
|
+
// Match `actionHints:` at the top level — we'll be conservative and look
|
|
47
|
+
// for the field name preceded by whitespace and followed by `:`.
|
|
48
|
+
return /\bactionHints\s*:/.test(slice);
|
|
49
|
+
}
|
|
50
|
+
function buildUnifiedDiff(rel, a, b) {
|
|
51
|
+
const aLines = a.split('\n');
|
|
52
|
+
const bLines = b.split('\n');
|
|
53
|
+
let prefix = 0;
|
|
54
|
+
while (prefix < aLines.length && prefix < bLines.length && aLines[prefix] === bLines[prefix]) {
|
|
55
|
+
prefix += 1;
|
|
56
|
+
}
|
|
57
|
+
let suffix = 0;
|
|
58
|
+
while (suffix < aLines.length - prefix &&
|
|
59
|
+
suffix < bLines.length - prefix &&
|
|
60
|
+
aLines[aLines.length - 1 - suffix] === bLines[bLines.length - 1 - suffix]) {
|
|
61
|
+
suffix += 1;
|
|
62
|
+
}
|
|
63
|
+
const aMid = aLines.slice(prefix, aLines.length - suffix);
|
|
64
|
+
const bMid = bLines.slice(prefix, bLines.length - suffix);
|
|
65
|
+
const head = `--- ${rel}\n+++ ${rel}\n@@ -${prefix + 1},${aMid.length} +${prefix + 1},${bMid.length} @@\n`;
|
|
66
|
+
return (head +
|
|
67
|
+
aMid.map((l) => `-${l}`).join('\n') +
|
|
68
|
+
(aMid.length ? '\n' : '') +
|
|
69
|
+
bMid.map((l) => `+${l}`).join('\n'));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Compute the patched body. Pure — no IO. The caller persists when
|
|
73
|
+
* `input.write` is true.
|
|
74
|
+
*/
|
|
75
|
+
export function applyActionHintStub(input) {
|
|
76
|
+
const cwd = nodePath.resolve(input.cwd);
|
|
77
|
+
const targetAbs = nodePath.resolve(cwd, input.targetPath);
|
|
78
|
+
if (escapesCwd(cwd, targetAbs)) {
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
refusal: `Target path escapes the project root (cwd=${cwd}).`,
|
|
82
|
+
targetAbs,
|
|
83
|
+
entryId: input.entryId,
|
|
84
|
+
originalLength: 0,
|
|
85
|
+
nextLength: 0,
|
|
86
|
+
wrote: false,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (!existsSync(targetAbs)) {
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
refusal: `Target file not found: ${targetAbs}`,
|
|
93
|
+
targetAbs,
|
|
94
|
+
entryId: input.entryId,
|
|
95
|
+
originalLength: 0,
|
|
96
|
+
nextLength: 0,
|
|
97
|
+
wrote: false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const body = readFileSync(targetAbs, 'utf8');
|
|
101
|
+
const range = findEntryRange(body, input.entryId);
|
|
102
|
+
if (!range) {
|
|
103
|
+
return {
|
|
104
|
+
ok: false,
|
|
105
|
+
refusal: `Entry "${input.entryId}" not found in ${nodePath.relative(cwd, targetAbs)}.`,
|
|
106
|
+
targetAbs,
|
|
107
|
+
entryId: input.entryId,
|
|
108
|
+
originalLength: body.length,
|
|
109
|
+
nextLength: body.length,
|
|
110
|
+
wrote: false,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (entryHasActionHints(body, range) && !input.allowDivergent) {
|
|
114
|
+
return {
|
|
115
|
+
ok: false,
|
|
116
|
+
refusal: `Entry "${input.entryId}" already has an actionHints field. Pass --allow-divergent to overwrite.`,
|
|
117
|
+
targetAbs,
|
|
118
|
+
entryId: input.entryId,
|
|
119
|
+
originalLength: body.length,
|
|
120
|
+
nextLength: body.length,
|
|
121
|
+
wrote: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const stubBody = input.stubBody ?? DEFAULT_STUB_BODY;
|
|
125
|
+
// Match the closing brace's indent + 2 spaces for the stub.
|
|
126
|
+
const childIndent = range.indent + ' ';
|
|
127
|
+
const indentedStub = stubBody
|
|
128
|
+
.split('\n')
|
|
129
|
+
.map((l) => (l.length > 0 ? childIndent + l.replace(/^ {2}/, '') : l))
|
|
130
|
+
.join('\n');
|
|
131
|
+
// Insert before the closing `}` of the entry literal, with a leading
|
|
132
|
+
// newline so the result lands on its own lines.
|
|
133
|
+
const before = body.slice(0, range.close);
|
|
134
|
+
const after = body.slice(range.close);
|
|
135
|
+
// Ensure the inserted block is separated from the previous content by a
|
|
136
|
+
// newline + appropriate indent.
|
|
137
|
+
const trimmedBefore = before.replace(/[ \t]*$/, '');
|
|
138
|
+
// Ensure the preceding line ends with a comma (object literal field).
|
|
139
|
+
const ensuredComma = /[,{][ \t\r\n]*$/.test(trimmedBefore)
|
|
140
|
+
? trimmedBefore
|
|
141
|
+
: trimmedBefore.replace(/[ \t\r\n]*$/, '') + ',';
|
|
142
|
+
// See `insertField` in entry-mutator.ts: the inserted line carries
|
|
143
|
+
// the indent for the next `}`, so `after` is appended verbatim —
|
|
144
|
+
// slicing the indent here strips the closing `}` whenever it lived
|
|
145
|
+
// on its own indented line.
|
|
146
|
+
const insertedLine = (ensuredComma.length > 0 && !ensuredComma.endsWith('\n') ? '\n' : '') +
|
|
147
|
+
indentedStub +
|
|
148
|
+
'\n' +
|
|
149
|
+
range.indent;
|
|
150
|
+
const nextBody = ensuredComma + insertedLine + after;
|
|
151
|
+
let wrote = false;
|
|
152
|
+
if (input.write && nextBody !== body) {
|
|
153
|
+
writeFileSync(targetAbs, nextBody, 'utf8');
|
|
154
|
+
wrote = true;
|
|
155
|
+
}
|
|
156
|
+
const rel = nodePath.relative(cwd, targetAbs) || nodePath.basename(targetAbs);
|
|
157
|
+
const diff = buildUnifiedDiff(rel, body, nextBody);
|
|
158
|
+
// Compute the line where the stub starts (after the comma we ensured).
|
|
159
|
+
const insertedAt = ensuredComma.split('\n').length;
|
|
160
|
+
return {
|
|
161
|
+
ok: true,
|
|
162
|
+
targetAbs,
|
|
163
|
+
entryId: input.entryId,
|
|
164
|
+
insertedAtLine: insertedAt,
|
|
165
|
+
originalLength: body.length,
|
|
166
|
+
nextLength: nextBody.length,
|
|
167
|
+
diff,
|
|
168
|
+
wrote,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Asset file kinds the merge knows how to insert into. */
|
|
2
|
+
export type AssetTargetKind = 'knowledge' | 'rules' | 'paths' | 'templates' | 'pipelines' | 'boundaries' | 'presets' | 'unknown';
|
|
3
|
+
/** Single unified-diff entry for the preview output. */
|
|
4
|
+
export interface IDiffSummary {
|
|
5
|
+
readonly added: number;
|
|
6
|
+
readonly removed: number;
|
|
7
|
+
/** First 20 lines of context; full text available in `unifiedDiff`. */
|
|
8
|
+
readonly preview: string;
|
|
9
|
+
readonly unifiedDiff: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IAssetPreviewInput {
|
|
12
|
+
readonly cwd: string;
|
|
13
|
+
readonly draftPath: string;
|
|
14
|
+
readonly targetPath: string;
|
|
15
|
+
readonly write: boolean;
|
|
16
|
+
readonly allowUnknownTarget: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface IAssetPreviewResult {
|
|
19
|
+
readonly ok: boolean;
|
|
20
|
+
readonly refusal?: string;
|
|
21
|
+
readonly draftAbs: string;
|
|
22
|
+
readonly targetAbs: string;
|
|
23
|
+
readonly targetKind: AssetTargetKind;
|
|
24
|
+
readonly originalLength: number;
|
|
25
|
+
readonly nextLength: number;
|
|
26
|
+
readonly diff?: IDiffSummary;
|
|
27
|
+
readonly wrote: boolean;
|
|
28
|
+
readonly validationCommands: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
export declare function applyAssetPreview(input: IAssetPreviewInput): IAssetPreviewResult;
|
|
31
|
+
//# sourceMappingURL=apply-asset-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-asset-preview.d.ts","sourceRoot":"","sources":["../../src/asset-preview/apply-asset-preview.ts"],"names":[],"mappings":"AAwBA,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GACvB,WAAW,GACX,OAAO,GACP,OAAO,GACP,WAAW,GACX,WAAW,GACX,YAAY,GACZ,SAAS,GACT,SAAS,CAAC;AAYd,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;CAChD;AAiFD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CAmHhF"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `shrk apply --asset-preview <draft.ts> --target <file>`.
|
|
3
|
+
*
|
|
4
|
+
* Paste-with-review for authoring drafts. The agent generated a preview
|
|
5
|
+
* under `.sharkcraft/authoring/<...>.draft.ts` (via `knowledge add` /
|
|
6
|
+
* `rules scaffold` / etc.) and now needs to *merge* that draft into the
|
|
7
|
+
* actual asset file (`sharkcraft/knowledge.ts` or a pack's equivalent).
|
|
8
|
+
*
|
|
9
|
+
* Default dry-run. `--write` to persist.
|
|
10
|
+
* Refuses path-escape on `--target`.
|
|
11
|
+
* Refuses unknown asset types unless `--allow-unknown-target`.
|
|
12
|
+
* Surfaces signature status after pack asset changes.
|
|
13
|
+
* Records provenance automatically.
|
|
14
|
+
* Prints the exact validation commands to run next.
|
|
15
|
+
*
|
|
16
|
+
* Merge strategy: insert the draft body just before the last `]` in the
|
|
17
|
+
* target. Asset files are arrays of literal entries, so this preserves
|
|
18
|
+
* formatting and keeps the entries grouped. When no `]` is found, the
|
|
19
|
+
* draft appends to the end (this can only happen for non-array targets,
|
|
20
|
+
* which require `--allow-unknown-target` anyway).
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
23
|
+
import * as nodePath from 'node:path';
|
|
24
|
+
const KNOWN_ASSET_BASENAMES = new Map([
|
|
25
|
+
['knowledge.ts', 'knowledge'],
|
|
26
|
+
['rules.ts', 'rules'],
|
|
27
|
+
['paths.ts', 'paths'],
|
|
28
|
+
['templates.ts', 'templates'],
|
|
29
|
+
['pipelines.ts', 'pipelines'],
|
|
30
|
+
['boundaries.ts', 'boundaries'],
|
|
31
|
+
['presets.ts', 'presets'],
|
|
32
|
+
]);
|
|
33
|
+
function classifyTarget(absPath) {
|
|
34
|
+
return KNOWN_ASSET_BASENAMES.get(nodePath.basename(absPath)) ?? 'unknown';
|
|
35
|
+
}
|
|
36
|
+
function escapesCwd(cwd, absPath) {
|
|
37
|
+
const rel = nodePath.relative(cwd, absPath);
|
|
38
|
+
return rel.startsWith('..') || nodePath.isAbsolute(rel);
|
|
39
|
+
}
|
|
40
|
+
/** Insert `draftBody` before the last `]` in `targetBody`. */
|
|
41
|
+
function mergeIntoArray(targetBody, draftBody) {
|
|
42
|
+
const trimmedDraft = draftBody.trimEnd();
|
|
43
|
+
if (!trimmedDraft)
|
|
44
|
+
return targetBody;
|
|
45
|
+
const close = targetBody.lastIndexOf(']');
|
|
46
|
+
if (close === -1) {
|
|
47
|
+
// Not an array file — append.
|
|
48
|
+
const sep = targetBody.endsWith('\n') ? '\n' : '\n\n';
|
|
49
|
+
return targetBody + sep + trimmedDraft + '\n';
|
|
50
|
+
}
|
|
51
|
+
const before = targetBody.slice(0, close);
|
|
52
|
+
const after = targetBody.slice(close);
|
|
53
|
+
const ensureComma = trimmedDraft.endsWith(',') ? trimmedDraft : trimmedDraft + ',';
|
|
54
|
+
// Preserve the indentation of the last entry — pick the leading whitespace
|
|
55
|
+
// of the line containing the `]`.
|
|
56
|
+
const lineStart = before.lastIndexOf('\n');
|
|
57
|
+
const closingIndent = lineStart === -1 ? '' : before.slice(lineStart + 1);
|
|
58
|
+
const indent = closingIndent.replace(/[^ \t]/g, '');
|
|
59
|
+
const childIndent = indent + ' ';
|
|
60
|
+
const indented = ensureComma
|
|
61
|
+
.split('\n')
|
|
62
|
+
.map((l) => (l.length > 0 ? childIndent + l : l))
|
|
63
|
+
.join('\n');
|
|
64
|
+
return before.trimEnd() + '\n' + indented + '\n' + closingIndent + after.slice(0);
|
|
65
|
+
}
|
|
66
|
+
function buildUnifiedDiff(aPath, a, bPath, b) {
|
|
67
|
+
const aLines = a.split('\n');
|
|
68
|
+
const bLines = b.split('\n');
|
|
69
|
+
// Tiny diff: line-level common-prefix + common-suffix + middle delta.
|
|
70
|
+
let prefix = 0;
|
|
71
|
+
while (prefix < aLines.length && prefix < bLines.length && aLines[prefix] === bLines[prefix]) {
|
|
72
|
+
prefix += 1;
|
|
73
|
+
}
|
|
74
|
+
let suffix = 0;
|
|
75
|
+
while (suffix < aLines.length - prefix &&
|
|
76
|
+
suffix < bLines.length - prefix &&
|
|
77
|
+
aLines[aLines.length - 1 - suffix] === bLines[bLines.length - 1 - suffix]) {
|
|
78
|
+
suffix += 1;
|
|
79
|
+
}
|
|
80
|
+
const aMiddle = aLines.slice(prefix, aLines.length - suffix);
|
|
81
|
+
const bMiddle = bLines.slice(prefix, bLines.length - suffix);
|
|
82
|
+
const ctxBefore = aLines.slice(Math.max(0, prefix - 3), prefix);
|
|
83
|
+
const ctxAfter = aLines.slice(aLines.length - suffix, Math.min(aLines.length, aLines.length - suffix + 3));
|
|
84
|
+
const head = `--- ${aPath}\n+++ ${bPath}\n@@ -${prefix + 1},${aMiddle.length} +${prefix + 1},${bMiddle.length} @@\n`;
|
|
85
|
+
const body = ctxBefore.map((l) => ` ${l}`).join('\n') +
|
|
86
|
+
(ctxBefore.length ? '\n' : '') +
|
|
87
|
+
aMiddle.map((l) => `-${l}`).join('\n') +
|
|
88
|
+
(aMiddle.length ? '\n' : '') +
|
|
89
|
+
bMiddle.map((l) => `+${l}`).join('\n') +
|
|
90
|
+
(bMiddle.length ? '\n' : '') +
|
|
91
|
+
ctxAfter.map((l) => ` ${l}`).join('\n');
|
|
92
|
+
const unified = head + body;
|
|
93
|
+
const previewLines = unified.split('\n').slice(0, 24).join('\n');
|
|
94
|
+
return {
|
|
95
|
+
added: bMiddle.length,
|
|
96
|
+
removed: aMiddle.length,
|
|
97
|
+
preview: previewLines,
|
|
98
|
+
unifiedDiff: unified,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function applyAssetPreview(input) {
|
|
102
|
+
const validationCommands = [
|
|
103
|
+
'shrk doctor',
|
|
104
|
+
'shrk knowledge stale-check --ci',
|
|
105
|
+
'shrk check boundaries --changed-only',
|
|
106
|
+
];
|
|
107
|
+
const cwd = nodePath.resolve(input.cwd);
|
|
108
|
+
const draftAbs = nodePath.resolve(cwd, input.draftPath);
|
|
109
|
+
const targetAbs = nodePath.resolve(cwd, input.targetPath);
|
|
110
|
+
if (escapesCwd(cwd, draftAbs)) {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
refusal: `Draft path escapes the project root (cwd=${cwd}).`,
|
|
114
|
+
draftAbs,
|
|
115
|
+
targetAbs,
|
|
116
|
+
targetKind: 'unknown',
|
|
117
|
+
originalLength: 0,
|
|
118
|
+
nextLength: 0,
|
|
119
|
+
wrote: false,
|
|
120
|
+
validationCommands,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (escapesCwd(cwd, targetAbs)) {
|
|
124
|
+
return {
|
|
125
|
+
ok: false,
|
|
126
|
+
refusal: `Target path escapes the project root (cwd=${cwd}).`,
|
|
127
|
+
draftAbs,
|
|
128
|
+
targetAbs,
|
|
129
|
+
targetKind: 'unknown',
|
|
130
|
+
originalLength: 0,
|
|
131
|
+
nextLength: 0,
|
|
132
|
+
wrote: false,
|
|
133
|
+
validationCommands,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (!existsSync(draftAbs)) {
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
refusal: `Draft file not found: ${draftAbs}`,
|
|
140
|
+
draftAbs,
|
|
141
|
+
targetAbs,
|
|
142
|
+
targetKind: 'unknown',
|
|
143
|
+
originalLength: 0,
|
|
144
|
+
nextLength: 0,
|
|
145
|
+
wrote: false,
|
|
146
|
+
validationCommands,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (!existsSync(targetAbs)) {
|
|
150
|
+
return {
|
|
151
|
+
ok: false,
|
|
152
|
+
refusal: `Target file not found: ${targetAbs}`,
|
|
153
|
+
draftAbs,
|
|
154
|
+
targetAbs,
|
|
155
|
+
targetKind: 'unknown',
|
|
156
|
+
originalLength: 0,
|
|
157
|
+
nextLength: 0,
|
|
158
|
+
wrote: false,
|
|
159
|
+
validationCommands,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const targetKind = classifyTarget(targetAbs);
|
|
163
|
+
if (targetKind === 'unknown' && !input.allowUnknownTarget) {
|
|
164
|
+
return {
|
|
165
|
+
ok: false,
|
|
166
|
+
refusal: `Target is not a known asset/config type (${nodePath.basename(targetAbs)}). Pass --allow-unknown-target to override.`,
|
|
167
|
+
draftAbs,
|
|
168
|
+
targetAbs,
|
|
169
|
+
targetKind,
|
|
170
|
+
originalLength: 0,
|
|
171
|
+
nextLength: 0,
|
|
172
|
+
wrote: false,
|
|
173
|
+
validationCommands,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const draftBody = readFileSync(draftAbs, 'utf8');
|
|
177
|
+
const targetBody = readFileSync(targetAbs, 'utf8');
|
|
178
|
+
const nextBody = mergeIntoArray(targetBody, draftBody);
|
|
179
|
+
const diff = buildUnifiedDiff(input.targetPath, targetBody, input.targetPath, nextBody);
|
|
180
|
+
let wrote = false;
|
|
181
|
+
if (input.write && nextBody !== targetBody) {
|
|
182
|
+
writeFileSync(targetAbs, nextBody, 'utf8');
|
|
183
|
+
wrote = true;
|
|
184
|
+
}
|
|
185
|
+
// Provide a kind-aware extra validation command.
|
|
186
|
+
const kindValidation = {
|
|
187
|
+
knowledge: 'shrk knowledge stale-check --ci',
|
|
188
|
+
rules: 'shrk rules lint',
|
|
189
|
+
paths: 'shrk paths list',
|
|
190
|
+
templates: 'shrk templates drift --min-severity warning',
|
|
191
|
+
pipelines: 'shrk pipelines lint',
|
|
192
|
+
boundaries: 'shrk check boundaries --changed-only',
|
|
193
|
+
presets: 'shrk presets list --json',
|
|
194
|
+
};
|
|
195
|
+
const extra = kindValidation[targetKind];
|
|
196
|
+
const allValidation = extra
|
|
197
|
+
? Array.from(new Set([extra, ...validationCommands]))
|
|
198
|
+
: validationCommands;
|
|
199
|
+
return {
|
|
200
|
+
ok: true,
|
|
201
|
+
draftAbs,
|
|
202
|
+
targetAbs,
|
|
203
|
+
targetKind,
|
|
204
|
+
originalLength: targetBody.length,
|
|
205
|
+
nextLength: nextBody.length,
|
|
206
|
+
diff,
|
|
207
|
+
wrote,
|
|
208
|
+
validationCommands: allValidation,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IKnowledgeReference } from '@shrkcrft/knowledge';
|
|
2
|
+
/**
|
|
3
|
+
* Optional rename payload. When present, the apply rewrites the
|
|
4
|
+
* matching reference's identifying field (`path` / `id` / `symbol`)
|
|
5
|
+
* rather than removing the whole element. Migration is strictly safer
|
|
6
|
+
* than drop when the engine can identify the new location.
|
|
7
|
+
*/
|
|
8
|
+
export interface IKnowledgeStaleRename {
|
|
9
|
+
readonly path?: string;
|
|
10
|
+
readonly id?: string;
|
|
11
|
+
readonly symbol?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface IKnowledgeStaleFixInput {
|
|
14
|
+
readonly cwd: string;
|
|
15
|
+
readonly targetPath: string;
|
|
16
|
+
readonly entryId: string;
|
|
17
|
+
readonly reference: IKnowledgeReference;
|
|
18
|
+
readonly write: boolean;
|
|
19
|
+
/** When present, rename in place instead of dropping. */
|
|
20
|
+
readonly renameTo?: IKnowledgeStaleRename;
|
|
21
|
+
}
|
|
22
|
+
export interface IKnowledgeStaleFixResult {
|
|
23
|
+
readonly ok: boolean;
|
|
24
|
+
readonly refusal?: string;
|
|
25
|
+
readonly targetAbs: string;
|
|
26
|
+
readonly entryId: string;
|
|
27
|
+
readonly originalLength: number;
|
|
28
|
+
readonly nextLength: number;
|
|
29
|
+
/** Number of references dropped (only meaningful in `drop` mode). */
|
|
30
|
+
readonly removedCount: number;
|
|
31
|
+
/** Mode the splicer actually applied. */
|
|
32
|
+
readonly mode: 'drop' | 'rename';
|
|
33
|
+
readonly diff?: string;
|
|
34
|
+
readonly wrote: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function applyKnowledgeStaleFix(input: IKnowledgeStaleFixInput): IKnowledgeStaleFixResult;
|
|
37
|
+
//# sourceMappingURL=apply-knowledge-stale-fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-knowledge-stale-fix.d.ts","sourceRoot":"","sources":["../../src/asset-preview/apply-knowledge-stale-fix.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAC3C;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AA2MD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,uBAAuB,GAC7B,wBAAwB,CAwI1B"}
|