passport-bridge 0.26.0 → 0.27.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.
Files changed (42) hide show
  1. package/README.md +2 -2
  2. package/dist/blindKind.d.ts +15 -0
  3. package/dist/blindKind.js +5 -0
  4. package/dist/cliChanges.d.ts +12 -4
  5. package/dist/cliChanges.js +26 -15
  6. package/dist/cliGuardState.js +2 -2
  7. package/dist/cliHookBlind.d.ts +15 -0
  8. package/dist/cliHookBlind.js +65 -0
  9. package/dist/cliHookLocal.d.ts +7 -16
  10. package/dist/cliHookLocal.js +75 -97
  11. package/dist/cliHookLocalCode.js +7 -1
  12. package/dist/cliHookLocalFs.d.ts +15 -0
  13. package/dist/cliHookLocalFs.js +77 -0
  14. package/dist/cliHookScripts.d.ts +2 -1
  15. package/dist/cliOutput.js +2 -2
  16. package/dist/cliProjectSummary.d.ts +1 -1
  17. package/dist/cliProjectSummary.js +19 -8
  18. package/dist/cliScriptRead.d.ts +5 -4
  19. package/dist/cliScriptRead.js +3 -2
  20. package/dist/cliSeen.d.ts +24 -15
  21. package/dist/cliSeen.js +34 -16
  22. package/dist/cliSessions.js +20 -6
  23. package/dist/cliSessionsJson.d.ts +48 -0
  24. package/dist/cliSessionsJson.js +40 -10
  25. package/dist/cliSessionsRender.d.ts +4 -0
  26. package/dist/cliSessionsRender.js +42 -8
  27. package/dist/inlineCode.d.ts +35 -0
  28. package/dist/inlineCode.js +201 -0
  29. package/dist/inlineScan.d.ts +23 -0
  30. package/dist/inlineScan.js +389 -0
  31. package/dist/localCommands.d.ts +10 -3
  32. package/dist/localCommands.js +59 -37
  33. package/dist/localFiles.d.ts +38 -2
  34. package/dist/localFiles.js +453 -33
  35. package/dist/localGit.js +53 -17
  36. package/dist/localShared.d.ts +3 -0
  37. package/dist/pluginPin.d.ts +1 -1
  38. package/dist/pluginPin.js +1 -1
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/npm-shrinkwrap.json +2 -2
  42. package/package.json +1 -1
@@ -27,7 +27,30 @@ export function list(raw) {
27
27
  export function oneOf(raw, values) {
28
28
  return typeof raw === "string" && values.includes(raw) ? raw : null;
29
29
  }
30
- /* ------------------------------- the JSON -------------------------------- */
30
+ export function windowOf(raw) {
31
+ const window = record(raw);
32
+ const label = text(window.label, 80);
33
+ if (!label || typeof window.since !== "number" || !Number.isFinite(window.since))
34
+ return null;
35
+ return { since: Math.max(0, window.since), until: time(window.until), label };
36
+ }
37
+ export function workCountsOf(raw) {
38
+ const work = record(raw);
39
+ if (typeof work.productionChanges !== "number")
40
+ return null;
41
+ return {
42
+ sessions: count(work.sessions),
43
+ items: count(work.items),
44
+ actions: count(work.actions),
45
+ changes: count(work.changes),
46
+ productionChanges: count(work.productionChanges),
47
+ unplaced: count(work.unplaced),
48
+ failed: count(work.failed),
49
+ asks: count(work.asks),
50
+ running: count(work.running),
51
+ shipped: count(work.shipped)
52
+ };
53
+ }
31
54
  export const NOTABLE_REASONS = [
32
55
  "failed",
33
56
  "production",
@@ -92,9 +115,20 @@ function pullOf(raw) {
92
115
  url: url && /^https:\/\//.test(url) ? url : null
93
116
  };
94
117
  }
118
+ /** The server's asks for a session or item (shared/askCounts.ts), as sent. */
119
+ function asksOf(raw) {
120
+ const asks = record(raw);
121
+ return {
122
+ total: count(asks.total),
123
+ allowed: count(asks.allowed),
124
+ declined: count(asks.declined),
125
+ expired: count(asks.expired),
126
+ answered: count(asks.answered),
127
+ waiting: count(asks.waiting)
128
+ };
129
+ }
95
130
  function shapeOf(raw) {
96
131
  const shape = record(raw);
97
- const asks = record(shape.asks);
98
132
  return {
99
133
  actions: count(shape.actions),
100
134
  reads: count(shape.reads),
@@ -105,14 +139,7 @@ function shapeOf(raw) {
105
139
  dataChecks: count(shape.dataChecks),
106
140
  undone: count(shape.undone),
107
141
  unchecked: count(shape.unchecked),
108
- asks: {
109
- total: count(asks.total),
110
- allowed: count(asks.allowed),
111
- declined: count(asks.declined),
112
- expired: count(asks.expired),
113
- answered: count(asks.answered),
114
- waiting: count(asks.waiting)
115
- },
142
+ asks: asksOf(shape.asks),
116
143
  apps: list(shape.apps)
117
144
  .map((app) => text(app, 80))
118
145
  .filter((app) => !!app)
@@ -222,6 +249,8 @@ export function ledgerOf(raw) {
222
249
  untilTs: time(ledger.untilTs),
223
250
  total: count(ledger.total),
224
251
  unplaced: count(ledger.unplaced),
252
+ unplacedIncluded: ledger.unplacedIncluded === true,
253
+ window: windowOf(ledger.window),
225
254
  apps: list(ledger.apps).map((entry) => {
226
255
  const app = record(entry);
227
256
  const appKey = text(app.appKey, 80) ?? "";
@@ -306,6 +335,7 @@ export function sessionOf(raw, origin) {
306
335
  unplaced: count(session.unplaced),
307
336
  unchecked: count(session.unchecked),
308
337
  waiting: count(session.waiting),
338
+ asks: session.asks === undefined ? null : asksOf(session.asks),
309
339
  link: sessionLink(origin, id)
310
340
  },
311
341
  outcome: outcome
@@ -24,6 +24,10 @@ export declare function groupHeading(group: WorkGroupJson): string[];
24
24
  /** One work item: its mark and title (with the PR's number), its agents,
25
25
  * its shape, and its link, each wrapped only between parts. */
26
26
  export declare function workItemLines(item: WorkItemJson, term: Term, group?: Pick<WorkGroupJson, "label" | "running" | "items">): string[];
27
+ /** The server's count shape as one line: "12 work items · 2 running · 4
28
+ * Production changes (1 unplaced) · 2 failed · 3 asks". Null from an older
29
+ * server: the CLI never adds up its own. */
30
+ export declare function workLine(work: WorkItemsJson["work"]): string[] | null;
27
31
  export declare function renderWork(page: WorkItemsJson, term: Term, filtered: boolean, more: string | null): string;
28
32
  export declare function renderLedger(ledger: LedgerJson, term: Term, now: number, since: string | undefined, link: string | null): string;
29
33
  /**
@@ -131,6 +131,23 @@ export function workItemLines(item, term, group) {
131
131
  ...(item.link ? [` ${item.link}`] : [])
132
132
  ];
133
133
  }
134
+ /** The server's count shape as one line: "12 work items · 2 running · 4
135
+ * Production changes (1 unplaced) · 2 failed · 3 asks". Null from an older
136
+ * server: the CLI never adds up its own. */
137
+ export function workLine(work) {
138
+ if (!work)
139
+ return null;
140
+ const parts = [countOf(work.items, "work item")];
141
+ if (work.running)
142
+ parts.push(`${work.running.toLocaleString("en-US")} running`);
143
+ if (work.productionChanges)
144
+ parts.push(`${countOf(work.productionChanges, "Production change")}${work.unplaced ? ` (${work.unplaced.toLocaleString("en-US")} unplaced)` : ""}`);
145
+ if (work.failed)
146
+ parts.push(`${work.failed.toLocaleString("en-US")} failed`);
147
+ if (work.asks)
148
+ parts.push(countOf(work.asks, "ask"));
149
+ return parts;
150
+ }
134
151
  export function renderWork(page, term, filtered, more) {
135
152
  if (!page.groups.length) {
136
153
  if (filtered)
@@ -159,7 +176,12 @@ export function renderWork(page, term, filtered, more) {
159
176
  notes.push("Only the latest sessions were read. Narrow it with --since or --project.");
160
177
  if (more)
161
178
  notes.push(`More work in Passport: ${more}`);
162
- return [...sections, ...notes.map((note) => wrap(note, term.width).join("\n"))].join("\n\n");
179
+ // The server's window after its counts ("Last 7 days"); an older server sent none.
180
+ const summary = workLine(page.work);
181
+ const head = summary
182
+ ? [joinParts([...summary, ...(page.window ? [page.window.label] : [])], term.width).join("\n")]
183
+ : [];
184
+ return [...head, ...sections, ...notes.map((note) => wrap(note, term.width).join("\n"))].join("\n\n");
163
185
  }
164
186
  /* --------------------------- Production ledger --------------------------- */
165
187
  const CLASS_WORDS = {
@@ -182,10 +204,16 @@ function commandOf(appKey, tool) {
182
204
  }
183
205
  export function renderLedger(ledger, term, now, since, link) {
184
206
  const arrow = term.unicode ? "→" : "->";
185
- const window = since ? `since ${when(ledger.sinceTs, now) || since}` : "last 7 days";
186
- const lines = joinParts(["Production changes", window, `${countOf(ledger.total, "change")} on confirmed Production`], term.width);
207
+ // The server's label for the window it counted; an older server's, worded here.
208
+ const window = ledger.window?.label ?? (since ? `since ${when(ledger.sinceTs, now) || since}` : "last 7 days");
209
+ // Since the count shape, unplaced changes are among the total; an older
210
+ // server counted confirmed Production only.
211
+ const where = ledger.unplacedIncluded ? "on Production" : "on confirmed Production";
212
+ const lines = joinParts(["Production changes", window, `${countOf(ledger.total, "change")} ${where}`], term.width);
187
213
  if (!ledger.apps.length)
188
- lines.push("", "Nothing your agents ran changed a target you placed in Production.");
214
+ lines.push("", ledger.unplacedIncluded
215
+ ? "Nothing your agents ran changed Production."
216
+ : "Nothing your agents ran changed a target you placed in Production.");
189
217
  for (const app of ledger.apps) {
190
218
  lines.push("", `${app.appKey.startsWith("cli:") ? appName(app.appKey) : app.appName} · ${countOf(app.count, "change")}`);
191
219
  for (const target of app.targets) {
@@ -202,7 +230,8 @@ export function renderLedger(ledger, term, now, since, link) {
202
230
  }
203
231
  }
204
232
  if (ledger.unplaced) {
205
- lines.push("", ...wrap(`${countOf(ledger.unplaced, "unplaced action")}, counted as Production until you place them.`, term.width));
233
+ const among = ledger.unplacedIncluded ? " among them" : "";
234
+ lines.push("", ...wrap(`${countOf(ledger.unplaced, "unplaced action")}${among}, counted as Production until you place them.`, term.width));
206
235
  if (link)
207
236
  lines.push(`Set environments: ${link}`);
208
237
  }
@@ -244,7 +273,12 @@ export function summaryRows(detail) {
244
273
  const what = countOf(session.failed, "action");
245
274
  rows.push(["Failed", first ? (session.failed === 1 ? first : `${what}, first ${first}`) : what]);
246
275
  }
247
- if (approvals.length) {
276
+ // The server's asks (rows that asked plus approvals still holding), the
277
+ // number the web's tile and row show; an older server's approvals otherwise.
278
+ const asked = session.asks ? asksPart(session.asks) : null;
279
+ if (asked)
280
+ rows.push(["Asked", asked]);
281
+ else if (!session.asks && approvals.length) {
248
282
  const of = (status) => approvals.filter((approval) => approval.status === status).length;
249
283
  const parts = [
250
284
  [of("allowed"), "allowed"],
@@ -258,8 +292,8 @@ export function summaryRows(detail) {
258
292
  rows.push(["Asked", `${countOf(approvals.length, "ask")}: ${parts.join(", ")}`]);
259
293
  }
260
294
  if (session.unchecked) {
261
- const programs = outcome.uncheckedPrograms > 1 ? ` from ${countOf(outcome.uncheckedPrograms, "program")}` : "";
262
- rows.push(["Not checked", `${countOf(session.unchecked, "command")}${programs}`]);
295
+ const distinct = outcome.uncheckedPrograms > 1 ? `, ${outcome.uncheckedPrograms.toLocaleString("en-US")} different` : "";
296
+ rows.push(["Not checked", `${countOf(session.unchecked, "command")}${distinct}`]);
263
297
  }
264
298
  if (outcome.backups)
265
299
  rows.push([
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Code an agent hands an interpreter on the line itself (`python3 -c`, `node
3
+ * -e`, `perl -ne`, `ruby -e`) or in a heredoc (`python3 - <<'EOF'`): a read of
4
+ * the project when the side-effect scan (`inlineScan.ts`) finds nothing that
5
+ * writes, runs, loads, or reaches the network, and no path outside the
6
+ * project; blind otherwise, with a reason that names the construct and never
7
+ * the code. Prefer blind to a wrong read: any option, quoting, or size
8
+ * Passport doesn't read leaves it blind. Pure: the caller places paths.
9
+ */
10
+ import { type CommandContext, type LocalAction, type Place, type ShellWord } from "./localShared.js";
11
+ export declare const INLINE_MAX_BYTES: number;
12
+ /** What the caller knows about the machine. */
13
+ export type InlineHost = {
14
+ ctx: CommandContext;
15
+ /** Where a path in the code lands (`~/x` and absolute paths; relative to the working folder). */
16
+ placePath(path: string): Place;
17
+ /** A file or folder in the working folder that a Python import of `module` would load instead. */
18
+ shadowed(module: string): boolean;
19
+ /** Every heredoc on the line has a quoted tag (`<<'EOF'`): the shell expands nothing in it. */
20
+ quotedHeredoc: boolean;
21
+ };
22
+ /** Interpreter code on a line: its program, and a read action or why it stays blind. */
23
+ export type InlineCode = {
24
+ program: string;
25
+ } & ({
26
+ read: LocalAction;
27
+ } | {
28
+ blind: string;
29
+ });
30
+ /**
31
+ * Inline code on this command, or null when there is none. `words` are the
32
+ * command's words (wrappers and assignments included); `heredoc` is the body
33
+ * fed to its program, when it has one.
34
+ */
35
+ export declare function inlineCode(words: ShellWord[], heredoc: string | undefined, host: InlineHost): InlineCode | null;
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Code an agent hands an interpreter on the line itself (`python3 -c`, `node
3
+ * -e`, `perl -ne`, `ruby -e`) or in a heredoc (`python3 - <<'EOF'`): a read of
4
+ * the project when the side-effect scan (`inlineScan.ts`) finds nothing that
5
+ * writes, runs, loads, or reaches the network, and no path outside the
6
+ * project; blind otherwise, with a reason that names the construct and never
7
+ * the code. Prefer blind to a wrong read: any option, quoting, or size
8
+ * Passport doesn't read leaves it blind. Pure: the caller places paths.
9
+ */
10
+ import { unwrap } from "./localCommands.js";
11
+ import { readOf } from "./localShared.js";
12
+ import { quotedStrings, scanNode, scanPython, scanScript } from "./inlineScan.js";
13
+ export const INLINE_MAX_BYTES = 8 * 1024;
14
+ const LANGUAGE = {
15
+ python: "python",
16
+ python3: "python",
17
+ node: "node",
18
+ perl: "perl",
19
+ ruby: "ruby"
20
+ };
21
+ /** Interpreters whose inline code Passport doesn't scan: still inline, always blind. */
22
+ const UNSCANNED = /^(python[\d.]*|deno|bun|nodejs|ruby[\d.]+|perl[\d.]+)$/;
23
+ /** Python: `-c CODE` ends the options; `-` reads the program from stdin. */
24
+ function pythonSource(words) {
25
+ for (let index = 0; index < words.length; index++) {
26
+ const text = words[index].text;
27
+ if (text === "-")
28
+ return { code: [], args: words.slice(index + 1), stdin: true };
29
+ if (!text.startsWith("-"))
30
+ return null;
31
+ if (text === "-m")
32
+ return null;
33
+ if (text === "-W" || text === "-X") {
34
+ index++;
35
+ continue;
36
+ }
37
+ const bundle = /^-([uBEIsSOqbvd]*)(c?)(.*)$/.exec(text);
38
+ if (!bundle[2]) {
39
+ if (bundle[3])
40
+ return { code: [], args: [], problem: "an option Passport doesn't read" };
41
+ continue;
42
+ }
43
+ const code = bundle[3] ? { text: bundle[3] } : words[index + 1];
44
+ if (!code)
45
+ return null;
46
+ return { code: [code.text], args: words.slice(index + (bundle[3] ? 1 : 2)), ...expanding(code) };
47
+ }
48
+ return { code: [], args: [], stdin: true };
49
+ }
50
+ const NODE_OPTIONS = /^--(input-type=(module|commonjs)|no-warnings|no-deprecation|enable-source-maps|experimental-strip-types|max-old-space-size=\d+|stack-trace-limit=\d+)$/;
51
+ /** Node: `-e`/`--eval`/`-p`/`--print CODE`; `-` reads stdin. Loaders and requires stay blind. */
52
+ function nodeSource(words) {
53
+ for (let index = 0; index < words.length; index++) {
54
+ const text = words[index].text;
55
+ if (text === "-")
56
+ return { code: [], args: words.slice(index + 1), stdin: true };
57
+ if (/^(-e|-p|-pe|-ep|--eval|--print)$/.test(text) || /^--(eval|print)=/.test(text)) {
58
+ const inline = /^--(eval|print)=/.test(text) ? { text: text.slice(text.indexOf("=") + 1) } : null;
59
+ const code = inline ?? words[index + 1];
60
+ if (!code)
61
+ return null;
62
+ return { code: [code.text], args: words.slice(index + (inline ? 1 : 2)), ...expanding(code) };
63
+ }
64
+ if (!text.startsWith("-"))
65
+ return null;
66
+ if (!NODE_OPTIONS.test(text))
67
+ return { code: [], args: [], problem: "an option Passport doesn't read" };
68
+ }
69
+ return { code: [], args: [], stdin: true };
70
+ }
71
+ /** Perl and Ruby: bundles like `-lane`, any number of `-e CODE`; `-i`, `-M`, `-r`, `-I` stay blind. */
72
+ function scriptSource(language, words) {
73
+ const code = [];
74
+ let problem;
75
+ let index = 0;
76
+ for (; index < words.length; index++) {
77
+ const text = words[index].text;
78
+ if (text === "--") {
79
+ index++;
80
+ break;
81
+ }
82
+ if (text === "-")
83
+ return { code, args: words.slice(index + 1), stdin: true };
84
+ if (!text.startsWith("-"))
85
+ break;
86
+ if (language === "ruby" && /^--(disable|enable)[=-][\w,-]+$/.test(text))
87
+ continue;
88
+ for (let at = 1; at < text.length; at++) {
89
+ const flag = text[at];
90
+ if ("npalwsv".includes(flag))
91
+ continue;
92
+ if (flag === "W" && language === "ruby") {
93
+ if (/[0-2]/.test(text[at + 1] ?? ""))
94
+ at++;
95
+ continue;
96
+ }
97
+ if ((flag === "l" || flag === "0") && language === "perl") {
98
+ at += /^(x[0-9a-fA-F]*|[0-7]*)/.exec(text.slice(at + 1))[0].length;
99
+ continue;
100
+ }
101
+ if (flag === "e" || flag === "E") {
102
+ const word = at + 1 < text.length ? { text: text.slice(at + 1) } : words[++index];
103
+ if (!word)
104
+ return null;
105
+ code.push(word.text);
106
+ if (word.expands)
107
+ problem = "code built from shell values";
108
+ }
109
+ else if (flag !== "F")
110
+ problem ??= flag === "i" ? "edits files in place" : "an option Passport doesn't read";
111
+ break;
112
+ }
113
+ }
114
+ if (!code.length)
115
+ return problem ? { code, args: [], problem } : null;
116
+ return { code, args: words.slice(index), ...(problem ? { problem } : {}) };
117
+ }
118
+ function expanding(word) {
119
+ return word.expands ? { problem: "code built from shell values" } : {};
120
+ }
121
+ /** Paths the code names: absolute, `~`, `$HOME`, or climbing out with `..`. */
122
+ function pathProblem(scan, code, host) {
123
+ const strings = [...scan.strings, ...quotedStrings(code)];
124
+ for (const raw of strings) {
125
+ const text = raw.replace(/^\$\{?HOME\}?(?=\/|$)/, "~");
126
+ let path = null;
127
+ if (text === "~" || text.startsWith("~/"))
128
+ path = text;
129
+ else if (text.startsWith("~"))
130
+ return "reads outside the project";
131
+ else if (/^\/[^\s/]/.test(text) && !text.includes("\n"))
132
+ path = text;
133
+ else if (/(^|\/)\.\.(\/|$)/.test(text) && !/[\s:]/.test(text))
134
+ path = text;
135
+ if (path === null)
136
+ continue;
137
+ const place = host.placePath(path);
138
+ if (place !== "project" && place !== "project-root" && place !== "temp" && place !== "temp-root")
139
+ return "reads outside the project";
140
+ }
141
+ // A bare "/" handed to something that walks or opens paths is the whole disk.
142
+ if (strings.includes("/") && PATH_CALLS.test(code.replace(/(['"])\/\1\s*\.\s*join\s*\(/g, ""))) {
143
+ return "reads outside the project";
144
+ }
145
+ return null;
146
+ }
147
+ const PATH_CALLS = /\b(walk|listdir|scandir|glob|iglob|Path|open|stat|lstat|exists|isfile|isdir|readdir\w*|readFile\w*|opendir\w*|realpath\w*|resolve|chdir)\s*\(|\bpath\s*\.\s*join\b/;
148
+ /** Arguments the code gets: placed like `cat`'s; Perl and Ruby open them with `<>`/ARGF. */
149
+ function argumentProblem(language, args) {
150
+ if ((language === "perl" || language === "ruby") && args.some((word) => /[|<>&]|^\s|\s$|^-/.test(word.text)))
151
+ return "an argument that names a command";
152
+ return null;
153
+ }
154
+ /**
155
+ * Inline code on this command, or null when there is none. `words` are the
156
+ * command's words (wrappers and assignments included); `heredoc` is the body
157
+ * fed to its program, when it has one.
158
+ */
159
+ export function inlineCode(words, heredoc, host) {
160
+ const unwrapped = unwrap(words);
161
+ if (unwrapped.reason || unwrapped.sudo || !unwrapped.words.length)
162
+ return null;
163
+ const [head, ...rest] = unwrapped.words;
164
+ if (head.expands)
165
+ return null;
166
+ const program = head.text.slice(head.text.lastIndexOf("/") + 1);
167
+ const language = Object.hasOwn(LANGUAGE, program) ? LANGUAGE[program] : undefined;
168
+ if (!language) {
169
+ const flagged = rest.some((word) => /^(-e|-c|-p|-E|--eval|--print)$/.test(word.text)) || rest[0]?.text === "eval";
170
+ return UNSCANNED.test(program) && (flagged || heredoc !== undefined)
171
+ ? { program, blind: "an interpreter Passport doesn't scan" }
172
+ : null;
173
+ }
174
+ const source = language === "python" ? pythonSource(rest) : language === "node" ? nodeSource(rest) : scriptSource(language, rest);
175
+ if (!source)
176
+ return null;
177
+ if (source.stdin && heredoc === undefined)
178
+ return source.problem ? { program, blind: source.problem } : null;
179
+ const blind = (reason) => ({ program, blind: reason });
180
+ if (source.problem)
181
+ return blind(source.problem);
182
+ const code = source.stdin ? heredoc : source.code.join("\n");
183
+ if (source.stdin && !host.quotedHeredoc && /[$`]/.test(code))
184
+ return blind("a heredoc the shell expands");
185
+ if (code.length > INLINE_MAX_BYTES)
186
+ return blind("code over 8 KB");
187
+ if (head.text.includes("/"))
188
+ return blind("an interpreter run by path");
189
+ const scan = language === "python"
190
+ ? scanPython(code, host.shadowed)
191
+ : language === "node"
192
+ ? scanNode(code)
193
+ : scanScript(code, language);
194
+ const problem = scan.problem ?? pathProblem(scan, code, host) ?? argumentProblem(language, source.args);
195
+ if (problem)
196
+ return blind(problem);
197
+ const read = readOf(program, "read", source.args, host.ctx);
198
+ if (read.kind !== "local")
199
+ return blind(read.kind === "unknown" ? read.reason : "arguments Passport can't place");
200
+ return { program, read: read.actions[0] };
201
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The side-effect scan behind `inlineCode.ts`: does a one-liner's code only
3
+ * read? Each scanner returns the first construct that could write, run, load,
4
+ * or reach the network (a reason that names the construct, never the code),
5
+ * or null, and collects the string literals so the caller can place paths.
6
+ *
7
+ * Python's strings and comments tokenize reliably, so names are matched with
8
+ * string contents set aside (f-string contents stay in, they hold code).
9
+ * JavaScript, Perl, and Ruby have regex literals and quote-like operators a
10
+ * small scanner can misread, which could hide a call inside what looks like
11
+ * a string, so their names are matched against the raw code. Imports are
12
+ * allow-listed; everything else is a deny list. When in doubt: blind.
13
+ */
14
+ export type Scan = {
15
+ problem: string | null;
16
+ strings: string[];
17
+ modules: string[];
18
+ };
19
+ /** Strings in the code as written, for the caller's path check (best effort, raw). */
20
+ export declare function quotedStrings(code: string): string[];
21
+ export declare function scanPython(source: string, shadowed: (module: string) => boolean): Scan;
22
+ export declare function scanNode(code: string): Scan;
23
+ export declare function scanScript(code: string, language: "perl" | "ruby"): Scan;