Summary
The escapeYamlValue helper is currently duplicated verbatim across three adapter files:
src/core/command-generation/adapters/pi.ts
src/core/command-generation/adapters/claude.ts
src/core/command-generation/adapters/qwen.ts
There is also a known detect/escape asymmetry: \r (carriage return) is correctly detected as requiring YAML quoting (via the regex), but is not escaped in the double-quoted string replace chain. This gap exists consistently across all three siblings.
Proposed Work
- Extract
escapeYamlValue into a shared utility (e.g., src/core/command-generation/utils/yaml.ts or similar).
- Add
\r → \\r escaping in the shared implementation so double-quoted YAML strings fully conform to YAML 1.2.
- Update
pi.ts, claude.ts, and qwen.ts to import and use the shared helper instead of their local copies.
- Add or update unit tests for the shared utility to cover the
\r case.
Context
Requested by: @mc856
Summary
The
escapeYamlValuehelper is currently duplicated verbatim across three adapter files:src/core/command-generation/adapters/pi.tssrc/core/command-generation/adapters/claude.tssrc/core/command-generation/adapters/qwen.tsThere is also a known detect/escape asymmetry:
\r(carriage return) is correctly detected as requiring YAML quoting (via the regex), but is not escaped in the double-quoted string replace chain. This gap exists consistently across all three siblings.Proposed Work
escapeYamlValueinto a shared utility (e.g.,src/core/command-generation/utils/yaml.tsor similar).\r → \\rescaping in the shared implementation so double-quoted YAML strings fully conform to YAML 1.2.pi.ts,claude.ts, andqwen.tsto import and use the shared helper instead of their local copies.\rcase.Context
\rfix was intentionally deferred from PR fix(qwen): generate Markdown commands instead of deprecated TOML format #1191 to avoid diverging the qwen adapter copy from its siblings before a proper shared-util refactor.Requested by: @mc856