@epoch-agent/cli 0.7.1 → 0.8.1

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 +81 -28
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -939,6 +939,8 @@ function describeError(err2) {
939
939
  return err2 instanceof Error ? err2.message : String(err2);
940
940
  }
941
941
  // src/commands/plugin.ts
942
+ import { mkdirSync as mkdirSync2 } from "fs";
943
+ import { dirname, resolve } from "path";
942
944
  import {
943
945
  addMarketplace,
944
946
  currentEpochVersion,
@@ -946,6 +948,8 @@ import {
946
948
  inventoryTotal,
947
949
  isNonInteractive as isNonInteractive2,
948
950
  loadPlugins,
951
+ packPlugin,
952
+ planPack,
949
953
  readMarketplaces,
950
954
  readPluginManifest,
951
955
  removeMarketplace,
@@ -986,6 +990,9 @@ function registerBasics(cmd) {
986
990
  cmd.command("validate").description(t8("plugin.cmd_validate")).argument("[path]", t8("plugin.arg_dir")).action((path) => {
987
991
  validateDir(path ?? process.cwd());
988
992
  });
993
+ 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) => {
994
+ await packDir(path ?? process.cwd(), opts.out);
995
+ });
989
996
  }
990
997
  function registerLifecycle(cmd) {
991
998
  cmd.command("uninstall").alias("rm").description(t8("plugin.cmd_uninstall")).argument("<name>", t8("plugin.arg_name")).action(async (name) => {
@@ -1224,8 +1231,23 @@ function printSearch(keyword) {
1224
1231
  `);
1225
1232
  for (const hit of hits) {
1226
1233
  const category = hit.entry.category ? ` [${hit.entry.category}]` : "";
1227
- log6(` ${hit.ref}${category}`);
1234
+ const shown = hit.entry.displayName ? ` ${hit.entry.displayName}` : "";
1235
+ const version = hit.entry.version ? ` ${hit.entry.version}` : "";
1236
+ log6(` ${hit.ref}${shown}${version}${category}`);
1228
1237
  if (hit.entry.description) log6(` ${hit.entry.description}`);
1238
+ if (hit.entry.author) log6(` ${t8("plugin.search_author", { name: hit.entry.author.name })}`);
1239
+ const stats = [];
1240
+ const { downloads, likes } = hit.entry;
1241
+ if (downloads !== void 0) stats.push(t8("plugin.search_downloads", { count: downloads }));
1242
+ if (likes !== void 0) stats.push(t8("plugin.search_likes", { count: likes }));
1243
+ if (stats.length > 0) log6(` ${stats.join(" \xB7 ")}`);
1244
+ if (hit.entry.visibility) {
1245
+ log6(
1246
+ ` ${t8(
1247
+ hit.entry.visibility === "public" ? "plugin.search_public" : "plugin.search_private"
1248
+ )}`
1249
+ );
1250
+ }
1229
1251
  }
1230
1252
  log6(`
1231
1253
  ${t8("plugin.search_install_hint", { ref: hits[0]?.ref ?? t8("plugin.ref_placeholder") })}`);
@@ -1256,9 +1278,40 @@ ${t8("plugin.brings_head")}`);
1256
1278
  throw new CliError(t8("plugin.inv_issues", { count: inventory.issues.length }));
1257
1279
  }
1258
1280
  }
1281
+ async function packDir(dir, out2) {
1282
+ const target = resolve(dir);
1283
+ const planned = planPack(target);
1284
+ if (!planned.ok) throw new CliError(planned.reason);
1285
+ const plan = planned.plan;
1286
+ log6(t8("plugin.pack_head", { name: plan.manifest.name, version: plan.manifest.version }));
1287
+ for (const file of plan.files) log6(` ${file.path}`);
1288
+ log6(
1289
+ t8("plugin.pack_tally", {
1290
+ count: plan.files.length,
1291
+ kb: Math.round(plan.totalBytes / 1024)
1292
+ })
1293
+ );
1294
+ if (plan.suspicious.length > 0) {
1295
+ log6(`\u26A0 ${t8("plugin.pack_suspicious", { files: plan.suspicious.join(", ") })}`);
1296
+ }
1297
+ if (plan.skippedLinks.length > 0) {
1298
+ log6(`\u26A0 ${t8("plugin.pack_skipped_links", { files: plan.skippedLinks.join(", ") })}`);
1299
+ }
1300
+ const destDir = resolve(out2 ?? dirname(target));
1301
+ mkdirSync2(destDir, { recursive: true });
1302
+ const packed = await packPlugin(plan, destDir);
1303
+ if (!packed.ok) throw new CliError(packed.reason);
1304
+ log6(
1305
+ `\u2713 ${t8("plugin.pack_ok", {
1306
+ path: packed.archivePath,
1307
+ kb: Math.round(packed.bytes / 1024)
1308
+ })}`
1309
+ );
1310
+ log6(t8("plugin.pack_next", { path: packed.archivePath }));
1311
+ }
1259
1312
  // src/commands/run.ts
1260
1313
  import { existsSync as existsSync6 } from "fs";
1261
- import { dirname as dirname3, join as join5 } from "path";
1314
+ import { dirname as dirname4, join as join5 } from "path";
1262
1315
  import { fileURLToPath as fileURLToPath3 } from "url";
1263
1316
  import { isNonInteractive as isNonInteractive8, OPERATION_TYPES as OPERATION_TYPES3, PERMISSION_LEVELS as PERMISSION_LEVELS3 } from "@epoch-agent/core";
1264
1317
  import { t as t25 } from "@epoch-agent/infra";
@@ -1273,7 +1326,7 @@ import { t as t12 } from "@epoch-agent/infra";
1273
1326
  import { buildRuntime } from "@epoch-agent/runtime";
1274
1327
  // src/commands/run-flags.ts
1275
1328
  import { existsSync as existsSync3 } from "fs";
1276
- import { delimiter, resolve } from "path";
1329
+ import { delimiter, resolve as resolve2 } from "path";
1277
1330
  import { isOperationType, resolveWorkspace } from "@epoch-agent/core";
1278
1331
  import { t as t9 } from "@epoch-agent/infra";
1279
1332
  import {
@@ -1300,7 +1353,7 @@ function assertResumeFlagsExclusive(opts) {
1300
1353
  }
1301
1354
  function applySettingsPath(path) {
1302
1355
  if (!path) return;
1303
- const abs = resolve(path);
1356
+ const abs = resolve2(path);
1304
1357
  if (!existsSync3(abs)) {
1305
1358
  throw new CliError(t9("flags.settings_missing", { path }), 1, t9("flags.resolved_to", { abs }));
1306
1359
  }
@@ -1308,7 +1361,7 @@ function applySettingsPath(path) {
1308
1361
  }
1309
1362
  function applyAddDirs(dirs) {
1310
1363
  if (!dirs || dirs.length === 0) return [];
1311
- const abs = dirs.map((d) => resolve(d));
1364
+ const abs = dirs.map((d) => resolve2(d));
1312
1365
  const { issues } = resolveWorkspace(process.cwd(), abs);
1313
1366
  const fatal = issues.filter((i) => i.kind !== "redundant");
1314
1367
  if (fatal.length > 0) {
@@ -1389,7 +1442,7 @@ function resolveApproverProgram(raw) {
1389
1442
  const value = raw?.trim();
1390
1443
  if (!value) return void 0;
1391
1444
  if (/\s/.test(value) || !/[\\/]/.test(value)) return value;
1392
- const abs = resolve(value);
1445
+ const abs = resolve2(value);
1393
1446
  if (!existsSync3(abs)) {
1394
1447
  throw new CliError(
1395
1448
  t9("flags.prompt_tool_missing", { value }),
@@ -1878,14 +1931,14 @@ function warnInertFlags(opts) {
1878
1931
  }
1879
1932
  // src/update-check.ts
1880
1933
  import { spawn } from "child_process";
1881
- import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1934
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync } from "fs";
1882
1935
  import { get } from "https";
1883
- import { dirname as dirname2, join as join3 } from "path";
1936
+ import { dirname as dirname3, join as join3 } from "path";
1884
1937
  import { fileURLToPath as fileURLToPath2 } from "url";
1885
1938
  import { t as t15 } from "@epoch-agent/infra";
1886
1939
  // src/version.ts
1887
1940
  import { readFileSync as readFileSync2 } from "fs";
1888
- import { dirname, join as join2 } from "path";
1941
+ import { dirname as dirname2, join as join2 } from "path";
1889
1942
  import { fileURLToPath } from "url";
1890
1943
  import { t as t14 } from "@epoch-agent/infra";
1891
1944
  // src/installation.ts
@@ -2034,7 +2087,7 @@ function getInstallationInfo(packageName, cliPath = process.argv[1]) {
2034
2087
  }
2035
2088
  // src/version.ts
2036
2089
  function readVersion() {
2037
- const here = dirname(fileURLToPath(import.meta.url));
2090
+ const here = dirname2(fileURLToPath(import.meta.url));
2038
2091
  for (const candidate of [
2039
2092
  join2(here, "..", "package.json"),
2040
2093
  join2(here, "..", "..", "package.json")
@@ -2116,7 +2169,7 @@ function defaultCachePath(home = EPOCH_HOME) {
2116
2169
  return join3(home, "update-check.json");
2117
2170
  }
2118
2171
  function selfPackage() {
2119
- const here = dirname2(fileURLToPath2(import.meta.url));
2172
+ const here = dirname3(fileURLToPath2(import.meta.url));
2120
2173
  for (const candidate of [
2121
2174
  join3(here, "..", "package.json"),
2122
2175
  join3(here, "..", "..", "package.json")
@@ -2144,7 +2197,7 @@ function readCache(path) {
2144
2197
  }
2145
2198
  function writeCache(path, cache) {
2146
2199
  try {
2147
- mkdirSync2(dirname2(path), { recursive: true });
2200
+ mkdirSync3(dirname3(path), { recursive: true });
2148
2201
  writeFileSync(path, `${JSON.stringify(cache)}
2149
2202
  `, "utf-8");
2150
2203
  } catch {
@@ -2155,14 +2208,14 @@ function registryOf(env) {
2155
2208
  }
2156
2209
  function fetchLatestFromRegistry(name, registry) {
2157
2210
  const url = `${registry}/-/package/${name.replace("/", "%2F")}/dist-tags`;
2158
- return new Promise((resolve4) => {
2211
+ return new Promise((resolve5) => {
2159
2212
  const request = get(
2160
2213
  url,
2161
2214
  { timeout: REQUEST_TIMEOUT_MS, headers: { accept: "application/json" } },
2162
2215
  (response) => {
2163
2216
  if (response.statusCode !== 200) {
2164
2217
  response.resume();
2165
- resolve4(null);
2218
+ resolve5(null);
2166
2219
  return;
2167
2220
  }
2168
2221
  let body = "";
@@ -2174,16 +2227,16 @@ function fetchLatestFromRegistry(name, registry) {
2174
2227
  response.on("end", () => {
2175
2228
  try {
2176
2229
  const tags = JSON.parse(body);
2177
- resolve4(typeof tags.latest === "string" ? tags.latest : null);
2230
+ resolve5(typeof tags.latest === "string" ? tags.latest : null);
2178
2231
  } catch {
2179
- resolve4(null);
2232
+ resolve5(null);
2180
2233
  }
2181
2234
  });
2182
- response.on("error", () => resolve4(null));
2235
+ response.on("error", () => resolve5(null));
2183
2236
  }
2184
2237
  );
2185
2238
  request.on("timeout", () => request.destroy());
2186
- request.on("error", () => resolve4(null));
2239
+ request.on("error", () => resolve5(null));
2187
2240
  });
2188
2241
  }
2189
2242
  function readUpdateNotice(options = {}) {
@@ -2264,8 +2317,8 @@ ${notice.message}
2264
2317
  // src/worktree.ts
2265
2318
  import { execFile } from "child_process";
2266
2319
  import { randomBytes } from "crypto";
2267
- import { mkdirSync as mkdirSync3 } from "fs";
2268
- import { basename, join as join4, resolve as resolve2 } from "path";
2320
+ import { mkdirSync as mkdirSync4 } from "fs";
2321
+ import { basename, join as join4, resolve as resolve3 } from "path";
2269
2322
  import { t as t16, worktreesDir } from "@epoch-agent/infra";
2270
2323
  var TIMEOUT_MS = 6e4;
2271
2324
  function git(args, cwd) {
@@ -2299,7 +2352,7 @@ async function createWorktree(cwd = process.cwd(), container = worktreesDir()) {
2299
2352
  const shortId = randomBytes(3).toString("hex");
2300
2353
  const branch = `epoch/${shortId}`;
2301
2354
  const path = join4(container, `${basename(repoRoot)}-${shortId}`);
2302
- mkdirSync3(container, { recursive: true });
2355
+ mkdirSync4(container, { recursive: true });
2303
2356
  const added = await git(["worktree", "add", "-b", branch, path, baseRef], repoRoot);
2304
2357
  if (!added.ok) {
2305
2358
  throw new CliError(t16("worktree.err_add_failed", { path }), 1, firstLine(added.stderr));
@@ -2318,7 +2371,7 @@ async function resolveRepoRoot(cwd) {
2318
2371
  t16("worktree.err_not_a_repo_hint", { cwd, why: firstLine(root.stderr) })
2319
2372
  );
2320
2373
  }
2321
- return resolve2(root.stdout.trim());
2374
+ return resolve3(root.stdout.trim());
2322
2375
  }
2323
2376
  function countLines(text) {
2324
2377
  return text.split("\n").filter((line) => line.trim() !== "").length;
@@ -2553,13 +2606,13 @@ function preauthorizedBy(configPolicy, cliPolicy, req) {
2553
2606
  }
2554
2607
  function askExternalApprover(program2, payload, opts = {}) {
2555
2608
  const timeoutMs = opts.timeoutMs ?? APPROVER_TIMEOUT_MS;
2556
- return new Promise((resolve4) => {
2609
+ return new Promise((resolve5) => {
2557
2610
  let settled = false;
2558
2611
  let out2 = "";
2559
2612
  const settle = (v) => {
2560
2613
  if (settled) return;
2561
2614
  settled = true;
2562
- resolve4(v);
2615
+ resolve5(v);
2563
2616
  };
2564
2617
  const child = spawn2(program2, {
2565
2618
  shell: true,
@@ -3433,7 +3486,7 @@ function resolveTuiEntry(baseDir, exists = existsSync6) {
3433
3486
  ].find(exists);
3434
3487
  }
3435
3488
  async function launchTui(resumeId) {
3436
- const target = resolveTuiEntry(dirname3(fileURLToPath3(import.meta.url)));
3489
+ const target = resolveTuiEntry(dirname4(fileURLToPath3(import.meta.url)));
3437
3490
  if (!target) {
3438
3491
  process.stderr.write(`${t25("run.tui_entry_missing")}
3439
3492
  `);
@@ -4566,7 +4619,7 @@ ${t35("cli.doctor.build_failed", {
4566
4619
  }
4567
4620
  // src/commands/trust.ts
4568
4621
  import { existsSync as existsSync8, realpathSync as realpathSync3 } from "fs";
4569
- import { resolve as resolve3 } from "path";
4622
+ import { resolve as resolve4 } from "path";
4570
4623
  import { loadConfig as loadConfig5, TrustManager as TrustManager3 } from "@epoch-agent/core";
4571
4624
  import { t as t36, trustPath as trustPath3, uiDateLocale as uiDateLocale4 } from "@epoch-agent/infra";
4572
4625
  var log11 = (msg) => process.stdout.write(msg + "\n");
@@ -4585,7 +4638,7 @@ function levelLabel(level) {
4585
4638
  }
4586
4639
  }
4587
4640
  function physicalPath(input2) {
4588
- const abs = resolve3(input2);
4641
+ const abs = resolve4(input2);
4589
4642
  if (!existsSync8(abs)) return abs;
4590
4643
  try {
4591
4644
  return realpathSync3(abs);
@@ -4623,7 +4676,7 @@ function registerTrustCommand(program2) {
4623
4676
  cmd.command("remove").alias("rm").description(t36("trust.cmd_remove")).argument("<path>", t36("trust.arg_path")).action((path) => {
4624
4677
  withTrust((tm) => {
4625
4678
  const dir = physicalPath(path);
4626
- if (!tm.list().some((r) => resolve3(r.path) === dir)) {
4679
+ if (!tm.list().some((r) => resolve4(r.path) === dir)) {
4627
4680
  warn3(t36("trust.no_record", { dir }));
4628
4681
  process.exit(1);
4629
4682
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-agent/cli",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
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.8.1",
26
+ "@epoch-agent/runtime": "0.8.1",
27
+ "@epoch-agent/infra": "0.8.1",
28
+ "@epoch-agent/protocol": "0.8.1",
29
+ "@epoch-agent/tui": "^0.8.1",
30
+ "@epoch-agent/server": "0.8.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.20.1",