hamster-wheel-cli 0.3.1 → 0.3.4
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/.wheel-ai/config.toml +2 -0
- package/CHANGELOG.md +12 -0
- package/README.md +7 -1
- package/dist/cli.js +30 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +33 -2
- package/src/loop.ts +3 -1
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
import fs from 'fs-extra';
|
|
3
4
|
import { Command } from 'commander';
|
|
4
5
|
import { buildLoopConfig, CliOptions, defaultNotesPath, defaultPlanPath, defaultWorkflowDoc } from './config';
|
|
@@ -85,6 +86,33 @@ const RUN_OPTION_FLAG_MAP = new Map<string, RunOptionSpec>(
|
|
|
85
86
|
|
|
86
87
|
const USE_ALIAS_FLAG = '--use-alias';
|
|
87
88
|
const USE_AGENT_FLAG = '--use-agent';
|
|
89
|
+
const PACKAGE_VERSION_FALLBACK = '0.0.0';
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 读取 package.json 中的版本号,失败时返回兜底值。
|
|
93
|
+
*/
|
|
94
|
+
async function resolveCliVersion(): Promise<string> {
|
|
95
|
+
const candidatePaths = [
|
|
96
|
+
path.resolve(__dirname, '..', 'package.json'),
|
|
97
|
+
path.resolve(process.cwd(), 'package.json')
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
for (const candidatePath of candidatePaths) {
|
|
101
|
+
const exists = await fs.pathExists(candidatePath);
|
|
102
|
+
if (!exists) continue;
|
|
103
|
+
try {
|
|
104
|
+
const pkg = (await fs.readJson(candidatePath)) as { version?: unknown };
|
|
105
|
+
if (typeof pkg?.version === 'string') {
|
|
106
|
+
const trimmed = pkg.version.trim();
|
|
107
|
+
if (trimmed.length > 0) return trimmed;
|
|
108
|
+
}
|
|
109
|
+
} catch {
|
|
110
|
+
// 读取失败则继续尝试下一个路径。
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return PACKAGE_VERSION_FALLBACK;
|
|
115
|
+
}
|
|
88
116
|
|
|
89
117
|
function parseInteger(value: string, defaultValue: number): number {
|
|
90
118
|
const parsed = Number.parseInt(value, 10);
|
|
@@ -499,15 +527,17 @@ async function runForegroundWithDetach(options: {
|
|
|
499
527
|
export async function runCli(argv: string[]): Promise<void> {
|
|
500
528
|
const globalConfig = await loadGlobalConfig(defaultLogger);
|
|
501
529
|
const effectiveArgv = applyShortcutArgv(argv, globalConfig);
|
|
530
|
+
const cliVersion = await resolveCliVersion();
|
|
502
531
|
const program = new Command();
|
|
503
532
|
|
|
504
533
|
program
|
|
505
534
|
.name('wheel-ai')
|
|
506
535
|
.description('基于 AI CLI 的持续迭代开发工具')
|
|
507
|
-
.version(
|
|
536
|
+
.version(cliVersion);
|
|
537
|
+
program.enablePositionalOptions();
|
|
508
538
|
program.addHelpText(
|
|
509
539
|
'after',
|
|
510
|
-
'\nalias 管理:\n wheel-ai alias set <name> <options...>\n wheel-ai alias list\n wheel-ai alias delete <name>\n\nalias/agent 叠加:\n wheel-ai run --use-alias <name> [--use-alias <name>...]\n wheel-ai run --use-agent <name> [--use-agent <name>...]\n 同名选项按出现顺序覆盖。\n'
|
|
540
|
+
'\nalias 管理:\n wheel-ai alias set <name> <options...>\n wheel-ai alias list\n wheel-ai alias delete <name>\n\nalias/agent 叠加:\n wheel-ai run --use-alias <name> [--use-alias <name>...]\n wheel-ai run --use-agent <name> [--use-agent <name>...]\n 同名选项按出现顺序覆盖。\n\nagent 录入包含选项时使用 -- 终止解析:\n wheel-ai agent set <name> -- <command...>\n 例如:wheel-ai agent set glm -- goose run --text\n'
|
|
511
541
|
);
|
|
512
542
|
|
|
513
543
|
program
|
|
@@ -807,6 +837,7 @@ export async function runCli(argv: string[]): Promise<void> {
|
|
|
807
837
|
agentCommand
|
|
808
838
|
.command('set <name> [command...]')
|
|
809
839
|
.description('写入 agent')
|
|
840
|
+
.passThroughOptions()
|
|
810
841
|
.allowUnknownOption(true)
|
|
811
842
|
.allowExcessArguments(true)
|
|
812
843
|
.action(async (name: string) => {
|
package/src/loop.ts
CHANGED
|
@@ -316,6 +316,8 @@ export async function runLoop(config: LoopConfig): Promise<LoopResult> {
|
|
|
316
316
|
const logger = new Logger({ verbose: config.verbose, logFile: config.logFile });
|
|
317
317
|
const repoRoot = await getRepoRoot(config.cwd, logger);
|
|
318
318
|
logger.debug(`仓库根目录: ${repoRoot}`);
|
|
319
|
+
// 项目名以首次识别为准,避免切换 worktree 后发生变化。
|
|
320
|
+
const initialProjectName = path.basename(repoRoot);
|
|
319
321
|
|
|
320
322
|
let branchName = config.git.branchName;
|
|
321
323
|
let workDir = repoRoot;
|
|
@@ -338,7 +340,7 @@ export async function runLoop(config: LoopConfig): Promise<LoopResult> {
|
|
|
338
340
|
let pushSucceeded = false;
|
|
339
341
|
|
|
340
342
|
const preWorktreeRecords: string[] = [];
|
|
341
|
-
const resolveProjectName = (): string =>
|
|
343
|
+
const resolveProjectName = (): string => initialProjectName;
|
|
342
344
|
|
|
343
345
|
const notifyWebhook = async (
|
|
344
346
|
event: 'task_start' | 'iteration_start' | 'task_end',
|