@gmickel/gno 2.15.0 → 2.17.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/README.md +1 -1
- package/assets/skill/SKILL.md +27 -0
- package/assets/skill/cli-reference.md +24 -15
- package/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/{gno-browser-clipper-v2.15.0.zip → gno-browser-clipper-v2.17.0.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.17.0.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/spec/cli.md +43 -3
- package/spec/db/schema.sql +53 -1
- package/spec/mcp.md +9 -3
- package/spec/output-schemas/doctor.schema.json +27 -0
- package/spec/output-schemas/retrieval-trace-payloads.schema.json +14 -0
- package/spec/output-schemas/search-results.schema.json +14 -0
- package/spec/output-schemas/status.schema.json +22 -0
- package/src/cli/commands/agents/commands.ts +1 -1
- package/src/cli/commands/ask.ts +1 -1
- package/src/cli/commands/context-build.ts +1 -1
- package/src/cli/commands/doctor.ts +101 -29
- package/src/cli/commands/embed.ts +2 -2
- package/src/cli/commands/links.ts +30 -6
- package/src/cli/commands/mcp/install.ts +2 -2
- package/src/cli/commands/mcp/status.ts +1 -1
- package/src/cli/commands/mcp/uninstall.ts +1 -1
- package/src/cli/commands/query.ts +1 -1
- package/src/cli/commands/shared.ts +4 -4
- package/src/cli/commands/skill/install.ts +1 -1
- package/src/cli/commands/skill/paths-cmd.ts +1 -1
- package/src/cli/commands/skill/uninstall.ts +1 -1
- package/src/cli/commands/status.ts +75 -58
- package/src/cli/commands/vec.ts +180 -8
- package/src/cli/config-cache.ts +86 -0
- package/src/cli/globals.ts +64 -0
- package/src/cli/program.ts +63 -36
- package/src/cli/run.ts +121 -67
- package/src/cli/runtime-health.ts +132 -122
- package/src/cli/session-binding.ts +11 -2
- package/src/config/saver.ts +8 -0
- package/src/config/types.ts +6 -0
- package/src/converters/adapters/browser-export/formats.ts +25 -15
- package/src/converters/adapters/email/adapter.ts +37 -53
- package/src/converters/adapters/email/html.ts +37 -20
- package/src/converters/adapters/email/mime.ts +71 -39
- package/src/converters/adapters/ical/adapter.ts +20 -12
- package/src/converters/adapters/jsonl/adapter.ts +8 -6
- package/src/converters/adapters/shared/html-text.ts +55 -37
- package/src/converters/adapters/shared/ooxml-protection.ts +5 -13
- package/src/converters/adapters/shared/utf8-lines.ts +69 -31
- package/src/converters/adapters/transcript/adapter.ts +12 -7
- package/src/converters/adapters/xlsx/adapter.ts +10 -7
- package/src/converters/adapters/xlsx/sheet-markdown.ts +93 -50
- package/src/converters/canonicalize.ts +17 -3
- package/src/converters/native/markdown.ts +24 -17
- package/src/converters/native/plaintext.ts +5 -6
- package/src/converters/registry.ts +130 -8
- package/src/core/activation-status.ts +4 -8
- package/src/core/change-diff.ts +38 -11
- package/src/core/context-compiler.ts +17 -18
- package/src/core/context-evidence.ts +116 -25
- package/src/core/context-verifier.ts +70 -31
- package/src/core/file-lock.ts +10 -2
- package/src/core/graph-analysis.ts +3 -3
- package/src/core/link-inventory-markdown.ts +2 -2
- package/src/core/links.ts +20 -87
- package/src/core/memory-fence.ts +16 -9
- package/src/core/memory-recall.ts +168 -34
- package/src/core/path-rules.ts +143 -0
- package/src/core/retrieval-trace-session.ts +3 -0
- package/src/core/retrieval-trace.ts +9 -0
- package/src/core/section-parse.ts +16 -6
- package/src/core/typed-metadata.ts +68 -0
- package/src/core/vector-partition-status.ts +13 -0
- package/src/core/wiki-link-syntax.ts +88 -0
- package/src/embed/backlog.ts +142 -60
- package/src/embed/retry.ts +39 -33
- package/src/embed/variant-backlog.ts +582 -116
- package/src/embed/variant-retry.ts +157 -48
- package/src/index.ts +3 -3
- package/src/ingestion/budget-error-codes.ts +13 -0
- package/src/ingestion/chunker.ts +60 -49
- package/src/ingestion/compiled-context.ts +4 -5
- package/src/ingestion/convert-file.ts +1 -1
- package/src/ingestion/document-metadata.ts +16 -9
- package/src/ingestion/excluded-ranges.ts +97 -0
- package/src/ingestion/file-processor.ts +122 -37
- package/src/ingestion/frontmatter.ts +35 -7
- package/src/ingestion/graph-reconciliation.ts +187 -51
- package/src/ingestion/language.ts +66 -61
- package/src/ingestion/position.ts +5 -5
- package/src/ingestion/prepare-file.ts +50 -29
- package/src/ingestion/record-adapter-canonical.ts +37 -26
- package/src/ingestion/record-adapter.ts +46 -26
- package/src/ingestion/record-container.ts +121 -53
- package/src/ingestion/record-path.ts +5 -2
- package/src/ingestion/source-availability/darwin-io.ts +10 -7
- package/src/ingestion/source-availability/darwin-path.ts +21 -3
- package/src/ingestion/source-availability/readers.ts +51 -0
- package/src/ingestion/strip.ts +39 -105
- package/src/ingestion/sync.ts +692 -386
- package/src/ingestion/typed-metadata.ts +10 -4
- package/src/ingestion/walker.ts +485 -158
- package/src/llm/cache.ts +128 -84
- package/src/llm/http-inference.ts +112 -35
- package/src/llm/http-policy.ts +101 -0
- package/src/llm/httpEmbedding.ts +8 -1
- package/src/llm/httpGeneration.ts +5 -1
- package/src/llm/httpRerank.ts +5 -1
- package/src/llm/inference-scope.ts +15 -2
- package/src/llm/lazy-ports.ts +33 -3
- package/src/llm/lockfile.ts +34 -7
- package/src/llm/model-cleanup.ts +24 -0
- package/src/llm/native-worker/client.ts +23 -12
- package/src/llm/native-worker/dispatcher.ts +19 -9
- package/src/llm/native-worker/embedding-identity.ts +42 -16
- package/src/llm/native-worker/entry.ts +2 -1
- package/src/llm/native-worker/owner.ts +1 -0
- package/src/llm/native-worker/ports.ts +86 -23
- package/src/llm/native-worker/protocol.ts +386 -55
- package/src/llm/nodeLlamaCpp/adapter.ts +46 -29
- package/src/llm/nodeLlamaCpp/embedding.ts +93 -40
- package/src/llm/nodeLlamaCpp/generation.ts +194 -30
- package/src/llm/nodeLlamaCpp/lifecycle.ts +2 -0
- package/src/llm/nodeLlamaCpp/rerank-capacity.ts +101 -23
- package/src/llm/nodeLlamaCpp/rerank.ts +253 -44
- package/src/llm/types.ts +14 -0
- package/src/mcp/context.ts +342 -23
- package/src/mcp/http-transport.ts +21 -3
- package/src/mcp/tool-profile-types.ts +62 -0
- package/src/mcp/tool-profile.ts +32 -56
- package/src/mcp/tools/context.ts +5 -1
- package/src/mcp/tools/index.ts +269 -191
- package/src/mcp/tools/links.ts +14 -6
- package/src/mcp/tools/query.ts +60 -37
- package/src/mcp/tools/vsearch.ts +25 -14
- package/src/pipeline/answer.ts +133 -40
- package/src/pipeline/claim-verification.ts +293 -189
- package/src/pipeline/claim-verifier.ts +6 -7
- package/src/pipeline/egress-lineage.ts +37 -26
- package/src/pipeline/exclude.ts +34 -11
- package/src/pipeline/expansion.ts +233 -19
- package/src/pipeline/explain.ts +17 -2
- package/src/pipeline/filters.ts +169 -33
- package/src/pipeline/graph-retrieval.ts +117 -61
- package/src/pipeline/hybrid.ts +626 -330
- package/src/pipeline/hydration.ts +86 -24
- package/src/pipeline/intent.ts +15 -7
- package/src/pipeline/owner-fusion.ts +61 -19
- package/src/pipeline/query-language.ts +15 -2
- package/src/pipeline/rerank.ts +15 -22
- package/src/pipeline/search.ts +193 -72
- package/src/pipeline/snippet.ts +15 -2
- package/src/pipeline/temporal.ts +51 -10
- package/src/pipeline/types.ts +7 -0
- package/src/pipeline/vsearch.ts +269 -154
- package/src/publish/attachment-raster.ts +2 -16
- package/src/publish/encrypted-export.ts +15 -5
- package/src/serve/browse-tree.ts +50 -42
- package/src/serve/connectors.ts +2 -1
- package/src/serve/context.ts +13 -4
- package/src/serve/doc-events.ts +3 -0
- package/src/serve/public/app.tsx +49 -21
- package/src/serve/public/components/BrowseTreeSidebar.tsx +163 -23
- package/src/serve/public/components/CaptureModal.tsx +14 -10
- package/src/serve/public/components/ai-elements/code-block.tsx +87 -50
- package/src/serve/public/components/editor/MarkdownPreview.tsx +99 -67
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/public/globals.css +19 -0
- package/src/serve/public/hooks/useCaptureModal.tsx +23 -10
- package/src/serve/public/lib/metadata-filter.ts +234 -9
- package/src/serve/public/pages/Browse.tsx +61 -27
- package/src/serve/public/pages/DocView.tsx +44 -25
- package/src/serve/public/pages/GraphView.tsx +8 -3
- package/src/serve/resident-runtime.ts +199 -48
- package/src/serve/routes/api.ts +98 -67
- package/src/serve/routes/links.ts +25 -5
- package/src/serve/server.ts +1370 -1180
- package/src/serve/spa-bundle-source.ts +52 -27
- package/src/serve/status.ts +101 -52
- package/src/serve/watch-reconciliation-fallback.ts +11 -7
- package/src/serve/watch-reconciliation-shared.ts +42 -4
- package/src/serve/watch-reconciliation.ts +21 -8
- package/src/serve/watch-service-events.ts +7 -1
- package/src/serve/watch-service-hosts.ts +3 -1
- package/src/serve/watch-service.ts +46 -21
- package/src/serve/watch-snapshot-scan.ts +6 -15
- package/src/sessions/archive.ts +20 -8
- package/src/sessions/sanitize.ts +38 -18
- package/src/sessions/service.ts +180 -102
- package/src/store/migrations/037-performance-indexes.ts +56 -0
- package/src/store/migrations/038-vector-mirror-null-cosine.ts +47 -0
- package/src/store/migrations/039-vector-mirror-v2.ts +94 -0
- package/src/store/migrations/index.ts +6 -0
- package/src/store/sqlite/adapter.ts +1260 -651
- package/src/store/sqlite/chunking-policy.ts +15 -1
- package/src/store/sqlite/eligibility.ts +110 -70
- package/src/store/sqlite/graph-neighbors.ts +71 -46
- package/src/store/sqlite/graph-reference-state.ts +27 -3
- package/src/store/sqlite/graph-similarity.ts +59 -12
- package/src/store/sqlite/metadata-predicate.ts +123 -28
- package/src/store/sqlite/retrieval-trace-management-store.ts +126 -33
- package/src/store/sqlite/retrieval-trace-retention.ts +88 -76
- package/src/store/sqlite/retrieval-trace-rows.ts +7 -3
- package/src/store/types.ts +32 -0
- package/src/store/vector/coarse-router.ts +312 -0
- package/src/store/vector/eligibility.ts +39 -0
- package/src/store/vector/lazy.ts +17 -0
- package/src/store/vector/partition-index.ts +333 -59
- package/src/store/vector/proof-cache.ts +209 -0
- package/src/store/vector/runtime-compat.ts +6 -0
- package/src/store/vector/sqlite-vec.ts +270 -162
- package/src/store/vector/stats.ts +37 -73
- package/src/store/vector/status.ts +169 -53
- package/src/store/vector/stored-vectors.ts +131 -45
- package/src/store/vector/types.ts +19 -0
- package/src/store/vector/v2-mirror.ts +669 -0
- package/src/store/vector/variant-search.ts +1187 -111
- package/src/store/vector/variants.ts +964 -160
- package/browser-extension/artifacts/gno-browser-clipper-v2.15.0.zip.sha256 +0 -1
|
@@ -146,80 +146,85 @@ const repairCommand = (target: McpTarget, scope: McpScope): string =>
|
|
|
146
146
|
export async function checkRegistrationRuntimes(
|
|
147
147
|
overrides: { cwd?: string; homeDir?: string } = {}
|
|
148
148
|
): Promise<RuntimeIssue[]> {
|
|
149
|
-
const issues: RuntimeIssue[] = [];
|
|
150
149
|
const runningBun = realpathOrNull(process.execPath);
|
|
151
150
|
const versions = new Map<string, Promise<string | null>>();
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
151
|
+
const targets = resolveAllMcpPaths("all", "all", overrides);
|
|
152
|
+
|
|
153
|
+
const perTarget = await Promise.all(
|
|
154
|
+
targets.map(
|
|
155
|
+
async ({ target, scope, paths }): Promise<RuntimeIssue | null> => {
|
|
156
|
+
let entry: unknown;
|
|
157
|
+
let configPath = paths.configPath;
|
|
158
|
+
try {
|
|
159
|
+
configPath = await resolveMcpConfigLocation(paths);
|
|
160
|
+
entry = await readRegistrationEntry(configPath, paths.configFormat);
|
|
161
|
+
} catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
const registration =
|
|
165
|
+
entry === undefined
|
|
166
|
+
? null
|
|
167
|
+
: readExistingRegistration(entry, paths.configFormat);
|
|
168
|
+
if (
|
|
169
|
+
!registration ||
|
|
170
|
+
registration.extra.enabled === false ||
|
|
171
|
+
registration.extra.disabled === true
|
|
172
|
+
) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
const { command, args } = registration;
|
|
176
|
+
const viaBun = args[0] === "run" && args.length >= 2;
|
|
177
|
+
if (!viaBun && !isGnoExecutable(command)) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
const subject = `${getTargetDisplayName(target)} (${scope}) ${configPath}`;
|
|
181
|
+
const repair = repairCommand(target, scope);
|
|
182
|
+
const launchFiles = viaBun ? [command, args[1] ?? ""] : [command];
|
|
183
|
+
const missing = launchFiles.filter((path) => !realpathOrNull(path));
|
|
184
|
+
if (missing.length > 0) {
|
|
185
|
+
return {
|
|
186
|
+
kind: "registration",
|
|
187
|
+
severity: "error",
|
|
188
|
+
subject,
|
|
189
|
+
message: `launches ${missing.join(" and ")}, which no longer exists`,
|
|
190
|
+
repair,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (!viaBun) {
|
|
194
|
+
// The gno launcher finds Bun on PATH when it starts.
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const resolved = realpathOrNull(command) ?? command;
|
|
198
|
+
let versionPromise = versions.get(resolved);
|
|
199
|
+
if (!versionPromise) {
|
|
200
|
+
versionPromise = interpreterVersion(command);
|
|
201
|
+
versions.set(resolved, versionPromise);
|
|
202
|
+
}
|
|
203
|
+
const version = await versionPromise;
|
|
204
|
+
if (version && !bunMeetsFloor(version)) {
|
|
205
|
+
return {
|
|
206
|
+
kind: "registration",
|
|
207
|
+
severity: "error",
|
|
208
|
+
subject,
|
|
209
|
+
message: `runs Bun ${version} (${command}), older than the supported minimum ${BUN_FLOOR}`,
|
|
210
|
+
repair,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (resolved !== runningBun) {
|
|
214
|
+
return {
|
|
215
|
+
kind: "registration",
|
|
216
|
+
severity: "info",
|
|
217
|
+
subject,
|
|
218
|
+
message: `runs ${version ? `Bun ${version}` : "a Bun of unknown version"} (${command}), not this Bun ${Bun.version}`,
|
|
219
|
+
repair,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
return perTarget.filter((issue): issue is RuntimeIssue => issue !== null);
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
/** The Bun a resident reports through `/api/status`, if it is GNO. */
|
|
@@ -269,57 +274,62 @@ function restartSteps(
|
|
|
269
274
|
* another GNO version is read through its HTTP status; it is never signalled.
|
|
270
275
|
*/
|
|
271
276
|
export async function checkResidentRuntimes(): Promise<RuntimeIssue[]> {
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
277
|
+
const perKind = await Promise.all(
|
|
278
|
+
(["serve", "daemon"] as const).map(
|
|
279
|
+
async (kind): Promise<RuntimeIssue | null> => {
|
|
280
|
+
const { pidFile } = resolveProcessPaths(kind);
|
|
281
|
+
let payload: Awaited<ReturnType<typeof readPidFile>>;
|
|
282
|
+
try {
|
|
283
|
+
payload = await readPidFile(pidFile);
|
|
284
|
+
} catch {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
if (!payload || payload.cmd !== kind || !isProcessAlive(payload.pid)) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
const sameVersion = payload.version === VERSION;
|
|
291
|
+
let version = payload.bun_version ?? null;
|
|
292
|
+
if (!version && typeof payload.port === "number") {
|
|
293
|
+
version = await residentBunVersion(payload.port);
|
|
294
|
+
}
|
|
295
|
+
const subject = `gno ${kind} (pid ${payload.pid}, GNO ${payload.version})`;
|
|
296
|
+
const repair = restartSteps(kind, payload.pid, sameVersion);
|
|
297
|
+
if (!version) {
|
|
298
|
+
if (!sameVersion) {
|
|
299
|
+
return {
|
|
300
|
+
kind: "resident",
|
|
301
|
+
severity: "info",
|
|
302
|
+
subject,
|
|
303
|
+
message:
|
|
304
|
+
"is running from another GNO version; its Bun version is unknown",
|
|
305
|
+
repair,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
if (!bunMeetsFloor(version)) {
|
|
311
|
+
return {
|
|
312
|
+
kind: "resident",
|
|
313
|
+
severity: "error",
|
|
314
|
+
subject,
|
|
315
|
+
message: `runs Bun ${version}, older than the supported minimum ${BUN_FLOOR}`,
|
|
316
|
+
repair,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
if (Bun.semver.order(version, Bun.version) < 0) {
|
|
320
|
+
return {
|
|
321
|
+
kind: "resident",
|
|
322
|
+
severity: "warn",
|
|
323
|
+
subject,
|
|
324
|
+
message: `runs Bun ${version}, older than this Bun ${Bun.version}`,
|
|
325
|
+
repair,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
301
329
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
issues.push({
|
|
306
|
-
kind: "resident",
|
|
307
|
-
severity: "error",
|
|
308
|
-
subject,
|
|
309
|
-
message: `runs Bun ${version}, older than the supported minimum ${BUN_FLOOR}`,
|
|
310
|
-
repair,
|
|
311
|
-
});
|
|
312
|
-
} else if (Bun.semver.order(version, Bun.version) < 0) {
|
|
313
|
-
issues.push({
|
|
314
|
-
kind: "resident",
|
|
315
|
-
severity: "warn",
|
|
316
|
-
subject,
|
|
317
|
-
message: `runs Bun ${version}, older than this Bun ${Bun.version}`,
|
|
318
|
-
repair,
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return issues;
|
|
330
|
+
)
|
|
331
|
+
);
|
|
332
|
+
return perKind.filter((issue): issue is RuntimeIssue => issue !== null);
|
|
323
333
|
}
|
|
324
334
|
|
|
325
335
|
/** One line per issue for terminal output. */
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
import type { Config } from "../config/types";
|
|
13
13
|
|
|
14
14
|
import { getIndexDbPath } from "../app/constants";
|
|
15
|
-
import { getConfigPaths
|
|
15
|
+
import { getConfigPaths } from "../config";
|
|
16
16
|
import { assertSessionBinding } from "../sessions/binding";
|
|
17
17
|
import { SessionsError } from "../sessions/types";
|
|
18
|
+
import {
|
|
19
|
+
isSessionBindingVerifiedInInvocation,
|
|
20
|
+
loadConfigCached,
|
|
21
|
+
markSessionBindingVerifiedInInvocation,
|
|
22
|
+
} from "./config-cache";
|
|
18
23
|
import { CliError } from "./errors";
|
|
19
24
|
|
|
20
25
|
export async function assertCliSessionBinding(
|
|
@@ -23,10 +28,13 @@ export async function assertCliSessionBinding(
|
|
|
23
28
|
loadedConfig?: Config
|
|
24
29
|
): Promise<void> {
|
|
25
30
|
const path = configPath ?? getConfigPaths().configFile;
|
|
31
|
+
if (isSessionBindingVerifiedInInvocation(path, indexName)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
26
34
|
let config = loadedConfig;
|
|
27
35
|
if (!config) {
|
|
28
36
|
if (!(await Bun.file(path).exists())) return;
|
|
29
|
-
const loaded = await
|
|
37
|
+
const loaded = await loadConfigCached(path);
|
|
30
38
|
// Unreadable configs are reported by the command itself.
|
|
31
39
|
if (!loaded.ok) return;
|
|
32
40
|
config = loaded.value;
|
|
@@ -38,6 +46,7 @@ export async function assertCliSessionBinding(
|
|
|
38
46
|
indexName,
|
|
39
47
|
dbPath: getIndexDbPath(indexName),
|
|
40
48
|
});
|
|
49
|
+
markSessionBindingVerifiedInInvocation(path, indexName);
|
|
41
50
|
} catch (error) {
|
|
42
51
|
if (error instanceof SessionsError) {
|
|
43
52
|
throw new CliError("VALIDATION", error.message, {
|
package/src/config/saver.ts
CHANGED
|
@@ -23,6 +23,13 @@ export type SaveError =
|
|
|
23
23
|
| { code: "VALIDATION_ERROR"; message: string }
|
|
24
24
|
| { code: "IO_ERROR"; message: string; cause: Error };
|
|
25
25
|
|
|
26
|
+
let configWriteGeneration = 0;
|
|
27
|
+
|
|
28
|
+
/** Monotonic counter incremented whenever config/text is atomically saved. */
|
|
29
|
+
export function getConfigWriteGeneration(): number {
|
|
30
|
+
return configWriteGeneration;
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
27
34
|
// Saving Functions
|
|
28
35
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -134,6 +141,7 @@ export async function saveTextToPath(
|
|
|
134
141
|
};
|
|
135
142
|
}
|
|
136
143
|
|
|
144
|
+
configWriteGeneration += 1;
|
|
137
145
|
return { ok: true, path: filePath };
|
|
138
146
|
}
|
|
139
147
|
|
package/src/config/types.ts
CHANGED
|
@@ -683,6 +683,12 @@ export const ConfigSchema = z.object({
|
|
|
683
683
|
)
|
|
684
684
|
.default(DEFAULT_BUSY_TIMEOUT_MS),
|
|
685
685
|
|
|
686
|
+
/**
|
|
687
|
+
* Toggle cost-routed two-stage bit coarse vec0 mirror routing for large vector scopes.
|
|
688
|
+
* Defaults to true; set to false to keep all searches on the exact paths.
|
|
689
|
+
*/
|
|
690
|
+
coarseVectorSearch: z.boolean().optional(),
|
|
691
|
+
|
|
686
692
|
/** Optional terminal hyperlink editor URI template */
|
|
687
693
|
editorUriTemplate: z.string().min(1).optional(),
|
|
688
694
|
|
|
@@ -42,8 +42,15 @@ const SUPPORTED_JSON_KEYS = new Set([
|
|
|
42
42
|
"readingList",
|
|
43
43
|
"reading_list",
|
|
44
44
|
]);
|
|
45
|
+
const SUPPORTED_JSON_KEY_LIST = [...SUPPORTED_JSON_KEYS];
|
|
45
46
|
const BOOKMARK_EXPORT_DOCUMENT_PATTERN =
|
|
46
47
|
/<!DOCTYPE\s+(?:NETSCAPE-Bookmark-file-1\b[^>]*|html\s*)>/i;
|
|
48
|
+
const OPENING_DL_PATTERN = /<DL\b[^>]*>/gi;
|
|
49
|
+
const CLOSING_DL_PATTERN = /<\/DL\s*>/gi;
|
|
50
|
+
const OPENING_ANCHOR_PATTERN = /<A\b[^>]*>/gi;
|
|
51
|
+
const CLOSING_ANCHOR_PATTERN = /<\/A\s*>/gi;
|
|
52
|
+
const OPENING_HEADING_PATTERN = /<H3\b[^>]*>/gi;
|
|
53
|
+
const CLOSING_HEADING_PATTERN = /<\/H3\s*>/gi;
|
|
47
54
|
|
|
48
55
|
const plainText = (value: string): string =>
|
|
49
56
|
htmlFragmentToText(value).replace(/\s+/g, " ").trim();
|
|
@@ -62,23 +69,26 @@ const attributes = (value: string): Map<string, string> => {
|
|
|
62
69
|
const hasSensitiveJsonKey = (value: Record<string, unknown>): boolean =>
|
|
63
70
|
Object.keys(value).some((key) => SENSITIVE_JSON_KEYS.has(key.toLowerCase()));
|
|
64
71
|
|
|
65
|
-
const
|
|
66
|
-
|
|
72
|
+
const countTagMatches = (source: string, pattern: RegExp): number => {
|
|
73
|
+
pattern.lastIndex = 0;
|
|
74
|
+
let count = 0;
|
|
75
|
+
while (pattern.exec(source) !== null) {
|
|
76
|
+
count += 1;
|
|
77
|
+
}
|
|
78
|
+
return count;
|
|
79
|
+
};
|
|
67
80
|
|
|
68
81
|
const hasCompleteNetscapeStructure = (source: string): boolean => {
|
|
69
82
|
if (!BOOKMARK_EXPORT_DOCUMENT_PATTERN.test(source)) return false;
|
|
70
|
-
const openingDl =
|
|
71
|
-
const closingDl =
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
openingAnchors === closingAnchors &&
|
|
80
|
-
openingHeadings === closingHeadings
|
|
81
|
-
);
|
|
83
|
+
const openingDl = countTagMatches(source, OPENING_DL_PATTERN);
|
|
84
|
+
const closingDl = countTagMatches(source, CLOSING_DL_PATTERN);
|
|
85
|
+
if (openingDl <= 0 || openingDl !== closingDl) return false;
|
|
86
|
+
const openingAnchors = countTagMatches(source, OPENING_ANCHOR_PATTERN);
|
|
87
|
+
const closingAnchors = countTagMatches(source, CLOSING_ANCHOR_PATTERN);
|
|
88
|
+
if (openingAnchors !== closingAnchors) return false;
|
|
89
|
+
const openingHeadings = countTagMatches(source, OPENING_HEADING_PATTERN);
|
|
90
|
+
const closingHeadings = countTagMatches(source, CLOSING_HEADING_PATTERN);
|
|
91
|
+
return openingHeadings === closingHeadings;
|
|
82
92
|
};
|
|
83
93
|
|
|
84
94
|
const exportDate = (value: string | undefined): string | undefined => {
|
|
@@ -321,7 +331,7 @@ export function parseBrowserJson(
|
|
|
321
331
|
const folderName =
|
|
322
332
|
!record && typeof object.name === "string" ? object.name : undefined;
|
|
323
333
|
const nextFolders = folderName ? [...folders, folderName] : folders;
|
|
324
|
-
const supportedChildren =
|
|
334
|
+
const supportedChildren = SUPPORTED_JSON_KEY_LIST.filter((key) =>
|
|
325
335
|
Object.hasOwn(object, key)
|
|
326
336
|
);
|
|
327
337
|
if (!record && supportedChildren.length === 0) {
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
const ADAPTER_ID = "native/email-export";
|
|
17
17
|
const ADAPTER_VERSION = "1.0.0";
|
|
18
18
|
const MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
|
|
19
|
-
const BINARY_STRING_CHUNK = 8_192;
|
|
20
19
|
const CONTROL_CHAR_PATTERN = new RegExp(
|
|
21
20
|
`[${String.fromCharCode(0)}-${String.fromCharCode(31)}${String.fromCharCode(127)}]`,
|
|
22
21
|
"g"
|
|
@@ -37,20 +36,10 @@ interface BinaryLine {
|
|
|
37
36
|
const hashText = (value: string): string =>
|
|
38
37
|
new Bun.CryptoHasher("sha256").update(value).digest("hex");
|
|
39
38
|
|
|
40
|
-
const bytesToBinary = (bytes: Uint8Array): string =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
String.fromCharCode(
|
|
45
|
-
...bytes.subarray(
|
|
46
|
-
offset,
|
|
47
|
-
Math.min(offset + BINARY_STRING_CHUNK, bytes.length)
|
|
48
|
-
)
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
return pieces.join("");
|
|
53
|
-
};
|
|
39
|
+
const bytesToBinary = (bytes: Uint8Array): string =>
|
|
40
|
+
Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString(
|
|
41
|
+
"latin1"
|
|
42
|
+
);
|
|
54
43
|
|
|
55
44
|
const rawMessageLimit = (input: RecordAdapterInput): number => {
|
|
56
45
|
const attachmentLimit = Math.max(
|
|
@@ -75,44 +64,53 @@ async function* binaryLines(
|
|
|
75
64
|
let oversized = false;
|
|
76
65
|
for await (const chunk of input.open()) {
|
|
77
66
|
let start = 0;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
while (start < chunk.length) {
|
|
68
|
+
const nl = chunk.indexOf(0x0a, start);
|
|
69
|
+
if (nl === -1) break;
|
|
70
|
+
const segmentLen = nl - start;
|
|
71
|
+
rawLength += segmentLen + 1;
|
|
82
72
|
if (!oversized) {
|
|
83
|
-
if (pendingChars +
|
|
73
|
+
if (pendingChars + segmentLen > maxLineChars) {
|
|
84
74
|
oversized = true;
|
|
85
75
|
pendingParts = [];
|
|
86
76
|
pendingChars = 0;
|
|
87
|
-
} else {
|
|
88
|
-
pendingParts.push(
|
|
89
|
-
pendingChars +=
|
|
77
|
+
} else if (segmentLen > 0) {
|
|
78
|
+
pendingParts.push(bytesToBinary(chunk.subarray(start, nl)));
|
|
79
|
+
pendingChars += segmentLen;
|
|
90
80
|
}
|
|
91
81
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
82
|
+
if (oversized) {
|
|
83
|
+
yield { rawLength, oversized: true };
|
|
84
|
+
} else {
|
|
85
|
+
const joined =
|
|
86
|
+
pendingParts.length === 0
|
|
87
|
+
? ""
|
|
88
|
+
: pendingParts.length === 1
|
|
89
|
+
? pendingParts[0]!
|
|
90
|
+
: pendingParts.join("");
|
|
91
|
+
yield {
|
|
92
|
+
rawLength,
|
|
93
|
+
value: joined.endsWith("\r") ? joined.slice(0, -1) : joined,
|
|
94
|
+
oversized: false,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
99
97
|
pendingParts = [];
|
|
100
98
|
pendingChars = 0;
|
|
101
99
|
rawLength = 0;
|
|
102
100
|
oversized = false;
|
|
103
|
-
start =
|
|
101
|
+
start = nl + 1;
|
|
104
102
|
}
|
|
105
103
|
if (start < chunk.length) {
|
|
106
|
-
const
|
|
107
|
-
rawLength +=
|
|
104
|
+
const segmentLen = chunk.length - start;
|
|
105
|
+
rawLength += segmentLen;
|
|
108
106
|
if (!oversized) {
|
|
109
|
-
if (pendingChars +
|
|
107
|
+
if (pendingChars + segmentLen > maxLineChars) {
|
|
110
108
|
oversized = true;
|
|
111
109
|
pendingParts = [];
|
|
112
110
|
pendingChars = 0;
|
|
113
111
|
} else {
|
|
114
|
-
pendingParts.push(
|
|
115
|
-
pendingChars +=
|
|
112
|
+
pendingParts.push(bytesToBinary(chunk.subarray(start)));
|
|
113
|
+
pendingChars += segmentLen;
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
}
|
|
@@ -254,25 +252,11 @@ const markdownInline = (value: string): string =>
|
|
|
254
252
|
.replace(/\s+/g, " ")
|
|
255
253
|
.trim();
|
|
256
254
|
|
|
257
|
-
const
|
|
258
|
-
"\\",
|
|
259
|
-
"`",
|
|
260
|
-
"*",
|
|
261
|
-
"_",
|
|
262
|
-
"[",
|
|
263
|
-
"]",
|
|
264
|
-
"<",
|
|
265
|
-
">",
|
|
266
|
-
]);
|
|
255
|
+
const BODY_MARKDOWN_ESCAPE_REGEX = /([\\`*_[\]<>])/g;
|
|
267
256
|
|
|
268
257
|
const safeBodyMarkdown = (value: string): string => {
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
if (character === "\r") continue;
|
|
272
|
-
if (BODY_MARKDOWN_ESCAPE_CHARS.has(character)) output.push("\\");
|
|
273
|
-
output.push(character);
|
|
274
|
-
}
|
|
275
|
-
return output.join("");
|
|
258
|
+
const withoutCr = value.includes("\r") ? value.replaceAll("\r", "") : value;
|
|
259
|
+
return withoutCr.replace(BODY_MARKDOWN_ESCAPE_REGEX, "\\$1");
|
|
276
260
|
};
|
|
277
261
|
|
|
278
262
|
const renderAttachments = (attachments: ParsedAttachment[]): string => {
|
|
@@ -28,15 +28,20 @@ const HTML_LINE_BREAK_ELEMENTS = new Set([
|
|
|
28
28
|
"h6",
|
|
29
29
|
]);
|
|
30
30
|
|
|
31
|
+
const NAMED_HTML_ENTITIES: Record<string, string> = {
|
|
32
|
+
amp: "&",
|
|
33
|
+
apos: "'",
|
|
34
|
+
gt: ">",
|
|
35
|
+
lt: "<",
|
|
36
|
+
nbsp: " ",
|
|
37
|
+
quot: '"',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const DANGEROUS_TAG_QUICK_TEST =
|
|
41
|
+
/<\/?(?:script|style|iframe|object|embed|form|svg|math|head)(?![a-z\d-])/i;
|
|
42
|
+
|
|
31
43
|
const decodeHtmlEntities = (value: string): string => {
|
|
32
|
-
|
|
33
|
-
amp: "&",
|
|
34
|
-
apos: "'",
|
|
35
|
-
gt: ">",
|
|
36
|
-
lt: "<",
|
|
37
|
-
nbsp: " ",
|
|
38
|
-
quot: '"',
|
|
39
|
-
};
|
|
44
|
+
if (!value.includes("&")) return value;
|
|
40
45
|
return value.replace(
|
|
41
46
|
/&(?:#(\d+)|#x([\da-f]+)|([a-z]+));/gi,
|
|
42
47
|
(_match, decimal: string, hexadecimal: string, name: string) => {
|
|
@@ -50,7 +55,7 @@ const decodeHtmlEntities = (value: string): string => {
|
|
|
50
55
|
? String.fromCodePoint(code)
|
|
51
56
|
: "";
|
|
52
57
|
}
|
|
53
|
-
return
|
|
58
|
+
return NAMED_HTML_ENTITIES[name.toLowerCase()] ?? "";
|
|
54
59
|
}
|
|
55
60
|
);
|
|
56
61
|
};
|
|
@@ -95,6 +100,7 @@ const parseHtmlTag = (raw: string): ParsedHtmlTag | undefined => {
|
|
|
95
100
|
const embeddedDangerousTag = (
|
|
96
101
|
raw: string
|
|
97
102
|
): Pick<ParsedHtmlTag, "name" | "closing"> | undefined => {
|
|
103
|
+
if (!DANGEROUS_TAG_QUICK_TEST.test(raw)) return undefined;
|
|
98
104
|
const lower = raw.toLowerCase();
|
|
99
105
|
for (const name of DANGEROUS_HTML_ELEMENTS) {
|
|
100
106
|
for (const closing of [true, false]) {
|
|
@@ -113,24 +119,31 @@ const embeddedDangerousTag = (
|
|
|
113
119
|
};
|
|
114
120
|
|
|
115
121
|
const htmlToPlainText = (value: string): string => {
|
|
122
|
+
let lt = value.indexOf("<");
|
|
123
|
+
if (lt === -1) return value;
|
|
116
124
|
const output: string[] = [];
|
|
117
125
|
const suppressedElements: string[] = [];
|
|
118
126
|
let index = 0;
|
|
119
|
-
while (
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
while (lt !== -1) {
|
|
128
|
+
if (suppressedElements.length === 0 && lt > index) {
|
|
129
|
+
output.push(value.slice(index, lt));
|
|
130
|
+
}
|
|
131
|
+
if (value.startsWith("<!--", lt)) {
|
|
132
|
+
const commentEnd = value.indexOf("-->", lt + 4);
|
|
133
|
+
if (commentEnd < 0) {
|
|
134
|
+
index = value.length;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
123
137
|
index = commentEnd + 3;
|
|
138
|
+
lt = value.indexOf("<", index);
|
|
124
139
|
continue;
|
|
125
140
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
index
|
|
129
|
-
|
|
141
|
+
const tagEnd = findTagEnd(value, lt);
|
|
142
|
+
if (tagEnd < 0) {
|
|
143
|
+
index = value.length;
|
|
144
|
+
break;
|
|
130
145
|
}
|
|
131
|
-
const
|
|
132
|
-
if (tagEnd < 0) break;
|
|
133
|
-
const rawTag = value.slice(index, tagEnd + 1);
|
|
146
|
+
const rawTag = value.slice(lt, tagEnd + 1);
|
|
134
147
|
const parsed = embeddedDangerousTag(rawTag) ?? parseHtmlTag(rawTag);
|
|
135
148
|
if (parsed && DANGEROUS_HTML_ELEMENTS.has(parsed.name)) {
|
|
136
149
|
if (parsed.closing) {
|
|
@@ -148,6 +161,10 @@ const htmlToPlainText = (value: string): string => {
|
|
|
148
161
|
output.push("\n");
|
|
149
162
|
}
|
|
150
163
|
index = tagEnd + 1;
|
|
164
|
+
lt = value.indexOf("<", index);
|
|
165
|
+
}
|
|
166
|
+
if (suppressedElements.length === 0 && index < value.length) {
|
|
167
|
+
output.push(value.slice(index));
|
|
151
168
|
}
|
|
152
169
|
return output.join("");
|
|
153
170
|
};
|