@jive-sh/skill-sync 0.4.18 → 0.5.0-latest-darwin-arm64
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/multi-call-binary +4 -0
- package/package.json +11 -39
- package/README.md +0 -127
- package/bin/package.json +0 -1
- package/bin/skill-sync +0 -576
- package/bin/skill-sync-daemon +0 -576
- package/dist/daemons/skill-sync-daemon.js +0 -491
- package/dist/daemons/skill-sync-daemon.js.map +0 -1
- package/dist/entrypoints/skill-sync.js +0 -153
- package/dist/entrypoints/skill-sync.js.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/internal/agents/agent-tool.js +0 -83
- package/dist/internal/agents/agent-tool.js.map +0 -1
- package/dist/internal/agents/claude.js +0 -249
- package/dist/internal/agents/claude.js.map +0 -1
- package/dist/internal/agents/codex.js +0 -150
- package/dist/internal/agents/codex.js.map +0 -1
- package/dist/internal/agents/grok.js +0 -111
- package/dist/internal/agents/grok.js.map +0 -1
- package/dist/internal/agents/index.js +0 -31
- package/dist/internal/agents/index.js.map +0 -1
- package/dist/internal/config.js +0 -131
- package/dist/internal/config.js.map +0 -1
- package/dist/internal/control.js +0 -101
- package/dist/internal/control.js.map +0 -1
- package/dist/internal/folders.js +0 -47
- package/dist/internal/folders.js.map +0 -1
- package/dist/internal/path.js +0 -36
- package/dist/internal/path.js.map +0 -1
- package/dist/internal/server.js +0 -32
- package/dist/internal/server.js.map +0 -1
- package/dist/internal/skill-check.js +0 -83
- package/dist/internal/skill-check.js.map +0 -1
- package/dist/internal/sync.js +0 -183
- package/dist/internal/sync.js.map +0 -1
- package/dist/internal/wire.js +0 -24
- package/dist/internal/wire.js.map +0 -1
- package/install.cjs +0 -576
- package/src/daemons/skill-sync-daemon.ts +0 -483
- package/src/entrypoints/skill-sync.ts +0 -156
- package/src/index.ts +0 -15
- package/src/internal/agents/agent-tool.ts +0 -109
- package/src/internal/agents/claude.ts +0 -259
- package/src/internal/agents/codex.ts +0 -163
- package/src/internal/agents/grok.ts +0 -112
- package/src/internal/agents/index.ts +0 -34
- package/src/internal/config.ts +0 -172
- package/src/internal/control.ts +0 -140
- package/src/internal/folders.ts +0 -50
- package/src/internal/path.ts +0 -32
- package/src/internal/server.ts +0 -34
- package/src/internal/skill-check.ts +0 -97
- package/src/internal/sync.ts +0 -217
- package/src/internal/wire.ts +0 -252
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import { Effect } from "effect";
|
|
4
|
-
import { daemonStatuses, upgrade } from "jive-abstract-library";
|
|
5
|
-
import { name, version } from "../../package.json";
|
|
6
|
-
import { DaemonUnreachable, request } from "../internal/control";
|
|
7
|
-
/**
|
|
8
|
-
* The CLI that accompanies the daemon: `login`, `logout`, `list`, `add`, `upgrade` and `version`. Which folders
|
|
9
|
-
* sync is chosen on the dashboard; skills are ticked there too, or added with `add` by the agent that wrote one.
|
|
10
|
-
*
|
|
11
|
-
* The daemon owns the sync token and keeps it in `~/.jive/skill-sync-token.json`. `login`, `logout`, `list`
|
|
12
|
-
* and `add` are requests to it over the control socket; the token goes from the browser straight to the daemon
|
|
13
|
-
* and never through here.
|
|
14
|
-
*/
|
|
15
|
-
const program = new Command("skill-sync")
|
|
16
|
-
.description("keep the skills you choose identical across every Claude, Codex and Grok skills folder on every machine; choose them at https://skill-sync.jive.sh/");
|
|
17
|
-
program
|
|
18
|
-
.command("login")
|
|
19
|
-
.description("sign this machine in with your passkey in the browser; it stays signed in until you log out")
|
|
20
|
-
.action(async () => {
|
|
21
|
-
const result = await withDaemon({ type: "login" }, (event) => {
|
|
22
|
-
if (event.type !== "open")
|
|
23
|
-
return;
|
|
24
|
-
console.log(`Opening ${event.url}`);
|
|
25
|
-
openBrowser(event.url);
|
|
26
|
-
});
|
|
27
|
-
if (result.type === "signedIn") {
|
|
28
|
-
console.log(`Signed in. ${result.machine} is syncing; choose what syncs at https://skill-sync.jive.sh/`);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
fail(result);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
program
|
|
35
|
-
.command("logout")
|
|
36
|
-
.description("revoke this machine's token and stop syncing until the next login")
|
|
37
|
-
.action(async () => {
|
|
38
|
-
const result = await withDaemon({ type: "logout" }, () => undefined);
|
|
39
|
-
if (result.type === "signedOut") {
|
|
40
|
-
console.log(result.revoked ? "Signed out; the token is revoked." : "Signed out locally; the server could not be reached to revoke the token.");
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
fail(result);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
program
|
|
47
|
-
.command("list")
|
|
48
|
-
.description("list the skills that sync, as the server holds them; needs this machine signed in")
|
|
49
|
-
.action(async () => {
|
|
50
|
-
const result = await withDaemon({ type: "list" }, () => undefined);
|
|
51
|
-
if (result.type !== "list")
|
|
52
|
-
fail(result);
|
|
53
|
-
if (result.skills.length === 0) {
|
|
54
|
-
console.log("No skills sync yet; tick them at https://skill-sync.jive.sh/");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const width = Math.max(...result.skills.map((skill) => skill.name.length));
|
|
58
|
-
for (const skill of result.skills) {
|
|
59
|
-
const detail = skill.editedAt === null
|
|
60
|
-
? "no files yet"
|
|
61
|
-
: `${skill.files} ${skill.files === 1 ? "file" : "files"}, last edited ${new Date(skill.editedAt).toLocaleString()} on ${skill.editedBy}`;
|
|
62
|
-
console.log(`${skill.name.padEnd(width)} ${detail}`);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
program
|
|
66
|
-
.command("add")
|
|
67
|
-
.argument("<skill>", "the skill's folder name, which must match the name in its SKILL.md")
|
|
68
|
-
.description("put a skill meant for every project on the synced list; it must be in a folder skill-sync syncs, with a valid SKILL.md. Repeating it changes nothing")
|
|
69
|
-
.action(async (skill) => {
|
|
70
|
-
const result = await withDaemon({ type: "add", skill }, () => undefined);
|
|
71
|
-
if (result.type !== "added")
|
|
72
|
-
fail(result);
|
|
73
|
-
console.log(result.added ? `Added ${skill} to the synced list.` : `${skill} was already on the synced list.`);
|
|
74
|
-
if (result.syncingFolders.length === 0) {
|
|
75
|
-
console.log(`None of the folders holding it on this machine (${result.folders.join(", ")}) is ticked at https://skill-sync.jive.sh/, so its files upload once one is.`);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
program
|
|
79
|
-
.command("upgrade")
|
|
80
|
-
.description("upgrade skill-sync to the latest version with the package manager that installed it")
|
|
81
|
-
.action(async () => {
|
|
82
|
-
await Effect.runPromise(upgrade({ packageName: name })).catch((cause) => {
|
|
83
|
-
console.error(`Upgrade failed: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
program
|
|
88
|
-
.command("version")
|
|
89
|
-
.description("print the version of skill-sync installed here")
|
|
90
|
-
.action(() => {
|
|
91
|
-
console.log(version);
|
|
92
|
-
});
|
|
93
|
-
program.parse();
|
|
94
|
-
if (process.argv.length <= 2)
|
|
95
|
-
program.help();
|
|
96
|
-
/**
|
|
97
|
-
* Sends a request to the running daemon. If none is listening — stopped, or never started since the
|
|
98
|
-
* install — this package's registered daemon is started through its service manager and the request is
|
|
99
|
-
* retried for a few seconds.
|
|
100
|
-
*/
|
|
101
|
-
async function withDaemon(message, onEvent) {
|
|
102
|
-
try {
|
|
103
|
-
return await request(message, onEvent);
|
|
104
|
-
}
|
|
105
|
-
catch (cause) {
|
|
106
|
-
if (!(cause instanceof DaemonUnreachable))
|
|
107
|
-
throw cause;
|
|
108
|
-
}
|
|
109
|
-
await startDaemons();
|
|
110
|
-
for (let attempt = 0;; attempt++) {
|
|
111
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
112
|
-
try {
|
|
113
|
-
return await request(message, onEvent);
|
|
114
|
-
}
|
|
115
|
-
catch (cause) {
|
|
116
|
-
if (!(cause instanceof DaemonUnreachable) || attempt >= 20) {
|
|
117
|
-
console.error(`${cause instanceof Error ? cause.message : String(cause)}. Reinstall skill-sync to register its daemon.`);
|
|
118
|
-
process.exit(1);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function fail(event) {
|
|
124
|
-
console.error(event.type === "error" ? event.message : `unexpected answer from the daemon: ${JSON.stringify(event)}`);
|
|
125
|
-
process.exit(1);
|
|
126
|
-
}
|
|
127
|
-
/** Starts this package's registered daemons through their service manager. */
|
|
128
|
-
async function startDaemons() {
|
|
129
|
-
const statuses = await Effect.runPromise(daemonStatuses).catch(() => []);
|
|
130
|
-
const ours = statuses.filter((status) => status.registration.packageName === name && status.executableExists);
|
|
131
|
-
if (ours.length === 0) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
for (const { registration } of ours) {
|
|
135
|
-
const command = registration.kind === "launchd"
|
|
136
|
-
? ["launchctl", "kickstart", "-k", `gui/${process.getuid?.() ?? 0}/${registration.unit}`]
|
|
137
|
-
: registration.kind === "systemd"
|
|
138
|
-
? ["systemctl", "--user", "restart", registration.unit]
|
|
139
|
-
: ["schtasks", "/Run", "/TN", registration.unit];
|
|
140
|
-
const result = spawnSync(command[0], command.slice(1), { stdio: ["ignore", "ignore", "pipe"] });
|
|
141
|
-
if (result.status !== 0) {
|
|
142
|
-
console.error(`Could not start ${registration.unit}: ${String(result.stderr ?? "").trim() || `exit ${result.status}`}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function openBrowser(url) {
|
|
147
|
-
const command = process.platform === "darwin" ? "open"
|
|
148
|
-
: process.platform === "win32" ? "cmd"
|
|
149
|
-
: "xdg-open";
|
|
150
|
-
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
151
|
-
spawn(command, args, { stdio: "ignore", detached: true }).unref();
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=skill-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CAAC,CAAC,KAAK,EAAE,CAAC;AACpE,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What the service needs from this package.
|
|
3
|
-
*
|
|
4
|
-
* The daemon and CLI are the product; this entrypoint exists so the service can share the path rules
|
|
5
|
-
* and wire types rather than restate them. A rule restated is a rule that drifts, and these two are
|
|
6
|
-
* exactly the pair that must not: one validates what the other writes to disk.
|
|
7
|
-
*/
|
|
8
|
-
export { invalidPathReason, isValidPath } from "./internal/path";
|
|
9
|
-
export { DAEMON_VERSION_HEADER, isSkillName, skillOf } from "./internal/wire";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { closeSync, openSync, readdirSync, readSync, statSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { SchemaIssue } from "effect";
|
|
4
|
-
import { isLock } from "../config";
|
|
5
|
-
/** Sessions are counted over this many days: Claude Code deletes session files older than 30 days by default. */
|
|
6
|
-
export const PERIOD_DAYS = 30;
|
|
7
|
-
export const DAY_MS = 24 * 60 * 60 * 1000;
|
|
8
|
-
const formatIssue = SchemaIssue.makeFormatterDefault();
|
|
9
|
-
/** A record that failed to decode: what failed, on one line, so the dashboard can say why it shows nothing. */
|
|
10
|
-
export const unknownShape = (what, issue) => ({ state: "unknown", reason: `${what} changed shape: ${formatIssue(issue).replace(/\s+/g, " ").slice(0, 160)}` });
|
|
11
|
-
export function isDirectory(path) {
|
|
12
|
-
try {
|
|
13
|
-
return statSync(path).isDirectory();
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export const parseJson = (line) => {
|
|
20
|
-
try {
|
|
21
|
-
return JSON.parse(line);
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* A file's whole lines, last first, reading at most `limit` bytes back from its end. Lines longer than
|
|
29
|
-
* `maxLine` bytes are skipped: holding a multi-megabyte line while reading backwards would copy it once
|
|
30
|
-
* per chunk read, and the lines wanted here are a few hundred bytes.
|
|
31
|
-
*/
|
|
32
|
-
export function* linesFromEnd(path, limit, maxLine = 1024 * 1024) {
|
|
33
|
-
const CHUNK = 64 * 1024;
|
|
34
|
-
const fd = openSync(path, "r");
|
|
35
|
-
try {
|
|
36
|
-
const size = statSync(path).size;
|
|
37
|
-
const stop = Math.max(0, size - limit);
|
|
38
|
-
let position = size;
|
|
39
|
-
// The start of a line whose line break has not been read yet, since reading goes backwards.
|
|
40
|
-
let carry = Buffer.alloc(0);
|
|
41
|
-
// The line being read is longer than `maxLine`; its bytes are dropped until its start is found.
|
|
42
|
-
let oversized = false;
|
|
43
|
-
while (position > stop) {
|
|
44
|
-
const length = Math.min(CHUNK, position - stop);
|
|
45
|
-
position -= length;
|
|
46
|
-
const chunk = Buffer.alloc(length);
|
|
47
|
-
readSync(fd, chunk, 0, length, position);
|
|
48
|
-
const buffer = Buffer.concat([chunk, carry]);
|
|
49
|
-
// Splitting on the newline byte is safe in UTF-8: it never occurs inside a multi-byte character.
|
|
50
|
-
let end = buffer.length;
|
|
51
|
-
for (let index = buffer.length - 1; index >= 0; index--) {
|
|
52
|
-
if (buffer[index] !== 0x0a)
|
|
53
|
-
continue;
|
|
54
|
-
const line = buffer.subarray(index + 1, end).toString("utf-8").trim();
|
|
55
|
-
if (!oversized && line !== "")
|
|
56
|
-
yield line;
|
|
57
|
-
oversized = false;
|
|
58
|
-
end = index;
|
|
59
|
-
}
|
|
60
|
-
carry = buffer.subarray(0, end);
|
|
61
|
-
if (carry.length > maxLine) {
|
|
62
|
-
carry = Buffer.alloc(0);
|
|
63
|
-
oversized = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// The file's first line. When the search stopped short of the start, what is left is part of a line.
|
|
67
|
-
const first = carry.toString("utf-8").trim();
|
|
68
|
-
if (stop === 0 && !oversized && first !== "")
|
|
69
|
-
yield first;
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
closeSync(fd);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/** The directories in `home` named `.<name>` or `.<name>-<suffix>`, never a lock: one tool's account folders. */
|
|
76
|
-
export function homesNamed(home, name) {
|
|
77
|
-
return readdirSync(home)
|
|
78
|
-
.filter((entry) => (entry === `.${name}` || entry.startsWith(`.${name}-`)) && !isLock(entry))
|
|
79
|
-
.map((entry) => join(home, entry))
|
|
80
|
-
.filter(isDirectory)
|
|
81
|
-
.sort();
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=agent-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-tool.js","sourceRoot":"","sources":["../../../../../src/internal/agents/agent-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2BnC,iHAAiH;AACjH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE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CAAC,CAAC,CAAC;gBACxB,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;QACD,qGAAqG;QACrG,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7C,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,KAAK,KAAK,EAAE;YAAE,MAAM,KAAK,CAAC;IAC5D,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,IAAY;IACnD,OAAO,WAAW,CAAC,IAAI,CAAC;SACrB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,EAAE,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC5F,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACjC,MAAM,CAAC,WAAW,CAAC;SACnB,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
-
import { join, sep } from "node:path";
|
|
3
|
-
import { Result, Schema, SchemaIssue } from "effect";
|
|
4
|
-
import { DAY_MS, PERIOD_DAYS, homesNamed, isDirectory, linesFromEnd, parseJson, unknownShape, } from "./agent-tool";
|
|
5
|
-
/**
|
|
6
|
-
* Claude Code. Each account is a `CLAUDE_CONFIG_DIR` (`~/.claude`, `~/.claude-<name>`), and reads its
|
|
7
|
-
* user skills from the `skills` folder inside it.
|
|
8
|
-
*
|
|
9
|
-
* Usage is read only from files Claude Code writes for itself, never from its credentials. Neither file
|
|
10
|
-
* format is a published contract, so a shape this code does not recognise is reported as `unknown`.
|
|
11
|
-
*
|
|
12
|
-
* - Plan limits: Claude Code keeps the last plan usage it fetched in the account's `.claude.json` under
|
|
13
|
-
* `cachedUsageUtilization`, and refreshes it about every five minutes while a session runs on that
|
|
14
|
-
* account. It is what `/usage` shows when the usage endpoint is rate limited.
|
|
15
|
-
* - No plan limits (Amazon Bedrock, an API key): Claude Code computes each session's cost locally from
|
|
16
|
-
* token counts at list price, the figure `/usage` shows as the Session block's total cost
|
|
17
|
-
* (https://code.claude.com/docs/en/costs), and saves it as a `cost-state` line in the session's file
|
|
18
|
-
* under `projects/`. An account with a plan cache keeps showing its limits, unless its settings turn
|
|
19
|
-
* Bedrock on.
|
|
20
|
-
*/
|
|
21
|
-
export const claude = {
|
|
22
|
-
tool: "claude",
|
|
23
|
-
skillsFolders: (home) => homesNamed(home, "claude").map((account) => join(account, "skills")),
|
|
24
|
-
accounts: (home) => homesNamed(home, "claude"),
|
|
25
|
-
readUsage: (account, home, now) => readClaude(account, home, now),
|
|
26
|
-
};
|
|
27
|
-
// ── Claude ──────────────────────────────────────────────────────────────────────────────────────────
|
|
28
|
-
/**
|
|
29
|
-
* The default account keeps its state in `~/.claude.json`, beside its folder rather than in it; an
|
|
30
|
-
* account given its own `CLAUDE_CONFIG_DIR` keeps it inside that folder.
|
|
31
|
-
*/
|
|
32
|
-
export function claudeStatePath(accountPath, home) {
|
|
33
|
-
return accountPath === join(home, ".claude") ? join(home, ".claude.json") : join(accountPath, ".claude.json");
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* A subscription account's plan limits, else what its recent sessions cost. A Bedrock account can still
|
|
37
|
-
* hold a plan cache from before it switched, so its settings saying Bedrock outrank the cache.
|
|
38
|
-
*/
|
|
39
|
-
function readClaude(accountPath, home, now) {
|
|
40
|
-
const statePath = claudeStatePath(accountPath, home);
|
|
41
|
-
const plan = existsSync(statePath) ? parseClaudeState(readFileSync(statePath, "utf-8")) : { state: "none" };
|
|
42
|
-
const settingsPath = join(accountPath, "settings.json");
|
|
43
|
-
const bedrockSetting = existsSync(settingsPath) && settingsUseBedrock(readFileSync(settingsPath, "utf-8"));
|
|
44
|
-
if (plan.state !== "none" && !bedrockSetting)
|
|
45
|
-
return plan;
|
|
46
|
-
const projects = join(accountPath, "projects");
|
|
47
|
-
const files = [...sessionFilesSince(projects, now - PERIOD_DAYS * DAY_MS)];
|
|
48
|
-
forgetOtherSessionFiles(projects, new Set(files.map((file) => file.path)));
|
|
49
|
-
return estimateSpend({ sessions: files.map(latestSessionCost), bedrockSetting, now });
|
|
50
|
-
}
|
|
51
|
-
// ── Claude without plan limits ──────────────────────────────────────────────────────────────────────
|
|
52
|
-
/** How far back from its end a session file is searched for its cost. Claude Code writes it last, on leaving the session. */
|
|
53
|
-
const CLAUDE_TAIL_BYTES = 16 * 1024 * 1024;
|
|
54
|
-
/**
|
|
55
|
-
* True when the account's `settings.json` turns on Bedrock: the `/setup-bedrock` wizard writes
|
|
56
|
-
* `CLAUDE_CODE_USE_BEDROCK` to its `env` block (https://code.claude.com/docs/en/amazon-bedrock), and
|
|
57
|
-
* `CLAUDE_CODE_USE_MANTLE` selects Bedrock's Mantle endpoint. Set only in a shell, it is invisible here;
|
|
58
|
-
* the model IDs in the account's sessions then say Bedrock instead.
|
|
59
|
-
*/
|
|
60
|
-
export function settingsUseBedrock(text) {
|
|
61
|
-
let settings;
|
|
62
|
-
try {
|
|
63
|
-
settings = JSON.parse(text);
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
const env = Schema.decodeUnknownOption(Schema.Struct({ env: Schema.Record(Schema.String, Schema.Unknown) }))(settings);
|
|
69
|
-
if (env._tag === "None")
|
|
70
|
-
return false;
|
|
71
|
-
return [env.value.env.CLAUDE_CODE_USE_BEDROCK, env.value.env.CLAUDE_CODE_USE_MANTLE]
|
|
72
|
-
.some((value) => value === true || (typeof value === "string" && /^(1|true)$/i.test(value.trim())));
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Bedrock's model IDs: a cross-region inference profile (`us.anthropic.claude-opus-4-8`, with `us-gov.`, `eu.`,
|
|
76
|
-
* `apac.`, `jp.`, `au.` or `global.`), a Mantle or foundation model ID (`anthropic.claude-haiku-4-5`), or an
|
|
77
|
-
* application inference profile ARN (`arn:aws:bedrock:…`), per https://code.claude.com/docs/en/amazon-bedrock.
|
|
78
|
-
* An Anthropic API model ID (`claude-opus-5-5`) has no `anthropic.` prefix.
|
|
79
|
-
*/
|
|
80
|
-
export const isBedrockModelId = (model) => /^(?:(?:us|us-gov|eu|apac|jp|au|global)\.)?anthropic\./.test(model) || /^arn:aws[a-z-]*:bedrock:/.test(model);
|
|
81
|
-
/** Session files written to since `since`: `projects/<project>/<session id>.jsonl`. Subagents' files are a level deeper and hold no cost. */
|
|
82
|
-
function* sessionFilesSince(projects, since) {
|
|
83
|
-
if (!isDirectory(projects))
|
|
84
|
-
return;
|
|
85
|
-
for (const project of readdirSync(projects)) {
|
|
86
|
-
const dir = join(projects, project);
|
|
87
|
-
if (!isDirectory(dir))
|
|
88
|
-
continue;
|
|
89
|
-
for (const entry of readdirSync(dir)) {
|
|
90
|
-
if (!entry.endsWith(".jsonl"))
|
|
91
|
-
continue;
|
|
92
|
-
const path = join(dir, entry);
|
|
93
|
-
const modifiedAt = statSync(path).mtimeMs;
|
|
94
|
-
if (modifiedAt >= since)
|
|
95
|
-
yield { path, modifiedAt };
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const CostState = Schema.Struct({
|
|
100
|
-
type: Schema.Literal("cost-state"),
|
|
101
|
-
sessionId: Schema.String,
|
|
102
|
-
totalCostUSD: Schema.Finite,
|
|
103
|
-
modelUsage: Schema.Record(Schema.String, Schema.Unknown),
|
|
104
|
-
hasUnknownModelCost: Schema.optionalKey(Schema.Boolean),
|
|
105
|
-
});
|
|
106
|
-
/** Session files keep growing while a session runs; one unchanged since it was last read is not read again. */
|
|
107
|
-
const sessionCostCache = new Map();
|
|
108
|
-
/** The daemon runs for weeks; files Claude Code deleted, or that left the period, leave the cache too. */
|
|
109
|
-
function forgetOtherSessionFiles(projects, current) {
|
|
110
|
-
for (const path of sessionCostCache.keys()) {
|
|
111
|
-
if (path.startsWith(projects + sep) && !current.has(path))
|
|
112
|
-
sessionCostCache.delete(path);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The cost a session file last saved, and when the session was last active before that save: the time of the
|
|
117
|
-
* nearest earlier line that has one, since the cost line itself carries no time.
|
|
118
|
-
*/
|
|
119
|
-
export function latestSessionCost(file) {
|
|
120
|
-
const cached = sessionCostCache.get(file.path);
|
|
121
|
-
if (cached !== undefined && cached.modifiedAt === file.modifiedAt)
|
|
122
|
-
return cached.cost;
|
|
123
|
-
let found;
|
|
124
|
-
let cost = { kind: "none" };
|
|
125
|
-
for (const line of linesFromEnd(file.path, CLAUDE_TAIL_BYTES)) {
|
|
126
|
-
if (found === undefined) {
|
|
127
|
-
// Cheap test first: only the cost line is worth parsing until it is found.
|
|
128
|
-
if (!line.includes("\"cost-state\""))
|
|
129
|
-
continue;
|
|
130
|
-
const entry = parseJson(line);
|
|
131
|
-
if (typeof entry !== "object" || entry === null || !("type" in entry) || entry.type !== "cost-state")
|
|
132
|
-
continue;
|
|
133
|
-
const decoded = Schema.decodeUnknownResult(CostState)(entry);
|
|
134
|
-
if (Result.isFailure(decoded)) {
|
|
135
|
-
cost = { kind: "changed", issue: decoded.failure.issue };
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
const state = decoded.success;
|
|
139
|
-
found = {
|
|
140
|
-
kind: "cost",
|
|
141
|
-
sessionId: state.sessionId,
|
|
142
|
-
costUsd: state.totalCostUSD,
|
|
143
|
-
lastActiveAt: file.modifiedAt,
|
|
144
|
-
partial: state.hasUnknownModelCost === true,
|
|
145
|
-
models: Object.keys(state.modelUsage),
|
|
146
|
-
};
|
|
147
|
-
cost = found;
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (!line.includes("\"timestamp\""))
|
|
151
|
-
continue;
|
|
152
|
-
const entry = parseJson(line);
|
|
153
|
-
const at = typeof entry === "object" && entry !== null && "timestamp" in entry && typeof entry.timestamp === "string"
|
|
154
|
-
? Date.parse(entry.timestamp)
|
|
155
|
-
: NaN;
|
|
156
|
-
if (Number.isFinite(at)) {
|
|
157
|
-
cost = { ...found, lastActiveAt: at };
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
sessionCostCache.set(file.path, { modifiedAt: file.modifiedAt, cost });
|
|
162
|
-
return cost;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* The sum over sessions last active within the period. A session's saved cost covers the whole session, so
|
|
166
|
-
* a resumed one counts once, at its latest save, and a session forked from another carries the cost it
|
|
167
|
-
* started with, so the sum can count that part twice.
|
|
168
|
-
*/
|
|
169
|
-
export function estimateSpend(input) {
|
|
170
|
-
const changed = input.sessions.find((session) => session.kind === "changed");
|
|
171
|
-
if (changed !== undefined)
|
|
172
|
-
return unknownShape("Claude Code's session cost record", changed.issue);
|
|
173
|
-
const since = input.now - PERIOD_DAYS * DAY_MS;
|
|
174
|
-
const bySession = new Map();
|
|
175
|
-
for (const session of input.sessions) {
|
|
176
|
-
if (session.kind !== "cost" || session.lastActiveAt < since)
|
|
177
|
-
continue;
|
|
178
|
-
const seen = bySession.get(session.sessionId);
|
|
179
|
-
if (seen === undefined || session.costUsd > seen.costUsd)
|
|
180
|
-
bySession.set(session.sessionId, session);
|
|
181
|
-
}
|
|
182
|
-
const counted = [...bySession.values()];
|
|
183
|
-
if (counted.length === 0)
|
|
184
|
-
return { state: "none" };
|
|
185
|
-
const usd = counted.reduce((sum, session) => sum + session.costUsd, 0);
|
|
186
|
-
return {
|
|
187
|
-
state: "estimate",
|
|
188
|
-
asOf: Math.max(...counted.map((session) => session.lastActiveAt)),
|
|
189
|
-
periodDays: PERIOD_DAYS,
|
|
190
|
-
spent: { amountMinor: Math.round(usd * 100), currency: "USD", exponent: 2 },
|
|
191
|
-
sessions: counted.length,
|
|
192
|
-
partial: counted.some((session) => session.partial),
|
|
193
|
-
provider: input.bedrockSetting || counted.some((session) => session.models.some(isBedrockModelId)) ? "bedrock" : null,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
const ClaudeWindow = Schema.Struct({ utilization: Schema.Finite, resets_at: Schema.NullOr(Schema.String) });
|
|
197
|
-
const ClaudeMoney = Schema.Struct({ amount_minor: Schema.Finite, currency: Schema.String, exponent: Schema.Int });
|
|
198
|
-
const ClaudeUsageCache = Schema.Struct({
|
|
199
|
-
fetchedAtMs: Schema.Finite,
|
|
200
|
-
utilization: Schema.Struct({
|
|
201
|
-
five_hour: Schema.optionalKey(Schema.NullOr(ClaudeWindow)),
|
|
202
|
-
seven_day: Schema.optionalKey(Schema.NullOr(ClaudeWindow)),
|
|
203
|
-
// Usage credits, the account's spend beyond its plan limits. `limit` has only been seen as null, so a
|
|
204
|
-
// limit in another shape is left out rather than failing the whole reading.
|
|
205
|
-
spend: Schema.optionalKey(Schema.NullOr(Schema.Struct({ enabled: Schema.Boolean, used: ClaudeMoney, limit: Schema.Unknown }))),
|
|
206
|
-
}),
|
|
207
|
-
});
|
|
208
|
-
/** Claude's documented window lengths: its status line calls them the 5-hour and 7-day limits. */
|
|
209
|
-
const CLAUDE_WINDOWS = [["five_hour", 300], ["seven_day", 7 * 24 * 60]];
|
|
210
|
-
/** Reads the usage Claude Code cached in an account's `.claude.json`. */
|
|
211
|
-
export function parseClaudeState(text) {
|
|
212
|
-
let state;
|
|
213
|
-
try {
|
|
214
|
-
state = JSON.parse(text);
|
|
215
|
-
}
|
|
216
|
-
catch {
|
|
217
|
-
// Claude Code rewrites the file while it runs; a half-written one reads fine a moment later.
|
|
218
|
-
return { state: "unknown", reason: "the account's .claude.json is not valid JSON" };
|
|
219
|
-
}
|
|
220
|
-
if (typeof state !== "object" || state === null || !("cachedUsageUtilization" in state))
|
|
221
|
-
return { state: "none" };
|
|
222
|
-
const decoded = Schema.decodeUnknownResult(ClaudeUsageCache)(state.cachedUsageUtilization);
|
|
223
|
-
if (Result.isFailure(decoded))
|
|
224
|
-
return unknownShape("Claude Code's usage cache", decoded.failure.issue);
|
|
225
|
-
const cache = decoded.success;
|
|
226
|
-
const windows = [];
|
|
227
|
-
for (const [key, minutes] of CLAUDE_WINDOWS) {
|
|
228
|
-
const window = cache.utilization[key];
|
|
229
|
-
if (window === undefined || window === null)
|
|
230
|
-
continue;
|
|
231
|
-
const resetsAt = window.resets_at === null ? null : Date.parse(window.resets_at);
|
|
232
|
-
if (resetsAt !== null && !Number.isFinite(resetsAt)) {
|
|
233
|
-
return { state: "unknown", reason: `Claude Code's usage cache changed shape: ${key}.resets_at is not a time` };
|
|
234
|
-
}
|
|
235
|
-
windows.push({ minutes, usedPercent: window.utilization, resetsAt });
|
|
236
|
-
}
|
|
237
|
-
const spend = cache.utilization.spend;
|
|
238
|
-
const limit = Schema.decodeUnknownOption(ClaudeMoney)(spend?.limit);
|
|
239
|
-
return {
|
|
240
|
-
state: "reading",
|
|
241
|
-
asOf: cache.fetchedAtMs,
|
|
242
|
-
windows,
|
|
243
|
-
...(spend?.enabled === true
|
|
244
|
-
? { spent: { used: money(spend.used), limit: limit._tag === "Some" ? money(limit.value) : null } }
|
|
245
|
-
: {}),
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
const money = (value) => ({ amountMinor: value.amount_minor, currency: value.currency, exponent: value.exponent });
|
|
249
|
-
//# sourceMappingURL=claude.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../../../../src/internal/agents/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,GA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