@jive-sh/skill-sync 0.8.1 → 0.8.2-latest-darwin-x64

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 (110) hide show
  1. package/multi-call-binary +4 -0
  2. package/package.json +11 -45
  3. package/README.md +0 -205
  4. package/bin/package.json +0 -1
  5. package/bin/skill-sync +0 -34
  6. package/bin/skill-sync-daemon +0 -34
  7. package/dist/daemons/skill-sync-daemon.js +0 -640
  8. package/dist/daemons/skill-sync-daemon.js.map +0 -1
  9. package/dist/entrypoints/skill-sync.js +0 -7
  10. package/dist/entrypoints/skill-sync.js.map +0 -1
  11. package/dist/index.js +0 -10
  12. package/dist/index.js.map +0 -1
  13. package/dist/internal/agents/agent-tool.js +0 -102
  14. package/dist/internal/agents/agent-tool.js.map +0 -1
  15. package/dist/internal/agents/claude.js +0 -424
  16. package/dist/internal/agents/claude.js.map +0 -1
  17. package/dist/internal/agents/codex.js +0 -270
  18. package/dist/internal/agents/codex.js.map +0 -1
  19. package/dist/internal/agents/command.js +0 -219
  20. package/dist/internal/agents/command.js.map +0 -1
  21. package/dist/internal/agents/grok.js +0 -170
  22. package/dist/internal/agents/grok.js.map +0 -1
  23. package/dist/internal/agents/index.js +0 -70
  24. package/dist/internal/agents/index.js.map +0 -1
  25. package/dist/internal/cli.js +0 -185
  26. package/dist/internal/cli.js.map +0 -1
  27. package/dist/internal/config.js +0 -131
  28. package/dist/internal/config.js.map +0 -1
  29. package/dist/internal/control.js +0 -113
  30. package/dist/internal/control.js.map +0 -1
  31. package/dist/internal/daemon-control/impl.js +0 -68
  32. package/dist/internal/daemon-control/impl.js.map +0 -1
  33. package/dist/internal/daemon-control/interface.js +0 -4
  34. package/dist/internal/daemon-control/interface.js.map +0 -1
  35. package/dist/internal/folders.js +0 -47
  36. package/dist/internal/folders.js.map +0 -1
  37. package/dist/internal/local-skills.js +0 -43
  38. package/dist/internal/local-skills.js.map +0 -1
  39. package/dist/internal/path.js +0 -36
  40. package/dist/internal/path.js.map +0 -1
  41. package/dist/internal/server.js +0 -80
  42. package/dist/internal/server.js.map +0 -1
  43. package/dist/internal/skill-check.js +0 -83
  44. package/dist/internal/skill-check.js.map +0 -1
  45. package/dist/internal/skill-refinement/evals/cases.js +0 -143
  46. package/dist/internal/skill-refinement/evals/cases.js.map +0 -1
  47. package/dist/internal/skill-refinement/evals/opus-action-judge-original.json +0 -350
  48. package/dist/internal/skill-refinement/evals/opus-judge-original.json +0 -165
  49. package/dist/internal/skill-refinement/feedback/intake.js +0 -52
  50. package/dist/internal/skill-refinement/feedback/intake.js.map +0 -1
  51. package/dist/internal/skill-refinement/jev/impl.js +0 -63
  52. package/dist/internal/skill-refinement/jev/impl.js.map +0 -1
  53. package/dist/internal/skill-refinement/jev/interface.js +0 -6
  54. package/dist/internal/skill-refinement/jev/interface.js.map +0 -1
  55. package/dist/internal/skill-refinement/paths.js +0 -62
  56. package/dist/internal/skill-refinement/paths.js.map +0 -1
  57. package/dist/internal/skill-refinement/platform.js +0 -67
  58. package/dist/internal/skill-refinement/platform.js.map +0 -1
  59. package/dist/internal/skill-refinement/service.js +0 -255
  60. package/dist/internal/skill-refinement/service.js.map +0 -1
  61. package/dist/internal/skill-refinement/skills/skill-text.js +0 -217
  62. package/dist/internal/skill-refinement/skills/skill-text.js.map +0 -1
  63. package/dist/internal/skill-refinement/workflow/retry.js +0 -69
  64. package/dist/internal/skill-refinement/workflow/retry.js.map +0 -1
  65. package/dist/internal/skill-refinement/workflow/skill-refinement.js +0 -595
  66. package/dist/internal/skill-refinement/workflow/skill-refinement.js.map +0 -1
  67. package/dist/internal/skill-refinement/writer/impl.js +0 -74
  68. package/dist/internal/skill-refinement/writer/impl.js.map +0 -1
  69. package/dist/internal/skill-refinement/writer/interface.js +0 -6
  70. package/dist/internal/skill-refinement/writer/interface.js.map +0 -1
  71. package/dist/internal/sync.js +0 -182
  72. package/dist/internal/sync.js.map +0 -1
  73. package/dist/internal/wire.js +0 -31
  74. package/dist/internal/wire.js.map +0 -1
  75. package/postinstall.cjs +0 -663
  76. package/src/daemons/skill-sync-daemon.ts +0 -645
  77. package/src/entrypoints/skill-sync.ts +0 -12
  78. package/src/index.ts +0 -15
  79. package/src/internal/agents/agent-tool.ts +0 -149
  80. package/src/internal/agents/claude.ts +0 -442
  81. package/src/internal/agents/codex.ts +0 -288
  82. package/src/internal/agents/command.ts +0 -257
  83. package/src/internal/agents/grok.ts +0 -174
  84. package/src/internal/agents/index.ts +0 -74
  85. package/src/internal/cli.ts +0 -217
  86. package/src/internal/config.ts +0 -172
  87. package/src/internal/control.ts +0 -157
  88. package/src/internal/daemon-control/impl.ts +0 -80
  89. package/src/internal/daemon-control/interface.ts +0 -40
  90. package/src/internal/folders.ts +0 -50
  91. package/src/internal/local-skills.ts +0 -58
  92. package/src/internal/path.ts +0 -32
  93. package/src/internal/server.ts +0 -76
  94. package/src/internal/skill-check.ts +0 -97
  95. package/src/internal/skill-refinement/evals/cases.ts +0 -167
  96. package/src/internal/skill-refinement/evals/opus-action-judge-original.json +0 -350
  97. package/src/internal/skill-refinement/evals/opus-judge-original.json +0 -165
  98. package/src/internal/skill-refinement/feedback/intake.ts +0 -66
  99. package/src/internal/skill-refinement/jev/impl.ts +0 -76
  100. package/src/internal/skill-refinement/jev/interface.ts +0 -56
  101. package/src/internal/skill-refinement/paths.ts +0 -87
  102. package/src/internal/skill-refinement/platform.ts +0 -71
  103. package/src/internal/skill-refinement/service.ts +0 -301
  104. package/src/internal/skill-refinement/skills/skill-text.ts +0 -290
  105. package/src/internal/skill-refinement/workflow/retry.ts +0 -76
  106. package/src/internal/skill-refinement/workflow/skill-refinement.ts +0 -667
  107. package/src/internal/skill-refinement/writer/impl.ts +0 -86
  108. package/src/internal/skill-refinement/writer/interface.ts +0 -34
  109. package/src/internal/sync.ts +0 -216
  110. package/src/internal/wire.ts +0 -439
@@ -1,86 +0,0 @@
1
- import { OutsideServiceUnavailable } from '@jive-sh/workflow-platform';
2
- import { Effect, Layer, Schema } from 'effect';
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { Writer, WriterError, type IWriter, type Written } from './interface';
6
-
7
- /** Claude's own words where it could not do the work: "You've hit your weekly limit · resets 6am (UTC)", a 429, a 529. */
8
- const CLAUDE_UNAVAILABLE = /hit your .*limit|usage limit|rate limit|overloaded/i;
9
- /** Claude's failure `text`: an outside one where its words say it could not do the work, else `WriterError` with `reason`. */
10
- export const claudeFailure = (input: { readonly text: string; readonly reason: string }): WriterError | OutsideServiceUnavailable =>
11
- CLAUDE_UNAVAILABLE.test(input.text) ? new OutsideServiceUnavailable({ service: 'claude', reason: input.text.slice(0, 600) }) : new WriterError({ reason: input.reason });
12
-
13
- /** Which Claude account and model the calls run on, and where each call's system prompt file is written. */
14
- export interface WriterConfig {
15
- /** The `claude` CLI to run: found where its installers put it, since the daemon runs with the service manager's PATH. */
16
- readonly claudeCommand: string;
17
- /** The Claude Code config folder whose sign-in the calls use (`CLAUDE_CONFIG_DIR`): it decides which account pays. */
18
- readonly claudeConfigDir: string;
19
- readonly model: string;
20
- readonly scratch: string;
21
- }
22
-
23
- /** `claude -p --output-format json`'s result, the fields this module reads. */
24
- const ClaudeResult = Schema.Struct({
25
- is_error: Schema.Boolean,
26
- result: Schema.String,
27
- total_cost_usd: Schema.Finite,
28
- usage: Schema.Struct({
29
- input_tokens: Schema.Finite,
30
- cache_read_input_tokens: Schema.Finite,
31
- cache_creation_input_tokens: Schema.Finite,
32
- output_tokens: Schema.Finite,
33
- }),
34
- });
35
- const decodeResult = Schema.decodeUnknownEffect(Schema.fromJsonString(ClaudeResult));
36
-
37
- class ClaudeCliWriter implements IWriter {
38
- constructor(private readonly config: WriterConfig) {}
39
-
40
- *write(input: { readonly system: string; readonly prompt: string }): Effect.fn.Return<Written, WriterError | OutsideServiceUnavailable> {
41
- const { config } = this;
42
- // The system prompt goes in a file: a skill is longer than an argument should carry.
43
- const systemFile = path.join(config.scratch, `system-${Bun.hash(input.system).toString(36)}.md`);
44
- yield* Effect.try({
45
- try: () => { fs.mkdirSync(config.scratch, { recursive: true }); if (!fs.existsSync(systemFile)) fs.writeFileSync(systemFile, input.system); },
46
- catch: (e) => new WriterError({ reason: `the system prompt file could not be written: ${String(e)}` }),
47
- });
48
- const out = yield* Effect.tryPromise({
49
- try: async () => {
50
- const proc = Bun.spawn(
51
- [config.claudeCommand, '-p', input.prompt, '--model', config.model, '--setting-sources', '', '--tools', '', '--no-session-persistence', '--output-format', 'json', '--system-prompt-file', systemFile],
52
- { cwd: config.scratch, stdout: 'pipe', stderr: 'pipe', env: childEnv(config.claudeConfigDir) },
53
- );
54
- const [stdout, stderr, code] = await Promise.all([new Response(proc.stdout).text(), new Response(proc.stderr).text(), proc.exited]);
55
- return { stdout, stderr, code };
56
- },
57
- catch: (e) => new WriterError({ reason: `claude could not start: ${String(e)}` }),
58
- });
59
- const parsed = yield* Effect.mapError(decodeResult(out.stdout), () => claudeFailure({ text: out.stdout + out.stderr, reason: `claude exited ${out.code}: ${(out.stdout + out.stderr).slice(0, 600)}` }));
60
- if (parsed.is_error) return yield* Effect.fail(claudeFailure({ text: parsed.result, reason: `claude failed: ${parsed.result.slice(0, 600)}` }));
61
- return {
62
- text: parsed.result,
63
- spend: {
64
- model: config.model,
65
- inputTokens: parsed.usage.input_tokens,
66
- cacheReadTokens: parsed.usage.cache_read_input_tokens,
67
- cacheWriteTokens: parsed.usage.cache_creation_input_tokens,
68
- outputTokens: parsed.usage.output_tokens,
69
- costUsd: parsed.total_cost_usd,
70
- },
71
- };
72
- }
73
- }
74
-
75
- export const WriterLive = (config: WriterConfig) => Layer.succeed(Writer, new ClaudeCliWriter(config));
76
-
77
- /**
78
- * The service's own environment with the account set, and none of the variables a running Claude Code session gives the
79
- * processes it starts: a call made from inside a session would otherwise act as part of it.
80
- */
81
- const childEnv = (claudeConfigDir: string): Record<string, string> => {
82
- const env: Record<string, string> = {};
83
- for (const [k, v] of Object.entries(process.env)) if (v !== undefined && !k.startsWith('CLAUDE_CODE') && k !== 'CLAUDECODE') env[k] = v;
84
- env["CLAUDE_CONFIG_DIR"] = claudeConfigDir;
85
- return env;
86
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * THE GENERATIVE MODEL, for the steps that must write text: drafting a skill edit and writing a reply under a skill
3
- * version. Each call is a fresh, small request with only the text the step gives it: no tools, no settings, no history.
4
- */
5
- import type { OutsideServiceUnavailable } from '@jive-sh/workflow-platform';
6
- import { Context, Data, type Effect } from 'effect';
7
-
8
- /** What one call spent, as the model's API reported it, and its list price. */
9
- export interface WriterSpend {
10
- readonly model: string;
11
- readonly inputTokens: number;
12
- readonly cacheReadTokens: number;
13
- readonly cacheWriteTokens: number;
14
- readonly outputTokens: number;
15
- readonly costUsd: number;
16
- }
17
-
18
- export interface Written {
19
- readonly text: string;
20
- readonly spend: WriterSpend;
21
- }
22
-
23
- export class WriterError extends Data.TaggedError('WriterError')<{ readonly reason: string }> {}
24
-
25
- export interface IWriter {
26
- /**
27
- * `system` is the rules the text is written under (a skill version); `prompt` the one request. Fails with
28
- * `OutsideServiceUnavailable` where Claude could not do the work (a usage or rate limit, an overload), which the workflow
29
- * platform counts as no try; with `WriterError` for any other failure.
30
- */
31
- readonly write: (input: { readonly system: string; readonly prompt: string }) => Effect.fn.Return<Written, WriterError | OutsideServiceUnavailable>;
32
- }
33
-
34
- export class Writer extends Context.Service<Writer, IWriter>()('Writer') {}
@@ -1,216 +0,0 @@
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, type Config, type State } from "./config";
4
- import { invalidPathReason } from "./path";
5
- import { fetchServer } from "./server";
6
- import { skillOf, type ListFilesResponse, type PutFileRequest } from "./wire";
7
-
8
- /**
9
- * One sync cycle: take every newer edit the server has, then send every newer edit this folder has.
10
- *
11
- * The latest edit wins, always. Every file carries the time it was last edited: here, the file's
12
- * modification time; on the server, the edit time of the version it holds. When this folder and the
13
- * server disagree about a file, whichever was edited later is kept, on both sides. Nothing is merged and
14
- * nothing is set aside, so every folder converges on the same bytes.
15
- *
16
- * A pulled file is given the server's edit time as its modification time, so the next cycle does not
17
- * mistake the pull for a local edit.
18
- */
19
-
20
- export interface Report {
21
- readonly pulled: string[];
22
- readonly pushed: string[];
23
- readonly deletedLocally: string[];
24
- /** Paths the server offered that this machine refused to write. */
25
- readonly rejected: string[];
26
- }
27
-
28
- /** True when a report has nothing in it worth telling anyone. */
29
- export function isQuiet(report: Report): boolean {
30
- return [report.pulled, report.pushed, report.deletedLocally, report.rejected].every((list) => list.length === 0);
31
- }
32
-
33
- /**
34
- * What a cycle changed, as the dashboard shows it under the folder: per direction, how many files in
35
- * which skills ("pulled 64 files: agentic-collaboration 52, senior-swe 12"), never the file paths, which
36
- * after a large pull fill the page. Empty when nothing changed.
37
- */
38
- export function describeActivity(report: Report): string {
39
- const direction = (verb: string, paths: ReadonlyArray<string>): string => {
40
- if (paths.length === 0) return "";
41
- const perSkill = new Map<string, number>();
42
- for (const path of paths) perSkill.set(skillOf(path), (perSkill.get(skillOf(path)) ?? 0) + 1);
43
- const skills = [...perSkill].sort(([a], [b]) => a.localeCompare(b)).map(([skill, files]) => `${skill} ${files}`);
44
- return `${verb} ${paths.length} ${paths.length === 1 ? "file" : "files"}: ${skills.join(", ")}`;
45
- };
46
- return [
47
- direction("pulled", report.pulled),
48
- direction("pushed", report.pushed),
49
- direction("deleted", report.deletedLocally),
50
- ].filter(Boolean).join("; ");
51
- }
52
-
53
- /**
54
- * `skills` is the synced list. Every other skill in the folder is local to it: never pushed, never
55
- * overwritten, never deleted by a sync.
56
- */
57
- export async function syncOnce(config: Config, folder: string, state: State, skills: ReadonlySet<string>): Promise<Report> {
58
- const report: Report = { pulled: [], pushed: [], deletedLocally: [], rejected: [] };
59
- mkdirSync(folder, { recursive: true });
60
-
61
- // A skill added to the list since last cycle may have server files older than the cursor; re-read from the start.
62
- if ([...skills].some((skill) => !(state.skills ?? []).includes(skill))) state.cursor = 0;
63
- state.skills = [...skills].sort();
64
- // A skill removed from the list stops being tracked here. Left in `known`, its files would look deleted
65
- // from this folder and the push would delete them on every machine.
66
- for (const path of Object.keys(state.known)) {
67
- if (!skills.has(skillOf(path)) || path.split("/").some(isLock)) delete state.known[path];
68
- }
69
-
70
- const present = new Set(listLocalFiles(folder, config.exclude).filter((path) => skills.has(skillOf(path))));
71
- // Files deleted here since the last cycle. When they were deleted is not recorded anywhere, so the
72
- // deletion counts as an edit made now: the pull leaves these paths alone and the push deletes them.
73
- const deletedHere = new Set(Object.keys(state.known).filter((path) => !present.has(path)));
74
-
75
- const ctx: Cycle = { config, folder, state, report, skills };
76
- await pull(ctx, deletedHere, present);
77
- await push(ctx, present);
78
- return report;
79
- }
80
-
81
- interface Cycle {
82
- readonly config: Config;
83
- readonly folder: string;
84
- readonly state: State;
85
- readonly report: Report;
86
- readonly skills: ReadonlySet<string>;
87
- }
88
-
89
- /** When this file was last edited here, to the millisecond the server stores. */
90
- const editedAt = (file: string): number => Math.floor(statSync(file).mtimeMs);
91
-
92
- async function pull(ctx: Cycle, deletedHere: ReadonlySet<string>, present: Set<string>): Promise<void> {
93
- const { config, folder, state, report } = ctx;
94
- const body = await (await call(config, `/files?since=${state.cursor}`)).json() as ListFilesResponse;
95
-
96
- for (const file of body.files) {
97
- // The server is not trusted to supply a path either: one bad row would otherwise write outside the
98
- // skills directory on every machine that syncs.
99
- const badPath = invalidPathReason(file.path);
100
- if (badPath) {
101
- report.rejected.push(`${file.path} (${badPath})`);
102
- continue;
103
- }
104
- if (!ctx.skills.has(skillOf(file.path))) continue;
105
- // Never written here: the file listing skips lock names, so a pulled one would read as deleted next cycle.
106
- if (file.path.split("/").some(isLock)) continue;
107
- // Deleted here, which is newer than anything the server has; the push sends the deletion.
108
- if (deletedHere.has(file.path)) continue;
109
-
110
- const local = join(folder, file.path);
111
- const exists = existsSync(local);
112
- const localHash = exists ? hashBytes(readFileSync(local)) : undefined;
113
- if (localHash === (file.hash ?? undefined)) {
114
- if (file.hash === null) delete state.known[file.path];
115
- else state.known[file.path] = file.hash;
116
- continue;
117
- }
118
- // Edited here since this folder last agreed with the server, and later than the server's version:
119
- // this folder's edit wins, and the push sends it.
120
- if (exists && localHash !== state.known[file.path] && editedAt(local) > file.editedAt) continue;
121
-
122
- await apply(ctx, file, present);
123
- }
124
-
125
- state.cursor = body.cursor;
126
- }
127
-
128
- async function push(ctx: Cycle, present: Set<string>): Promise<void> {
129
- const { config, folder, state, report } = ctx;
130
- for (const path of [...present]) {
131
- const file = join(folder, path);
132
- const bytes = readFileSync(file);
133
- const hash = hashBytes(bytes);
134
- if (state.known[path] === hash) continue;
135
- const later = await put(config, { path, hash, content: Buffer.from(bytes).toString("base64"), editedAt: editedAt(file) });
136
- if (later === undefined) {
137
- state.known[path] = hash;
138
- report.pushed.push(path);
139
- } else {
140
- await apply(ctx, { path, ...later }, present);
141
- }
142
- }
143
-
144
- // A path this folder agreed on that is no longer on disk was deleted here. The server keeps the
145
- // deletion, or the next machine to sync would upload the file again.
146
- for (const path of Object.keys(state.known)) {
147
- if (present.has(path)) continue;
148
- const later = await put(config, { path, hash: null, content: null, editedAt: Date.now() });
149
- if (later === undefined) {
150
- delete state.known[path];
151
- report.pushed.push(`${path} (deleted)`);
152
- } else {
153
- await apply(ctx, { path, ...later }, present);
154
- }
155
- }
156
- }
157
-
158
- /** The server's version of a file, as it answers a refused write. */
159
- interface ServerVersion {
160
- readonly hash: string | null;
161
- readonly editedAt: number;
162
- }
163
-
164
- /**
165
- * Writes the server's version of a file here: its bytes with its edit time, or a deletion. Used by the
166
- * pull, and by the push when the server refuses a write because it holds a later edit, so a refused write
167
- * settles at once rather than waiting for a pull that may never list the file again.
168
- */
169
- async function apply(ctx: Cycle, file: ServerVersion & { readonly path: string }, present: Set<string>): Promise<void> {
170
- const { config, folder, state, report } = ctx;
171
- const local = join(folder, file.path);
172
- if (file.hash === null) {
173
- rmSync(local, { force: true });
174
- removeEmptyParents(folder, local);
175
- present.delete(file.path);
176
- delete state.known[file.path];
177
- report.deletedLocally.push(file.path);
178
- return;
179
- }
180
- const content = new Uint8Array(await (await call(config, `/content/${file.hash}`)).arrayBuffer());
181
- mkdirSync(dirname(local), { recursive: true });
182
- writeFileSync(local, content);
183
- utimesSync(local, new Date(), new Date(file.editedAt));
184
- state.known[file.path] = file.hash;
185
- present.add(file.path);
186
- report.pulled.push(file.path);
187
- }
188
-
189
- /** A deleted skill leaves no empty directory behind, which would still show up as a skill. */
190
- function removeEmptyParents(folder: string, file: string): void {
191
- for (let dir = dirname(file); dir !== folder && dir.startsWith(folder); dir = dirname(dir)) {
192
- if (readdirSync(dir).length > 0) return;
193
- rmdirSync(dir);
194
- }
195
- }
196
-
197
- /** Undefined when the server took the write; otherwise the later version it holds instead. */
198
- async function put(config: Config, request: PutFileRequest): Promise<ServerVersion | undefined> {
199
- const response = await fetchServer(config, "/files", {
200
- method: "PUT",
201
- headers: { "content-type": "application/json" },
202
- body: JSON.stringify(request),
203
- });
204
- if (response.status === 409) {
205
- const current = await response.json() as { currentHash: string | null; currentEditedAt: number };
206
- return { hash: current.currentHash, editedAt: current.currentEditedAt };
207
- }
208
- if (!response.ok) throw new Error(`PUT /files ${request.path}: ${response.status} ${await response.text()}`);
209
- return undefined;
210
- }
211
-
212
- async function call(config: Config, path: string): Promise<Response> {
213
- const response = await fetchServer(config, path);
214
- if (!response.ok) throw new Error(`GET ${path}: ${response.status} ${await response.text()}`);
215
- return response;
216
- }