@secretstartups/workshop 0.1.2 → 0.2.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 (177) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +210 -2
  3. package/dist/agent/agent-session.d.ts +60 -0
  4. package/dist/agent/agent-session.js +262 -0
  5. package/dist/agent/agent-session.js.map +1 -0
  6. package/dist/agent/agent.module.d.ts +2 -0
  7. package/dist/agent/agent.module.js +46 -0
  8. package/dist/agent/agent.module.js.map +1 -0
  9. package/dist/agent/build-api.service.d.ts +141 -0
  10. package/dist/agent/build-api.service.js +100 -0
  11. package/dist/agent/build-api.service.js.map +1 -0
  12. package/dist/agent/build-events.types.d.ts +172 -0
  13. package/dist/agent/build-events.types.js +11 -0
  14. package/dist/agent/build-events.types.js.map +1 -0
  15. package/dist/agent/commands/agent-diff.command.d.ts +17 -0
  16. package/dist/agent/commands/agent-diff.command.js +84 -0
  17. package/dist/agent/commands/agent-diff.command.js.map +1 -0
  18. package/dist/agent/commands/agent-files.command.d.ts +19 -0
  19. package/dist/agent/commands/agent-files.command.js +93 -0
  20. package/dist/agent/commands/agent-files.command.js.map +1 -0
  21. package/dist/agent/commands/agent-merge.command.d.ts +17 -0
  22. package/dist/agent/commands/agent-merge.command.js +101 -0
  23. package/dist/agent/commands/agent-merge.command.js.map +1 -0
  24. package/dist/agent/commands/agent-models.command.d.ts +14 -0
  25. package/dist/agent/commands/agent-models.command.js +49 -0
  26. package/dist/agent/commands/agent-models.command.js.map +1 -0
  27. package/dist/agent/commands/agent-resume.command.d.ts +14 -0
  28. package/dist/agent/commands/agent-resume.command.js +72 -0
  29. package/dist/agent/commands/agent-resume.command.js.map +1 -0
  30. package/dist/agent/commands/agent-rm.command.d.ts +16 -0
  31. package/dist/agent/commands/agent-rm.command.js +71 -0
  32. package/dist/agent/commands/agent-rm.command.js.map +1 -0
  33. package/dist/agent/commands/agent-sessions.command.d.ts +22 -0
  34. package/dist/agent/commands/agent-sessions.command.js +92 -0
  35. package/dist/agent/commands/agent-sessions.command.js.map +1 -0
  36. package/dist/agent/commands/agent.command.d.ts +65 -0
  37. package/dist/agent/commands/agent.command.js +819 -0
  38. package/dist/agent/commands/agent.command.js.map +1 -0
  39. package/dist/agent/executor/allowlist.d.ts +11 -0
  40. package/dist/agent/executor/allowlist.js +56 -0
  41. package/dist/agent/executor/allowlist.js.map +1 -0
  42. package/dist/agent/executor/approval.d.ts +24 -0
  43. package/dist/agent/executor/approval.js +90 -0
  44. package/dist/agent/executor/approval.js.map +1 -0
  45. package/dist/agent/executor/atomic-write.d.ts +9 -0
  46. package/dist/agent/executor/atomic-write.js +89 -0
  47. package/dist/agent/executor/atomic-write.js.map +1 -0
  48. package/dist/agent/executor/executor-client.d.ts +39 -0
  49. package/dist/agent/executor/executor-client.js +197 -0
  50. package/dist/agent/executor/executor-client.js.map +1 -0
  51. package/dist/agent/executor/executor.types.d.ts +97 -0
  52. package/dist/agent/executor/executor.types.js +10 -0
  53. package/dist/agent/executor/executor.types.js.map +1 -0
  54. package/dist/agent/executor/ops/file-ops.d.ts +8 -0
  55. package/dist/agent/executor/ops/file-ops.js +290 -0
  56. package/dist/agent/executor/ops/file-ops.js.map +1 -0
  57. package/dist/agent/executor/ops/run-command.d.ts +2 -0
  58. package/dist/agent/executor/ops/run-command.js +67 -0
  59. package/dist/agent/executor/ops/run-command.js.map +1 -0
  60. package/dist/agent/executor/roots.d.ts +9 -0
  61. package/dist/agent/executor/roots.js +140 -0
  62. package/dist/agent/executor/roots.js.map +1 -0
  63. package/dist/agent/executor/safe-path.d.ts +3 -0
  64. package/dist/agent/executor/safe-path.js +102 -0
  65. package/dist/agent/executor/safe-path.js.map +1 -0
  66. package/dist/agent/gates/gate-prompter.d.ts +21 -0
  67. package/dist/agent/gates/gate-prompter.js +189 -0
  68. package/dist/agent/gates/gate-prompter.js.map +1 -0
  69. package/dist/agent/prompt/cancellable.d.ts +5 -0
  70. package/dist/agent/prompt/cancellable.js +49 -0
  71. package/dist/agent/prompt/cancellable.js.map +1 -0
  72. package/dist/agent/prompt/mode-prompt.d.ts +14 -0
  73. package/dist/agent/prompt/mode-prompt.js +61 -0
  74. package/dist/agent/prompt/mode-prompt.js.map +1 -0
  75. package/dist/agent/render/diff-renderer.d.ts +14 -0
  76. package/dist/agent/render/diff-renderer.js +57 -0
  77. package/dist/agent/render/diff-renderer.js.map +1 -0
  78. package/dist/agent/render/event-renderer.d.ts +35 -0
  79. package/dist/agent/render/event-renderer.js +226 -0
  80. package/dist/agent/render/event-renderer.js.map +1 -0
  81. package/dist/agent/render/live-console.d.ts +17 -0
  82. package/dist/agent/render/live-console.js +84 -0
  83. package/dist/agent/render/live-console.js.map +1 -0
  84. package/dist/agent/render/plan-renderer.d.ts +2 -0
  85. package/dist/agent/render/plan-renderer.js +51 -0
  86. package/dist/agent/render/plan-renderer.js.map +1 -0
  87. package/dist/agent/render/run-summary.d.ts +13 -0
  88. package/dist/agent/render/run-summary.js +103 -0
  89. package/dist/agent/render/run-summary.js.map +1 -0
  90. package/dist/agent/render/sandbox-log.grouper.d.ts +10 -0
  91. package/dist/agent/render/sandbox-log.grouper.js +76 -0
  92. package/dist/agent/render/sandbox-log.grouper.js.map +1 -0
  93. package/dist/agent/slash-commands.d.ts +11 -0
  94. package/dist/agent/slash-commands.js +43 -0
  95. package/dist/agent/slash-commands.js.map +1 -0
  96. package/dist/agent/sse/build-stream.client.d.ts +20 -0
  97. package/dist/agent/sse/build-stream.client.js +206 -0
  98. package/dist/agent/sse/build-stream.client.js.map +1 -0
  99. package/dist/agent/sse/sse-parser.d.ts +11 -0
  100. package/dist/agent/sse/sse-parser.js +55 -0
  101. package/dist/agent/sse/sse-parser.js.map +1 -0
  102. package/dist/agent/target-resolver.d.ts +35 -0
  103. package/dist/agent/target-resolver.js +223 -0
  104. package/dist/agent/target-resolver.js.map +1 -0
  105. package/dist/app.module.js +4 -0
  106. package/dist/app.module.js.map +1 -1
  107. package/dist/auth/commands/login.command.d.ts +8 -0
  108. package/dist/auth/commands/login.command.js +115 -2
  109. package/dist/auth/commands/login.command.js.map +1 -1
  110. package/dist/auth/commands/token/token-create.command.d.ts +4 -0
  111. package/dist/auth/commands/token/token-create.command.js +91 -26
  112. package/dist/auth/commands/token/token-create.command.js.map +1 -1
  113. package/dist/clone/clone-runner.d.ts +26 -0
  114. package/dist/clone/clone-runner.js +108 -0
  115. package/dist/clone/clone-runner.js.map +1 -0
  116. package/dist/clone/clone.command.d.ts +30 -0
  117. package/dist/clone/clone.command.js +262 -0
  118. package/dist/clone/clone.command.js.map +1 -0
  119. package/dist/cluster/commands/cluster-delete.command.js +11 -11
  120. package/dist/cluster/commands/cluster-delete.command.js.map +1 -1
  121. package/dist/cluster/commands/cluster-install-local.command.d.ts +15 -0
  122. package/dist/cluster/commands/cluster-install-local.command.js +292 -22
  123. package/dist/cluster/commands/cluster-install-local.command.js.map +1 -1
  124. package/dist/cluster/commands/cluster.command.js +1 -1
  125. package/dist/cluster/commands/cluster.command.js.map +1 -1
  126. package/dist/cluster/kind-manager.d.ts +12 -1
  127. package/dist/cluster/kind-manager.js +55 -12
  128. package/dist/cluster/kind-manager.js.map +1 -1
  129. package/dist/common/api/api.service.d.ts +3 -1
  130. package/dist/common/api/api.service.js +13 -3
  131. package/dist/common/api/api.service.js.map +1 -1
  132. package/dist/common/config/cli-config.service.d.ts +28 -2
  133. package/dist/common/config/cli-config.service.js +37 -6
  134. package/dist/common/config/cli-config.service.js.map +1 -1
  135. package/dist/common/output/output.service.d.ts +1 -0
  136. package/dist/common/output/output.service.js +3 -0
  137. package/dist/common/output/output.service.js.map +1 -1
  138. package/dist/main.js +1 -0
  139. package/dist/main.js.map +1 -1
  140. package/dist/project/commands/project-use.command.d.ts +16 -0
  141. package/dist/project/commands/project-use.command.js +65 -0
  142. package/dist/project/commands/project-use.command.js.map +1 -0
  143. package/dist/project/commands/project.command.js +9 -1
  144. package/dist/project/commands/project.command.js.map +1 -1
  145. package/dist/project/project.module.js +2 -1
  146. package/dist/project/project.module.js.map +1 -1
  147. package/dist/service/commands/service-stop.command.js +12 -5
  148. package/dist/service/commands/service-stop.command.js.map +1 -1
  149. package/dist/tsconfig.build.tsbuildinfo +1 -1
  150. package/dist/vpn/commands/vpn-connect.command.d.ts +28 -0
  151. package/dist/vpn/commands/vpn-connect.command.js +213 -0
  152. package/dist/vpn/commands/vpn-connect.command.js.map +1 -0
  153. package/dist/vpn/commands/vpn-disconnect.command.d.ts +24 -0
  154. package/dist/vpn/commands/vpn-disconnect.command.js +149 -0
  155. package/dist/vpn/commands/vpn-disconnect.command.js.map +1 -0
  156. package/dist/vpn/commands/vpn-status.command.d.ts +18 -0
  157. package/dist/vpn/commands/vpn-status.command.js +94 -0
  158. package/dist/vpn/commands/vpn-status.command.js.map +1 -0
  159. package/dist/vpn/commands/vpn.command.d.ts +4 -0
  160. package/dist/vpn/commands/vpn.command.js +30 -0
  161. package/dist/vpn/commands/vpn.command.js.map +1 -0
  162. package/dist/vpn/kubectl-manager.d.ts +31 -0
  163. package/dist/vpn/kubectl-manager.js +276 -0
  164. package/dist/vpn/kubectl-manager.js.map +1 -0
  165. package/dist/vpn/vpn-api.d.ts +45 -0
  166. package/dist/vpn/vpn-api.js +51 -0
  167. package/dist/vpn/vpn-api.js.map +1 -0
  168. package/dist/vpn/vpn-connect.flow.d.ts +41 -0
  169. package/dist/vpn/vpn-connect.flow.js +172 -0
  170. package/dist/vpn/vpn-connect.flow.js.map +1 -0
  171. package/dist/vpn/vpn.module.d.ts +2 -0
  172. package/dist/vpn/vpn.module.js +23 -0
  173. package/dist/vpn/vpn.module.js.map +1 -0
  174. package/dist/vpn/wireguard-keys.d.ts +5 -0
  175. package/dist/vpn/wireguard-keys.js +12 -0
  176. package/dist/vpn/wireguard-keys.js.map +1 -0
  177. package/package.json +10 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,93 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@secretstartups/workshop` are recorded here.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ Each release's section becomes the notes on its GitHub release, so write entries for people
8
+ who use the CLI, not for people reading the diff.
9
+
10
+ ## [Unreleased]
11
+
12
+ ## [0.2.0] - 2026-09-30
13
+
14
+ ### Added
15
+
16
+ - **`workshop agent`**: an interactive agent session against a workspace or a single service.
17
+ - Plan, auto and discuss modes. Switch with `--mode`, `/mode` or shift+tab.
18
+ - Sessions are kept and can be resumed with `--resume`, `/resume` or `/sessions`. On exit,
19
+ the CLI prints a recap of the session.
20
+ - Slash commands: `/target`, `/diff`, `/files`, `/pr`, `/merge [--all]`, `/model`, `/new`,
21
+ `/status`, `/editor`, `/clear` and `/help`.
22
+ - `--print <prompt>` runs a single turn without the interactive session.
23
+ - `workshop agent sessions` lists recent sessions, and `workshop agent models` lists the models
24
+ the agent can use.
25
+ - **Local mode (`workshop agent --local`)**: the agent edits files and runs commands on your
26
+ machine, so each turn leaves the change in your working tree instead of opening a pull request.
27
+ - Every command needs your approval unless it is on the allowlist. Manage the allowlist with
28
+ `--allow <command>`, `/allow` and `/allowed`.
29
+ - `/roots` shows which working trees the agent can change, and `--root` sets them.
30
+ - The agent cannot write outside the declared roots, write through symlinks or write inside
31
+ `.git`.
32
+ - Local mode works with a single service as well as a whole workspace.
33
+ - **`workshop clone [destination]`**: clones every repository in a workspace into the layout
34
+ that `agent --local` expects. You can run it again at any time: it fetches only the
35
+ repositories you don't have yet and leaves existing checkouts untouched.
36
+ - **`workshop vpn`**: `connect`, `disconnect` and `status` for reaching private and on-prem
37
+ clusters over WireGuard.
38
+ - **`workshop cluster install-local`**: creates a local kind cluster and connects it over the
39
+ VPN. Use `--node-image` to override the pinned Kubernetes version and `--skip-ingress-ports`
40
+ to skip the port 80/443 mapping.
41
+ - **`workshop auth token create | list | revoke`**: manage API tokens. You choose scopes
42
+ interactively or with `--scopes`.
43
+ - `workshop auth login --token` signs in with an API token instead of email and password.
44
+ - `workshop project use` remembers your active project for later commands.
45
+
46
+ ### Changed
47
+
48
+ - `workshop service stop` now pauses the service (scales it to zero and keeps its config and
49
+ URL) instead of undeploying it.
50
+ - Repository slugs now come from the server instead of being derived by the CLI, which fixes
51
+ cases where two services with similar names were mapped to the same checkout.
52
+
53
+ ### Fixed
54
+
55
+ - `cluster install-local` now pins Kubernetes to v1.32.2. Newer kind defaults break ArgoCD DNS.
56
+ - `cluster install-local` now loads locally built connector images into kind.
57
+ - `cluster install-local` now queues add-ons when the tunnel is already up, so they are
58
+ installed.
59
+ - `cluster install-local` no longer registers the same cluster twice.
60
+ - `cluster install-local` now fails early when ports 80/443 are already taken.
61
+ - `vpn connect` now reports when the connector pod has no WireGuard handshake.
62
+
63
+ ## [0.1.3] - 2026-07-16
64
+
65
+ ### Added
66
+
67
+ - `-v` works as an alias for `--version`.
68
+
69
+ ## [0.1.2] - 2026-07-16
70
+
71
+ ### Added
72
+
73
+ - `--version` flag.
74
+ - Update notifications when a newer version is published to npm.
75
+
76
+ ## [0.1.1] - 2026-07-16
77
+
78
+ ### Changed
79
+
80
+ - Release housekeeping.
81
+
82
+ ## [0.1.0] - 2026-06-23
83
+
84
+ ### Added
85
+
86
+ - First public release on npm.
87
+
88
+ [Unreleased]: https://github.com/secretstartups/workshop-cli/compare/v0.2.0...HEAD
89
+ [0.2.0]: https://github.com/secretstartups/workshop-cli/compare/v0.1.3...v0.2.0
90
+ [0.1.3]: https://github.com/secretstartups/workshop-cli/compare/v0.1.2...v0.1.3
91
+ [0.1.2]: https://github.com/secretstartups/workshop-cli/compare/v0.1.1...v0.1.2
92
+ [0.1.1]: https://github.com/secretstartups/workshop-cli/compare/v0.1.0...v0.1.1
93
+ [0.1.0]: https://github.com/secretstartups/workshop-cli/releases/tag/v0.1.0
package/README.md CHANGED
@@ -13,6 +13,17 @@ npm install -g @secretstartups/workshop
13
13
  # workshop <command> now works from anywhere
14
14
  ```
15
15
 
16
+ ### Updating
17
+
18
+ Global installs are pinned and do **not** auto-update. Check your version and update to the latest release:
19
+
20
+ ```bash
21
+ workshop --version # also -v / -V
22
+ npm install -g @secretstartups/workshop@latest # update to the newest release
23
+ ```
24
+
25
+ From `0.1.2` onward the CLI nudges you (once a day) when a newer version is available, so you only need to run the update command when prompted.
26
+
16
27
  ### From source (for contributors)
17
28
 
18
29
  ```bash
@@ -58,14 +69,153 @@ workshop service list --env <envId>
58
69
 
59
70
  ```bash
60
71
  workshop auth login # Log in with email and password
72
+ workshop auth login --token # Log in by pasting an access token (prompts; stays out of shell history)
61
73
  workshop auth logout # Clear stored credentials
62
74
  workshop auth status # Show the currently authenticated user
63
75
 
64
76
  workshop auth token list # List your API tokens
65
- workshop auth token create # Create a new API token (interactive scope selection)
77
+ workshop auth token create # Create a new API token (pick areas, then drill down if you want)
78
+ workshop auth token create --scopes ai --expires 30 # Non-interactive; 'ai' expands to the whole group
66
79
  workshop auth token revoke <id> # Revoke an API token
67
80
  ```
68
81
 
82
+ ### Agent
83
+
84
+ An interactive session with the Workshop AI agent, in your terminal. It streams
85
+ the same builds the web UI shows, prompts for the same clarifications and plan
86
+ approvals, and opens the same pull requests.
87
+
88
+ ```bash
89
+ workshop agent # Open the REPL on the remembered target
90
+ workshop agent -w <workspaceId> # ...on a workspace (multi-repo)
91
+ workshop agent -s <serviceId> # ...on a single service
92
+ workshop agent --resume # Continue the most recent session
93
+ workshop agent --print "add /health" # One prompt, no REPL (add --yes to auto-approve)
94
+
95
+ workshop agent sessions # Recent sessions for the current target
96
+ workshop agent resume <buildId> # Show a session's turns
97
+ workshop agent diff <buildId> # Show what a build changed
98
+ workshop agent files <buildId> # List files on the build's branch
99
+ workshop agent merge <buildId> --all # Merge the pull requests it opened
100
+ workshop agent models # Models available to the agent
101
+ workshop agent rm <sessionId> # Delete a session
102
+ ```
103
+
104
+ ### Local mode
105
+
106
+ By default the agent edits a copy of your code and opens a pull request. With
107
+ `--local` it works on the checkout you actually have:
108
+
109
+ ```bash
110
+ workshop agent --local # find the repos automatically
111
+ workshop agent --local --root api=~/code/api --root web=~/code/web
112
+ workshop agent -s <serviceId> --local --root ~/code/api # one service, one path
113
+ ```
114
+
115
+ It looks for each repository in three places, in order: a `--root` you stated,
116
+ `$HOME/<slug>` (where the browser editor checks repos out), then `<cwd>/<slug>`
117
+ or a directory beside this one whose git remote matches. Directories are matched
118
+ by their remote, never by their name, so a renamed checkout is still found and a
119
+ coincidentally-named one is not used. `workshop clone` writes exactly the layout
120
+ this expects.
121
+
122
+ The agent then reads and writes those working trees and runs commands there, and
123
+ **stops** — nothing is committed and no pull request is opened. Review what it
124
+ did with `git diff` and commit it yourself.
125
+
126
+ Every command it proposes asks first:
127
+
128
+ ```
129
+ ⚙ npm test
130
+ in ~/code/api
131
+ ? Run this?
132
+ ❯ Yes, once
133
+ Yes, and always allow `npm test`
134
+ Yes, and always allow `npm test …`
135
+ No
136
+ No — and tell it why
137
+ ```
138
+
139
+ `/allow <command>` pre-approves one for good, `/allowed` lists what may run
140
+ without asking, and `/roots` shows which trees the agent can reach. Rules match
141
+ an exact command or a first-token prefix and nothing else — `npm test` will
142
+ never quietly authorise `npm test && rm -rf ~`.
143
+
144
+ File edits are not prompted; that is the point of the mode. They are written
145
+ atomically, keep the file's existing mode, and can never land outside a declared
146
+ root or inside `.git`.
147
+
148
+ Non-interactively (`--print`, a pipe, CI) commands are **refused by default**
149
+ with a reason the agent can read, while file edits still proceed. Pre-approve
150
+ specific ones with `--allow`, or use `--dangerously-allow-all` if you genuinely
151
+ want a CI job running whatever the model writes.
152
+
153
+ Local mode needs a terminal attached for the whole turn:
154
+ if it disconnects the agent waits a couple of minutes for you to come back and
155
+ then fails the turn rather than leaving your tree half-edited.
156
+
157
+ The agent needs these scopes on its token: `ai.view`, `ai.execute` (start and
158
+ continue builds, merge their PRs), `ai.update` (approve, revise or answer a
159
+ plan), `workspaces.view`, and `projects.view` + `services.view` for the
160
+ interactive pickers. Add `ai.delete` if you want `workshop agent rm`.
161
+
162
+ The prompt shows the mode it will submit under, and **shift+tab** cycles it in
163
+ place — `plan` (plans first, asks before changing anything) → `auto` (makes the
164
+ change and opens a PR) → `discuss` (answers questions, never edits):
165
+
166
+ ```
167
+ [plan] › add a health endpoint to the API
168
+ plans first, asks before changing anything · shift+tab to change
169
+ ```
170
+
171
+ **Esc** backs out of any picker and returns you to the prompt, with nothing
172
+ changed.
173
+
174
+ `/help` lists the slash commands. `/sessions` and `/resume` both open a
175
+ scrollable list of past sessions to continue, `/target` switches to another
176
+ workspace or service, `/mode` and `/model` open pickers when given no argument,
177
+ and Ctrl+C detaches without stopping the build — it runs server-side, so
178
+ `workshop agent --resume` picks it back up.
179
+
180
+ The target is remembered between runs, so `workshop agent` on its own reopens
181
+ whatever you last worked on; `/target` (or `-w` / `-s`) moves somewhere else.
182
+
183
+ A workspace target needs to know its project, so run `workshop project use <id>`
184
+ once (or pass `--project`).
185
+
186
+ **Running it inside a workspace editor.** The code-server terminal has no
187
+ credentials and cannot reach a private API, so set both explicitly:
188
+
189
+ ```bash
190
+ npm i -g @secretstartups/workshop
191
+ export WORKSHOP_API_URL=https://your-workshop-api/api/v1
192
+ workshop auth login --token # paste a token (see the scopes the agent needs, below)
193
+ workshop agent
194
+ ```
195
+
196
+ ### Clone
197
+
198
+ Put a workspace's repositories on this machine, laid out the way `--local`
199
+ expects:
200
+
201
+ ```bash
202
+ workshop clone # every repo of the remembered workspace, here
203
+ workshop clone ~/code # ...into a directory you name
204
+ workshop clone --service <serviceId> # just one service
205
+ workshop clone --branch next # override the branch each service pins
206
+ ```
207
+
208
+ It behaves like `git clone`: one directory per repository in the directory you
209
+ are standing in, named by the slug the platform addresses that repository by —
210
+ which is what lets `workshop agent --local` find them afterwards with no flags.
211
+
212
+ Repositories already present are left alone, so running it again after a service
213
+ joins the workspace fetches only the new one. If a repository fails the rest
214
+ still land, and the exact `git clone` to retry is printed.
215
+
216
+ It uses your own git credentials — the CLI holds no GitHub token and the
217
+ platform does not issue one for this.
218
+
69
219
  ### Organizations
70
220
 
71
221
  ```bash
@@ -86,6 +236,7 @@ workshop org members remove <id> # Remove a member
86
236
  workshop project list # List projects in the active org
87
237
  workshop project create # Create a project
88
238
  workshop project get <projectId> # Get project details
239
+ workshop project use <projectId> # Set the active project (remembered for later commands)
89
240
  workshop project delete <projectId> # Delete a project
90
241
  ```
91
242
 
@@ -118,12 +269,55 @@ workshop service stop <serviceId> # Stop (undeploy) a service
118
269
  ```bash
119
270
  workshop cluster list # List Kubernetes clusters
120
271
  workshop cluster create # Create a cluster (interactive wizard)
272
+ workshop cluster install-local # Create a local kind cluster and connect it
121
273
  workshop cluster get <clusterId> # Get cluster details
122
274
  workshop cluster delete <clusterId> # Delete a cluster
123
275
  workshop cluster nodes <clusterId> # List cluster nodes
124
276
  workshop cluster workloads <clusterId> # List cluster workloads
125
277
  ```
126
278
 
279
+ #### Local clusters
280
+
281
+ `install-local` installs kind if needed, creates a cluster, and attaches it to
282
+ Workshop in one step.
283
+
284
+ How it connects depends on whether Workshop can reach the cluster:
285
+
286
+ | Your Workshop API | What happens |
287
+ |---|---|
288
+ | `localhost` | Connects directly over loopback. Nothing else needed. |
289
+ | anywhere else | Connects over the VPN — the cluster dials out to Workshop, so no inbound ports are opened. |
290
+
291
+ If Workshop is remote and its VPN gateway is not configured, the command stops
292
+ before creating anything and tells you which settings are missing. It will not
293
+ silently fall back to registering by certificate, which would store a client key
294
+ server-side and disable TLS verification.
295
+
296
+ ```bash
297
+ workshop cluster install-local --name dev # auto-detect
298
+ workshop cluster install-local --vpn # force the VPN
299
+ workshop cluster install-local --direct # register by certificate (less secure)
300
+ workshop cluster install-local --skip-bootstrap # skip add-on installation
301
+ ```
302
+
303
+ If any step fails, the kind cluster this command created is removed again — you
304
+ are not left with an orphan to clean up by hand.
305
+
306
+ ### VPN (private clusters)
307
+
308
+ Lets Workshop manage a cluster it cannot reach directly — on a laptop, or behind
309
+ a firewall — over an outbound-only WireGuard tunnel. `install-local` uses this
310
+ automatically; these commands are for clusters that already exist.
311
+
312
+ ```bash
313
+ workshop vpn connect --context <ctx> # Install the connector and attach the cluster
314
+ workshop vpn status # Connection status, handshakes and traffic
315
+ workshop vpn disconnect # Revoke access and remove the connector
316
+ ```
317
+
318
+ The WireGuard private key is generated on your machine and never sent to
319
+ Workshop; only the public half leaves the host.
320
+
127
321
  ### Virtual Machines
128
322
 
129
323
  ```bash
@@ -165,6 +359,7 @@ Every command supports these flags:
165
359
  | `--json` | Output raw JSON instead of formatted tables |
166
360
  | `--org <orgId>` | Override the active organization for this command |
167
361
  | `--help` | Show help for any command |
362
+ | `--version`, `-v`, `-V` | Print the installed CLI version |
168
363
 
169
364
  ## Configuration
170
365
 
@@ -175,10 +370,23 @@ The CLI stores its config at `~/.workshop/config.json`:
175
370
  "apiUrl": "http://localhost:3000/api/v1",
176
371
  "token": "eyJ...",
177
372
  "currentOrgId": "uuid",
178
- "currentOrgName": "My Org"
373
+ "currentOrgName": "My Org",
374
+ "currentProjectId": "uuid",
375
+ "agentTarget": { "kind": "workspace", "id": "uuid", "label": "Checkout", "projectId": "uuid" }
179
376
  }
180
377
  ```
181
378
 
379
+ Environment variables override the stored file, so no interactive setup is
380
+ needed in CI or inside a workspace pod:
381
+
382
+ | Variable | Overrides |
383
+ |---|---|
384
+ | `WORKSHOP_API_URL` | `apiUrl` |
385
+ | `WORKSHOP_TOKEN` | `token` |
386
+ | `WORKSHOP_ORG_ID` | `currentOrgId` |
387
+ | `WORKSHOP_PROJECT_ID` | `currentProjectId` |
388
+ | `WORKSHOP_WORKSPACE_ID` / `WORKSHOP_SERVICE_ID` | the agent's target |
389
+
182
390
  You can also authenticate using a long-lived API token (useful for CI/CD):
183
391
 
184
392
  ```bash
@@ -0,0 +1,60 @@
1
+ import { AgentTarget } from '../common/config/cli-config.service';
2
+ import { BuildApiService, BuildMode, BuildResponse } from './build-api.service';
3
+ import { GateOptions, GatePrompter } from './gates/gate-prompter';
4
+ import { LiveConsole } from './render/live-console';
5
+ import { BuildStreamClient } from './sse/build-stream.client';
6
+ import { ExecutorClient } from './executor/executor-client';
7
+ import { ExecutorDeclaration } from './executor/executor.types';
8
+ import { CommandAllowlist } from './executor/allowlist';
9
+ export interface TurnRecord {
10
+ prompt: string;
11
+ buildId: string;
12
+ status: string;
13
+ summary?: string;
14
+ prUrls: string[];
15
+ kind?: string;
16
+ }
17
+ export interface ExecutorRuntimeContext {
18
+ client: ExecutorClient;
19
+ declaration: ExecutorDeclaration;
20
+ allowlist: CommandAllowlist;
21
+ }
22
+ export declare function prUrlsOf(build: BuildResponse): string[];
23
+ export declare function settledPrUrlsOf(build: BuildResponse): string[];
24
+ export interface SessionOptions {
25
+ mode: BuildMode;
26
+ executor?: ExecutorRuntimeContext;
27
+ modelId?: string;
28
+ verbosity: number;
29
+ gates: GateOptions;
30
+ }
31
+ export declare class AgentSession {
32
+ private _target;
33
+ private readonly api;
34
+ private readonly stream;
35
+ private readonly gates;
36
+ private readonly console;
37
+ private readonly opts;
38
+ sessionId?: string;
39
+ lastBuildId?: string;
40
+ readonly turns: TurnRecord[];
41
+ readonly settledPrs: Set<string>;
42
+ constructor(_target: AgentTarget, api: BuildApiService, stream: BuildStreamClient, gates: GatePrompter, console: LiveConsole, opts: SessionOptions);
43
+ get target(): AgentTarget;
44
+ setTarget(target: AgentTarget): void;
45
+ get mode(): BuildMode;
46
+ get modelId(): string | undefined;
47
+ setMode(mode: BuildMode): void;
48
+ setModel(modelId: string): void;
49
+ get executorContext(): ExecutorRuntimeContext | undefined;
50
+ detachExecutor(reason: string): Promise<void>;
51
+ reset(): void;
52
+ attach(buildId: string): Promise<TurnRecord[]>;
53
+ markPrsSettled(urls: string[]): void;
54
+ openPrUrls(): string[];
55
+ lastTurnWithPrs(): TurnRecord | undefined;
56
+ runTurn(prompt: string, signal?: AbortSignal): Promise<TurnRecord | null>;
57
+ private maybeGate;
58
+ private finishTurn;
59
+ private printSummary;
60
+ }
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AgentSession = void 0;
7
+ exports.prUrlsOf = prUrlsOf;
8
+ exports.settledPrUrlsOf = settledPrUrlsOf;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const build_events_types_1 = require("./build-events.types");
11
+ const gate_prompter_1 = require("./gates/gate-prompter");
12
+ const event_renderer_1 = require("./render/event-renderer");
13
+ const run_summary_1 = require("./render/run-summary");
14
+ const build_stream_client_1 = require("./sse/build-stream.client");
15
+ function prUrlsOf(build) {
16
+ const urls = (build.repositories ?? [])
17
+ .map((repo) => repo.prUrl)
18
+ .filter((url) => Boolean(url));
19
+ if (build.repository?.prUrl)
20
+ urls.push(build.repository.prUrl);
21
+ return [...new Set(urls)];
22
+ }
23
+ function settledPrUrlsOf(build) {
24
+ const done = (state) => state === 'merged' || state === 'closed';
25
+ const urls = (build.repositories ?? [])
26
+ .filter((repo) => repo.prUrl && done(repo.prState))
27
+ .map((repo) => repo.prUrl);
28
+ if (build.repository?.prUrl && done(build.repository.prState)) {
29
+ urls.push(build.repository.prUrl);
30
+ }
31
+ return urls;
32
+ }
33
+ class AgentSession {
34
+ constructor(_target, api, stream, gates, console, opts) {
35
+ this._target = _target;
36
+ this.api = api;
37
+ this.stream = stream;
38
+ this.gates = gates;
39
+ this.console = console;
40
+ this.opts = opts;
41
+ this.turns = [];
42
+ this.settledPrs = new Set();
43
+ }
44
+ get target() {
45
+ return this._target;
46
+ }
47
+ setTarget(target) {
48
+ this._target = target;
49
+ this.reset();
50
+ }
51
+ get mode() {
52
+ return this.opts.mode;
53
+ }
54
+ get modelId() {
55
+ return this.opts.modelId;
56
+ }
57
+ setMode(mode) {
58
+ this.opts.mode = mode;
59
+ }
60
+ setModel(modelId) {
61
+ this.opts.modelId = modelId;
62
+ }
63
+ get executorContext() {
64
+ return this.opts.executor;
65
+ }
66
+ async detachExecutor(reason) {
67
+ await this.opts.executor?.client.detach(reason);
68
+ }
69
+ reset() {
70
+ this.sessionId = undefined;
71
+ this.lastBuildId = undefined;
72
+ }
73
+ async attach(buildId) {
74
+ const session = await this.api.getSession(buildId);
75
+ this.sessionId = session.sessionId;
76
+ this.turns.length = 0;
77
+ this.settledPrs.clear();
78
+ for (const turn of session.turns) {
79
+ for (const url of settledPrUrlsOf(turn))
80
+ this.settledPrs.add(url);
81
+ this.turns.push({
82
+ prompt: turn.prompt ?? '',
83
+ buildId: turn.id,
84
+ status: turn.status,
85
+ summary: turn.summary,
86
+ prUrls: prUrlsOf(turn),
87
+ kind: turn.kind,
88
+ });
89
+ }
90
+ const latest = session.turns[session.turns.length - 1];
91
+ this.lastBuildId = latest?.id ?? buildId;
92
+ return this.turns;
93
+ }
94
+ markPrsSettled(urls) {
95
+ for (const url of urls)
96
+ this.settledPrs.add(url);
97
+ }
98
+ openPrUrls() {
99
+ return [...new Set(this.turns.flatMap((t) => t.prUrls))].filter((url) => !this.settledPrs.has(url));
100
+ }
101
+ lastTurnWithPrs() {
102
+ const withPrs = [...this.turns].reverse().filter((t) => t.prUrls.length);
103
+ return withPrs.find((t) => t.kind && t.kind !== 'discuss') ?? withPrs[0];
104
+ }
105
+ async runTurn(prompt, signal) {
106
+ let buildId;
107
+ try {
108
+ const started = this.lastBuildId
109
+ ? await this.api.continueTurn(this.lastBuildId, {
110
+ message: prompt,
111
+ mode: this.opts.mode,
112
+ modelId: this.opts.modelId,
113
+ executor: this.opts.executor?.declaration,
114
+ })
115
+ : this.target.kind === 'workspace'
116
+ ? await this.api.startWorkspaceEdit(this.target.id, {
117
+ prompt,
118
+ mode: this.opts.mode,
119
+ modelId: this.opts.modelId,
120
+ executor: this.opts.executor?.declaration,
121
+ })
122
+ : await this.api.startServiceEdit(this.target.id, {
123
+ prompt,
124
+ mode: this.opts.mode,
125
+ modelId: this.opts.modelId,
126
+ executor: this.opts.executor?.declaration,
127
+ });
128
+ buildId = started.buildId;
129
+ this.lastBuildId = buildId;
130
+ }
131
+ catch (err) {
132
+ if (/running|in progress|not.*finish/i.test(err?.message ?? '')) {
133
+ throw new Error(`That turn is still running. Re-attach with: workshop agent resume ${this.lastBuildId}`);
134
+ }
135
+ throw err;
136
+ }
137
+ const startedAt = Date.now();
138
+ const ctx = (0, event_renderer_1.newTurnContext)(buildId);
139
+ const renderer = new event_renderer_1.EventRenderer(this.console, ctx, this.opts.verbosity);
140
+ if (this.opts.executor) {
141
+ this.opts.executor.client.forBuild(buildId);
142
+ await this.opts.executor.client.attach();
143
+ }
144
+ this.console.status('Thinking');
145
+ let denied = false;
146
+ try {
147
+ for await (const event of this.stream.events(buildId, {
148
+ signal,
149
+ hooks: {
150
+ onReconnect: (n, max) => this.console.line(chalk_1.default.yellow(`⚠ reconnecting (${n}/${max})…`)),
151
+ onHistoryLost: () => this.console.line(chalk_1.default.yellow('⚠ event history expired; following the build status instead')),
152
+ onDegraded: (why) => this.console.line(chalk_1.default.yellow(`⚠ ${why}; polling for the result`)),
153
+ },
154
+ })) {
155
+ renderer.handle(event);
156
+ if (this.opts.executor) {
157
+ await this.opts.executor.client.handle(event);
158
+ }
159
+ const outcome = await this.maybeGate(buildId, event);
160
+ if (outcome === 'denied') {
161
+ denied = true;
162
+ break;
163
+ }
164
+ }
165
+ }
166
+ catch (err) {
167
+ this.console.stop();
168
+ if (err instanceof gate_prompter_1.GateAbort)
169
+ throw err;
170
+ if (err instanceof build_stream_client_1.BuildNotFoundError)
171
+ throw err;
172
+ throw err;
173
+ }
174
+ finally {
175
+ this.console.stop();
176
+ }
177
+ return this.finishTurn(prompt, buildId, ctx, denied, startedAt);
178
+ }
179
+ async maybeGate(buildId, event) {
180
+ if ((0, build_events_types_1.isEvent)(event, 'clarification_required')) {
181
+ await this.gates.handleClarification(buildId, event, this.console, this.opts.gates);
182
+ this.console.status('Thinking');
183
+ return null;
184
+ }
185
+ if ((0, build_events_types_1.isEvent)(event, 'approval_required')) {
186
+ const outcome = await this.gates.handleApproval(buildId, event, this.console, {
187
+ ...this.opts.gates,
188
+ isWorkspace: this.target.kind === 'workspace',
189
+ });
190
+ if (outcome !== 'denied')
191
+ this.console.status('Working');
192
+ return outcome;
193
+ }
194
+ return null;
195
+ }
196
+ async finishTurn(prompt, buildId, ctx, denied, startedAt) {
197
+ let build = null;
198
+ try {
199
+ build = await this.api.getBuild(buildId);
200
+ }
201
+ catch {
202
+ }
203
+ if (build?.sessionId && !this.sessionId)
204
+ this.sessionId = build.sessionId;
205
+ const prUrls = [
206
+ ...new Set([...ctx.prUrls, ...(build ? prUrlsOf(build) : [])]),
207
+ ];
208
+ const record = {
209
+ prompt,
210
+ buildId,
211
+ status: denied ? 'cancelled' : (build?.status ?? 'unknown'),
212
+ summary: build?.summary,
213
+ prUrls,
214
+ };
215
+ this.turns.push(record);
216
+ if (!denied)
217
+ this.printSummary(record, build, ctx, startedAt);
218
+ return record;
219
+ }
220
+ printSummary(record, build, ctx, startedAt = Date.now()) {
221
+ this.console.line('');
222
+ if (record.status === 'failed' || ctx.errors.length) {
223
+ const why = build?.error ?? ctx.errors[ctx.errors.length - 1] ?? 'unknown error';
224
+ this.console.line(`${chalk_1.default.red('✗')} ${why}`);
225
+ this.console.line(chalk_1.default.dim(` build ${record.buildId}`));
226
+ return;
227
+ }
228
+ if (this.opts.executor) {
229
+ for (const line of (0, run_summary_1.renderRunSummary)({
230
+ summary: build?.summary ?? record.summary,
231
+ elapsedMs: Date.now() - startedAt,
232
+ trees: ctx.workingTrees,
233
+ authored: ctx.files.size,
234
+ tally: this.opts.executor.client.activity,
235
+ externallyModified: [...this.opts.executor.client.externallyModified],
236
+ })) {
237
+ this.console.line(line);
238
+ }
239
+ this.console.line('');
240
+ return;
241
+ }
242
+ if (ctx.files.size) {
243
+ this.console.line(chalk_1.default.dim(` ${ctx.files.size} file${ctx.files.size === 1 ? '' : 's'} changed`));
244
+ }
245
+ for (const url of record.prUrls) {
246
+ this.console.line(` ${chalk_1.default.green('⇡')} ${chalk_1.default.underline(url)}`);
247
+ }
248
+ const failedRepos = (build?.repositories ?? []).filter((r) => r.commitError);
249
+ for (const repo of failedRepos) {
250
+ this.console.line(` ${chalk_1.default.red('✗')} ${repo.slug}: ${repo.commitError}`);
251
+ }
252
+ if (record.prUrls.length) {
253
+ const cmd = this.target.kind === 'workspace'
254
+ ? `workshop agent merge ${record.buildId} --all`
255
+ : `workshop agent merge ${record.buildId}`;
256
+ this.console.line(chalk_1.default.dim(` merge with: ${cmd}`));
257
+ }
258
+ this.console.line('');
259
+ }
260
+ }
261
+ exports.AgentSession = AgentSession;
262
+ //# sourceMappingURL=agent-session.js.map