[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXD2T2K2J1NYRW0BDCF28V":3,"skill-same:01M6HXD2T2K2J1NYRW0BDCF28V":79},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":46,"linkOnly":47,"markdownContent":48,"markdownBody":49,"frontMatter":50,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":54,"repositoryHtmlUrl":55,"repositoryHomepageUrl":6,"ownerHtmlUrl":56,"ownerBlogUrl":57,"ownerDescription":6,"updatedAt":58,"install":59,"resources":72},"01M6HXD2T2K2J1NYRW0BDCF28V","unicode-safe-file-writing",null,"How to reliably write files containing multi-byte Unicode (emoji, special symbols) when write_file fails with 'unknown error' by falling back to run_shell with a heredoc.","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Funicode-safe-file-writing\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45],"safe","unicode safe file writing","Unicode","file","writing","shell","how","write","files","back","emoji","how to","error","multi","run","with","unknown","2026-11-10 10:12:30",false,"---\nname: unicode-safe-file-writing\ndescription: How to reliably write files containing multi-byte Unicode (emoji, special symbols) when write_file fails with 'unknown error' by falling back to run_shell with a heredoc.\n---\n\n# Unicode-Safe File Writing\n\n## Problem\n\nThe `write_file` tool may fail with `'unknown error'` when the file content\ncontains multi-byte Unicode characters such as:\n\n- Emoji (e.g. `?`, `✅`, `❌`)\n- Special typographic symbols (e.g. `→`, `•`, `—`, `©`)\n- Non-ASCII characters outside the Latin-1 range\n\nThis is a known encoding limitation of `write_file`.\n\n## Solution\n\nFall back to `run_shell` and write the file using a **shell heredoc**\n(`cat > file \u003C\u003C 'EOF' ... EOF`). The single-quoted delimiter `'EOF'`\nprevents the shell from interpreting any special characters inside the\nblock.\n\n---\n\n## Step-by-Step Recovery\n\n### Step 1 — Detect the failure\n\nIf `write_file` returns an error such as:\n\n```\nError: unknown error\n```\n\nand the content contains non-ASCII characters, assume a Unicode encoding\nissue and proceed to the heredoc fallback.\n\n### Step 2 — Strip or replace problematic characters (if needed)\n\nBefore embedding content in the heredoc, decide whether to:\n\n- **Keep** the characters as-is (works if the shell\u002Fterminal is UTF-8 aware)\n- **Replace** emoji\u002Fsymbols with ASCII equivalents (safest, most portable)\n- **Remove** them entirely\n\nCommon replacements:\n\n| Original | Replacement |\n|----------|-------------|\n| `✅`     | `[OK]`      |\n| `❌`     | `[ERROR]`   |\n| `?`     | `[START]`   |\n| `→`      | `->`        |\n| `•`      | `-`         |\n| `—`      | `--`        |\n\n### Step 3 — Write the file via heredoc\n\nUse `run_shell` with the following pattern:\n\n```bash\ncat > path\u002Fto\u002Ffile.ext \u003C\u003C 'EOF'\n...file content here (with Unicode stripped\u002Freplaced if needed)...\nEOF\n```\n\n**Key details:**\n- Use `'EOF'` (single-quoted) as the heredoc delimiter — this disables all\n  shell variable expansion and special character interpretation inside the block.\n- Do **not** indent the closing `EOF` (it must start at column 0).\n- For deeply nested content, choose a delimiter that cannot appear in the\n  content itself (e.g. `'HEREDOC_END'`, `'FILEEND'`).\n\n---\n\n## Example\n\n### Failing call\n\n```python\nwrite_file(\n    path=\"src\u002Fcomponents\u002FStatusPanel.ts\",\n    content=\"\u002F\u002F Status icons\\nconst icons = { ok: '✅', err: '❌', run: '?' };\\n\"\n)\n# → Error: unknown error\n```\n\n### Recovery via heredoc\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '[OK]', err: '[ERROR]', run: '[START]' };\nEOF\n```\n\nOr, if UTF-8 output is acceptable in the environment:\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '✅', err: '❌', run: '?' };\nEOF\n```\n\n---\n\n## Multi-File Scenario\n\nWhen writing several files and one fails, write the others with `write_file`\nas normal and apply the heredoc fallback only to the failing file(s):\n\n```bash\n# Write multiple files that contain Unicode\ncat > src\u002Futils\u002Ficons.ts \u003C\u003C 'EOF'\nexport const ICONS = {\n  success: '[OK]',\n  failure: '[FAIL]',\n  pending: '[...]',\n};\nEOF\n\ncat > src\u002Futils\u002Flabels.ts \u003C\u003C 'EOF'\nexport const LABELS = {\n  title: 'Dashboard',\n  subtitle: 'Real-time status',\n};\nEOF\n```\n\n---\n\n## Important Notes\n\n1. **Always prefer `write_file` first** — only fall back to the heredoc\n   approach when `write_file` fails.\n2. **Verify after writing** — use `run_shell` with `cat path\u002Fto\u002Ffile` or\n   `head -5 path\u002Fto\u002Ffile` to confirm the content was written correctly.\n3. **Directory creation** — `write_file` auto-creates parent directories;\n   the heredoc approach does not. Pre-create directories with\n   `mkdir -p path\u002Fto\u002Fdir` if needed.\n4. **Large files** — heredocs work well for files of any practical size;\n   there is no meaningful shell limit.\n5. **Escaping backslashes** — inside a single-quoted heredoc, backslashes\n   are treated literally (no escaping needed), which is usually desirable.","# Unicode-Safe File Writing\n\n## Problem\n\nThe `write_file` tool may fail with `'unknown error'` when the file content\ncontains multi-byte Unicode characters such as:\n\n- Emoji (e.g. `?`, `✅`, `❌`)\n- Special typographic symbols (e.g. `→`, `•`, `—`, `©`)\n- Non-ASCII characters outside the Latin-1 range\n\nThis is a known encoding limitation of `write_file`.\n\n## Solution\n\nFall back to `run_shell` and write the file using a **shell heredoc**\n(`cat > file \u003C\u003C 'EOF' ... EOF`). The single-quoted delimiter `'EOF'`\nprevents the shell from interpreting any special characters inside the\nblock.\n\n---\n\n## Step-by-Step Recovery\n\n### Step 1 — Detect the failure\n\nIf `write_file` returns an error such as:\n\n```\nError: unknown error\n```\n\nand the content contains non-ASCII characters, assume a Unicode encoding\nissue and proceed to the heredoc fallback.\n\n### Step 2 — Strip or replace problematic characters (if needed)\n\nBefore embedding content in the heredoc, decide whether to:\n\n- **Keep** the characters as-is (works if the shell\u002Fterminal is UTF-8 aware)\n- **Replace** emoji\u002Fsymbols with ASCII equivalents (safest, most portable)\n- **Remove** them entirely\n\nCommon replacements:\n\n| Original | Replacement |\n|----------|-------------|\n| `✅`     | `[OK]`      |\n| `❌`     | `[ERROR]`   |\n| `?`     | `[START]`   |\n| `→`      | `->`        |\n| `•`      | `-`         |\n| `—`      | `--`        |\n\n### Step 3 — Write the file via heredoc\n\nUse `run_shell` with the following pattern:\n\n```bash\ncat > path\u002Fto\u002Ffile.ext \u003C\u003C 'EOF'\n...file content here (with Unicode stripped\u002Freplaced if needed)...\nEOF\n```\n\n**Key details:**\n- Use `'EOF'` (single-quoted) as the heredoc delimiter — this disables all\n  shell variable expansion and special character interpretation inside the block.\n- Do **not** indent the closing `EOF` (it must start at column 0).\n- For deeply nested content, choose a delimiter that cannot appear in the\n  content itself (e.g. `'HEREDOC_END'`, `'FILEEND'`).\n\n---\n\n## Example\n\n### Failing call\n\n```python\nwrite_file(\n    path=\"src\u002Fcomponents\u002FStatusPanel.ts\",\n    content=\"\u002F\u002F Status icons\\nconst icons = { ok: '✅', err: '❌', run: '?' };\\n\"\n)\n# → Error: unknown error\n```\n\n### Recovery via heredoc\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '[OK]', err: '[ERROR]', run: '[START]' };\nEOF\n```\n\nOr, if UTF-8 output is acceptable in the environment:\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '✅', err: '❌', run: '?' };\nEOF\n```\n\n---\n\n## Multi-File Scenario\n\nWhen writing several files and one fails, write the others with `write_file`\nas normal and apply the heredoc fallback only to the failing file(s):\n\n```bash\n# Write multiple files that contain Unicode\ncat > src\u002Futils\u002Ficons.ts \u003C\u003C 'EOF'\nexport const ICONS = {\n  success: '[OK]',\n  failure: '[FAIL]',\n  pending: '[...]',\n};\nEOF\n\ncat > src\u002Futils\u002Flabels.ts \u003C\u003C 'EOF'\nexport const LABELS = {\n  title: 'Dashboard',\n  subtitle: 'Real-time status',\n};\nEOF\n```\n\n---\n\n## Important Notes\n\n1. **Always prefer `write_file` first** — only fall back to the heredoc\n   approach when `write_file` fails.\n2. **Verify after writing** — use `run_shell` with `cat path\u002Fto\u002Ffile` or\n   `head -5 path\u002Fto\u002Ffile` to confirm the content was written correctly.\n3. **Directory creation** — `write_file` auto-creates parent directories;\n   the heredoc approach does not. Pre-create directories with\n   `mkdir -p path\u002Fto\u002Fdir` if needed.\n4. **Large files** — heredocs work well for files of any practical size;\n   there is no meaningful shell limit.\n5. **Escaping backslashes** — inside a single-quoted heredoc, backslashes\n   are treated literally (no escaping needed), which is usually desirable.",{"name":5,"description":7},"main","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Funicode-safe-file-writing",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add HKUDS\u002FAgentPilot --skill unicode-safe-file-writing",{"tool":65,"command":66},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill unicode-safe-file-writing",{"tool":68,"command":69},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill unicode-safe-file-writing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Funicode-safe-file-writing\u002FSKILL.md",true,[73],{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},".skill_id","OTHER","其他",39,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Funicode-safe-file-writing\u002F.skill_id",[80,98,117,140,164,184],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":46},"01M6HYB297NDABRERJRVG0K8R0","agentpilot","Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[82,87,88,44,89,90,91,92,93,94,95,96,43,97],"prepare","requests","missing","installation","rsi","up","use","user","work","SET","experiments",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":46},"01M6HYAYWXTTE1J7DJM0MFNQ4H","remember","Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[100,105,106,107,108,109,110,111,112,113,114,115,116],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":126,"publishedAt":46},"01M6HYAVMPM4SBDV60R2B5HPV8","skill-discovery","Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[123],{"categoryNo":124,"categoryName":125,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[127,128,129,108,130,131,132,133,134,135,136,137,138,139],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":147,"publishedAt":46},"01M6HYAR811B3RB0M50RBEDGN6","delegate-task","Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[146],{"categoryNo":124,"categoryName":125,"taxonomyType":21,"taxonomyTypeDesc":22},[148,149,150,108,151,152,153,154,155,129,107,93,156,157,158,159,160,161,162,163],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","for","share","tasks","automation","MCP",{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":170,"publishedAt":46},"01M6HYAM9FSGV6E52AYENDQXYH","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[171,36,172,173,37,174,175,176,32,177,178,179,180,181,159,182,183],"write special chars ts check","check","type","filters","only","template","python","typescript","output","Existing","type-checking","errors","script",{"skillNo":185,"name":186,"nameZh":6,"description":187,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":188,"categories":189,"keywords":190,"publishedAt":46},"01M6HYAH05HGV7SVWSVR8PJRQD","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[191,192,36,44,159,183,193,194,195,196,197,176,32,198,199,177],"write special chars readback","readback","helper","post","via","scripts","read","verification","cleanup"]