@gmickel/gno 2.15.0 → 2.16.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/cli-reference.md +4 -2
- package/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/{gno-browser-clipper-v2.15.0.zip → gno-browser-clipper-v2.16.0.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.16.0.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/spec/cli.md +1 -1
- 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/embed.ts +2 -2
- package/src/cli/commands/links.ts +1 -1
- 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/config-cache.ts +86 -0
- package/src/cli/globals.ts +64 -0
- package/src/cli/program.ts +20 -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/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/section-parse.ts +16 -6
- package/src/core/typed-metadata.ts +68 -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 +546 -114
- 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 +7 -5
- 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/filters.ts +169 -33
- package/src/pipeline/graph-retrieval.ts +117 -61
- package/src/pipeline/hybrid.ts +598 -329
- 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/vsearch.ts +250 -152
- 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 +18 -4
- 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/index.ts +2 -0
- package/src/store/sqlite/adapter.ts +1217 -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/eligibility.ts +39 -0
- package/src/store/vector/lazy.ts +17 -0
- package/src/store/vector/partition-index.ts +28 -45
- package/src/store/vector/proof-cache.ts +103 -0
- package/src/store/vector/sqlite-vec.ts +230 -139
- package/src/store/vector/stats.ts +29 -73
- package/src/store/vector/status.ts +151 -52
- package/src/store/vector/stored-vectors.ts +131 -45
- package/src/store/vector/types.ts +10 -0
- package/src/store/vector/variant-search.ts +771 -109
- package/src/store/vector/variants.ts +495 -139
- package/browser-extension/artifacts/gno-browser-clipper-v2.15.0.zip.sha256 +0 -1
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ See the [guide](docs/COMPILED-CONTEXT.md).
|
|
|
139
139
|
|
|
140
140
|
<!-- public-truth:current-version -->
|
|
141
141
|
|
|
142
|
-
> Current source version: **v2.
|
|
142
|
+
> Current source version: **v2.16.0**. See [CHANGELOG.md](./CHANGELOG.md).
|
|
143
143
|
|
|
144
144
|
<!-- /public-truth -->
|
|
145
145
|
|
|
@@ -117,9 +117,11 @@ gno collection clear-embeddings <name> [--all] [--json]
|
|
|
117
117
|
### gno embed
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
|
-
gno embed [collection] [--collection <name>] [--force] [--model <uri>] [--batch-size <n>] [--dry-run] [--new-partition]
|
|
120
|
+
gno embed [collection] [--collection <name>] [--force] [--model <uri>] [--batch-size <n>] [--max-chunks <n>] [--max-seconds <n>] [--dry-run] [--new-partition]
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
+
Default foreground `--batch-size` is `64` (background embedding is capped at `32`). Use `--max-chunks` or `--max-seconds` to process a large backlog in bounded slices.
|
|
124
|
+
|
|
123
125
|
Switching `GNO_LLAMA_GPU`, Bun version or thread count resumes the existing
|
|
124
126
|
vector partition when a measured sample of stored chunks matches. If it does
|
|
125
127
|
not, embed refuses to build a separate partition without `--new-partition`
|
|
@@ -169,7 +171,7 @@ them in a collection instead.
|
|
|
169
171
|
Generate embeddings only.
|
|
170
172
|
|
|
171
173
|
```bash
|
|
172
|
-
gno embed [--force] [--model <uri>] [--batch-size <n>] [--dry-run] [--new-partition]
|
|
174
|
+
gno embed [--force] [--model <uri>] [--batch-size <n>] [--max-chunks <n>] [--max-seconds <n>] [--dry-run] [--new-partition]
|
|
173
175
|
```
|
|
174
176
|
|
|
175
177
|
## Project Profiles
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4aacdd5ad2205fdb41b02a4ec771b875b7fc73c771a74c4342925636b18c8729 gno-browser-clipper-v2.16.0.zip
|
package/package.json
CHANGED
package/spec/cli.md
CHANGED
|
@@ -1454,7 +1454,7 @@ never confirms; without confirmation embed exits 2 and writes nothing.
|
|
|
1454
1454
|
| ------------------------ | -------- | ------- | ---------------------------------------------------------------------------- |
|
|
1455
1455
|
| `--force` | boolean | false | Re-embed all chunks (ignore existing vectors) |
|
|
1456
1456
|
| `--model` | string | config | Override embedding model URI |
|
|
1457
|
-
| `--batch-size` | integer |
|
|
1457
|
+
| `--batch-size` | integer | 64 | Chunks per batch (foreground default; background capped at 32) |
|
|
1458
1458
|
| `--dry-run` | boolean | false | Show what would be embedded without doing it |
|
|
1459
1459
|
| `--max-chunks <n>` | integer | - | Stop after the batch that reaches this many chunks (see Bounded runs above) |
|
|
1460
1460
|
| `--max-seconds <n>` | integer | - | Stop after the batch that reaches this many seconds (see Bounded runs above) |
|
package/src/cli/commands/ask.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { resolveDownloadPolicy } from "../../llm/policy";
|
|
|
22
22
|
import { resolveModelUri } from "../../llm/registry";
|
|
23
23
|
import { createVectorIndexPort } from "../../store/vector";
|
|
24
24
|
import { CliError } from "../errors";
|
|
25
|
-
import { getGlobals } from "../
|
|
25
|
+
import { getGlobals } from "../globals";
|
|
26
26
|
import {
|
|
27
27
|
createProgressRenderer,
|
|
28
28
|
createThrottledProgressRenderer,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
type VectorIndexPort,
|
|
65
65
|
type VectorStatsPort,
|
|
66
66
|
} from "../../store/vector";
|
|
67
|
-
import { getGlobals } from "../
|
|
67
|
+
import { getGlobals } from "../globals";
|
|
68
68
|
import {
|
|
69
69
|
createProgressRenderer,
|
|
70
70
|
createThrottledProgressRenderer,
|
|
@@ -652,7 +652,7 @@ async function confirmSeparatePartition(message: string): Promise<boolean> {
|
|
|
652
652
|
* Execute gno embed command.
|
|
653
653
|
*/
|
|
654
654
|
export async function embed(options: EmbedOptions = {}): Promise<EmbedResult> {
|
|
655
|
-
const batchSize = options.batchSize ??
|
|
655
|
+
const batchSize = options.batchSize ?? 64;
|
|
656
656
|
const force = options.force ?? false;
|
|
657
657
|
const dryRun = options.dryRun ?? false;
|
|
658
658
|
const limits: EmbedRunLimits | undefined =
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module src/cli/commands/links
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { DocEdgeRow, DocLinkRow
|
|
8
|
+
import type { DocEdgeRow, DocLinkRow } from "../../store/types";
|
|
9
9
|
|
|
10
10
|
import { resolveDocRef } from "../../core/ref-parser";
|
|
11
11
|
import { initStore } from "./shared";
|
|
@@ -9,9 +9,9 @@ import { getConfigPaths, toAbsolutePath } from "../../../config/paths.js";
|
|
|
9
9
|
import {
|
|
10
10
|
type McpToolProfile,
|
|
11
11
|
parseMcpToolProfile,
|
|
12
|
-
} from "../../../mcp/tool-profile.js";
|
|
12
|
+
} from "../../../mcp/tool-profile-types.js";
|
|
13
13
|
import { CliError } from "../../errors.js";
|
|
14
|
-
import { getGlobals } from "../../
|
|
14
|
+
import { getGlobals } from "../../globals.js";
|
|
15
15
|
import { resolveMcpConfigLocation } from "./config-discovery.js";
|
|
16
16
|
import {
|
|
17
17
|
getJsoncServerEntry,
|
|
@@ -11,7 +11,7 @@ import type { StandardMcpEntry } from "./config.js";
|
|
|
11
11
|
|
|
12
12
|
import { normalizeConnectorWorkspaceEnvironment } from "../../../core/connector-environment";
|
|
13
13
|
import { CliError } from "../../errors.js";
|
|
14
|
-
import { getGlobals } from "../../
|
|
14
|
+
import { getGlobals } from "../../globals.js";
|
|
15
15
|
import {
|
|
16
16
|
configPathEntryExists,
|
|
17
17
|
resolveMcpConfigLocation,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
type VectorIndexPort,
|
|
40
40
|
} from "../../store/vector";
|
|
41
41
|
import { VECTOR_RUNTIME_INCOMPATIBLE } from "../../store/vector/variant-search";
|
|
42
|
-
import { getGlobals } from "../
|
|
42
|
+
import { getGlobals } from "../globals";
|
|
43
43
|
import {
|
|
44
44
|
createProgressRenderer,
|
|
45
45
|
createThrottledProgressRenderer,
|
|
@@ -17,15 +17,15 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
getConfigPaths,
|
|
19
19
|
isInitialized,
|
|
20
|
-
loadConfig,
|
|
21
20
|
writeConfigWarningsToStderr,
|
|
22
21
|
} from "../../config";
|
|
23
22
|
import { tracePhase } from "../../core/phase-trace";
|
|
24
|
-
import { BUDGET_ERROR_CODES } from "../../ingestion/
|
|
23
|
+
import { BUDGET_ERROR_CODES } from "../../ingestion/budget-error-codes";
|
|
25
24
|
import {
|
|
26
25
|
SqliteAdapter,
|
|
27
26
|
staleCollectionsMessage,
|
|
28
27
|
} from "../../store/sqlite/adapter";
|
|
28
|
+
import { loadConfigCached } from "../config-cache";
|
|
29
29
|
import { assertCliSessionBinding } from "../session-binding";
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -78,8 +78,8 @@ export async function initStore(
|
|
|
78
78
|
return { ok: false, error: "GNO not initialized. Run: gno init" };
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
// Load config
|
|
82
|
-
const configResult = await
|
|
81
|
+
// Load config (reused within the same CLI invocation when unchanged)
|
|
82
|
+
const configResult = await loadConfigCached(options.configPath);
|
|
83
83
|
if (!configResult.ok) {
|
|
84
84
|
return { ok: false, error: configResult.error.message };
|
|
85
85
|
}
|
|
@@ -10,7 +10,7 @@ import { dirname, join } from "node:path";
|
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
|
|
12
12
|
import { CliError } from "../../errors.js";
|
|
13
|
-
import { getGlobals } from "../../
|
|
13
|
+
import { getGlobals } from "../../globals.js";
|
|
14
14
|
import {
|
|
15
15
|
resolveSkillPaths,
|
|
16
16
|
SKILL_TARGETS,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
|
|
10
|
-
import { getGlobals } from "../../
|
|
10
|
+
import { getGlobals } from "../../globals.js";
|
|
11
11
|
import { resolveAllPaths, type SkillScope, type SkillTarget } from "./paths.js";
|
|
12
12
|
|
|
13
13
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -9,7 +9,7 @@ import { rm } from "node:fs/promises";
|
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
|
|
11
11
|
import { CliError } from "../../errors.js";
|
|
12
|
-
import { getGlobals } from "../../
|
|
12
|
+
import { getGlobals } from "../../globals.js";
|
|
13
13
|
import {
|
|
14
14
|
resolveSkillPaths,
|
|
15
15
|
SKILL_TARGETS,
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
buildContentTypeBoostStatus,
|
|
17
17
|
getConfigPaths,
|
|
18
18
|
isInitialized,
|
|
19
|
-
loadConfig,
|
|
20
19
|
} from "../../config";
|
|
21
20
|
import {
|
|
22
21
|
describeConnectorSummary,
|
|
@@ -32,7 +31,7 @@ import {
|
|
|
32
31
|
formatMemoryStatusLines,
|
|
33
32
|
} from "../../core/memory-diagnostics";
|
|
34
33
|
import { formatVectorPartitionLines } from "../../core/vector-partition-status";
|
|
35
|
-
import { BUDGET_ERROR_CODES } from "../../ingestion/
|
|
34
|
+
import { BUDGET_ERROR_CODES } from "../../ingestion/budget-error-codes";
|
|
36
35
|
import {
|
|
37
36
|
checkCollectionRoots,
|
|
38
37
|
type CollectionRootError,
|
|
@@ -42,6 +41,7 @@ import { getActivePreset, resolveModelUri } from "../../llm/registry";
|
|
|
42
41
|
import { getConnectorVerificationTargets } from "../../serve/connectors";
|
|
43
42
|
import { createStandaloneResidentStatus } from "../../serve/resident-status";
|
|
44
43
|
import { SqliteAdapter } from "../../store/sqlite/adapter";
|
|
44
|
+
import { loadConfigCached } from "../config-cache";
|
|
45
45
|
import {
|
|
46
46
|
formatBackgroundIssue,
|
|
47
47
|
residentIssues,
|
|
@@ -115,37 +115,19 @@ const STALE_COLLECTIONS_HINT =
|
|
|
115
115
|
const BUDGET_STOP_SCAN_LIMIT = 100;
|
|
116
116
|
/** Most budget stops listed in status output. */
|
|
117
117
|
const MAX_BUDGET_STOPS = 10;
|
|
118
|
+
const BUDGET_ERROR_CODE_LIST = Array.from(BUDGET_ERROR_CODES);
|
|
118
119
|
|
|
119
120
|
/**
|
|
120
121
|
* Files whose latest indexing attempt stopped at the conversion budget, from
|
|
121
122
|
* the recent error log, kept only while the document still carries that code.
|
|
122
123
|
*/
|
|
123
124
|
async function collectBudgetStops(store: SqliteAdapter): Promise<BudgetStop[]> {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (seen.has(key)) continue;
|
|
131
|
-
seen.add(key);
|
|
132
|
-
if (!BUDGET_ERROR_CODES.has(row.code)) continue;
|
|
133
|
-
const document = await store.getDocument(row.collection, row.relPath);
|
|
134
|
-
if (
|
|
135
|
-
document.ok &&
|
|
136
|
-
document.value?.active &&
|
|
137
|
-
document.value.lastErrorCode === row.code
|
|
138
|
-
) {
|
|
139
|
-
stops.push({
|
|
140
|
-
collection: row.collection,
|
|
141
|
-
relPath: row.relPath,
|
|
142
|
-
code: row.code,
|
|
143
|
-
message: row.message,
|
|
144
|
-
});
|
|
145
|
-
if (stops.length >= MAX_BUDGET_STOPS) break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return stops;
|
|
125
|
+
const stops = await store.getRecentBudgetStops(
|
|
126
|
+
BUDGET_ERROR_CODE_LIST,
|
|
127
|
+
BUDGET_STOP_SCAN_LIMIT,
|
|
128
|
+
MAX_BUDGET_STOPS
|
|
129
|
+
);
|
|
130
|
+
return stops.ok ? stops.value : [];
|
|
149
131
|
}
|
|
150
132
|
|
|
151
133
|
/** A background issue reported by (or about) a running detached resident. */
|
|
@@ -423,13 +405,22 @@ export async function status(
|
|
|
423
405
|
}
|
|
424
406
|
|
|
425
407
|
// Load config
|
|
426
|
-
const configResult = await
|
|
408
|
+
const configResult = await loadConfigCached(options.configPath);
|
|
427
409
|
if (!configResult.ok) {
|
|
428
410
|
return { success: false, error: configResult.error.message };
|
|
429
411
|
}
|
|
430
412
|
const config = configResult.value;
|
|
431
|
-
|
|
432
|
-
const
|
|
413
|
+
const collectionNames = config.collections.map(({ name }) => name);
|
|
414
|
+
const preset = getActivePreset(config);
|
|
415
|
+
// Launch filesystem/process probes in parallel with index open + SQLite reads.
|
|
416
|
+
const rootErrorsPromise = checkCollectionRoots(config.collections);
|
|
417
|
+
const embedModelCachedPromise = new ModelCache(getModelsCachePath()).isCached(
|
|
418
|
+
preset.embed
|
|
419
|
+
);
|
|
420
|
+
const connectorTargetsPromise = getConnectorVerificationTargets();
|
|
421
|
+
const backgroundIssuesPromise = collectResidentIssues();
|
|
422
|
+
const registrationRuntimeIssuesPromise = checkRegistrationRuntimes();
|
|
423
|
+
const residentRuntimeIssuesPromise = checkResidentRuntimes();
|
|
433
424
|
|
|
434
425
|
// Open database
|
|
435
426
|
const store = new SqliteAdapter();
|
|
@@ -445,52 +436,78 @@ export async function status(
|
|
|
445
436
|
config.busyTimeoutMs
|
|
446
437
|
);
|
|
447
438
|
if (!openResult.ok) {
|
|
439
|
+
await Promise.allSettled([
|
|
440
|
+
rootErrorsPromise,
|
|
441
|
+
embedModelCachedPromise,
|
|
442
|
+
connectorTargetsPromise,
|
|
443
|
+
backgroundIssuesPromise,
|
|
444
|
+
registrationRuntimeIssuesPromise,
|
|
445
|
+
residentRuntimeIssuesPromise,
|
|
446
|
+
]);
|
|
448
447
|
return { success: false, error: openResult.error.message };
|
|
449
448
|
}
|
|
450
449
|
|
|
451
450
|
try {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
451
|
+
const [
|
|
452
|
+
statusResult,
|
|
453
|
+
embedModelCached,
|
|
454
|
+
connectorTargets,
|
|
455
|
+
memory,
|
|
456
|
+
budgetStops,
|
|
457
|
+
staleCollections,
|
|
458
|
+
] = await Promise.all([
|
|
459
|
+
store.getStatus({
|
|
460
|
+
embedModel: resolveModelUri(config, "embed"),
|
|
461
|
+
chunking: config.chunking ?? {},
|
|
462
|
+
configuredCollections: collectionNames,
|
|
463
|
+
}),
|
|
464
|
+
embedModelCachedPromise,
|
|
465
|
+
connectorTargetsPromise,
|
|
466
|
+
buildMemoryStatus(store, config.collections),
|
|
467
|
+
collectBudgetStops(store),
|
|
468
|
+
collectStaleCollections(store, collectionNames),
|
|
469
|
+
]);
|
|
457
470
|
if (!statusResult.ok) {
|
|
471
|
+
await Promise.allSettled([
|
|
472
|
+
rootErrorsPromise,
|
|
473
|
+
backgroundIssuesPromise,
|
|
474
|
+
registrationRuntimeIssuesPromise,
|
|
475
|
+
residentRuntimeIssuesPromise,
|
|
476
|
+
]);
|
|
458
477
|
return { success: false, error: statusResult.error.message };
|
|
459
478
|
}
|
|
460
479
|
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
{
|
|
480
|
+
const [
|
|
481
|
+
activation,
|
|
482
|
+
backgroundIssues,
|
|
483
|
+
registrationIssues,
|
|
484
|
+
residentIssuesList,
|
|
485
|
+
rootErrors,
|
|
486
|
+
] = await Promise.all([
|
|
487
|
+
buildActivationStatus(store, collectionNames, {
|
|
469
488
|
semantic: {
|
|
470
489
|
modelsCached: embedModelCached,
|
|
471
490
|
embeddingBacklog: statusResult.value.embeddingBacklog,
|
|
472
491
|
},
|
|
473
|
-
connectorTargets
|
|
474
|
-
}
|
|
475
|
-
|
|
492
|
+
connectorTargets,
|
|
493
|
+
}),
|
|
494
|
+
backgroundIssuesPromise,
|
|
495
|
+
registrationRuntimeIssuesPromise,
|
|
496
|
+
residentRuntimeIssuesPromise,
|
|
497
|
+
rootErrorsPromise,
|
|
498
|
+
]);
|
|
476
499
|
|
|
477
500
|
return {
|
|
478
501
|
success: true,
|
|
479
502
|
status: statusResult.value,
|
|
480
503
|
activation,
|
|
481
504
|
contentTypeBoost: buildContentTypeBoostStatus(config.contentTypes ?? []),
|
|
482
|
-
memory
|
|
483
|
-
backgroundIssues
|
|
484
|
-
runtimeIssues: [
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
budgetStops: await collectBudgetStops(store),
|
|
489
|
-
staleCollections: await collectStaleCollections(
|
|
490
|
-
store,
|
|
491
|
-
config.collections.map(({ name }) => name)
|
|
492
|
-
),
|
|
493
|
-
rootErrors: await rootErrors,
|
|
505
|
+
memory,
|
|
506
|
+
backgroundIssues,
|
|
507
|
+
runtimeIssues: [...registrationIssues, ...residentIssuesList],
|
|
508
|
+
budgetStops,
|
|
509
|
+
staleCollections,
|
|
510
|
+
rootErrors,
|
|
494
511
|
};
|
|
495
512
|
} finally {
|
|
496
513
|
await store.close();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-invocation CLI config and session-binding cache.
|
|
3
|
+
*
|
|
4
|
+
* Eliminates 2x-3x redundant YAML/Zod parses across preAction session-binding,
|
|
5
|
+
* initStore, and terminal-link policy within a single CLI command while staying
|
|
6
|
+
* completely inactive for direct non-CLI callers and invalidating immediately
|
|
7
|
+
* on config writes or resetGlobals().
|
|
8
|
+
*
|
|
9
|
+
* @module src/cli/config-cache
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { LoadResult } from "../config/loader";
|
|
13
|
+
import type { Config } from "../config/types";
|
|
14
|
+
|
|
15
|
+
import { expandPath, getConfigPaths } from "../config/paths";
|
|
16
|
+
import { getConfigWriteGeneration } from "../config/saver";
|
|
17
|
+
import { isCliInvocationActive, registerGlobalsResetListener } from "./globals";
|
|
18
|
+
|
|
19
|
+
type LoadConfigResult = LoadResult<Config>;
|
|
20
|
+
|
|
21
|
+
interface CachedConfigEntry {
|
|
22
|
+
generation: number;
|
|
23
|
+
result: LoadConfigResult;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const configCache = new Map<string, CachedConfigEntry>();
|
|
27
|
+
const verifiedBindings = new Map<string, number>();
|
|
28
|
+
|
|
29
|
+
export function clearCliConfigCache(): void {
|
|
30
|
+
configCache.clear();
|
|
31
|
+
verifiedBindings.clear();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
registerGlobalsResetListener(clearCliConfigCache);
|
|
35
|
+
|
|
36
|
+
function resolveCanonicalConfigPath(configPath?: string): string {
|
|
37
|
+
return configPath ? expandPath(configPath) : getConfigPaths().configFile;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Load config, reusing a parsed result within the same CLI invocation when
|
|
42
|
+
* no config write has occurred since it was loaded.
|
|
43
|
+
*/
|
|
44
|
+
export async function loadConfigCached(
|
|
45
|
+
configPath?: string
|
|
46
|
+
): Promise<LoadConfigResult> {
|
|
47
|
+
const { loadConfig } = await import("../config/loader");
|
|
48
|
+
if (!isCliInvocationActive()) {
|
|
49
|
+
return loadConfig(configPath);
|
|
50
|
+
}
|
|
51
|
+
const canonical = resolveCanonicalConfigPath(configPath);
|
|
52
|
+
const generation = getConfigWriteGeneration();
|
|
53
|
+
const cached = configCache.get(canonical);
|
|
54
|
+
if (cached && cached.generation === generation) {
|
|
55
|
+
return cached.result;
|
|
56
|
+
}
|
|
57
|
+
const loaded = await loadConfig(configPath);
|
|
58
|
+
if (loaded.ok && getConfigWriteGeneration() === generation) {
|
|
59
|
+
configCache.set(canonical, { generation, result: loaded });
|
|
60
|
+
}
|
|
61
|
+
return loaded;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Check whether a (configPath, indexName) binding was already verified in this CLI invocation. */
|
|
65
|
+
export function isSessionBindingVerifiedInInvocation(
|
|
66
|
+
configPath: string,
|
|
67
|
+
indexName: string
|
|
68
|
+
): boolean {
|
|
69
|
+
if (!isCliInvocationActive()) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const key = `${resolveCanonicalConfigPath(configPath)}\u0000${indexName}`;
|
|
73
|
+
return verifiedBindings.get(key) === getConfigWriteGeneration();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Record that (configPath, indexName) passed session-binding verification in this CLI invocation. */
|
|
77
|
+
export function markSessionBindingVerifiedInInvocation(
|
|
78
|
+
configPath: string,
|
|
79
|
+
indexName: string
|
|
80
|
+
): void {
|
|
81
|
+
if (!isCliInvocationActive()) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const key = `${resolveCanonicalConfigPath(configPath)}\u0000${indexName}`;
|
|
85
|
+
verifiedBindings.set(key, getConfigWriteGeneration());
|
|
86
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CLI global options state.
|
|
3
|
+
* Extracted from src/cli/program so commands and runners do not pull in
|
|
4
|
+
* Commander or the full command definition tree just to read/reset globals.
|
|
5
|
+
*
|
|
6
|
+
* @module src/cli/globals
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { GlobalOptions } from "./context";
|
|
10
|
+
|
|
11
|
+
import { setColorsEnabled } from "./colors";
|
|
12
|
+
|
|
13
|
+
const globalState: { current: GlobalOptions | null } = { current: null };
|
|
14
|
+
let cliInvocationActive = false;
|
|
15
|
+
const resetListeners = new Set<() => void>();
|
|
16
|
+
|
|
17
|
+
/** Register a cleanup hook invoked when CLI global state resets. */
|
|
18
|
+
export function registerGlobalsResetListener(listener: () => void): void {
|
|
19
|
+
resetListeners.add(listener);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Mark that a CLI invocation is active (enables per-invocation caches). */
|
|
23
|
+
export function setCliInvocationActive(active: boolean): void {
|
|
24
|
+
cliInvocationActive = active;
|
|
25
|
+
if (!active) {
|
|
26
|
+
for (const listener of resetListeners) {
|
|
27
|
+
listener();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** True while inside an active runCli() invocation. */
|
|
33
|
+
export function isCliInvocationActive(): boolean {
|
|
34
|
+
return cliInvocationActive || globalState.current !== null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Set resolved global options (called by Commander's preAction hook). */
|
|
38
|
+
export function setGlobals(globals: GlobalOptions): void {
|
|
39
|
+
globalState.current = globals;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get resolved global options. Must be called after command parsing.
|
|
44
|
+
* Throws if called before preAction hook runs.
|
|
45
|
+
*/
|
|
46
|
+
export function getGlobals(): GlobalOptions {
|
|
47
|
+
if (!globalState.current) {
|
|
48
|
+
throw new Error("Global options not resolved - called before preAction?");
|
|
49
|
+
}
|
|
50
|
+
return globalState.current;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Reset global state (for testing and at the start of every CLI invocation).
|
|
55
|
+
* Resets option state, color state, and per-invocation caches.
|
|
56
|
+
*/
|
|
57
|
+
export function resetGlobals(): void {
|
|
58
|
+
globalState.current = null;
|
|
59
|
+
cliInvocationActive = false;
|
|
60
|
+
setColorsEnabled(true);
|
|
61
|
+
for (const listener of resetListeners) {
|
|
62
|
+
listener();
|
|
63
|
+
}
|
|
64
|
+
}
|