@eliya-oss/agent-diff 0.1.0-alpha.46 → 0.1.0-alpha.47
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 +6 -0
- package/dist/main.js +111 -63
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.47
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- `adiff upgrade` upgrades. It runs the command for the install it found instead of printing it, shows the package manager working, and ends by naming the version you now have. `--check` reports without running, `--run` still works and does nothing, and a route adiff cannot do for you, a downloaded binary or a checkout, explains why and exits 1.
|
|
8
|
+
|
|
3
9
|
## 0.1.0-alpha.46
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/main.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { appendFile, mkdir, readFile, realpath, writeFile } from "node:fs/promises";
|
|
3
3
|
import { text } from "node:stream/consumers";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
|
-
import { execFile } from "node:child_process";
|
|
5
|
+
import { execFile, spawn } from "node:child_process";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
import { homedir, hostname, platform } from "node:os";
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, watch } from "node:fs";
|
|
@@ -9098,7 +9098,7 @@ var init_init = __esmMin((() => {
|
|
|
9098
9098
|
}));
|
|
9099
9099
|
//#endregion
|
|
9100
9100
|
//#region src/cli/pane.ts
|
|
9101
|
-
var TIMEOUT_MS$1, set, splitters, selfInvocation, ran
|
|
9101
|
+
var TIMEOUT_MS$1, set, splitters, selfInvocation, ran, split, openPane;
|
|
9102
9102
|
var init_pane = __esmMin((() => {
|
|
9103
9103
|
init_dist();
|
|
9104
9104
|
TIMEOUT_MS$1 = 5e3;
|
|
@@ -9173,11 +9173,11 @@ var init_pane = __esmMin((() => {
|
|
|
9173
9173
|
repo
|
|
9174
9174
|
];
|
|
9175
9175
|
};
|
|
9176
|
-
ran
|
|
9176
|
+
ran = (binary, args) => callback$1((resume) => {
|
|
9177
9177
|
execFile(binary, [...args], { timeout: TIMEOUT_MS$1 }, (cause) => resume(succeed(cause === null)));
|
|
9178
9178
|
});
|
|
9179
9179
|
split = fn("Cli.split")(function* (chosen, repo) {
|
|
9180
|
-
return yield* ran
|
|
9180
|
+
return yield* ran(chosen.binary, chosen.args(repo, selfInvocation(repo)));
|
|
9181
9181
|
});
|
|
9182
9182
|
openPane = fn("Cli.openPane")(function* (repo) {
|
|
9183
9183
|
const command = `adiff review open --repo ${repo}`;
|
|
@@ -9199,10 +9199,10 @@ var init_pane = __esmMin((() => {
|
|
|
9199
9199
|
init_commands();
|
|
9200
9200
|
init_init();
|
|
9201
9201
|
init_pane();
|
|
9202
|
-
var version$1 = "0.1.0-alpha.
|
|
9202
|
+
var version$1 = "0.1.0-alpha.47";
|
|
9203
9203
|
//#endregion
|
|
9204
9204
|
//#region src/cli/upgrade.ts
|
|
9205
|
-
var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest,
|
|
9205
|
+
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;
|
|
9206
9206
|
var init_upgrade$1 = __esmMin((() => {
|
|
9207
9207
|
init_dist();
|
|
9208
9208
|
PACKAGE = "@eliya-oss/agent-diff";
|
|
@@ -9221,6 +9221,14 @@ var init_upgrade$1 = __esmMin((() => {
|
|
|
9221
9221
|
if (!INSTALLED.test(module)) return "source";
|
|
9222
9222
|
return BUN_GLOBAL.test(module) ? "bun" : "npm";
|
|
9223
9223
|
};
|
|
9224
|
+
ROUTES = [
|
|
9225
|
+
"brew",
|
|
9226
|
+
"npm",
|
|
9227
|
+
"bun",
|
|
9228
|
+
"binary",
|
|
9229
|
+
"source"
|
|
9230
|
+
];
|
|
9231
|
+
asRoute = (named) => ROUTES.find((route) => route === named);
|
|
9224
9232
|
checkoutOf = (module) => module.replace(/[/\\](?:src|dist)[/\\].*$/, "").replace(/[/\\](?:src|dist)$/, "");
|
|
9225
9233
|
assetOf = () => `adiff-${process.platform}-${process.arch}`;
|
|
9226
9234
|
commandFor = (route, executable, module) => {
|
|
@@ -9237,6 +9245,10 @@ var init_upgrade$1 = __esmMin((() => {
|
|
|
9237
9245
|
binary: "This is a downloaded binary, so nothing upgrades it on its own, and a running executable cannot rewrite itself.",
|
|
9238
9246
|
source: "This is running from a checkout, so git is what updates it."
|
|
9239
9247
|
};
|
|
9248
|
+
REFUSALS = {
|
|
9249
|
+
binary: `adiff cannot do this one for you. Every build is listed on ${RELEASES}.`,
|
|
9250
|
+
source: "adiff will not pull your checkout for you."
|
|
9251
|
+
};
|
|
9240
9252
|
RUNNABLE = /* @__PURE__ */ new Set([
|
|
9241
9253
|
"brew",
|
|
9242
9254
|
"npm",
|
|
@@ -9278,64 +9290,90 @@ var init_upgrade$1 = __esmMin((() => {
|
|
|
9278
9290
|
};
|
|
9279
9291
|
fetched = (url) => fetch(url, { signal: AbortSignal.timeout(ASK_MS) }).then((response) => response.ok ? response.json() : void 0).then(tagIn).catch(() => void 0);
|
|
9280
9292
|
askLatest = promise(() => fetched(process.env["ADIFF_REGISTRY"] ?? REGISTRY));
|
|
9281
|
-
ran = (command) => callback$1((resume) => {
|
|
9282
|
-
execFile("/bin/sh", ["-c", command], { timeout: RUN_MS }, (cause) => resume(succeed(!cause)));
|
|
9283
|
-
});
|
|
9284
9293
|
here = () => ({
|
|
9285
9294
|
executable: process.execPath,
|
|
9286
9295
|
module: fileURLToPath(new URL(".", import.meta.url))
|
|
9287
9296
|
});
|
|
9288
|
-
|
|
9289
|
-
if (!told.checked) return `adiff ${told.version} is installed. The registry did not answer, so adiff cannot tell whether a newer build is out.`;
|
|
9290
|
-
if (told.current === true) return `adiff ${told.version} is the newest build.`;
|
|
9291
|
-
return `adiff ${told.version} is installed, and ${told.latest} is out.`;
|
|
9292
|
-
};
|
|
9293
|
-
ranLine = (told) => told.latest === void 0 ? `Ran \`${told.command}\`. Run \`adiff --version\` to see what you have now.` : `Ran \`${told.command}\`, so the next adiff you run will be ${told.latest}.`;
|
|
9294
|
-
failedLine = (told) => `Ran \`${told.command}\` and it did not work. Run it yourself to see what it said.`;
|
|
9295
|
-
noteFor = (told, run) => {
|
|
9296
|
-
if (told.current === true) return statusOf$1(told);
|
|
9297
|
-
if (told.ran) return `${statusOf$1(told)} ${ranLine(told)}`;
|
|
9298
|
-
if (run && RUNNABLE.has(told.route)) return `${statusOf$1(told)} ${failedLine(told)}`;
|
|
9299
|
-
const refused = run ? " adiff will not run this one for you; run it yourself." : "";
|
|
9300
|
-
return `${statusOf$1(told)} ${NOTES[told.route]}${refused} Run \`${told.command}\` to upgrade.`;
|
|
9301
|
-
};
|
|
9302
|
-
offerFor = (told) => RUNNABLE.has(told.route) ? "Or run `adiff upgrade --run` and adiff runs that for you." : `Every build is listed on ${RELEASES}.`;
|
|
9303
|
-
restOf = (told, run) => {
|
|
9304
|
-
if (told.ran) return [ranLine(told)];
|
|
9305
|
-
if (run && RUNNABLE.has(told.route)) return [failedLine(told)];
|
|
9306
|
-
const refused = run ? " adiff will not run this one for you; run it yourself." : "";
|
|
9307
|
-
return [
|
|
9308
|
-
`${NOTES[told.route]}${refused}`,
|
|
9309
|
-
` ${told.command}`,
|
|
9310
|
-
offerFor(told)
|
|
9311
|
-
];
|
|
9312
|
-
};
|
|
9313
|
-
sayUpgrade = (told, run) => told.current === true ? statusOf$1(told) : [statusOf$1(told), ...restOf(told, run)].join("\n\n");
|
|
9314
|
-
upgradeAdiff = fn("Cli.upgradeAdiff")(function* (run) {
|
|
9297
|
+
findUpgrade = gen(function* () {
|
|
9315
9298
|
const { executable, module } = here();
|
|
9316
|
-
const route = routeOf(executable, module);
|
|
9299
|
+
const route = asRoute(process.env["ADIFF_UPGRADE_ROUTE"]) ?? routeOf(executable, module);
|
|
9317
9300
|
const version = version$1;
|
|
9318
9301
|
const command = commandFor(route, executable, module);
|
|
9319
9302
|
const latest = yield* askLatest;
|
|
9320
|
-
const current = latest === void 0 ? void 0 : !newer(latest, version);
|
|
9321
9303
|
const known = latest === void 0 ? {} : {
|
|
9322
9304
|
latest,
|
|
9323
|
-
current:
|
|
9305
|
+
current: !newer(latest, version)
|
|
9324
9306
|
};
|
|
9325
|
-
|
|
9326
|
-
const told = {
|
|
9307
|
+
return {
|
|
9327
9308
|
route,
|
|
9328
9309
|
version,
|
|
9329
9310
|
checked: latest !== void 0,
|
|
9330
9311
|
...known,
|
|
9331
|
-
command
|
|
9332
|
-
ran: performed
|
|
9312
|
+
command
|
|
9333
9313
|
};
|
|
9314
|
+
}).pipe(withSpan("Cli.findUpgrade"));
|
|
9315
|
+
willUpgrade = (found, check) => !check && found.current !== true && RUNNABLE.has(found.route);
|
|
9316
|
+
runUpgrade = (found, quiet) => callback$1((resume) => {
|
|
9317
|
+
let answered = false;
|
|
9318
|
+
const settle = (worked) => {
|
|
9319
|
+
if (answered) return;
|
|
9320
|
+
answered = true;
|
|
9321
|
+
resume(succeed(worked));
|
|
9322
|
+
};
|
|
9323
|
+
const child = spawn("/bin/sh", ["-c", found.command], {
|
|
9324
|
+
timeout: RUN_MS,
|
|
9325
|
+
stdio: quiet ? "ignore" : [
|
|
9326
|
+
"ignore",
|
|
9327
|
+
"inherit",
|
|
9328
|
+
"inherit"
|
|
9329
|
+
]
|
|
9330
|
+
});
|
|
9331
|
+
child.on("error", () => settle(false));
|
|
9332
|
+
child.on("close", (code) => settle(code === 0));
|
|
9333
|
+
}).pipe(withSpan("Cli.runUpgrade"));
|
|
9334
|
+
statusOf$1 = (found) => {
|
|
9335
|
+
if (!found.checked) return `adiff ${found.version} is installed. The registry did not answer, so adiff cannot tell whether a newer build is out.`;
|
|
9336
|
+
if (found.current === true) return `adiff ${found.version} is the newest build.`;
|
|
9337
|
+
return `adiff ${found.version} is installed, and ${found.latest} is out.`;
|
|
9338
|
+
};
|
|
9339
|
+
refusalOf = (found) => {
|
|
9340
|
+
const refusal = REFUSALS[found.route];
|
|
9341
|
+
return refusal === void 0 ? NOTES[found.route] : `${NOTES[found.route]} ${refusal}`;
|
|
9342
|
+
};
|
|
9343
|
+
OFFER = "Run `adiff upgrade` and adiff runs that for you.";
|
|
9344
|
+
sayFound = (found, check) => {
|
|
9345
|
+
if (found.current === true) return statusOf$1(found);
|
|
9346
|
+
if (willUpgrade(found, check)) return [
|
|
9347
|
+
statusOf$1(found),
|
|
9348
|
+
`${NOTES[found.route]} Running it now:`,
|
|
9349
|
+
` ${found.command}`
|
|
9350
|
+
].join("\n\n");
|
|
9351
|
+
const offer = RUNNABLE.has(found.route) ? [OFFER] : [];
|
|
9352
|
+
return [
|
|
9353
|
+
statusOf$1(found),
|
|
9354
|
+
refusalOf(found),
|
|
9355
|
+
` ${found.command}`,
|
|
9356
|
+
...offer
|
|
9357
|
+
].join("\n\n");
|
|
9358
|
+
};
|
|
9359
|
+
sayDone = (found, ran) => {
|
|
9360
|
+
if (!ran) return `That did not work. Run \`${found.command}\` yourself to see what it said.`;
|
|
9361
|
+
if (found.latest === void 0) return "That worked. Run `adiff --version` to see which build you have now.";
|
|
9362
|
+
return `adiff ${found.latest} is installed now.`;
|
|
9363
|
+
};
|
|
9364
|
+
attempted = (found, ran) => {
|
|
9365
|
+
if (!ran) return `Ran \`${found.command}\` and it did not work. Run it yourself to see what it said.`;
|
|
9366
|
+
if (found.latest === void 0) return `Ran \`${found.command}\`. Run \`adiff --version\` to see which build you have now.`;
|
|
9367
|
+
return `Ran \`${found.command}\`, and adiff ${found.latest} is installed now.`;
|
|
9368
|
+
};
|
|
9369
|
+
upgradeReport = (found, ran, check) => {
|
|
9370
|
+
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.`;
|
|
9334
9371
|
return {
|
|
9335
|
-
...
|
|
9336
|
-
|
|
9372
|
+
...found,
|
|
9373
|
+
ran,
|
|
9374
|
+
note
|
|
9337
9375
|
};
|
|
9338
|
-
}
|
|
9376
|
+
};
|
|
9339
9377
|
}));
|
|
9340
9378
|
//#endregion
|
|
9341
9379
|
//#region src/cli/search.ts
|
|
@@ -10196,15 +10234,15 @@ var init_catalog = __esmMin((() => {
|
|
|
10196
10234
|
},
|
|
10197
10235
|
{
|
|
10198
10236
|
name: "upgrade",
|
|
10199
|
-
about: "
|
|
10237
|
+
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",
|
|
10200
10238
|
group: SET_UP,
|
|
10201
10239
|
addresses: "none",
|
|
10202
|
-
safety: "
|
|
10240
|
+
safety: "write",
|
|
10203
10241
|
options: [{
|
|
10204
|
-
name: "
|
|
10242
|
+
name: "check",
|
|
10205
10243
|
required: false,
|
|
10206
10244
|
value: "flag",
|
|
10207
|
-
about: "
|
|
10245
|
+
about: "Report what would happen and name the command, without running anything. Always exits 0"
|
|
10208
10246
|
}, {
|
|
10209
10247
|
name: "json",
|
|
10210
10248
|
required: false,
|
|
@@ -10212,7 +10250,7 @@ var init_catalog = __esmMin((() => {
|
|
|
10212
10250
|
about: "Answer with the usual envelope instead of plain text. This is the only command that needs it"
|
|
10213
10251
|
}],
|
|
10214
10252
|
dataKey: "upgrade",
|
|
10215
|
-
example: "adiff upgrade --json --fields route,
|
|
10253
|
+
example: "adiff upgrade --check --json --fields route,latest,current"
|
|
10216
10254
|
},
|
|
10217
10255
|
{
|
|
10218
10256
|
name: "describe",
|
|
@@ -15138,6 +15176,15 @@ const init = fn("Main.init")(function* (options) {
|
|
|
15138
15176
|
changes: report.changes
|
|
15139
15177
|
});
|
|
15140
15178
|
});
|
|
15179
|
+
const reviewPane = fn("Main.reviewPane")(function* (options) {
|
|
15180
|
+
const report = yield* openPane(yield* required(options, "repo"));
|
|
15181
|
+
yield* answer(options, {
|
|
15182
|
+
opened: report.opened,
|
|
15183
|
+
pane: report.pane,
|
|
15184
|
+
command: report.command
|
|
15185
|
+
});
|
|
15186
|
+
});
|
|
15187
|
+
const say = (line) => sync(() => process.stdout.write(line));
|
|
15141
15188
|
const routes = {
|
|
15142
15189
|
"branch list": branchList,
|
|
15143
15190
|
"comment send": commentSend,
|
|
@@ -15150,23 +15197,24 @@ const routes = {
|
|
|
15150
15197
|
"comment remove": commentRemove,
|
|
15151
15198
|
"comment restore": commentRestore,
|
|
15152
15199
|
"review send": reviewSend,
|
|
15153
|
-
"review pane":
|
|
15154
|
-
const report = yield* openPane(yield* required(options, "repo"));
|
|
15155
|
-
yield* answer(options, {
|
|
15156
|
-
opened: report.opened,
|
|
15157
|
-
pane: report.pane,
|
|
15158
|
-
command: report.command
|
|
15159
|
-
});
|
|
15160
|
-
}),
|
|
15200
|
+
"review pane": reviewPane,
|
|
15161
15201
|
"review progress": reviewStatus,
|
|
15162
15202
|
"layers set": layersSet,
|
|
15163
15203
|
"layers show": layersShow,
|
|
15164
15204
|
init,
|
|
15165
15205
|
upgrade: fn("Main.upgrade")(function* (options) {
|
|
15166
|
-
const
|
|
15167
|
-
const
|
|
15168
|
-
|
|
15169
|
-
|
|
15206
|
+
const check = options["check"] !== void 0;
|
|
15207
|
+
const quiet = options["json"] !== void 0;
|
|
15208
|
+
const found = yield* findUpgrade;
|
|
15209
|
+
const upgrading = willUpgrade(found, check);
|
|
15210
|
+
if (!quiet) yield* say(`${sayFound(found, check)}\n${upgrading ? "\n" : ""}`);
|
|
15211
|
+
const ran = upgrading ? yield* runUpgrade(found, quiet) : false;
|
|
15212
|
+
if (quiet) return yield* answer(options, { upgrade: upgradeReport(found, ran, check) });
|
|
15213
|
+
if (upgrading) yield* say(`\n${sayDone(found, ran)}\n`);
|
|
15214
|
+
const settled = check || found.current === true || ran;
|
|
15215
|
+
return yield* sync(() => {
|
|
15216
|
+
if (!settled) process.exitCode = 1;
|
|
15217
|
+
});
|
|
15170
15218
|
}),
|
|
15171
15219
|
describe: fn("Main.describe")(function* (options) {
|
|
15172
15220
|
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.
|
|
26
|
+
"version": "0.1.0-alpha.47",
|
|
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": {
|