@mifune/agro 0.13.0 → 0.14.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 (2) hide show
  1. package/dist/agro.js +57 -15
  2. package/package.json +1 -1
package/dist/agro.js CHANGED
@@ -2221,6 +2221,18 @@ function resolveExecutionTarget(opts) {
2221
2221
  return new DockerComposeExecutionTarget(opts);
2222
2222
  }
2223
2223
 
2224
+ // src/lib/version.ts
2225
+ var AGRO_VERSION = true ? "0.14.0" : "0.0.0-dev";
2226
+ var OFFICIAL_IMAGE = "ghcr.io/mifunedev/agro";
2227
+ var RELEASE_VERSION = /^[0-9]+\.[0-9]+\.[0-9]+$/;
2228
+ function parseReleaseVersion(value) {
2229
+ const bare = value.startsWith("v") ? value.slice(1) : value;
2230
+ return RELEASE_VERSION.test(bare) ? bare : void 0;
2231
+ }
2232
+ function officialImageRef(version) {
2233
+ return `${OFFICIAL_IMAGE}:${RELEASE_VERSION.test(version) ? version : "latest"}`;
2234
+ }
2235
+
2224
2236
  // src/lib/config-render.ts
2225
2237
  var RETIRED_KEYS = [
2226
2238
  "WORKTREES_DIR",
@@ -2242,6 +2254,12 @@ var RETIRED_KEYS = [
2242
2254
  "LANGFUSE_BASE_URL",
2243
2255
  "LANGFUSE_PRIVACY_PRESET"
2244
2256
  ];
2257
+ function runsPrebuiltImage(config) {
2258
+ return config.image?.mode === "image";
2259
+ }
2260
+ function sandboxImageRef(config) {
2261
+ return config.image?.ref ?? (runsPrebuiltImage(config) ? officialImageRef(AGRO_VERSION) : void 0);
2262
+ }
2245
2263
  function renderComposeVars(config) {
2246
2264
  const out = [];
2247
2265
  const put = (key, value) => {
@@ -2257,7 +2275,7 @@ function renderComposeVars(config) {
2257
2275
  put("DOCKER_SOCKET", config.access?.dockerSocket);
2258
2276
  put("SANDBOX_SSH", config.access?.ssh);
2259
2277
  put("SANDBOX_SSH_PORT", config.access?.sshPort);
2260
- put("AGRO_SANDBOX_IMAGE", config.image?.ref);
2278
+ put("AGRO_SANDBOX_IMAGE", sandboxImageRef(config));
2261
2279
  put("AGRO_PULL_POLICY", config.image?.pullPolicy);
2262
2280
  for (const { key, value } of out) {
2263
2281
  if (isSecretKey(key)) {
@@ -2318,7 +2336,6 @@ function sandboxRoot(opts) {
2318
2336
  return root;
2319
2337
  }
2320
2338
  var DEFAULT_CONTAINER_NAME = DEFAULT_SANDBOX_NAME;
2321
- var DEFAULT_SANDBOX_IMAGE = "ghcr.io/mifunedev/agro:latest";
2322
2339
  function configuredField(root, path4) {
2323
2340
  const file = agroConfigPath(root);
2324
2341
  if (!existsSync10(file)) return void 0;
@@ -2363,7 +2380,7 @@ async function runSandbox(opts, io) {
2363
2380
  const root = resolveProjectRoot(opts.cwd);
2364
2381
  const useImage = opts.image === true || opts.imageRef !== void 0;
2365
2382
  const useNoBuild = useImage || opts.noBuild === true;
2366
- const imageRef = useImage ? opts.imageRef ?? configuredImage(root) ?? DEFAULT_SANDBOX_IMAGE : void 0;
2383
+ const imageRef = useImage ? opts.imageRef ?? configuredImage(root) ?? officialImageRef(AGRO_VERSION) : void 0;
2367
2384
  const env = imageRef === void 0 ? void 0 : { ...process.env, ...agroEnvPair("SANDBOX_IMAGE", imageRef) };
2368
2385
  if (opts.printArgv === true) {
2369
2386
  const script = requireLifecycleScript(root, "docker-compose.sh");
@@ -3933,9 +3950,6 @@ async function runSandboxInstall(opts, io) {
3933
3950
  if (opts.imageRef !== void 0) {
3934
3951
  config.image = { ...config.image, ref: opts.imageRef, mode: "image" };
3935
3952
  }
3936
- if (configCheckout(config) !== void 0 && config.image?.mode === "image" && nonEmpty(config.image?.ref) === void 0) {
3937
- config.image = { ...config.image, ref: DEFAULT_SANDBOX_IMAGE };
3938
- }
3939
3953
  const useNoBuild = opts.noBuild === true || !(configCheckout(config) !== void 0 && config.image?.mode === "build");
3940
3954
  const sandboxOpts = {
3941
3955
  bin: opts.bin,
@@ -5678,7 +5692,6 @@ function fetchRemoteSource(opts) {
5678
5692
  }
5679
5693
 
5680
5694
  // src/cli.ts
5681
- var VERSION = true ? "0.13.0" : "0.0.0-dev";
5682
5695
  var DEFAULT_SOURCE_CONTROL_DIR = resolve11(
5683
5696
  dirname10(fileURLToPath(import.meta.url)),
5684
5697
  "../.."
@@ -5706,7 +5719,7 @@ function integrationLines() {
5706
5719
  }
5707
5720
  function printAgroHelp(product = AGRO_PRODUCT) {
5708
5721
  const { bin, title } = product;
5709
- process.stdout.write(`${bin} \u2014 ${title} (v${VERSION})
5722
+ process.stdout.write(`${bin} \u2014 ${title} (v${AGRO_VERSION})
5710
5723
 
5711
5724
  Usage:
5712
5725
  ${bin} sandbox <args...> Create and list sandboxes (install|list)
@@ -5871,7 +5884,8 @@ function printSandboxHelp(bin = AGRO_PRODUCT.bin) {
5871
5884
  Usage:
5872
5885
  ${bin} sandbox install <runtime> [--name <name>] [--checkout <dir>]
5873
5886
  [--home-mount <dir>] [--yes]
5874
- [--image[=<ref>]] [--no-build] [--print-argv]
5887
+ [--version <X.Y.Z> | --image[=<ref>]]
5888
+ [--no-build] [--print-argv]
5875
5889
  ${bin} sandbox list [--json]
5876
5890
 
5877
5891
  \`install\` writes a sandbox entry under \${${stateNames(bin).envPrefix}HOME:-~/${stateNames(bin).userStateDir}}/sandboxes/<name>/,
@@ -5898,9 +5912,14 @@ Flags:
5898
5912
  Docker-managed volume. Relative paths resolve against the
5899
5913
  working directory. The directory is created when absent
5900
5914
  --yes Non-interactive: keep every default and ask nothing
5901
- --image[=<ref>] Run the prebuilt image instead of building (implies
5902
- --no-build). Ref resolves last-wins: --image=<ref> >
5903
- ${stateNames(bin).configFile} image.ref > ${DEFAULT_SANDBOX_IMAGE}.
5915
+ --version <X.Y.Z>
5916
+ Run the official release image ghcr.io/mifunedev/agro:<X.Y.Z>
5917
+ (implies --image). A leading v is accepted
5918
+ --image Run the prebuilt image instead of building (implies
5919
+ --no-build). The ref resolves first-match: --version or
5920
+ --image=<ref> > ${stateNames(bin).envPrefix}SANDBOX_IMAGE >
5921
+ ${stateNames(bin).configFile} image.ref > ${officialImageRef(AGRO_VERSION)}
5922
+ --image=<ref> Run a custom image (implies --image); conflicts with --version
5904
5923
  --no-build Suppress the local build and reuse an existing image
5905
5924
  --print-argv Print the docker compose argv that would run, then exit
5906
5925
  without writing an entry
@@ -6376,6 +6395,7 @@ function parseSandboxArgs(rest, bin = AGRO_PRODUCT.bin) {
6376
6395
  if (isHelpFlag(tail[0])) return { ok: true, args: { ...args, help: true } };
6377
6396
  const positionals = [];
6378
6397
  const checkoutSpellings = /* @__PURE__ */ new Set();
6398
+ let version;
6379
6399
  for (let i = 0; i < tail.length; i++) {
6380
6400
  const token = tail[i];
6381
6401
  const valueFlag = SANDBOX_VALUE_FLAGS[token];
@@ -6402,6 +6422,18 @@ function parseSandboxArgs(rest, bin = AGRO_PRODUCT.bin) {
6402
6422
  }
6403
6423
  args.image = true;
6404
6424
  args.imageRef = ref;
6425
+ } else if (token === "--version" || token.startsWith("--version=")) {
6426
+ const value = token === "--version" ? tail[++i] : token.slice("--version=".length);
6427
+ if (value === void 0 || value === "") {
6428
+ return { ok: false, error: `${bin} sandbox ${head}: --version requires a value` };
6429
+ }
6430
+ version = parseReleaseVersion(value);
6431
+ if (version === void 0) {
6432
+ return {
6433
+ ok: false,
6434
+ error: `${bin} sandbox ${head}: --version "${value}" is not a release version \u2014 expected X.Y.Z`
6435
+ };
6436
+ }
6405
6437
  } else if (token === "--json") {
6406
6438
  args.json = true;
6407
6439
  } else if (token.startsWith("-")) {
@@ -6416,6 +6448,16 @@ function parseSandboxArgs(rest, bin = AGRO_PRODUCT.bin) {
6416
6448
  error: `${bin} sandbox ${head}: --checkout conflicts with --repo \u2014 pass exactly one, and prefer --checkout`
6417
6449
  };
6418
6450
  }
6451
+ if (version !== void 0) {
6452
+ if (args.imageRef !== void 0) {
6453
+ return {
6454
+ ok: false,
6455
+ error: `${bin} sandbox ${head}: --version conflicts with --image=<ref> \u2014 pass --version for an official release or --image=<ref> for a custom image`
6456
+ };
6457
+ }
6458
+ args.image = true;
6459
+ args.imageRef = officialImageRef(version);
6460
+ }
6419
6461
  if (head === "list") {
6420
6462
  if (positionals.length > 0) {
6421
6463
  return { ok: false, error: `${bin} sandbox list: unexpected argument "${positionals[0]}"` };
@@ -6687,7 +6729,7 @@ async function runWithRemoteSource(hooks, fn) {
6687
6729
  const checkoutDir = mkdtemp();
6688
6730
  try {
6689
6731
  fetch2({ destDir: checkoutDir, repoUrl: hooks.repoUrl, ref: hooks.ref });
6690
- out(`fetched payload v${readPayloadVersion(checkoutDir)} (installed CLI v${VERSION})
6732
+ out(`fetched payload v${readPayloadVersion(checkoutDir)} (installed CLI v${AGRO_VERSION})
6691
6733
  `);
6692
6734
  return await fn(checkoutDir);
6693
6735
  } finally {
@@ -6703,7 +6745,7 @@ async function main(argv) {
6703
6745
  return 0;
6704
6746
  }
6705
6747
  if (isVersionFlag(first)) {
6706
- process.stdout.write(`${VERSION}
6748
+ process.stdout.write(`${AGRO_VERSION}
6707
6749
  `);
6708
6750
  return 0;
6709
6751
  }
@@ -6809,7 +6851,7 @@ async function main(argv) {
6809
6851
  };
6810
6852
  return await runSelfUpgrade(
6811
6853
  { dryRun: parsed.args.dryRun, argv1: process.argv[1] },
6812
- defaultDeps(VERSION),
6854
+ defaultDeps(AGRO_VERSION),
6813
6855
  io
6814
6856
  );
6815
6857
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mifune/agro",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "AGRO CLI — create and manage sandboxes for coding agents.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/mifunedev/agro#readme",