cuelo 0.10.331 โ†’ 0.10.333

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 (160) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +56 -56
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/_not-found.html +1 -1
  18. package/.next/server/app/_not-found.rsc +2 -2
  19. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  22. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  25. package/.next/server/app/api/agent/[id]/account/route.js +1 -1
  26. package/.next/server/app/api/agent/[id]/account/route.js.nft.json +1 -1
  27. package/.next/server/app/api/agent/[id]/computer-takeover/route.js +1 -1
  28. package/.next/server/app/api/agent/[id]/computer-takeover/route.js.nft.json +1 -1
  29. package/.next/server/app/api/agent/[id]/events/route.js +1 -1
  30. package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -1
  31. package/.next/server/app/api/agent/[id]/route.js +1 -1
  32. package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -1
  33. package/.next/server/app/api/agent/new/route.js +1 -1
  34. package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
  35. package/.next/server/app/api/agent/running/route.js +1 -1
  36. package/.next/server/app/api/agent/running/route.js.nft.json +1 -1
  37. package/.next/server/app/api/gpt6/handles/route.js +1 -1
  38. package/.next/server/app/api/gpt6/handles/route.js.nft.json +1 -1
  39. package/.next/server/app/api/gpt6/reply/route.js +1 -1
  40. package/.next/server/app/api/gpt6/reply/route.js.nft.json +1 -1
  41. package/.next/server/app/api/gpt6/token/route.js +1 -1
  42. package/.next/server/app/api/gpt6/token/route.js.nft.json +1 -1
  43. package/.next/server/app/api/gpt6/web6-session/route.js +1 -1
  44. package/.next/server/app/api/gpt6/web6-session/route.js.nft.json +1 -1
  45. package/.next/server/app/api/live/call/[callId]/route.js +1 -1
  46. package/.next/server/app/api/live/call/[callId]/route.js.nft.json +1 -1
  47. package/.next/server/app/api/live/draft-secret/route.js +1 -1
  48. package/.next/server/app/api/live/draft-secret/route.js.nft.json +1 -1
  49. package/.next/server/app/api/live/events/route.js +1 -1
  50. package/.next/server/app/api/live/events/route.js.nft.json +1 -1
  51. package/.next/server/app/api/live/interpret/assist/route.js +1 -1
  52. package/.next/server/app/api/live/interpret/assist/route.js.nft.json +1 -1
  53. package/.next/server/app/api/live/interpret/reading/route.js +1 -1
  54. package/.next/server/app/api/live/interpret/reading/route.js.nft.json +1 -1
  55. package/.next/server/app/api/live/interpret/route.js +1 -1
  56. package/.next/server/app/api/live/interpret/route.js.nft.json +1 -1
  57. package/.next/server/app/api/live/interpret/scan/route.js +1 -1
  58. package/.next/server/app/api/live/interpret/scan/route.js.nft.json +1 -1
  59. package/.next/server/app/api/live/interpret/text/route.js +1 -1
  60. package/.next/server/app/api/live/interpret/text/route.js.nft.json +1 -1
  61. package/.next/server/app/api/live/offer/route.js +1 -1
  62. package/.next/server/app/api/live/offer/route.js.nft.json +1 -1
  63. package/.next/server/app/api/live/voices/route.js +1 -1
  64. package/.next/server/app/api/live/voices/route.js.nft.json +1 -1
  65. package/.next/server/app/api/project-trust/route.js +1 -1
  66. package/.next/server/app/api/project-trust/route.js.nft.json +1 -1
  67. package/.next/server/app/api/runs/[runId]/prelude/route.js +1 -1
  68. package/.next/server/app/api/runs/[runId]/prelude/route.js.nft.json +1 -1
  69. package/.next/server/app/api/sessions/[id]/auto-name/route.js +1 -1
  70. package/.next/server/app/api/sessions/[id]/auto-name/route.js.nft.json +1 -1
  71. package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
  72. package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +1 -1
  73. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  74. package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
  75. package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
  76. package/.next/server/app/api/sessions/[id]/state/route.js.nft.json +1 -1
  77. package/.next/server/app/api/sessions/route.js +1 -1
  78. package/.next/server/app/api/sessions/route.js.nft.json +1 -1
  79. package/.next/server/app/api/skills/check/route.js +1 -1
  80. package/.next/server/app/api/skills/check/route.js.nft.json +1 -1
  81. package/.next/server/app/api/skills/install/route.js +1 -1
  82. package/.next/server/app/api/skills/install/route.js.nft.json +1 -1
  83. package/.next/server/app/api/skills/route.js +1 -1
  84. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  85. package/.next/server/app/api/skills/update/route.js +1 -1
  86. package/.next/server/app/api/skills/update/route.js.nft.json +1 -1
  87. package/.next/server/app/api/tool-image/route.js +1 -1
  88. package/.next/server/app/api/tool-image/route.js.nft.json +1 -1
  89. package/.next/server/app/api/update-maintenance/route.js +1 -1
  90. package/.next/server/app/api/update-maintenance/route.js.nft.json +1 -1
  91. package/.next/server/app/api/updates/apply/route.js +2 -2
  92. package/.next/server/app/api/updates/route.js +1 -1
  93. package/.next/server/app/api/upkeep/check/route.js +1 -1
  94. package/.next/server/app/api/upkeep/check/route.js.nft.json +1 -1
  95. package/.next/server/app/api/upkeep/morning/route.js +2 -3
  96. package/.next/server/app/api/upkeep/morning/route.js.nft.json +1 -1
  97. package/.next/server/app/api/upkeep/nightly/export/route.js +1 -1
  98. package/.next/server/app/api/upkeep/nightly/export/route.js.nft.json +1 -1
  99. package/.next/server/app/api/upkeep/nightly/result/route.js +1 -2
  100. package/.next/server/app/api/upkeep/nightly/result/route.js.nft.json +1 -1
  101. package/.next/server/app/api/upkeep/nightly/route.js +1 -2
  102. package/.next/server/app/api/upkeep/nightly/route.js.nft.json +1 -1
  103. package/.next/server/app/api/upkeep/route.js +1 -1
  104. package/.next/server/app/api/upkeep/route.js.nft.json +1 -1
  105. package/.next/server/app/api/worktrees/route.js +1 -1
  106. package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
  107. package/.next/server/app/index.html +1 -1
  108. package/.next/server/app/index.rsc +4 -4
  109. package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  110. package/.next/server/app/index.segments/_full.segment.rsc +4 -4
  111. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  112. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  113. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  114. package/.next/server/app/page.js +2 -2
  115. package/.next/server/app/page_client-reference-manifest.js +1 -1
  116. package/.next/server/app/recover/page_client-reference-manifest.js +1 -1
  117. package/.next/server/app/recover.html +1 -1
  118. package/.next/server/app/recover.rsc +2 -2
  119. package/.next/server/app/recover.segments/_full.segment.rsc +2 -2
  120. package/.next/server/app/recover.segments/_head.segment.rsc +1 -1
  121. package/.next/server/app/recover.segments/_index.segment.rsc +2 -2
  122. package/.next/server/app/recover.segments/_tree.segment.rsc +1 -1
  123. package/.next/server/app/recover.segments/recover/__PAGE__.segment.rsc +1 -1
  124. package/.next/server/app/recover.segments/recover.segment.rsc +1 -1
  125. package/.next/server/app-paths-manifest.json +56 -56
  126. package/.next/server/chunks/2235.js +2 -0
  127. package/.next/server/chunks/3173.js +3 -0
  128. package/.next/server/chunks/3392.js +2 -0
  129. package/.next/server/chunks/4831.js +1 -1
  130. package/.next/server/chunks/5228.js +1 -1
  131. package/.next/server/chunks/8041.js +1 -6
  132. package/.next/server/chunks/{6119.js โ†’ 8094.js} +1 -1
  133. package/.next/server/chunks/8685.js +2 -2
  134. package/.next/server/chunks/9467.js +2 -3
  135. package/.next/server/middleware-build-manifest.js +1 -1
  136. package/.next/server/pages/404.html +1 -1
  137. package/.next/server/pages/500.html +1 -1
  138. package/.next/server/server-reference-manifest.json +1 -1
  139. package/.next/static/chunks/app/{layout-bc3824f2c0eebb33.js โ†’ layout-b2da0140cc733ca6.js} +1 -1
  140. package/.next/static/chunks/app/{page-9e999c92e12dc19c.js โ†’ page-2affef230bc901fc.js} +2 -2
  141. package/.next/trace +113 -113
  142. package/.next/trace-build +1 -1
  143. package/README.md +1 -1
  144. package/Tools/CUELO_Setup/files/native-runtime-patch.js +1 -1
  145. package/Tools/OMP_Global_Config/agent/extensions/lib/finalize-checks.ts +353 -0
  146. package/Tools/OMP_Global_Config/agent/extensions/lib/interpreter.ts +12 -6
  147. package/Tools/OMP_Global_Config/agent/extensions/todo-nudge.ts +48 -14
  148. package/Tools/OMP_Global_Config/agent/tools/ego-browser/index.ts +19 -4
  149. package/Tools/OMP_Global_Config/agent/tools/git-finalizer/finalizer.ps1 +11 -1
  150. package/Tools/OMP_Global_Config/agent/tools/git-finalizer/index.ts +89 -21
  151. package/Tools/OMP_Global_Config/agent/tools/git-finalizer/integrate.ts +66 -11
  152. package/Tools/OMP_Global_Config/patches/apply-core-patch.mjs +97 -0
  153. package/bin/ci-local.mjs +291 -0
  154. package/install.mjs +124 -10
  155. package/package.json +3 -2
  156. package/.next/server/chunks/4259.js +0 -2
  157. package/.next/server/chunks/8139.js +0 -3
  158. package/Tools/OMP_Global_Config/agent/extensions/user-input-interpreter.ts +0 -130
  159. /package/.next/static/{qYIo9_tHAFFQaFxpOUmz_ โ†’ UerdzBExCL9nskNG-lvSd}/_buildManifest.js +0 -0
  160. /package/.next/static/{qYIo9_tHAFFQaFxpOUmz_ โ†’ UerdzBExCL9nskNG-lvSd}/_ssgManifest.js +0 -0
package/.next/trace-build CHANGED
@@ -1 +1 @@
1
- [{"name":"run-webpack","duration":84096676,"timestamp":387143,"id":14,"parentId":1,"tags":{},"startTime":1795145644397,"traceId":"f00720b2c07d0bfa"},{"name":"run-typescript","duration":18587350,"timestamp":84867631,"id":11560,"parentId":1,"tags":{},"startTime":1795145728877,"traceId":"f00720b2c07d0bfa"},{"name":"static-check","duration":2696291,"timestamp":103537096,"id":11563,"parentId":1,"tags":{},"startTime":1795145747547,"traceId":"f00720b2c07d0bfa"},{"name":"static-generation","duration":6562596,"timestamp":106319612,"id":11781,"parentId":1,"tags":{},"startTime":1795145750329,"traceId":"f00720b2c07d0bfa"},{"name":"collect-build-traces","duration":16996645,"timestamp":106301980,"id":11778,"parentId":1,"tags":{},"startTime":1795145750312,"traceId":"f00720b2c07d0bfa"},{"name":"telemetry-flush","duration":56,"timestamp":123302281,"id":11790,"parentId":1,"tags":{},"startTime":1795145767312,"traceId":"f00720b2c07d0bfa"},{"name":"next-build","duration":122982488,"timestamp":319874,"id":1,"tags":{"buildMode":"default","version":"16.2.12","bundler":"webpack","has-custom-webpack-config":"true","use-build-worker":"false"},"startTime":1795145644329,"traceId":"f00720b2c07d0bfa"}]
1
+ [{"name":"run-webpack","duration":67641037,"timestamp":343719,"id":14,"parentId":1,"tags":{},"startTime":1795191741394,"traceId":"564173344e4e651e"},{"name":"run-typescript","duration":15767195,"timestamp":68363276,"id":11561,"parentId":1,"tags":{},"startTime":1795191809414,"traceId":"564173344e4e651e"},{"name":"static-check","duration":2325910,"timestamp":84206400,"id":11564,"parentId":1,"tags":{},"startTime":1795191825257,"traceId":"564173344e4e651e"},{"name":"static-generation","duration":5726920,"timestamp":86614801,"id":11782,"parentId":1,"tags":{},"startTime":1795191827666,"traceId":"564173344e4e651e"},{"name":"collect-build-traces","duration":14750427,"timestamp":86601016,"id":11779,"parentId":1,"tags":{},"startTime":1795191827652,"traceId":"564173344e4e651e"},{"name":"telemetry-flush","duration":72,"timestamp":101354663,"id":11791,"parentId":1,"tags":{},"startTime":1795191842405,"traceId":"564173344e4e651e"},{"name":"next-build","duration":101068697,"timestamp":286060,"id":1,"tags":{"buildMode":"default","version":"16.2.12","bundler":"webpack","has-custom-webpack-config":"true","use-build-worker":"false"},"startTime":1795191741337,"traceId":"564173344e4e651e"}]
package/README.md CHANGED
@@ -376,7 +376,7 @@ bun bin/cuelo.js --reset-password # ๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •
376
376
 
377
377
  ์œ„ ์กฐ๊ฑด์„ ํ•˜๋‚˜๋ผ๋„ ๋งŒ์กฑํ•˜์ง€ ๋ชปํ•˜๊ฑฐ๋‚˜ ์„ค์น˜ ๋ฐฉ์‹์„ ์•Œ์•„๋ณผ ์ˆ˜ ์—†์œผ๋ฉด ๋ฒ„ํŠผ ๋Œ€์‹  ์ˆ˜๋™ ๋ช…๋ น์„ ํ™”๋ฉด์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ์„œ๋ฒ„(๋˜๋Š” ๊ฐœ๋ฐœ ์„œ๋ฒ„)๋ฅผ ๋จผ์ € ๋ฉˆ์ถ˜ ๋’ค `git pull --ff-only && node install.mjs setup`์„ ์‹คํ–‰ํ•˜์„ธ์š”. `setup`์ด ์‹คํ–‰ ์ค‘์ธ ์„œ๋ฒ„๊ฐ€ ์ฝ๋Š” `.next/` ๋นŒ๋“œ ํด๋”๋ฅผ ์ƒˆ๋กœ ๋งŒ๋“ค๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. `setup`์€ `bun install --frozen-lockfile`, SDK ์†Œ์Šค ์ค€๋น„, ๋นŒ๋“œ, ํŒจ์น˜์™€ ๊ณ ์ง€๋ฌธ ์ ์šฉยท๊ฒ€์‚ฌ๋ฅผ ์ฐจ๋ก€๋กœ ํ•ฉ๋‹ˆ๋‹ค. ๋๋‚˜๋ฉด `node install.mjs start`๋กœ ์„œ๋ฒ„๋ฅผ ๋‹ค์‹œ ์ผญ๋‹ˆ๋‹ค. `--home <dir>`๋กœ ์‹œ์ž‘ํ–ˆ๋‹ค๋ฉด `node install.mjs setup --home <dir>`์ฒ˜๋Ÿผ ๊ฐ™์€ ์˜ต์…˜์„ ๋ถ™์ด์„ธ์š”.
378
378
 
379
- ์•ฑ ์—…๋ฐ์ดํŠธ์™€ ํ”„๋กœํ•„(ํ•˜๋„ค์Šค) ์—…๋ฐ์ดํŠธ๋Š” ๋”ฐ๋กœ์ž…๋‹ˆ๋‹ค. ์•ฑ์„ ์—…๋ฐ์ดํŠธํ•ด๋„ ๊ธฐ์กด ํ”„๋กœํ•„์˜ ํ•˜๋„ค์Šคยท์—ญํ•  ์„ค์ •์€ ๋ฎ์–ด์“ฐ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ƒˆ ๋ฒ„์ „์˜ ํ•˜๋„ค์Šค๋Š” `node install.mjs harness-diff`๋กœ ์ฐจ์ด๋ฅผ ๋ณด๊ณ  `node install.mjs harness-update`๋กœ ๋ฐ˜์˜ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ๊ณ ์น˜์ง€ ์•Š์€ ํŒŒ์ผ๋งŒ ๋ฐฑ์—… ํ›„ ๋ฐ”๊พธ๊ณ , ๊ณ ์นœ ํŒŒ์ผ๊ณผ `config.yml`์€ ๊ทธ๋Œ€๋กœ ๋‘ก๋‹ˆ๋‹ค([๊ธฐ์กด ํ”„๋กœํ•„์˜ ํ•˜๋„ค์Šค ๊ฐฑ์‹ ](./docs/installation.md#๊ธฐ์กด-ํ”„๋กœํ•„์˜-ํ•˜๋„ค์Šค-๊ฐฑ์‹ )). ๋ฐ˜์˜ ํ›„ CUELO์™€ `omp`๋ฅผ ๋‹ค์‹œ ์‹œ์ž‘ํ•˜์„ธ์š”.
379
+ ์•ฑ ์—…๋ฐ์ดํŠธ์™€ ํ”„๋กœํ•„(ํ•˜๋„ค์Šค) ์—…๋ฐ์ดํŠธ๋Š” ๋”ฐ๋กœ์ž…๋‹ˆ๋‹ค. ์•ฑ์„ ์—…๋ฐ์ดํŠธํ•ด๋„ ๊ธฐ์กด ํ”„๋กœํ•„์˜ ํ•˜๋„ค์Šคยท์—ญํ•  ์„ค์ •์€ ๋ฎ์–ด์“ฐ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ƒˆ ๋ฒ„์ „์˜ ํ•˜๋„ค์Šค๋Š” `node install.mjs harness-diff`๋กœ ์ฐจ์ด๋ฅผ ๋ณด๊ณ  `node install.mjs harness-update`๋กœ ๋ฐ˜์˜ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ๊ณ ์น˜์ง€ ์•Š์€ ํŒŒ์ผ๋งŒ ๋ฐฑ์—… ํ›„ ๋ฐ”๊พธ๊ณ , ์ƒˆ ๋ฒ„์ „์ด ๋”๋Š” ๋ฐฐํฌํ•˜์ง€ ์•Š๋Š” ํŒŒ์ผ๋„ CUELO๊ฐ€ ์„ค์น˜ํ•œ ๊ทธ๋Œ€๋กœ์ผ ๋•Œ๋งŒ ๋ฐฑ์—… ํ›„ ์ง€์›๋‹ˆ๋‹ค. ๊ณ ์นœ ํŒŒ์ผ๊ณผ `config.yml`์€ ๊ทธ๋Œ€๋กœ ๋‘ก๋‹ˆ๋‹ค([๊ธฐ์กด ํ”„๋กœํ•„์˜ ํ•˜๋„ค์Šค ๊ฐฑ์‹ ](./docs/installation.md#๊ธฐ์กด-ํ”„๋กœํ•„์˜-ํ•˜๋„ค์Šค-๊ฐฑ์‹ )). ๋ฐ˜์˜ ํ›„ CUELO์™€ `omp`๋ฅผ ๋‹ค์‹œ ์‹œ์ž‘ํ•˜์„ธ์š”.
380
380
 
381
381
  ์—…๋ฐ์ดํŠธ ๋Œ€๊ธฐ ํ™”๋ฉด์—์„œ ์‹คํŒจ๊ฐ€ ํ™•์ธ๋˜๋”๋ผ๋„ ์„œ๋ฒ„๊ฐ€ ๋‹ค์‹œ ์š”์ฒญ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๊ณ  ์›๋ž˜ ๋Œ€ํ™”๊ฐ€ ํ™•์ธ๋˜๋ฉด ๊ทธ ๋Œ€ํ™”๋กœ ์ž๋™ ๋ณต๊ท€ํ•ฉ๋‹ˆ๋‹ค. ๋ณต๊ท€ํ•œ ํ™”๋ฉด์€ ์ง„ํ–‰ ์ค‘์ธ ๋‹ต๋ณ€์ด๋‚˜ ์ด๋ฏธ ๋๋‚œ ์‹คํŒจ ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ผ์žก์œผ๋ฉฐ, ๋ณต๊ท€ ์ž์ฒด๊ฐ€ ๋ช…๋ น์„ ๋‹ค์‹œ ๋ณด๋‚ด์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค.
382
382
 
@@ -9,7 +9,7 @@ const MEMORY_RE = /(const phase1Model = await resolveMemoryModel\(\{[^}]*?fallba
9
9
  const MEMORY_DONE = /const phase1Model = await resolveMemoryModel\(\{[^}]*?fallbackRole: "smol"/;
10
10
  const EXPECTED = {
11
11
  name: 'cuelo',
12
- version: '0.10.331',
12
+ version: '0.10.333',
13
13
  distribution: 'cuelo',
14
14
  coreVersion: '19.0.1',
15
15
  };
@@ -0,0 +1,353 @@
1
+ import { execFile, spawn } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import { lstat, mkdir, mkdtemp, open, readFile, readlink, realpath, writeFile } from "node:fs/promises";
4
+ import { isAbsolute, join, relative, resolve, sep } from "node:path";
5
+ import type { CustomToolContext } from "@oh-my-pi/pi-coding-agent";
6
+ import { Process } from "@oh-my-pi/pi-natives";
7
+ import { getAgentDir } from "@oh-my-pi/pi-utils";
8
+ import { spawnExec, type Exec } from "./cross-review";
9
+
10
+ export const FINALIZE_CHECKS_CONFIG = ".finalize-checks.json";
11
+ const DEFAULT_TIMEOUT_SECONDS = 1_200;
12
+ const MAX_TIMER_MS = 2_147_483_647;
13
+ const TERMINATION_GRACE_MS = 10_000;
14
+ const TAIL_BYTES = 12_000;
15
+
16
+ type Check = { name: string; paths: string[]; command: [string, ...string[]]; timeoutSeconds: number };
17
+ type CheckResult = { name: string; seconds: number; reused: boolean };
18
+ export type FinalizeChecksResult = { checks: CheckResult[]; waiver?: string };
19
+
20
+ type Options = {
21
+ root: string;
22
+ files: readonly string[] | (() => Promise<string[]>);
23
+ sessionManager?: CustomToolContext["sessionManager"];
24
+ ledgerDir?: string;
25
+ waiver?: string;
26
+ authorize?: () => Promise<void>;
27
+ signal?: AbortSignal;
28
+ git?: string;
29
+ exec?: Exec;
30
+ showDirtyTracked?: boolean;
31
+ };
32
+
33
+ function objectWithKeys(value: unknown, keys: string[]): value is Record<string, unknown> {
34
+ return value !== null && typeof value === "object" && !Array.isArray(value)
35
+ && Object.keys(value).every((key) => keys.includes(key));
36
+ }
37
+
38
+ function validPath(value: unknown): value is string {
39
+ return typeof value === "string" && !/[\\\0\r\n]/.test(value) && !/^[A-Za-z]:/.test(value)
40
+ && value.replace(/\/$/, "").split("/").every((part) => part !== "" && part !== "." && part !== "..");
41
+ }
42
+
43
+ async function loadConfig(path: string): Promise<{ source: string; checks: Check[] } | undefined> {
44
+ try {
45
+ const stat = await lstat(path).catch((error: NodeJS.ErrnoException) => {
46
+ if (error.code !== "ENOENT") throw error;
47
+ return undefined;
48
+ });
49
+ if (!stat) return undefined;
50
+ if (!stat.isFile()) throw new Error("expected a regular file");
51
+ const source = await readFile(path, "utf8");
52
+ const config: unknown = JSON.parse(source);
53
+ if (!objectWithKeys(config, ["version", "checks"]) || config.version !== 1 || !Array.isArray(config.checks)) {
54
+ throw new Error("expected version 1 and a checks array");
55
+ }
56
+ const names = new Set<string>();
57
+ const checks = config.checks.map((entry: unknown, index: number): Check => {
58
+ if (!objectWithKeys(entry, ["name", "paths", "command", "timeoutSeconds"])) throw new Error(`checks[${index}] has unknown fields or is not an object`);
59
+ const { name, paths, command, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS } = entry;
60
+ if (typeof name !== "string" || name.trim() !== name || !name || /[\x00-\x1f\x7f]/.test(name) || names.has(name)) {
61
+ throw new Error(`checks[${index}].name must be a unique, non-empty name`);
62
+ }
63
+ if (!Array.isArray(paths) || paths.length === 0 || !paths.every(validPath)) throw new Error(`check ${name}: paths must contain repository-relative file paths or directory prefixes ending in /`);
64
+ if (!Array.isArray(command) || command.length === 0 || !command.every((arg) => typeof arg === "string" && !arg.includes("\0")) || !command[0].trim()) {
65
+ throw new Error(`check ${name}: command must be a non-empty argv array with an executable`);
66
+ }
67
+ if (typeof timeoutSeconds !== "number" || !Number.isSafeInteger(timeoutSeconds) || timeoutSeconds < 1) {
68
+ throw new Error(`check ${name}: timeoutSeconds must be a positive integer`);
69
+ }
70
+ names.add(name);
71
+ return { name, paths, command: command as Check["command"], timeoutSeconds };
72
+ });
73
+ return { source, checks };
74
+ } catch (error) {
75
+ throw new Error(`${path}: ${error instanceof Error ? error.message : String(error)}`);
76
+ }
77
+ }
78
+
79
+ function matches(paths: readonly string[], file: string): boolean {
80
+ if (process.platform === "win32") file = file.toLowerCase();
81
+ return paths.some((path) => {
82
+ if (process.platform === "win32") path = path.toLowerCase();
83
+ return path.endsWith("/") ? file.startsWith(path) : file === path;
84
+ });
85
+ }
86
+
87
+ async function fileFingerprint(root: string, path: string, checkPaths: readonly string[]): Promise<{ value: string; opaque?: true }> {
88
+ const absolute = join(root, path);
89
+ const info = await lstat(absolute).catch((error: NodeJS.ErrnoException) => {
90
+ if (error.code !== "ENOENT") throw error;
91
+ return undefined;
92
+ });
93
+ if (!info) return { value: "missing" };
94
+ const link = info.isSymbolicLink() ? (await readlink(absolute, { encoding: "buffer" })).toString("base64") : "";
95
+ if (!link && !info.isFile()) return { value: `non-file:${info.mode}`, opaque: true };
96
+ const real = await realpath(absolute).catch((error: NodeJS.ErrnoException) => {
97
+ if (link && error.code === "ENOENT") return undefined;
98
+ throw error;
99
+ });
100
+ const within = real && relative(root, real);
101
+ if (within === undefined || isAbsolute(within) || within === ".." || within.startsWith(`..${sep}`)) {
102
+ // The link itself is known even when its target cannot be treated as a repository input.
103
+ return { value: `${real === undefined ? "dangling" : "external"}:${link}`, ...(link && !matches(checkPaths, path) ? {} : { opaque: true }) };
104
+ }
105
+ if (!real) throw new Error("no resolved path");
106
+ const realInfo = await lstat(real, { bigint: true });
107
+ if (!realInfo.isFile()) return { value: `${link}:non-file:${realInfo.mode}`, opaque: true };
108
+ const handle = await open(real, "r");
109
+ try {
110
+ const before = await handle.stat({ bigint: true });
111
+ if (!before.isFile()) throw new Error("file type changed while opening it");
112
+ const hash = createHash("sha256");
113
+ for await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk);
114
+ const after = await lstat(real, { bigint: true });
115
+ if (before.ino !== after.ino || before.dev !== after.dev || before.mode !== after.mode || before.ctimeNs !== after.ctimeNs || before.mtimeNs !== after.mtimeNs || before.size !== after.size) {
116
+ throw new Error("file changed while being read");
117
+ }
118
+ return { value: `${link}:${after.mode}:${hash.digest("hex")}` };
119
+ } finally {
120
+ await handle.close();
121
+ }
122
+ }
123
+
124
+ type ReadGit = (args: string[]) => ReturnType<Exec>;
125
+ type Snapshot = { hash: string; complete: boolean };
126
+
127
+ /** Hash raw working bytes rather than `git diff`, which can hide changes behind clean filters and index flags. */
128
+ async function fingerprint(root: string, files: readonly string[], paths: readonly string[], git: ReadGit, signal?: AbortSignal): Promise<Snapshot | undefined> {
129
+ try {
130
+ const [head, tracked, committed, untracked] = await Promise.all([
131
+ git(["rev-parse", "--verify", "HEAD"]),
132
+ git(["ls-files", "--stage", "-z"]),
133
+ git(["ls-tree", "--full-tree", "--name-only", "-r", "-z", "HEAD"]),
134
+ git(["-c", "core.untrackedCache=false", "ls-files", "--others", "--exclude-standard", "-z"]),
135
+ ]);
136
+ if ([head, tracked, committed, untracked].some((result) => result.code !== 0)) return undefined;
137
+ // Include HEAD paths even when a deletion is already staged and the path is absent from the index.
138
+ const inputs = new Set([FINALIZE_CHECKS_CONFIG, ...files]);
139
+ let complete = true;
140
+ for (const path of committed.stdout.split("\0")) if (path) inputs.add(path);
141
+ for (const entry of tracked.stdout.split("\0")) {
142
+ if (!entry) continue;
143
+ const tab = entry.indexOf("\t");
144
+ if (tab < 0) return undefined;
145
+ if (!entry.slice(0, tab).endsWith(" 0") || entry.startsWith("160000 ")) complete = false;
146
+ inputs.add(entry.slice(tab + 1));
147
+ }
148
+ for (const path of untracked.stdout.split("\0")) if (path && matches(paths, path)) inputs.add(path);
149
+ const hash = createHash("sha256").update(JSON.stringify([head.stdout.trim(), tracked.stdout, files]));
150
+ const ordered: string[] = [];
151
+ for (const path of [...inputs].sort()) {
152
+ // The text Git adapter cannot distinguish invalid UTF-8 from U+FFFD. Keep
153
+ // that part opaque instead of dropping the evidence from all other paths.
154
+ if (path.includes("\uFFFD")) {
155
+ complete = false;
156
+ hash.update(JSON.stringify([path, null]));
157
+ } else ordered.push(path);
158
+ }
159
+ for (let index = 0; index < ordered.length; index += 32) {
160
+ signal?.throwIfAborted();
161
+ const batch = ordered.slice(index, index + 32);
162
+ const entries = await Promise.allSettled(batch.map((path) => fileFingerprint(root, path, paths)));
163
+ for (let offset = 0; offset < batch.length; offset++) {
164
+ const entry = entries[offset];
165
+ if (entry.status === "rejected") {
166
+ complete = false;
167
+ hash.update(JSON.stringify([batch[offset], null]));
168
+ } else {
169
+ if (entry.value.opaque) complete = false;
170
+ hash.update(JSON.stringify([batch[offset], entry.value.value]));
171
+ }
172
+ }
173
+ }
174
+ return { hash: hash.digest("hex"), complete };
175
+ } catch {
176
+ // Cache evidence is optional. Unknown, inaccessible or unsupported inputs require a fresh run.
177
+ return undefined;
178
+ }
179
+ }
180
+
181
+ async function runCommand(check: Check, cwd: string, env: NodeJS.ProcessEnv, fd: number, signal?: AbortSignal): Promise<string | undefined> {
182
+ if (signal?.aborted) return "was cancelled";
183
+ const win = process.platform === "win32";
184
+ const child = spawn(check.command[0], check.command.slice(1), { cwd, env, stdio: ["ignore", fd, fd], detached: !win, windowsHide: true });
185
+ const pid = child.pid;
186
+ let native: Process | null = null;
187
+ if (!win && pid) {
188
+ try { native = Process.fromPid(pid); } catch { /* The live child/group remains available for direct signalling. */ }
189
+ }
190
+ const { promise: closed, resolve: done } = Promise.withResolvers<string | undefined>();
191
+ child.once("error", (error) => done(`could not start: ${error.message}`));
192
+ child.once("close", (code, by) => done(code === 0 ? undefined : code === null ? `was terminated by ${by ?? "an unknown signal"}` : `exited ${code}`));
193
+ let stopped: string | undefined;
194
+ let terminating: Promise<unknown> | undefined;
195
+ let hardKill: ReturnType<typeof setTimeout> | undefined;
196
+ const stop = (reason: string) => {
197
+ if (stopped) return;
198
+ stopped = reason;
199
+ if (!pid || child.exitCode !== null || child.signalCode !== null) return;
200
+ if (win) {
201
+ const { promise, resolve: killed } = Promise.withResolvers<void>();
202
+ terminating = promise;
203
+ execFile("taskkill.exe", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 5_000 }, (error) => {
204
+ if (error) child.kill("SIGKILL");
205
+ killed();
206
+ });
207
+ } else {
208
+ const graceEnd = performance.now() + TERMINATION_GRACE_MS;
209
+ const signalGroup = (name: NodeJS.Signals) => {
210
+ // Only use a numeric PGID while its leader is still our live child.
211
+ if (child.exitCode !== null || child.signalCode !== null) return;
212
+ try { process.kill(-pid, name); } catch (error) {
213
+ if ((error as NodeJS.ErrnoException).code !== "ESRCH") child.kill(name);
214
+ }
215
+ };
216
+ const fallback = () => {
217
+ signalGroup("SIGTERM");
218
+ hardKill = setTimeout(() => signalGroup("SIGKILL"), Math.max(0, graceEnd - performance.now()));
219
+ };
220
+ // A stable native reference retains group/tree identity across the grace.
221
+ if (native) terminating = native.terminate({ group: true, gracefulMs: TERMINATION_GRACE_MS }).catch(fallback);
222
+ else fallback();
223
+ }
224
+ };
225
+ const deadline = performance.now() + check.timeoutSeconds * 1_000;
226
+ let timer: ReturnType<typeof setTimeout> | undefined;
227
+ const schedule = () => {
228
+ const left = deadline - performance.now();
229
+ if (left <= 0) stop(`timed out after ${check.timeoutSeconds}s`);
230
+ else timer = setTimeout(schedule, Math.min(left, MAX_TIMER_MS));
231
+ };
232
+ const abort = () => stop("was cancelled");
233
+ schedule();
234
+ signal?.addEventListener("abort", abort, { once: true });
235
+ if (signal?.aborted) abort();
236
+ try {
237
+ const status = await closed;
238
+ await terminating;
239
+ return stopped ?? status;
240
+ } finally {
241
+ clearTimeout(timer);
242
+ clearTimeout(hardKill);
243
+ signal?.removeEventListener("abort", abort);
244
+ }
245
+ }
246
+
247
+ async function failureContext(root: string, files: readonly string[], git: ReadGit): Promise<string> {
248
+ const result = await git(["--no-optional-locks", "status", "--porcelain=v1", "--no-renames", "--untracked-files=no", "-z"]);
249
+ const label = "Dirty tracked paths outside this publication";
250
+ const paths = result.stdout.split("\0").filter(Boolean).map((line) => line.slice(3))
251
+ .filter((path) => !matches(files, path));
252
+ const names = result.code !== 0 ? "could not be determined" : paths.length === 0 ? "none"
253
+ : paths.slice(0, 8).map((path) => JSON.stringify(path)).join(", ") + (paths.length > 8 ? ` (+${paths.length - 8} more)` : "");
254
+ return `The check ran on the working tree at ${root}. ${label}: ${names}.`;
255
+ }
256
+
257
+ export async function runFinalizeChecks(options: Options): Promise<FinalizeChecksResult | undefined> {
258
+ const configPath = join(options.root, FINALIZE_CHECKS_CONFIG);
259
+ const config = await loadConfig(configPath);
260
+ if (!config?.checks.length) return undefined;
261
+ const files = typeof options.files === "function" ? await options.files() : options.files;
262
+ const selected = config.checks.filter((check) => files.some((file) => matches(check.paths, file)));
263
+ if (!selected.length) return undefined;
264
+ const waiver = options.waiver?.trim();
265
+ if (waiver) return { checks: [], waiver };
266
+ const trust = options.sessionManager && Reflect.get(options.sessionManager, Symbol.for("cuelo.finalizeChecksProjectTrust"));
267
+ const inCuelo = Reflect.get(globalThis, Symbol.for("cuelo.finalizeChecksBrowser")) === true;
268
+ if ((inCuelo || trust !== undefined) && (typeof trust !== "function" || trust(options.root) !== true)) {
269
+ throw new Error(`The project is untrusted, so ${configPath} was not executed. Trust the project in CUELO, or use finalizeChecksWaiver only if the user explicitly requests a waiver.`);
270
+ }
271
+ await options.authorize?.();
272
+
273
+ const exec = options.exec ?? spawnExec(options.signal);
274
+ const git: ReadGit = (args) => exec(options.git ?? "git", args, { cwd: options.root });
275
+ const root = await realpath(options.root);
276
+ const agentDir = getAgentDir();
277
+ const ledgerDir = resolve(options.ledgerDir ?? (process.env.OMP_FINALIZE_CHECKS_LEDGER || join(agentDir, "finalize-checks-ledger")));
278
+ const env = { ...process.env };
279
+ const envKey = createHash("sha256").update(JSON.stringify(Object.entries(env).sort())).digest("hex");
280
+ const results: CheckResult[] = [];
281
+ const verified: { check: Check; fingerprint: string }[] = [];
282
+ let ranAfterVerification = false;
283
+ let logDir: string | undefined;
284
+ for (const check of selected) {
285
+ options.signal?.throwIfAborted();
286
+ const prior = await fingerprint(root, files, check.paths, git, options.signal);
287
+ options.signal?.throwIfAborted();
288
+ const slot = createHash("sha256").update(JSON.stringify([root, check.name])).digest("hex");
289
+ const ledgerFile = join(ledgerDir, slot);
290
+ const key = prior?.complete ? createHash("sha256").update(JSON.stringify([2, envKey, check, prior.hash])).digest("hex") : undefined;
291
+ if (key && await readFile(ledgerFile, "utf8").catch(() => undefined) === key) {
292
+ results.push({ name: check.name, seconds: 0, reused: true });
293
+ verified.push({ check, fingerprint: prior!.hash });
294
+ continue;
295
+ }
296
+
297
+ if (!logDir) {
298
+ const parent = resolve(options.sessionManager?.getArtifactManager().dir ?? join(agentDir, "artifacts"), "finalize-checks");
299
+ await mkdir(parent, { recursive: true, mode: 0o700 });
300
+ logDir = await mkdtemp(join(parent, "run-"));
301
+ }
302
+ const log = join(logDir, `${results.length + 1}.log`);
303
+ const handle = await open(log, "wx+", 0o600);
304
+ const started = performance.now();
305
+ let failure: string | undefined;
306
+ let tail = "";
307
+ try {
308
+ failure = await runCommand(check, root, env, handle.fd, options.signal).catch((error: Error) => `could not start: ${error.message}`);
309
+ if (failure) {
310
+ const size = (await handle.stat()).size;
311
+ const buf = Buffer.allocUnsafe(Math.min(size, TAIL_BYTES));
312
+ const { bytesRead } = await handle.read(buf, 0, buf.length, size - buf.length);
313
+ tail = buf.subarray(0, bytesRead).toString("utf8").trimEnd().split(/\r?\n/).slice(-60).join("\n");
314
+ }
315
+ } finally {
316
+ await handle.close();
317
+ }
318
+ const seconds = Math.round(performance.now() - started) / 1_000;
319
+ if (failure) {
320
+ const context = options.showDirtyTracked ? await failureContext(root, files, git) : undefined;
321
+ throw new Error([`${check.name} ${failure} (${seconds}s).`, context, tail && `Last output:\n${tail}`, `Full log: ${log}`, "Fix the failing check, then call the publication tool again."].filter(Boolean).join("\n"));
322
+ }
323
+ results.push({ name: check.name, seconds, reused: false });
324
+ ranAfterVerification = verified.length > 0;
325
+ const after = await fingerprint(root, files, check.paths, git, options.signal);
326
+ if (after) verified.push({ check, fingerprint: after.hash });
327
+ if (key && after?.complete && after.hash === prior?.hash) {
328
+ try {
329
+ await mkdir(ledgerDir, { recursive: true, mode: 0o700 });
330
+ await writeFile(ledgerFile, key, { mode: 0o600 });
331
+ } catch { /* An unwritable cache must not turn a successful check into a failed one. */ }
332
+ }
333
+ }
334
+ // Subsequent checks can touch inputs of earlier checks. Do not publish based on a stale pass.
335
+ if (ranAfterVerification) {
336
+ for (const entry of verified) {
337
+ if ((await fingerprint(root, files, entry.check.paths, git, options.signal))?.hash !== entry.fingerprint) {
338
+ throw new Error(`${entry.check.name}'s working-tree inputs changed after it passed. Call the publication tool again when the inputs are stable.`);
339
+ }
340
+ }
341
+ }
342
+ options.signal?.throwIfAborted();
343
+ if (await readFile(configPath, "utf8").catch(() => undefined) !== config.source) {
344
+ throw new Error(`${configPath} changed during the checks; call the publication tool again.`);
345
+ }
346
+ return { checks: results };
347
+ }
348
+
349
+ export function finalizeChecksNote(result?: FinalizeChecksResult): string {
350
+ if (!result) return "";
351
+ if (result.waiver) return `Finalize checks waived by explicit user instruction: ${result.waiver}.`;
352
+ return `Finalize checks: ${result.checks.map(({ name, seconds, reused }) => reused ? `${name} reused` : `${name} ran (${seconds}s)`).join("; ")}.`;
353
+ }
@@ -3,8 +3,8 @@ import { beforeModelAbort, directFallbackModel, isHydrogen, modelRoleSelector, o
3
3
  // ๋Ÿฐํƒ€์ž„ ํŒจํ‚ค์ง€๋Š” legacy-pi ํ™•์žฅ loader๊ฐ€ host SDK ๊ฒฝ๋กœ๋กœ ์žฌ์ž‘์„ฑํ•˜๋ฏ€๋กœ ์•„๋ž˜์—์„œ ์ง€์—ฐ importํ•œ๋‹ค.
4
4
 
5
5
  /**
6
- * ํ†ต์—ญ ์ž๋ฆฌ(2026-10-30 ์‚ฌ์šฉ์ž ๊ฒฐ์ •): ์‚ฌ์šฉ์ž ํ•œ๊ตญ์–ด ์ž…๋ ฅ์˜ ์˜์–ด ๋ฒˆ์—ญ(user-input-interpreter)๊ณผ Main์˜ ๋น„ํ•œ๊ตญ์–ด ๋‹ต ๋ฒˆ์—ญ
7
- * (korean-reply-guard)์ด ํ•จ๊ป˜ ์“ฐ๋Š” ๋ชจ๋ธ ํ˜ธ์ถœ. `modelRoles.interpreter`๋ฅผ ์“ฐ๊ณ , ๊ทธ slot์ด ์—†๋Š” ์„ค์น˜๋Š” ์˜ˆ์ „์ฒ˜๋Ÿผ `tiny`๋ฅผ ์“ด๋‹ค.
6
+ * ํ†ต์—ญ ์ž๋ฆฌ(2026-10-30 ์‚ฌ์šฉ์ž ๊ฒฐ์ •, 2026-11-20 ์ž…๋ ฅ ํ†ต์—ญ ์ฒ ๊ฑฐ): Main์˜ ๋น„ํ•œ๊ตญ์–ด ๋‹ต ๋ฒˆ์—ญ(korean-reply-guard)์ด ์“ฐ๋Š”
7
+ * ๋ชจ๋ธ ํ˜ธ์ถœ. `modelRoles.interpreter`๋ฅผ ์“ฐ๊ณ , ๊ทธ slot์ด ์—†๋Š” ์„ค์น˜๋Š” ์˜ˆ์ „์ฒ˜๋Ÿผ `tiny`๋ฅผ ์“ด๋‹ค.
8
8
  */
9
9
  export const INTERPRETER_ROLE = "interpreter";
10
10
 
@@ -13,7 +13,8 @@ export const SECRET_PATTERN = /(?:^|[\s"'`:])(?:password|passwd|api[_ -]?key|bea
13
13
 
14
14
  /**
15
15
  * ํ†ต์—ญ ๋ชจ๋ธ๋กœ ํ•œ ๋ฒˆ ํ˜ธ์ถœํ•ด ํ…์ŠคํŠธ ๋‹ต์„ ๋Œ๋ ค์ค€๋‹ค. ์ถœ๋ ฅ ํ•œ๋„์—์„œ ๋Š๊ธฐ๋ฉด ๋Š๊ธด ๋‹ต๊ณผ `truncated`๋ฅผ ํ•จ๊ป˜ ์ค€๋‹ค.
16
- * Hydrogen uses the one configured interpreterFallback, within the callers' existing total deadlines.
16
+ * Hydrogen falls back to `interpreterFallback` on operating failures; any other primary falls back to it on a usage
17
+ * limit (2026-11-20 user decision: Terra, then Haiku), within the callers' existing total deadlines.
17
18
  */
18
19
  export async function interpret(prompt: string, purpose: string, ctx: ExtensionContext, signal: AbortSignal): Promise<{ text: string; truncated: boolean }> {
19
20
  const { completeSimple, isUsageLimitOutcome } = await import("@oh-my-pi/pi-ai");
@@ -21,7 +22,8 @@ export async function interpret(prompt: string, purpose: string, ctx: ExtensionC
21
22
  const role = selector ? INTERPRETER_ROLE : "tiny";
22
23
  const primary = ctx.models.resolve(`@${role}`);
23
24
  const hydrogen = isHydrogen(primary ? `${primary.provider}/${primary.id}` : selector);
24
- const fallback = hydrogen ? await directFallbackModel(ctx, "interpreterFallback") : undefined;
25
+ const configured = await directFallbackModel(ctx, "interpreterFallback");
26
+ const fallback = configured && !(primary && configured.provider === primary.provider && configured.id === primary.id) ? configured : undefined;
25
27
  if (!primary && !fallback) throw new Error(`modelRoles.${role} ๋ชจ๋ธ์„ ํ•ด์„ํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.`);
26
28
  const sessionId = ctx.sessionManager.getSessionId();
27
29
  const models = primary ? [primary] : [fallback!];
@@ -29,8 +31,8 @@ export async function interpret(prompt: string, purpose: string, ctx: ExtensionC
29
31
  for (let index = 0; index < models.length; index++) {
30
32
  const model = models[index]!;
31
33
  signal.throwIfAborted();
32
- // Input has 20 s total; reply translation has 120 s total. Leave half for the alternate.
33
- const timeout = primary && index === 0 && fallback ? AbortSignal.timeout(purpose === "user-input-translation" ? 10_000 : 60_000) : undefined;
34
+ // Reply translation has 120 s total. Leave half for the alternate when Hydrogen may need it.
35
+ const timeout = hydrogen && primary && index === 0 && fallback ? AbortSignal.timeout(60_000) : undefined;
34
36
  const attempt = timeout ? AbortSignal.any([signal, timeout]) : signal;
35
37
  let operating: boolean | undefined;
36
38
  try {
@@ -63,6 +65,10 @@ export async function interpret(prompt: string, purpose: string, ctx: ExtensionC
63
65
  if (index === 0 && hydrogen) {
64
66
  if (primary && fallback && (operating ?? await operationalFailure(error))) models.push(fallback);
65
67
  } else if (index === 0 && primary && isUsageLimitOutcome(undefined, error instanceof Error ? error.message : String(error))) {
68
+ if (fallback) {
69
+ models.push(fallback);
70
+ continue;
71
+ }
66
72
  for (const route of await sameModelRoutes(ctx.cwd, `${primary.provider}/${primary.id}`)) {
67
73
  const next = ctx.models.resolve(route);
68
74
  if (next) models.push(next);
@@ -3,12 +3,25 @@ import { createQuietDelivery } from "./lib/quiet-delivery";
3
3
  import { onSessionLifecycle } from "./lib/session-identity";
4
4
  import { readPersistedTodoProgress, readTodoSnapshot, type TodoSnapshotItem } from "./lib/task-progress";
5
5
 
6
- // ์‚ฌ์šฉ์ž ์ง์ ‘ ์ž…๋ ฅ ํ•˜๋‚˜์—์„œ todo ์—†์ด ๋„๊ตฌ๋ฅผ ๋‹ค์„ฏ ๋ฒˆ ๋ถ€๋ฅด๋ฉด ์š”์ฒญ๋‹น ํ•œ ๋ฒˆ ์•ˆ๋‚ดํ•œ๋‹ค.
6
+ // ์‚ฌ์šฉ์ž ์ง์ ‘ ์ž…๋ ฅ ํ•˜๋‚˜์—์„œ todo ์—†์ด ์ฝ๊ธฐ ์ „์šฉ์ด ์•„๋‹Œ ๋„๊ตฌ๋ฅผ ๋‹ค์„ฏ ๋ฒˆ ๋ถ€๋ฅด๋ฉด ์•ˆ๋‚ดํ•œ๋‹ค.
7
7
  // 2026-10-08 ์‚ฌ์šฉ์ž ๊ฒฐ์ •: ์š”์ฒญ ๋ถ„๋ฅ˜์šฉ JEV ํ˜ธ์ถœ์„ ๋‘์ง€ ์•Š๋Š”๋‹ค. ๊ฒฐ์ •๋ก ์  ํšŸ์ˆ˜ ๊ทœ์น™๋งŒ ์“ด๋‹ค.
8
8
  // 2026-10-28 ํ‘œ๋ณธ(doc/history/2026/10/28-guard-trim/advisory): ์„ธ ๋ฒˆ์งธ ํ˜ธ์ถœ ์•Œ๋ฆผ 281๊ฑด ์ค‘ ๋น„-todo ํ˜ธ์ถœ์ด ๋„ท ์ดํ•˜๋กœ ๋๋‚œ ์š”์ฒญ์ด
9
9
  // 93๊ฑด(๋ฏธ์ถ”์ข… 61)์ด์—ˆ๊ณ , ๋ฏธ์ถ”์ข… ํ‘œ๋ณธ 25๊ฑด ์ค‘ 17๊ฑด์ด ์งง์€ ์งˆ๋ฌธยท์กฐํšŒ๋ผ ๋ชฉ๋ก์ด ํ•„์š” ์—†์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋‹ค์„ฏ ๋ฒˆ์งธ ํ˜ธ์ถœ๋กœ ๋Šฆ์ถ˜๋‹ค.
10
10
  const TOOL_CALLS_BEFORE_NUDGE = 5;
11
11
 
12
+ // Registered read-only tools: file reads/searches, skim, web search and AST queries.
13
+ // LSP is mixed-mode: only the core's read-only actions are exempt. Unknown modes, bash and eval count.
14
+ const READ_ONLY_TOOLS: Record<string, true> = {
15
+ read: true, grep: true, find: true, glob: true, skim: true, web_search: true, ast_grep: true,
16
+ };
17
+ const READ_ONLY_LSP_ACTIONS: Record<string, true> = {
18
+ diagnostics: true, definition: true, type_definition: true, implementation: true, references: true,
19
+ hover: true, symbols: true, status: true, capabilities: true,
20
+ };
21
+
22
+ type RequestSlot = { claimed: boolean; fifthReminder?: { content: string; atStop: boolean } };
23
+ type Request = { slot: RequestSlot; currentCoreSlot?: () => RequestSlot | undefined };
24
+
12
25
  const REMINDER =
13
26
  "์ด๋ฒˆ ์‚ฌ์šฉ์ž ์š”์ฒญ์—์„œ todo ์—†์ด ๋„๊ตฌ๋ฅผ ์ด์–ด ๋ถ€๋ฅด๊ณ  ์žˆ๋‹ค. ์—ฌ๋Ÿฌ ํ•ญ๋ชฉ ๋˜๋Š” 3๋‹จ๊ณ„ ์ด์ƒ ์ž‘์—…์ด๋ฉด ์ง€๊ธˆ todo ๋ฅผ init ํ•ด์„œ ์š”์ฒญ ํ•ญ๋ชฉ์„ ๋น ์ง์—†์ด ๋‚˜๋ˆ„๊ณ , ์ง„ํ–‰์— ๋งž์ถฐ ์ƒํƒœ๋ฅผ ๊ฐฑ์‹ ํ•˜๋ฉฐ ์ด์–ด ๊ฐ€๋ผ.";
14
27
 
@@ -31,19 +44,30 @@ function textOf(content: unknown): string {
31
44
 
32
45
  export function createTodoNudge(now: () => number = Date.now) {
33
46
  return function todoNudge(pi: ExtensionAPI): void {
34
- let armed = false;
47
+ let request: Request | undefined;
35
48
  let usedTodo = false;
36
- let nudged = false;
49
+ const queuedFifth = new WeakMap<object, Request>();
37
50
  let calls = 0;
38
51
  let todos: readonly TodoSnapshotItem[] = [];
39
52
  let noticeNudged = false;
40
53
  let coreNudgedAt = Number.NEGATIVE_INFINITY;
41
54
  // wait๋ฅผ ๋Š๊ฑฐ๋‚˜ ๋๋‚œ ํ„ด์„ ๋‹ค์‹œ ์—ด์ง€ ์•Š๋Š”๋‹ค(2026-11-16, 7์ผ ํ‘œ๋ณธ์—์„œ wait ๋Š๊น€ 11).
42
- const quiet = createQuietDelivery(pi);
55
+ const quiet = createQuietDelivery({
56
+ on: pi.on,
57
+ sendMessage(message, options) {
58
+ const owner = typeof message === "object" ? queuedFifth.get(message) : undefined;
59
+ if (!owner) return pi.sendMessage(message, options); // Arrival reminder.
60
+ if (request !== owner) return;
61
+ if (!owner.currentCoreSlot) return pi.sendMessage(message, options); // Standalone OMP without the SDK patch.
62
+ if (owner.currentCoreSlot() !== owner.slot) return;
63
+ // Core polls the current request at injection time, even if newer input arrives after this tool result.
64
+ owner.slot.fifthReminder = { content: REMINDER, atStop: options?.deliverAs === "aside" };
65
+ },
66
+ });
43
67
 
44
68
  onSessionLifecycle(pi, {
45
69
  start: (ctx) => {
46
- armed = false;
70
+ request = undefined;
47
71
  noticeNudged = false;
48
72
  coreNudgedAt = Number.NEGATIVE_INFINITY;
49
73
  todos = readPersistedTodoProgress(ctx.sessionManager.getBranch()).currentTodos;
@@ -54,13 +78,17 @@ export function createTodoNudge(now: () => number = Date.now) {
54
78
  },
55
79
  });
56
80
  pi.on("session_shutdown", () => {
57
- armed = false;
81
+ request = undefined;
58
82
  });
59
- pi.on("input", (event) => {
83
+ pi.on("input", (event, ctx) => {
60
84
  if (event.source !== "interactive" && event.source !== "rpc") return;
61
- armed = true;
85
+ const manager = ctx.sessionManager as typeof ctx.sessionManager & {
86
+ getCueloTodoNudgeRequest?: () => RequestSlot | undefined;
87
+ };
88
+ const currentCoreSlot = manager.getCueloTodoNudgeRequest?.bind(manager);
89
+ const slot = currentCoreSlot?.();
90
+ request = slot ? { slot, currentCoreSlot } : { slot: { claimed: false } };
62
91
  usedTodo = false;
63
- nudged = false;
64
92
  calls = 0;
65
93
  });
66
94
  pi.on("tool_result", (event) => {
@@ -72,6 +100,7 @@ export function createTodoNudge(now: () => number = Date.now) {
72
100
  const message = event.message as { role?: string; customType?: string; content?: unknown };
73
101
  if (message.role === "custom" && message.customType === CORE_NUDGE_TYPE) {
74
102
  coreNudgedAt = now();
103
+ if (request && !request.currentCoreSlot) request.slot.claimed = true;
75
104
  return;
76
105
  }
77
106
  if (message.role !== "custom" || (message.customType !== "async-result" && message.customType !== "irc:incoming")) return;
@@ -84,17 +113,22 @@ export function createTodoNudge(now: () => number = Date.now) {
84
113
  });
85
114
  pi.on("tool_call", (event, ctx) => {
86
115
  if (event.toolName === "todo") noticeNudged = false;
87
- if (!armed || nudged || usedTodo) return;
116
+ if (!request || request.slot.claimed || usedTodo || calls >= TOOL_CALLS_BEFORE_NUDGE) return;
117
+ if (request.currentCoreSlot && request.currentCoreSlot() !== request.slot) return;
88
118
  if (event.toolName === "todo") {
89
119
  usedTodo = true;
90
120
  return;
91
121
  }
122
+ if (Object.hasOwn(READ_ONLY_TOOLS, event.toolName)) return;
123
+ if (event.toolName === "lsp" && "action" in event.input &&
124
+ typeof event.input.action === "string" && Object.hasOwn(READ_ONLY_LSP_ACTIONS, event.input.action)) return;
125
+ if (++calls < TOOL_CALLS_BEFORE_NUDGE) return;
92
126
  // ์ด์ „ ์š”์ฒญ์˜ ์ง„ํ–‰ ์ค‘ ๋ชฉ๋ก์ด ์žˆ์œผ๋ฉด ์ด๋ฏธ ์ถ”์  ์ค‘์ด๋‹ค.
93
127
  if (todos.some((item) => item.status === "pending" || item.status === "in_progress")) return;
94
- calls += 1;
95
- if (calls < TOOL_CALLS_BEFORE_NUDGE) return;
96
- nudged = true;
97
- quiet({ customType: "todo-nudge", content: REMINDER, display: false, attribution: "agent" }, ctx);
128
+ request.slot.claimed = true;
129
+ const message = { customType: "todo-nudge", content: REMINDER, display: false, attribution: "agent" as const };
130
+ queuedFifth.set(message, request);
131
+ quiet(message, ctx);
98
132
  });
99
133
  };
100
134
  }
@@ -111,11 +111,26 @@ const page = task.page("p1");
111
111
  `;
112
112
  }
113
113
 
114
- /** finish๊ฐ€ true๋ฉด ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ๋˜์ ธ๋„ ๊ณต๊ฐ„์„ ์ •๋ฆฌํ•œ๋‹ค. ๋ณธ๋ฌธ์€ ๋ธ”๋ก ์•ˆ์—์„œ ๋ˆ๋‹ค. */
114
+ /**
115
+ * ๋ณธ๋ฌธ์€ ๋จธ๋ฆฌ๋ง๊ณผ ๋‹ค๋ฅธ ๋ธ”๋ก์—์„œ ๋ˆ๋‹ค. 11-14~11-19 Linux 9์„ธ์…˜์ด ego ๊ฐ€์ด๋“œ ์˜ˆ์ œ๋Œ€๋กœ ์ฒซ ํ˜ธ์ถœ์—
116
+ * `const task = await taskSpace(...)`ยท`const page = task.page("p1")`๋ฅผ ์จ์„œ ๋จธ๋ฆฌ๋ง๊ณผ ๊ฒน์ณ
117
+ * `SyntaxError: Identifier 'task' has already been declared`๋กœ ํ•œ ํ„ด์”ฉ ๋ฒ„๋ ธ๋‹ค. ๋ธ”๋ก์ด๋ฉด ๋ณธ๋ฌธ ์„ ์–ธ์€ ๊ฐ€๋ฆฌ๊ธฐ๋งŒ ํ•œ๋‹ค.
118
+ * ์ด๋ฆ„(๋ฌธ์ž์—ด)๋งŒ ์ค€ `taskSpace`๋Š” ์ด ์„ธ์…˜ ๊ณต๊ฐ„์„ ๋Œ๋ ค์ค€๋‹ค. ๊ทธ๋Œ€๋กœ SDK์— ๋„˜๊ธฐ๋ฉด ์„ธ์…˜ ์ •๋ฆฌ๊ฐ€ ๋ชจ๋ฅด๋Š” ๊ณต๊ฐ„์ด ๋‚จ๋Š”๋‹ค.
119
+ * ์ˆซ์ž id(์‚ฌ์šฉ์ž๊ฐ€ ๋„˜๊ธด ๊ณต๊ฐ„ ์žฌ๊ฐœ ๋“ฑ)๋‚˜ ๊ฐ’์ด ์žˆ๋Š” ์˜ต์…˜(profileId ๋“ฑ)์ด ๋ถ™์€ ํ˜ธ์ถœ์€ ๋ช…์‹œํ•œ ์š”์ฒญ์ด๋ผ SDK์— ๊ทธ๋Œ€๋กœ ๋„˜๊ธด๋‹ค.
120
+ * ๋ณธ๋ฌธ์€ `taskSpace`๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ›๋Š” ์•ˆ์ชฝ ํ•จ์ˆ˜์˜ ๋ธ”๋ก์—์„œ ๋ˆ๋‹ค. ๋ณธ๋ฌธ์˜ `const`ยท`let`ยท`var` ์„ ์–ธ(`task`, `page`, `taskSpace` ํฌํ•จ)์ด
121
+ * ๋จธ๋ฆฌ๋ง๊ณผ ๊ฒน์น˜์ง€ ์•Š๊ณ , ๋Œ€์ฒด ํ•จ์ˆ˜๋Š” ๋จธ๋ฆฌ๋ง ๋ฒ”์œ„์— ๋ฌถ์—ฌ ๋ณธ๋ฌธ ์„ ์–ธ์— ํ”๋“ค๋ฆฌ์ง€ ์•Š๋Š”๋‹ค. ๋ณธ๋ฌธ์˜ `return` ๊ฐ’์€ ๊ทธ๋Œ€๋กœ ๋Œ๋ ค์ค€๋‹ค.
122
+ * finish๊ฐ€ true๋ฉด ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ๋˜์ ธ๋„ ๊ณต๊ฐ„์„ ์ •๋ฆฌํ•œ๋‹ค.
123
+ */
115
124
  export function buildScript(name: string, profile: EgoProfile, body: string, finish: boolean, host: EgoHost = "windows"): string {
116
- const prelude = buildPrelude(name, profile, host);
117
- if (!finish) return `${prelude}${body}\n`;
118
- return `${prelude}try {\n${body}\n} finally {\n await task.finish({ keep: [] });\n}\n`;
125
+ const prelude = `${buildPrelude(name, profile, host)}const __egoTask = task;
126
+ const __egoTaskSpace = typeof taskSpace === "function" ? taskSpace : undefined;
127
+ const __egoNamedTaskSpace = (nameOrId, ...rest) => typeof nameOrId === "string" && rest.every((value) => value === undefined || (typeof value === "object" && value !== null && Object.values(value).every((option) => option === undefined)))
128
+ ? Promise.resolve(__egoTask)
129
+ : __egoTaskSpace(nameOrId, ...rest);
130
+ `;
131
+ const run = `return await (async (taskSpace) => {\n{\n${body}\n}\n})(__egoNamedTaskSpace);`;
132
+ if (!finish) return `${prelude}${run}\n`;
133
+ return `${prelude}try {\n${run}\n} finally {\n await task.finish({ keep: [] });\n}\n`;
119
134
  }
120
135
 
121
136
  /**
@@ -1,7 +1,8 @@
1
1
  [CmdletBinding()]
2
2
  param(
3
3
  [Parameter(Mandatory = $true)]
4
- [string]$Request
4
+ [string]$Request,
5
+ [switch]$PreflightOnly
5
6
  )
6
7
 
7
8
  $ErrorActionPreference = 'Stop'
@@ -235,6 +236,11 @@ try {
235
236
  $repoPaths += $repoPath
236
237
  }
237
238
 
239
+ if ($PreflightOnly) {
240
+ [Console]::Out.WriteLine((@{ ok = $true; stage = 'preflight'; repositoryRoot = $repoRoot; repositoryFiles = @($repoPaths) } | ConvertTo-Json -Compress))
241
+ exit 0
242
+ }
243
+
238
244
  $stage = 'remote'
239
245
  $branch = (Invoke-Git -WorkingDirectory $repoRoot -GitArgs @('rev-parse', '--abbrev-ref', 'HEAD')).Output
240
246
  if (-not $branch -or $branch -eq 'HEAD') { throw 'Detached HEAD is not supported.' }
@@ -289,6 +295,10 @@ try {
289
295
 
290
296
  $stage = 'fetch'
291
297
  $headSha = (Invoke-Git -WorkingDirectory $repoRoot -GitArgs @('rev-parse', 'HEAD')).Output
298
+ if ($payload.finalizeChecksHead -and $payload.finalizeChecksHead -cne $headSha) {
299
+ $stage = 'finalize-checks'
300
+ throw 'HEAD changed after running the repository checks. Call git_finalize again.'
301
+ }
292
302
  $upstreamSha = $null
293
303
  if ($upstreamExists) {
294
304
  [void](Invoke-Git -WorkingDirectory $repoRoot -GitArgs @('fetch', '--no-tags', $remote, $upstreamRef))