@nathapp/nax-agent 0.1.0
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 +24 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/coding-tools/coding-tool-bash.d.ts +46 -0
- package/dist/coding-tools/coding-tool-bash.js +44 -0
- package/dist/coding-tools/coding-tool-extras.d.ts +35 -0
- package/dist/coding-tools/coding-tool-extras.js +56 -0
- package/dist/coding-tools/coding-tool-sandbox.d.ts +74 -0
- package/dist/coding-tools/coding-tool-sandbox.js +215 -0
- package/dist/coding-tools/coding-tool-support.d.ts +132 -0
- package/dist/coding-tools/coding-tool-support.js +159 -0
- package/dist/coding-tools/universal-coding-tools.d.ts +11 -0
- package/dist/coding-tools/universal-coding-tools.js +5 -0
- package/dist/command-interceptor/index.d.ts +55 -0
- package/dist/command-interceptor/index.js +60 -0
- package/dist/command-interceptor/shell.d.ts +36 -0
- package/dist/command-interceptor/shell.js +137 -0
- package/dist/command-safety/build.d.ts +19 -0
- package/dist/command-safety/build.js +47 -0
- package/dist/command-safety/guard.d.ts +32 -0
- package/dist/command-safety/guard.js +179 -0
- package/dist/command-safety/identifiers.d.ts +24 -0
- package/dist/command-safety/identifiers.js +20 -0
- package/dist/command-safety/index.d.ts +17 -0
- package/dist/command-safety/index.js +11 -0
- package/dist/command-safety/questions.d.ts +19 -0
- package/dist/command-safety/questions.js +60 -0
- package/dist/command-safety/row.d.ts +2 -0
- package/dist/command-safety/row.js +14 -0
- package/dist/command-safety/rule-scorer.d.ts +9 -0
- package/dist/command-safety/rule-scorer.js +391 -0
- package/dist/command-safety/shadow.d.ts +33 -0
- package/dist/command-safety/shadow.js +188 -0
- package/dist/command-safety/systemone-client.d.ts +16 -0
- package/dist/command-safety/systemone-client.js +92 -0
- package/dist/command-safety/tap.d.ts +37 -0
- package/dist/command-safety/tap.js +77 -0
- package/dist/command-safety/temp-only.d.ts +6 -0
- package/dist/command-safety/temp-only.js +215 -0
- package/dist/command-safety/tmp-write.d.ts +2 -0
- package/dist/command-safety/tmp-write.js +112 -0
- package/dist/command-safety/types.d.ts +185 -0
- package/dist/command-safety/types.js +21 -0
- package/dist/config/bash-approval.d.ts +33 -0
- package/dist/config/bash-approval.js +30 -0
- package/dist/config/catalog-overrides.d.ts +94 -0
- package/dist/config/catalog-overrides.js +7 -0
- package/dist/config/native-agent/index.d.ts +8 -0
- package/dist/config/native-agent/index.js +8 -0
- package/dist/config/schemas-sandbox.d.ts +31 -0
- package/dist/config/schemas-sandbox.js +45 -0
- package/dist/cost/core/index.d.ts +8 -0
- package/dist/cost/core/index.js +7 -0
- package/dist/cost/estimate.d.ts +34 -0
- package/dist/cost/estimate.js +65 -0
- package/dist/cost/model-spec.d.ts +28 -0
- package/dist/cost/model-spec.js +29 -0
- package/dist/cost/standard-types.d.ts +9 -0
- package/dist/cost/standard-types.js +1 -0
- package/dist/cost/usage-math.d.ts +18 -0
- package/dist/cost/usage-math.js +46 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +21 -0
- package/dist/infra/agent-logger.d.ts +22 -0
- package/dist/infra/agent-logger.js +19 -0
- package/dist/infra/credentials-config.d.ts +20 -0
- package/dist/infra/credentials-config.js +15 -0
- package/dist/infra/errors.d.ts +9 -0
- package/dist/infra/errors.js +11 -0
- package/dist/infra/index.d.ts +7 -0
- package/dist/infra/index.js +7 -0
- package/dist/infra/nax-error.d.ts +10 -0
- package/dist/infra/nax-error.js +16 -0
- package/dist/infra/spin-breaker/hash.d.ts +2 -0
- package/dist/infra/spin-breaker/hash.js +5 -0
- package/dist/infra/spin-breaker/index.d.ts +120 -0
- package/dist/infra/spin-breaker/index.js +340 -0
- package/dist/internal/agent-output-env.d.ts +44 -0
- package/dist/internal/agent-output-env.js +57 -0
- package/dist/internal/argv-exec.d.ts +58 -0
- package/dist/internal/argv-exec.js +224 -0
- package/dist/internal/bounded-io.d.ts +24 -0
- package/dist/internal/bounded-io.js +51 -0
- package/dist/internal/command-spec/index.d.ts +29 -0
- package/dist/internal/command-spec/index.js +36 -0
- package/dist/internal/describe-value-type.d.ts +8 -0
- package/dist/internal/describe-value-type.js +14 -0
- package/dist/internal/exec-framing.d.ts +18 -0
- package/dist/internal/exec-framing.js +22 -0
- package/dist/internal/file-lock.d.ts +91 -0
- package/dist/internal/file-lock.js +212 -0
- package/dist/internal/file-size.d.ts +2 -0
- package/dist/internal/file-size.js +12 -0
- package/dist/internal/git-add.d.ts +43 -0
- package/dist/internal/git-add.js +59 -0
- package/dist/internal/git-env.d.ts +59 -0
- package/dist/internal/git-env.js +93 -0
- package/dist/internal/git-exec.d.ts +58 -0
- package/dist/internal/git-exec.js +115 -0
- package/dist/internal/path-file-lock.d.ts +23 -0
- package/dist/internal/path-file-lock.js +25 -0
- package/dist/internal/process-alive.d.ts +42 -0
- package/dist/internal/process-alive.js +56 -0
- package/dist/internal/process-kill.d.ts +27 -0
- package/dist/internal/process-kill.js +54 -0
- package/dist/internal/realpath.d.ts +29 -0
- package/dist/internal/realpath.js +52 -0
- package/dist/internal/redact.d.ts +40 -0
- package/dist/internal/redact.js +161 -0
- package/dist/internal/shell-quote.d.ts +2 -0
- package/dist/internal/shell-quote.js +4 -0
- package/dist/internal/sort.d.ts +20 -0
- package/dist/internal/sort.js +20 -0
- package/dist/internal/strip-control-chars.d.ts +19 -0
- package/dist/internal/strip-control-chars.js +38 -0
- package/dist/internal/thenable.d.ts +10 -0
- package/dist/internal/thenable.js +15 -0
- package/dist/internal.d.ts +91 -0
- package/dist/internal.js +91 -0
- package/dist/native/adapter-deps.d.ts +46 -0
- package/dist/native/adapter-deps.js +43 -0
- package/dist/native/auth-types.d.ts +70 -0
- package/dist/native/auth-types.js +13 -0
- package/dist/native/auth.d.ts +133 -0
- package/dist/native/auth.js +362 -0
- package/dist/native/client.d.ts +50 -0
- package/dist/native/client.js +174 -0
- package/dist/native/complete.d.ts +33 -0
- package/dist/native/complete.js +88 -0
- package/dist/native/credentials/chained-store.d.ts +30 -0
- package/dist/native/credentials/chained-store.js +68 -0
- package/dist/native/credentials/change-guard.d.ts +51 -0
- package/dist/native/credentials/change-guard.js +136 -0
- package/dist/native/credentials/exec-source.d.ts +50 -0
- package/dist/native/credentials/exec-source.js +222 -0
- package/dist/native/credentials/fingerprint.d.ts +26 -0
- package/dist/native/credentials/fingerprint.js +174 -0
- package/dist/native/credentials/helper-process.d.ts +79 -0
- package/dist/native/credentials/helper-process.js +259 -0
- package/dist/native/credentials/helper-protocol.d.ts +36 -0
- package/dist/native/credentials/helper-protocol.js +79 -0
- package/dist/native/credentials/index.d.ts +60 -0
- package/dist/native/credentials/index.js +184 -0
- package/dist/native/errors.d.ts +34 -0
- package/dist/native/errors.js +109 -0
- package/dist/native/index.d.ts +25 -0
- package/dist/native/index.js +23 -0
- package/dist/native/model-resolver.d.ts +57 -0
- package/dist/native/model-resolver.js +73 -0
- package/dist/native/models.d.ts +116 -0
- package/dist/native/models.js +183 -0
- package/dist/native/session/ask-human.d.ts +15 -0
- package/dist/native/session/ask-human.js +22 -0
- package/dist/native/session/compaction.d.ts +94 -0
- package/dist/native/session/compaction.js +170 -0
- package/dist/native/session/handle-invalid-tool-call.d.ts +111 -0
- package/dist/native/session/handle-invalid-tool-call.js +159 -0
- package/dist/native/session/loop-events/cache-boundary.d.ts +11 -0
- package/dist/native/session/loop-events/cache-boundary.js +29 -0
- package/dist/native/session/loop-events/external-handler.d.ts +38 -0
- package/dist/native/session/loop-events/external-handler.js +193 -0
- package/dist/native/session/loop-events/index.d.ts +16 -0
- package/dist/native/session/loop-events/index.js +15 -0
- package/dist/native/session/loop-events/payload-guard.d.ts +9 -0
- package/dist/native/session/loop-events/payload-guard.js +31 -0
- package/dist/native/session/loop-events/registry.d.ts +84 -0
- package/dist/native/session/loop-events/registry.js +305 -0
- package/dist/native/session/loop-events/types.d.ts +251 -0
- package/dist/native/session/loop-events/types.js +14 -0
- package/dist/native/session/loop-handlers.d.ts +73 -0
- package/dist/native/session/loop-handlers.js +137 -0
- package/dist/native/session/nudge.d.ts +29 -0
- package/dist/native/session/nudge.js +35 -0
- package/dist/native/session/rate-provenance.d.ts +17 -0
- package/dist/native/session/rate-provenance.js +39 -0
- package/dist/native/session/session.d.ts +139 -0
- package/dist/native/session/session.js +208 -0
- package/dist/native/session/tool-input-exemplar.d.ts +2 -0
- package/dist/native/session/tool-input-exemplar.js +66 -0
- package/dist/native/session/tool-input-validation.d.ts +15 -0
- package/dist/native/session/tool-input-validation.js +146 -0
- package/dist/native/session/tool-mapping.d.ts +18 -0
- package/dist/native/session/tool-mapping.js +27 -0
- package/dist/native/session/tool-result.d.ts +37 -0
- package/dist/native/session/tool-result.js +25 -0
- package/dist/native/session/transcript-store.d.ts +77 -0
- package/dist/native/session/transcript-store.js +200 -0
- package/dist/native/session/truncation-handler.d.ts +47 -0
- package/dist/native/session/truncation-handler.js +83 -0
- package/dist/native/session/turn-accumulator.d.ts +45 -0
- package/dist/native/session/turn-accumulator.js +67 -0
- package/dist/native/session/turn-ask-human.d.ts +23 -0
- package/dist/native/session/turn-ask-human.js +41 -0
- package/dist/native/session/turn-compaction-step.d.ts +74 -0
- package/dist/native/session/turn-compaction-step.js +128 -0
- package/dist/native/session/turn-complete-step.d.ts +77 -0
- package/dist/native/session/turn-complete-step.js +159 -0
- package/dist/native/session/turn-end-event.d.ts +3 -0
- package/dist/native/session/turn-end-event.js +17 -0
- package/dist/native/session/turn-events.d.ts +63 -0
- package/dist/native/session/turn-events.js +48 -0
- package/dist/native/session/turn-loop-round-trip.d.ts +116 -0
- package/dist/native/session/turn-loop-round-trip.js +318 -0
- package/dist/native/session/turn-loop.d.ts +23 -0
- package/dist/native/session/turn-loop.js +250 -0
- package/dist/native/session/turn-result.d.ts +39 -0
- package/dist/native/session/turn-result.js +64 -0
- package/dist/native/session/turn-retry.d.ts +120 -0
- package/dist/native/session/turn-retry.js +182 -0
- package/dist/native/session/turn-tool-batch.d.ts +61 -0
- package/dist/native/session/turn-tool-batch.js +259 -0
- package/dist/native/session/turn-types.d.ts +164 -0
- package/dist/native/session/turn-types.js +36 -0
- package/dist/native/session-adapter.d.ts +56 -0
- package/dist/native/session-adapter.js +369 -0
- package/dist/native/session-affinity.d.ts +36 -0
- package/dist/native/session-affinity.js +43 -0
- package/dist/native/tier-providers.d.ts +18 -0
- package/dist/native/tier-providers.js +20 -0
- package/dist/permissions/approval-audit.d.ts +10 -0
- package/dist/permissions/approval-audit.js +22 -0
- package/dist/permissions/approvals-link.d.ts +20 -0
- package/dist/permissions/approvals-link.js +62 -0
- package/dist/permissions/approvals-store.d.ts +168 -0
- package/dist/permissions/approvals-store.js +259 -0
- package/dist/permissions/approvals-taint.d.ts +33 -0
- package/dist/permissions/approvals-taint.js +138 -0
- package/dist/permissions/ask-chain.d.ts +69 -0
- package/dist/permissions/ask-chain.js +32 -0
- package/dist/permissions/ask.d.ts +23 -0
- package/dist/permissions/ask.js +25 -0
- package/dist/permissions/bash-lex.d.ts +59 -0
- package/dist/permissions/bash-lex.js +279 -0
- package/dist/permissions/grammar.d.ts +12 -0
- package/dist/permissions/grammar.js +24 -0
- package/dist/permissions/index.d.ts +11 -0
- package/dist/permissions/index.js +9 -0
- package/dist/permissions/secret-spans.d.ts +19 -0
- package/dist/permissions/secret-spans.js +88 -0
- package/dist/permissions/types.d.ts +85 -0
- package/dist/permissions/types.js +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/node-glob.d.ts +3 -0
- package/dist/runtime/node-glob.js +83 -0
- package/dist/runtime/node-runtime.d.ts +3 -0
- package/dist/runtime/node-runtime.js +126 -0
- package/dist/runtime/slot.d.ts +11 -0
- package/dist/runtime/slot.js +17 -0
- package/dist/runtime/types.d.ts +51 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/which.d.ts +8 -0
- package/dist/runtime/which.js +32 -0
- package/dist/sandbox/argv-quote.d.ts +11 -0
- package/dist/sandbox/argv-quote.js +13 -0
- package/dist/sandbox/defaults.d.ts +27 -0
- package/dist/sandbox/defaults.js +47 -0
- package/dist/sandbox/git-guards.d.ts +64 -0
- package/dist/sandbox/git-guards.js +161 -0
- package/dist/sandbox/index.d.ts +11 -0
- package/dist/sandbox/index.js +10 -0
- package/dist/sandbox/launcher.d.ts +37 -0
- package/dist/sandbox/launcher.js +160 -0
- package/dist/sandbox/messages.d.ts +17 -0
- package/dist/sandbox/messages.js +46 -0
- package/dist/sandbox/policy-builder.d.ts +44 -0
- package/dist/sandbox/policy-builder.js +149 -0
- package/dist/sandbox/policy-inputs.d.ts +53 -0
- package/dist/sandbox/policy-inputs.js +76 -0
- package/dist/sandbox/probe.d.ts +8 -0
- package/dist/sandbox/probe.js +66 -0
- package/dist/sandbox/registry.d.ts +17 -0
- package/dist/sandbox/registry.js +57 -0
- package/dist/sandbox/session-tmp.d.ts +20 -0
- package/dist/sandbox/session-tmp.js +95 -0
- package/dist/sandbox/srt-backend.d.ts +21 -0
- package/dist/sandbox/srt-backend.js +99 -0
- package/dist/sandbox/types.d.ts +102 -0
- package/dist/sandbox/types.js +1 -0
- package/dist/session/adapter-failure.d.ts +60 -0
- package/dist/session/adapter-failure.js +11 -0
- package/dist/session/agent-stream-events.d.ts +103 -0
- package/dist/session/agent-stream-events.js +6 -0
- package/dist/session/interaction-handler.d.ts +53 -0
- package/dist/session/interaction-handler.js +2 -0
- package/dist/session/no-op-interaction-handler.d.ts +9 -0
- package/dist/session/no-op-interaction-handler.js +11 -0
- package/dist/session/protocol-types.d.ts +12 -0
- package/dist/session/protocol-types.js +1 -0
- package/dist/session/session-types.d.ts +456 -0
- package/dist/session/session-types.js +64 -0
- package/dist/session/tool-descriptor.d.ts +23 -0
- package/dist/session/tool-descriptor.js +5 -0
- package/dist/session/turn-deadline.d.ts +17 -0
- package/dist/session/turn-deadline.js +23 -0
- package/dist/tools/ask-request.d.ts +35 -0
- package/dist/tools/ask-request.js +57 -0
- package/dist/tools/bash-cwd.d.ts +82 -0
- package/dist/tools/bash-cwd.js +55 -0
- package/dist/tools/bash.d.ts +69 -0
- package/dist/tools/bash.js +283 -0
- package/dist/tools/delete.d.ts +57 -0
- package/dist/tools/delete.js +154 -0
- package/dist/tools/denial-redirect.d.ts +42 -0
- package/dist/tools/denial-redirect.js +266 -0
- package/dist/tools/deny-paths.d.ts +35 -0
- package/dist/tools/deny-paths.js +76 -0
- package/dist/tools/edit-region.d.ts +50 -0
- package/dist/tools/edit-region.js +90 -0
- package/dist/tools/edit.d.ts +25 -0
- package/dist/tools/edit.js +114 -0
- package/dist/tools/exec-allowlist-text.d.ts +18 -0
- package/dist/tools/exec-allowlist-text.js +24 -0
- package/dist/tools/exec-guard.d.ts +69 -0
- package/dist/tools/exec-guard.js +151 -0
- package/dist/tools/git-commit.d.ts +59 -0
- package/dist/tools/git-commit.js +220 -0
- package/dist/tools/git-flags/index.d.ts +10 -0
- package/dist/tools/git-flags/index.js +10 -0
- package/dist/tools/git.d.ts +88 -0
- package/dist/tools/git.js +397 -0
- package/dist/tools/glob.d.ts +29 -0
- package/dist/tools/glob.js +153 -0
- package/dist/tools/grep.d.ts +21 -0
- package/dist/tools/grep.js +162 -0
- package/dist/tools/index.d.ts +36 -0
- package/dist/tools/index.js +28 -0
- package/dist/tools/narrow-grants.d.ts +19 -0
- package/dist/tools/narrow-grants.js +54 -0
- package/dist/tools/nax-owned-writes.d.ts +135 -0
- package/dist/tools/nax-owned-writes.js +259 -0
- package/dist/tools/package-managers-table.d.ts +146 -0
- package/dist/tools/package-managers-table.js +325 -0
- package/dist/tools/package-managers-types.d.ts +36 -0
- package/dist/tools/package-managers-types.js +6 -0
- package/dist/tools/package-managers.d.ts +85 -0
- package/dist/tools/package-managers.js +391 -0
- package/dist/tools/path-list.d.ts +38 -0
- package/dist/tools/path-list.js +62 -0
- package/dist/tools/policy-bash-raw.d.ts +19 -0
- package/dist/tools/policy-bash-raw.js +210 -0
- package/dist/tools/policy-bash.d.ts +64 -0
- package/dist/tools/policy-bash.js +232 -0
- package/dist/tools/policy-command-branch.d.ts +32 -0
- package/dist/tools/policy-command-branch.js +63 -0
- package/dist/tools/policy-input.d.ts +2 -0
- package/dist/tools/policy-input.js +10 -0
- package/dist/tools/policy-match.d.ts +75 -0
- package/dist/tools/policy-match.js +117 -0
- package/dist/tools/policy-paths-branch.d.ts +97 -0
- package/dist/tools/policy-paths-branch.js +314 -0
- package/dist/tools/policy.d.ts +65 -0
- package/dist/tools/policy.js +232 -0
- package/dist/tools/protected-paths.d.ts +26 -0
- package/dist/tools/protected-paths.js +8 -0
- package/dist/tools/provider-adapt.d.ts +4 -0
- package/dist/tools/provider-adapt.js +32 -0
- package/dist/tools/provider-advertise.d.ts +39 -0
- package/dist/tools/provider-advertise.js +50 -0
- package/dist/tools/provider-grants.d.ts +36 -0
- package/dist/tools/provider-grants.js +72 -0
- package/dist/tools/provider-sanitize.d.ts +19 -0
- package/dist/tools/provider-sanitize.js +53 -0
- package/dist/tools/provider-types.d.ts +41 -0
- package/dist/tools/provider-types.js +26 -0
- package/dist/tools/read-continuation.d.ts +147 -0
- package/dist/tools/read-continuation.js +176 -0
- package/dist/tools/read-file.d.ts +32 -0
- package/dist/tools/read-file.js +85 -0
- package/dist/tools/read.d.ts +25 -0
- package/dist/tools/read.js +182 -0
- package/dist/tools/registry.d.ts +125 -0
- package/dist/tools/registry.js +67 -0
- package/dist/tools/request-capability.d.ts +13 -0
- package/dist/tools/request-capability.js +23 -0
- package/dist/tools/run-command-exec.d.ts +14 -0
- package/dist/tools/run-command-exec.js +161 -0
- package/dist/tools/run-command.d.ts +107 -0
- package/dist/tools/run-command.js +398 -0
- package/dist/tools/runtime-calltool.d.ts +146 -0
- package/dist/tools/runtime-calltool.js +223 -0
- package/dist/tools/runtime.d.ts +149 -0
- package/dist/tools/runtime.js +345 -0
- package/dist/tools/scratchpad.d.ts +20 -0
- package/dist/tools/scratchpad.js +197 -0
- package/dist/tools/spill.d.ts +81 -0
- package/dist/tools/spill.js +251 -0
- package/dist/tools/tool-audit.d.ts +171 -0
- package/dist/tools/tool-audit.js +183 -0
- package/dist/tools/truncate.d.ts +98 -0
- package/dist/tools/truncate.js +297 -0
- package/dist/tools/types.d.ts +145 -0
- package/dist/tools/types.js +24 -0
- package/dist/tools/verb-denial-argv-hint.d.ts +35 -0
- package/dist/tools/verb-denial-argv-hint.js +40 -0
- package/dist/tools/write.d.ts +9 -0
- package/dist/tools/write.js +45 -0
- package/package.json +54 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which paths nax refuses to let an agent touch, and to which tools.
|
|
3
|
+
*
|
|
4
|
+
* A separate file rather than an addition to src/tools/policy.ts, for the same
|
|
5
|
+
* reason src/tools/deny-paths.ts is one: that file carries the containment
|
|
6
|
+
* seam and sits at the project's file-size ratchet, while this is a narrower
|
|
7
|
+
* concern -- it has nothing to do with resolving or containing a path, only
|
|
8
|
+
* with refusing one containment would otherwise allow.
|
|
9
|
+
*
|
|
10
|
+
* Segment-exact, never a prefix or substring match: `.naxignore`,
|
|
11
|
+
* `docs/nax/config.json` and `.nax/mono/api/notes.md` are ordinary paths a
|
|
12
|
+
* tool must still reach.
|
|
13
|
+
*/
|
|
14
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
15
|
+
import { realOrRaw } from "#src/internal/realpath";
|
|
16
|
+
/**
|
|
17
|
+
* The one top-level `.nax/` entry agents may write freely: the scratchpad.
|
|
18
|
+
* Must equal the last segment of SCRATCHPAD_DIR (pinned by a test; importing
|
|
19
|
+
* it here would close a scratchpad -> policy -> nax-owned-writes cycle).
|
|
20
|
+
*/
|
|
21
|
+
export const NAX_SCRATCHPAD_ENTRY = "scratchpad";
|
|
22
|
+
/**
|
|
23
|
+
* Top-level `.nax/` entries an allowWrite opt-in can never open (nax#2260):
|
|
24
|
+
* config is the trust anchor for ungated commands, `mono` holds package
|
|
25
|
+
* configs, and `features` holds every PRD plus the running feature's state.
|
|
26
|
+
*/
|
|
27
|
+
const NAX_NEVER_OPT_IN = new Set(["config.json", "mono", "features"]);
|
|
28
|
+
/**
|
|
29
|
+
* Entries nax loads as human-authored input. The sandbox denies these even
|
|
30
|
+
* when absent, so an agent cannot create one: a new `.nax/rules/x.md` would be
|
|
31
|
+
* injected into every later session's prompt, and `hooks.json` / `plugins/`
|
|
32
|
+
* run unsandboxed on the next `nax run`. `templates/` and `prompts/` are where
|
|
33
|
+
* `prompts.overrides` points. nax creates none of them mid-run (CLI only).
|
|
34
|
+
*/
|
|
35
|
+
export const NAX_ALWAYS_DENIED_ENTRIES = [
|
|
36
|
+
"config.json",
|
|
37
|
+
"mono",
|
|
38
|
+
"rules",
|
|
39
|
+
"context.md",
|
|
40
|
+
"hooks.json",
|
|
41
|
+
"plugins",
|
|
42
|
+
"templates",
|
|
43
|
+
"prompts",
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* A test file directly inside a feature dir: the acceptance and suggested
|
|
47
|
+
* tests under their per-language names (`.nax-acceptance.test.ts`,
|
|
48
|
+
* `_nax_acceptance_test.py`, `.nax-acceptance.rs`, ...) or a custom
|
|
49
|
+
* `acceptance.testPath`, which is itself a test file name.
|
|
50
|
+
*/
|
|
51
|
+
const FEATURE_TEST_FILE = /^\.nax-(acceptance|suggested)|[._-](test|spec)\.[a-z0-9]+$/i;
|
|
52
|
+
const NO_OPT_INS = new Set();
|
|
53
|
+
/**
|
|
54
|
+
* Top-level `.nax/` entries a human opened for agent writes by listing them in
|
|
55
|
+
* `execution.sandbox.filesystem.allowWrite` (nax#2260). Only an exact entry
|
|
56
|
+
* counts -- `.nax/rules`, never `.nax/rules/a.md` -- and never the scratchpad
|
|
57
|
+
* (always open) or a NAX_NEVER_OPT_IN entry. Relative entries resolve against
|
|
58
|
+
* `root`, as the sandbox's own write roots do.
|
|
59
|
+
*/
|
|
60
|
+
export function naxWriteOptIns(root, allowWrite) {
|
|
61
|
+
const naxDir = resolve(root, ".nax");
|
|
62
|
+
const names = allowWrite
|
|
63
|
+
.map((p) => relative(naxDir, isAbsolute(p) ? resolve(p) : resolve(root, p)))
|
|
64
|
+
.filter((rel) => rel !== "" && !rel.startsWith("..") && !rel.includes(sep) && !isAbsolute(rel))
|
|
65
|
+
.filter((name) => name !== NAX_SCRATCHPAD_ENTRY && !NAX_NEVER_OPT_IN.has(name));
|
|
66
|
+
return new Set(names);
|
|
67
|
+
}
|
|
68
|
+
/** `.nax/config.json`, or `.nax/mono/<package...>/config.json`, as root-relative segments. */
|
|
69
|
+
function isNaxConfigSegments(segments) {
|
|
70
|
+
if (segments[0] !== ".nax" || segments[segments.length - 1] !== "config.json")
|
|
71
|
+
return false;
|
|
72
|
+
return segments.length === 2 || (segments.length >= 4 && segments[1] === "mono");
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Is `resolved` one of nax's own CONFIG files, relative to `root`?
|
|
76
|
+
*
|
|
77
|
+
* `.nax/config.json`, and `.nax/mono/<package>/config.json` in a monorepo.
|
|
78
|
+
*
|
|
79
|
+
* Why these at all: `quality.commands` and `acceptance.command` are run by key
|
|
80
|
+
* through a shell and never pass the permission gate -- they are trusted
|
|
81
|
+
* because a HUMAN wrote them. That trust rests entirely on a model being
|
|
82
|
+
* unable to write them. An agent holding `Write` under the default
|
|
83
|
+
* `unrestricted` profile could otherwise add a quality command and receive an
|
|
84
|
+
* ungated shell on the next run, routing around every `Bash(...)` rule, the
|
|
85
|
+
* lexer's construct refusals and containment itself.
|
|
86
|
+
*
|
|
87
|
+
* Refused to EVERY tool, reads included -- this is the pre-existing behaviour
|
|
88
|
+
* and it is deliberate.
|
|
89
|
+
*/
|
|
90
|
+
export function isNaxConfigFile(root, resolved) {
|
|
91
|
+
const rel = relative(realOrRaw(root), resolved);
|
|
92
|
+
if (rel === "" || rel.startsWith(".."))
|
|
93
|
+
return false;
|
|
94
|
+
// `.nax/config.json` (2), or `.nax/mono/<package>/config.json` at ANY package
|
|
95
|
+
// depth (>= 4). The real override path is nested -- `loadConfigForWorkdir`
|
|
96
|
+
// reads `.nax/mono/<packageDir>/config.json` where packageDir is the
|
|
97
|
+
// repo-relative package path (`src/config/loader.ts:382`), so a normal
|
|
98
|
+
// `packages/*` layout is 5 segments, not 4. A length-exact rule left every
|
|
99
|
+
// such override writable whenever the story's root was the repo root.
|
|
100
|
+
return isNaxConfigSegments(rel.split(sep));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The path-bearing tools that MUTATE. Read, Grep, Glob and Git are read-only
|
|
104
|
+
* and are deliberately absent: an agent legitimately reads its own PRD, and
|
|
105
|
+
* refusing that would break ordinary work to close one hole.
|
|
106
|
+
*
|
|
107
|
+
* Bash and Exec are absent because they carry no path fields -- a shell
|
|
108
|
+
* redirect into `.nax/` is gated by the human-authored `Bash(...)` rules and
|
|
109
|
+
* the lexer, which is a different seam from this one.
|
|
110
|
+
*/
|
|
111
|
+
export const NAX_OWNED_WRITE_TOOLS = new Set(["Write", "Edit", "Delete", "GitCommit"]);
|
|
112
|
+
/**
|
|
113
|
+
* nax's run-control files at the root: the command channel an agent could
|
|
114
|
+
* otherwise use to PAUSE, ABORT or SKIP stories without writing any code.
|
|
115
|
+
*
|
|
116
|
+
* `.queue.txt.processing` is the atomic-rename target the queue handler reads
|
|
117
|
+
* from (src/execution/queue-handler.ts), so guarding only `.queue.txt` would
|
|
118
|
+
* leave the same hole one rename downstream.
|
|
119
|
+
*/
|
|
120
|
+
export const QUEUE_CONTROL_FILES = new Set([".queue.txt", ".queue.txt.processing"]);
|
|
121
|
+
/**
|
|
122
|
+
* Is this path one nax owns the writes to, independent of WHICH tool is asking?
|
|
123
|
+
*
|
|
124
|
+
* `naxOwnedWriteRefusal` answers the same question for the four file-writing
|
|
125
|
+
* tools and returns prose. This predicate is the tool-agnostic half, extracted
|
|
126
|
+
* so the `raw` bash screen (ADR-030) can consult exactly the same path set
|
|
127
|
+
* without being in `NAX_OWNED_WRITE_TOOLS`. One definition, two callers.
|
|
128
|
+
*
|
|
129
|
+
* @param rel - Path relative to the permitted root, `/`-joined.
|
|
130
|
+
*/
|
|
131
|
+
export function isNaxOwnedWritePath(rel) {
|
|
132
|
+
return naxOwnedKind(rel) !== undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Which kind of nax-owned write path `rel` is, or undefined when it is not one.
|
|
136
|
+
*
|
|
137
|
+
* `/`-joined and root-relative, like `isNaxOwnedWritePath`. Never returns
|
|
138
|
+
* `"config"` -- nax config files are recognised by the lexical
|
|
139
|
+
* `isNaxConfigFile` pass, which callers (`protectedHit` in policy-bash-raw.ts)
|
|
140
|
+
* run FIRST. Keeping the two apart is what lets the raw screen name the kind it
|
|
141
|
+
* matched without duplicating the config rule here.
|
|
142
|
+
*/
|
|
143
|
+
export function naxOwnedKind(rel) {
|
|
144
|
+
const segments = rel.split("/");
|
|
145
|
+
// SEC-5: the run-control file lives at the root, so match it exactly there
|
|
146
|
+
// and not at any other depth -- a nested `sub/.queue.txt` is an ordinary
|
|
147
|
+
// file, not the queue nax reads.
|
|
148
|
+
if (segments.length === 1 && QUEUE_CONTROL_FILES.has(segments[0] ?? ""))
|
|
149
|
+
return "queue";
|
|
150
|
+
if (segments[0] === ".nax" && segments[1] === "features" && segments[segments.length - 1] === "prd.json") {
|
|
151
|
+
return "prd";
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Refusal text for a Bash command that names (verb "names") or redirects into
|
|
157
|
+
* (verb "redirects into") a nax-owned file.
|
|
158
|
+
*
|
|
159
|
+
* Kind-specific on purpose. The previous screen returned one modification-only
|
|
160
|
+
* sentence for every kind, which read as "you cannot WRITE this" -- so an agent
|
|
161
|
+
* that only wanted to READ a PRD retried a command it will never be allowed to
|
|
162
|
+
* run. Each branch now says what the file IS and what the agent can do instead.
|
|
163
|
+
*
|
|
164
|
+
* The text never spells `.nax/features/` literally: `src/tools/` is covered by
|
|
165
|
+
* the `check:feature-dir-ssot` gate, so the PRD branch names the token the agent
|
|
166
|
+
* used (`hit`) rather than the tree layout.
|
|
167
|
+
*
|
|
168
|
+
* US-002: `opts.sandboxWrapped` (an available launcher) swaps only the PRD
|
|
169
|
+
* sentence -- reading through Bash is then allowed, writing still is not.
|
|
170
|
+
* `config` and `queue` are unchanged in both modes.
|
|
171
|
+
*/
|
|
172
|
+
export function naxOwnedBashRefusal(tool, kind, hit, verb, opts) {
|
|
173
|
+
switch (kind) {
|
|
174
|
+
case "prd":
|
|
175
|
+
return (`${tool} command ${verb} "${hit}", which holds this story's acceptance criteria. ` +
|
|
176
|
+
"nax updates it itself during the run, so it shows as modified. " +
|
|
177
|
+
(opts?.sandboxWrapped === true
|
|
178
|
+
? "Reading it through Bash is allowed; writing it is not -- nax updates it itself. "
|
|
179
|
+
: "Bash commands naming it are refused, reads included -- leave it as is. ") +
|
|
180
|
+
"To view it, use the `Read` tool.");
|
|
181
|
+
case "queue":
|
|
182
|
+
return (`${tool} command ${verb} "${hit}", which is nax's run-control queue. ` +
|
|
183
|
+
"Bash commands naming it are refused, reads included -- change the run through the queue command.");
|
|
184
|
+
case "config":
|
|
185
|
+
return (`${tool} command ${verb} "${hit}", which is nax configuration. ` +
|
|
186
|
+
"Bash commands naming it are refused, reads included -- nax configuration is not changed from inside a run.");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Why `tool` may not touch `rel`, or `undefined` when it may.
|
|
191
|
+
*
|
|
192
|
+
* `rel` MUST be the canonical, posix-separated, root-relative spelling the
|
|
193
|
+
* policy itself derived -- never the caller's own. Matching the caller's
|
|
194
|
+
* spelling means this guard and the policy that approved the call are reading
|
|
195
|
+
* different strings, and every alternate spelling ("./x", "a/../x") walks past
|
|
196
|
+
* the guard. Same rule, and the same reason, as `matchesDenyPaths`.
|
|
197
|
+
*
|
|
198
|
+
* The PRD defines the acceptance criteria the story is judged against. An
|
|
199
|
+
* agent that can rewrite it can pass any review without writing any code,
|
|
200
|
+
* which defeats the review layer without touching a config file.
|
|
201
|
+
*
|
|
202
|
+
* The queue file is the other half of the same concern: it is the run-control
|
|
203
|
+
* channel, and a write there can pause, abort or skip stories outright.
|
|
204
|
+
*/
|
|
205
|
+
export function naxOwnedWriteRefusal(tool, rel, exemptRel, optIns = NO_OPT_INS) {
|
|
206
|
+
if (!NAX_OWNED_WRITE_TOOLS.has(tool))
|
|
207
|
+
return undefined;
|
|
208
|
+
if (!isNaxOwnedWritePath(rel)) {
|
|
209
|
+
return exemptRel !== undefined && rel === exemptRel ? undefined : naxStateRefusal(rel, optIns);
|
|
210
|
+
}
|
|
211
|
+
const segments = rel.split("/");
|
|
212
|
+
// SEC-5: the run-control file lives at the root, so match it exactly
|
|
213
|
+
// there and not at any other depth -- a nested `sub/.queue.txt` is an
|
|
214
|
+
// ordinary file, not the queue nax reads.
|
|
215
|
+
if (segments.length === 1) {
|
|
216
|
+
return `"${rel}" is nax's own run state: it carries the PAUSE/ABORT/SKIP commands that control this run, so no tool may modify it. Change the run through the queue command, not by writing its file.`;
|
|
217
|
+
}
|
|
218
|
+
// nax#2115: the plan session is the ONE writer of a PRD -- its op declares
|
|
219
|
+
// `fileOutput: (input) => input.outputPath` and every plan prompt instructs
|
|
220
|
+
// the agent to write the PRD there rather than reply with it. #2095 added
|
|
221
|
+
// this guard without an exemption, which severed that contract and left
|
|
222
|
+
// `nax plan` unable to produce a PRD in ANY mode.
|
|
223
|
+
//
|
|
224
|
+
// The exemption is PATH-EXACT, not role-shaped: the plan session may write
|
|
225
|
+
// the single path its own op declared, and nothing else. A sibling feature's
|
|
226
|
+
// PRD stays refused even to the plan session, so a planner cannot reach
|
|
227
|
+
// across features to rewrite criteria it is not authoring. `exemptRel` must
|
|
228
|
+
// be the caller's canonical, posix-separated, root-relative spelling --
|
|
229
|
+
// derived by the policy itself, never taken from the agent's own arguments.
|
|
230
|
+
if (exemptRel !== undefined && rel === exemptRel)
|
|
231
|
+
return undefined;
|
|
232
|
+
return `"${rel}" is nax's own run state: it holds the acceptance criteria this story is judged against, so no tool may modify it. Change the code, not the criteria.`;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* nax#2260: everything else under `.nax/` is nax's own state. Writable: the
|
|
236
|
+
* scratchpad, test files directly inside a feature dir (FEATURE_TEST_FILE --
|
|
237
|
+
* the tool-audit ledgers show these are the only file-tool writes agents need
|
|
238
|
+
* there; the feature's context.md, spec and state files stay refused), and
|
|
239
|
+
* opted-in entries. Config files are left to the earlier, more specific
|
|
240
|
+
* `isNaxConfigFile` refusal, which covers reads too.
|
|
241
|
+
*
|
|
242
|
+
* Only a leading `.nax/` segment is matched, so a monorepo package's own
|
|
243
|
+
* `.nax/` is excluded on purpose -- see `naxDenies` in
|
|
244
|
+
* src/sandbox/policy-builder.ts for why that is mostly safe to delete and
|
|
245
|
+
* where the one gap (package `rules/`) remains.
|
|
246
|
+
*/
|
|
247
|
+
function naxStateRefusal(rel, optIns) {
|
|
248
|
+
const segments = rel.split("/");
|
|
249
|
+
if (segments[0] !== ".nax" || isNaxConfigSegments(segments))
|
|
250
|
+
return undefined;
|
|
251
|
+
const entry = segments[1];
|
|
252
|
+
if (segments.length > 2 && (entry === NAX_SCRATCHPAD_ENTRY || optIns.has(entry ?? "")))
|
|
253
|
+
return undefined;
|
|
254
|
+
if (segments.length === 4 && entry === "features" && FEATURE_TEST_FILE.test(segments[3] ?? ""))
|
|
255
|
+
return undefined;
|
|
256
|
+
return (`"${rel}" is nax's own state, which agents do not modify. Under .nax/, write only to your scratchpad ` +
|
|
257
|
+
"(.nax/scratchpad/) or to a feature's acceptance test file. " +
|
|
258
|
+
"A human can open a path for a story by listing it in execution.sandbox.filesystem.allowWrite in the project config.");
|
|
259
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package-manager knowledge table for the install-shaped exec branch.
|
|
3
|
+
*
|
|
4
|
+
* Each entry is DATA — a description of one manager's install verbs (and
|
|
5
|
+
* their aliases), its no-scripts mechanism, how to rewrite argv for a
|
|
6
|
+
* package-scoped versus repo-root-scoped call, and which incoming flags
|
|
7
|
+
* would smuggle in a second workspace member if we spliced our own scoping
|
|
8
|
+
* flag in beside them. No branching policy lives here; `normalizeExec` in
|
|
9
|
+
* `package-managers.ts` is the only place that interprets these fields.
|
|
10
|
+
*
|
|
11
|
+
* Facts this table encodes, verified against each tool's own documentation
|
|
12
|
+
* (see task-4 brief, 2026-09-06) plus two review-driven fix rounds:
|
|
13
|
+
*
|
|
14
|
+
* - Yarn 2+ ("Berry") has no `--ignore-scripts` flag; it honours the
|
|
15
|
+
* `enableScripts` setting, overridable per-invocation via the
|
|
16
|
+
* `YARN_ENABLE_SCRIPTS` environment variable. Yarn 1 ("Classic") takes
|
|
17
|
+
* `--ignore-scripts`. Passing `--ignore-scripts` to Yarn 2+ is a hard
|
|
18
|
+
* error, so version detection that is inconclusive must default to the
|
|
19
|
+
* Yarn 2+ branch — the env var is inert on Yarn 1, the flag is fatal on
|
|
20
|
+
* Yarn 2+, and failing toward the inert option is the safe direction.
|
|
21
|
+
* - pnpm's `--filter` requires the `./` prefix to select by path
|
|
22
|
+
* (`--filter ./packages/foo`); the bare form (`packages/foo`) is parsed as
|
|
23
|
+
* a package NAME and silently selects nothing.
|
|
24
|
+
* - `yarn workspace <name>` and `cargo add -p <name>` take the manifest
|
|
25
|
+
* NAME, not a path.
|
|
26
|
+
*
|
|
27
|
+
* pip and uv no-scripts mechanisms: I could not confirm a mechanism from
|
|
28
|
+
* either tool's own documentation that actually suppresses arbitrary code
|
|
29
|
+
* execution during an install the way `--ignore-scripts` does for npm/bun/
|
|
30
|
+
* yarn-classic:
|
|
31
|
+
*
|
|
32
|
+
* - pip has no `--ignore-scripts` equivalent at all. `--only-binary :all:`
|
|
33
|
+
* forces wheel-only resolution (no sdist, so no `setup.py` executes for
|
|
34
|
+
* any package pip resolves), but it is a resolution-strategy flag, not a
|
|
35
|
+
* scripts switch — it errors the whole install if a required dependency
|
|
36
|
+
* ships no wheel, rather than degrading gracefully. Wiring it in as if it
|
|
37
|
+
* were "the no-scripts flag" would look like protection where none was
|
|
38
|
+
* verified, and I have not confirmed it is safe as a blanket default
|
|
39
|
+
* here. Left as `{ none: true }`.
|
|
40
|
+
* - uv installs prebuilt wheels by default and only builds from source
|
|
41
|
+
* (running a build backend, e.g. `setup.py`/PEP 517 hooks) when a
|
|
42
|
+
* dependency has no wheel for the target platform, same as pip. There is
|
|
43
|
+
* no uv flag documented as suppressing that fallback build step itself —
|
|
44
|
+
* `--no-build-isolation` changes how a source build is isolated, it does
|
|
45
|
+
* not prevent one from happening, so it is not a substitute either. Left
|
|
46
|
+
* as `{ none: true }` per the brief's instruction not to invent a switch.
|
|
47
|
+
*
|
|
48
|
+
* Both gaps mean pip/uv installs get cwd/scoping normalization but no
|
|
49
|
+
* scripts-suppression hardening. This should be tracked as a follow-up
|
|
50
|
+
* rather than silently accepted.
|
|
51
|
+
*
|
|
52
|
+
* Install-verb ALIASES (fix round 1, Critical finding A): each manager's
|
|
53
|
+
* install verb has common short aliases the model can reach for just as
|
|
54
|
+
* easily as the canonical spelling (`npm i` is as ordinary an invocation as
|
|
55
|
+
* `npm install`). They are listed here as additional single-token verb
|
|
56
|
+
* sequences, matched by `classifyExec` exactly like the canonical verb in
|
|
57
|
+
* both its position-anchored match and its fail-closed scan — never as a
|
|
58
|
+
* special case in the matcher itself. Sources: npm's own `install` command
|
|
59
|
+
* aliases (`i`, `in`, `ins`, `inst`, `insta`, `instal`, `install`, `add`) and
|
|
60
|
+
* its `install-test`/`it` alias pair; pnpm's `i`/`install-test` aliases of
|
|
61
|
+
* `install`; bun's `i`/`a` aliases of `install`/`add`. Yarn Classic and
|
|
62
|
+
* Berry do not document a short alias for `install`/`add`, so none is
|
|
63
|
+
* added — checked and confirmed empty, not merely unresearched.
|
|
64
|
+
*
|
|
65
|
+
* Workspace-scoping SMUGGLING (fix round 1, Critical finding 2 + addendum
|
|
66
|
+
* A/C): before this table splices in its own scoping flag or no-scripts
|
|
67
|
+
* flag, `normalizeExec` screens the incoming argv for tokens that would
|
|
68
|
+
* change what gets targeted if left in place — a second `-w`/`--filter`
|
|
69
|
+
* naming another member, or a `--ignore-scripts`/`--no-ignore-scripts` the
|
|
70
|
+
* model added itself. `scopingConflict` is each entry's screen for the
|
|
71
|
+
* first kind; the second kind (`SCRIPTS_CONTROL_FLAG`) is universal and
|
|
72
|
+
* lives in `package-managers.ts` since it isn't manager-specific data. Both
|
|
73
|
+
* DENY rather than strip: dropping a flag the model wrote changes the
|
|
74
|
+
* request while reporting success, which is worse than a visible refusal.
|
|
75
|
+
* Coverage: npm `-w`/`--workspace`/`--workspaces`/`--workspace-root`/
|
|
76
|
+
* `--include-workspace-root`; pnpm `--filter`/`-f`/`-w`/`--workspace-root`/
|
|
77
|
+
* `--filter-prod`/`--include-workspace-root`; cargo `-p`/`--package`; uv
|
|
78
|
+
* `--package`/`--all-packages`. Yarn's `workspace`/`workspaces` leading
|
|
79
|
+
* subcommand is not screened here — see the comment on yarn's
|
|
80
|
+
* `scopingConflict` for why that path is already unreachable by
|
|
81
|
+
* construction.
|
|
82
|
+
*
|
|
83
|
+
* Directory-redirect CONTAINMENT (fix round 2): `target` is a closed enum
|
|
84
|
+
* precisely so no path can arrive from the model — `normalizeExec` computes
|
|
85
|
+
* cwd, the model never supplies one. A directory-redirect flag inside argv
|
|
86
|
+
* (`bun add --cwd /elsewhere x`) hands that choice straight back, ignoring
|
|
87
|
+
* whatever cwd this table computed. This is the containment property
|
|
88
|
+
* itself, not a scoping nicety, so it is screened for EVERY manager entry
|
|
89
|
+
* via `globalDirectoryFlags`/`installDirectoryFlags`, denied on the same
|
|
90
|
+
* deny-never-strip basis as scoping/scripts-control flags.
|
|
91
|
+
*
|
|
92
|
+
* A flag global to the manager (works with any subcommand, not just an
|
|
93
|
+
* install verb) is screened for BOTH install-shaped and generic calls —
|
|
94
|
+
* `normalizeExec` checks it before branching on classification kind at all,
|
|
95
|
+
* because a generic call (`bun x tsc --cwd /elsewhere`) escapes the same
|
|
96
|
+
* containment otherwise. An install-specific flag is screened only when the
|
|
97
|
+
* call is already install-shaped, since it has no effect (or no meaning) on
|
|
98
|
+
* a generic invocation of that manager.
|
|
99
|
+
*
|
|
100
|
+
* | manager | global (`globalDirectoryFlags`) | install-only (`installDirectoryFlags`) |
|
|
101
|
+
* |---|---|---|
|
|
102
|
+
* | bun | `--cwd` | — |
|
|
103
|
+
* | yarn | `--cwd`, `-C` (fix round 3 — `-C` is added for symmetry with pnpm; not confirmed as a documented yarn alias, but an over-denial here is the safe direction) | — |
|
|
104
|
+
* | pnpm | `--dir`, `-C` | — |
|
|
105
|
+
* | npm | — | — (`--prefix` changes npm's effective directory; already denied by `DENIED_FLAGS` in `exec-guard.ts` regardless of manager — not duplicated here) |
|
|
106
|
+
* | cargo | `--manifest-path` (accepted by nearly every cargo subcommand, `add`/`fetch` included) | — |
|
|
107
|
+
* | pip | `--python` (a general pip option, valid before or after the subcommand, that redirects which interpreter/environment gets installed into) | `--target`, `-t` (documented short alias, fix round 3), `--root` (install-destination overrides, meaningful only for `pip install`; `--prefix` is likewise install-scoped but already covered by the same shared `DENIED_FLAGS` entry as npm's, so also not duplicated) |
|
|
108
|
+
* | uv | `--directory`, `--project` (both are documented as general uv options, accepted ahead of the subcommand, that change what "the project" means for the whole invocation) | — |
|
|
109
|
+
* | go | `-C` (a general go flag: "change to dir before running the command") | — |
|
|
110
|
+
*
|
|
111
|
+
* `uv pip <anything>` (fix round 3, finding 3) is denied at classification
|
|
112
|
+
* time, not treated as a directory-redirect flag gap — see the comment on
|
|
113
|
+
* `isNestedPipInvocation` in `package-managers.ts` for why nesting one
|
|
114
|
+
* manager's semantics inside another's entry was rejected in favor of a
|
|
115
|
+
* flat denial.
|
|
116
|
+
*/
|
|
117
|
+
import type { NormalizeResult, NoScripts, WorkspaceContext } from "./package-managers-types.ts";
|
|
118
|
+
export interface ManagerEntry {
|
|
119
|
+
/** Install verbs AND their aliases. A verb outside this list makes the call generic, not denied. */
|
|
120
|
+
readonly installVerbs: readonly (readonly string[])[];
|
|
121
|
+
readonly noScripts: (ctx: WorkspaceContext) => NoScripts;
|
|
122
|
+
/** True when the manager needs the member's manifest NAME rather than its path. Read centrally by `normalizeExec`. */
|
|
123
|
+
readonly needsPackageName: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the incoming flag/token that would smuggle in a scoping
|
|
126
|
+
* decision of its own (another workspace member, or "all packages") if
|
|
127
|
+
* this table spliced its own scoping flag in beside it — or `undefined`
|
|
128
|
+
* when the argv is clean. Checked before any rewriting.
|
|
129
|
+
*/
|
|
130
|
+
readonly scopingConflict: (argv: readonly string[]) => string | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Returns the incoming flag that redirects the working directory (or the
|
|
133
|
+
* install destination/environment) this manager operates on, when that
|
|
134
|
+
* flag is global to the manager — checked for BOTH install-shaped and
|
|
135
|
+
* generic calls, since `target` being a closed enum only holds if no
|
|
136
|
+
* argv-supplied path can override it.
|
|
137
|
+
*/
|
|
138
|
+
readonly globalDirectoryConflict: (argv: readonly string[]) => string | undefined;
|
|
139
|
+
/** Same as `globalDirectoryConflict`, but for a flag that only applies to
|
|
140
|
+
* (or only makes sense for) an install verb — checked only when the call
|
|
141
|
+
* is already install-shaped. */
|
|
142
|
+
readonly installDirectoryConflict: (argv: readonly string[]) => string | undefined;
|
|
143
|
+
readonly packageForm: (argv: readonly string[], ctx: WorkspaceContext) => NormalizeResult;
|
|
144
|
+
readonly rootForm: (argv: readonly string[], ctx: WorkspaceContext) => NormalizeResult;
|
|
145
|
+
}
|
|
146
|
+
export declare const MANAGER_TABLE: Readonly<Record<string, ManagerEntry>>;
|