@crouton-kit/tsym 0.1.0 → 0.1.1
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/dist/server/main.js +10 -1
- package/dist/store/meta.d.ts +2 -0
- package/dist/store/meta.js +17 -1
- package/package.json +2 -2
package/dist/server/main.js
CHANGED
|
@@ -11,7 +11,7 @@ import { ingestCommits } from '../index/commits.js';
|
|
|
11
11
|
import { refreshIndex } from '../index/refresh.js';
|
|
12
12
|
import { IndexStateController } from '../index/state.js';
|
|
13
13
|
import { watchIndex } from '../index/watch.js';
|
|
14
|
-
import { canReuse, hasSourceDrift, metadataFor, readMetadata, writeMetadata } from '../store/meta.js';
|
|
14
|
+
import { canReuse, discardIncompatibleStore, hasSourceDrift, metadataFor, readMetadata, writeMetadata } from '../store/meta.js';
|
|
15
15
|
import { EngineBinaryError, Store } from '../store/store.js';
|
|
16
16
|
import { executeSemantic } from '../commands/handlers.js';
|
|
17
17
|
import { findNode } from '../commands/tree.js';
|
|
@@ -255,6 +255,8 @@ async function main() {
|
|
|
255
255
|
semantic ??= createSemanticContext(root);
|
|
256
256
|
const { program, projects } = semantic;
|
|
257
257
|
await projects.bootstrap();
|
|
258
|
+
if (discardIncompatibleStore(paths.store))
|
|
259
|
+
append(paths, 'discarded a store written by another tsym schema version');
|
|
258
260
|
store = new Store(paths.store);
|
|
259
261
|
if (active)
|
|
260
262
|
sendPhase(active.socket, active.request.requestId, 'index-build-start', remaining(loadDeadlineAt));
|
|
@@ -290,6 +292,13 @@ async function main() {
|
|
|
290
292
|
finally {
|
|
291
293
|
if (deadlineTimer)
|
|
292
294
|
clearTimeout(deadlineTimer);
|
|
295
|
+
if (!bootstrapped) {
|
|
296
|
+
// A failed load must leave nothing open, or the next attempt fails on store ownership instead of its real cause.
|
|
297
|
+
watcher?.close();
|
|
298
|
+
watcher = undefined;
|
|
299
|
+
store?.close();
|
|
300
|
+
store = undefined;
|
|
301
|
+
}
|
|
293
302
|
loading = false;
|
|
294
303
|
loadDeadlineAt = undefined;
|
|
295
304
|
if (!timedOut && !retired) {
|
package/dist/store/meta.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface StoreMetadata {
|
|
|
18
18
|
}
|
|
19
19
|
export declare function metadataPath(storePath: string): string;
|
|
20
20
|
export declare function readMetadata(storePath: string): StoreMetadata | null;
|
|
21
|
+
/** A store written by another schema version, or without readable metadata, cannot be read by this build; it is deleted so the next build starts from nothing. */
|
|
22
|
+
export declare function discardIncompatibleStore(storePath: string): boolean;
|
|
21
23
|
export declare function writeMetadata(storePath: string, metadata: StoreMetadata): void;
|
|
22
24
|
/** Captures every input whose change can alter the configured-program graph. */
|
|
23
25
|
export declare function metadataFor(root: string, projects: ConfiguredProjects, indexedCommit: string, indexDurationMs?: number, tsVersion?: string): StoreMetadata;
|
package/dist/store/meta.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import * as ts from 'ts5';
|
|
@@ -20,6 +20,22 @@ export function readMetadata(storePath) {
|
|
|
20
20
|
throw error;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
/** A store written by another schema version, or without readable metadata, cannot be read by this build; it is deleted so the next build starts from nothing. */
|
|
24
|
+
export function discardIncompatibleStore(storePath) {
|
|
25
|
+
if (!existsSync(storePath))
|
|
26
|
+
return false;
|
|
27
|
+
let metadata = null;
|
|
28
|
+
try {
|
|
29
|
+
metadata = readMetadata(storePath);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
metadata = null;
|
|
33
|
+
}
|
|
34
|
+
if (metadata?.schemaVersion === STORE_SCHEMA_VERSION)
|
|
35
|
+
return false;
|
|
36
|
+
rmSync(storePath, { recursive: true, force: true });
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
23
39
|
export function writeMetadata(storePath, metadata) {
|
|
24
40
|
if (metadata.schemaVersion !== STORE_SCHEMA_VERSION)
|
|
25
41
|
throw new Error(`Store metadata schema version must be ${STORE_SCHEMA_VERSION}.`);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crouton-kit/tsym",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Symbol-level reading of a TypeScript codebase for agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
8
|
-
"tsym": "
|
|
8
|
+
"tsym": "bin/tsym.js"
|
|
9
9
|
},
|
|
10
10
|
"main": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|