codex-multi-auth 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +162 -0
  3. package/assets/opencode-logo-ornate-dark.svg +18 -0
  4. package/assets/readme-hero.svg +31 -0
  5. package/config/README.md +87 -0
  6. package/config/minimal-opencode.json +13 -0
  7. package/config/opencode-legacy.json +571 -0
  8. package/config/opencode-modern.json +239 -0
  9. package/dist/index.d.ts +45 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +3160 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/lib/accounts/rate-limits.d.ts +22 -0
  14. package/dist/lib/accounts/rate-limits.d.ts.map +1 -0
  15. package/dist/lib/accounts/rate-limits.js +63 -0
  16. package/dist/lib/accounts/rate-limits.js.map +1 -0
  17. package/dist/lib/accounts.d.ts +95 -0
  18. package/dist/lib/accounts.d.ts.map +1 -0
  19. package/dist/lib/accounts.js +668 -0
  20. package/dist/lib/accounts.js.map +1 -0
  21. package/dist/lib/audit.d.ts +45 -0
  22. package/dist/lib/audit.d.ts.map +1 -0
  23. package/dist/lib/audit.js +131 -0
  24. package/dist/lib/audit.js.map +1 -0
  25. package/dist/lib/auth/auth.d.ts +56 -0
  26. package/dist/lib/auth/auth.d.ts.map +1 -0
  27. package/dist/lib/auth/auth.js +214 -0
  28. package/dist/lib/auth/auth.js.map +1 -0
  29. package/dist/lib/auth/browser.d.ts +34 -0
  30. package/dist/lib/auth/browser.d.ts.map +1 -0
  31. package/dist/lib/auth/browser.js +185 -0
  32. package/dist/lib/auth/browser.js.map +1 -0
  33. package/dist/lib/auth/server.d.ts +24 -0
  34. package/dist/lib/auth/server.d.ts.map +1 -0
  35. package/dist/lib/auth/server.js +116 -0
  36. package/dist/lib/auth/server.js.map +1 -0
  37. package/dist/lib/auth/token-utils.d.ts +59 -0
  38. package/dist/lib/auth/token-utils.d.ts.map +1 -0
  39. package/dist/lib/auth/token-utils.js +331 -0
  40. package/dist/lib/auth/token-utils.js.map +1 -0
  41. package/dist/lib/auth-rate-limit.d.ts +20 -0
  42. package/dist/lib/auth-rate-limit.d.ts.map +1 -0
  43. package/dist/lib/auth-rate-limit.js +91 -0
  44. package/dist/lib/auth-rate-limit.js.map +1 -0
  45. package/dist/lib/auto-update-checker.d.ts +10 -0
  46. package/dist/lib/auto-update-checker.d.ts.map +1 -0
  47. package/dist/lib/auto-update-checker.js +216 -0
  48. package/dist/lib/auto-update-checker.js.map +1 -0
  49. package/dist/lib/capability-policy.d.ts +18 -0
  50. package/dist/lib/capability-policy.d.ts.map +1 -0
  51. package/dist/lib/capability-policy.js +150 -0
  52. package/dist/lib/capability-policy.js.map +1 -0
  53. package/dist/lib/circuit-breaker.d.ts +34 -0
  54. package/dist/lib/circuit-breaker.d.ts.map +1 -0
  55. package/dist/lib/circuit-breaker.js +124 -0
  56. package/dist/lib/circuit-breaker.js.map +1 -0
  57. package/dist/lib/cli.d.ts +64 -0
  58. package/dist/lib/cli.d.ts.map +1 -0
  59. package/dist/lib/cli.js +274 -0
  60. package/dist/lib/cli.js.map +1 -0
  61. package/dist/lib/codex-cli/observability.d.ts +22 -0
  62. package/dist/lib/codex-cli/observability.d.ts.map +1 -0
  63. package/dist/lib/codex-cli/observability.js +36 -0
  64. package/dist/lib/codex-cli/observability.js.map +1 -0
  65. package/dist/lib/codex-cli/state.d.ts +86 -0
  66. package/dist/lib/codex-cli/state.d.ts.map +1 -0
  67. package/dist/lib/codex-cli/state.js +470 -0
  68. package/dist/lib/codex-cli/state.js.map +1 -0
  69. package/dist/lib/codex-cli/sync.d.ts +27 -0
  70. package/dist/lib/codex-cli/sync.d.ts.map +1 -0
  71. package/dist/lib/codex-cli/sync.js +325 -0
  72. package/dist/lib/codex-cli/sync.js.map +1 -0
  73. package/dist/lib/codex-cli/writer.d.ts +12 -0
  74. package/dist/lib/codex-cli/writer.d.ts.map +1 -0
  75. package/dist/lib/codex-cli/writer.js +388 -0
  76. package/dist/lib/codex-cli/writer.js.map +1 -0
  77. package/dist/lib/codex-manager.d.ts +2 -0
  78. package/dist/lib/codex-manager.d.ts.map +1 -0
  79. package/dist/lib/codex-manager.js +4841 -0
  80. package/dist/lib/codex-manager.js.map +1 -0
  81. package/dist/lib/config.d.ts +269 -0
  82. package/dist/lib/config.d.ts.map +1 -0
  83. package/dist/lib/config.js +789 -0
  84. package/dist/lib/config.js.map +1 -0
  85. package/dist/lib/constants.d.ts +78 -0
  86. package/dist/lib/constants.d.ts.map +1 -0
  87. package/dist/lib/constants.js +78 -0
  88. package/dist/lib/constants.js.map +1 -0
  89. package/dist/lib/context-overflow.d.ts +27 -0
  90. package/dist/lib/context-overflow.d.ts.map +1 -0
  91. package/dist/lib/context-overflow.js +124 -0
  92. package/dist/lib/context-overflow.js.map +1 -0
  93. package/dist/lib/dashboard-settings.d.ts +90 -0
  94. package/dist/lib/dashboard-settings.d.ts.map +1 -0
  95. package/dist/lib/dashboard-settings.js +327 -0
  96. package/dist/lib/dashboard-settings.js.map +1 -0
  97. package/dist/lib/entitlement-cache.d.ts +41 -0
  98. package/dist/lib/entitlement-cache.d.ts.map +1 -0
  99. package/dist/lib/entitlement-cache.js +137 -0
  100. package/dist/lib/entitlement-cache.js.map +1 -0
  101. package/dist/lib/errors.d.ts +113 -0
  102. package/dist/lib/errors.d.ts.map +1 -0
  103. package/dist/lib/errors.js +103 -0
  104. package/dist/lib/errors.js.map +1 -0
  105. package/dist/lib/forecast.d.ts +42 -0
  106. package/dist/lib/forecast.d.ts.map +1 -0
  107. package/dist/lib/forecast.js +256 -0
  108. package/dist/lib/forecast.js.map +1 -0
  109. package/dist/lib/health.d.ts +33 -0
  110. package/dist/lib/health.d.ts.map +1 -0
  111. package/dist/lib/health.js +70 -0
  112. package/dist/lib/health.js.map +1 -0
  113. package/dist/lib/index.d.ts +32 -0
  114. package/dist/lib/index.d.ts.map +1 -0
  115. package/dist/lib/index.js +32 -0
  116. package/dist/lib/index.js.map +1 -0
  117. package/dist/lib/live-account-sync.d.ts +39 -0
  118. package/dist/lib/live-account-sync.d.ts.map +1 -0
  119. package/dist/lib/live-account-sync.js +196 -0
  120. package/dist/lib/live-account-sync.js.map +1 -0
  121. package/dist/lib/logger.d.ts +40 -0
  122. package/dist/lib/logger.d.ts.map +1 -0
  123. package/dist/lib/logger.js +364 -0
  124. package/dist/lib/logger.js.map +1 -0
  125. package/dist/lib/oauth-success.html +338 -0
  126. package/dist/lib/parallel-probe.d.ts +28 -0
  127. package/dist/lib/parallel-probe.d.ts.map +1 -0
  128. package/dist/lib/parallel-probe.js +97 -0
  129. package/dist/lib/parallel-probe.js.map +1 -0
  130. package/dist/lib/preemptive-quota-scheduler.d.ts +53 -0
  131. package/dist/lib/preemptive-quota-scheduler.d.ts.map +1 -0
  132. package/dist/lib/preemptive-quota-scheduler.js +220 -0
  133. package/dist/lib/preemptive-quota-scheduler.js.map +1 -0
  134. package/dist/lib/proactive-refresh.d.ts +66 -0
  135. package/dist/lib/proactive-refresh.d.ts.map +1 -0
  136. package/dist/lib/proactive-refresh.js +143 -0
  137. package/dist/lib/proactive-refresh.js.map +1 -0
  138. package/dist/lib/prompts/codex-opencode-bridge.d.ts +19 -0
  139. package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +1 -0
  140. package/dist/lib/prompts/codex-opencode-bridge.js +169 -0
  141. package/dist/lib/prompts/codex-opencode-bridge.js.map +1 -0
  142. package/dist/lib/prompts/codex.d.ts +41 -0
  143. package/dist/lib/prompts/codex.d.ts.map +1 -0
  144. package/dist/lib/prompts/codex.js +383 -0
  145. package/dist/lib/prompts/codex.js.map +1 -0
  146. package/dist/lib/prompts/opencode-codex.d.ts +25 -0
  147. package/dist/lib/prompts/opencode-codex.d.ts.map +1 -0
  148. package/dist/lib/prompts/opencode-codex.js +270 -0
  149. package/dist/lib/prompts/opencode-codex.js.map +1 -0
  150. package/dist/lib/quota-cache.d.ts +68 -0
  151. package/dist/lib/quota-cache.d.ts.map +1 -0
  152. package/dist/lib/quota-cache.js +224 -0
  153. package/dist/lib/quota-cache.js.map +1 -0
  154. package/dist/lib/quota-probe.d.ts +49 -0
  155. package/dist/lib/quota-probe.d.ts.map +1 -0
  156. package/dist/lib/quota-probe.js +368 -0
  157. package/dist/lib/quota-probe.js.map +1 -0
  158. package/dist/lib/recovery/constants.d.ts +12 -0
  159. package/dist/lib/recovery/constants.d.ts.map +1 -0
  160. package/dist/lib/recovery/constants.js +31 -0
  161. package/dist/lib/recovery/constants.js.map +1 -0
  162. package/dist/lib/recovery/index.d.ts +12 -0
  163. package/dist/lib/recovery/index.d.ts.map +1 -0
  164. package/dist/lib/recovery/index.js +12 -0
  165. package/dist/lib/recovery/index.js.map +1 -0
  166. package/dist/lib/recovery/storage.d.ts +24 -0
  167. package/dist/lib/recovery/storage.d.ts.map +1 -0
  168. package/dist/lib/recovery/storage.js +362 -0
  169. package/dist/lib/recovery/storage.js.map +1 -0
  170. package/dist/lib/recovery/types.d.ts +116 -0
  171. package/dist/lib/recovery/types.d.ts.map +1 -0
  172. package/dist/lib/recovery/types.js +7 -0
  173. package/dist/lib/recovery/types.js.map +1 -0
  174. package/dist/lib/recovery.d.ts +31 -0
  175. package/dist/lib/recovery.d.ts.map +1 -0
  176. package/dist/lib/recovery.js +313 -0
  177. package/dist/lib/recovery.js.map +1 -0
  178. package/dist/lib/refresh-guardian.d.ts +31 -0
  179. package/dist/lib/refresh-guardian.d.ts.map +1 -0
  180. package/dist/lib/refresh-guardian.js +151 -0
  181. package/dist/lib/refresh-guardian.js.map +1 -0
  182. package/dist/lib/refresh-lease.d.ts +37 -0
  183. package/dist/lib/refresh-lease.d.ts.map +1 -0
  184. package/dist/lib/refresh-lease.js +335 -0
  185. package/dist/lib/refresh-lease.js.map +1 -0
  186. package/dist/lib/refresh-queue.d.ts +117 -0
  187. package/dist/lib/refresh-queue.d.ts.map +1 -0
  188. package/dist/lib/refresh-queue.js +297 -0
  189. package/dist/lib/refresh-queue.js.map +1 -0
  190. package/dist/lib/request/failure-policy.d.ts +42 -0
  191. package/dist/lib/request/failure-policy.d.ts.map +1 -0
  192. package/dist/lib/request/failure-policy.js +133 -0
  193. package/dist/lib/request/failure-policy.js.map +1 -0
  194. package/dist/lib/request/fetch-helpers.d.ts +152 -0
  195. package/dist/lib/request/fetch-helpers.d.ts.map +1 -0
  196. package/dist/lib/request/fetch-helpers.js +704 -0
  197. package/dist/lib/request/fetch-helpers.js.map +1 -0
  198. package/dist/lib/request/helpers/input-utils.d.ts +7 -0
  199. package/dist/lib/request/helpers/input-utils.d.ts.map +1 -0
  200. package/dist/lib/request/helpers/input-utils.js +214 -0
  201. package/dist/lib/request/helpers/input-utils.js.map +1 -0
  202. package/dist/lib/request/helpers/model-map.d.ts +28 -0
  203. package/dist/lib/request/helpers/model-map.d.ts.map +1 -0
  204. package/dist/lib/request/helpers/model-map.js +133 -0
  205. package/dist/lib/request/helpers/model-map.js.map +1 -0
  206. package/dist/lib/request/helpers/tool-utils.d.ts +29 -0
  207. package/dist/lib/request/helpers/tool-utils.d.ts.map +1 -0
  208. package/dist/lib/request/helpers/tool-utils.js +117 -0
  209. package/dist/lib/request/helpers/tool-utils.js.map +1 -0
  210. package/dist/lib/request/rate-limit-backoff.d.ts +17 -0
  211. package/dist/lib/request/rate-limit-backoff.d.ts.map +1 -0
  212. package/dist/lib/request/rate-limit-backoff.js +83 -0
  213. package/dist/lib/request/rate-limit-backoff.js.map +1 -0
  214. package/dist/lib/request/request-transformer.d.ts +107 -0
  215. package/dist/lib/request/request-transformer.d.ts.map +1 -0
  216. package/dist/lib/request/request-transformer.js +814 -0
  217. package/dist/lib/request/request-transformer.js.map +1 -0
  218. package/dist/lib/request/response-handler.d.ts +23 -0
  219. package/dist/lib/request/response-handler.d.ts.map +1 -0
  220. package/dist/lib/request/response-handler.js +155 -0
  221. package/dist/lib/request/response-handler.js.map +1 -0
  222. package/dist/lib/request/stream-failover.d.ts +21 -0
  223. package/dist/lib/request/stream-failover.d.ts.map +1 -0
  224. package/dist/lib/request/stream-failover.js +204 -0
  225. package/dist/lib/request/stream-failover.js.map +1 -0
  226. package/dist/lib/rotation.d.ts +146 -0
  227. package/dist/lib/rotation.d.ts.map +1 -0
  228. package/dist/lib/rotation.js +321 -0
  229. package/dist/lib/rotation.js.map +1 -0
  230. package/dist/lib/runtime-paths.d.ts +58 -0
  231. package/dist/lib/runtime-paths.d.ts.map +1 -0
  232. package/dist/lib/runtime-paths.js +164 -0
  233. package/dist/lib/runtime-paths.js.map +1 -0
  234. package/dist/lib/schemas.d.ts +435 -0
  235. package/dist/lib/schemas.d.ts.map +1 -0
  236. package/dist/lib/schemas.js +268 -0
  237. package/dist/lib/schemas.js.map +1 -0
  238. package/dist/lib/session-affinity.d.ts +23 -0
  239. package/dist/lib/session-affinity.d.ts.map +1 -0
  240. package/dist/lib/session-affinity.js +127 -0
  241. package/dist/lib/session-affinity.js.map +1 -0
  242. package/dist/lib/shutdown.d.ts +7 -0
  243. package/dist/lib/shutdown.d.ts.map +1 -0
  244. package/dist/lib/shutdown.js +43 -0
  245. package/dist/lib/shutdown.js.map +1 -0
  246. package/dist/lib/storage/migrations.d.ts +59 -0
  247. package/dist/lib/storage/migrations.d.ts.map +1 -0
  248. package/dist/lib/storage/migrations.js +41 -0
  249. package/dist/lib/storage/migrations.js.map +1 -0
  250. package/dist/lib/storage/paths.d.ts +51 -0
  251. package/dist/lib/storage/paths.d.ts.map +1 -0
  252. package/dist/lib/storage/paths.js +152 -0
  253. package/dist/lib/storage/paths.js.map +1 -0
  254. package/dist/lib/storage.d.ts +106 -0
  255. package/dist/lib/storage.d.ts.map +1 -0
  256. package/dist/lib/storage.js +896 -0
  257. package/dist/lib/storage.js.map +1 -0
  258. package/dist/lib/table-formatter.d.ts +32 -0
  259. package/dist/lib/table-formatter.d.ts.map +1 -0
  260. package/dist/lib/table-formatter.js +44 -0
  261. package/dist/lib/table-formatter.js.map +1 -0
  262. package/dist/lib/tools/hashline-tools.d.ts +51 -0
  263. package/dist/lib/tools/hashline-tools.d.ts.map +1 -0
  264. package/dist/lib/tools/hashline-tools.js +456 -0
  265. package/dist/lib/tools/hashline-tools.js.map +1 -0
  266. package/dist/lib/types.d.ts +130 -0
  267. package/dist/lib/types.d.ts.map +1 -0
  268. package/dist/lib/types.js +2 -0
  269. package/dist/lib/types.js.map +1 -0
  270. package/dist/lib/ui/ansi.d.ts +40 -0
  271. package/dist/lib/ui/ansi.d.ts.map +1 -0
  272. package/dist/lib/ui/ansi.js +68 -0
  273. package/dist/lib/ui/ansi.js.map +1 -0
  274. package/dist/lib/ui/auth-menu.d.ts +76 -0
  275. package/dist/lib/ui/auth-menu.d.ts.map +1 -0
  276. package/dist/lib/ui/auth-menu.js +590 -0
  277. package/dist/lib/ui/auth-menu.js.map +1 -0
  278. package/dist/lib/ui/confirm.d.ts +11 -0
  279. package/dist/lib/ui/confirm.d.ts.map +1 -0
  280. package/dist/lib/ui/confirm.js +29 -0
  281. package/dist/lib/ui/confirm.js.map +1 -0
  282. package/dist/lib/ui/copy.d.ts +123 -0
  283. package/dist/lib/ui/copy.d.ts.map +1 -0
  284. package/dist/lib/ui/copy.js +127 -0
  285. package/dist/lib/ui/copy.js.map +1 -0
  286. package/dist/lib/ui/format.d.ts +62 -0
  287. package/dist/lib/ui/format.d.ts.map +1 -0
  288. package/dist/lib/ui/format.js +205 -0
  289. package/dist/lib/ui/format.js.map +1 -0
  290. package/dist/lib/ui/runtime.d.ts +43 -0
  291. package/dist/lib/ui/runtime.d.ts.map +1 -0
  292. package/dist/lib/ui/runtime.js +69 -0
  293. package/dist/lib/ui/runtime.js.map +1 -0
  294. package/dist/lib/ui/select.d.ts +60 -0
  295. package/dist/lib/ui/select.d.ts.map +1 -0
  296. package/dist/lib/ui/select.js +467 -0
  297. package/dist/lib/ui/select.js.map +1 -0
  298. package/dist/lib/ui/theme.d.ts +56 -0
  299. package/dist/lib/ui/theme.d.ts.map +1 -0
  300. package/dist/lib/ui/theme.js +186 -0
  301. package/dist/lib/ui/theme.js.map +1 -0
  302. package/dist/lib/unified-settings.d.ts +71 -0
  303. package/dist/lib/unified-settings.d.ts.map +1 -0
  304. package/dist/lib/unified-settings.js +299 -0
  305. package/dist/lib/unified-settings.js.map +1 -0
  306. package/dist/lib/utils.d.ts +29 -0
  307. package/dist/lib/utils.d.ts.map +1 -0
  308. package/dist/lib/utils.js +54 -0
  309. package/dist/lib/utils.js.map +1 -0
  310. package/package.json +115 -0
  311. package/scripts/audit-dev-allowlist.js +128 -0
  312. package/scripts/bench-format/hashline-v2.mjs +642 -0
  313. package/scripts/bench-format/models.mjs +105 -0
  314. package/scripts/bench-format/opencode.mjs +205 -0
  315. package/scripts/bench-format/render.mjs +496 -0
  316. package/scripts/bench-format/stats.mjs +54 -0
  317. package/scripts/bench-format/tasks.mjs +151 -0
  318. package/scripts/benchmark-edit-formats.mjs +1161 -0
  319. package/scripts/benchmark-render-dashboard.mjs +49 -0
  320. package/scripts/codex-multi-auth.js +6 -0
  321. package/scripts/codex-routing.js +34 -0
  322. package/scripts/codex.js +122 -0
  323. package/scripts/copy-oauth-success.js +37 -0
  324. package/scripts/install-opencode-codex-auth.js +193 -0
  325. package/scripts/test-all-models.sh +7 -0
  326. package/scripts/test-model-matrix.js +424 -0
  327. package/scripts/validate-model-map.sh +7 -0
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Codex-OpenCode Bridge Prompt
3
+ *
4
+ * This prompt bridges Codex CLI instructions to the OpenCode environment.
5
+ * It incorporates critical tool mappings, available tools list, substitution rules,
6
+ * and verification checklist to ensure proper tool usage.
7
+ *
8
+ * Token Count: ~450 tokens (~90% reduction vs full OpenCode prompt)
9
+ */
10
+ export const CODEX_OPENCODE_BRIDGE = `# Codex Running in OpenCode
11
+
12
+ You are running Codex through OpenCode, an open-source terminal coding assistant. OpenCode provides specific tools to help you work efficiently.
13
+
14
+ ## CRITICAL: Tool Usage
15
+
16
+ <critical_rule priority="0">
17
+ apply_patch/applyPatch are Codex names, but OpenCode tool names vary by version.
18
+ - Inspect the actual tool list before editing.
19
+ - If \`edit\` exists: use \`edit\` for precise in-place string replacements and hashline edits.
20
+ - If \`edit\` is absent and \`apply_patch\` exists: use \`apply_patch\` for those precise/hashline edits in this plugin.
21
+ - For diff-style or multi-line structural edits: use \`patch\` if available, otherwise use \`apply_patch\`.
22
+ - In this plugin, \`edit\` / \`apply_patch\` also support hashline refs (\`lineRef\`, \`endLineRef\`, \`operation\`, \`content\`)
23
+ </critical_rule>
24
+
25
+ <critical_rule priority="0">
26
+ UPDATE_PLAN DOES NOT EXIST -> USE "todowrite" INSTEAD
27
+ - NEVER use: update_plan, updatePlan, read_plan, readPlan
28
+ - ALWAYS use: todowrite for task/plan updates, todoread to read plans
29
+ - Before plan operations: Verify you're using "todowrite", NOT "update_plan"
30
+ </critical_rule>
31
+
32
+ ## Available OpenCode Tools
33
+
34
+ **File Operations:**
35
+ - \`write\` - Create new files
36
+ - Overwriting existing files requires a prior Read in this session; default to ASCII unless the file already uses Unicode.
37
+ - \`edit\` - Modify existing files with string replacement (version-dependent)
38
+ - Requires a prior Read in this session; preserve exact indentation; ensure \`oldString\` uniquely matches or use \`replaceAll\`; edit fails if ambiguous or missing.
39
+ - Never pass unresolved template placeholders in \`oldString\` (e.g. \`\${TARGET_SNIPPET}\`); \`oldString\` must be literal text copied from the current file.
40
+ - For complex multi-line changes: break into multiple sequential edit calls, each with unique oldString context.
41
+ - \`apply_patch\` - May be the edit/patch tool name in newer OpenCode builds (version-dependent)
42
+ - In this plugin, \`apply_patch\` also accepts hashline edit args (\`path\`, \`lineRef\`, \`endLineRef\`, \`operation\`, \`content\`) when \`edit\` is not available.
43
+ - \`hashline_read\` - Read file with hashline refs (\`L<line>#<hash>\`) for deterministic edits
44
+ - \`patch\` - Apply diff-style patches for multi-line updates (version-dependent)
45
+ - \`read\` - Read file contents
46
+
47
+ Note: Tool naming is version-dependent. If \`edit\` is unavailable but \`apply_patch\` exists, use \`apply_patch\`.
48
+
49
+ When available, prefer hashline workflow for reliability:
50
+ 1. Call \`hashline_read\` for target file and capture refs.
51
+ 2. Call \`edit\` or \`apply_patch\` with \`lineRef\` (and optional \`endLineRef\`) plus \`operation\` and \`content\`.
52
+ 3. Use legacy \`oldString\` / \`newString\` only when hashline refs are unavailable, and only with literal file text (no template placeholders).
53
+
54
+ **Search/Discovery:**
55
+ - \`grep\` - Search file contents (tool, not bash grep); use \`include\` to filter patterns; set \`path\` only when not searching workspace root; for cross-file match counts use bash with \`rg\`.
56
+ - \`glob\` - Find files by pattern; defaults to workspace cwd unless \`path\` is set.
57
+ - \`list\` - List directories (requires absolute paths)
58
+
59
+ **Execution:**
60
+ - \`bash\` - Run shell commands
61
+ - No workdir parameter; do not include it in tool calls.
62
+ - Always include a short description for the command.
63
+ - Do not use cd; use absolute paths in commands.
64
+ - Quote paths containing spaces with double quotes.
65
+ - Chain multiple commands with ';' or '&&'; avoid newlines.
66
+ - Use Grep/Glob tools for searches; only use bash with \`rg\` when you need counts or advanced features.
67
+ - Do not use \`ls\`/\`cat\` in bash; use \`list\`/\`read\` tools instead.
68
+ - For deletions (rm), verify by listing parent dir with \`list\`.
69
+
70
+ **Network:**
71
+ - \`webfetch\` - Fetch web content
72
+ - Use fully-formed URLs (http/https; http auto-upgrades to https).
73
+ - Always set \`format\` to one of: text | markdown | html; prefer markdown unless otherwise required.
74
+ - Read-only; short cache window.
75
+
76
+ **Task Management:**
77
+ - \`todowrite\` - Manage tasks/plans (REPLACES update_plan)
78
+ - \`todoread\` - Read current plan
79
+
80
+ ## Substitution Rules
81
+
82
+ Base instruction says: You MUST use instead:
83
+ apply_patch -> patch (preferred if available), otherwise edit/apply_patch based on actual tool list
84
+ update_plan -> todowrite
85
+ read_plan -> todoread
86
+
87
+ **Path Usage:** Use per-tool conventions to avoid conflicts:
88
+ - Tool calls: \`read\`, \`edit\`, \`write\`, \`list\` require absolute paths.
89
+ - Searches: \`grep\`/\`glob\` default to the workspace cwd; prefer relative include patterns; set \`path\` only when a different root is needed.
90
+ - Presentation: In assistant messages, show workspace-relative paths; use absolute paths only inside tool calls.
91
+ - Tool schema overrides general path preferences-do not convert required absolute paths to relative.
92
+
93
+ ## Verification Checklist
94
+
95
+ Before file/plan modifications:
96
+ 1. Am I using the actual available edit tool name (\`edit\`, \`patch\`, or \`apply_patch\`)?
97
+ 2. Am I using "todowrite" NOT "update_plan"?
98
+ 3. Is this tool in the approved list above?
99
+ 4. Am I following each tool's path requirements?
100
+
101
+ If ANY answer is NO -> STOP and correct before proceeding.
102
+
103
+ ## OpenCode Working Style
104
+
105
+ **Communication:**
106
+ - Send brief preambles (8-12 words) before tool calls, building on prior context
107
+ - Provide progress updates during longer tasks
108
+
109
+ **Execution:**
110
+ - Keep working autonomously until query is fully resolved before yielding
111
+ - Don't return to user with partial solutions
112
+
113
+ **Code Approach:**
114
+ - New projects: Be ambitious and creative
115
+ - Existing codebases: Surgical precision - modify only what's requested unless explicitly instructed to do otherwise
116
+
117
+ **Testing:**
118
+ - If tests exist: Start specific to your changes, then broader validation
119
+
120
+ ## Advanced Tools
121
+
122
+ **Task Tool (Sub-Agents):**
123
+ - Use the Task tool (functions.task) to launch sub-agents
124
+ - Check the Task tool description for current agent types and their capabilities
125
+ - Useful for complex analysis, specialized workflows, or tasks requiring isolated context
126
+ - The agent list is dynamically generated - refer to tool schema for available agents
127
+
128
+ **Parallelization:**
129
+ - When multiple independent tool calls are needed, use multi_tool_use.parallel to run them concurrently.
130
+ - Reserve sequential calls for ordered or data-dependent steps.
131
+
132
+ **MCP Tools:**
133
+ - Model Context Protocol servers provide additional capabilities
134
+ - MCP tools are prefixed: \`mcp__<server-name>__<tool-name>\`
135
+ - Check your available tools for MCP integrations
136
+ - Use when the tool's functionality matches your task needs
137
+
138
+ ## What Remains from Codex
139
+
140
+ Sandbox policies, approval mechanisms, final answer formatting, git commit protocols, and file reference formats all follow Codex instructions. In approval policy "never", never request escalations.
141
+
142
+ ## Approvals & Safety
143
+ - Assume workspace-write filesystem, network enabled, approval on-failure unless explicitly stated otherwise.
144
+ - When a command fails due to sandboxing or permissions, retry with escalated permissions if allowed by policy, including a one-line justification.
145
+ - Treat destructive commands (e.g., \`rm\`, \`git reset --hard\`) as requiring explicit user request or approval.
146
+ - Never run \`git reset --hard\`, \`git checkout --\`, or force deletes unless the user explicitly asked for that exact action.
147
+ - \`request_user_input\` is Plan-mode only; do not call it in Default mode.
148
+ - When uncertain, prefer non-destructive verification first (e.g., confirm file existence with \`list\`, then delete with \`bash\`).`;
149
+ export const CODEX_OPENCODE_BRIDGE_META = {
150
+ estimatedTokens: 550,
151
+ reductionVsCurrent: "88%",
152
+ reductionVsToolRemap: "10%",
153
+ protects: [
154
+ "Tool name confusion (update_plan)",
155
+ "Missing tool awareness",
156
+ "Task tool / sub-agent awareness",
157
+ "MCP tool awareness",
158
+ "Premature yielding to user",
159
+ "Over-modification of existing code",
160
+ "Environment confusion",
161
+ ],
162
+ omits: [
163
+ "Sandbox details (in Codex)",
164
+ "Formatting rules (in Codex)",
165
+ "Tool schemas (in tool JSONs)",
166
+ "Git protocols (in Codex)",
167
+ ],
168
+ };
169
+ //# sourceMappingURL=codex-opencode-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-opencode-bridge.js","sourceRoot":"","sources":["../../../lib/prompts/codex-opencode-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qIA0IgG,CAAC;AAUtI,MAAM,CAAC,MAAM,0BAA0B,GAA4B;IAClE,eAAe,EAAE,GAAG;IACpB,kBAAkB,EAAE,KAAK;IACzB,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE;QACT,mCAAmC;QACnC,wBAAwB;QACxB,iCAAiC;QACjC,oBAAoB;QACpB,4BAA4B;QAC5B,oCAAoC;QACpC,uBAAuB;KACvB;IACD,KAAK,EAAE;QACN,4BAA4B;QAC5B,6BAA6B;QAC7B,8BAA8B;QAC9B,0BAA0B;KAC1B;CACD,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Clear the memory cache - exposed for testing
3
+ * @internal
4
+ */
5
+ export declare function __clearCacheForTesting(): void;
6
+ /**
7
+ * Model family type for prompt selection
8
+ * Maps to different system prompts in the Codex CLI
9
+ */
10
+ export type ModelFamily = "gpt-5-codex" | "codex-max" | "codex" | "gpt-5.2" | "gpt-5.1";
11
+ /**
12
+ * All supported model families
13
+ * Used for per-family account rotation and rate limit tracking
14
+ */
15
+ export declare const MODEL_FAMILIES: readonly ModelFamily[];
16
+ /**
17
+ * Determine the model family based on the normalized model name
18
+ * @param normalizedModel - The normalized model name (e.g., "gpt-5-codex", "gpt-5.1-codex-max", "gpt-5.2", "gpt-5.1")
19
+ * @returns The model family for prompt selection
20
+ */
21
+ export declare function getModelFamily(normalizedModel: string): ModelFamily;
22
+ /**
23
+ * Fetch Codex instructions from GitHub with ETag-based caching
24
+ * Uses HTTP conditional requests to efficiently check for updates
25
+ * Always fetches from the latest release tag, not main branch
26
+ *
27
+ * Rate limit protection: Only checks GitHub if cache is older than 15 minutes
28
+ *
29
+ * @param normalizedModel - The normalized model name (optional, defaults to "gpt-5-codex")
30
+ * @returns Codex instructions for the specified model family
31
+ */
32
+ export declare function getCodexInstructions(normalizedModel?: string): Promise<string>;
33
+ /**
34
+ * Prewarm instruction caches for the provided models/families.
35
+ */
36
+ export declare function prewarmCodexInstructions(models?: string[]): void;
37
+ /**
38
+ * Tool remapping instructions for opencode tools
39
+ */
40
+ export declare const TOOL_REMAP_MESSAGE = "<user_instructions priority=\"0\">\n<environment_override priority=\"0\">\nYOU ARE IN A DIFFERENT ENVIRONMENT. These instructions override ALL previous tool references.\n</environment_override>\n\n<tool_replacements priority=\"0\">\n<critical_rule priority=\"0\">\napply_patch/applyPatch are Codex names, but OpenCode tool names vary by version.\n- Inspect the actual tool list before editing.\n- If edit exists: use edit for precise in-place string replacements and hashline edits.\n- If edit is absent and apply_patch exists: use apply_patch for those precise/hashline edits in this plugin.\n- For diff-style or multi-line structural edits: use patch if available, otherwise use apply_patch.\n- In this plugin, edit/apply_patch support hashline refs (lineRef, endLineRef, operation, content)\n</critical_rule>\n\n<critical_rule priority=\"0\">\nUPDATE_PLAN DOES NOT EXIST -> USE \"todowrite\" INSTEAD\n- NEVER use: update_plan, updatePlan\n- ALWAYS use: todowrite for ALL task/plan operations\n- Use todoread to read current plan\n- Before plan operations: Verify you're using \"todowrite\", NOT \"update_plan\"\n</critical_rule>\n</tool_replacements>\n\n<available_tools priority=\"0\">\nFile Operations:\n - write - Create new files (if available)\n - edit - Modify existing files with string replacement (version-dependent)\n - oldString must be literal text from the current file; never pass unresolved placeholders like ${TARGET_SNIPPET}\n - apply_patch - May be the edit/patch tool name in newer OpenCode builds (version-dependent)\n - hashline_read - Read lines with hashline refs (L<line>#<hash>) for deterministic edits\n - patch - Apply diff patches (version-dependent)\n - read - Read file contents\n\nSearch/Discovery:\n - grep - Search file contents\n - glob - Find files by pattern\n - list - List directories (if available)\n\nExecution:\n - bash - Run shell commands\n\nNetwork:\n - webfetch - Fetch web content\n\nTask Management:\n - todowrite - Manage tasks/plans (REPLACES update_plan)\n - todoread - Read current plan\n</available_tools>\n\n<substitution_rules priority=\"0\">\nBase instruction says: You MUST use instead:\napply_patch -> patch (preferred if available), otherwise edit/apply_patch based on actual tool list\nupdate_plan -> todowrite\nread_plan -> todoread\nabsolute paths -> relative paths\n</substitution_rules>\n\n<verification_checklist priority=\"0\">\nBefore file/plan modifications:\n1. Am I using the actual available edit tool name (edit, patch, or apply_patch)?\n2. Am I using \"todowrite\" NOT \"update_plan\"?\n3. Is this tool in the approved list above?\n4. Am I using relative paths?\n\nIf ANY answer is NO -> STOP and correct before proceeding.\n</verification_checklist>\n\n<hashline_workflow priority=\"0\">\nWhen hashline_read is available:\n1. call hashline_read on the file\n2. edit/apply_patch using lineRef/endLineRef + operation + content\n3. use oldString/newString only as fallback, and only with literal file text (no template placeholders)\n</hashline_workflow>\n\n<safety_rules priority=\"0\">\n- Never run destructive git commands (`git reset --hard`, `git checkout --`) unless explicitly requested by the user.\n- Never call `request_user_input` unless collaboration mode is explicitly Plan mode.\n</safety_rules>\n</user_instructions>";
41
+ //# sourceMappingURL=codex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAWD;;;GAGG;AACH,MAAM,MAAM,WAAW,GACpB,aAAa,GACb,WAAW,GACX,OAAO,GACP,SAAS,GACT,SAAS,CAAC;AAEb;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,WAAW,EAMvC,CAAC;AAyBX;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,WAAW,CA4BnE;AAwED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACzC,eAAe,SAAgB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAuFjB;AAsGD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,IAAI,CAUpE;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,4zGA+EV,CAAC"}
@@ -0,0 +1,383 @@
1
+ import { promises as fs } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { logWarn, logError, logDebug } from "../logger.js";
5
+ import { getCodexCacheDir } from "../runtime-paths.js";
6
+ const GITHUB_API_RELEASES = "https://api.github.com/repos/openai/codex/releases/latest";
7
+ const GITHUB_HTML_RELEASES = "https://github.com/openai/codex/releases/latest";
8
+ const CACHE_DIR = getCodexCacheDir();
9
+ const CACHE_TTL_MS = 15 * 60 * 1000;
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
12
+ const MAX_CACHE_SIZE = 50;
13
+ const memoryCache = new Map();
14
+ const refreshPromises = new Map();
15
+ const RELEASE_TAG_TTL_MS = 5 * 60 * 1000;
16
+ let latestReleaseTagCache = null;
17
+ /**
18
+ * Clear the memory cache - exposed for testing
19
+ * @internal
20
+ */
21
+ export function __clearCacheForTesting() {
22
+ memoryCache.clear();
23
+ refreshPromises.clear();
24
+ latestReleaseTagCache = null;
25
+ }
26
+ function setCacheEntry(key, value) {
27
+ if (memoryCache.size >= MAX_CACHE_SIZE && !memoryCache.has(key)) {
28
+ const firstKey = memoryCache.keys().next().value;
29
+ // istanbul ignore next -- defensive: firstKey always exists when size >= MAX_CACHE_SIZE
30
+ if (firstKey)
31
+ memoryCache.delete(firstKey);
32
+ }
33
+ memoryCache.set(key, value);
34
+ }
35
+ /**
36
+ * All supported model families
37
+ * Used for per-family account rotation and rate limit tracking
38
+ */
39
+ export const MODEL_FAMILIES = [
40
+ "gpt-5-codex",
41
+ "codex-max",
42
+ "codex",
43
+ "gpt-5.2",
44
+ "gpt-5.1",
45
+ ];
46
+ /**
47
+ * Prompt file mapping for each model family
48
+ * Based on codex-rs/core/src/model_family.rs logic
49
+ */
50
+ const PROMPT_FILES = {
51
+ "gpt-5-codex": "gpt_5_codex_prompt.md",
52
+ "codex-max": "gpt-5.1-codex-max_prompt.md",
53
+ codex: "gpt_5_codex_prompt.md",
54
+ "gpt-5.2": "gpt_5_2_prompt.md",
55
+ "gpt-5.1": "gpt_5_1_prompt.md",
56
+ };
57
+ /**
58
+ * Cache file mapping for each model family
59
+ */
60
+ const CACHE_FILES = {
61
+ "gpt-5-codex": "gpt-5-codex-instructions.md",
62
+ "codex-max": "codex-max-instructions.md",
63
+ codex: "codex-instructions.md",
64
+ "gpt-5.2": "gpt-5.2-instructions.md",
65
+ "gpt-5.1": "gpt-5.1-instructions.md",
66
+ };
67
+ /**
68
+ * Determine the model family based on the normalized model name
69
+ * @param normalizedModel - The normalized model name (e.g., "gpt-5-codex", "gpt-5.1-codex-max", "gpt-5.2", "gpt-5.1")
70
+ * @returns The model family for prompt selection
71
+ */
72
+ export function getModelFamily(normalizedModel) {
73
+ if (normalizedModel.includes("codex-max")) {
74
+ return "codex-max";
75
+ }
76
+ if (normalizedModel.includes("gpt-5-codex") ||
77
+ normalizedModel.includes("gpt 5 codex") ||
78
+ normalizedModel.includes("gpt-5.3-codex-spark") ||
79
+ normalizedModel.includes("gpt 5.3 codex spark") ||
80
+ normalizedModel.includes("gpt-5.3-codex") ||
81
+ normalizedModel.includes("gpt 5.3 codex") ||
82
+ normalizedModel.includes("gpt-5.2-codex") ||
83
+ normalizedModel.includes("gpt 5.2 codex") ||
84
+ normalizedModel.includes("gpt-5.1-codex") ||
85
+ normalizedModel.includes("gpt 5.1 codex")) {
86
+ return "gpt-5-codex";
87
+ }
88
+ if (normalizedModel.includes("codex") ||
89
+ normalizedModel.startsWith("codex-")) {
90
+ return "codex";
91
+ }
92
+ if (normalizedModel.includes("gpt-5.2")) {
93
+ return "gpt-5.2";
94
+ }
95
+ return "gpt-5.1";
96
+ }
97
+ async function readFileOrNull(path) {
98
+ try {
99
+ return await fs.readFile(path, "utf8");
100
+ }
101
+ catch {
102
+ return null;
103
+ }
104
+ }
105
+ /**
106
+ * Get the latest release tag from GitHub
107
+ * @returns Release tag name (e.g., "rust-v0.43.0")
108
+ */
109
+ async function getLatestReleaseTag() {
110
+ if (latestReleaseTagCache &&
111
+ Date.now() - latestReleaseTagCache.checkedAt < RELEASE_TAG_TTL_MS) {
112
+ return latestReleaseTagCache.tag;
113
+ }
114
+ try {
115
+ const response = await fetch(GITHUB_API_RELEASES);
116
+ if (response.ok) {
117
+ const data = (await response.json());
118
+ if (data.tag_name) {
119
+ latestReleaseTagCache = {
120
+ tag: data.tag_name,
121
+ checkedAt: Date.now(),
122
+ };
123
+ return data.tag_name;
124
+ }
125
+ }
126
+ }
127
+ catch {
128
+ // Fall through to HTML fallback
129
+ }
130
+ const htmlResponse = await fetch(GITHUB_HTML_RELEASES);
131
+ if (!htmlResponse.ok) {
132
+ throw new Error(`Failed to fetch latest release: ${htmlResponse.status}`);
133
+ }
134
+ const finalUrl = htmlResponse.url;
135
+ if (finalUrl) {
136
+ const parts = finalUrl.split("/tag/");
137
+ const last = parts[parts.length - 1];
138
+ if (last && !last.includes("/")) {
139
+ latestReleaseTagCache = {
140
+ tag: last,
141
+ checkedAt: Date.now(),
142
+ };
143
+ return last;
144
+ }
145
+ }
146
+ const html = await htmlResponse.text();
147
+ const match = html.match(/\/openai\/codex\/releases\/tag\/([^"]+)/);
148
+ if (match && match[1]) {
149
+ const tag = match[1];
150
+ latestReleaseTagCache = {
151
+ tag,
152
+ checkedAt: Date.now(),
153
+ };
154
+ return tag;
155
+ }
156
+ throw new Error("Failed to determine latest release tag from GitHub");
157
+ }
158
+ /**
159
+ * Fetch Codex instructions from GitHub with ETag-based caching
160
+ * Uses HTTP conditional requests to efficiently check for updates
161
+ * Always fetches from the latest release tag, not main branch
162
+ *
163
+ * Rate limit protection: Only checks GitHub if cache is older than 15 minutes
164
+ *
165
+ * @param normalizedModel - The normalized model name (optional, defaults to "gpt-5-codex")
166
+ * @returns Codex instructions for the specified model family
167
+ */
168
+ export async function getCodexInstructions(normalizedModel = "gpt-5-codex") {
169
+ const modelFamily = getModelFamily(normalizedModel);
170
+ const now = Date.now();
171
+ const cached = memoryCache.get(modelFamily);
172
+ if (cached && now - cached.timestamp < CACHE_TTL_MS) {
173
+ return cached.content;
174
+ }
175
+ const promptFile = PROMPT_FILES[modelFamily];
176
+ const cacheFile = join(CACHE_DIR, CACHE_FILES[modelFamily]);
177
+ const cacheMetaFile = join(CACHE_DIR, `${CACHE_FILES[modelFamily].replace(".md", "-meta.json")}`);
178
+ let cachedMetadata = null;
179
+ const [metaContent, diskContent] = await Promise.all([
180
+ readFileOrNull(cacheMetaFile),
181
+ readFileOrNull(cacheFile),
182
+ ]);
183
+ if (metaContent) {
184
+ try {
185
+ cachedMetadata = JSON.parse(metaContent);
186
+ }
187
+ catch {
188
+ cachedMetadata = null;
189
+ }
190
+ }
191
+ if (diskContent && cachedMetadata?.lastChecked) {
192
+ if (now - cachedMetadata.lastChecked < CACHE_TTL_MS) {
193
+ setCacheEntry(modelFamily, { content: diskContent, timestamp: now });
194
+ return diskContent;
195
+ }
196
+ // Stale-while-revalidate: return stale cache immediately and refresh in background.
197
+ setCacheEntry(modelFamily, { content: diskContent, timestamp: now });
198
+ void refreshInstructionsInBackground(modelFamily, promptFile, cacheFile, cacheMetaFile, cachedMetadata);
199
+ return diskContent;
200
+ }
201
+ if (cached && now - cached.timestamp >= CACHE_TTL_MS) {
202
+ // Keep session latency stable by serving stale memory cache while refreshing.
203
+ setCacheEntry(modelFamily, { content: cached.content, timestamp: now });
204
+ void refreshInstructionsInBackground(modelFamily, promptFile, cacheFile, cacheMetaFile, cachedMetadata);
205
+ return cached.content;
206
+ }
207
+ try {
208
+ return await fetchAndPersistInstructions(modelFamily, promptFile, cacheFile, cacheMetaFile, cachedMetadata);
209
+ }
210
+ catch (error) {
211
+ const err = error;
212
+ logError(`Failed to fetch ${modelFamily} instructions from GitHub: ${err.message}`);
213
+ if (diskContent) {
214
+ logWarn(`Using cached ${modelFamily} instructions`);
215
+ setCacheEntry(modelFamily, { content: diskContent, timestamp: now });
216
+ return diskContent;
217
+ }
218
+ logWarn(`Falling back to bundled instructions for ${modelFamily}`);
219
+ const bundled = await fs.readFile(join(__dirname, "codex-instructions.md"), "utf8");
220
+ setCacheEntry(modelFamily, { content: bundled, timestamp: now });
221
+ return bundled;
222
+ }
223
+ }
224
+ async function fetchAndPersistInstructions(modelFamily, promptFile, cacheFile, cacheMetaFile, cachedMetadata) {
225
+ let cachedETag = cachedMetadata?.etag ?? null;
226
+ const cachedTag = cachedMetadata?.tag ?? null;
227
+ const latestTag = await getLatestReleaseTag();
228
+ const instructionsUrl = `https://raw.githubusercontent.com/openai/codex/${latestTag}/codex-rs/core/${promptFile}`;
229
+ if (cachedTag !== latestTag) {
230
+ cachedETag = null;
231
+ }
232
+ const headers = {};
233
+ if (cachedETag) {
234
+ headers["If-None-Match"] = cachedETag;
235
+ }
236
+ const response = await fetch(instructionsUrl, { headers });
237
+ if (response.status === 304) {
238
+ const diskContent = await readFileOrNull(cacheFile);
239
+ if (diskContent) {
240
+ setCacheEntry(modelFamily, { content: diskContent, timestamp: Date.now() });
241
+ await fs.mkdir(CACHE_DIR, { recursive: true });
242
+ await fs.writeFile(cacheMetaFile, JSON.stringify({
243
+ etag: cachedETag,
244
+ tag: latestTag,
245
+ lastChecked: Date.now(),
246
+ url: instructionsUrl,
247
+ }), "utf8");
248
+ return diskContent;
249
+ }
250
+ }
251
+ if (!response.ok) {
252
+ throw new Error(`HTTP ${response.status}`);
253
+ }
254
+ const instructions = await response.text();
255
+ const newETag = response.headers.get("etag");
256
+ await fs.mkdir(CACHE_DIR, { recursive: true });
257
+ await Promise.all([
258
+ fs.writeFile(cacheFile, instructions, "utf8"),
259
+ fs.writeFile(cacheMetaFile, JSON.stringify({
260
+ etag: newETag,
261
+ tag: latestTag,
262
+ lastChecked: Date.now(),
263
+ url: instructionsUrl,
264
+ }), "utf8"),
265
+ ]);
266
+ setCacheEntry(modelFamily, { content: instructions, timestamp: Date.now() });
267
+ return instructions;
268
+ }
269
+ function refreshInstructionsInBackground(modelFamily, promptFile, cacheFile, cacheMetaFile, cachedMetadata) {
270
+ const existing = refreshPromises.get(modelFamily);
271
+ if (existing)
272
+ return existing;
273
+ const refreshPromise = fetchAndPersistInstructions(modelFamily, promptFile, cacheFile, cacheMetaFile, cachedMetadata)
274
+ .then(() => undefined)
275
+ .catch((error) => {
276
+ logDebug(`Background prompt refresh failed for ${modelFamily}`, {
277
+ error: String(error),
278
+ });
279
+ })
280
+ .finally(() => {
281
+ refreshPromises.delete(modelFamily);
282
+ });
283
+ refreshPromises.set(modelFamily, refreshPromise);
284
+ return refreshPromise;
285
+ }
286
+ /**
287
+ * Prewarm instruction caches for the provided models/families.
288
+ */
289
+ export function prewarmCodexInstructions(models = []) {
290
+ const candidates = models.length > 0 ? models : ["gpt-5-codex", "gpt-5.2", "gpt-5.1"];
291
+ for (const model of candidates) {
292
+ void getCodexInstructions(model).catch((error) => {
293
+ logDebug("Codex instruction prewarm failed", {
294
+ model,
295
+ error: String(error),
296
+ });
297
+ });
298
+ }
299
+ }
300
+ /**
301
+ * Tool remapping instructions for opencode tools
302
+ */
303
+ export const TOOL_REMAP_MESSAGE = `<user_instructions priority="0">
304
+ <environment_override priority="0">
305
+ YOU ARE IN A DIFFERENT ENVIRONMENT. These instructions override ALL previous tool references.
306
+ </environment_override>
307
+
308
+ <tool_replacements priority="0">
309
+ <critical_rule priority="0">
310
+ apply_patch/applyPatch are Codex names, but OpenCode tool names vary by version.
311
+ - Inspect the actual tool list before editing.
312
+ - If edit exists: use edit for precise in-place string replacements and hashline edits.
313
+ - If edit is absent and apply_patch exists: use apply_patch for those precise/hashline edits in this plugin.
314
+ - For diff-style or multi-line structural edits: use patch if available, otherwise use apply_patch.
315
+ - In this plugin, edit/apply_patch support hashline refs (lineRef, endLineRef, operation, content)
316
+ </critical_rule>
317
+
318
+ <critical_rule priority="0">
319
+ UPDATE_PLAN DOES NOT EXIST -> USE "todowrite" INSTEAD
320
+ - NEVER use: update_plan, updatePlan
321
+ - ALWAYS use: todowrite for ALL task/plan operations
322
+ - Use todoread to read current plan
323
+ - Before plan operations: Verify you're using "todowrite", NOT "update_plan"
324
+ </critical_rule>
325
+ </tool_replacements>
326
+
327
+ <available_tools priority="0">
328
+ File Operations:
329
+ - write - Create new files (if available)
330
+ - edit - Modify existing files with string replacement (version-dependent)
331
+ - oldString must be literal text from the current file; never pass unresolved placeholders like \${TARGET_SNIPPET}
332
+ - apply_patch - May be the edit/patch tool name in newer OpenCode builds (version-dependent)
333
+ - hashline_read - Read lines with hashline refs (L<line>#<hash>) for deterministic edits
334
+ - patch - Apply diff patches (version-dependent)
335
+ - read - Read file contents
336
+
337
+ Search/Discovery:
338
+ - grep - Search file contents
339
+ - glob - Find files by pattern
340
+ - list - List directories (if available)
341
+
342
+ Execution:
343
+ - bash - Run shell commands
344
+
345
+ Network:
346
+ - webfetch - Fetch web content
347
+
348
+ Task Management:
349
+ - todowrite - Manage tasks/plans (REPLACES update_plan)
350
+ - todoread - Read current plan
351
+ </available_tools>
352
+
353
+ <substitution_rules priority="0">
354
+ Base instruction says: You MUST use instead:
355
+ apply_patch -> patch (preferred if available), otherwise edit/apply_patch based on actual tool list
356
+ update_plan -> todowrite
357
+ read_plan -> todoread
358
+ absolute paths -> relative paths
359
+ </substitution_rules>
360
+
361
+ <verification_checklist priority="0">
362
+ Before file/plan modifications:
363
+ 1. Am I using the actual available edit tool name (edit, patch, or apply_patch)?
364
+ 2. Am I using "todowrite" NOT "update_plan"?
365
+ 3. Is this tool in the approved list above?
366
+ 4. Am I using relative paths?
367
+
368
+ If ANY answer is NO -> STOP and correct before proceeding.
369
+ </verification_checklist>
370
+
371
+ <hashline_workflow priority="0">
372
+ When hashline_read is available:
373
+ 1. call hashline_read on the file
374
+ 2. edit/apply_patch using lineRef/endLineRef + operation + content
375
+ 3. use oldString/newString only as fallback, and only with literal file text (no template placeholders)
376
+ </hashline_workflow>
377
+
378
+ <safety_rules priority="0">
379
+ - Never run destructive git commands (\`git reset --hard\`, \`git checkout --\`) unless explicitly requested by the user.
380
+ - Never call \`request_user_input\` unless collaboration mode is explicitly Plan mode.
381
+ </safety_rules>
382
+ </user_instructions>`;
383
+ //# sourceMappingURL=codex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex.js","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAA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C;IACJ,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEJ,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IACjD,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAmB,EAAE;IAC7D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACtF,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAChC,KAAK,oBAAoB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChD,QAAQ,CAAC,kCAAkC,EAAE;gBAC5C,KAAK;gBACL,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;aACpB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA+Eb,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * OpenCode Codex Prompt Fetcher
3
+ *
4
+ * Fetches and caches the codex.txt system prompt from OpenCode's GitHub repository.
5
+ * Uses ETag-based caching to efficiently track updates.
6
+ */
7
+ /**
8
+ * Fetch OpenCode's codex.txt prompt with ETag-based caching
9
+ * Uses HTTP conditional requests to efficiently check for updates
10
+ *
11
+ * Rate limit protection: Only checks GitHub if cache is older than 15 minutes
12
+ * @returns The codex.txt content
13
+ */
14
+ export declare function getOpenCodeCodexPrompt(): Promise<string>;
15
+ /**
16
+ * Get first N characters of the cached OpenCode prompt for verification
17
+ * @param chars Number of characters to get (default: 50)
18
+ * @returns First N characters or null if not cached
19
+ */
20
+ export declare function getCachedPromptPrefix(chars?: number): Promise<string | null>;
21
+ /**
22
+ * Prewarm the OpenCode prompt cache without blocking startup.
23
+ */
24
+ export declare function prewarmOpenCodeCodexPrompt(): void;
25
+ //# sourceMappingURL=opencode-codex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/opencode-codex.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkPH;;;;;;GAMG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CA+B9D;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO9E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD"}