@jive-sh/skill-sync 0.4.16-latest-darwin-x64 → 0.4.16
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 +121 -0
- package/bin/package.json +1 -0
- package/bin/skill-sync +576 -0
- package/bin/skill-sync-daemon +576 -0
- package/dist/daemons/skill-sync-daemon.js +500 -0
- package/dist/daemons/skill-sync-daemon.js.map +1 -0
- package/dist/entrypoints/skill-sync.js +153 -0
- package/dist/entrypoints/skill-sync.js.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/config.js +159 -0
- package/dist/internal/config.js.map +1 -0
- package/dist/internal/control.js +101 -0
- package/dist/internal/control.js.map +1 -0
- package/dist/internal/folders.js +46 -0
- package/dist/internal/folders.js.map +1 -0
- package/dist/internal/path.js +36 -0
- package/dist/internal/path.js.map +1 -0
- package/dist/internal/server.js +32 -0
- package/dist/internal/server.js.map +1 -0
- package/dist/internal/skill-check.js +83 -0
- package/dist/internal/skill-check.js.map +1 -0
- package/dist/internal/sync.js +162 -0
- package/dist/internal/sync.js.map +1 -0
- package/dist/internal/usage.js +419 -0
- package/dist/internal/usage.js.map +1 -0
- package/dist/internal/wire.js +24 -0
- package/dist/internal/wire.js.map +1 -0
- package/install.cjs +576 -0
- package/package.json +39 -11
- package/src/daemons/skill-sync-daemon.ts +493 -0
- package/src/entrypoints/skill-sync.ts +156 -0
- package/src/index.ts +15 -0
- package/src/internal/config.ts +200 -0
- package/src/internal/control.ts +140 -0
- package/src/internal/folders.ts +49 -0
- package/src/internal/path.ts +32 -0
- package/src/internal/server.ts +34 -0
- package/src/internal/skill-check.ts +97 -0
- package/src/internal/sync.ts +197 -0
- package/src/internal/usage.ts +457 -0
- package/src/internal/wire.ts +241 -0
- package/multi-call-binary +0 -4
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the daemon and the service exchange.
|
|
3
|
+
*
|
|
4
|
+
* Declared in the library and imported by the service so there is one definition rather than two that
|
|
5
|
+
* drift. The service depends on the library; nothing goes the other way.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface RemoteFile {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
/** Null when the file is deleted; the row stays, so the deletion reaches every machine. */
|
|
11
|
+
readonly hash: string | null;
|
|
12
|
+
/** When this version was edited, in milliseconds since the epoch. The latest edit wins. */
|
|
13
|
+
readonly editedAt: number;
|
|
14
|
+
readonly updatedBy: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ListFilesResponse {
|
|
18
|
+
/** Highest sequence number in this page; the caller sends it back as `since`. */
|
|
19
|
+
readonly cursor: number;
|
|
20
|
+
readonly files: ReadonlyArray<RemoteFile>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Taken only when `editedAt` is later than the edit the server holds; refused with 409 otherwise. */
|
|
24
|
+
export interface PutFileRequest {
|
|
25
|
+
readonly path: string;
|
|
26
|
+
/** When the file was edited: its modification time, or for a deletion, when it was noticed. */
|
|
27
|
+
readonly editedAt: number;
|
|
28
|
+
/** Null to delete. */
|
|
29
|
+
readonly hash: string | null;
|
|
30
|
+
/** Base64, absent for a delete. */
|
|
31
|
+
readonly content: string | null;
|
|
32
|
+
readonly machine: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Where a folder's sync stands, as the dashboard shows it. `attention` means a cycle failed; `detail` says why. */
|
|
36
|
+
export type FolderState = "idle" | "attention";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A skill is a top-level entry of a skills folder — usually a directory like `jive/` holding `SKILL.md`
|
|
40
|
+
* and its files — and it is the unit of opting in: all of its files sync, or none do, so a skill never
|
|
41
|
+
* arrives half-present on another machine.
|
|
42
|
+
*/
|
|
43
|
+
export const skillOf = (path: string): string => path.split("/")[0]!;
|
|
44
|
+
|
|
45
|
+
/** A file and the SHA-256 of its content — the same hash the server stores, so copies can be compared. */
|
|
46
|
+
export interface FileHash {
|
|
47
|
+
readonly path: string;
|
|
48
|
+
readonly hash: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** One skill as a folder holds it. */
|
|
52
|
+
export interface LocalSkill {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly files: ReadonlyArray<FileHash>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `POST /folders`: every folder this machine found, with the skills in each, for the dashboard. Answered
|
|
59
|
+
* with the enabled folders, each with the synced list: the daemon pushes and pulls exactly those skills,
|
|
60
|
+
* and never touches any other.
|
|
61
|
+
*/
|
|
62
|
+
export interface FoldersRequest {
|
|
63
|
+
readonly folders: ReadonlyArray<{ readonly path: string; readonly skills: ReadonlyArray<LocalSkill> }>;
|
|
64
|
+
}
|
|
65
|
+
export interface FolderPrefs {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly skills: ReadonlyArray<string>;
|
|
68
|
+
}
|
|
69
|
+
export interface FoldersResponse {
|
|
70
|
+
readonly folders: ReadonlyArray<FolderPrefs>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether a name can be a skill's: lowercase letters and digits in hyphen-joined words, at most 64
|
|
75
|
+
* characters, which is what Claude, Codex and Grok accept as a skill name. The daemon checks it before
|
|
76
|
+
* asking, and the service again before writing, so both judge a name by this one rule.
|
|
77
|
+
*/
|
|
78
|
+
export const isSkillName = (name: string): boolean => name.length <= 64 && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name);
|
|
79
|
+
|
|
80
|
+
/** `PUT /skills/<name>`: puts a skill on the synced list. `added` is false when it was already on it. */
|
|
81
|
+
export interface AddSkillResponse {
|
|
82
|
+
readonly added: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** `GET /skills`: the synced list, as `skill-sync list` shows it. Deleted skills are not on it. */
|
|
86
|
+
export interface ListSkillsResponse {
|
|
87
|
+
readonly skills: ReadonlyArray<ListedSkill>;
|
|
88
|
+
}
|
|
89
|
+
export interface ListedSkill {
|
|
90
|
+
readonly name: string;
|
|
91
|
+
/** Live files on the server; zero for a skill ticked before any machine has pushed it. */
|
|
92
|
+
readonly files: number;
|
|
93
|
+
/** The latest edit of any of its files, and the display name of the machine it came from; null with no files. */
|
|
94
|
+
readonly editedAt: number | null;
|
|
95
|
+
readonly editedBy: string | null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The header a daemon names its own version in when it opens its WebSocket to the hub, so the dashboard
|
|
100
|
+
* can show which version each machine runs. Daemons before 0.4.6 do not send it.
|
|
101
|
+
*/
|
|
102
|
+
export const DAEMON_VERSION_HEADER = "x-skill-sync-version";
|
|
103
|
+
|
|
104
|
+
/** One usage limit of an account: how much of it is used and when it starts over. */
|
|
105
|
+
export interface UsageWindow {
|
|
106
|
+
/** How long the window is, in minutes (300 for five hours, 10080 for a week); null when the tool does not say. */
|
|
107
|
+
readonly minutes: number | null;
|
|
108
|
+
/** Percent of the limit used, from 0 to 100, as the tool last recorded it. */
|
|
109
|
+
readonly usedPercent: number;
|
|
110
|
+
/** When the window starts over, in milliseconds since the epoch; null when no window is running. */
|
|
111
|
+
readonly resetsAt: number | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Money as the tool records it: an amount in the currency's smallest unit, so 1234 with exponent 2 is 12.34. */
|
|
115
|
+
export interface Money {
|
|
116
|
+
readonly amountMinor: number;
|
|
117
|
+
readonly currency: string;
|
|
118
|
+
readonly exponent: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* What a daemon knows about one Claude or Codex account on its machine, read from files the tool itself
|
|
123
|
+
* writes. Never a credential: only these numbers leave the machine.
|
|
124
|
+
*
|
|
125
|
+
* `reading`: the tool's latest record, with the time it was taken (`asOf`); every number is as of then.
|
|
126
|
+
* `estimate`: a Claude account with no plan limits, such as one on Amazon Bedrock or an API key: what
|
|
127
|
+
* Claude Code estimated its recent sessions cost at list price. `none`: the tool has not recorded usage for
|
|
128
|
+
* this account yet. `unknown`: the record exists but is in a shape this version cannot read, as when a new
|
|
129
|
+
* release of the tool changes it.
|
|
130
|
+
*/
|
|
131
|
+
export type AccountUsage = {
|
|
132
|
+
readonly tool: "claude" | "codex";
|
|
133
|
+
/** The account's folder in the home directory, such as `.claude-work` or `.codex`. */
|
|
134
|
+
readonly home: string;
|
|
135
|
+
} & (
|
|
136
|
+
| {
|
|
137
|
+
readonly state: "reading";
|
|
138
|
+
readonly asOf: number;
|
|
139
|
+
readonly windows: ReadonlyArray<UsageWindow>;
|
|
140
|
+
/** Spent beyond the plan, when the account pays for usage past its limits; absent when it does not. */
|
|
141
|
+
readonly spent?: { readonly used: Money; readonly limit: Money | null };
|
|
142
|
+
}
|
|
143
|
+
| {
|
|
144
|
+
readonly state: "estimate";
|
|
145
|
+
/** When the newest session counted was last active; nothing later is in the sum. */
|
|
146
|
+
readonly asOf: number;
|
|
147
|
+
/** Sessions last active within this many days before the reading are counted. */
|
|
148
|
+
readonly periodDays: number;
|
|
149
|
+
/**
|
|
150
|
+
* The sum of Claude Code's own estimate for each session, at list price. Claude Code saves a session's
|
|
151
|
+
* estimate when the session ends, is cleared, resumed or forked, so a session still running is not in it.
|
|
152
|
+
*/
|
|
153
|
+
readonly spent: Money;
|
|
154
|
+
readonly sessions: number;
|
|
155
|
+
/** Claude Code could not price a model in at least one session, so the true cost is higher. */
|
|
156
|
+
readonly partial: boolean;
|
|
157
|
+
/** `bedrock` when the account's settings or the model IDs its sessions used say so; null when nothing says. */
|
|
158
|
+
readonly provider: "bedrock" | null;
|
|
159
|
+
}
|
|
160
|
+
| { readonly state: "none" }
|
|
161
|
+
| { readonly state: "unknown"; readonly reason: string }
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
/** Daemon → hub, over the daemon's WebSocket. */
|
|
165
|
+
export type DaemonMessage =
|
|
166
|
+
| {
|
|
167
|
+
readonly type: "status";
|
|
168
|
+
readonly folder: string;
|
|
169
|
+
readonly state: FolderState;
|
|
170
|
+
readonly detail?: string;
|
|
171
|
+
/** A one-line summary of what the last cycle changed, when it changed anything. */
|
|
172
|
+
readonly activity?: string;
|
|
173
|
+
}
|
|
174
|
+
/** Every account on the machine, sent on connecting and whenever a number changes. Daemons before 0.4.9 never send it. */
|
|
175
|
+
| { readonly type: "usage"; readonly accounts: ReadonlyArray<AccountUsage> };
|
|
176
|
+
|
|
177
|
+
/** Hub → daemon. `prefs` replaces what syncs; `changed` means another write landed on the server. */
|
|
178
|
+
export type HubToDaemon =
|
|
179
|
+
| { readonly type: "prefs"; readonly folders: ReadonlyArray<FolderPrefs> }
|
|
180
|
+
| { readonly type: "changed" };
|
|
181
|
+
|
|
182
|
+
export interface SkillView {
|
|
183
|
+
readonly name: string;
|
|
184
|
+
/** On the list of synced skills, which every enabled folder sends and receives. */
|
|
185
|
+
readonly synced: boolean;
|
|
186
|
+
/** The folder has a copy on disk. */
|
|
187
|
+
readonly local: boolean;
|
|
188
|
+
readonly files: ReadonlyArray<FileHash>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface FolderView {
|
|
192
|
+
readonly path: string;
|
|
193
|
+
readonly enabled: boolean;
|
|
194
|
+
readonly state: FolderState;
|
|
195
|
+
readonly detail: string | null;
|
|
196
|
+
readonly lastActivityAt: number | null;
|
|
197
|
+
readonly lastActivity: string | null;
|
|
198
|
+
readonly skills: ReadonlyArray<SkillView>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface MachineView {
|
|
202
|
+
/** The name the machine's daemon uses; it identifies the machine and never changes. */
|
|
203
|
+
readonly machine: string;
|
|
204
|
+
/** What the dashboard calls it: renamed there, or the machine name until then. */
|
|
205
|
+
readonly name: string;
|
|
206
|
+
/** True while this machine's daemon holds a connection to the hub. */
|
|
207
|
+
readonly online: boolean;
|
|
208
|
+
/** The version its connected daemon runs; null while offline, or when the daemon is too old to say. */
|
|
209
|
+
readonly daemonVersion: string | null;
|
|
210
|
+
/** Each account's usage as its connected daemon last sent it; empty while offline, or from a daemon before 0.4.9. */
|
|
211
|
+
readonly accounts: ReadonlyArray<AccountUsage>;
|
|
212
|
+
readonly lastSeen: number | null;
|
|
213
|
+
readonly folders: ReadonlyArray<FolderView>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** A skill on the synced list, as the server holds it: the version every enabled folder converges on. */
|
|
217
|
+
export interface SyncedSkill {
|
|
218
|
+
readonly name: string;
|
|
219
|
+
readonly files: ReadonlyArray<FileHash & { readonly updatedBy: string; readonly editedAt: number }>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Hub → dashboard: the whole picture, resent on every change. It is small, and a diff protocol is not. */
|
|
223
|
+
export interface Snapshot {
|
|
224
|
+
readonly type: "snapshot";
|
|
225
|
+
/** The deployed service version. A dashboard built by another version reloads itself. */
|
|
226
|
+
readonly version: string;
|
|
227
|
+
/** The `latest` version of this package on npm, which every daemon upgrades to; null if npm could not be reached. */
|
|
228
|
+
readonly publishedVersion: string | null;
|
|
229
|
+
/** Display name for every machine name that appears anywhere in the snapshot, including old log entries. */
|
|
230
|
+
readonly names: Readonly<Record<string, string>>;
|
|
231
|
+
readonly skills: ReadonlyArray<SyncedSkill>;
|
|
232
|
+
readonly machines: ReadonlyArray<MachineView>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Dashboard → hub. */
|
|
236
|
+
export type DashboardMessage =
|
|
237
|
+
| { readonly type: "setFolder"; readonly machine: string; readonly path: string; readonly enabled: boolean }
|
|
238
|
+
/** Adds a skill to the synced list, or removes it: one list for every machine and folder. */
|
|
239
|
+
| { readonly type: "setSkill"; readonly skill: string; readonly synced: boolean }
|
|
240
|
+
/** An empty name restores the machine name. */
|
|
241
|
+
| { readonly type: "renameMachine"; readonly machine: string; readonly name: string };
|
package/multi-call-binary
DELETED