@unhuman/wsync-cli 0.2.0 → 0.4.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 +29 -107
- package/dist/wsync.mjs +228 -7286
- package/package.json +10 -11
package/README.md
CHANGED
|
@@ -1,138 +1,60 @@
|
|
|
1
1
|
# @unhuman/wsync-cli
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Connects Claude Code to a **Work Context** workstream's memories over MCP, so every session — on this
|
|
4
|
+
machine or another — reads and writes the same Markdown notes: how to build, conventions, gotchas,
|
|
5
|
+
decisions, where a piece of work stands.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
still prints `{}` and exits `0`.
|
|
7
|
+
The CLI records nothing. It writes a link for a directory, registers the wsync MCP server for it
|
|
8
|
+
(`claude mcp add …`), and then gets out of the way.
|
|
10
9
|
|
|
11
10
|
## Quick start
|
|
12
11
|
|
|
13
|
-
1. In Unhuman, open **Work Context**, pick
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
2. Inside the repository you want captured:
|
|
12
|
+
1. In Unhuman, open **Work Context**, pick a workstream and press **Connect a device**. You get a
|
|
13
|
+
one-time code that works once, for 15 minutes.
|
|
14
|
+
2. Inside the repository:
|
|
17
15
|
|
|
18
16
|
```sh
|
|
19
|
-
npx @unhuman/wsync-cli
|
|
17
|
+
npx @unhuman/wsync-cli connect K7PQ-4QX2
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
The server defaults to `https://unhuman.unbs.cloud/api
|
|
23
|
-
|
|
20
|
+
The server defaults to `https://unhuman.unbs.cloud/api`; pass `--server URL` (or set
|
|
21
|
+
`WSYNC_SERVER`) for another.
|
|
24
22
|
|
|
25
|
-
> **Mind the scope.** Plain `npx wsync` is an unrelated package
|
|
26
|
-
> `@unhuman/wsync-cli`.
|
|
23
|
+
> **Mind the scope.** Plain `npx wsync` is an unrelated package; it has to be `@unhuman/wsync-cli`.
|
|
27
24
|
|
|
28
|
-
> **From a checkout**, run the working copy
|
|
29
|
-
>
|
|
30
|
-
> the `workspace:*` protocol pnpm uses here, and fails with `EUNSUPPORTEDPROTOCOL` before it ever
|
|
31
|
-
> reaches the registry.
|
|
25
|
+
> **From a checkout**, run the working copy: `pnpm --filter @unhuman/wsync-cli build` then
|
|
26
|
+
> `node apps/wsync-cli/dist/wsync.mjs …`.
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
`~/.wsync/config.json`, installs the Claude Code hooks (see below), and registers the wsync MCP
|
|
35
|
-
server for this directory (`claude mcp add …`) so Claude can query context on demand, not just
|
|
36
|
-
at session start.
|
|
37
|
-
3. Start Claude Code. Nothing else to do — captures happen automatically from here.
|
|
38
|
-
|
|
39
|
-
Run `wsync status` at any time to see the configured server, which directories are linked, and how
|
|
40
|
-
many captures are still waiting to be sent (e.g. because you were offline).
|
|
41
|
-
|
|
42
|
-
## What gets captured
|
|
43
|
-
|
|
44
|
-
Once a directory is linked, wsync hooks into these Claude Code lifecycle events:
|
|
45
|
-
|
|
46
|
-
| Event | What happens |
|
|
47
|
-
|-----------------------|--------------|
|
|
48
|
-
| `SessionStart` | Injects a rendered summary of prior work on this project back into context (from a local cache — never blocks on the network). |
|
|
49
|
-
| `UserPromptSubmit`, `PostToolUse`, `PostToolUseFailure`, `Stop` | Spool a lightweight event (prompt text, tool name/response, assistant reply) for the activity timeline. |
|
|
50
|
-
| `PreCompact`, `SessionEnd` | Spool a **checkpoint**: a pointer at the transcript segment since the last checkpoint. A detached `wsync flush` then distills it (extracts prompts, files touched, tickets, git identity — all locally, no LLM call), redacts secrets, and uploads both the structured distillation and a gzip'd raw archive of that segment. |
|
|
51
|
-
|
|
52
|
-
Everything text-bearing is capped at 64KB per field before it ever leaves the spool, and redacted
|
|
53
|
-
(again, belt-and-braces with the server's own redaction pass) before upload. An unlinked directory
|
|
54
|
-
captures nothing — `SessionStart` tells you so, once, so you're never silently uncaptured.
|
|
28
|
+
3. Start Claude Code. Nothing else to do.
|
|
55
29
|
|
|
56
30
|
## Commands
|
|
57
31
|
|
|
58
32
|
```
|
|
59
|
-
wsync
|
|
60
|
-
wsync
|
|
61
|
-
|
|
62
|
-
wsync
|
|
63
|
-
wsync status show config, links (keys by prefix) and pending spool
|
|
64
|
-
wsync install-hooks [--dry-run] register hooks in ~/.claude/settings.json
|
|
65
|
-
wsync uninstall-hooks remove them again
|
|
66
|
-
wsync refresh-context --cwd PATH refresh the local context cache
|
|
67
|
-
wsync hook <sub> invoked by Claude Code itself; reads stdin
|
|
33
|
+
wsync connect <code> [--server URL] connect this directory with a one-time code
|
|
34
|
+
wsync link <key> [--server URL] link this directory with a device key
|
|
35
|
+
wsync status server, links (keys by prefix), MCP registration, leftover hooks
|
|
36
|
+
wsync uninstall-hooks remove old capture hooks from ~/.claude/settings.json
|
|
68
37
|
```
|
|
69
38
|
|
|
70
|
-
|
|
71
|
-
haven't been capturing since the start — entirely over HTTP, using whichever linked ancestor
|
|
72
|
-
directory owns each transcript's working directory, or `--key` as a fallback for anything with no
|
|
73
|
-
linked ancestor. Sessions that match neither are skipped and counted, never silently dropped.
|
|
39
|
+
## Old capture hooks are removed
|
|
74
40
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
but it never overrules the key and never creates a project.
|
|
80
|
-
- **`backfill`** sends `mode: backfill`, and there the remote may choose the project — among the
|
|
81
|
-
projects that already exist in your workspace (by slug, by a remote the workspace has seen before,
|
|
82
|
-
or by an unambiguous bare name). A transcript whose remote matches nothing lands in the app's
|
|
83
|
-
**Needs filing** queue with the remote named, for a person to file. Neither mode invents a project;
|
|
84
|
-
one key can import a whole machine without funnelling twenty repositories into one project.
|
|
41
|
+
Earlier versions recorded sessions through seven Claude Code hooks and a spool in `~/.wsync/spool`.
|
|
42
|
+
That is gone. `connect` and `link` remove any such hooks from `~/.claude/settings.json` and
|
|
43
|
+
delete the spool, so a machine that ran an older install stops recording as soon as it is connected.
|
|
44
|
+
`wsync status` warns if any hooks remain; `wsync uninstall-hooks` removes them on their own.
|
|
85
45
|
|
|
86
46
|
**Re-linking a directory moves it.** `link` on a directory that already has a key verifies the new
|
|
87
|
-
key, writes it,
|
|
88
|
-
has one live key at a time and `status` never lists ghosts. A retire the server refuses is reported
|
|
89
|
-
and does not undo the link; revoke the old key from the app's Keys list in that case.
|
|
90
|
-
|
|
91
|
-
**`.wsync.json`** in a repository root is an optional marker (`{ "project": "<slug>", "ticket":
|
|
92
|
-
"<KEY>" }`) the identity layer reads ahead of the git remote. It does not change where live capture
|
|
93
|
-
files a session — the key does that — but it names the project `backfill` should look for and the
|
|
94
|
-
ticket to prefer. It lives in the repository, so committing it shares the choice with everyone who
|
|
95
|
-
clones; whether a project name belongs in a public repository is the owner's call. `link` never
|
|
96
|
-
writes it.
|
|
97
|
-
|
|
98
|
-
## Production server
|
|
99
|
-
|
|
100
|
-
The default server (used when you pass no `--server` and have none configured) is
|
|
101
|
-
`http://localhost:3000` — a local backend with nothing in front of it.
|
|
102
|
-
|
|
103
|
-
In production, requests go through the reverse proxy, which strips `/api` before they reach the
|
|
104
|
-
backend. So the server value you pass there is the site origin **plus** `/api`:
|
|
105
|
-
|
|
106
|
-
```sh
|
|
107
|
-
npx @unhuman/wsync-cli link wsp_your_key_here --server https://unhuman.unbs.cloud/api
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Every API call is a plain concatenation of the configured server and a `/wsync/...` path (see
|
|
111
|
-
`apiUrl` in `src/config.ts`), so this is the only place the `/api` prefix needs to be spelled out —
|
|
112
|
-
nothing else in the CLI knows or cares which environment it's talking to.
|
|
47
|
+
key, writes it, then retires the previous one on the server, so a directory has one live key.
|
|
113
48
|
|
|
114
49
|
## On-disk layout
|
|
115
50
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
~/.wsync/
|
|
120
|
-
config.json server + per-directory links, mode 0600
|
|
121
|
-
spool/ pending checkpoints and events, drained by `flush`
|
|
122
|
-
cache/ rendered context per linked directory + per-session segment bookmarks
|
|
123
|
-
wsync.log best-effort diagnostics from the hooks themselves
|
|
124
|
-
flush.lock single-holder lock so a hook-spawned flush and a manual one never race
|
|
125
|
-
```
|
|
51
|
+
Under `~/.wsync` (override with `WSYNC_HOME`): `config.json` — the server and per-directory links,
|
|
52
|
+
mode 0600.
|
|
126
53
|
|
|
127
54
|
## Development
|
|
128
55
|
|
|
129
56
|
```sh
|
|
130
|
-
pnpm --filter @unhuman/wsync-cli typecheck
|
|
57
|
+
pnpm --filter @unhuman/wsync-cli typecheck
|
|
58
|
+
pnpm --filter @unhuman/wsync-cli test
|
|
131
59
|
pnpm --filter @unhuman/wsync-cli build # esbuild bundle -> dist/wsync.mjs
|
|
132
60
|
```
|
|
133
|
-
|
|
134
|
-
This package reuses `@unhuman/wsync-core` for everything content-shaped — mechanical transcript
|
|
135
|
-
distillation, git/ticket identity resolution, and redaction — rather than reimplementing any of
|
|
136
|
-
it. It has no test suite of its own; correctness here is verified by the backend's wsync specs and
|
|
137
|
-
by live end-to-end use (linking a real directory, running Claude Code against it, checking
|
|
138
|
-
`wsync status` and the server's session view).
|