runwork 0.15.1 → 0.16.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 (404) hide show
  1. package/bundled-types/task-delegation/task-delegation/types.d.ts +6 -0
  2. package/dist/index.js +20237 -116
  3. package/package.json +4 -4
  4. package/dist/__tests__/curl-parser.test.d.ts +0 -1
  5. package/dist/__tests__/curl-parser.test.js +0 -250
  6. package/dist/__tests__/install-scripts.test.d.ts +0 -1
  7. package/dist/__tests__/install-scripts.test.js +0 -280
  8. package/dist/__tests__/types-manager.test.d.ts +0 -1
  9. package/dist/__tests__/types-manager.test.js +0 -89
  10. package/dist/agents/__tests__/chatgpt-registry.test.d.ts +0 -1
  11. package/dist/agents/__tests__/chatgpt-registry.test.js +0 -61
  12. package/dist/agents/__tests__/claude-code-managed-block.test.d.ts +0 -1
  13. package/dist/agents/__tests__/claude-code-managed-block.test.js +0 -105
  14. package/dist/agents/__tests__/claude-code-plugin.test.d.ts +0 -1
  15. package/dist/agents/__tests__/claude-code-plugin.test.js +0 -47
  16. package/dist/agents/__tests__/claude-code-stats.test.d.ts +0 -1
  17. package/dist/agents/__tests__/claude-code-stats.test.js +0 -390
  18. package/dist/agents/__tests__/claude-desktop-memory.test.d.ts +0 -1
  19. package/dist/agents/__tests__/claude-desktop-memory.test.js +0 -154
  20. package/dist/agents/__tests__/claude-desktop-plugin-tree.test.d.ts +0 -1
  21. package/dist/agents/__tests__/claude-desktop-plugin-tree.test.js +0 -161
  22. package/dist/agents/__tests__/claude-desktop-plugin.test.d.ts +0 -1
  23. package/dist/agents/__tests__/claude-desktop-plugin.test.js +0 -117
  24. package/dist/agents/__tests__/claude-desktop-rpm.test.d.ts +0 -1
  25. package/dist/agents/__tests__/claude-desktop-rpm.test.js +0 -126
  26. package/dist/agents/__tests__/claude-desktop-stats.test.d.ts +0 -1
  27. package/dist/agents/__tests__/claude-desktop-stats.test.js +0 -280
  28. package/dist/agents/__tests__/codex-instructions.test.d.ts +0 -1
  29. package/dist/agents/__tests__/codex-instructions.test.js +0 -57
  30. package/dist/agents/__tests__/codex-minimum-permissions.test.d.ts +0 -1
  31. package/dist/agents/__tests__/codex-minimum-permissions.test.js +0 -82
  32. package/dist/agents/__tests__/codex-stats.test.d.ts +0 -1
  33. package/dist/agents/__tests__/codex-stats.test.js +0 -370
  34. package/dist/agents/__tests__/cursor-merge.test.d.ts +0 -1
  35. package/dist/agents/__tests__/cursor-merge.test.js +0 -66
  36. package/dist/agents/__tests__/cursor-stats.test.d.ts +0 -1
  37. package/dist/agents/__tests__/cursor-stats.test.js +0 -183
  38. package/dist/agents/__tests__/defaults-merge.test.d.ts +0 -1
  39. package/dist/agents/__tests__/defaults-merge.test.js +0 -268
  40. package/dist/agents/__tests__/detection.test.d.ts +0 -1
  41. package/dist/agents/__tests__/detection.test.js +0 -89
  42. package/dist/agents/__tests__/graceful-degradation.test.d.ts +0 -1
  43. package/dist/agents/__tests__/graceful-degradation.test.js +0 -129
  44. package/dist/agents/__tests__/instruction-hint.test.d.ts +0 -1
  45. package/dist/agents/__tests__/instruction-hint.test.js +0 -69
  46. package/dist/agents/__tests__/intro-skill.test.d.ts +0 -1
  47. package/dist/agents/__tests__/intro-skill.test.js +0 -193
  48. package/dist/agents/__tests__/schema-validation.test.d.ts +0 -1
  49. package/dist/agents/__tests__/schema-validation.test.js +0 -212
  50. package/dist/agents/__tests__/skill-slug.test.d.ts +0 -1
  51. package/dist/agents/__tests__/skill-slug.test.js +0 -77
  52. package/dist/agents/claude-code.d.ts +0 -59
  53. package/dist/agents/claude-code.js +0 -753
  54. package/dist/agents/claude-desktop-plugin-tree.d.ts +0 -59
  55. package/dist/agents/claude-desktop-plugin-tree.js +0 -143
  56. package/dist/agents/claude-desktop.d.ts +0 -47
  57. package/dist/agents/claude-desktop.js +0 -684
  58. package/dist/agents/cline.d.ts +0 -15
  59. package/dist/agents/cline.js +0 -130
  60. package/dist/agents/codex.d.ts +0 -44
  61. package/dist/agents/codex.js +0 -453
  62. package/dist/agents/conversation-skills.d.ts +0 -18
  63. package/dist/agents/conversation-skills.js +0 -229
  64. package/dist/agents/cursor.d.ts +0 -35
  65. package/dist/agents/cursor.js +0 -294
  66. package/dist/agents/default-config.d.ts +0 -30
  67. package/dist/agents/default-config.js +0 -67
  68. package/dist/agents/defaults-merge.d.ts +0 -87
  69. package/dist/agents/defaults-merge.js +0 -150
  70. package/dist/agents/detect.d.ts +0 -4
  71. package/dist/agents/detect.js +0 -67
  72. package/dist/agents/detection.d.ts +0 -18
  73. package/dist/agents/detection.js +0 -94
  74. package/dist/agents/gemini.d.ts +0 -15
  75. package/dist/agents/gemini.js +0 -122
  76. package/dist/agents/generic-adapter.d.ts +0 -25
  77. package/dist/agents/generic-adapter.js +0 -151
  78. package/dist/agents/intro-skill.d.ts +0 -45
  79. package/dist/agents/intro-skill.js +0 -447
  80. package/dist/agents/registry-data.d.ts +0 -192
  81. package/dist/agents/registry-data.js +0 -669
  82. package/dist/agents/registry.d.ts +0 -13
  83. package/dist/agents/registry.js +0 -36
  84. package/dist/agents/runtime-detection.d.ts +0 -82
  85. package/dist/agents/runtime-detection.js +0 -271
  86. package/dist/agents/session-start-hook.d.ts +0 -37
  87. package/dist/agents/session-start-hook.js +0 -159
  88. package/dist/agents/types.d.ts +0 -171
  89. package/dist/agents/types.js +0 -75
  90. package/dist/agents/utils/instruction-hint.d.ts +0 -21
  91. package/dist/agents/utils/instruction-hint.js +0 -108
  92. package/dist/agents/utils/json-config.d.ts +0 -19
  93. package/dist/agents/utils/json-config.js +0 -69
  94. package/dist/agents/utils/toml-config.d.ts +0 -8
  95. package/dist/agents/utils/toml-config.js +0 -27
  96. package/dist/agents/windsurf.d.ts +0 -14
  97. package/dist/agents/windsurf.js +0 -102
  98. package/dist/api/__tests__/client.test.d.ts +0 -1
  99. package/dist/api/__tests__/client.test.js +0 -272
  100. package/dist/api/client.d.ts +0 -326
  101. package/dist/api/client.js +0 -427
  102. package/dist/auth/__tests__/login-flow.test.d.ts +0 -1
  103. package/dist/auth/__tests__/login-flow.test.js +0 -101
  104. package/dist/auth/__tests__/store.test.d.ts +0 -1
  105. package/dist/auth/__tests__/store.test.js +0 -132
  106. package/dist/auth/login-flow.d.ts +0 -26
  107. package/dist/auth/login-flow.js +0 -137
  108. package/dist/auth/store.d.ts +0 -5
  109. package/dist/auth/store.js +0 -62
  110. package/dist/commands/__tests__/clone-args.test.d.ts +0 -1
  111. package/dist/commands/__tests__/clone-args.test.js +0 -51
  112. package/dist/commands/__tests__/clone-source-result.test.d.ts +0 -1
  113. package/dist/commands/__tests__/clone-source-result.test.js +0 -45
  114. package/dist/commands/__tests__/info-merge.test.d.ts +0 -1
  115. package/dist/commands/__tests__/info-merge.test.js +0 -55
  116. package/dist/commands/__tests__/mcp-entries.test.d.ts +0 -1
  117. package/dist/commands/__tests__/mcp-entries.test.js +0 -48
  118. package/dist/commands/__tests__/setup-persona.test.d.ts +0 -1
  119. package/dist/commands/__tests__/setup-persona.test.js +0 -31
  120. package/dist/commands/__tests__/setup.test.d.ts +0 -1
  121. package/dist/commands/__tests__/setup.test.js +0 -81
  122. package/dist/commands/__tests__/sync-redetect.test.d.ts +0 -1
  123. package/dist/commands/__tests__/sync-redetect.test.js +0 -96
  124. package/dist/commands/__tests__/sync-telemetry.test.d.ts +0 -1
  125. package/dist/commands/__tests__/sync-telemetry.test.js +0 -281
  126. package/dist/commands/__tests__/upgrade.test.d.ts +0 -1
  127. package/dist/commands/__tests__/upgrade.test.js +0 -157
  128. package/dist/commands/agents.d.ts +0 -2
  129. package/dist/commands/agents.js +0 -160
  130. package/dist/commands/api-keys.d.ts +0 -2
  131. package/dist/commands/api-keys.js +0 -95
  132. package/dist/commands/apps.d.ts +0 -2
  133. package/dist/commands/apps.js +0 -82
  134. package/dist/commands/build-plugin.d.ts +0 -2
  135. package/dist/commands/build-plugin.js +0 -135
  136. package/dist/commands/clone.d.ts +0 -60
  137. package/dist/commands/clone.js +0 -271
  138. package/dist/commands/components.d.ts +0 -2
  139. package/dist/commands/components.js +0 -43
  140. package/dist/commands/deploy.d.ts +0 -2
  141. package/dist/commands/deploy.js +0 -279
  142. package/dist/commands/dev.d.ts +0 -11
  143. package/dist/commands/dev.js +0 -1011
  144. package/dist/commands/doctor.d.ts +0 -2
  145. package/dist/commands/doctor.js +0 -230
  146. package/dist/commands/endpoints.d.ts +0 -2
  147. package/dist/commands/endpoints.js +0 -189
  148. package/dist/commands/entities.d.ts +0 -2
  149. package/dist/commands/entities.js +0 -198
  150. package/dist/commands/files.d.ts +0 -2
  151. package/dist/commands/files.js +0 -193
  152. package/dist/commands/inbox.d.ts +0 -11
  153. package/dist/commands/inbox.js +0 -60
  154. package/dist/commands/info.d.ts +0 -178
  155. package/dist/commands/info.js +0 -455
  156. package/dist/commands/init.d.ts +0 -21
  157. package/dist/commands/init.js +0 -185
  158. package/dist/commands/integrations.d.ts +0 -2
  159. package/dist/commands/integrations.js +0 -233
  160. package/dist/commands/login.d.ts +0 -2
  161. package/dist/commands/login.js +0 -44
  162. package/dist/commands/logout.d.ts +0 -2
  163. package/dist/commands/logout.js +0 -13
  164. package/dist/commands/logs.d.ts +0 -2
  165. package/dist/commands/logs.js +0 -232
  166. package/dist/commands/mcp-entries.d.ts +0 -13
  167. package/dist/commands/mcp-entries.js +0 -26
  168. package/dist/commands/mcp.d.ts +0 -2
  169. package/dist/commands/mcp.js +0 -245
  170. package/dist/commands/open.d.ts +0 -2
  171. package/dist/commands/open.js +0 -53
  172. package/dist/commands/resume.d.ts +0 -2
  173. package/dist/commands/resume.js +0 -289
  174. package/dist/commands/save-convo.d.ts +0 -8
  175. package/dist/commands/save-convo.js +0 -20
  176. package/dist/commands/schedules.d.ts +0 -2
  177. package/dist/commands/schedules.js +0 -221
  178. package/dist/commands/setup.d.ts +0 -27
  179. package/dist/commands/setup.js +0 -177
  180. package/dist/commands/share-convo.d.ts +0 -24
  181. package/dist/commands/share-convo.js +0 -167
  182. package/dist/commands/skills.d.ts +0 -2
  183. package/dist/commands/skills.js +0 -352
  184. package/dist/commands/sync-telemetry.d.ts +0 -33
  185. package/dist/commands/sync-telemetry.js +0 -186
  186. package/dist/commands/sync.d.ts +0 -37
  187. package/dist/commands/sync.js +0 -702
  188. package/dist/commands/uninstall.d.ts +0 -2
  189. package/dist/commands/uninstall.js +0 -145
  190. package/dist/commands/upgrade.d.ts +0 -14
  191. package/dist/commands/upgrade.js +0 -217
  192. package/dist/commands/validate.d.ts +0 -2
  193. package/dist/commands/validate.js +0 -89
  194. package/dist/commands/welcome.d.ts +0 -1
  195. package/dist/commands/welcome.js +0 -86
  196. package/dist/commands/workflows.d.ts +0 -2
  197. package/dist/commands/workflows.js +0 -187
  198. package/dist/deploy/__tests__/deploy-state.test.d.ts +0 -1
  199. package/dist/deploy/__tests__/deploy-state.test.js +0 -80
  200. package/dist/deploy/__tests__/deploy-status.test.d.ts +0 -1
  201. package/dist/deploy/__tests__/deploy-status.test.js +0 -41
  202. package/dist/deploy/__tests__/detach-args.test.d.ts +0 -1
  203. package/dist/deploy/__tests__/detach-args.test.js +0 -30
  204. package/dist/deploy/deploy-state.d.ts +0 -36
  205. package/dist/deploy/deploy-state.js +0 -63
  206. package/dist/deploy/deploy-status.d.ts +0 -21
  207. package/dist/deploy/deploy-status.js +0 -36
  208. package/dist/deploy/detach.d.ts +0 -32
  209. package/dist/deploy/detach.js +0 -71
  210. package/dist/dev/__tests__/attach.test.d.ts +0 -1
  211. package/dist/dev/__tests__/attach.test.js +0 -296
  212. package/dist/dev/__tests__/detach.test.d.ts +0 -1
  213. package/dist/dev/__tests__/detach.test.js +0 -404
  214. package/dist/dev/__tests__/preview-url-poller.test.d.ts +0 -1
  215. package/dist/dev/__tests__/preview-url-poller.test.js +0 -149
  216. package/dist/dev/__tests__/session.test.d.ts +0 -1
  217. package/dist/dev/__tests__/session.test.js +0 -446
  218. package/dist/dev/__tests__/startup-sync.test.d.ts +0 -1
  219. package/dist/dev/__tests__/startup-sync.test.js +0 -32
  220. package/dist/dev/__tests__/stop.test.d.ts +0 -1
  221. package/dist/dev/__tests__/stop.test.js +0 -172
  222. package/dist/dev/attach.d.ts +0 -120
  223. package/dist/dev/attach.js +0 -269
  224. package/dist/dev/detach.d.ts +0 -187
  225. package/dist/dev/detach.js +0 -292
  226. package/dist/dev/preview-url-poller.d.ts +0 -35
  227. package/dist/dev/preview-url-poller.js +0 -50
  228. package/dist/dev/session.d.ts +0 -175
  229. package/dist/dev/session.js +0 -258
  230. package/dist/dev/startup-sync.d.ts +0 -23
  231. package/dist/dev/startup-sync.js +0 -14
  232. package/dist/dev/stop.d.ts +0 -52
  233. package/dist/dev/stop.js +0 -101
  234. package/dist/devtools/registry-data.d.ts +0 -46
  235. package/dist/devtools/registry-data.js +0 -40
  236. package/dist/generated/bundled-types.d.ts +0 -1
  237. package/dist/generated/bundled-types.js +0 -46
  238. package/dist/generated/version.d.ts +0 -1
  239. package/dist/generated/version.js +0 -2
  240. package/dist/git/__tests__/auto-commit.test.d.ts +0 -1
  241. package/dist/git/__tests__/auto-commit.test.js +0 -431
  242. package/dist/git/__tests__/classify-sync-error.test.d.ts +0 -1
  243. package/dist/git/__tests__/classify-sync-error.test.js +0 -57
  244. package/dist/git/__tests__/credential-helper-e2e.test.d.ts +0 -21
  245. package/dist/git/__tests__/credential-helper-e2e.test.js +0 -195
  246. package/dist/git/__tests__/credentials.test.d.ts +0 -1
  247. package/dist/git/__tests__/credentials.test.js +0 -141
  248. package/dist/git/__tests__/deploy-guard.test.d.ts +0 -1
  249. package/dist/git/__tests__/deploy-guard.test.js +0 -61
  250. package/dist/git/__tests__/ensure-git-credential-helper.test.d.ts +0 -1
  251. package/dist/git/__tests__/ensure-git-credential-helper.test.js +0 -133
  252. package/dist/git/__tests__/ensure-runwork-remote.test.d.ts +0 -1
  253. package/dist/git/__tests__/ensure-runwork-remote.test.js +0 -109
  254. package/dist/git/__tests__/identity.test.d.ts +0 -1
  255. package/dist/git/__tests__/identity.test.js +0 -146
  256. package/dist/git/__tests__/manifest.test.d.ts +0 -1
  257. package/dist/git/__tests__/manifest.test.js +0 -446
  258. package/dist/git/__tests__/preflight-resolution.test.d.ts +0 -1
  259. package/dist/git/__tests__/preflight-resolution.test.js +0 -366
  260. package/dist/git/__tests__/preflight.test.d.ts +0 -1
  261. package/dist/git/__tests__/preflight.test.js +0 -36
  262. package/dist/git/__tests__/repo-config.test.d.ts +0 -1
  263. package/dist/git/__tests__/repo-config.test.js +0 -26
  264. package/dist/git/__tests__/sync.test.d.ts +0 -1
  265. package/dist/git/__tests__/sync.test.js +0 -405
  266. package/dist/git/auto-commit.d.ts +0 -35
  267. package/dist/git/auto-commit.js +0 -293
  268. package/dist/git/classify-sync-error.d.ts +0 -21
  269. package/dist/git/classify-sync-error.js +0 -111
  270. package/dist/git/credentials.d.ts +0 -75
  271. package/dist/git/credentials.js +0 -164
  272. package/dist/git/critical-files.d.ts +0 -20
  273. package/dist/git/critical-files.js +0 -68
  274. package/dist/git/deploy-guard.d.ts +0 -53
  275. package/dist/git/deploy-guard.js +0 -78
  276. package/dist/git/identity.d.ts +0 -44
  277. package/dist/git/identity.js +0 -133
  278. package/dist/git/preflight.d.ts +0 -57
  279. package/dist/git/preflight.js +0 -276
  280. package/dist/git/remote.d.ts +0 -37
  281. package/dist/git/remote.js +0 -75
  282. package/dist/git/repo-config.d.ts +0 -8
  283. package/dist/git/repo-config.js +0 -29
  284. package/dist/git/sync.d.ts +0 -15
  285. package/dist/git/sync.js +0 -159
  286. package/dist/health/__tests__/checks.test.d.ts +0 -1
  287. package/dist/health/__tests__/checks.test.js +0 -357
  288. package/dist/health/__tests__/cli-distribution-checks.test.d.ts +0 -1
  289. package/dist/health/__tests__/cli-distribution-checks.test.js +0 -196
  290. package/dist/health/__tests__/fix.test.d.ts +0 -1
  291. package/dist/health/__tests__/fix.test.js +0 -72
  292. package/dist/health/__tests__/runner-filter.test.d.ts +0 -1
  293. package/dist/health/__tests__/runner-filter.test.js +0 -61
  294. package/dist/health/checks.d.ts +0 -42
  295. package/dist/health/checks.js +0 -636
  296. package/dist/health/fix.d.ts +0 -22
  297. package/dist/health/fix.js +0 -62
  298. package/dist/health/runner.d.ts +0 -8
  299. package/dist/health/runner.js +0 -47
  300. package/dist/health/types.d.ts +0 -12
  301. package/dist/health/types.js +0 -1
  302. package/dist/index.d.ts +0 -1
  303. package/dist/logs/__tests__/tailer-format.test.d.ts +0 -1
  304. package/dist/logs/__tests__/tailer-format.test.js +0 -43
  305. package/dist/logs/tailer.d.ts +0 -17
  306. package/dist/logs/tailer.js +0 -217
  307. package/dist/sync/__tests__/change-detect.test.d.ts +0 -1
  308. package/dist/sync/__tests__/change-detect.test.js +0 -123
  309. package/dist/sync/__tests__/hash.test.d.ts +0 -1
  310. package/dist/sync/__tests__/hash.test.js +0 -18
  311. package/dist/sync/change-detect.d.ts +0 -19
  312. package/dist/sync/change-detect.js +0 -136
  313. package/dist/sync/conflict-ui.d.ts +0 -5
  314. package/dist/sync/conflict-ui.js +0 -78
  315. package/dist/sync/executor.d.ts +0 -23
  316. package/dist/sync/executor.js +0 -102
  317. package/dist/sync/hash.d.ts +0 -1
  318. package/dist/sync/hash.js +0 -4
  319. package/dist/sync/types.d.ts +0 -24
  320. package/dist/sync/types.js +0 -1
  321. package/dist/template/manifest.d.ts +0 -17
  322. package/dist/template/manifest.js +0 -145
  323. package/dist/tools/types.d.ts +0 -52
  324. package/dist/tools/types.js +0 -8
  325. package/dist/types-manager.d.ts +0 -1
  326. package/dist/types-manager.js +0 -35
  327. package/dist/types.d.ts +0 -349
  328. package/dist/types.js +0 -1
  329. package/dist/ui/__tests__/banner.test.d.ts +0 -1
  330. package/dist/ui/__tests__/banner.test.js +0 -98
  331. package/dist/ui/__tests__/colors.test.d.ts +0 -1
  332. package/dist/ui/__tests__/colors.test.js +0 -22
  333. package/dist/ui/__tests__/keyboard.test.d.ts +0 -1
  334. package/dist/ui/__tests__/keyboard.test.js +0 -34
  335. package/dist/ui/__tests__/status-line.test.d.ts +0 -1
  336. package/dist/ui/__tests__/status-line.test.js +0 -54
  337. package/dist/ui/banner.d.ts +0 -29
  338. package/dist/ui/banner.js +0 -153
  339. package/dist/ui/colors.d.ts +0 -4
  340. package/dist/ui/colors.js +0 -7
  341. package/dist/ui/keyboard.d.ts +0 -12
  342. package/dist/ui/keyboard.js +0 -61
  343. package/dist/ui/status-line.d.ts +0 -6
  344. package/dist/ui/status-line.js +0 -53
  345. package/dist/utils/__tests__/format-error.test.d.ts +0 -1
  346. package/dist/utils/__tests__/format-error.test.js +0 -43
  347. package/dist/utils/__tests__/help-json.test.d.ts +0 -1
  348. package/dist/utils/__tests__/help-json.test.js +0 -39
  349. package/dist/utils/__tests__/http.test.d.ts +0 -1
  350. package/dist/utils/__tests__/http.test.js +0 -381
  351. package/dist/utils/__tests__/ignore-matcher.test.d.ts +0 -1
  352. package/dist/utils/__tests__/ignore-matcher.test.js +0 -205
  353. package/dist/utils/__tests__/output.test.d.ts +0 -1
  354. package/dist/utils/__tests__/output.test.js +0 -38
  355. package/dist/utils/__tests__/prompt.test.d.ts +0 -1
  356. package/dist/utils/__tests__/prompt.test.js +0 -27
  357. package/dist/utils/__tests__/resolve.test.d.ts +0 -1
  358. package/dist/utils/__tests__/resolve.test.js +0 -95
  359. package/dist/utils/__tests__/sqlite.test.d.ts +0 -1
  360. package/dist/utils/__tests__/sqlite.test.js +0 -89
  361. package/dist/utils/agent-guidance.d.ts +0 -47
  362. package/dist/utils/agent-guidance.js +0 -128
  363. package/dist/utils/app-info.d.ts +0 -70
  364. package/dist/utils/app-info.js +0 -167
  365. package/dist/utils/curl-parser.d.ts +0 -12
  366. package/dist/utils/curl-parser.js +0 -162
  367. package/dist/utils/data-input.d.ts +0 -1
  368. package/dist/utils/data-input.js +0 -38
  369. package/dist/utils/format-error.d.ts +0 -10
  370. package/dist/utils/format-error.js +0 -38
  371. package/dist/utils/fs.d.ts +0 -5
  372. package/dist/utils/fs.js +0 -23
  373. package/dist/utils/help-json.d.ts +0 -70
  374. package/dist/utils/help-json.js +0 -88
  375. package/dist/utils/http.d.ts +0 -46
  376. package/dist/utils/http.js +0 -421
  377. package/dist/utils/ignore-matcher.d.ts +0 -47
  378. package/dist/utils/ignore-matcher.js +0 -132
  379. package/dist/utils/output.d.ts +0 -17
  380. package/dist/utils/output.js +0 -27
  381. package/dist/utils/prompt.d.ts +0 -5
  382. package/dist/utils/prompt.js +0 -42
  383. package/dist/utils/resolve.d.ts +0 -12
  384. package/dist/utils/resolve.js +0 -52
  385. package/dist/utils/setup-state.d.ts +0 -3
  386. package/dist/utils/setup-state.js +0 -19
  387. package/dist/utils/sqlite-adapter.d.ts +0 -48
  388. package/dist/utils/sqlite-adapter.js +0 -147
  389. package/dist/utils/sqlite.d.ts +0 -14
  390. package/dist/utils/sqlite.js +0 -14
  391. package/dist/utils/subprocess.d.ts +0 -19
  392. package/dist/utils/subprocess.js +0 -27
  393. package/dist/utils/which.d.ts +0 -14
  394. package/dist/utils/which.js +0 -47
  395. package/dist/utils/zip.d.ts +0 -7
  396. package/dist/utils/zip.js +0 -42
  397. package/dist/validate/__tests__/validate.test.d.ts +0 -1
  398. package/dist/validate/__tests__/validate.test.js +0 -42
  399. package/dist/validate/freshness.d.ts +0 -28
  400. package/dist/validate/freshness.js +0 -48
  401. package/dist/validate/preview.d.ts +0 -21
  402. package/dist/validate/preview.js +0 -39
  403. package/dist/workspace/resolve.d.ts +0 -19
  404. package/dist/workspace/resolve.js +0 -100
@@ -1,13 +0,0 @@
1
- /**
2
- * CLI-side agent registry entry point.
3
- *
4
- * The data and browser-safe types / lookups live in `./registry-data.ts` so
5
- * that the desktop package can import them without pulling in Node-only
6
- * modules. This file keeps the existing public surface for CLI callers by
7
- * re-exporting everything from the data module and adding the Node-only path
8
- * resolvers used by the generic adapter and `sync` command.
9
- */
10
- export * from './registry-data.js';
11
- import type { PlatformString } from './registry-data.js';
12
- export declare function resolvePlatformString(ps: PlatformString): string | undefined;
13
- export declare function resolveToAbsolute(ps: PlatformString, scope: 'global' | 'project'): string | undefined;
@@ -1,36 +0,0 @@
1
- /**
2
- * CLI-side agent registry entry point.
3
- *
4
- * The data and browser-safe types / lookups live in `./registry-data.ts` so
5
- * that the desktop package can import them without pulling in Node-only
6
- * modules. This file keeps the existing public surface for CLI callers by
7
- * re-exporting everything from the data module and adding the Node-only path
8
- * resolvers used by the generic adapter and `sync` command.
9
- */
10
- import { platform, homedir } from 'os';
11
- import { join } from 'path';
12
- // Re-export types, data, and browser-safe lookups so every existing CLI
13
- // caller keeps working unchanged (`import { getRegistryAgent, ... } from './registry.js'`).
14
- export * from './registry-data.js';
15
- function getNodePlatform() {
16
- const p = platform();
17
- if (p === 'darwin')
18
- return 'macos';
19
- if (p === 'win32')
20
- return 'windows';
21
- return 'linux';
22
- }
23
- export function resolvePlatformString(ps) {
24
- if (typeof ps === 'string')
25
- return ps;
26
- const p = getNodePlatform();
27
- return ps[p] ?? ps.default;
28
- }
29
- export function resolveToAbsolute(ps, scope) {
30
- const resolved = resolvePlatformString(ps);
31
- if (!resolved)
32
- return undefined;
33
- return scope === 'global'
34
- ? join(homedir(), resolved)
35
- : join(process.cwd(), resolved);
36
- }
@@ -1,82 +0,0 @@
1
- /**
2
- * Runtime host-agent detection.
3
- *
4
- * Determines which AI agent the CLI was just invoked FROM (env vars,
5
- * SessionStart hook info file, process tree). Used by `runwork share-convo`
6
- * to locate the active conversation's native transcript file, and by
7
- * `runwork resume` to bias the target agent toward "same as sender."
8
- *
9
- * This is distinct from install-time detection (./detection.ts), which
10
- * answers "is agent X installed on this machine."
11
- *
12
- * Detection priority (highest to lowest fidelity):
13
- *
14
- * 1. SessionStart hook info file at ~/.runwork/sessions/<sessionId>.json,
15
- * keyed by the agent-provided session ID from env. Contains the
16
- * authoritative transcript_path plus rich metadata. Written by the
17
- * Runwork plugin's SessionStart hook script.
18
- *
19
- * 2. Env-var signals (CLAUDE_CODE_SESSION_ID, CODEX_THREAD_ID) plus a
20
- * filesystem walk to locate the JSONL/rollout for that session ID.
21
- *
22
- * 3. Heuristic env vars (CLAUDECODE=1, CODEX_CI=1) when we know we're
23
- * inside the agent but have no session ID. Falls back to mtime-newest
24
- * file in the agent's session directory.
25
- *
26
- * 4. None detected: caller may still proceed with `--source-agent` override
27
- * from the LLM (LLM passed `--native-file` and `--source-agent`).
28
- */
29
- /** Slug values mirror packages/runwork-cli/src/agents/registry-data.ts AGENT_REGISTRY. */
30
- export type DetectedAgentSlug = 'claude-code' | 'claude-desktop' | 'codex' | 'codex-app' | 'gemini' | 'cursor' | 'windsurf' | 'cline';
31
- export interface RuntimeAgentDetection {
32
- slug: DetectedAgentSlug;
33
- sessionId: string | null;
34
- /** Absolute path to the agent's native transcript file for this session, if known. */
35
- sessionFilePath: string | null;
36
- /** Source of the detection, useful for `runwork doctor --verbose` */
37
- source: 'hook-info-file' | 'env-var' | 'heuristic';
38
- /** Hook-info-file contents when source='hook-info-file' (richer metadata) */
39
- hookInfo?: SessionHookInfo;
40
- }
41
- /**
42
- * Shape of `~/.runwork/sessions/<sessionId>.json` files written by the
43
- * SessionStart hook script.
44
- */
45
- export interface SessionHookInfo {
46
- writtenAt: string;
47
- agent: DetectedAgentSlug;
48
- sessionId: string;
49
- transcriptPath?: string | null;
50
- cwd?: string;
51
- gitBranch?: string | null;
52
- gitRemote?: string | null;
53
- model?: string;
54
- mcpServers?: string[];
55
- plugins?: string[];
56
- agentVersion?: string;
57
- pid?: number;
58
- originalPayload?: Record<string, unknown>;
59
- }
60
- /**
61
- * Primary entrypoint. Returns the best-effort identification of the active
62
- * host agent. `null` only if no signals at all are present.
63
- */
64
- export declare function detectCurrentAgent(): RuntimeAgentDetection | null;
65
- /**
66
- * Read the SessionStart hook's info file for a given session ID, if present.
67
- * Returns null when the hook hasn't fired yet (first invocation in the session
68
- * before the hook ran, or the user hasn't installed the hook).
69
- */
70
- export declare function readHookSessionInfo(sessionId: string): SessionHookInfo | null;
71
- /**
72
- * Walk ~/.claude/projects/*\/<sessionId>.jsonl for the matching file.
73
- * Robust against the cwd-encoding rule changing or the recipient running from
74
- * a different cwd than the sender.
75
- */
76
- export declare function findClaudeCodeSessionFile(sessionId: string): string | null;
77
- /**
78
- * Walk ~/.codex/sessions/YYYY/MM/DD/rollout-*-<UUID>.jsonl for the file
79
- * matching this thread/session ID. The codex CLI itself does this scan,
80
- * so dropping the file anywhere in the tree works for resume too.
81
- */
82
- export declare function findCodexRolloutFile(threadId: string): string | null;
@@ -1,271 +0,0 @@
1
- /**
2
- * Runtime host-agent detection.
3
- *
4
- * Determines which AI agent the CLI was just invoked FROM (env vars,
5
- * SessionStart hook info file, process tree). Used by `runwork share-convo`
6
- * to locate the active conversation's native transcript file, and by
7
- * `runwork resume` to bias the target agent toward "same as sender."
8
- *
9
- * This is distinct from install-time detection (./detection.ts), which
10
- * answers "is agent X installed on this machine."
11
- *
12
- * Detection priority (highest to lowest fidelity):
13
- *
14
- * 1. SessionStart hook info file at ~/.runwork/sessions/<sessionId>.json,
15
- * keyed by the agent-provided session ID from env. Contains the
16
- * authoritative transcript_path plus rich metadata. Written by the
17
- * Runwork plugin's SessionStart hook script.
18
- *
19
- * 2. Env-var signals (CLAUDE_CODE_SESSION_ID, CODEX_THREAD_ID) plus a
20
- * filesystem walk to locate the JSONL/rollout for that session ID.
21
- *
22
- * 3. Heuristic env vars (CLAUDECODE=1, CODEX_CI=1) when we know we're
23
- * inside the agent but have no session ID. Falls back to mtime-newest
24
- * file in the agent's session directory.
25
- *
26
- * 4. None detected: caller may still proceed with `--source-agent` override
27
- * from the LLM (LLM passed `--native-file` and `--source-agent`).
28
- */
29
- import { existsSync, readFileSync, statSync, readdirSync } from 'fs';
30
- import { homedir } from 'os';
31
- import { join } from 'path';
32
- const RUNWORK_SESSIONS_DIR = join(homedir(), '.runwork', 'sessions');
33
- /**
34
- * Primary entrypoint. Returns the best-effort identification of the active
35
- * host agent. `null` only if no signals at all are present.
36
- */
37
- export function detectCurrentAgent() {
38
- // 1. Env-var-based session IDs (highest signal): use them to look up the
39
- // hook info file first, then fall back to env+filesystem walk.
40
- const claudeCodeSessionId = process.env.CLAUDE_CODE_SESSION_ID;
41
- if (claudeCodeSessionId) {
42
- const hookInfo = readHookSessionInfo(claudeCodeSessionId);
43
- if (hookInfo) {
44
- return {
45
- slug: hookInfo.agent,
46
- sessionId: claudeCodeSessionId,
47
- sessionFilePath: hookInfo.transcriptPath ?? null,
48
- source: 'hook-info-file',
49
- hookInfo,
50
- };
51
- }
52
- const filePath = findClaudeCodeSessionFile(claudeCodeSessionId);
53
- return {
54
- slug: 'claude-code',
55
- sessionId: claudeCodeSessionId,
56
- sessionFilePath: filePath,
57
- source: 'env-var',
58
- };
59
- }
60
- const codexThreadId = process.env.CODEX_THREAD_ID;
61
- if (codexThreadId) {
62
- const hookInfo = readHookSessionInfo(codexThreadId);
63
- if (hookInfo) {
64
- return {
65
- slug: hookInfo.agent,
66
- sessionId: codexThreadId,
67
- sessionFilePath: hookInfo.transcriptPath ?? null,
68
- source: 'hook-info-file',
69
- hookInfo,
70
- };
71
- }
72
- const filePath = findCodexRolloutFile(codexThreadId);
73
- return {
74
- slug: 'codex',
75
- sessionId: codexThreadId,
76
- sessionFilePath: filePath,
77
- source: 'env-var',
78
- };
79
- }
80
- // 2. Heuristic env vars - we know we're inside the agent but session ID
81
- // was not exposed. mtime-newest fallback.
82
- if (process.env.CLAUDECODE === '1' || process.env.CLAUDECODE === 'true') {
83
- const newest = findNewestClaudeCodeSession();
84
- return {
85
- slug: 'claude-code',
86
- sessionId: newest?.sessionId ?? null,
87
- sessionFilePath: newest?.path ?? null,
88
- source: 'heuristic',
89
- };
90
- }
91
- if (process.env.CODEX_CI === '1') {
92
- const newest = findNewestCodexRollout();
93
- return {
94
- slug: 'codex',
95
- sessionId: newest?.sessionId ?? null,
96
- sessionFilePath: newest?.path ?? null,
97
- source: 'heuristic',
98
- };
99
- }
100
- return null;
101
- }
102
- /**
103
- * Read the SessionStart hook's info file for a given session ID, if present.
104
- * Returns null when the hook hasn't fired yet (first invocation in the session
105
- * before the hook ran, or the user hasn't installed the hook).
106
- */
107
- export function readHookSessionInfo(sessionId) {
108
- const path = join(RUNWORK_SESSIONS_DIR, `${sessionId}.json`);
109
- if (!existsSync(path))
110
- return null;
111
- try {
112
- const raw = readFileSync(path, 'utf8');
113
- const parsed = JSON.parse(raw);
114
- return parsed;
115
- }
116
- catch {
117
- return null;
118
- }
119
- }
120
- /**
121
- * Walk ~/.claude/projects/*\/<sessionId>.jsonl for the matching file.
122
- * Robust against the cwd-encoding rule changing or the recipient running from
123
- * a different cwd than the sender.
124
- */
125
- export function findClaudeCodeSessionFile(sessionId) {
126
- const root = join(homedir(), '.claude', 'projects');
127
- if (!existsSync(root))
128
- return null;
129
- let projectDirs;
130
- try {
131
- projectDirs = readdirSync(root);
132
- }
133
- catch {
134
- return null;
135
- }
136
- for (const dir of projectDirs) {
137
- const candidate = join(root, dir, `${sessionId}.jsonl`);
138
- if (existsSync(candidate))
139
- return candidate;
140
- }
141
- return null;
142
- }
143
- /**
144
- * Walk ~/.codex/sessions/YYYY/MM/DD/rollout-*-<UUID>.jsonl for the file
145
- * matching this thread/session ID. The codex CLI itself does this scan,
146
- * so dropping the file anywhere in the tree works for resume too.
147
- */
148
- export function findCodexRolloutFile(threadId) {
149
- const root = join(homedir(), '.codex', 'sessions');
150
- if (!existsSync(root))
151
- return null;
152
- const stack = [root];
153
- while (stack.length > 0) {
154
- const dir = stack.pop();
155
- let entries;
156
- try {
157
- entries = readdirSync(dir);
158
- }
159
- catch {
160
- continue;
161
- }
162
- for (const entry of entries) {
163
- const full = join(dir, entry);
164
- let s;
165
- try {
166
- s = statSync(full);
167
- }
168
- catch {
169
- continue;
170
- }
171
- if (s.isDirectory()) {
172
- stack.push(full);
173
- }
174
- else if (s.isFile() && entry.includes(threadId) && entry.endsWith('.jsonl')) {
175
- return full;
176
- }
177
- }
178
- }
179
- return null;
180
- }
181
- /**
182
- * Fallback when no session ID env var is set: scan all project folders for
183
- * the most recently modified .jsonl. Fragile with multiple concurrent
184
- * Claude Code windows; documented as a known limitation.
185
- */
186
- function findNewestClaudeCodeSession() {
187
- const root = join(homedir(), '.claude', 'projects');
188
- if (!existsSync(root))
189
- return null;
190
- let projectDirs;
191
- try {
192
- projectDirs = readdirSync(root);
193
- }
194
- catch {
195
- return null;
196
- }
197
- let best = null;
198
- for (const dir of projectDirs) {
199
- const projectPath = join(root, dir);
200
- let files;
201
- try {
202
- files = readdirSync(projectPath);
203
- }
204
- catch {
205
- continue;
206
- }
207
- for (const file of files) {
208
- if (!file.endsWith('.jsonl'))
209
- continue;
210
- const full = join(projectPath, file);
211
- try {
212
- const s = statSync(full);
213
- if (!best || s.mtimeMs > best.mtime) {
214
- best = {
215
- sessionId: file.replace(/\.jsonl$/, ''),
216
- path: full,
217
- mtime: s.mtimeMs,
218
- };
219
- }
220
- }
221
- catch {
222
- continue;
223
- }
224
- }
225
- }
226
- return best ? { sessionId: best.sessionId, path: best.path } : null;
227
- }
228
- function findNewestCodexRollout() {
229
- const root = join(homedir(), '.codex', 'sessions');
230
- if (!existsSync(root))
231
- return null;
232
- const stack = [root];
233
- let best = null;
234
- while (stack.length > 0) {
235
- const dir = stack.pop();
236
- let entries;
237
- try {
238
- entries = readdirSync(dir);
239
- }
240
- catch {
241
- continue;
242
- }
243
- for (const entry of entries) {
244
- const full = join(dir, entry);
245
- let s;
246
- try {
247
- s = statSync(full);
248
- }
249
- catch {
250
- continue;
251
- }
252
- if (s.isDirectory()) {
253
- stack.push(full);
254
- }
255
- else if (s.isFile() && entry.startsWith('rollout-') && entry.endsWith('.jsonl')) {
256
- // Extract UUID from filename: rollout-YYYY-MM-DDThh-mm-ss-<uuid>.jsonl
257
- const match = entry.match(/rollout-[\d-T:]+-([0-9a-f-]{36})\.jsonl$/);
258
- if (!match)
259
- continue;
260
- if (!best || s.mtimeMs > best.mtime) {
261
- best = {
262
- sessionId: match[1],
263
- path: full,
264
- mtime: s.mtimeMs,
265
- };
266
- }
267
- }
268
- }
269
- }
270
- return best ? { sessionId: best.sessionId, path: best.path } : null;
271
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * SessionStart hook script for Claude Code (and any other agent that
3
- * follows the same hook contract: stdin JSON with session_id and
4
- * transcript_path).
5
- *
6
- * SAFETY CONTRACT - this hook MUST NEVER break the user's session.
7
- *
8
- * Failure modes a hook can cause in Claude Code:
9
- * - Non-zero exit -> Claude may surface an error or refuse to start
10
- * - Stdout contamination -> Claude may interpret it as a hook response
11
- * - Hanging -> Blocks the session indefinitely
12
- * - Stderr noise -> Pollutes the user's terminal
13
- *
14
- * Mitigations applied:
15
- * - No `set -e`. Every operation is fault-tolerant with || true.
16
- * - All stdout/stderr from internal operations are redirected to /dev/null.
17
- * - A hard wall-clock timeout via a backgrounded watchdog that SIGKILLs the
18
- * hook if it runs longer than 5 seconds.
19
- * - Wrapped in a "{...} </dev/null/stdin; echo nothing" pattern so failures
20
- * never propagate to Claude.
21
- * - Always exits 0, regardless of any internal failure.
22
- *
23
- * The hook does best-effort logging to a side-channel file
24
- * (~/.runwork/sessions-hook-debug.log, last 50 entries) so we can debug
25
- * issues without ever talking to Claude's stdio.
26
- *
27
- * Installed into the user's Claude Code plugin tree by sync. When Claude
28
- * Code starts a new session, this script runs once and writes
29
- * `~/.runwork/sessions/<sessionId>.json` with rich session metadata. The
30
- * runwork CLI's runtime-detection module reads from that location.
31
- *
32
- * Hook installation locations:
33
- * - Claude Code (sync): ~/.claude/plugins/cache/runwork/<plugin>/<v>/hooks/
34
- * + marketplace mirror
35
- * - Claude Desktop (Cowork): inside the runwork-plugin.zip the user uploads
36
- */
37
- export declare const SESSION_START_HOOK_SCRIPT = "#!/usr/bin/env bash\n# Runwork SessionStart hook - SAFETY-FIRST design.\n#\n# Writes ~/.runwork/sessions/<sessionId>.json with rich session metadata.\n# Generated by the runwork CLI on sync; do not edit by hand.\n#\n# Hard guarantees:\n# - Exits 0 no matter what.\n# - Never writes to Claude's stdout (would corrupt the hook response).\n# - Never hangs (5-second wall-clock kill via watchdog).\n# - Never errors out into Claude's stderr.\n\n# Read full payload from stdin BEFORE we redirect anything; this is the one\n# thing we can't lose.\nPAYLOAD=\"\"\nif [ ! -t 0 ]; then\n PAYLOAD=$(cat 2>/dev/null || true)\nfi\n\n# Suppress every potential side-channel: redirect stdout/stderr to /dev/null\n# for the rest of execution. Claude reads the hook's stdout as a structured\n# response, so any accidental print would be interpreted as protocol data.\nexec 1>/dev/null 2>/dev/null\n\n# Watchdog: kill this hook after 5 seconds no matter what.\n( sleep 5 && kill -9 $$ 2>/dev/null ) &\nWATCHDOG_PID=$!\n# Ensure the watchdog is cleaned up if we exit normally.\ntrap \"kill -9 $WATCHDOG_PID 2>/dev/null; exit 0\" EXIT INT TERM\n\n# Everything below runs in a \"best-effort, never-fail\" mode. We capture\n# extras via subshells with /dev/null redirection and || true so nothing\n# can escape.\n{\n RUNWORK_DIR=\"${HOME:-/tmp}/.runwork\"\n SESSIONS_DIR=\"$RUNWORK_DIR/sessions\"\n DEBUG_LOG=\"$RUNWORK_DIR/sessions-hook-debug.log\"\n\n mkdir -p \"$SESSIONS_DIR\" 2>/dev/null || exit 0\n\n # Bail silently if no payload.\n if [ -z \"$PAYLOAD\" ]; then\n exit 0\n fi\n\n # Parse session_id and transcript_path. Prefer jq when available.\n SESSION_ID=\"\"\n TRANSCRIPT_PATH=\"\"\n CWD=\"\"\n\n if command -v jq >/dev/null 2>&1; then\n SESSION_ID=$(echo \"$PAYLOAD\" | jq -r '.session_id // .sessionId // empty' 2>/dev/null || true)\n TRANSCRIPT_PATH=$(echo \"$PAYLOAD\" | jq -r '.transcript_path // .transcriptPath // empty' 2>/dev/null || true)\n CWD=$(echo \"$PAYLOAD\" | jq -r '.cwd // empty' 2>/dev/null || true)\n else\n # Minimal grep+sed fallback - intentionally permissive about formatting.\n SESSION_ID=$(echo \"$PAYLOAD\" | grep -oE '\"session_id\"[[:space:]]*:[[:space:]]*\"[^\"]+\"' 2>/dev/null | head -1 | sed -E 's/.*\"([^\"]+)\"$/\\1/' || true)\n TRANSCRIPT_PATH=$(echo \"$PAYLOAD\" | grep -oE '\"transcript_path\"[[:space:]]*:[[:space:]]*\"[^\"]+\"' 2>/dev/null | head -1 | sed -E 's/.*\"([^\"]+)\"$/\\1/' || true)\n CWD=$(echo \"$PAYLOAD\" | grep -oE '\"cwd\"[[:space:]]*:[[:space:]]*\"[^\"]+\"' 2>/dev/null | head -1 | sed -E 's/.*\"([^\"]+)\"$/\\1/' || true)\n fi\n\n # Without a session ID we have nothing useful to write.\n if [ -z \"$SESSION_ID\" ]; then\n exit 0\n fi\n\n # Sanity check sessionId looks like a safe filename component\n # (alphanumeric, hyphens, underscores only). Anything weird -> bail.\n case \"$SESSION_ID\" in\n *[!a-zA-Z0-9_-]*) exit 0 ;;\n esac\n\n EFFECTIVE_CWD=\"${CWD:-${PWD:-/}}\"\n\n GIT_BRANCH=\"\"\n GIT_REMOTE=\"\"\n if [ -n \"$EFFECTIVE_CWD\" ] && [ -d \"$EFFECTIVE_CWD\" ]; then\n GIT_BRANCH=$(git -C \"$EFFECTIVE_CWD\" rev-parse --abbrev-ref HEAD 2>/dev/null || true)\n GIT_REMOTE=$(git -C \"$EFFECTIVE_CWD\" config --get remote.origin.url 2>/dev/null | sed -E 's#.*[:/]([^/:]+/[^/]+)(\\.git)?$#\\1#' 2>/dev/null || true)\n fi\n\n AGENT_VERSION=$(claude --version 2>/dev/null | head -1 || true)\n\n OUT_PATH=\"$SESSIONS_DIR/${SESSION_ID}.json\"\n TMP_PATH=\"${OUT_PATH}.tmp.$$\"\n\n # Build JSON safely; values that may contain quotes/backslashes are escaped\n # via a tiny helper. We avoid heredoc + interpolation pitfalls.\n json_escape() {\n # Escape backslash and double-quote, strip newlines.\n printf '%s' \"$1\" | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\"/\\\\\"/g' | tr -d '\\n'\n }\n\n TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || true)\n\n {\n printf '{\\n'\n printf ' \"writtenAt\": \"%s\",\\n' \"$(json_escape \"$TIMESTAMP\")\"\n printf ' \"agent\": \"claude-code\",\\n'\n printf ' \"sessionId\": \"%s\",\\n' \"$(json_escape \"$SESSION_ID\")\"\n printf ' \"transcriptPath\": \"%s\",\\n' \"$(json_escape \"$TRANSCRIPT_PATH\")\"\n printf ' \"cwd\": \"%s\",\\n' \"$(json_escape \"$EFFECTIVE_CWD\")\"\n printf ' \"gitBranch\": \"%s\",\\n' \"$(json_escape \"$GIT_BRANCH\")\"\n printf ' \"gitRemote\": \"%s\",\\n' \"$(json_escape \"$GIT_REMOTE\")\"\n printf ' \"agentVersion\": \"%s\",\\n' \"$(json_escape \"$AGENT_VERSION\")\"\n printf ' \"pid\": %d\\n' \"$$\"\n printf '}\\n'\n } > \"$TMP_PATH\" 2>/dev/null || exit 0\n\n mv \"$TMP_PATH\" \"$OUT_PATH\" 2>/dev/null || true\n\n # Best-effort debug log (rotated to last 50 lines).\n {\n echo \"$(date -u +%Y-%m-%dT%H:%M:%SZ) wrote $OUT_PATH\"\n if [ -f \"$DEBUG_LOG\" ]; then\n tail -49 \"$DEBUG_LOG\" 2>/dev/null || true\n fi\n } > \"${DEBUG_LOG}.tmp\" 2>/dev/null && mv \"${DEBUG_LOG}.tmp\" \"$DEBUG_LOG\" 2>/dev/null || true\n} 2>/dev/null || true\n\n# Hard guarantee.\nexit 0\n";
@@ -1,159 +0,0 @@
1
- /**
2
- * SessionStart hook script for Claude Code (and any other agent that
3
- * follows the same hook contract: stdin JSON with session_id and
4
- * transcript_path).
5
- *
6
- * SAFETY CONTRACT - this hook MUST NEVER break the user's session.
7
- *
8
- * Failure modes a hook can cause in Claude Code:
9
- * - Non-zero exit -> Claude may surface an error or refuse to start
10
- * - Stdout contamination -> Claude may interpret it as a hook response
11
- * - Hanging -> Blocks the session indefinitely
12
- * - Stderr noise -> Pollutes the user's terminal
13
- *
14
- * Mitigations applied:
15
- * - No `set -e`. Every operation is fault-tolerant with || true.
16
- * - All stdout/stderr from internal operations are redirected to /dev/null.
17
- * - A hard wall-clock timeout via a backgrounded watchdog that SIGKILLs the
18
- * hook if it runs longer than 5 seconds.
19
- * - Wrapped in a "{...} </dev/null/stdin; echo nothing" pattern so failures
20
- * never propagate to Claude.
21
- * - Always exits 0, regardless of any internal failure.
22
- *
23
- * The hook does best-effort logging to a side-channel file
24
- * (~/.runwork/sessions-hook-debug.log, last 50 entries) so we can debug
25
- * issues without ever talking to Claude's stdio.
26
- *
27
- * Installed into the user's Claude Code plugin tree by sync. When Claude
28
- * Code starts a new session, this script runs once and writes
29
- * `~/.runwork/sessions/<sessionId>.json` with rich session metadata. The
30
- * runwork CLI's runtime-detection module reads from that location.
31
- *
32
- * Hook installation locations:
33
- * - Claude Code (sync): ~/.claude/plugins/cache/runwork/<plugin>/<v>/hooks/
34
- * + marketplace mirror
35
- * - Claude Desktop (Cowork): inside the runwork-plugin.zip the user uploads
36
- */
37
- export const SESSION_START_HOOK_SCRIPT = `#!/usr/bin/env bash
38
- # Runwork SessionStart hook - SAFETY-FIRST design.
39
- #
40
- # Writes ~/.runwork/sessions/<sessionId>.json with rich session metadata.
41
- # Generated by the runwork CLI on sync; do not edit by hand.
42
- #
43
- # Hard guarantees:
44
- # - Exits 0 no matter what.
45
- # - Never writes to Claude's stdout (would corrupt the hook response).
46
- # - Never hangs (5-second wall-clock kill via watchdog).
47
- # - Never errors out into Claude's stderr.
48
-
49
- # Read full payload from stdin BEFORE we redirect anything; this is the one
50
- # thing we can't lose.
51
- PAYLOAD=""
52
- if [ ! -t 0 ]; then
53
- PAYLOAD=$(cat 2>/dev/null || true)
54
- fi
55
-
56
- # Suppress every potential side-channel: redirect stdout/stderr to /dev/null
57
- # for the rest of execution. Claude reads the hook's stdout as a structured
58
- # response, so any accidental print would be interpreted as protocol data.
59
- exec 1>/dev/null 2>/dev/null
60
-
61
- # Watchdog: kill this hook after 5 seconds no matter what.
62
- ( sleep 5 && kill -9 $$ 2>/dev/null ) &
63
- WATCHDOG_PID=$!
64
- # Ensure the watchdog is cleaned up if we exit normally.
65
- trap "kill -9 $WATCHDOG_PID 2>/dev/null; exit 0" EXIT INT TERM
66
-
67
- # Everything below runs in a "best-effort, never-fail" mode. We capture
68
- # extras via subshells with /dev/null redirection and || true so nothing
69
- # can escape.
70
- {
71
- RUNWORK_DIR="\${HOME:-/tmp}/.runwork"
72
- SESSIONS_DIR="$RUNWORK_DIR/sessions"
73
- DEBUG_LOG="$RUNWORK_DIR/sessions-hook-debug.log"
74
-
75
- mkdir -p "$SESSIONS_DIR" 2>/dev/null || exit 0
76
-
77
- # Bail silently if no payload.
78
- if [ -z "$PAYLOAD" ]; then
79
- exit 0
80
- fi
81
-
82
- # Parse session_id and transcript_path. Prefer jq when available.
83
- SESSION_ID=""
84
- TRANSCRIPT_PATH=""
85
- CWD=""
86
-
87
- if command -v jq >/dev/null 2>&1; then
88
- SESSION_ID=$(echo "$PAYLOAD" | jq -r '.session_id // .sessionId // empty' 2>/dev/null || true)
89
- TRANSCRIPT_PATH=$(echo "$PAYLOAD" | jq -r '.transcript_path // .transcriptPath // empty' 2>/dev/null || true)
90
- CWD=$(echo "$PAYLOAD" | jq -r '.cwd // empty' 2>/dev/null || true)
91
- else
92
- # Minimal grep+sed fallback - intentionally permissive about formatting.
93
- SESSION_ID=$(echo "$PAYLOAD" | grep -oE '"session_id"[[:space:]]*:[[:space:]]*"[^"]+"' 2>/dev/null | head -1 | sed -E 's/.*"([^"]+)"$/\\1/' || true)
94
- TRANSCRIPT_PATH=$(echo "$PAYLOAD" | grep -oE '"transcript_path"[[:space:]]*:[[:space:]]*"[^"]+"' 2>/dev/null | head -1 | sed -E 's/.*"([^"]+)"$/\\1/' || true)
95
- CWD=$(echo "$PAYLOAD" | grep -oE '"cwd"[[:space:]]*:[[:space:]]*"[^"]+"' 2>/dev/null | head -1 | sed -E 's/.*"([^"]+)"$/\\1/' || true)
96
- fi
97
-
98
- # Without a session ID we have nothing useful to write.
99
- if [ -z "$SESSION_ID" ]; then
100
- exit 0
101
- fi
102
-
103
- # Sanity check sessionId looks like a safe filename component
104
- # (alphanumeric, hyphens, underscores only). Anything weird -> bail.
105
- case "$SESSION_ID" in
106
- *[!a-zA-Z0-9_-]*) exit 0 ;;
107
- esac
108
-
109
- EFFECTIVE_CWD="\${CWD:-\${PWD:-/}}"
110
-
111
- GIT_BRANCH=""
112
- GIT_REMOTE=""
113
- if [ -n "$EFFECTIVE_CWD" ] && [ -d "$EFFECTIVE_CWD" ]; then
114
- GIT_BRANCH=$(git -C "$EFFECTIVE_CWD" rev-parse --abbrev-ref HEAD 2>/dev/null || true)
115
- GIT_REMOTE=$(git -C "$EFFECTIVE_CWD" config --get remote.origin.url 2>/dev/null | sed -E 's#.*[:/]([^/:]+/[^/]+)(\\.git)?$#\\1#' 2>/dev/null || true)
116
- fi
117
-
118
- AGENT_VERSION=$(claude --version 2>/dev/null | head -1 || true)
119
-
120
- OUT_PATH="$SESSIONS_DIR/\${SESSION_ID}.json"
121
- TMP_PATH="\${OUT_PATH}.tmp.$$"
122
-
123
- # Build JSON safely; values that may contain quotes/backslashes are escaped
124
- # via a tiny helper. We avoid heredoc + interpolation pitfalls.
125
- json_escape() {
126
- # Escape backslash and double-quote, strip newlines.
127
- printf '%s' "$1" | sed -e 's/\\\\/\\\\\\\\/g' -e 's/"/\\\\"/g' | tr -d '\\n'
128
- }
129
-
130
- TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || true)
131
-
132
- {
133
- printf '{\\n'
134
- printf ' "writtenAt": "%s",\\n' "$(json_escape "$TIMESTAMP")"
135
- printf ' "agent": "claude-code",\\n'
136
- printf ' "sessionId": "%s",\\n' "$(json_escape "$SESSION_ID")"
137
- printf ' "transcriptPath": "%s",\\n' "$(json_escape "$TRANSCRIPT_PATH")"
138
- printf ' "cwd": "%s",\\n' "$(json_escape "$EFFECTIVE_CWD")"
139
- printf ' "gitBranch": "%s",\\n' "$(json_escape "$GIT_BRANCH")"
140
- printf ' "gitRemote": "%s",\\n' "$(json_escape "$GIT_REMOTE")"
141
- printf ' "agentVersion": "%s",\\n' "$(json_escape "$AGENT_VERSION")"
142
- printf ' "pid": %d\\n' "$$"
143
- printf '}\\n'
144
- } > "$TMP_PATH" 2>/dev/null || exit 0
145
-
146
- mv "$TMP_PATH" "$OUT_PATH" 2>/dev/null || true
147
-
148
- # Best-effort debug log (rotated to last 50 lines).
149
- {
150
- echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) wrote $OUT_PATH"
151
- if [ -f "$DEBUG_LOG" ]; then
152
- tail -49 "$DEBUG_LOG" 2>/dev/null || true
153
- fi
154
- } > "\${DEBUG_LOG}.tmp" 2>/dev/null && mv "\${DEBUG_LOG}.tmp" "$DEBUG_LOG" 2>/dev/null || true
155
- } 2>/dev/null || true
156
-
157
- # Hard guarantee.
158
- exit 0
159
- `;