@treygoff/specgate
v0.3.1
Published
NPM wrapper for Specgate CLI with a TypeScript resolution snapshot generator. Before publishing, bump version manually or use 'npm run release' which runs 'npm version patch' automatically.
Readme
specgate npm wrapper
Lightweight npm wrapper for Specgate distribution, including a focused TypeScript resolution snapshot generator that can be fed to specgate doctor compare --tsc-trace.
This README is wrapper-specific. For the main product overview, install flow, and agent-facing routing, see:
What this package provides
specgatewrapper binaryspecgate-resolution-snapshotfocused trace generator
The wrapper is intentionally small and self-contained. It does not assume CI-specific environment variables or secret configuration.
CLI usage
Focused snapshot generation
npx specgate-resolution-snapshot \
--project-root . \
--from src/app/main.ts \
--import @core/utils \
--out .tmp/tsc-focus.json \
--prettyEquivalent command through the wrapper bin (also supports snapshot-resolution alias):
npx specgate resolution-snapshot \
--from src/app/main.ts \
--import @core/utils \
--out .tmp/tsc-focus.jsonFeed snapshot into doctor compare
specgate doctor compare \
--project-root . \
--from src/app/main.ts \
--import @core/utils \
--structured-snapshot-in .tmp/tsc-focus.json \
--parser-mode structuredSnapshot JSON schema (doctor_compare_tsc_resolution_focus)
The generator emits a JSON object with this shape:
{
"schema_version": "1",
"snapshot_kind": "doctor_compare_tsc_resolution_focus",
"producer": "specgate-npm-wrapper",
"generated_at": "2026-02-28T18:20:00.000Z",
"project_root": "/abs/path/to/repo",
"tsconfig_path": "tsconfig.json",
"focus": {
"from": "src/app/main.ts",
"import_specifier": "@core/utils"
},
"resolutions": [
{
"source": "tsc_compiler_api",
"from": "src/app/main.ts",
"import": "@core/utils",
"import_specifier": "@core/utils",
"result_kind": "first_party",
"resolved_to": "src/core/utils.ts",
"trace": [
"tsconfig: tsconfig.json",
"module_resolution: NodeNext"
]
}
],
"edges": [
{
"from": "src/app/main.ts",
"to": "src/core/utils.ts"
}
]
}result_kind is one of:
first_partythird_partyunresolvable
For third_party results, package_name is included when it can be inferred.
Rust parser compatibility contract
This shape is intentionally aligned to Specgate's doctor compare structured parser:
- Any object with
from+tocontributes an edge. - Any object with
from+ one ofimport/import_specifier/specifiercontributes a focused resolution record. resolved_tois consumed when present.result_kindis consumed when present and falls back to inference when omitted.traceis consumed as an array of strings.
Because resolutions[] and edges[] are standard JSON objects using those field names, the output can be passed directly to --structured-snapshot-in.
Native specgate binary forwarding
The specgate wrapper forwards non-resolution-snapshot commands to a native binary if one is available at:
SPECGATE_NATIVE_BIN(env var)npm/specgate/native/<platform>/<arch>/specgatenpm/specgate/native/<platform>/specgate
If no native binary is found, the wrapper exits with an explanatory error.
