Skip to content

feat: native ast generalization#46

Merged
Houseofmvps merged 4 commits into
Houseofmvps:mainfrom
the-wondersmith:feat/native-ast-generalization
Jun 27, 2026
Merged

feat: native ast generalization#46
Houseofmvps merged 4 commits into
Houseofmvps:mainfrom
the-wondersmith:feat/native-ast-generalization

Conversation

@the-wondersmith

Copy link
Copy Markdown
Contributor

PR is the next iteration in the native-AST plugin stack, building on top of #44 and #45 (initial machinery and transition to minimal WASI env initialization respectively).

PR makes native-AST dispatch language-driven instead of tied to the built-in detectors. Plugins now self-describe the languages/extensions they handle, and codesight routes matching files accordingly through one generic pass. This enables any user-declared language to use codesight, not just those with built-in (read: codesight-specific) extractors.

Changes

  • describe() ABI export — plugins return {languageId, extensions, frameworks?}; the host uses languageId (authoritative over filename) + extensions to route. The in-repo reference plugin gains a describe().
  • Registry + discovery — extension → plugin via buildNativeRegistry (template-guarded ^codesight-<lang>-ast.wasm$, PATH-alike waterfall, first-match-wins, collision rule); default ext map for rust/go/python when describe() is absent.
  • Single generic pass src/detectors/native.ts — the only dispatch point; built-in detectors become pure fallback (migrated off in-detector dispatch).
  • CLI--native-ast[=ids|all|none].
  • Merge — explicit --native-ast=<ids> is authoritative (native replaces built-in per file for routes; warns on empty-with-builtin); bare/all is additive (native-preferred dedup).
  • Docs - project documentation has all been updated with appropriate-depth explanations of the new capabilities/behavior

Compatibility / Notes

  • Plugin dispatch is default-off, meaning behavior is still byte-identical to codesight's baseline (v1.15.0).
  • Authoritative replacement is route-only (SchemaModel has no file provenance → schemas dedup-by-name). framework: "unknown" until describe().frameworks is wired. parseImports stays defined + conformance-tested but not yet dispatched.

…icit selection

Add an optional describe()->i64 export (JSON {languageId, extensions}) that
the host reads into LoadedPlugin.metadata, making modules fully
self-describing alongside contractVersion() and parse* capability probes.

- types: NativeLang widened to string; add PluginMetadata.
- plugin-host: read describe() during bindExports; listPluginFiles globs the
  template-guarded ^codesight-(<lang>)-ast.wasm$ across the dir waterfall.
- native-loader: buildNativeRegistry maps extension -> plugin (describe-wins
  languageId, DEFAULT_EXTENSIONS fallback, first-match precedence, collision
  rule); NativeAstResolved gains authoritative + warnings.
- index: --native-ast[=ids|all|none] selection (drops KNOWN_NATIVE_LANGS).
- reference plugin: export describe(); rebuild wasm + checksums.

Foundation only: built-in in-detector dispatch is still live, so behavior is
unchanged.
…detector dispatch

Introduce src/detectors/native.ts as the single point where WASM plugins are
dispatched: group files by extension via the registry, call parseRoutes/
parseSchemas, stamp confidence "native" (framework "unknown" interim), and
record strict diagnostics. mergeNativeRoutes is native-preferred-dedup
(additive) or per-file replace (authoritative, with an empty-with-builtin
warning); mergeNativeSchemas dedups by name (SchemaModel lacks file
provenance).

- routes/schema: drop the per-detector nativePluginFor calls; built-in
  extractors remain as pure fallback. Export detectTags for the pass.
- core: run detectNative after the built-in detectors and merge.
- tests: native-ast dispatch tests move to the generic pass (detectNative).
…ic pass

Add a generalization suite to reference-plugin.test.ts: reads describe()
metadata off the loaded plugin, asserts buildNativeRegistry routes the
declared extension (explicit => authoritative), drives the generic pass over
a .ref file, and verifies `all` mode discovers the plugin by globbing the
plugin dir (=> additive).
…iation

Rework the plugin contract for the generalization: any user-declared
language, describe()-driven discovery (id/extensions, template guard,
precedence/collision), all/none/=ids enabling with additive-vs-authoritative
merge, and the WASI instantiation row in the ABI.
@the-wondersmith

Copy link
Copy Markdown
Contributor Author

As previously, just keeping track of the remaining follow-ups:

Each branch builds directly on the previous -

  1. feat/native-ast-generalization (this PR)

  2. wip/initial-wasm-ast-plugins (+4 commits) — actual working plugins for Rust, Python, and Go (under plugins/ast/), plus a CI workflow that builds them, shrinks them with wasm-opt, smoke-tests each against the host ABI, and publishes the .wasm + checksums as release assets on plugins-v* tags. The npm package neither builds nor ships them.

Intended merge order: this PRwip/initial-wasm-ast-plugins.

Looking forward to nailing down the details of where/how plugins live, are built, and delivered 😁.

@Houseofmvps
Houseofmvps merged commit 6622f58 into Houseofmvps:main Jun 27, 2026
2 of 3 checks passed
@the-wondersmith
the-wondersmith deleted the feat/native-ast-generalization branch June 28, 2026 00:11
Houseofmvps pushed a commit that referenced this pull request Jun 28, 2026
Final PR in the #44#45#46 native-AST stack. Adds canonical Rust (syn), Python (ruff), and Go (go/parser) WASM plugins under plugins/ast/, plus the ast-plugins CI workflow that builds, smoke-tests against the host ABI, and publishes them on plugins-v* tags.

Reviewed safe: strictly additive (0 deletions), no TS/src/dist/package.json changes, npm tarball still excludes plugins/ (verified via npm pack), plugins do no I/O/network/process/fs (pure AST parsers in sandboxed WASM), deps reputably pinned (syn, ruff@SHA, Go stdlib), CI least-privilege with release gated to maintainer tags. All functional checks pass; only failure is the known fork-PR read-only-token artifact.
Houseofmvps pushed a commit that referenced this pull request Jun 29, 2026
Docs-only sync from the-wondersmith: corrects stale counts (14 ORM parsers, 14 MCP tools, 145 tests, 30+ frameworks), rewrites native-AST WASM plugin docs to match the shipped #46/#47 language-driven dispatch + reference plugins, adds gin-gorm eval fixture row and reference-plugin describe() note. Verified: 14 MCP tools registered, 145 tests pass, gin-gorm fixture present, 14 ORMs in source. No code/dependency changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants