Everything a module author needs to plug real functionality into typescript-anything. The engine (CLI, pipeline commands) never calls module code directly — modules register capabilities through the typed extension points below, and the pipeline consumes them.
src/modules/<category>/<module-id>.ts # one module per file
<category>is one of:codecs,record,diff,fuzz,gate,bench,port,runtime,adapters,watch,security,report,ai,mcp,kill,swap,state,observ,interop,profile,pm,fw,ci,docs.<module-id>is kebab-case (codec-typed-arrays), identical to the module'sidfield and to the file name (without.ts).- The file
src/modules/index.tsis GENERATED (scripts/gen-module-index.mjsregenerates it). Never edit it by hand.
import type { Module } from '../../types.js';
const m: Module = {
id: 'codec-typed-arrays', // kebab-case, unique, == file name
name: 'Typed Array Codec',
category: 'codecs', // must match the parent directory
description: 'One-sentence, user-facing description of what this does.',
keywords: ['typedarray', 'serialization'], // optional
features: [
// 3–6 machine-countable features. Every id MUST be `<moduleId>:<kebab>`.
{ id: 'codec-typed-arrays:roundtrip', name: 'Round-trip', description: '…', kind: 'codec' },
{ id: 'codec-typed-arrays:bigi64', name: 'BigInt64 support', description: '…', kind: 'codec' },
],
register(ctx) {
ctx.registerCodec({
id: 'codec-typed-arrays',
name: 'Typed Array Codec',
detect(value) { return value instanceof Float64Array; },
encode(value, encodeValue) { return { data: [...(value as Float64Array)] }; },
decode(data, decodeValue) { return new Float64Array((data as { data: number[] }).data); },
});
},
};
export default m;- Relative imports MUST end with
.js(NodeNext ESM):import type { Module } from '../../types.js'. Do not import other modules; import shared types from../../types.jsonly. - No third-party dependencies.
node:*builtins only (node:crypto,node:fs,node:path,node:child_process, …). - Real logic only. No
TODO, no placeholders, nothrow new Error('not implemented'). Every feature you declare must be backed by code that runs when the module registers (a codec, check, corpus, rule, reporter, transform, runtime, command, or analyzer — or an event handler with side effects). - Feature count: 3–6 per module. Feature ids are globally unique and are
machine-verified by
ta doctor/ta features count. register(ctx)must not throw on any reasonable config; wrap risky work in try/catch internally.- Do not modify files outside your module file. No edits to
src/types.ts,src/modules/index.ts, commands, or other modules.
| Method | Registers | Consumed by |
|---|---|---|
registerCodec(codec) |
a lossless value codec (detect/encode/decode) |
ta record, ta replay, doctor |
registerCheck(check) |
a gate check returning {check,status,severity,summary,details} |
ta gate, ta ci |
registerCorpus(corpus) |
an adversarial input generator (generate(rng)) |
ta record, ta fuzz |
registerDiffRule(rule) |
first-match-wins tolerance rule | ta diff, ta shadow |
registerReporter(section) |
a markdown report section (order, render(ctx)) |
ta report |
registerPortTransform(t) |
a JS→TS source transform | ta port |
registerRuntime(adapter) |
a process runtime (detect, runFile) |
runtime matrix commands |
registerCommand(cmd) |
an extra CLI subcommand | ta <name> |
registerAnalyzer(an) |
a project analyzer returning findings | ta analyze |
on(event, handler) |
subscribe to pipeline events (see EventName) |
the bus |
store |
per-run scratch storage | cross-module state |
Codec wire format: the serializer wraps plugin output as
{ $codec: '<codecId>', v: <encoded> } — you only produce the v part.
encode/decode receive an encodeValue/decodeValue callback for
nested values.
cd /home/z/my-project/typescript-anything
node scripts/gen-module-index.mjs # regenerate the module index
npm run build # tsc — must be error-free
node dist/cli.js modules count # your module must be counted
node dist/cli.js features count # your features must be counted
node dist/cli.js doctor # must stay green (no new issues)