@jive-sh/skill-sync 0.6.0-latest-darwin-x64 → 0.6.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 (70) hide show
  1. package/README.md +146 -0
  2. package/bin/package.json +1 -0
  3. package/bin/skill-sync +614 -0
  4. package/bin/skill-sync-daemon +614 -0
  5. package/dist/daemons/skill-sync-daemon.js +499 -0
  6. package/dist/daemons/skill-sync-daemon.js.map +1 -0
  7. package/dist/entrypoints/skill-sync.js +7 -0
  8. package/dist/entrypoints/skill-sync.js.map +1 -0
  9. package/dist/index.js +10 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/internal/agents/agent-tool.js +92 -0
  12. package/dist/internal/agents/agent-tool.js.map +1 -0
  13. package/dist/internal/agents/claude.js +422 -0
  14. package/dist/internal/agents/claude.js.map +1 -0
  15. package/dist/internal/agents/codex.js +266 -0
  16. package/dist/internal/agents/codex.js.map +1 -0
  17. package/dist/internal/agents/command.js +137 -0
  18. package/dist/internal/agents/command.js.map +1 -0
  19. package/dist/internal/agents/grok.js +172 -0
  20. package/dist/internal/agents/grok.js.map +1 -0
  21. package/dist/internal/agents/index.js +70 -0
  22. package/dist/internal/agents/index.js.map +1 -0
  23. package/dist/internal/cli.js +161 -0
  24. package/dist/internal/cli.js.map +1 -0
  25. package/dist/internal/config.js +131 -0
  26. package/dist/internal/config.js.map +1 -0
  27. package/dist/internal/control.js +113 -0
  28. package/dist/internal/control.js.map +1 -0
  29. package/dist/internal/daemon-control/impl.js +62 -0
  30. package/dist/internal/daemon-control/impl.js.map +1 -0
  31. package/dist/internal/daemon-control/interface.js +4 -0
  32. package/dist/internal/daemon-control/interface.js.map +1 -0
  33. package/dist/internal/folders.js +47 -0
  34. package/dist/internal/folders.js.map +1 -0
  35. package/dist/internal/local-skills.js +43 -0
  36. package/dist/internal/local-skills.js.map +1 -0
  37. package/dist/internal/path.js +36 -0
  38. package/dist/internal/path.js.map +1 -0
  39. package/dist/internal/server.js +32 -0
  40. package/dist/internal/server.js.map +1 -0
  41. package/dist/internal/skill-check.js +83 -0
  42. package/dist/internal/skill-check.js.map +1 -0
  43. package/dist/internal/sync.js +183 -0
  44. package/dist/internal/sync.js.map +1 -0
  45. package/dist/internal/wire.js +24 -0
  46. package/dist/internal/wire.js.map +1 -0
  47. package/install.cjs +614 -0
  48. package/package.json +36 -11
  49. package/src/daemons/skill-sync-daemon.ts +491 -0
  50. package/src/entrypoints/skill-sync.ts +12 -0
  51. package/src/index.ts +15 -0
  52. package/src/internal/agents/agent-tool.ts +136 -0
  53. package/src/internal/agents/claude.ts +440 -0
  54. package/src/internal/agents/codex.ts +283 -0
  55. package/src/internal/agents/command.ts +173 -0
  56. package/src/internal/agents/grok.ts +176 -0
  57. package/src/internal/agents/index.ts +74 -0
  58. package/src/internal/cli.ts +194 -0
  59. package/src/internal/config.ts +172 -0
  60. package/src/internal/control.ts +153 -0
  61. package/src/internal/daemon-control/impl.ts +74 -0
  62. package/src/internal/daemon-control/interface.ts +38 -0
  63. package/src/internal/folders.ts +50 -0
  64. package/src/internal/local-skills.ts +58 -0
  65. package/src/internal/path.ts +32 -0
  66. package/src/internal/server.ts +34 -0
  67. package/src/internal/skill-check.ts +97 -0
  68. package/src/internal/sync.ts +217 -0
  69. package/src/internal/wire.ts +315 -0
  70. package/multi-call-binary +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folders.js","sourceRoot":"","sources":["../../../../src/internal/folders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAe,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,OAAO,GACR,MAAM,QAAQ,CAAC;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E;QACrD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,QAAQ,CAAC,MAAM,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAChG,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAsB,CAAA,CAAC,OAAO,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { Option } from "effect";
4
+ import { isLock } from "./config";
5
+ import { checkSkillToAdd, readFrontmatter } from "./skill-check";
6
+ /** Every copy of `skill` in `folders`, in the order of `folders`. */
7
+ export function skillCopies(input) {
8
+ return input.folders
9
+ .map((folder) => join(folder, input.skill))
10
+ .filter((path) => existsSync(path))
11
+ .map((path) => ({ path, description: readDescription(join(path, "SKILL.md")) }));
12
+ }
13
+ /**
14
+ * What `skill-sync show` prints: each description above the paths of the copies that have it. Copies agree once
15
+ * synced, so this is usually one description; copies that differ are shown apart rather than one hiding another.
16
+ */
17
+ export function formatSkillCopies(copies) {
18
+ const byDescription = Map.groupBy(copies, (copy) => Option.getOrElse(copy.description, () => "(its SKILL.md has no description)"));
19
+ return [...byDescription]
20
+ .map(([description, group]) => [description, ...group.map((copy) => ` ${copy.path}`)].join("\n"))
21
+ .join("\n\n");
22
+ }
23
+ /**
24
+ * The skills in `folders` that are not on the synced list and that `skill-sync add` would accept: the same check
25
+ * the daemon runs before adding (`checkSkillToAdd`), so Tab offers nothing the daemon would refuse.
26
+ */
27
+ export function addableSkills(input) {
28
+ const { folders, exclude, synced } = input;
29
+ const names = new Set(folders.flatMap((folder) => entries(folder).filter((entry) => !entry.startsWith(".") && !isLock(entry))));
30
+ return [...names]
31
+ .filter((skill) => !synced.includes(skill) && checkSkillToAdd({ skill, folders, exclude }).ok)
32
+ .sort();
33
+ }
34
+ function readDescription(skillFile) {
35
+ if (!existsSync(skillFile))
36
+ return Option.none();
37
+ const description = readFrontmatter(readFileSync(skillFile, "utf8"))?.get("description");
38
+ return description === undefined || description === "" ? Option.none() : Option.some(description);
39
+ }
40
+ function entries(folder) {
41
+ return existsSync(folder) ? readdirSync(folder) : [];
42
+ }
43
+ //# sourceMappingURL=local-skills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-skills.js","sourceRoot":"","sources":["../../../../src/internal/local-skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAUjE,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAC,KAA0E;IACpG,OAAO,KAAK,CAAC,OAAO;SACjB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1C,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SAClC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAgC;IAChE,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,CA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Ae,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IACzF,OAAO,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACpG,CAAC;AAED,SAAS,OAAO,CAAC,MAAc;IAC7B,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Validation for the one piece of untrusted input that becomes a filesystem path.
3
+ *
4
+ * Shared by the Worker and the daemon on purpose, and deliberately free of any Node import so the Worker
5
+ * can bundle it. Both ends check: the server so one compromised client cannot poison what every machine
6
+ * pulls, and the daemon because a server it does not control is not a thing to take paths from either.
7
+ *
8
+ * Without this, a pushed path of `../../.ssh/authorized_keys` is joined to the skills directory and
9
+ * written wherever the daemon's user can write.
10
+ */
11
+ /** Long enough for any real nesting, short enough that nothing can be used to exhaust anything. */
12
+ const MAX_LENGTH = 512;
13
+ export function invalidPathReason(path) {
14
+ if (path.length === 0 || path.length > MAX_LENGTH)
15
+ return "path is empty or too long";
16
+ if (path.includes("\0"))
17
+ return "path contains a null byte";
18
+ if (path.includes("\\"))
19
+ return "path must use forward slashes";
20
+ if (path.startsWith("/"))
21
+ return "path must be relative";
22
+ // A Windows drive letter is absolute on the machine that matters even though it has no leading slash.
23
+ if (/^[A-Za-z]:/.test(path))
24
+ return "path must be relative";
25
+ for (const segment of path.split("/")) {
26
+ if (segment === "")
27
+ return "path has an empty segment";
28
+ if (segment === "." || segment === "..")
29
+ return "path must not contain . or .. segments";
30
+ }
31
+ return undefined;
32
+ }
33
+ export function isValidPath(path) {
34
+ return invalidPathReason(path) === undefined;
35
+ }
36
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../src/internal/path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,mGAAmG;AACnG,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,UAAU;QAAE,OAAO,2BAA2B,CAAC;IACtF,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,2BAA2B,CAAC;IAC5D,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,+BAA+B,CAAC;IAChE,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,uBAAuB,CAAC;IACzD,sGAAsG;IACtG,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,uBAAuB,CAAC;IAE5D,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACtC,IAAI,OAAO,KAAK,EAAE;YAAE,OAAO,2BAA2B,CAAC;QACvD,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,wCAAwC,CAAC;IAC3F,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Requests to the skill-sync service, signed with this machine's token.
3
+ *
4
+ * Every request goes through `fetchServer`, so a token the server no longer accepts is noticed the same
5
+ * way whichever request hits it first.
6
+ */
7
+ /** The server answered 401: the token was revoked or is unknown, so no retry with it can succeed. */
8
+ export class TokenRejected extends Error {
9
+ token;
10
+ constructor(message, token) {
11
+ super(message);
12
+ this.token = token;
13
+ }
14
+ }
15
+ export function authHeaders(config, extra) {
16
+ return { authorization: `Bearer ${config.token}`, "x-skill-sync-machine": config.machine, ...extra };
17
+ }
18
+ /**
19
+ * Sends one request to the server with the token. Throws `TokenRejected` on 401; every other status is
20
+ * returned for the caller to judge, since some (a 409 from `PUT /files`) are answers rather than failures.
21
+ */
22
+ export async function fetchServer(config, path, init = {}) {
23
+ const response = await fetch(`${config.endpoint}${path}`, {
24
+ ...init,
25
+ headers: authHeaders(config, (init.headers ?? {})),
26
+ });
27
+ if (response.status === 401) {
28
+ throw new TokenRejected(`${init.method ?? "GET"} ${path}: the server rejected this machine's token`, config.token);
29
+ }
30
+ return response;
31
+ }
32
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/internal/server.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,qGAAqG;AACrG,MAAM,OAAO,aAAc,SAAQ,KAAK;IACA;IAAtC,YAAY,OAAe,EAAW,KAAa;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,UAAK,GAAL,KAAK,CAAQ;IAEnD,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,KAA6B;IACvE,OAAO,EAAE,aAAa,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,sBAAsB,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;AACvG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,IAAY,EAAE,OAAoB,EAAE;IACpF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,QAAQ,GAAG,IAAI,EAAE,EAAE;QACxD,GAAG,IAAI;QACP,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAA2B,CAAC;KAC7E,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,aAAa,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,IAAI,IAAI,4CAA4C,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACrH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { existsSync, readFileSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { isSkillName } from "./wire";
4
+ export function checkSkillToAdd(input) {
5
+ const { skill, folders, exclude } = input;
6
+ if (!isSkillName(skill)) {
7
+ return { ok: false, reason: `"${skill}" is not a skill name: lowercase letters and digits in hyphen-joined words, at most 64 characters` };
8
+ }
9
+ if (exclude.includes(skill)) {
10
+ return { ok: false, reason: `"${skill}" is excluded from syncing in ~/.jive/skill-sync.json` };
11
+ }
12
+ const holding = folders.filter((folder) => isDirectory(join(folder, skill)));
13
+ if (holding.length === 0) {
14
+ return {
15
+ ok: false,
16
+ reason: `no skills folder skill-sync syncs has a "${skill}" folder; it looked in ${folders.join(", ") || "no folders"}. `
17
+ + "Only skills meant for every project sync: write the skill into one of those folders. A skill inside a "
18
+ + "project's own skills folder is specific to that project and stays there.",
19
+ };
20
+ }
21
+ for (const folder of holding) {
22
+ const problem = frontmatterProblem(skill, join(folder, skill, "SKILL.md"));
23
+ if (problem !== undefined)
24
+ return { ok: false, reason: problem };
25
+ }
26
+ return { ok: true, folders: holding };
27
+ }
28
+ /** Why a skill's `SKILL.md` would not load as that skill, or undefined when it would. */
29
+ function frontmatterProblem(skill, path) {
30
+ if (!existsSync(path))
31
+ return `${path} does not exist; every skill needs a SKILL.md`;
32
+ const fields = readFrontmatter(readFileSync(path, "utf8"));
33
+ if (fields === undefined)
34
+ return `${path} does not start with a frontmatter block between --- lines`;
35
+ const name = fields.get("name");
36
+ if (name === undefined || name === "")
37
+ return `${path}'s frontmatter has no name`;
38
+ if (name !== skill)
39
+ return `${path}'s frontmatter name is "${name}", but its folder is "${skill}"; they must match`;
40
+ if ((fields.get("description") ?? "") === "")
41
+ return `${path}'s frontmatter has no description, which is how agents decide to load it`;
42
+ return undefined;
43
+ }
44
+ /**
45
+ * The top-level keys of a `SKILL.md`'s frontmatter, with their values as text. Covers what skills use: a
46
+ * plain or quoted value on the key's line, or a block (`>` or `|`) on the indented lines after it.
47
+ */
48
+ export function readFrontmatter(text) {
49
+ const lines = text.replace(/^/, "").split(/\r?\n/);
50
+ if (lines[0]?.trim() !== "---")
51
+ return undefined;
52
+ const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
53
+ if (end === -1)
54
+ return undefined;
55
+ const fields = new Map();
56
+ let blockKey;
57
+ for (const line of lines.slice(1, end)) {
58
+ const field = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
59
+ if (field !== null) {
60
+ const key = field[1];
61
+ const raw = field[2];
62
+ blockKey = /^[>|][+-]?$/.test(raw.trim()) ? key : undefined;
63
+ fields.set(key, blockKey === undefined ? unquote(raw.trim()) : "");
64
+ }
65
+ else if (blockKey !== undefined && /^\s+\S/.test(line)) {
66
+ fields.set(blockKey, `${fields.get(blockKey)} ${line.trim()}`.trim());
67
+ }
68
+ }
69
+ return fields;
70
+ }
71
+ function unquote(value) {
72
+ const quoted = /^(["'])(.*)\1$/.exec(value);
73
+ return quoted === null ? value : quoted[2];
74
+ }
75
+ function isDirectory(path) {
76
+ try {
77
+ return statSync(path).isDirectory();
78
+ }
79
+ catch {
80
+ return false;
81
+ }
82
+ }
83
+ //# sourceMappingURL=skill-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-check.js","sourceRoot":"","sources":["../../../../src/internal/skill-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,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;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,183 @@
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { hashBytes, isLock, listLocalFiles } from "./config";
4
+ import { invalidPathReason } from "./path";
5
+ import { fetchServer } from "./server";
6
+ import { skillOf } from "./wire";
7
+ /** True when a report has nothing in it worth telling anyone. */
8
+ export function isQuiet(report) {
9
+ return [report.pulled, report.pushed, report.deletedLocally, report.rejected].every((list) => list.length === 0);
10
+ }
11
+ /**
12
+ * What a cycle changed, as the dashboard shows it under the folder: per direction, how many files in
13
+ * which skills ("pulled 64 files: agentic-collaboration 52, senior-swe 12"), never the file paths, which
14
+ * after a large pull fill the page. Empty when nothing changed.
15
+ */
16
+ export function describeActivity(report) {
17
+ const direction = (verb, paths) => {
18
+ if (paths.length === 0)
19
+ return "";
20
+ const perSkill = new Map();
21
+ for (const path of paths)
22
+ perSkill.set(skillOf(path), (perSkill.get(skillOf(path)) ?? 0) + 1);
23
+ const skills = [...perSkill].sort(([a], [b]) => a.localeCompare(b)).map(([skill, files]) => `${skill} ${files}`);
24
+ return `${verb} ${paths.length} ${paths.length === 1 ? "file" : "files"}: ${skills.join(", ")}`;
25
+ };
26
+ return [
27
+ direction("pulled", report.pulled),
28
+ direction("pushed", report.pushed),
29
+ direction("deleted", report.deletedLocally),
30
+ ].filter(Boolean).join("; ");
31
+ }
32
+ /**
33
+ * `skills` is the synced list. Every other skill in the folder is local to it: never pushed, never
34
+ * overwritten, never deleted by a sync.
35
+ */
36
+ export async function syncOnce(config, folder, state, skills) {
37
+ const report = { pulled: [], pushed: [], deletedLocally: [], rejected: [] };
38
+ mkdirSync(folder, { recursive: true });
39
+ // A skill added to the list since last cycle may have server files older than the cursor; re-read from the start.
40
+ if ([...skills].some((skill) => !(state.skills ?? []).includes(skill)))
41
+ state.cursor = 0;
42
+ state.skills = [...skills].sort();
43
+ // A skill removed from the list stops being tracked here. Left in `known`, its files would look deleted
44
+ // from this folder and the push would delete them on every machine.
45
+ for (const path of Object.keys(state.known)) {
46
+ if (!skills.has(skillOf(path)) || path.split("/").some(isLock))
47
+ delete state.known[path];
48
+ }
49
+ const present = new Set(listLocalFiles(folder, config.exclude).filter((path) => skills.has(skillOf(path))));
50
+ // Files deleted here since the last cycle. When they were deleted is not recorded anywhere, so the
51
+ // deletion counts as an edit made now: the pull leaves these paths alone and the push deletes them.
52
+ const deletedHere = new Set(Object.keys(state.known).filter((path) => !present.has(path)));
53
+ const ctx = { config, folder, state, report, skills };
54
+ await pull(ctx, deletedHere, present);
55
+ await push(ctx, present);
56
+ return report;
57
+ }
58
+ /** When this file was last edited here, to the millisecond the server stores. */
59
+ const editedAt = (file) => Math.floor(statSync(file).mtimeMs);
60
+ async function pull(ctx, deletedHere, present) {
61
+ const { config, folder, state, report } = ctx;
62
+ const body = await (await call(config, `/files?since=${state.cursor}`)).json();
63
+ for (const file of body.files) {
64
+ // The server is not trusted to supply a path either: one bad row would otherwise write outside the
65
+ // skills directory on every machine that syncs.
66
+ const badPath = invalidPathReason(file.path);
67
+ if (badPath) {
68
+ report.rejected.push(`${file.path} (${badPath})`);
69
+ continue;
70
+ }
71
+ if (!ctx.skills.has(skillOf(file.path)))
72
+ continue;
73
+ // Never written here: the file listing skips lock names, so a pulled one would read as deleted next cycle.
74
+ if (file.path.split("/").some(isLock))
75
+ continue;
76
+ // Deleted here, which is newer than anything the server has; the push sends the deletion.
77
+ if (deletedHere.has(file.path))
78
+ continue;
79
+ const local = join(folder, file.path);
80
+ const exists = existsSync(local);
81
+ const localHash = exists ? hashBytes(readFileSync(local)) : undefined;
82
+ if (localHash === (file.hash ?? undefined)) {
83
+ if (file.hash === null)
84
+ delete state.known[file.path];
85
+ else
86
+ state.known[file.path] = file.hash;
87
+ continue;
88
+ }
89
+ // Edited here since this folder last agreed with the server, and later than the server's version:
90
+ // this folder's edit wins, and the push sends it.
91
+ if (exists && localHash !== state.known[file.path] && editedAt(local) > file.editedAt)
92
+ continue;
93
+ await apply(ctx, file, present);
94
+ }
95
+ state.cursor = body.cursor;
96
+ }
97
+ async function push(ctx, present) {
98
+ const { config, folder, state, report } = ctx;
99
+ for (const path of [...present]) {
100
+ const file = join(folder, path);
101
+ const bytes = readFileSync(file);
102
+ const hash = hashBytes(bytes);
103
+ if (state.known[path] === hash)
104
+ continue;
105
+ const later = await put(config, { path, hash, content: Buffer.from(bytes).toString("base64"), editedAt: editedAt(file) });
106
+ if (later === undefined) {
107
+ state.known[path] = hash;
108
+ report.pushed.push(path);
109
+ }
110
+ else {
111
+ await apply(ctx, { path, ...later }, present);
112
+ }
113
+ }
114
+ // A path this folder agreed on that is no longer on disk was deleted here. The server keeps the
115
+ // deletion, or the next machine to sync would upload the file again.
116
+ for (const path of Object.keys(state.known)) {
117
+ if (present.has(path))
118
+ continue;
119
+ const later = await put(config, { path, hash: null, content: null, editedAt: Date.now() });
120
+ if (later === undefined) {
121
+ delete state.known[path];
122
+ report.pushed.push(`${path} (deleted)`);
123
+ }
124
+ else {
125
+ await apply(ctx, { path, ...later }, present);
126
+ }
127
+ }
128
+ }
129
+ /**
130
+ * Writes the server's version of a file here: its bytes with its edit time, or a deletion. Used by the
131
+ * pull, and by the push when the server refuses a write because it holds a later edit, so a refused write
132
+ * settles at once rather than waiting for a pull that may never list the file again.
133
+ */
134
+ async function apply(ctx, file, present) {
135
+ const { config, folder, state, report } = ctx;
136
+ const local = join(folder, file.path);
137
+ if (file.hash === null) {
138
+ rmSync(local, { force: true });
139
+ removeEmptyParents(folder, local);
140
+ present.delete(file.path);
141
+ delete state.known[file.path];
142
+ report.deletedLocally.push(file.path);
143
+ return;
144
+ }
145
+ const content = new Uint8Array(await (await call(config, `/content/${file.hash}`)).arrayBuffer());
146
+ mkdirSync(dirname(local), { recursive: true });
147
+ writeFileSync(local, content);
148
+ utimesSync(local, new Date(), new Date(file.editedAt));
149
+ state.known[file.path] = file.hash;
150
+ present.add(file.path);
151
+ report.pulled.push(file.path);
152
+ }
153
+ /** A deleted skill leaves no empty directory behind, which would still show up as a skill. */
154
+ function removeEmptyParents(folder, file) {
155
+ for (let dir = dirname(file); dir !== folder && dir.startsWith(folder); dir = dirname(dir)) {
156
+ if (readdirSync(dir).length > 0)
157
+ return;
158
+ rmdirSync(dir);
159
+ }
160
+ }
161
+ /** Undefined when the server took the write; otherwise the later version it holds instead. */
162
+ async function put(config, body) {
163
+ const request = { ...body, machine: config.machine };
164
+ const response = await fetchServer(config, "/files", {
165
+ method: "PUT",
166
+ headers: { "content-type": "application/json" },
167
+ body: JSON.stringify(request),
168
+ });
169
+ if (response.status === 409) {
170
+ const current = await response.json();
171
+ return { hash: current.currentHash, editedAt: current.currentEditedAt };
172
+ }
173
+ if (!response.ok)
174
+ throw new Error(`PUT /files ${body.path}: ${response.status} ${await response.text()}`);
175
+ return undefined;
176
+ }
177
+ async function call(config, path) {
178
+ const response = await fetchServer(config, path);
179
+ if (!response.ok)
180
+ throw new Error(`GET ${path}: ${response.status} ${await response.text()}`);
181
+ return response;
182
+ }
183
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/internal/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnI,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAA2B,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,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E,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAA6D,CAAC;QACjG,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC1G,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,IAAI,CAAC,MAAc,EAAE,IAAY;IAC9C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,MAAM,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9F,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,24 @@
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
+ * A skill is a top-level entry of a skills folder — usually a directory like `jive/` holding `SKILL.md`
9
+ * and its files — and it is the unit of opting in: all of its files sync, or none do, so a skill never
10
+ * arrives half-present on another machine.
11
+ */
12
+ export const skillOf = (path) => path.split("/")[0];
13
+ /**
14
+ * Whether a name can be a skill's: lowercase letters and digits in hyphen-joined words, at most 64
15
+ * characters, which is what Claude, Codex and Grok accept as a skill name. The daemon checks it before
16
+ * asking, and the service again before writing, so both judge a name by this one rule.
17
+ */
18
+ export const isSkillName = (name) => name.length <= 64 && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name);
19
+ /**
20
+ * The header a daemon names its own version in when it opens its WebSocket to the hub, so the dashboard
21
+ * can show which version each machine runs. Daemons before 0.4.6 do not send it.
22
+ */
23
+ export const DAEMON_VERSION_HEADER = "x-skill-sync-version";
24
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../../src/internal/wire.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;AA8BrE;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,IAAI,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAoBnH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC"}