Sync languages - #986
Conversation
📝 WalkthroughWalkthroughThis PR adds Haskell and Dart language support to the ast-grep documentation website and introduces a new consistency validator script. It updates reference tables, guides, and editor configurations to document the new languages, and implements automated checks to keep language definitions synchronized across parser configuration, component mappings, and filesystem assets. ChangesLanguage Support Expansion and Consistency Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm-workspace.yaml`:
- Around line 1-3: The allowBuilds map currently uses instructional strings for
the dprint and esbuild keys; replace those string values with boolean literals
(true or false) so the entries become valid booleans under the allowBuilds
key—update the dprint and esbuild values to the intended true/false settings in
pnpm-workspace.yaml.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ae7c7903-195e-4c36-94fe-119934019b94
⛔ Files ignored due to path filters (3)
website/public/langs/haskell.svgis excluded by!**/*.svgwebsite/public/langs/nix.svgis excluded by!**/*.svgwebsite/public/parsers/tree-sitter-haskell.wasmis excluded by!**/*.wasm
📒 Files selected for processing (9)
package.jsonpnpm-workspace.yamlwebsite/_data/parsers.tswebsite/check-lang-consistency.mjswebsite/guide/introduction.mdwebsite/guide/tools/editors.mdwebsite/reference/languages.mdwebsite/reference/yaml.mdwebsite/src/components/astGrep/lang.ts
| allowBuilds: | ||
| dprint: set this to true or false | ||
| esbuild: set this to true or false |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
For the pnpm version used by this repo, what is the exact pnpm-workspace.yamlschema forallowBuilds (including valid value types and examples)?
💡 Result:
Answer: In a pnpm v11-style pnpm-workspace.yaml, the allowBuilds field uses a YAML map (Record) from package matchers to boolean values. Each entry is true to allow that package’s install/build scripts and false to disallow them. Exact schema (shape) - allowBuilds must be a map/object: allowBuilds: { <package-matcher>: <boolean>, ... } [1] - Value type for each map entry: boolean (true or false) [1] - Keys: “package matchers” (package names and/or version-spec style matchers) used to match dependencies whose build scripts may be run/blocked [1] Valid value examples 1) Simple allow/deny by package name: allowBuilds: esbuild: true core-js: false # disallow ghooks: true fuse-native: true unrs-resolver: true [2] 2) Using matcher expressions that include package name + versions (as shown in the docs): allowBuilds: esbuild: true core-js: false nx@21.6.4 || 21.6.5: true nx@21.6.0: false [1] Notes about behavior (what the booleans mean) - Docs state it is “A map of package matchers to explicitly allow (true) or disallow (false) script execution.” [1] - Packages not listed are disallowed by default, and pnpm’s behavior depends on strictDepBuilds (error vs warning). [1] Repo pnpm version used - Your question asks “For the pnpm version used by this repo…”. I did not receive the repo URL / pnpm version from you, so I can only provide the current authoritative schema from pnpm’s docs for allowBuilds as used in modern pnpm (v10.26+ / v11 docs). If you share the repo link (or its packageManager field / lockfile pnpm version), I can confirm the exact pnpm release and re-check the corresponding documentation for that version.
Citations:
Fix pnpm allowBuilds value types to booleans
allowBuilds in pnpm-workspace.yaml is a map of package matchers to boolean values (true/false). Setting dprint/esbuild to instructional strings makes the config invalid (wrong value type) and will likely be rejected or ignored by pnpm.
Proposed fix
allowBuilds:
- dprint: set this to true or false
- esbuild: set this to true or false
+ dprint: true
+ esbuild: true📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| allowBuilds: | |
| dprint: set this to true or false | |
| esbuild: set this to true or false | |
| allowBuilds: | |
| dprint: true | |
| esbuild: true |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pnpm-workspace.yaml` around lines 1 - 3, The allowBuilds map currently uses
instructional strings for the dprint and esbuild keys; replace those string
values with boolean literals (true or false) so the entries become valid
booleans under the allowBuilds key—update the dprint and esbuild values to the
intended true/false settings in pnpm-workspace.yaml.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@website/check-lang-consistency.mjs`:
- Around line 24-30: The code currently uses langTableRe and langsFromTable to
capture the first table cell (display name) with /^\|(\w+)\s*\|/ which excludes
punctuation and returns display names instead of IDs; change the regex to
capture the second column (the language ID) and allow non-word characters (e.g.
/^\|[^|]*\|\s*([^|]+)\s*\|/gm), then replace uses of langTableRe /
langsFromTable (including the other occurrences that parse table rows) so they
push the captured ID (m[1]) and handle trimming; ensure all three locations that
previously used /^\|(\w+)\s*\|/ are updated to the new regex and logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bbb70a89-fe5f-47be-8a1c-b8bb22534fc8
⛔ Files ignored due to path filters (3)
website/public/langs/haskell.svgis excluded by!**/*.svgwebsite/public/langs/nix.svgis excluded by!**/*.svgwebsite/public/parsers/tree-sitter-haskell.wasmis excluded by!**/*.wasm
📒 Files selected for processing (8)
package.jsonwebsite/_data/parsers.tswebsite/check-lang-consistency.mjswebsite/guide/introduction.mdwebsite/guide/tools/editors.mdwebsite/reference/languages.mdwebsite/reference/yaml.mdwebsite/src/components/astGrep/lang.ts
✅ Files skipped from review due to trivial changes (4)
- website/reference/yaml.md
- website/guide/introduction.md
- package.json
- website/reference/languages.md
| const langTableRe = /^\|(\w+)\s*\|/gm | ||
| const langsFromTable = [] | ||
| for (const m of langsMd.matchAll(langTableRe)) { | ||
| const name = m[1] | ||
| if (name === 'Language') continue // header row | ||
| langsFromTable.push(name) | ||
| } |
There was a problem hiding this comment.
Parse language IDs from languages.md, not display names.
The current regex reads the first column (Language display name), then compares it with yaml/parser IDs. This creates false errors (and misses names like C#/C++ because \w+ excludes punctuation).
Suggested fix
-const langTableRe = /^\|(\w+)\s*\|/gm
-const langsFromTable = []
-for (const m of langsMd.matchAll(langTableRe)) {
- const name = m[1]
- if (name === 'Language') continue // header row
- langsFromTable.push(name)
-}
+// Capture the Language Id column and collect all backticked ids/aliases.
+const langTableRe = /^\|\s*[^|]+\|\s*([^|]+)\|/gm
+const langsFromTable = []
+for (const m of langsMd.matchAll(langTableRe)) {
+ const idColumn = m[1]
+ for (const id of idColumn.matchAll(/`([^`]+)`/g)) {
+ langsFromTable.push(id[1])
+ }
+}-const tableLower = new Set(langsFromTable.map(l => l.toLowerCase()))
+const tableLower = new Set(langsFromTable.map(l => l.toLowerCase()))Also applies to: 47-55, 145-149
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@website/check-lang-consistency.mjs` around lines 24 - 30, The code currently
uses langTableRe and langsFromTable to capture the first table cell (display
name) with /^\|(\w+)\s*\|/ which excludes punctuation and returns display names
instead of IDs; change the regex to capture the second column (the language ID)
and allow non-word characters (e.g. /^\|[^|]*\|\s*([^|]+)\s*\|/gm), then replace
uses of langTableRe / langsFromTable (including the other occurrences that parse
table rows) so they push the captured ID (m[1]) and handle trimming; ensure all
three locations that previously used /^\|(\w+)\s*\|/ are updated to the new
regex and logic.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scripts/check-lang-consistency.mjs (1)
40-42:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winGuard against null when no backticked values are found.
If
yamlMatch[1]contains no backticked values,.match()returnsnulland calling.map()on it will throw aTypeError.🛡️ Proposed fix
const langsFromYaml = yamlMatch - ? yamlMatch[1].match(/`(\w+)`/g).map(s => s.replace(/`/g, '')) + ? (yamlMatch[1].match(/`(\w+)`/g) || []).map(s => s.replace(/`/g, '')) : []🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/check-lang-consistency.mjs` around lines 40 - 42, The code computes langsFromYaml from yamlMatch[1].match(...).map(...), but if yamlMatch[1].match(...) returns null the .map call will throw; update the logic in scripts/check-lang-consistency.mjs (symbols: yamlMatch, langsFromYaml) to handle a null match by supplying an empty-array fallback before calling .map (e.g. store the result of yamlMatch[1].match(/`(\w+)`/g) into a variable and use || or ?? to default to []), so .map is only invoked on an array and langsFromYaml becomes [] when no backticked values are found.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@scripts/check-lang-consistency.mjs`:
- Around line 40-42: The code computes langsFromYaml from
yamlMatch[1].match(...).map(...), but if yamlMatch[1].match(...) returns null
the .map call will throw; update the logic in scripts/check-lang-consistency.mjs
(symbols: yamlMatch, langsFromYaml) to handle a null match by supplying an
empty-array fallback before calling .map (e.g. store the result of
yamlMatch[1].match(/`(\w+)`/g) into a variable and use || or ?? to default to
[]), so .map is only invoked on an array and langsFromYaml becomes [] when no
backticked values are found.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ac8cba69-961d-447f-912d-bbf124f11695
📒 Files selected for processing (2)
package.jsonscripts/check-lang-consistency.mjs
✅ Files skipped from review due to trivial changes (1)
- package.json
There are some inconsistencies between the various language lists, including Dart not appearing on https://ast-grep.github.io/reference/languages.html
Summary by CodeRabbit
New Features
Documentation
Chores