dsh-mnemon-source-documents 0.6.4 → 0.6.5

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/lib/client.js CHANGED
@@ -228,7 +228,6 @@ window.__ModuleLoader__.load({
228
228
  function PathText(props) {
229
229
  return canRenderPathLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.PathLabel, { path: props.path }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: props.path });
230
230
  }
231
- /** Render managed Markdown through the official DSH Markdown pipeline without raw HTML or unsafe links. */
232
231
  function DocumentMarkdown(props) {
233
232
  const locale = (0, dsh_mnemon_client.useLocale)();
234
233
  const labels = (0, react.useMemo)(() => {
@@ -21,7 +21,6 @@ interface DocumentRecord {
21
21
  }
22
22
  interface DocumentView extends DocumentRecord {
23
23
  content: string;
24
- /** Digest of the exact managed file read; deletion also fences external edits. */
25
24
  fileRevision?: string;
26
25
  }
27
26
  interface DocumentSnapshot {
@@ -91,41 +90,22 @@ interface DocumentCapacityPlan {
91
90
  }
92
91
  declare const DOCUMENTS_VERSION = 1;
93
92
  declare const DOCUMENTS_ACTIVE_LIMIT_BYTES: number;
94
- /** The Documents Source's directory under a storage root; each document sits in `<status>/<filename>` below it. */
95
93
  declare const DOCUMENTS_DIRECTORY = "documents";
96
- /** The metadata of every document, the source of truth for which files belong to the Source. */
97
94
  declare const DOCUMENTS_INDEX_FILE = "index.json";
98
- /** Created exclusively while the index or a document is read or written; whoever copies them takes it too. */
99
95
  declare const DOCUMENTS_LOCK_FILE = ".index.lock";
100
- /** A lock file older than this was left by a process that stopped, and may be taken over. */
101
96
  declare const DOCUMENTS_LOCK_STALE_MS = 30000;
102
- /** The file name a document may have: one path segment, so it never leaves its status directory. */
103
97
  declare const DOCUMENT_FILENAME_PATTERN: RegExp;
104
98
  interface DocumentIndex {
105
99
  version: typeof DOCUMENTS_VERSION;
106
100
  documents: DocumentRecord[];
107
101
  }
108
- /**
109
- * Read an index as a copy of it carries it, such as a Mnemon Pack or a sync branch: every record
110
- * complete, each id unique and each file name safe, or the whole index is refused. A record's path
111
- * is where its status puts it, whatever the copy says. Unknown fields are dropped, and so are
112
- * list items that are not strings. Reading the index does not judge a record's content hash: a
113
- * store that needs repair still has to be copied as one.
114
- */
115
102
  declare function parseDocumentIndex(value: unknown): DocumentIndex;
116
- /** What a stored index.json holds, counted without judging each record. */
117
103
  interface DocumentIndexSummary {
118
- /** Whether the index has a record list at all. Without one, every count is 0. */
119
104
  valid: boolean;
120
- /** Every record that is an object, whatever its status. */
121
105
  documents: number;
122
106
  active: number;
123
107
  archived: number;
124
108
  }
125
- /**
126
- * Count the records of a parsed index.json for a read-only inventory. It never throws: an index
127
- * without a record list is not `valid`, and a malformed record is counted or skipped, never refused.
128
- */
129
109
  declare function summarizeDocumentIndex(value: unknown): DocumentIndexSummary;
130
110
  //#endregion
131
111
  export { DOCUMENTS_ACTIVE_LIMIT_BYTES, DOCUMENTS_DIRECTORY, DOCUMENTS_INDEX_FILE, DOCUMENTS_LOCK_FILE, DOCUMENTS_LOCK_STALE_MS, DOCUMENTS_VERSION, DOCUMENT_FILENAME_PATTERN, DocumentCapacityPlan, DocumentIndex, DocumentIndexSummary, DocumentMutation, DocumentMutationResult, DocumentRecord, DocumentSearchResult, DocumentSnapshot, DocumentStatus, DocumentView, parseDocumentIndex, summarizeDocumentIndex };
package/lib/contracts.js CHANGED
@@ -1,26 +1,14 @@
1
1
  //#region src/contracts.ts
2
2
  const DOCUMENTS_VERSION = 1;
3
3
  const DOCUMENTS_ACTIVE_LIMIT_BYTES = 10485760;
4
- /** The Documents Source's directory under a storage root; each document sits in `<status>/<filename>` below it. */
5
4
  const DOCUMENTS_DIRECTORY = "documents";
6
- /** The metadata of every document, the source of truth for which files belong to the Source. */
7
5
  const DOCUMENTS_INDEX_FILE = "index.json";
8
- /** Created exclusively while the index or a document is read or written; whoever copies them takes it too. */
9
6
  const DOCUMENTS_LOCK_FILE = ".index.lock";
10
- /** A lock file older than this was left by a process that stopped, and may be taken over. */
11
7
  const DOCUMENTS_LOCK_STALE_MS = 3e4;
12
- /** The file name a document may have: one path segment, so it never leaves its status directory. */
13
8
  const DOCUMENT_FILENAME_PATTERN = /^[a-zA-Z0-9._-]+\.md$/u;
14
9
  function isObject(value) {
15
10
  return typeof value === "object" && value !== null && !Array.isArray(value);
16
11
  }
17
- /**
18
- * Read an index as a copy of it carries it, such as a Mnemon Pack or a sync branch: every record
19
- * complete, each id unique and each file name safe, or the whole index is refused. A record's path
20
- * is where its status puts it, whatever the copy says. Unknown fields are dropped, and so are
21
- * list items that are not strings. Reading the index does not judge a record's content hash: a
22
- * store that needs repair still has to be copied as one.
23
- */
24
12
  function parseDocumentIndex(value) {
25
13
  const index = isObject(value) ? value : void 0;
26
14
  if (index?.version !== 1 || !Array.isArray(index.documents)) throw new Error("Documents index.json is invalid");
@@ -57,10 +45,6 @@ function parseDocumentIndex(value) {
57
45
  })
58
46
  };
59
47
  }
60
- /**
61
- * Count the records of a parsed index.json for a read-only inventory. It never throws: an index
62
- * without a record list is not `valid`, and a malformed record is counted or skipped, never refused.
63
- */
64
48
  function summarizeDocumentIndex(value) {
65
49
  const documents = isObject(value) && Array.isArray(value.documents) ? value.documents.filter(isObject) : [];
66
50
  return {
package/lib/index.js CHANGED
@@ -26,7 +26,6 @@ function documentsSourceConfig(value, instanceKey) {
26
26
  }
27
27
  //#endregion
28
28
  //#region src/search-tokens.ts
29
- /** Small deterministic tokenizer shared by local Document and Native recovery. */
30
29
  function lexicalSearchTokens(value, maximum = 64) {
31
30
  const normalized = value.normalize("NFKC").toLocaleLowerCase();
32
31
  const tokens = [];
@@ -41,7 +40,6 @@ function lexicalSearchTokens(value, maximum = 64) {
41
40
  }
42
41
  return [...new Set(tokens)].slice(0, maximum);
43
42
  }
44
- /** Require broader coverage only after a query is focused enough to support it. */
45
43
  function lexicalRequiredMatchCount(tokens) {
46
44
  if (tokens.length === 0) return 0;
47
45
  if (tokens.length < 4) return 1;
@@ -151,7 +149,6 @@ function excerpt(content, maximum = 220) {
151
149
  const normalized = content.replace(/[#>*_`\[\]]/gu, "").replace(/\s+/gu, " ").trim();
152
150
  return normalized.length <= maximum ? normalized : `${normalized.slice(0, maximum - 1)}…`;
153
151
  }
154
- /** Include ctime and identity so restored mtimes and atomic replacements miss. */
155
152
  function diskIdentity(stat) {
156
153
  return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}:${stat.mode}`;
157
154
  }
@@ -200,7 +197,6 @@ function parseRecord(value) {
200
197
  memoryBodyIds: value.memoryBodyIds.filter((entry) => typeof entry === "string")
201
198
  };
202
199
  }
203
- /** Project-scoped control plane for managed active and cold document copies. */
204
200
  var DocumentController = class {
205
201
  limitBytes;
206
202
  now;
@@ -235,7 +231,6 @@ var DocumentController = class {
235
231
  snapshot() {
236
232
  return this.withLock(() => this.snapshotUnlocked(this.readIndex()));
237
233
  }
238
- /** Index push can sample short excerpts for active documents without descriptions. */
239
234
  catalog(includeIndexExcerpts = false) {
240
235
  return this.withLock(() => this.snapshotUnlocked(this.readIndex(), includeIndexExcerpts ? "index" : false));
241
236
  }
@@ -619,7 +614,6 @@ var DocumentController = class {
619
614
  documents
620
615
  };
621
616
  }
622
- /** Cache only presentation excerpts; reads/search and each health check stay live. */
623
617
  bodyExcerpt(record, path, stat, cacheable, indexExcerpt) {
624
618
  const identity = diskIdentity(stat);
625
619
  const cache = indexExcerpt ? this.indexExcerpts : this.excerpts;
@@ -732,7 +726,6 @@ var DocumentController = class {
732
726
  }
733
727
  }
734
728
  };
735
- /** Resolves one cached controller per canonical DSH workspace. */
736
729
  var DocumentManager = class {
737
730
  limitBytes;
738
731
  now;
@@ -757,7 +750,6 @@ var DocumentManager = class {
757
750
  };
758
751
  //#endregion
759
752
  //#region src/evidence.ts
760
- /** Preserve query-local evidence under the Source's per-document budget. */
761
753
  function documentEvidence(content, query, maximum) {
762
754
  if (maximum <= 0) return "";
763
755
  if (content.length <= maximum) return content;
@@ -1,5 +1,4 @@
1
1
  import type { DocumentMutation, DocumentMutationResult, DocumentSearchResult, DocumentSnapshot, DocumentView } from '../contracts.ts';
2
- /** Source-owned structural page API; the default bundle may supply agent-assisted callbacks. */
3
2
  export interface DocumentsPageClient {
4
3
  documents(): Promise<DocumentSnapshot>;
5
4
  document(id: string): Promise<DocumentView>;
@@ -20,7 +20,6 @@ export interface DocumentRecord {
20
20
  }
21
21
  export interface DocumentView extends DocumentRecord {
22
22
  content: string;
23
- /** Digest of the exact managed file read; deletion also fences external edits. */
24
23
  fileRevision?: string;
25
24
  }
26
25
  export interface DocumentSnapshot {
@@ -90,39 +89,20 @@ export interface DocumentCapacityPlan {
90
89
  }
91
90
  export declare const DOCUMENTS_VERSION = 1;
92
91
  export declare const DOCUMENTS_ACTIVE_LIMIT_BYTES: number;
93
- /** The Documents Source's directory under a storage root; each document sits in `<status>/<filename>` below it. */
94
92
  export declare const DOCUMENTS_DIRECTORY = "documents";
95
- /** The metadata of every document, the source of truth for which files belong to the Source. */
96
93
  export declare const DOCUMENTS_INDEX_FILE = "index.json";
97
- /** Created exclusively while the index or a document is read or written; whoever copies them takes it too. */
98
94
  export declare const DOCUMENTS_LOCK_FILE = ".index.lock";
99
- /** A lock file older than this was left by a process that stopped, and may be taken over. */
100
95
  export declare const DOCUMENTS_LOCK_STALE_MS = 30000;
101
- /** The file name a document may have: one path segment, so it never leaves its status directory. */
102
96
  export declare const DOCUMENT_FILENAME_PATTERN: RegExp;
103
97
  export interface DocumentIndex {
104
98
  version: typeof DOCUMENTS_VERSION;
105
99
  documents: DocumentRecord[];
106
100
  }
107
- /**
108
- * Read an index as a copy of it carries it, such as a Mnemon Pack or a sync branch: every record
109
- * complete, each id unique and each file name safe, or the whole index is refused. A record's path
110
- * is where its status puts it, whatever the copy says. Unknown fields are dropped, and so are
111
- * list items that are not strings. Reading the index does not judge a record's content hash: a
112
- * store that needs repair still has to be copied as one.
113
- */
114
101
  export declare function parseDocumentIndex(value: unknown): DocumentIndex;
115
- /** What a stored index.json holds, counted without judging each record. */
116
102
  export interface DocumentIndexSummary {
117
- /** Whether the index has a record list at all. Without one, every count is 0. */
118
103
  valid: boolean;
119
- /** Every record that is an object, whatever its status. */
120
104
  documents: number;
121
105
  active: number;
122
106
  archived: number;
123
107
  }
124
- /**
125
- * Count the records of a parsed index.json for a read-only inventory. It never throws: an index
126
- * without a record list is not `valid`, and a malformed record is counted or skipped, never refused.
127
- */
128
108
  export declare function summarizeDocumentIndex(value: unknown): DocumentIndexSummary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mnemon-source-documents",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Self-contained documents Source for Composable View Memory.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -60,7 +60,7 @@
60
60
  "@types/node": "^22.0.0",
61
61
  "@types/react": "^18.3.0",
62
62
  "@types/react-dom": "^18.3.0",
63
- "dsh-mnemon": "^0.5.51",
63
+ "dsh-mnemon": "^0.5.52",
64
64
  "jsdom": "^26.0.0",
65
65
  "react": "^18.2.0",
66
66
  "react-dom": "^18.2.0",