@b00dea/cockpit 0.0.0-stage → 0.1.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/CHANGELOG.md +474 -0
- package/LICENSE +21 -0
- package/README.md +25 -2
- package/bin/cockpit.mjs +33 -0
- package/cockpit.schema.json +2644 -0
- package/dist/autonomy.d.ts +45 -0
- package/dist/autonomy.js +173 -0
- package/dist/bounded-read.d.ts +14 -0
- package/dist/bounded-read.js +42 -0
- package/dist/browser/commands.d.ts +117 -0
- package/dist/browser/commands.js +453 -0
- package/dist/browser/package-paths.d.ts +1 -0
- package/dist/browser/package-paths.js +6 -0
- package/dist/browser/proxy.d.ts +22 -0
- package/dist/browser/proxy.js +37 -0
- package/dist/browser/runtime.d.ts +118 -0
- package/dist/browser/runtime.js +186 -0
- package/dist/browser/surfaces.d.ts +141 -0
- package/dist/browser/surfaces.js +561 -0
- package/dist/browser/ui-gate.d.ts +15 -0
- package/dist/browser/ui-gate.js +18 -0
- package/dist/canonical-json.d.ts +2 -0
- package/dist/canonical-json.js +5 -0
- package/dist/cli-guard.d.ts +5 -0
- package/dist/cli-guard.js +71 -0
- package/dist/cli-main.d.ts +176 -0
- package/dist/cli-main.js +1584 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +16 -0
- package/dist/command-table.d.ts +121 -0
- package/dist/command-table.js +664 -0
- package/dist/config/load.d.ts +183 -0
- package/dist/config/load.js +367 -0
- package/dist/config/sibling-toml.d.ts +48 -0
- package/dist/config/sibling-toml.js +160 -0
- package/dist/config/surface-tools-toml.d.ts +9 -0
- package/dist/config/surface-tools-toml.js +37 -0
- package/dist/config/unconfirmed-toml.d.ts +9 -0
- package/dist/config/unconfirmed-toml.js +29 -0
- package/dist/config/verified-write.d.ts +43 -0
- package/dist/config/verified-write.js +89 -0
- package/dist/diagnostics.d.ts +26 -0
- package/dist/diagnostics.js +344 -0
- package/dist/docs/check.d.ts +16 -0
- package/dist/docs/check.js +197 -0
- package/dist/docs/decision-record.d.ts +34 -0
- package/dist/docs/decision-record.js +135 -0
- package/dist/docs/decisions.d.ts +16 -0
- package/dist/docs/decisions.js +103 -0
- package/dist/docs/markdown.d.ts +36 -0
- package/dist/docs/markdown.js +88 -0
- package/dist/docs/references.d.ts +32 -0
- package/dist/docs/references.js +148 -0
- package/dist/emit.d.ts +22 -0
- package/dist/emit.js +43 -0
- package/dist/entrypoint-kinds.d.ts +3 -0
- package/dist/entrypoint-kinds.js +11 -0
- package/dist/environment/application/confirm.d.ts +35 -0
- package/dist/environment/application/confirm.js +122 -0
- package/dist/environment/application/destructive.d.ts +6 -0
- package/dist/environment/application/destructive.js +429 -0
- package/dist/environment/application/doctor.d.ts +94 -0
- package/dist/environment/application/doctor.js +247 -0
- package/dist/environment/application/guard.d.ts +49 -0
- package/dist/environment/application/guard.js +677 -0
- package/dist/environment/application/health.d.ts +143 -0
- package/dist/environment/application/health.js +385 -0
- package/dist/environment/application/lifecycle-context.d.ts +235 -0
- package/dist/environment/application/lifecycle-context.js +154 -0
- package/dist/environment/application/lifecycle-state.d.ts +25 -0
- package/dist/environment/application/lifecycle-state.js +202 -0
- package/dist/environment/application/lifecycle.d.ts +18 -0
- package/dist/environment/application/lifecycle.js +737 -0
- package/dist/environment/application/logs.d.ts +45 -0
- package/dist/environment/application/logs.js +127 -0
- package/dist/environment/application/services.d.ts +60 -0
- package/dist/environment/application/services.js +89 -0
- package/dist/environment/application/setup.d.ts +129 -0
- package/dist/environment/application/setup.js +741 -0
- package/dist/environment/application/shared.d.ts +11 -0
- package/dist/environment/application/shared.js +61 -0
- package/dist/environment/application/siblings.d.ts +43 -0
- package/dist/environment/application/siblings.js +269 -0
- package/dist/environment/claims.d.ts +389 -0
- package/dist/environment/claims.js +1701 -0
- package/dist/environment/codex-hook-trust.d.ts +11 -0
- package/dist/environment/codex-hook-trust.js +185 -0
- package/dist/environment/compose-environment.d.ts +1 -0
- package/dist/environment/compose-environment.js +6 -0
- package/dist/environment/compose-ownership.d.ts +21 -0
- package/dist/environment/compose-ownership.js +117 -0
- package/dist/environment/compose-topology.d.ts +125 -0
- package/dist/environment/compose-topology.js +490 -0
- package/dist/environment/contract.d.ts +522 -0
- package/dist/environment/contract.js +794 -0
- package/dist/environment/declaration.d.ts +14 -0
- package/dist/environment/declaration.js +39 -0
- package/dist/environment/destructive-composition.d.ts +29 -0
- package/dist/environment/destructive-composition.js +333 -0
- package/dist/environment/docker-daemon.d.ts +30 -0
- package/dist/environment/docker-daemon.js +78 -0
- package/dist/environment/docker-endpoint.d.ts +10 -0
- package/dist/environment/docker-endpoint.js +19 -0
- package/dist/environment/env-schema-observation.d.ts +46 -0
- package/dist/environment/env-schema-observation.js +241 -0
- package/dist/environment/evidence.d.ts +136 -0
- package/dist/environment/evidence.js +437 -0
- package/dist/environment/executable.d.ts +38 -0
- package/dist/environment/executable.js +190 -0
- package/dist/environment/generated-application/authorities.d.ts +5 -0
- package/dist/environment/generated-application/authorities.js +61 -0
- package/dist/environment/generated-application/bootstrap-skill.d.ts +16 -0
- package/dist/environment/generated-application/bootstrap-skill.js +328 -0
- package/dist/environment/generated-application/check.d.ts +13 -0
- package/dist/environment/generated-application/check.js +191 -0
- package/dist/environment/generated-application/custom-surface.d.ts +26 -0
- package/dist/environment/generated-application/custom-surface.js +289 -0
- package/dist/environment/generated-application/prepare.d.ts +29 -0
- package/dist/environment/generated-application/prepare.js +278 -0
- package/dist/environment/generated-application/publication.d.ts +33 -0
- package/dist/environment/generated-application/publication.js +547 -0
- package/dist/environment/generated-application/shared.d.ts +492 -0
- package/dist/environment/generated-application/shared.js +354 -0
- package/dist/environment/generated-application/surface-observation.d.ts +4 -0
- package/dist/environment/generated-application/surface-observation.js +69 -0
- package/dist/environment/generated-application/surface-outputs.d.ts +71 -0
- package/dist/environment/generated-application/surface-outputs.js +400 -0
- package/dist/environment/generated-application/surfaces.d.ts +3 -0
- package/dist/environment/generated-application/surfaces.js +704 -0
- package/dist/environment/generated-application/sync.d.ts +6 -0
- package/dist/environment/generated-application/sync.js +124 -0
- package/dist/environment/git-observation.d.ts +202 -0
- package/dist/environment/git-observation.js +553 -0
- package/dist/environment/health-composition.d.ts +12 -0
- package/dist/environment/health-composition.js +645 -0
- package/dist/environment/host-observation.d.ts +56 -0
- package/dist/environment/host-observation.js +52 -0
- package/dist/environment/identity.d.ts +48 -0
- package/dist/environment/identity.js +85 -0
- package/dist/environment/init-application.d.ts +333 -0
- package/dist/environment/init-application.js +726 -0
- package/dist/environment/install-policy-observation.d.ts +71 -0
- package/dist/environment/install-policy-observation.js +284 -0
- package/dist/environment/install-policy.d.ts +48 -0
- package/dist/environment/install-policy.js +96 -0
- package/dist/environment/instance.d.ts +33 -0
- package/dist/environment/instance.js +122 -0
- package/dist/environment/instruction-pointer.d.ts +19 -0
- package/dist/environment/instruction-pointer.js +144 -0
- package/dist/environment/lifecycle-composition.d.ts +31 -0
- package/dist/environment/lifecycle-composition.js +742 -0
- package/dist/environment/lifecycle-stage.d.ts +120 -0
- package/dist/environment/lifecycle-stage.js +408 -0
- package/dist/environment/lifecycle.d.ts +75 -0
- package/dist/environment/lifecycle.js +354 -0
- package/dist/environment/logs.d.ts +132 -0
- package/dist/environment/logs.js +519 -0
- package/dist/environment/map-limit.d.ts +2 -0
- package/dist/environment/map-limit.js +13 -0
- package/dist/environment/mcp-observation.d.ts +9 -0
- package/dist/environment/mcp-observation.js +46 -0
- package/dist/environment/observations.d.ts +46 -0
- package/dist/environment/observations.js +346 -0
- package/dist/environment/operator-application.d.ts +79 -0
- package/dist/environment/operator-application.js +197 -0
- package/dist/environment/ports.d.ts +182 -0
- package/dist/environment/ports.js +1205 -0
- package/dist/environment/posture-observation.d.ts +68 -0
- package/dist/environment/posture-observation.js +253 -0
- package/dist/environment/presence.d.ts +4 -0
- package/dist/environment/presence.js +26 -0
- package/dist/environment/read-composition.d.ts +32 -0
- package/dist/environment/read-composition.js +397 -0
- package/dist/environment/readiness-composition.d.ts +57 -0
- package/dist/environment/readiness-composition.js +151 -0
- package/dist/environment/reclaim.d.ts +370 -0
- package/dist/environment/reclaim.js +1940 -0
- package/dist/environment/repository-identity.d.ts +13 -0
- package/dist/environment/repository-identity.js +108 -0
- package/dist/environment/runtime-measurement-record.d.ts +38 -0
- package/dist/environment/runtime-measurement-record.js +111 -0
- package/dist/environment/runtime-measurement.d.ts +27 -0
- package/dist/environment/runtime-measurement.js +224 -0
- package/dist/environment/runtime-probe-residue.d.ts +43 -0
- package/dist/environment/runtime-probe-residue.js +148 -0
- package/dist/environment/runtime-probe.d.ts +72 -0
- package/dist/environment/runtime-probe.js +725 -0
- package/dist/environment/runtime.d.ts +551 -0
- package/dist/environment/runtime.js +2405 -0
- package/dist/environment/seed.d.ts +16 -0
- package/dist/environment/seed.js +43 -0
- package/dist/environment/selftest-application.d.ts +86 -0
- package/dist/environment/selftest-application.js +713 -0
- package/dist/environment/sensitive.d.ts +3 -0
- package/dist/environment/sensitive.js +48 -0
- package/dist/environment/served-checkout-grants.d.ts +53 -0
- package/dist/environment/served-checkout-grants.js +182 -0
- package/dist/environment/setup-observation.d.ts +62 -0
- package/dist/environment/setup-observation.js +1473 -0
- package/dist/environment/setup.d.ts +43 -0
- package/dist/environment/setup.js +176 -0
- package/dist/environment/sibling-checkouts.d.ts +119 -0
- package/dist/environment/sibling-checkouts.js +254 -0
- package/dist/environment/sibling-instructions.d.ts +33 -0
- package/dist/environment/sibling-instructions.js +224 -0
- package/dist/environment/sibling-observation.d.ts +27 -0
- package/dist/environment/sibling-observation.js +45 -0
- package/dist/environment/sibling-pull.d.ts +23 -0
- package/dist/environment/sibling-pull.js +95 -0
- package/dist/environment/sibling-registration.d.ts +45 -0
- package/dist/environment/sibling-registration.js +538 -0
- package/dist/environment/stack-inputs.d.ts +18 -0
- package/dist/environment/stack-inputs.js +210 -0
- package/dist/environment/stack-inventory-prune.d.ts +31 -0
- package/dist/environment/stack-inventory-prune.js +129 -0
- package/dist/environment/stack-inventory-report.d.ts +44 -0
- package/dist/environment/stack-inventory-report.js +78 -0
- package/dist/environment/stack-inventory.d.ts +94 -0
- package/dist/environment/stack-inventory.js +418 -0
- package/dist/environment/state.d.ts +410 -0
- package/dist/environment/state.js +2153 -0
- package/dist/environment/templates.d.ts +140 -0
- package/dist/environment/templates.js +685 -0
- package/dist/environment/tool-registration.d.ts +9 -0
- package/dist/environment/tool-registration.js +92 -0
- package/dist/environment/upgrade-application.d.ts +19 -0
- package/dist/environment/upgrade-application.js +175 -0
- package/dist/environment-exec/execute.d.ts +105 -0
- package/dist/environment-exec/execute.js +1179 -0
- package/dist/environment-exec/libexec-program.d.ts +6 -0
- package/dist/environment-exec/libexec-program.js +22 -0
- package/dist/environment-exec/verified-digest.d.ts +4 -0
- package/dist/environment-exec/verified-digest.js +16 -0
- package/dist/exact-keys.d.ts +7 -0
- package/dist/exact-keys.js +15 -0
- package/dist/fix-catalogue.d.ts +32 -0
- package/dist/fix-catalogue.js +60 -0
- package/dist/freshness.d.ts +29 -0
- package/dist/freshness.js +75 -0
- package/dist/generated-environment/adopt.d.ts +16 -0
- package/dist/generated-environment/adopt.js +271 -0
- package/dist/generated-environment/command.d.ts +47 -0
- package/dist/generated-environment/command.js +75 -0
- package/dist/generated-environment/transaction.d.ts +186 -0
- package/dist/generated-environment/transaction.js +1770 -0
- package/dist/grading/evaluate.d.ts +71 -0
- package/dist/grading/evaluate.js +403 -0
- package/dist/grading/grade.d.ts +33 -0
- package/dist/grading/grade.js +57 -0
- package/dist/guards/answer-confirmation.d.ts +41 -0
- package/dist/guards/answer-confirmation.js +109 -0
- package/dist/guards/evaluator.d.ts +130 -0
- package/dist/guards/evaluator.js +1258 -0
- package/dist/guards/harness-adapter.d.ts +17 -0
- package/dist/guards/harness-adapter.js +57 -0
- package/dist/guards/host.d.ts +8 -0
- package/dist/guards/host.js +10 -0
- package/dist/guards/invocation-parser.d.ts +66 -0
- package/dist/guards/invocation-parser.js +595 -0
- package/dist/guards/local-identity.d.ts +44 -0
- package/dist/guards/local-identity.js +129 -0
- package/dist/guards/policy-change.d.ts +43 -0
- package/dist/guards/policy-change.js +159 -0
- package/dist/guards/policy-pin.d.ts +13 -0
- package/dist/guards/policy-pin.js +177 -0
- package/dist/guards/protected-locations.d.ts +62 -0
- package/dist/guards/protected-locations.js +461 -0
- package/dist/guards/read-only.d.ts +37 -0
- package/dist/guards/read-only.js +315 -0
- package/dist/init/command.d.ts +41 -0
- package/dist/init/command.js +330 -0
- package/dist/init/derive.d.ts +53 -0
- package/dist/init/derive.js +819 -0
- package/dist/init/draft.d.ts +140 -0
- package/dist/init/draft.js +1228 -0
- package/dist/init/render.d.ts +47 -0
- package/dist/init/render.js +104 -0
- package/dist/init/scaffold.d.ts +53 -0
- package/dist/init/scaffold.js +121 -0
- package/dist/invocation.d.ts +13 -0
- package/dist/invocation.js +20 -0
- package/dist/package-metadata.d.ts +9 -0
- package/dist/package-metadata.js +19 -0
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.js +88 -0
- package/dist/references/named.d.ts +24 -0
- package/dist/references/named.js +27 -0
- package/dist/refusal.d.ts +15 -0
- package/dist/refusal.js +7 -0
- package/dist/registry-derivation.d.ts +31 -0
- package/dist/registry-derivation.js +32 -0
- package/dist/registry-resolve/command.d.ts +47 -0
- package/dist/registry-resolve/command.js +226 -0
- package/dist/registry-resolve/registry.d.ts +68 -0
- package/dist/registry-resolve/registry.js +292 -0
- package/dist/registry-resolve/render-shell.d.ts +18 -0
- package/dist/registry-resolve/render-shell.js +36 -0
- package/dist/repair.d.ts +29 -0
- package/dist/repair.js +8 -0
- package/dist/repository-path.d.ts +9 -0
- package/dist/repository-path.js +16 -0
- package/dist/schema-json.d.ts +1 -0
- package/dist/schema-json.js +177 -0
- package/dist/schema.d.ts +1289 -0
- package/dist/schema.js +985 -0
- package/dist/setup/command.d.ts +4 -0
- package/dist/setup/command.js +4 -0
- package/dist/sha256.d.ts +1 -0
- package/dist/sha256.js +4 -0
- package/dist/surfaces/adoption.d.ts +41 -0
- package/dist/surfaces/adoption.js +217 -0
- package/dist/surfaces/consumer-instructions.d.ts +20 -0
- package/dist/surfaces/consumer-instructions.js +43 -0
- package/dist/surfaces/contract.d.ts +42 -0
- package/dist/surfaces/contract.js +169 -0
- package/dist/surfaces/core-declarations.d.ts +24 -0
- package/dist/surfaces/core-declarations.js +79 -0
- package/dist/surfaces/development-markers.d.ts +1 -0
- package/dist/surfaces/development-markers.js +18 -0
- package/dist/surfaces/generator-adapter.d.ts +71 -0
- package/dist/surfaces/generator-adapter.js +809 -0
- package/dist/surfaces/harness-registry.d.ts +260 -0
- package/dist/surfaces/harness-registry.js +146 -0
- package/dist/surfaces/mcp.d.ts +145 -0
- package/dist/surfaces/mcp.js +349 -0
- package/dist/surfaces/merge.d.ts +30 -0
- package/dist/surfaces/merge.js +105 -0
- package/dist/surfaces/ownership.d.ts +190 -0
- package/dist/surfaces/ownership.js +795 -0
- package/dist/surfaces/projection.d.ts +136 -0
- package/dist/surfaces/projection.js +716 -0
- package/dist/surfaces/render.d.ts +79 -0
- package/dist/surfaces/render.js +636 -0
- package/dist/surfaces/restrictions.d.ts +130 -0
- package/dist/surfaces/restrictions.js +447 -0
- package/dist/surfaces/selftest.d.ts +162 -0
- package/dist/surfaces/selftest.js +393 -0
- package/dist/surfaces/skill-contract.d.ts +85 -0
- package/dist/surfaces/skill-contract.js +449 -0
- package/dist/surfaces/sync.d.ts +57 -0
- package/dist/surfaces/sync.js +164 -0
- package/dist/team-metadata.d.ts +41 -0
- package/dist/team-metadata.js +513 -0
- package/dist/testing/gates.d.ts +91 -0
- package/dist/testing/gates.js +182 -0
- package/dist/testing/hooks.d.ts +59 -0
- package/dist/testing/hooks.js +139 -0
- package/dist/testing/test-protection.d.ts +34 -0
- package/dist/testing/test-protection.js +137 -0
- package/dist/testing/verdict.d.ts +29 -0
- package/dist/testing/verdict.js +62 -0
- package/dist/testing/weakening.d.ts +15 -0
- package/dist/testing/weakening.js +30 -0
- package/dist/work-orders/application-closure.d.ts +7 -0
- package/dist/work-orders/application-closure.js +76 -0
- package/dist/work-orders/application-context.d.ts +162 -0
- package/dist/work-orders/application-context.js +137 -0
- package/dist/work-orders/application-decisions.d.ts +27 -0
- package/dist/work-orders/application-decisions.js +121 -0
- package/dist/work-orders/application-grading.d.ts +11 -0
- package/dist/work-orders/application-grading.js +212 -0
- package/dist/work-orders/application.d.ts +6 -0
- package/dist/work-orders/application.js +223 -0
- package/dist/work-orders/composition.d.ts +101 -0
- package/dist/work-orders/composition.js +1202 -0
- package/dist/work-orders/contract.d.ts +77 -0
- package/dist/work-orders/contract.js +140 -0
- package/dist/work-orders/decisions.d.ts +23 -0
- package/dist/work-orders/decisions.js +55 -0
- package/dist/work-orders/store.d.ts +207 -0
- package/dist/work-orders/store.js +291 -0
- package/docs/README.md +68 -0
- package/docs/architecture.md +136 -0
- package/docs/capability-matrix.md +58 -0
- package/docs/cli-reference.md +807 -0
- package/docs/command-list.md +62 -0
- package/docs/compose-patterns.md +99 -0
- package/docs/concepts.md +173 -0
- package/docs/configuration-essentials.md +177 -0
- package/docs/configuration-reference.md +636 -0
- package/docs/docs-check.md +76 -0
- package/docs/environment.md +948 -0
- package/docs/extending.md +43 -0
- package/docs/faq.md +113 -0
- package/docs/getting-started.md +692 -0
- package/docs/harness-surfaces.md +500 -0
- package/docs/joining-a-team.md +76 -0
- package/docs/release-policy.md +49 -0
- package/docs/safety-and-autonomy.md +463 -0
- package/docs/troubleshooting.md +382 -0
- package/docs/tutorial.md +171 -0
- package/docs/work-and-browser.md +420 -0
- package/libexec/browser-operation.cjs +270 -0
- package/libexec/fence-marker.cjs +101 -0
- package/libexec/fence-marker.d.cts +24 -0
- package/libexec/fenced-group-runner.cjs +77 -0
- package/libexec/fenced-supervisor.cjs +137 -0
- package/libexec/generated-filesystem.cjs +731 -0
- package/libexec/install-filesystem.cjs +225 -0
- package/libexec/rulesync-generator.NOTICE.md +1112 -0
- package/libexec/rulesync-generator.cjs +743 -0
- package/libexec/surface-generator-worker.cjs +266 -0
- package/libexec/surface-output-reader.cjs +99 -0
- package/libexec/surface-scratch-cleanup.cjs +14 -0
- package/libexec/validate-harness-evidence.d.mts +183 -0
- package/libexec/validate-harness-evidence.mjs +1312 -0
- package/package.json +74 -4
- package/surfaces/README.md +33 -0
- package/surfaces/agents/evaluator.agent.md +76 -0
- package/surfaces/guards/bash-guard.sh +48 -0
- package/surfaces/guards/claude.adapter.json +25 -0
- package/surfaces/guards/codex.adapter.json +24 -0
- package/surfaces/guards/opencode.adapter.json +25 -0
- package/surfaces/references/browser.md +63 -0
- package/surfaces/references/test-data-and-personas.md +84 -0
- package/surfaces/references/testing-tiers.md +11 -0
- package/surfaces/skills/cockpit-browser.skill.md +59 -0
- package/surfaces/skills/cockpit-explain.skill.md +32 -0
- package/surfaces/skills/cockpit-fix.skill.md +37 -0
- package/surfaces/skills/cockpit-setup.skill.md +39 -0
- package/surfaces/skills/cockpit-work.skill.md +34 -0
- package/surfaces/skills/collection.json +5 -0
- package/surfaces/skills/procedures/explain.md +66 -0
- package/surfaces/skills/procedures/fix.md +95 -0
- package/surfaces/skills/procedures/setup.md +452 -0
- package/surfaces/skills/procedures/work.md +134 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// Owns the built-in read-only invocation profile: which exact argument shapes of a few inspection
|
|
2
|
+
// commands only read, and which paths each one reads, searches or lists. Agents run these
|
|
3
|
+
// constantly, and an ask that Codex and OpenCode turn into a deny strands them. It performs no I/O
|
|
4
|
+
// and grants nothing alone: the evaluator inspects every returned path, applies every hard denial
|
|
5
|
+
// first, and allows a whole command only when every segment is classified here.
|
|
6
|
+
import { posix } from 'node:path';
|
|
7
|
+
const set = (...values) => new Set(values);
|
|
8
|
+
function parseOptions(argv, table) {
|
|
9
|
+
const positionals = [];
|
|
10
|
+
const present = new Set();
|
|
11
|
+
const files = [];
|
|
12
|
+
let options = true;
|
|
13
|
+
for (let index = 0; index < argv.length; index++) {
|
|
14
|
+
const word = argv[index];
|
|
15
|
+
if (!options || word === '-' || !word.startsWith('-')) {
|
|
16
|
+
positionals.push(word);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (word === '--') {
|
|
20
|
+
options = false;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const long = word.startsWith('--');
|
|
24
|
+
const equals = long ? word.indexOf('=') : -1;
|
|
25
|
+
// `-n5` attaches a short option's value; `--lines=5` attaches a long one's.
|
|
26
|
+
const name = long ? (equals < 0 ? word : word.slice(0, equals)) : table.values.has(word.slice(0, 2)) ? word.slice(0, 2) : word;
|
|
27
|
+
if (table.values.has(name)) {
|
|
28
|
+
const value = long ? (equals < 0 ? argv[++index] : word.slice(equals + 1)) : word.length > 2 ? word.slice(2) : argv[++index];
|
|
29
|
+
if (value === undefined || table.countValues?.has(name) && !/^[+-]?\d+[bkKmMgG]?$/.test(value)
|
|
30
|
+
|| table.exclusionValues?.has(name) && !value.startsWith('!'))
|
|
31
|
+
return undefined;
|
|
32
|
+
if (table.fileValues?.has(name))
|
|
33
|
+
files.push(value);
|
|
34
|
+
present.add(name);
|
|
35
|
+
}
|
|
36
|
+
else if (long && table.attachedOnly?.has(name))
|
|
37
|
+
present.add(name);
|
|
38
|
+
else if (equals < 0 && table.flags.has(word))
|
|
39
|
+
present.add(word);
|
|
40
|
+
else if (equals < 0 && table.cluster?.test(word))
|
|
41
|
+
for (const flag of word.slice(1))
|
|
42
|
+
present.add(`-${flag}`);
|
|
43
|
+
else
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return { positionals, present, files };
|
|
47
|
+
}
|
|
48
|
+
const LS = { flags: set('--all', '--almost-all', '--classify', '--human-readable', '--recursive', '--reverse'), values: set(), attachedOnly: set('--color'), cluster: /^-[1aAbBcCdFfghiklLmnopqrRsStTuUvwxX@]+$/ };
|
|
49
|
+
const CAT = { flags: set('--number', '--number-nonblank', '--show-all', '--show-ends', '--show-tabs', '--squeeze-blank'), values: set(), cluster: /^-[AbeEnstTuv]+$/ };
|
|
50
|
+
// `tail -f` never exits, so following is absent; `head -5` is the legacy count spelling.
|
|
51
|
+
const HEAD_TAIL = { flags: set('-q', '-v', '--quiet', '--silent', '--verbose'), values: set('-n', '-c', '--lines', '--bytes'),
|
|
52
|
+
countValues: set('-n', '-c', '--lines', '--bytes'), cluster: /^-\d+$/ };
|
|
53
|
+
// Only output-shaping flags: `-f`/`--from-file`, `--rawfile`, `--slurpfile` and `-L` read other files and
|
|
54
|
+
// `--arg`-style options take values, so none is listed.
|
|
55
|
+
const JQ = { flags: set('--raw-output', '--compact-output', '--sort-keys', '--slurp', '--exit-status', '--tab', '--join-output', '--ascii-output', '--monochrome-output'),
|
|
56
|
+
values: set(), cluster: /^-[rcSseCMjan]+$/ };
|
|
57
|
+
// `env`, `$ENV` and `$__prog_args` expose the environment, and `import`/`include` read module files.
|
|
58
|
+
const JQ_UNSAFE_FILTER = /\benv\b|\$ENV\b|\$__prog|\b(?:import|include|input_filename|getpath_file)\b/;
|
|
59
|
+
const WC = { flags: set('--bytes', '--chars', '--lines', '--words', '--max-line-length'), values: set(), cluster: /^-[clmwL]+$/ };
|
|
60
|
+
const GREP = {
|
|
61
|
+
flags: set('--recursive', '--dereference-recursive', '--ignore-case', '--invert-match', '--word-regexp', '--line-regexp', '--count', '--files-with-matches', '--files-without-match', '--line-number', '--no-filename', '--with-filename', '--only-matching', '--quiet', '--silent', '--no-messages', '--fixed-strings', '--extended-regexp', '--basic-regexp', '--perl-regexp', '--null', '--text'),
|
|
62
|
+
values: set('-e', '--regexp', '-f', '--file', '-A', '-B', '--after-context', '--before-context', '-m', '--max-count', '--include', '--exclude', '--exclude-dir'),
|
|
63
|
+
fileValues: set('-f', '--file'),
|
|
64
|
+
countValues: set('-A', '-B', '--after-context', '--before-context', '-m', '--max-count'),
|
|
65
|
+
// A misread optional value would swallow the next word, so a file operand would go uninspected.
|
|
66
|
+
// BSD grep, the macOS default, takes `-C` and `--context` values only attached, unlike GNU grep.
|
|
67
|
+
attachedOnly: set('--color', '--colour', '--context'),
|
|
68
|
+
cluster: /^-[iIvwxclLnhHoqsrRFEGPaZz]+$/,
|
|
69
|
+
};
|
|
70
|
+
// Hidden, ignored, compressed and symlink-following searches widen what is read past what the
|
|
71
|
+
// declared protections can see, and `--pre` and `--hostname-bin` run programs, so none is listed.
|
|
72
|
+
// A glob that is not an exclusion overrides the hidden and ignore filters: `rg -g '.env*' KEY`
|
|
73
|
+
// prints a hidden `.env.local`, and `rg -g '*.ts'` an ignored file.
|
|
74
|
+
const RG = {
|
|
75
|
+
flags: set('--ignore-case', '--smart-case', '--case-sensitive', '--word-regexp', '--line-regexp', '--invert-match', '--line-number', '--no-line-number', '--files-with-matches', '--files-without-match', '--count', '--count-matches', '--fixed-strings', '--with-filename', '--no-filename', '--only-matching', '--quiet', '--files', '--no-heading', '--heading', '--vimgrep', '--json', '--column', '--trim', '--stats'),
|
|
76
|
+
values: set('-e', '--regexp', '-f', '--file', '-g', '--glob', '--iglob', '-t', '--type', '-T', '--type-not', '-A', '-B', '-C', '--after-context', '--before-context', '--context', '-m', '--max-count', '-d', '--max-depth', '--max-filesize', '-M', '--max-columns', '--sort', '--sortr', '--color', '--colors'),
|
|
77
|
+
fileValues: set('-f', '--file'),
|
|
78
|
+
countValues: set('-A', '-B', '-C', '--after-context', '--before-context', '--context', '-m', '--max-count', '-d', '--max-depth'),
|
|
79
|
+
exclusionValues: set('-g', '--glob', '--iglob'),
|
|
80
|
+
cluster: /^-[iSswxvnNlcFHIoqp]+$/,
|
|
81
|
+
};
|
|
82
|
+
const FD = {
|
|
83
|
+
flags: set('--hidden', '--no-ignore', '--case-sensitive', '--ignore-case', '--glob', '--regex', '--fixed-strings', '--absolute-path', '--print0', '--full-path'),
|
|
84
|
+
values: set('-t', '--type', '-e', '--extension', '-d', '--max-depth', '--min-depth', '-E', '--exclude', '--max-results', '--color'),
|
|
85
|
+
cluster: /^-[HIsigFap01]+$/,
|
|
86
|
+
};
|
|
87
|
+
const FIND_VALUE = set('-name', '-iname', '-path', '-ipath', '-wholename', '-iwholename', '-regex', '-iregex', '-type', '-maxdepth', '-mindepth', '-mtime', '-mmin', '-atime', '-amin', '-ctime', '-cmin', '-size', '-user', '-group', '-perm', '-newer');
|
|
88
|
+
const FIND_FLAG = set('-print', '-print0', '-prune', '-empty', '-not', '!', '-a', '-and', '-o', '-or', '(', ')', '-depth', '-xdev', '-mount', '-true', '-false');
|
|
89
|
+
function find(argv) {
|
|
90
|
+
let index = 0;
|
|
91
|
+
const roots = [];
|
|
92
|
+
while (index < argv.length && !argv[index].startsWith('-') && argv[index] !== '!' && argv[index] !== '(')
|
|
93
|
+
roots.push(argv[index++]);
|
|
94
|
+
const listings = roots.length ? [...roots] : ['.'];
|
|
95
|
+
for (; index < argv.length; index++) {
|
|
96
|
+
const word = argv[index];
|
|
97
|
+
if (FIND_FLAG.has(word))
|
|
98
|
+
continue;
|
|
99
|
+
if (!FIND_VALUE.has(word) || argv[index + 1] === undefined)
|
|
100
|
+
return undefined;
|
|
101
|
+
if (word === '-newer')
|
|
102
|
+
listings.push(argv[index + 1]);
|
|
103
|
+
index++;
|
|
104
|
+
}
|
|
105
|
+
return { reads: [], trees: [], listings };
|
|
106
|
+
}
|
|
107
|
+
function search(argv, table, recursiveByDefault) {
|
|
108
|
+
const parsed = parseOptions(argv, table);
|
|
109
|
+
if (!parsed)
|
|
110
|
+
return undefined;
|
|
111
|
+
const listOnly = parsed.present.has('--files');
|
|
112
|
+
const explicitPattern = ['-e', '--regexp', '-f', '--file'].some(name => parsed.present.has(name));
|
|
113
|
+
const operands = listOnly || explicitPattern ? parsed.positionals : parsed.positionals.slice(1);
|
|
114
|
+
if (!listOnly && !explicitPattern && parsed.positionals.length === 0)
|
|
115
|
+
return undefined;
|
|
116
|
+
const recursive = recursiveByDefault || ['-r', '-R', '--recursive', '--dereference-recursive'].some(name => parsed.present.has(name));
|
|
117
|
+
// grep follows symlinks only with -R; that reads through links the inspection never sees.
|
|
118
|
+
if (parsed.present.has('-R') || parsed.present.has('--dereference-recursive'))
|
|
119
|
+
return undefined;
|
|
120
|
+
const paths = operands.length ? operands : recursive ? ['.'] : [];
|
|
121
|
+
if (listOnly)
|
|
122
|
+
return { reads: parsed.files, trees: [], listings: paths };
|
|
123
|
+
return recursive ? { reads: parsed.files, trees: paths, listings: [] } : { reads: [...parsed.files, ...paths], trees: [], listings: [] };
|
|
124
|
+
}
|
|
125
|
+
// Only `p` commands on line-number or last-line addresses: any other sed command can write (`w`),
|
|
126
|
+
// read another file (`r`), run a program (GNU `e`) or edit in place (`-i`).
|
|
127
|
+
const SED_PRINT = /^(?:\d+|\$)(?:,(?:\d+|\$))?p(?:;(?:\d+|\$)(?:,(?:\d+|\$))?p)*$/;
|
|
128
|
+
function sed(argv) {
|
|
129
|
+
const scripts = [];
|
|
130
|
+
const operands = [];
|
|
131
|
+
let options = true;
|
|
132
|
+
for (let index = 0; index < argv.length; index++) {
|
|
133
|
+
const word = argv[index];
|
|
134
|
+
if (options && word === '--')
|
|
135
|
+
options = false;
|
|
136
|
+
else if (!options || word === '-' || !word.startsWith('-'))
|
|
137
|
+
operands.push(word);
|
|
138
|
+
else if (word === '-e' || word === '--expression') {
|
|
139
|
+
const script = argv[++index];
|
|
140
|
+
if (script === undefined)
|
|
141
|
+
return undefined;
|
|
142
|
+
scripts.push(script);
|
|
143
|
+
}
|
|
144
|
+
else if (word.startsWith('--expression='))
|
|
145
|
+
scripts.push(word.slice('--expression='.length));
|
|
146
|
+
else if (!['-n', '--quiet', '--silent'].includes(word))
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
// Without -e the first operand is the script.
|
|
150
|
+
if (!scripts.length && operands.length)
|
|
151
|
+
scripts.push(operands.shift());
|
|
152
|
+
return scripts.length && scripts.every(script => SED_PRINT.test(script)) ? { reads: operands, trees: [], listings: [] } : undefined;
|
|
153
|
+
}
|
|
154
|
+
function files(argv, table) {
|
|
155
|
+
const parsed = parseOptions(argv, table);
|
|
156
|
+
return parsed && { reads: parsed.positionals, trees: [], listings: [] };
|
|
157
|
+
}
|
|
158
|
+
function jq(argv) {
|
|
159
|
+
const parsed = parseOptions(argv, JQ);
|
|
160
|
+
const [filter, ...operands] = parsed?.positionals ?? [];
|
|
161
|
+
// `-n` reads no input, so a file operand with it is still just a read; the filter alone must be inert.
|
|
162
|
+
return parsed && filter !== undefined && !JQ_UNSAFE_FILTER.test(filter) ? { reads: operands, trees: [], listings: [] } : undefined;
|
|
163
|
+
}
|
|
164
|
+
const GIT_READ_VERBS = set('status', 'diff', 'log', 'show');
|
|
165
|
+
const GIT_BRANCH_LIST = set('--list', '-a', '--all', '-r', '--remotes', '-v', '-vv', '--verbose', '--show-current');
|
|
166
|
+
// Diff output that names files or counts lines; any other diff output prints file content.
|
|
167
|
+
const GIT_NAME_ONLY = set('--stat', '--numstat', '--shortstat', '--name-only', '--name-status', '--summary', '--raw', '--dirstat', '-s', '--no-patch', '--quiet');
|
|
168
|
+
// Options that print changed lines: patch output, and `--check`, which quotes each line it flags. Git
|
|
169
|
+
// also accepts some short options bundled, so any single-dash word holding one of these letters
|
|
170
|
+
// counts, at the cost of asking for an attached `-S` pickaxe value.
|
|
171
|
+
const GIT_PATCH = /^(?:--patch(?:-with-(?:stat|raw))?|--cc|--dd|--remerge-diff|--diff-merges|--word-diff|--color-words|--function-context|--unified|--binary|--check)$/;
|
|
172
|
+
/** What file content `git diff`, `show` or `log` prints, or undefined when it prints none. */
|
|
173
|
+
function gitTrackedContent(verb, args) {
|
|
174
|
+
const end = args.indexOf('--');
|
|
175
|
+
const options = end < 0 ? args : args.slice(0, end);
|
|
176
|
+
const name = (arg) => arg.split('=')[0];
|
|
177
|
+
const patch = options.some(arg => GIT_PATCH.test(name(arg)) || /^-[^-]/.test(arg) && /[pucmWU]/.test(arg.slice(1)));
|
|
178
|
+
const revisions = options.some(arg => !arg.startsWith('-'));
|
|
179
|
+
const nameOnly = options.some(arg => GIT_NAME_ONLY.has(name(arg)));
|
|
180
|
+
// `git show` prints a named blob whatever its options, and `diff` and `show` print a named blob
|
|
181
|
+
// whatever pathspec follows, so only a revision-free command is limited by its pathspecs.
|
|
182
|
+
if (!(verb === 'log' ? patch : patch || !nameOnly || verb === 'show' && revisions))
|
|
183
|
+
return undefined;
|
|
184
|
+
const pathspecs = end < 0 ? null : args.slice(end + 1);
|
|
185
|
+
// Magic and wildcard pathspecs match more than their spelling, so they limit nothing.
|
|
186
|
+
// `--full-diff` prints every file a commit the pathspec selects changed.
|
|
187
|
+
return { limitedTo: pathspecs === null || verb !== 'log' && revisions || pathspecs.length === 0 || options.includes('--full-diff')
|
|
188
|
+
|| pathspecs.some(spec => spec.startsWith(':') || /[*?[\\]/.test(spec)) ? null : pathspecs };
|
|
189
|
+
}
|
|
190
|
+
// Git discovers an implicit bare repository in any directory holding HEAD, objects and refs, and runs
|
|
191
|
+
// programs its config names, so read-only Git runs only where `.git` exists: discovery takes it before
|
|
192
|
+
// the directory itself, and nothing under `.git` is agent-writable.
|
|
193
|
+
function git(argv, cwd) {
|
|
194
|
+
let index = 0;
|
|
195
|
+
let directory = cwd;
|
|
196
|
+
// `-c`, `--git-dir` and friends change which configuration runs; only -C and paging are exact.
|
|
197
|
+
while (argv[index]?.startsWith('-')) {
|
|
198
|
+
const option = argv[index++];
|
|
199
|
+
if (option === '-C' && argv[index] !== undefined)
|
|
200
|
+
directory = posix.resolve(directory, argv[index++]);
|
|
201
|
+
else if (option !== '--no-pager')
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
const verb = argv[index++];
|
|
205
|
+
const args = argv.slice(index);
|
|
206
|
+
const requires = ['.git'];
|
|
207
|
+
// Branch names are positional only when creating, renaming or deleting, so flags alone only list.
|
|
208
|
+
if (verb === 'branch')
|
|
209
|
+
return args.every(arg => GIT_BRANCH_LIST.has(arg)) ? { cwd: directory, reads: [], trees: [], listings: [], requires } : undefined;
|
|
210
|
+
// rev-parse prints object names, refs and repository paths, never file content.
|
|
211
|
+
if (verb === 'rev-parse')
|
|
212
|
+
return args.some(arg => /^--(?:git-path|resolve-git-dir|parseopt|sq-quote)(?:=|$)/.test(arg)) ? undefined : { cwd: directory, reads: [], trees: [], listings: [], requires };
|
|
213
|
+
if (verb === undefined || !GIT_READ_VERBS.has(verb))
|
|
214
|
+
return undefined;
|
|
215
|
+
// --output writes a file, an external diff driver runs a program, and --no-index prints any file.
|
|
216
|
+
if (args.some(arg => /^--(?:output|ext-diff|textconv|no-index)(?:=|$)/.test(arg)))
|
|
217
|
+
return undefined;
|
|
218
|
+
// Revision operands that name a blob (`HEAD:path`) print content the path inspection cannot see, and
|
|
219
|
+
// so does `git log -L<range>:<path>`, whose path is attached to the option.
|
|
220
|
+
if (args.some(arg => !arg.startsWith('-') && arg.includes(':') || /^-L/.test(arg)))
|
|
221
|
+
return undefined;
|
|
222
|
+
// Operands may be pathspecs whose content is printed, and a path outside the repository turns
|
|
223
|
+
// `git diff` into a file comparison, so every operand is inspected as a read.
|
|
224
|
+
const trackedContent = verb === 'status' ? undefined : gitTrackedContent(verb, args);
|
|
225
|
+
return { cwd: directory, reads: args.filter(arg => !arg.startsWith('-')), trees: [], listings: [], requires, ...(trackedContent ? { trackedContent } : {}) };
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* How many leading words of `argv` belong to the launcher when `executable` may start cockpit, or
|
|
229
|
+
* undefined when it cannot: the bare `cockpit` name, a path, `node <path>`, and `npx --no [--]
|
|
230
|
+
* cockpit`. Every spelling is a candidate only; the application proves which one starts the guard's
|
|
231
|
+
* own installed cockpit, so all of them are judged by that one identity.
|
|
232
|
+
*/
|
|
233
|
+
export function cockpitLauncherPrefix(executable, argv) {
|
|
234
|
+
if (executable === 'cockpit' || executable.includes('/'))
|
|
235
|
+
return 0;
|
|
236
|
+
// `node --require … launcher` would run other code first, so the script must come first.
|
|
237
|
+
if (executable === 'node')
|
|
238
|
+
return argv[0]?.includes('/') && !argv[0].startsWith('-') ? 1 : undefined;
|
|
239
|
+
// Without --no, npx downloads and runs a missing package; any other npx option chooses the
|
|
240
|
+
// package, the command or the shell. npx also reads every option before the first operand after
|
|
241
|
+
// the package name as its own, so `npx --no cockpit --script-shell=… doctor` runs another program.
|
|
242
|
+
if (executable !== 'npx' || argv[0] !== '--no')
|
|
243
|
+
return undefined;
|
|
244
|
+
if (argv[1] === '--')
|
|
245
|
+
return argv[2] === 'cockpit' ? 3 : undefined;
|
|
246
|
+
return argv[1] === 'cockpit' && argv[2] !== undefined && !argv[2].startsWith('-') ? 2 : undefined;
|
|
247
|
+
}
|
|
248
|
+
const COCKPIT_READ_VERBS = set('check', 'doctor');
|
|
249
|
+
// Help and version print and exit before any command runs; `<verb> --help` and, for a command
|
|
250
|
+
// group, `<group> <subcommand> --help` do the same.
|
|
251
|
+
function cockpit(argv) {
|
|
252
|
+
if (argv.length === 1 && (argv[0] === '--help' || argv[0] === '--version')
|
|
253
|
+
|| argv.length >= 2 && argv.length <= 3 && argv.at(-1) === '--help' && argv.slice(0, -1).every(word => /^[a-z][a-z-]*$/.test(word))) {
|
|
254
|
+
return { reads: [], trees: [], listings: [] };
|
|
255
|
+
}
|
|
256
|
+
const [verb, ...rest] = argv;
|
|
257
|
+
if (verb === undefined || !COCKPIT_READ_VERBS.has(verb))
|
|
258
|
+
return undefined;
|
|
259
|
+
const parsed = parseOptions(rest, { flags: set('--json'), values: set('--config'), fileValues: set('--config') });
|
|
260
|
+
return parsed && parsed.positionals.length === 0 ? { reads: parsed.files, trees: [], listings: [] } : undefined;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The paths an exact read-only invocation touches, or undefined when it is not one. `cockpit` holds
|
|
264
|
+
* the cockpit arguments only when the application proved the invocation starts the installed cockpit.
|
|
265
|
+
*/
|
|
266
|
+
export function classifyReadOnlyInvocation(invocation, environment = { ripgrepConfigActive: false }) {
|
|
267
|
+
if (invocation.executable === null || invocation.wrapped || invocation.redirects.some(redirect => redirect.write)
|
|
268
|
+
|| invocation.words.some(word => word.role === 'environment-assignment-value'))
|
|
269
|
+
return undefined;
|
|
270
|
+
const argv = invocation.argv;
|
|
271
|
+
const inputs = invocation.redirects.map(redirect => redirect.target);
|
|
272
|
+
const shape = (classified) => classified && { cwd: invocation.cwd, ...classified, reads: [...classified.reads, ...inputs] };
|
|
273
|
+
const access = classify(invocation, environment, shape, inputs);
|
|
274
|
+
// `$?` expands to digits the guard cannot see, so a path holding it is unproven.
|
|
275
|
+
return invocation.expandsStatus && access && [access.cwd, ...access.reads, ...access.trees, ...access.listings, ...access.requires ?? []].some(path => path.includes('$?'))
|
|
276
|
+
? undefined : access;
|
|
277
|
+
}
|
|
278
|
+
function classify(invocation, environment, shape, inputs) {
|
|
279
|
+
const argv = invocation.argv;
|
|
280
|
+
if (environment.cockpit)
|
|
281
|
+
return shape(cockpit(environment.cockpit));
|
|
282
|
+
switch (invocation.executable) {
|
|
283
|
+
// Both print their arguments and touch no file. `printf -v` assigns any variable, PATH and HOME
|
|
284
|
+
// included, and evaluates an array subscript, so printf is read-only only without options.
|
|
285
|
+
case 'echo': return shape({ reads: [], trees: [], listings: [] });
|
|
286
|
+
case 'printf': return argv[0] !== undefined && !argv[0].startsWith('-') ? shape({ reads: [], trees: [], listings: [] }) : undefined;
|
|
287
|
+
case 'sed': return shape(sed(argv));
|
|
288
|
+
case 'pwd': return argv.length === 0 || argv.length === 1 && ['-L', '-P'].includes(argv[0]) ? shape({ reads: [], trees: [], listings: [] }) : undefined;
|
|
289
|
+
case 'ls': {
|
|
290
|
+
const parsed = parseOptions(argv, LS);
|
|
291
|
+
return parsed && shape({ reads: [], trees: [], listings: parsed.positionals.length ? parsed.positionals : ['.'] });
|
|
292
|
+
}
|
|
293
|
+
case 'cat': return shape(files(argv, CAT));
|
|
294
|
+
case 'head':
|
|
295
|
+
case 'tail': return shape(files(argv, HEAD_TAIL));
|
|
296
|
+
case 'jq': return shape(jq(argv));
|
|
297
|
+
case 'wc': return shape(files(argv, WC));
|
|
298
|
+
case 'grep': return shape(search(argv, GREP, false));
|
|
299
|
+
// Every option ripgrep is admitted with keeps its ignore filters, which the trees are then judged by.
|
|
300
|
+
case 'rg': {
|
|
301
|
+
const access = environment.ripgrepConfigActive ? undefined : shape(search(argv, RG, true));
|
|
302
|
+
return access && { ...access, skipsIgnored: true };
|
|
303
|
+
}
|
|
304
|
+
case 'fd': {
|
|
305
|
+
const parsed = parseOptions(argv, FD);
|
|
306
|
+
return parsed && shape({ reads: [], trees: [], listings: parsed.positionals.length > 1 ? parsed.positionals.slice(1) : ['.'] });
|
|
307
|
+
}
|
|
308
|
+
case 'find': return shape(find(argv));
|
|
309
|
+
case 'git': {
|
|
310
|
+
const access = git(argv, invocation.cwd);
|
|
311
|
+
return access && inputs.length === 0 ? access : undefined;
|
|
312
|
+
}
|
|
313
|
+
default: return undefined;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { SurfaceTarget } from '../surfaces/contract.js';
|
|
2
|
+
import { type CockpitRootQuestion, type InitApplicationInput, type InitApplicationOutcome } from '../environment/init-application.js';
|
|
3
|
+
interface InitCommandInput {
|
|
4
|
+
readonly root: string;
|
|
5
|
+
readonly target: SurfaceTarget;
|
|
6
|
+
/** Every chosen tool, target first; just the target when only one was given. */
|
|
7
|
+
readonly tools?: readonly SurfaceTarget[];
|
|
8
|
+
readonly registry?: string;
|
|
9
|
+
readonly sessionId?: string;
|
|
10
|
+
readonly platform?: 'darwin' | 'linux';
|
|
11
|
+
readonly home?: string;
|
|
12
|
+
readonly xdgStateHome?: string;
|
|
13
|
+
readonly resetAnswer?: InitApplicationInput['resetAnswer'];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Consent and answers supplied as arguments by a caller with no terminal. The digests are the ones a
|
|
17
|
+
* pending run printed, so acceptance stays bound to the exact bytes and no flag accepts blindly.
|
|
18
|
+
*/
|
|
19
|
+
export interface UnattendedInit {
|
|
20
|
+
readonly previewSha256: string;
|
|
21
|
+
/** The parsed answers file, keyed by interview field (nested tables spell the dotted field names). */
|
|
22
|
+
readonly answers: Readonly<Record<string, unknown>>;
|
|
23
|
+
readonly defaultsSha256?: string;
|
|
24
|
+
}
|
|
25
|
+
interface InitCommandOptions {
|
|
26
|
+
readonly interactive: boolean;
|
|
27
|
+
readonly json: boolean;
|
|
28
|
+
readonly unattended?: UnattendedInit;
|
|
29
|
+
}
|
|
30
|
+
export interface InitCommandIo {
|
|
31
|
+
readonly terminal: boolean;
|
|
32
|
+
readonly confirm: (preview: NonNullable<InitApplicationOutcome['result']>) => Promise<string | undefined>;
|
|
33
|
+
readonly writeArtifact: (destination: string, artifact: string) => Promise<void>;
|
|
34
|
+
readonly answerQuestion?: (question: NonNullable<NonNullable<InitApplicationOutcome['result']>['question']>) => Promise<string | undefined>;
|
|
35
|
+
readonly chooseCockpitRoot?: (question: CockpitRootQuestion) => Promise<string | undefined>;
|
|
36
|
+
/** Creates and initialises one repository beside the product, or initialises its existing plain directory; it never creates parents. */
|
|
37
|
+
readonly createCockpitRoot?: (path: string) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
type InitApplicationHandler = (input: InitApplicationInput) => Promise<InitApplicationOutcome>;
|
|
40
|
+
export declare function runInitOperatorCommand(input: InitCommandInput, options: InitCommandOptions, io: InitCommandIo, application: InitApplicationHandler): Promise<InitApplicationOutcome>;
|
|
41
|
+
export {};
|