@mnemonica/tactica 0.4.4 → 0.4.6

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/README.md CHANGED
@@ -33,6 +33,12 @@ TypeScript can't infer that `user.AdminType` exists, because `UserType.define()`
33
33
 
34
34
  Tactica parses your source, builds the type hierarchy, and emits `.tactica/types.ts` + `.tactica/registry.ts`. Once those files are part of your `tsc` compilation, TypeScript understands the full hierarchy — without runtime changes.
35
35
 
36
+ > Emitting `define()` results directly instead of using tactica (or the
37
+ > builder pattern) breaks TypeScript 6 declaration emit with a TS2883
38
+ > error. That failure is the guard rail, not a missing export — the full
39
+ > story and the available paths:
40
+ > [mnemonica docs/typed-lookup.md — Declaration emit on TypeScript 6](https://github.com/wentout/mnemonica/blob/master/docs/typed-lookup.md#declaration-emit-on-typescript-6-the-ts2883-symptom).
41
+
36
42
  ## Installation
37
43
 
38
44
  ```bash
@@ -135,10 +141,11 @@ Tactica writes everything under the `--output` directory (default `.tactica/`).
135
141
  | `registry.ts` | default mode | `declare module 'mnemonica' { interface TypeRegistry { … } }` augmentation — powers `lookup<K>()`. |
136
142
  | `index.ts` | default mode | Re-exports everything from `types.ts` and `registry.ts`. |
137
143
  | `index.d.ts` | with `--module-augmentation` | Single global-augmentation file (legacy mode). |
138
- | `definitions.json` | always | One entry per discovered type: `{ name, location, kind: 'define'\|'decorate', parent, strictChain, blockErrors }`. Consumed by `mnemographica`'s Go to Definition. |
144
+ | `definitions.json` | always | One entry per discovered type: `{ name, location, kind: 'define'\|'decorate', parent, strictChain, blockErrors }`, plus `fields` (the type's own fields in declaration order, `{ name, type, optional }`) and `args` (the constructor's parameters in declaration order, `{ name, type, optional?, kind? }` — a rest parameter carries `kind: 'rest'` and no `optional`). Consumed by `mnemographica`'s Go to Definition. |
139
145
  | `usages.json` | always | One entry per type, value is an array of `{ location, kind, code, holderScopeId?, constructorText? }` records — where each type is instantiated, referenced, accessed, or looked up. `holderScopeId` points into `scopes.json` (the innermost scope holding the usage); `constructorText` (instantiations only) is the constructor expression text actually used. Consumed by `mnemographica`'s Find References. |
140
146
  | `flow.json` | always | Native instance-flow patterns (property reads/writes, method calls, destructuring, returns, spreads, etc.) per type. |
141
147
  | `instrumentation.json` | always | v2 envelope. `points`: framework lifecycle crossroads (interceptors, guards, pipes, filters, middleware) detected via **plugin-supplied vocabulary** — heritage declarations, decorator sites, provider-token registrations, `consumer.apply()` wiring. Syntactic only — no dive dependency; with no plugins loaded, `points` is `[]`. `creationGraph`: the inside-out walk from every instantiation site out to the starters — see "Creation graph" below. |
148
+ | `control.json` | always | The lethe cross-language rendering of the same data: `callers` is the instrumentation `creationGraph`, `points` the same instrumentation points. `instrumentation.json` stays unchanged for `mnemographica`. |
142
149
  | `modules.json` | always | Module-scope graph: every module's `exportedBindings`/`importedBindings` (functions, classes, consts, types — not only mnemonica types), project-internal `dependencies`, `builtinSpecifiers` (Node builtins are skipped entirely — both `'path'` and `'node:path'` forms), `unresolvedSpecifiers`, circular-import `cycles`, and cross-module mnemonica-type `edges`. Resolution uses `ts.resolveModuleName` with the project's compilerOptions (tsconfig `paths`, extensionless imports, index files) — no type checker. Bindings resolved into `node_modules` are marked `external: true` and never enter `dependencies`. |
143
150
  | `scopes.json` | always | Local-scope graph: function/method/arrow scopes only (no block scopes) plus one module scope per file; variables with `typePath` (mnemonica type when known), `isParameter`, `isMutable`, and `reassignments` — each reassignment of a mutable binding is a flow-termination point. `lookup()` initializers resolve through the same tier law as the analyzer (scope-chain receiver first, then the analyzer's source-relative/root law), so scopes metadata never disagrees with the hard-fail verdicts. |
144
151
  | `eds.json` | when EDS enabled | Execution-flow patterns (`wrap`, `current`, `getFlow`, `attachHooks` lifecycle wiring). Consumed by tools that visualize execution chains. |
@@ -770,11 +777,12 @@ class TypesWriter {
770
777
  writeGlobalAugmentation(generated: GeneratedTypes): string; // → outputDir/index.d.ts
771
778
  writeTo(filename: string, content: string): string; // → outputDir/<filename>
772
779
 
773
- writeDefinitionsFile(map: Map<string, DefinitionInfo>): string; // → outputDir/definitions.json
780
+ writeDefinitionsFile(map: Map<string, DefinitionInfo>, graph?: TypeGraph): string; // → outputDir/definitions.json (graph adds fields/args)
774
781
  writeUsagesFile (map: Map<string, UsageInfo[]>): string; // → outputDir/usages.json
775
782
  writeEDSFile (map: Map<string, EDSInfo[]>): string; // → outputDir/eds.json
776
783
  writeFlowFile (map: Map<string, FlowInfo[]>): string; // → outputDir/flow.json
777
784
  writeInstrumentationFile(points: InstrumentationPoint[], creationGraph?: CreationGraph): string; // → outputDir/instrumentation.json
785
+ writeControlFile (points: InstrumentationPoint[], callers: CreationGraph): string; // → outputDir/control.json
778
786
  writeModulesFile (graph: ModuleGraph): string; // → outputDir/modules.json
779
787
  writeScopesFile (analysis: ScopeAnalysis): string; // → outputDir/scopes.json
780
788
 
@@ -786,7 +794,7 @@ class TypesWriter {
786
794
 
787
795
  ### Types
788
796
 
789
- `TacticaConfig`, `TypeNode`, `TypeGraph`, `PropertyInfo`, `ConstructorParamInfo`, `AnalyzeResult`, `AnalyzeError`, `GeneratedTypes`, `DefinitionInfo`, `UsageInfo`, `UsagesJson`, `DefinitionsJson`, `EDSInfo`, `EDSJson`, `EDSKind`, `FlowInfo`, `FlowJson`, `FlowKind`, `InstrumentationKind`, `InstrumentationScope`, `InstrumentationPoint`, `InstrumentationJson`, `ModuleBindingKind`, `ModuleImportKind`, `ModuleBinding`, `ModuleInfo`, `CrossModuleUsage`, `ModuleGraph`, `ModulesJson`, `ScopeKind`, `ScopeInfo`, `ScopeVariable`, `ScopeAnalysis`, `ScopesJson`, `CreationGraphNode`, `CreationGraphEdge`, `CreationAnchor`, `CreationGraph`, `TacticaPlugin`, `InstrumentationVocabulary` — all exported from `@mnemonica/tactica`. See [`src/types.ts`](src/types.ts) for the full schema. The `mergeTacticaPlugins(plugins)` helper merges plugin vocabulary the same way the analyzer does.
797
+ `TacticaConfig`, `TypeNode`, `TypeGraph`, `PropertyInfo`, `ConstructorParamInfo`, `AnalyzeResult`, `AnalyzeError`, `GeneratedTypes`, `DefinitionInfo`, `DefinitionField`, `DefinitionArg`, `UsageInfo`, `UsagesJson`, `DefinitionsJson`, `EDSInfo`, `EDSJson`, `EDSKind`, `FlowInfo`, `FlowJson`, `FlowKind`, `InstrumentationKind`, `InstrumentationScope`, `InstrumentationPoint`, `InstrumentationJson`, `ControlJson`, `ModuleBindingKind`, `ModuleImportKind`, `ModuleBinding`, `ModuleInfo`, `CrossModuleUsage`, `ModuleGraph`, `ModulesJson`, `ScopeKind`, `ScopeInfo`, `ScopeVariable`, `ScopeAnalysis`, `ScopesJson`, `CreationGraphNode`, `CreationGraphEdge`, `CreationAnchor`, `CreationGraph`, `TacticaPlugin`, `InstrumentationVocabulary` — all exported from `@mnemonica/tactica`. See [`src/types.ts`](src/types.ts) for the full schema. The `mergeTacticaPlugins(plugins)` helper merges plugin vocabulary the same way the analyzer does.
790
798
 
791
799
  ## EDS (Execution Data Storage) Tracking
792
800
 
@@ -925,7 +933,7 @@ Deliberate approximations (name-based, no type checker): namespace imports count
925
933
  1. **Parse** — load `tsconfig.json`, build a `ts.Program`, walk each source file's AST.
926
934
  2. **Detect** — find `define()` and `@decorate()` calls, plus `lookup` lookups, `new` expressions, and EDS / flow patterns.
927
935
  3. **Graph** — build a Trie of types in `TypeGraphImpl`, with parent links via the chain of `.define()` calls and `@decorate(Parent)` references.
928
- 4. **Generate** — emit `types.ts`, `registry.ts`, `index.ts` (default mode) or `index.d.ts` (legacy mode), plus `definitions.json`, `usages.json` (with `holderScopeId`), `flow.json`, `instrumentation.json`, `modules.json`, `scopes.json`, `hierarchy.json`/`hierarchy.txt`, `collections.json`, and optionally `eds.json`.
936
+ 4. **Generate** — emit `types.ts`, `registry.ts`, `index.ts` (default mode) or `index.d.ts` (legacy mode), plus `definitions.json`, `usages.json` (with `holderScopeId`), `flow.json`, `instrumentation.json`, `control.json`, `modules.json`, `scopes.json`, `hierarchy.json`/`hierarchy.txt`, `collections.json`, and optionally `eds.json`.
929
937
  5. **Write** — files land in the output directory (default `.tactica/`).
930
938
 
931
939
  ```
package/SKILL.md CHANGED
@@ -27,6 +27,11 @@ consumed by editor extensions and other tools.
27
27
  - Code calls `lookup('Some.Type')` and you want the result typed
28
28
  - A constructor or subtype type-errors and the fix belongs upstream
29
29
  (regenerate `.tactica` before reaching for a cast)
30
+ - TypeScript 6 declaration emit fails with TS2883 ("cannot be named
31
+ without a reference to 'GlobalRegistry'") — the project exports free
32
+ `define()` results without a registry merge; tactica is one of the
33
+ right fixes. Full story:
34
+ [mnemonica docs/typed-lookup.md — Declaration emit on TypeScript 6](https://github.com/wentout/mnemonica/blob/master/docs/typed-lookup.md#declaration-emit-on-typescript-6-the-ts2883-symptom)
30
35
 
31
36
  ## How to run
32
37