@volter/supercode-interchange 0.1.13 → 0.1.14
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/index.d.ts +4 -0
- package/index.mjs +2 -2
- package/package.json +1 -1
- package/retained-projection.mjs +6 -1
- package/source-layout.mjs +7 -0
package/index.d.ts
CHANGED
|
@@ -83,6 +83,8 @@ export function fileRoot(harness: HarnessId, homes: HarnessHomes): string | null
|
|
|
83
83
|
export function sessionPartFor(harness: HarnessId, root: string, path: string): Promise<string | null>;
|
|
84
84
|
export function listSessionParts(harness: HarnessId, root: string, options?: { folder?: string; beforeDirectory?: (path: string) => Promise<void>; metrics?: IndexMetrics }): Promise<{ parts: Set<string>; directories: Set<string> }>;
|
|
85
85
|
export function readFileMetadata(harness: HarnessId, root: string, path: string, options?: { previous?: FileReadCache; projects?: Map<string, string>; nativeTopic?: (path: string, id: string) => string | null; metrics?: IndexMetrics }): Promise<{ descriptor: SessionDescriptor | null; cache: FileReadCache | null }>;
|
|
86
|
+
/** The version of a harness's metadata reader; a part read by another version is read again. */
|
|
87
|
+
export function metadataReaderVersion(harness: HarnessId): number;
|
|
86
88
|
export function sourceStat(path: string): Promise<import('node:fs').BigIntStats | null>;
|
|
87
89
|
export function sourceEntries(path: string): Promise<string[]>;
|
|
88
90
|
export function selectStoreFiles(harness: HarnessId, homes: HarnessHomes): Promise<Array<{ path: string; profile: string | null }>>;
|
|
@@ -115,6 +117,8 @@ export interface IndexMetadataRecord {
|
|
|
115
117
|
source: string; part: string; row_key: string; descriptor: SessionDescriptor;
|
|
116
118
|
mirror?: { harness: string | null; messages: number | null; continued: boolean; count: number } | null;
|
|
117
119
|
}
|
|
120
|
+
/** Whether a row stands for the session its key names: false for one that names that same key as its parent. */
|
|
121
|
+
export function filedUnderOwnKey(descriptor: SessionDescriptor): boolean;
|
|
118
122
|
export class RetainedMetadataProjection {
|
|
119
123
|
constructor(query: DiscoveryQuery, sources: string[], records: Iterable<IndexMetadataRecord>, metrics?: IndexMetrics);
|
|
120
124
|
updatePart(source: string, part: string, records: Iterable<IndexMetadataRecord>): void;
|
package/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ export {
|
|
|
5
5
|
encodeDiscoveryCursor, decodeDiscoveryCursor, paginateDescriptors,
|
|
6
6
|
discoveryReceipt, projectMetadataPage,
|
|
7
7
|
} from './query.mjs';
|
|
8
|
-
export { FILE_HARNESSES, STORE_HARNESSES, normalizedSourcePath, pathUnder, fileRoot, sessionPartFor, listSessionParts, readFileMetadata } from './source-layout.mjs';
|
|
8
|
+
export { FILE_HARNESSES, STORE_HARNESSES, normalizedSourcePath, pathUnder, fileRoot, sessionPartFor, listSessionParts, readFileMetadata, metadataReaderVersion } from './source-layout.mjs';
|
|
9
9
|
export { sourceStat, sourceEntries, selectStoreFiles, storeRegistryDirectories } from './store-registry.mjs';
|
|
10
10
|
export { fileFingerprint, sameFingerprint } from './file-io.mjs';
|
|
11
11
|
export { verifySources, readGeminiProjects, readSourceJson } from './source-files.mjs';
|
|
@@ -17,4 +17,4 @@ export { codexNamesPath, readCodexNames, readCodexHistory, readClaudeTitles } fr
|
|
|
17
17
|
export { enrichDescriptor, enrichIndexPage, discoverFromIndex } from './discovery.mjs';
|
|
18
18
|
export { nativeInteger } from './native-json.mjs';
|
|
19
19
|
export { nativeTrim } from './text.mjs';
|
|
20
|
-
export { RetainedMetadataProjection } from './retained-projection.mjs';
|
|
20
|
+
export { RetainedMetadataProjection, filedUnderOwnKey } from './retained-projection.mjs';
|
package/package.json
CHANGED
package/retained-projection.mjs
CHANGED
|
@@ -4,6 +4,10 @@ const order = (a, b) => a.rank - b.rank || Buffer.compare(Buffer.from(a.part), B
|
|
|
4
4
|
|| Buffer.compare(Buffer.from(a.row_key), Buffer.from(b.row_key));
|
|
5
5
|
const originKey = (row) => JSON.stringify([row.source, row.part, row.row_key]);
|
|
6
6
|
const partKey = (source, part) => JSON.stringify([source, part]);
|
|
7
|
+
/** A row naming its own key as its parent is another transcript filed under that key (a child's file that carries
|
|
8
|
+
* its parent's id). It never stands for the session, whatever reader wrote it and whichever part sorts last. */
|
|
9
|
+
export const filedUnderOwnKey = (descriptor) => descriptor.parent_session_id == null
|
|
10
|
+
|| descriptor.parent_session_id !== descriptor.locator.session_id;
|
|
7
11
|
|
|
8
12
|
/** A retained query owns one ordered metadata projection, shared by windows
|
|
9
13
|
* with the same filters. An ordinary part update replaces only its connected
|
|
@@ -33,7 +37,8 @@ export class RetainedMetadataProjection {
|
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
#winner(key) {
|
|
36
|
-
const candidates = [...(this.candidates.get(key) ?? [])].map((origin) => this.origins.get(origin))
|
|
40
|
+
const candidates = [...(this.candidates.get(key) ?? [])].map((origin) => this.origins.get(origin))
|
|
41
|
+
.filter((row) => filedUnderOwnKey(row.descriptor)).sort(order);
|
|
37
42
|
if (!candidates.length) { this.raw.delete(key); return; }
|
|
38
43
|
// snapshot's deduplication keeps the last value, but the first occurrence
|
|
39
44
|
// determines map iteration order (including native cross-harness families).
|
package/source-layout.mjs
CHANGED
|
@@ -82,6 +82,13 @@ export async function listSessionParts(harness, root, { folder = root, beforeDir
|
|
|
82
82
|
return { parts, directories };
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/** Each harness's metadata reader version, 1 where none is named. A change that makes a reader name a session
|
|
86
|
+
* differently from the same bytes (its key, its parent, the facts of its header) raises that harness's number: the
|
|
87
|
+
* daemon keeps the version each part was read with and reads again every part an older reader wrote
|
|
88
|
+
* (session-index-owner.mjs), since a file whose stamps hold is otherwise never read twice. */
|
|
89
|
+
const METADATA_READERS = { 'claude-code': 2 };
|
|
90
|
+
export const metadataReaderVersion = (harness) => METADATA_READERS[harness] ?? 1;
|
|
91
|
+
|
|
85
92
|
/** All readers return one cache/descriptor unit. Cache identities and offsets
|
|
86
93
|
* are committed beside the descriptor by the daemon, never by this library. */
|
|
87
94
|
export async function readFileMetadata(harness, root, path, { previous, projects, nativeTopic, metrics = {} } = {}) {
|