@treestructuredplanning/gateway 0.1.3 → 0.3.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.
- package/README.md +57 -82
- package/dist/cli.js +55 -48
- package/dist/gateway-schema.json +450 -38
- package/dist/{shared-RM5C4AZN.js → shared-KRIZBGVD.js} +3658 -2328
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# TSP gateway
|
|
2
2
|
|
|
3
3
|
The TSP gateway lets the [Tree-Structured Planning](https://treestructuredplanning.com)
|
|
4
|
-
(TSP) canvas start, stop and
|
|
4
|
+
(TSP) canvas start, stop and continue Claude Code, Codex and Cursor sessions on your computer, in the
|
|
5
5
|
repository folders you register. It runs in the background under your own user account and
|
|
6
6
|
only connects outward to TSP.
|
|
7
7
|
|
|
@@ -17,79 +17,28 @@ only connects outward to TSP.
|
|
|
17
17
|
count for a repository inside it.
|
|
18
18
|
- On Linux, a running Secret Service such as GNOME Keyring or KWallet. The gateway will not
|
|
19
19
|
run without an OS credential store.
|
|
20
|
-
- Build must be available for your TSP account.
|
|
21
20
|
|
|
22
21
|
`connect` and `tsp-gateway status` say which harnesses can build in each folder and what is left to
|
|
23
22
|
you: installing or signing in to a harness, or accepting its trust prompt. Once one harness is ready
|
|
24
23
|
in a folder, steps for your other harnesses are optional.
|
|
25
24
|
|
|
26
|
-
## Connect
|
|
25
|
+
## Connect, disconnect and commands
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
Connecting, turning the gateway off, disconnecting, every command, what leaves your computer, and
|
|
28
|
+
stopping and continuing agents are documented on one page:
|
|
29
|
+
[Build on your machine](https://treestructuredplanning.com/docs/drive-with-your-agent/build-on-your-machine). Start there.
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
npx -y @treestructuredplanning/gateway@latest connect
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
`connect [folder]` (the folder defaults to the current one) does the whole setup, and running
|
|
35
|
-
it again is safe:
|
|
36
|
-
|
|
37
|
-
1. It checks that the folder is a clone with a GitHub remote, so a wrong folder fails before
|
|
38
|
-
anything changes.
|
|
39
|
-
2. It pairs this computer with your TSP account, only after you approve in the browser window
|
|
40
|
-
it opens. It also prints the approval link in case no browser opens. A working pairing is
|
|
41
|
-
kept.
|
|
42
|
-
3. It registers the folder.
|
|
43
|
-
4. It installs a login item that starts the gateway when you log in.
|
|
44
|
-
5. It prints a short summary: which harnesses are ready in each folder, and the steps only you can
|
|
45
|
-
take (install a harness, sign in, or run it there once to accept its trust prompt). They are
|
|
46
|
-
required until one harness is ready, and optional after that.
|
|
47
|
-
|
|
48
|
-
Run outside any clone, `connect` keeps the folders already registered and repairs the rest,
|
|
49
|
-
so it also fixes a stopped, outdated or revoked gateway. If TSP cannot be reached, nothing
|
|
50
|
-
changes; try again later. The login item runs the copy of the gateway that `connect` ran
|
|
51
|
-
from. With `npx` that is npm's cache, so if you clear that cache, run `connect` again.
|
|
52
|
-
|
|
53
|
-
## Disconnect and uninstall
|
|
54
|
-
|
|
55
|
-
```sh
|
|
56
|
-
npx -y @treestructuredplanning/gateway@latest disconnect
|
|
57
|
-
```
|
|
31
|
+
## Remove it completely
|
|
58
32
|
|
|
59
|
-
`disconnect
|
|
60
|
-
its stored credential. Registered folders stay in the config file. If TSP cannot be reached,
|
|
61
|
-
the pairing is kept; run `disconnect` again. If the credential was already missing, the
|
|
62
|
-
computer may still be listed in TSP; remove it from Settings there.
|
|
63
|
-
|
|
64
|
-
To leave nothing behind, also delete the config and state folders listed under
|
|
33
|
+
After `disconnect`, delete the config and state folders listed under
|
|
65
34
|
[What it stores](#what-it-stores), and if you installed globally:
|
|
66
35
|
|
|
67
36
|
```sh
|
|
68
37
|
npm uninstall --global @treestructuredplanning/gateway
|
|
69
38
|
```
|
|
70
39
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
With a global install (`npm install --global @treestructuredplanning/gateway@latest`) the
|
|
74
|
-
command is `tsp-gateway`; with `npx`, use `npx -y @treestructuredplanning/gateway@latest`
|
|
75
|
-
in its place.
|
|
76
|
-
|
|
77
|
-
| Command | What it does |
|
|
78
|
-
| ----------------------------- | ------------------------------------------------------------------------------- |
|
|
79
|
-
| `connect [folder]` | Pair if needed, register the folder, install the login item, print a summary. |
|
|
80
|
-
| `disconnect` | Remove the login item, then unpair. |
|
|
81
|
-
| `pair` | Pair this computer with your TSP account (replaces any existing pairing). |
|
|
82
|
-
| `add <folder>` | Register a repository folder. |
|
|
83
|
-
| `remove <owner/name>` | Unregister a repository. |
|
|
84
|
-
| `configure-launch '<json>'` | Set how sessions get your shell environment (see below). |
|
|
85
|
-
| `configure-reporting <level>` | `activity` (default) or `off`: whether session activity is sent to TSP. |
|
|
86
|
-
| `status [--json]` | Show pairing, connection and each folder's next steps; `--json` is for scripts. |
|
|
87
|
-
| `start` | Run the gateway in the foreground. Ctrl-C stops it, not your sessions. |
|
|
88
|
-
| `install` | Install or refresh the login item. Run it again after upgrading the gateway. |
|
|
89
|
-
| `uninstall` | Remove the login item; keep the pairing and folders. |
|
|
90
|
-
| `unpair` | Revoke this computer's pairing in TSP and delete the stored credential. |
|
|
91
|
-
|
|
92
|
-
Registering or removing a folder takes effect in the running gateway without a restart.
|
|
40
|
+
The login item runs the copy of the gateway that `connect` ran from. With `npx` that is npm's
|
|
41
|
+
cache, so if you clear that cache, run `connect` again.
|
|
93
42
|
|
|
94
43
|
## What TSP can ask it to do
|
|
95
44
|
|
|
@@ -98,14 +47,14 @@ TSP can ask the gateway for exactly four things, and only in folders you registe
|
|
|
98
47
|
- **Launch** a Claude Code, Codex or Cursor session, with a prompt describing the TSP work you
|
|
99
48
|
started from the canvas.
|
|
100
49
|
- **Stop** that session.
|
|
101
|
-
- **
|
|
102
|
-
|
|
103
|
-
|
|
50
|
+
- **Continue** that session. A stopped session gets the fixed prompt
|
|
51
|
+
`Continue where you left off.`; a done or failed session reopens without a prompt and
|
|
52
|
+
waits for you.
|
|
104
53
|
- **Report status**: which harnesses are installed, signed in and trust each registered
|
|
105
54
|
folder, and how each launched session is doing.
|
|
106
55
|
|
|
107
56
|
Only your own clicks in TSP send a prompt. Claude Code and Codex sessions keep running if the
|
|
108
|
-
gateway stops; a Cursor session ends with the gateway, and
|
|
57
|
+
gateway stops; a Cursor session ends with the gateway, and Continue reopens its chat. A
|
|
109
58
|
session that finishes does not mean TSP has reviewed or accepted its work. Keep the
|
|
110
59
|
[TSP plugin](https://github.com/WebifyServices/tsp-plugin) installed so launched sessions
|
|
111
60
|
have TSP's tools.
|
|
@@ -132,22 +81,6 @@ child process for each running turn. It sends no mode, model, permission or sign
|
|
|
132
81
|
Cursor applies your own settings and permission rules, and the gateway starts a session only in a
|
|
133
82
|
folder you have already trusted.
|
|
134
83
|
|
|
135
|
-
## What leaves your computer
|
|
136
|
-
|
|
137
|
-
The gateway sends TSP only repository names (`owner/name`), which harnesses are available,
|
|
138
|
-
signed in and trusted per folder, and session status, including any waiting message with
|
|
139
|
-
folder paths removed. For each launched session it also sends what the session is doing
|
|
140
|
-
(reading, editing, running a command), when it was last active, and counts of files edited
|
|
141
|
-
and commands run; never file names or commands. When a Cursor turn finishes it also sends what
|
|
142
|
-
Cursor last said, trimmed to 240 characters with folder paths removed, so TSP can show it; no
|
|
143
|
-
other transcript text is sent. Folder paths, environment variables, command lines, transcripts
|
|
144
|
-
and raw error output stay on your computer. Run
|
|
145
|
-
`tsp-gateway configure-reporting off` to stop sending activity (`activity` turns it back on).
|
|
146
|
-
|
|
147
|
-
The gateway only connects outward, to TSP, and accepts no inbound connections. The only
|
|
148
|
-
exception is pairing: while you approve in the browser, it listens briefly on `127.0.0.1`
|
|
149
|
-
(your computer only) for the browser's reply, then stops.
|
|
150
|
-
|
|
151
84
|
## How sessions get your environment
|
|
152
85
|
|
|
153
86
|
By default, Claude Code sessions start through your login shell, so variables your shell
|
|
@@ -213,7 +146,49 @@ or choose `direct`. Changes apply to sessions started afterwards, not to running
|
|
|
213
146
|
On Windows, access to these folders follows your user profile's permissions. Delete the state
|
|
214
147
|
folder only after `disconnect`, once no gateway is running.
|
|
215
148
|
|
|
149
|
+
Repository advertisements and launches use protocol 2, with an explicit host, owner and name. Upgrade a protocol 1 gateway when TSP shows the update state. Only `github.com` launches are supported. Existing local GitHub registrations are expanded and rewritten on the next config read.
|
|
150
|
+
|
|
151
|
+
## Attempt checkouts
|
|
152
|
+
|
|
153
|
+
With **Own worktree**, Build prepares a separate worktree at
|
|
154
|
+
`<Git top level>/.tsp/worktrees/<attempt-id>` on `tsp/<attempt-id>`. Registering `packages/app` starts the agent in
|
|
155
|
+
`<worktree>/packages/app`, preserving its package configuration. Its base is fetched from the repository's remote landing line;
|
|
156
|
+
a failed fetch refuses the launch. A dirty, stale or unrelated main checkout does
|
|
157
|
+
not determine that base. **Shared checkout, current branch** leaves its branch alone.
|
|
158
|
+
**Shared checkout, new branch** refuses to switch while another tracked agent is live
|
|
159
|
+
there or files are dirty.
|
|
160
|
+
|
|
161
|
+
Set the local machine root with `tsp-gateway config worktrees-root <path>`; restore
|
|
162
|
+
the default with `tsp-gateway config worktrees-root --reset`. Override one clone with
|
|
163
|
+
`tsp-gateway config worktrees-root --repo <folder> <path>`; clear that override with
|
|
164
|
+
`tsp-gateway config worktrees-root --repo <folder> --reset`. The folder must already
|
|
165
|
+
be registered. These config commands never install or change a login item.
|
|
166
|
+
`tsp-gateway worktrees` prints each registered folder's worktree folder in full and
|
|
167
|
+
which setting chose it. It prints only in your terminal; TSP never receives these paths.
|
|
168
|
+
`connect <folder> --worktrees-root <path>` also sets the override during setup.
|
|
169
|
+
Paths can be absolute, `~/`
|
|
170
|
+
relative, or relative to the registered folder. The root cannot be the clone or an ancestor. Existing
|
|
171
|
+
sessions keep their recorded folder when configuration changes. The default adds
|
|
172
|
+
`/.tsp/` to Git's local exclude file once. A custom root inside the repository
|
|
173
|
+
gets an exclude anchored at the Git top level, including any package prefix; an
|
|
174
|
+
outside root needs no root exclude.
|
|
175
|
+
|
|
176
|
+
Claude Code and Codex linked worktrees inherit the registered clone's trust. TSP never writes trust
|
|
177
|
+
or permission settings. Allow the worktree root in per-path tools such as direnv
|
|
178
|
+
or mise if your harness installation depends on them.
|
|
179
|
+
|
|
180
|
+
Only ignored files selected by `.worktreeinclude` are copied. No file is copied
|
|
181
|
+
when it is absent, and symlinks escaping the clone are not followed. Existing
|
|
182
|
+
files in the destination are preserved, including on reuse. Before copying a new
|
|
183
|
+
file, the gateway verifies that the destination ignores it, adding an exact path
|
|
184
|
+
to Git's local exclude when needed. If it cannot protect the file, the launch
|
|
185
|
+
refuses before copying it. Tracked destination files are never written. A local branch
|
|
186
|
+
named `tsp` blocks the `tsp/<attempt-id>` namespace and must be renamed by the user.
|
|
187
|
+
TSP never deletes worktrees or branches. Reusing an attempt never rebases its
|
|
188
|
+
branch; the reported base is its shared ancestor with the fetched landing line.
|
|
189
|
+
|
|
216
190
|
## Help
|
|
217
191
|
|
|
218
|
-
See the
|
|
219
|
-
|
|
192
|
+
See the
|
|
193
|
+
[TSP documentation](https://treestructuredplanning.com/docs/drive-with-your-agent/build-on-your-machine)
|
|
194
|
+
or email `support@treestructuredplanning.com`.
|
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
ActivityReporter,
|
|
5
|
+
CheckoutPreparer,
|
|
5
6
|
Commands,
|
|
6
7
|
GATEWAY_CLOSE_DISPOSITION,
|
|
7
8
|
GatewayStatus,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
builtinHarnesses,
|
|
14
15
|
connect,
|
|
15
16
|
connectLines,
|
|
17
|
+
connectWorktreeArgs,
|
|
16
18
|
daemonConnection,
|
|
17
19
|
daemonLock,
|
|
18
20
|
decodeLaunchConfig,
|
|
@@ -25,24 +27,29 @@ import {
|
|
|
25
27
|
isObject,
|
|
26
28
|
keychain,
|
|
27
29
|
locations,
|
|
28
|
-
|
|
30
|
+
loginItemHome,
|
|
29
31
|
parseJson,
|
|
32
|
+
parseRepositoryRemote,
|
|
33
|
+
printWorktreeRoots,
|
|
30
34
|
privateDirectory,
|
|
31
35
|
readConfig,
|
|
32
36
|
readLaunchObservation,
|
|
37
|
+
recordConnectRoot,
|
|
38
|
+
registeredLines,
|
|
33
39
|
removeLoginItem,
|
|
40
|
+
repositoryFolders,
|
|
41
|
+
repositoryKey,
|
|
34
42
|
runDaemon,
|
|
35
43
|
saveConfig,
|
|
36
44
|
statusLines,
|
|
37
|
-
|
|
38
|
-
validSlug,
|
|
45
|
+
updateGateway,
|
|
39
46
|
validateOrigin,
|
|
40
|
-
watchConfig
|
|
41
|
-
|
|
47
|
+
watchConfig,
|
|
48
|
+
worktreesCommand
|
|
49
|
+
} from "./shared-KRIZBGVD.js";
|
|
42
50
|
|
|
43
51
|
// src/cli.ts
|
|
44
52
|
import { readFile } from "node:fs/promises";
|
|
45
|
-
import { homedir } from "node:os";
|
|
46
53
|
import { isAbsolute, join } from "node:path";
|
|
47
54
|
import { fileURLToPath } from "node:url";
|
|
48
55
|
import { parseArgs } from "node:util";
|
|
@@ -50,7 +57,7 @@ import { parseArgs } from "node:util";
|
|
|
50
57
|
// package.json
|
|
51
58
|
var package_default = {
|
|
52
59
|
name: "@treestructuredplanning/gateway",
|
|
53
|
-
version: "0.
|
|
60
|
+
version: "0.3.0",
|
|
54
61
|
description: "Outbound local harness gateway for Tree-Structured Planning",
|
|
55
62
|
type: "module",
|
|
56
63
|
engines: {
|
|
@@ -69,13 +76,13 @@ var package_default = {
|
|
|
69
76
|
scripts: {
|
|
70
77
|
build: "node scripts/build.mjs",
|
|
71
78
|
prepack: "pnpm build",
|
|
72
|
-
test: "pnpm build && node --test --test-concurrency=3 test/*.test.mjs",
|
|
79
|
+
test: "pnpm build && node --test --test-concurrency=3 --test-timeout=120000 --test-force-exit test/*.test.mjs",
|
|
73
80
|
"measure:launch": "pnpm build && node scripts/measure-launch.mjs",
|
|
74
81
|
typecheck: "tsc --noEmit",
|
|
75
82
|
lint: "eslint src --report-unused-disable-directives --max-warnings 0",
|
|
76
83
|
check: "pnpm typecheck && pnpm lint && pnpm format:check && pnpm test",
|
|
77
84
|
"format:check": 'prettier --check "src/**/*.ts" "test/*.mjs" "scripts/*.mjs" README.md package.json tsconfig.json',
|
|
78
|
-
"test:coverage": 'pnpm build && node --test-concurrency=3 --experimental-test-coverage --test-coverage-lines=80 --test --test-coverage-include="dist/*.js" --test-coverage-exclude="dist/vendor.js" test/*.test.mjs'
|
|
85
|
+
"test:coverage": 'pnpm build && node --test-concurrency=3 --test-timeout=120000 --test-force-exit --experimental-test-coverage --test-coverage-lines=80 --test --test-coverage-include="dist/*.js" --test-coverage-exclude="dist/vendor.js" test/*.test.mjs'
|
|
79
86
|
},
|
|
80
87
|
devDependencies: {
|
|
81
88
|
"@tsp/shared": "workspace:*",
|
|
@@ -102,7 +109,7 @@ var package_default = {
|
|
|
102
109
|
// src/cli.ts
|
|
103
110
|
async function runLocal(loginPath, paths, config, version) {
|
|
104
111
|
const pairing = config.pairing;
|
|
105
|
-
if (!pairing) throw new Error("Run tsp-gateway
|
|
112
|
+
if (!pairing) throw new Error("Run tsp-gateway connect first.");
|
|
106
113
|
await privateDirectory(paths.state);
|
|
107
114
|
const release = await daemonLock(paths.state);
|
|
108
115
|
const abort = new AbortController();
|
|
@@ -112,8 +119,8 @@ async function runLocal(loginPath, paths, config, version) {
|
|
|
112
119
|
let drivers;
|
|
113
120
|
try {
|
|
114
121
|
const journal = new Journal(join(paths.state, `${pairing.machine_id}-receipts.jsonl`));
|
|
115
|
-
await journal.load();
|
|
116
|
-
const repositories = async () => (await readConfig(paths.config))
|
|
122
|
+
await journal.load(repositoryFolders(config));
|
|
123
|
+
const repositories = async () => repositoryFolders(await readConfig(paths.config));
|
|
117
124
|
const environment = {
|
|
118
125
|
...process.env,
|
|
119
126
|
PATH: loginPath ?? config.loginPath ?? process.env["PATH"]
|
|
@@ -129,6 +136,7 @@ async function runLocal(loginPath, paths, config, version) {
|
|
|
129
136
|
await drivers.reap();
|
|
130
137
|
const registry = drivers;
|
|
131
138
|
const commands = new Commands(journal, registry, repositories, {
|
|
139
|
+
checkout: new CheckoutPreparer(executor, () => readConfig(paths.config)),
|
|
132
140
|
activity: new ActivityReporter(async () => (await readConfig(paths.config)).reporting)
|
|
133
141
|
});
|
|
134
142
|
await runDaemon({
|
|
@@ -170,6 +178,7 @@ async function readStatus(paths, config, drivers, executor, idle = "Not running"
|
|
|
170
178
|
if (isObject(status) && typeof field(status, "message") === "string")
|
|
171
179
|
lastMessage = field(status, "message");
|
|
172
180
|
} catch {
|
|
181
|
+
lastMessage = null;
|
|
173
182
|
}
|
|
174
183
|
return {
|
|
175
184
|
paired: config.pairing !== null,
|
|
@@ -186,9 +195,6 @@ async function readStatus(paths, config, drivers, executor, idle = "Not running"
|
|
|
186
195
|
reporting: config.reporting
|
|
187
196
|
};
|
|
188
197
|
}
|
|
189
|
-
function harnessName(drivers) {
|
|
190
|
-
return (harness) => drivers.get(harness).displayName;
|
|
191
|
-
}
|
|
192
198
|
async function printStatus(paths, config, drivers, executor, json) {
|
|
193
199
|
const status = await readStatus(paths, config, drivers, executor);
|
|
194
200
|
if (json) {
|
|
@@ -196,8 +202,8 @@ async function printStatus(paths, config, drivers, executor, json) {
|
|
|
196
202
|
return;
|
|
197
203
|
}
|
|
198
204
|
const view = machineView(status);
|
|
199
|
-
const setups = await folderSetups(drivers, config, null);
|
|
200
|
-
for (const line of statusLines(view, setups,
|
|
205
|
+
const setups = await folderSetups(drivers, config, null, executor);
|
|
206
|
+
for (const line of statusLines(view, setups, drivers.displayName)) console.log(line);
|
|
201
207
|
}
|
|
202
208
|
function machineView(status) {
|
|
203
209
|
return {
|
|
@@ -209,7 +215,7 @@ function machineView(status) {
|
|
|
209
215
|
};
|
|
210
216
|
}
|
|
211
217
|
function startupOptions(args, version) {
|
|
212
|
-
const options = args[0] === "
|
|
218
|
+
const options = args[0] === "run" ? parseArgs({
|
|
213
219
|
args: args.slice(1),
|
|
214
220
|
options: {
|
|
215
221
|
"expected-version": { type: "string" },
|
|
@@ -219,7 +225,9 @@ function startupOptions(args, version) {
|
|
|
219
225
|
}
|
|
220
226
|
}).values : void 0;
|
|
221
227
|
if (options?.["expected-version"] !== void 0 && options["expected-version"] !== version)
|
|
222
|
-
throw new Error(
|
|
228
|
+
throw new Error(
|
|
229
|
+
"Installed gateway version changed. Run npx @treestructuredplanning/gateway@latest update."
|
|
230
|
+
);
|
|
223
231
|
const defaults = locations();
|
|
224
232
|
const paths = {
|
|
225
233
|
config: options?.["config-file"] ?? defaults.config,
|
|
@@ -256,10 +264,12 @@ async function configureReporting(args, config, path) {
|
|
|
256
264
|
);
|
|
257
265
|
}
|
|
258
266
|
var VERBS = {
|
|
259
|
-
connect: async ({ args,
|
|
260
|
-
|
|
267
|
+
connect: async ({ args, config, host, paths, drivers, executor }) => {
|
|
268
|
+
const choice = connectWorktreeArgs(args);
|
|
261
269
|
const since = Date.now();
|
|
262
|
-
const outcome = await connect(host, config,
|
|
270
|
+
const outcome = await connect(host, config, choice.folder);
|
|
271
|
+
await recordConnectRoot(config, paths.config, outcome.repository?.slug, choice.root);
|
|
272
|
+
await printWorktreeRoots(config, executor);
|
|
263
273
|
const reported = outcome.loginItem === "installed" ? await awaitDaemonConnection(join(paths.state, "status.json"), since) : null;
|
|
264
274
|
const status = await readStatus(
|
|
265
275
|
paths,
|
|
@@ -268,32 +278,28 @@ var VERBS = {
|
|
|
268
278
|
executor,
|
|
269
279
|
outcome.loginItem === "installed" && reported === null ? "Starting" : void 0
|
|
270
280
|
);
|
|
271
|
-
const setups = await folderSetups(drivers, config, outcome.repository);
|
|
272
|
-
for (const line of connectLines(machineView(status), setups,
|
|
281
|
+
const setups = await folderSetups(drivers, config, outcome.repository, executor);
|
|
282
|
+
for (const line of connectLines(machineView(status), setups, drivers.displayName))
|
|
273
283
|
console.log(line);
|
|
274
284
|
},
|
|
285
|
+
config: worktreesCommand,
|
|
286
|
+
worktrees: worktreesCommand,
|
|
275
287
|
disconnect: async ({ args, host, config }) => {
|
|
276
288
|
if (args.length !== 1) throw new Error("Usage: tsp-gateway disconnect");
|
|
277
289
|
const outcome = await disconnect(host, config);
|
|
278
290
|
console.log(
|
|
279
|
-
`${outcome.loginItem === "removed" ? "Login item removed." : "No login item was installed."} ${outcome.pairing} Registered folders are kept.`
|
|
291
|
+
`${outcome.loginItem === "removed" ? "Login item removed." : "No login item was installed."} ${outcome.pairing} Registered folders are kept. Run tsp-gateway connect to reconnect.`
|
|
280
292
|
);
|
|
281
293
|
},
|
|
282
|
-
pair: async ({ host, config }) => {
|
|
283
|
-
await pairMachine(host, config);
|
|
284
|
-
console.log("Paired. Use tsp-gateway add <folder>, then tsp-gateway install.");
|
|
285
|
-
},
|
|
286
294
|
add: async ({ args, argument, host, config, drivers }) => {
|
|
287
295
|
if (!argument || args.length !== 2) throw new Error("Usage: tsp-gateway add <folder>");
|
|
288
296
|
const registered = await addRepository(host, config, argument);
|
|
289
|
-
console.log(
|
|
290
|
-
`Registered ${registered.slug}. ${drivers.setupInstructions().join(" ")} The running gateway picks up the change automatically.`
|
|
291
|
-
);
|
|
297
|
+
for (const line of registeredLines(registered, drivers)) console.log(line);
|
|
292
298
|
},
|
|
293
299
|
remove: async ({ argument, config, paths }) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
delete config.repositories[
|
|
300
|
+
const repository = argument ? parseRepositoryRemote(argument) : null;
|
|
301
|
+
if (!repository) throw new Error("Usage: tsp-gateway remove <host/owner/name>");
|
|
302
|
+
delete config.repositories[repositoryKey(repository)];
|
|
297
303
|
await saveConfig(paths.config, config);
|
|
298
304
|
console.log("Repository removed. The running gateway picks up the change automatically.");
|
|
299
305
|
},
|
|
@@ -305,32 +311,33 @@ var VERBS = {
|
|
|
305
311
|
throw new Error("Usage: tsp-gateway status [--json]");
|
|
306
312
|
return printStatus(paths, config, drivers, executor, json);
|
|
307
313
|
},
|
|
308
|
-
|
|
314
|
+
start: async ({ args, host, config, version }) => {
|
|
315
|
+
if (args.length !== 1) throw new Error("Usage: tsp-gateway start");
|
|
309
316
|
await installLoginItem(host, config);
|
|
310
|
-
console.log(`
|
|
317
|
+
console.log(`Started tsp-gateway ${version} now and at login.`);
|
|
311
318
|
},
|
|
312
|
-
|
|
319
|
+
stop: async ({ args, host }) => {
|
|
320
|
+
if (args.length !== 1) throw new Error("Usage: tsp-gateway stop");
|
|
313
321
|
console.log(
|
|
314
|
-
`${await removeLoginItem(host) === "removed" ? "Login item removed." : "No login item was installed."}
|
|
322
|
+
`${await removeLoginItem(host) === "removed" ? "Login item removed." : "No login item was installed."} The link and registered folders are kept.`
|
|
315
323
|
);
|
|
316
324
|
},
|
|
317
|
-
|
|
318
|
-
|
|
325
|
+
update: async ({ args, host, config }) => {
|
|
326
|
+
if (args.length !== 1) throw new Error("Usage: tsp-gateway update");
|
|
327
|
+
await updateGateway(host, config);
|
|
328
|
+
console.log("Gateway updated and restarted. The link and registered folders are kept.");
|
|
319
329
|
},
|
|
320
|
-
|
|
330
|
+
run: ({ loginPath, paths, config, version }) => runLocal(loginPath, paths, config, version)
|
|
321
331
|
};
|
|
322
332
|
function isVerbName(name) {
|
|
323
333
|
return Object.hasOwn(VERBS, name);
|
|
324
334
|
}
|
|
325
|
-
function verbNamed(name) {
|
|
326
|
-
return name !== void 0 && isVerbName(name) ? VERBS[name] : null;
|
|
327
|
-
}
|
|
328
335
|
async function main(args) {
|
|
329
336
|
const [command, argument] = args;
|
|
330
|
-
const verb =
|
|
337
|
+
const verb = command !== void 0 && isVerbName(command) ? VERBS[command] : null;
|
|
331
338
|
if (!verb) {
|
|
332
339
|
console.log(
|
|
333
|
-
"Usage: tsp-gateway connect [folder] | disconnect |
|
|
340
|
+
"Usage: tsp-gateway connect [folder] | disconnect | add <folder> | remove <slug> | configure-launch <json> | configure-reporting <activity|off> | status [--json] | worktrees (config) | start | stop | run | update\n\nstart: Start the background gateway now and at login.\nstop: Stop it and disable login startup; keep the link and folders.\nrun: Run the gateway in the foreground.\nupdate: Install the latest version and restart; keep the link and folders."
|
|
334
341
|
);
|
|
335
342
|
return;
|
|
336
343
|
}
|
|
@@ -360,7 +367,7 @@ async function main(args) {
|
|
|
360
367
|
entry: fileURLToPath(import.meta.url),
|
|
361
368
|
env: process.env,
|
|
362
369
|
platform: process.platform,
|
|
363
|
-
home:
|
|
370
|
+
home: loginItemHome(),
|
|
364
371
|
cwd: process.cwd(),
|
|
365
372
|
tokens: keychain,
|
|
366
373
|
openBrowser: openAuthorization,
|