hamster-wheel-cli 0.3.4 → 0.3.6
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/CHANGELOG.md +8 -0
- package/dist/cli.js +11 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +22 -2
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -300,6 +300,19 @@ function extractRunCommandArgs(argv: string[]): string[] {
|
|
|
300
300
|
return args.slice(start + 1);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/**
|
|
304
|
+
* 从原始参数中提取 --ai-args 的完整值。
|
|
305
|
+
* commander 的 variadic 选项会在遇到 `-` 开头的参数时停止收集,
|
|
306
|
+
* 所以需要使用我们自己的解析逻辑来获取完整的参数列表。
|
|
307
|
+
*/
|
|
308
|
+
function extractAiArgsFromRawArgs(rawArgs: string[]): string[] {
|
|
309
|
+
const segments = parseArgSegments(rawArgs);
|
|
310
|
+
const aiArgsSegment = segments.find(segment => segment.name === 'ai-args');
|
|
311
|
+
if (!aiArgsSegment) return [];
|
|
312
|
+
// tokens 的第一个元素是 '--ai-args' 本身,后面的才是值
|
|
313
|
+
return aiArgsSegment.tokens.slice(1);
|
|
314
|
+
}
|
|
315
|
+
|
|
303
316
|
function parseUseOptionToken(token: string, flag: string): { matched: boolean; value?: string } {
|
|
304
317
|
if (token === flag) {
|
|
305
318
|
return { matched: true };
|
|
@@ -542,6 +555,8 @@ export async function runCli(argv: string[]): Promise<void> {
|
|
|
542
555
|
|
|
543
556
|
program
|
|
544
557
|
.command('run')
|
|
558
|
+
.allowUnknownOption(true)
|
|
559
|
+
.allowExcessArguments(true)
|
|
545
560
|
.option('-t, --task <task>', '需要完成的任务描述(可重复传入,独立处理)', collect, [])
|
|
546
561
|
.option('--use-alias <name>', '叠加 alias 配置(可重复)', collect, [])
|
|
547
562
|
.option('--use-agent <name>', '叠加 agent 配置(可重复)', collect, [])
|
|
@@ -699,10 +714,13 @@ export async function runCli(argv: string[]): Promise<void> {
|
|
|
699
714
|
logFile: logFileInput
|
|
700
715
|
});
|
|
701
716
|
|
|
717
|
+
// 使用自己的解析逻辑提取 --ai-args,因为 commander 的 variadic 选项
|
|
718
|
+
// 会在遇到 `-` 开头的参数时停止收集
|
|
719
|
+
const extractedAiArgs = extractAiArgsFromRawArgs(rawRunArgs);
|
|
702
720
|
const baseOptions = {
|
|
703
721
|
iterations: options.iterations as number,
|
|
704
722
|
aiCli: options.aiCli as string,
|
|
705
|
-
aiArgs: (options.aiArgs as string[]) ?? [],
|
|
723
|
+
aiArgs: extractedAiArgs.length > 0 ? extractedAiArgs : ((options.aiArgs as string[]) ?? []),
|
|
706
724
|
aiPromptArg: options.aiPromptArg as string | undefined,
|
|
707
725
|
notesFile: options.notesFile as string,
|
|
708
726
|
planFile: options.planFile as string,
|
|
@@ -804,11 +822,13 @@ export async function runCli(argv: string[]): Promise<void> {
|
|
|
804
822
|
|
|
805
823
|
const agentCommand = program
|
|
806
824
|
.command('agent')
|
|
807
|
-
.description('管理 AI CLI agent 配置')
|
|
825
|
+
.description('管理 AI CLI agent 配置')
|
|
826
|
+
.enablePositionalOptions();
|
|
808
827
|
|
|
809
828
|
agentCommand
|
|
810
829
|
.command('add <name> [command...]')
|
|
811
830
|
.description('新增 agent')
|
|
831
|
+
.passThroughOptions()
|
|
812
832
|
.allowUnknownOption(true)
|
|
813
833
|
.allowExcessArguments(true)
|
|
814
834
|
.action(async (name: string) => {
|