{"id":50055961,"url":"https://github.com/code-yeongyu/pi-apply-patch","last_synced_at":"2026-05-21T13:13:57.453Z","repository":{"id":356858126,"uuid":"1226346747","full_name":"code-yeongyu/pi-apply-patch","owner":"code-yeongyu","description":"Codex-style apply_patch tool extension for pi","archived":false,"fork":false,"pushed_at":"2026-05-18T07:19:09.000Z","size":157,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-18T09:36:25.775Z","etag":null,"topics":["apply-patch","codex","coding-agent","openai","pi","pi-extension","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-yeongyu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-01T09:21:52.000Z","updated_at":"2026-05-18T07:19:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/code-yeongyu/pi-apply-patch","commit_stats":null,"previous_names":["code-yeongyu/pi-apply-patch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/code-yeongyu/pi-apply-patch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fpi-apply-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fpi-apply-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fpi-apply-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fpi-apply-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-yeongyu","download_url":"https://codeload.github.com/code-yeongyu/pi-apply-patch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fpi-apply-patch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33301804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"ssl_error","status_checked_at":"2026-05-21T12:22:11.673Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apply-patch","codex","coding-agent","openai","pi","pi-extension","typescript"],"created_at":"2026-05-21T13:13:55.167Z","updated_at":"2026-05-21T13:13:57.446Z","avatar_url":"https://github.com/code-yeongyu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pi-apply-patch\n\nCodex-style `apply_patch` tool extension for the [pi coding agent](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent). It registers a freeform grammar patch tool for OpenAI GPT-family models and swaps out `write` / `edit` while those models are active.\n\n## Behavior\n\nThe extension registers one LLM-callable tool: `apply_patch`. The tool accepts Codex patch envelopes and applies file additions, updates, deletions, and moves after resolving file paths against the current workspace.\n\n| Case | Result |\n|------|--------|\n| OpenAI GPT model active | replaces `write` and `edit` with `apply_patch` |\n| Non-GPT model active | restores the original `write` and `edit` toolset |\n| Raw freeform patch input | accepted and applied |\n| JSON `{ \"input\": \"...\" }` patch input | accepted and applied |\n| Absolute or parent-escaping path | accepted and resolved by Node path semantics |\n\n## Tool\n\n### `apply_patch`\n\nUse this tool to edit files with the Codex patch format.\n\n```text\n*** Begin Patch\n*** Add File: hello.txt\n+Hello world\n*** Update File: src/app.py\n@@ def greet():\n-print(\"Hi\")\n+print(\"Hello, world!\")\n*** Delete File: obsolete.txt\n*** End Patch\n```\n\nThe OpenAI Responses API receives this as a custom freeform grammar tool, not as a JSON function tool.\n\n## Installation\n\nThe package targets the [`pi`](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent) coding agent. Pi loads extensions from `~/.pi/agent/extensions/`, project `.pi/extensions/`, or via the `--extension` / `-e` CLI flag.\n\n```bash\n# 1. From npm (once published)\npi install npm:@code-yeongyu/pi-apply-patch\n\n# 2. From git\npi install git:github.com/code-yeongyu/pi-apply-patch\n\n# 3. Manual placement\ngit clone https://github.com/code-yeongyu/pi-apply-patch ~/.pi/agent/extensions/pi-apply-patch\ncd ~/.pi/agent/extensions/pi-apply-patch \u0026\u0026 npm install\n\n# 4. Dev / one-shot test\npi -e /path/to/pi-apply-patch/src/index.ts\n```\n\nAfter installation, restart pi or run `/reload` inside an interactive session.\n\n## Development\n\n```bash\nnpm install\nnpm test\nnpm run typecheck\nnpm run check\nnpm pack --dry-run\npi -e ./src/index.ts\n```\n\nThe test suite uses vitest. TypeScript is strict, Node-only, and uses ESM imports with `.js` suffixes.\n\n## Origin\n\nPorted from `packages/coding-agent/src/core/extensions/builtin/gpt-apply-patch.ts` in `code-yeongyu/senpi-mono`. The patch grammar and tool descriptions mirror Codex.\n\n## License\n\n[MIT](LICENSE).\n\n## Related\n\n- [senpi](https://github.com/code-yeongyu/senpi) — the fork/runtime these extensions are extracted from.\n- [Ultraworkers Discord](https://discord.gg/PUwSMR9XNk) — community link from the senpi README.\n- [Dori](https://sisyphuslabs.ai) — the product powered by senpi under the hood.\n\n## Acknowledgements\n\n- **Mario Zechner** ([@badlogic](https://github.com/badlogic)) — author of [pi-mono](https://github.com/badlogic/pi-mono) and the pi-coding-agent extension API this package targets.\n- **OpenAI Codex** — reference `apply_patch` tool grammar and patch language.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fpi-apply-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-yeongyu%2Fpi-apply-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fpi-apply-patch/lists"}