gsd-pi 2.44.0-dev.848dd4c → 2.44.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 (298) hide show
  1. package/README.md +12 -30
  2. package/dist/resources/extensions/gsd/auto-start.js +0 -10
  3. package/dist/resources/extensions/gsd/commands/handlers/workflow.js +0 -5
  4. package/dist/web/standalone/.next/BUILD_ID +1 -1
  5. package/dist/web/standalone/.next/app-path-routes-manifest.json +14 -14
  6. package/dist/web/standalone/.next/build-manifest.json +3 -3
  7. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  8. package/dist/web/standalone/.next/required-server-files.json +3 -3
  9. package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
  10. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  11. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  12. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  13. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  14. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  15. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  16. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  17. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  18. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  19. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  20. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  21. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  22. package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
  23. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  24. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  26. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
  30. package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
  31. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
  32. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
  33. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
  34. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
  35. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
  36. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
  37. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  38. package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
  39. package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
  40. package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
  41. package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
  42. package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
  43. package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
  44. package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
  45. package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
  46. package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
  47. package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
  48. package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
  49. package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
  50. package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  51. package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
  52. package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
  53. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  54. package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  55. package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
  56. package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
  57. package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
  58. package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
  59. package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
  60. package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
  61. package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
  62. package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
  63. package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
  64. package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
  65. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  66. package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  67. package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
  68. package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
  69. package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
  70. package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  71. package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
  72. package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
  73. package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +5 -5
  74. package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
  75. package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
  76. package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
  77. package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
  78. package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
  79. package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
  80. package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
  81. package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
  82. package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
  83. package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
  84. package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
  85. package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
  86. package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  87. package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
  88. package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
  89. package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
  90. package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
  91. package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
  92. package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
  93. package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
  94. package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
  95. package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
  96. package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
  97. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
  98. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
  99. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
  100. package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
  101. package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
  102. package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
  103. package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
  104. package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
  105. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  106. package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  107. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  108. package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
  109. package/dist/web/standalone/.next/server/app/index.html +1 -1
  110. package/dist/web/standalone/.next/server/app/index.rsc +4 -4
  111. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  112. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  113. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  114. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  115. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  116. package/dist/web/standalone/.next/server/app/page.js +2 -2
  117. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  118. package/dist/web/standalone/.next/server/app-paths-manifest.json +14 -14
  119. package/dist/web/standalone/.next/server/chunks/229.js +1 -1
  120. package/dist/web/standalone/.next/server/chunks/471.js +3 -3
  121. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  122. package/dist/web/standalone/.next/server/middleware.js +2 -2
  123. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  124. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  125. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  126. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  127. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  128. package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-f2a7482d42a5614b.js → page-2f24283c162b6ab3.js} +1 -1
  129. package/dist/web/standalone/.next/static/chunks/app/{layout-a16c7a7ecdf0c2cf.js → layout-9ecfd95f343793f0.js} +1 -1
  130. package/dist/web/standalone/.next/static/chunks/app/page-7e9530a7122506c5.js +1 -0
  131. package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +1 -0
  132. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +1 -0
  133. package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
  134. package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
  135. package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
  136. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
  137. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
  138. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
  139. package/dist/web/standalone/server.js +1 -1
  140. package/package.json +1 -1
  141. package/packages/pi-coding-agent/dist/core/auth-storage.test.js +8 -6
  142. package/packages/pi-coding-agent/dist/core/auth-storage.test.js.map +1 -1
  143. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +26 -24
  144. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
  145. package/packages/pi-coding-agent/dist/core/fs-utils.test.js +48 -29
  146. package/packages/pi-coding-agent/dist/core/fs-utils.test.js.map +1 -1
  147. package/packages/pi-coding-agent/dist/core/resolve-config-value.test.js +44 -34
  148. package/packages/pi-coding-agent/dist/core/resolve-config-value.test.js.map +1 -1
  149. package/packages/pi-coding-agent/dist/core/session-manager.test.js +34 -30
  150. package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -1
  151. package/packages/pi-coding-agent/dist/core/tools/edit-diff.test.js +12 -10
  152. package/packages/pi-coding-agent/dist/core/tools/edit-diff.test.js.map +1 -1
  153. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.test.js +47 -43
  154. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.test.js.map +1 -1
  155. package/packages/pi-coding-agent/src/core/auth-storage.test.ts +7 -7
  156. package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +26 -26
  157. package/packages/pi-coding-agent/src/core/fs-utils.test.ts +43 -31
  158. package/packages/pi-coding-agent/src/core/resolve-config-value.test.ts +45 -40
  159. package/packages/pi-coding-agent/src/core/session-manager.test.ts +33 -33
  160. package/packages/pi-coding-agent/src/core/tools/edit-diff.test.ts +17 -17
  161. package/packages/pi-coding-agent/src/resources/extensions/memory/storage.test.ts +74 -74
  162. package/src/resources/extensions/gsd/auto-start.ts +0 -14
  163. package/src/resources/extensions/gsd/commands/handlers/workflow.ts +0 -8
  164. package/src/resources/extensions/gsd/tests/all-milestones-complete-merge.test.ts +99 -99
  165. package/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts +16 -14
  166. package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +57 -43
  167. package/src/resources/extensions/gsd/tests/auto-preflight.test.ts +13 -11
  168. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +523 -465
  169. package/src/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +75 -73
  170. package/src/resources/extensions/gsd/tests/auto-start-needs-discussion.test.ts +56 -34
  171. package/src/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +656 -533
  172. package/src/resources/extensions/gsd/tests/auto-worktree.test.ts +143 -165
  173. package/src/resources/extensions/gsd/tests/cache-staleness-regression.test.ts +52 -29
  174. package/src/resources/extensions/gsd/tests/captures.test.ts +176 -148
  175. package/src/resources/extensions/gsd/tests/claude-import-tui.test.ts +33 -32
  176. package/src/resources/extensions/gsd/tests/collect-from-manifest.test.ts +143 -141
  177. package/src/resources/extensions/gsd/tests/commands-inspect-open-db.test.ts +25 -25
  178. package/src/resources/extensions/gsd/tests/commands-logs.test.ts +81 -81
  179. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +59 -38
  180. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +263 -228
  181. package/src/resources/extensions/gsd/tests/complete-task.test.ts +302 -250
  182. package/src/resources/extensions/gsd/tests/context-store.test.ts +367 -354
  183. package/src/resources/extensions/gsd/tests/continue-here.test.ts +72 -68
  184. package/src/resources/extensions/gsd/tests/cost-projection.test.ts +106 -92
  185. package/src/resources/extensions/gsd/tests/crash-recovery.test.ts +35 -27
  186. package/src/resources/extensions/gsd/tests/dashboard-budget.test.ts +237 -220
  187. package/src/resources/extensions/gsd/tests/db-writer.test.ts +420 -390
  188. package/src/resources/extensions/gsd/tests/definition-loader.test.ts +92 -76
  189. package/src/resources/extensions/gsd/tests/derive-state-crossval.test.ts +83 -68
  190. package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +183 -152
  191. package/src/resources/extensions/gsd/tests/derive-state-deps.test.ts +101 -78
  192. package/src/resources/extensions/gsd/tests/derive-state.test.ts +227 -192
  193. package/src/resources/extensions/gsd/tests/detection.test.ts +278 -232
  194. package/src/resources/extensions/gsd/tests/dev-engine-wrapper.test.ts +34 -30
  195. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +180 -164
  196. package/src/resources/extensions/gsd/tests/dispatch-missing-task-plans.test.ts +49 -43
  197. package/src/resources/extensions/gsd/tests/dispatch-uat-last-completed.test.ts +32 -28
  198. package/src/resources/extensions/gsd/tests/doctor-completion-deferral.test.ts +29 -27
  199. package/src/resources/extensions/gsd/tests/doctor-delimiter-fix.test.ts +38 -34
  200. package/src/resources/extensions/gsd/tests/doctor-enhancements.test.ts +75 -54
  201. package/src/resources/extensions/gsd/tests/doctor-environment-worktree.test.ts +32 -21
  202. package/src/resources/extensions/gsd/tests/doctor-environment.test.ts +97 -72
  203. package/src/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +44 -38
  204. package/src/resources/extensions/gsd/tests/doctor-git.test.ts +145 -104
  205. package/src/resources/extensions/gsd/tests/doctor-proactive.test.ts +106 -84
  206. package/src/resources/extensions/gsd/tests/doctor-roadmap-summary-atomicity.test.ts +60 -54
  207. package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +93 -72
  208. package/src/resources/extensions/gsd/tests/doctor.test.ts +134 -104
  209. package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +131 -123
  210. package/src/resources/extensions/gsd/tests/exit-command.test.ts +24 -20
  211. package/src/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +57 -48
  212. package/src/resources/extensions/gsd/tests/files-loadfile-eisdir.test.ts +7 -5
  213. package/src/resources/extensions/gsd/tests/flag-file-db.test.ts +42 -30
  214. package/src/resources/extensions/gsd/tests/freeform-decisions.test.ts +206 -198
  215. package/src/resources/extensions/gsd/tests/git-locale.test.ts +27 -13
  216. package/src/resources/extensions/gsd/tests/git-service.test.ts +388 -285
  217. package/src/resources/extensions/gsd/tests/gitignore-tracked-gsd.test.ts +39 -31
  218. package/src/resources/extensions/gsd/tests/graph-operations.test.ts +69 -63
  219. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +264 -255
  220. package/src/resources/extensions/gsd/tests/gsd-inspect.test.ts +119 -108
  221. package/src/resources/extensions/gsd/tests/gsd-recover.test.ts +103 -81
  222. package/src/resources/extensions/gsd/tests/gsd-tools.test.ts +262 -229
  223. package/src/resources/extensions/gsd/tests/headless-answers.test.ts +13 -13
  224. package/src/resources/extensions/gsd/tests/health-widget.test.ts +37 -29
  225. package/src/resources/extensions/gsd/tests/idle-recovery.test.ts +102 -81
  226. package/src/resources/extensions/gsd/tests/init-wizard.test.ts +18 -16
  227. package/src/resources/extensions/gsd/tests/integration-edge.test.ts +46 -41
  228. package/src/resources/extensions/gsd/tests/integration-lifecycle.test.ts +53 -42
  229. package/src/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +91 -75
  230. package/src/resources/extensions/gsd/tests/integration-proof.test.ts +18 -18
  231. package/src/resources/extensions/gsd/tests/markdown-renderer.test.ts +194 -150
  232. package/src/resources/extensions/gsd/tests/md-importer.test.ts +125 -101
  233. package/src/resources/extensions/gsd/tests/memory-extractor.test.ts +54 -45
  234. package/src/resources/extensions/gsd/tests/memory-store.test.ts +93 -80
  235. package/src/resources/extensions/gsd/tests/migrate-command.test.ts +66 -57
  236. package/src/resources/extensions/gsd/tests/migrate-hierarchy.test.ts +93 -83
  237. package/src/resources/extensions/gsd/tests/migrate-parser.test.ts +170 -161
  238. package/src/resources/extensions/gsd/tests/migrate-transformer.test.ts +141 -125
  239. package/src/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +131 -107
  240. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +96 -87
  241. package/src/resources/extensions/gsd/tests/migrate-writer.test.ts +164 -125
  242. package/src/resources/extensions/gsd/tests/must-have-parser.test.ts +94 -81
  243. package/src/resources/extensions/gsd/tests/none-mode-gates.test.ts +36 -35
  244. package/src/resources/extensions/gsd/tests/overrides.test.ts +106 -99
  245. package/src/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +47 -40
  246. package/src/resources/extensions/gsd/tests/parallel-worker-monitoring.test.ts +28 -25
  247. package/src/resources/extensions/gsd/tests/parallel-workers-multi-milestone-e2e.test.ts +83 -66
  248. package/src/resources/extensions/gsd/tests/park-edge-cases.test.ts +77 -54
  249. package/src/resources/extensions/gsd/tests/park-milestone.test.ts +115 -68
  250. package/src/resources/extensions/gsd/tests/parsers.test.ts +611 -546
  251. package/src/resources/extensions/gsd/tests/paths.test.ts +87 -72
  252. package/src/resources/extensions/gsd/tests/post-unit-hooks.test.ts +117 -77
  253. package/src/resources/extensions/gsd/tests/prompt-db.test.ts +56 -56
  254. package/src/resources/extensions/gsd/tests/queue-draft-detection.test.ts +119 -93
  255. package/src/resources/extensions/gsd/tests/queue-order.test.ts +82 -70
  256. package/src/resources/extensions/gsd/tests/queue-reorder-e2e.test.ts +55 -42
  257. package/src/resources/extensions/gsd/tests/quick-branch-lifecycle.test.ts +73 -45
  258. package/src/resources/extensions/gsd/tests/reassess-prompt.test.ts +38 -28
  259. package/src/resources/extensions/gsd/tests/replan-slice.test.ts +80 -73
  260. package/src/resources/extensions/gsd/tests/repo-identity-worktree.test.ts +74 -71
  261. package/src/resources/extensions/gsd/tests/requirements.test.ts +75 -70
  262. package/src/resources/extensions/gsd/tests/retry-state-reset.test.ts +66 -44
  263. package/src/resources/extensions/gsd/tests/roadmap-parse-regression.test.ts +181 -114
  264. package/src/resources/extensions/gsd/tests/rule-registry.test.ts +65 -63
  265. package/src/resources/extensions/gsd/tests/run-uat.test.ts +128 -66
  266. package/src/resources/extensions/gsd/tests/session-lock-multipath.test.ts +25 -18
  267. package/src/resources/extensions/gsd/tests/session-lock-regression.test.ts +44 -37
  268. package/src/resources/extensions/gsd/tests/shared-wal.test.ts +26 -19
  269. package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +8 -6
  270. package/src/resources/extensions/gsd/tests/symlink-numbered-variants.test.ts +28 -22
  271. package/src/resources/extensions/gsd/tests/token-savings.test.ts +56 -54
  272. package/src/resources/extensions/gsd/tests/tool-call-loop-guard.test.ts +25 -23
  273. package/src/resources/extensions/gsd/tests/tool-naming.test.ts +11 -9
  274. package/src/resources/extensions/gsd/tests/unique-milestone-ids.test.ts +82 -66
  275. package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +47 -46
  276. package/src/resources/extensions/gsd/tests/visualizer-critical-path.test.ts +22 -20
  277. package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +86 -84
  278. package/src/resources/extensions/gsd/tests/visualizer-overlay.test.ts +43 -41
  279. package/src/resources/extensions/gsd/tests/visualizer-views.test.ts +96 -94
  280. package/src/resources/extensions/gsd/tests/windows-path-normalization.test.ts +13 -11
  281. package/src/resources/extensions/gsd/tests/worker-registry.test.ts +29 -27
  282. package/src/resources/extensions/gsd/tests/workflow-templates.test.ts +52 -50
  283. package/src/resources/extensions/gsd/tests/worktree-bugfix.test.ts +13 -10
  284. package/src/resources/extensions/gsd/tests/worktree-db-integration.test.ts +18 -14
  285. package/src/resources/extensions/gsd/tests/worktree-db.test.ts +39 -38
  286. package/src/resources/extensions/gsd/tests/worktree-e2e.test.ts +21 -17
  287. package/src/resources/extensions/gsd/tests/worktree-health.test.ts +30 -25
  288. package/src/resources/extensions/gsd/tests/worktree-integration.test.ts +37 -30
  289. package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +22 -15
  290. package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +66 -59
  291. package/src/resources/extensions/gsd/tests/worktree.test.ts +50 -44
  292. package/dist/web/standalone/.next/static/chunks/app/page-b9367c5ae13b99c6.js +0 -1
  293. package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +0 -1
  294. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +0 -1
  295. package/src/resources/extensions/gsd/tests/quick-auto-guard.test.ts +0 -100
  296. package/src/resources/extensions/gsd/tests/sqlite-unavailable-gate.test.ts +0 -63
  297. /package/dist/web/standalone/.next/static/{-zps1Q9mQmioAKLcQiCr8 → mgkxN0mGP6gSUmGPEzbk_}/_buildManifest.js +0 -0
  298. /package/dist/web/standalone/.next/static/{-zps1Q9mQmioAKLcQiCr8 → mgkxN0mGP6gSUmGPEzbk_}/_ssgManifest.js +0 -0
@@ -1,5 +1,5 @@
1
1
  import assert from "node:assert/strict";
2
- import { describe, it, afterEach } from "node:test";
2
+ import { describe, it } from "node:test";
3
3
  import { mkdtempSync, rmSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { tmpdir } from "node:os";
@@ -19,39 +19,43 @@ function makeAssistantMessage(input, output, cacheRead = 0, cacheWrite = 0, cost
19
19
  };
20
20
  }
21
21
  describe("SessionManager usage totals", () => {
22
- let dir;
23
- afterEach(() => {
24
- if (dir) {
22
+ it("tracks assistant usage incrementally without rescanning entries", () => {
23
+ const dir = mkdtempSync(join(tmpdir(), "gsd-session-manager-test-"));
24
+ try {
25
+ const manager = SessionManager.create(dir, dir);
26
+ manager.appendMessage({ role: "user", content: [{ type: "text", text: "hello" }] });
27
+ manager.appendMessage(makeAssistantMessage(10, 5, 3, 2, 0.25));
28
+ manager.appendMessage(makeAssistantMessage(7, 4, 1, 0, 0.1));
29
+ assert.deepEqual(manager.getUsageTotals(), {
30
+ input: 17,
31
+ output: 9,
32
+ cacheRead: 4,
33
+ cacheWrite: 2,
34
+ cost: 0.35,
35
+ });
36
+ }
37
+ finally {
25
38
  rmSync(dir, { recursive: true, force: true });
26
39
  }
27
40
  });
28
- it("tracks assistant usage incrementally without rescanning entries", () => {
29
- dir = mkdtempSync(join(tmpdir(), "gsd-session-manager-test-"));
30
- const manager = SessionManager.create(dir, dir);
31
- manager.appendMessage({ role: "user", content: [{ type: "text", text: "hello" }] });
32
- manager.appendMessage(makeAssistantMessage(10, 5, 3, 2, 0.25));
33
- manager.appendMessage(makeAssistantMessage(7, 4, 1, 0, 0.1));
34
- assert.deepEqual(manager.getUsageTotals(), {
35
- input: 17,
36
- output: 9,
37
- cacheRead: 4,
38
- cacheWrite: 2,
39
- cost: 0.35,
40
- });
41
- });
42
41
  it("resets totals when starting a new session", () => {
43
- dir = mkdtempSync(join(tmpdir(), "gsd-session-manager-test-"));
44
- const manager = SessionManager.create(dir, dir);
45
- manager.appendMessage(makeAssistantMessage(5, 5, 0, 0, 0.05));
46
- assert.equal(manager.getUsageTotals().input, 5);
47
- manager.newSession();
48
- assert.deepEqual(manager.getUsageTotals(), {
49
- input: 0,
50
- output: 0,
51
- cacheRead: 0,
52
- cacheWrite: 0,
53
- cost: 0,
54
- });
42
+ const dir = mkdtempSync(join(tmpdir(), "gsd-session-manager-test-"));
43
+ try {
44
+ const manager = SessionManager.create(dir, dir);
45
+ manager.appendMessage(makeAssistantMessage(5, 5, 0, 0, 0.05));
46
+ assert.equal(manager.getUsageTotals().input, 5);
47
+ manager.newSession();
48
+ assert.deepEqual(manager.getUsageTotals(), {
49
+ input: 0,
50
+ output: 0,
51
+ cacheRead: 0,
52
+ cacheWrite: 0,
53
+ cost: 0,
54
+ });
55
+ }
56
+ finally {
57
+ rmSync(dir, { recursive: true, force: true });
58
+ }
55
59
  });
56
60
  });
57
61
  //# sourceMappingURL=session-manager.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-manager.test.js","sourceRoot":"","sources":["../../src/core/session-manager.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,SAAS,oBAAoB,CAAC,KAAa,EAAE,MAAc,EAAE,SAAS,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC;IACnG,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACvC,KAAK,EAAE;YACN,KAAK;YACL,MAAM;YACN,SAAS;YACT,UAAU;YACV,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU;YAC9C,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;SACrB;KACM,CAAC;AACV,CAAC;AAED,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC5C,IAAI,GAAW,CAAC;IAEhB,SAAS,CAAC,GAAG,EAAE;QACd,IA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,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEhD,OAAO,CAAC,UAAU,EAAE,CAAC;QACrB,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE;YAC1C,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,CAAC;SACP,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it, afterEach } from \"node:test\";\nimport { mkdtempSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\n\nimport { SessionManager } from \"./session-manager.js\";\n\nfunction makeAssistantMessage(input: number, output: number, cacheRead = 0, cacheWrite = 0, cost = 0) {\n\treturn {\n\t\trole: \"assistant\",\n\t\tcontent: [{ type: \"text\", text: \"ok\" }],\n\t\tusage: {\n\t\t\tinput,\n\t\t\toutput,\n\t\t\tcacheRead,\n\t\t\tcacheWrite,\n\t\t\ttotal: input + output + cacheRead + cacheWrite,\n\t\t\tcost: { total: cost },\n\t\t},\n\t} as any;\n}\n\ndescribe(\"SessionManager usage totals\", () => {\n\tlet dir: string;\n\n\tafterEach(() => {\n\t\tif (dir) {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t}\n\t});\n\n\tit(\"tracks assistant usage incrementally without rescanning entries\", () => {\n\t\tdir = mkdtempSync(join(tmpdir(), \"gsd-session-manager-test-\"));\n\t\tconst manager = SessionManager.create(dir, dir);\n\n\t\tmanager.appendMessage({ role: \"user\", content: [{ type: \"text\", text: \"hello\" }] } as any);\n\t\tmanager.appendMessage(makeAssistantMessage(10, 5, 3, 2, 0.25));\n\t\tmanager.appendMessage(makeAssistantMessage(7, 4, 1, 0, 0.1));\n\n\t\tassert.deepEqual(manager.getUsageTotals(), {\n\t\t\tinput: 17,\n\t\t\toutput: 9,\n\t\t\tcacheRead: 4,\n\t\t\tcacheWrite: 2,\n\t\t\tcost: 0.35,\n\t\t});\n\t});\n\n\tit(\"resets totals when starting a new session\", () => {\n\t\tdir = mkdtempSync(join(tmpdir(), \"gsd-session-manager-test-\"));\n\t\tconst manager = SessionManager.create(dir, dir);\n\t\tmanager.appendMessage(makeAssistantMessage(5, 5, 0, 0, 0.05));\n\t\tassert.equal(manager.getUsageTotals().input, 5);\n\n\t\tmanager.newSession();\n\t\tassert.deepEqual(manager.getUsageTotals(), {\n\t\t\tinput: 0,\n\t\t\toutput: 0,\n\t\t\tcacheRead: 0,\n\t\t\tcacheWrite: 0,\n\t\t\tcost: 0,\n\t\t});\n\t});\n});\n"]}
1
+ {"version":3,"file":"session-manager.test.js","sourceRoot":"","sources":["../../src/core/session-manager.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,SAAS,oBAAoB,CAAC,KAAa,EAAE,MAAc,EAAE,SAAS,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC;IACnG,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACvC,KAAK,EAAE;YACN,KAAK;YACL,MAAM;YACN,S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D,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,2BAA2B,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAChD,OAAO,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;YAC9D,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAEhD,OAAO,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE;gBAC1C,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,CAAC;gBACT,SAAS,EAAE,CAAC;gBACZ,UAAU,EAAE,CAAC;gBACb,IAAI,EAAE,CAAC;aACP,CAAC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it } from \"node:test\";\nimport { mkdtempSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\n\nimport { SessionManager } from \"./session-manager.js\";\n\nfunction makeAssistantMessage(input: number, output: number, cacheRead = 0, cacheWrite = 0, cost = 0) {\n\treturn {\n\t\trole: \"assistant\",\n\t\tcontent: [{ type: \"text\", text: \"ok\" }],\n\t\tusage: {\n\t\t\tinput,\n\t\t\toutput,\n\t\t\tcacheRead,\n\t\t\tcacheWrite,\n\t\t\ttotal: input + output + cacheRead + cacheWrite,\n\t\t\tcost: { total: cost },\n\t\t},\n\t} as any;\n}\n\ndescribe(\"SessionManager usage totals\", () => {\n\tit(\"tracks assistant usage incrementally without rescanning entries\", () => {\n\t\tconst dir = mkdtempSync(join(tmpdir(), \"gsd-session-manager-test-\"));\n\t\ttry {\n\t\t\tconst manager = SessionManager.create(dir, dir);\n\n\t\t\tmanager.appendMessage({ role: \"user\", content: [{ type: \"text\", text: \"hello\" }] } as any);\n\t\t\tmanager.appendMessage(makeAssistantMessage(10, 5, 3, 2, 0.25));\n\t\t\tmanager.appendMessage(makeAssistantMessage(7, 4, 1, 0, 0.1));\n\n\t\t\tassert.deepEqual(manager.getUsageTotals(), {\n\t\t\t\tinput: 17,\n\t\t\t\toutput: 9,\n\t\t\t\tcacheRead: 4,\n\t\t\t\tcacheWrite: 2,\n\t\t\t\tcost: 0.35,\n\t\t\t});\n\t\t} finally {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t}\n\t});\n\n\tit(\"resets totals when starting a new session\", () => {\n\t\tconst dir = mkdtempSync(join(tmpdir(), \"gsd-session-manager-test-\"));\n\t\ttry {\n\t\t\tconst manager = SessionManager.create(dir, dir);\n\t\t\tmanager.appendMessage(makeAssistantMessage(5, 5, 0, 0, 0.05));\n\t\t\tassert.equal(manager.getUsageTotals().input, 5);\n\n\t\t\tmanager.newSession();\n\t\t\tassert.deepEqual(manager.getUsageTotals(), {\n\t\t\t\tinput: 0,\n\t\t\t\toutput: 0,\n\t\t\t\tcacheRead: 0,\n\t\t\t\tcacheWrite: 0,\n\t\t\t\tcost: 0,\n\t\t\t});\n\t\t} finally {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t}\n\t});\n});\n"]}
@@ -47,18 +47,20 @@ describe("edit-diff", () => {
47
47
  assert.ok(result.firstChangedLine !== undefined);
48
48
  assert.match(result.diff, /CHANGED/);
49
49
  });
50
- it("computes diffs for preview without native helpers", async (t) => {
50
+ it("computes diffs for preview without native helpers", async () => {
51
51
  const dir = mkdtempSync(join(tmpdir(), "edit-diff-test-"));
52
- t.after(() => {
52
+ try {
53
+ const file = join(dir, "sample.ts");
54
+ writeFileSync(file, "const title = “Hello”;\n", "utf-8");
55
+ const result = await computeEditDiff(file, "const title = \"Hello\";\n", "const title = \"Hi\";\n", dir);
56
+ assert.ok(!("error" in result), "expected a diff result");
57
+ if (!("error" in result)) {
58
+ assert.equal(result.firstChangedLine, 1);
59
+ assert.match(result.diff, /\+1 const title = "Hi";/);
60
+ }
61
+ }
62
+ finally {
53
63
  rmSync(dir, { recursive: true, force: true });
54
- });
55
- const file = join(dir, "sample.ts");
56
- writeFileSync(file, "const title = “Hello”;\n", "utf-8");
57
- const result = await computeEditDiff(file, "const title = \"Hello\";\n", "const title = \"Hi\";\n", dir);
58
- assert.ok(!("error" in result), "expected a diff result");
59
- if (!("error" in result)) {
60
- assert.equal(result.firstChangedLine, 1);
61
- assert.match(result.diff, /\+1 const title = "Hi";/);
62
64
  }
63
65
  });
64
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"edit-diff.test.js","sourceRoot":"","sources":["../../../src/core/tools/edit-diff.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EACN,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AAExB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACrE,MAAM,KAAK,GAAG,yCAAyC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE,gCAAgC,CAAC,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mDAAmD,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACnE,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACZ,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACpC,aAAa,CAAC,IAAI,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;QAEzD,MAAM,MAAM,GAAG,MAAM,eAAe,CACnC,IAAI,EACJ,4BAA4B,EAC5B,yBAAyB,EACzB,GAAG,CACH,CAAC;QAEF,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;QACtD,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { describe, it } from \"node:test\";\n\nimport {\n\tcomputeEditDiff,\n\tfuzzyFindText,\n\tgenerateDiffString,\n\tnormalizeForFuzzyMatch,\n} from \"./edit-diff.js\";\n\ndescribe(\"edit-diff\", () => {\n\tit(\"normalizes quotes, dashes, spaces, and trailing whitespace\", () => {\n\t\tconst input = \"“hello”\\u00A0world — test \\nnext\\t\\t\\n\";\n\t\tassert.equal(normalizeForFuzzyMatch(input), \"\\\"hello\\\" world - test\\nnext\\n\");\n\t});\n\n\tit(\"falls back to fuzzy matching when unicode punctuation differs\", () => {\n\t\tconst result = fuzzyFindText(\"const title = “Hello”;\\n\", \"const title = \\\"Hello\\\";\\n\");\n\t\tassert.equal(result.found, true);\n\t\tassert.equal(result.usedFuzzyMatch, true);\n\t\tassert.equal(result.contentForReplacement, \"const title = \\\"Hello\\\";\\n\");\n\t});\n\n\tit(\"renders numbered diffs with the first changed line\", () => {\n\t\tconst result = generateDiffString(\"line 1\\nline 2\\nline 3\\n\", \"line 1\\nline two\\nline 3\\n\");\n\t\tassert.equal(result.firstChangedLine, 2);\n\t\tassert.match(result.diff, /-2 line 2/);\n\t\tassert.match(result.diff, /\\+2 line two/);\n\t});\n\n\tit(\"respects contextLines and inserts separators for distant changes\", () => {\n\t\tconst lines = Array.from({ length: 20 }, (_, i) => `line ${i + 1}`);\n\t\tconst oldContent = lines.join(\"\\n\") + \"\\n\";\n\t\tconst modified = [...lines];\n\t\tmodified[1] = \"changed 2\"; // line 2\n\t\tmodified[17] = \"changed 18\"; // line 18\n\t\tconst newContent = modified.join(\"\\n\") + \"\\n\";\n\n\t\tconst result = generateDiffString(oldContent, newContent, 2);\n\t\t// Should contain separator between the two distant change regions\n\t\tassert.match(result.diff, /\\.\\.\\./);\n\t\t// Should NOT contain lines far from changes (e.g. line 10)\n\t\tassert.doesNotMatch(result.diff, /line 10/);\n\t\t// Should contain the changed lines\n\t\tassert.match(result.diff, /changed 2/);\n\t\tassert.match(result.diff, /changed 18/);\n\t});\n\n\tit(\"handles large files without OOM by falling back to linear diff\", () => {\n\t\t// Create files large enough to exceed the DP threshold\n\t\tconst lineCount = 3000;\n\t\tconst oldLines = Array.from({ length: lineCount }, (_, i) => `line ${i}`);\n\t\tconst newLines = [...oldLines];\n\t\tnewLines[1500] = \"CHANGED\";\n\t\tconst result = generateDiffString(oldLines.join(\"\\n\") + \"\\n\", newLines.join(\"\\n\") + \"\\n\");\n\t\tassert.ok(result.firstChangedLine !== undefined);\n\t\tassert.match(result.diff, /CHANGED/);\n\t});\n\n\tit(\"computes diffs for preview without native helpers\", async (t) => {\n\t\tconst dir = mkdtempSync(join(tmpdir(), \"edit-diff-test-\"));\n\t\tt.after(() => {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t});\n\n\t\tconst file = join(dir, \"sample.ts\");\n\t\twriteFileSync(file, \"const title = “Hello”;\\n\", \"utf-8\");\n\n\t\tconst result = await computeEditDiff(\n\t\t\tfile,\n\t\t\t\"const title = \\\"Hello\\\";\\n\",\n\t\t\t\"const title = \\\"Hi\\\";\\n\",\n\t\t\tdir,\n\t\t);\n\n\t\tassert.ok(!(\"error\" in result), \"expected a diff result\");\n\t\tif (!(\"error\" in result)) {\n\t\t\tassert.equal(result.firstChangedLine, 1);\n\t\t\tassert.match(result.diff, /\\+1 const title = \"Hi\";/);\n\t\t}\n\t});\n});\n"]}
1
+ {"version":3,"file":"edit-diff.test.js","sourceRoot":"","sources":["../../../src/core/tools/edit-diff.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EACN,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AAExB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACrE,MAAM,KAAK,GAAG,yCAAyC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,KAA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AAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YACpC,aAAa,CAAC,IAAI,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;YAEzD,MAAM,MAAM,GAAG,MAAM,eAAe,CACnC,IAAI,EACJ,4BAA4B,EAC5B,yBAAyB,EACzB,GAAG,CACH,CAAC;YAEF,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,EAAE,wBAAwB,CAAC,CAAC;YAC1D,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,EAAE,CAAC;gBAC1B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;gBACzC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;YACtD,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { describe, it } from \"node:test\";\n\nimport {\n\tcomputeEditDiff,\n\tfuzzyFindText,\n\tgenerateDiffString,\n\tnormalizeForFuzzyMatch,\n} from \"./edit-diff.js\";\n\ndescribe(\"edit-diff\", () => {\n\tit(\"normalizes quotes, dashes, spaces, and trailing whitespace\", () => {\n\t\tconst input = \"“hello”\\u00A0world — test \\nnext\\t\\t\\n\";\n\t\tassert.equal(normalizeForFuzzyMatch(input), \"\\\"hello\\\" world - test\\nnext\\n\");\n\t});\n\n\tit(\"falls back to fuzzy matching when unicode punctuation differs\", () => {\n\t\tconst result = fuzzyFindText(\"const title = “Hello”;\\n\", \"const title = \\\"Hello\\\";\\n\");\n\t\tassert.equal(result.found, true);\n\t\tassert.equal(result.usedFuzzyMatch, true);\n\t\tassert.equal(result.contentForReplacement, \"const title = \\\"Hello\\\";\\n\");\n\t});\n\n\tit(\"renders numbered diffs with the first changed line\", () => {\n\t\tconst result = generateDiffString(\"line 1\\nline 2\\nline 3\\n\", \"line 1\\nline two\\nline 3\\n\");\n\t\tassert.equal(result.firstChangedLine, 2);\n\t\tassert.match(result.diff, /-2 line 2/);\n\t\tassert.match(result.diff, /\\+2 line two/);\n\t});\n\n\tit(\"respects contextLines and inserts separators for distant changes\", () => {\n\t\tconst lines = Array.from({ length: 20 }, (_, i) => `line ${i + 1}`);\n\t\tconst oldContent = lines.join(\"\\n\") + \"\\n\";\n\t\tconst modified = [...lines];\n\t\tmodified[1] = \"changed 2\"; // line 2\n\t\tmodified[17] = \"changed 18\"; // line 18\n\t\tconst newContent = modified.join(\"\\n\") + \"\\n\";\n\n\t\tconst result = generateDiffString(oldContent, newContent, 2);\n\t\t// Should contain separator between the two distant change regions\n\t\tassert.match(result.diff, /\\.\\.\\./);\n\t\t// Should NOT contain lines far from changes (e.g. line 10)\n\t\tassert.doesNotMatch(result.diff, /line 10/);\n\t\t// Should contain the changed lines\n\t\tassert.match(result.diff, /changed 2/);\n\t\tassert.match(result.diff, /changed 18/);\n\t});\n\n\tit(\"handles large files without OOM by falling back to linear diff\", () => {\n\t\t// Create files large enough to exceed the DP threshold\n\t\tconst lineCount = 3000;\n\t\tconst oldLines = Array.from({ length: lineCount }, (_, i) => `line ${i}`);\n\t\tconst newLines = [...oldLines];\n\t\tnewLines[1500] = \"CHANGED\";\n\t\tconst result = generateDiffString(oldLines.join(\"\\n\") + \"\\n\", newLines.join(\"\\n\") + \"\\n\");\n\t\tassert.ok(result.firstChangedLine !== undefined);\n\t\tassert.match(result.diff, /CHANGED/);\n\t});\n\n\tit(\"computes diffs for preview without native helpers\", async () => {\n\t\tconst dir = mkdtempSync(join(tmpdir(), \"edit-diff-test-\"));\n\t\ttry {\n\t\t\tconst file = join(dir, \"sample.ts\");\n\t\t\twriteFileSync(file, \"const title = “Hello”;\\n\", \"utf-8\");\n\n\t\t\tconst result = await computeEditDiff(\n\t\t\t\tfile,\n\t\t\t\t\"const title = \\\"Hello\\\";\\n\",\n\t\t\t\t\"const title = \\\"Hi\\\";\\n\",\n\t\t\t\tdir,\n\t\t\t);\n\n\t\t\tassert.ok(!(\"error\" in result), \"expected a diff result\");\n\t\t\tif (!(\"error\" in result)) {\n\t\t\t\tassert.equal(result.firstChangedLine, 1);\n\t\t\t\tassert.match(result.diff, /\\+1 const title = \"Hi\";/);\n\t\t\t}\n\t\t} finally {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t}\n\t});\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  import assert from "node:assert/strict";
2
- import { describe, it, afterEach } from "node:test";
2
+ import { describe, it } from "node:test";
3
3
  import { mkdtempSync, rmSync, readFileSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { tmpdir } from "node:os";
@@ -11,53 +11,57 @@ function wait(ms) {
11
11
  return new Promise((resolve) => setTimeout(resolve, ms));
12
12
  }
13
13
  describe("MemoryStorage debounced persistence", () => {
14
- let dir;
15
- afterEach(() => {
16
- if (dir) {
17
- rmSync(dir, { recursive: true, force: true });
18
- }
19
- });
20
14
  it("multiple rapid mutations only trigger one persist write", async () => {
21
- dir = makeTmpDir();
15
+ const dir = makeTmpDir();
22
16
  const dbPath = join(dir, "test.db");
23
- const storage = await MemoryStorage.create(dbPath);
24
- const initialStat = readFileSync(dbPath);
25
- const initialMtime = initialStat.length;
26
- storage.upsertThreads([
27
- { threadId: "t1", filePath: "/a.txt", fileSize: 100, fileMtime: 1000, cwd: "/proj" },
28
- ]);
29
- storage.upsertThreads([
30
- { threadId: "t2", filePath: "/b.txt", fileSize: 200, fileMtime: 2000, cwd: "/proj" },
31
- ]);
32
- storage.upsertThreads([
33
- { threadId: "t3", filePath: "/c.txt", fileSize: 300, fileMtime: 3000, cwd: "/proj" },
34
- ]);
35
- const afterMutationsBuf = readFileSync(dbPath);
36
- assert.deepEqual(afterMutationsBuf, initialStat, "File should not have been written yet (debounce window has not elapsed)");
37
- await wait(700);
38
- const afterDebounceBuf = readFileSync(dbPath);
39
- assert.notDeepEqual(afterDebounceBuf, initialStat, "File should have been written after debounce window elapsed");
40
- const stats = storage.getStats();
41
- assert.equal(stats.totalThreads, 3);
42
- storage.close();
17
+ try {
18
+ const storage = await MemoryStorage.create(dbPath);
19
+ const initialStat = readFileSync(dbPath);
20
+ const initialMtime = initialStat.length;
21
+ storage.upsertThreads([
22
+ { threadId: "t1", filePath: "/a.txt", fileSize: 100, fileMtime: 1000, cwd: "/proj" },
23
+ ]);
24
+ storage.upsertThreads([
25
+ { threadId: "t2", filePath: "/b.txt", fileSize: 200, fileMtime: 2000, cwd: "/proj" },
26
+ ]);
27
+ storage.upsertThreads([
28
+ { threadId: "t3", filePath: "/c.txt", fileSize: 300, fileMtime: 3000, cwd: "/proj" },
29
+ ]);
30
+ const afterMutationsBuf = readFileSync(dbPath);
31
+ assert.deepEqual(afterMutationsBuf, initialStat, "File should not have been written yet (debounce window has not elapsed)");
32
+ await wait(700);
33
+ const afterDebounceBuf = readFileSync(dbPath);
34
+ assert.notDeepEqual(afterDebounceBuf, initialStat, "File should have been written after debounce window elapsed");
35
+ const stats = storage.getStats();
36
+ assert.equal(stats.totalThreads, 3);
37
+ storage.close();
38
+ }
39
+ finally {
40
+ rmSync(dir, { recursive: true, force: true });
41
+ }
43
42
  });
44
43
  it("close() flushes pending changes immediately without waiting for debounce", async () => {
45
- dir = makeTmpDir();
44
+ const dir = makeTmpDir();
46
45
  const dbPath = join(dir, "test.db");
47
- const storage = await MemoryStorage.create(dbPath);
48
- const initialBuf = readFileSync(dbPath);
49
- storage.upsertThreads([
50
- { threadId: "t1", filePath: "/a.txt", fileSize: 100, fileMtime: 1000, cwd: "/proj" },
51
- ]);
52
- const beforeCloseBuf = readFileSync(dbPath);
53
- assert.deepEqual(beforeCloseBuf, initialBuf, "File should not have been written yet (debounce window has not elapsed)");
54
- storage.close();
55
- const afterCloseBuf = readFileSync(dbPath);
56
- assert.notDeepEqual(afterCloseBuf, initialBuf, "File should have been written immediately on close()");
57
- const reopened = await MemoryStorage.create(dbPath);
58
- const stats = reopened.getStats();
59
- assert.equal(stats.totalThreads, 1, "Data should be persisted and readable after close");
60
- reopened.close();
46
+ try {
47
+ const storage = await MemoryStorage.create(dbPath);
48
+ const initialBuf = readFileSync(dbPath);
49
+ storage.upsertThreads([
50
+ { threadId: "t1", filePath: "/a.txt", fileSize: 100, fileMtime: 1000, cwd: "/proj" },
51
+ ]);
52
+ const beforeCloseBuf = readFileSync(dbPath);
53
+ assert.deepEqual(beforeCloseBuf, initialBuf, "File should not have been written yet (debounce window has not elapsed)");
54
+ storage.close();
55
+ const afterCloseBuf = readFileSync(dbPath);
56
+ assert.notDeepEqual(afterCloseBuf, initialBuf, "File should have been written immediately on close()");
57
+ const reopened = await MemoryStorage.create(dbPath);
58
+ const stats = reopened.getStats();
59
+ assert.equal(stats.totalThreads, 1, "Data should be persisted and readable after close");
60
+ reopened.close();
61
+ }
62
+ finally {
63
+ rmSync(dir, { recursive: true, force: true });
64
+ }
61
65
  });
62
66
  });
63
67
  //# sourceMappingURL=storage.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.test.js","sourceRoot":"","sources":["../../../../src/resources/extensions/memory/storage.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE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,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE;SACpF,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,CAAC,SAAS,CACf,cAAc,EACd,UAAU,EACV,yEAAyE,CACzE,CAAC;QAEF,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,YAAY,CAClB,aAAa,EACb,UAAU,EACV,sDAAsD,CACtD,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,EAAE,mDAAmD,CAAC,CAAC;QACzF,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it, afterEach } from \"node:test\";\nimport { mkdtempSync, rmSync, readFileSync, existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\n\nimport { MemoryStorage } from \"./storage.js\";\n\nfunction makeTmpDir(): string {\n\treturn mkdtempSync(join(tmpdir(), \"gsd-memory-storage-test-\"));\n}\n\nfunction wait(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\ndescribe(\"MemoryStorage debounced persistence\", () => {\n\tlet dir: string;\n\n\tafterEach(() => {\n\t\tif (dir) {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t}\n\t});\n\n\tit(\"multiple rapid mutations only trigger one persist write\", async () => {\n\t\tdir = makeTmpDir();\n\t\tconst dbPath = join(dir, \"test.db\");\n\t\tconst storage = await MemoryStorage.create(dbPath);\n\n\t\tconst initialStat = readFileSync(dbPath);\n\t\tconst initialMtime = initialStat.length;\n\n\t\tstorage.upsertThreads([\n\t\t\t{ threadId: \"t1\", filePath: \"/a.txt\", fileSize: 100, fileMtime: 1000, cwd: \"/proj\" },\n\t\t]);\n\t\tstorage.upsertThreads([\n\t\t\t{ threadId: \"t2\", filePath: \"/b.txt\", fileSize: 200, fileMtime: 2000, cwd: \"/proj\" },\n\t\t]);\n\t\tstorage.upsertThreads([\n\t\t\t{ threadId: \"t3\", filePath: \"/c.txt\", fileSize: 300, fileMtime: 3000, cwd: \"/proj\" },\n\t\t]);\n\n\t\tconst afterMutationsBuf = readFileSync(dbPath);\n\t\tassert.deepEqual(\n\t\t\tafterMutationsBuf,\n\t\t\tinitialStat,\n\t\t\t\"File should not have been written yet (debounce window has not elapsed)\",\n\t\t);\n\n\t\tawait wait(700);\n\n\t\tconst afterDebounceBuf = readFileSync(dbPath);\n\t\tassert.notDeepEqual(\n\t\t\tafterDebounceBuf,\n\t\t\tinitialStat,\n\t\t\t\"File should have been written after debounce window elapsed\",\n\t\t);\n\n\t\tconst stats = storage.getStats();\n\t\tassert.equal(stats.totalThreads, 3);\n\n\t\tstorage.close();\n\t});\n\n\tit(\"close() flushes pending changes immediately without waiting for debounce\", async () => {\n\t\tdir = makeTmpDir();\n\t\tconst dbPath = join(dir, \"test.db\");\n\t\tconst storage = await MemoryStorage.create(dbPath);\n\n\t\tconst initialBuf = readFileSync(dbPath);\n\n\t\tstorage.upsertThreads([\n\t\t\t{ threadId: \"t1\", filePath: \"/a.txt\", fileSize: 100, fileMtime: 1000, cwd: \"/proj\" },\n\t\t]);\n\n\t\tconst beforeCloseBuf = readFileSync(dbPath);\n\t\tassert.deepEqual(\n\t\t\tbeforeCloseBuf,\n\t\t\tinitialBuf,\n\t\t\t\"File should not have been written yet (debounce window has not elapsed)\",\n\t\t);\n\n\t\tstorage.close();\n\n\t\tconst afterCloseBuf = readFileSync(dbPath);\n\t\tassert.notDeepEqual(\n\t\t\tafterCloseBuf,\n\t\t\tinitialBuf,\n\t\t\t\"File should have been written immediately on close()\",\n\t\t);\n\n\t\tconst reopened = await MemoryStorage.create(dbPath);\n\t\tconst stats = reopened.getStats();\n\t\tassert.equal(stats.totalThreads, 1, \"Data should be persisted and readable after close\");\n\t\treopened.close();\n\t});\n});\n"]}
1
+ {"version":3,"file":"storage.test.js","sourceRoot":"","sources":["../../../../src/resources/extensions/memory/storage.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAQ,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAc,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,SAAS,UAAU;IAClB,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,IAAI,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACpD,EAAE,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;QACxE,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACpC,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEnD,MAAM,WAAW,GAAG,YAAY,CAAC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C,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it, mock } from \"node:test\";\nimport { mkdtempSync, rmSync, readFileSync, existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\n\nimport { MemoryStorage } from \"./storage.js\";\n\nfunction makeTmpDir(): string {\n\treturn mkdtempSync(join(tmpdir(), \"gsd-memory-storage-test-\"));\n}\n\nfunction wait(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\ndescribe(\"MemoryStorage debounced persistence\", () => {\n\tit(\"multiple rapid mutations only trigger one persist write\", async () => {\n\t\tconst dir = makeTmpDir();\n\t\tconst dbPath = join(dir, \"test.db\");\n\t\ttry {\n\t\t\tconst storage = await MemoryStorage.create(dbPath);\n\n\t\t\tconst initialStat = readFileSync(dbPath);\n\t\t\tconst initialMtime = initialStat.length;\n\n\t\t\tstorage.upsertThreads([\n\t\t\t\t{ threadId: \"t1\", filePath: \"/a.txt\", fileSize: 100, fileMtime: 1000, cwd: \"/proj\" },\n\t\t\t]);\n\t\t\tstorage.upsertThreads([\n\t\t\t\t{ threadId: \"t2\", filePath: \"/b.txt\", fileSize: 200, fileMtime: 2000, cwd: \"/proj\" },\n\t\t\t]);\n\t\t\tstorage.upsertThreads([\n\t\t\t\t{ threadId: \"t3\", filePath: \"/c.txt\", fileSize: 300, fileMtime: 3000, cwd: \"/proj\" },\n\t\t\t]);\n\n\t\t\tconst afterMutationsBuf = readFileSync(dbPath);\n\t\t\tassert.deepEqual(\n\t\t\t\tafterMutationsBuf,\n\t\t\t\tinitialStat,\n\t\t\t\t\"File should not have been written yet (debounce window has not elapsed)\",\n\t\t\t);\n\n\t\t\tawait wait(700);\n\n\t\t\tconst afterDebounceBuf = readFileSync(dbPath);\n\t\t\tassert.notDeepEqual(\n\t\t\t\tafterDebounceBuf,\n\t\t\t\tinitialStat,\n\t\t\t\t\"File should have been written after debounce window elapsed\",\n\t\t\t);\n\n\t\t\tconst stats = storage.getStats();\n\t\t\tassert.equal(stats.totalThreads, 3);\n\n\t\t\tstorage.close();\n\t\t} finally {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t}\n\t});\n\n\tit(\"close() flushes pending changes immediately without waiting for debounce\", async () => {\n\t\tconst dir = makeTmpDir();\n\t\tconst dbPath = join(dir, \"test.db\");\n\t\ttry {\n\t\t\tconst storage = await MemoryStorage.create(dbPath);\n\n\t\t\tconst initialBuf = readFileSync(dbPath);\n\n\t\t\tstorage.upsertThreads([\n\t\t\t\t{ threadId: \"t1\", filePath: \"/a.txt\", fileSize: 100, fileMtime: 1000, cwd: \"/proj\" },\n\t\t\t]);\n\n\t\t\tconst beforeCloseBuf = readFileSync(dbPath);\n\t\t\tassert.deepEqual(\n\t\t\t\tbeforeCloseBuf,\n\t\t\t\tinitialBuf,\n\t\t\t\t\"File should not have been written yet (debounce window has not elapsed)\",\n\t\t\t);\n\n\t\t\tstorage.close();\n\n\t\t\tconst afterCloseBuf = readFileSync(dbPath);\n\t\t\tassert.notDeepEqual(\n\t\t\t\tafterCloseBuf,\n\t\t\t\tinitialBuf,\n\t\t\t\t\"File should have been written immediately on close()\",\n\t\t\t);\n\n\t\t\tconst reopened = await MemoryStorage.create(dbPath);\n\t\t\tconst stats = reopened.getStats();\n\t\t\tassert.equal(stats.totalThreads, 1, \"Data should be persisted and readable after close\");\n\t\t\treopened.close();\n\t\t} finally {\n\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t}\n\t});\n});\n"]}
@@ -287,7 +287,7 @@ describe("AuthStorage — oauth credential for non-OAuth provider (#2083)", () =
287
287
  assert.equal(key, undefined);
288
288
  });
289
289
 
290
- it("falls through to env var when openrouter has type:oauth credential", async (t) => {
290
+ it("falls through to env var when openrouter has type:oauth credential", async () => {
291
291
  const storage = inMemory({
292
292
  openrouter: {
293
293
  type: "oauth",
@@ -299,17 +299,17 @@ describe("AuthStorage — oauth credential for non-OAuth provider (#2083)", () =
299
299
 
300
300
  // Simulate OPENROUTER_API_KEY being set via env
301
301
  const origEnv = process.env.OPENROUTER_API_KEY;
302
- t.after(() => {
302
+ try {
303
+ process.env.OPENROUTER_API_KEY = "sk-or-v1-env-key";
304
+ const key = await storage.getApiKey("openrouter");
305
+ assert.equal(key, "sk-or-v1-env-key");
306
+ } finally {
303
307
  if (origEnv === undefined) {
304
308
  delete process.env.OPENROUTER_API_KEY;
305
309
  } else {
306
310
  process.env.OPENROUTER_API_KEY = origEnv;
307
311
  }
308
- });
309
-
310
- process.env.OPENROUTER_API_KEY = "sk-or-v1-env-key";
311
- const key = await storage.getApiKey("openrouter");
312
- assert.equal(key, "sk-or-v1-env-key");
312
+ }
313
313
  });
314
314
 
315
315
  it("falls through to fallback resolver when openrouter has type:oauth credential", async () => {
@@ -48,37 +48,37 @@ function makeThrowingExtension(eventType: string, error: Error): Extension {
48
48
  }
49
49
 
50
50
  describe("ExtensionRunner.emitToolCall", () => {
51
- it("catches throwing extension handler and routes to emitError", async (t) => {
51
+ it("catches throwing extension handler and routes to emitError", async () => {
52
52
  const dir = mkdtempSync(join(tmpdir(), "runner-test-"));
53
- t.after(() => {
54
- rmSync(dir, { recursive: true, force: true });
55
- });
56
-
57
- const sessionManager = SessionManager.create(dir, dir);
58
- const authStorage = AuthStorage.create();
59
- const modelRegistry = new ModelRegistry(authStorage, join(dir, "models.json"));
53
+ try {
54
+ const sessionManager = SessionManager.create(dir, dir);
55
+ const authStorage = AuthStorage.create();
56
+ const modelRegistry = new ModelRegistry(authStorage, join(dir, "models.json"));
60
57
 
61
- const throwingExt = makeThrowingExtension("tool_call", new Error("handler crashed"));
62
- const runtime = makeMinimalRuntime();
63
- const runner = new ExtensionRunner([throwingExt], runtime, dir, sessionManager, modelRegistry);
58
+ const throwingExt = makeThrowingExtension("tool_call", new Error("handler crashed"));
59
+ const runtime = makeMinimalRuntime();
60
+ const runner = new ExtensionRunner([throwingExt], runtime, dir, sessionManager, modelRegistry);
64
61
 
65
- const errors: any[] = [];
66
- runner.onError((err) => errors.push(err));
62
+ const errors: any[] = [];
63
+ runner.onError((err) => errors.push(err));
67
64
 
68
- const event: ToolCallEvent = {
69
- type: "tool_call",
70
- toolCallId: "test-123",
71
- toolName: "test_tool",
72
- input: {},
73
- } as ToolCallEvent;
65
+ const event: ToolCallEvent = {
66
+ type: "tool_call",
67
+ toolCallId: "test-123",
68
+ toolName: "test_tool",
69
+ input: {},
70
+ } as ToolCallEvent;
74
71
 
75
- const result = await runner.emitToolCall(event);
72
+ const result = await runner.emitToolCall(event);
76
73
 
77
- // Should not throw — error is caught and routed to emitError
78
- assert.equal(result, undefined);
79
- assert.equal(errors.length, 1);
80
- assert.equal(errors[0].error, "handler crashed");
81
- assert.equal(errors[0].event, "tool_call");
82
- assert.equal(errors[0].extensionPath, "/test/throwing-ext");
74
+ // Should not throw — error is caught and routed to emitError
75
+ assert.equal(result, undefined);
76
+ assert.equal(errors.length, 1);
77
+ assert.equal(errors[0].error, "handler crashed");
78
+ assert.equal(errors[0].event, "tool_call");
79
+ assert.equal(errors[0].extensionPath, "/test/throwing-ext");
80
+ } finally {
81
+ rmSync(dir, { recursive: true, force: true });
82
+ }
83
83
  });
84
84
  });
@@ -1,54 +1,66 @@
1
1
  import assert from "node:assert/strict";
2
- import { describe, it, afterEach } from "node:test";
2
+ import { describe, it } from "node:test";
3
3
  import { mkdtempSync, readFileSync, rmSync, existsSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { tmpdir } from "node:os";
6
6
  import { atomicWriteFileSync } from "./fs-utils.js";
7
7
 
8
8
  describe("atomicWriteFileSync", () => {
9
- let dir: string;
10
-
11
- afterEach(() => {
12
- if (dir) {
9
+ it("writes file content atomically", () => {
10
+ const dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
11
+ try {
12
+ const filePath = join(dir, "test.txt");
13
+ atomicWriteFileSync(filePath, "hello world");
14
+ assert.equal(readFileSync(filePath, "utf-8"), "hello world");
15
+ } finally {
13
16
  rmSync(dir, { recursive: true, force: true });
14
17
  }
15
18
  });
16
19
 
17
- it("writes file content atomically", () => {
18
- dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
19
- const filePath = join(dir, "test.txt");
20
- atomicWriteFileSync(filePath, "hello world");
21
- assert.equal(readFileSync(filePath, "utf-8"), "hello world");
22
- });
23
-
24
20
  it("overwrites existing file atomically", () => {
25
- dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
26
- const filePath = join(dir, "test.txt");
27
- atomicWriteFileSync(filePath, "first");
28
- atomicWriteFileSync(filePath, "second");
29
- assert.equal(readFileSync(filePath, "utf-8"), "second");
21
+ const dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
22
+ try {
23
+ const filePath = join(dir, "test.txt");
24
+ atomicWriteFileSync(filePath, "first");
25
+ atomicWriteFileSync(filePath, "second");
26
+ assert.equal(readFileSync(filePath, "utf-8"), "second");
27
+ } finally {
28
+ rmSync(dir, { recursive: true, force: true });
29
+ }
30
30
  });
31
31
 
32
32
  it("does not leave .tmp file after successful write", () => {
33
- dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
34
- const filePath = join(dir, "test.txt");
35
- atomicWriteFileSync(filePath, "content");
36
- assert.equal(existsSync(filePath + ".tmp"), false);
33
+ const dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
34
+ try {
35
+ const filePath = join(dir, "test.txt");
36
+ atomicWriteFileSync(filePath, "content");
37
+ assert.equal(existsSync(filePath + ".tmp"), false);
38
+ } finally {
39
+ rmSync(dir, { recursive: true, force: true });
40
+ }
37
41
  });
38
42
 
39
43
  it("supports Buffer content", () => {
40
- dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
41
- const filePath = join(dir, "test.bin");
42
- const buf = Buffer.from([0x00, 0x01, 0x02, 0xff]);
43
- atomicWriteFileSync(filePath, buf);
44
- const result = readFileSync(filePath);
45
- assert.deepEqual(result, buf);
44
+ const dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
45
+ try {
46
+ const filePath = join(dir, "test.bin");
47
+ const buf = Buffer.from([0x00, 0x01, 0x02, 0xff]);
48
+ atomicWriteFileSync(filePath, buf);
49
+ const result = readFileSync(filePath);
50
+ assert.deepEqual(result, buf);
51
+ } finally {
52
+ rmSync(dir, { recursive: true, force: true });
53
+ }
46
54
  });
47
55
 
48
56
  it("supports encoding parameter", () => {
49
- dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
50
- const filePath = join(dir, "test.txt");
51
- atomicWriteFileSync(filePath, "utf8 content", "utf-8");
52
- assert.equal(readFileSync(filePath, "utf-8"), "utf8 content");
57
+ const dir = mkdtempSync(join(tmpdir(), "fs-utils-test-"));
58
+ try {
59
+ const filePath = join(dir, "test.txt");
60
+ atomicWriteFileSync(filePath, "utf8 content", "utf-8");
61
+ assert.equal(readFileSync(filePath, "utf-8"), "utf8 content");
62
+ } finally {
63
+ rmSync(dir, { recursive: true, force: true });
64
+ }
53
65
  });
54
66
  });