LearnNewsExamplesServices
Frontmatter
id11973
titleBump SourceParser acorn ecmaVersion to support ES2025 import attributes
stateClosed
labels
bugai
assigneesneo-opus-ada
createdAtMay 25, 2026, 3:12 PM
updatedAtMay 25, 2026, 3:56 PM
githubUrlhttps://github.com/neomjs/neo/issues/11973
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMay 25, 2026, 3:56 PM

Bump SourceParser acorn ecmaVersion to support ES2025 import attributes

neo-opus-ada
neo-opus-ada commented on May 25, 2026, 3:12 PM

Context

Operator-flagged KB-sync regression surfaced after restarting the orchestrator (npm run ai:orchestrator[ProcessSupervisor] knowledge base sync stderr):

[WARN] Failed to parse source file ai/scripts/maintenance/downloadKnowledgeBase.mjs: Unexpected token (5:48)
[WARN] Failed to parse source file ai/scripts/maintenance/uploadKnowledgeBase.mjs: Unexpected token (5:48)

The Problem

ai/services/knowledge-base/parser/SourceParser.mjs:58 hardcodes acorn.parse(content, {sourceType: 'module', locations: true, ecmaVersion: 2022}). Both failing files use ES2025 import-attribute syntax at line 5 column 48:

import packageJson from '../../../package.json' with {type: 'json'};

Acorn 8.16.0 (currently pinned in package.json) supports import ... with {type: 'json'} only under ecmaVersion: 2025 or ecmaVersion: 'latest'. ecmaVersion: 2022 does not recognize the with keyword as an import attribute.

The Architectural Reality

Primary surfaces:

Provenance: The with syntax was introduced 2026-05-23 in commit e6c9df098 (#11848/#11853 buildScripts/ai → ai/scripts collapse refactor). KB-sync has been silently dropping these chunks since then; today's orchestrator restart triggered a full re-parse and surfaced the WARN.

Blast scope: WARN only — KB sync completes; the 2 affected files just don't contribute source chunks to the knowledge base. Agents querying the KB about downloadKnowledgeBase/uploadKnowledgeBase get no source-level results. Not a stop-the-world but degrades agent-facing observability.

The Fix

Single-line change at SourceParser.mjs:58:

- ast = acorn.parse(content, { sourceType: 'module', locations: true, ecmaVersion: 2022 });
+ ast = acorn.parse(content, { sourceType: 'module', locations: true, ecmaVersion: 'latest' });

'latest' is acorn's documented sentinel for "the most recent ECMA version this acorn release supports" — auto-tracks new syntax as acorn is upgraded, without further hardcoded version bumps required when new TC39 features land.

Acceptance Criteria

  • SourceParser.mjs:58 uses ecmaVersion: 'latest' (no hardcoded year).
  • New unit test in test/playwright/unit/ai/services/knowledge-base/parser/SourceParser.spec.mjs (or equivalent canonical location) parses a fixture containing import x from 'y.json' with {type: 'json'} without warning.
  • After npm run ai:orchestrator triggers a KB sync, no Failed to parse source file warnings for downloadKnowledgeBase.mjs or uploadKnowledgeBase.mjs appear in the daemon log.
  • No regression in existing KB-sync chunk counts (parser was permissive enough before; bumping the floor doesn't change behavior on files already parseable under 2022).

Out of Scope

  • Migrating the 2 files back to fs.readJson (would lose the static-import benefit; we want the parser to handle modern syntax, not constrain authoring).
  • Bumping acorn itself — 8.16.0 already supports 'latest'.
  • Auditing for other parsers in the codebase that may have the same hardcoded-year issue (file as follow-up if any are found).

Avoided Traps

  • Do NOT switch ecmaVersion: 2025 instead of 'latest' — the literal year locks future agents into another hardcoded bump when ES2026+ syntax lands. 'latest' auto-tracks.
  • Do NOT add a fallback try { 'latest' } catch { 2022 } block — defensive code that never fires is noise. Acorn's contract is documented; trust it.
  • Do NOT touch the 2 files using import with — they're authoring the canonical modern shape; the parser is the surface to fix.

Related

  • #11848 / #11853 — refactor that introduced the import with syntax in the 2 maintenance scripts
  • Operator-reported regression 2026-05-25 via orchestrator daemon log

Handoff Retrieval Hint: "SourceParser acorn ecmaVersion 2022 import attribute with type json regression".

tobiu referenced in commit 426baf2 - "fix(kb): bump SourceParser acorn ecmaVersion to 'latest' for ES2025 import attributes (#11973) (#11974) on May 25, 2026, 3:56 PM
tobiu closed this issue on May 25, 2026, 3:56 PM