qwen-code/packages
LaZzyMan ce2f1902b9 fix(core): add regex-based fallback when tree-sitter WASM fails to load
When the WASM files cannot be found (e.g. symlinked CLI whose vendor path
probe still fails, or any other I/O error), isShellCommandReadOnlyAST and
initParser previously left the agent in a permanently broken state:
  - initParser() returned a rejected promise stored in initPromise, so every
    subsequent call returned the same rejection immediately
  - isShellCommandReadOnlyAST() propagated the error to its caller, which
    caused the shell tool to throw and left the agent 'thinking forever'

Changes:
- Import isShellCommandReadOnly from shellReadOnlyChecker.js
- Track parserInitFailed: boolean flag on the parser singleton
- initParser(): on any init error, set parserInitFailed=true and reset
  initPromise=null (preventing permanent hang on the rejected promise)
- isShellCommandReadOnlyAST(): check parserInitFailed before attempting
  AST parse; wrap the AST path in try/catch so any unexpected runtime
  error also falls through to the regex checker
- _resetParser(): also resets parserInitFailed so tests can re-initialise
- Export _setParserFailedForTesting() to allow unit tests to exercise the
  fallback path without breaking actual WASM loading

Tests added:
- Fallback suite: verifies that when the parser is marked as failed, all
  isShellCommandReadOnlyAST calls delegate to isShellCommandReadOnly and
  that _resetParser() restores normal AST operation
- Consistency suite: 40+ commands from shellReadOnlyChecker.test.ts run
  through BOTH implementations; every case must agree. Known intentional
  divergences (pure assignment, process substitution, control flow,
  function definitions) are documented explicitly - all happen to agree
  on the same boolean result, confirming the two implementations are
  behaviourally consistent across the tested corpus

Fixes #2758
2026-03-31 15:23:51 +08:00
..
cli chore: bump version to v0.13.1 (#2716) 2026-03-27 18:32:26 +08:00
core fix(core): add regex-based fallback when tree-sitter WASM fails to load 2026-03-31 15:23:51 +08:00
hook_design/hooks_ui add test for hooks ui 2026-03-24 15:23:31 +08:00
sdk-java fix(core/rateLimit): add support for IdealTalk rate limit error code 1305 2026-02-28 11:05:41 +08:00
sdk-typescript docs(sdk): enhance coreTools/excludeTools/allowedTools documentation with permissions reference 2026-03-24 22:26:54 +08:00
test-utils chore: bump version to v0.13.1 (#2716) 2026-03-27 18:32:26 +08:00
vscode-ide-companion chore: bump version to v0.13.1 (#2716) 2026-03-27 18:32:26 +08:00
web-templates chore: bump version to v0.13.1 (#2716) 2026-03-27 18:32:26 +08:00
webui chore: bump version to v0.13.1 (#2716) 2026-03-27 18:32:26 +08:00
zed-extension chore(zed-extension): update package version to 0.10.0 2026-02-06 14:26:01 +08:00