@agentic-kit/permissions 0.0.0-stage → 0.2.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/LICENSE +23 -0
- package/README.md +278 -2
- package/bash/analyze.d.ts +133 -0
- package/bash/analyze.js +442 -0
- package/bash/args.d.ts +45 -0
- package/bash/args.js +145 -0
- package/bash/braces.d.ts +6 -0
- package/bash/braces.js +72 -0
- package/bash/commands.d.ts +14 -0
- package/bash/commands.js +361 -0
- package/bash/file-commands.d.ts +22 -0
- package/bash/file-commands.js +278 -0
- package/bash/flows.d.ts +67 -0
- package/bash/flows.js +208 -0
- package/bash/git.d.ts +7 -0
- package/bash/git.js +163 -0
- package/bash/network.d.ts +24 -0
- package/bash/network.js +295 -0
- package/bash/quoting.d.ts +16 -0
- package/bash/quoting.js +164 -0
- package/bash/system.d.ts +16 -0
- package/bash/system.js +122 -0
- package/bash/tokenize.d.ts +67 -0
- package/bash/tokenize.js +440 -0
- package/bash/words.d.ts +9 -0
- package/bash/words.js +30 -0
- package/bash/wrappers.d.ts +32 -0
- package/bash/wrappers.js +237 -0
- package/classify.d.ts +22 -0
- package/classify.js +259 -0
- package/engine.d.ts +109 -0
- package/engine.js +144 -0
- package/env.d.ts +13 -0
- package/env.js +37 -0
- package/esm/bash/analyze.d.ts +133 -0
- package/esm/bash/analyze.js +405 -0
- package/esm/bash/args.d.ts +45 -0
- package/esm/bash/args.js +135 -0
- package/esm/bash/braces.d.ts +6 -0
- package/esm/bash/braces.js +69 -0
- package/esm/bash/commands.d.ts +14 -0
- package/esm/bash/commands.js +324 -0
- package/esm/bash/file-commands.d.ts +22 -0
- package/esm/bash/file-commands.js +233 -0
- package/esm/bash/flows.d.ts +67 -0
- package/esm/bash/flows.js +203 -0
- package/esm/bash/git.d.ts +7 -0
- package/esm/bash/git.js +127 -0
- package/esm/bash/network.d.ts +24 -0
- package/esm/bash/network.js +282 -0
- package/esm/bash/quoting.d.ts +16 -0
- package/esm/bash/quoting.js +153 -0
- package/esm/bash/system.d.ts +16 -0
- package/esm/bash/system.js +82 -0
- package/esm/bash/tokenize.d.ts +67 -0
- package/esm/bash/tokenize.js +437 -0
- package/esm/bash/words.d.ts +9 -0
- package/esm/bash/words.js +24 -0
- package/esm/bash/wrappers.d.ts +32 -0
- package/esm/bash/wrappers.js +200 -0
- package/esm/classify.d.ts +22 -0
- package/esm/classify.js +223 -0
- package/esm/engine.d.ts +109 -0
- package/esm/engine.js +108 -0
- package/esm/env.d.ts +13 -0
- package/esm/env.js +34 -0
- package/esm/findings.d.ts +7 -0
- package/esm/findings.js +9 -0
- package/esm/glob.d.ts +15 -0
- package/esm/glob.js +69 -0
- package/esm/grants.d.ts +36 -0
- package/esm/grants.js +99 -0
- package/esm/index.d.ts +19 -0
- package/esm/index.js +18 -0
- package/esm/node-fs.d.ts +6 -0
- package/esm/node-fs.js +34 -0
- package/esm/paths.d.ts +43 -0
- package/esm/paths.js +121 -0
- package/esm/policy.d.ts +21 -0
- package/esm/policy.js +85 -0
- package/esm/prompt.d.ts +14 -0
- package/esm/prompt.js +79 -0
- package/esm/roots.d.ts +75 -0
- package/esm/roots.js +148 -0
- package/esm/secret-files.d.ts +16 -0
- package/esm/secret-files.js +84 -0
- package/esm/secrets/collect.d.ts +19 -0
- package/esm/secrets/collect.js +60 -0
- package/esm/secrets/index.d.ts +5 -0
- package/esm/secrets/index.js +5 -0
- package/esm/secrets/parse.d.ts +19 -0
- package/esm/secrets/parse.js +140 -0
- package/esm/secrets/redact-result.d.ts +8 -0
- package/esm/secrets/redact-result.js +67 -0
- package/esm/secrets/rules.d.ts +34 -0
- package/esm/secrets/rules.js +101 -0
- package/esm/secrets/vault.d.ts +48 -0
- package/esm/secrets/vault.js +158 -0
- package/esm/signals.d.ts +14 -0
- package/esm/signals.js +26 -0
- package/esm/tool-input.d.ts +13 -0
- package/esm/tool-input.js +40 -0
- package/esm/types.d.ts +146 -0
- package/esm/types.js +20 -0
- package/findings.d.ts +7 -0
- package/findings.js +13 -0
- package/glob.d.ts +15 -0
- package/glob.js +73 -0
- package/grants.d.ts +36 -0
- package/grants.js +110 -0
- package/index.d.ts +19 -0
- package/index.js +52 -0
- package/node-fs.d.ts +6 -0
- package/node-fs.js +37 -0
- package/package.json +38 -4
- package/paths.d.ts +43 -0
- package/paths.js +164 -0
- package/policy.d.ts +21 -0
- package/policy.js +88 -0
- package/prompt.d.ts +14 -0
- package/prompt.js +83 -0
- package/roots.d.ts +75 -0
- package/roots.js +192 -0
- package/secret-files.d.ts +16 -0
- package/secret-files.js +124 -0
- package/secrets/collect.d.ts +19 -0
- package/secrets/collect.js +96 -0
- package/secrets/index.d.ts +5 -0
- package/secrets/index.js +21 -0
- package/secrets/parse.d.ts +19 -0
- package/secrets/parse.js +145 -0
- package/secrets/redact-result.d.ts +8 -0
- package/secrets/redact-result.js +70 -0
- package/secrets/rules.d.ts +34 -0
- package/secrets/rules.js +107 -0
- package/secrets/vault.d.ts +48 -0
- package/secrets/vault.js +163 -0
- package/signals.d.ts +14 -0
- package/signals.js +29 -0
- package/tool-input.d.ts +13 -0
- package/tool-input.js +46 -0
- package/types.d.ts +146 -0
- package/types.js +24 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quoting and bracket matching for the lexer: where a quote, a substitution or
|
|
3
|
+
* a `${…}` ends, and how `$'…'` decodes. Every helper throws `LexError` on
|
|
4
|
+
* input that does not close, and the lexer turns that into `shell-dynamic`.
|
|
5
|
+
*/
|
|
6
|
+
export class LexError extends Error {
|
|
7
|
+
}
|
|
8
|
+
/** Find the `)` that closes a `(` at `open`, skipping quotes and nested parens. */
|
|
9
|
+
export function matchParen(s, open) {
|
|
10
|
+
let depth = 0;
|
|
11
|
+
for (let i = open; i < s.length; i++) {
|
|
12
|
+
const ch = s[i];
|
|
13
|
+
if (ch === '\\') {
|
|
14
|
+
i++;
|
|
15
|
+
}
|
|
16
|
+
else if (ch === "'") {
|
|
17
|
+
const end = s.indexOf("'", i + 1);
|
|
18
|
+
if (end < 0)
|
|
19
|
+
throw new LexError('unterminated single quote');
|
|
20
|
+
i = end;
|
|
21
|
+
}
|
|
22
|
+
else if (ch === '"') {
|
|
23
|
+
i = skipDouble(s, i);
|
|
24
|
+
}
|
|
25
|
+
else if (ch === '`') {
|
|
26
|
+
i = matchBacktick(s, i);
|
|
27
|
+
}
|
|
28
|
+
else if (ch === '(') {
|
|
29
|
+
depth++;
|
|
30
|
+
}
|
|
31
|
+
else if (ch === ')') {
|
|
32
|
+
depth--;
|
|
33
|
+
if (depth === 0)
|
|
34
|
+
return i;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
throw new LexError('unterminated substitution');
|
|
38
|
+
}
|
|
39
|
+
function skipDouble(s, open) {
|
|
40
|
+
for (let i = open + 1; i < s.length; i++) {
|
|
41
|
+
const ch = s[i];
|
|
42
|
+
if (ch === '\\')
|
|
43
|
+
i++;
|
|
44
|
+
else if (ch === '"')
|
|
45
|
+
return i;
|
|
46
|
+
else if (ch === '$' && s[i + 1] === '(')
|
|
47
|
+
i = matchParen(s, i + 1);
|
|
48
|
+
else if (ch === '`')
|
|
49
|
+
i = matchBacktick(s, i);
|
|
50
|
+
}
|
|
51
|
+
throw new LexError('unterminated double quote');
|
|
52
|
+
}
|
|
53
|
+
export function matchBacktick(s, open) {
|
|
54
|
+
for (let i = open + 1; i < s.length; i++) {
|
|
55
|
+
if (s[i] === '\\')
|
|
56
|
+
i++;
|
|
57
|
+
else if (s[i] === '`')
|
|
58
|
+
return i;
|
|
59
|
+
}
|
|
60
|
+
throw new LexError('unterminated backtick');
|
|
61
|
+
}
|
|
62
|
+
export function matchBrace(s, open) {
|
|
63
|
+
let depth = 0;
|
|
64
|
+
for (let i = open; i < s.length; i++) {
|
|
65
|
+
const ch = s[i];
|
|
66
|
+
if (ch === '\\')
|
|
67
|
+
i++;
|
|
68
|
+
else if (ch === "'") {
|
|
69
|
+
const end = s.indexOf("'", i + 1);
|
|
70
|
+
if (end < 0)
|
|
71
|
+
throw new LexError('unterminated single quote');
|
|
72
|
+
i = end;
|
|
73
|
+
}
|
|
74
|
+
else if (ch === '"')
|
|
75
|
+
i = skipDouble(s, i);
|
|
76
|
+
else if (ch === '{')
|
|
77
|
+
depth++;
|
|
78
|
+
else if (ch === '}') {
|
|
79
|
+
depth--;
|
|
80
|
+
if (depth === 0)
|
|
81
|
+
return i;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
throw new LexError('unterminated ${');
|
|
85
|
+
}
|
|
86
|
+
const ANSI_ESCAPES = {
|
|
87
|
+
n: '\n',
|
|
88
|
+
t: '\t',
|
|
89
|
+
r: '\r',
|
|
90
|
+
a: '\x07',
|
|
91
|
+
b: '\b',
|
|
92
|
+
e: '\x1b',
|
|
93
|
+
E: '\x1b',
|
|
94
|
+
f: '\f',
|
|
95
|
+
v: '\v',
|
|
96
|
+
'\\': '\\',
|
|
97
|
+
"'": "'",
|
|
98
|
+
'"': '"',
|
|
99
|
+
'?': '?'
|
|
100
|
+
};
|
|
101
|
+
/** Decode a `$'…'` body (ANSI-C quoting), so `$'\x72m'` reads as `rm`. */
|
|
102
|
+
export function decodeAnsiC(body) {
|
|
103
|
+
let out = '';
|
|
104
|
+
for (let i = 0; i < body.length; i++) {
|
|
105
|
+
const ch = body[i];
|
|
106
|
+
if (ch !== '\\' || i + 1 >= body.length) {
|
|
107
|
+
out += ch;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const next = body[++i];
|
|
111
|
+
if (ANSI_ESCAPES[next] !== undefined) {
|
|
112
|
+
out += ANSI_ESCAPES[next];
|
|
113
|
+
}
|
|
114
|
+
else if (next === 'x') {
|
|
115
|
+
const hex = /^[0-9a-fA-F]{1,2}/.exec(body.slice(i + 1))?.[0] ?? '';
|
|
116
|
+
out += hex ? String.fromCharCode(parseInt(hex, 16)) : '\\x';
|
|
117
|
+
i += hex.length;
|
|
118
|
+
}
|
|
119
|
+
else if (next === 'u' || next === 'U') {
|
|
120
|
+
const hex = new RegExp(`^[0-9a-fA-F]{1,${next === 'u' ? 4 : 8}}`).exec(body.slice(i + 1))?.[0] ?? '';
|
|
121
|
+
out += hex ? String.fromCodePoint(parseInt(hex, 16)) : `\\${next}`;
|
|
122
|
+
i += hex.length;
|
|
123
|
+
}
|
|
124
|
+
else if (/[0-7]/.test(next)) {
|
|
125
|
+
const oct = /^[0-7]{1,3}/.exec(body.slice(i))?.[0] ?? next;
|
|
126
|
+
out += String.fromCharCode(parseInt(oct, 8));
|
|
127
|
+
i += oct.length - 1;
|
|
128
|
+
}
|
|
129
|
+
else if (next === 'c') {
|
|
130
|
+
out += String.fromCharCode((body.charCodeAt(i + 1) || 64) & 31);
|
|
131
|
+
i++;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
out += `\\${next}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
export function findAnsiClose(s, from) {
|
|
140
|
+
for (let i = from; i < s.length; i++) {
|
|
141
|
+
if (s[i] === '\\')
|
|
142
|
+
i++;
|
|
143
|
+
else if (s[i] === "'")
|
|
144
|
+
return i;
|
|
145
|
+
}
|
|
146
|
+
throw new LexError("unterminated $'");
|
|
147
|
+
}
|
|
148
|
+
export function unescapeBackticks(inner) {
|
|
149
|
+
return inner.replace(/\\([`$\\])/g, '$1');
|
|
150
|
+
}
|
|
151
|
+
export function stripQuotes(text) {
|
|
152
|
+
return text.replace(/^(['"])(.*)\1$/s, '$2');
|
|
153
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands that reach past the project into the machine: jobs and services
|
|
3
|
+
* that outlive the session, the macOS keychain, the clipboard, and archivers
|
|
4
|
+
* that take their file names from stdin.
|
|
5
|
+
*/
|
|
6
|
+
import type { Arg } from './analyze';
|
|
7
|
+
import { type CommandContext } from './args';
|
|
8
|
+
/** `crontab`, `at`, `launchctl load`, `defaults write`: a change that lasts past this session. */
|
|
9
|
+
export declare function persistence(name: string, ctx: CommandContext, rest: readonly Arg[]): void;
|
|
10
|
+
/** `security find-generic-password`, …: a read of the keychain, which the hard-deny list blocks. */
|
|
11
|
+
export declare function security(ctx: CommandContext, rest: readonly Arg[]): void;
|
|
12
|
+
export declare const CLIPBOARD: Set<string>;
|
|
13
|
+
/** The clipboard: a paste shows the model what the user copied, a copy may carry a secret file out. */
|
|
14
|
+
export declare function clipboard(name: string, ctx: CommandContext, rest: readonly Arg[]): void;
|
|
15
|
+
/** `cpio -o`, `tar -T -`, `zip -@`: the file names come from stdin. */
|
|
16
|
+
export declare function namesFromStdin(name: string, rest: readonly Arg[]): boolean;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands that reach past the project into the machine: jobs and services
|
|
3
|
+
* that outlive the session, the macOS keychain, the clipboard, and archivers
|
|
4
|
+
* that take their file names from stdin.
|
|
5
|
+
*/
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { KEYCHAIN_DIR } from '../roots';
|
|
8
|
+
import { generic, literalArg } from './args';
|
|
9
|
+
import { isPathLike } from './words';
|
|
10
|
+
const LAUNCHCTL_LOADS = new Set(['load', 'bootstrap', 'submit', 'enable']);
|
|
11
|
+
/** `crontab`, `at`, `launchctl load`, `defaults write`: a change that lasts past this session. */
|
|
12
|
+
export function persistence(name, ctx, rest) {
|
|
13
|
+
const words = rest.map((a) => a.text);
|
|
14
|
+
const say = (what) => ctx.analyzer.flag('persistence', `it makes a change that outlasts this session: ${what}`);
|
|
15
|
+
if (name === 'crontab' && !words.includes('-l'))
|
|
16
|
+
say('crontab installs or changes cron jobs');
|
|
17
|
+
if ((name === 'at' || name === 'batch') && !words.some((w) => w === '-l' || w === '-c'))
|
|
18
|
+
say(`${name} schedules a command to run later`);
|
|
19
|
+
if (name === 'launchctl') {
|
|
20
|
+
const sub = words.find((w) => !w.startsWith('-'));
|
|
21
|
+
if (sub && LAUNCHCTL_LOADS.has(sub))
|
|
22
|
+
say(`launchctl ${sub} starts a background service`);
|
|
23
|
+
}
|
|
24
|
+
if (name === 'defaults' && words.some((w) => w === 'write' || w === 'import'))
|
|
25
|
+
say('defaults write changes app or system settings');
|
|
26
|
+
generic(ctx, rest.filter((a) => isPathLike(a.text)));
|
|
27
|
+
}
|
|
28
|
+
const KEYCHAIN_READS = new Set(['find-generic-password', 'find-internet-password', 'dump-keychain', 'export']);
|
|
29
|
+
/** `security find-generic-password`, …: a read of the keychain, which the hard-deny list blocks. */
|
|
30
|
+
export function security(ctx, rest) {
|
|
31
|
+
const { analyzer } = ctx;
|
|
32
|
+
const sub = rest.find((a) => !a.text.startsWith('-'));
|
|
33
|
+
const pem = sub?.text === 'find-certificate' && rest.some((a) => /^-[a-zA-Z]*p/.test(a.text));
|
|
34
|
+
if (sub && (KEYCHAIN_READS.has(sub.text) || pem)) {
|
|
35
|
+
analyzer.addPath(literalArg(path.join(analyzer.ctx.homeDir, KEYCHAIN_DIR), `security ${sub.text}`), 'read', true);
|
|
36
|
+
}
|
|
37
|
+
generic(ctx, rest.filter((a) => isPathLike(a.text)));
|
|
38
|
+
}
|
|
39
|
+
export const CLIPBOARD = new Set(['pbcopy', 'pbpaste', 'xclip', 'xsel', 'wl-copy', 'wl-paste']);
|
|
40
|
+
/** xclip options whose value is the next word. */
|
|
41
|
+
const XCLIP_WITH_VALUE = new Set(['-selection', '-sel', '-target', '-t', '-display', '-d', '-loops', '-l']);
|
|
42
|
+
/** The clipboard: a paste shows the model what the user copied, a copy may carry a secret file out. */
|
|
43
|
+
export function clipboard(name, ctx, rest) {
|
|
44
|
+
const { analyzer } = ctx;
|
|
45
|
+
const words = rest.map((a) => a.text);
|
|
46
|
+
const pastes = name === 'pbpaste' ||
|
|
47
|
+
name === 'wl-paste' ||
|
|
48
|
+
(name === 'xclip' && words.some((w) => w === '-o' || w === '-out')) ||
|
|
49
|
+
(name === 'xsel' && (words.some((w) => /^(-[a-zA-Z]*o|--output)$/.test(w)) || (!ctx.stdinFed && !words.includes('-i'))));
|
|
50
|
+
if (pastes) {
|
|
51
|
+
analyzer.flag('clipboard', `it reads the clipboard with ${name}, which may hold anything the user copied`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
analyzer.flag('clipboard', `it puts text on the clipboard with ${name}`);
|
|
55
|
+
const sources = [...analyzer.stdin.sources];
|
|
56
|
+
if (name === 'xclip') {
|
|
57
|
+
for (let k = 0; k < rest.length; k++) {
|
|
58
|
+
if (XCLIP_WITH_VALUE.has(rest[k].text))
|
|
59
|
+
k++;
|
|
60
|
+
else if (!rest[k].text.startsWith('-')) {
|
|
61
|
+
analyzer.addPath(rest[k], 'read', true);
|
|
62
|
+
const abs = rest[k].unknown ? null : analyzer.toAbs(rest[k].text);
|
|
63
|
+
if (abs !== null)
|
|
64
|
+
sources.push({ raw: rest[k].raw, abs });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (sources.length > 0)
|
|
69
|
+
analyzer.tracker.flows.push({ sources, to: { kind: 'clipboard' }, what: name });
|
|
70
|
+
}
|
|
71
|
+
/** `cpio -o`, `tar -T -`, `zip -@`: the file names come from stdin. */
|
|
72
|
+
export function namesFromStdin(name, rest) {
|
|
73
|
+
const words = rest.map((a) => a.text);
|
|
74
|
+
if (name === 'cpio')
|
|
75
|
+
return words.some((w) => /^-[a-zA-Z]*[op]/.test(w) || w === '--create' || w === '--pass-through');
|
|
76
|
+
if (name === 'zip')
|
|
77
|
+
return words.includes('-@');
|
|
78
|
+
if (name === 'tar') {
|
|
79
|
+
return words.some((w, k) => w === '-T-' || w === '--files-from=-' || ((w === '-T' || w === '--files-from') && words[k + 1] === '-'));
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A POSIX-shell lexer that is good enough to find what a command touches.
|
|
3
|
+
*
|
|
4
|
+
* It splits a command into simple commands (on `;`, `&&`, `||`, `|`, `&`,
|
|
5
|
+
* newline and subshell parens), keeps quoting so expansion can be judged, and
|
|
6
|
+
* records redirections and heredocs. Command substitution (`$(…)`, backticks,
|
|
7
|
+
* `<(…)`) is lexed recursively, so the commands inside it are analyzed too.
|
|
8
|
+
*
|
|
9
|
+
* It never executes or expands anything that needs the environment. What it
|
|
10
|
+
* cannot know it marks: a word part is `unknown`, and constructs that hide code
|
|
11
|
+
* add a `dynamic` note. Any lexer error (an unterminated quote) is reported as
|
|
12
|
+
* `error`, and the analyzer turns both into `shell-dynamic`.
|
|
13
|
+
*/
|
|
14
|
+
/** One piece of a word. `quoted` pieces take no globbing, brace or tilde expansion. */
|
|
15
|
+
export type Part = {
|
|
16
|
+
kind: 'lit';
|
|
17
|
+
text: string;
|
|
18
|
+
quoted: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'var';
|
|
21
|
+
name: string;
|
|
22
|
+
quoted: boolean;
|
|
23
|
+
fallback?: string;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'tilde';
|
|
26
|
+
}
|
|
27
|
+
/** `ref` names the variable a complex `${…}` reads (`${TOKEN:0:4}`). */
|
|
28
|
+
| {
|
|
29
|
+
kind: 'unknown';
|
|
30
|
+
ref?: string;
|
|
31
|
+
};
|
|
32
|
+
export interface Word {
|
|
33
|
+
parts: Part[];
|
|
34
|
+
/** The source text of the word. */
|
|
35
|
+
raw: string;
|
|
36
|
+
}
|
|
37
|
+
export interface Redirect {
|
|
38
|
+
op: string;
|
|
39
|
+
fd: number | null;
|
|
40
|
+
/** `null` for an fd duplication (`2>&1`) or a heredoc. */
|
|
41
|
+
target: Word | null;
|
|
42
|
+
}
|
|
43
|
+
export interface Heredoc {
|
|
44
|
+
quoted: boolean;
|
|
45
|
+
body: string;
|
|
46
|
+
}
|
|
47
|
+
export interface SimpleCommand {
|
|
48
|
+
words: Word[];
|
|
49
|
+
redirects: Redirect[];
|
|
50
|
+
heredocs: Heredoc[];
|
|
51
|
+
/** stdin is the previous command's stdout. */
|
|
52
|
+
pipedIn: boolean;
|
|
53
|
+
/** stdin is a heredoc or a here-string. */
|
|
54
|
+
stdinDoc: boolean;
|
|
55
|
+
/** The words after `<<<`. */
|
|
56
|
+
hereStrings: Word[];
|
|
57
|
+
/** The command whose stdout this one reads, or `group` after `( … ) |`. */
|
|
58
|
+
upstream?: SimpleCommand | 'group';
|
|
59
|
+
}
|
|
60
|
+
export interface Lexed {
|
|
61
|
+
commands: SimpleCommand[];
|
|
62
|
+
/** Notes on constructs that run code the analyzer cannot see. */
|
|
63
|
+
dynamic: string[];
|
|
64
|
+
error?: string;
|
|
65
|
+
}
|
|
66
|
+
/** Lex a command. Never throws: a lexer error comes back in `error`. */
|
|
67
|
+
export declare function tokenize(command: string): Lexed;
|