@unhuman/wsync-cli 0.2.0 → 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.
Files changed (2) hide show
  1. package/dist/wsync.mjs +74 -5
  2. package/package.json +1 -1
package/dist/wsync.mjs CHANGED
@@ -6236,7 +6236,7 @@ var init_package = __esm({
6236
6236
  "package.json"() {
6237
6237
  package_default = {
6238
6238
  name: "@unhuman/wsync-cli",
6239
- version: "0.2.0",
6239
+ version: "0.3.0",
6240
6240
  description: "Capture Claude Code sessions to an Unhuman Work Context project: link a checkout, install the hooks, drain the spool.",
6241
6241
  license: "UNLICENSED",
6242
6242
  repository: {
@@ -6517,6 +6517,61 @@ var init_link = __esm({
6517
6517
  }
6518
6518
  });
6519
6519
 
6520
+ // src/commands/connect.ts
6521
+ var connect_exports = {};
6522
+ __export(connect_exports, {
6523
+ connect: () => connect
6524
+ });
6525
+ import { hostname as osHostname, release, platform as platform2 } from "node:os";
6526
+ async function connect(code, opts = {}) {
6527
+ const cfg = loadConfig();
6528
+ const server = (opts.server ?? cfg.server).replace(/\/+$/, "");
6529
+ let res;
6530
+ try {
6531
+ res = await fetch(`${server}/wsync/connect`, {
6532
+ method: "POST",
6533
+ headers: { "content-type": "application/json" },
6534
+ body: JSON.stringify({ code, hostname: osHostname().trim() || "device", os: `${platform2()} ${release()}`, cliVersion: AGENT_VERSION }),
6535
+ signal: AbortSignal.timeout(15e3)
6536
+ });
6537
+ } catch (e) {
6538
+ console.error(`Could not reach ${server}: ${String(e)}`);
6539
+ process.exitCode = 1;
6540
+ return;
6541
+ }
6542
+ if (res.status === 401) {
6543
+ console.error("That code is not valid any more \u2014 codes work once and for 15 minutes. Make a new one on the workstream.");
6544
+ process.exitCode = 1;
6545
+ return;
6546
+ }
6547
+ if (res.status === 429) {
6548
+ console.error("Too many tries from this address \u2014 wait a minute and run it again.");
6549
+ process.exitCode = 1;
6550
+ return;
6551
+ }
6552
+ if (!res.ok) {
6553
+ console.error(`${server} answered ${res.status}.`);
6554
+ process.exitCode = 1;
6555
+ return;
6556
+ }
6557
+ const body = await res.json().catch(() => ({}));
6558
+ if (!body.key) {
6559
+ console.error(`${server} answered, but without a key. Check --server.`);
6560
+ process.exitCode = 1;
6561
+ return;
6562
+ }
6563
+ console.log(` Connected this device to ${body.workstream?.name ?? "the workstream"}.`);
6564
+ await link(body.key, { server, capture: opts.capture });
6565
+ }
6566
+ var init_connect = __esm({
6567
+ "src/commands/connect.ts"() {
6568
+ "use strict";
6569
+ init_config();
6570
+ init_version();
6571
+ init_link();
6572
+ }
6573
+ });
6574
+
6520
6575
  // src/discover.ts
6521
6576
  import { readdirSync as readdirSync2, existsSync as existsSync8, statSync as statSync3 } from "node:fs";
6522
6577
  import { join as join8, relative } from "node:path";
@@ -6606,7 +6661,7 @@ var backfill_exports = {};
6606
6661
  __export(backfill_exports, {
6607
6662
  backfill: () => backfill
6608
6663
  });
6609
- import { hostname as hostname2, platform as platform2 } from "node:os";
6664
+ import { hostname as hostname2, platform as platform3 } from "node:os";
6610
6665
  async function backfill(opts = {}) {
6611
6666
  const cfg = loadConfig();
6612
6667
  const found = discoverTranscripts();
@@ -6641,7 +6696,7 @@ async function backfill(opts = {}) {
6641
6696
  distillation: (0, import_wsync_core4.clampDistillation)(d),
6642
6697
  identity,
6643
6698
  machineHostname: hostname2(),
6644
- machineOs: platform2(),
6699
+ machineOs: platform3(),
6645
6700
  agentVersion: AGENT_VERSION,
6646
6701
  transcriptPath: f.path,
6647
6702
  transcriptShaPrefix: await (0, import_wsync_core4.transcriptPrefixSha)(f.path),
@@ -6812,7 +6867,7 @@ var setup_exports = {};
6812
6867
  __export(setup_exports, {
6813
6868
  setup: () => setup
6814
6869
  });
6815
- import { hostname as osHostname } from "node:os";
6870
+ import { hostname as osHostname2 } from "node:os";
6816
6871
  import { resolve as resolve4 } from "node:path";
6817
6872
  async function setup(token, opts = {}) {
6818
6873
  const cfg = loadConfig();
@@ -6869,7 +6924,7 @@ async function remoteProject(cwd) {
6869
6924
  return remote ? (0, import_wsync_core6.normaliseRemote)(remote) : null;
6870
6925
  }
6871
6926
  function hostname3() {
6872
- return osHostname().trim() || "this machine";
6927
+ return osHostname2().trim() || "this machine";
6873
6928
  }
6874
6929
  async function callTool(server, token, params) {
6875
6930
  let res;
@@ -7398,6 +7453,9 @@ var val = (n) => {
7398
7453
  };
7399
7454
  var USAGE = `wsync \u2014 work context across machines
7400
7455
 
7456
+ wsync connect <code> [--server URL] [--capture]
7457
+ connect this directory to a workstream with the
7458
+ one-time code from "Connect a device" in the app
7401
7459
  wsync setup <api-token> [--server URL] [--project KEY] [--machine NAME] [--create] [--capture]
7402
7460
  one paste: mint this machine's key and link
7403
7461
  (connects Claude Code to the project's memories
@@ -7426,6 +7484,17 @@ var USAGE = `wsync \u2014 work context across machines
7426
7484
  `;
7427
7485
  try {
7428
7486
  switch (cmd) {
7487
+ case "connect": {
7488
+ const code = args[0];
7489
+ if (!code || code.startsWith("--")) {
7490
+ console.error('usage: wsync connect <code> [--server URL] [--capture] (the code comes from "Connect a device" on a workstream)');
7491
+ process.exitCode = 1;
7492
+ break;
7493
+ }
7494
+ const { connect: connect2 } = await Promise.resolve().then(() => (init_connect(), connect_exports));
7495
+ await connect2(code, { server: val("server"), capture: has("capture") });
7496
+ break;
7497
+ }
7429
7498
  case "link": {
7430
7499
  const key = args[0];
7431
7500
  if (!key || key.startsWith("--")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unhuman/wsync-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Capture Claude Code sessions to an Unhuman Work Context project: link a checkout, install the hooks, drain the spool.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {