@eliya-oss/agent-diff 0.1.0-alpha.49 → 0.1.0-alpha.50

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.50
4
+
5
+ ### Patch Changes
6
+
7
+ - `adiff upgrade` says the command it ran and the version it landed on, and stops there. It used to open with which package manager installed the build, which registry tag mattered and what it was about to do, which is four paragraphs standing between you and the one fact you asked for. Upgrading now also rewrites the adiff skill wherever it is already installed, so an agent is not left reading last month's instructions; `adiff skill refresh` does that on its own, and neither installs a skill that was not already there.
8
+
3
9
  ## 0.1.0-alpha.49
4
10
 
5
11
  ### Patch Changes
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { appendFile, mkdir, readFile, realpath, writeFile } from "node:fs/promises";
3
+ import { homedir, hostname, platform } from "node:os";
3
4
  import { text } from "node:stream/consumers";
4
5
  import { dirname, join, resolve } from "node:path";
5
6
  import { execFile, spawn } from "node:child_process";
6
7
  import { promisify } from "node:util";
7
- import { homedir, hostname, platform } from "node:os";
8
- import { existsSync, mkdirSync, readFileSync, watch } from "node:fs";
8
+ import { existsSync, mkdirSync, readFileSync, realpathSync, watch } from "node:fs";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, LineNumberRenderable, RGBA, SelectRenderable, StyledText, SyntaxStyle, TextRenderable, bg, createCliRenderer, fg, getTreeSitterClient, pathToFiletype, t } from "@opentui/core";
11
11
  //#region \0rolldown/runtime.js
@@ -8978,7 +8978,7 @@ var init_commands = __esmMin((() => {
8978
8978
  }));
8979
8979
  //#endregion
8980
8980
  //#region src/cli/init.ts
8981
- var BEGIN, END, REACH, INSTRUCTIONS, IMPORT, blockIn, replaced, appended, planFor, readAt, writeAt, settle, skillSource, shippedSkill, settleSkill, initRepository;
8981
+ var BEGIN, END, REACH, INSTRUCTIONS, IMPORT, blockIn, replaced, appended, planFor, readAt, writeAt, settle, skillSource, shippedSkill, settleSkill, SKILL_AT, refreshAt, settledRoot, refreshSkill, initRepository;
8982
8982
  var init_init = __esmMin((() => {
8983
8983
  init_dist();
8984
8984
  init_error$1();
@@ -9082,6 +9082,35 @@ var init_init = __esmMin((() => {
9082
9082
  action
9083
9083
  };
9084
9084
  });
9085
+ SKILL_AT = join(".claude", "skills", "adiff", "SKILL.md");
9086
+ refreshAt = fn("Cli.refreshAt")(function* (root, wanted) {
9087
+ const path = join(root, SKILL_AT);
9088
+ if (!existsSync(path)) return [];
9089
+ const current = yield* readAt(path);
9090
+ if (getOrUndefined$1(current) === wanted) return [{
9091
+ path,
9092
+ action: "unchanged"
9093
+ }];
9094
+ yield* writeAt(path, wanted);
9095
+ return [{
9096
+ path,
9097
+ action: "update"
9098
+ }];
9099
+ });
9100
+ settledRoot = (root) => {
9101
+ try {
9102
+ return realpathSync(root);
9103
+ } catch {
9104
+ return root;
9105
+ }
9106
+ };
9107
+ refreshSkill = fn("Cli.refreshSkill")(function* (roots) {
9108
+ const wanted = yield* shippedSkill();
9109
+ const seen = [...new Set(roots.map(settledRoot))];
9110
+ const found = [];
9111
+ for (const root of seen) found.push(...yield* refreshAt(root, wanted));
9112
+ return { changes: found };
9113
+ });
9085
9114
  initRepository = fn("Cli.initRepository")(function* (request) {
9086
9115
  const instructions = yield* settle(request.repo, "AGENTS.md", INSTRUCTIONS, request.write);
9087
9116
  const memory = yield* settle(request.repo, "CLAUDE.md", IMPORT, request.write);
@@ -9201,10 +9230,10 @@ var init_pane = __esmMin((() => {
9201
9230
  init_commands();
9202
9231
  init_init();
9203
9232
  init_pane();
9204
- var version$1 = "0.1.0-alpha.49";
9233
+ var version$1 = "0.1.0-alpha.50";
9205
9234
  //#endregion
9206
9235
  //#region src/cli/upgrade.ts
9207
- var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, REFUSALS, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, refusalOf, OFFER, sayFound, sayDone, attempted, upgradeReport;
9236
+ var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
9208
9237
  var init_upgrade$1 = __esmMin((() => {
9209
9238
  init_dist();
9210
9239
  PACKAGE = "@eliya-oss/agent-diff";
@@ -9241,15 +9270,11 @@ var init_upgrade$1 = __esmMin((() => {
9241
9270
  return `curl -fsSL ${RELEASES}/download/${assetOf()} -o ${executable} && chmod +x ${executable}`;
9242
9271
  };
9243
9272
  NOTES = {
9244
- brew: "Homebrew installed this build, so Homebrew replaces it.",
9245
- npm: `npm installed this build, so npm replaces it. The ${TAG} tag matters: the latest tag on the registry still points at an old build.`,
9246
- bun: `bun installed this build, so bun replaces it. The ${TAG} tag matters: the latest tag on the registry still points at an old build.`,
9247
- binary: "This is a downloaded binary, so nothing upgrades it on its own, and a running executable cannot rewrite itself.",
9248
- source: "This is running from a checkout, so git is what updates it."
9249
- };
9250
- REFUSALS = {
9251
- binary: `adiff cannot do this one for you. Every build is listed on ${RELEASES}.`,
9252
- source: "adiff will not pull your checkout for you."
9273
+ brew: "Homebrew installed it, so Homebrew replaces it.",
9274
+ npm: "npm installed it, so npm replaces it.",
9275
+ bun: "bun installed it, so bun replaces it.",
9276
+ binary: "A running binary cannot rewrite itself.",
9277
+ source: "This is a checkout, so git is what updates it."
9253
9278
  };
9254
9279
  RUNNABLE = /* @__PURE__ */ new Set([
9255
9280
  "brew",
@@ -9334,42 +9359,64 @@ var init_upgrade$1 = __esmMin((() => {
9334
9359
  child.on("close", (code) => settle(code === 0));
9335
9360
  }).pipe(withSpan("Cli.runUpgrade"));
9336
9361
  statusOf$1 = (found) => {
9337
- if (!found.checked) return `adiff ${found.version} is installed. The registry did not answer, so adiff cannot tell whether a newer build is out.`;
9362
+ if (!found.checked) return `adiff ${found.version} is installed. The registry did not answer.`;
9338
9363
  if (found.current === true) return `adiff ${found.version} is the newest build.`;
9339
- return `adiff ${found.version} is installed, and ${found.latest} is out.`;
9340
- };
9341
- refusalOf = (found) => {
9342
- const refusal = REFUSALS[found.route];
9343
- return refusal === void 0 ? NOTES[found.route] : `${NOTES[found.route]} ${refusal}`;
9364
+ return `adiff ${found.version} is installed, ${found.latest} is out.`;
9344
9365
  };
9345
- OFFER = "Run `adiff upgrade` and adiff runs that for you.";
9346
9366
  sayFound = (found, check) => {
9347
9367
  if (found.current === true) return statusOf$1(found);
9348
- if (willUpgrade(found, check)) return [
9349
- statusOf$1(found),
9350
- `${NOTES[found.route]} Running it now:`,
9351
- ` ${found.command}`
9352
- ].join("\n\n");
9353
- const offer = RUNNABLE.has(found.route) ? [OFFER] : [];
9354
- return [
9355
- statusOf$1(found),
9356
- refusalOf(found),
9357
- ` ${found.command}`,
9358
- ...offer
9359
- ].join("\n\n");
9368
+ if (willUpgrade(found, check)) return found.checked ? `$ ${found.command}` : `${statusOf$1(found)}\n$ ${found.command}`;
9369
+ const offer = RUNNABLE.has(found.route) ? `Run \`adiff upgrade\`, or \`${found.command}\` yourself.` : `Run: ${found.command}`;
9370
+ return `${statusOf$1(found)} ${NOTES[found.route]} ${offer}`;
9360
9371
  };
9361
9372
  sayDone = (found, ran) => {
9362
9373
  if (!ran) return `That did not work. Run \`${found.command}\` yourself to see what it said.`;
9363
- if (found.latest === void 0) return "That worked. Run `adiff --version` to see which build you have now.";
9374
+ if (found.latest === void 0) return "Upgraded. Run `adiff --version` to see which build you have now.";
9364
9375
  return `adiff ${found.latest} is installed now.`;
9365
9376
  };
9366
9377
  attempted = (found, ran) => {
9367
- if (!ran) return `Ran \`${found.command}\` and it did not work. Run it yourself to see what it said.`;
9378
+ if (!ran) return `Ran \`${found.command}\` and it did not work.`;
9368
9379
  if (found.latest === void 0) return `Ran \`${found.command}\`. Run \`adiff --version\` to see which build you have now.`;
9369
9380
  return `Ran \`${found.command}\`, and adiff ${found.latest} is installed now.`;
9370
9381
  };
9382
+ REFRESH_MS = 1e4;
9383
+ refreshSkills = callback$1((resume) => {
9384
+ let said = "";
9385
+ let answered = false;
9386
+ const settle = (paths) => {
9387
+ if (answered) return;
9388
+ answered = true;
9389
+ resume(succeed(paths));
9390
+ };
9391
+ const child = spawn("adiff", [
9392
+ "skill",
9393
+ "refresh",
9394
+ "--json"
9395
+ ], {
9396
+ timeout: REFRESH_MS,
9397
+ stdio: [
9398
+ "ignore",
9399
+ "pipe",
9400
+ "ignore"
9401
+ ]
9402
+ });
9403
+ child.stdout?.on("data", (chunk) => {
9404
+ said += chunk.toString("utf8");
9405
+ });
9406
+ child.on("error", () => settle([]));
9407
+ child.on("close", (code) => settle(code === 0 ? updatedIn(said) : []));
9408
+ }).pipe(withSpan("Cli.refreshedSkill"));
9409
+ updatedIn = (said) => {
9410
+ return (runSync(try_(() => JSON.parse(said)).pipe(orElseSucceed(() => ({})))).changes ?? []).filter((change) => change.action === "update").flatMap((change) => change.path === void 0 ? [] : [change.path]);
9411
+ };
9412
+ sayRefreshed = (paths) => {
9413
+ const first = paths[0];
9414
+ if (first === void 0) return void 0;
9415
+ const rest = paths.length - 1;
9416
+ return rest === 0 ? `The skill at ${first} is the newest one too.` : `The skill at ${first} and ${rest} more is the newest one too.`;
9417
+ };
9371
9418
  upgradeReport = (found, ran, check) => {
9372
- const note = found.current === true ? statusOf$1(found) : willUpgrade(found, check) ? `${statusOf$1(found)} ${attempted(found, ran)}` : `${statusOf$1(found)} ${refusalOf(found)} Run \`${found.command}\` to upgrade.`;
9419
+ const note = found.current === true ? statusOf$1(found) : willUpgrade(found, check) ? `${statusOf$1(found)} ${attempted(found, ran)}` : `${statusOf$1(found)} ${NOTES[found.route]} Run \`${found.command}\` to upgrade.`;
9373
9420
  return {
9374
9421
  ...found,
9375
9422
  ran,
@@ -10240,6 +10287,16 @@ var init_catalog = __esmMin((() => {
10240
10287
  dataKey: "changes",
10241
10288
  example: "adiff init --repo . --write"
10242
10289
  },
10290
+ {
10291
+ name: "skill refresh",
10292
+ about: "Rewrite the adiff skill wherever it is already installed, in this directory and in your home directory. Installs nothing that is not already there",
10293
+ group: SET_UP,
10294
+ addresses: "none",
10295
+ safety: "write",
10296
+ options: [],
10297
+ dataKey: "changes",
10298
+ example: "adiff skill refresh"
10299
+ },
10243
10300
  {
10244
10301
  name: "upgrade",
10245
10302
  about: "Upgrade this install to the newest build, using whatever installed it. Answers a person in plain text, and a caller in JSON with --json",
@@ -15580,6 +15637,10 @@ const init = fn("Main.init")(function* (options) {
15580
15637
  changes: report.changes
15581
15638
  });
15582
15639
  });
15640
+ const skillRefresh = fn("Main.skillRefresh")(function* (options) {
15641
+ const report = yield* refreshSkill([process.cwd(), homedir()]);
15642
+ yield* answer(options, { changes: report.changes });
15643
+ });
15583
15644
  const reviewPane = fn("Main.reviewPane")(function* (options) {
15584
15645
  const report = yield* openPane(yield* required(options, "repo"), options["branch"]);
15585
15646
  yield* answer(options, {
@@ -15589,6 +15650,15 @@ const reviewPane = fn("Main.reviewPane")(function* (options) {
15589
15650
  });
15590
15651
  });
15591
15652
  const say = (line) => sync(() => process.stdout.write(line));
15653
+ const settledUpgrade = (found, check, ran) => sync(() => {
15654
+ if (check || found.current === true || ran) return;
15655
+ process.exitCode = 1;
15656
+ });
15657
+ const saidUpgrade = fn("Main.saidUpgrade")(function* (found, ran, skills) {
15658
+ yield* say(`\n${sayDone(found, ran)}\n`);
15659
+ const also = sayRefreshed(skills);
15660
+ if (also !== void 0) yield* say(`${also}\n`);
15661
+ });
15592
15662
  const routes = {
15593
15663
  "branch list": branchList,
15594
15664
  "comment send": commentSend,
@@ -15606,6 +15676,7 @@ const routes = {
15606
15676
  "layers set": layersSet,
15607
15677
  "layers show": layersShow,
15608
15678
  init,
15679
+ "skill refresh": skillRefresh,
15609
15680
  upgrade: fn("Main.upgrade")(function* (options) {
15610
15681
  const check = options["check"] !== void 0;
15611
15682
  const quiet = options["json"] !== void 0;
@@ -15613,12 +15684,16 @@ const routes = {
15613
15684
  const upgrading = willUpgrade(found, check);
15614
15685
  if (!quiet) yield* say(`${sayFound(found, check)}\n${upgrading ? "\n" : ""}`);
15615
15686
  const ran = upgrading ? yield* runUpgrade(found, quiet) : false;
15616
- if (quiet) return yield* answer(options, { upgrade: upgradeReport(found, ran, check) });
15617
- if (upgrading) yield* say(`\n${sayDone(found, ran)}\n`);
15618
- const settled = check || found.current === true || ran;
15619
- return yield* sync(() => {
15620
- if (!settled) process.exitCode = 1;
15621
- });
15687
+ const skills = ran ? yield* refreshSkills : [];
15688
+ if (quiet) {
15689
+ const also = skills.length === 0 ? {} : { skills };
15690
+ return yield* answer(options, {
15691
+ upgrade: upgradeReport(found, ran, check),
15692
+ ...also
15693
+ });
15694
+ }
15695
+ if (upgrading) yield* saidUpgrade(found, ran, skills);
15696
+ return yield* settledUpgrade(found, check, ran);
15622
15697
  }),
15623
15698
  describe: fn("Main.describe")(function* (options) {
15624
15699
  const wanted = options["command"];
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "bin": {
24
24
  "adiff": "./bin/adiff.js"
25
25
  },
26
- "version": "0.1.0-alpha.49",
26
+ "version": "0.1.0-alpha.50",
27
27
  "description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
28
28
  "license": "MIT",
29
29
  "repository": {