@sema-agent/core 7.51.1 → 7.52.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 +550 -2
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cumulative-stats.d.ts +3 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/read-inbox-tool.d.ts +1 -1
- package/dist/agents/repair-loop.js +4 -0
- package/dist/agents/send-message-tool.d.ts +11 -16
- package/dist/agents/send-message-tool.js +11 -13
- package/dist/agents/subagent.d.ts +5 -0
- package/dist/agents/subagent.js +7 -4
- package/dist/agents/tool-filter.d.ts +40 -13
- package/dist/agents/tool-filter.js +28 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.js +16 -12
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +4 -4
- package/dist/brain/open-responses.js +16 -12
- package/dist/brain/openai.js +16 -12
- package/dist/brain/request-params.d.ts +12 -33
- package/dist/brain/request-params.js +5 -2
- package/dist/brain/request-route.d.ts +9 -8
- package/dist/brain/request-route.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +117 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/core/allow-entry.d.ts +42 -8
- package/dist/core/allow-entry.js +24 -17
- package/dist/core/auto-compaction.d.ts +23 -20
- package/dist/core/auto-compaction.js +37 -16
- package/dist/core/auto-promote.d.ts +2 -1
- package/dist/core/auto-promote.js +2 -2
- package/dist/core/caller-tool-name.d.ts +9 -0
- package/dist/core/caller-tool-name.js +13 -0
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +36 -12
- package/dist/core/checkpoint-store.js +1 -1
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/credential-vocabulary.d.ts +33 -8
- package/dist/core/credential-vocabulary.js +32 -7
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/delegation-frames.d.ts +9 -2
- package/dist/core/delegation-name.d.ts +18 -0
- package/dist/core/delegation-name.js +47 -0
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +36 -19
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +5 -23
- package/dist/core/gate-lanes.js +356 -270
- package/dist/core/governance-codes.d.ts +9 -4
- package/dist/core/governance-codes.js +9 -3
- package/dist/core/hooks.d.ts +276 -734
- package/dist/core/hooks.js +97 -192
- package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
- package/dist/{tools/fs → core}/image-admission.js +24 -6
- package/dist/core/locked-config.d.ts +26 -5
- package/dist/core/locked-config.js +31 -6
- package/dist/core/mcp-connection-pool.d.ts +4 -1
- package/dist/core/mcp-connection-pool.js +7 -2
- package/dist/core/mcp-probe.d.ts +12 -9
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-spec.d.ts +53 -7
- package/dist/core/mcp-server-spec.js +84 -1
- package/dist/core/mcp.d.ts +11 -7
- package/dist/core/mcp.js +27 -9
- package/dist/core/memory-engine/data-plane.js +5 -1
- package/dist/core/memory-engine/distiller.js +16 -2
- package/dist/core/memory-engine/engine.d.ts +8 -11
- package/dist/core/memory-engine/engine.js +9 -5
- package/dist/core/memory-engine/frontmatter.d.ts +6 -0
- package/dist/core/memory-engine/frontmatter.js +19 -16
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/mode-policy.d.ts +4 -0
- package/dist/core/mode-policy.js +7 -5
- package/dist/core/model-seat.d.ts +4 -1
- package/dist/core/mods/dollar.d.ts +109 -0
- package/dist/core/mods/dollar.js +154 -0
- package/dist/core/mods/host.d.ts +23 -0
- package/dist/core/mods/host.js +21 -0
- package/dist/core/mods/kernel/budget.d.ts +43 -0
- package/dist/core/mods/kernel/budget.js +83 -0
- package/dist/core/mods/kernel/dispatch.d.ts +100 -0
- package/dist/core/mods/kernel/dispatch.js +701 -0
- package/dist/core/mods/kernel/events.d.ts +242 -0
- package/dist/core/mods/kernel/events.js +210 -0
- package/dist/core/mods/kernel/index.d.ts +6 -0
- package/dist/core/mods/kernel/index.js +5 -0
- package/dist/core/mods/kernel/receive.d.ts +65 -0
- package/dist/core/mods/kernel/receive.js +123 -0
- package/dist/core/mods/kernel/registration.d.ts +131 -0
- package/dist/core/mods/kernel/registration.js +102 -0
- package/dist/core/mods/kernel/site-rules.d.ts +84 -0
- package/dist/core/mods/kernel/site-rules.js +104 -0
- package/dist/core/mods/stations.d.ts +350 -0
- package/dist/core/mods/stations.js +444 -0
- package/dist/core/own-property-receipt.js +11 -23
- package/dist/core/parent-spec-seat.d.ts +18 -7
- package/dist/core/parent-spec-seat.js +6 -2
- package/dist/core/path-identity.js +2 -1
- package/dist/core/permission-rule-syntax.d.ts +15 -0
- package/dist/core/permission-rule-syntax.js +24 -16
- package/dist/core/permission-rules.d.ts +7 -1
- package/dist/core/permission-rules.js +26 -15
- package/dist/core/prompt-section-seat.d.ts +15 -27
- package/dist/core/prompt-section-seat.js +73 -40
- package/dist/core/protocol-http-auth.d.ts +3 -1
- package/dist/core/protocol-http-auth.js +2 -0
- package/dist/core/reminder-mint.d.ts +2 -2
- package/dist/core/remote-env.d.ts +24 -12
- package/dist/core/remote-env.js +1 -0
- package/dist/core/resume-startup-cause.d.ts +16 -1
- package/dist/core/resume-startup-cause.js +4 -1
- package/dist/core/retired-keys.d.ts +4 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +31 -1
- package/dist/core/runner/announce-once-ledger.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/call-hook-stations.d.ts +23 -27
- package/dist/core/runner/call-hook-stations.js +58 -42
- package/dist/core/runner/caller-stop-gate.d.ts +25 -0
- package/dist/core/runner/caller-stop-gate.js +7 -0
- package/dist/core/runner/compaction-seams.d.ts +8 -22
- package/dist/core/runner/compaction-seams.js +28 -53
- package/dist/core/runner/construction-doors.js +11 -1
- package/dist/core/runner/contracts.d.ts +85 -83
- package/dist/core/runner/credential-origin-seat.d.ts +2 -0
- package/dist/core/runner/credential-origin-seat.js +19 -0
- package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
- package/dist/core/runner/gate-exit.d.ts +47 -36
- package/dist/core/runner/gate-exit.js +8 -2
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/notice-seat-input.d.ts +11 -0
- package/dist/core/runner/notice-seat-input.js +1 -0
- package/dist/core/runner/person-path-rows.js +1 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
- package/dist/core/runner/prepare-ask-lane.js +6 -15
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
- package/dist/core/runner/prepare-config-doors.d.ts +5 -0
- package/dist/core/runner/prepare-config-doors.js +9 -0
- package/dist/core/runner/prepare-defer-classify.js +3 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
- package/dist/core/runner/prepare-gate-stations.js +11 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +8 -21
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -16
- package/dist/core/runner/prepare-policy-chain.js +98 -101
- package/dist/core/runner/prepare-project-context.js +7 -10
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +134 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +18 -19
- package/dist/core/runner/prepare-prompt-inputs.js +5 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +6 -4
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-safety-scan.js +6 -10
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -5
- package/dist/core/runner/prepare-task.js +33 -15
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
- package/dist/core/runner/prepare-turn-wiring.js +29 -27
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -6
- package/dist/core/runner/prepare-wiring-manifest.js +7 -7
- package/dist/core/runner/resume-apply.d.ts +5 -2
- package/dist/core/runner/resume-apply.js +24 -42
- package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
- package/dist/core/runner/resume-checkpoint-screen.js +9 -1
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.js +3 -1
- package/dist/core/runner/run-brain-sinks.d.ts +3 -2
- package/dist/core/runner/run-brain-sinks.js +5 -1
- package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
- package/dist/core/runner/run-compaction-machinery.js +7 -33
- package/dist/core/runner/run-harness-handlers.js +4 -2
- package/dist/core/runner/run-identity-wiring.d.ts +3 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +62 -84
- package/dist/core/runner/run-notification-lane.js +1 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
- package/dist/core/runner/run-recovery-lanes.js +11 -10
- package/dist/core/runner/run-settle-and-teardown.js +9 -28
- package/dist/core/runner/run-stop-and-final-verify.js +18 -25
- package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
- package/dist/core/runner/run-terminal-adoption.js +33 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +23 -34
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +14 -72
- package/dist/core/runner/session-rule-policy.d.ts +6 -4
- package/dist/core/runner/session-rule-policy.js +17 -10
- package/dist/core/runner/side-call-account.d.ts +68 -0
- package/dist/core/runner/side-call-account.js +61 -0
- package/dist/core/runner/stream-halt-verbs.js +12 -17
- package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +20 -38
- package/dist/core/runner/sub-agent-deny-lists.d.ts +121 -22
- package/dist/core/runner/sub-agent-deny-lists.js +228 -71
- package/dist/core/runner/tool-end-body.d.ts +5 -6
- package/dist/core/runner/tool-end-body.js +6 -4
- package/dist/core/runner/tool-not-executed.d.ts +15 -0
- package/dist/core/runner/tool-not-executed.js +30 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -7
- package/dist/core/runner/tool-occurrence.js +5 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
- package/dist/core/runner-deps.d.ts +20 -28
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +93 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +93 -17
- package/dist/core/session-policy-store.js +178 -25
- package/dist/core/session-reconcile.d.ts +4 -0
- package/dist/core/session-reconcile.js +2 -1
- package/dist/core/shell-read-silence.js +3 -32
- package/dist/core/side-query.d.ts +5 -3
- package/dist/core/skill-grant.d.ts +3 -2
- package/dist/core/skill-grant.js +17 -9
- package/dist/core/skills-directory.d.ts +31 -11
- package/dist/core/skills-directory.js +655 -104
- package/dist/core/task-event.d.ts +13 -3
- package/dist/core/task-result.d.ts +8 -0
- package/dist/core/task-spec.d.ts +20 -19
- package/dist/core/task-stream.d.ts +14 -4
- package/dist/core/tighten-task-spec.d.ts +4 -3
- package/dist/core/tighten-task-spec.js +2 -4
- package/dist/core/tool-check-reading.d.ts +74 -0
- package/dist/core/tool-check-reading.js +80 -0
- package/dist/core/tool-policy.d.ts +59 -18
- package/dist/core/tool-policy.js +77 -12
- package/dist/core/tool-registry.d.ts +20 -0
- package/dist/core/tool-registry.js +4 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/tools.js +2 -0
- package/dist/core/trace.d.ts +51 -32
- package/dist/core/types.d.ts +2 -1
- package/dist/core/types.js +1 -0
- package/dist/core/unc-spelling.d.ts +10 -0
- package/dist/core/unc-spelling.js +3 -0
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-egress.js +4 -1
- package/dist/core/user-attachment.d.ts +12 -2
- package/dist/core/user-attachment.js +17 -2
- package/dist/core/wiring-manifest.d.ts +14 -13
- package/dist/core/wiring-manifest.js +2 -2
- package/dist/engine/compaction/utils.js +1 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/symlink-chain.js +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +3 -3
- package/dist/engine/harness/types.d.ts +17 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.js +1 -1
- package/dist/engine/loop/types.d.ts +1 -1
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.js +3 -10
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/engine/session/session.js +4 -4
- package/dist/index.d.ts +24 -17
- package/dist/index.js +15 -12
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.d.ts +4 -6
- package/dist/orchestration/run-spec.js +39 -63
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow.d.ts +11 -3
- package/dist/orchestration/workflow.js +11 -2
- package/dist/prompt-assembly/artifact-store.d.ts +37 -56
- package/dist/prompt-assembly/artifact-store.js +31 -49
- package/dist/prompt-assembly/artifact.d.ts +89 -76
- package/dist/prompt-assembly/artifact.js +167 -146
- package/dist/prompt-assembly/assemble.d.ts +34 -29
- package/dist/prompt-assembly/assemble.js +33 -220
- package/dist/prompt-assembly/bands.d.ts +20 -0
- package/dist/prompt-assembly/bands.js +18 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
- package/dist/prompt-assembly/catalog/constitution.js +69 -0
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
- package/dist/prompt-assembly/catalog/index.d.ts +11 -0
- package/dist/prompt-assembly/catalog/index.js +59 -0
- package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
- package/dist/prompt-assembly/catalog/modes.js +137 -0
- package/dist/prompt-assembly/catalog/role.d.ts +10 -0
- package/dist/prompt-assembly/catalog/role.js +157 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +124 -0
- package/dist/prompt-assembly/catalog/schema.js +25 -0
- package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
- package/dist/prompt-assembly/catalog/sections.js +98 -0
- package/dist/prompt-assembly/catalog/team.d.ts +4 -0
- package/dist/prompt-assembly/catalog/team.js +258 -0
- package/dist/prompt-assembly/composer.d.ts +24 -28
- package/dist/prompt-assembly/composer.js +124 -46
- package/dist/prompt-assembly/epoch.d.ts +89 -79
- package/dist/prompt-assembly/epoch.js +115 -142
- package/dist/prompt-assembly/explain.d.ts +58 -34
- package/dist/prompt-assembly/explain.js +21 -24
- package/dist/prompt-assembly/overlay.d.ts +127 -0
- package/dist/prompt-assembly/overlay.js +301 -0
- package/dist/prompt-assembly/renderers.d.ts +21 -0
- package/dist/prompt-assembly/renderers.js +39 -0
- package/dist/prompt-assembly/section-usage.d.ts +3 -3
- package/dist/prompt-assembly/section-usage.js +1 -1
- package/dist/prompt-assembly/select.d.ts +56 -0
- package/dist/prompt-assembly/select.js +69 -0
- package/dist/prompt-assembly/sugar.d.ts +31 -0
- package/dist/prompt-assembly/sugar.js +20 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
- package/dist/prompt-assembly/types.d.ts +45 -148
- package/dist/prompts/coordinator.d.ts +2 -21
- package/dist/prompts/coordinator.js +3 -255
- package/dist/prompts/cowork.d.ts +27 -16
- package/dist/prompts/cowork.js +2 -23
- package/dist/prompts/default.d.ts +38 -500
- package/dist/prompts/default.js +20 -285
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/stores/file/session-policy-store.d.ts +3 -3
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
- package/dist/tools/fs/dir-entries.d.ts +4 -2
- package/dist/tools/fs/dir-entries.js +16 -4
- package/dist/tools/fs/fs-bash.d.ts +1 -1
- package/dist/tools/fs/fs-bash.js +22 -11
- package/dist/tools/fs/fs-pdf.js +17 -13
- package/dist/tools/fs/fs-read.js +4 -3
- package/dist/tools/fs/fs-shared.d.ts +1 -10
- package/dist/tools/fs/fs-shared.js +3 -4
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/notebook.js +1 -1
- package/dist/tools/fs/pdf.d.ts +20 -10
- package/dist/tools/fs/pdf.js +19 -10
- package/dist/tools/fs/program-read-model.d.ts +68 -8
- package/dist/tools/fs/program-read-model.js +112 -33
- package/dist/tools/fs/program-read-model.rows.js +30 -10
- package/dist/tools/fs/read-deny-home.d.ts +25 -9
- package/dist/tools/fs/read-deny-home.js +28 -27
- package/dist/tools/fs/read-deny.d.ts +41 -11
- package/dist/tools/fs/read-deny.js +51 -5
- package/dist/tools/fs/safety.d.ts +4 -26
- package/dist/tools/fs/safety.js +10 -32
- package/dist/tools/fs/search.js +15 -10
- package/dist/tools/fs/shell-read-argv.d.ts +3 -2
- package/dist/tools/fs/shell-read-argv.js +118 -38
- package/dist/tools/fs/shell-read-establish.d.ts +5 -5
- package/dist/tools/fs/shell-read-establish.js +11 -61
- package/dist/tools/fs/shell-read-identity.js +6 -3
- package/dist/tools/fs/shell-read-judge.d.ts +13 -15
- package/dist/tools/fs/shell-read-judge.js +18 -4
- package/dist/tools/fs/shell-read-plan.d.ts +2 -2
- package/dist/tools/web.js +1 -1
- package/package.json +13 -1
- package/test/export-surface.snapshot.json +256 -99
- package/wire-changes/core@7.51.1.json +5 -5
- package/wire-changes/core@7.51.2.json +293 -0
- package/wire-changes/core@7.52.0.json +5859 -0
- package/dist/core/hook-seats.d.ts +0 -66
- package/dist/core/hook-seats.js +0 -37
- package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
- package/dist/prompt-assembly/packs/sema-default.js +0 -147
- package/dist/prompts/simple-sections.d.ts +0 -58
- package/dist/prompts/simple-sections.js +0 -43
|
@@ -77,8 +77,9 @@ export function longOptionNameOf(tok) {
|
|
|
77
77
|
const name = eq >= 0 ? body.slice(0, eq) : body;
|
|
78
78
|
return name.length > 0 ? name : undefined;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
const abbreviates = (g) => g.acceptsAbbreviations !== false;
|
|
81
|
+
export function isLongOptionSpellingOf(name, full, accepts) {
|
|
82
|
+
return full === name || (accepts && full.startsWith(name));
|
|
82
83
|
}
|
|
83
84
|
const MERGED = new WeakMap();
|
|
84
85
|
function mergedTable(row, table) {
|
|
@@ -93,10 +94,11 @@ function mergedTable(row, table) {
|
|
|
93
94
|
const out = new Map();
|
|
94
95
|
const names = new Set(row.grammars.flatMap((g) => Object.keys(g[table] ?? {})));
|
|
95
96
|
for (const name of names) {
|
|
96
|
-
const
|
|
97
|
+
const declaring = row.grammars.filter((g) => g[table]?.[name] !== undefined);
|
|
98
|
+
const specs = declaring.map((g) => g[table][name]);
|
|
97
99
|
const arities = new Set(specs.map((s) => s.arity));
|
|
98
100
|
const widest = specs.reduce((a, b) => (roleRank(b.value) > roleRank(a.value) ? b : a));
|
|
99
|
-
out.set(name, { arity: arities.size === 1 ? specs[0].arity : "disputed", spec: widest, takesValueEverywhere: specs.every((s) => s.arity === 1), ownsRestEverywhere: specs.every((s) => s.arity !== 0), takesValueSomewhere: specs.some((s) => s.arity === 1) });
|
|
101
|
+
out.set(name, { arity: arities.size === 1 ? specs[0].arity : "disputed", spec: widest, takesValueEverywhere: specs.every((s) => s.arity === 1), ownsRestEverywhere: specs.every((s) => s.arity !== 0), takesValueSomewhere: specs.some((s) => s.arity === 1), abbreviable: declaring.some(abbreviates) });
|
|
100
102
|
}
|
|
101
103
|
byTable.set(table, out);
|
|
102
104
|
return out;
|
|
@@ -141,27 +143,28 @@ function viewTable(row, table, view) {
|
|
|
141
143
|
for (const [name, m] of mergedTable(row, table)) {
|
|
142
144
|
const role = m.spec.value;
|
|
143
145
|
const spec = m.spec;
|
|
146
|
+
const abbreviable = m.abbreviable;
|
|
144
147
|
if (view === "roles") {
|
|
145
148
|
if (m.arity === 0)
|
|
146
|
-
out.set(name, { arity: 0, spec });
|
|
149
|
+
out.set(name, { arity: 0, spec, abbreviable });
|
|
147
150
|
else if (m.arity === 1)
|
|
148
|
-
out.set(name, { arity: 1, spec, ...(role !== undefined ? { role } : {}) });
|
|
151
|
+
out.set(name, { arity: 1, spec, abbreviable, ...(role !== undefined ? { role } : {}) });
|
|
149
152
|
else if (m.arity === "suffix")
|
|
150
|
-
out.set(name, { arity: "suffix", spec, ...(role !== undefined ? { role } : {}) });
|
|
153
|
+
out.set(name, { arity: "suffix", spec, abbreviable, ...(role !== undefined ? { role } : {}) });
|
|
151
154
|
else if (m.arity === "attached" || (m.arity === "disputed" && table === "long"))
|
|
152
|
-
out.set(name, { arity: "attached", spec, ...(role !== undefined ? { role } : {}) });
|
|
155
|
+
out.set(name, { arity: "attached", spec, abbreviable, ...(role !== undefined ? { role } : {}) });
|
|
153
156
|
continue;
|
|
154
157
|
}
|
|
155
158
|
if (m.arity === 0)
|
|
156
|
-
out.set(name, { arity: 0, spec });
|
|
159
|
+
out.set(name, { arity: 0, spec, abbreviable });
|
|
157
160
|
else if (m.arity === "disputed") {
|
|
158
161
|
if (table === "long" && preciseRole(role))
|
|
159
|
-
out.set(name, { arity: "attached", role: role, spec });
|
|
162
|
+
out.set(name, { arity: "attached", role: role, spec, abbreviable });
|
|
160
163
|
}
|
|
161
164
|
else if (m.arity === 1 && preciseRole(role))
|
|
162
|
-
out.set(name, { arity: 1, role: role, spec });
|
|
165
|
+
out.set(name, { arity: 1, role: role, spec, abbreviable });
|
|
163
166
|
else if (m.arity === "attached" && table === "long" && preciseRole(role))
|
|
164
|
-
out.set(name, { arity: "attached", role: role, spec });
|
|
167
|
+
out.set(name, { arity: "attached", role: role, spec, abbreviable });
|
|
165
168
|
}
|
|
166
169
|
return out;
|
|
167
170
|
}
|
|
@@ -184,7 +187,7 @@ function readOptionIn(row, tok, view, next) {
|
|
|
184
187
|
return attached !== undefined ? { form: "attached", value: attached, role: exact.role, spec: exact.spec } : { form: "no-value" };
|
|
185
188
|
return attached === undefined ? { form: "no-value" } : { form: "unexplained" };
|
|
186
189
|
}
|
|
187
|
-
const reach = [...longs.entries()].filter(([full]) =>
|
|
190
|
+
const reach = [...longs.entries()].filter(([full, s]) => isLongOptionSpellingOf(long, full, s.abbreviable));
|
|
188
191
|
const valueNames = reach.filter(([, s]) => s.arity === 1 || (attached !== undefined && s.arity === "attached"));
|
|
189
192
|
const plainNames = reach.filter(([, s]) => s.arity === 0 || (attached === undefined && s.arity === "attached"));
|
|
190
193
|
if (valueNames.length === 0)
|
|
@@ -247,13 +250,13 @@ export function firstOperandSlot(row, view = "candidates") {
|
|
|
247
250
|
const shorts = [...mergedTable(row, "short")];
|
|
248
251
|
const letters = shorts.filter(([, m]) => m.spec.fillsSlot === true).map(([l]) => l).join("");
|
|
249
252
|
const valueLetters = shorts.filter(([, m]) => m.spec.fillsSlot !== true && m.ownsRestEverywhere).map(([l]) => l).join("");
|
|
250
|
-
const
|
|
251
|
-
return { role, suppliedByLetters: letters, suppliedByLongNames:
|
|
253
|
+
const supplying = [...mergedTable(row, "long")].filter(([, m]) => m.spec.fillsSlot === true);
|
|
254
|
+
return { role, suppliedByLetters: letters, suppliedByLongNames: supplying.map(([n]) => n), abbreviableLongNames: supplying.filter(([, m]) => m.abbreviable).map(([n]) => n), valueLetters };
|
|
252
255
|
}
|
|
253
256
|
export function suppliesFirstOperandSlot(slot, tok) {
|
|
254
257
|
if (tok.startsWith("--")) {
|
|
255
258
|
const long = longOptionNameOf(tok);
|
|
256
|
-
return long !== undefined && slot.suppliedByLongNames.some((full) =>
|
|
259
|
+
return long !== undefined && slot.suppliedByLongNames.some((full) => isLongOptionSpellingOf(long, full, slot.abbreviableLongNames.includes(full)));
|
|
257
260
|
}
|
|
258
261
|
if (!tok.startsWith("-"))
|
|
259
262
|
return false;
|
|
@@ -442,11 +445,16 @@ export function objectPathsOf(value) {
|
|
|
442
445
|
}
|
|
443
446
|
return out;
|
|
444
447
|
}
|
|
445
|
-
function walkArgs(row, words, readOption, slot, readsRole) {
|
|
448
|
+
function walkArgs(row, words, readOption, slot, readsRole, ownedValue) {
|
|
446
449
|
const out = [];
|
|
450
|
+
const valueAt = new Set();
|
|
447
451
|
const folded = words.map((w) => w.folded);
|
|
448
|
-
const
|
|
449
|
-
const
|
|
452
|
+
const unsettling = (at, anyOption) => (folded[at] === "--" || (anyOption && folded[at].startsWith("-") && folded[at] !== "-") ? { unsettled: true } : {});
|
|
453
|
+
const plain = slot === undefined ? [] : walkArgs(row, words, readOption, undefined, readsRole);
|
|
454
|
+
const eoo = plain.find((e) => e.kind === "end-of-options")?.at ?? -1;
|
|
455
|
+
const operandsPast = new Set(plain.flatMap((e) => (e.kind === "dash-word-operand" ? [e.at] : [])));
|
|
456
|
+
const notOptions = new Set(plain.flatMap((e) => (e.kind === "value" && (e.consumed || operandsPast.has(e.of)) ? [e.at] : [])));
|
|
457
|
+
const slotSupplied = slot !== undefined && folded.some((t, k) => (eoo === -1 || k < eoo) && !notOptions.has(k) && suppliesFirstOperandSlot(slot, t));
|
|
450
458
|
const permutes = !optionsStandAnywhere(row);
|
|
451
459
|
const dashRead = row?.operands?.dash === "file" ? "file" : "stdin";
|
|
452
460
|
const plus = row?.grammars.some((g) => g.plusOptions === true) === true;
|
|
@@ -467,11 +475,21 @@ function walkArgs(row, words, readOption, slot, readsRole) {
|
|
|
467
475
|
const both = sawOperand && permutes;
|
|
468
476
|
if (both) {
|
|
469
477
|
out.push({ kind: "dash-word-operand", at: k });
|
|
470
|
-
if (r.form === "separated" && k + 1 < words.length)
|
|
471
|
-
out.push({ kind: "value", at: k + 1, of: k, role: r.role, consumed: false, ...(r.spec !== undefined ? { spec: r.spec } : {}) });
|
|
478
|
+
if (r.form === "separated" && k + 1 < words.length) {
|
|
479
|
+
out.push({ kind: "value", at: k + 1, of: k, role: r.role, consumed: false, ...(r.spec !== undefined ? { spec: r.spec } : {}), ...unsettling(k + 1, false) });
|
|
480
|
+
valueAt.add(k + 1);
|
|
481
|
+
}
|
|
472
482
|
}
|
|
483
|
+
const owned = r.form === "no-value" || r.form === "unexplained" ? (valueAt.has(k) ? undefined : ownedValue?.(t, folded[k + 1])) : undefined;
|
|
484
|
+
const maybeValue = () => {
|
|
485
|
+
if (owned !== undefined && k + 1 < words.length) {
|
|
486
|
+
out.push({ kind: "value", at: k + 1, of: k, role: owned.role, consumed: false, ...(owned.spec !== undefined ? { spec: owned.spec } : {}), ...unsettling(k + 1, true) });
|
|
487
|
+
valueAt.add(k + 1);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
473
490
|
if (r.form === "no-value") {
|
|
474
491
|
out.push({ kind: "option", at: k, reading: "no-value" });
|
|
492
|
+
maybeValue();
|
|
475
493
|
continue;
|
|
476
494
|
}
|
|
477
495
|
if (r.form === "attached") {
|
|
@@ -485,6 +503,7 @@ function walkArgs(row, words, readOption, slot, readsRole) {
|
|
|
485
503
|
continue;
|
|
486
504
|
}
|
|
487
505
|
out.push({ kind: "option", at: k, reading: "speculative" });
|
|
506
|
+
maybeValue();
|
|
488
507
|
continue;
|
|
489
508
|
}
|
|
490
509
|
const inSlot = slot !== undefined && !slotSupplied && !sawOperand;
|
|
@@ -497,11 +516,34 @@ function walkArgs(row, words, readOption, slot, readsRole) {
|
|
|
497
516
|
}
|
|
498
517
|
export function readArgs(row, words, opts) {
|
|
499
518
|
const slot = opts.firstOperandSlot === false ? undefined : firstOperandSlot(row);
|
|
500
|
-
|
|
519
|
+
const owned = opts.ownedValues === true && row?.traversal?.discloses === "contents"
|
|
520
|
+
? (tok, next) => {
|
|
521
|
+
const v = bareOptionValueOf(row, tok, next);
|
|
522
|
+
return v !== undefined && preciseRole(v.role) ? v : undefined;
|
|
523
|
+
}
|
|
524
|
+
: undefined;
|
|
525
|
+
return walkArgs(row, words, (tok) => readOptionSlot(row, tok), opts.firstOperandSlot === "program-text" && slot?.role.kind !== "program-text" ? undefined : slot, preciseRole, owned);
|
|
501
526
|
}
|
|
502
527
|
export function readArgRoles(row, args) {
|
|
503
528
|
return walkArgs(row, args.map((folded) => ({ folded })), (tok, next) => readOptionRole(row, tok, next), firstOperandSlot(row, "roles"), () => true);
|
|
504
529
|
}
|
|
530
|
+
function keyWordIndex(row, args) {
|
|
531
|
+
if (row.traversal?.keyWordLetters === undefined)
|
|
532
|
+
return undefined;
|
|
533
|
+
const at = args.findIndex((t) => t.length > 0);
|
|
534
|
+
return at >= 0 && /^[A-Za-z]+$/.test(args[at]) ? at : undefined;
|
|
535
|
+
}
|
|
536
|
+
export function deliversOperands(row, args) {
|
|
537
|
+
if (row === undefined)
|
|
538
|
+
return false;
|
|
539
|
+
const key = keyWordIndex(row, args);
|
|
540
|
+
if (key !== undefined) {
|
|
541
|
+
const shorts = mergedTable(row, "short");
|
|
542
|
+
if ([...args[key]].some((ch) => shorts.get(ch)?.spec.delivers === "operands"))
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
return selectedOptions(row, key === undefined ? args : args.filter((_, k) => k !== key)).some((s) => s.delivers === "operands");
|
|
546
|
+
}
|
|
505
547
|
export function selectsContentsTraversal(row, args) {
|
|
506
548
|
const model = row?.traversal;
|
|
507
549
|
if (row === undefined || model === undefined || model.discloses !== "contents")
|
|
@@ -509,8 +551,8 @@ export function selectsContentsTraversal(row, args) {
|
|
|
509
551
|
if (model.always === true)
|
|
510
552
|
return true;
|
|
511
553
|
if (model.keyWordLetters !== undefined) {
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
554
|
+
const at = keyWordIndex(row, args);
|
|
555
|
+
if (at !== undefined && [...args[at]].some((ch) => model.keyWordLetters.includes(ch)))
|
|
514
556
|
return true;
|
|
515
557
|
}
|
|
516
558
|
const shorts = mergedTable(row, "short");
|
|
@@ -531,11 +573,11 @@ export function selectsContentsTraversal(row, args) {
|
|
|
531
573
|
const long = longOptionNameOf(t);
|
|
532
574
|
if (long === undefined)
|
|
533
575
|
continue;
|
|
534
|
-
if ([...longs].some(([full, m]) => m.spec.selects === "traversal" &&
|
|
576
|
+
if ([...longs].some(([full, m]) => m.spec.selects === "traversal" && isLongOptionSpellingOf(long, full, m.abbreviable)))
|
|
535
577
|
return true;
|
|
536
578
|
for (const [full, m] of longs) {
|
|
537
579
|
const recursive = m.spec.selectsWhenValue;
|
|
538
|
-
if (recursive === undefined || !
|
|
580
|
+
if (recursive === undefined || !isLongOptionSpellingOf(long, full, m.abbreviable))
|
|
539
581
|
continue;
|
|
540
582
|
const eq = t.indexOf("=");
|
|
541
583
|
const v = eq >= 0 ? t.slice(eq + 1) : args[k + 1];
|
|
@@ -580,7 +622,7 @@ export function valuesAreLiteral(row, args) {
|
|
|
580
622
|
const longs = mergedTable(row, "long");
|
|
581
623
|
const negates = (t) => {
|
|
582
624
|
const name = t.startsWith("--no-") ? longOptionNameOf(t)?.slice(3) : undefined;
|
|
583
|
-
return name !== undefined && name.length > 0 && [...longs].some(([full, m]) => m.spec.literalValues === true &&
|
|
625
|
+
return name !== undefined && name.length > 0 && [...longs].some(([full, m]) => m.spec.literalValues === true && isLongOptionSpellingOf(name, full, m.abbreviable));
|
|
584
626
|
};
|
|
585
627
|
if (args.some(negates))
|
|
586
628
|
return false;
|
|
@@ -599,7 +641,7 @@ export function valuesAreLiteral(row, args) {
|
|
|
599
641
|
if (long === undefined || t.includes("="))
|
|
600
642
|
continue;
|
|
601
643
|
const exact = longs.get(long);
|
|
602
|
-
const hits = exact !== undefined ? [exact] : [...longs].filter(([full]) =>
|
|
644
|
+
const hits = exact !== undefined ? [exact] : [...longs].filter(([full, m]) => isLongOptionSpellingOf(long, full, m.abbreviable)).map(([, m]) => m);
|
|
603
645
|
if (hits.length === 1 && hits[0].spec.literalValues === true)
|
|
604
646
|
return true;
|
|
605
647
|
continue;
|
|
@@ -629,7 +671,7 @@ export function takesSeparatedDatum(row, tok) {
|
|
|
629
671
|
if (tok.includes("="))
|
|
630
672
|
return false;
|
|
631
673
|
const name = longOptionNameOf(tok);
|
|
632
|
-
return name !== undefined && [...mergedTable(row, "long")].some(([full, m]) =>
|
|
674
|
+
return name !== undefined && [...mergedTable(row, "long")].some(([full, m]) => isLongOptionSpellingOf(name, full, m.abbreviable) && m.takesValueSomewhere && isDatumValue(m));
|
|
633
675
|
}
|
|
634
676
|
if (!/^-[A-Za-z0-9]/.test(tok))
|
|
635
677
|
return false;
|
|
@@ -644,6 +686,43 @@ export function takesSeparatedDatum(row, tok) {
|
|
|
644
686
|
}
|
|
645
687
|
return false;
|
|
646
688
|
}
|
|
689
|
+
const COUNT_SPELLING = /^[+-]?[0-9_]+$/;
|
|
690
|
+
const UNDECLARED_VALUE = { kind: "datum", form: "label" };
|
|
691
|
+
export function bareOptionValueOf(row, tok, next) {
|
|
692
|
+
if (next === undefined || !tok.startsWith("-") || tok === "-" || tok === "--")
|
|
693
|
+
return undefined;
|
|
694
|
+
if (tok.startsWith("--") && !tok.includes("=")) {
|
|
695
|
+
const name = longOptionNameOf(tok);
|
|
696
|
+
if (name !== undefined && ![...mergedTable(row, "long")].some(([full, m]) => isLongOptionSpellingOf(name, full, m.abbreviable)))
|
|
697
|
+
return { role: UNDECLARED_VALUE };
|
|
698
|
+
}
|
|
699
|
+
const owns = (s) => s.value !== undefined && (s.arity === 1 || (s.arity === "attached" && s.value.kind === "datum" && s.value.form === "count" && COUNT_SPELLING.test(next)));
|
|
700
|
+
for (const g of row.grammars) {
|
|
701
|
+
let found;
|
|
702
|
+
if (tok.startsWith("--")) {
|
|
703
|
+
const name = longOptionNameOf(tok);
|
|
704
|
+
if (name === undefined || tok.includes("="))
|
|
705
|
+
continue;
|
|
706
|
+
const exact = g.long[name];
|
|
707
|
+
const reach = exact !== undefined ? [exact] : Object.entries(g.long).filter(([full]) => isLongOptionSpellingOf(name, full, abbreviates(g))).map(([, s]) => s);
|
|
708
|
+
if (reach.length > 0 && reach.every(owns))
|
|
709
|
+
found = reach[0];
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
for (let i = 1; i < tok.length; i++) {
|
|
713
|
+
const spec = g.short[tok[i]];
|
|
714
|
+
if (spec === undefined || spec.arity === 0)
|
|
715
|
+
continue;
|
|
716
|
+
if (i === tok.length - 1 && owns(spec))
|
|
717
|
+
found = spec;
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (found?.value !== undefined)
|
|
722
|
+
return { role: found.value, spec: found };
|
|
723
|
+
}
|
|
724
|
+
return undefined;
|
|
725
|
+
}
|
|
647
726
|
export function attachedStdinFile(row, tok) {
|
|
648
727
|
if (row === undefined)
|
|
649
728
|
return false;
|
|
@@ -654,7 +733,7 @@ export function attachedStdinFile(row, tok) {
|
|
|
654
733
|
return false;
|
|
655
734
|
const longs = mergedTable(row, "long");
|
|
656
735
|
const exact = longs.get(name);
|
|
657
|
-
const reach = exact !== undefined ? [exact] : [...longs].filter(([full]) =>
|
|
736
|
+
const reach = exact !== undefined ? [exact] : [...longs].filter(([full, m]) => isLongOptionSpellingOf(name, full, m.abbreviable)).map(([, m]) => m);
|
|
658
737
|
return reach.length === 0 || reach.some((m) => m.arity !== 0 && isFileValue(m.spec));
|
|
659
738
|
}
|
|
660
739
|
if (!/^-[A-Za-z0-9]/.test(tok))
|
|
@@ -747,7 +826,7 @@ function scanOptions(row, args, one) {
|
|
|
747
826
|
continue;
|
|
748
827
|
const eq = t.indexOf("=");
|
|
749
828
|
const exact = longs.get(name);
|
|
750
|
-
const hits = exact !== undefined ? [[name, exact]] : [...longs].filter(([full]) =>
|
|
829
|
+
const hits = exact !== undefined ? [[name, exact]] : [...longs].filter(([full, m]) => isLongOptionSpellingOf(name, full, m.abbreviable));
|
|
751
830
|
for (const [full, m] of hits)
|
|
752
831
|
select(m.spec, `--${full}`);
|
|
753
832
|
const [full, only] = hits[0] ?? [];
|
|
@@ -1173,7 +1252,7 @@ function programTextUnder(g, args) {
|
|
|
1173
1252
|
let endOfOptions = false;
|
|
1174
1253
|
let firstOperand;
|
|
1175
1254
|
const longs = Object.entries(g.long);
|
|
1176
|
-
const reach = (long, pick) => longs.some(([full, s]) => pick(s) &&
|
|
1255
|
+
const reach = (long, pick) => longs.some(([full, s]) => pick(s) && isLongOptionSpellingOf(long, full, abbreviates(g)));
|
|
1177
1256
|
for (let k = 0; k < args.length; k++) {
|
|
1178
1257
|
const tok = args[k];
|
|
1179
1258
|
if (!endOfOptions && tok === "--") {
|
|
@@ -1318,7 +1397,7 @@ export function messageWords(program, words, programIndex) {
|
|
|
1318
1397
|
if (w.startsWith("--")) {
|
|
1319
1398
|
const eq = w.indexOf("=");
|
|
1320
1399
|
const name = w.slice(2, eq < 0 ? undefined : eq);
|
|
1321
|
-
const takers = longValues.filter(([n]) => n
|
|
1400
|
+
const takers = longValues.filter(([n]) => isLongOptionSpellingOf(name, n, abbreviates(sub)));
|
|
1322
1401
|
const message = (name.length > 0 && takers.length > 0 && takers.every(([, s]) => isMessage(s))) || isMessage(sub.long[name]);
|
|
1323
1402
|
if (eq >= 0) {
|
|
1324
1403
|
if (message)
|
|
@@ -32,6 +32,7 @@ const MOUNT = { kind: "mount-source", form: "mount" };
|
|
|
32
32
|
const OBJECT_PATH = { kind: "object-path" };
|
|
33
33
|
const text = (language) => ({ kind: "program-text", language });
|
|
34
34
|
const file = (language) => ({ kind: "program-file", language });
|
|
35
|
+
const WALKS = { walks: true };
|
|
35
36
|
const SWITCH = { arity: 0 };
|
|
36
37
|
const QUERY = { arity: 0, mode: "queries" };
|
|
37
38
|
const val = (value, extra = {}) => ({ arity: 1, ...(value !== undefined ? { value } : {}), ...extra });
|
|
@@ -114,9 +115,9 @@ const grepRow = (key) => ({
|
|
|
114
115
|
});
|
|
115
116
|
const diff = {
|
|
116
117
|
key: "diff",
|
|
117
|
-
grammars: implementations(grammar({ C: val(COUNT), D: val(LABEL), F: val(PATTERN), I: val(PATTERN), L: val(LABEL), S: val(
|
|
118
|
-
exclude: val(NAME_PATTERN), "exclude-from": val(READ), "from-file": val(READ), "horizon-lines": val(COUNT), ifdef: val(LABEL), "ignore-matching-lines": val(PATTERN),
|
|
119
|
-
label: val(LABEL), "show-function-line": val(PATTERN), "starting-file": val(
|
|
118
|
+
grammars: implementations(grammar({ C: val(COUNT), D: val(LABEL), F: val(PATTERN), I: val(PATTERN), L: val(LABEL), S: val(NAME_PATTERN), U: val(COUNT), W: val(COUNT), X: val(READ), x: val(NAME_PATTERN), ...switches("abBcdeEHilnNpqstTuvwyZ"), ...switches("r", { selects: "traversal" }) }, {
|
|
119
|
+
exclude: val(NAME_PATTERN), "exclude-from": val(READ), "from-file": val(READ, WALKS), "horizon-lines": val(COUNT), ifdef: val(LABEL), "ignore-matching-lines": val(PATTERN),
|
|
120
|
+
label: val(LABEL), "show-function-line": val(PATTERN), "starting-file": val(NAME_PATTERN), tabsize: val(COUNT), "to-file": val(READ, WALKS), width: val(COUNT),
|
|
120
121
|
color: optional(LABEL), context: optional(COUNT), unified: optional(COUNT),
|
|
121
122
|
...longSwitches(["brief", "ed", "expand-tabs", "ignore-all-space", "ignore-blank-lines", "ignore-case", "ignore-space-change", "ignore-tab-expansion", "ignore-trailing-space", "initial-tab", "minimal", "new-file", "normal", "paginate", "report-identical-files", "rcs", "show-c-function", "side-by-side", "speed-large-files", "suppress-blank-empty", "text"]), ...BANNERS,
|
|
122
123
|
...longSwitches(["recursive"], { selects: "traversal" }),
|
|
@@ -163,8 +164,8 @@ const date = {
|
|
|
163
164
|
};
|
|
164
165
|
const tar = {
|
|
165
166
|
key: "tar",
|
|
166
|
-
grammars: [grammar({ b: val(COUNT), C: val(NAMES), f: val(READ), T: val(READ, { delivers: "operands" }), X: val(READ), g: val(), ...switches("adhjJkmOpPStvwWxzZ"), ...switches("cru", { selects: "traversal" }) }, {
|
|
167
|
-
"blocking-factor": val(COUNT), directory: val(NAMES), exclude: val(NAME_PATTERN), "exclude-from": val(READ), file: val(READ), "files-from": val(READ, { delivers: "operands" }), "strip-components": val(COUNT),
|
|
167
|
+
grammars: [grammar({ b: val(COUNT), C: val(NAMES, WALKS), f: val(READ), T: val(READ, { delivers: "operands" }), X: val(READ), g: val(), ...switches("adhjJkmOpPStvwWxzZ"), ...switches("cru", { selects: "traversal" }) }, {
|
|
168
|
+
"blocking-factor": val(COUNT), directory: val(NAMES, WALKS), exclude: val(NAME_PATTERN), "exclude-from": val(READ), file: val(READ), "files-from": val(READ, { delivers: "operands" }), "strip-components": val(COUNT),
|
|
168
169
|
...longSwitches(["absolute-names", "dereference", "extract", "get", "interactive", "keep-old-files", "list", "preserve-permissions", "sparse", "to-stdout", "touch", "verbose", "verify"]), ...BANNERS,
|
|
169
170
|
...longSwitches(["append", "create", "update"], { selects: "traversal" }),
|
|
170
171
|
})],
|
|
@@ -230,13 +231,32 @@ const ls = {
|
|
|
230
231
|
traversal: { discloses: "names" },
|
|
231
232
|
witness: BINARY,
|
|
232
233
|
};
|
|
233
|
-
const
|
|
234
|
+
const namesWalker = (key) => ({ key, grammars: [], operands: { dash: "file", rest: NAMES }, traversal: { discloses: "names", always: true }, witness: BINARY });
|
|
235
|
+
const contentsWalker = (key, short, long, extra = {}) => ({
|
|
234
236
|
key,
|
|
235
|
-
grammars:
|
|
236
|
-
|
|
237
|
-
traversal: { discloses, always: true },
|
|
237
|
+
grammars: [grammar(short, long, { walksCwdWithoutOperand: true, ...extra })],
|
|
238
|
+
operands: { positional: [PATTERN] },
|
|
239
|
+
traversal: { discloses: "contents", always: true },
|
|
238
240
|
witness: BINARY,
|
|
239
241
|
});
|
|
242
|
+
const rg = contentsWalker("rg", { e: val(PATTERN, { fillsSlot: true }), f: val(READ, { fillsSlot: true }), ...values("ABCdjmM", COUNT), ...values("ErtT", LABEL), g: val(NAME_PATTERN) }, {
|
|
243
|
+
regexp: val(PATTERN, { fillsSlot: true }), file: val(READ, { fillsSlot: true }),
|
|
244
|
+
files: { arity: 0, fillsSlot: true },
|
|
245
|
+
...Object.fromEntries(["after-context", "before-context", "context", "max-count", "max-depth", "max-columns", "threads"].map((n) => [n, val(COUNT)])),
|
|
246
|
+
...Object.fromEntries(["color", "colors", "context-separator", "dfa-size-limit", "encoding", "engine", "field-context-separator", "field-match-separator", "generate", "hyperlink-format", "max-filesize", "path-separator", "regex-size-limit", "replace", "sort", "sortr", "type", "type-add", "type-clear", "type-not"].map((n) => [n, val(LABEL)])),
|
|
247
|
+
glob: val(NAME_PATTERN), iglob: val(NAME_PATTERN), "pre-glob": val(NAME_PATTERN), "ignore-file": val(READ),
|
|
248
|
+
...BANNERS,
|
|
249
|
+
}, { acceptsAbbreviations: false });
|
|
250
|
+
const ag = contentsWalker("ag", { g: val(PATTERN, { fillsSlot: true }), G: val(PATTERN), m: val(COUNT), p: val(READ), A: val(COUNT), B: val(COUNT), C: val(COUNT) }, {
|
|
251
|
+
"file-search-regex": val(PATTERN), "max-count": val(COUNT), "path-to-ignore": val(READ),
|
|
252
|
+
after: optional(COUNT), before: optional(COUNT), context: optional(COUNT),
|
|
253
|
+
...BANNERS,
|
|
254
|
+
});
|
|
255
|
+
const ack = contentsWalker("ack", { f: { arity: 0, fillsSlot: true }, m: val(COUNT), A: optional(COUNT), B: optional(COUNT), C: optional(COUNT), x: { arity: 0, delivers: "operands" } }, {
|
|
256
|
+
match: val(PATTERN, { fillsSlot: true }), "max-count": val(COUNT), ackrc: val(READ), "files-from": val(READ, { delivers: "operands" }),
|
|
257
|
+
"after-context": optional(COUNT), "before-context": optional(COUNT), context: optional(COUNT),
|
|
258
|
+
...BANNERS,
|
|
259
|
+
});
|
|
240
260
|
const BANNER_LONGS = ["--version", "--help", "--usage", "-version", "-help"];
|
|
241
261
|
function interpreterGrammar(language, g) {
|
|
242
262
|
const short = {};
|
|
@@ -591,7 +611,7 @@ const block = (key, g = []) => ({ key, grammars: g, syntax: "block", witness: SY
|
|
|
591
611
|
const BLOCK_GRAMMARS = { "[[": [grammar({ v: val(BINDS_NAME) })] };
|
|
592
612
|
export const PROGRAM_ROWS = [
|
|
593
613
|
head, tail, cut, grepRow("grep"), grepRow("egrep"), grepRow("fgrep"), diff, cmp, sed, date, tar, find, curl,
|
|
594
|
-
ls,
|
|
614
|
+
ls, namesWalker("du"), rg, namesWalker("tree"), ag, ack,
|
|
595
615
|
interpreter("perl", "perl", PERL, "file", true),
|
|
596
616
|
interpreter("ruby", "ruby", RUBY, "file", true),
|
|
597
617
|
interpreter("python", "python", PYTHON, "file", true, { modules: { timeit: text("python") } }),
|
|
@@ -95,18 +95,34 @@ export interface HomeViewSource {
|
|
|
95
95
|
* once and shared by every path below it. */
|
|
96
96
|
views(signal?: AbortSignal, env?: HomeViewEnv): HomeViews;
|
|
97
97
|
}
|
|
98
|
-
/** A judgment's views. `of` answers
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* `leaf: "file"` skips the path's own identity (a file is never a directory
|
|
98
|
+
/** A judgment's views. `of` answers one path's {@link HomeView}: no view where there is nothing to read (no `fileIdentity`
|
|
99
|
+
* seat, no home, a seat that declares the surface absent — the path is judged as spelled); the view where it differs from
|
|
100
|
+
* the path as spelled; and `unread` wherever a lookup the view stands on gave no answer. A level that does not exist (a
|
|
101
|
+
* write's missing tail) takes its parent's view. `leaf: "file"` skips the path's own identity (a file is never a directory
|
|
102
|
+
* on the chain). */
|
|
102
103
|
export interface HomeViews {
|
|
103
104
|
of(path: string, opts?: {
|
|
104
105
|
readonly leaf?: "file";
|
|
105
|
-
}): Promise<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
}): Promise<HomeView>;
|
|
107
|
+
}
|
|
108
|
+
/** One path's home view as a judge reads it:
|
|
109
|
+
* · `view` — the path respelled through a home's own directory chain, present only where it differs from the spelling;
|
|
110
|
+
* · `unread` — the first lookup the view stands on that gave no answer (an identity lookup that threw, timed out or failed
|
|
111
|
+
* with an error that is no conclusive "not there": a level of a home's chain — the index of every path is then partial —
|
|
112
|
+
* or a level of the path itself), present wherever one did, and inherited by every path below it.
|
|
113
|
+
* An `unread` answer is no reading: the path's view is not "none", it is unknown, so a judge that places the home-anchored
|
|
114
|
+
* rows by the view has not finished — every judge refuses to vouch past it ({@link homeViewUnreadSentence}). */
|
|
115
|
+
export interface HomeView {
|
|
116
|
+
readonly view?: string;
|
|
117
|
+
readonly unread?: string;
|
|
118
|
+
}
|
|
119
|
+
/** The one sentence a judgment that met an unread home view ({@link HomeView.unread}) refuses with — `subject` the path the
|
|
120
|
+
* call judged, `face` the deny table it was judged against. */
|
|
121
|
+
export declare function homeViewUnreadSentence(subject: string, unread: string, face?: "read" | "write"): string;
|
|
122
|
+
/** The refusal a traversal raises when an entry it walks met an unread home view: the whole call is refused (what the walk
|
|
123
|
+
* would serve was not judged), with the one sentence. */
|
|
124
|
+
export declare class HomeViewUnreadError extends Error {
|
|
125
|
+
constructor(subject: string, unread: string);
|
|
110
126
|
}
|
|
111
127
|
/** A judge that carries the home views of the placement its rows were compiled at. */
|
|
112
128
|
export interface HomeViewsCarrier {
|
|
@@ -260,6 +260,15 @@ async function readAuxiliaryHome(env, home, opts, signal) {
|
|
|
260
260
|
sayAuxiliary("a probe did not answer", opts.configRoot === true ? "config_root" : "auxiliary");
|
|
261
261
|
return reading;
|
|
262
262
|
}
|
|
263
|
+
export function homeViewUnreadSentence(subject, unread, face = "read") {
|
|
264
|
+
return `"${subject}" could not be judged against the ${face} deny list: "${unread}" cannot be identified against the home directories the home-anchored rows are placed under, so whether such a row covers it is unknown; refused — a deny judgment that did not finish is not a pass. Retry once the environment answers identity lookups.`;
|
|
265
|
+
}
|
|
266
|
+
export class HomeViewUnreadError extends Error {
|
|
267
|
+
constructor(subject, unread) {
|
|
268
|
+
super(homeViewUnreadSentence(subject, unread));
|
|
269
|
+
this.name = "HomeViewUnreadError";
|
|
270
|
+
}
|
|
271
|
+
}
|
|
263
272
|
function homeViewSourceOver(env, auxiliary) {
|
|
264
273
|
const declared = declaredHomeOf(env);
|
|
265
274
|
let declaredChain;
|
|
@@ -285,12 +294,10 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
285
294
|
const at = judgmentEnv ?? env;
|
|
286
295
|
const identity = at.fileIdentity;
|
|
287
296
|
let index;
|
|
288
|
-
const unread = [];
|
|
289
297
|
const indexOf = () => (index ??= (async () => {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
unread.push(at);
|
|
298
|
+
const declaredChain = await readDeclared(at);
|
|
299
|
+
const chains = [declaredChain, ...(await Promise.all(auxiliary)).map((a) => a.chain)];
|
|
300
|
+
const unread = declaredChain.unread[0];
|
|
294
301
|
const out = new Map();
|
|
295
302
|
for (const { own } of chains)
|
|
296
303
|
if (own !== undefined && !out.has(own.id))
|
|
@@ -299,7 +306,7 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
299
306
|
for (const { dir, id } of ancestors)
|
|
300
307
|
if (!out.has(id))
|
|
301
308
|
out.set(id, dir);
|
|
302
|
-
return out.size > 0 ? out : undefined;
|
|
309
|
+
return { ...(out.size > 0 ? { ids: out } : {}), ...(unread !== undefined ? { unread } : {}) };
|
|
303
310
|
})());
|
|
304
311
|
const views = new Map();
|
|
305
312
|
const viewOf = (path, leafIsFile) => {
|
|
@@ -308,25 +315,26 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
308
315
|
if (v === undefined) {
|
|
309
316
|
v = (async () => {
|
|
310
317
|
const index = await indexOf();
|
|
311
|
-
|
|
312
|
-
|
|
318
|
+
const chain = index.unread !== undefined ? { unread: index.unread } : {};
|
|
319
|
+
if (index.ids === undefined || typeof identity !== "function")
|
|
320
|
+
return chain;
|
|
313
321
|
if (!leafIsFile) {
|
|
314
322
|
const id = await identityOf(at, identity, path, signal);
|
|
315
323
|
if (identityUnread(id))
|
|
316
|
-
return
|
|
324
|
+
return { unread: path };
|
|
317
325
|
if (id?.ok === true) {
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
326
|
+
const dir = index.ids.get(id.value);
|
|
327
|
+
if (dir !== undefined)
|
|
328
|
+
return { ...chain, view: dir };
|
|
321
329
|
}
|
|
322
330
|
else if (id?.error.code === "not_supported")
|
|
323
|
-
return
|
|
331
|
+
return chain;
|
|
324
332
|
}
|
|
325
333
|
const parent = normalizeAbsPathLexically(`${path}/..`);
|
|
326
334
|
if (parent === path)
|
|
327
|
-
return
|
|
335
|
+
return chain;
|
|
328
336
|
const up = await viewOf(parent, false);
|
|
329
|
-
return up === undefined ?
|
|
337
|
+
return up.view === undefined ? up : { ...up, view: joinForFamily(pathFamilyOf({ root: path }), up.view, path.slice(parent.length).replace(/^[\\/]+/, "")) };
|
|
330
338
|
})();
|
|
331
339
|
views.set(key, v);
|
|
332
340
|
}
|
|
@@ -335,12 +343,11 @@ function homeViewSourceOver(env, auxiliary) {
|
|
|
335
343
|
return {
|
|
336
344
|
async of(path, opts) {
|
|
337
345
|
if (typeof identity !== "function" || (declared === undefined && auxiliary.length === 0) || !isAbsoluteForFamily("own", path))
|
|
338
|
-
return
|
|
346
|
+
return {};
|
|
339
347
|
const spelled = normalizeAbsPathLexically(path);
|
|
340
|
-
const view = await viewOf(spelled, opts?.leaf === "file");
|
|
341
|
-
return view
|
|
348
|
+
const { view, unread } = await viewOf(spelled, opts?.leaf === "file");
|
|
349
|
+
return { ...(view !== undefined && view !== spelled ? { view } : {}), ...(unread !== undefined ? { unread } : {}) };
|
|
342
350
|
},
|
|
343
|
-
unread,
|
|
344
351
|
};
|
|
345
352
|
},
|
|
346
353
|
};
|
|
@@ -379,6 +386,7 @@ export function readDenyOver(current, homeViews) {
|
|
|
379
386
|
return current().rgProbeGlobs;
|
|
380
387
|
},
|
|
381
388
|
unexcludableUnder: (scope) => current().unexcludableUnder?.(scope) ?? false,
|
|
389
|
+
rowUnderRoot: (scope) => current().rowUnderRoot?.(scope) ?? null,
|
|
382
390
|
rowAtOrBelow: (path) => current().rowAtOrBelow?.(path) ?? null,
|
|
383
391
|
homeViews: homeViews ?? { views: (signal) => current().homeViews.views(signal) },
|
|
384
392
|
};
|
|
@@ -464,15 +472,8 @@ export function readDenyPlacedLater(unplaced, place) {
|
|
|
464
472
|
const homeViews = {
|
|
465
473
|
views(signal, judgmentEnv) {
|
|
466
474
|
let views;
|
|
467
|
-
const unread = [];
|
|
468
475
|
return {
|
|
469
|
-
of: async (path, opts) =>
|
|
470
|
-
const inner = await (views ??= settled().then((m) => m.homeViews.views(signal, judgmentEnv)));
|
|
471
|
-
const view = await inner.of(path, opts);
|
|
472
|
-
unread.splice(0, unread.length, ...inner.unread);
|
|
473
|
-
return view;
|
|
474
|
-
},
|
|
475
|
-
unread,
|
|
476
|
+
of: async (path, opts) => (await (views ??= settled().then((m) => m.homeViews.views(signal, judgmentEnv)))).of(path, opts),
|
|
476
477
|
};
|
|
477
478
|
},
|
|
478
479
|
};
|