@mmnto/totem 1.21.0 → 1.22.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/dist/ast-classifier.d.ts +72 -4
- package/dist/ast-classifier.d.ts.map +1 -1
- package/dist/ast-classifier.js +155 -30
- package/dist/ast-classifier.js.map +1 -1
- package/dist/ast-classifier.test.js +80 -2
- package/dist/ast-classifier.test.js.map +1 -1
- package/dist/ast-grep-query.d.ts.map +1 -1
- package/dist/ast-grep-query.js +31 -11
- package/dist/ast-grep-query.js.map +1 -1
- package/dist/chunkers/chunker-registry.d.ts +77 -0
- package/dist/chunkers/chunker-registry.d.ts.map +1 -0
- package/dist/chunkers/chunker-registry.js +134 -0
- package/dist/chunkers/chunker-registry.js.map +1 -0
- package/dist/chunkers/chunker-registry.test.d.ts +14 -0
- package/dist/chunkers/chunker-registry.test.d.ts.map +1 -0
- package/dist/chunkers/chunker-registry.test.js +95 -0
- package/dist/chunkers/chunker-registry.test.js.map +1 -0
- package/dist/chunkers/chunker.d.ts +18 -3
- package/dist/chunkers/chunker.d.ts.map +1 -1
- package/dist/chunkers/chunker.js +20 -13
- package/dist/chunkers/chunker.js.map +1 -1
- package/dist/config-schema.d.ts +61 -10
- package/dist/config-schema.d.ts.map +1 -1
- package/dist/config-schema.js +43 -2
- package/dist/config-schema.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/pack-discovery.d.ts +201 -0
- package/dist/pack-discovery.d.ts.map +1 -0
- package/dist/pack-discovery.js +298 -0
- package/dist/pack-discovery.js.map +1 -0
- package/dist/pack-discovery.test.d.ts +17 -0
- package/dist/pack-discovery.test.d.ts.map +1 -0
- package/dist/pack-discovery.test.js +343 -0
- package/dist/pack-discovery.test.js.map +1 -0
- package/dist/pack-manifest-writer.d.ts +88 -0
- package/dist/pack-manifest-writer.d.ts.map +1 -0
- package/dist/pack-manifest-writer.js +162 -0
- package/dist/pack-manifest-writer.js.map +1 -0
- package/dist/pack-manifest-writer.test.d.ts +15 -0
- package/dist/pack-manifest-writer.test.d.ts.map +1 -0
- package/dist/pack-manifest-writer.test.js +184 -0
- package/dist/pack-manifest-writer.test.js.map +1 -0
- package/dist/rule-engine.d.ts.map +1 -1
- package/dist/rule-engine.js +24 -2
- package/dist/rule-engine.js.map +1 -1
- package/dist/rule-engine.test.js +74 -0
- package/dist/rule-engine.test.js.map +1 -1
- package/dist/store/lance-schema.d.ts +3 -3
- package/package.json +3 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime chunker registry (ADR-097 § 5 Q3, mmnto-ai/totem#1769).
|
|
3
|
+
*
|
|
4
|
+
* Replaces the closed `CHUNKER_MAP` keyed by the closed `ChunkStrategy` Zod
|
|
5
|
+
* enum. The registry is a string-keyed Map populated by:
|
|
6
|
+
*
|
|
7
|
+
* 1. Built-in chunkers self-registering at module load (this file's bottom).
|
|
8
|
+
* 2. Pack registration callbacks invoked by `loadInstalledPacks()` during
|
|
9
|
+
* boot (mmnto-ai/totem#1768) — they register via the
|
|
10
|
+
* `PackRegistrationAPI.registerChunkStrategy()` surface, which calls
|
|
11
|
+
* through to `register()` in this module.
|
|
12
|
+
*
|
|
13
|
+
* After boot completes, the engine seals (`pack-discovery.ts` flips
|
|
14
|
+
* `engineSealed = true`) and any further `register()` call throws.
|
|
15
|
+
*
|
|
16
|
+
* The registry has no concept of which built-in vs pack-registered an
|
|
17
|
+
* entry is — that distinction is enforced at registration time (see
|
|
18
|
+
* `register()` and `BUILTIN_CHUNKER_NAMES`).
|
|
19
|
+
*/
|
|
20
|
+
import type { Chunker } from './chunker.js';
|
|
21
|
+
/**
|
|
22
|
+
* Register a chunker under a strategy name. Called by built-ins at module
|
|
23
|
+
* load and by Pack registration callbacks during boot. Throws when:
|
|
24
|
+
*
|
|
25
|
+
* - `engineSealed` (per `pack-discovery.ts`) is true.
|
|
26
|
+
* - The strategy name is already registered (built-ins are immutable;
|
|
27
|
+
* pack-vs-pack collisions are also rejected).
|
|
28
|
+
*
|
|
29
|
+
* Boot vs pack distinction: built-ins call `register()` directly at
|
|
30
|
+
* module-load time (sealed === false, name not yet in registry → succeeds).
|
|
31
|
+
* Packs call via `PackRegistrationAPI.registerChunkStrategy` which routes
|
|
32
|
+
* to this same function. The seal check + name-collision check covers both
|
|
33
|
+
* in one place.
|
|
34
|
+
*/
|
|
35
|
+
export declare function register(name: string, chunkerCtor: new () => Chunker): void;
|
|
36
|
+
/**
|
|
37
|
+
* Look up a chunker class by strategy name. Returns undefined when the
|
|
38
|
+
* name isn't registered — callers decide whether absence is a hard error
|
|
39
|
+
* (Zod validation), a fail-loud at runtime (createChunker), or a soft
|
|
40
|
+
* miss.
|
|
41
|
+
*/
|
|
42
|
+
export declare function lookup(name: string): (new () => Chunker) | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Snapshot of currently-registered strategy names. Used for:
|
|
45
|
+
*
|
|
46
|
+
* - `ChunkStrategySchema` validation error messages (suggesting the valid set).
|
|
47
|
+
* - `totem describe` output enumerating effective strategies.
|
|
48
|
+
*
|
|
49
|
+
* Returns a sorted array for deterministic output.
|
|
50
|
+
*/
|
|
51
|
+
export declare function registeredNames(): readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* True iff the strategy name is one of the built-ins (vs pack-registered).
|
|
54
|
+
* Used by tooling that needs to distinguish core-shipped strategies from
|
|
55
|
+
* pack-contributed ones.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isBuiltin(name: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Mark the registry as sealed. After this, `register()` calls throw.
|
|
60
|
+
* Called by `pack-discovery.ts` `loadInstalledPacks()` after every pack
|
|
61
|
+
* callback returns.
|
|
62
|
+
*
|
|
63
|
+
* The seal applies process-wide. Tests that need to register additional
|
|
64
|
+
* fixture chunkers between cases use `__unsealForTests()`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function seal(): void;
|
|
67
|
+
/** True iff the registry has been sealed. */
|
|
68
|
+
export declare function isSealed(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Test-only: reset the registry and re-register built-ins. Lets per-test
|
|
71
|
+
* fixtures register without leaking state across tests. NEVER call from
|
|
72
|
+
* production code.
|
|
73
|
+
*/
|
|
74
|
+
export declare function __resetForTests(): void;
|
|
75
|
+
/** Test-only: clear the seal so subsequent registrations succeed. */
|
|
76
|
+
export declare function __unsealForTests(): void;
|
|
77
|
+
//# sourceMappingURL=chunker-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunker-registry.d.ts","sourceRoot":"","sources":["../../src/chunkers/chunker-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAyB5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,OAAO,GAAG,IAAI,CAa3E;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,UAAU,OAAO,CAAC,GAAG,SAAS,CAEpE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,IAAI,SAAS,MAAM,EAAE,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,IAAI,IAAI,CAE3B;AAED,6CAA6C;AAC7C,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAID;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAKtC;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime chunker registry (ADR-097 § 5 Q3, mmnto-ai/totem#1769).
|
|
3
|
+
*
|
|
4
|
+
* Replaces the closed `CHUNKER_MAP` keyed by the closed `ChunkStrategy` Zod
|
|
5
|
+
* enum. The registry is a string-keyed Map populated by:
|
|
6
|
+
*
|
|
7
|
+
* 1. Built-in chunkers self-registering at module load (this file's bottom).
|
|
8
|
+
* 2. Pack registration callbacks invoked by `loadInstalledPacks()` during
|
|
9
|
+
* boot (mmnto-ai/totem#1768) — they register via the
|
|
10
|
+
* `PackRegistrationAPI.registerChunkStrategy()` surface, which calls
|
|
11
|
+
* through to `register()` in this module.
|
|
12
|
+
*
|
|
13
|
+
* After boot completes, the engine seals (`pack-discovery.ts` flips
|
|
14
|
+
* `engineSealed = true`) and any further `register()` call throws.
|
|
15
|
+
*
|
|
16
|
+
* The registry has no concept of which built-in vs pack-registered an
|
|
17
|
+
* entry is — that distinction is enforced at registration time (see
|
|
18
|
+
* `register()` and `BUILTIN_CHUNKER_NAMES`).
|
|
19
|
+
*/
|
|
20
|
+
import { MarkdownChunker } from './markdown-chunker.js';
|
|
21
|
+
import { SchemaFileChunker } from './schema-file-chunker.js';
|
|
22
|
+
import { SessionLogChunker } from './session-log-chunker.js';
|
|
23
|
+
import { TestFileChunker } from './test-file-chunker.js';
|
|
24
|
+
import { TypeScriptChunker } from './typescript-chunker.js';
|
|
25
|
+
// ─── Internal state ─────────────────────────────────
|
|
26
|
+
const CHUNKER_REGISTRY = new Map();
|
|
27
|
+
/**
|
|
28
|
+
* Built-in chunker names, immutable. A pack attempting to re-register one
|
|
29
|
+
* of these names is rejected at the boundary in `register()`. The set is
|
|
30
|
+
* populated alongside the initial registrations below; we read it at
|
|
31
|
+
* registration time, so adding a new built-in only requires editing the
|
|
32
|
+
* `register()` calls at the bottom of this file.
|
|
33
|
+
*/
|
|
34
|
+
const BUILTIN_CHUNKER_NAMES = new Set();
|
|
35
|
+
/** Cleared by `__resetForTests` / `unsealForTests` — see pack-discovery.ts. */
|
|
36
|
+
let sealed = false;
|
|
37
|
+
// ─── Public API ─────────────────────────────────────
|
|
38
|
+
/**
|
|
39
|
+
* Register a chunker under a strategy name. Called by built-ins at module
|
|
40
|
+
* load and by Pack registration callbacks during boot. Throws when:
|
|
41
|
+
*
|
|
42
|
+
* - `engineSealed` (per `pack-discovery.ts`) is true.
|
|
43
|
+
* - The strategy name is already registered (built-ins are immutable;
|
|
44
|
+
* pack-vs-pack collisions are also rejected).
|
|
45
|
+
*
|
|
46
|
+
* Boot vs pack distinction: built-ins call `register()` directly at
|
|
47
|
+
* module-load time (sealed === false, name not yet in registry → succeeds).
|
|
48
|
+
* Packs call via `PackRegistrationAPI.registerChunkStrategy` which routes
|
|
49
|
+
* to this same function. The seal check + name-collision check covers both
|
|
50
|
+
* in one place.
|
|
51
|
+
*/
|
|
52
|
+
export function register(name, chunkerCtor) {
|
|
53
|
+
if (sealed) {
|
|
54
|
+
throw new Error(`Chunker registration after engine seal: tried to register '${name}' but engine has already started serving requests. Pack registration must complete during boot — see ADR-097 § 5 Q5.`);
|
|
55
|
+
}
|
|
56
|
+
if (CHUNKER_REGISTRY.has(name)) {
|
|
57
|
+
const existingIsBuiltin = BUILTIN_CHUNKER_NAMES.has(name);
|
|
58
|
+
throw new Error(`Chunker '${name}' is already registered${existingIsBuiltin ? ' as a built-in (built-in entries are immutable)' : ' (pack-vs-pack collision — one of the packs must rename)'}.`);
|
|
59
|
+
}
|
|
60
|
+
CHUNKER_REGISTRY.set(name, chunkerCtor);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Look up a chunker class by strategy name. Returns undefined when the
|
|
64
|
+
* name isn't registered — callers decide whether absence is a hard error
|
|
65
|
+
* (Zod validation), a fail-loud at runtime (createChunker), or a soft
|
|
66
|
+
* miss.
|
|
67
|
+
*/
|
|
68
|
+
export function lookup(name) {
|
|
69
|
+
return CHUNKER_REGISTRY.get(name);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Snapshot of currently-registered strategy names. Used for:
|
|
73
|
+
*
|
|
74
|
+
* - `ChunkStrategySchema` validation error messages (suggesting the valid set).
|
|
75
|
+
* - `totem describe` output enumerating effective strategies.
|
|
76
|
+
*
|
|
77
|
+
* Returns a sorted array for deterministic output.
|
|
78
|
+
*/
|
|
79
|
+
export function registeredNames() {
|
|
80
|
+
return [...CHUNKER_REGISTRY.keys()].sort();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* True iff the strategy name is one of the built-ins (vs pack-registered).
|
|
84
|
+
* Used by tooling that needs to distinguish core-shipped strategies from
|
|
85
|
+
* pack-contributed ones.
|
|
86
|
+
*/
|
|
87
|
+
export function isBuiltin(name) {
|
|
88
|
+
return BUILTIN_CHUNKER_NAMES.has(name);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Mark the registry as sealed. After this, `register()` calls throw.
|
|
92
|
+
* Called by `pack-discovery.ts` `loadInstalledPacks()` after every pack
|
|
93
|
+
* callback returns.
|
|
94
|
+
*
|
|
95
|
+
* The seal applies process-wide. Tests that need to register additional
|
|
96
|
+
* fixture chunkers between cases use `__unsealForTests()`.
|
|
97
|
+
*/
|
|
98
|
+
export function seal() {
|
|
99
|
+
sealed = true;
|
|
100
|
+
}
|
|
101
|
+
/** True iff the registry has been sealed. */
|
|
102
|
+
export function isSealed() {
|
|
103
|
+
return sealed;
|
|
104
|
+
}
|
|
105
|
+
// ─── Test-only helpers ──────────────────────────────
|
|
106
|
+
/**
|
|
107
|
+
* Test-only: reset the registry and re-register built-ins. Lets per-test
|
|
108
|
+
* fixtures register without leaking state across tests. NEVER call from
|
|
109
|
+
* production code.
|
|
110
|
+
*/
|
|
111
|
+
export function __resetForTests() {
|
|
112
|
+
CHUNKER_REGISTRY.clear();
|
|
113
|
+
BUILTIN_CHUNKER_NAMES.clear();
|
|
114
|
+
sealed = false;
|
|
115
|
+
registerBuiltins();
|
|
116
|
+
}
|
|
117
|
+
/** Test-only: clear the seal so subsequent registrations succeed. */
|
|
118
|
+
export function __unsealForTests() {
|
|
119
|
+
sealed = false;
|
|
120
|
+
}
|
|
121
|
+
// ─── Built-in registration (runs at module load) ────
|
|
122
|
+
function registerBuiltin(name, ctor) {
|
|
123
|
+
BUILTIN_CHUNKER_NAMES.add(name);
|
|
124
|
+
register(name, ctor);
|
|
125
|
+
}
|
|
126
|
+
function registerBuiltins() {
|
|
127
|
+
registerBuiltin('session-log', SessionLogChunker);
|
|
128
|
+
registerBuiltin('markdown-heading', MarkdownChunker);
|
|
129
|
+
registerBuiltin('typescript-ast', TypeScriptChunker);
|
|
130
|
+
registerBuiltin('schema-file', SchemaFileChunker);
|
|
131
|
+
registerBuiltin('test-file', TestFileChunker);
|
|
132
|
+
}
|
|
133
|
+
registerBuiltins();
|
|
134
|
+
//# sourceMappingURL=chunker-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunker-registry.js","sourceRoot":"","sources":["../../src/chunkers/chunker-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,uDAAuD;AAEvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA6B,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;AAEhD,+EAA+E;AAC/E,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,uDAAuD;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,WAA8B;IACnE,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,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,uDAAuD;AAEvD,SAAS,eAAe,CAAC,IAAY,EAAE,IAAuB;IAC5D,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,gBAAgB;IACvB,eAAe,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAClD,eAAe,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;IACrD,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACrD,eAAe,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAClD,eAAe,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAChD,CAAC;AAED,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the chunker registry (mmnto-ai/totem#1769, ADR-097 § 5 Q3).
|
|
3
|
+
*
|
|
4
|
+
* Covers invariants 4-9 + 11 (chunker side) from
|
|
5
|
+
* `.totem/specs/pack-substrate-bundle.md`:
|
|
6
|
+
*
|
|
7
|
+
* - All five built-in chunkers self-register at module load.
|
|
8
|
+
* - Pack-style registration adds new entries.
|
|
9
|
+
* - Re-registration of the same name throws.
|
|
10
|
+
* - Registering a built-in name throws (immutable).
|
|
11
|
+
* - Post-seal mutation throws.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=chunker-registry.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunker-registry.test.d.ts","sourceRoot":"","sources":["../../src/chunkers/chunker-registry.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the chunker registry (mmnto-ai/totem#1769, ADR-097 § 5 Q3).
|
|
3
|
+
*
|
|
4
|
+
* Covers invariants 4-9 + 11 (chunker side) from
|
|
5
|
+
* `.totem/specs/pack-substrate-bundle.md`:
|
|
6
|
+
*
|
|
7
|
+
* - All five built-in chunkers self-register at module load.
|
|
8
|
+
* - Pack-style registration adds new entries.
|
|
9
|
+
* - Re-registration of the same name throws.
|
|
10
|
+
* - Registering a built-in name throws (immutable).
|
|
11
|
+
* - Post-seal mutation throws.
|
|
12
|
+
*/
|
|
13
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
14
|
+
import { __resetForTests, __unsealForTests, isBuiltin, isSealed, lookup, register, registeredNames, seal, } from './chunker-registry.js';
|
|
15
|
+
class FakeChunker {
|
|
16
|
+
strategy = 'fake-strategy';
|
|
17
|
+
chunk(_content, _filePath, _type) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class AnotherFakeChunker {
|
|
22
|
+
strategy = 'another-fake';
|
|
23
|
+
chunk(_content, _filePath, _type) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
// Each test gets a fresh registry with built-ins re-registered. Without
|
|
29
|
+
// this, a sealed registry from a prior test would leak into subsequent
|
|
30
|
+
// ones and they'd all fail with "after seal" errors.
|
|
31
|
+
__resetForTests();
|
|
32
|
+
});
|
|
33
|
+
describe('chunker-registry built-ins', () => {
|
|
34
|
+
it('registers all five built-in chunkers at module load', () => {
|
|
35
|
+
expect(lookup('session-log')).toBeDefined();
|
|
36
|
+
expect(lookup('markdown-heading')).toBeDefined();
|
|
37
|
+
expect(lookup('typescript-ast')).toBeDefined();
|
|
38
|
+
expect(lookup('schema-file')).toBeDefined();
|
|
39
|
+
expect(lookup('test-file')).toBeDefined();
|
|
40
|
+
});
|
|
41
|
+
it('exposes registered names sorted alphabetically', () => {
|
|
42
|
+
expect(registeredNames()).toEqual([
|
|
43
|
+
'markdown-heading',
|
|
44
|
+
'schema-file',
|
|
45
|
+
'session-log',
|
|
46
|
+
'test-file',
|
|
47
|
+
'typescript-ast',
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
it('marks built-ins as built-in', () => {
|
|
51
|
+
expect(isBuiltin('markdown-heading')).toBe(true);
|
|
52
|
+
expect(isBuiltin('typescript-ast')).toBe(true);
|
|
53
|
+
expect(isBuiltin('not-a-real-strategy')).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('chunker-registry pack-style registration', () => {
|
|
57
|
+
it('accepts new strategy registration before seal', () => {
|
|
58
|
+
register('fake-strategy', FakeChunker);
|
|
59
|
+
expect(lookup('fake-strategy')).toBe(FakeChunker);
|
|
60
|
+
expect(registeredNames()).toContain('fake-strategy');
|
|
61
|
+
});
|
|
62
|
+
it('does not mark pack-registered names as built-in', () => {
|
|
63
|
+
register('fake-strategy', FakeChunker);
|
|
64
|
+
expect(isBuiltin('fake-strategy')).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
it('throws when re-registering the same strategy name (pack-vs-pack collision)', () => {
|
|
67
|
+
register('fake-strategy', FakeChunker);
|
|
68
|
+
expect(() => register('fake-strategy', AnotherFakeChunker)).toThrowError(/already registered.*pack-vs-pack collision/);
|
|
69
|
+
});
|
|
70
|
+
it('throws when registering a built-in name (built-ins immutable)', () => {
|
|
71
|
+
expect(() => register('markdown-heading', FakeChunker)).toThrowError(/already registered.*as a built-in.*immutable/);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('chunker-registry seal contract', () => {
|
|
75
|
+
it('starts unsealed', () => {
|
|
76
|
+
expect(isSealed()).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
it('seal() flips the flag', () => {
|
|
79
|
+
seal();
|
|
80
|
+
expect(isSealed()).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
it('register() after seal throws with ADR-097 § 5 Q5 reference', () => {
|
|
83
|
+
seal();
|
|
84
|
+
expect(() => register('fake-strategy', FakeChunker)).toThrowError(/after engine seal.*ADR-097 § 5 Q5/);
|
|
85
|
+
});
|
|
86
|
+
it('__unsealForTests reverts the seal so subsequent tests can register', () => {
|
|
87
|
+
seal();
|
|
88
|
+
expect(isSealed()).toBe(true);
|
|
89
|
+
__unsealForTests();
|
|
90
|
+
expect(isSealed()).toBe(false);
|
|
91
|
+
register('fake-strategy', FakeChunker);
|
|
92
|
+
expect(lookup('fake-strategy')).toBe(FakeChunker);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=chunker-registry.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunker-registry.test.js","sourceRoot":"","sources":["../../src/chunkers/chunker-registry.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAKzD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,eAAe,EACf,IAAI,GACL,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW;IACN,QAAQ,GAAW,eAAe,CAAC;IAC5C,KAAK,CAAC,QAAgB,EAAE,SAAiB,EAAE,KAAkB;QAC3D,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,MAAM,kBAAkB;IACb,QAAQ,GAAW,cAAc,CAAC;IAC3C,KAAK,CAAC,QAAgB,EAAE,SAAiB,EAAE,KAAkB;QAC3D,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,SAAS,CAAC,GAAG,EAAE;IACb,wEAAwE;IACxE,uEAAuE;IACvE,qDAAqD;IACrD,eAAe,EAAE,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5C,MAAM,C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,CAAC;QACP,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,gBAAgB,EAAE,CAAC;QACnB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentType } from '../config-schema.js';
|
|
2
2
|
import type { Chunk } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* All chunkers implement this interface.
|
|
5
5
|
* Given file content and metadata, produce an array of Chunks.
|
|
6
6
|
*/
|
|
7
7
|
export interface Chunker {
|
|
8
|
-
readonly strategy:
|
|
8
|
+
readonly strategy: string;
|
|
9
9
|
chunk(content: string, filePath: string, type: ContentType): Chunk[];
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a strategy name to a fresh chunker instance via the registry.
|
|
13
|
+
*
|
|
14
|
+
* Pre-ADR-097 the strategy → constructor mapping was a closed `Record`
|
|
15
|
+
* keyed by the closed `ChunkStrategy` Zod enum (mmnto-ai/totem#1769).
|
|
16
|
+
* Now the lookup goes through `chunker-registry.ts`, which is populated
|
|
17
|
+
* by built-ins at module load and extended by Pack registration
|
|
18
|
+
* callbacks during boot.
|
|
19
|
+
*
|
|
20
|
+
* Fail-loud per Tenet 4: an unregistered strategy name names the missing
|
|
21
|
+
* pack (callers consume the registry's `registeredNames()` for context).
|
|
22
|
+
* Schema validation (`ChunkStrategySchema`) catches misconfigured strategy
|
|
23
|
+
* names at config-load time, so reaching this fail-loud at runtime is an
|
|
24
|
+
* architectural error.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createChunker(strategy: string): Chunker;
|
|
12
27
|
//# sourceMappingURL=chunker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../src/chunkers/chunker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../src/chunkers/chunker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,KAAK,EAAE,CAAC;CACtE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQvD"}
|
package/dist/chunkers/chunker.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { lookup } from './chunker-registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a strategy name to a fresh chunker instance via the registry.
|
|
4
|
+
*
|
|
5
|
+
* Pre-ADR-097 the strategy → constructor mapping was a closed `Record`
|
|
6
|
+
* keyed by the closed `ChunkStrategy` Zod enum (mmnto-ai/totem#1769).
|
|
7
|
+
* Now the lookup goes through `chunker-registry.ts`, which is populated
|
|
8
|
+
* by built-ins at module load and extended by Pack registration
|
|
9
|
+
* callbacks during boot.
|
|
10
|
+
*
|
|
11
|
+
* Fail-loud per Tenet 4: an unregistered strategy name names the missing
|
|
12
|
+
* pack (callers consume the registry's `registeredNames()` for context).
|
|
13
|
+
* Schema validation (`ChunkStrategySchema`) catches misconfigured strategy
|
|
14
|
+
* names at config-load time, so reaching this fail-loud at runtime is an
|
|
15
|
+
* architectural error.
|
|
16
|
+
*/
|
|
13
17
|
export function createChunker(strategy) {
|
|
14
|
-
const Ctor =
|
|
18
|
+
const Ctor = lookup(strategy);
|
|
19
|
+
if (!Ctor) {
|
|
20
|
+
throw new Error(`Unknown chunk strategy: '${strategy}'. The strategy is not registered — either install the pack that provides it or correct the strategy name in totem.config.ts.`);
|
|
21
|
+
}
|
|
15
22
|
return new Ctor();
|
|
16
23
|
}
|
|
17
24
|
//# sourceMappingURL=chunker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunker.js","sourceRoot":"","sources":["../../src/chunkers/chunker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"chunker.js","sourceRoot":"","sources":["../../src/chunkers/chunker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAY/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,4BAA4B,QAAQ,+HAA+H,CACpK,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC"}
|
package/dist/config-schema.d.ts
CHANGED
|
@@ -2,20 +2,48 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Zod schema for totem.config.ts — lives at the root of consuming projects.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Built-in chunk strategy names. Exported so the literal union derived
|
|
7
|
+
* via `typeof BUILTIN_CHUNK_STRATEGIES[number]` keeps the runtime list
|
|
8
|
+
* and the type signature in sync with a single source of truth. Pack-
|
|
9
|
+
* contributed strategies extend `ChunkStrategy` via the `(string & {})`
|
|
10
|
+
* tail and register at boot through `chunker-registry.ts`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BUILTIN_CHUNK_STRATEGIES: readonly ["typescript-ast", "markdown-heading", "session-log", "schema-file", "test-file"];
|
|
13
|
+
/**
|
|
14
|
+
* `ChunkStrategy` schema. Per ADR-097 § 10 + mmnto-ai/totem#1769 strategy
|
|
15
|
+
* lookup goes through `chunker-registry.ts` at runtime; this schema only
|
|
16
|
+
* shape-checks the input string.
|
|
17
|
+
*
|
|
18
|
+
* **Why not refine against the registry here?** Bootstrap chicken-and-egg
|
|
19
|
+
* (Gemini review of mmnto-ai/totem#1768 PR-A): config parse runs BEFORE
|
|
20
|
+
* `loadInstalledPacks()` populates the registry with pack-contributed
|
|
21
|
+
* strategies (the manifest is read AFTER config load by every command).
|
|
22
|
+
* A strict registry-check at parse time would crash `totem sync` on the
|
|
23
|
+
* very edit that adds the pack — user adds `@totem/pack-foo` to extends
|
|
24
|
+
* AND a target with `strategy: 'foo-strat'` in the same change, sync
|
|
25
|
+
* fails to parse the config, never writes installed-packs.json, never
|
|
26
|
+
* registers the pack. Forever stuck.
|
|
27
|
+
*
|
|
28
|
+
* The actual fail-loud happens at `createChunker(strategy)` in
|
|
29
|
+
* `chunkers/chunker.ts` — runtime lookup against the post-boot registry
|
|
30
|
+
* with a structured error naming the missing strategy. That's the right
|
|
31
|
+
* boundary because by then the registry IS populated.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ChunkStrategySchema: z.ZodString;
|
|
6
34
|
export declare const ContentTypeSchema: z.ZodEnum<["code", "session_log", "spec", "lesson"]>;
|
|
7
35
|
export declare const IngestTargetSchema: z.ZodObject<{
|
|
8
36
|
glob: z.ZodString;
|
|
9
37
|
type: z.ZodEnum<["code", "session_log", "spec", "lesson"]>;
|
|
10
|
-
strategy: z.
|
|
38
|
+
strategy: z.ZodString;
|
|
11
39
|
}, "strip", z.ZodTypeAny, {
|
|
12
40
|
type: "code" | "session_log" | "spec" | "lesson";
|
|
13
41
|
glob: string;
|
|
14
|
-
strategy:
|
|
42
|
+
strategy: string;
|
|
15
43
|
}, {
|
|
16
44
|
type: "code" | "session_log" | "spec" | "lesson";
|
|
17
45
|
glob: string;
|
|
18
|
-
strategy:
|
|
46
|
+
strategy: string;
|
|
19
47
|
}>;
|
|
20
48
|
export declare const OpenAIProviderSchema: z.ZodObject<{
|
|
21
49
|
provider: z.ZodLiteral<"openai">;
|
|
@@ -788,15 +816,15 @@ export declare const TotemConfigSchema: z.ZodObject<{
|
|
|
788
816
|
targets: z.ZodArray<z.ZodObject<{
|
|
789
817
|
glob: z.ZodString;
|
|
790
818
|
type: z.ZodEnum<["code", "session_log", "spec", "lesson"]>;
|
|
791
|
-
strategy: z.
|
|
819
|
+
strategy: z.ZodString;
|
|
792
820
|
}, "strip", z.ZodTypeAny, {
|
|
793
821
|
type: "code" | "session_log" | "spec" | "lesson";
|
|
794
822
|
glob: string;
|
|
795
|
-
strategy:
|
|
823
|
+
strategy: string;
|
|
796
824
|
}, {
|
|
797
825
|
type: "code" | "session_log" | "spec" | "lesson";
|
|
798
826
|
glob: string;
|
|
799
|
-
strategy:
|
|
827
|
+
strategy: string;
|
|
800
828
|
}>, "many">;
|
|
801
829
|
/** Embedding provider configuration (optional for Lite tier) */
|
|
802
830
|
embedding: z.ZodOptional<z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
|
|
@@ -1190,6 +1218,19 @@ export declare const TotemConfigSchema: z.ZodObject<{
|
|
|
1190
1218
|
botMarkers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1191
1219
|
/** Optional: paths to other totem-managed directories whose indexes should be queried alongside this one (e.g., ['.strategy', '../docs-repo']) */
|
|
1192
1220
|
linkedIndexes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1221
|
+
/**
|
|
1222
|
+
* Optional: pack package names to extend rules from (ADR-085 + ADR-097).
|
|
1223
|
+
*
|
|
1224
|
+
* Each entry is a pack name like `@totem/pack-rust-architecture`. The
|
|
1225
|
+
* pack must also appear in the consumer's `package.json` dependencies
|
|
1226
|
+
* (or devDependencies) so npm/pnpm can resolve it. Pack-merge logic
|
|
1227
|
+
* (`packages/core/src/pack-merge.ts`) reads pack rules at lint time.
|
|
1228
|
+
* Pack discovery (`packages/core/src/pack-discovery.ts`,
|
|
1229
|
+
* mmnto-ai/totem#1768) reads this field plus the project's
|
|
1230
|
+
* package.json dependencies, deduplicates, and writes the union to
|
|
1231
|
+
* `.totem/installed-packs.json` for boot-time registration.
|
|
1232
|
+
*/
|
|
1233
|
+
extends: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1193
1234
|
/**
|
|
1194
1235
|
* Optional: path override for the strategy repository (mmnto-ai/totem#1710).
|
|
1195
1236
|
*
|
|
@@ -1337,7 +1378,7 @@ export declare const TotemConfigSchema: z.ZodObject<{
|
|
|
1337
1378
|
targets: {
|
|
1338
1379
|
type: "code" | "session_log" | "spec" | "lesson";
|
|
1339
1380
|
glob: string;
|
|
1340
|
-
strategy:
|
|
1381
|
+
strategy: string;
|
|
1341
1382
|
}[];
|
|
1342
1383
|
totemDir: string;
|
|
1343
1384
|
lanceDir: string;
|
|
@@ -1427,6 +1468,7 @@ export declare const TotemConfigSchema: z.ZodObject<{
|
|
|
1427
1468
|
repositories?: string[] | undefined;
|
|
1428
1469
|
botMarkers?: string[] | undefined;
|
|
1429
1470
|
linkedIndexes?: string[] | undefined;
|
|
1471
|
+
extends?: string[] | undefined;
|
|
1430
1472
|
strategyRoot?: string | undefined;
|
|
1431
1473
|
partitions?: Record<string, string[]> | undefined;
|
|
1432
1474
|
garbageCollection?: {
|
|
@@ -1448,7 +1490,7 @@ export declare const TotemConfigSchema: z.ZodObject<{
|
|
|
1448
1490
|
targets: {
|
|
1449
1491
|
type: "code" | "session_log" | "spec" | "lesson";
|
|
1450
1492
|
glob: string;
|
|
1451
|
-
strategy:
|
|
1493
|
+
strategy: string;
|
|
1452
1494
|
}[];
|
|
1453
1495
|
secrets?: {
|
|
1454
1496
|
value: string;
|
|
@@ -1484,6 +1526,7 @@ export declare const TotemConfigSchema: z.ZodObject<{
|
|
|
1484
1526
|
repositories?: string[] | undefined;
|
|
1485
1527
|
botMarkers?: string[] | undefined;
|
|
1486
1528
|
linkedIndexes?: string[] | undefined;
|
|
1529
|
+
extends?: string[] | undefined;
|
|
1487
1530
|
strategyRoot?: string | undefined;
|
|
1488
1531
|
partitions?: Record<string, string[]> | undefined;
|
|
1489
1532
|
shieldAutoLearn?: boolean | undefined;
|
|
@@ -1522,7 +1565,15 @@ export declare const TotemConfigSchema: z.ZodObject<{
|
|
|
1522
1565
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
1523
1566
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1524
1567
|
}>;
|
|
1525
|
-
|
|
1568
|
+
/**
|
|
1569
|
+
* `ChunkStrategy` keeps the literal union of built-in strategy names for
|
|
1570
|
+
* IntelliSense on core code paths while admitting any string registered
|
|
1571
|
+
* via Pack registration callbacks at boot. The Zod schema validates the
|
|
1572
|
+
* runtime value against the registry; this type alias lives independently
|
|
1573
|
+
* so callers don't lose type safety on built-in names. Per ADR-097 § 10 +
|
|
1574
|
+
* mmnto-ai/totem#1769.
|
|
1575
|
+
*/
|
|
1576
|
+
export type ChunkStrategy = (typeof BUILTIN_CHUNK_STRATEGIES)[number] | (string & {});
|
|
1526
1577
|
export type ContentType = z.infer<typeof ContentTypeSchema>;
|
|
1527
1578
|
export type IngestTarget = z.infer<typeof IngestTargetSchema>;
|
|
1528
1579
|
export type EmbeddingProvider = z.infer<typeof EmbeddingProviderSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../src/config-schema.ts"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