@epoch-agent/cli 0.7.1 → 0.9.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/index.js +100 -34
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -499,6 +499,11 @@ var SECTION_FIELDS = {
499
499
  compression: {
500
500
  enabled: (v) => v === "true" || v === "false",
501
501
  threshold: (v) => Number.isFinite(Number(v)) && Number(v) > 0 && Number(v) <= 1
502
+ },
503
+ memory: {
504
+ memoryCharLimit: isPositiveInt,
505
+ userCharLimit: isPositiveInt,
506
+ indexCharLimit: isPositiveInt
502
507
  }
503
508
  };
504
509
  function knownKeys() {
@@ -939,6 +944,8 @@ function describeError(err2) {
939
944
  return err2 instanceof Error ? err2.message : String(err2);
940
945
  }
941
946
  // src/commands/plugin.ts
947
+ import { mkdirSync as mkdirSync2 } from "fs";
948
+ import { dirname, resolve } from "path";
942
949
  import {
943
950
  addMarketplace,
944
951
  currentEpochVersion,
@@ -946,6 +953,8 @@ import {
946
953
  inventoryTotal,
947
954
  isNonInteractive as isNonInteractive2,
948
955
  loadPlugins,
956
+ packPlugin,
957
+ planPack,
949
958
  readMarketplaces,
950
959
  readPluginManifest,
951
960
  removeMarketplace,
@@ -986,6 +995,9 @@ function registerBasics(cmd) {
986
995
  cmd.command("validate").description(t8("plugin.cmd_validate")).argument("[path]", t8("plugin.arg_dir")).action((path) => {
987
996
  validateDir(path ?? process.cwd());
988
997
  });
998
+ cmd.command("pack").description(t8("plugin.cmd_pack")).argument("[path]", t8("plugin.arg_dir")).option("--out <dir>", t8("plugin.opt_out")).action(async (path, opts) => {
999
+ await packDir(path ?? process.cwd(), opts.out);
1000
+ });
989
1001
  }
990
1002
  function registerLifecycle(cmd) {
991
1003
  cmd.command("uninstall").alias("rm").description(t8("plugin.cmd_uninstall")).argument("<name>", t8("plugin.arg_name")).action(async (name) => {
@@ -1224,8 +1236,23 @@ function printSearch(keyword) {
1224
1236
  `);
1225
1237
  for (const hit of hits) {
1226
1238
  const category = hit.entry.category ? ` [${hit.entry.category}]` : "";
1227
- log6(` ${hit.ref}${category}`);
1239
+ const shown = hit.entry.displayName ? ` ${hit.entry.displayName}` : "";
1240
+ const version = hit.entry.version ? ` ${hit.entry.version}` : "";
1241
+ log6(` ${hit.ref}${shown}${version}${category}`);
1228
1242
  if (hit.entry.description) log6(` ${hit.entry.description}`);
1243
+ if (hit.entry.author) log6(` ${t8("plugin.search_author", { name: hit.entry.author.name })}`);
1244
+ const stats = [];
1245
+ const { downloads, likes } = hit.entry;
1246
+ if (downloads !== void 0) stats.push(t8("plugin.search_downloads", { count: downloads }));
1247
+ if (likes !== void 0) stats.push(t8("plugin.search_likes", { count: likes }));
1248
+ if (stats.length > 0) log6(` ${stats.join(" \xB7 ")}`);
1249
+ if (hit.entry.visibility) {
1250
+ log6(
1251
+ ` ${t8(
1252
+ hit.entry.visibility === "public" ? "plugin.search_public" : "plugin.search_private"
1253
+ )}`
1254
+ );
1255
+ }
1229
1256
  }
1230
1257
  log6(`
1231
1258
  ${t8("plugin.search_install_hint", { ref: hits[0]?.ref ?? t8("plugin.ref_placeholder") })}`);
@@ -1256,9 +1283,40 @@ ${t8("plugin.brings_head")}`);
1256
1283
  throw new CliError(t8("plugin.inv_issues", { count: inventory.issues.length }));
1257
1284
  }
1258
1285
  }
1286
+ async function packDir(dir, out2) {
1287
+ const target = resolve(dir);
1288
+ const planned = planPack(target);
1289
+ if (!planned.ok) throw new CliError(planned.reason);
1290
+ const plan = planned.plan;
1291
+ log6(t8("plugin.pack_head", { name: plan.manifest.name, version: plan.manifest.version }));
1292
+ for (const file of plan.files) log6(` ${file.path}`);
1293
+ log6(
1294
+ t8("plugin.pack_tally", {
1295
+ count: plan.files.length,
1296
+ kb: Math.round(plan.totalBytes / 1024)
1297
+ })
1298
+ );
1299
+ if (plan.suspicious.length > 0) {
1300
+ log6(`\u26A0 ${t8("plugin.pack_suspicious", { files: plan.suspicious.join(", ") })}`);
1301
+ }
1302
+ if (plan.skippedLinks.length > 0) {
1303
+ log6(`\u26A0 ${t8("plugin.pack_skipped_links", { files: plan.skippedLinks.join(", ") })}`);
1304
+ }
1305
+ const destDir = resolve(out2 ?? dirname(target));
1306
+ mkdirSync2(destDir, { recursive: true });
1307
+ const packed = await packPlugin(plan, destDir);
1308
+ if (!packed.ok) throw new CliError(packed.reason);
1309
+ log6(
1310
+ `\u2713 ${t8("plugin.pack_ok", {
1311
+ path: packed.archivePath,
1312
+ kb: Math.round(packed.bytes / 1024)
1313
+ })}`
1314
+ );
1315
+ log6(t8("plugin.pack_next", { path: packed.archivePath }));
1316
+ }
1259
1317
  // src/commands/run.ts
1260
1318
  import { existsSync as existsSync6 } from "fs";
1261
- import { dirname as dirname3, join as join5 } from "path";
1319
+ import { dirname as dirname4, join as join5 } from "path";
1262
1320
  import { fileURLToPath as fileURLToPath3 } from "url";
1263
1321
  import { isNonInteractive as isNonInteractive8, OPERATION_TYPES as OPERATION_TYPES3, PERMISSION_LEVELS as PERMISSION_LEVELS3 } from "@epoch-agent/core";
1264
1322
  import { t as t25 } from "@epoch-agent/infra";
@@ -1273,7 +1331,7 @@ import { t as t12 } from "@epoch-agent/infra";
1273
1331
  import { buildRuntime } from "@epoch-agent/runtime";
1274
1332
  // src/commands/run-flags.ts
1275
1333
  import { existsSync as existsSync3 } from "fs";
1276
- import { delimiter, resolve } from "path";
1334
+ import { delimiter, resolve as resolve2 } from "path";
1277
1335
  import { isOperationType, resolveWorkspace } from "@epoch-agent/core";
1278
1336
  import { t as t9 } from "@epoch-agent/infra";
1279
1337
  import {
@@ -1300,7 +1358,7 @@ function assertResumeFlagsExclusive(opts) {
1300
1358
  }
1301
1359
  function applySettingsPath(path) {
1302
1360
  if (!path) return;
1303
- const abs = resolve(path);
1361
+ const abs = resolve2(path);
1304
1362
  if (!existsSync3(abs)) {
1305
1363
  throw new CliError(t9("flags.settings_missing", { path }), 1, t9("flags.resolved_to", { abs }));
1306
1364
  }
@@ -1308,7 +1366,7 @@ function applySettingsPath(path) {
1308
1366
  }
1309
1367
  function applyAddDirs(dirs) {
1310
1368
  if (!dirs || dirs.length === 0) return [];
1311
- const abs = dirs.map((d) => resolve(d));
1369
+ const abs = dirs.map((d) => resolve2(d));
1312
1370
  const { issues } = resolveWorkspace(process.cwd(), abs);
1313
1371
  const fatal = issues.filter((i) => i.kind !== "redundant");
1314
1372
  if (fatal.length > 0) {
@@ -1389,7 +1447,7 @@ function resolveApproverProgram(raw) {
1389
1447
  const value = raw?.trim();
1390
1448
  if (!value) return void 0;
1391
1449
  if (/\s/.test(value) || !/[\\/]/.test(value)) return value;
1392
- const abs = resolve(value);
1450
+ const abs = resolve2(value);
1393
1451
  if (!existsSync3(abs)) {
1394
1452
  throw new CliError(
1395
1453
  t9("flags.prompt_tool_missing", { value }),
@@ -1878,14 +1936,14 @@ function warnInertFlags(opts) {
1878
1936
  }
1879
1937
  // src/update-check.ts
1880
1938
  import { spawn } from "child_process";
1881
- import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1939
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync } from "fs";
1882
1940
  import { get } from "https";
1883
- import { dirname as dirname2, join as join3 } from "path";
1941
+ import { dirname as dirname3, join as join3 } from "path";
1884
1942
  import { fileURLToPath as fileURLToPath2 } from "url";
1885
1943
  import { t as t15 } from "@epoch-agent/infra";
1886
1944
  // src/version.ts
1887
1945
  import { readFileSync as readFileSync2 } from "fs";
1888
- import { dirname, join as join2 } from "path";
1946
+ import { dirname as dirname2, join as join2 } from "path";
1889
1947
  import { fileURLToPath } from "url";
1890
1948
  import { t as t14 } from "@epoch-agent/infra";
1891
1949
  // src/installation.ts
@@ -2034,7 +2092,7 @@ function getInstallationInfo(packageName, cliPath = process.argv[1]) {
2034
2092
  }
2035
2093
  // src/version.ts
2036
2094
  function readVersion() {
2037
- const here = dirname(fileURLToPath(import.meta.url));
2095
+ const here = dirname2(fileURLToPath(import.meta.url));
2038
2096
  for (const candidate of [
2039
2097
  join2(here, "..", "package.json"),
2040
2098
  join2(here, "..", "..", "package.json")
@@ -2116,7 +2174,7 @@ function defaultCachePath(home = EPOCH_HOME) {
2116
2174
  return join3(home, "update-check.json");
2117
2175
  }
2118
2176
  function selfPackage() {
2119
- const here = dirname2(fileURLToPath2(import.meta.url));
2177
+ const here = dirname3(fileURLToPath2(import.meta.url));
2120
2178
  for (const candidate of [
2121
2179
  join3(here, "..", "package.json"),
2122
2180
  join3(here, "..", "..", "package.json")
@@ -2144,7 +2202,7 @@ function readCache(path) {
2144
2202
  }
2145
2203
  function writeCache(path, cache) {
2146
2204
  try {
2147
- mkdirSync2(dirname2(path), { recursive: true });
2205
+ mkdirSync3(dirname3(path), { recursive: true });
2148
2206
  writeFileSync(path, `${JSON.stringify(cache)}
2149
2207
  `, "utf-8");
2150
2208
  } catch {
@@ -2155,14 +2213,14 @@ function registryOf(env) {
2155
2213
  }
2156
2214
  function fetchLatestFromRegistry(name, registry) {
2157
2215
  const url = `${registry}/-/package/${name.replace("/", "%2F")}/dist-tags`;
2158
- return new Promise((resolve4) => {
2216
+ return new Promise((resolve5) => {
2159
2217
  const request = get(
2160
2218
  url,
2161
2219
  { timeout: REQUEST_TIMEOUT_MS, headers: { accept: "application/json" } },
2162
2220
  (response) => {
2163
2221
  if (response.statusCode !== 200) {
2164
2222
  response.resume();
2165
- resolve4(null);
2223
+ resolve5(null);
2166
2224
  return;
2167
2225
  }
2168
2226
  let body = "";
@@ -2174,16 +2232,16 @@ function fetchLatestFromRegistry(name, registry) {
2174
2232
  response.on("end", () => {
2175
2233
  try {
2176
2234
  const tags = JSON.parse(body);
2177
- resolve4(typeof tags.latest === "string" ? tags.latest : null);
2235
+ resolve5(typeof tags.latest === "string" ? tags.latest : null);
2178
2236
  } catch {
2179
- resolve4(null);
2237
+ resolve5(null);
2180
2238
  }
2181
2239
  });
2182
- response.on("error", () => resolve4(null));
2240
+ response.on("error", () => resolve5(null));
2183
2241
  }
2184
2242
  );
2185
2243
  request.on("timeout", () => request.destroy());
2186
- request.on("error", () => resolve4(null));
2244
+ request.on("error", () => resolve5(null));
2187
2245
  });
2188
2246
  }
2189
2247
  function readUpdateNotice(options = {}) {
@@ -2264,8 +2322,8 @@ ${notice.message}
2264
2322
  // src/worktree.ts
2265
2323
  import { execFile } from "child_process";
2266
2324
  import { randomBytes } from "crypto";
2267
- import { mkdirSync as mkdirSync3 } from "fs";
2268
- import { basename, join as join4, resolve as resolve2 } from "path";
2325
+ import { mkdirSync as mkdirSync4 } from "fs";
2326
+ import { basename, join as join4, resolve as resolve3 } from "path";
2269
2327
  import { t as t16, worktreesDir } from "@epoch-agent/infra";
2270
2328
  var TIMEOUT_MS = 6e4;
2271
2329
  function git(args, cwd) {
@@ -2299,7 +2357,7 @@ async function createWorktree(cwd = process.cwd(), container = worktreesDir()) {
2299
2357
  const shortId = randomBytes(3).toString("hex");
2300
2358
  const branch = `epoch/${shortId}`;
2301
2359
  const path = join4(container, `${basename(repoRoot)}-${shortId}`);
2302
- mkdirSync3(container, { recursive: true });
2360
+ mkdirSync4(container, { recursive: true });
2303
2361
  const added = await git(["worktree", "add", "-b", branch, path, baseRef], repoRoot);
2304
2362
  if (!added.ok) {
2305
2363
  throw new CliError(t16("worktree.err_add_failed", { path }), 1, firstLine(added.stderr));
@@ -2318,7 +2376,7 @@ async function resolveRepoRoot(cwd) {
2318
2376
  t16("worktree.err_not_a_repo_hint", { cwd, why: firstLine(root.stderr) })
2319
2377
  );
2320
2378
  }
2321
- return resolve2(root.stdout.trim());
2379
+ return resolve3(root.stdout.trim());
2322
2380
  }
2323
2381
  function countLines(text) {
2324
2382
  return text.split("\n").filter((line) => line.trim() !== "").length;
@@ -2458,16 +2516,14 @@ ${t17("approval.headless_denied_hint", { tool: req.toolName })}`
2458
2516
  }
2459
2517
  console.log("\n" + formatApprovalRequest(req).join("\n"));
2460
2518
  if (req.plan) return await askPlan(req.plan);
2519
+ if (req.rememberable === false) {
2520
+ console.log(t17("approval.not_rememberable"));
2521
+ }
2461
2522
  const { select: select2 } = await import("@inquirer/prompts");
2462
2523
  try {
2463
2524
  return await select2({
2464
2525
  message: t17("approval.ask"),
2465
- choices: [
2466
- { name: t17("tui.approval.allow_once"), value: "allow-once" },
2467
- { name: t17("tui.approval.allow_session"), value: "allow-session" },
2468
- { name: t17("approval.allow_always_cli"), value: "allow-always" },
2469
- { name: t17("tui.approval.deny"), value: "deny" }
2470
- ],
2526
+ choices: approvalChoices(req),
2471
2527
  default: "allow-once"
2472
2528
  });
2473
2529
  } catch {
@@ -2475,6 +2531,16 @@ ${t17("approval.headless_denied_hint", { tool: req.toolName })}`
2475
2531
  }
2476
2532
  };
2477
2533
  }
2534
+ function approvalChoices(req) {
2535
+ return [
2536
+ { name: t17("tui.approval.allow_once"), value: "allow-once" },
2537
+ ...req.rememberable === false ? [] : [
2538
+ { name: t17("tui.approval.allow_session"), value: "allow-session" },
2539
+ { name: t17("approval.allow_always_cli"), value: "allow-always" }
2540
+ ],
2541
+ { name: t17("tui.approval.deny"), value: "deny" }
2542
+ ];
2543
+ }
2478
2544
  async function askPlan(proposal) {
2479
2545
  const { input: input2, select: select2 } = await import("@inquirer/prompts");
2480
2546
  const choices3 = [
@@ -2553,13 +2619,13 @@ function preauthorizedBy(configPolicy, cliPolicy, req) {
2553
2619
  }
2554
2620
  function askExternalApprover(program2, payload, opts = {}) {
2555
2621
  const timeoutMs = opts.timeoutMs ?? APPROVER_TIMEOUT_MS;
2556
- return new Promise((resolve4) => {
2622
+ return new Promise((resolve5) => {
2557
2623
  let settled = false;
2558
2624
  let out2 = "";
2559
2625
  const settle = (v) => {
2560
2626
  if (settled) return;
2561
2627
  settled = true;
2562
- resolve4(v);
2628
+ resolve5(v);
2563
2629
  };
2564
2630
  const child = spawn2(program2, {
2565
2631
  shell: true,
@@ -3433,7 +3499,7 @@ function resolveTuiEntry(baseDir, exists = existsSync6) {
3433
3499
  ].find(exists);
3434
3500
  }
3435
3501
  async function launchTui(resumeId) {
3436
- const target = resolveTuiEntry(dirname3(fileURLToPath3(import.meta.url)));
3502
+ const target = resolveTuiEntry(dirname4(fileURLToPath3(import.meta.url)));
3437
3503
  if (!target) {
3438
3504
  process.stderr.write(`${t25("run.tui_entry_missing")}
3439
3505
  `);
@@ -4566,7 +4632,7 @@ ${t35("cli.doctor.build_failed", {
4566
4632
  }
4567
4633
  // src/commands/trust.ts
4568
4634
  import { existsSync as existsSync8, realpathSync as realpathSync3 } from "fs";
4569
- import { resolve as resolve3 } from "path";
4635
+ import { resolve as resolve4 } from "path";
4570
4636
  import { loadConfig as loadConfig5, TrustManager as TrustManager3 } from "@epoch-agent/core";
4571
4637
  import { t as t36, trustPath as trustPath3, uiDateLocale as uiDateLocale4 } from "@epoch-agent/infra";
4572
4638
  var log11 = (msg) => process.stdout.write(msg + "\n");
@@ -4585,7 +4651,7 @@ function levelLabel(level) {
4585
4651
  }
4586
4652
  }
4587
4653
  function physicalPath(input2) {
4588
- const abs = resolve3(input2);
4654
+ const abs = resolve4(input2);
4589
4655
  if (!existsSync8(abs)) return abs;
4590
4656
  try {
4591
4657
  return realpathSync3(abs);
@@ -4623,7 +4689,7 @@ function registerTrustCommand(program2) {
4623
4689
  cmd.command("remove").alias("rm").description(t36("trust.cmd_remove")).argument("<path>", t36("trust.arg_path")).action((path) => {
4624
4690
  withTrust((tm) => {
4625
4691
  const dir = physicalPath(path);
4626
- if (!tm.list().some((r) => resolve3(r.path) === dir)) {
4692
+ if (!tm.list().some((r) => resolve4(r.path) === dir)) {
4627
4693
  warn3(t36("trust.no_record", { dir }));
4628
4694
  process.exit(1);
4629
4695
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-agent/cli",
3
- "version": "0.7.1",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "description": "epoch-agent CLI 入口",
6
6
  "repository": {
@@ -22,12 +22,12 @@
22
22
  "commander": "^15.0.0",
23
23
  "ink": "^7.1.1",
24
24
  "react": "^19.2.8",
25
- "@epoch-agent/core": "0.7.1",
26
- "@epoch-agent/infra": "0.7.1",
27
- "@epoch-agent/server": "0.7.1",
28
- "@epoch-agent/protocol": "0.7.1",
29
- "@epoch-agent/runtime": "0.7.1",
30
- "@epoch-agent/tui": "^0.7.1"
25
+ "@epoch-agent/core": "0.9.0",
26
+ "@epoch-agent/infra": "0.9.0",
27
+ "@epoch-agent/server": "0.9.0",
28
+ "@epoch-agent/tui": "^0.9.0",
29
+ "@epoch-agent/protocol": "0.9.0",
30
+ "@epoch-agent/runtime": "0.9.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.20.1",