Bug Description
When clicking "Always Allow" in CodeIsland for a Codex command that contains multiline content (e.g. python3 -c with inline Python code), the generated Starlark rule file contains raw newline characters inside a string literal, causing a parse error.
Error
Error loading rules:
/Users/ningjiabing/.codex/rules/codeisland.rules:111: starlark error: error: Parse error: unfinished string literal (problem is on or around line 111)
Reproduction
- Use Codex to run a multiline command like:
python3 -c "import json\nd=json.load(...)"
- Click "Always Allow" in CodeIsland for this command
- CodeIsland writes the raw multiline string into
~/.codex/rules/codeisland.rules
- Starlark parser fails with
unfinished string literal
Generated (Broken) Output
prefix_rule(
pattern = ["python3", "-c", "
import json
d=json.load(open('/tmp/apps.json'))
for a in d.get('apps',[]):
...
"],
decision = "allow",
)
Expected Output
Newlines should be escaped as \n:
prefix_rule(
pattern = ["python3", "-c", "import json\nd=json.load(open('/tmp/apps.json'))\nfor a in d.get('apps',[]):\n ...\n"],
decision = "allow",
)
Fix Suggestion
In the rule generation code, when serializing command arguments to Starlark string literals, escape \n → \\n and \r → \\r before writing to the .rules file.
Environment
- macOS arm64 (Apple Silicon, macOS 26)
- CodeIsland: installed via Homebrew
- Codex CLI
Bug Description
When clicking "Always Allow" in CodeIsland for a Codex command that contains multiline content (e.g.
python3 -cwith inline Python code), the generated Starlark rule file contains raw newline characters inside a string literal, causing a parse error.Error
Reproduction
python3 -c "import json\nd=json.load(...)"~/.codex/rules/codeisland.rulesunfinished string literalGenerated (Broken) Output
Expected Output
Newlines should be escaped as
\n:Fix Suggestion
In the rule generation code, when serializing command arguments to Starlark string literals, escape
\n→\\nand\r→\\rbefore writing to the.rulesfile.Environment