@mmnto/totem 1.21.0 → 1.23.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 +31 -0
- package/dist/ast-grep-query.d.ts.map +1 -1
- package/dist/ast-grep-query.js +75 -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/compile-lesson.d.ts +24 -15
- package/dist/compile-lesson.d.ts.map +1 -1
- package/dist/compile-lesson.js +72 -34
- package/dist/compile-lesson.js.map +1 -1
- package/dist/compile-lesson.test.js +30 -0
- package/dist/compile-lesson.test.js.map +1 -1
- package/dist/compile-smoke-gate.d.ts.map +1 -1
- package/dist/compile-smoke-gate.js +25 -12
- package/dist/compile-smoke-gate.js.map +1 -1
- package/dist/compile-smoke-gate.test.js +39 -0
- package/dist/compile-smoke-gate.test.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-grep-query.js","sourceRoot":"","sources":["../src/ast-grep-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAYlD,uDAAuD;AAEvD,MAAM,aAAa,GACjB,sGAAsG,CAAC;AAEzG,uDAAuD;AAEvD
|
|
1
|
+
{"version":3,"file":"ast-grep-query.js","sourceRoot":"","sources":["../src/ast-grep-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAA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O,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,IAAqC,CAAC;IAC1C,IAAI,CAAC;QACH,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,mBAAmB,CAAC,6BAA6B,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAE,EAAE;QACvD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,qDAAqD;YACrD,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,8DAA8D;YAC9D,4DAA4D;YAC5D,4DAA4D;YAC5D,wCAAwC;YACxC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACpF,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9B,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -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/ch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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,E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AAC,CAAC,CAAC;AAEH,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,IAAI,EAAE,CAAC;QACP,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,IAAI,EAAE,CAAC;QACP,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC,YAAY,CAC/D,mCAAmC,CACpC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,IAAI,EAAE,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/compile-lesson.d.ts
CHANGED
|
@@ -191,21 +191,30 @@ export interface CompileLessonDeps {
|
|
|
191
191
|
* patterns (statement boundaries outside braces/parens), and
|
|
192
192
|
* compound object patterns missing the required `rule` key.
|
|
193
193
|
* Gives fast, human-readable error messages for the common cases.
|
|
194
|
-
* 2. Parser-based check (#1339) — actually invoke ast-grep's rule
|
|
195
|
-
* compiler via `parse(
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* semantic validation — e.g.
|
|
200
|
-
* (floating member call with no
|
|
201
|
-
* (bare catch clause that can only
|
|
194
|
+
* 2. Parser-based check (#1339, #1654) — actually invoke ast-grep's rule
|
|
195
|
+
* compiler via `parse(lang, '').root().findAll(pattern)` for every
|
|
196
|
+
* Lang resolved from the rule's `fileGlobs`. The pattern is accepted
|
|
197
|
+
* if it parses under any of those Langs; rejected with the last
|
|
198
|
+
* Lang's error message if all of them fail. This catches single-line
|
|
199
|
+
* patterns that look balanced but fail semantic validation — e.g.
|
|
200
|
+
* `.option("--no-$FLAG", $$$REST)` (floating member call with no
|
|
201
|
+
* receiver) or `catch($E) { $$$ }` (bare catch clause that can only
|
|
202
|
+
* exist inside a try statement) — and equally importantly, surfaces
|
|
203
|
+
* grammar-mismatch failures when a pattern would parse under TSX
|
|
204
|
+
* but not under the rule's actual target grammar (e.g. a Rust
|
|
205
|
+
* `ResMut<TacticalState>` pattern that TSX accepts as a JSX element
|
|
206
|
+
* but Rust rejects as a malformed type expression).
|
|
202
207
|
*
|
|
203
|
-
* Language choice:
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
208
|
+
* Language choice: when `fileGlobs` resolves to one or more registered
|
|
209
|
+
* languages (e.g., `**\/*.rs` → Rust, `**\/*.ts` → TypeScript), the pattern
|
|
210
|
+
* is validated under every such grammar and accepted if any one accepts
|
|
211
|
+
* it. When `fileGlobs` is absent or no glob carries a registered
|
|
212
|
+
* extension, falls back to `Lang.Tsx` — the most permissive parser
|
|
213
|
+
* available (superset of TypeScript plus JSX) — so unscoped pre-1.16
|
|
214
|
+
* rules retain their legacy validation behavior. Empty source (`''`)
|
|
215
|
+
* keeps the call cheap — ast-grep compiles the pattern into a rule
|
|
216
|
+
* before iterating any AST, so we see the rule-compile error even though
|
|
217
|
+
* there's nothing to match against.
|
|
209
218
|
*
|
|
210
219
|
* Lite-build safety: this function is only called from compile flows
|
|
211
220
|
* (buildCompiledRule / buildManualRule), which require an orchestrator
|
|
@@ -217,7 +226,7 @@ export interface CompileLessonDeps {
|
|
|
217
226
|
* failure) degrades conservatively to `valid: false` rather than
|
|
218
227
|
* crashing the compile command.
|
|
219
228
|
*/
|
|
220
|
-
export declare function validateAstGrepPattern(pattern: string | Record<string, unknown
|
|
229
|
+
export declare function validateAstGrepPattern(pattern: string | Record<string, unknown>, fileGlobs?: readonly string[]): RegexValidation;
|
|
221
230
|
/**
|
|
222
231
|
* Options controlling how `buildCompiledRule` validates its input before
|
|
223
232
|
* emitting a `CompiledRule`. The smoke gate is opt-in so Pipeline 1 (manual)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-lesson.d.ts","sourceRoot":"","sources":["../src/compile-lesson.ts"],"names":[],"mappings":"
|
|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