Skip to content

feat(al): add AL (Business Central / Dynamics 365) language support - #1649

Open
Capitaller wants to merge 8 commits into
colbymchenry:mainfrom
Capitaller:feature/al-language-support
Open

feat(al): add AL (Business Central / Dynamics 365) language support#1649
Capitaller wants to merge 8 commits into
colbymchenry:mainfrom
Capitaller:feature/al-language-support

Conversation

@Capitaller

Copy link
Copy Markdown

Summary

Adds full AL (Microsoft Dynamics 365 Business Central) language support to CodeGraph, enabling semantic code intelligence across large ERP codebases.

What's included:

  • New alExtractor in src/extraction/languages/al.ts with a resolveName hook that correctly resolves AL object names from the object_name field (Codeunit, Table, Page, Report, XMLport, Query, and all extension types)
  • .al extension registered in src/extraction/grammars.ts
  • 'al' language type added to src/types.ts
  • Case-insensitive reference resolution in src/resolution/name-matcher.ts (AL is case-insensitive by language spec)
  • Extraction parity test in __tests__/al-extraction.test.ts
  • Uses the tree-sitter-al WASM grammar (bundled under src/extraction/wasm/)

Motivation

AL is the primary language for Microsoft Dynamics 365 Business Central, one of the most widely deployed ERP platforms globally. A typical BC codebase (e.g. the official W1 BaseApp) contains 7,800+ files, 115,000+ symbols and 264,000+ dependency edges.

Without CodeGraph, AI agents are forced to rely on grep/find, which fails to understand the graph of Codeunit dependencies and produces shallow, keyword-matched answers.

With CodeGraph, an AI agent answers this in 47s using 2 tool calls:

"Which Codeunit and function is responsible for calculating invoice rounding when there is a 100% prepayment on a Sales line? What temporary tables does it use?"

The agent correctly traces the full call chain: GetSalesLinesInsertInvoiceRoundingInitInvoiceRoundingLine, identifies the responsible Codeunit (Sales-Post Prepayments, Codeunit 442), and names the correct temporary tables (TempPrepmtInvLineBuf, TempSalesLine, TempVATAmountLine). Without CodeGraph, the same agent runs 10+ grep commands and produces a shallow answer that misses the core architecture.

Test plan

  • npm run build — passes with zero TypeScript errors
  • npm run test __tests__/al-extraction.test.ts — AL extraction parity test passes (Codeunit name, procedure nodes, and call reference edges all verified)
  • npm run test — full suite passes: 175 test files, 3,010 tests, 0 failures
  • Indexed 7,820 files from the official Microsoft BC W1 BaseApp source → 115,609 nodes, 264,588 edges in 11.3s
  • Verified AI agent uses codegraph_explore MCP tool calls exclusively — no grep/find fallback — on real Business Central architecture queries

@Capitaller Capitaller changed the title Ífeat(al): add AL (Business Central / Dynamics 365) language support feat(al): add AL (Business Central / Dynamics 365) language support Aug 30, 2026
…extensions, and namespace-aware symbol resolution
… support, additional extension types, and case-insensitive matching logic
@Capitaller
Capitaller marked this pull request as ready for review August 31, 2026 06:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c05fe9eeb2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +13 to +17
const AL_CLASS_TYPES = [
'codeunit_declaration', 'table_declaration', 'page_declaration',
'report_declaration', 'xmlport_declaration', 'query_declaration',
...AL_EXTENSION_TYPES,
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add missing AL object declarations

When an AL project declares standard objects such as permissionset, profile, controladdin, entitlement, or pagecustomization, this extractor never emits a node for them because only the types in AL_CLASS_TYPES plus enum/interface are routed to createNode. This also makes the new permissionsetextension/profileextension extends refs unable to resolve to in-repo base objects, so search/impact miss those AL objects. Please include the missing declaration node types in the object set.

Useful? React with 👍 / 👎.

resolvedBy: 'exact-match',
};
}
if (chosen.length > 1) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prefer local AL calls before declaring ambiguity

For a bare AL call like ValidateName();, if another object anywhere in the project defines a method with the same name while the caller file also has its own ValidateName, preferCallSiteFile only reorders the candidates; chosen.length is still greater than one, so this returns null and suppresses the normal exact-name fallback. This leaves common local helper calls unresolved as soon as the name is duplicated elsewhere; filter to the unique same-file/local candidate or let the generic scorer run before treating it as ambiguous.

Useful? React with 👍 / 👎.

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