@telepath-computer/stash 0.1.4 → 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 (48) hide show
  1. package/README.md +102 -0
  2. package/dist/cli-main.d.ts +20 -0
  3. package/dist/cli-main.d.ts.map +1 -0
  4. package/dist/cli-main.js +445 -0
  5. package/dist/cli-main.js.map +1 -0
  6. package/dist/cli.js +1 -158
  7. package/dist/cli.js.map +1 -1
  8. package/dist/daemon.d.ts +42 -0
  9. package/dist/daemon.d.ts.map +1 -0
  10. package/dist/daemon.js +210 -0
  11. package/dist/daemon.js.map +1 -0
  12. package/dist/global-config.d.ts +7 -0
  13. package/dist/global-config.d.ts.map +1 -1
  14. package/dist/global-config.js +62 -2
  15. package/dist/global-config.js.map +1 -1
  16. package/dist/index.d.ts +4 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/providers/github-provider.d.ts.map +1 -1
  21. package/dist/providers/github-provider.js +16 -17
  22. package/dist/providers/github-provider.js.map +1 -1
  23. package/dist/service/controller.d.ts +32 -0
  24. package/dist/service/controller.d.ts.map +1 -0
  25. package/dist/service/controller.js +162 -0
  26. package/dist/service/controller.js.map +1 -0
  27. package/dist/service/index.d.ts +16 -0
  28. package/dist/service/index.d.ts.map +1 -0
  29. package/dist/service/index.js +6 -0
  30. package/dist/service/index.js.map +1 -0
  31. package/dist/stash.d.ts +1 -1
  32. package/dist/stash.d.ts.map +1 -1
  33. package/dist/stash.js +10 -8
  34. package/dist/stash.js.map +1 -1
  35. package/dist/types.d.ts +8 -1
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/ui/format.d.ts.map +1 -1
  38. package/dist/ui/format.js +2 -4
  39. package/dist/ui/format.js.map +1 -1
  40. package/dist/ui/watch-renderer.d.ts +16 -0
  41. package/dist/ui/watch-renderer.d.ts.map +1 -0
  42. package/dist/ui/watch-renderer.js +59 -0
  43. package/dist/ui/watch-renderer.js.map +1 -0
  44. package/dist/watch.d.ts +64 -4
  45. package/dist/watch.d.ts.map +1 -1
  46. package/dist/watch.js +253 -214
  47. package/dist/watch.js.map +1 -1
  48. package/package.json +15 -7
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # Stash
2
+
3
+ Conflict-free synced folders. Multiple people, agents, and machines can edit the same directory, then converge with a single `stash sync`.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npm install -g @telepath-computer/stash
9
+ ```
10
+
11
+ Set up GitHub access and connect the current directory:
12
+
13
+ ```bash
14
+ stash background install
15
+ stash init
16
+ stash setup github
17
+ stash connect github --repo user/repo --background
18
+ ```
19
+
20
+ You can initialize a directory explicitly with `stash init`, or let `stash connect` create `.stash/` for you automatically.
21
+
22
+ You'll need a GitHub [personal access token](https://github.com/settings/tokens). A classic token needs the `repo` scope. A fine-grained token needs **Contents: Read and write** permission on the target repo.
23
+
24
+ ## How It Works
25
+
26
+ - `stash sync` pushes local changes, pulls remote changes, and merges concurrent edits in one operation.
27
+ - Text files are merged automatically. Different-region edits combine cleanly; overlapping edits preserve both sides instead of silently dropping content.
28
+ - Binary files use last-modified-wins.
29
+ - All files in the stash directory are tracked automatically except dotfiles, dot-directories, symlinks, and local-only `.stash/` metadata.
30
+
31
+ ## Commands
32
+
33
+ ```bash
34
+ stash background install
35
+ stash background add
36
+ stash init
37
+ stash setup github
38
+ stash connect github --repo user/repo --background
39
+ stash sync
40
+ stash watch
41
+ stash background status
42
+ stash status
43
+ stash disconnect github
44
+ stash background remove
45
+ stash background uninstall
46
+ ```
47
+
48
+ `stash watch` keeps the directory in sync continuously. Press `.` to trigger an immediate sync and `q` to quit.
49
+
50
+ `stash background install` plus `stash connect --background` gives you boot-time background syncing managed by `launchd` on macOS or `systemd` on Linux.
51
+
52
+ ## Config
53
+
54
+ - Global config lives at `~/.stash/config.json` or `$XDG_CONFIG_HOME/stash/config.json`.
55
+ - Per-stash connection config lives at `.stash/config.local.json` inside the synced directory.
56
+
57
+ Example global config:
58
+
59
+ ```json
60
+ {
61
+ "providers": {
62
+ "github": { "token": "ghp_..." }
63
+ },
64
+ "background": {
65
+ "stashes": ["/Users/me/notes"]
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Docs
71
+
72
+ - `docs/api.md` - developer-facing `Stash` and provider contracts
73
+ - `docs/architecture.md` - core components and repo boundaries
74
+ - `docs/sync.md` - sync lifecycle, locking, drift, and snapshot semantics
75
+ - `docs/reconciliation.md` - merge and file-resolution rules
76
+ - `docs/cli.md` - user-facing CLI behavior
77
+ - `docs/providers/github.md` - GitHub remote contract
78
+ - `docs/development.md` - local development and testing
79
+
80
+ ## FAQ
81
+
82
+ **Will stash delete or overwrite my existing files?**
83
+
84
+ Not blindly. On first sync, local and remote content are reconciled rather than replaced wholesale. The result becomes the baseline for future syncs.
85
+
86
+ **Can I use the same repo with both stash and git?**
87
+
88
+ Yes, but not on the same machine and directory. Stash syncs the working tree directly to `main` through the GitHub API and does not understand local git state.
89
+
90
+ **Does stash use branches or PRs?**
91
+
92
+ No. Stash reads and writes the `main` branch directly.
93
+
94
+ ## Development
95
+
96
+ Requires Node.js v22.6+.
97
+
98
+ ```bash
99
+ npm install
100
+ npm link
101
+ npm test
102
+ ```
@@ -0,0 +1,20 @@
1
+ import * as service from "./service/index.ts";
2
+ import type { GlobalConfig } from "./types.ts";
3
+ type CliDependencies = {
4
+ cwd?: () => string;
5
+ readGlobalConfig?: () => Promise<GlobalConfig>;
6
+ writeGlobalConfig?: (config: GlobalConfig) => Promise<void>;
7
+ service?: {
8
+ install: typeof service.install;
9
+ uninstall: typeof service.uninstall;
10
+ status: typeof service.status;
11
+ };
12
+ runDaemon?: () => Promise<void>;
13
+ resolveStashCommand?: () => Promise<string>;
14
+ stdout?: NodeJS.WriteStream;
15
+ stderr?: NodeJS.WriteStream;
16
+ };
17
+ export declare function resolveStashCommand(): Promise<string>;
18
+ export declare function main(argv?: string[], deps?: CliDependencies): Promise<void>;
19
+ export {};
20
+ //# sourceMappingURL=cli-main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-main.d.ts","sourceRoot":"","sources":["../src/cli-main.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAQ9C,OAAO,KAAK,EAAS,YAAY,EAAiB,MAAM,YAAY,CAAC;AAKrE,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,OAAO,CAAC,EAAE;QACR,OAAO,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC;QAChC,SAAS,EAAE,OAAO,OAAO,CAAC,SAAS,CAAC;QACpC,MAAM,EAAE,OAAO,OAAO,CAAC,MAAM,CAAC;KAC/B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;CAC7B,CAAC;AAkCF,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAoB3D;AA0XD,wBAAsB,IAAI,CAAC,IAAI,WAAe,EAAE,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4IzF"}
@@ -0,0 +1,445 @@
1
+ import { existsSync } from "node:fs";
2
+ import { access, constants, readFile } from "node:fs/promises";
3
+ import { basename, delimiter, join, resolve } from "node:path";
4
+ import { Command, Option } from "commander";
5
+ import { input, password } from "@inquirer/prompts";
6
+ import { addBackgroundStash, getBackgroundStashes, getProviderConfig, readGlobalConfig, removeBackgroundStash, setProviderConfig, writeGlobalConfig, } from "./global-config.js";
7
+ import { runDaemon } from "./daemon.js";
8
+ import * as service from "./service/index.js";
9
+ import { providers } from "./providers/index.js";
10
+ import { Stash } from "./stash.js";
11
+ import { createColors } from "./ui/color.js";
12
+ import { formatTimeAgo } from "./ui/format.js";
13
+ import { LiveLine } from "./ui/live-line.js";
14
+ import { SyncRenderer } from "./ui/sync-renderer.js";
15
+ import { watch as watchStash } from "./watch.js";
16
+ const SERVICE_NAME = "stash-background";
17
+ const SERVICE_DESCRIPTION = "Stash background sync";
18
+ function getProvider(name) {
19
+ const provider = providers[name];
20
+ if (!provider) {
21
+ throw new Error(`Unknown provider: ${name}`);
22
+ }
23
+ return provider;
24
+ }
25
+ async function isExecutable(path) {
26
+ try {
27
+ await access(path, constants.X_OK);
28
+ return true;
29
+ }
30
+ catch {
31
+ return false;
32
+ }
33
+ }
34
+ function writeLine(stream, text) {
35
+ stream.write(`${text}\n`);
36
+ }
37
+ function isUnsupportedPlatformError(error) {
38
+ return error instanceof Error && error.message.includes("not supported on this platform yet");
39
+ }
40
+ export async function resolveStashCommand() {
41
+ const argvPath = process.argv[1];
42
+ if (argvPath && basename(argvPath) === "stash") {
43
+ const candidate = resolve(argvPath);
44
+ if (await isExecutable(candidate)) {
45
+ return candidate;
46
+ }
47
+ }
48
+ for (const pathEntry of (process.env.PATH ?? "").split(delimiter)) {
49
+ if (!pathEntry) {
50
+ continue;
51
+ }
52
+ const candidate = join(pathEntry, "stash");
53
+ if (await isExecutable(candidate)) {
54
+ return candidate;
55
+ }
56
+ }
57
+ throw new Error("Could not find the `stash` binary on PATH");
58
+ }
59
+ async function promptField(field) {
60
+ if (field.secret) {
61
+ return password({ message: field.label });
62
+ }
63
+ return input({ message: field.label });
64
+ }
65
+ async function collectFields(fields, valuesFromCli, current = {}) {
66
+ const values = { ...current };
67
+ for (const field of fields) {
68
+ if (values[field.name]) {
69
+ continue;
70
+ }
71
+ const cliValue = valuesFromCli[field.name];
72
+ if (typeof cliValue === "string") {
73
+ values[field.name] = cliValue;
74
+ continue;
75
+ }
76
+ values[field.name] = await promptField(field);
77
+ }
78
+ return values;
79
+ }
80
+ async function readBackgroundStatus(dir) {
81
+ const statusPath = join(dir, ".stash", "status.json");
82
+ if (!existsSync(statusPath)) {
83
+ return null;
84
+ }
85
+ return JSON.parse(await readFile(statusPath, "utf8"));
86
+ }
87
+ async function warnIfServiceUnavailable(serviceModule, stderr) {
88
+ if (!serviceModule) {
89
+ return;
90
+ }
91
+ try {
92
+ const status = await serviceModule.status({ name: SERVICE_NAME });
93
+ if (!status.installed) {
94
+ writeLine(stderr, "warning: background service is not installed");
95
+ }
96
+ }
97
+ catch (error) {
98
+ if (isUnsupportedPlatformError(error)) {
99
+ writeLine(stderr, "warning: service install is not supported on this platform yet; run `stash background watch` manually");
100
+ return;
101
+ }
102
+ throw error;
103
+ }
104
+ }
105
+ async function runSetup(providerName, valuesFromCli, deps, stdout) {
106
+ const provider = getProvider(providerName);
107
+ let globalConfig = await deps.readGlobalConfig();
108
+ const values = await collectFields(provider.spec.setup, valuesFromCli, getProviderConfig(globalConfig, providerName));
109
+ globalConfig = setProviderConfig(globalConfig, providerName, values);
110
+ await deps.writeGlobalConfig(globalConfig);
111
+ writeLine(stdout, `Configured ${providerName}.`);
112
+ }
113
+ async function runInit(cwd, readConfig, stdout) {
114
+ const dir = cwd();
115
+ const alreadyInitialized = existsSync(join(dir, ".stash"));
116
+ await Stash.init(dir, await readConfig());
117
+ writeLine(stdout, alreadyInitialized ? "Already initialized." : "Initialized stash.");
118
+ }
119
+ async function registerBackgroundStash(dir, readConfig, writeConfig, serviceModule, stderr) {
120
+ const globalConfig = await readConfig();
121
+ const stash = await Stash.load(dir, globalConfig);
122
+ if (Object.keys(stash.connections).length === 0) {
123
+ writeLine(stderr, "warning: this stash won't sync until a provider is connected");
124
+ }
125
+ await writeConfig(addBackgroundStash(globalConfig, dir));
126
+ await warnIfServiceUnavailable(serviceModule, stderr);
127
+ }
128
+ async function runConnect(providerName, valuesFromCli, deps, stdout, stderr) {
129
+ const provider = getProvider(providerName);
130
+ let globalConfig = await deps.readGlobalConfig();
131
+ const setupValues = await collectFields(provider.spec.setup, valuesFromCli, getProviderConfig(globalConfig, providerName));
132
+ globalConfig = setProviderConfig(globalConfig, providerName, setupValues);
133
+ await deps.writeGlobalConfig(globalConfig);
134
+ const dir = deps.cwd();
135
+ const stash = await Stash.init(dir, globalConfig);
136
+ const connectValues = await collectFields(provider.spec.connect, valuesFromCli);
137
+ await stash.connect(providerName, connectValues);
138
+ if (valuesFromCli.background === true) {
139
+ await registerBackgroundStash(dir, deps.readGlobalConfig, deps.writeGlobalConfig, deps.service, stderr);
140
+ }
141
+ writeLine(stdout, `Connected ${providerName}.`);
142
+ }
143
+ async function runDisconnect(providerName, cwd, readConfig, stdout) {
144
+ const stash = await Stash.load(cwd(), await readConfig());
145
+ await stash.disconnect(providerName);
146
+ writeLine(stdout, `Disconnected ${providerName}.`);
147
+ }
148
+ async function runSync(cwd, readConfig) {
149
+ const stash = await Stash.load(cwd(), await readConfig());
150
+ const line = new LiveLine(process.stdout);
151
+ const { green, red } = line.colors;
152
+ const renderer = new SyncRenderer(line);
153
+ const subscription = stash.on("mutation", (mutation) => {
154
+ renderer.onMutation(mutation);
155
+ });
156
+ line.startSpinner("checking...");
157
+ try {
158
+ await stash.sync();
159
+ const summary = renderer.done();
160
+ line.print(summary ? `${green("✓")} synced (${summary})` : `${green("✓")} up to date`);
161
+ }
162
+ catch (error) {
163
+ renderer.error(error);
164
+ line.print(`${red("✗")} sync failed: ${error instanceof Error ? error.message : String(error)}`);
165
+ process.exitCode = 1;
166
+ }
167
+ finally {
168
+ subscription.dispose();
169
+ renderer.dispose();
170
+ line.dispose();
171
+ }
172
+ }
173
+ async function runWatch(cwd, readConfig) {
174
+ const dir = cwd();
175
+ const stash = await Stash.load(dir, await readConfig());
176
+ if (Object.keys(stash.connections).length === 0) {
177
+ throw new Error("no connection configured — run `stash connect <provider>` first");
178
+ }
179
+ await watchStash(stash, { dir, stdin: process.stdin, stdout: process.stdout });
180
+ }
181
+ function formatChangeParts(status) {
182
+ const parts = [];
183
+ if (status.added.length > 0)
184
+ parts.push(`${status.added.length} added`);
185
+ if (status.modified.length > 0)
186
+ parts.push(`${status.modified.length} modified`);
187
+ if (status.deleted.length > 0)
188
+ parts.push(`${status.deleted.length} deleted`);
189
+ return parts;
190
+ }
191
+ async function runStatus(cwd, readConfig, stdout) {
192
+ const { dim, green, yellow } = createColors(stdout);
193
+ const stash = await Stash.load(cwd(), await readConfig());
194
+ const connectionNames = Object.keys(stash.connections);
195
+ if (connectionNames.length === 0) {
196
+ writeLine(stdout, dim("no connections — run `stash connect <provider>` to get started"));
197
+ return;
198
+ }
199
+ const status = stash.status();
200
+ const parts = formatChangeParts(status);
201
+ for (const name of connectionNames) {
202
+ const conn = stash.connections[name];
203
+ const label = conn.repo ?? Object.values(conn).join(", ");
204
+ const dot = parts.length > 0 ? yellow("●") : green("●");
205
+ writeLine(stdout, `${dot} ${name} ${dim(label)}`);
206
+ if (status.lastSync) {
207
+ const ago = formatTimeAgo(status.lastSync);
208
+ if (parts.length > 0) {
209
+ writeLine(stdout, ` ${parts.join(", ")} ${dim("·")} ${dim(`synced ${ago}`)}`);
210
+ }
211
+ else {
212
+ writeLine(stdout, dim(` up to date · synced ${ago}`));
213
+ }
214
+ }
215
+ else if (parts.length > 0) {
216
+ writeLine(stdout, ` ${parts.join(", ")} ${dim("·")} ${dim("never synced")}`);
217
+ }
218
+ else {
219
+ writeLine(stdout, dim(" never synced"));
220
+ }
221
+ }
222
+ }
223
+ async function runBackgroundInstall(serviceModule, resolveCommand, stdout) {
224
+ const command = await resolveCommand();
225
+ await serviceModule.install({
226
+ name: SERVICE_NAME,
227
+ description: SERVICE_DESCRIPTION,
228
+ command,
229
+ args: ["background", "watch"],
230
+ });
231
+ writeLine(stdout, "Installed background service.");
232
+ }
233
+ async function runBackgroundUninstall(serviceModule, stdout) {
234
+ await serviceModule.uninstall({ name: SERVICE_NAME });
235
+ writeLine(stdout, "Uninstalled background service.");
236
+ }
237
+ async function runBackgroundAdd(dirArg, cwd, readConfig, writeConfig, serviceModule, stdout, stderr) {
238
+ const dir = resolve(dirArg ?? cwd());
239
+ await registerBackgroundStash(dir, readConfig, writeConfig, serviceModule, stderr);
240
+ writeLine(stdout, `Registered ${dir} for background sync.`);
241
+ }
242
+ async function runBackgroundRemove(dirArg, cwd, readConfig, writeConfig, stdout) {
243
+ const dir = resolve(dirArg ?? cwd());
244
+ const globalConfig = await readConfig();
245
+ await writeConfig(removeBackgroundStash(globalConfig, dir));
246
+ writeLine(stdout, `Removed ${dir} from background sync.`);
247
+ }
248
+ async function runBackgroundStatus(readConfig, serviceModule, stdout) {
249
+ const { dim, green, red } = createColors(stdout);
250
+ const ora = stdout.isTTY ? (await import("ora")).default : null;
251
+ let serviceRunning = false;
252
+ let serviceMessage = null;
253
+ try {
254
+ const current = await serviceModule.status({ name: SERVICE_NAME });
255
+ if (!current.installed) {
256
+ serviceMessage = dim("service not installed — run `stash background install`");
257
+ }
258
+ else if (current.running) {
259
+ serviceRunning = true;
260
+ }
261
+ else {
262
+ serviceMessage = red("background service is stopped — run `stash background install` to restart");
263
+ }
264
+ }
265
+ catch (error) {
266
+ if (isUnsupportedPlatformError(error)) {
267
+ serviceMessage = dim("service install not supported on this platform — run `stash background watch` manually");
268
+ }
269
+ else {
270
+ throw error;
271
+ }
272
+ }
273
+ const globalConfig = await readConfig();
274
+ const stashes = getBackgroundStashes(globalConfig);
275
+ if (stashes.length === 0) {
276
+ if (serviceMessage) {
277
+ writeLine(stdout, serviceMessage);
278
+ writeLine(stdout, "");
279
+ }
280
+ writeLine(stdout, dim("no stashes registered — run `stash background add` to add one"));
281
+ return;
282
+ }
283
+ for (const dir of stashes) {
284
+ if (!existsSync(dir)) {
285
+ writeLine(stdout, `${red("✗")} ${dir}`);
286
+ writeLine(stdout, dim(" directory not found"));
287
+ continue;
288
+ }
289
+ const status = await readBackgroundStatus(dir);
290
+ if (!status) {
291
+ writeLine(stdout, `${dim("○")} ${dir}`);
292
+ writeLine(stdout, dim(" waiting for first sync"));
293
+ continue;
294
+ }
295
+ if (status.kind === "error") {
296
+ writeLine(stdout, `${red("✗")} ${dir}`);
297
+ const ago = status.lastSync ? formatTimeAgo(new Date(status.lastSync)) : null;
298
+ const errorMsg = status.error ?? "unknown error";
299
+ writeLine(stdout, ago ? ` ${red(errorMsg)} ${dim("·")} ${dim(`synced ${ago}`)}` : ` ${red(errorMsg)}`);
300
+ continue;
301
+ }
302
+ const ago = status.lastSync ? formatTimeAgo(new Date(status.lastSync)) : null;
303
+ if (status.summary) {
304
+ writeLine(stdout, `${green("●")} ${dir}`);
305
+ writeLine(stdout, ` ${status.summary} ${dim("·")} ${dim(`synced ${ago ?? "unknown"}`)}`);
306
+ }
307
+ else {
308
+ writeLine(stdout, `${green("●")} ${dir}`);
309
+ writeLine(stdout, dim(` up to date · synced ${ago ?? "unknown"}`));
310
+ }
311
+ }
312
+ if (serviceRunning) {
313
+ stdout.write("\n");
314
+ if (ora) {
315
+ ora({ text: dim("stash is syncing in the background"), stream: stdout }).start();
316
+ }
317
+ else {
318
+ writeLine(stdout, "stash is syncing in the background");
319
+ }
320
+ }
321
+ else if (serviceMessage) {
322
+ writeLine(stdout, "");
323
+ writeLine(stdout, serviceMessage);
324
+ }
325
+ }
326
+ function addFieldOptions(command, fields) {
327
+ for (const field of fields) {
328
+ command.addOption(new Option(`--${field.name} <value>`, field.label));
329
+ }
330
+ }
331
+ export async function main(argv = process.argv, deps = {}) {
332
+ const cwd = deps.cwd ?? (() => process.cwd());
333
+ const readConfig = deps.readGlobalConfig ?? readGlobalConfig;
334
+ const writeConfig = deps.writeGlobalConfig ?? writeGlobalConfig;
335
+ const serviceModule = deps.service ?? service;
336
+ const runDaemonCommand = deps.runDaemon ?? runDaemon;
337
+ const resolveCommand = deps.resolveStashCommand ?? resolveStashCommand;
338
+ const stdout = deps.stdout ?? process.stdout;
339
+ const stderr = deps.stderr ?? process.stderr;
340
+ const program = new Command()
341
+ .name("stash")
342
+ .description("Conflict-free synced folders")
343
+ .showHelpAfterError()
344
+ .configureOutput({
345
+ writeOut: (text) => {
346
+ stdout.write(text);
347
+ },
348
+ writeErr: (text) => {
349
+ stderr.write(text);
350
+ },
351
+ });
352
+ const setupCommand = program
353
+ .command("setup")
354
+ .description("Configure global provider settings")
355
+ .argument("<provider>", "Provider name")
356
+ .allowUnknownOption(true)
357
+ .action(async (providerName, _opts, command) => {
358
+ await runSetup(providerName, command.opts(), { readGlobalConfig: readConfig, writeGlobalConfig: writeConfig }, stdout);
359
+ });
360
+ const connectCommand = program
361
+ .command("connect")
362
+ .description("Connect this stash to a provider")
363
+ .argument("<provider>", "Provider name")
364
+ .option("--background", "Register this stash for background syncing")
365
+ .allowUnknownOption(true)
366
+ .action(async (providerName, _opts, command) => {
367
+ await runConnect(providerName, command.opts(), {
368
+ cwd,
369
+ readGlobalConfig: readConfig,
370
+ writeGlobalConfig: writeConfig,
371
+ service: serviceModule,
372
+ }, stdout, stderr);
373
+ });
374
+ program
375
+ .command("disconnect")
376
+ .description("Disconnect provider from this stash")
377
+ .argument("<provider>", "Provider name")
378
+ .action(async (providerName) => {
379
+ await runDisconnect(providerName, cwd, readConfig, stdout);
380
+ });
381
+ program
382
+ .command("init")
383
+ .description("Initialize the current directory as a stash")
384
+ .action(() => {
385
+ return runInit(cwd, readConfig, stdout);
386
+ });
387
+ program
388
+ .command("sync")
389
+ .description("Sync local files with connections")
390
+ .action(() => runSync(cwd, readConfig));
391
+ program
392
+ .command("watch")
393
+ .description("Watch and sync continuously")
394
+ .action(() => runWatch(cwd, readConfig));
395
+ program
396
+ .command("status")
397
+ .description("Show local stash status")
398
+ .action(() => runStatus(cwd, readConfig, stdout));
399
+ const backgroundCommand = program.command("background").description("Manage background syncing");
400
+ backgroundCommand
401
+ .command("install")
402
+ .description("Install the background service")
403
+ .action(() => runBackgroundInstall(serviceModule, resolveCommand, stdout));
404
+ backgroundCommand
405
+ .command("uninstall")
406
+ .description("Remove the background service")
407
+ .action(() => runBackgroundUninstall(serviceModule, stdout));
408
+ backgroundCommand
409
+ .command("add")
410
+ .description("Register a stash for background syncing")
411
+ .argument("[dir]", "Stash directory")
412
+ .action((dirArg) => runBackgroundAdd(dirArg, cwd, readConfig, writeConfig, serviceModule, stdout, stderr));
413
+ backgroundCommand
414
+ .command("remove")
415
+ .description("Unregister a stash from background syncing")
416
+ .argument("[dir]", "Stash directory")
417
+ .action((dirArg) => runBackgroundRemove(dirArg, cwd, readConfig, writeConfig, stdout));
418
+ backgroundCommand
419
+ .command("status")
420
+ .description("Show background service and stash status")
421
+ .action(() => runBackgroundStatus(readConfig, serviceModule, stdout));
422
+ backgroundCommand
423
+ .command("watch", { hidden: true })
424
+ .description("Run the background daemon")
425
+ .action(() => runDaemonCommand());
426
+ const commandName = argv[2];
427
+ const providerName = argv[3];
428
+ if (providerName && (commandName === "setup" || commandName === "connect")) {
429
+ const provider = providers[providerName];
430
+ if (provider) {
431
+ if (commandName === "setup") {
432
+ addFieldOptions(setupCommand, provider.spec.setup);
433
+ }
434
+ else {
435
+ addFieldOptions(connectCommand, [...provider.spec.setup, ...provider.spec.connect]);
436
+ }
437
+ }
438
+ }
439
+ if (argv.length <= 2) {
440
+ program.outputHelp();
441
+ return;
442
+ }
443
+ await program.parseAsync(argv);
444
+ }
445
+ //# sourceMappingURL=cli-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-main.js","sourceRoot":"","sources":["../src/cli-main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,OA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