Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: remove Bob and Charlie from the contributors array\n\n<FILE path=\"config.json\" name=\"config.json\">\n001|{\n002|  \"name\": \"my-app\",\n003|  \"contributors\": [\n004|    {\n005|      \"name\": \"Alice\",\n006|      \"role\": \"lead\"\n007|    },\n008|    {\n009|      \"name\": \"Bob\",\n010|      \"role\": \"dev\"\n011|    },\n012|    {\n013|      \"name\": \"Charlie\",\n014|      \"role\": \"intern\"\n015|    },\n016|    {\n017|      \"name\": \"Diana\",\n018|      \"role\": \"dev\"\n019|    }\n020|  ]\n021|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="config.json">
◼-8-11
◼-12-15
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: make the name \"super-app\", debug = true, change port should be 8080\n\n<FILE path=\"config.json\" name=\"config.json\">\n001|{\n002|  \"name\": \"my-app\",\n003|  \"version\": \"1.0.0\",\n004|  \"debug\": false,\n005|  \"port\": 3000\n006|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="config.json">
◼=2|  "name": "super-app",
◼=4|  "debug": true,
◼=5|  "port": 8080
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: Migrate from Express+Jest+ESLint to Hono+Vitest+Biome:\n- change scripts.build to \"bun build src/index.ts --outdir dist\"\n- change scripts.dev to \"bun --hot src/index.ts\"\n- change scripts.test to \"vitest\"\n- change scripts.lint to \"biome check src/\"\n- remove express, cors, helmet, dotenv from dependencies\n- add hono \"^4.0.0\" to dependencies\n- remove all @types/* packages, jest, ts-jest, eslint from devDependencies\n- add vitest \"^1.2.0\" and @biomejs/biome \"^1.5.0\" to devDependencies\n- bump the version to \"3.0.0\"\n- change engines.node to \">=20.0.0\"\n- change license to \"MIT\"\n- remove the private field\n- add a \"type\": \"module\" field\n\n<FILE path=\"package.json\" name=\"package.json\">\n001|{\n002|  \"name\": \"@acme/api-server\",\n003|  \"version\": \"2.4.1\",\n004|  \"description\": \"Acme API Server\",\n005|  \"main\": \"dist/index.js\",\n006|  \"scripts\": {\n007|    \"build\": \"tsc\",\n008|    \"dev\": \"ts-node src/index.ts\",\n009|    \"test\": \"jest\",\n010|    \"lint\": \"eslint src/\",\n011|    \"db:migrate\": \"knex migrate:latest\",\n012|    \"db:seed\": \"knex seed:run\"\n013|  },\n014|  \"dependencies\": {\n015|    \"express\": \"^4.18.2\",\n016|    \"knex\": \"^3.1.0\",\n017|    \"pg\": \"^8.11.3\",\n018|    \"zod\": \"^3.22.4\",\n019|    \"dotenv\": \"^16.3.1\",\n020|    \"cors\": \"^2.8.5\",\n021|    \"helmet\": \"^7.1.0\",\n022|    \"jsonwebtoken\": \"^9.0.2\",\n023|    \"bcrypt\": \"^5.1.1\"\n024|  },\n025|  \"devDependencies\": {\n026|    \"typescript\": \"^5.3.3\",\n027|    \"@types/node\": \"^20.10.0\",\n028|    \"@types/express\": \"^4.17.21\",\n029|    \"jest\": \"^29.7.0\",\n030|    \"ts-jest\": \"^29.1.1\",\n031|    \"eslint\": \"^8.55.0\",\n032|    \"@types/cors\": \"^2.8.17\",\n033|    \"@types/jsonwebtoken\": \"^9.0.5\",\n034|    \"@types/bcrypt\": \"^5.0.2\"\n035|  },\n036|  \"engines\": {\n037|    \"node\": \">=18.0.0\"\n038|  },\n039|  \"repository\": {\n040|    \"type\": \"git\",\n041|    \"url\": \"https://github.com/acme/api-server.git\"\n042|  },\n043|  \"author\": \"Acme Corp\",\n044|  \"license\": \"UNLICENSED\",\n045|  \"private\": true\n046|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="package.json">
◼<4|    "type": "module",
◼=3|  "version": "3.0.0",
◼=7|    "build": "bun build src/index.ts --outdir dist",
◼=8|    "dev": "bun --hot src/index.ts",
◼=9|    "test": "vitest",
◼=10|    "lint": "biome check src/",
◼-15
◼-19
◼-20
◼-21
◼=23|    "bcrypt": "^5.1.1",
◼<24|    "hono": "^4.0.0",
◼-27-34
◼<35|    "vitest": "^1.2.0",
◼<35|    "@biomejs/biome": "^1.5.0",
◼=37|    "node": ">=20.0.0",
◼=44|  "license": "MIT",
◼-45
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: Make the following changes to the pipeline config:\n- bump pipeline.version to 2\n- in triggers: remove the schedule trigger, add \"develop\" to the push trigger branches, remove \"charlie\" from manual approvers and add \"diana\"\n- change env.global.LOG_LEVEL to \"warn\" and add CACHE_TTL: \"3600\" to env.global\n- add \"JWT_SECRET\" to the env.secrets array\n- in the build stage: change timeout to 900, change \"npm ci\" to \"bun install\", \"npm run build\" to \"bun run build\", \"npm test\" to \"bun test\", and set retry to 3 on the test step\n- remove the entire security stage\n- in the deploy stage: remove dependsOn on \"security\" (keep \"build\"), add a new first step { run: \"bun run smoke-test\" } before the ecr login, and change retry on kubectl to 5\n- in notifications.onFailure: remove the pagerduty notification, change the email recipients to [\"oncall@acme.com\", \"platform@acme.com\"]\n- add a new notifications.onTimeout array with one entry: { type: \"slack\", channel: \"#alerts\" }\n\n<FILE path=\"pipeline.json\" name=\"pipeline.json\">\n001|{\n002|  \"pipeline\": {\n003|    \"name\": \"deploy-prod\",\n004|    \"version\": 1,\n005|    \"triggers\": [\n006|      {\n007|        \"type\": \"push\",\n008|        \"branches\": [\n009|          \"main\",\n010|          \"release/*\"\n011|        ]\n012|      },\n013|      {\n014|        \"type\": \"schedule\",\n015|        \"cron\": \"0 2 * * 1\"\n016|      },\n017|      {\n018|        \"type\": \"manual\",\n019|        \"approvers\": [\n020|          \"alice\",\n021|          \"bob\",\n022|          \"charlie\"\n023|        ]\n024|      }\n025|    ],\n026|    \"env\": {\n027|      \"global\": {\n028|        \"NODE_ENV\": \"production\",\n029|        \"LOG_LEVEL\": \"info\",\n030|        \"REGION\": \"us-east-1\"\n031|      },\n032|      \"secrets\": [\n033|        \"DB_PASSWORD\",\n034|        \"API_KEY\",\n035|        \"SLACK_WEBHOOK\"\n036|      ]\n037|    },\n038|    \"stages\": [\n039|      {\n040|        \"name\": \"build\",\n041|        \"timeout\": 600,\n042|        \"steps\": [\n043|          {\n044|            \"run\": \"npm ci\",\n045|            \"cache\": true\n046|          },\n047|          {\n048|            \"run\": \"npm run build\",\n049|            \"artifacts\": [\n050|              \"dist/**\"\n051|            ]\n052|          },\n053|          {\n054|            \"run\": \"npm test\",\n055|            \"retry\": 2\n056|          }\n057|        ]\n058|      },\n059|      {\n060|        \"name\": \"security\",\n061|        \"timeout\": 300,\n062|        \"steps\": [\n063|          {\n064|            \"run\": \"npm audit\",\n065|            \"allowFailure\": true\n066|          },\n067|          {\n068|            \"run\": \"snyk test\",\n069|            \"env\": {\n070|              \"SNYK_TOKEN\": \"$SNYK_TOKEN\"\n071|            }\n072|          }\n073|        ]\n074|      },\n075|      {\n076|        \"name\": \"deploy\",\n077|        \"timeout\": 900,\n078|        \"dependsOn\": [\n079|          \"build\",\n080|          \"security\"\n081|        ],\n082|        \"conditions\": {\n083|          \"branches\": [\n084|            \"main\"\n085|          ]\n086|        },\n087|        \"steps\": [\n088|          {\n089|            \"run\": \"aws ecr login\",\n090|            \"env\": {\n091|              \"AWS_REGION\": \"$REGION\"\n092|            }\n093|          },\n094|          {\n095|            \"run\": \"docker build -t app:latest .\",\n096|            \"cache\": true\n097|          },\n098|          {\n099|            \"run\": \"docker push app:latest\"\n100|          },\n101|          {\n102|            \"run\": \"kubectl apply -f k8s/\",\n103|            \"retry\": 3\n104|          }\n105|        ]\n106|      }\n107|    ],\n108|    \"notifications\": {\n109|      \"onSuccess\": [\n110|        {\n111|          \"type\": \"slack\",\n112|          \"channel\": \"#deploys\"\n113|        }\n114|      ],\n115|      \"onFailure\": [\n116|        {\n117|          \"type\": \"slack\",\n118|          \"channel\": \"#deploys\"\n119|        },\n120|        {\n121|          \"type\": \"email\",\n122|          \"recipients\": [\n123|            \"oncall@acme.com\"\n124|          ]\n125|        },\n126|        {\n127|          \"type\": \"pagerduty\",\n128|          \"severity\": \"high\"\n129|        }\n130|      ]\n131|    }\n132|  }\n133|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="pipeline.json">
◼=4|    "version": 2,
◼-14-16
◼>10|          "develop",
◼=22|          "diana"
◼=29|        "LOG_LEVEL": "warn",
◼>30|        "CACHE_TTL": "3600",
◼>35|        "JWT_SECRET",
◼=41|        "timeout": 900,
◼=44|            "run": "bun install",
◼=48|            "run": "bun run build",
◼=54|            "run": "bun test",
◼=55|            "retry": 3
◼-60-74
◼=79|          "build"
◼-80
◼<88|          {
◼<88|            "run": "bun run smoke-test"
◼<88|          },
◼=103|            "retry": 5
◼-126-129
◼=123-124|            "oncall@acme.com",\n            "platform@acme.com"
◼=130|      ],
◼<131|      "onTimeout": [
◼<131|        {
◼<131|          "type": "slack",
◼<131|          "channel": "#alerts"
◼<131|        }
◼<131|      ]
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: Make the following changes to the pipeline config:\n- bump pipeline.version to 2\n- in triggers: remove the schedule trigger, add \"develop\" to the push trigger branches, remove \"charlie\" from manual approvers and add \"diana\"\n- change env.global.LOG_LEVEL to \"warn\" and add CACHE_TTL: \"3600\" to env.global\n- add \"JWT_SECRET\" to the env.secrets array\n- in the build stage: change timeout to 900, change \"npm ci\" to \"bun install\", \"npm run build\" to \"bun run build\", \"npm test\" to \"bun test\", and set retry to 3 on the test step\n- remove the entire security stage\n- in the deploy stage: remove dependsOn on \"security\" (keep \"build\"), add a new first step { run: \"bun run smoke-test\" } before the ecr login, and change retry on kubectl to 5\n- in notifications.onFailure: remove the pagerduty notification, change the email recipients to [\"oncall@acme.com\", \"platform@acme.com\"]\n- add a new notifications.onTimeout array with one entry: { type: \"slack\", channel: \"#alerts\" }\n\n<FILE path=\"pipeline.json\" name=\"pipeline.json\">\n001|{\n002|  \"pipeline\": {\n003|    \"name\": \"deploy-prod\",\n004|    \"version\": 1,\n005|    \"triggers\": [\n006|      {\n007|        \"type\": \"push\",\n008|        \"branches\": [\n009|          \"main\",\n010|          \"release/*\"\n011|        ]\n012|      },\n013|      {\n014|        \"type\": \"schedule\",\n015|        \"cron\": \"0 2 * * 1\"\n016|      },\n017|      {\n018|        \"type\": \"manual\",\n019|        \"approvers\": [\n020|          \"alice\",\n021|          \"bob\",\n022|          \"charlie\"\n023|        ]\n024|      }\n025|    ],\n026|    \"env\": {\n027|      \"global\": {\n028|        \"NODE_ENV\": \"production\",\n029|        \"LOG_LEVEL\": \"info\",\n030|        \"REGION\": \"us-east-1\"\n031|      },\n032|      \"secrets\": [\n033|        \"DB_PASSWORD\",\n034|        \"API_KEY\",\n035|        \"SLACK_WEBHOOK\"\n036|      ]\n037|    },\n038|    \"stages\": [\n039|      {\n040|        \"name\": \"build\",\n041|        \"timeout\": 600,\n042|        \"steps\": [\n043|          {\n044|            \"run\": \"npm ci\",\n045|            \"cache\": true\n046|          },\n047|          {\n048|            \"run\": \"npm run build\",\n049|            \"artifacts\": [\n050|              \"dist/**\"\n051|            ]\n052|          },\n053|          {\n054|            \"run\": \"npm test\",\n055|            \"retry\": 2\n056|          }\n057|        ]\n058|      },\n059|      {\n060|        \"name\": \"security\",\n061|        \"timeout\": 300,\n062|        \"steps\": [\n063|          {\n064|            \"run\": \"npm audit\",\n065|            \"allowFailure\": true\n066|          },\n067|          {\n068|            \"run\": \"snyk test\",\n069|            \"env\": {\n070|              \"SNYK_TOKEN\": \"$SNYK_TOKEN\"\n071|            }\n072|          }\n073|        ]\n074|      },\n075|      {\n076|        \"name\": \"deploy\",\n077|        \"timeout\": 900,\n078|        \"dependsOn\": [\n079|          \"build\",\n080|          \"security\"\n081|        ],\n082|        \"conditions\": {\n083|          \"branches\": [\n084|            \"main\"\n085|          ]\n086|        },\n087|        \"steps\": [\n088|          {\n089|            \"run\": \"aws ecr login\",\n090|            \"env\": {\n091|              \"AWS_REGION\": \"$REGION\"\n092|            }\n093|          },\n094|          {\n095|            \"run\": \"docker build -t app:latest .\",\n096|            \"cache\": true\n097|          },\n098|          {\n099|            \"run\": \"docker push app:latest\"\n100|          },\n101|          {\n102|            \"run\": \"kubectl apply -f k8s/\",\n103|            \"retry\": 3\n104|          }\n105|        ]\n106|      }\n107|    ],\n108|    \"notifications\": {\n109|      \"onSuccess\": [\n110|        {\n111|          \"type\": \"slack\",\n112|          \"channel\": \"#deploys\"\n113|        }\n114|      ],\n115|      \"onFailure\": [\n116|        {\n117|          \"type\": \"slack\",\n118|          \"channel\": \"#deploys\"\n119|        },\n120|        {\n121|          \"type\": \"email\",\n122|          \"recipients\": [\n123|            \"oncall@acme.com\"\n124|          ]\n125|        },\n126|        {\n127|          \"type\": \"pagerduty\",\n128|          \"severity\": \"high\"\n129|        }\n130|      ]\n131|    }\n132|  }\n133|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"},{"content":"<FILE path=\"pipeline.json\">\n{\n  \"pipeline\": {\n    \"name\": \"deploy-prod\",\n    \"version\": 2,\n    \"triggers\": [\n      {\n        \"type\": \"push\",\n        \"branches\": [\n          \"main\",\n          \"release/*\"\n          \"develop\",\n        ]\n      },\n      {\n      {\n        \"type\": \"manual\",\n        \"approvers\": [\n          \"alice\",\n          \"bob\",\n          \"diana\"\n        ]\n      }\n    ],\n    \"env\": {\n      \"global\": {\n        \"NODE_ENV\": \"production\",\n        \"LOG_LEVEL\": \"warn\",\n        \"REGION\": \"us-east-1\"\n        \"CACHE_TTL\": \"3600\",\n      },\n      \"secrets\": [\n        \"DB_PASSWORD\",\n        \"API_KEY\",\n        \"SLACK_WEBHOOK\"\n        \"JWT_SECRET\",\n      ]\n    },\n    \"stages\": [\n      {\n        \"name\": \"build\",\n        \"timeout\": 900,\n        \"steps\": [\n          {\n            \"run\": \"bun install\",\n            \"cache\": true\n          },\n          {\n            \"run\": \"bun run build\",\n            \"artifacts\": [\n              \"dist/**\"\n            ]\n          },\n          {\n            \"run\": \"bun test\",\n            \"retry\": 3\n          }\n        ]\n      },\n      {\n      {\n        \"name\": \"deploy\",\n        \"timeout\": 900,\n        \"dependsOn\": [\n          \"build\"\n        ],\n        \"conditions\": {\n          \"branches\": [\n            \"main\"\n          ]\n        },\n        \"steps\": [\n          {\n            \"run\": \"bun run smoke-test\"\n          },\n          {\n            \"run\": \"aws ecr login\",\n            \"env\": {\n              \"AWS_REGION\": \"$REGION\"\n            }\n          },\n          {\n            \"run\": \"docker build -t app:latest .\",\n            \"cache\": true\n          },\n          {\n            \"run\": \"docker push app:latest\"\n          },\n          {\n            \"run\": \"kubectl apply -f k8s/\",\n            \"retry\": 5\n          }\n        ]\n      }\n    ],\n    \"notifications\": {\n      \"onSuccess\": [\n        {\n          \"type\": \"slack\",\n          \"channel\": \"#deploys\"\n        }\n      ],\n      \"onFailure\": [\n        {\n          \"type\": \"slack\",\n          \"channel\": \"#deploys\"\n        },\n        {\n          \"type\": \"email\",\n          \"recipients\": [\n            \"oncall@acme.com\",\\n            \"platform@acme.com\"\n        },\n      ],\n      \"onTimeout\": [\n        {\n          \"type\": \"slack\",\n          \"channel\": \"#alerts\"\n        }\n      ]\n    }\n  }\n}\n</FILE>","role":"assistant"},{"content":"ERROR: The patched output for \"pipeline.json\" produced invalid JSON.\n\nJSON Syntax Error: Expected ',' or ']' after array element in JSON at position 185 (line 11 column 11)\n\n 8|        \"branches\": [\n 9|          \"main\",\n10|          \"release/*\"\n11|          \"develop\", ← ERROR\n             ^\n12|        ]\n13|      },\n14|      {\n\n\nPlease regenerate the patches for this file, fixing the syntax error. The output MUST be valid JSON.","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="pipeline.json">
◼=4|    "version": 2,
◼-13-16
◼=11|          "release/*",
◼>11|          "develop"
◼=22|          "diana"
◼=29|        "LOG_LEVEL": "warn",
◼=30|        "REGION": "us-east-1",
◼>30|        "CACHE_TTL": "3600",
◼=35|        "SLACK_WEBHOOK",
◼>35|        "JWT_SECRET"
◼=41|        "timeout": 900,
◼=44|            "run": "bun install",
◼=48|            "run": "bun run build",
◼=54|            "run": "bun test",
◼=55|            "retry": 3
◼-59-74
◼=79|          "build"
◼-80
◼<89|          {
◼<89|            "run": "bun run smoke-test"
◼<89|          },
◼=103|            "retry": 5
◼-126-129
◼=123|            "oncall@acme.com",
◼>123|            "platform@acme.com"
◼=130|      ],
◼<131|      "onTimeout": [
◼<131|        {
◼<131|          "type": "slack",
◼<131|          "channel": "#alerts"
◼<131|        }
◼<131|      ]
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: Make the following changes to the pipeline config:\n- bump pipeline.version to 2\n- in triggers: remove the schedule trigger, add \"develop\" to the push trigger branches, remove \"charlie\" from manual approvers and add \"diana\"\n- change env.global.LOG_LEVEL to \"warn\" and add CACHE_TTL: \"3600\" to env.global\n- add \"JWT_SECRET\" to the env.secrets array\n- in the build stage: change timeout to 900, change \"npm ci\" to \"bun install\", \"npm run build\" to \"bun run build\", \"npm test\" to \"bun test\", and set retry to 3 on the test step\n- remove the entire security stage\n- in the deploy stage: remove dependsOn on \"security\" (keep \"build\"), add a new first step { run: \"bun run smoke-test\" } before the ecr login, and change retry on kubectl to 5\n- in notifications.onFailure: remove the pagerduty notification, change the email recipients to [\"oncall@acme.com\", \"platform@acme.com\"]\n- add a new notifications.onTimeout array with one entry: { type: \"slack\", channel: \"#alerts\" }\n\n<FILE path=\"pipeline.json\" name=\"pipeline.json\">\n001|{\n002|  \"pipeline\": {\n003|    \"name\": \"deploy-prod\",\n004|    \"version\": 1,\n005|    \"triggers\": [\n006|      {\n007|        \"type\": \"push\",\n008|        \"branches\": [\n009|          \"main\",\n010|          \"release/*\"\n011|        ]\n012|      },\n013|      {\n014|        \"type\": \"schedule\",\n015|        \"cron\": \"0 2 * * 1\"\n016|      },\n017|      {\n018|        \"type\": \"manual\",\n019|        \"approvers\": [\n020|          \"alice\",\n021|          \"bob\",\n022|          \"charlie\"\n023|        ]\n024|      }\n025|    ],\n026|    \"env\": {\n027|      \"global\": {\n028|        \"NODE_ENV\": \"production\",\n029|        \"LOG_LEVEL\": \"info\",\n030|        \"REGION\": \"us-east-1\"\n031|      },\n032|      \"secrets\": [\n033|        \"DB_PASSWORD\",\n034|        \"API_KEY\",\n035|        \"SLACK_WEBHOOK\"\n036|      ]\n037|    },\n038|    \"stages\": [\n039|      {\n040|        \"name\": \"build\",\n041|        \"timeout\": 600,\n042|        \"steps\": [\n043|          {\n044|            \"run\": \"npm ci\",\n045|            \"cache\": true\n046|          },\n047|          {\n048|            \"run\": \"npm run build\",\n049|            \"artifacts\": [\n050|              \"dist/**\"\n051|            ]\n052|          },\n053|          {\n054|            \"run\": \"npm test\",\n055|            \"retry\": 2\n056|          }\n057|        ]\n058|      },\n059|      {\n060|        \"name\": \"security\",\n061|        \"timeout\": 300,\n062|        \"steps\": [\n063|          {\n064|            \"run\": \"npm audit\",\n065|            \"allowFailure\": true\n066|          },\n067|          {\n068|            \"run\": \"snyk test\",\n069|            \"env\": {\n070|              \"SNYK_TOKEN\": \"$SNYK_TOKEN\"\n071|            }\n072|          }\n073|        ]\n074|      },\n075|      {\n076|        \"name\": \"deploy\",\n077|        \"timeout\": 900,\n078|        \"dependsOn\": [\n079|          \"build\",\n080|          \"security\"\n081|        ],\n082|        \"conditions\": {\n083|          \"branches\": [\n084|            \"main\"\n085|          ]\n086|        },\n087|        \"steps\": [\n088|          {\n089|            \"run\": \"aws ecr login\",\n090|            \"env\": {\n091|              \"AWS_REGION\": \"$REGION\"\n092|            }\n093|          },\n094|          {\n095|            \"run\": \"docker build -t app:latest .\",\n096|            \"cache\": true\n097|          },\n098|          {\n099|            \"run\": \"docker push app:latest\"\n100|          },\n101|          {\n102|            \"run\": \"kubectl apply -f k8s/\",\n103|            \"retry\": 3\n104|          }\n105|        ]\n106|      }\n107|    ],\n108|    \"notifications\": {\n109|      \"onSuccess\": [\n110|        {\n111|          \"type\": \"slack\",\n112|          \"channel\": \"#deploys\"\n113|        }\n114|      ],\n115|      \"onFailure\": [\n116|        {\n117|          \"type\": \"slack\",\n118|          \"channel\": \"#deploys\"\n119|        },\n120|        {\n121|          \"type\": \"email\",\n122|          \"recipients\": [\n123|            \"oncall@acme.com\"\n124|          ]\n125|        },\n126|        {\n127|          \"type\": \"pagerduty\",\n128|          \"severity\": \"high\"\n129|        }\n130|      ]\n131|    }\n132|  }\n133|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"},{"content":"<FILE path=\"pipeline.json\">\n◼=4|    \"version\": 2,\n◼-14-16\n◼>10|          \"develop\",\n◼=22|          \"diana\"\n◼=29|        \"LOG_LEVEL\": \"warn\",\n◼>30|        \"CACHE_TTL\": \"3600\",\n◼>35|        \"JWT_SECRET\",\n◼=41|        \"timeout\": 900,\n◼=44|            \"run\": \"bun install\",\n◼=48|            \"run\": \"bun run build\",\n◼=54|            \"run\": \"bun test\",\n◼=55|            \"retry\": 3\n◼-60-74\n◼=79|          \"build\"\n◼-80\n◼<88|          {\n◼<88|            \"run\": \"bun run smoke-test\"\n◼<88|          },\n◼=103|            \"retry\": 5\n◼-126-129\n◼=123-124|            \"oncall@acme.com\",\\n            \"platform@acme.com\"\n◼=130|      ],\n◼<131|      \"onTimeout\": [\n◼<131|        {\n◼<131|          \"type\": \"slack\",\n◼<131|          \"channel\": \"#alerts\"\n◼<131|        }\n◼<131|      ]\n</FILE>","role":"assistant"},{"content":"ERROR: Applying your patches to \"pipeline.json\" produced invalid JSON.\n\nJSON Syntax Error: Expected ',' or ']' after array element in JSON at position 185 (line 11 column 11)\n\n 8|        \"branches\": [\n 9|          \"main\",\n10|          \"release/*\"\n11|          \"develop\", ← ERROR\n             ^\n12|        ]\n13|      },\n14|      {\n\n\nPlease regenerate ALL the patches for this file from scratch, ensuring the result is syntactically valid JSON (correct commas, brackets, braces, quoting).","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="pipeline.json">
◼=4|    "version": 2,
◼-14-16
◼=10|          "release/*",
◼>10|          "develop",
◼=22|          "diana"
◼=29|        "LOG_LEVEL": "warn",
◼=30|        "REGION": "us-east-1",
◼<31|        "CACHE_TTL": "3600",
◼=35|        "SLACK_WEBHOOK",
◼>35|        "JWT_SECRET"
◼=41|        "timeout": 900,
◼=44|            "run": "bun install",
◼=48|            "run": "bun run build",
◼=54|            "run": "bun test",
◼=55|            "retry": 3
◼-60-74
◼=78-81|        "dependsOn": ["build"],
◼=88-94|          {
            "run": "bun run smoke-test"
          },
          {
            "run": "aws ecr login",
            "env": {
              "AWS_REGION": "$REGION"
            }
          }
◼=103|            "retry": 5
◼=122-124|            "recipients": [
              "oncall@acme.com",
              "platform@acme.com"
            ]
◼=125|        }
◼-126-129
◼=130|      ],
◼<131|      "onTimeout": [
        {
          "type": "slack",
          "channel": "#alerts"
        }
      ]
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: Make the following changes to the pipeline config:\n- bump pipeline.version to 2\n- in triggers: remove the schedule trigger, add \"develop\" to the push trigger branches, remove \"charlie\" from manual approvers and add \"diana\"\n- change env.global.LOG_LEVEL to \"warn\" and add CACHE_TTL: \"3600\" to env.global\n- add \"JWT_SECRET\" to the env.secrets array\n- in the build stage: change timeout to 900, change \"npm ci\" to \"bun install\", \"npm run build\" to \"bun run build\", \"npm test\" to \"bun test\", and set retry to 3 on the test step\n- remove the entire security stage\n- in the deploy stage: remove dependsOn on \"security\" (keep \"build\"), add a new first step { run: \"bun run smoke-test\" } before the ecr login, and change retry on kubectl to 5\n- in notifications.onFailure: remove the pagerduty notification, change the email recipients to [\"oncall@acme.com\", \"platform@acme.com\"]\n- add a new notifications.onTimeout array with one entry: { type: \"slack\", channel: \"#alerts\" }\n\n<FILE path=\"pipeline.json\" name=\"pipeline.json\">\n001|{\n002|  \"pipeline\": {\n003|    \"name\": \"deploy-prod\",\n004|    \"version\": 1,\n005|    \"triggers\": [\n006|      {\n007|        \"type\": \"push\",\n008|        \"branches\": [\n009|          \"main\",\n010|          \"release/*\"\n011|        ]\n012|      },\n013|      {\n014|        \"type\": \"schedule\",\n015|        \"cron\": \"0 2 * * 1\"\n016|      },\n017|      {\n018|        \"type\": \"manual\",\n019|        \"approvers\": [\n020|          \"alice\",\n021|          \"bob\",\n022|          \"charlie\"\n023|        ]\n024|      }\n025|    ],\n026|    \"env\": {\n027|      \"global\": {\n028|        \"NODE_ENV\": \"production\",\n029|        \"LOG_LEVEL\": \"info\",\n030|        \"REGION\": \"us-east-1\"\n031|      },\n032|      \"secrets\": [\n033|        \"DB_PASSWORD\",\n034|        \"API_KEY\",\n035|        \"SLACK_WEBHOOK\"\n036|      ]\n037|    },\n038|    \"stages\": [\n039|      {\n040|        \"name\": \"build\",\n041|        \"timeout\": 600,\n042|        \"steps\": [\n043|          {\n044|            \"run\": \"npm ci\",\n045|            \"cache\": true\n046|          },\n047|          {\n048|            \"run\": \"npm run build\",\n049|            \"artifacts\": [\n050|              \"dist/**\"\n051|            ]\n052|          },\n053|          {\n054|            \"run\": \"npm test\",\n055|            \"retry\": 2\n056|          }\n057|        ]\n058|      },\n059|      {\n060|        \"name\": \"security\",\n061|        \"timeout\": 300,\n062|        \"steps\": [\n063|          {\n064|            \"run\": \"npm audit\",\n065|            \"allowFailure\": true\n066|          },\n067|          {\n068|            \"run\": \"snyk test\",\n069|            \"env\": {\n070|              \"SNYK_TOKEN\": \"$SNYK_TOKEN\"\n071|            }\n072|          }\n073|        ]\n074|      },\n075|      {\n076|        \"name\": \"deploy\",\n077|        \"timeout\": 900,\n078|        \"dependsOn\": [\n079|          \"build\",\n080|          \"security\"\n081|        ],\n082|        \"conditions\": {\n083|          \"branches\": [\n084|            \"main\"\n085|          ]\n086|        },\n087|        \"steps\": [\n088|          {\n089|            \"run\": \"aws ecr login\",\n090|            \"env\": {\n091|              \"AWS_REGION\": \"$REGION\"\n092|            }\n093|          },\n094|          {\n095|            \"run\": \"docker build -t app:latest .\",\n096|            \"cache\": true\n097|          },\n098|          {\n099|            \"run\": \"docker push app:latest\"\n100|          },\n101|          {\n102|            \"run\": \"kubectl apply -f k8s/\",\n103|            \"retry\": 3\n104|          }\n105|        ]\n106|      }\n107|    ],\n108|    \"notifications\": {\n109|      \"onSuccess\": [\n110|        {\n111|          \"type\": \"slack\",\n112|          \"channel\": \"#deploys\"\n113|        }\n114|      ],\n115|      \"onFailure\": [\n116|        {\n117|          \"type\": \"slack\",\n118|          \"channel\": \"#deploys\"\n119|        },\n120|        {\n121|          \"type\": \"email\",\n122|          \"recipients\": [\n123|            \"oncall@acme.com\"\n124|          ]\n125|        },\n126|        {\n127|          \"type\": \"pagerduty\",\n128|          \"severity\": \"high\"\n129|        }\n130|      ]\n131|    }\n132|  }\n133|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"},{"content":"<FILE path=\"pipeline.json\">\n◼=4|    \"version\": 2,\n◼-14-16\n◼>10|          \"develop\",\n◼=22|          \"diana\"\n◼=29|        \"LOG_LEVEL\": \"warn\",\n◼>30|        \"CACHE_TTL\": \"3600\",\n◼>35|        \"JWT_SECRET\",\n◼=41|        \"timeout\": 900,\n◼=44|            \"run\": \"bun install\",\n◼=48|            \"run\": \"bun run build\",\n◼=54|            \"run\": \"bun test\",\n◼=55|            \"retry\": 3\n◼-60-74\n◼=79|          \"build\"\n◼-80\n◼<88|          {\n◼<88|            \"run\": \"bun run smoke-test\"\n◼<88|          },\n◼=103|            \"retry\": 5\n◼-126-129\n◼=123-124|            \"oncall@acme.com\",\\n            \"platform@acme.com\"\n◼=130|      ],\n◼<131|      \"onTimeout\": [\n◼<131|        {\n◼<131|          \"type\": \"slack\",\n◼<131|          \"channel\": \"#alerts\"\n◼<131|        }\n◼<131|      ]\n</FILE>","role":"assistant"},{"content":"ERROR: Applying your patches to \"pipeline.json\" produced invalid JSON.\n\nJSON Syntax Error: Expected ',' or ']' after array element in JSON at position 185 (line 11 column 11)\n\n 8|        \"branches\": [\n 9|          \"main\",\n10|          \"release/*\"\n11|          \"develop\", ← ERROR\n             ^\n12|        ]\n13|      },\n14|      {\n\n\nPlease regenerate ALL the patches for this file from scratch. Pay careful attention to commas between array/object elements and ensure all braces/brackets are properly paired.","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="pipeline.json">
◼=4|    "version": 2,
◼=10|          "release/*",
◼<11|          "develop"
◼-13-16
◼=22|          "diana"
◼=29|        "LOG_LEVEL": "warn",
◼=30|        "REGION": "us-east-1",
◼<31|        "CACHE_TTL": "3600",
◼=35|        "SLACK_WEBHOOK",
◼<36|        "JWT_SECRET",
◼=41|        "timeout": 900,
◼=44|            "run": "bun install",
◼=48|            "run": "bun run build",
◼=54|            "run": "bun test",
◼=55|            "retry": 3
◼-60-74
◼=79|          "build"
◼-80
◼<88|          {
◼<88|            "run": "bun run smoke-test"
◼<88|          },
◼=103|            "retry": 5
◼-126-129
◼=123|            "oncall@acme.com",\n            "platform@acme.com"
◼=130|      ],
◼<131|      "onTimeout": [
◼<131|        {
◼<131|          "type": "slack",
◼<131|          "channel": "#alerts"
◼<131|        }
◼<131|      ]
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"The following JSON file has syntax errors. The original instructions were:\nMake the following changes to the pipeline config:\n- bump pipeline.version to 2\n- in triggers: remove the schedule trigger, add \"develop\" to the push trigger branches, remove \"charlie\" from manual approvers and add \"diana\"\n- change env.global.LOG_LEVEL to \"warn\" and add CACHE_TTL: \"3600\" to env.global\n- add \"JWT_SECRET\" to the env.secrets array\n- in the build stage: change timeout to 900, change \"npm ci\" to \"bun install\", \"npm run build\" to \"bun run build\", \"npm test\" to \"bun test\", and set retry to 3 on the test step\n- remove the entire security stage\n- in the deploy stage: remove dependsOn on \"security\" (keep \"build\"), add a new first step { run: \"bun run smoke-test\" } before the ecr login, and change retry on kubectl to 5\n- in notifications.onFailure: remove the pagerduty notification, change the email recipients to [\"oncall@acme.com\", \"platform@acme.com\"]\n- add a new notifications.onTimeout array with one entry: { type: \"slack\", channel: \"#alerts\" }\n\nHere is the broken result:\n\n<FILE path=\"pipeline.json\" name=\"pipeline.json\">\n001|{\n002|  \"pipeline\": {\n003|    \"name\": \"deploy-prod\",\n004|    \"version\": 2,\n005|    \"triggers\": [\n006|      {\n007|        \"type\": \"push\",\n008|        \"branches\": [\n009|          \"main\",\n010|          \"release/*\"\n011|          \"develop\",\n012|        ]\n013|      },\n014|      {\n015|      {\n016|        \"type\": \"manual\",\n017|        \"approvers\": [\n018|          \"alice\",\n019|          \"bob\",\n020|          \"diana\"\n021|        ]\n022|      }\n023|    ],\n024|    \"env\": {\n025|      \"global\": {\n026|        \"NODE_ENV\": \"production\",\n027|        \"LOG_LEVEL\": \"warn\",\n028|        \"REGION\": \"us-east-1\"\n029|        \"CACHE_TTL\": \"3600\",\n030|      },\n031|      \"secrets\": [\n032|        \"DB_PASSWORD\",\n033|        \"API_KEY\",\n034|        \"SLACK_WEBHOOK\"\n035|        \"JWT_SECRET\",\n036|      ]\n037|    },\n038|    \"stages\": [\n039|      {\n040|        \"name\": \"build\",\n041|        \"timeout\": 900,\n042|        \"steps\": [\n043|          {\n044|            \"run\": \"bun install\",\n045|            \"cache\": true\n046|          },\n047|          {\n048|            \"run\": \"bun run build\",\n049|            \"artifacts\": [\n050|              \"dist/**\"\n051|            ]\n052|          },\n053|          {\n054|            \"run\": \"bun test\",\n055|            \"retry\": 3\n056|          }\n057|        ]\n058|      },\n059|      {\n060|      {\n061|        \"name\": \"deploy\",\n062|        \"timeout\": 900,\n063|        \"dependsOn\": [\n064|          \"build\"\n065|        ],\n066|        \"conditions\": {\n067|          \"branches\": [\n068|            \"main\"\n069|          ]\n070|        },\n071|        \"steps\": [\n072|          {\n073|            \"run\": \"bun run smoke-test\"\n074|          },\n075|          {\n076|            \"run\": \"aws ecr login\",\n077|            \"env\": {\n078|              \"AWS_REGION\": \"$REGION\"\n079|            }\n080|          },\n081|          {\n082|            \"run\": \"docker build -t app:latest .\",\n083|            \"cache\": true\n084|          },\n085|          {\n086|            \"run\": \"docker push app:latest\"\n087|          },\n088|          {\n089|            \"run\": \"kubectl apply -f k8s/\",\n090|            \"retry\": 5\n091|          }\n092|        ]\n093|      }\n094|    ],\n095|    \"notifications\": {\n096|      \"onSuccess\": [\n097|        {\n098|          \"type\": \"slack\",\n099|          \"channel\": \"#deploys\"\n100|        }\n101|      ],\n102|      \"onFailure\": [\n103|        {\n104|          \"type\": \"slack\",\n105|          \"channel\": \"#deploys\"\n106|        },\n107|        {\n108|          \"type\": \"email\",\n109|          \"recipients\": [\n110|            \"oncall@acme.com\",\\n            \"platform@acme.com\"\n111|        },\n112|      ],\n113|      \"onTimeout\": [\n114|        {\n115|          \"type\": \"slack\",\n116|          \"channel\": \"#alerts\"\n117|        }\n118|      ]\n119|    }\n120|  }\n121|}\n</FILE>\n\nJSON parse error: JSON Syntax Error: Expected ',' or ']' after array element in JSON at position 185 (line 11 column 11)\n\n 8|        \"branches\": [\n 9|          \"main\",\n10|          \"release/*\"\n11|          \"develop\", ← ERROR\n             ^\n12|        ]\n13|      },\n14|      {\n\n\nFix ONLY the JSON syntax errors (missing commas, orphaned braces, etc). Do NOT change the data — only fix the syntax to make it valid JSON.","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="pipeline.json">
◼=010|          "release/*",
◼-015
◼=029|          "REGION": "us-east-1",
◼=034|          "SLACK_WEBHOOK",
◼=035|        "JWT_SECRET"
◼=110|            "oncall@acme.com",
◼>110|            "platform@acme.com"
◼<111|          ]
◼-060
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: Make the following changes to the pipeline config:\n- bump pipeline.version to 2\n- remove the schedule trigger from the triggers array\n- remove \"charlie\" from the manual trigger approvers and add \"diana\"\n- remove the entire security stage from stages\n- in the deploy stage: remove \"security\" from dependsOn (keep \"build\"), and change retry on the kubectl step to 5\n- in notifications.onFailure: remove the pagerduty entry and add \"platform@acme.com\" to the email recipients\n\n<FILE path=\"pipeline.json\" name=\"pipeline.json\">\n001|{\n002|  \"pipeline\": {\n003|    \"name\": \"deploy-prod\",\n004|    \"version\": 1,\n005|    \"triggers\": [\n006|      {\n007|        \"type\": \"push\",\n008|        \"branches\": [\n009|          \"main\",\n010|          \"release/*\"\n011|        ]\n012|      },\n013|      {\n014|        \"type\": \"schedule\",\n015|        \"cron\": \"0 2 * * 1\"\n016|      },\n017|      {\n018|        \"type\": \"manual\",\n019|        \"approvers\": [\n020|          \"alice\",\n021|          \"bob\",\n022|          \"charlie\"\n023|        ]\n024|      }\n025|    ],\n026|    \"stages\": [\n027|      {\n028|        \"name\": \"build\",\n029|        \"timeout\": 600,\n030|        \"steps\": [\n031|          {\n032|            \"run\": \"npm ci\",\n033|            \"cache\": true\n034|          },\n035|          {\n036|            \"run\": \"npm run build\",\n037|            \"artifacts\": [\n038|              \"dist/**\"\n039|            ]\n040|          },\n041|          {\n042|            \"run\": \"npm test\",\n043|            \"retry\": 2\n044|          }\n045|        ]\n046|      },\n047|      {\n048|        \"name\": \"security\",\n049|        \"timeout\": 300,\n050|        \"steps\": [\n051|          {\n052|            \"run\": \"npm audit\",\n053|            \"allowFailure\": true\n054|          },\n055|          {\n056|            \"run\": \"snyk test\",\n057|            \"env\": {\n058|              \"SNYK_TOKEN\": \"$SNYK_TOKEN\"\n059|            }\n060|          }\n061|        ]\n062|      },\n063|      {\n064|        \"name\": \"deploy\",\n065|        \"timeout\": 900,\n066|        \"dependsOn\": [\n067|          \"build\",\n068|          \"security\"\n069|        ],\n070|        \"steps\": [\n071|          {\n072|            \"run\": \"docker build -t app:latest .\"\n073|          },\n074|          {\n075|            \"run\": \"docker push app:latest\"\n076|          },\n077|          {\n078|            \"run\": \"kubectl apply -f k8s/\",\n079|            \"retry\": 3\n080|          }\n081|        ]\n082|      }\n083|    ],\n084|    \"notifications\": {\n085|      \"onSuccess\": [\n086|        {\n087|          \"type\": \"slack\",\n088|          \"channel\": \"#deploys\"\n089|        }\n090|      ],\n091|      \"onFailure\": [\n092|        {\n093|          \"type\": \"slack\",\n094|          \"channel\": \"#deploys\"\n095|        },\n096|        {\n097|          \"type\": \"email\",\n098|          \"recipients\": [\n099|            \"oncall@acme.com\"\n100|          ]\n101|        },\n102|        {\n103|          \"type\": \"pagerduty\",\n104|          \"severity\": \"high\"\n105|        }\n106|      ]\n107|    }\n108|  }\n109|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="pipeline.json">
◼=004|    "version": 2,
◼-013-016
◼=022|            "diana"
◼-048-062
◼=067|          "build"
◼-068
◼=079|            "retry": 5
◼-103-105
◼=099|              "oncall@acme.com",
◼>099|              "platform@acme.com"
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"The following JSON file has syntax errors. The original instructions were:\nMake the following changes to the pipeline config:\n- bump pipeline.version to 2\n- remove the schedule trigger from the triggers array\n- remove \"charlie\" from the manual trigger approvers and add \"diana\"\n- remove the entire security stage from stages\n- in the deploy stage: remove \"security\" from dependsOn (keep \"build\"), and change retry on the kubectl step to 5\n- in notifications.onFailure: remove the pagerduty entry and add \"platform@acme.com\" to the email recipients\n\nHere is the broken result:\n\n<FILE path=\"pipeline.json\" name=\"pipeline.json\">\n001|{\n002|  \"pipeline\": {\n003|    \"name\": \"deploy-prod\",\n004|    \"version\": 2,\n005|    \"triggers\": [\n006|      {\n007|        \"type\": \"push\",\n008|        \"branches\": [\n009|          \"main\",\n010|          \"release/*\"\n011|        ]\n012|      },\n013|      {\n014|        \"type\": \"manual\",\n015|        \"approvers\": [\n016|          \"alice\",\n017|          \"bob\",\n018|            \"diana\"\n019|        ]\n020|      }\n021|    ],\n022|    \"stages\": [\n023|      {\n024|        \"name\": \"build\",\n025|        \"timeout\": 600,\n026|        \"steps\": [\n027|          {\n028|            \"run\": \"npm ci\",\n029|            \"cache\": true\n030|          },\n031|          {\n032|            \"run\": \"npm run build\",\n033|            \"artifacts\": [\n034|              \"dist/**\"\n035|            ]\n036|          },\n037|          {\n038|            \"run\": \"npm test\",\n039|            \"retry\": 2\n040|          }\n041|        ]\n042|      },\n043|      {\n044|      {\n045|        \"name\": \"deploy\",\n046|        \"timeout\": 900,\n047|        \"dependsOn\": [\n048|          \"build\"\n049|        ],\n050|        \"steps\": [\n051|          {\n052|            \"run\": \"docker build -t app:latest .\"\n053|          },\n054|          {\n055|            \"run\": \"docker push app:latest\"\n056|          },\n057|          {\n058|            \"run\": \"kubectl apply -f k8s/\",\n059|            \"retry\": 5\n060|          }\n061|        ]\n062|      }\n063|    ],\n064|    \"notifications\": {\n065|      \"onSuccess\": [\n066|        {\n067|          \"type\": \"slack\",\n068|          \"channel\": \"#deploys\"\n069|        }\n070|      ],\n071|      \"onFailure\": [\n072|        {\n073|          \"type\": \"slack\",\n074|          \"channel\": \"#deploys\"\n075|        },\n076|        {\n077|          \"type\": \"email\",\n078|          \"recipients\": [\n079|              \"oncall@acme.com\",\n080|              \"platform@acme.com\"\n081|          ]\n082|        },\n083|        {\n084|      ]\n085|    }\n086|  }\n087|}\n</FILE>\n\nJSON parse error: JSON Syntax Error: Expected property name or '}' in JSON at position 741 (line 44 column 7)\n\n41|        ]\n42|      },\n43|      {\n44|      { ← ERROR\n         ^\n45|        \"name\": \"deploy\",\n46|        \"timeout\": 900,\n47|        \"dependsOn\": [\n\n\nFix ONLY the JSON syntax errors (missing commas, orphaned braces, etc). Do NOT change the data — only fix the syntax to make it valid JSON.","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="pipeline.json">
◼-44
◼=82|        }
◼-83
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: change port to 8080 and set debug to true\n\n<FILE path=\"config.json\" name=\"config.json\">\n001|{\n002|  \"name\": \"my-app\",\n003|  \"version\": \"1.0.0\",\n004|  \"port\": 3000,\n005|  \"debug\": false\n006|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="config.json">
◼=4|  "port": 8080,
◼=5|  "debug": true
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: change database host to \"db.prod.internal\", port to 5433, and add \"caching\" to features\n\n<FILE path=\"config.json\" name=\"config.json\">\n001|{\n002|  \"database\": {\n003|    \"host\": \"localhost\",\n004|    \"port\": 5432,\n005|    \"credentials\": {\n006|      \"username\": \"admin\",\n007|      \"password\": \"secret\"\n008|    }\n009|  },\n010|  \"features\": [\n011|    \"auth\",\n012|    \"logging\"\n013|  ]\n014|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="config.json">
◼=3|    "host": "db.prod.internal",
◼=4|    "port": 5433,
◼=12|    "logging",
◼<13|    "caching"
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"Instructions: change database host to \"db.prod.internal\", port to 5433 or higher, and add \"caching\" to features\n\n<FILE path=\"config.json\" name=\"config.json\">\n001|{\n002|  \"database\": {\n003|    \"host\": \"localhost\",\n004|    \"port\": 5432,\n005|    \"credentials\": {\n006|      \"username\": \"admin\",\n007|      \"password\": \"secret\"\n008|    }\n009|  },\n010|  \"features\": [\n011|    \"auth\",\n012|    \"logging\"\n013|  ]\n014|}\n</FILE>\n\nGenerate patches for each file that needs modification:","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="config.json">
◼=003|    "host": "db.prod.internal",
◼=004|    "port": 5433,
◼=012|    "logging",
◼>012|    "caching"
</FILE>


Input: {"body":{"messages":[{"content":"You are a code patching assistant. Your task is to generate precise line-based patches using the Micropatch protocol.\n\n## Input Format\n\nYou will receive files in this XML format:\n\n```\n<FILE path=\"src/hello.ts\" name=\"hello.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n</FILE>\n\n<FILE path=\"src/utils.ts\" name=\"utils.ts\">\n001|export function add(a, b) {\n002|  return a + b\n003|}\n</FILE>\n```\n\nEach file has:\n- **path**: Full file path\n- **name**: File name\n- **Numbered lines**: Format is `NNN|content` where NNN is the ORIGINAL line number (1-based)\n\n## Output Format\n\nGenerate patches for EACH file that needs modification using this EXACT XML format:\n\n```\n<FILE path=\"src/hello.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n</FILE>\n\n<FILE path=\"src/utils.ts\">\n◼<1|/**\n * Adds two numbers\n */\n</FILE>\n```\n\n**CRITICAL RULES**:\n1. Each `<FILE>` tag MUST include the exact `path` attribute from the input\n2. Put patch operations for EACH file inside its own `<FILE>...</FILE>` block\n3. If a file doesn't need changes, omit its `<FILE>` block entirely\n4. DO NOT mix patches from different files\n5. DO NOT include line numbers or any text outside the patch operations\n\n## Micropatch Protocol\n\nThe Micropatch protocol uses line numbers to reference ORIGINAL lines (before any edits).\n\n### Operations\n\nEach operation starts with the marker `◼` at the beginning of a line:\n\n1. **Insert BEFORE line**: `◼<NNN|text`\n   - Inserts `text` as a new line BEFORE original line NNN\n   - Example: `◼<5|console.log('debug')`\n\n2. **Insert AFTER line**: `◼>NNN|text`\n   - Inserts `text` as a new line AFTER original line NNN\n   - Example: `◼>10|}`\n\n3. **Replace single line**: `◼=NNN|new text`\n   - Replaces original line NNN with `new text`\n   - Can span multiple lines (continue until next ◼ or end)\n   - Example:\n     ```\n     ◼=7|function newName() {\n       return 42\n     }\n     ```\n\n4. **Replace range**: `◼=NNN-MMM|replacement`\n   - Replaces lines NNN through MMM with replacement text\n   - Example: `◼=5-8|const combined = a + b + c + d`\n\n5. **Delete single line**: `◼-NNN`\n   - Deletes original line NNN\n   - Example: `◼-12`\n\n6. **Delete range**: `◼-NNN-MMM`\n   - Deletes lines NNN through MMM inclusive\n   - Example: `◼-5-10`\n\n### Escaping\n\n- To include a literal `◼` in your text, use `\\◼`\n- No other escape sequences are recognized\n\n### Important Rules\n\n1. **Use ORIGINAL line numbers**: Always reference the line numbers shown in the input (001, 002, etc.)\n2. **One operation per line**: Each operation must start on a new line with `◼`\n3. **No explanations**: Output ONLY patch operations inside `<FILE>` tags\n4. **Precise operations**: Use the minimal set of operations to achieve the goal\n5. **Verify line numbers**: Double-check that line numbers match the input\n\n## Example\n\n**Input:**\n```\n<FILE path=\"src/math.ts\" name=\"math.ts\">\n001|const x = 1\n002|const y = 2\n003|console.log(x + y)\n004|\n005|export { x, y }\n</FILE>\n```\n\n**Task:** Change variable names from x,y to a,b\n\n**Output:**\n```\n<FILE path=\"src/math.ts\">\n◼=1|const a = 1\n◼=2|const b = 2\n◼=3|console.log(a + b)\n◼=5|export { a, b }\n</FILE>\n```\n\n## Your Task\n\nGenerate ONLY the `<FILE>` blocks with patch operations. Do not include explanations, comments, or any other text.","role":"system"},{"content":"The following JSON file is valid JSON but does not match the expected schema.\n\n<FILE path=\"config.json\" name=\"config.json\">\n001|{\n002|  \"database\": {\n003|    \"host\": \"db.prod.internal\",\n004|    \"port\": 5433,\n005|    \"credentials\": {\n006|      \"username\": \"admin\",\n007|      \"password\": \"secret\"\n008|    }\n009|  },\n010|  \"features\": [\n011|    \"auth\",\n012|    \"logging\",\n013|    \"caching\"\n014|  ]\n015|}\n</FILE>\n\nError parsing JSON:\n\n---JSON---\n{\n  \"database\": {\n    \"host\": \"db.prod.internal\",\n    \"port\": 5433,\n    \"credentials\": {\n      \"username\": \"admin\",\n      \"password\": \"secret\"\n    }\n  },\n  \"features\": [\n    \"auth\",\n    \"logging\",\n    \"caching\"\n  ]\n}\n\n---Validation Errors---\n\n1. Field: \"database.port\"\n   Problem: Number must be at least 5434\n   Message: Number must be greater than or equal to 5434\n\n\nFix the JSON to match the schema. Only change what's needed to satisfy the validation errors above.","role":"user","type":"text"}],"meta":{"integrationName":"zai","promptCategory":"zai:zai.patch","promptSource":"zai:zai.patch:default"},"model":"fast","signal":{},"stopSequences":[]},"method":"POST","url":"https://api.botpress.cloud/v2/cognitive/generate-text"}

Output:
<FILE path="config.json">
◼=004|    "port": 5434,
</FILE>