@visual-z/xeno 0.8.4 → 0.9.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 +8 -0
- package/README.md +31 -746
- package/bin/xeno.exe +26 -0
- package/install.cjs +88 -0
- package/package.json +18 -48
- package/docs/app-server.md +0 -115
- package/docs/foundations.md +0 -88
- package/docs/install.md +0 -244
- package/docs/providers.md +0 -172
- package/docs/research/foundation-clients-2026-10-09.md +0 -27
- package/docs/research/foundation-editing-2026-10-09.md +0 -56
- package/docs/research/foundation-network-2026-10-09.md +0 -37
- package/docs/research/foundation-workflow-2026-10-09.md +0 -37
- package/src/apps/acp-server.ts +0 -41
- package/src/apps/agent-profiles.ts +0 -19
- package/src/apps/app-server.ts +0 -30
- package/src/apps/approve.ts +0 -49
- package/src/apps/cli.ts +0 -99
- package/src/apps/commands.ts +0 -319
- package/src/apps/completions.ts +0 -87
- package/src/apps/control-transport.ts +0 -90
- package/src/apps/export-cli.ts +0 -24
- package/src/apps/goal-flow.ts +0 -70
- package/src/apps/image-draft.ts +0 -46
- package/src/apps/input.ts +0 -312
- package/src/apps/model-catalog.ts +0 -69
- package/src/apps/preferences.ts +0 -20
- package/src/apps/project-trust.ts +0 -9
- package/src/apps/provider-connect.ts +0 -346
- package/src/apps/question-ui.ts +0 -27
- package/src/apps/render.ts +0 -181
- package/src/apps/resources.ts +0 -66
- package/src/apps/review.ts +0 -109
- package/src/apps/session-hub.ts +0 -96
- package/src/apps/session-lifecycle.ts +0 -64
- package/src/apps/shell.ts +0 -2071
- package/src/apps/startup-input.ts +0 -135
- package/src/apps/startup.ts +0 -1677
- package/src/apps/ui/app.ts +0 -1818
- package/src/apps/ui/control-model.ts +0 -43
- package/src/apps/ui/extension-host.ts +0 -194
- package/src/apps/ui/image-cache.ts +0 -121
- package/src/apps/ui/palette.ts +0 -88
- package/src/apps/ui/project.ts +0 -127
- package/src/apps/ui/standalone.ts +0 -148
- package/src/apps/ui/status-model.ts +0 -68
- package/src/apps/ui/surface.ts +0 -91
- package/src/apps/ui/theme.ts +0 -86
- package/src/apps/update-check.ts +0 -112
- package/src/apps/workflow.ts +0 -58
- package/src/core/acceptance.ts +0 -139
- package/src/core/action-defaults.ts +0 -58
- package/src/core/activity-status.ts +0 -52
- package/src/core/agent-profile.ts +0 -130
- package/src/core/attachment-input.ts +0 -17
- package/src/core/blind-checks.ts +0 -72
- package/src/core/boundary.ts +0 -174
- package/src/core/branch-receipt.ts +0 -26
- package/src/core/catalog-merge.ts +0 -19
- package/src/core/checkpoints.ts +0 -85
- package/src/core/churn.ts +0 -61
- package/src/core/command-artifacts.ts +0 -94
- package/src/core/command-contract.ts +0 -151
- package/src/core/completion-action.ts +0 -20
- package/src/core/completion-review.ts +0 -98
- package/src/core/context-detail.ts +0 -37
- package/src/core/context-policy.ts +0 -133
- package/src/core/context-window.ts +0 -54
- package/src/core/continuation.ts +0 -130
- package/src/core/control-protocol.ts +0 -69
- package/src/core/control-view.ts +0 -39
- package/src/core/cycle.ts +0 -17
- package/src/core/data-query.ts +0 -201
- package/src/core/deadline.ts +0 -40
- package/src/core/derive.ts +0 -516
- package/src/core/draft-images.ts +0 -56
- package/src/core/edit-plan.ts +0 -200
- package/src/core/environment.ts +0 -181
- package/src/core/event-validation.ts +0 -220
- package/src/core/events.ts +0 -670
- package/src/core/evidence-ladder.ts +0 -62
- package/src/core/evidence-links.ts +0 -68
- package/src/core/evidence.ts +0 -240
- package/src/core/execution.ts +0 -18
- package/src/core/exhaustive.ts +0 -18
- package/src/core/export.ts +0 -179
- package/src/core/extension-flags.ts +0 -14
- package/src/core/external-effects.ts +0 -488
- package/src/core/failure-recovery.ts +0 -173
- package/src/core/file-precondition.ts +0 -78
- package/src/core/file-references.ts +0 -35
- package/src/core/frontmatter.ts +0 -213
- package/src/core/git-status.ts +0 -29
- package/src/core/goal-view.ts +0 -64
- package/src/core/goal.ts +0 -200
- package/src/core/handoff.ts +0 -479
- package/src/core/history-query.ts +0 -139
- package/src/core/history.ts +0 -237
- package/src/core/image-limits.ts +0 -72
- package/src/core/images.ts +0 -46
- package/src/core/integration-health.ts +0 -34
- package/src/core/json-event.ts +0 -131
- package/src/core/json-pointer.ts +0 -46
- package/src/core/keymap.ts +0 -153
- package/src/core/lsp-framing.ts +0 -34
- package/src/core/mcp-config.ts +0 -68
- package/src/core/model-picker.ts +0 -64
- package/src/core/model-preferences.ts +0 -28
- package/src/core/model-replay.ts +0 -22
- package/src/core/model-scope.ts +0 -53
- package/src/core/note-guidance.ts +0 -34
- package/src/core/oauth-fields.ts +0 -44
- package/src/core/observation-view.ts +0 -152
- package/src/core/outcome.ts +0 -44
- package/src/core/overflow.ts +0 -59
- package/src/core/packages.ts +0 -47
- package/src/core/patch.ts +0 -130
- package/src/core/path-suggestions.ts +0 -59
- package/src/core/permissions.ts +0 -410
- package/src/core/process-receipt.ts +0 -105
- package/src/core/process-state.ts +0 -37
- package/src/core/program-status.ts +0 -40
- package/src/core/progress.ts +0 -150
- package/src/core/project.ts +0 -431
- package/src/core/prompt-policy.ts +0 -46
- package/src/core/prompts.ts +0 -111
- package/src/core/question.ts +0 -94
- package/src/core/queue.ts +0 -78
- package/src/core/read-bounds.ts +0 -24
- package/src/core/read-observation.ts +0 -106
- package/src/core/recovery-sources.ts +0 -74
- package/src/core/regex-dialect.ts +0 -25
- package/src/core/request-budget.ts +0 -23
- package/src/core/request-progress.ts +0 -87
- package/src/core/request-state.ts +0 -273
- package/src/core/resource-selection.ts +0 -36
- package/src/core/response-recovery.ts +0 -59
- package/src/core/resume.ts +0 -59
- package/src/core/review.ts +0 -68
- package/src/core/ripgrep-release.ts +0 -64
- package/src/core/runtime-target.ts +0 -94
- package/src/core/scheduling.ts +0 -8
- package/src/core/search-observation.ts +0 -97
- package/src/core/secrets.ts +0 -188
- package/src/core/session-archive.ts +0 -4
- package/src/core/session-browser.ts +0 -82
- package/src/core/session-entry.ts +0 -61
- package/src/core/session-exit.ts +0 -42
- package/src/core/session-format.ts +0 -169
- package/src/core/session-position.ts +0 -26
- package/src/core/session-tree.ts +0 -147
- package/src/core/settings.ts +0 -192
- package/src/core/skills.ts +0 -165
- package/src/core/sql-query.ts +0 -211
- package/src/core/stall.ts +0 -128
- package/src/core/stop-report.ts +0 -68
- package/src/core/text-normalize.ts +0 -81
- package/src/core/theme.ts +0 -166
- package/src/core/thinking.ts +0 -26
- package/src/core/tokens.ts +0 -151
- package/src/core/tool-contract.ts +0 -153
- package/src/core/tool-discovery.ts +0 -87
- package/src/core/tool-failure.ts +0 -81
- package/src/core/tool-input.ts +0 -44
- package/src/core/transcript.ts +0 -108
- package/src/core/tui-mode.ts +0 -29
- package/src/core/update-check.ts +0 -157
- package/src/core/version.ts +0 -55
- package/src/core/web-content.ts +0 -80
- package/src/core/work-state.ts +0 -154
- package/src/core/workflow-mode.ts +0 -34
- package/src/core/working-set.ts +0 -119
- package/src/core/yaml.ts +0 -282
- package/src/runtime/acp-agent.ts +0 -289
- package/src/runtime/agent-profiles.ts +0 -21
- package/src/runtime/auth.ts +0 -367
- package/src/runtime/blind-check.ts +0 -36
- package/src/runtime/branch-jobs.ts +0 -36
- package/src/runtime/catalog.ts +0 -285
- package/src/runtime/clipboard.ts +0 -125
- package/src/runtime/command-artifacts.ts +0 -64
- package/src/runtime/connection-reuse.ts +0 -40
- package/src/runtime/control-client.ts +0 -149
- package/src/runtime/control-connection.ts +0 -139
- package/src/runtime/counter-check.ts +0 -74
- package/src/runtime/environment-tools.ts +0 -60
- package/src/runtime/evidence-notes.ts +0 -35
- package/src/runtime/exec-sessions.ts +0 -456
- package/src/runtime/execution-control.ts +0 -40
- package/src/runtime/extension-loader.ts +0 -37
- package/src/runtime/extension-ui.ts +0 -47
- package/src/runtime/extensions.ts +0 -370
- package/src/runtime/formatter-tool.ts +0 -38
- package/src/runtime/formatter.ts +0 -50
- package/src/runtime/foundation.ts +0 -116
- package/src/runtime/history-cache.ts +0 -57
- package/src/runtime/history-tools.ts +0 -168
- package/src/runtime/images.ts +0 -80
- package/src/runtime/integrations.ts +0 -216
- package/src/runtime/loop.ts +0 -3108
- package/src/runtime/lsp-client.ts +0 -201
- package/src/runtime/mcp-client.ts +0 -264
- package/src/runtime/mcp-oauth.ts +0 -168
- package/src/runtime/mcp-schema.ts +0 -51
- package/src/runtime/model-config.ts +0 -232
- package/src/runtime/model-data.LICENSE +0 -27
- package/src/runtime/model-data.ts +0 -21
- package/src/runtime/model-discovery.ts +0 -208
- package/src/runtime/model-replay.ts +0 -10
- package/src/runtime/model-scope.ts +0 -20
- package/src/runtime/model-sources.ts +0 -151
- package/src/runtime/model.ts +0 -686
- package/src/runtime/models-fetch.ts +0 -57
- package/src/runtime/oauth-device.ts +0 -86
- package/src/runtime/oauth.ts +0 -853
- package/src/runtime/open-image.ts +0 -42
- package/src/runtime/openai-responses.ts +0 -304
- package/src/runtime/openai.ts +0 -697
- package/src/runtime/output-schema.ts +0 -26
- package/src/runtime/package-manager.ts +0 -125
- package/src/runtime/patch-tool.ts +0 -38
- package/src/runtime/permission-resources.ts +0 -18
- package/src/runtime/pi-provider.ts +0 -423
- package/src/runtime/program-status.ts +0 -38
- package/src/runtime/progress.ts +0 -26
- package/src/runtime/provider-access.ts +0 -21
- package/src/runtime/provider-connect.ts +0 -109
- package/src/runtime/provider-presets.ts +0 -98
- package/src/runtime/provider-protocols.ts +0 -29
- package/src/runtime/provider-request.ts +0 -87
- package/src/runtime/provider-tool-policy.ts +0 -33
- package/src/runtime/provider.ts +0 -580
- package/src/runtime/question-tool.ts +0 -62
- package/src/runtime/retry.ts +0 -447
- package/src/runtime/review-tool.ts +0 -48
- package/src/runtime/rich-text.ts +0 -36
- package/src/runtime/runtime-target.ts +0 -149
- package/src/runtime/secrets.ts +0 -79
- package/src/runtime/self-update.ts +0 -74
- package/src/runtime/session-control.ts +0 -265
- package/src/runtime/session-hub.ts +0 -85
- package/src/runtime/stream-idle.ts +0 -80
- package/src/runtime/tool-broker.ts +0 -137
- package/src/runtime/tool-discovery.ts +0 -58
- package/src/runtime/tool-queue.ts +0 -77
- package/src/runtime/tools.ts +0 -1820
- package/src/runtime/turn-effects.ts +0 -31
- package/src/runtime/update-check.ts +0 -48
- package/src/runtime/usage.ts +0 -253
- package/src/runtime/version.ts +0 -12
- package/src/runtime/web-http.ts +0 -56
- package/src/runtime/web-tools.ts +0 -88
- package/src/runtime/working-notes.ts +0 -60
- package/src/runtime/workspace-lifecycle.ts +0 -141
- package/src/store/acceptance.ts +0 -15
- package/src/store/agent-profile-files.ts +0 -13
- package/src/store/atomic.ts +0 -31
- package/src/store/auth-store.ts +0 -50
- package/src/store/blind-checks.ts +0 -32
- package/src/store/blobs.ts +0 -143
- package/src/store/checkpoint-history.ts +0 -32
- package/src/store/command-artifacts.ts +0 -96
- package/src/store/command.ts +0 -111
- package/src/store/config.ts +0 -69
- package/src/store/context-files.ts +0 -436
- package/src/store/file-checkpoints.ts +0 -108
- package/src/store/file-index.ts +0 -174
- package/src/store/foundation-config.ts +0 -24
- package/src/store/git-checkpoints.ts +0 -67
- package/src/store/git-status.ts +0 -15
- package/src/store/history-search.ts +0 -19
- package/src/store/log.ts +0 -725
- package/src/store/lsp-document.ts +0 -30
- package/src/store/mcp-credentials.ts +0 -85
- package/src/store/models.ts +0 -60
- package/src/store/observations.ts +0 -224
- package/src/store/packages.ts +0 -98
- package/src/store/patch.ts +0 -92
- package/src/store/permission-paths.ts +0 -34
- package/src/store/process-receipts.ts +0 -34
- package/src/store/query-source.ts +0 -49
- package/src/store/recovery.ts +0 -44
- package/src/store/replay.ts +0 -76
- package/src/store/resource-index.ts +0 -170
- package/src/store/resources.ts +0 -285
- package/src/store/restore.ts +0 -110
- package/src/store/review.ts +0 -109
- package/src/store/runtime-target.ts +0 -64
- package/src/store/search.ts +0 -728
- package/src/store/secrets.ts +0 -44
- package/src/store/serial.ts +0 -13
- package/src/store/session-archive.ts +0 -165
- package/src/store/session-browser.ts +0 -68
- package/src/store/session-position.ts +0 -27
- package/src/store/sessions.ts +0 -525
- package/src/store/source-cancellation.ts +0 -6
- package/src/store/tool-binaries.ts +0 -90
- package/src/store/trust.ts +0 -82
- package/src/store/update-cache.ts +0 -36
- package/src/store/user-settings.ts +0 -30
- package/src/store/workspace-clone.ts +0 -42
- package/src/store/workspace-observation.ts +0 -113
- package/src/store/workspace.ts +0 -115
- package/src/store/worktree.ts +0 -278
- package/src/tui/ansi-spans.ts +0 -126
- package/src/tui/diff.ts +0 -160
- package/src/tui/exhaustive.ts +0 -14
- package/src/tui/fuzzy.ts +0 -75
- package/src/tui/style.ts +0 -208
- package/src/tui/ui/atomic-draft.ts +0 -121
- package/src/tui/ui/branch-panel.ts +0 -47
- package/src/tui/ui/canvas.ts +0 -96
- package/src/tui/ui/colors.ts +0 -70
- package/src/tui/ui/composer.ts +0 -199
- package/src/tui/ui/control-panel.ts +0 -25
- package/src/tui/ui/control-sidebar.ts +0 -49
- package/src/tui/ui/dialog.ts +0 -398
- package/src/tui/ui/draft.ts +0 -23
- package/src/tui/ui/duration.ts +0 -16
- package/src/tui/ui/edge.ts +0 -186
- package/src/tui/ui/image-size.ts +0 -44
- package/src/tui/ui/ink.ts +0 -210
- package/src/tui/ui/items.ts +0 -42
- package/src/tui/ui/keys.ts +0 -40
- package/src/tui/ui/layout.ts +0 -74
- package/src/tui/ui/list-model.ts +0 -86
- package/src/tui/ui/list-view.ts +0 -172
- package/src/tui/ui/mascot.ts +0 -67
- package/src/tui/ui/messages.ts +0 -518
- package/src/tui/ui/motion.ts +0 -28
- package/src/tui/ui/paths.ts +0 -10
- package/src/tui/ui/pictures.ts +0 -108
- package/src/tui/ui/prompt-history.ts +0 -60
- package/src/tui/ui/screen.ts +0 -579
- package/src/tui/ui/status.ts +0 -403
- package/src/tui/ui/styled.ts +0 -85
- package/src/tui/ui/tool-card.ts +0 -150
- package/src/tui/width.ts +0 -567
- package/src/vendor/pi-rich/LICENSE.upstream +0 -21
- package/src/vendor/pi-rich/UPSTREAM.json +0 -17
- package/src/vendor/pi-rich/clipboard-command.ts +0 -44
- package/src/vendor/pi-rich/exif-orientation.ts +0 -182
- package/src/vendor/pi-rich/html.ts +0 -51
- package/src/vendor/pi-rich/image-convert.ts +0 -49
- package/src/vendor/pi-rich/image-resize-core.ts +0 -164
- package/src/vendor/pi-rich/image-resize-worker.ts +0 -42
- package/src/vendor/pi-rich/image-resize.ts +0 -123
- package/src/vendor/pi-rich/mime.ts +0 -116
- package/src/vendor/pi-rich/photon.ts +0 -139
- package/src/vendor/pi-rich/syntax-highlight.ts +0 -214
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/** P.3: bounded path operations with durable before-images and conflict checks. */
|
|
2
|
-
import { lstat, readFile, mkdir, open, rename, rm } from "node:fs/promises";
|
|
3
|
-
import { resolve, relative, dirname, join, sep } from "node:path";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
|
-
import { blobAddress, putBlob, getBlobBytes, verifyBlob } from "./blobs.ts";
|
|
6
|
-
import { sameVersion, changedPaths, type FileVersion, type FileChanges } from "../core/checkpoints.ts";
|
|
7
|
-
import { ToolFault, NOT_STARTED, READ_ATTEMPTED, STATE_PATH_GUIDANCE, failureFromError } from "../core/tool-failure.ts";
|
|
8
|
-
|
|
9
|
-
export async function editablePath(root: string, path: string): Promise<string> {
|
|
10
|
-
const base = resolve(root), absolute = resolve(base, path), rel = relative(base, absolute);
|
|
11
|
-
if (!rel || rel === ".." || rel.startsWith(`..${sep}`) || resolve(rel) === rel) throw new ToolFault("permission_denied", `unsafe file checkpoint path: ${path}`, NOT_STARTED);
|
|
12
|
-
// Session logs and blobs are the evidence; an edit there could rewrite it.
|
|
13
|
-
if (rel.split(sep).some(part => part === ".git" || part === ".xeno")) {
|
|
14
|
-
throw new ToolFault("permission_denied", `${path} is inside .git or .xeno, which edit tools never change; this is not a permission problem and no approval will allow it`, NOT_STARTED, { next: STATE_PATH_GUIDANCE });
|
|
15
|
-
}
|
|
16
|
-
let current = base;
|
|
17
|
-
for (const part of rel.split(sep)) {
|
|
18
|
-
current = join(current, part);
|
|
19
|
-
try {
|
|
20
|
-
const info = await lstat(current);
|
|
21
|
-
if (info.isSymbolicLink() || current !== absolute && !info.isDirectory() || current === absolute && (!info.isFile() || info.nlink > 1))
|
|
22
|
-
throw new ToolFault("permission_denied", `unsupported file checkpoint path: ${path}`, NOT_STARTED);
|
|
23
|
-
} catch (error) { if ((error as { code?: string }).code !== "ENOENT") throw error; }
|
|
24
|
-
}
|
|
25
|
-
return absolute;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function readEditableFile(root: string, path: string): Promise<{ bytes: Uint8Array | null; version: FileVersion }> {
|
|
29
|
-
const absolute = await editablePath(root, path);
|
|
30
|
-
try {
|
|
31
|
-
const info = await lstat(absolute);
|
|
32
|
-
const bytes = await readFile(absolute);
|
|
33
|
-
return { bytes, version: { sha256: blobAddress(bytes), mode: info.mode & 0o777 } };
|
|
34
|
-
} catch (error) {
|
|
35
|
-
if ((error as { code?: string }).code === "ENOENT") return { bytes: null, version: null };
|
|
36
|
-
const diagnostic = failureFromError(error, READ_ATTEMPTED);
|
|
37
|
-
throw new ToolFault(diagnostic.code, diagnostic.message, READ_ATTEMPTED);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** The prepared record is durable before rename; cancellation and conflicts leave bytes untouched. */
|
|
42
|
-
export async function replaceFile(root: string, path: string, expected: FileVersion, bytes: Uint8Array | null,
|
|
43
|
-
mode: number, signal?: AbortSignal): Promise<void> {
|
|
44
|
-
const absolute = await editablePath(root, path);
|
|
45
|
-
if (signal?.aborted) throw new ToolFault("cancelled", "file operation cancelled", NOT_STARTED);
|
|
46
|
-
if (!sameVersion((await readEditableFile(root, path)).version, expected)) throw new ToolFault("version_mismatch", `file conflict: ${path}; read it again before editing`, READ_ATTEMPTED, { recover: { tool: "read", input: { path } } });
|
|
47
|
-
if (bytes === null) {
|
|
48
|
-
if (expected === null) return;
|
|
49
|
-
await rm(absolute);
|
|
50
|
-
const directory = await open(dirname(absolute), "r");
|
|
51
|
-
try { await directory.sync(); } finally { await directory.close(); }
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
await mkdir(dirname(absolute), { recursive: true });
|
|
55
|
-
const temporary = join(dirname(absolute), `.xeno-edit-${randomUUID()}`);
|
|
56
|
-
try {
|
|
57
|
-
const file = await open(temporary, "wx", mode);
|
|
58
|
-
try { await file.writeFile(bytes); await file.chmod(mode); await file.sync(); } finally { await file.close(); }
|
|
59
|
-
await editablePath(root, path);
|
|
60
|
-
if (signal?.aborted) throw new ToolFault("cancelled", "file operation cancelled", READ_ATTEMPTED);
|
|
61
|
-
if (!sameVersion((await readEditableFile(root, path)).version, expected)) throw new ToolFault("version_mismatch", `file conflict: ${path}; read it again before editing`, READ_ATTEMPTED, { recover: { tool: "read", input: { path } } });
|
|
62
|
-
await rename(temporary, absolute);
|
|
63
|
-
const directory = await open(dirname(absolute), "r");
|
|
64
|
-
try { await directory.sync(); } finally { await directory.close(); }
|
|
65
|
-
} finally { await rm(temporary, { force: true }); }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function archiveEdit(blobs: string, before: Uint8Array | null, after: Uint8Array): Promise<void> {
|
|
69
|
-
if (before !== null) await putBlob(blobs, before);
|
|
70
|
-
await putBlob(blobs, after);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function preflightChanges(root: string, blobs: string, changes: FileChanges, signal?: AbortSignal): Promise<void> {
|
|
74
|
-
for (const path of changedPaths(changes)) {
|
|
75
|
-
if (signal?.aborted) throw new ToolFault("cancelled", "file operation cancelled", NOT_STARTED);
|
|
76
|
-
const change = changes[path]!;
|
|
77
|
-
if (!sameVersion((await readEditableFile(root, path)).version, change.before)) throw new Error(`file conflict: ${path}; external changes were preserved`);
|
|
78
|
-
if (change.after && !await verifyBlob(blobs, change.after.sha256)) throw new Error(`missing checkpoint object: ${path}`);
|
|
79
|
-
if (change.before && !await verifyBlob(blobs, change.before.sha256)) throw new Error(`missing recovery object: ${path}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Preflight the complete plan, then compensate partial writes if an individual replacement fails. */
|
|
84
|
-
export async function applyFileChanges(root: string, blobs: string, changes: FileChanges, signal?: AbortSignal): Promise<void> {
|
|
85
|
-
await preflightChanges(root, blobs, changes, signal);
|
|
86
|
-
const applied: string[] = [];
|
|
87
|
-
try {
|
|
88
|
-
for (const path of changedPaths(changes)) {
|
|
89
|
-
const { before, after } = changes[path]!;
|
|
90
|
-
const bytes = after === null ? null : await getBlobBytes(blobs, after.sha256);
|
|
91
|
-
if (after && bytes === null) throw new Error(`missing checkpoint object: ${path}`);
|
|
92
|
-
await replaceFile(root, path, before, bytes, after?.mode ?? 0o644, signal);
|
|
93
|
-
applied.push(path);
|
|
94
|
-
}
|
|
95
|
-
} catch (error) {
|
|
96
|
-
const failures: string[] = [];
|
|
97
|
-
for (const path of applied.reverse()) {
|
|
98
|
-
const { before, after } = changes[path]!;
|
|
99
|
-
try {
|
|
100
|
-
const bytes = before === null ? null : await getBlobBytes(blobs, before.sha256);
|
|
101
|
-
if (before && bytes === null) throw new Error("missing recovery object");
|
|
102
|
-
await replaceFile(root, path, after, bytes, before?.mode ?? 0o644);
|
|
103
|
-
} catch { failures.push(path); }
|
|
104
|
-
}
|
|
105
|
-
if (failures.length) throw new Error(`restore interrupted; inspect partially applied paths: ${failures.join(", ")}; ${String(error)}`);
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
package/src/store/file-index.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Candidate paths for @-file expansion and the walk search engine.
|
|
3
|
-
*
|
|
4
|
-
* A glob on every keystroke is a stall in a large repo (the card's rejected
|
|
5
|
-
* alternative). Scan once, cache for the session. The snapshot scanner is a
|
|
6
|
-
* different job -- it hashes contents and refuses to truncate -- so this walk
|
|
7
|
-
* is its own function rather than a mode flag on scanWorkspace.
|
|
8
|
-
*
|
|
9
|
-
* Inside a Git work tree the candidates are Git's own listing: tracked plus
|
|
10
|
-
* untracked files that are not ignored (S.6 item 4). Claude Code's Grep,
|
|
11
|
-
* OpenCode (`rg --files`) and Pi (`fd`) follow .gitignore the same way; a
|
|
12
|
-
* walk that ignores it let an ignored worktree's build output fill the whole
|
|
13
|
-
* budget before the product's directories were reached
|
|
14
|
-
* (research-file-index-truncation).
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { lstat, readdir } from "node:fs/promises";
|
|
18
|
-
import type { Dirent } from "node:fs";
|
|
19
|
-
import { dirname, join, relative, sep } from "node:path";
|
|
20
|
-
import { DEFAULT_IGNORE } from "./workspace.ts";
|
|
21
|
-
import { gitBytes } from "./workspace-observation.ts";
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Cap on paths from an unfiltered directory walk, outside Git. Assumed, not
|
|
25
|
-
* measured: enough to fuzzy-search a large tree; past this the walk is hiding
|
|
26
|
-
* a missing filter, not serving one. Hitting it truncates and says so -- a
|
|
27
|
-
* silent cut would make @ miss files that exist. A Git listing is already the
|
|
28
|
-
* filtered candidate set and is not capped unless the caller asks.
|
|
29
|
-
*/
|
|
30
|
-
export const MAX_INDEX_ENTRIES = 20_000;
|
|
31
|
-
|
|
32
|
-
export interface FileIndex {
|
|
33
|
-
readonly paths: readonly string[];
|
|
34
|
-
readonly truncated: boolean;
|
|
35
|
-
readonly issues?: readonly { code: string; path?: string }[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface IndexOptions {
|
|
39
|
-
readonly ignore?: readonly string[];
|
|
40
|
-
readonly maxEntries?: number;
|
|
41
|
-
readonly deadline?: number;
|
|
42
|
-
readonly signal?: AbortSignal;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function isIgnored(rel: string, ignore: readonly string[]): boolean {
|
|
46
|
-
const parts = rel.split(sep);
|
|
47
|
-
return ignore.some((i) => parts.includes(i));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** Git judges its own ignore rules; an error or a path outside any work tree is not ignored. */
|
|
51
|
-
export async function gitIgnored(path: string, signal?: AbortSignal): Promise<boolean> {
|
|
52
|
-
try {
|
|
53
|
-
const info = await lstat(path);
|
|
54
|
-
await gitBytes(info.isDirectory() ? path : dirname(path), ["check-ignore", "-q", "--", path], undefined, signal);
|
|
55
|
-
return true;
|
|
56
|
-
} catch { return false; }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Git's listing under `dir`, relative to it, or null when `dir` is not a work tree that Git lists. */
|
|
60
|
-
async function gitListing(dir: string, signal?: AbortSignal): Promise<string[] | null> {
|
|
61
|
-
try {
|
|
62
|
-
if (new TextDecoder().decode(await gitBytes(dir, ["rev-parse", "--is-inside-work-tree"], undefined, signal)).trim() !== "true") return null;
|
|
63
|
-
// Naming an ignored directory is an explicit request: walk it instead.
|
|
64
|
-
if (await gitIgnored(dir, signal)) return null;
|
|
65
|
-
const listed = new TextDecoder().decode(await gitBytes(dir, ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], undefined, signal));
|
|
66
|
-
// An untracked nested repository is listed once, as "name/".
|
|
67
|
-
return [...new Set(listed.split("\0").filter(Boolean).map(path => path.replace(/\/$/, "")))].sort();
|
|
68
|
-
} catch { return null; }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Assumed: enough concurrent lstat calls to hide latency without exhausting descriptors. */
|
|
72
|
-
const LSTAT_BATCH = 256;
|
|
73
|
-
|
|
74
|
-
async function indexGitListing(root: string, listed: readonly string[], opts: IndexOptions): Promise<FileIndex> {
|
|
75
|
-
const ignore = opts.ignore ?? DEFAULT_IGNORE;
|
|
76
|
-
const max = opts.maxEntries ?? Infinity;
|
|
77
|
-
const paths: string[] = [], issues: { code: string; path?: string }[] = [];
|
|
78
|
-
// The index can name a path under a directory since replaced by a symlink;
|
|
79
|
-
// following it would read outside the tree, so every ancestor is checked once.
|
|
80
|
-
const directories = new Map<string, Promise<boolean>>([["", Promise.resolve(true)]]);
|
|
81
|
-
const plainDirectory = (rel: string): Promise<boolean> => {
|
|
82
|
-
let known = directories.get(rel);
|
|
83
|
-
if (known === undefined) {
|
|
84
|
-
const parent = rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "";
|
|
85
|
-
known = plainDirectory(parent).then(async ok => ok && await lstat(join(root, rel)).then(info => info.isDirectory() && !info.isSymbolicLink(), () => false));
|
|
86
|
-
directories.set(rel, known);
|
|
87
|
-
}
|
|
88
|
-
return known;
|
|
89
|
-
};
|
|
90
|
-
for (let offset = 0; offset < listed.length; offset += LSTAT_BATCH) {
|
|
91
|
-
if (opts.signal?.aborted || opts.deadline !== undefined && performance.now() >= opts.deadline) {
|
|
92
|
-
issues.push({ code: opts.signal?.aborted ? "cancelled" : "timeout" }); return { paths, truncated: true, issues };
|
|
93
|
-
}
|
|
94
|
-
const batch = listed.slice(offset, offset + LSTAT_BATCH).filter(rel => !isIgnored(rel.split("/").join(sep), ignore));
|
|
95
|
-
const kinds = await Promise.all(batch.map(async rel => {
|
|
96
|
-
const parent = rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "";
|
|
97
|
-
if (!await plainDirectory(parent)) return "skip";
|
|
98
|
-
// A tracked path deleted from the work tree is not a candidate.
|
|
99
|
-
const info = await lstat(join(root, rel)).catch(() => null);
|
|
100
|
-
return info === null || info.isSymbolicLink() ? "skip" : info.isDirectory() ? "nested" : info.isFile() ? "file" : "skip";
|
|
101
|
-
}));
|
|
102
|
-
for (let i = 0; i < batch.length; i++) {
|
|
103
|
-
const rel = batch[i]!;
|
|
104
|
-
if (kinds[i] === "nested") {
|
|
105
|
-
// A submodule or nested repository: its own listing, or a walk if it has none.
|
|
106
|
-
const nested = await buildFileIndex(join(root, rel), { ...opts, ...(max === Infinity ? {} : { maxEntries: max - paths.length }) });
|
|
107
|
-
paths.push(...nested.paths.map(path => `${rel}/${path}`));
|
|
108
|
-
issues.push(...(nested.issues ?? []).map(issue => issue.path === undefined ? issue : { ...issue, path: `${rel}/${issue.path}` }));
|
|
109
|
-
if (nested.truncated) return { paths, truncated: true, issues };
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (kinds[i] !== "file") continue;
|
|
113
|
-
if (paths.length >= max) { issues.push({ code: "file_index_limit" }); return { paths, truncated: true, issues }; }
|
|
114
|
-
paths.push(rel);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return { paths, truncated: false, ...(issues.length ? { issues } : {}) };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export async function buildFileIndex(root: string, opts: IndexOptions = {}): Promise<FileIndex> {
|
|
121
|
-
const listed = await gitListing(root, opts.signal);
|
|
122
|
-
if (listed !== null) return indexGitListing(root, listed, opts);
|
|
123
|
-
const ignore = opts.ignore ?? DEFAULT_IGNORE;
|
|
124
|
-
const max = opts.maxEntries ?? MAX_INDEX_ENTRIES;
|
|
125
|
-
const paths: string[] = [];
|
|
126
|
-
let truncated = false;
|
|
127
|
-
const issues: { code: string; path?: string }[] = [];
|
|
128
|
-
|
|
129
|
-
async function walk(dir: string): Promise<void> {
|
|
130
|
-
if (truncated) return;
|
|
131
|
-
if (opts.signal?.aborted || opts.deadline !== undefined && performance.now() >= opts.deadline) {
|
|
132
|
-
truncated = true; issues.push({ code: opts.signal?.aborted ? "cancelled" : "timeout" }); return;
|
|
133
|
-
}
|
|
134
|
-
let entries: Dirent[];
|
|
135
|
-
try {
|
|
136
|
-
entries = await readdir(dir, { withFileTypes: true });
|
|
137
|
-
} catch {
|
|
138
|
-
issues.push({ code: "unreadable_directory", path: relative(root, dir) || "." });
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
for (const entry of entries.sort((a, b) => (a.name < b.name ? -1 : 1))) {
|
|
142
|
-
if (truncated) return;
|
|
143
|
-
if (opts.signal?.aborted || opts.deadline !== undefined && performance.now() >= opts.deadline) {
|
|
144
|
-
truncated = true; issues.push({ code: opts.signal?.aborted ? "cancelled" : "timeout" }); return;
|
|
145
|
-
}
|
|
146
|
-
// Do not follow symlinks: a link to / walks the disk, and
|
|
147
|
-
// node_modules/.bin is nothing but links. Same judgment as
|
|
148
|
-
// feat-workspace-snapshots, which also skips them via isFile().
|
|
149
|
-
if (entry.isSymbolicLink()) continue;
|
|
150
|
-
const abs = join(dir, entry.name);
|
|
151
|
-
const rel = relative(root, abs);
|
|
152
|
-
if (isIgnored(rel, ignore)) continue;
|
|
153
|
-
if (entry.isDirectory()) {
|
|
154
|
-
await walk(abs);
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
if (!entry.isFile()) continue;
|
|
158
|
-
if (paths.length >= max) {
|
|
159
|
-
truncated = true;
|
|
160
|
-
issues.push({ code: "file_index_limit" });
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
paths.push(rel.split(sep).join("/"));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
await walk(root);
|
|
168
|
-
return { paths, truncated, ...(issues.length ? { issues } : {}) };
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function indexTruncationNote(index: FileIndex): string | null {
|
|
172
|
-
if (!index.truncated) return null;
|
|
173
|
-
return `file index truncated at ${index.paths.length} entries; later paths are not searchable`;
|
|
174
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** Trusted executable configuration follows the same user/project boundary as extensions. */
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
|
|
5
|
-
export async function readFoundationConfig(configDirectory: string, workspace: string, trusted: boolean): Promise<Record<string, unknown>> {
|
|
6
|
-
let value: Record<string, unknown> = {};
|
|
7
|
-
for (const path of [join(configDirectory, "foundation.json"), ...(trusted ? [join(workspace, ".xeno", "foundation.json")] : [])]) {
|
|
8
|
-
let text: string;
|
|
9
|
-
try { text = await readFile(path, "utf8"); }
|
|
10
|
-
catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") continue; throw error; }
|
|
11
|
-
const parsed: unknown = JSON.parse(text);
|
|
12
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw Error(`${path}: expected an object`);
|
|
13
|
-
const allowed = ["mcp", "webSearch", "formatters", "lsp", "permissions"];
|
|
14
|
-
if (Object.keys(parsed).some(key => !allowed.includes(key))) throw Error(`${path}: unknown foundation setting`);
|
|
15
|
-
value = { ...value, ...parsed };
|
|
16
|
-
}
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function readOutputSchema(path: string): Promise<unknown> {
|
|
21
|
-
const text = await readFile(path, "utf8");
|
|
22
|
-
if (Buffer.byteLength(text) > 1_048_576) throw Error("output schema exceeds 1 MiB");
|
|
23
|
-
return JSON.parse(text) as unknown;
|
|
24
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** P.3/OpenCode v2: retained private index, scoped capture, path-only CAS export. */
|
|
2
|
-
import { mkdir, lstat } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { blobAddress, putBlob } from "./blobs.ts";
|
|
5
|
-
import { gitBytes, sourceInventory } from "./workspace-observation.ts";
|
|
6
|
-
import type { FileChanges, FileVersion } from "../core/checkpoints.ts";
|
|
7
|
-
import { atomicWrite } from "./atomic.ts";
|
|
8
|
-
|
|
9
|
-
const text = (bytes: Uint8Array) => new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
10
|
-
export interface GitCheckpoint { tree: string; modes: ReadonlyMap<string, number>; }
|
|
11
|
-
export class GitCheckpoints {
|
|
12
|
-
readonly root: string;
|
|
13
|
-
private readonly ownedPaths: readonly string[];
|
|
14
|
-
private initialized = false;
|
|
15
|
-
readonly directory: string;
|
|
16
|
-
constructor(root: string, storage: string, ownedPaths: readonly string[] = []) {
|
|
17
|
-
this.root = root; this.directory = join(storage, "git-checkpoints", blobAddress(root)); this.ownedPaths = ownedPaths;
|
|
18
|
-
}
|
|
19
|
-
private git(args: readonly string[], input?: Uint8Array, signal?: AbortSignal) {
|
|
20
|
-
return gitBytes(this.root, ["--literal-pathspecs", "-c", "core.autocrlf=false", "-c", "core.safecrlf=false", "-c", "core.attributesFile=/dev/null", "-c", "core.hooksPath=/dev/null", "-c", "gc.auto=0", ...args], input, signal,
|
|
21
|
-
{ GIT_DIR: this.directory, GIT_WORK_TREE: this.root, GIT_INDEX_FILE: join(this.directory, "index"), GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_ATTR_NOSYSTEM: "1" });
|
|
22
|
-
}
|
|
23
|
-
async capture(signal?: AbortSignal): Promise<GitCheckpoint> {
|
|
24
|
-
const inventory = await sourceInventory(this.root, signal, true, this.ownedPaths);
|
|
25
|
-
if (!this.initialized) {
|
|
26
|
-
await mkdir(this.directory, { recursive: true });
|
|
27
|
-
await gitBytes(this.root, ["init", "--bare", "--quiet", this.directory], undefined, signal);
|
|
28
|
-
// Git's highest-precedence attributes keep checkpoint bytes exact, even if the project uses LFS, encoding or EOL conversion.
|
|
29
|
-
await atomicWrite(join(this.directory, "info", "attributes"), "* -text -crlf -ident -filter -working-tree-encoding -eol\n");
|
|
30
|
-
this.initialized = true;
|
|
31
|
-
}
|
|
32
|
-
// Git trees retain only the executable bit; recovery needs the observed POSIX permissions as well.
|
|
33
|
-
const modes = new Map<string, number>();
|
|
34
|
-
for (const path of inventory.paths) {
|
|
35
|
-
const info = await lstat(join(this.root, path));
|
|
36
|
-
if (!info.isFile() || info.nlink > 1) throw new Error(`unsupported Git checkpoint path: ${path}`);
|
|
37
|
-
modes.set(path, info.mode & 0o777);
|
|
38
|
-
}
|
|
39
|
-
const previous = text(await this.git(["ls-files", "-z"], undefined, signal)).split("\0").filter(Boolean);
|
|
40
|
-
const present = new Set(inventory.paths);
|
|
41
|
-
const removed = previous.filter(path => !present.has(path));
|
|
42
|
-
if (removed.length) await this.git(["update-index", "--force-remove", "-z", "--stdin"], Buffer.from(removed.join("\0") + "\0"), signal);
|
|
43
|
-
// Feeding explicit paths avoids scanning ignored descendants and preserves names with newlines or leading dashes.
|
|
44
|
-
if (inventory.paths.length) await this.git(["add", "--force", "--pathspec-from-file=-", "--pathspec-file-nul"], Buffer.from(inventory.paths.join("\0") + "\0"), signal);
|
|
45
|
-
const tree = text(await this.git(["write-tree"], undefined, signal)).trim();
|
|
46
|
-
// Durable reachability is owned by Xeno, independent of the user's Git GC/index/HEAD.
|
|
47
|
-
await this.git(["update-ref", `refs/checkpoints/${tree}`, tree], undefined, signal);
|
|
48
|
-
return { tree, modes };
|
|
49
|
-
}
|
|
50
|
-
async changes(before: GitCheckpoint, after: GitCheckpoint, blobs: string, signal?: AbortSignal): Promise<FileChanges> {
|
|
51
|
-
const paths = new Set(before.tree === after.tree ? [] : text(await this.git(["diff-tree", "--no-renames", "--name-only", "-r", "-z", before.tree, after.tree], undefined, signal)).split("\0").filter(Boolean));
|
|
52
|
-
for (const [path, mode] of before.modes) if (mode !== after.modes.get(path)) paths.add(path);
|
|
53
|
-
for (const path of after.modes.keys()) if (!before.modes.has(path)) paths.add(path);
|
|
54
|
-
const version = async (snapshot: GitCheckpoint, path: string): Promise<FileVersion> => {
|
|
55
|
-
const entry = text(await this.git(["ls-tree", "-z", snapshot.tree, "--", path], undefined, signal));
|
|
56
|
-
if (!entry) return null;
|
|
57
|
-
const match = /^(100644|100755) blob ([a-f0-9]+)\t/.exec(entry);
|
|
58
|
-
const mode = snapshot.modes.get(path);
|
|
59
|
-
if (!match || mode === undefined) throw new Error(`unsupported Git checkpoint entry: ${path}`);
|
|
60
|
-
const bytes = await this.git(["cat-file", "blob", match[2]!], undefined, signal);
|
|
61
|
-
return { sha256: await putBlob(blobs, bytes), mode };
|
|
62
|
-
};
|
|
63
|
-
const changes: FileChanges = Object.create(null) as FileChanges;
|
|
64
|
-
for (const path of paths) changes[path] = { before: await version(before, path), after: await version(after, path) };
|
|
65
|
-
return changes;
|
|
66
|
-
}
|
|
67
|
-
}
|
package/src/store/git-status.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** Local Git reads are asynchronous and bounded; a paint never launches a process. */
|
|
2
|
-
import { execFile } from "node:child_process";
|
|
3
|
-
import { parseGitStatus, type GitStatus } from "../core/git-status.ts";
|
|
4
|
-
/** Assumed cold-disk allowance; Git failure remains unavailable rather than "clean". */
|
|
5
|
-
const GIT_STATUS_TIMEOUT_MS = 1000;
|
|
6
|
-
/** A busy repository cannot flood memory or the status view with paths. */
|
|
7
|
-
const GIT_STATUS_MAX_BYTES = 1024 * 1024;
|
|
8
|
-
|
|
9
|
-
export function readGitStatus(cwd: string): Promise<GitStatus | null> {
|
|
10
|
-
return new Promise(resolve => {
|
|
11
|
-
execFile("git", ["--no-optional-locks", "status", "--porcelain=v2", "--branch", "-z", "--untracked-files=normal"],
|
|
12
|
-
{ cwd, timeout: GIT_STATUS_TIMEOUT_MS, maxBuffer: GIT_STATUS_MAX_BYTES, encoding: "utf8" },
|
|
13
|
-
(error, output) => resolve(error ? null : parseGitStatus(output)));
|
|
14
|
-
});
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Search immutable observation bodies without loading large command output into RAM. */
|
|
2
|
-
import { createReadStream } from "node:fs";
|
|
3
|
-
import { blobFilePath, verifyBlob } from "./blobs.ts";
|
|
4
|
-
|
|
5
|
-
export async function observationContains(dir: string, sha256: string, terms: readonly string[]): Promise<boolean> {
|
|
6
|
-
if (!await verifyBlob(dir, sha256)) throw new Error(`missing or corrupt observation ${sha256}`);
|
|
7
|
-
const remaining = new Set(terms);
|
|
8
|
-
const overlap = Math.max(0, ...terms.map((term) => term.length - 1));
|
|
9
|
-
const decoder = new TextDecoder();
|
|
10
|
-
let tail = "";
|
|
11
|
-
for await (const chunk of createReadStream(blobFilePath(dir, sha256))) {
|
|
12
|
-
const text = tail + decoder.decode(chunk as Uint8Array, { stream: true }).toLowerCase();
|
|
13
|
-
for (const term of remaining) if (text.includes(term)) remaining.delete(term);
|
|
14
|
-
if (remaining.size === 0) return true;
|
|
15
|
-
tail = overlap > 0 ? text.slice(-overlap) : "";
|
|
16
|
-
}
|
|
17
|
-
const last = tail + decoder.decode().toLowerCase();
|
|
18
|
-
return [...remaining].every((term) => last.includes(term));
|
|
19
|
-
}
|