Skip to content

feat: Pascal/Delphi support, pnpm v10 fixes, and cross-platform test improvements#322

Open
jimmckeeth wants to merge 8 commits into
Egonex-AI:mainfrom
jimmckeeth:feat/pascal-delphi
Open

feat: Pascal/Delphi support, pnpm v10 fixes, and cross-platform test improvements#322
jimmckeeth wants to merge 8 commits into
Egonex-AI:mainfrom
jimmckeeth:feat/pascal-delphi

Conversation

@jimmckeeth

Copy link
Copy Markdown

Summary

  • Pascal/Delphi language support via tree-sitter-pascal (own grammar at github:jimmckeeth/tree-sitter-pascal), with WASM now pre-built and bundled in the npm package — no manual download step needed
  • pnpm v10 allowBuilds fixpnpm-workspace.yaml had placeholder text instead of true values, causing ERR_PNPM_IGNORED_BUILDS for all tree-sitter packages and esbuild
  • Prereq docs — README now mentions Node.js ≥ 22 and pnpm ≥ 10 as prerequisites
  • Auto-install pnpminstall.sh / install.ps1 now attempt to install pnpm if it's missing, rather than failing with an unhelpful error
  • Branch auto-detection in install scripts — when running install.sh / install.ps1 from a local git checkout (e.g. on a feature branch), the installer checks out the same branch in ~/.understand-anything/repo
  • Cross-platform test fixes — 5 fixes so pnpm test passes on Windows without Python or bash in PATH (shebang-strip vitest plugin, conditional skips for bash/Python-dependent tests, test isolation fix for !pattern negation)

Test plan

  • pnpm install && pnpm test passes (14 pass, 2 skipped on Linux; all 16 pass/skip on Windows)
  • pnpm --filter @understand-anything/core test passes
  • Pascal .pas / .dpr files are recognized and parsed in the /understand skill
  • pnpm-workspace.yaml allowBuilds entries are true (not placeholder text)

🤖 Generated with Claude Code

jimmckeeth and others added 5 commits June 29, 2026 22:37
- Add allowBuilds: true to pnpm-workspace.yaml for esbuild and all
  tree-sitter-* packages; pnpm v10+ requires explicit opt-in for
  packages that run build scripts (ERR_PNPM_IGNORED_BUILDS)
- Update pnpm-lock.yaml after successful pnpm install
- Add Ensure-Pnpm / ensure_pnpm to install.ps1 and install.sh so the
  installers automatically install pnpm via corepack (preferred) or
  npm if it is not already on PATH
- Add prerequisites note to README listing Node.js >= 22 and pnpm >= 10
Adds full structural analysis and call graph extraction for Pascal,
Object Pascal (Delphi), and Free Pascal source files using
github:jimmckeeth/tree-sitter-pascal.

- Language config: .pas, .dpr, .lpr, .pp extensions; entry points, test
  patterns, and Pascal-specific concept hints
- PascalExtractor: extracts procedures/functions (defProc), class and
  interface type declarations (declType + declClass/declIntf), uses-clause
  imports (declUses + moduleName), and exports from the interface section
- Call graph: captures exprCall (with-args) and bare statement identifier
  calls; handles qualified names (genericDot, operatorDot) for method impls
- WASM build scripts: scripts/build-pascal-wasm.{sh,ps1} via Docker/Emscripten;
  pre-built WASM available at jimmckeeth/tree-sitter-pascal releases
- 16 passing tests covering functions, classes, interfaces, imports,
  exports, call graph, and a comprehensive realistic unit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…stall workaround

tree-sitter-pascal now ships tree-sitter-pascal.wasm directly in the
GitHub repo. Update pnpm-lock.yaml to commit 8212ff0 which includes
the pre-built WASM, so pnpm install delivers it automatically.

Remove the stale comments in pascal.ts that directed users to download
the WASM separately — it is now available via the normal dependency
install path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…it checkout

When install.sh / install.ps1 is run from a local git working tree
(e.g. during development on a feature branch), the installer now
detects the current branch and checks it out in the cloned repo at
~/.understand-anything/repo. Falls back gracefully when piped from
curl (no git context available).

This lets developers test branches end-to-end with a real install path
by running the local install.sh / install.ps1 directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Five fixes for cross-platform test compatibility:

- vitest.config.ts: add strip-shebang load plugin so test files can
  import CLI .mjs scripts that start with #!/usr/bin/env node
- worktree-redirect.test.mjs: skip on Windows (bash resolves paths
  through MSYS /tmp/... while Node.js uses C:\... Windows paths)
- merge-recover-imports.test.mjs: skip when python3 is not available
  (Windows typically lacks python3 in PATH; CI/Linux still runs these)
- test_scan_project.test.mjs: use gitInit:false for !pattern negation
  test so a developer's global gitignore (which may include *.log)
  cannot shadow the .understandignore negation before createIgnoreFilter
  sees it — the test is about filter logic, not git enumeration
- test_extract_import_map.test.mjs: skip tree-sitter init graceful
  failure test on Windows (ESM loader hooks don't reliably intercept
  module resolution there)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gonex-AI#183

- Extend StructuralAnalysis types with optional parents[], interfaces[],
  and imports[].section ("interface"|"implementation") — backward compatible
- PascalExtractor now emits parents/interfaces from declClass/declIntf
  typeref ancestors, and tags each import with its Pascal section
- extract-structure.mjs surfaces parents, interfaces, and section in JSON output
- Add emit-dfm-pairs.mjs: post-merge helper that wires .pas↔.dfm related edges
- Add resolve-external-class-refs.mjs: generic post-merge pass that rewires
  cross-batch class:external:<Name> inheritance edges to actual node IDs
- Add skills/understand/languages/pascal.md: LLM prompt snippet for Pascal/Delphi

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jimmckeeth jimmckeeth force-pushed the feat/pascal-delphi branch from ebc7871 to 52f9746 Compare June 30, 2026 21:47
Port the inheritance/interface fields from Egonex-AI PR Egonex-AI#183 to all
existing language extractors, using each language's native AST nodes:

- TypeScript/JS: class_heritage → extends_clause (parents) + implements_clause (interfaces)
- Java: superclass field (parents) + interfaces field (interfaces); interface extends_interfaces (parents)
- C#: base_list with I-prefix heuristic to split parents vs interfaces
- Python: superclasses argument_list → parents (no syntactic interface distinction)
- PHP: base_clause (parents) + class_interface_clause (interfaces)
- Ruby: superclass field (parents) + include/prepend/extend calls (interfaces)
- Go: embedded struct fields (no field_identifier child) → parents for method promotion
- C++: base_class_clause → parents (no syntactic interface concept)
- Rust: trait supertrait bounds → parents; impl Trait for Type → interfaces via traitsByType pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jimmckeeth

Copy link
Copy Markdown
Author

I rebased, resolved conflicts, and integrated the changes from the similar PR #183 by @Cameron64

The Wasmer Registry (jimmckeeth/tree-sitter-pascal) and PyPI packages ship
non-npm formats that can't be consumed by web-tree-sitter's require.resolve()
mechanism. Follow the same pattern used for Dart: vendor the pre-built WASM
from the v0.11.0 GitHub release into a workspace package.

- Add packages/tree-sitter-pascal-wasm/ with tree-sitter-pascal.wasm (v0.11.0,
  964 KB) — resolves via require.resolve() just like all other grammars
- Switch core package.json from "tree-sitter-pascal": "github:jimmckeeth/..."
  to "@understand-anything/tree-sitter-pascal-wasm": "workspace:*"
- Update pascal.ts language config: wasmPackage → "@understand-anything/tree-sitter-pascal-wasm"
- Remove tree-sitter-pascal from pnpm-workspace.yaml allowBuilds (no build
  scripts needed for a vendored WASM); fix the Kotlin allowBuilds entry that
  was previously left as "set this to true or false"
- Update pnpm-lock.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant