hamster-wheel-cli 0.3.2 → 0.3.5

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/dist/index.js CHANGED
@@ -38,6 +38,7 @@ module.exports = __toCommonJS(src_exports);
38
38
 
39
39
  // src/cli.ts
40
40
  var import_node_child_process = require("child_process");
41
+ var import_node_path12 = __toESM(require("path"));
41
42
  var import_fs_extra12 = __toESM(require("fs-extra"));
42
43
  var import_commander = require("commander");
43
44
 
@@ -2523,14 +2524,14 @@ async function safeRemove(logFile, logger) {
2523
2524
  }
2524
2525
  }
2525
2526
  async function createRunTracker(options) {
2526
- const { logFile, command, path: path12, logger } = options;
2527
+ const { logFile, command, path: path13, logger } = options;
2527
2528
  if (!logFile) return null;
2528
2529
  const update = async (round, tokenUsed) => {
2529
2530
  const metadata = {
2530
2531
  command,
2531
2532
  round,
2532
2533
  tokenUsed,
2533
- path: path12,
2534
+ path: path13,
2534
2535
  pid: process.pid
2535
2536
  };
2536
2537
  await safeWrite(logFile, metadata, logger);
@@ -4124,6 +4125,26 @@ var RUN_OPTION_FLAG_MAP = new Map(
4124
4125
  );
4125
4126
  var USE_ALIAS_FLAG = "--use-alias";
4126
4127
  var USE_AGENT_FLAG = "--use-agent";
4128
+ var PACKAGE_VERSION_FALLBACK = "0.0.0";
4129
+ async function resolveCliVersion() {
4130
+ const candidatePaths = [
4131
+ import_node_path12.default.resolve(__dirname, "..", "package.json"),
4132
+ import_node_path12.default.resolve(process.cwd(), "package.json")
4133
+ ];
4134
+ for (const candidatePath of candidatePaths) {
4135
+ const exists = await import_fs_extra12.default.pathExists(candidatePath);
4136
+ if (!exists) continue;
4137
+ try {
4138
+ const pkg = await import_fs_extra12.default.readJson(candidatePath);
4139
+ if (typeof pkg?.version === "string") {
4140
+ const trimmed = pkg.version.trim();
4141
+ if (trimmed.length > 0) return trimmed;
4142
+ }
4143
+ } catch {
4144
+ }
4145
+ }
4146
+ return PACKAGE_VERSION_FALLBACK;
4147
+ }
4127
4148
  function parseInteger(value, defaultValue) {
4128
4149
  const parsed = Number.parseInt(value, 10);
4129
4150
  if (Number.isNaN(parsed)) return defaultValue;
@@ -4466,11 +4487,13 @@ async function runForegroundWithDetach(options) {
4466
4487
  async function runCli(argv) {
4467
4488
  const globalConfig = await loadGlobalConfig(defaultLogger);
4468
4489
  const effectiveArgv = applyShortcutArgv(argv, globalConfig);
4490
+ const cliVersion = await resolveCliVersion();
4469
4491
  const program = new import_commander.Command();
4470
- program.name("wheel-ai").description("\u57FA\u4E8E AI CLI \u7684\u6301\u7EED\u8FED\u4EE3\u5F00\u53D1\u5DE5\u5177").version("0.2.1");
4492
+ program.name("wheel-ai").description("\u57FA\u4E8E AI CLI \u7684\u6301\u7EED\u8FED\u4EE3\u5F00\u53D1\u5DE5\u5177").version(cliVersion);
4493
+ program.enablePositionalOptions();
4471
4494
  program.addHelpText(
4472
4495
  "after",
4473
- "\nalias \u7BA1\u7406\uFF1A\n wheel-ai alias set <name> <options...>\n wheel-ai alias list\n wheel-ai alias delete <name>\n\nalias/agent \u53E0\u52A0\uFF1A\n wheel-ai run --use-alias <name> [--use-alias <name>...]\n wheel-ai run --use-agent <name> [--use-agent <name>...]\n \u540C\u540D\u9009\u9879\u6309\u51FA\u73B0\u987A\u5E8F\u8986\u76D6\u3002\n"
4496
+ "\nalias \u7BA1\u7406\uFF1A\n wheel-ai alias set <name> <options...>\n wheel-ai alias list\n wheel-ai alias delete <name>\n\nalias/agent \u53E0\u52A0\uFF1A\n wheel-ai run --use-alias <name> [--use-alias <name>...]\n wheel-ai run --use-agent <name> [--use-agent <name>...]\n \u540C\u540D\u9009\u9879\u6309\u51FA\u73B0\u987A\u5E8F\u8986\u76D6\u3002\n\nagent \u5F55\u5165\u5305\u542B\u9009\u9879\u65F6\u4F7F\u7528 -- \u7EC8\u6B62\u89E3\u6790\uFF1A\n wheel-ai agent set <name> -- <command...>\n \u4F8B\u5982\uFF1Awheel-ai agent set glm -- goose run --text\n"
4474
4497
  );
4475
4498
  program.command("run").option("-t, --task <task>", "\u9700\u8981\u5B8C\u6210\u7684\u4EFB\u52A1\u63CF\u8FF0\uFF08\u53EF\u91CD\u590D\u4F20\u5165\uFF0C\u72EC\u7ACB\u5904\u7406\uFF09", collect, []).option("--use-alias <name>", "\u53E0\u52A0 alias \u914D\u7F6E\uFF08\u53EF\u91CD\u590D\uFF09", collect, []).option("--use-agent <name>", "\u53E0\u52A0 agent \u914D\u7F6E\uFF08\u53EF\u91CD\u590D\uFF09", collect, []).option("-i, --iterations <number>", "\u6700\u5927\u8FED\u4EE3\u6B21\u6570", (value) => parseInteger(value, 5), 5).option("--ai-cli <command>", "AI CLI \u547D\u4EE4", "claude").option("--ai-args <args...>", "AI CLI \u53C2\u6570", []).option("--ai-prompt-arg <flag>", "\u7528\u4E8E\u4F20\u5165 prompt \u7684\u53C2\u6570\uFF08\u4E3A\u7A7A\u5219\u4F7F\u7528 stdin\uFF09").option("--notes-file <path>", "\u6301\u4E45\u5316\u8BB0\u5FC6\u6587\u4EF6", defaultNotesPath()).option("--plan-file <path>", "\u8BA1\u5212\u6587\u4EF6", defaultPlanPath()).option("--workflow-doc <path>", "AI \u5DE5\u4F5C\u6D41\u7A0B\u8BF4\u660E\u6587\u4EF6", defaultWorkflowDoc()).option("--worktree", "\u5728\u72EC\u7ACB worktree \u4E0A\u6267\u884C", false).option("--branch <name>", "worktree \u5206\u652F\u540D\uFF08\u9ED8\u8BA4\u81EA\u52A8\u751F\u6210\u6216\u5F53\u524D\u5206\u652F\uFF09").option("--worktree-path <path>", "worktree \u8DEF\u5F84\uFF0C\u9ED8\u8BA4 ../worktrees/<branch>").option("--base-branch <name>", "\u521B\u5EFA\u5206\u652F\u7684\u57FA\u7EBF\u5206\u652F", "main").option("--skip-install", "\u8DF3\u8FC7\u5F00\u59CB\u4EFB\u52A1\u524D\u7684\u4F9D\u8D56\u68C0\u67E5", false).option("--run-tests", "\u8FD0\u884C\u5355\u5143\u6D4B\u8BD5\u547D\u4EE4", false).option("--run-e2e", "\u8FD0\u884C e2e \u6D4B\u8BD5\u547D\u4EE4", false).option("--unit-command <cmd>", "\u5355\u5143\u6D4B\u8BD5\u547D\u4EE4", "yarn test").option("--e2e-command <cmd>", "e2e \u6D4B\u8BD5\u547D\u4EE4", "yarn e2e").option("--auto-commit", "\u81EA\u52A8 git commit", false).option("--auto-push", "\u81EA\u52A8 git push", false).option("--pr", "\u4F7F\u7528 gh \u521B\u5EFA PR", false).option("--pr-title <title>", "PR \u6807\u9898").option("--pr-body <path>", "PR \u63CF\u8FF0\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u7559\u7A7A\u81EA\u52A8\u751F\u6210\uFF09").option("--draft", "\u4EE5\u8349\u7A3F\u5F62\u5F0F\u521B\u5EFA PR", false).option("--reviewer <user...>", "PR reviewers", collect, []).option("--auto-merge", "PR \u68C0\u67E5\u901A\u8FC7\u540E\u81EA\u52A8\u5408\u5E76", false).option("--webhook <url>", "webhook \u901A\u77E5 URL\uFF08\u53EF\u91CD\u590D\uFF09", collect, []).option("--webhook-timeout <ms>", "webhook \u8BF7\u6C42\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09", (value) => parseInteger(value, 8e3)).option("--multi-task-mode <mode>", "\u591A\u4EFB\u52A1\u6267\u884C\u6A21\u5F0F\uFF08relay/serial/serial-continue/parallel\uFF0C\u6216\u4E2D\u6587\u63CF\u8FF0\uFF09", "relay").option("--stop-signal <token>", "AI \u8F93\u51FA\u4E2D\u7684\u505C\u6B62\u6807\u8BB0", "<<DONE>>").option("--log-file <path>", "\u65E5\u5FD7\u8F93\u51FA\u6587\u4EF6\u8DEF\u5F84").option("--background", "\u5207\u5165\u540E\u53F0\u8FD0\u884C", false).option("-v, --verbose", "\u8F93\u51FA\u8C03\u8BD5\u65E5\u5FD7", false).option("--skip-quality", "\u8DF3\u8FC7\u4EE3\u7801\u8D28\u91CF\u68C0\u67E5", false).action(async (options) => {
4476
4499
  const rawRunArgs = extractRunCommandArgs(effectiveArgv);
@@ -4668,8 +4691,8 @@ async function runCli(argv) {
4668
4691
  program.command("logs").description("\u67E5\u770B\u5386\u53F2\u65E5\u5FD7").action(async () => {
4669
4692
  await runLogsViewer();
4670
4693
  });
4671
- const agentCommand = program.command("agent").description("\u7BA1\u7406 AI CLI agent \u914D\u7F6E");
4672
- agentCommand.command("add <name> [command...]").description("\u65B0\u589E agent").allowUnknownOption(true).allowExcessArguments(true).action(async (name) => {
4694
+ const agentCommand = program.command("agent").description("\u7BA1\u7406 AI CLI agent \u914D\u7F6E").enablePositionalOptions();
4695
+ agentCommand.command("add <name> [command...]").description("\u65B0\u589E agent").passThroughOptions().allowUnknownOption(true).allowExcessArguments(true).action(async (name) => {
4673
4696
  const normalized = normalizeAgentName(name);
4674
4697
  if (!normalized) {
4675
4698
  throw new Error("agent \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u4E14\u4E0D\u80FD\u5305\u542B\u7A7A\u767D\u5B57\u7B26");
@@ -4689,7 +4712,7 @@ async function runCli(argv) {
4689
4712
  await upsertAgentEntry(normalized, commandLine);
4690
4713
  console.log(`\u5DF2\u65B0\u589E agent\uFF1A${normalized}`);
4691
4714
  });
4692
- agentCommand.command("set <name> [command...]").description("\u5199\u5165 agent").allowUnknownOption(true).allowExcessArguments(true).action(async (name) => {
4715
+ agentCommand.command("set <name> [command...]").description("\u5199\u5165 agent").passThroughOptions().allowUnknownOption(true).allowExcessArguments(true).action(async (name) => {
4693
4716
  const normalized = normalizeAgentName(name);
4694
4717
  if (!normalized) {
4695
4718
  throw new Error("agent \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u4E14\u4E0D\u80FD\u5305\u542B\u7A7A\u767D\u5B57\u7B26");