@gmickel/gno 2.14.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.14.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 +88 -45
- package/spec/db/schema.sql +45 -0
- package/spec/output-schemas/embed-receipt.schema.json +89 -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/embed.ts +341 -20
- 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/options.ts +23 -0
- package/src/cli/program.ts +44 -37
- 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 +173 -60
- package/src/embed/batch.ts +83 -12
- package/src/embed/resume-cursor.ts +103 -0
- package/src/embed/retry.ts +41 -32
- package/src/embed/variant-backlog.ts +697 -63
- package/src/embed/variant-plan.ts +41 -45
- package/src/embed/variant-retry.ts +157 -44
- 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/036-vector-mirror-state.ts +83 -0
- package/src/store/migrations/037-performance-indexes.ts +56 -0
- package/src/store/migrations/index.ts +4 -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 +49 -47
- 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 +785 -144
- package/browser-extension/artifacts/gno-browser-clipper-v2.14.0.zip.sha256 +0 -1
|
@@ -603,3 +603,22 @@ mark {
|
|
|
603
603
|
border-top: 1px solid hsl(var(--border));
|
|
604
604
|
padding: 1rem 1.5rem;
|
|
605
605
|
}
|
|
606
|
+
|
|
607
|
+
/* Shiki dual-theme CSS variable switch (single-pass HTML tree for light + dark). */
|
|
608
|
+
@media (prefers-color-scheme: dark) {
|
|
609
|
+
:root:not([data-theme="light"]) .shiki,
|
|
610
|
+
:root:not([data-theme="light"]) .shiki span {
|
|
611
|
+
color: var(--shiki-dark) !important;
|
|
612
|
+
font-style: var(--shiki-dark-font-style) !important;
|
|
613
|
+
font-weight: var(--shiki-dark-font-weight) !important;
|
|
614
|
+
text-decoration: var(--shiki-dark-text-decoration) !important;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.dark .shiki,
|
|
619
|
+
.dark .shiki span {
|
|
620
|
+
color: var(--shiki-dark) !important;
|
|
621
|
+
font-style: var(--shiki-dark-font-style) !important;
|
|
622
|
+
font-weight: var(--shiki-dark-font-weight) !important;
|
|
623
|
+
text-decoration: var(--shiki-dark-text-decoration) !important;
|
|
624
|
+
}
|
|
@@ -9,16 +9,23 @@
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
createContext,
|
|
12
|
+
lazy,
|
|
12
13
|
type ReactNode,
|
|
14
|
+
Suspense,
|
|
13
15
|
useCallback,
|
|
14
16
|
useContext,
|
|
15
17
|
useMemo,
|
|
16
18
|
useState,
|
|
17
19
|
} from "react";
|
|
18
20
|
|
|
19
|
-
import { CaptureModal } from "../components/CaptureModal";
|
|
20
21
|
import { useKeyboardShortcuts } from "./useKeyboardShortcuts";
|
|
21
22
|
|
|
23
|
+
const CaptureModal = lazy(() =>
|
|
24
|
+
import("../components/CaptureModal").then((module) => ({
|
|
25
|
+
default: module.CaptureModal,
|
|
26
|
+
}))
|
|
27
|
+
);
|
|
28
|
+
|
|
22
29
|
export interface CaptureModalOpenOptions {
|
|
23
30
|
draftTitle?: string;
|
|
24
31
|
defaultCollection?: string;
|
|
@@ -48,6 +55,7 @@ export function CaptureModalProvider({
|
|
|
48
55
|
onSuccess,
|
|
49
56
|
}: CaptureModalProviderProps) {
|
|
50
57
|
const [open, setOpen] = useState(false);
|
|
58
|
+
const [hasOpened, setHasOpened] = useState(false);
|
|
51
59
|
const [draftTitle, setDraftTitle] = useState("");
|
|
52
60
|
const [defaultCollection, setDefaultCollection] = useState("");
|
|
53
61
|
const [defaultFolderPath, setDefaultFolderPath] = useState("");
|
|
@@ -66,6 +74,7 @@ export function CaptureModalProvider({
|
|
|
66
74
|
setDefaultFolderPath(options?.defaultFolderPath ?? "");
|
|
67
75
|
setPresetId(options?.presetId ?? "");
|
|
68
76
|
}
|
|
77
|
+
setHasOpened(true);
|
|
69
78
|
setOpen(true);
|
|
70
79
|
},
|
|
71
80
|
[]
|
|
@@ -95,15 +104,19 @@ export function CaptureModalProvider({
|
|
|
95
104
|
return (
|
|
96
105
|
<CaptureModalContext.Provider value={value}>
|
|
97
106
|
{children}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
{(open || hasOpened) && (
|
|
108
|
+
<Suspense fallback={null}>
|
|
109
|
+
<CaptureModal
|
|
110
|
+
defaultCollection={defaultCollection}
|
|
111
|
+
defaultFolderPath={defaultFolderPath}
|
|
112
|
+
draftTitle={draftTitle}
|
|
113
|
+
onOpenChange={setOpen}
|
|
114
|
+
onSuccess={onSuccess}
|
|
115
|
+
open={open}
|
|
116
|
+
presetId={presetId}
|
|
117
|
+
/>
|
|
118
|
+
</Suspense>
|
|
119
|
+
)}
|
|
107
120
|
</CaptureModalContext.Provider>
|
|
108
121
|
);
|
|
109
122
|
}
|
|
@@ -1,23 +1,248 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight browser-side typed metadata predicate parser and normalizer.
|
|
3
|
+
* Mirrors src/core/typed-metadata.ts validation and canonicalization rules
|
|
4
|
+
* without pulling `zod` into the Web UI bundle.
|
|
5
|
+
*/
|
|
2
6
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
import type {
|
|
8
|
+
MetadataPredicate,
|
|
9
|
+
MetadataScalar,
|
|
6
10
|
} from "../../../core/typed-metadata";
|
|
7
11
|
|
|
12
|
+
const LIMITS = {
|
|
13
|
+
keyLength: 128,
|
|
14
|
+
stringLength: 4096,
|
|
15
|
+
members: 128,
|
|
16
|
+
bytes: 65_536,
|
|
17
|
+
nodes: 128,
|
|
18
|
+
depth: 8,
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
const RESERVED_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
22
|
+
const UTF8_ENCODER = new TextEncoder();
|
|
23
|
+
|
|
24
|
+
class PredicateValidationError extends Error {
|
|
25
|
+
constructor(
|
|
26
|
+
readonly path: string[],
|
|
27
|
+
message: string
|
|
28
|
+
) {
|
|
29
|
+
super(message);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function fail(path: string[], message: string): never {
|
|
34
|
+
throw new PredicateValidationError(path, message);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assertExactKeys(
|
|
38
|
+
obj: Record<string, unknown>,
|
|
39
|
+
allowed: readonly string[],
|
|
40
|
+
path: string[]
|
|
41
|
+
): void {
|
|
42
|
+
for (const key of Object.keys(obj)) {
|
|
43
|
+
if (!allowed.includes(key)) {
|
|
44
|
+
fail(path, `Unrecognized key: "${key}"`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function validateKey(value: unknown, path: string[]): string {
|
|
50
|
+
if (typeof value !== "string" || value.length < 1) {
|
|
51
|
+
fail([...path, "key"], "Expected non-empty string");
|
|
52
|
+
}
|
|
53
|
+
if (value.length > LIMITS.keyLength) {
|
|
54
|
+
fail([...path, "key"], `Key exceeds ${LIMITS.keyLength} characters`);
|
|
55
|
+
}
|
|
56
|
+
if (RESERVED_KEYS.has(value)) {
|
|
57
|
+
fail([...path, "key"], "Reserved metadata key");
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function validateScalar(value: unknown, path: string[]): MetadataScalar {
|
|
63
|
+
if (typeof value === "string") {
|
|
64
|
+
if (value.length > LIMITS.stringLength) {
|
|
65
|
+
fail(path, `String exceeds ${LIMITS.stringLength} characters`);
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === "number") {
|
|
70
|
+
if (!Number.isFinite(value)) {
|
|
71
|
+
fail(path, "Expected finite number");
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
if (typeof value === "boolean") {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
fail(path, "Expected string, finite number, or boolean");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function validatePredicate(
|
|
82
|
+
input: unknown,
|
|
83
|
+
depth: number,
|
|
84
|
+
path: string[],
|
|
85
|
+
counter: { nodes: number }
|
|
86
|
+
): MetadataPredicate {
|
|
87
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
88
|
+
fail(path, "Expected predicate object");
|
|
89
|
+
}
|
|
90
|
+
counter.nodes += 1;
|
|
91
|
+
if (counter.nodes > LIMITS.nodes) {
|
|
92
|
+
fail([], `Filter exceeds ${LIMITS.nodes} nodes`);
|
|
93
|
+
}
|
|
94
|
+
const obj = input as Record<string, unknown>;
|
|
95
|
+
const op = obj.op;
|
|
96
|
+
if (typeof op !== "string") {
|
|
97
|
+
fail([...path, "op"], "Missing or invalid operator");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
switch (op) {
|
|
101
|
+
case "eq":
|
|
102
|
+
case "ne": {
|
|
103
|
+
assertExactKeys(obj, ["op", "key", "value"], path);
|
|
104
|
+
return {
|
|
105
|
+
op,
|
|
106
|
+
key: validateKey(obj.key, path),
|
|
107
|
+
value: validateScalar(obj.value, [...path, "value"]),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
case "gt":
|
|
111
|
+
case "gte":
|
|
112
|
+
case "lt":
|
|
113
|
+
case "lte": {
|
|
114
|
+
assertExactKeys(obj, ["op", "key", "value"], path);
|
|
115
|
+
if (typeof obj.value !== "number" || !Number.isFinite(obj.value)) {
|
|
116
|
+
fail([...path, "value"], "Expected finite number");
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
op,
|
|
120
|
+
key: validateKey(obj.key, path),
|
|
121
|
+
value: obj.value,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
case "in":
|
|
125
|
+
case "nin":
|
|
126
|
+
case "all": {
|
|
127
|
+
assertExactKeys(obj, ["op", "key", "values"], path);
|
|
128
|
+
const key = validateKey(obj.key, path);
|
|
129
|
+
if (!Array.isArray(obj.values)) {
|
|
130
|
+
fail([...path, "values"], "Expected array of values");
|
|
131
|
+
}
|
|
132
|
+
if (obj.values.length === 0) {
|
|
133
|
+
fail([...path, "values"], "Membership requires values");
|
|
134
|
+
}
|
|
135
|
+
if (obj.values.length > LIMITS.members) {
|
|
136
|
+
fail([...path, "values"], `Array exceeds ${LIMITS.members} items`);
|
|
137
|
+
}
|
|
138
|
+
const scalars: MetadataScalar[] = [];
|
|
139
|
+
let expectedType: string | null = null;
|
|
140
|
+
for (let i = 0; i < obj.values.length; i += 1) {
|
|
141
|
+
const scalar = validateScalar(obj.values[i], [
|
|
142
|
+
...path,
|
|
143
|
+
"values",
|
|
144
|
+
String(i),
|
|
145
|
+
]);
|
|
146
|
+
if (expectedType === null) {
|
|
147
|
+
expectedType = typeof scalar;
|
|
148
|
+
} else if (typeof scalar !== expectedType) {
|
|
149
|
+
fail([...path, "values"], "Array members must have one scalar type");
|
|
150
|
+
}
|
|
151
|
+
scalars.push(scalar);
|
|
152
|
+
}
|
|
153
|
+
const uniqueValues = [...new Set(scalars)].sort((a, b) => {
|
|
154
|
+
const sa = JSON.stringify(a);
|
|
155
|
+
const sb = JSON.stringify(b);
|
|
156
|
+
return sa < sb ? -1 : sa > sb ? 1 : 0;
|
|
157
|
+
});
|
|
158
|
+
return { op, key, values: uniqueValues };
|
|
159
|
+
}
|
|
160
|
+
case "exists": {
|
|
161
|
+
assertExactKeys(obj, ["op", "key", "value"], path);
|
|
162
|
+
if (typeof obj.value !== "boolean") {
|
|
163
|
+
fail([...path, "value"], "Expected boolean");
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
op,
|
|
167
|
+
key: validateKey(obj.key, path),
|
|
168
|
+
value: obj.value,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
case "and":
|
|
172
|
+
case "or": {
|
|
173
|
+
if (depth >= LIMITS.depth) {
|
|
174
|
+
fail(
|
|
175
|
+
[...path, "op"],
|
|
176
|
+
`Maximum predicate depth (${LIMITS.depth}) exceeded`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
assertExactKeys(obj, ["op", "predicates"], path);
|
|
180
|
+
if (!Array.isArray(obj.predicates)) {
|
|
181
|
+
fail([...path, "predicates"], "Expected array of predicates");
|
|
182
|
+
}
|
|
183
|
+
if (obj.predicates.length < 1 || obj.predicates.length > LIMITS.nodes) {
|
|
184
|
+
fail(
|
|
185
|
+
[...path, "predicates"],
|
|
186
|
+
`Expected 1..${LIMITS.nodes} child predicates`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
const unique = new Map<string, MetadataPredicate>();
|
|
190
|
+
for (let i = 0; i < obj.predicates.length; i += 1) {
|
|
191
|
+
const child = validatePredicate(
|
|
192
|
+
obj.predicates[i],
|
|
193
|
+
depth + 1,
|
|
194
|
+
[...path, "predicates", String(i)],
|
|
195
|
+
counter
|
|
196
|
+
);
|
|
197
|
+
unique.set(JSON.stringify(child), child);
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
op,
|
|
201
|
+
predicates: [...unique.entries()]
|
|
202
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
203
|
+
.map(([, value]) => value),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
case "not": {
|
|
207
|
+
if (depth >= LIMITS.depth) {
|
|
208
|
+
fail(
|
|
209
|
+
[...path, "op"],
|
|
210
|
+
`Maximum predicate depth (${LIMITS.depth}) exceeded`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
assertExactKeys(obj, ["op", "predicate"], path);
|
|
214
|
+
return {
|
|
215
|
+
op,
|
|
216
|
+
predicate: validatePredicate(
|
|
217
|
+
obj.predicate,
|
|
218
|
+
depth + 1,
|
|
219
|
+
[...path, "predicate"],
|
|
220
|
+
counter
|
|
221
|
+
),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
default:
|
|
225
|
+
fail([...path, "op"], `Invalid operator "${op}"`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
8
229
|
export function parseMetadataFilter(text: string): {
|
|
9
230
|
filter?: MetadataPredicate;
|
|
10
231
|
error?: string;
|
|
11
232
|
} {
|
|
12
233
|
if (!text.trim()) return {};
|
|
13
234
|
try {
|
|
14
|
-
|
|
235
|
+
const parsed: unknown = JSON.parse(text);
|
|
236
|
+
const normalized = validatePredicate(parsed, 1, [], { nodes: 0 });
|
|
237
|
+
if (UTF8_ENCODER.encode(JSON.stringify(parsed)).length > LIMITS.bytes) {
|
|
238
|
+
fail([], "Filter exceeds 64 KiB");
|
|
239
|
+
}
|
|
240
|
+
return { filter: normalized };
|
|
15
241
|
} catch (error) {
|
|
16
|
-
if (error instanceof
|
|
17
|
-
const
|
|
18
|
-
const path = issue?.path.length ? `.${issue.path.join(".")}` : "";
|
|
242
|
+
if (error instanceof PredicateValidationError) {
|
|
243
|
+
const suffix = error.path.length ? `.${error.path.join(".")}` : "";
|
|
19
244
|
return {
|
|
20
|
-
error: `filter${
|
|
245
|
+
error: `filter${suffix}: ${error.message}. Check the operator, key, and JSON value type.`,
|
|
21
246
|
};
|
|
22
247
|
}
|
|
23
248
|
return {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
RefreshCw,
|
|
8
8
|
StarIcon,
|
|
9
9
|
} from "lucide-react";
|
|
10
|
-
import { useEffect, useMemo, useState } from "react";
|
|
10
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
createBrowseNodeId,
|
|
@@ -93,7 +93,6 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
93
93
|
const [tree, setTree] = useState<BrowseTreeResponse | null>(null);
|
|
94
94
|
const [docs, setDocs] = useState<BrowseDocument[]>([]);
|
|
95
95
|
const [total, setTotal] = useState(0);
|
|
96
|
-
const [offset, setOffset] = useState(0);
|
|
97
96
|
const [treeLoading, setTreeLoading] = useState(true);
|
|
98
97
|
const [docsLoading, setDocsLoading] = useState(false);
|
|
99
98
|
const [availableDateFields, setAvailableDateFields] = useState<string[]>([]);
|
|
@@ -116,6 +115,17 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
116
115
|
|
|
117
116
|
const selectedCollection = selection.collection;
|
|
118
117
|
const selectedPath = selection.path;
|
|
118
|
+
// Scope pagination offset to (collection, path, sort) so switching folders
|
|
119
|
+
// immediately resolves to offset 0 on the first render without a stale-offset
|
|
120
|
+
// double fetch.
|
|
121
|
+
const docsScopeKey = `${selectedCollection ?? ""}\u0000${selectedPath ?? ""}\u0000${sortField}\u0000${sortOrder}`;
|
|
122
|
+
const [pagination, setPagination] = useState<{
|
|
123
|
+
scopeKey: string;
|
|
124
|
+
offset: number;
|
|
125
|
+
}>({ scopeKey: docsScopeKey, offset: 0 });
|
|
126
|
+
const offset = pagination.scopeKey === docsScopeKey ? pagination.offset : 0;
|
|
127
|
+
const treeReqSeqRef = useRef(0);
|
|
128
|
+
const docsReqSeqRef = useRef(0);
|
|
119
129
|
const selectedNodeId = selectedCollection
|
|
120
130
|
? createBrowseNodeId(selectedCollection, selectedPath)
|
|
121
131
|
: null;
|
|
@@ -177,9 +187,13 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
177
187
|
);
|
|
178
188
|
|
|
179
189
|
useEffect(() => {
|
|
180
|
-
setOffset(0);
|
|
181
190
|
setDocs([]);
|
|
182
|
-
|
|
191
|
+
setPagination((prev) =>
|
|
192
|
+
prev.scopeKey === docsScopeKey && prev.offset === 0
|
|
193
|
+
? prev
|
|
194
|
+
: { scopeKey: docsScopeKey, offset: 0 }
|
|
195
|
+
);
|
|
196
|
+
}, [docsScopeKey]);
|
|
183
197
|
|
|
184
198
|
useEffect(() => {
|
|
185
199
|
setFavoriteDocHrefs(loadFavoriteDocuments().map((entry) => entry.href));
|
|
@@ -189,12 +203,22 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
189
203
|
}, []);
|
|
190
204
|
|
|
191
205
|
useEffect(() => {
|
|
192
|
-
|
|
206
|
+
const controller = new AbortController();
|
|
207
|
+
const reqSeq = ++treeReqSeqRef.current;
|
|
208
|
+
void apiFetch<BrowseTreeResponse>("/api/browse/tree", {
|
|
209
|
+
signal: controller.signal,
|
|
210
|
+
}).then(({ data }) => {
|
|
211
|
+
if (controller.signal.aborted || reqSeq !== treeReqSeqRef.current) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
193
214
|
setTree(
|
|
194
215
|
data ?? { collections: [], totalCollections: 0, totalDocuments: 0 }
|
|
195
216
|
);
|
|
196
217
|
setTreeLoading(false);
|
|
197
218
|
});
|
|
219
|
+
return () => {
|
|
220
|
+
controller.abort();
|
|
221
|
+
};
|
|
198
222
|
}, [refreshToken]);
|
|
199
223
|
|
|
200
224
|
useEffect(() => {
|
|
@@ -229,10 +253,11 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
229
253
|
if (!selectedCollection) {
|
|
230
254
|
setDocs([]);
|
|
231
255
|
setTotal(0);
|
|
232
|
-
setOffset(0);
|
|
233
256
|
return;
|
|
234
257
|
}
|
|
235
258
|
|
|
259
|
+
const controller = new AbortController();
|
|
260
|
+
const reqSeq = ++docsReqSeqRef.current;
|
|
236
261
|
setDocsLoading(true);
|
|
237
262
|
const params = new URLSearchParams({
|
|
238
263
|
collection: selectedCollection,
|
|
@@ -246,21 +271,27 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
246
271
|
params.set("pathPrefix", selectedPath);
|
|
247
272
|
}
|
|
248
273
|
|
|
249
|
-
void apiFetch<DocsResponse>(`/api/docs?${params.toString()}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
setAvailableDateFields(data.availableDateFields ?? []);
|
|
256
|
-
setSortField(data.sortField);
|
|
257
|
-
setSortOrder(data.sortOrder);
|
|
258
|
-
setDocs((prev) =>
|
|
259
|
-
offset === 0 ? data.documents : [...prev, ...data.documents]
|
|
260
|
-
);
|
|
261
|
-
setTotal(data.total);
|
|
274
|
+
void apiFetch<DocsResponse>(`/api/docs?${params.toString()}`, {
|
|
275
|
+
signal: controller.signal,
|
|
276
|
+
}).then(({ data }) => {
|
|
277
|
+
if (controller.signal.aborted || reqSeq !== docsReqSeqRef.current) {
|
|
278
|
+
return;
|
|
262
279
|
}
|
|
263
|
-
|
|
280
|
+
setDocsLoading(false);
|
|
281
|
+
if (!data) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
setAvailableDateFields(data.availableDateFields ?? []);
|
|
285
|
+
setSortField(data.sortField);
|
|
286
|
+
setSortOrder(data.sortOrder);
|
|
287
|
+
setDocs((prev) =>
|
|
288
|
+
offset === 0 ? data.documents : [...prev, ...data.documents]
|
|
289
|
+
);
|
|
290
|
+
setTotal(data.total);
|
|
291
|
+
});
|
|
292
|
+
return () => {
|
|
293
|
+
controller.abort();
|
|
294
|
+
};
|
|
264
295
|
}, [
|
|
265
296
|
limit,
|
|
266
297
|
offset,
|
|
@@ -275,10 +306,15 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
275
306
|
if (!latestDocEvent?.changedAt) {
|
|
276
307
|
return;
|
|
277
308
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
309
|
+
// 250 ms trailing debounce coalesces bursty watcher SSE events into one refresh.
|
|
310
|
+
const timer = window.setTimeout(() => {
|
|
311
|
+
setPagination({ scopeKey: docsScopeKey, offset: 0 });
|
|
312
|
+
setRefreshToken((current) => current + 1);
|
|
313
|
+
}, 250);
|
|
314
|
+
return () => {
|
|
315
|
+
window.clearTimeout(timer);
|
|
316
|
+
};
|
|
317
|
+
}, [docsScopeKey, latestDocEvent?.changedAt]);
|
|
282
318
|
|
|
283
319
|
useEffect(() => {
|
|
284
320
|
return subscribeWorkspaceActionRequest("create-folder-here", () => {
|
|
@@ -310,12 +346,11 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
310
346
|
]);
|
|
311
347
|
|
|
312
348
|
const handleLoadMore = () => {
|
|
313
|
-
|
|
349
|
+
setPagination({ scopeKey: docsScopeKey, offset: offset + limit });
|
|
314
350
|
};
|
|
315
351
|
|
|
316
352
|
const handleSelectNode = (collection: string, path?: string) => {
|
|
317
353
|
setDocs([]);
|
|
318
|
-
setOffset(0);
|
|
319
354
|
setMobileTreeOpen(false);
|
|
320
355
|
navigate(buildBrowseLocation(collection, path));
|
|
321
356
|
};
|
|
@@ -350,7 +385,6 @@ export default function Browse({ navigate, location }: PageProps) {
|
|
|
350
385
|
}
|
|
351
386
|
setSortField(nextField);
|
|
352
387
|
setSortOrder(nextOrder);
|
|
353
|
-
setOffset(0);
|
|
354
388
|
setDocs([]);
|
|
355
389
|
};
|
|
356
390
|
|
|
@@ -44,14 +44,23 @@ import {
|
|
|
44
44
|
} from "../components/ai-elements/code-block";
|
|
45
45
|
import { Loader } from "../components/ai-elements/loader";
|
|
46
46
|
import { BacklinksPanel } from "../components/BacklinksPanel";
|
|
47
|
-
import { MarkdownPreview } from "../components/editor";
|
|
47
|
+
import { MarkdownPreview } from "../components/editor/MarkdownPreview";
|
|
48
48
|
import {
|
|
49
49
|
OutgoingLinksPanel,
|
|
50
50
|
type OutgoingLink,
|
|
51
51
|
} from "../components/OutgoingLinksPanel";
|
|
52
|
-
import { PublishExportDialog } from "../components/PublishExportDialog";
|
|
53
|
-
import { RefactorImpactPreview } from "../components/RefactorImpactPreview";
|
|
54
52
|
import { RelatedNotesSidebar } from "../components/RelatedNotesSidebar";
|
|
53
|
+
|
|
54
|
+
const PublishExportDialog = lazy(() =>
|
|
55
|
+
import("../components/PublishExportDialog").then((module) => ({
|
|
56
|
+
default: module.PublishExportDialog,
|
|
57
|
+
}))
|
|
58
|
+
);
|
|
59
|
+
const RefactorImpactPreview = lazy(() =>
|
|
60
|
+
import("../components/RefactorImpactPreview").then((module) => ({
|
|
61
|
+
default: module.RefactorImpactPreview,
|
|
62
|
+
}))
|
|
63
|
+
);
|
|
55
64
|
import { TagInput } from "../components/TagInput";
|
|
56
65
|
import { Badge } from "../components/ui/badge";
|
|
57
66
|
import { Button } from "../components/ui/button";
|
|
@@ -1957,12 +1966,14 @@ export default function DocView({ navigate }: PageProps) {
|
|
|
1957
1966
|
</header>
|
|
1958
1967
|
|
|
1959
1968
|
{publishExportOpen && doc && (
|
|
1960
|
-
<
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1969
|
+
<Suspense fallback={null}>
|
|
1970
|
+
<PublishExportDialog
|
|
1971
|
+
key={doc.uri}
|
|
1972
|
+
onClose={() => setPublishExportOpen(false)}
|
|
1973
|
+
target={doc.uri}
|
|
1974
|
+
title={doc.title ?? doc.uri}
|
|
1975
|
+
/>
|
|
1976
|
+
</Suspense>
|
|
1966
1977
|
)}
|
|
1967
1978
|
<div className="mx-auto flex max-w-[1800px] gap-5 px-6 xl:px-8">
|
|
1968
1979
|
{/* Left rail — metadata + outline */}
|
|
@@ -2383,14 +2394,18 @@ export default function DocView({ navigate }: PageProps) {
|
|
|
2383
2394
|
onChange={(event) => setRenameValue(event.target.value)}
|
|
2384
2395
|
value={renameValue}
|
|
2385
2396
|
/>
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2397
|
+
{renameDialogOpen && (
|
|
2398
|
+
<Suspense fallback={null}>
|
|
2399
|
+
<RefactorImpactPreview
|
|
2400
|
+
confirmed={renameConfirmed}
|
|
2401
|
+
loading={renamePlanLoading}
|
|
2402
|
+
onConfirmedChange={setRenameConfirmed}
|
|
2403
|
+
outcomeMessage={renameOutcome}
|
|
2404
|
+
outcomeTone="warning"
|
|
2405
|
+
plan={renamePlan}
|
|
2406
|
+
/>
|
|
2407
|
+
</Suspense>
|
|
2408
|
+
)}
|
|
2394
2409
|
{renameError && (
|
|
2395
2410
|
<div
|
|
2396
2411
|
className="rounded-lg bg-destructive/10 p-3 text-destructive text-sm"
|
|
@@ -2455,14 +2470,18 @@ export default function DocView({ navigate }: PageProps) {
|
|
|
2455
2470
|
placeholder="note.md"
|
|
2456
2471
|
value={moveName}
|
|
2457
2472
|
/>
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2473
|
+
{moveDialogOpen && (
|
|
2474
|
+
<Suspense fallback={null}>
|
|
2475
|
+
<RefactorImpactPreview
|
|
2476
|
+
confirmed={moveConfirmed}
|
|
2477
|
+
loading={movePlanLoading}
|
|
2478
|
+
onConfirmedChange={setMoveConfirmed}
|
|
2479
|
+
outcomeMessage={moveOutcome}
|
|
2480
|
+
outcomeTone="warning"
|
|
2481
|
+
plan={movePlan}
|
|
2482
|
+
/>
|
|
2483
|
+
</Suspense>
|
|
2484
|
+
)}
|
|
2466
2485
|
{moveError && (
|
|
2467
2486
|
<div
|
|
2468
2487
|
className="rounded-lg bg-destructive/10 p-3 text-destructive text-sm"
|
|
@@ -360,9 +360,14 @@ export default function GraphView({ navigate }: PageProps) {
|
|
|
360
360
|
// Fetch collections on mount
|
|
361
361
|
useEffect(() => {
|
|
362
362
|
const fetchCollections = async () => {
|
|
363
|
-
const { data } = await apiFetch<StatusResponse>(
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
const { data } = await apiFetch<Array<{ name: string }> | StatusResponse>(
|
|
364
|
+
"/api/collections"
|
|
365
|
+
);
|
|
366
|
+
const list = Array.isArray(data) ? data : data?.collections;
|
|
367
|
+
if (list) {
|
|
368
|
+
setCollections(
|
|
369
|
+
list.map((c) => c.name).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
|
370
|
+
);
|
|
366
371
|
}
|
|
367
372
|
};
|
|
368
373
|
void fetchCollections();
|