@sema-agent/core 7.58.0 → 7.59.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 +776 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +87 -21
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +18 -6
- package/dist/core/allow-entry.js +16 -8
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +58 -12
- package/dist/core/checkpoint-store.js +18 -6
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +98 -8
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +8 -4
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +31 -3
- package/dist/core/hooks.js +5 -6
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +5 -2
- package/dist/core/locked-config.js +2 -1
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-failure.d.ts +114 -18
- package/dist/core/mcp-failure.js +63 -5
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp.d.ts +12 -8
- package/dist/core/mcp.js +42 -25
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +2 -1
- package/dist/core/mods/kernel/events.d.ts +2 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/stations.d.ts +31 -10
- package/dist/core/mods/stations.js +44 -10
- package/dist/core/mods/tool-call.js +1 -1
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/peer-seat.d.ts +70 -8
- package/dist/core/peer-seat.js +143 -11
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/rewrite-rejudge.d.ts +1 -0
- package/dist/core/rewrite-rejudge.js +2 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/contracts.d.ts +20 -16
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +12 -4
- package/dist/core/runner/gate-exit.js +10 -7
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
- package/dist/core/runner/prepare-config-doors.js +2 -0
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +1 -0
- package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
- package/dist/core/runner/prepare-hands-readface.js +5 -0
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.js +10 -17
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
- package/dist/core/runner/prepare-policy-chain.js +16 -13
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.js +9 -1
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-task.js +4 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +5 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +37 -28
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +2 -5
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +32 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +5 -0
- package/dist/core/task-spec.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +9 -12
- package/dist/engine/harness/agent-harness.d.ts +25 -2
- package/dist/engine/harness/agent-harness.js +41 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +8 -0
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +16 -10
- package/dist/index.js +11 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/index.js +6 -2
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +87 -1
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** One release's pass. */
|
|
2
|
+
interface Pass {
|
|
3
|
+
readonly version: string;
|
|
4
|
+
/** A second here-document header on a line leaves the delimiter the first one set (4.0 keeps the last). */
|
|
5
|
+
readonly firstHeader: boolean;
|
|
6
|
+
/** A `)` right after the delimiter, at depth one, ends the document (`EOF)`). */
|
|
7
|
+
readonly compactClose: boolean;
|
|
8
|
+
/** A body opened `((` is read as an arithmetic expansion's matched pair. */
|
|
9
|
+
readonly arithmeticFirst: boolean;
|
|
10
|
+
/** A backslash-newline in a comment stays in it (4.0 and 4.1 join the next line to the comment). */
|
|
11
|
+
readonly commentKeepsNewline: boolean;
|
|
12
|
+
/** A backslash-newline in a quoted document stays in it (4.x joins every document's lines, whatever the parity). */
|
|
13
|
+
readonly quotedDocumentKeepsNewline: boolean;
|
|
14
|
+
/** The line that ends a document IS the delimiter (4.x: BEGINS with it). */
|
|
15
|
+
readonly exactEnd: boolean;
|
|
16
|
+
/** A blank is passed over while a delimiter word is read (4.0 and 4.1). */
|
|
17
|
+
readonly blankInDelimiter: boolean;
|
|
18
|
+
readonly wordResetsReserved: boolean;
|
|
19
|
+
readonly reservedDo: boolean;
|
|
20
|
+
readonly reservedFour: boolean;
|
|
21
|
+
readonly metaKeepsReserved: boolean;
|
|
22
|
+
/** A `<` that opens no here-document is read again from the next character (4.x reads that character in its place). */
|
|
23
|
+
readonly rereadAfterLess: boolean;
|
|
24
|
+
/** A `$` after a `$` opens nothing. */
|
|
25
|
+
readonly dollarOnce: boolean;
|
|
26
|
+
/** `${…}` reads a `$(`, `${` or `$[` in it as a body of its own. */
|
|
27
|
+
readonly braceNests: boolean;
|
|
28
|
+
/** `${…}` reads a `<(` / `>(` in it as a body of its own (in both pass and pair readers, a `<` / `>` arms it). */
|
|
29
|
+
readonly braceProcessNests: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare const PASSES: readonly Pass[];
|
|
32
|
+
/** One release per distinct reading of the text from `from` on: releases whose differing flags it gives nothing to act on
|
|
33
|
+
* read it alike, so one of them stands for all. A trigger acts on the text from `from` on, as written or with its
|
|
34
|
+
* backslash-newlines removed, exactly when `from` is at or before the last place it does ({@link TextReadings}). */
|
|
35
|
+
export declare function passesFor(text: string, from: number): readonly Pass[];
|
|
36
|
+
/** Is there a `#` at or after `from`? */
|
|
37
|
+
export declare function holdsHashFrom(text: string, from: number): boolean;
|
|
38
|
+
/** Run `read` with the readings of `text` open (kept if `text` is open already): every ask of `text` inside it is
|
|
39
|
+
* answered from one reading of it, which ends with `read`. */
|
|
40
|
+
export declare function whileReading<T>(text: string, read: () => T): T;
|
|
41
|
+
type End = number | "unterminated" | "undelimited";
|
|
42
|
+
/** Where pass `v` closes the body opened at `open` (a `(`): the index just past its `)`. */
|
|
43
|
+
export declare function countingPassEnd(text: string, open: number, v: Pass): End;
|
|
44
|
+
/** Where release `v` (and 3.2 as 4.0, 5.2 as 5.1) closes the `${…}` opened at `open` (a `{`): at the first `}` its pair
|
|
45
|
+
* reader meets — bash 5.3's `${ list; }` is to them a parameter expansion that ends there. */
|
|
46
|
+
export declare function bracePassEnd(text: string, open: number, v: Pass): End;
|
|
47
|
+
/** A `((` whose second `(` stands at `second` opens an arithmetic command when its matched pair is followed at once by the
|
|
48
|
+
* closing `)` (`parse_arith_cmd`; otherwise it is two subshell parentheses): the index just past that `)`, or `undefined`. */
|
|
49
|
+
export declare function arithmeticCommandEnd(text: string, second: number): number | undefined;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import { shellWordsOf } from "./shell-words.js";
|
|
2
|
+
const FLAG_NAMES = ["firstHeader", "compactClose", "arithmeticFirst", "commentKeepsNewline", "quotedDocumentKeepsNewline", "exactEnd", "blankInDelimiter", "wordResetsReserved", "reservedDo", "reservedFour", "metaKeepsReserved", "rereadAfterLess", "dollarOnce", "braceNests", "braceProcessNests"];
|
|
3
|
+
const PASS_FLAGS = [
|
|
4
|
+
["4.0", "000000100000000"],
|
|
5
|
+
["4.1", "110000100000000"],
|
|
6
|
+
["4.2", "111100000000010"],
|
|
7
|
+
["4.3", "111100011000010"],
|
|
8
|
+
["4.4", "111100011100010"],
|
|
9
|
+
["5.0", "111111011111111"],
|
|
10
|
+
["5.1", "111111011111111"],
|
|
11
|
+
];
|
|
12
|
+
export const PASSES = PASS_FLAGS.map(([version, bits]) => Object.freeze({ version, ...Object.fromEntries(FLAG_NAMES.map((n, k) => [n, bits[k] === "1"])) }));
|
|
13
|
+
const RESERVED_FLAGS = ["wordResetsReserved", "reservedDo", "reservedFour", "metaKeepsReserved"];
|
|
14
|
+
const FLAG_TRIGGERS = [
|
|
15
|
+
[/</, ["firstHeader", "compactClose", "quotedDocumentKeepsNewline", "exactEnd", "blankInDelimiter", "rereadAfterLess"]],
|
|
16
|
+
[/\(\(/, ["arithmeticFirst"]],
|
|
17
|
+
[/[\s;&|()<>]#/, ["commentKeepsNewline", ...RESERVED_FLAGS]],
|
|
18
|
+
[/case/, RESERVED_FLAGS],
|
|
19
|
+
[/\$/, [...RESERVED_FLAGS, "dollarOnce", "braceNests", "braceProcessNests"]],
|
|
20
|
+
];
|
|
21
|
+
export function passesFor(text, from) {
|
|
22
|
+
const last = readingsOf(text).triggerLast();
|
|
23
|
+
let triggered = 0;
|
|
24
|
+
for (let k = 0; k < FLAG_TRIGGERS.length; k++)
|
|
25
|
+
if (from <= last[k])
|
|
26
|
+
triggered |= 1 << k;
|
|
27
|
+
const known = PASSES_BY_TRIGGERS.get(triggered);
|
|
28
|
+
if (known !== undefined)
|
|
29
|
+
return known;
|
|
30
|
+
const live = new Set(FLAG_TRIGGERS.filter((_, k) => (triggered & (1 << k)) !== 0).flatMap(([, flags]) => flags));
|
|
31
|
+
const seen = new Map();
|
|
32
|
+
for (const pass of PASSES) {
|
|
33
|
+
const key = FLAG_NAMES.map((n) => (live.has(n) && pass[n] ? "1" : "0")).join("");
|
|
34
|
+
if (!seen.has(key))
|
|
35
|
+
seen.set(key, pass);
|
|
36
|
+
}
|
|
37
|
+
const passes = Object.freeze([...seen.values()]);
|
|
38
|
+
PASSES_BY_TRIGGERS.set(triggered, passes);
|
|
39
|
+
return passes;
|
|
40
|
+
}
|
|
41
|
+
const PASSES_BY_TRIGGERS = new Map();
|
|
42
|
+
export function holdsHashFrom(text, from) {
|
|
43
|
+
return from <= readingsOf(text).hashLast();
|
|
44
|
+
}
|
|
45
|
+
function lastMatchStart(re, s) {
|
|
46
|
+
const g = new RegExp(re.source, "g");
|
|
47
|
+
for (let width = 64;; width *= 2) {
|
|
48
|
+
const from = Math.max(0, s.length - width);
|
|
49
|
+
const tail = s.slice(from);
|
|
50
|
+
let last = -1;
|
|
51
|
+
g.lastIndex = 0;
|
|
52
|
+
for (let m = g.exec(tail); m !== null; m = g.exec(tail)) {
|
|
53
|
+
last = m.index;
|
|
54
|
+
g.lastIndex = m.index + 1;
|
|
55
|
+
}
|
|
56
|
+
if (last >= 0)
|
|
57
|
+
return from + last;
|
|
58
|
+
if (from === 0)
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class TextReadings {
|
|
63
|
+
text;
|
|
64
|
+
triggers;
|
|
65
|
+
hash;
|
|
66
|
+
pairs;
|
|
67
|
+
constructor(text) {
|
|
68
|
+
this.text = text;
|
|
69
|
+
}
|
|
70
|
+
triggerLast() {
|
|
71
|
+
if (this.triggers !== undefined)
|
|
72
|
+
return this.triggers;
|
|
73
|
+
const text = this.text;
|
|
74
|
+
const removedAt = [];
|
|
75
|
+
let joined = "";
|
|
76
|
+
let from = 0;
|
|
77
|
+
for (let p = text.indexOf("\\\n"); p >= 0; p = text.indexOf("\\\n", p + 2)) {
|
|
78
|
+
joined += text.slice(from, p);
|
|
79
|
+
removedAt.push(joined.length);
|
|
80
|
+
from = p + 2;
|
|
81
|
+
}
|
|
82
|
+
joined += text.slice(from);
|
|
83
|
+
const inText = (k) => { let removed = 0; while (removed < removedAt.length && removedAt[removed] <= k)
|
|
84
|
+
removed++; return k + 2 * removed; };
|
|
85
|
+
this.triggers = FLAG_TRIGGERS.map(([re]) => {
|
|
86
|
+
const inJoined = lastMatchStart(re, joined);
|
|
87
|
+
return Math.max(lastMatchStart(re, text), inJoined < 0 ? -1 : inText(inJoined));
|
|
88
|
+
});
|
|
89
|
+
return this.triggers;
|
|
90
|
+
}
|
|
91
|
+
hashLast() { return (this.hash ??= this.text.lastIndexOf("#")); }
|
|
92
|
+
pairEnds() { return (this.pairs ??= new PairEnds(this.text.length)); }
|
|
93
|
+
}
|
|
94
|
+
const OPEN = [];
|
|
95
|
+
export function whileReading(text, read) {
|
|
96
|
+
if (openReadingsOf(text) !== undefined)
|
|
97
|
+
return read();
|
|
98
|
+
OPEN.push(new TextReadings(text));
|
|
99
|
+
try {
|
|
100
|
+
return read();
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
OPEN.pop();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function openReadingsOf(text) {
|
|
107
|
+
for (let k = OPEN.length - 1; k >= 0; k--)
|
|
108
|
+
if (OPEN[k].text === text)
|
|
109
|
+
return OPEN[k];
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
function readingsOf(text) {
|
|
113
|
+
return openReadingsOf(text) ?? new TextReadings(text);
|
|
114
|
+
}
|
|
115
|
+
class PairEnds {
|
|
116
|
+
known;
|
|
117
|
+
places = [];
|
|
118
|
+
depths = [];
|
|
119
|
+
constructor(length) { this.known = new Int32Array(length + 1); }
|
|
120
|
+
at(p) {
|
|
121
|
+
const k = this.known[p];
|
|
122
|
+
return k === 0 ? undefined : k === -1 ? "unterminated" : k === -2 ? "undelimited" : k;
|
|
123
|
+
}
|
|
124
|
+
stand(p, depth) { this.places.push(p); this.depths.push(depth); }
|
|
125
|
+
out(depth, end) {
|
|
126
|
+
while (this.depths.length > 0 && this.depths[this.depths.length - 1] > depth) {
|
|
127
|
+
this.depths.pop();
|
|
128
|
+
this.known[this.places.pop()] = end;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
ended(end) {
|
|
132
|
+
if (this.places.length === 0)
|
|
133
|
+
return;
|
|
134
|
+
const k = end === "unterminated" ? -1 : end === "undelimited" ? -2 : end;
|
|
135
|
+
for (let i = 0; i < this.places.length; i++)
|
|
136
|
+
this.known[this.places[i]] = k;
|
|
137
|
+
this.places = [];
|
|
138
|
+
this.depths = [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const KEEPS_RESERVED = shellWordsOf("pass_keeps_reserved");
|
|
142
|
+
const BREAK = new Set("()<>;&| \t\n");
|
|
143
|
+
const META = new Set("()<>;&|");
|
|
144
|
+
const QUOTE = "\"`'";
|
|
145
|
+
const PASS_NESTING_MAX = 64;
|
|
146
|
+
const EOF = "";
|
|
147
|
+
class Input {
|
|
148
|
+
text;
|
|
149
|
+
p;
|
|
150
|
+
last = 0;
|
|
151
|
+
constructor(text, from) {
|
|
152
|
+
this.text = text;
|
|
153
|
+
this.p = from;
|
|
154
|
+
}
|
|
155
|
+
getc(remove) {
|
|
156
|
+
while (this.p < this.text.length) {
|
|
157
|
+
if (remove && this.text[this.p] === "\\" && this.text[this.p + 1] === "\n") {
|
|
158
|
+
this.p += 2;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
this.last = this.p;
|
|
162
|
+
return this.text[this.p++];
|
|
163
|
+
}
|
|
164
|
+
return EOF;
|
|
165
|
+
}
|
|
166
|
+
unget(c) { if (c !== EOF)
|
|
167
|
+
this.p = this.last; }
|
|
168
|
+
}
|
|
169
|
+
function quoteRemoved(raw) {
|
|
170
|
+
let out = "";
|
|
171
|
+
let q;
|
|
172
|
+
for (let i = 0; i < raw.length; i++) {
|
|
173
|
+
const c = raw[i];
|
|
174
|
+
if (q === "'") {
|
|
175
|
+
if (c === "'")
|
|
176
|
+
q = undefined;
|
|
177
|
+
else
|
|
178
|
+
out += c;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (c === "\\" && (q === undefined || "$`\"\\\n".includes(raw[i + 1] ?? ""))) {
|
|
182
|
+
out += raw[++i] ?? "";
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (c === "'" && q === undefined) {
|
|
186
|
+
q = c;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (c === "\"") {
|
|
190
|
+
q = q === undefined ? c : undefined;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
out += c;
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
function matchedPair(input, v, qc, open, close, o, level, ends) {
|
|
198
|
+
if (level > PASS_NESTING_MAX)
|
|
199
|
+
return "undelimited";
|
|
200
|
+
let count = 1;
|
|
201
|
+
let passNext = false;
|
|
202
|
+
let wasDollar = false;
|
|
203
|
+
let wasAngle = false;
|
|
204
|
+
for (;;) {
|
|
205
|
+
if (ends !== undefined && !passNext && !wasDollar && !wasAngle) {
|
|
206
|
+
const known = ends.at(input.p);
|
|
207
|
+
if (known !== undefined) {
|
|
208
|
+
if (typeof known !== "number")
|
|
209
|
+
return known;
|
|
210
|
+
input.p = known;
|
|
211
|
+
ends.out(--count, known);
|
|
212
|
+
if (count === 0)
|
|
213
|
+
return known;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
ends.stand(input.p, count);
|
|
217
|
+
}
|
|
218
|
+
const ch = input.getc(qc !== "'" && !passNext);
|
|
219
|
+
if (ch === EOF)
|
|
220
|
+
return "unterminated";
|
|
221
|
+
if (passNext) {
|
|
222
|
+
passNext = false;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (ch === "\x01" || ch === "\x7f")
|
|
226
|
+
return "undelimited";
|
|
227
|
+
if (ch === close) {
|
|
228
|
+
count--;
|
|
229
|
+
ends?.out(count, input.p);
|
|
230
|
+
}
|
|
231
|
+
else if (open !== close && wasDollar && open === "{" && ch === open)
|
|
232
|
+
count++;
|
|
233
|
+
else if (o.firstClose !== true && ch === open)
|
|
234
|
+
count++;
|
|
235
|
+
if (count === 0)
|
|
236
|
+
return input.p;
|
|
237
|
+
if (open === "'") {
|
|
238
|
+
if (o.allowEscape === true && ch === "\\")
|
|
239
|
+
passNext = true;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (ch === "\\")
|
|
243
|
+
passNext = true;
|
|
244
|
+
let inner;
|
|
245
|
+
if (open !== close) {
|
|
246
|
+
if (QUOTE.includes(ch))
|
|
247
|
+
inner = matchedPair(input, v, ch, ch, ch, { allowEscape: wasDollar && ch === "'" }, level + 1);
|
|
248
|
+
else if (o.dollarBrace === true && wasDollar && "({[".includes(ch))
|
|
249
|
+
inner = dollarWord(input, v, ch, open, () => count--, level);
|
|
250
|
+
else if (o.dollarBrace === true && wasAngle && ch === "(")
|
|
251
|
+
inner = dollarWord(input, v, ch, open, () => count--, level);
|
|
252
|
+
}
|
|
253
|
+
else if (open === "\"" && ch === "`")
|
|
254
|
+
inner = matchedPair(input, v, "", "`", "`", {}, level + 1);
|
|
255
|
+
else if (open !== "`" && wasDollar && "({[".includes(ch))
|
|
256
|
+
inner = dollarWord(input, v, ch, open, () => count--, level);
|
|
257
|
+
if (inner !== undefined && typeof inner !== "number")
|
|
258
|
+
return inner;
|
|
259
|
+
wasAngle = v.braceProcessNests && (ch === "<" || ch === ">") && !wasAngle;
|
|
260
|
+
wasDollar = ch === "$" && !(v.dollarOnce && wasDollar);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function dollarWord(input, v, ch, open, undo, level) {
|
|
264
|
+
if (open === ch)
|
|
265
|
+
undo();
|
|
266
|
+
if (ch === "(")
|
|
267
|
+
return countingPass(input, v, level + 1);
|
|
268
|
+
return ch === "{" ? matchedPair(input, v, "", "{", "}", { firstClose: true, dollarBrace: v.braceNests }, level + 1) : matchedPair(input, v, "", "[", "]", {}, level + 1);
|
|
269
|
+
}
|
|
270
|
+
class ReadText {
|
|
271
|
+
chars = [];
|
|
272
|
+
base = 0;
|
|
273
|
+
get length() { return this.base + this.chars.length; }
|
|
274
|
+
at(i) { return this.chars[i - this.base]; }
|
|
275
|
+
push(c) { this.chars.push(c); }
|
|
276
|
+
pop() { this.chars.pop(); }
|
|
277
|
+
from(i) { return this.chars.slice(i - this.base).join(""); }
|
|
278
|
+
tail(n) { return this.chars.slice(-n).join(""); }
|
|
279
|
+
keepFrom(i) { if (this.chars.length > 8192 && i - this.base > 4096) {
|
|
280
|
+
this.chars = this.chars.slice(i - this.base);
|
|
281
|
+
this.base = i;
|
|
282
|
+
} }
|
|
283
|
+
}
|
|
284
|
+
function countingPass(input, v, level) {
|
|
285
|
+
if (level > PASS_NESTING_MAX)
|
|
286
|
+
return "undelimited";
|
|
287
|
+
if (v.arithmeticFirst && input.text[input.p] === "(")
|
|
288
|
+
return matchedPair(input, v, "", "(", ")", {}, level + 1);
|
|
289
|
+
let count = 1;
|
|
290
|
+
let reservedOk = true;
|
|
291
|
+
let inComment = false;
|
|
292
|
+
let passNext = false;
|
|
293
|
+
let inDocument = false;
|
|
294
|
+
let readingDelimiter = false;
|
|
295
|
+
let stripTabs = false;
|
|
296
|
+
let quotedDocument = false;
|
|
297
|
+
let inWord = false;
|
|
298
|
+
let wasDollar = false;
|
|
299
|
+
let rwlen = 0;
|
|
300
|
+
let wlen = 0;
|
|
301
|
+
let delimiter;
|
|
302
|
+
let firstind = -1;
|
|
303
|
+
const ret = new ReadText();
|
|
304
|
+
const append = (from) => { for (let k = from; k < input.p; k++)
|
|
305
|
+
ret.push(input.text[k]); };
|
|
306
|
+
const lineHas = (exact) => {
|
|
307
|
+
let t = firstind;
|
|
308
|
+
while (stripTabs && ret.at(t) === "\t")
|
|
309
|
+
t++;
|
|
310
|
+
const d = delimiter;
|
|
311
|
+
if (exact ? ret.length - t !== d.length : ret.length - t < d.length)
|
|
312
|
+
return false;
|
|
313
|
+
for (let k = 0; k < d.length; k++)
|
|
314
|
+
if (ret.at(t + k) !== d[k])
|
|
315
|
+
return false;
|
|
316
|
+
return true;
|
|
317
|
+
};
|
|
318
|
+
const documentEnds = () => { inDocument = stripTabs = quotedDocument = false; if (v.firstHeader)
|
|
319
|
+
delimiter = undefined; firstind = -1; };
|
|
320
|
+
for (;;) {
|
|
321
|
+
let ch = input.getc(!passNext && !(v.commentKeepsNewline && inComment) && !(v.quotedDocumentKeepsNewline && quotedDocument));
|
|
322
|
+
let at = input.last;
|
|
323
|
+
if (ch === EOF)
|
|
324
|
+
return "unterminated";
|
|
325
|
+
if (ch === "\n") {
|
|
326
|
+
ret.keepFrom(firstind >= 0 ? firstind : ret.length - 4);
|
|
327
|
+
if (readingDelimiter && delimiter !== undefined) {
|
|
328
|
+
readingDelimiter = false;
|
|
329
|
+
inDocument = true;
|
|
330
|
+
firstind = ret.length + 1;
|
|
331
|
+
}
|
|
332
|
+
else if (inDocument) {
|
|
333
|
+
if (lineHas(v.exactEnd))
|
|
334
|
+
documentEnds();
|
|
335
|
+
else
|
|
336
|
+
firstind = ret.length + 1;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (v.compactClose && inDocument && ch === ")" && count === 1 && lineHas(true))
|
|
340
|
+
documentEnds();
|
|
341
|
+
if (inComment || inDocument) {
|
|
342
|
+
ret.push(ch);
|
|
343
|
+
if (inComment && ch === "\n")
|
|
344
|
+
inComment = false;
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (passNext) {
|
|
348
|
+
passNext = false;
|
|
349
|
+
if (ch === "\n")
|
|
350
|
+
ret.pop();
|
|
351
|
+
else
|
|
352
|
+
ret.push(ch);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
const brk = BREAK.has(ch);
|
|
356
|
+
if (brk)
|
|
357
|
+
inWord = false;
|
|
358
|
+
else if (inWord)
|
|
359
|
+
wlen++;
|
|
360
|
+
else {
|
|
361
|
+
inWord = true;
|
|
362
|
+
wlen = 0;
|
|
363
|
+
if (v.wordResetsReserved && reservedOk)
|
|
364
|
+
rwlen = 0;
|
|
365
|
+
}
|
|
366
|
+
if ((ch === " " || ch === "\t") && (v.blankInDelimiter || !readingDelimiter) && rwlen === 0) {
|
|
367
|
+
ret.push(ch);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (readingDelimiter) {
|
|
371
|
+
if (firstind === -1 && !brk)
|
|
372
|
+
firstind = ret.length;
|
|
373
|
+
else if (firstind >= 0 && brk) {
|
|
374
|
+
if (delimiter === undefined || !v.firstHeader) {
|
|
375
|
+
const raw = ret.from(firstind);
|
|
376
|
+
delimiter = quoteRemoved(raw);
|
|
377
|
+
if (delimiter !== raw)
|
|
378
|
+
quotedDocument = true;
|
|
379
|
+
}
|
|
380
|
+
if (ch === "\n") {
|
|
381
|
+
inDocument = true;
|
|
382
|
+
readingDelimiter = false;
|
|
383
|
+
firstind = ret.length + 1;
|
|
384
|
+
}
|
|
385
|
+
else
|
|
386
|
+
firstind = -1;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (!reservedOk && (META.has(ch) || ch === "\n")) {
|
|
390
|
+
const peek = input.getc(true);
|
|
391
|
+
if (ch === peek && "&|;".includes(ch)) {
|
|
392
|
+
ret.push(ch);
|
|
393
|
+
ret.push(peek);
|
|
394
|
+
reservedOk = true;
|
|
395
|
+
rwlen = 0;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
input.unget(peek);
|
|
399
|
+
if (ch === "\n" || ";&|".includes(ch)) {
|
|
400
|
+
ret.push(ch);
|
|
401
|
+
reservedOk = true;
|
|
402
|
+
rwlen = 0;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (reservedOk) {
|
|
407
|
+
if (ch >= "a" && ch <= "z") {
|
|
408
|
+
ret.push(ch);
|
|
409
|
+
rwlen++;
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if (rwlen === 4 && brk) {
|
|
413
|
+
const word = ret.tail(4);
|
|
414
|
+
if (word === "case")
|
|
415
|
+
return "undelimited";
|
|
416
|
+
if (v.reservedFour && KEEPS_RESERVED.has(word))
|
|
417
|
+
rwlen = 0;
|
|
418
|
+
else if (v.metaKeepsReserved && META.has(ch))
|
|
419
|
+
rwlen = 0;
|
|
420
|
+
else
|
|
421
|
+
reservedOk = false;
|
|
422
|
+
}
|
|
423
|
+
else if (ch === "#" && (rwlen === 0 || (inWord && wlen === 0))) { }
|
|
424
|
+
else if (v.reservedDo && (ch === " " || ch === "\t" || ch === "\n") && rwlen === 2 && ret.tail(2) === "do")
|
|
425
|
+
rwlen = 0;
|
|
426
|
+
else if (!brk)
|
|
427
|
+
reservedOk = false;
|
|
428
|
+
}
|
|
429
|
+
if (ch === "<") {
|
|
430
|
+
ret.push(ch);
|
|
431
|
+
let peek = input.getc(true);
|
|
432
|
+
if (peek === EOF)
|
|
433
|
+
return "unterminated";
|
|
434
|
+
if (peek === "<") {
|
|
435
|
+
ret.push(peek);
|
|
436
|
+
peek = input.getc(true);
|
|
437
|
+
if (peek === EOF)
|
|
438
|
+
return "unterminated";
|
|
439
|
+
if (peek === "-") {
|
|
440
|
+
ret.push(peek);
|
|
441
|
+
stripTabs = true;
|
|
442
|
+
}
|
|
443
|
+
else
|
|
444
|
+
input.unget(peek);
|
|
445
|
+
if (peek !== "<") {
|
|
446
|
+
readingDelimiter = true;
|
|
447
|
+
firstind = -1;
|
|
448
|
+
}
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
if (v.rereadAfterLess) {
|
|
452
|
+
input.unget(peek);
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
ch = peek;
|
|
456
|
+
at = input.last;
|
|
457
|
+
}
|
|
458
|
+
else if (ch === "#" && ((reservedOk && rwlen === 0) || (inWord && wlen === 0)))
|
|
459
|
+
inComment = true;
|
|
460
|
+
if (ch === "\x01" || ch === "\x7f")
|
|
461
|
+
return "undelimited";
|
|
462
|
+
if (ch === ")")
|
|
463
|
+
count--;
|
|
464
|
+
else if (ch === "(")
|
|
465
|
+
count++;
|
|
466
|
+
ret.push(ch);
|
|
467
|
+
if (count === 0)
|
|
468
|
+
return at + 1;
|
|
469
|
+
if (ch === "\\")
|
|
470
|
+
passNext = true;
|
|
471
|
+
const from = input.p;
|
|
472
|
+
let inner;
|
|
473
|
+
if (QUOTE.includes(ch)) {
|
|
474
|
+
if (readingDelimiter && wasDollar)
|
|
475
|
+
return "undelimited";
|
|
476
|
+
inner = matchedPair(input, v, ch, ch, ch, { allowEscape: wasDollar && ch === "'" }, level + 1);
|
|
477
|
+
}
|
|
478
|
+
else if (wasDollar && "({[".includes(ch))
|
|
479
|
+
inner = dollarWord(input, v, ch, "(", () => count--, level);
|
|
480
|
+
if (inner !== undefined) {
|
|
481
|
+
if (typeof inner !== "number")
|
|
482
|
+
return inner;
|
|
483
|
+
append(from);
|
|
484
|
+
}
|
|
485
|
+
wasDollar = ch === "$" && !(v.dollarOnce && wasDollar);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
export function countingPassEnd(text, open, v) {
|
|
489
|
+
return countingPass(new Input(text, open + 1), v, 0);
|
|
490
|
+
}
|
|
491
|
+
export function bracePassEnd(text, open, v) {
|
|
492
|
+
return matchedPair(new Input(text, open + 1), v, "", "{", "}", { firstClose: true, dollarBrace: v.braceNests }, 0);
|
|
493
|
+
}
|
|
494
|
+
export function arithmeticCommandEnd(text, second) {
|
|
495
|
+
const input = new Input(text, second + 1);
|
|
496
|
+
const ends = readingsOf(text).pairEnds();
|
|
497
|
+
const end = matchedPair(input, PASSES[PASSES.length - 1], "", "(", ")", {}, 0, ends);
|
|
498
|
+
ends.ended(end);
|
|
499
|
+
if (typeof end !== "number")
|
|
500
|
+
return undefined;
|
|
501
|
+
return input.getc(false) === ")" ? input.p : undefined;
|
|
502
|
+
}
|
package/dist/shell/lex.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const UNRESOLVED_SENTENCE: {
|
|
|
26
26
|
readonly trailing_backslash: "a backslash ends the command, which the shell versions read differently (3.2 drops it, 5 keeps it)";
|
|
27
27
|
};
|
|
28
28
|
/** Why a command yields no segments: bash's own syntax errors and the two constructs this lexer cannot delimit. */
|
|
29
|
-
export declare const PARSE_FAILURE_REASONS: readonly ["unterminated_single_quote", "unterminated_double_quote", "unterminated_ansi_c", "unterminated_subscript", "unterminated_compound_value", "unterminated_command_substitution", "unterminated_process_substitution", "unterminated_parameter_expansion", "unterminated_arithmetic_expansion", "unterminated_heredoc", "undelimited_substitution", "redirect_without_target", "heredoc_without_delimiter", "heredoc_delimiter_expands"];
|
|
29
|
+
export declare const PARSE_FAILURE_REASONS: readonly ["unterminated_single_quote", "unterminated_double_quote", "unterminated_ansi_c", "unterminated_subscript", "unterminated_compound_value", "unterminated_command_substitution", "unterminated_process_substitution", "unterminated_parameter_expansion", "unterminated_arithmetic_expansion", "unterminated_heredoc", "undelimited_substitution", "undelimited_substitution_heredoc", "redirect_without_target", "heredoc_without_delimiter", "heredoc_delimiter_expands"];
|
|
30
30
|
export type ParseFailureReason = (typeof PARSE_FAILURE_REASONS)[number];
|
|
31
31
|
export declare const PARSE_FAILURE_SENTENCE: {
|
|
32
32
|
readonly unterminated_single_quote: "a single-quoted word never closes";
|
|
@@ -40,6 +40,7 @@ export declare const PARSE_FAILURE_SENTENCE: {
|
|
|
40
40
|
readonly unterminated_arithmetic_expansion: "an arithmetic expansion never terminates";
|
|
41
41
|
readonly unterminated_heredoc: "a here-document body never terminates";
|
|
42
42
|
readonly undelimited_substitution: "a command substitution carries a construct this lexer cannot delimit";
|
|
43
|
+
readonly undelimited_substitution_heredoc: "a here-document in a command substitution that shell versions end at different places — feed the text as stdin (`git commit -F -`) or reword it";
|
|
43
44
|
readonly redirect_without_target: "a redirection names no target";
|
|
44
45
|
readonly heredoc_without_delimiter: "a here-document operator names no delimiter";
|
|
45
46
|
readonly heredoc_delimiter_expands: "a here-document delimiter is not a plain word";
|
|
@@ -261,7 +262,8 @@ export interface HeredocExpansion {
|
|
|
261
262
|
}
|
|
262
263
|
/** The expansions of an UNQUOTED here-document body, in order: `$(…)`, `$((…))`, `$[…]` and backticks, `${ …; }` /
|
|
263
264
|
* `${| …; }`, `${…}` and `$NAME`. The body expands as double-quoted text does: quotes are ordinary characters, a backslash
|
|
264
|
-
* protects the next character, nothing is word-split. `undefined` when an expansion never closes.
|
|
265
|
+
* protects the next character, nothing is word-split. `undefined` when an expansion never closes. What its expansions
|
|
266
|
+
* ask of the rest of `body` is read once for the whole body ({@link whileReading}). */
|
|
265
267
|
export declare function expansionsInHeredocBody(body: string): readonly HeredocExpansion[] | undefined;
|
|
266
268
|
/** The substitution bodies of an UNQUOTED here-document body (the command and arithmetic members of
|
|
267
269
|
* {@link expansionsInHeredocBody}, a function / value substitution marked `currentShell`). `undefined` when an
|