patchwork-os 0.2.0-alpha.34 → 0.2.0-alpha.36

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 (270) hide show
  1. package/README.md +202 -93
  2. package/deploy/bootstrap-new-vps.sh +12 -12
  3. package/deploy/bootstrap-vps.sh +6 -3
  4. package/deploy/deploy-landing.sh +59 -2
  5. package/dist/activityLog.d.ts +49 -0
  6. package/dist/activityLog.js +78 -0
  7. package/dist/activityLog.js.map +1 -1
  8. package/dist/approvalHttp.d.ts +25 -0
  9. package/dist/approvalHttp.js +74 -18
  10. package/dist/approvalHttp.js.map +1 -1
  11. package/dist/approvalInsights.d.ts +49 -0
  12. package/dist/approvalInsights.js +97 -0
  13. package/dist/approvalInsights.js.map +1 -0
  14. package/dist/approvalQueue.d.ts +11 -0
  15. package/dist/approvalQueue.js +80 -1
  16. package/dist/approvalQueue.js.map +1 -1
  17. package/dist/approvalSignals.d.ts +124 -0
  18. package/dist/approvalSignals.js +512 -0
  19. package/dist/approvalSignals.js.map +1 -0
  20. package/dist/automation.d.ts +37 -0
  21. package/dist/automation.js +105 -61
  22. package/dist/automation.js.map +1 -1
  23. package/dist/automationSuggestions.d.ts +79 -0
  24. package/dist/automationSuggestions.js +150 -0
  25. package/dist/automationSuggestions.js.map +1 -0
  26. package/dist/bridge.js +78 -1
  27. package/dist/bridge.js.map +1 -1
  28. package/dist/ccPermissions.d.ts +15 -0
  29. package/dist/ccPermissions.js +15 -0
  30. package/dist/ccPermissions.js.map +1 -1
  31. package/dist/claudeDriver.js +74 -16
  32. package/dist/claudeDriver.js.map +1 -1
  33. package/dist/commands/patchworkInit.d.ts +8 -0
  34. package/dist/commands/patchworkInit.js +41 -5
  35. package/dist/commands/patchworkInit.js.map +1 -1
  36. package/dist/commands/recipe.d.ts +20 -0
  37. package/dist/commands/recipe.js +212 -6
  38. package/dist/commands/recipe.js.map +1 -1
  39. package/dist/commands/recipeInstall.d.ts +79 -1
  40. package/dist/commands/recipeInstall.js +333 -16
  41. package/dist/commands/recipeInstall.js.map +1 -1
  42. package/dist/commands/tracesExport.d.ts +83 -0
  43. package/dist/commands/tracesExport.js +269 -0
  44. package/dist/commands/tracesExport.js.map +1 -0
  45. package/dist/commands/tracesImport.d.ts +56 -0
  46. package/dist/commands/tracesImport.js +161 -0
  47. package/dist/commands/tracesImport.js.map +1 -0
  48. package/dist/config.d.ts +8 -0
  49. package/dist/config.js +9 -1
  50. package/dist/config.js.map +1 -1
  51. package/dist/connectorRoutes.d.ts +43 -0
  52. package/dist/connectorRoutes.js +1023 -0
  53. package/dist/connectorRoutes.js.map +1 -0
  54. package/dist/connectors/asana.d.ts +198 -0
  55. package/dist/connectors/asana.js +679 -0
  56. package/dist/connectors/asana.js.map +1 -0
  57. package/dist/connectors/baseConnector.d.ts +36 -0
  58. package/dist/connectors/baseConnector.js +151 -28
  59. package/dist/connectors/baseConnector.js.map +1 -1
  60. package/dist/connectors/discord.d.ts +150 -0
  61. package/dist/connectors/discord.js +543 -0
  62. package/dist/connectors/discord.js.map +1 -0
  63. package/dist/connectors/github.js +11 -4
  64. package/dist/connectors/github.js.map +1 -1
  65. package/dist/connectors/gitlab.d.ts +180 -0
  66. package/dist/connectors/gitlab.js +582 -0
  67. package/dist/connectors/gitlab.js.map +1 -0
  68. package/dist/connectors/gmail.js +50 -10
  69. package/dist/connectors/gmail.js.map +1 -1
  70. package/dist/connectors/googleCalendar.js +36 -10
  71. package/dist/connectors/googleCalendar.js.map +1 -1
  72. package/dist/connectors/googleDrive.d.ts +34 -0
  73. package/dist/connectors/googleDrive.js +321 -0
  74. package/dist/connectors/googleDrive.js.map +1 -0
  75. package/dist/connectors/linear.js +23 -4
  76. package/dist/connectors/linear.js.map +1 -1
  77. package/dist/connectors/mcpOAuth.js +26 -2
  78. package/dist/connectors/mcpOAuth.js.map +1 -1
  79. package/dist/connectors/oauthStateStore.d.ts +31 -0
  80. package/dist/connectors/oauthStateStore.js +52 -0
  81. package/dist/connectors/oauthStateStore.js.map +1 -0
  82. package/dist/connectors/pagerduty.d.ts +160 -0
  83. package/dist/connectors/pagerduty.js +464 -0
  84. package/dist/connectors/pagerduty.js.map +1 -0
  85. package/dist/connectors/slack.d.ts +16 -1
  86. package/dist/connectors/slack.js +57 -5
  87. package/dist/connectors/slack.js.map +1 -1
  88. package/dist/connectors/tokenStorage.js +27 -2
  89. package/dist/connectors/tokenStorage.js.map +1 -1
  90. package/dist/connectors/zendesk.js +19 -1
  91. package/dist/connectors/zendesk.js.map +1 -1
  92. package/dist/cors.d.ts +10 -0
  93. package/dist/cors.js +29 -0
  94. package/dist/cors.js.map +1 -0
  95. package/dist/decisionReplay.d.ts +72 -0
  96. package/dist/decisionReplay.js +92 -0
  97. package/dist/decisionReplay.js.map +1 -0
  98. package/dist/decisionTraceLog.d.ts +6 -0
  99. package/dist/decisionTraceLog.js +54 -2
  100. package/dist/decisionTraceLog.js.map +1 -1
  101. package/dist/featureFlags.d.ts +17 -11
  102. package/dist/featureFlags.js +52 -47
  103. package/dist/featureFlags.js.map +1 -1
  104. package/dist/fp/automationInterpreter.js +25 -21
  105. package/dist/fp/automationInterpreter.js.map +1 -1
  106. package/dist/fp/automationState.js +4 -1
  107. package/dist/fp/automationState.js.map +1 -1
  108. package/dist/fp/policyParser.js +4 -1
  109. package/dist/fp/policyParser.js.map +1 -1
  110. package/dist/inboxRoutes.d.ts +22 -0
  111. package/dist/inboxRoutes.js +114 -0
  112. package/dist/inboxRoutes.js.map +1 -0
  113. package/dist/index.js +734 -144
  114. package/dist/index.js.map +1 -1
  115. package/dist/mcpRoutes.d.ts +37 -0
  116. package/dist/mcpRoutes.js +76 -0
  117. package/dist/mcpRoutes.js.map +1 -0
  118. package/dist/oauth.d.ts +3 -0
  119. package/dist/oauth.js +151 -26
  120. package/dist/oauth.js.map +1 -1
  121. package/dist/oauthRoutes.d.ts +32 -0
  122. package/dist/oauthRoutes.js +124 -0
  123. package/dist/oauthRoutes.js.map +1 -0
  124. package/dist/orchestrator/orchestratorBridge.js +2 -2
  125. package/dist/orchestrator/orchestratorBridge.js.map +1 -1
  126. package/dist/patchworkConfig.d.ts +7 -0
  127. package/dist/patchworkConfig.js.map +1 -1
  128. package/dist/pluginLoader.d.ts +12 -0
  129. package/dist/pluginLoader.js +43 -4
  130. package/dist/pluginLoader.js.map +1 -1
  131. package/dist/pluginWatcher.js +8 -3
  132. package/dist/pluginWatcher.js.map +1 -1
  133. package/dist/preToolUseHook.d.ts +12 -0
  134. package/dist/preToolUseHook.js +23 -0
  135. package/dist/preToolUseHook.js.map +1 -1
  136. package/dist/recipeOrchestration.d.ts +8 -0
  137. package/dist/recipeOrchestration.js +320 -39
  138. package/dist/recipeOrchestration.js.map +1 -1
  139. package/dist/recipeRoutes.d.ts +154 -0
  140. package/dist/recipeRoutes.js +1098 -0
  141. package/dist/recipeRoutes.js.map +1 -0
  142. package/dist/recipes/captureForRunlog.d.ts +27 -0
  143. package/dist/recipes/captureForRunlog.js +128 -0
  144. package/dist/recipes/captureForRunlog.js.map +1 -0
  145. package/dist/recipes/chainedRunner.d.ts +54 -3
  146. package/dist/recipes/chainedRunner.js +256 -36
  147. package/dist/recipes/chainedRunner.js.map +1 -1
  148. package/dist/recipes/compiler.js +3 -3
  149. package/dist/recipes/compiler.js.map +1 -1
  150. package/dist/recipes/detectSilentFail.d.ts +34 -0
  151. package/dist/recipes/detectSilentFail.js +105 -0
  152. package/dist/recipes/detectSilentFail.js.map +1 -0
  153. package/dist/recipes/installer.js +3 -3
  154. package/dist/recipes/installer.js.map +1 -1
  155. package/dist/recipes/manifest.js +21 -6
  156. package/dist/recipes/manifest.js.map +1 -1
  157. package/dist/recipes/migrationWarnings.d.ts +12 -0
  158. package/dist/recipes/migrationWarnings.js +44 -0
  159. package/dist/recipes/migrationWarnings.js.map +1 -0
  160. package/dist/recipes/replayRun.d.ts +62 -0
  161. package/dist/recipes/replayRun.js +97 -0
  162. package/dist/recipes/replayRun.js.map +1 -0
  163. package/dist/recipes/resolveRecipePath.d.ts +69 -0
  164. package/dist/recipes/resolveRecipePath.js +202 -0
  165. package/dist/recipes/resolveRecipePath.js.map +1 -0
  166. package/dist/recipes/scheduler.js +102 -11
  167. package/dist/recipes/scheduler.js.map +1 -1
  168. package/dist/recipes/schemaGenerator.js +3 -3
  169. package/dist/recipes/schemaGenerator.js.map +1 -1
  170. package/dist/recipes/toolRegistry.d.ts +5 -0
  171. package/dist/recipes/toolRegistry.js +9 -0
  172. package/dist/recipes/toolRegistry.js.map +1 -1
  173. package/dist/recipes/tools/asana.d.ts +16 -0
  174. package/dist/recipes/tools/asana.js +524 -0
  175. package/dist/recipes/tools/asana.js.map +1 -0
  176. package/dist/recipes/tools/discord.d.ts +18 -0
  177. package/dist/recipes/tools/discord.js +254 -0
  178. package/dist/recipes/tools/discord.js.map +1 -0
  179. package/dist/recipes/tools/file.d.ts +6 -0
  180. package/dist/recipes/tools/file.js +12 -8
  181. package/dist/recipes/tools/file.js.map +1 -1
  182. package/dist/recipes/tools/github.js +29 -4
  183. package/dist/recipes/tools/github.js.map +1 -1
  184. package/dist/recipes/tools/gitlab.d.ts +11 -0
  185. package/dist/recipes/tools/gitlab.js +285 -0
  186. package/dist/recipes/tools/gitlab.js.map +1 -0
  187. package/dist/recipes/tools/gmail.d.ts +1 -1
  188. package/dist/recipes/tools/gmail.js +230 -6
  189. package/dist/recipes/tools/gmail.js.map +1 -1
  190. package/dist/recipes/tools/googleDrive.d.ts +1 -0
  191. package/dist/recipes/tools/googleDrive.js +55 -0
  192. package/dist/recipes/tools/googleDrive.js.map +1 -0
  193. package/dist/recipes/tools/index.d.ts +8 -0
  194. package/dist/recipes/tools/index.js +8 -0
  195. package/dist/recipes/tools/index.js.map +1 -1
  196. package/dist/recipes/tools/jira.d.ts +14 -0
  197. package/dist/recipes/tools/jira.js +369 -0
  198. package/dist/recipes/tools/jira.js.map +1 -0
  199. package/dist/recipes/tools/linear.d.ts +2 -1
  200. package/dist/recipes/tools/linear.js +227 -3
  201. package/dist/recipes/tools/linear.js.map +1 -1
  202. package/dist/recipes/tools/meetingNotes.d.ts +21 -0
  203. package/dist/recipes/tools/meetingNotes.js +701 -0
  204. package/dist/recipes/tools/meetingNotes.js.map +1 -0
  205. package/dist/recipes/tools/pagerduty.d.ts +15 -0
  206. package/dist/recipes/tools/pagerduty.js +451 -0
  207. package/dist/recipes/tools/pagerduty.js.map +1 -0
  208. package/dist/recipes/tools/sentry.d.ts +12 -0
  209. package/dist/recipes/tools/sentry.js +73 -0
  210. package/dist/recipes/tools/sentry.js.map +1 -0
  211. package/dist/recipes/tools/slack.js +15 -5
  212. package/dist/recipes/tools/slack.js.map +1 -1
  213. package/dist/recipes/validation.js +83 -14
  214. package/dist/recipes/validation.js.map +1 -1
  215. package/dist/recipes/yamlRunner.d.ts +30 -2
  216. package/dist/recipes/yamlRunner.js +369 -70
  217. package/dist/recipes/yamlRunner.js.map +1 -1
  218. package/dist/recipesHttp.d.ts +76 -1
  219. package/dist/recipesHttp.js +474 -12
  220. package/dist/recipesHttp.js.map +1 -1
  221. package/dist/runLog.d.ts +78 -2
  222. package/dist/runLog.js +204 -6
  223. package/dist/runLog.js.map +1 -1
  224. package/dist/schemas/dry-run-plan.v1.json +139 -0
  225. package/dist/schemas/recipe.v1.json +684 -0
  226. package/dist/server.d.ts +79 -10
  227. package/dist/server.js +366 -1384
  228. package/dist/server.js.map +1 -1
  229. package/dist/ssrfGuard.d.ts +54 -0
  230. package/dist/ssrfGuard.js +122 -0
  231. package/dist/ssrfGuard.js.map +1 -0
  232. package/dist/streamableHttp.d.ts +39 -1
  233. package/dist/streamableHttp.js +126 -17
  234. package/dist/streamableHttp.js.map +1 -1
  235. package/dist/tools/getDocumentSymbols.d.ts +24 -0
  236. package/dist/tools/getDocumentSymbols.js +74 -8
  237. package/dist/tools/getDocumentSymbols.js.map +1 -1
  238. package/dist/tools/getSecurityAdvisories.js +10 -1
  239. package/dist/tools/getSecurityAdvisories.js.map +1 -1
  240. package/dist/tools/getSessionUsage.d.ts +3 -0
  241. package/dist/tools/getSessionUsage.js +3 -0
  242. package/dist/tools/getSessionUsage.js.map +1 -1
  243. package/dist/tools/index.d.ts +8 -0
  244. package/dist/tools/index.js +32 -2
  245. package/dist/tools/index.js.map +1 -1
  246. package/dist/tools/slackPostMessage.js +1 -1
  247. package/dist/tools/slackPostMessage.js.map +1 -1
  248. package/dist/tools/transaction.d.ts +19 -0
  249. package/dist/tools/transaction.js +29 -0
  250. package/dist/tools/transaction.js.map +1 -1
  251. package/dist/traceEncryption.d.ts +46 -0
  252. package/dist/traceEncryption.js +124 -0
  253. package/dist/traceEncryption.js.map +1 -0
  254. package/dist/transport.d.ts +39 -0
  255. package/dist/transport.js +88 -8
  256. package/dist/transport.js.map +1 -1
  257. package/package.json +22 -5
  258. package/templates/policies/README.md +72 -0
  259. package/templates/policies/conservative.json +14 -0
  260. package/templates/policies/developer.json +14 -0
  261. package/templates/policies/headless-ci.json +24 -0
  262. package/templates/policies/personal-assistant.json +15 -0
  263. package/templates/policies/regulated-industry.json +18 -0
  264. package/templates/recipes/project-health-check.yaml +1 -1
  265. package/templates/recipes/webhook/README.md +70 -0
  266. package/templates/recipes/webhook/capture-thought.yaml +26 -0
  267. package/templates/recipes/webhook/customer-escalation.yaml +49 -0
  268. package/templates/recipes/webhook/incident-intake.yaml +46 -0
  269. package/templates/recipes/webhook/meeting-prep.yaml +48 -0
  270. package/templates/recipes/webhook/morning-brief.yaml +57 -0
package/README.md CHANGED
@@ -1,6 +1,89 @@
1
1
  # Patchwork OS
2
2
 
3
- **Proactive AI automation that runs on your machine. Oversight built in. No vendor lock-in.**
3
+ ### Your personal AI runtime, local-first.
4
+
5
+ > Patchwork OS is a local-first personal AI runtime: pluggable model providers, hot-reloadable tools, YAML recipes, a delegation policy with approval queue, and a durable trace memory — all running on your machine, all under your policy.
6
+
7
+ You decide which model. You decide which actions need a human nod. You own the credentials, the logs, and the deployment. Nothing phones home.
8
+
9
+ **Five primitives, one runtime:**
10
+
11
+ - **Tools** — 170+ built-in (LSP, git, terminal, debugger, files) plus any plugin you write. Plugins hot-reload — Claude can author a tool mid-session and call it on the next turn. See [Live Toolsmithing](documents/live-toolsmithing.md).
12
+ - **Recipes** — YAML automations triggered by cron, file save, git commit, test run, or webhook. Anything that can POST a JSON payload can fire a recipe.
13
+ - **Delegation Policy** — three risk tiers, four-source precedence (managed → project-local → project → user). Auto-approve safe, require approval for risky, block dangerous.
14
+ - **Trace memory** — every approval, every recipe run, every enrichment is durable JSONL. Past decisions are surfaced into future sessions automatically. Bundle and back up with [`patchwork traces export`](src/commands/tracesExport.ts).
15
+ - **OAuth** — turn your runtime into a private personal API. PKCE S256, dynamic client registration, deployable on a VPS in minutes.
16
+
17
+ > **Why not [an MCP server / Zapier / a hosted assistant / a local agent framework]?** See [the comparison page](documents/comparison.md) for the honest tradeoff against each.
18
+ >
19
+ > **What does this look like in one diagram?** See the [architecture overview](documents/architecture.md).
20
+
21
+ ---
22
+
23
+ The same codebase ships **two ways to use it.** Pick the layer you need.
24
+
25
+ | | What you get | Install | Best for |
26
+ |---|---|---|---|
27
+ | **🔌 Claude IDE Bridge** | MCP bridge connecting Claude Code to your IDE. 170+ tools — diagnostics, LSP, debugger, terminal, git, GitHub, file ops. | `npm i -g patchwork-os` then run `claude-ide-bridge` | Anyone who wants Claude Code to see and act on their editor state |
28
+ | **🤖 Patchwork OS** | Everything in the bridge **plus** YAML recipes, approval queue, oversight dashboard, mobile push approvals, multi-model providers, JetBrains companion. | Same package, run `patchwork patchwork-init` | Power users running automation, agent workflows, or background tasks |
29
+
30
+ Same codebase. Bridge is the foundation; Patchwork OS is the optional layer on top. **No vendor lock-in. Runs on your machine.**
31
+
32
+ ---
33
+
34
+ ## 🔌 Claude IDE Bridge — Quick Start
35
+
36
+ ```bash
37
+ # 1. Install the npm package
38
+ npm install -g patchwork-os
39
+
40
+ # 2. Install the VS Code / Cursor / Windsurf extension
41
+ # Search "Claude IDE Bridge" on OpenVSX, or:
42
+ claude-ide-bridge install-extension
43
+
44
+ # 3. Start the bridge for your workspace
45
+ claude-ide-bridge --workspace .
46
+
47
+ # 4. Connect Claude Code (in another terminal)
48
+ CLAUDE_CODE_IDE_SKIP_VALID_CHECK=true claude --ide
49
+ ```
50
+
51
+ Type `/ide` in Claude Code to confirm the connection. That's it — Claude now sees your diagnostics, open files, and editor state, and can call 170+ tools to act on them.
52
+
53
+ **What the bridge gives Claude:**
54
+
55
+ - Diagnostics, LSP navigation (goto / references / call hierarchy), refactoring with risk analysis
56
+ - Terminal — run commands, read output, wait for async work
57
+ - Git — status, diff, commit, push, blame, checkout, branch list
58
+ - GitHub — open PRs, list issues, post reviews, fetch run logs
59
+ - Debugger — set breakpoints, evaluate expressions, inspect runtime state
60
+ - Files — read, edit by line range, search and replace, capture screenshots
61
+ - Code quality — `auditDependencies`, `detectUnusedCode`, `getCodeCoverage`, `getGitHotspots`
62
+
63
+ The bridge runs without any flags. No recipes, no automation, no dashboard — just the IDE-Claude connection.
64
+
65
+ **Compatible IDEs:** VS Code, Cursor, Windsurf, Google Antigravity. JetBrains IDEs via [companion plugin](#jetbrains-plugin).
66
+
67
+ **Transport layers:**
68
+
69
+ | Client | Protocol |
70
+ |---|---|
71
+ | Claude Code CLI | WebSocket `ws://127.0.0.1:<port>` |
72
+ | Claude Desktop | stdio shim → WebSocket |
73
+ | Remote (claude.ai, Codex CLI) | Streamable HTTP + Bearer token |
74
+
75
+ **Tool modes:**
76
+
77
+ | Mode | Tools | When to use |
78
+ |---|---|---|
79
+ | Full _(default)_ | ~170 | All git, GitHub, terminal, file ops, orchestration |
80
+ | Slim (`--slim`) | ~60 | LSP + debugger + editor state only |
81
+
82
+ Bridge-only docs: [documents/platform-docs.md](documents/platform-docs.md)
83
+
84
+ ---
85
+
86
+ ## 🤖 Patchwork OS — Quick Start
4
87
 
5
88
  ```bash
6
89
  npx patchwork-os@alpha patchwork-init
@@ -8,9 +91,27 @@ npx patchwork-os@alpha patchwork-init
8
91
 
9
92
  Sets up 5 local recipes, detects Ollama, and opens a terminal dashboard — under 90 seconds.
10
93
 
94
+ ### ☀️ Morning Brief — the hero workflow
95
+
96
+ Get an AI digest of your Gmail, calendar, and tasks every morning — or on demand:
97
+
98
+ ```bash
99
+ # First-time setup (connect Gmail + Google Calendar)
100
+ patchwork-os patchwork-init
101
+ patchwork-os connections connect gmail
102
+ patchwork-os connections connect google-calendar
103
+
104
+ # Run it now
105
+ patchwork-os recipe run morning-brief
106
+ ```
107
+
108
+ The brief lands in `~/.patchwork/inbox/` as a Markdown file. Open the dashboard (`http://localhost:3100`) to read it, approve any drafted replies, or let it auto-send at 08:00 via the built-in cron trigger.
109
+
110
+ No connectors yet? Run with `--local` using Ollama — it summarises your clipboard and last-touched files instead.
111
+
11
112
  ---
12
113
 
13
- ## What it is
114
+ ### What it adds on top of the bridge
14
115
 
15
116
  Patchwork OS is a local automation platform that watches your workspace for events, runs AI-powered recipes in response, and routes anything risky through an approval queue before it goes anywhere.
16
117
 
@@ -20,94 +121,109 @@ Think of it as a background agent that acts on your behalf — but asks before s
20
121
  - Customer email arrives → draft reply in your voice, pending your approval
21
122
  - Field-trip permission form flagged → reply drafted to the teacher, waiting for your nod
22
123
 
23
- ---
24
-
25
- ## How it works
26
-
27
124
  **Recipes** are plain YAML files. They declare a trigger (cron, file save, git commit, test run, webhook) and an action (run a prompt, write to inbox, call a connector). No code required. Share them like dotfiles.
28
125
 
29
126
  **Models** are yours. Claude, GPT, Gemini, Grok, or local Ollama. Swap at any time. Nothing phones home.
30
127
 
31
128
  **Oversight** is non-negotiable. Every write or external action lands in `~/.patchwork/inbox/` for approval. The web UI at `http://localhost:3100` shows pending approvals, live sessions, recipe run history, and analytics.
32
129
 
33
- ---
34
-
35
- ## Quickstart
130
+ ### Patchwork commands
36
131
 
37
132
  ```bash
38
- # Install globally
39
- npm install -g patchwork-os
40
-
41
133
  # One-command setup: extension + CLAUDE.md + starter recipes
42
- patchwork-os patchwork-init
134
+ patchwork patchwork-init
43
135
 
44
136
  # Explore
45
- patchwork-os recipe list # installed recipes
46
- patchwork-os recipe run daily-status # run one now
47
- patchwork-os recipe run morning-brief --local # run with local Ollama
48
- patchwork-os tools list # browse 170+ tools
49
- patchwork-os # open terminal dashboard
137
+ patchwork recipe list # installed recipes
138
+ patchwork recipe run daily-status # run one now
139
+ patchwork recipe run morning-brief --local # run with local Ollama
140
+ patchwork tools list # browse 170+ tools
141
+ patchwork # open terminal dashboard
142
+
143
+ # Web UI — bridge + extension watcher in tmux
144
+ patchwork start-all # then http://localhost:3100
50
145
  ```
51
146
 
52
- **Web UI** — start the bridge, then open `http://localhost:3100`
147
+ ### Starter recipes
53
148
 
54
- ```bash
55
- patchwork-os start-all # bridge + extension watcher in tmux
56
- ```
149
+ The package ships these in `templates/recipes/`. Recipes that need API keys are noted; the rest are zero-config.
57
150
 
58
- ---
151
+ | Recipe | Trigger | What it does | Needs |
152
+ |---|---|---|---|
153
+ | `ambient-journal` | git commit | Appends one line to `~/.patchwork/journal/` | — |
154
+ | `daily-status` | cron 08:00 | Morning brief from yesterday's commits | — |
155
+ | `lint-on-save` | file save | Surfaces new TS/JS diagnostics to inbox | — |
156
+ | `stale-branches` | cron weekly | Lists branches older than 30 days | — |
157
+ | `watch-failing-tests` | test run | Drops triage note to inbox on failure | — |
158
+ | `project-health-check` | manual | Snapshot of repo health + flagged risks | — |
159
+ | `ctx-loop-test` | manual | Smoke test for context-platform end-to-end | — |
160
+ | `morning-brief` | cron 08:00 | Gmail + Linear + Slack + Calendar digest | Gmail, Linear, Slack, Google Calendar |
161
+ | `morning-brief-slack` | cron 08:00 | Same brief but only posts to Slack | Linear, Slack |
162
+ | `gmail-health-check` | manual | Verify Gmail connector + token state | Gmail |
163
+ | `inbox-triage` | manual | Triage Gmail unread → suggest archive/reply | Gmail |
164
+ | `sentry-to-linear` | manual | Sentry issue → Linear ticket (one-shot) | Sentry, Linear |
59
165
 
60
- ## Starter recipes
166
+ **Connectors available** (all writes governed by your delegation policy): Slack, GitHub, Linear, Gmail, Google Calendar, Google Drive, Sentry, Notion, Confluence, Datadog, HubSpot, Intercom, Stripe, Zendesk, Jira, PagerDuty, Discord, Asana, GitLab.
61
167
 
62
- No external API keys needed for these:
168
+ **Delegation policy presets** ([`templates/policies/`](templates/policies/)): five persona starters — conservative, developer, headless-CI, regulated-industry, personal-assistant. Copy one into `~/.patchwork/config.json` and restart.
63
169
 
64
- | Recipe | Trigger | What it does |
65
- |---|---|---|
66
- | `ambient-journal` | git commit | Appends one line to `~/.patchwork/journal/` |
67
- | `daily-status` | cron 08:00 | Morning brief from yesterday's commits |
68
- | `watch-failing-tests` | test run | Drops triage note to inbox on failure |
69
- | `lint-on-save` | file save | Surfaces new TS/JS diagnostics to inbox |
70
- | `stale-branches` | cron weekly | Lists branches older than 30 days |
71
- | `morning-brief` | cron 08:00 | Commits + Linear issues + Calendar events |
72
- | `sentry-to-linear` | manual | Sentry issue → Linear ticket (one-shot) |
170
+ **Webhook recipe starters** ([`templates/recipes/webhook/`](templates/recipes/webhook/)): five webhook-triggered recipes capture-thought, morning-brief (on-demand), meeting-prep, incident-intake, customer-escalation. Anything that can POST HTTP can drive these — iPhone Shortcut, Stream Deck, Home Assistant, NFC tag, monitoring tool.
73
171
 
74
- Connectors (Linear, Sentry, Slack, Google Calendar) require API keys and approval-gated writes.
172
+ ### Automation hooks
173
+
174
+ Event-driven hooks trigger Claude tasks automatically. Activate with `--automation --automation-policy <path.json> --claude-driver subprocess`.
175
+
176
+ Key hooks:
177
+
178
+ | Hook | Fires when |
179
+ |---|---|
180
+ | `onFileSave` | Matching files saved |
181
+ | `onDiagnosticsStateChange` | Errors appear or clear |
182
+ | `onRecipeSave` | Any `.yaml`/`.yml` saved — runs preflight |
183
+ | `onGitCommit` / `onGitPush` / `onGitPull` | Git tools succeed |
184
+ | `onTestRun` | Test run completes (filter: any/failure/pass-after-fail) |
185
+ | `onBranchCheckout` | After branch switch |
186
+ | `onPullRequest` | After `githubCreatePR` succeeds |
187
+ | `onCompaction` | Before/after Claude context compaction |
188
+ | `onTaskCreated` / `onTaskSuccess` | Orchestrator task lifecycle |
189
+
190
+ All hooks support inline prompts, named prompt references, and a minimum 5s cooldown. Full reference: [documents/platform-docs.md → Automation Hooks](documents/platform-docs.md)
75
191
 
76
192
  ---
77
193
 
78
194
  ## Architecture
79
195
 
80
196
  ```
81
- patchwork-os CLI
82
- ├── Recipe runner YAML triggers → LLM prompt → action
83
- ├── Claude IDE Bridge MCP server 170+ tools over WebSocket/HTTP
84
- │ ├── VS Code extension LSP, debugger, editor state, live diagnostics
85
- │ ├── Git / GitHub gitCommit, gitPush, githubCreatePR,
86
- │ ├── Terminal runInTerminal, getTerminalOutput, …
87
- │ ├── Connectors Linear, Sentry, Slack, Google Calendar
88
- │ └── Orchestrator Claude subprocess tasks, automation hooks
89
- ├── Oversight inbox ~/.patchwork/inbox/ — approval queue
90
- └── Web dashboard http://localhost:3100 approvals, sessions, analytics
197
+ patchwork-os (npm package)
198
+
199
+ ├── claude-ide-bridge ← run alone for bridge-only mode
200
+ │ ├── MCP server 170+ tools over WebSocket / HTTP / stdio
201
+ │ ├── VS Code extension LSP, debugger, editor state, live diagnostics
202
+ │ ├── Git / GitHub gitCommit, gitPush, githubCreatePR,
203
+ │ ├── Terminal runInTerminal, getTerminalOutput,
204
+ │ └── Code quality auditDependencies, detectUnusedCode, getCodeCoverage
205
+
206
+ └── patchwork ← run for full Patchwork OS layer
207
+ ├── Recipe runner YAML triggers → LLM prompt → action
208
+ ├── Connectors Linear, Sentry, Slack, Google Calendar, +
209
+ ├── Orchestrator Claude subprocess tasks, automation hooks
210
+ ├── Oversight inbox ~/.patchwork/inbox/ — approval queue
211
+ └── Web dashboard http://localhost:3100 — approvals, sessions, analytics
91
212
  ```
92
213
 
93
- **Transport layers:**
214
+ The npm package ships **three CLI binaries** that share the same code:
94
215
 
95
- | Client | Protocol |
216
+ | Binary | Default behavior |
96
217
  |---|---|
97
- | Claude Code CLI | WebSocket `ws://127.0.0.1:<port>` |
98
- | Claude Desktop | stdio shim WebSocket |
99
- | Remote (claude.ai, Codex) | Streamable HTTP + Bearer token |
218
+ | `claude-ide-bridge` | Bridge only no automation, no recipe runner, no dashboard |
219
+ | `patchwork` | Full Patchwork OS automation + recipes + dashboard |
220
+ | `patchwork-os` | Alias for `patchwork` |
100
221
 
101
- **Tool modes:**
102
-
103
- | Mode | Tools | When to use |
104
- |---|---|---|
105
- | Full _(default)_ | ~170 | All git, GitHub, terminal, file ops, orchestration |
106
- | Slim (`--slim`) | ~60 | LSP + debugger + editor state only |
222
+ Use whichever fits your mental model.
107
223
 
108
224
  ---
109
225
 
110
- ## Tool surface (v0.2.0-alpha.33)
226
+ ## Tool surface (v0.2.0-alpha.35)
111
227
 
112
228
  170+ MCP tools across 15 categories. Highlights:
113
229
 
@@ -126,52 +242,42 @@ Full reference: [documents/platform-docs.md](documents/platform-docs.md)
126
242
 
127
243
  ---
128
244
 
129
- ## Automation hooks
130
-
131
- Event-driven hooks trigger Claude tasks automatically. Activate with `--automation --automation-policy <path.json> --claude-driver subprocess`.
132
-
133
- Key hooks:
134
-
135
- | Hook | Fires when |
136
- |---|---|
137
- | `onFileSave` | Matching files saved |
138
- | `onDiagnosticsStateChange` | Errors appear or clear |
139
- | `onRecipeSave` | Any `.yaml`/`.yml` saved — runs preflight |
140
- | `onGitCommit` | After successful commit |
141
- | `onTestRun` | After test run completes |
142
- | `onBranchCheckout` | After branch switch |
143
- | `onCompaction` | Before/after Claude context compaction |
144
-
145
- All hooks support inline prompts, named prompt references, and a minimum 5s cooldown.
146
-
147
- Full reference: [documents/platform-docs.md → Automation Hooks](documents/platform-docs.md)
148
-
149
- ---
150
-
151
245
  ## Plugin system
152
246
 
153
247
  Extend the tool surface without forking the bridge.
154
248
 
155
249
  ```bash
156
250
  # Scaffold a new plugin
157
- patchwork-os gen-plugin-stub ./my-plugin --name "org/name" --prefix "myPrefix"
251
+ patchwork gen-plugin-stub ./my-plugin --name "org/name" --prefix "myPrefix"
158
252
 
159
253
  # Load at runtime
160
- patchwork-os --plugin ./my-plugin
254
+ claude-ide-bridge --plugin ./my-plugin
161
255
  ```
162
256
 
163
- Plugins register MCP tools in-process. Publish to npm with keyword `claude-ide-bridge-plugin`.
257
+ Plugins register MCP tools in-process. With `--plugin-watch`, the bridge reloads them on save — Claude can write a tool *during* a session and use it on the next turn. See [documents/live-toolsmithing.md](documents/live-toolsmithing.md) for the worked walkthrough and [examples/plugins/sqlite-library/](examples/plugins/sqlite-library/) for a runnable example.
258
+
259
+ Publish to npm with keyword `claude-ide-bridge-plugin` for distribution.
164
260
 
165
261
  Full reference: [documents/plugin-authoring.md](documents/plugin-authoring.md)
166
262
 
167
263
  ---
168
264
 
265
+ ## JetBrains plugin
266
+
267
+ Companion IntelliJ plugin (v1.0.0) on the JetBrains Marketplace. Covers 49 handlers: core tools, PSI-based LSP (goto, references, hover, rename, symbols, format), XDebugger integration, and code style tools.
268
+
269
+ Use the same bridge from VS Code and JetBrains IDEs simultaneously — IntelliJ IDEA, PyCharm, GoLand, WebStorm, and other IntelliJ-platform editors.
270
+
271
+ Source: [intellij-plugin/](intellij-plugin/)
272
+
273
+ ---
274
+
169
275
  ## Remote deployment
170
276
 
171
- Patchwork runs headless on a VPS with full tool support via VS Code Remote-SSH.
277
+ Run headless on a VPS with full tool support via VS Code Remote-SSH.
172
278
 
173
279
  ```bash
174
- patchwork-os --bind 0.0.0.0 \
280
+ claude-ide-bridge --bind 0.0.0.0 \
175
281
  --issuer-url https://your-domain.com \
176
282
  --fixed-token <uuid> \
177
283
  --vps
@@ -185,20 +291,18 @@ Systemd service and deploy scripts in [`deploy/`](deploy/). Full guide: [docs/re
185
291
 
186
292
  | Feature | Status |
187
293
  |---|---|
294
+ | 170+ MCP tools (LSP, git, tests, debugger, diagnostics) | **shipped** |
295
+ | VS Code / Cursor / Windsurf / Antigravity extension | **shipped** |
296
+ | JetBrains plugin (49 handlers) | **shipped** |
188
297
  | `patchwork-init` — one-command setup | **shipped** |
189
298
  | Terminal dashboard | **shipped** |
190
299
  | Web oversight UI (approvals, sessions, recipes) | **shipped** |
191
300
  | Recipe runner (YAML, cron, manual, webhook) | **shipped** |
192
301
  | Multi-provider LLM (Claude, Gemini, OpenAI, Grok, Ollama) | **shipped** |
193
- | 170+ MCP tools (LSP, git, tests, debugger, diagnostics) | **shipped** |
194
- | Linear connector (read + approval-gated write) | **shipped** |
195
- | Sentry connector | **shipped** |
196
- | Google Calendar connector (read-only) | **shipped** |
197
- | Slack connector | **shipped** |
302
+ | Connectors: Linear, Sentry, Slack, Google Calendar, Intercom, HubSpot, Datadog, Stripe | **shipped** |
198
303
  | Cross-session memory (traces, handoff notes) | **shipped** |
199
- | JetBrains plugin | **shipped** (marketplace review) |
200
- | Mobile oversight PWA | in progress |
201
- | Community recipe marketplace | Q3 |
304
+ | Mobile oversight PWA (push approvals) | **shipped (alpha)** |
305
+ | Community recipe marketplace | Q3 2026 |
202
306
 
203
307
  ---
204
308
 
@@ -213,7 +317,7 @@ npm install && npm run build
213
317
  # Symlink installs break the macOS LaunchAgent (EPERM at startup)
214
318
  npm pack
215
319
  npm install -g patchwork-os-*.tgz
216
- patchwork-os patchwork-init
320
+ patchwork patchwork-init
217
321
  ```
218
322
 
219
323
  ---
@@ -228,6 +332,11 @@ patchwork-os patchwork-init
228
332
  | [documents/roadmap.md](documents/roadmap.md) | Development direction |
229
333
  | [documents/data-reference.md](documents/data-reference.md) | Data flows, state management, protocol details |
230
334
  | [documents/plugin-authoring.md](documents/plugin-authoring.md) | Plugin manifest schema, entrypoint API, distribution |
335
+ | [documents/live-toolsmithing.md](documents/live-toolsmithing.md) | Write tools while the AI is using them — hot-reload narrative + worked example |
336
+ | [documents/triggers.md](documents/triggers.md) | Anything Can Trigger Your AI — iPhone Shortcuts, Stream Deck, Home Assistant, curl, GitHub Actions |
337
+ | [documents/speculative-refactoring.md](documents/speculative-refactoring.md) | Stage multi-file edits, review the diff, commit or discard — honest about commit-phase semantics |
338
+ | [documents/architecture.md](documents/architecture.md) | One-page architecture diagram + how to read it |
339
+ | [documents/comparison.md](documents/comparison.md) | Patchwork vs MCP server / Zapier / hosted assistants / agent frameworks — honest tradeoffs |
231
340
  | [docs/adr/](docs/adr/) | Architecture Decision Records |
232
341
  | [docs/remote-access.md](docs/remote-access.md) | VPS deployment guide |
233
342
 
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env bash
2
2
  # deploy/bootstrap-new-vps.sh
3
- # Full fresh-server setup for claude-ide-bridge on a NEW VPS.
3
+ # Full fresh-server setup for patchwork-os on a NEW VPS.
4
4
  # Handles everything from Node.js install to running HTTPS service.
5
5
  #
6
6
  # Usage (run as root on a fresh Ubuntu 22.04/24.04 VPS):
7
- # curl -fsSL https://raw.githubusercontent.com/Oolab-labs/claude-ide-bridge/main/deploy/bootstrap-new-vps.sh | \
7
+ # curl -fsSL https://raw.githubusercontent.com/Oolab-labs/patchwork-os/main/deploy/bootstrap-new-vps.sh | \
8
8
  # DOMAIN=bridge.example.com bash
9
9
  #
10
10
  # Or after cloning:
@@ -14,9 +14,9 @@
14
14
  # DOMAIN Subdomain for the bridge (e.g. bridge.example.com)
15
15
  #
16
16
  # Optional environment variables:
17
- # REPO_URL Git repo URL (default: https://github.com/Oolab-labs/claude-ide-bridge)
18
- # INSTALL_DIR Where to clone the repo (default: /opt/claude-ide-bridge)
19
- # SERVICE_USER System user to run bridge (default: claude-bridge)
17
+ # REPO_URL Git repo URL (default: https://github.com/Oolab-labs/patchwork-os)
18
+ # INSTALL_DIR Where to clone the repo (default: /opt/patchwork-os)
19
+ # SERVICE_USER System user to run bridge (default: patchwork)
20
20
  # PORT Bridge port (default: 9000)
21
21
  # BRANCH Git branch to clone (default: main)
22
22
  # SKIP_CERTBOT Set to 1 to skip TLS cert (useful if DNS not yet set)
@@ -25,13 +25,13 @@ set -euo pipefail
25
25
 
26
26
  # ── Config ────────────────────────────────────────────────────────────────────
27
27
  DOMAIN="${DOMAIN:-}"
28
- REPO_URL="${REPO_URL:-https://github.com/Oolab-labs/claude-ide-bridge}"
29
- INSTALL_DIR="${INSTALL_DIR:-/opt/claude-ide-bridge}"
30
- SERVICE_USER="${SERVICE_USER:-claude-bridge}"
28
+ REPO_URL="${REPO_URL:-https://github.com/Oolab-labs/patchwork-os}"
29
+ INSTALL_DIR="${INSTALL_DIR:-/opt/patchwork-os}"
30
+ SERVICE_USER="${SERVICE_USER:-patchwork}"
31
31
  PORT="${PORT:-9000}"
32
32
  BRANCH="${BRANCH:-main}"
33
33
  SKIP_CERTBOT="${SKIP_CERTBOT:-0}"
34
- SERVICE_NAME="claude-ide-bridge"
34
+ SERVICE_NAME="patchwork-os"
35
35
 
36
36
  RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
37
37
  info() { echo -e "${GREEN}✓${NC} $*"; }
@@ -163,8 +163,8 @@ section "Systemd service"
163
163
  # Generate service file from template (parameterised for this install)
164
164
  cat > "/etc/systemd/system/${SERVICE_NAME}.service" <<SERVICE
165
165
  [Unit]
166
- Description=Claude IDE Bridge MCP Server
167
- Documentation=https://github.com/Oolab-labs/claude-ide-bridge
166
+ Description=Patchwork OS bridge
167
+ Documentation=https://github.com/Oolab-labs/patchwork-os
168
168
  After=network.target
169
169
  StartLimitIntervalSec=120
170
170
  StartLimitBurst=5
@@ -193,7 +193,7 @@ RestartSec=5
193
193
 
194
194
  StandardOutput=journal
195
195
  StandardError=journal
196
- SyslogIdentifier=claude-ide-bridge
196
+ SyslogIdentifier=patchwork-os
197
197
 
198
198
  NoNewPrivileges=true
199
199
  PrivateTmp=true
@@ -40,9 +40,12 @@ mkdir -p "${BRIDGE_HOME}"
40
40
  chown "${BRIDGE_USER}:${BRIDGE_USER}" "${BRIDGE_HOME}"
41
41
 
42
42
  # ── 4. Install bridge globally ────────────────────────────────────────────────
43
- info "Installing claude-ide-bridge from npm..."
44
- npm install -g claude-ide-bridge 2>&1 | tail -5
45
- BRIDGE_BIN="$(which claude-ide-bridge)"
43
+ info "Installing patchwork-os from npm..."
44
+ npm install -g patchwork-os@alpha 2>&1 | tail -5
45
+ # `patchwork-os` ships three bin aliases: `patchwork` (preferred),
46
+ # `patchwork-os`, and the legacy `claude-ide-bridge`. Use the canonical
47
+ # `patchwork` name for the systemd unit + nginx config below.
48
+ BRIDGE_BIN="$(which patchwork)"
46
49
  info "Bridge binary: ${BRIDGE_BIN}"
47
50
 
48
51
  # ── 5. Generate fixed token ───────────────────────────────────────────────────
@@ -9,9 +9,16 @@ NGINX_CONF="/etc/nginx/sites-available/patchworkos"
9
9
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
10
  REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
11
11
 
12
- echo "==> Copying landing page to VPS..."
12
+ echo "==> Copying landing page + assets to VPS..."
13
13
  ssh "$VPS" "mkdir -p $LANDING_DIR"
14
- scp "$REPO_ROOT/landing/index.html" "$VPS:$LANDING_DIR/index.html"
14
+ # index.html plus the favicon + manifest browsers probe at apex. Without
15
+ # these the browser console fills with /favicon.svg and /manifest.json
16
+ # 401s on every page load (nginx falls through to the dashboard middleware
17
+ # for paths that don't have an explicit `location`).
18
+ scp "$REPO_ROOT/landing/index.html" "$VPS:$LANDING_DIR/index.html"
19
+ scp "$REPO_ROOT/landing/favicon.ico" "$VPS:$LANDING_DIR/favicon.ico"
20
+ scp "$REPO_ROOT/landing/favicon.svg" "$VPS:$LANDING_DIR/favicon.svg"
21
+ scp "$REPO_ROOT/landing/manifest.json" "$VPS:$LANDING_DIR/manifest.json"
15
22
 
16
23
  echo "==> Updating nginx to serve landing page at root..."
17
24
  ssh "$VPS" bash <<'REMOTE'
@@ -70,6 +77,56 @@ else
70
77
  echo "nginx: landing location already present, skipping"
71
78
  fi
72
79
 
80
+ # Independent idempotency block for the apex asset locations — these were
81
+ # added after the original landing block, so existing installs miss them.
82
+ if ! grep -q "location = /favicon.ico" "$NGINX_CONF"; then
83
+ python3 - "$NGINX_CONF" <<'PYEOF'
84
+ import sys
85
+
86
+ path = sys.argv[1]
87
+ with open(path) as f:
88
+ content = f.read()
89
+
90
+ asset_blocks = """
91
+ # Apex assets — favicon + PWA manifest browsers probe at root
92
+ location = /favicon.ico {
93
+ root /var/www/patchwork-landing;
94
+ try_files /favicon.ico =404;
95
+ access_log off;
96
+ }
97
+ location = /favicon.svg {
98
+ root /var/www/patchwork-landing;
99
+ try_files /favicon.svg =404;
100
+ access_log off;
101
+ }
102
+ location = /manifest.json {
103
+ root /var/www/patchwork-landing;
104
+ try_files /manifest.json =404;
105
+ access_log off;
106
+ }
107
+ """
108
+
109
+ # Insert immediately after the existing `location = /` block
110
+ marker = ' location = / {'
111
+ idx = content.find(marker)
112
+ if idx == -1:
113
+ print("WARN: could not find `location = /` to anchor; appending to end", flush=True)
114
+ idx = content.rfind('\n}')
115
+ new_content = content[:idx] + asset_blocks + content[idx:]
116
+ else:
117
+ # find end of the location = / block
118
+ end = content.find(' }', idx)
119
+ end = content.find('\n', end) + 1 if end != -1 else idx
120
+ new_content = content[:end] + asset_blocks + content[end:]
121
+
122
+ with open(path, 'w') as f:
123
+ f.write(new_content)
124
+ print("nginx: apex asset location blocks inserted")
125
+ PYEOF
126
+ else
127
+ echo "nginx: apex asset locations already present, skipping"
128
+ fi
129
+
73
130
  nginx -t && systemctl reload nginx
74
131
  echo "nginx reloaded"
75
132
  REMOTE
@@ -58,6 +58,55 @@ export declare class ActivityLog {
58
58
  * need historical correlation should cross-reference by time bounds.
59
59
  */
60
60
  querySessionTools(sessionId: string, limit?: number): ActivityEntry[];
61
+ /**
62
+ * Cross-session query for approval-decision lifecycle rows. Used by the
63
+ * passive risk personalization signals (`src/approvalSignals.ts`) to
64
+ * answer questions like "how many times has the user approved this tool
65
+ * before?" without paying the cost of `queryTimeline`'s combined-sort.
66
+ *
67
+ * Filters honored:
68
+ * - `toolName` — match `metadata.toolName` exactly
69
+ * - `decision` — match `metadata.decision` ("allow" | "deny")
70
+ * - `last` — return at most this many most-recent matches (cap 1000)
71
+ *
72
+ * Returns rows ordered oldest → newest (the natural append order of the
73
+ * lifecycle log) so callers can compute counts or "last decision" cheaply.
74
+ */
75
+ queryApprovalDecisions(opts?: {
76
+ toolName?: string;
77
+ decision?: string;
78
+ last?: number;
79
+ }): LifecycleEntry[];
80
+ /**
81
+ * Return the most recent tool entry matching `toolName` exactly, or
82
+ * `null` if none. Used by personalization heuristic 5 ("last called T
83
+ * days ago") to compute the gap between now and the most recent prior
84
+ * call without scanning the whole buffer downstream.
85
+ *
86
+ * Walks the entries ring backwards (newest first) so the common case —
87
+ * a tool called recently — returns after one comparison.
88
+ */
89
+ queryLastToolCall(toolName: string): ActivityEntry | null;
90
+ /**
91
+ * Cross-session query for tool entries by namespace prefix (e.g. "gmail"
92
+ * matches "gmail.fetch_unread", "gmail.send"). Used by personalization
93
+ * heuristic 3 ("first use of this connector") to detect whether the
94
+ * connector has been used before. Cap at 1000 most-recent matches.
95
+ */
96
+ queryByNamespace(namespace: string, last?: number): ActivityEntry[];
97
+ /**
98
+ * Return all activity entries within a time window. Used by the
99
+ * automation-suggestions module (`src/automationSuggestions.ts`) to feed
100
+ * `computeCoOccurrence` and similar pattern-mining over a fresh slice of
101
+ * the activity ring without pulling the whole buffer.
102
+ *
103
+ * `sinceMs` is an absolute epoch ms — entries with `timestamp >= sinceMs`
104
+ * are returned. Set to `0` for "all".
105
+ */
106
+ queryAll(opts?: {
107
+ sinceMs?: number;
108
+ last?: number;
109
+ }): ActivityEntry[];
61
110
  queryTimeline(opts?: {
62
111
  last?: number;
63
112
  }): TimelineEntry[];