@sema-agent/core 7.44.0 → 7.46.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 +418 -1
- package/dist/agents/extra-tool-names.d.ts +65 -0
- package/dist/agents/extra-tool-names.js +124 -0
- package/dist/agents/subagent.d.ts +17 -5
- package/dist/agents/subagent.js +65 -38
- package/dist/agents/tool-filter.d.ts +82 -5
- package/dist/agents/tool-filter.js +134 -4
- package/dist/core/agent-config-dir.d.ts +20 -0
- package/dist/core/agent-config-dir.js +49 -0
- package/dist/core/agent-definition.d.ts +2 -2
- package/dist/core/allow-entry.d.ts +30 -4
- package/dist/core/allow-entry.js +32 -5
- package/dist/core/ask-origin.d.ts +23 -4
- package/dist/core/ask-origin.js +11 -5
- package/dist/core/checkpoint-store.d.ts +41 -4
- package/dist/core/decision-receipt.js +1 -1
- package/dist/core/effective-path-target.d.ts +143 -10
- package/dist/core/effective-path-target.js +113 -9
- package/dist/core/engine-notice.d.ts +25 -3
- package/dist/core/engine-notice.js +12 -6
- package/dist/core/gate-fold.js +3 -0
- package/dist/core/gate-lanes.js +11 -3
- package/dist/core/gate-outcome.d.ts +5 -0
- package/dist/core/gate-outcome.js +2 -0
- package/dist/core/governance-codes.d.ts +3 -1
- package/dist/core/governance-codes.js +3 -0
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/memory-engine/content-origin.d.ts +0 -34
- package/dist/core/memory-engine/content-origin.js +9 -4
- package/dist/core/memory-engine/layout.d.ts +5 -1
- package/dist/core/memory-engine/layout.js +1 -0
- package/dist/core/path-rule-binding.d.ts +65 -0
- package/dist/core/path-rule-binding.js +99 -0
- package/dist/core/permission-rule-model.d.ts +47 -18
- package/dist/core/permission-rule-model.js +38 -42
- package/dist/core/permission-rule-provider.d.ts +7 -0
- package/dist/core/permission-rule-provider.js +10 -3
- package/dist/core/permission-rule-store.d.ts +8 -0
- package/dist/core/permission-rule-store.js +6 -2
- package/dist/core/permission-rule-sync.js +2 -2
- package/dist/core/permission-rules.d.ts +22 -36
- package/dist/core/permission-rules.js +50 -40
- package/dist/core/real-approval.d.ts +9 -6
- package/dist/core/real-approval.js +5 -5
- package/dist/core/runner/child-tree.d.ts +110 -0
- package/dist/core/runner/child-tree.js +107 -0
- package/dist/core/runner/construction-doors.d.ts +5 -0
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +54 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +34 -25
- package/dist/core/runner/permission-rule-lanes.js +18 -12
- package/dist/core/runner/persisted-path-rows.d.ts +31 -7
- package/dist/core/runner/persisted-path-rows.js +31 -12
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -0
- package/dist/core/runner/prepare-ask-lane.js +4 -2
- package/dist/core/runner/prepare-config-doors.js +3 -1
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +11 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +8 -4
- package/dist/core/runner/prepare-hands-readface.js +6 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -1
- package/dist/core/runner/prepare-inherited-gate.js +8 -2
- package/dist/core/runner/prepare-listings.d.ts +4 -4
- package/dist/core/runner/prepare-listings.js +2 -22
- package/dist/core/runner/prepare-park-ask.d.ts +5 -0
- package/dist/core/runner/prepare-park-ask.js +6 -4
- package/dist/core/runner/prepare-policy-chain.d.ts +16 -2
- package/dist/core/runner/prepare-policy-chain.js +14 -5
- package/dist/core/runner/prepare-suspend-saga.d.ts +10 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -1
- package/dist/core/runner/prepare-task.js +41 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +1 -0
- package/dist/core/runner/resume-apply.js +17 -3
- package/dist/core/runner/resume-checkpoint-screen.js +13 -0
- package/dist/core/runner/resume-policy-outcome.js +2 -1
- package/dist/core/runner/run-leg.js +5 -1
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/runtask.d.ts +2 -0
- package/dist/core/runner/runtask.js +4 -2
- package/dist/core/runner/stream-steer-verb.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +32 -0
- package/dist/core/runner/sub-agent-deny-lists.js +121 -0
- package/dist/core/runner/synthetic-tools.d.ts +1 -1
- package/dist/core/runner/synthetic-tools.js +3 -2
- package/dist/core/runner/write-protection-station.d.ts +3 -2
- package/dist/core/runner/write-protection-station.js +1 -0
- package/dist/core/runner-deps.d.ts +14 -0
- package/dist/core/sensitive-path-policy.d.ts +8 -0
- package/dist/core/sensitive-path-policy.js +18 -2
- package/dist/core/session-policy-store.d.ts +6 -2
- package/dist/core/session-policy-store.js +2 -1
- package/dist/core/shell-wrapper-projection.d.ts +11 -0
- package/dist/core/shell-wrapper-projection.js +56 -0
- package/dist/core/shell-wrapper-table.d.ts +144 -34
- package/dist/core/shell-wrapper-table.js +40 -20
- package/dist/core/skill-grant.d.ts +10 -2
- package/dist/core/skill-grant.js +20 -4
- package/dist/core/synthetic-read-verdict.d.ts +3 -0
- package/dist/core/synthetic-read-verdict.js +3 -1
- package/dist/core/task-notification.d.ts +12 -1
- package/dist/core/task-notification.js +13 -1
- package/dist/core/task-spec.d.ts +5 -3
- package/dist/core/tool-catalog-entries.d.ts +21 -0
- package/dist/core/tool-catalog-entries.js +9 -0
- package/dist/core/tool-policy.d.ts +45 -12
- package/dist/core/tool-policy.js +18 -20
- package/dist/core/tool-spec.d.ts +23 -4
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +30 -9
- package/dist/index.d.ts +10 -6
- package/dist/index.js +9 -5
- package/dist/orchestration/run-spec.js +8 -7
- package/dist/orchestration/workflow.js +3 -2
- package/dist/shell/lex.d.ts +7 -0
- package/dist/shell/lex.js +17 -0
- package/dist/tools/fs/bash-program-position.d.ts +8 -87
- package/dist/tools/fs/bash-program-position.js +33 -69
- package/dist/tools/fs/bash-readonly-classifier.d.ts +17 -444
- package/dist/tools/fs/bash-readonly-classifier.js +169 -1225
- package/dist/tools/fs/index.d.ts +3 -2
- package/dist/tools/fs/program-read-model.d.ts +694 -0
- package/dist/tools/fs/program-read-model.js +1252 -0
- package/dist/tools/fs/program-read-model.rows.d.ts +18 -0
- package/dist/tools/fs/program-read-model.rows.js +613 -0
- package/dist/tools/fs/read-deny-home.d.ts +19 -1
- package/dist/tools/fs/read-deny-home.js +62 -24
- package/dist/tools/fs/read-deny.d.ts +54 -14
- package/dist/tools/fs/read-deny.js +104 -50
- package/dist/tools/fs/removal-targets.d.ts +83 -0
- package/dist/tools/fs/removal-targets.js +236 -0
- package/dist/tools/fs/safety.d.ts +3 -0
- package/dist/tools/fs/safety.js +10 -3
- package/dist/tools/fs/shell-read-argv.d.ts +85 -0
- package/dist/tools/fs/shell-read-argv.js +386 -0
- package/dist/tools/fs/shell-read-bindings.d.ts +273 -0
- package/dist/tools/fs/shell-read-bindings.js +746 -0
- package/dist/tools/fs/shell-read-check.js +23 -15
- package/dist/tools/fs/shell-read-establish.js +79 -5
- package/dist/tools/fs/shell-read-judge.d.ts +11 -1
- package/dist/tools/fs/shell-read-judge.js +9 -1
- package/dist/tools/fs/shell-read-plan.d.ts +31 -7
- package/dist/tools/fs/shell-read-plan.js +299 -393
- package/dist/tools/fs/shell-read-word.d.ts +29 -26
- package/dist/tools/fs/shell-read-word.js +30 -38
- package/dist/tools/fs/shell-read-write-targets.d.ts +15 -37
- package/dist/tools/fs/shell-read-write-targets.js +83 -136
- package/dist/tools/fs/shell-reentry-text.d.ts +38 -6
- package/dist/tools/fs/shell-reentry-text.js +90 -53
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +49 -3
- package/wire-changes/core@7.45.0.json +1084 -0
- package/wire-changes/core@7.46.0.json +1522 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
const READ = { kind: "path", effect: "read" };
|
|
2
|
+
const WRITE = { kind: "path", effect: "write" };
|
|
3
|
+
const CREATED = { kind: "path", effect: "create" };
|
|
4
|
+
const TOUCHED = { kind: "path", effect: "create", seats: ["landing"] };
|
|
5
|
+
const REMOVED = { kind: "path", effect: "write", seats: ["entry"] };
|
|
6
|
+
const COPY_SOURCE = { kind: "path", effect: "write", seats: ["landing", "entry"], writtenAt: [] };
|
|
7
|
+
const MOVE_SOURCE = { kind: "path", effect: "write", seats: ["landing", "entry"], writtenAt: ["entry"] };
|
|
8
|
+
const DESTINATION = { kind: "path", effect: "write", seats: ["landing", "entry"] };
|
|
9
|
+
const EDITED = { kind: "path", effect: "edit-in-place", seats: ["entry"] };
|
|
10
|
+
const NAMES = { kind: "path", effect: "names" };
|
|
11
|
+
const INDIRECT = { kind: "path", effect: "read", valueForm: "indirect" };
|
|
12
|
+
const FORM = { kind: "path", effect: "read", valueForm: "form" };
|
|
13
|
+
const HEADER = { kind: "path", effect: "read", valueForm: "header" };
|
|
14
|
+
const URL = { kind: "path", effect: "read", valueForm: "url", programGlob: true };
|
|
15
|
+
const UPLOAD = { kind: "path", effect: "read", programGlob: true };
|
|
16
|
+
const COUNT = { kind: "datum", form: "count" };
|
|
17
|
+
const PATTERN = { kind: "datum", form: "pattern" };
|
|
18
|
+
const NAME_PATTERN = { kind: "datum", form: "name-pattern" };
|
|
19
|
+
const LABEL = { kind: "datum", form: "label" };
|
|
20
|
+
const DELIMITER = { kind: "datum", form: "delimiter" };
|
|
21
|
+
const MESSAGE = { kind: "datum", form: "message" };
|
|
22
|
+
const SHELL_TEXT = { kind: "shell-text" };
|
|
23
|
+
const ASSIGNMENT = { kind: "assignment" };
|
|
24
|
+
const ENTRY_PROBE = { kind: "entry-probe" };
|
|
25
|
+
const BINDS_NAME = { kind: "binds-name" };
|
|
26
|
+
const COMMAND = { kind: "command" };
|
|
27
|
+
const VOLUME = { kind: "mount-source", form: "volume" };
|
|
28
|
+
const MOUNT = { kind: "mount-source", form: "mount" };
|
|
29
|
+
const OBJECT_PATH = { kind: "object-path" };
|
|
30
|
+
const text = (language) => ({ kind: "program-text", language });
|
|
31
|
+
const file = (language) => ({ kind: "program-file", language });
|
|
32
|
+
const SWITCH = { arity: 0 };
|
|
33
|
+
const val = (value, extra = {}) => ({ arity: 1, ...(value !== undefined ? { value } : {}), ...extra });
|
|
34
|
+
const optional = (value) => ({ arity: "attached", ...(value !== undefined ? { value } : {}) });
|
|
35
|
+
const switches = (letters, extra = {}) => Object.fromEntries([...letters].map((l) => [l, { arity: 0, ...extra }]));
|
|
36
|
+
const longSwitches = (names, extra = {}) => Object.fromEntries(names.map((n) => [n, { arity: 0, ...extra }]));
|
|
37
|
+
const values = (letters, value) => Object.fromEntries([...letters].map((l) => [l, val(value)]));
|
|
38
|
+
const grammar = (short, long = {}, extra = {}) => ({ dialect: "any", short, long, afterFirstOperand: "either", ...extra });
|
|
39
|
+
function implementations(union, gnu, bsd) {
|
|
40
|
+
const one = (dialect, d) => {
|
|
41
|
+
const short = { ...union.short };
|
|
42
|
+
const long = { ...union.long };
|
|
43
|
+
const dashWords = union.dashWords === undefined ? undefined : { ...union.dashWords };
|
|
44
|
+
const table = (spelling) => (spelling.startsWith("--") ? long : spelling.length === 2 ? short : dashWords);
|
|
45
|
+
const key = (spelling) => spelling.replace(/^--?/, "");
|
|
46
|
+
for (const s of d.lacks ?? [])
|
|
47
|
+
delete table(s)?.[key(s)];
|
|
48
|
+
for (const [s, spec] of Object.entries(d.reads ?? {})) {
|
|
49
|
+
const t = table(s);
|
|
50
|
+
if (t !== undefined)
|
|
51
|
+
t[key(s)] = spec;
|
|
52
|
+
}
|
|
53
|
+
return { ...union, dialect, short, long, ...(dashWords !== undefined ? { dashWords } : {}), afterFirstOperand: d.afterFirstOperand ?? union.afterFirstOperand, ...(d.obsoleteFirst !== undefined ? { obsoleteFirst: d.obsoleteFirst } : {}) };
|
|
54
|
+
};
|
|
55
|
+
return [one("gnu", gnu), one("bsd", bsd)];
|
|
56
|
+
}
|
|
57
|
+
const BINARY = "binary";
|
|
58
|
+
const BANNERS = longSwitches(["help", "version"], { mode: "banner" });
|
|
59
|
+
const head = {
|
|
60
|
+
key: "head",
|
|
61
|
+
grammars: implementations(grammar({ c: val(COUNT, { bounds: "bytes" }), n: val(COUNT, { bounds: "lines" }), ...switches("qvz") }, { bytes: val(COUNT, { bounds: "bytes" }), lines: val(COUNT, { bounds: "lines" }), ...longSwitches(["quiet", "silent", "verbose", "zero-terminated"]), ...BANNERS }), {}, { lacks: ["-q", "-v", "-z", "--quiet", "--silent", "--verbose", "--zero-terminated", "--help", "--version"] }),
|
|
62
|
+
operands: { stdinBelow: 1 },
|
|
63
|
+
witness: BINARY,
|
|
64
|
+
};
|
|
65
|
+
const TAIL_OBSOLETE = { f: { arity: 0, mode: "follows" }, F: { arity: 0, mode: "follows" }, b: SWITCH, c: SWITCH, l: SWITCH, r: SWITCH };
|
|
66
|
+
const tail = {
|
|
67
|
+
key: "tail",
|
|
68
|
+
grammars: implementations(grammar({ ...values("bcns", COUNT), ...switches("fF", { mode: "follows" }), ...switches("qvz") }, {
|
|
69
|
+
bytes: val(COUNT), lines: val(COUNT), "max-unchanged-stats": val(COUNT), pid: val(COUNT), "sleep-interval": val(COUNT),
|
|
70
|
+
follow: { arity: "attached", value: LABEL, mode: "follows" },
|
|
71
|
+
...longSwitches(["quiet", "retry", "silent", "verbose", "zero-terminated"]), ...BANNERS,
|
|
72
|
+
}), { lacks: ["-b"], obsoleteFirst: { signs: "+-", letters: TAIL_OBSOLETE } }, { lacks: ["-s", "-z", "--max-unchanged-stats", "--pid", "--sleep-interval", "--follow", "--retry", "--zero-terminated", "--help", "--version"], obsoleteFirst: { signs: "+-", letters: TAIL_OBSOLETE } }),
|
|
73
|
+
operands: { stdinBelow: 1 },
|
|
74
|
+
witness: BINARY,
|
|
75
|
+
};
|
|
76
|
+
const cut = {
|
|
77
|
+
key: "cut",
|
|
78
|
+
grammars: implementations(grammar({ b: val(COUNT), c: val(COUNT), d: val(DELIMITER), f: val(COUNT), ...switches("nsz") }, {
|
|
79
|
+
bytes: val(COUNT), characters: val(COUNT), delimiter: val(DELIMITER), fields: val(COUNT), "output-delimiter": val(DELIMITER),
|
|
80
|
+
...longSwitches(["complement", "only-delimited", "zero-terminated"]), ...BANNERS,
|
|
81
|
+
}), {}, { lacks: ["-z", "--bytes", "--characters", "--delimiter", "--fields", "--output-delimiter", "--complement", "--only-delimited", "--zero-terminated", "--help", "--version"] }),
|
|
82
|
+
operands: { stdinBelow: 1 },
|
|
83
|
+
witness: BINARY,
|
|
84
|
+
};
|
|
85
|
+
const GREP_GRAMMAR = grammar({
|
|
86
|
+
A: val(COUNT), B: val(COUNT), C: val(COUNT), D: val(LABEL), d: val(LABEL, { selectsWhenValue: "recurse" }), e: val(PATTERN, { fillsSlot: true }), f: val(READ, { fillsSlot: true }), m: val(COUNT),
|
|
87
|
+
...switches("0123456789abcEFGhHiIlLnoPqsUvwxyzZ"),
|
|
88
|
+
V: { arity: 0, mode: "banner" },
|
|
89
|
+
...switches("rR", { selects: "traversal" }),
|
|
90
|
+
}, {
|
|
91
|
+
"after-context": val(COUNT), "before-context": val(COUNT), "binary-files": val(LABEL), devices: val(LABEL), directories: val(LABEL, { selectsWhenValue: "recurse" }),
|
|
92
|
+
exclude: val(NAME_PATTERN), "exclude-dir": val(NAME_PATTERN), "exclude-from": val(READ), file: val(READ, { fillsSlot: true }), "group-separator": val(LABEL),
|
|
93
|
+
include: val(NAME_PATTERN), label: val(LABEL), "max-count": val(COUNT), regexp: val(PATTERN, { fillsSlot: true }),
|
|
94
|
+
color: optional(LABEL), colour: optional(LABEL), context: optional(COUNT),
|
|
95
|
+
...longSwitches(["basic-regexp", "byte-offset", "count", "extended-regexp", "files-with-matches", "files-without-match", "fixed-strings", "ignore-case", "initial-tab", "invert-match", "line-buffered", "line-number", "line-regexp", "no-filename", "no-group-separator", "no-messages", "null", "null-data", "only-matching", "perl-regexp", "quiet", "silent", "text", "with-filename", "word-regexp"]), ...BANNERS,
|
|
96
|
+
...longSwitches(["dereference-recursive", "recursive"], { selects: "traversal" }),
|
|
97
|
+
}, { walksCwdWithoutOperand: true });
|
|
98
|
+
const BSD_GREP_LACKS = ["-P", "--exclude-from", "--group-separator", "--initial-tab", "--no-group-separator", "--perl-regexp", "--dereference-recursive"];
|
|
99
|
+
const GNU_MATCHER_CONFLICTS = {
|
|
100
|
+
grep: [],
|
|
101
|
+
egrep: ["-F", "-G", "-P", "--fixed-strings", "--basic-regexp", "--perl-regexp"],
|
|
102
|
+
fgrep: ["-E", "-G", "-P", "--extended-regexp", "--basic-regexp", "--perl-regexp"],
|
|
103
|
+
};
|
|
104
|
+
const grepRow = (key) => ({
|
|
105
|
+
key,
|
|
106
|
+
grammars: implementations(GREP_GRAMMAR, { reads: { "--context": val(COUNT) }, lacks: GNU_MATCHER_CONFLICTS[key] ?? [] }, { lacks: BSD_GREP_LACKS }),
|
|
107
|
+
operands: { positional: [PATTERN], stdinBelow: 2 },
|
|
108
|
+
traversal: { discloses: "contents" },
|
|
109
|
+
witness: BINARY,
|
|
110
|
+
});
|
|
111
|
+
const diff = {
|
|
112
|
+
key: "diff",
|
|
113
|
+
grammars: implementations(grammar({ C: val(COUNT), D: val(LABEL), F: val(PATTERN), I: val(PATTERN), L: val(LABEL), S: val(NAMES), U: val(COUNT), W: val(COUNT), X: val(READ), x: val(NAME_PATTERN), ...switches("abBcdeEHilnNpqstTuvwyZ"), ...switches("r", { selects: "traversal" }) }, {
|
|
114
|
+
exclude: val(NAME_PATTERN), "exclude-from": val(READ), "from-file": val(READ), "horizon-lines": val(COUNT), ifdef: val(LABEL), "ignore-matching-lines": val(PATTERN),
|
|
115
|
+
label: val(LABEL), "show-function-line": val(PATTERN), "starting-file": val(NAMES), tabsize: val(COUNT), "to-file": val(READ), width: val(COUNT),
|
|
116
|
+
color: optional(LABEL), context: optional(COUNT), unified: optional(COUNT),
|
|
117
|
+
...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,
|
|
118
|
+
...longSwitches(["recursive"], { selects: "traversal" }),
|
|
119
|
+
}), { reads: { "-v": { arity: 0, mode: "banner" } } }, { lacks: ["-E", "-v", "-Z", "--from-file", "--to-file", "--ignore-tab-expansion", "--ignore-trailing-space", "--suppress-blank-empty"] }),
|
|
120
|
+
operands: { stdinBelow: 2 },
|
|
121
|
+
traversal: { discloses: "contents", always: true },
|
|
122
|
+
witness: BINARY,
|
|
123
|
+
};
|
|
124
|
+
const cmp = {
|
|
125
|
+
key: "cmp",
|
|
126
|
+
grammars: implementations(grammar({ i: val(COUNT), n: val(COUNT), ...switches("blsv") }, { bytes: val(COUNT), "ignore-initial": val(COUNT), ...longSwitches(["print-bytes", "quiet", "silent", "verbose"]), ...BANNERS }), { reads: { "-v": { arity: 0, mode: "banner" } } }, { lacks: ["-v", "--help", "--version"] }),
|
|
127
|
+
operands: { stdinBelow: 2 },
|
|
128
|
+
witness: BINARY,
|
|
129
|
+
};
|
|
130
|
+
const IN_PLACE_ATTACHED = { arity: "attached", value: LABEL, selects: "edit-in-place" };
|
|
131
|
+
const IN_PLACE_SUFFIX = { arity: "suffix", value: LABEL, selects: "edit-in-place" };
|
|
132
|
+
const INERT = { effect: "none" };
|
|
133
|
+
const SED_LONG = {
|
|
134
|
+
expression: val(text("sed"), { fillsSlot: true, ...INERT }), file: val(file("sed"), { fillsSlot: true, ...INERT }), "line-length": val(COUNT),
|
|
135
|
+
"in-place": IN_PLACE_ATTACHED,
|
|
136
|
+
"follow-symlinks": { arity: 0, writesAt: ["landing"] },
|
|
137
|
+
...longSwitches(["debug", "null-data", "sandbox", "separate", "unbuffered"]),
|
|
138
|
+
...longSwitches(["posix", "regexp-extended", "zero-terminated"], INERT),
|
|
139
|
+
...longSwitches(["quiet", "silent"], { ...INERT, mode: "quiet" }),
|
|
140
|
+
...BANNERS,
|
|
141
|
+
};
|
|
142
|
+
const SED_SHORT = {
|
|
143
|
+
e: val(text("sed"), { fillsSlot: true, ...INERT }), f: val(file("sed"), { fillsSlot: true, ...INERT }),
|
|
144
|
+
i: IN_PLACE_ATTACHED, I: IN_PLACE_SUFFIX,
|
|
145
|
+
n: { arity: 0, ...INERT, mode: "quiet" },
|
|
146
|
+
...switches("s"),
|
|
147
|
+
...switches("uzEraH", INERT),
|
|
148
|
+
};
|
|
149
|
+
const sed = {
|
|
150
|
+
key: "sed",
|
|
151
|
+
grammars: implementations({ dialect: "any", short: SED_SHORT, long: SED_LONG, afterFirstOperand: "either" }, { reads: { "-l": val(COUNT) }, lacks: ["-a", "-H", "-I"], afterFirstOperand: "options" }, { reads: { "-l": SWITCH, "-i": IN_PLACE_SUFFIX }, lacks: ["-s", "-z", ...Object.keys(SED_LONG).map((n) => `--${n}`)], afterFirstOperand: "operands" }),
|
|
152
|
+
operands: { positional: [text("sed")], editedInPlace: EDITED, stdinBelow: 2 },
|
|
153
|
+
witness: BINARY,
|
|
154
|
+
};
|
|
155
|
+
const date = {
|
|
156
|
+
key: "date",
|
|
157
|
+
grammars: implementations(grammar({ d: val(COUNT), f: val(READ), r: val(NAMES), s: val(COUNT, { effect: "writes" }), ...switches("uR") }, { date: val(COUNT), file: val(READ), reference: val(NAMES), "rfc-3339": val(COUNT), set: val(COUNT, { effect: "writes" }), "iso-8601": optional(LABEL), ...longSwitches(["debug", "rfc-822", "rfc-email", "universal", "utc"]), ...BANNERS }), {}, { reads: { "-f": val(LABEL) }, lacks: ["--file", "--reference"] }),
|
|
158
|
+
witness: BINARY,
|
|
159
|
+
};
|
|
160
|
+
const tar = {
|
|
161
|
+
key: "tar",
|
|
162
|
+
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" }) }, {
|
|
163
|
+
"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),
|
|
164
|
+
...longSwitches(["absolute-names", "dereference", "extract", "get", "interactive", "keep-old-files", "list", "preserve-permissions", "sparse", "to-stdout", "touch", "verbose", "verify"]), ...BANNERS,
|
|
165
|
+
...longSwitches(["append", "create", "update"], { selects: "traversal" }),
|
|
166
|
+
})],
|
|
167
|
+
traversal: { discloses: "contents", keyWordLetters: "cru" },
|
|
168
|
+
witness: BINARY,
|
|
169
|
+
};
|
|
170
|
+
const find = {
|
|
171
|
+
key: "find",
|
|
172
|
+
grammars: implementations(grammar({ D: val(LABEL), O: val(COUNT), f: val(NAMES), ...switches("HLPdsx") }, BANNERS, {
|
|
173
|
+
afterFirstOperand: "options",
|
|
174
|
+
dashWords: {
|
|
175
|
+
amin: val(COUNT), anewer: val(NAMES), atime: val(COUNT), cmin: val(COUNT), cnewer: val(NAMES), context: val(LABEL),
|
|
176
|
+
ctime: val(COUNT), fstype: val(LABEL), gid: val(COUNT), group: val(LABEL), ilname: val(NAMES), iname: val(NAME_PATTERN),
|
|
177
|
+
inum: val(COUNT), ipath: val(NAMES), iregex: val(NAME_PATTERN), iwholename: val(NAMES), links: val(COUNT),
|
|
178
|
+
lname: val(NAMES), maxdepth: val(COUNT), mindepth: val(COUNT), mmin: val(COUNT), mtime: val(COUNT), name: val(NAME_PATTERN),
|
|
179
|
+
newer: val(NAMES), newerat: val(NAMES), neweraa: val(NAMES), neweram: val(NAMES), newerac: val(NAMES),
|
|
180
|
+
newerct: val(NAMES), newerca: val(NAMES), newercm: val(NAMES), newercc: val(NAMES),
|
|
181
|
+
newermt: val(NAMES), newerma: val(NAMES), newermm: val(NAMES), newermc: val(NAMES),
|
|
182
|
+
newerBt: val(NAMES), newerBa: val(NAMES), newerBm: val(NAMES), newerBc: val(NAMES),
|
|
183
|
+
path: val(NAMES), perm: val(LABEL), printf: val(LABEL), regex: val(NAME_PATTERN), regextype: val(LABEL),
|
|
184
|
+
samefile: val(NAMES), size: val(COUNT), type: val(LABEL), uid: val(COUNT), used: val(COUNT), user: val(LABEL),
|
|
185
|
+
wholename: val(NAMES), xtype: val(LABEL),
|
|
186
|
+
delete: { arity: 0, effect: "writes" },
|
|
187
|
+
...longSwitches(["exec", "execdir", "ok", "okdir"], { effect: "executes" }),
|
|
188
|
+
fprint: val(WRITE), fprint0: val(WRITE), fls: val(WRITE), fprintf: val(WRITE),
|
|
189
|
+
"files0-from": val(READ, { delivers: "operands" }),
|
|
190
|
+
...longSwitches([
|
|
191
|
+
"and", "daystart", "depth", "empty", "executable", "false", "follow", "ignore_readdir_race", "mount", "noignore_readdir_race", "noleaf", "not", "nogroup",
|
|
192
|
+
"nouser", "or", "print", "print0", "prune", "quit", "readable", "true", "writable", "xdev",
|
|
193
|
+
]),
|
|
194
|
+
...BANNERS,
|
|
195
|
+
},
|
|
196
|
+
}), { lacks: ["-f", "-s", "-x"], reads: { "-samefile": val(READ) } }, { lacks: ["-D", "-O", "--help", "--version", "-context", "-printf", "-regextype", "-used", "-xtype", "-fprint", "-fprint0", "-fls", "-fprintf", "-files0-from", "-daystart", "-executable", "-readable", "-writable", "-help", "-version"] }),
|
|
197
|
+
operands: { dash: "file" },
|
|
198
|
+
traversal: { discloses: "names", always: true },
|
|
199
|
+
witness: BINARY,
|
|
200
|
+
};
|
|
201
|
+
const curl = {
|
|
202
|
+
key: "curl",
|
|
203
|
+
grammars: [grammar({
|
|
204
|
+
A: val(LABEL), b: val(INDIRECT), C: val(COUNT), c: val(WRITE), D: val(WRITE), d: val(INDIRECT), E: val(READ), e: val(LABEL),
|
|
205
|
+
F: val(FORM), H: val(HEADER), K: val(READ), m: val(COUNT), o: val(WRITE), P: val(LABEL), Q: val(LABEL), r: val(COUNT),
|
|
206
|
+
T: val(UPLOAD), t: val(LABEL), U: val(LABEL), u: val(LABEL), w: val(INDIRECT), X: val(LABEL), x: val(LABEL), Y: val(COUNT),
|
|
207
|
+
y: val(COUNT), z: val(READ), g: { arity: 0, literalValues: true },
|
|
208
|
+
...switches("#012346aBfGiIjJklLnNOpqRsSvZ"),
|
|
209
|
+
...switches("hMV", { mode: "banner" }),
|
|
210
|
+
}, {
|
|
211
|
+
cacert: val(READ), capath: val(READ), cert: val(READ), config: val(READ), "connect-timeout": val(COUNT), cookie: val(INDIRECT), "cookie-jar": val(WRITE),
|
|
212
|
+
data: val(INDIRECT), "data-ascii": val(INDIRECT), "data-binary": val(INDIRECT), "data-raw": val(LABEL), "data-urlencode": val(FORM), "dump-header": val(WRITE),
|
|
213
|
+
form: val(FORM), "form-string": val(LABEL), header: val(HEADER), key: val(READ), "max-time": val(COUNT), "netrc-file": val(READ), output: val(WRITE),
|
|
214
|
+
proxy: val(LABEL), range: val(COUNT), referer: val(LABEL), request: val(LABEL), resolve: val(LABEL), trace: val(WRITE), "time-cond": val(READ),
|
|
215
|
+
"trace-ascii": val(WRITE), "upload-file": val(UPLOAD), url: val(URL), user: val(LABEL), "user-agent": val(LABEL), "write-out": val(INDIRECT),
|
|
216
|
+
...longSwitches(["append", "compressed", "disable", "fail", "get", "head", "include", "insecure", "junk-session-cookies", "list-only", "location", "netrc", "next", "no-buffer", "parallel", "proxytunnel", "remote-header-name", "remote-name", "remote-time", "show-error", "silent", "use-ascii", "verbose"]), ...BANNERS,
|
|
217
|
+
manual: { arity: 0, mode: "banner" }, globoff: { arity: 0, literalValues: true },
|
|
218
|
+
})],
|
|
219
|
+
operands: { rest: URL },
|
|
220
|
+
witness: BINARY,
|
|
221
|
+
};
|
|
222
|
+
const ls = {
|
|
223
|
+
key: "ls",
|
|
224
|
+
grammars: implementations(grammar(switches("R", { selects: "traversal" }), longSwitches(["recursive"], { selects: "traversal" })), {}, { lacks: ["--recursive"] }),
|
|
225
|
+
operands: { dash: "file", rest: NAMES },
|
|
226
|
+
traversal: { discloses: "names" },
|
|
227
|
+
witness: BINARY,
|
|
228
|
+
};
|
|
229
|
+
const walker = (key, discloses, dashFile) => ({
|
|
230
|
+
key,
|
|
231
|
+
grammars: discloses === "contents" ? [grammar({}, {}, { walksCwdWithoutOperand: true })] : [],
|
|
232
|
+
...(dashFile ? { operands: { dash: "file", ...(discloses === "names" ? { rest: NAMES } : {}) } } : {}),
|
|
233
|
+
traversal: { discloses, always: true },
|
|
234
|
+
witness: BINARY,
|
|
235
|
+
});
|
|
236
|
+
const BANNER_LONGS = ["--version", "--help", "--usage", "-version", "-help"];
|
|
237
|
+
function interpreterGrammar(language, g) {
|
|
238
|
+
const short = {};
|
|
239
|
+
const long = {};
|
|
240
|
+
const dashWords = {};
|
|
241
|
+
const put = (spelling, spec) => {
|
|
242
|
+
if (spelling.startsWith("--"))
|
|
243
|
+
long[spelling.slice(2)] = spec;
|
|
244
|
+
else
|
|
245
|
+
dashWords[spelling.slice(1)] = spec;
|
|
246
|
+
};
|
|
247
|
+
for (const l of g.plain ?? "")
|
|
248
|
+
short[l] = SWITCH;
|
|
249
|
+
for (const l of g.interactive ?? "")
|
|
250
|
+
short[l] = { arity: 0, mode: "interactive" };
|
|
251
|
+
for (const l of g.banner ?? "")
|
|
252
|
+
short[l] = { arity: 0, mode: "banner" };
|
|
253
|
+
for (const l of g.separated ?? "")
|
|
254
|
+
short[l] = val();
|
|
255
|
+
for (const l of g.attached ?? "")
|
|
256
|
+
short[l] = { arity: "attached", ...((g.banner ?? "").includes(l) ? { mode: "banner" } : {}) };
|
|
257
|
+
for (const l of g.file ?? "")
|
|
258
|
+
short[l] = val(file(language), { fillsSlot: true, ...(g.fileEndsOptions === true ? { endsOptions: true } : {}) });
|
|
259
|
+
for (const l of g.module ?? "")
|
|
260
|
+
short[l] = { arity: 1, mode: "names-program", fillsSlot: true, ...(g.fileEndsOptions === true ? { endsOptions: true } : {}) };
|
|
261
|
+
for (const l of g.assignment ?? "")
|
|
262
|
+
short[l] = val(ASSIGNMENT);
|
|
263
|
+
for (const l of g.modules ?? "")
|
|
264
|
+
short[l] = val(file(language));
|
|
265
|
+
for (const l of g.text ?? "")
|
|
266
|
+
short[l] = val(text(language), { fillsSlot: true });
|
|
267
|
+
for (const s of g.longPlain ?? [])
|
|
268
|
+
put(s, SWITCH);
|
|
269
|
+
for (const s of g.longValue ?? [])
|
|
270
|
+
put(s, val());
|
|
271
|
+
for (const s of g.longAttached ?? [])
|
|
272
|
+
put(s, optional());
|
|
273
|
+
for (const s of BANNER_LONGS)
|
|
274
|
+
put(s, { arity: 0, mode: "banner" });
|
|
275
|
+
for (const s of g.longSupplemental ?? [])
|
|
276
|
+
put(s, val(READ));
|
|
277
|
+
for (const s of g.longModules ?? [])
|
|
278
|
+
put(s, val(file(language)));
|
|
279
|
+
for (const s of g.longNamesProgram ?? [])
|
|
280
|
+
put(s, { arity: 0, mode: "names-program" });
|
|
281
|
+
for (const s of g.longFile ?? [])
|
|
282
|
+
put(s, val(file(language), { fillsSlot: true, ...(g.fileEndsOptions === true ? { endsOptions: true } : {}) }));
|
|
283
|
+
for (const s of g.longText ?? [])
|
|
284
|
+
put(s, val(text(language), { fillsSlot: true }));
|
|
285
|
+
return { dialect: "any", short, long, dashWords, afterFirstOperand: "either" };
|
|
286
|
+
}
|
|
287
|
+
const interpreter = (key, language, g, program, stdinWhenUnnamed, extra = {}, departures) => ({
|
|
288
|
+
key,
|
|
289
|
+
versioned: true,
|
|
290
|
+
grammars: departures === undefined ? [interpreterGrammar(language, g)] : implementations(interpreterGrammar(language, g), departures.gnu, departures.bsd),
|
|
291
|
+
...(program === "none" ? {} : { operands: { positional: program === "file" ? [file(language)] : program === "text" ? [text(language)] : [undefined, text(language)] } }),
|
|
292
|
+
delivery: { stdinWhenUnnamed },
|
|
293
|
+
witness: BINARY,
|
|
294
|
+
...extra,
|
|
295
|
+
});
|
|
296
|
+
const PERL = { text: "eEmM", separated: "I", attached: "iCFxDV", plain: "nplawcsStTUWX", banner: "vVh" };
|
|
297
|
+
const RUBY = { text: "e", separated: "IrECKT", attached: "F", plain: "nplawcsSU", banner: "vh" };
|
|
298
|
+
const PYTHON = { text: "c", module: "m", separated: "WXQ", plain: "uBEIsSqbdvxOtR", banner: "Vh?", interactive: "i", fileEndsOptions: true };
|
|
299
|
+
const NODE = {
|
|
300
|
+
longText: ["--eval", "--print"], text: "ep",
|
|
301
|
+
longModules: ["--import", "--loader", "--experimental-loader", "--require"],
|
|
302
|
+
longValue: ["--env-file", "--conditions"],
|
|
303
|
+
longAttached: ["--max-old-space-size"],
|
|
304
|
+
longNamesProgram: ["--test"],
|
|
305
|
+
longPlain: ["--inspect", "--inspect-brk", "--no-warnings", "--trace-warnings", "--watch", "--enable-source-maps", "--experimental-modules", "--no-deprecation", "--check"],
|
|
306
|
+
modules: "r", plain: "c", banner: "vh", interactive: "i",
|
|
307
|
+
};
|
|
308
|
+
const PHP = { longText: ["--run", "--process-begin", "--process-code", "--process-end"], text: "rRBE", file: "fF", separated: "dcz", plain: "nqswl", banner: "vhi", interactive: "a" };
|
|
309
|
+
const LUA = { text: "e", separated: "l", banner: "vh", interactive: "i" };
|
|
310
|
+
const EXPECT = { text: "c", separated: "Db", plain: "dN", banner: "vh", interactive: "i" };
|
|
311
|
+
const AWK = { longText: ["--source"], text: "e", longFile: ["--file", "--exec"], file: "fE", separated: "F", assignment: "v", banner: "V" };
|
|
312
|
+
const POSIX_AWK = { file: "f", separated: "F", assignment: "v" };
|
|
313
|
+
const AWK_IMPLEMENTATIONS = { gnu: {}, bsd: { lacks: ["-E", "--file", "--exec", "--source"] } };
|
|
314
|
+
const JQ = { longFile: ["--from-file"], file: "f", separated: "L", plain: "nrjcsSaCMRe", banner: "h" };
|
|
315
|
+
const BC = { longText: ["--expression"], text: "e", plain: "lqsw", banner: "vh", interactive: "i" };
|
|
316
|
+
const DC = { longText: ["--expression"], text: "e", longFile: ["--file"], file: "f", banner: "hV" };
|
|
317
|
+
const SQLITE = { longText: ["-cmd"], longSupplemental: ["-init"] };
|
|
318
|
+
const PSQL = { longText: ["--command"], text: "c", longFile: ["--file"], file: "f", separated: "hpUdoF", plain: "aeEqtxXwW", banner: "lV?" };
|
|
319
|
+
const OSASCRIPT = { text: "e", separated: "ls", plain: "i", banner: "h" };
|
|
320
|
+
const RSCRIPT = { text: "e", banner: "h" };
|
|
321
|
+
const JULIA = { longText: ["--eval", "--print"], text: "eE", separated: "JLp", plain: "q", banner: "vh", interactive: "i" };
|
|
322
|
+
const GHCI = { text: "e", separated: "io" };
|
|
323
|
+
const GROOVY = { text: "e", separated: "Dcl", plain: "n", banner: "vh", interactive: "i" };
|
|
324
|
+
const BUN = { longText: ["--eval", "--print"], text: "ep", modules: "r", banner: "vh" };
|
|
325
|
+
const launcher = (key, spec = {}, g, extra = {}) => ({
|
|
326
|
+
key,
|
|
327
|
+
grammars: g === undefined ? [] : [g],
|
|
328
|
+
launcher: spec ?? {},
|
|
329
|
+
witness: BINARY,
|
|
330
|
+
...extra,
|
|
331
|
+
});
|
|
332
|
+
const PRIVILEGED = { declared: "runs the program as another user or in another root: the gate does not acquire privileges" };
|
|
333
|
+
const LINUX_NAMESPACE = { declared: "a Linux namespace / scheduling wrapper that needs privileges or a kernel feature the gate host may not have" };
|
|
334
|
+
const SHELL_TEXT_LAUNCHER = { declared: "hands its operands to a shell as text: the row reads no program word whose opens the gate could predict" };
|
|
335
|
+
const WORKDIR = { kind: "path", effect: "names", base: "working-directory" };
|
|
336
|
+
const ROOTDIR = { kind: "path", effect: "names", base: "root" };
|
|
337
|
+
const PROGRAM_SEARCH = { kind: "path", effect: "names", base: "program-search" };
|
|
338
|
+
export const DURATION_SPELLING = /^\d+(?:\.\d+)?[smhd]?$/;
|
|
339
|
+
const BANNER = { arity: 0, mode: "banner" };
|
|
340
|
+
const launcherSwitches = (spellings, banners) => {
|
|
341
|
+
const spec = (x) => (x === "--help" || x === "--version" || banners.includes(x) ? BANNER : SWITCH);
|
|
342
|
+
return {
|
|
343
|
+
short: Object.fromEntries(spellings.filter((x) => !x.startsWith("--")).map((x) => [x.slice(1), spec(x)])),
|
|
344
|
+
long: Object.fromEntries(spellings.filter((x) => x.startsWith("--")).map((x) => [x.slice(2), spec(x)])),
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
const launcherGrammar = (g, extra = {}) => {
|
|
348
|
+
const sw = launcherSwitches(g.switches ?? [], g.banners ?? []);
|
|
349
|
+
const short = { ...sw.short };
|
|
350
|
+
const long = { ...sw.long };
|
|
351
|
+
const put = (spelling, spec) => { if (spelling.startsWith("--"))
|
|
352
|
+
long[spelling.slice(2)] = spec;
|
|
353
|
+
else
|
|
354
|
+
short[spelling.slice(1)] = spec; };
|
|
355
|
+
for (const [spelling, role] of Object.entries(g.values ?? {}))
|
|
356
|
+
put(spelling, val(role));
|
|
357
|
+
for (const [spelling, role] of Object.entries(g.optional ?? {}))
|
|
358
|
+
put(spelling, optional(role));
|
|
359
|
+
for (const spelling of g.shellText ?? [])
|
|
360
|
+
put(spelling, val(SHELL_TEXT));
|
|
361
|
+
for (const spelling of g.shells ?? [])
|
|
362
|
+
put(spelling, { arity: 0, mode: "interactive" });
|
|
363
|
+
return { dialect: "any", short, long, afterFirstOperand: "either", ...extra };
|
|
364
|
+
};
|
|
365
|
+
const launchers = [
|
|
366
|
+
{ key: "env", grammars: implementations(launcherGrammar({
|
|
367
|
+
switches: ["-i", "-v", "--ignore-environment", "--debug", "--list-signal-handling", "--help", "--version"],
|
|
368
|
+
values: { "-u": LABEL, "--unset": LABEL, "-C": WORKDIR, "--chdir": WORKDIR, "-a": LABEL, "--argv0": LABEL, "-P": PROGRAM_SEARCH },
|
|
369
|
+
optional: { "--default-signal": LABEL, "--ignore-signal": LABEL },
|
|
370
|
+
shellText: ["-S", "--split-string"],
|
|
371
|
+
}), { lacks: ["-P"] }, { lacks: ["-a", "--ignore-environment", "--debug", "--list-signal-handling", "--help", "--version", "--unset", "--chdir", "--argv0", "--default-signal", "--ignore-signal", "--split-string"] }), launcher: { assignmentOperands: true, bareDash: true }, witness: BINARY },
|
|
372
|
+
launcher("command", {}, grammar({ p: SWITCH })),
|
|
373
|
+
launcher("builtin"),
|
|
374
|
+
launcher("exec", {}, launcherGrammar({ switches: ["-c", "-l"], values: { "-a": LABEL } })),
|
|
375
|
+
launcher("noglob", {}, undefined, { witness: { declared: "a zsh precommand modifier" } }),
|
|
376
|
+
launcher("nocorrect", {}, undefined, { witness: { declared: "a zsh precommand modifier" } }),
|
|
377
|
+
{ key: "xargs", grammars: implementations(launcherGrammar({
|
|
378
|
+
switches: ["-0", "-r", "-t", "-x", "-p", "-o", "--null", "--no-run-if-empty", "--verbose", "--exit", "--interactive", "--open-tty", "--show-limits", "--help", "--version"],
|
|
379
|
+
values: { "-n": COUNT, "-L": COUNT, "-P": COUNT, "-I": LABEL, "-d": DELIMITER, "-s": COUNT, "-E": LABEL, "--max-args": COUNT, "--max-procs": COUNT, "--delimiter": DELIMITER, "--max-chars": COUNT, "--process-slot-var": LABEL },
|
|
380
|
+
optional: { "-i": LABEL, "-l": COUNT, "--replace": LABEL, "--eof": LABEL, "--max-lines": COUNT },
|
|
381
|
+
}, {}), { reads: { "-a": val(READ, { delivers: "operands" }), "--arg-file": val(READ, { delivers: "operands" }) } }, { lacks: ["-d", "-i", "-l", "-a", "--arg-file", "--null", "--no-run-if-empty", "--verbose", "--exit", "--interactive", "--open-tty", "--show-limits", "--help", "--version", "--max-args", "--max-procs", "--delimiter", "--max-chars", "--process-slot-var", "--replace", "--eof", "--max-lines"] }), launcher: {}, reentry: { kind: "argv", defaultProgram: "echo" }, witness: BINARY },
|
|
382
|
+
launcher("busybox"),
|
|
383
|
+
launcher("sudo", { assignmentOperands: true }, launcherGrammar({
|
|
384
|
+
switches: ["-A", "-b", "-E", "-H", "-K", "-k", "-l", "-n", "-P", "-S", "-V", "-v", "--askpass", "--background", "--preserve-env", "--set-home", "--remove-timestamp", "--reset-timestamp", "--list", "--non-interactive", "--preserve-groups", "--stdin", "--version", "--validate", "--bell", "--help"],
|
|
385
|
+
shells: ["-i", "-s", "--login", "--shell"],
|
|
386
|
+
values: {
|
|
387
|
+
"-u": LABEL, "-g": LABEL, "-U": LABEL, "-C": COUNT, "-D": WORKDIR, "-h": LABEL, "-p": LABEL, "-r": LABEL, "-R": ROOTDIR, "-t": LABEL, "-T": COUNT, "-a": LABEL,
|
|
388
|
+
"--user": LABEL, "--group": LABEL, "--other-user": LABEL, "--close-from": COUNT, "--chdir": WORKDIR, "--host": LABEL, "--prompt": LABEL, "--role": LABEL, "--chroot": ROOTDIR, "--type": LABEL, "--command-timeout": COUNT, "--auth-type": LABEL,
|
|
389
|
+
},
|
|
390
|
+
}), { witness: PRIVILEGED }),
|
|
391
|
+
launcher("doas", {}, launcherGrammar({ switches: ["-L", "-n"], shells: ["-s"], values: { "-a": LABEL, "-u": LABEL, "-C": READ } }), { witness: PRIVILEGED }),
|
|
392
|
+
launcher("pkexec", { whenNoProgram: "shell" }, launcherGrammar({ switches: ["--disable-internal-agent", "--keep-cwd", "--version", "--help"], values: { "--user": LABEL } }), { witness: PRIVILEGED }),
|
|
393
|
+
launcher("su", { shellText: true }, undefined, { witness: PRIVILEGED }),
|
|
394
|
+
launcher("runuser", { shellText: true }, undefined, { witness: PRIVILEGED }),
|
|
395
|
+
launcher("chroot", { requiredOperands: 1, whenNoProgram: "shell" }, undefined, { witness: PRIVILEGED }),
|
|
396
|
+
launcher("setpriv", {}, undefined, { witness: PRIVILEGED }),
|
|
397
|
+
launcher("nohup", {}, grammar({}, BANNERS)),
|
|
398
|
+
{ key: "nice", grammars: implementations(grammar({ n: val(COUNT) }, { adjustment: val(COUNT), ...BANNERS }), {}, { lacks: ["--adjustment", "--help", "--version"] }), launcher: { negativeIntegerIsOwnArgument: true }, witness: BINARY },
|
|
399
|
+
launcher("ionice", {}, launcherGrammar({
|
|
400
|
+
switches: ["-t", "--ignore", "-h", "--help", "-V", "--version"],
|
|
401
|
+
banners: ["-h", "-V"],
|
|
402
|
+
values: { "-c": LABEL, "-n": COUNT, "-p": COUNT, "-P": COUNT, "-u": COUNT, "--class": LABEL, "--classdata": COUNT, "--pid": COUNT, "--pgid": COUNT, "--uid": COUNT },
|
|
403
|
+
}), { witness: LINUX_NAMESPACE }),
|
|
404
|
+
launcher("chrt", { requiredOperands: 1, requiredOperandSpelling: /^\d+$/ }, launcherGrammar({
|
|
405
|
+
switches: ["-b", "-f", "-i", "-o", "-r", "-d", "-m", "-a", "-R", "-v", "--batch", "--fifo", "--idle", "--other", "--rr", "--deadline", "--max", "--all-tasks", "--reset-on-fork", "--verbose", "--help", "--version"],
|
|
406
|
+
values: { "-p": COUNT, "--pid": COUNT, "-T": COUNT, "-P": COUNT, "-D": COUNT, "--sched-runtime": COUNT, "--sched-period": COUNT, "--sched-deadline": COUNT },
|
|
407
|
+
}), { witness: LINUX_NAMESPACE }),
|
|
408
|
+
launcher("taskset", { requiredOperands: 1, requiredOperandSpelling: /^(?:0x)?[\da-f]+$|^[\d,:-]+$/i }, launcherGrammar({ switches: ["-a", "-p", "-c", "--all-tasks", "--pid", "--cpu-list", "--help", "--version"] }), { witness: LINUX_NAMESPACE }),
|
|
409
|
+
{ key: "stdbuf", grammars: implementations(grammar({ i: val(LABEL), o: val(LABEL), e: val(LABEL) }, { input: val(LABEL), output: val(LABEL), error: val(LABEL), ...BANNERS }), {}, { lacks: ["--input", "--output", "--error", "--help", "--version"] }), launcher: {}, witness: BINARY },
|
|
410
|
+
launcher("timeout", { requiredOperands: 1, requiredOperandSpelling: DURATION_SPELLING }, grammar({ v: SWITCH, k: val(COUNT), s: val(LABEL) }, { foreground: SWITCH, "preserve-status": SWITCH, verbose: SWITCH, "kill-after": val(COUNT), signal: val(LABEL), ...BANNERS })),
|
|
411
|
+
{ key: "time", grammars: implementations(grammar({ p: SWITCH, a: SWITCH, v: SWITCH, q: SWITCH, f: val(LABEL), o: val(WRITE) }, { portability: SWITCH, append: SWITCH, verbose: SWITCH, quiet: SWITCH, help: SWITCH, version: SWITCH, format: val(LABEL), output: val(WRITE) }, { stepsDashDash: true }), {}, { lacks: ["-v", "-q", "-f", "--portability", "--append", "--verbose", "--quiet", "--help", "--version", "--format", "--output"] }), launcher: {}, witness: BINARY },
|
|
412
|
+
launcher("watch", { shellText: true }, undefined, { witness: SHELL_TEXT_LAUNCHER }),
|
|
413
|
+
launcher("setsid", {}, launcherGrammar({ switches: ["-c", "-f", "-w", "--ctty", "--fork", "--wait", "--help", "--version"] })),
|
|
414
|
+
launcher("flock", { requiredOperands: 1 }, launcherGrammar({
|
|
415
|
+
switches: ["-s", "-x", "-u", "-n", "-o", "-F", "--shared", "--exclusive", "--unlock", "--nonblock", "--nb", "--close", "--no-fork", "--verbose", "--help", "--version"],
|
|
416
|
+
values: { "-w": COUNT, "-E": COUNT, "--timeout": COUNT, "--wait": COUNT, "--conflict-exit-code": COUNT },
|
|
417
|
+
shellText: ["-c", "--command"],
|
|
418
|
+
}), { operands: { rest: CREATED } }),
|
|
419
|
+
launcher("unshare", { whenNoProgram: "shell" }, launcherGrammar({
|
|
420
|
+
switches: ["-m", "-u", "-i", "-n", "-p", "-U", "-C", "-T", "-f", "-r", "-c", "--mount", "--uts", "--ipc", "--net", "--pid", "--user", "--cgroup", "--time", "--fork", "--map-root-user", "--map-current-user", "--kill-child", "--mount-proc", "--keep-caps", "--help", "--version"],
|
|
421
|
+
values: { "-R": ROOTDIR, "-w": WORKDIR, "-S": LABEL, "-G": LABEL, "--setuid": LABEL, "--setgid": LABEL, "--root": ROOTDIR, "--wd": WORKDIR, "--propagation": LABEL, "--setgroups": LABEL, "--monotonic": COUNT, "--boottime": COUNT, "--map-user": LABEL, "--map-group": LABEL },
|
|
422
|
+
}), { witness: LINUX_NAMESPACE }),
|
|
423
|
+
launcher("nsenter", { whenNoProgram: "shell" }, launcherGrammar({
|
|
424
|
+
switches: ["-a", "-m", "-u", "-i", "-n", "-p", "-U", "-C", "-T", "-F", "-Z", "--all", "--mount", "--uts", "--ipc", "--net", "--pid", "--user", "--cgroup", "--time", "--no-fork", "--preserve-credentials", "--help", "--version"],
|
|
425
|
+
values: { "-t": COUNT, "-S": LABEL, "-G": LABEL, "--target": COUNT, "--setuid": LABEL, "--setgid": LABEL },
|
|
426
|
+
optional: { "-r": ROOTDIR, "-w": WORKDIR, "--root": ROOTDIR, "--wd": WORKDIR },
|
|
427
|
+
}), { witness: LINUX_NAMESPACE }),
|
|
428
|
+
launcher("script", { shellText: true }, launcherGrammar({ shellText: ["-c", "--command"] }), { witness: SHELL_TEXT_LAUNCHER }),
|
|
429
|
+
launcher("numactl", {}, undefined, { witness: LINUX_NAMESPACE }),
|
|
430
|
+
launcher("prlimit", {}, undefined, { witness: LINUX_NAMESPACE }),
|
|
431
|
+
launcher("systemd-run", {}, undefined, { witness: { declared: "hands the program to a service manager" } }),
|
|
432
|
+
launcher("strace", {}, launcherGrammar({
|
|
433
|
+
switches: ["-f", "-c", "-C", "-d", "-D", "-h", "-i", "-k", "-q", "-r", "-t", "-T", "-v", "-V", "-w", "-x", "-y", "-z", "-Z", "-F", "--follow-forks", "--summary-only", "--summary", "--debug", "--help", "--version"],
|
|
434
|
+
banners: ["-h", "-V"],
|
|
435
|
+
values: {
|
|
436
|
+
"-e": LABEL, "-o": WRITE, "-p": COUNT, "-s": COUNT, "-E": ASSIGNMENT, "-P": NAMES, "-S": LABEL, "-a": COUNT, "-b": LABEL, "-I": COUNT, "-u": LABEL, "-X": LABEL, "-O": COUNT, "-U": LABEL,
|
|
437
|
+
"--output": WRITE, "--trace": LABEL, "--expr": LABEL, "--attach": COUNT, "--string-limit": COUNT, "--env": ASSIGNMENT, "--trace-path": NAMES, "--columns": COUNT, "--user": LABEL, "--interruptible": COUNT,
|
|
438
|
+
"--detach-on": LABEL, "--const-print-style": LABEL, "--summary-sort-by": LABEL, "--summary-syscall-overhead": COUNT, "--summary-columns": LABEL,
|
|
439
|
+
},
|
|
440
|
+
}), { witness: LINUX_NAMESPACE }),
|
|
441
|
+
launcher("ltrace", {}, launcherGrammar({
|
|
442
|
+
switches: ["-c", "-C", "-f", "-i", "-L", "-r", "-S", "-t", "-T", "-V", "--demangle", "--help", "--version"],
|
|
443
|
+
banners: ["-V"],
|
|
444
|
+
values: { "-a": COUNT, "-A": COUNT, "-e": LABEL, "-l": NAMES, "-n": COUNT, "-o": WRITE, "-p": COUNT, "-s": COUNT, "-u": LABEL, "-x": LABEL, "-D": LABEL, "-F": READ, "-w": COUNT, "--align": COUNT, "--config": READ, "--debug": LABEL, "--indent": COUNT, "--library": NAMES, "--output": WRITE, "--string-max": COUNT, "--where": COUNT },
|
|
445
|
+
}), { witness: LINUX_NAMESPACE }),
|
|
446
|
+
launcher("valgrind"),
|
|
447
|
+
launcher("firejail", { whenNoProgram: "shell" }, undefined, { witness: LINUX_NAMESPACE }),
|
|
448
|
+
launcher("bwrap", {}, undefined, { witness: LINUX_NAMESPACE }),
|
|
449
|
+
];
|
|
450
|
+
function gitSubcommand(plain, attached, valued, longValued) {
|
|
451
|
+
return { grammar: grammar({ ...switches(plain), ...Object.fromEntries([...attached].map((l) => [l, optional()])), ...Object.fromEntries([...valued].map((l) => [l, l === "m" ? val(MESSAGE) : val()])) }, Object.fromEntries(longValued.map((n) => [n, n === "message" ? val(MESSAGE) : val()]))) };
|
|
452
|
+
}
|
|
453
|
+
const GIT_GREP = {
|
|
454
|
+
grammar: grammar({
|
|
455
|
+
e: val(PATTERN, { fillsSlot: true }), f: val(READ, { fillsSlot: true }), A: val(COUNT), B: val(COUNT), C: val(COUNT), m: val(COUNT),
|
|
456
|
+
O: { arity: "attached", value: LABEL, effect: "executes" },
|
|
457
|
+
...switches("aEFGHIPchilnoqrsvwzL"),
|
|
458
|
+
}, {
|
|
459
|
+
regexp: val(PATTERN, { fillsSlot: true }), file: val(READ, { fillsSlot: true }), "after-context": val(COUNT), "before-context": val(COUNT), context: val(COUNT),
|
|
460
|
+
"max-count": val(COUNT), "max-depth": val(COUNT), threads: val(COUNT), "open-files-in-pager": { arity: "attached", value: LABEL, effect: "executes" },
|
|
461
|
+
...longSwitches(["cached", "untracked", "no-index", "recurse-submodules", "text", "ignore-case", "word-regexp", "invert-match", "line-number", "column", "files-with-matches", "files-without-match", "count", "null", "break", "heading", "show-function", "function-context", "extended-regexp", "basic-regexp", "fixed-strings", "perl-regexp", "all-match", "quiet", "full-name"]),
|
|
462
|
+
}, { walksCwdWithoutOperand: true }),
|
|
463
|
+
operands: { positional: [PATTERN] },
|
|
464
|
+
traversal: { discloses: "contents", always: true },
|
|
465
|
+
};
|
|
466
|
+
const gitObjectSubcommand = (short = {}, long = {}) => ({ grammar: grammar(short, long), operands: { rest: OBJECT_PATH } });
|
|
467
|
+
const git = {
|
|
468
|
+
key: "git",
|
|
469
|
+
grammars: [grammar({ p: SWITCH, P: SWITCH, C: val(WORKDIR), c: val() }, {
|
|
470
|
+
...longSwitches(["paginate", "no-pager", "bare", "no-replace-objects", "literal-pathspecs", "glob-pathspecs", "noglob-pathspecs", "icase-pathspecs", "no-optional-locks"]),
|
|
471
|
+
"git-dir": val(WORKDIR), "work-tree": val(WORKDIR), namespace: val(), "config-env": val(), "super-prefix": val(),
|
|
472
|
+
})],
|
|
473
|
+
subcommands: {
|
|
474
|
+
commit: gitSubcommand("apsnvqeioz", "Su", "mFCct", ["message", "file", "template", "pathspec-from-file", "author", "date", "cleanup", "fixup", "squash", "trailer", "reuse-message", "reedit-message"]),
|
|
475
|
+
tag: gitSubcommand("asfdvle", "n", "mFu", ["message", "file", "local-user", "cleanup", "trailer", "sort", "format", "contains", "no-contains", "points-at", "merged", "no-merged"]),
|
|
476
|
+
merge: gitSubcommand("nqve", "S", "mFsX", ["message", "file", "strategy", "strategy-option", "into-name", "cleanup"]),
|
|
477
|
+
stash: gitSubcommand("pkuaqS", "", "m", ["message", "pathspec-from-file"]),
|
|
478
|
+
grep: GIT_GREP,
|
|
479
|
+
show: gitObjectSubcommand(),
|
|
480
|
+
"cat-file": gitObjectSubcommand(switches("ptsep")),
|
|
481
|
+
archive: gitObjectSubcommand({ o: val(WRITE) }, { output: val(WRITE), format: val(LABEL), prefix: val(LABEL), remote: val(LABEL) }),
|
|
482
|
+
},
|
|
483
|
+
witness: BINARY,
|
|
484
|
+
};
|
|
485
|
+
const noPath = (key, rest, extra = {}) => ({ key, grammars: [], operands: { rest }, witness: BINARY, ...extra });
|
|
486
|
+
const BUILTIN_ONLY = { declared: "a shell builtin with no binary of its own on every host: its words are read by the shell" };
|
|
487
|
+
const noPathRows = [
|
|
488
|
+
noPath("pwd", LABEL, { builtin: "inert" }), noPath("echo", LABEL, { builtin: "inert", grammars: [grammar(switches("neE"), {}, { afterFirstOperand: "operands" })], prints: "words" }), noPath("printf", LABEL, { grammars: [grammar({ v: val(BINDS_NAME) })], prints: "format" }), noPath("whoami", LABEL), noPath("uname", LABEL),
|
|
489
|
+
noPath("which", LABEL), noPath("basename", LABEL), noPath("dirname", LABEL),
|
|
490
|
+
{ key: "tr", grammars: [], operands: { rest: LABEL, stdinBelow: "always" }, witness: BINARY },
|
|
491
|
+
noPath("cal", COUNT), noPath("uptime", LABEL), noPath("id", LABEL), noPath("groups", LABEL), noPath("nproc", LABEL), noPath("locale", LABEL),
|
|
492
|
+
noPath("free", LABEL, { grammars: [grammar({ s: val(COUNT, { mode: "repeats" }) }, { seconds: val(COUNT, { mode: "repeats" }) })] }),
|
|
493
|
+
noPath("true", LABEL, { builtin: "inert" }), noPath("false", LABEL, { builtin: "inert" }), noPath("seq", COUNT), noPath("expr", LABEL), noPath("type", LABEL, { witness: BUILTIN_ONLY }), noPath("sleep", COUNT),
|
|
494
|
+
{ key: "test", grammars: [grammar({ v: val(BINDS_NAME) })], operands: { rest: ENTRY_PROBE, evaluates: true }, witness: BINARY },
|
|
495
|
+
{ key: "[", grammars: [grammar({ v: val(BINDS_NAME) })], operands: { rest: ENTRY_PROBE, evaluates: true }, witness: BINARY },
|
|
496
|
+
];
|
|
497
|
+
const DECLARE_GRAMMAR = grammar({
|
|
498
|
+
i: { arity: 0, assigns: "integer" }, n: { arity: 0, assigns: "reference" }, r: { arity: 0, assigns: "frozen" },
|
|
499
|
+
...switches("aAluc", { assigns: "transformed" }), ...switches("pfFgI", { assigns: "unsettled" }), ...switches("tx"),
|
|
500
|
+
}, {}, { plusShort: { ...switches("afFirtx"), p: { arity: 0, assigns: "unsettled" } } });
|
|
501
|
+
const EXPORT_GRAMMAR = grammar({ ...switches("np"), ...switches("aAf", { assigns: "unsettled" }) });
|
|
502
|
+
const declaration = (key, g, rest = BINDS_NAME, assigns) => ({ key, grammars: [g], operands: { rest }, builtin: "declaration", ...(assigns !== undefined ? { assigns } : {}), witness: BUILTIN_ONLY });
|
|
503
|
+
const nameBinders = [
|
|
504
|
+
{ key: "read", grammars: [grammar({ a: val(BINDS_NAME), p: val(LABEL), d: val(DELIMITER), i: val(LABEL), t: val(COUNT), n: val(COUNT), N: val(COUNT), u: val(COUNT), ...switches("ers") })], operands: { rest: BINDS_NAME }, witness: BUILTIN_ONLY },
|
|
505
|
+
{ key: "getopts", grammars: [], operands: { positional: [LABEL, { kind: "binds-name", asWritten: true }], rest: LABEL }, witness: BUILTIN_ONLY },
|
|
506
|
+
{ key: "wait", grammars: [grammar({ ...switches("fn"), p: val(BINDS_NAME) })], operands: { rest: LABEL }, witness: BUILTIN_ONLY },
|
|
507
|
+
{ key: "unset", grammars: [], operands: { rest: BINDS_NAME }, witness: BUILTIN_ONLY },
|
|
508
|
+
{ key: "let", grammars: [], operands: { rest: { kind: "program-text", language: "arithmetic" } }, witness: BUILTIN_ONLY },
|
|
509
|
+
];
|
|
510
|
+
const assignmentNotPaths = (key) => ({ key, grammars: [], operands: { assignmentArguments: "not-paths" }, witness: { declared: "a build tool / container client: what a NAME=value argument means is the build's or the container's" } });
|
|
511
|
+
const CONTAINER_RUN = {
|
|
512
|
+
grammar: grammar({ v: val(VOLUME), e: val(ASSIGNMENT), w: val(LABEL), u: val(LABEL), p: val(LABEL), h: val(LABEL), l: val(LABEL), m: val(LABEL), ...switches("itdPq") }, {
|
|
513
|
+
volume: val(VOLUME), mount: val(MOUNT), env: val(ASSIGNMENT), "env-file": val(READ), "label-file": val(READ),
|
|
514
|
+
name: val(LABEL), network: val(LABEL), entrypoint: val(LABEL), user: val(LABEL), workdir: val(LABEL), publish: val(LABEL), platform: val(LABEL), hostname: val(LABEL), label: val(LABEL),
|
|
515
|
+
...longSwitches(["rm", "detach", "interactive", "tty", "privileged", "init", "read-only"]),
|
|
516
|
+
}, { afterFirstOperand: "operands" }),
|
|
517
|
+
operands: { assignmentArguments: "not-paths" },
|
|
518
|
+
};
|
|
519
|
+
const containerRuntime = (key) => ({
|
|
520
|
+
key,
|
|
521
|
+
grammars: [grammar({ H: val(LABEL), c: val(LABEL), l: val(LABEL), D: SWITCH }, { host: val(LABEL), context: val(LABEL), "log-level": val(LABEL), config: val(READ), tlscacert: val(READ), tlscert: val(READ), tlskey: val(READ), ...longSwitches(["debug", "tls", "tlsverify"]) })],
|
|
522
|
+
operands: { assignmentArguments: "not-paths" },
|
|
523
|
+
subcommands: { run: CONTAINER_RUN, create: CONTAINER_RUN },
|
|
524
|
+
witness: { declared: "a build tool / container client: what a NAME=value argument means is the build's or the container's" },
|
|
525
|
+
});
|
|
526
|
+
const shellRow = (key, textAt, witness = BINARY, grammars = [], stdin) => ({ key, grammars, reentry: { kind: "shell", text: textAt, ...(stdin !== undefined ? { stdin } : {}) }, witness });
|
|
527
|
+
const shellGrammar = (plain, valued, long = {}) => grammar({ ...switches(plain), ...(plain.includes("s") ? switches("s", { mode: "interactive" }) : {}), ...values(valued, LABEL), c: val(SHELL_TEXT) }, long);
|
|
528
|
+
const posixShellGrammar = (plain, valued) => ({ ...shellGrammar(plain, valued), plusOptions: true });
|
|
529
|
+
const POSIX_SHELL = posixShellGrammar("abCefhimnsuvx", "o");
|
|
530
|
+
const SHELL_GRAMMARS = {
|
|
531
|
+
sh: posixShellGrammar("abefimnsuvxCEI", "o"),
|
|
532
|
+
bash: posixShellGrammar("abefhiklmnprstuvxBCDEHPT", "oO"),
|
|
533
|
+
dash: posixShellGrammar("abefilmnsuvxCEIV", "o"),
|
|
534
|
+
ksh: posixShellGrammar("abefhiklmnprstuvxBCEGH", "o"),
|
|
535
|
+
zsh: posixShellGrammar("adefghiklmnprstuvwxyBCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "o"),
|
|
536
|
+
csh: shellGrammar("defilmnqstvxFVX", ""),
|
|
537
|
+
tcsh: shellGrammar("defilmnqstvxFVX", ""),
|
|
538
|
+
fish: grammar({ ...switches("ilnNP"), ...switches("hv", { mode: "banner" }), c: val(SHELL_TEXT), C: val(), d: val(LABEL), f: val(LABEL), o: val(WRITE), p: val(WRITE) }, { command: val(SHELL_TEXT), ...BANNERS }),
|
|
539
|
+
ash: POSIX_SHELL, mksh: POSIX_SHELL, pdksh: POSIX_SHELL, yash: POSIX_SHELL,
|
|
540
|
+
};
|
|
541
|
+
const SHELLS = ["sh", "bash", "zsh", "dash", "ksh", "fish", "ash", "mksh", "yash", "pdksh", "csh", "tcsh"];
|
|
542
|
+
const codeBodyRows = [
|
|
543
|
+
{ key: "trap", grammars: [grammar(switches("lpP"))], body: "first-operand", witness: BINARY },
|
|
544
|
+
{ key: "alias", grammars: [], body: "assignment-values", witness: BINARY },
|
|
545
|
+
{ key: "mapfile", grammars: [grammar({ ...switches("t"), ...values("dunOcs"), C: val(SHELL_TEXT) })], operands: { rest: BINDS_NAME }, body: "option-values", witness: BINARY },
|
|
546
|
+
{ key: "readarray", grammars: [grammar({ ...switches("t"), ...values("dunOcs"), C: val(SHELL_TEXT) })], operands: { rest: BINDS_NAME }, body: "option-values", witness: BINARY },
|
|
547
|
+
{ key: "compgen", grammars: [grammar({ ...switches("abcdefgjksuv"), ...values("oAGWPSXV"), F: val(COMMAND), C: val(SHELL_TEXT) })], body: "option-values", witness: BINARY },
|
|
548
|
+
{ key: "complete", grammars: [grammar({ ...switches("abcdefgjksuvDEIpr"), ...values("oAGWPSXV"), F: val(COMMAND), C: val(SHELL_TEXT) })], body: "option-values", witness: { declared: "a completion spec runs its command only when a person asks for a completion interactively" } },
|
|
549
|
+
];
|
|
550
|
+
const copyGrammars = (bsdSuffixSwitch) => implementations(grammar({ S: val(LABEL, { effect: "writes" }), t: val(DESTINATION, { fillsLast: true }) }, { "target-directory": val(DESTINATION, { fillsLast: true }), suffix: val(LABEL, { effect: "writes" }), "no-preserve": val(LABEL), sparse: val(LABEL) }), { afterFirstOperand: "options" }, { ...(bsdSuffixSwitch ? { reads: { "-S": SWITCH } } : {}), lacks: [...(bsdSuffixSwitch ? [] : ["-S"]), "-t", "--target-directory", "--suffix", "--no-preserve", "--sparse"], afterFirstOperand: "operands" });
|
|
551
|
+
const writerRows = [
|
|
552
|
+
{ key: "mkdir", grammars: [], operands: { rest: CREATED, dash: "file" }, witness: BINARY },
|
|
553
|
+
{ key: "touch", grammars: implementations(grammar({ h: { arity: 0, writesAt: ["landing", "entry"] } }, { "no-dereference": { arity: 0, writesAt: ["landing", "entry"] } }), {}, { lacks: ["--no-dereference"] }), operands: { rest: TOUCHED, dash: "file" }, witness: BINARY },
|
|
554
|
+
{ key: "rm", grammars: implementations(grammar({ ...switches("rR", { selects: "traversal" }), f: { arity: 0, mode: "forced" } }, { ...longSwitches(["recursive"], { selects: "traversal" }), force: { arity: 0, mode: "forced" } }), {}, { lacks: ["--recursive", "--force"] }), operands: { rest: REMOVED, dash: "file" }, witness: BINARY },
|
|
555
|
+
{ key: "rmdir", grammars: implementations(grammar({ p: { arity: 0, effect: "writes" } }, { parents: { arity: 0, effect: "writes" } }), {}, { lacks: ["--parents"] }), operands: { rest: REMOVED, dash: "file" }, witness: BINARY },
|
|
556
|
+
{ key: "tee", grammars: [], operands: { rest: WRITE, dash: "file" }, witness: BINARY },
|
|
557
|
+
{ key: "cp", grammars: copyGrammars(true), operands: { rest: COPY_SOURCE, last: DESTINATION, dash: "file" }, witness: BINARY },
|
|
558
|
+
{ key: "mv", grammars: copyGrammars(false), operands: { rest: MOVE_SOURCE, last: DESTINATION, dash: "file" }, witness: BINARY },
|
|
559
|
+
];
|
|
560
|
+
const stdinReaders = [
|
|
561
|
+
{ key: "cat", grammars: [], operands: { stdinBelow: 1 }, witness: BINARY },
|
|
562
|
+
{ key: "wc", grammars: [], operands: { stdinBelow: 1 }, witness: BINARY },
|
|
563
|
+
{ key: "comm", grammars: [], operands: { stdinBelow: 2 }, witness: BINARY },
|
|
564
|
+
];
|
|
565
|
+
const SYNTAX = { declared: "shell syntax, not a program: read by the lexer" };
|
|
566
|
+
const block = (key, g = []) => ({ key, grammars: g, syntax: "block", witness: SYNTAX });
|
|
567
|
+
export const PROGRAM_ROWS = [
|
|
568
|
+
head, tail, cut, grepRow("grep"), grepRow("egrep"), grepRow("fgrep"), diff, cmp, sed, date, tar, find, curl,
|
|
569
|
+
ls, walker("du", "names", true), walker("rg", "contents", false), walker("tree", "names", true), walker("ag", "contents", false), walker("ack", "contents", false),
|
|
570
|
+
interpreter("perl", "perl", PERL, "file", true),
|
|
571
|
+
interpreter("ruby", "ruby", RUBY, "file", true),
|
|
572
|
+
interpreter("python", "python", PYTHON, "file", true, { modules: { timeit: text("python") } }),
|
|
573
|
+
interpreter("node", "javascript", NODE, "file", true),
|
|
574
|
+
interpreter("nodejs", "javascript", NODE, "file", true),
|
|
575
|
+
interpreter("php", "php", PHP, "file", true),
|
|
576
|
+
interpreter("lua", "lua", LUA, "file", true),
|
|
577
|
+
interpreter("luajit", "lua", LUA, "file", true),
|
|
578
|
+
interpreter("tclsh", "tcl", {}, "file", true),
|
|
579
|
+
interpreter("wish", "tcl", {}, "file", true, { witness: { declared: "a windowing shell: it opens a display before it reads its script, and the gate host has none" } }),
|
|
580
|
+
interpreter("expect", "expect", EXPECT, "file", true),
|
|
581
|
+
interpreter("awk", "awk", AWK, "text", false, {}, AWK_IMPLEMENTATIONS),
|
|
582
|
+
interpreter("gawk", "awk", AWK, "text", false),
|
|
583
|
+
interpreter("mawk", "awk", POSIX_AWK, "text", false),
|
|
584
|
+
interpreter("nawk", "awk", POSIX_AWK, "text", false),
|
|
585
|
+
interpreter("jq", "jq", JQ, "text", false),
|
|
586
|
+
interpreter("bc", "bc", BC, "none", true),
|
|
587
|
+
interpreter("dc", "dc", DC, "none", true),
|
|
588
|
+
interpreter("sqlite", "sql", SQLITE, "text-second", true),
|
|
589
|
+
interpreter("psql", "sql", PSQL, "none", true, { witness: { declared: "a database client: it connects to a server before it reads a program file or text, and the gate host has no server" } }),
|
|
590
|
+
interpreter("osascript", "applescript", OSASCRIPT, "file", true),
|
|
591
|
+
interpreter("Rscript", "r", RSCRIPT, "file", false),
|
|
592
|
+
interpreter("julia", "julia", JULIA, "file", true),
|
|
593
|
+
interpreter("ghci", "haskell", GHCI, "none", true),
|
|
594
|
+
interpreter("groovy", "groovy", GROOVY, "file", false),
|
|
595
|
+
interpreter("bun", "javascript", BUN, "file", false),
|
|
596
|
+
...launchers,
|
|
597
|
+
git,
|
|
598
|
+
...noPathRows,
|
|
599
|
+
...writerRows,
|
|
600
|
+
...stdinReaders,
|
|
601
|
+
...["declare", "typeset", "local"].map((key) => declaration(key, DECLARE_GRAMMAR)),
|
|
602
|
+
declaration("export", EXPORT_GRAMMAR, { kind: "binds-name", asWritten: true }), declaration("readonly", EXPORT_GRAMMAR, { kind: "binds-name", asWritten: true }, "frozen"),
|
|
603
|
+
...nameBinders,
|
|
604
|
+
...["make", "gmake", "bmake", "cmake", "ninja", "meson"].map(assignmentNotPaths),
|
|
605
|
+
containerRuntime("docker"), containerRuntime("podman"),
|
|
606
|
+
{ key: "pushd", grammars: [], movesBase: "unfollowed", witness: BUILTIN_ONLY },
|
|
607
|
+
{ key: "popd", grammars: [], movesBase: "unfollowed", witness: BUILTIN_ONLY },
|
|
608
|
+
...SHELLS.map((s) => shellRow(s, "c-option", BINARY, [SHELL_GRAMMARS[s]], "script")),
|
|
609
|
+
shellRow("eval", "words", BUILTIN_ONLY), shellRow("source", "file-operand", BUILTIN_ONLY), shellRow(".", "file-operand", BUILTIN_ONLY), shellRow("parallel", "non-option-words", BINARY, [], "script"),
|
|
610
|
+
...codeBodyRows,
|
|
611
|
+
...["for", "select", "case", "esac", "fi", "done", "function", "coproc", "]]", "in"].map((k) => block(k)),
|
|
612
|
+
block("[[", [grammar({ v: val(BINDS_NAME) })]),
|
|
613
|
+
];
|