@ai-agent-forge/agent-forge 0.85.11 → 0.85.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAK3D,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE3C,MAAM,WAAW,IAAI;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,SAAS,CAA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EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE;AAMD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAExE;AAED,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa,CAE1E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGtE;AA2DD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAwV9C;AAED,wBAAgB,SAAS,IAAI,IAAI,CAsMhC","sourcesContent":["/**\n * CLI argument parsing and help display\n */\n\nimport type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_SESSION_DIR } from \"../config.ts\";\nimport type { HostLogLevel } from \"../core/logger.ts\";\nimport type { TuiMode } from \"../core/settings-manager.ts\";\n// TRACE_KINDS_V1 is a value import, but observability-types.ts has no runtime\n// edges (its two imports are type-only), so no import cycle can form here.\nimport { TRACE_KINDS_V1 } from \"../plugins/observability-types.ts\";\n\nexport type Mode = \"text\" | \"json\" | \"rpc\";\n\nexport interface Args {\n\tprovider?: string;\n\tmodel?: string;\n\tapiKey?: string;\n\tsystemPrompt?: string;\n\tappendSystemPrompt?: string[];\n\tthinking?: ThinkingLevel;\n\tcontinue?: boolean;\n\tresume?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n\tmode?: Mode;\n\tname?: string;\n\tnoSession?: boolean;\n\tsession?: string;\n\tsessionId?: string;\n\tfork?: string;\n\tsessionDir?: string;\n\t/** Suite (方案) id for session workspace and context assembly. */\n\tsuite?: string;\n\t/** One-shot lifecycle action: create the user suite workspace (设计 §9). */\n\tsuiteCreate?: string;\n\t/** Companion of --suite-create: clone the source suite workspace. */\n\tcloneFrom?: string;\n\t/** One-shot lifecycle action: delete the user suite workspace (设计 §9). */\n\tsuiteDelete?: string;\n\t/** One-shot lifecycle action: reset a builtin suite to factory contents (设计 §9). */\n\tsuiteReset?: string;\n\t/** Serve the coding-agent session runtime over TCP on the given port. */\n\tserve?: number;\n\t/** Opt-in `--serve` workspace boundary: remote creates must resolve inside one of these roots (repeatable). */\n\tserveWorkspaceRoots?: string[];\n\t/**\n\t * Run as a headless subagent runner (D-045 pooled increment 2b): serve the\n\t * subagent-task command surface on stdio for a parent session's runner pool.\n\t */\n\tsubagentRunner?: boolean;\n\tmodels?: string[];\n\ttools?: string[];\n\texcludeTools?: string[];\n\tnoTools?: boolean;\n\tnoBuiltinTools?: boolean;\n\tnoPlugins?: boolean;\n\t/** Disable session trace collection: equivalent to SDK `traceEnabled: false`. */\n\tnoTrace?: boolean;\n\t/** Host log level. Overrides AGENT_FORGE_LOG_LEVEL; default \"info\". */\n\tlogLevel?: HostLogLevel;\n\t/** Explicit builtin plugin profile for this run. */\n\tpluginProfile?: string;\n\t/** Explicit plugin IDs selected for the profile. */\n\tplugins?: string[];\n\t/** Explicit plugin IDs disabled for the profile. */\n\tdisabledPlugins?: string[];\n\t/** Persistence scope for explicit plugin selection: global by default. */\n\tpluginSelectionScope?: \"global\" | \"project\";\n\tprint?: boolean;\n\texport?: string;\n\t/** View a session's trace file (session id, path, or empty for the most recent session). */\n\ttrace?: string;\n\t/** Structured records output for --trace (设计 §8 第 3 期). */\n\ttraceJson?: boolean;\n\t/** With --trace, show only records whose kind is in this whitelist (TRACE_KINDS_V1 members). */\n\ttraceKind?: string[];\n\t/** With --trace, show only the last N records (positive integer). */\n\ttraceLimit?: number;\n\tnoSkills?: boolean;\n\tskills?: string[];\n\tpromptTemplates?: string[];\n\tnoPromptTemplates?: boolean;\n\tthemes?: string[];\n\tuseTheme?: string;\n\tnoThemes?: boolean;\n\tnoContextFiles?: boolean;\n\tlistModels?: string | true;\n\toffline?: boolean;\n\ttuiMode?: TuiMode;\n\tverbose?: boolean;\n\tmessages: string[];\n\tfileArgs: string[];\n\tdiagnostics: Array<{ type: \"warning\" | \"error\"; message: string }>;\n}\n\nconst VALID_THINKING_LEVELS = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\n\nconst VALID_LOG_LEVELS = [\"debug\", \"info\", \"warn\", \"error\"] as const;\n\nexport function isValidHostLogLevel(level: string): level is HostLogLevel {\n\treturn VALID_LOG_LEVELS.includes(level as HostLogLevel);\n}\n\n/** Single source of valid `--trace-kind` values: the TRACE_KINDS_V1 runtime mirror. */\nexport function isValidTraceKind(kind: string): boolean {\n\treturn (TRACE_KINDS_V1 as readonly string[]).includes(kind);\n}\n\n/** Keep CLI plugin selection bounded before it reaches profile resolution. */\nexport const MAX_PLUGIN_CLI_ID_CHARS = 128;\nexport const MAX_PLUGIN_CLI_IDS = 128;\n\nexport function isValidThinkingLevel(level: string): level is ThinkingLevel {\n\treturn VALID_THINKING_LEVELS.includes(level as ThinkingLevel);\n}\n\nexport function normalizeSessionName(value: string): string | undefined {\n\tconst name = value.trim();\n\treturn name.length > 0 ? name : undefined;\n}\n\nfunction parseBoundedPluginId(\n\targs: string[],\n\tindex: number,\n\tresult: Args,\n\toption: \"--plugin\" | \"--disable-plugin\",\n\tvalues: string[],\n): number {\n\tconst raw = args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a plugin id` });\n\t\treturn index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a non-empty plugin id` });\n\t\treturn index + 1;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tif (values.length >= MAX_PLUGIN_CLI_IDS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tvalues.push(value);\n\treturn index + 1;\n}\n\nfunction parsePluginProfileValue(args: string[], index: number, result: Args, rawValue?: string): number {\n\tconst raw = rawValue ?? args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a profile id\" });\n\t\treturn rawValue === undefined ? index : index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a non-empty profile id\" });\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `--plugin-profile id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tresult.pluginProfile = value;\n\treturn rawValue === undefined ? index + 1 : index;\n}\n\nexport function parseArgs(args: string[]): Args {\n\tconst result: Args = {\n\t\tmessages: [],\n\t\tfileArgs: [],\n\t\tdiagnostics: [],\n\t};\n\n\tfor (let i = 0; i < args.length; i++) {\n\t\tconst arg = args[i];\n\n\t\tif (arg === \"--\") {\n\t\t\tfor (const positionalArg of args.slice(i + 1)) {\n\t\t\t\tif (positionalArg.startsWith(\"@\")) {\n\t\t\t\t\tresult.fileArgs.push(positionalArg.slice(1));\n\t\t\t\t} else {\n\t\t\t\t\tresult.messages.push(positionalArg);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t} else if (arg === \"--help\" || arg === \"-h\") {\n\t\t\tresult.help = true;\n\t\t} else if (arg === \"--version\" || arg === \"-v\") {\n\t\t\tresult.version = true;\n\t\t} else if (arg === \"--mode\" && i + 1 < args.length) {\n\t\t\tconst mode = args[++i];\n\t\t\tif (mode === \"text\" || mode === \"json\" || mode === \"rpc\") {\n\t\t\t\tresult.mode = mode;\n\t\t\t}\n\t\t} else if (arg === \"--continue\" || arg === \"-c\") {\n\t\t\tresult.continue = true;\n\t\t} else if (arg === \"--resume\" || arg === \"-r\") {\n\t\t\tresult.resume = true;\n\t\t} else if (arg === \"--provider\" && i + 1 < args.length) {\n\t\t\tresult.provider = args[++i];\n\t\t} else if ((arg === \"--model\" || arg === \"-m\") && i + 1 < args.length) {\n\t\t\tresult.model = args[++i];\n\t\t} else if (arg === \"--api-key\" && i + 1 < args.length) {\n\t\t\tresult.apiKey = args[++i];\n\t\t} else if (arg === \"--system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.systemPrompt = args[++i];\n\t\t} else if (arg === \"--append-system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.appendSystemPrompt = result.appendSystemPrompt ?? [];\n\t\t\tresult.appendSystemPrompt.push(args[++i]);\n\t\t} else if (arg === \"--name\" || arg === \"-n\") {\n\t\t\tif (i + 1 < args.length) {\n\t\t\t\tresult.name = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--name requires a value\" });\n\t\t\t}\n\t\t} else if (arg === \"--no-session\") {\n\t\t\tresult.noSession = true;\n\t\t} else if (arg === \"--session\" && i + 1 < args.length) {\n\t\t\tresult.session = args[++i];\n\t\t} else if (arg === \"--session-id\" && i + 1 < args.length) {\n\t\t\tresult.sessionId = args[++i];\n\t\t} else if (arg === \"--fork\" && i + 1 < args.length) {\n\t\t\tresult.fork = args[++i];\n\t\t} else if (arg === \"--session-dir\" && i + 1 < args.length) {\n\t\t\tresult.sessionDir = args[++i];\n\t\t} else if (arg === \"--suite\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suite = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-create\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteCreate = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-create requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--clone-from\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.cloneFrom = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--clone-from requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-delete\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteDelete = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-delete requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-reset\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteReset = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-reset requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--serve\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tconst port = raw !== undefined && /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\tif (Number.isInteger(port) && port <= 65535) {\n\t\t\t\tresult.serve = port;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve requires a valid TCP port (0-65535)\" });\n\t\t\t\tif (raw !== undefined) i++;\n\t\t\t}\n\t\t} else if (arg === \"--subagent-runner\") {\n\t\t\tresult.subagentRunner = true;\n\t\t} else if (arg === \"--serve-workspace-root\") {\n\t\t\tconst dir = args[i + 1];\n\t\t\tif (dir === undefined || dir.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve-workspace-root requires a directory\" });\n\t\t\t} else {\n\t\t\t\tresult.serveWorkspaceRoots = result.serveWorkspaceRoots ?? [];\n\t\t\t\tresult.serveWorkspaceRoots.push(dir);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--models\" && i + 1 < args.length) {\n\t\t\tresult.models = args[++i].split(\",\").map((s) => s.trim());\n\t\t} else if (arg === \"--no-tools\" || arg === \"-nt\") {\n\t\t\tresult.noTools = true;\n\t\t} else if (arg === \"--no-builtin-tools\" || arg === \"-nbt\") {\n\t\t\tresult.noBuiltinTools = true;\n\t\t} else if ((arg === \"--tools\" || arg === \"-t\") && i + 1 < args.length) {\n\t\t\tresult.tools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if ((arg === \"--exclude-tools\" || arg === \"-xt\") && i + 1 < args.length) {\n\t\t\tresult.excludeTools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if (arg === \"--thinking\" && i + 1 < args.length) {\n\t\t\tconst level = args[++i];\n\t\t\tif (isValidThinkingLevel(level)) {\n\t\t\t\tresult.thinking = level;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Invalid thinking level \"${level}\". Valid values: ${VALID_THINKING_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--print\" || arg === \"-p\") {\n\t\t\tresult.print = true;\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"@\") && (!next.startsWith(\"-\") || next.startsWith(\"---\"))) {\n\t\t\t\tresult.messages.push(next);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--export\" && i + 1 < args.length) {\n\t\t\tresult.export = args[++i];\n\t\t} else if (arg === \"--trace\") {\n\t\t\t// View command: bare --trace targets the most recent session; a\n\t\t\t// following non-option token is the session id or trace/session path.\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"-\")) {\n\t\t\t\tresult.trace = next;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.trace = \"\";\n\t\t\t}\n\t\t} else if (arg === \"--trace-json\") {\n\t\t\tresult.traceJson = true;\n\t\t} else if (arg === \"--trace-kind\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires a comma-separated kind list\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst kinds = raw\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((kind) => kind.trim())\n\t\t\t\t\t.filter((kind) => kind.length > 0);\n\t\t\t\tconst invalid = kinds.filter((kind) => !isValidTraceKind(kind));\n\t\t\t\tif (kinds.length === 0) {\n\t\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires at least one trace kind\" });\n\t\t\t\t} else if (invalid.length > 0) {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace kind(s) \"${invalid.join(\", \")}\". Valid values: ${TRACE_KINDS_V1.join(\", \")}`,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.traceKind = kinds;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--trace-limit\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-limit requires a positive integer\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst limit = /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\t\tif (Number.isInteger(limit) && limit > 0) {\n\t\t\t\t\tresult.traceLimit = limit;\n\t\t\t\t} else {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace limit \"${raw}\". Expected a positive integer`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--no-plugins\" || arg === \"-np\") {\n\t\t\tresult.noPlugins = true;\n\t\t} else if (arg === \"--no-trace\") {\n\t\t\tresult.noTrace = true;\n\t\t} else if (arg === \"--log-level\") {\n\t\t\tconst level = args[i + 1];\n\t\t\tif (level === undefined || level.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--log-level requires a level\" });\n\t\t\t} else if (!isValidHostLogLevel(level)) {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid log level \"${level}\". Valid values: ${VALID_LOG_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.logLevel = level;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--plugin-profile\") {\n\t\t\ti = parsePluginProfileValue(args, i, result);\n\t\t} else if (arg.startsWith(\"--plugin-profile=\")) {\n\t\t\tparsePluginProfileValue(args, i, result, arg.slice(\"--plugin-profile=\".length));\n\t\t} else if (arg === \"--plugin-scope\" || arg.startsWith(\"--plugin-scope=\")) {\n\t\t\tconst raw = arg === \"--plugin-scope\" ? args[i + 1] : arg.slice(\"--plugin-scope=\".length);\n\t\t\tif (arg === \"--plugin-scope\") i++;\n\t\t\tif (raw !== \"global\" && raw !== \"project\") {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope must be global or project\" });\n\t\t\t} else if (result.pluginSelectionScope !== undefined) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope may be specified only once\" });\n\t\t\t} else {\n\t\t\t\tresult.pluginSelectionScope = raw;\n\t\t\t}\n\t\t} else if (arg === \"--plugin\") {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--plugin\", result.plugins);\n\t\t} else if (arg.startsWith(\"--plugin=\")) {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\tconst value = arg.slice(\"--plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.plugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.plugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--disable-plugin\") {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--disable-plugin\", result.disabledPlugins);\n\t\t} else if (arg.startsWith(\"--disable-plugin=\")) {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\tconst value = arg.slice(\"--disable-plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--disable-plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.disabledPlugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.disabledPlugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--skill\" && i + 1 < args.length) {\n\t\t\tresult.skills = result.skills ?? [];\n\t\t\tresult.skills.push(args[++i]);\n\t\t} else if (arg === \"--prompt-template\" && i + 1 < args.length) {\n\t\t\tresult.promptTemplates = result.promptTemplates ?? [];\n\t\t\tresult.promptTemplates.push(args[++i]);\n\t\t} else if (arg === \"--theme\" && i + 1 < args.length) {\n\t\t\tresult.themes = result.themes ?? [];\n\t\t\tresult.themes.push(args[++i]);\n\t\t} else if (arg === \"--use-theme\") {\n\t\t\tconst themeName = args[i + 1];\n\t\t\tif (themeName === undefined || themeName.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--use-theme requires a theme name\" });\n\t\t\t} else {\n\t\t\t\tresult.useTheme = themeName;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--no-skills\" || arg === \"-ns\") {\n\t\t\tresult.noSkills = true;\n\t\t} else if (arg === \"--no-prompt-templates\" || arg === \"-np\") {\n\t\t\tresult.noPromptTemplates = true;\n\t\t} else if (arg === \"--no-themes\") {\n\t\t\tresult.noThemes = true;\n\t\t} else if (arg === \"--no-context-files\" || arg === \"-nc\") {\n\t\t\tresult.noContextFiles = true;\n\t\t} else if (arg === \"--list-models\") {\n\t\t\t// Check if next arg is a search pattern (not a flag or file arg)\n\t\t\tif (i + 1 < args.length && !args[i + 1].startsWith(\"-\") && !args[i + 1].startsWith(\"@\")) {\n\t\t\t\tresult.listModels = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.listModels = true;\n\t\t\t}\n\t\t} else if (arg === \"--tui-mode\") {\n\t\t\tconst mode = args[i + 1];\n\t\t\tif (mode === \"regular\" || mode === \"fullscreen\") {\n\t\t\t\tresult.tuiMode = mode;\n\t\t\t\ti++;\n\t\t\t} else if (mode === undefined || mode.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--tui-mode requires regular or fullscreen\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid TUI mode \"${mode}\". Valid values: regular, fullscreen`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--verbose\") {\n\t\t\tresult.verbose = true;\n\t\t} else if (arg === \"--offline\") {\n\t\t\tresult.offline = true;\n\t\t} else if (arg.startsWith(\"@\")) {\n\t\t\tresult.fileArgs.push(arg.slice(1)); // Remove @ prefix\n\t\t} else if (arg.startsWith(\"--\")) {\n\t\t\t// Unknown long options are errors: extension-registered CLI flags no\n\t\t\t// longer exist, so there is nothing left that could claim them.\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg.split(\"=\")[0]}` });\n\t\t\ti++;\n\t\t} else if (arg.startsWith(\"-\") && !arg.startsWith(\"--\")) {\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg}` });\n\t\t} else if (!arg.startsWith(\"-\")) {\n\t\t\tresult.messages.push(arg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function printHelp(): void {\n\tconsole.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools\n\n${chalk.bold(\"Usage:\")}\n ${APP_NAME} [options] [--] [@files...] [messages...]\n\n${chalk.bold(\"Commands:\")}\n ${APP_NAME} install <source> [-l] Install extension source and add to settings\n ${APP_NAME} remove <source> [-l] Remove extension source from settings\n ${APP_NAME} uninstall <source> [-l] Alias for remove\n ${APP_NAME} update [source|self|agent-forge] Update Agent Forge, extensions, or model catalogs\n ${APP_NAME} list List installed extensions from settings\n ${APP_NAME} config [-l] Open TUI to enable/disable package resources (Tab switches scope)\n ${APP_NAME} auth <command> Print credentials or check provider readiness\n ${APP_NAME} <command> --help Show help for install/remove/uninstall/update/list/config/auth\n\n${chalk.bold(\"Options:\")}\n --provider <name> Provider name (default: google)\n --model <pattern> Model pattern or ID (supports \"provider/id\" and optional \":<thinking>\")\n --api-key <key> API key (defaults to env vars)\n --system-prompt <text> System prompt (default: coding assistant prompt)\n --append-system-prompt <text> Append text or file contents to the system prompt (can be used multiple times)\n --mode <mode> Output mode: text (default), json, or rpc\n --print, -p Non-interactive mode: process prompt and exit\n --continue, -c Continue previous session\n --resume, -r Select a session to resume\n --session <path|id> Use specific session file or partial UUID\n --session-id <id> Use exact project session ID, creating it if missing\n --fork <path|id> Fork specific session file or partial UUID into a new session\n --session-dir <dir> Directory for session storage and lookup\n --suite <id> Suite (方案) for this run: assistant (default) or coding; new sessions only\n --suite-create <id> Create a user suite workspace and exit; add --clone-from <id> to copy one\n --suite-delete <id> Delete a user suite workspace (active session references refuse) and exit\n --suite-reset <id> Reset a builtin suite to factory contents (shows a diff) and exit\n --serve <port> (Experimental, local trust only) Serve the coding-agent session runtime over the WebSocket gateway (default: 127.0.0.1; HTTP surface: /healthz plus token-protected artifact reads) and exit on SIGINT/SIGTERM\n Durable journal: <agentDir>/remote-server-journal.jsonl (never the process cwd)\n --serve-workspace-root <dir> Opt-in --serve boundary: remote creates must run inside one of these roots (repeatable); without it any local directory is allowed\n --subagent-runner (Experimental) Run as a headless subagent runner: serve the subagent-task protocol on stdio for a parent session's runner pool (D-045)\n --no-session Don't save session (ephemeral)\n --name, -n <name> Set session display name\n --models <patterns> Comma-separated model patterns for Ctrl+P cycling\n Supports globs (anthropic/*, *sonnet*) and fuzzy matching\n --no-tools, -nt Disable all tools by default (built-in and plugin)\n --no-builtin-tools, -nbt Disable built-in tools by default but keep plugin/custom tools enabled\n --tools, -t <tools> Comma-separated allowlist of tool names to enable\n Applies to built-in, plugin, and custom tools\n --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable\n Applies to built-in, plugin, and custom tools\n --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max\n --no-plugins, -np Disable capability plugin discovery (D-028 escape hatch)\n --no-trace Disable session trace collection (no .trace.jsonl file is written)\n --log-level <level> Host log level: debug, info (default), warn, error\n --plugin-profile <id> Select a builtin capability plugin profile for this run\n --plugin <id> Select a plugin within the profile (repeatable)\n --disable-plugin <id> Disable a plugin within the profile (repeatable)\n --plugin-scope <scope> Read the explicit selection from global or project storage\n plugin catalog list List installed/available ecosystem plugins (independent namespace)\n --skill <path> Load a skill file or directory (can be used multiple times)\n --no-skills, -ns Disable skills discovery and loading\n --prompt-template <path> Load a prompt template file or directory (can be used multiple times)\n --no-prompt-templates, -np Disable prompt template discovery and loading\n --theme <path> Load a theme file or directory (can be used multiple times)\n --use-theme <name[/name]> Set the initial interactive theme for this run\n --no-themes Disable theme discovery and loading\n --no-context-files, -nc Disable AGENTS.md and CLAUDE.md discovery and loading\n --export <file> Export session file to HTML and exit\n --trace <session> View a session trace file as a text timeline and exit; <session> is a session id/prefix or trace/session file path, omit it for the most recent session\n --trace-json With --trace, output the structured trace records as JSON instead of the text timeline\n --trace-kind <k1,k2> With --trace, show only records of these kinds (comma-separated); valid kinds: ${TRACE_KINDS_V1.join(\", \")}\n --trace-limit <n> With --trace, show only the last N records (positive integer)\n --list-models [search] List available models (with optional fuzzy search)\n --verbose Force verbose startup (overrides quietStartup setting)\n --tui-mode <mode> TUI mode: regular (default) or fullscreen\n --offline Disable startup network operations (same as AGENT_FORGE_OFFLINE=1)\n -- End option parsing; treat remaining arguments as messages/files\n --help, -h Show this help\n --version, -v Show version number\n\n${chalk.bold(\"Examples:\")}\n # Print a provider API key for an external client\n ${APP_NAME} auth print-api-key --provider openai\n\n # Print an OAuth bearer token for an external client (refreshes if expired)\n ${APP_NAME} auth print-bearer-token --provider openai-codex\n\n # Interactive mode\n ${APP_NAME}\n\n # Interactive mode with initial prompt\n ${APP_NAME} \"List all .ts files in src/\"\n\n # Include files in initial message\n ${APP_NAME} @prompt.md @image.png \"What color is the sky?\"\n\n # Non-interactive mode (process and exit)\n ${APP_NAME} -p \"List all .ts files in src/\"\n\n # Prompt beginning with a dash\n ${APP_NAME} -p -- \"- Summarize these points\"\n\n # Multiple messages (interactive)\n ${APP_NAME} \"Read package.json\" \"What dependencies do we have?\"\n\n # Continue previous session\n ${APP_NAME} --continue \"What did we discuss?\"\n\n # Start a named session\n ${APP_NAME} --name \"Refactor auth module\"\n\n # Use different model\n ${APP_NAME} --provider openai --model gpt-4o-mini \"Help me refactor this code\"\n\n # Use model with provider prefix (no --provider needed)\n ${APP_NAME} --model openai/gpt-4o \"Help me refactor this code\"\n\n # Use model with thinking level shorthand\n ${APP_NAME} --model sonnet:high \"Solve this complex problem\"\n\n # Limit model cycling to specific models\n ${APP_NAME} --models claude-sonnet,claude-haiku,gpt-4o\n\n # Limit to a specific provider with glob pattern\n ${APP_NAME} --models \"github-copilot/*\"\n\n # Cycle models with fixed thinking levels\n ${APP_NAME} --models sonnet:high,haiku:low\n\n # Start with a specific thinking level\n ${APP_NAME} --thinking high \"Solve this complex problem\"\n\n # Read-only mode (no file modifications possible)\n ${APP_NAME} --tools read,grep,find,ls -p \"Review the code in src/\"\n\n # Disable one tool while keeping the rest available\n ${APP_NAME} --exclude-tools ask_question\n\n # Export a session file to HTML\n ${APP_NAME} --export ~/${CONFIG_DIR_NAME}/agent/sessions/--path--/session.jsonl\n ${APP_NAME} --export session.jsonl output.html\n\n${chalk.bold(\"Environment Variables:\")}\n ANTHROPIC_AUTH_TOKEN - Anthropic bearer auth token\n ANTHROPIC_API_KEY - Anthropic Claude API key\n ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth token (alternative to API key)\n ANT_LING_API_KEY - Ant Ling API key\n OPENAI_API_KEY - OpenAI GPT API key\n AZURE_OPENAI_API_KEY - Azure OpenAI API key\n AZURE_OPENAI_BASE_URL - Azure OpenAI/Cognitive Services base URL (e.g. https://{resource}.openai.azure.com)\n AZURE_OPENAI_RESOURCE_NAME - Azure OpenAI resource name (alternative to base URL)\n AZURE_OPENAI_API_VERSION - Azure OpenAI API version (default: v1)\n AZURE_OPENAI_DEPLOYMENT_NAME_MAP - Azure OpenAI model=deployment map (comma-separated)\n DEEPSEEK_API_KEY - DeepSeek API key\n NVIDIA_API_KEY - NVIDIA NIM API key\n GEMINI_API_KEY - Google Gemini API key\n GROQ_API_KEY - Groq API key\n CEREBRAS_API_KEY - Cerebras API key\n XAI_API_KEY - xAI Grok API key\n FIREWORKS_API_KEY - Fireworks API key\n TOGETHER_API_KEY - Together AI API key\n BASETEN_API_KEY - Baseten API key\n OPENROUTER_API_KEY - OpenRouter API key\n AI_GATEWAY_API_KEY - Vercel AI Gateway API key\n ZAI_API_KEY - ZAI Coding Plan API key (Global)\n ZAI_CODING_CN_API_KEY - ZAI Coding Plan API key (China)\n MISTRAL_API_KEY - Mistral API key\n MINIMAX_API_KEY - MiniMax API key\n MOONSHOT_API_KEY - Moonshot AI API key\n OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key\n KIMI_API_KEY - Kimi For Coding API key\n CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)\n CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)\n CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)\n QWEN_TOKEN_PLAN_API_KEY - Qwen Token Plan API key (international region)\n QWEN_TOKEN_PLAN_CN_API_KEY - Qwen Token Plan API key (China region)\n XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)\n XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)\n XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)\n XIAOMI_TOKEN_PLAN_SGP_API_KEY - Xiaomi MiMo Token Plan API key (Singapore region)\n AWS_PROFILE - AWS profile for Amazon Bedrock\n AWS_ACCESS_KEY_ID - AWS access key for Amazon Bedrock\n AWS_SECRET_ACCESS_KEY - AWS secret key for Amazon Bedrock\n AWS_BEARER_TOKEN_BEDROCK - Bedrock API key (bearer token)\n AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)\n ${ENV_AGENT_DIR.padEnd(32)} - Config directory (default: ~/${CONFIG_DIR_NAME}/agent)\n ${ENV_SESSION_DIR.padEnd(32)} - Session storage directory (overridden by --session-dir)\n AGENT_FORGE_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)\n AGENT_FORGE_OFFLINE - Disable startup network operations when set to 1/true/yes\n\n${chalk.bold(\"Built-in Tool Names:\")}\n read - Read file contents\n bash - Execute bash commands\n powershell - Execute PowerShell commands on Windows\n edit - Edit files with find/replace\n write - Write files (creates/overwrites)\n grep - Search file contents (read-only, off by default)\n find - Find files by glob pattern (read-only, off by default)\n ls - List directory contents (read-only, off by default)\n`);\n}\n"]}
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAK3D,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE3C,MAAM,WAAW,IAAI;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kIAAkI;IAClI,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAgE;IA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ing and help display\n */\n\nimport type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_SESSION_DIR } from \"../config.ts\";\nimport type { HostLogLevel } from \"../core/logger.ts\";\nimport type { TuiMode } from \"../core/settings-manager.ts\";\n// TRACE_KINDS_V1 is a value import, but observability-types.ts has no runtime\n// edges (its two imports are type-only), so no import cycle can form here.\nimport { TRACE_KINDS_V1 } from \"../plugins/observability-types.ts\";\n\nexport type Mode = \"text\" | \"json\" | \"rpc\";\n\nexport interface Args {\n\tprovider?: string;\n\tmodel?: string;\n\tapiKey?: string;\n\tsystemPrompt?: string;\n\tappendSystemPrompt?: string[];\n\tthinking?: ThinkingLevel;\n\tcontinue?: boolean;\n\tresume?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n\tmode?: Mode;\n\tname?: string;\n\tnoSession?: boolean;\n\t/** Explicit suite/profile migration on resume (--rebind-suite): adopt the current plugin set when the session binding drifted. */\n\trebindSuite?: boolean;\n\tsession?: string;\n\tsessionId?: string;\n\tfork?: string;\n\tsessionDir?: string;\n\t/** Suite (方案) id for session workspace and context assembly. */\n\tsuite?: string;\n\t/** One-shot lifecycle action: create the user suite workspace (设计 §9). */\n\tsuiteCreate?: string;\n\t/** Companion of --suite-create: clone the source suite workspace. */\n\tcloneFrom?: string;\n\t/** One-shot lifecycle action: delete the user suite workspace (设计 §9). */\n\tsuiteDelete?: string;\n\t/** One-shot lifecycle action: reset a builtin suite to factory contents (设计 §9). */\n\tsuiteReset?: string;\n\t/** Serve the coding-agent session runtime over TCP on the given port. */\n\tserve?: number;\n\t/** Opt-in `--serve` workspace boundary: remote creates must resolve inside one of these roots (repeatable). */\n\tserveWorkspaceRoots?: string[];\n\t/**\n\t * Run as a headless subagent runner (D-045 pooled increment 2b): serve the\n\t * subagent-task command surface on stdio for a parent session's runner pool.\n\t */\n\tsubagentRunner?: boolean;\n\tmodels?: string[];\n\ttools?: string[];\n\texcludeTools?: string[];\n\tnoTools?: boolean;\n\tnoBuiltinTools?: boolean;\n\tnoPlugins?: boolean;\n\t/** Disable session trace collection: equivalent to SDK `traceEnabled: false`. */\n\tnoTrace?: boolean;\n\t/** Host log level. Overrides AGENT_FORGE_LOG_LEVEL; default \"info\". */\n\tlogLevel?: HostLogLevel;\n\t/** Explicit builtin plugin profile for this run. */\n\tpluginProfile?: string;\n\t/** Explicit plugin IDs selected for the profile. */\n\tplugins?: string[];\n\t/** Explicit plugin IDs disabled for the profile. */\n\tdisabledPlugins?: string[];\n\t/** Persistence scope for explicit plugin selection: global by default. */\n\tpluginSelectionScope?: \"global\" | \"project\";\n\tprint?: boolean;\n\texport?: string;\n\t/** View a session's trace file (session id, path, or empty for the most recent session). */\n\ttrace?: string;\n\t/** Structured records output for --trace (设计 §8 第 3 期). */\n\ttraceJson?: boolean;\n\t/** With --trace, show only records whose kind is in this whitelist (TRACE_KINDS_V1 members). */\n\ttraceKind?: string[];\n\t/** With --trace, show only the last N records (positive integer). */\n\ttraceLimit?: number;\n\tnoSkills?: boolean;\n\tskills?: string[];\n\tpromptTemplates?: string[];\n\tnoPromptTemplates?: boolean;\n\tthemes?: string[];\n\tuseTheme?: string;\n\tnoThemes?: boolean;\n\tnoContextFiles?: boolean;\n\tlistModels?: string | true;\n\toffline?: boolean;\n\ttuiMode?: TuiMode;\n\tverbose?: boolean;\n\tmessages: string[];\n\tfileArgs: string[];\n\tdiagnostics: Array<{ type: \"warning\" | \"error\"; message: string }>;\n}\n\nconst VALID_THINKING_LEVELS = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\n\nconst VALID_LOG_LEVELS = [\"debug\", \"info\", \"warn\", \"error\"] as const;\n\nexport function isValidHostLogLevel(level: string): level is HostLogLevel {\n\treturn VALID_LOG_LEVELS.includes(level as HostLogLevel);\n}\n\n/** Single source of valid `--trace-kind` values: the TRACE_KINDS_V1 runtime mirror. */\nexport function isValidTraceKind(kind: string): boolean {\n\treturn (TRACE_KINDS_V1 as readonly string[]).includes(kind);\n}\n\n/** Keep CLI plugin selection bounded before it reaches profile resolution. */\nexport const MAX_PLUGIN_CLI_ID_CHARS = 128;\nexport const MAX_PLUGIN_CLI_IDS = 128;\n\nexport function isValidThinkingLevel(level: string): level is ThinkingLevel {\n\treturn VALID_THINKING_LEVELS.includes(level as ThinkingLevel);\n}\n\nexport function normalizeSessionName(value: string): string | undefined {\n\tconst name = value.trim();\n\treturn name.length > 0 ? name : undefined;\n}\n\nfunction parseBoundedPluginId(\n\targs: string[],\n\tindex: number,\n\tresult: Args,\n\toption: \"--plugin\" | \"--disable-plugin\",\n\tvalues: string[],\n): number {\n\tconst raw = args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a plugin id` });\n\t\treturn index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a non-empty plugin id` });\n\t\treturn index + 1;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tif (values.length >= MAX_PLUGIN_CLI_IDS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tvalues.push(value);\n\treturn index + 1;\n}\n\nfunction parsePluginProfileValue(args: string[], index: number, result: Args, rawValue?: string): number {\n\tconst raw = rawValue ?? args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a profile id\" });\n\t\treturn rawValue === undefined ? index : index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a non-empty profile id\" });\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `--plugin-profile id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tresult.pluginProfile = value;\n\treturn rawValue === undefined ? index + 1 : index;\n}\n\nexport function parseArgs(args: string[]): Args {\n\tconst result: Args = {\n\t\tmessages: [],\n\t\tfileArgs: [],\n\t\tdiagnostics: [],\n\t};\n\n\tfor (let i = 0; i < args.length; i++) {\n\t\tconst arg = args[i];\n\n\t\tif (arg === \"--\") {\n\t\t\tfor (const positionalArg of args.slice(i + 1)) {\n\t\t\t\tif (positionalArg.startsWith(\"@\")) {\n\t\t\t\t\tresult.fileArgs.push(positionalArg.slice(1));\n\t\t\t\t} else {\n\t\t\t\t\tresult.messages.push(positionalArg);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t} else if (arg === \"--help\" || arg === \"-h\") {\n\t\t\tresult.help = true;\n\t\t} else if (arg === \"--version\" || arg === \"-v\") {\n\t\t\tresult.version = true;\n\t\t} else if (arg === \"--mode\" && i + 1 < args.length) {\n\t\t\tconst mode = args[++i];\n\t\t\tif (mode === \"text\" || mode === \"json\" || mode === \"rpc\") {\n\t\t\t\tresult.mode = mode;\n\t\t\t}\n\t\t} else if (arg === \"--continue\" || arg === \"-c\") {\n\t\t\tresult.continue = true;\n\t\t} else if (arg === \"--resume\" || arg === \"-r\") {\n\t\t\tresult.resume = true;\n\t\t} else if (arg === \"--provider\" && i + 1 < args.length) {\n\t\t\tresult.provider = args[++i];\n\t\t} else if ((arg === \"--model\" || arg === \"-m\") && i + 1 < args.length) {\n\t\t\tresult.model = args[++i];\n\t\t} else if (arg === \"--api-key\" && i + 1 < args.length) {\n\t\t\tresult.apiKey = args[++i];\n\t\t} else if (arg === \"--system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.systemPrompt = args[++i];\n\t\t} else if (arg === \"--append-system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.appendSystemPrompt = result.appendSystemPrompt ?? [];\n\t\t\tresult.appendSystemPrompt.push(args[++i]);\n\t\t} else if (arg === \"--name\" || arg === \"-n\") {\n\t\t\tif (i + 1 < args.length) {\n\t\t\t\tresult.name = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--name requires a value\" });\n\t\t\t}\n\t\t} else if (arg === \"--no-session\") {\n\t\t\tresult.noSession = true;\n\t\t} else if (arg === \"--rebind-suite\") {\n\t\t\tresult.rebindSuite = true;\n\t\t} else if (arg === \"--session\" && i + 1 < args.length) {\n\t\t\tresult.session = args[++i];\n\t\t} else if (arg === \"--session-id\" && i + 1 < args.length) {\n\t\t\tresult.sessionId = args[++i];\n\t\t} else if (arg === \"--fork\" && i + 1 < args.length) {\n\t\t\tresult.fork = args[++i];\n\t\t} else if (arg === \"--session-dir\" && i + 1 < args.length) {\n\t\t\tresult.sessionDir = args[++i];\n\t\t} else if (arg === \"--suite\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suite = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-create\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteCreate = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-create requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--clone-from\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.cloneFrom = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--clone-from requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-delete\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteDelete = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-delete requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-reset\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteReset = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-reset requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--serve\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tconst port = raw !== undefined && /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\tif (Number.isInteger(port) && port <= 65535) {\n\t\t\t\tresult.serve = port;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve requires a valid TCP port (0-65535)\" });\n\t\t\t\tif (raw !== undefined) i++;\n\t\t\t}\n\t\t} else if (arg === \"--subagent-runner\") {\n\t\t\tresult.subagentRunner = true;\n\t\t} else if (arg === \"--serve-workspace-root\") {\n\t\t\tconst dir = args[i + 1];\n\t\t\tif (dir === undefined || dir.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve-workspace-root requires a directory\" });\n\t\t\t} else {\n\t\t\t\tresult.serveWorkspaceRoots = result.serveWorkspaceRoots ?? [];\n\t\t\t\tresult.serveWorkspaceRoots.push(dir);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--models\" && i + 1 < args.length) {\n\t\t\tresult.models = args[++i].split(\",\").map((s) => s.trim());\n\t\t} else if (arg === \"--no-tools\" || arg === \"-nt\") {\n\t\t\tresult.noTools = true;\n\t\t} else if (arg === \"--no-builtin-tools\" || arg === \"-nbt\") {\n\t\t\tresult.noBuiltinTools = true;\n\t\t} else if ((arg === \"--tools\" || arg === \"-t\") && i + 1 < args.length) {\n\t\t\tresult.tools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if ((arg === \"--exclude-tools\" || arg === \"-xt\") && i + 1 < args.length) {\n\t\t\tresult.excludeTools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if (arg === \"--thinking\" && i + 1 < args.length) {\n\t\t\tconst level = args[++i];\n\t\t\tif (isValidThinkingLevel(level)) {\n\t\t\t\tresult.thinking = level;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Invalid thinking level \"${level}\". Valid values: ${VALID_THINKING_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--print\" || arg === \"-p\") {\n\t\t\tresult.print = true;\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"@\") && (!next.startsWith(\"-\") || next.startsWith(\"---\"))) {\n\t\t\t\tresult.messages.push(next);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--export\" && i + 1 < args.length) {\n\t\t\tresult.export = args[++i];\n\t\t} else if (arg === \"--trace\") {\n\t\t\t// View command: bare --trace targets the most recent session; a\n\t\t\t// following non-option token is the session id or trace/session path.\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"-\")) {\n\t\t\t\tresult.trace = next;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.trace = \"\";\n\t\t\t}\n\t\t} else if (arg === \"--trace-json\") {\n\t\t\tresult.traceJson = true;\n\t\t} else if (arg === \"--trace-kind\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires a comma-separated kind list\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst kinds = raw\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((kind) => kind.trim())\n\t\t\t\t\t.filter((kind) => kind.length > 0);\n\t\t\t\tconst invalid = kinds.filter((kind) => !isValidTraceKind(kind));\n\t\t\t\tif (kinds.length === 0) {\n\t\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires at least one trace kind\" });\n\t\t\t\t} else if (invalid.length > 0) {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace kind(s) \"${invalid.join(\", \")}\". Valid values: ${TRACE_KINDS_V1.join(\", \")}`,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.traceKind = kinds;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--trace-limit\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-limit requires a positive integer\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst limit = /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\t\tif (Number.isInteger(limit) && limit > 0) {\n\t\t\t\t\tresult.traceLimit = limit;\n\t\t\t\t} else {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace limit \"${raw}\". Expected a positive integer`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--no-plugins\" || arg === \"-np\") {\n\t\t\tresult.noPlugins = true;\n\t\t} else if (arg === \"--no-trace\") {\n\t\t\tresult.noTrace = true;\n\t\t} else if (arg === \"--log-level\") {\n\t\t\tconst level = args[i + 1];\n\t\t\tif (level === undefined || level.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--log-level requires a level\" });\n\t\t\t} else if (!isValidHostLogLevel(level)) {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid log level \"${level}\". Valid values: ${VALID_LOG_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.logLevel = level;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--plugin-profile\") {\n\t\t\ti = parsePluginProfileValue(args, i, result);\n\t\t} else if (arg.startsWith(\"--plugin-profile=\")) {\n\t\t\tparsePluginProfileValue(args, i, result, arg.slice(\"--plugin-profile=\".length));\n\t\t} else if (arg === \"--plugin-scope\" || arg.startsWith(\"--plugin-scope=\")) {\n\t\t\tconst raw = arg === \"--plugin-scope\" ? args[i + 1] : arg.slice(\"--plugin-scope=\".length);\n\t\t\tif (arg === \"--plugin-scope\") i++;\n\t\t\tif (raw !== \"global\" && raw !== \"project\") {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope must be global or project\" });\n\t\t\t} else if (result.pluginSelectionScope !== undefined) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope may be specified only once\" });\n\t\t\t} else {\n\t\t\t\tresult.pluginSelectionScope = raw;\n\t\t\t}\n\t\t} else if (arg === \"--plugin\") {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--plugin\", result.plugins);\n\t\t} else if (arg.startsWith(\"--plugin=\")) {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\tconst value = arg.slice(\"--plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.plugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.plugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--disable-plugin\") {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--disable-plugin\", result.disabledPlugins);\n\t\t} else if (arg.startsWith(\"--disable-plugin=\")) {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\tconst value = arg.slice(\"--disable-plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--disable-plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.disabledPlugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.disabledPlugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--skill\" && i + 1 < args.length) {\n\t\t\tresult.skills = result.skills ?? [];\n\t\t\tresult.skills.push(args[++i]);\n\t\t} else if (arg === \"--prompt-template\" && i + 1 < args.length) {\n\t\t\tresult.promptTemplates = result.promptTemplates ?? [];\n\t\t\tresult.promptTemplates.push(args[++i]);\n\t\t} else if (arg === \"--theme\" && i + 1 < args.length) {\n\t\t\tresult.themes = result.themes ?? [];\n\t\t\tresult.themes.push(args[++i]);\n\t\t} else if (arg === \"--use-theme\") {\n\t\t\tconst themeName = args[i + 1];\n\t\t\tif (themeName === undefined || themeName.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--use-theme requires a theme name\" });\n\t\t\t} else {\n\t\t\t\tresult.useTheme = themeName;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--no-skills\" || arg === \"-ns\") {\n\t\t\tresult.noSkills = true;\n\t\t} else if (arg === \"--no-prompt-templates\" || arg === \"-np\") {\n\t\t\tresult.noPromptTemplates = true;\n\t\t} else if (arg === \"--no-themes\") {\n\t\t\tresult.noThemes = true;\n\t\t} else if (arg === \"--no-context-files\" || arg === \"-nc\") {\n\t\t\tresult.noContextFiles = true;\n\t\t} else if (arg === \"--list-models\") {\n\t\t\t// Check if next arg is a search pattern (not a flag or file arg)\n\t\t\tif (i + 1 < args.length && !args[i + 1].startsWith(\"-\") && !args[i + 1].startsWith(\"@\")) {\n\t\t\t\tresult.listModels = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.listModels = true;\n\t\t\t}\n\t\t} else if (arg === \"--tui-mode\") {\n\t\t\tconst mode = args[i + 1];\n\t\t\tif (mode === \"regular\" || mode === \"fullscreen\") {\n\t\t\t\tresult.tuiMode = mode;\n\t\t\t\ti++;\n\t\t\t} else if (mode === undefined || mode.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--tui-mode requires regular or fullscreen\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid TUI mode \"${mode}\". Valid values: regular, fullscreen`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--verbose\") {\n\t\t\tresult.verbose = true;\n\t\t} else if (arg === \"--offline\") {\n\t\t\tresult.offline = true;\n\t\t} else if (arg.startsWith(\"@\")) {\n\t\t\tresult.fileArgs.push(arg.slice(1)); // Remove @ prefix\n\t\t} else if (arg.startsWith(\"--\")) {\n\t\t\t// Unknown long options are errors: extension-registered CLI flags no\n\t\t\t// longer exist, so there is nothing left that could claim them.\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg.split(\"=\")[0]}` });\n\t\t\ti++;\n\t\t} else if (arg.startsWith(\"-\") && !arg.startsWith(\"--\")) {\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg}` });\n\t\t} else if (!arg.startsWith(\"-\")) {\n\t\t\tresult.messages.push(arg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function printHelp(): void {\n\tconsole.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools\n\n${chalk.bold(\"Usage:\")}\n ${APP_NAME} [options] [--] [@files...] [messages...]\n\n${chalk.bold(\"Commands:\")}\n ${APP_NAME} install <source> [-l] Install extension source and add to settings\n ${APP_NAME} remove <source> [-l] Remove extension source from settings\n ${APP_NAME} uninstall <source> [-l] Alias for remove\n ${APP_NAME} update [source|self|agent-forge] Update Agent Forge, extensions, or model catalogs\n ${APP_NAME} list List installed extensions from settings\n ${APP_NAME} config [-l] Open TUI to enable/disable package resources (Tab switches scope)\n ${APP_NAME} auth <command> Print credentials or check provider readiness\n ${APP_NAME} <command> --help Show help for install/remove/uninstall/update/list/config/auth\n\n${chalk.bold(\"Options:\")}\n --provider <name> Provider name (default: google)\n --model <pattern> Model pattern or ID (supports \"provider/id\" and optional \":<thinking>\")\n --api-key <key> API key (defaults to env vars)\n --system-prompt <text> System prompt (default: coding assistant prompt)\n --append-system-prompt <text> Append text or file contents to the system prompt (can be used multiple times)\n --mode <mode> Output mode: text (default), json, or rpc\n --print, -p Non-interactive mode: process prompt and exit\n --continue, -c Continue previous session\n --resume, -r Select a session to resume\n --session <path|id> Use specific session file or partial UUID\n --session-id <id> Use exact project session ID, creating it if missing\n --fork <path|id> Fork specific session file or partial UUID into a new session\n --session-dir <dir> Directory for session storage and lookup\n --suite <id> Suite (方案) for this run: assistant (default) or coding; new sessions only\n --suite-create <id> Create a user suite workspace and exit; add --clone-from <id> to copy one\n --suite-delete <id> Delete a user suite workspace (active session references refuse) and exit\n --suite-reset <id> Reset a builtin suite to factory contents (shows a diff) and exit\n --serve <port> (Experimental, local trust only) Serve the coding-agent session runtime over the WebSocket gateway (default: 127.0.0.1; HTTP surface: /healthz plus token-protected artifact reads) and exit on SIGINT/SIGTERM\n Durable journal: <agentDir>/remote-server-journal.jsonl (never the process cwd)\n --serve-workspace-root <dir> Opt-in --serve boundary: remote creates must run inside one of these roots (repeatable); without it any local directory is allowed\n --subagent-runner (Experimental) Run as a headless subagent runner: serve the subagent-task protocol on stdio for a parent session's runner pool (D-045)\n --no-session Don't save session (ephemeral)\n --name, -n <name> Set session display name\n --models <patterns> Comma-separated model patterns for Ctrl+P cycling\n Supports globs (anthropic/*, *sonnet*) and fuzzy matching\n --no-tools, -nt Disable all tools by default (built-in and plugin)\n --no-builtin-tools, -nbt Disable built-in tools by default but keep plugin/custom tools enabled\n --tools, -t <tools> Comma-separated allowlist of tool names to enable\n Applies to built-in, plugin, and custom tools\n --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable\n Applies to built-in, plugin, and custom tools\n --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max\n --no-plugins, -np Disable capability plugin discovery (D-028 escape hatch)\n --no-trace Disable session trace collection (no .trace.jsonl file is written)\n --log-level <level> Host log level: debug, info (default), warn, error\n --plugin-profile <id> Select a builtin capability plugin profile for this run\n --plugin <id> Select a plugin within the profile (repeatable)\n --disable-plugin <id> Disable a plugin within the profile (repeatable)\n --plugin-scope <scope> Read the explicit selection from global or project storage\n plugin catalog list List installed/available ecosystem plugins (independent namespace)\n --skill <path> Load a skill file or directory (can be used multiple times)\n --no-skills, -ns Disable skills discovery and loading\n --prompt-template <path> Load a prompt template file or directory (can be used multiple times)\n --no-prompt-templates, -np Disable prompt template discovery and loading\n --theme <path> Load a theme file or directory (can be used multiple times)\n --use-theme <name[/name]> Set the initial interactive theme for this run\n --no-themes Disable theme discovery and loading\n --no-context-files, -nc Disable AGENTS.md and CLAUDE.md discovery and loading\n --export <file> Export session file to HTML and exit\n --trace <session> View a session trace file as a text timeline and exit; <session> is a session id/prefix or trace/session file path, omit it for the most recent session\n --trace-json With --trace, output the structured trace records as JSON instead of the text timeline\n --trace-kind <k1,k2> With --trace, show only records of these kinds (comma-separated); valid kinds: ${TRACE_KINDS_V1.join(\", \")}\n --trace-limit <n> With --trace, show only the last N records (positive integer)\n --list-models [search] List available models (with optional fuzzy search)\n --verbose Force verbose startup (overrides quietStartup setting)\n --tui-mode <mode> TUI mode: regular (default) or fullscreen\n --offline Disable startup network operations (same as AGENT_FORGE_OFFLINE=1)\n -- End option parsing; treat remaining arguments as messages/files\n --help, -h Show this help\n --version, -v Show version number\n\n${chalk.bold(\"Examples:\")}\n # Print a provider API key for an external client\n ${APP_NAME} auth print-api-key --provider openai\n\n # Print an OAuth bearer token for an external client (refreshes if expired)\n ${APP_NAME} auth print-bearer-token --provider openai-codex\n\n # Interactive mode\n ${APP_NAME}\n\n # Interactive mode with initial prompt\n ${APP_NAME} \"List all .ts files in src/\"\n\n # Include files in initial message\n ${APP_NAME} @prompt.md @image.png \"What color is the sky?\"\n\n # Non-interactive mode (process and exit)\n ${APP_NAME} -p \"List all .ts files in src/\"\n\n # Prompt beginning with a dash\n ${APP_NAME} -p -- \"- Summarize these points\"\n\n # Multiple messages (interactive)\n ${APP_NAME} \"Read package.json\" \"What dependencies do we have?\"\n\n # Continue previous session\n ${APP_NAME} --continue \"What did we discuss?\"\n\n # Start a named session\n ${APP_NAME} --name \"Refactor auth module\"\n\n # Use different model\n ${APP_NAME} --provider openai --model gpt-4o-mini \"Help me refactor this code\"\n\n # Use model with provider prefix (no --provider needed)\n ${APP_NAME} --model openai/gpt-4o \"Help me refactor this code\"\n\n # Use model with thinking level shorthand\n ${APP_NAME} --model sonnet:high \"Solve this complex problem\"\n\n # Limit model cycling to specific models\n ${APP_NAME} --models claude-sonnet,claude-haiku,gpt-4o\n\n # Limit to a specific provider with glob pattern\n ${APP_NAME} --models \"github-copilot/*\"\n\n # Cycle models with fixed thinking levels\n ${APP_NAME} --models sonnet:high,haiku:low\n\n # Start with a specific thinking level\n ${APP_NAME} --thinking high \"Solve this complex problem\"\n\n # Read-only mode (no file modifications possible)\n ${APP_NAME} --tools read,grep,find,ls -p \"Review the code in src/\"\n\n # Disable one tool while keeping the rest available\n ${APP_NAME} --exclude-tools ask_question\n\n # Export a session file to HTML\n ${APP_NAME} --export ~/${CONFIG_DIR_NAME}/agent/sessions/--path--/session.jsonl\n ${APP_NAME} --export session.jsonl output.html\n\n${chalk.bold(\"Environment Variables:\")}\n ANTHROPIC_AUTH_TOKEN - Anthropic bearer auth token\n ANTHROPIC_API_KEY - Anthropic Claude API key\n ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth token (alternative to API key)\n ANT_LING_API_KEY - Ant Ling API key\n OPENAI_API_KEY - OpenAI GPT API key\n AZURE_OPENAI_API_KEY - Azure OpenAI API key\n AZURE_OPENAI_BASE_URL - Azure OpenAI/Cognitive Services base URL (e.g. https://{resource}.openai.azure.com)\n AZURE_OPENAI_RESOURCE_NAME - Azure OpenAI resource name (alternative to base URL)\n AZURE_OPENAI_API_VERSION - Azure OpenAI API version (default: v1)\n AZURE_OPENAI_DEPLOYMENT_NAME_MAP - Azure OpenAI model=deployment map (comma-separated)\n DEEPSEEK_API_KEY - DeepSeek API key\n NVIDIA_API_KEY - NVIDIA NIM API key\n GEMINI_API_KEY - Google Gemini API key\n GROQ_API_KEY - Groq API key\n CEREBRAS_API_KEY - Cerebras API key\n XAI_API_KEY - xAI Grok API key\n FIREWORKS_API_KEY - Fireworks API key\n TOGETHER_API_KEY - Together AI API key\n BASETEN_API_KEY - Baseten API key\n OPENROUTER_API_KEY - OpenRouter API key\n AI_GATEWAY_API_KEY - Vercel AI Gateway API key\n ZAI_API_KEY - ZAI Coding Plan API key (Global)\n ZAI_CODING_CN_API_KEY - ZAI Coding Plan API key (China)\n MISTRAL_API_KEY - Mistral API key\n MINIMAX_API_KEY - MiniMax API key\n MOONSHOT_API_KEY - Moonshot AI API key\n OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key\n KIMI_API_KEY - Kimi For Coding API key\n CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)\n CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)\n CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)\n QWEN_TOKEN_PLAN_API_KEY - Qwen Token Plan API key (international region)\n QWEN_TOKEN_PLAN_CN_API_KEY - Qwen Token Plan API key (China region)\n XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)\n XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)\n XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)\n XIAOMI_TOKEN_PLAN_SGP_API_KEY - Xiaomi MiMo Token Plan API key (Singapore region)\n AWS_PROFILE - AWS profile for Amazon Bedrock\n AWS_ACCESS_KEY_ID - AWS access key for Amazon Bedrock\n AWS_SECRET_ACCESS_KEY - AWS secret key for Amazon Bedrock\n AWS_BEARER_TOKEN_BEDROCK - Bedrock API key (bearer token)\n AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)\n ${ENV_AGENT_DIR.padEnd(32)} - Config directory (default: ~/${CONFIG_DIR_NAME}/agent)\n ${ENV_SESSION_DIR.padEnd(32)} - Session storage directory (overridden by --session-dir)\n AGENT_FORGE_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)\n AGENT_FORGE_OFFLINE - Disable startup network operations when set to 1/true/yes\n\n${chalk.bold(\"Built-in Tool Names:\")}\n read - Read file contents\n bash - Execute bash commands\n powershell - Execute PowerShell commands on Windows\n edit - Edit files with find/replace\n write - Write files (creates/overwrites)\n grep - Search file contents (read-only, off by default)\n find - Find files by glob pattern (read-only, off by default)\n ls - List directory contents (read-only, off by default)\n`);\n}\n"]}
package/dist/cli/args.js CHANGED
@@ -138,6 +138,9 @@ export function parseArgs(args) {
138
138
  else if (arg === "--no-session") {
139
139
  result.noSession = true;
140
140
  }
141
+ else if (arg === "--rebind-suite") {
142
+ result.rebindSuite = true;
143
+ }
141
144
  else if (arg === "--session" && i + 1 < args.length) {
142
145
  result.session = args[++i];
143
146
  }
@@ -1 +1 @@
1
- {"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGzF,8EAA8E;AAC9E,2EAA2E;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAsFnE,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAEnG,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAErE,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAyB;IACzE,OAAO,gBAAgB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,IAAI,CAAC,QAAQ,CAAC;IAClB,QAAQ;;EAEV,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;IACrB,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;;EAEV,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kHAoD0F,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;EAUzI,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;;IAErB,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ,eAAe,eAAe;IACtC,QAAQ;;EAEV,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2ClC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,mCAAmC,eAAe;IAC1E,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;;;;EAI5B,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC;;;;;;;;;CASnC,CAAC,CAAC;AAAA,CACF","sourcesContent":["/**\n * CLI argument parsing and help display\n */\n\nimport type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_SESSION_DIR } from \"../config.ts\";\nimport type { HostLogLevel } from \"../core/logger.ts\";\nimport type { TuiMode } from \"../core/settings-manager.ts\";\n// TRACE_KINDS_V1 is a value import, but observability-types.ts has no runtime\n// edges (its two imports are type-only), so no import cycle can form here.\nimport { TRACE_KINDS_V1 } from \"../plugins/observability-types.ts\";\n\nexport type Mode = \"text\" | \"json\" | \"rpc\";\n\nexport interface Args {\n\tprovider?: string;\n\tmodel?: string;\n\tapiKey?: string;\n\tsystemPrompt?: string;\n\tappendSystemPrompt?: string[];\n\tthinking?: ThinkingLevel;\n\tcontinue?: boolean;\n\tresume?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n\tmode?: Mode;\n\tname?: string;\n\tnoSession?: boolean;\n\tsession?: string;\n\tsessionId?: string;\n\tfork?: string;\n\tsessionDir?: string;\n\t/** Suite (方案) id for session workspace and context assembly. */\n\tsuite?: string;\n\t/** One-shot lifecycle action: create the user suite workspace (设计 §9). */\n\tsuiteCreate?: string;\n\t/** Companion of --suite-create: clone the source suite workspace. */\n\tcloneFrom?: string;\n\t/** One-shot lifecycle action: delete the user suite workspace (设计 §9). */\n\tsuiteDelete?: string;\n\t/** One-shot lifecycle action: reset a builtin suite to factory contents (设计 §9). */\n\tsuiteReset?: string;\n\t/** Serve the coding-agent session runtime over TCP on the given port. */\n\tserve?: number;\n\t/** Opt-in `--serve` workspace boundary: remote creates must resolve inside one of these roots (repeatable). */\n\tserveWorkspaceRoots?: string[];\n\t/**\n\t * Run as a headless subagent runner (D-045 pooled increment 2b): serve the\n\t * subagent-task command surface on stdio for a parent session's runner pool.\n\t */\n\tsubagentRunner?: boolean;\n\tmodels?: string[];\n\ttools?: string[];\n\texcludeTools?: string[];\n\tnoTools?: boolean;\n\tnoBuiltinTools?: boolean;\n\tnoPlugins?: boolean;\n\t/** Disable session trace collection: equivalent to SDK `traceEnabled: false`. */\n\tnoTrace?: boolean;\n\t/** Host log level. Overrides AGENT_FORGE_LOG_LEVEL; default \"info\". */\n\tlogLevel?: HostLogLevel;\n\t/** Explicit builtin plugin profile for this run. */\n\tpluginProfile?: string;\n\t/** Explicit plugin IDs selected for the profile. */\n\tplugins?: string[];\n\t/** Explicit plugin IDs disabled for the profile. */\n\tdisabledPlugins?: string[];\n\t/** Persistence scope for explicit plugin selection: global by default. */\n\tpluginSelectionScope?: \"global\" | \"project\";\n\tprint?: boolean;\n\texport?: string;\n\t/** View a session's trace file (session id, path, or empty for the most recent session). */\n\ttrace?: string;\n\t/** Structured records output for --trace (设计 §8 第 3 期). */\n\ttraceJson?: boolean;\n\t/** With --trace, show only records whose kind is in this whitelist (TRACE_KINDS_V1 members). */\n\ttraceKind?: string[];\n\t/** With --trace, show only the last N records (positive integer). */\n\ttraceLimit?: number;\n\tnoSkills?: boolean;\n\tskills?: string[];\n\tpromptTemplates?: string[];\n\tnoPromptTemplates?: boolean;\n\tthemes?: string[];\n\tuseTheme?: string;\n\tnoThemes?: boolean;\n\tnoContextFiles?: boolean;\n\tlistModels?: string | true;\n\toffline?: boolean;\n\ttuiMode?: TuiMode;\n\tverbose?: boolean;\n\tmessages: string[];\n\tfileArgs: string[];\n\tdiagnostics: Array<{ type: \"warning\" | \"error\"; message: string }>;\n}\n\nconst VALID_THINKING_LEVELS = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\n\nconst VALID_LOG_LEVELS = [\"debug\", \"info\", \"warn\", \"error\"] as const;\n\nexport function isValidHostLogLevel(level: string): level is HostLogLevel {\n\treturn VALID_LOG_LEVELS.includes(level as HostLogLevel);\n}\n\n/** Single source of valid `--trace-kind` values: the TRACE_KINDS_V1 runtime mirror. */\nexport function isValidTraceKind(kind: string): boolean {\n\treturn (TRACE_KINDS_V1 as readonly string[]).includes(kind);\n}\n\n/** Keep CLI plugin selection bounded before it reaches profile resolution. */\nexport const MAX_PLUGIN_CLI_ID_CHARS = 128;\nexport const MAX_PLUGIN_CLI_IDS = 128;\n\nexport function isValidThinkingLevel(level: string): level is ThinkingLevel {\n\treturn VALID_THINKING_LEVELS.includes(level as ThinkingLevel);\n}\n\nexport function normalizeSessionName(value: string): string | undefined {\n\tconst name = value.trim();\n\treturn name.length > 0 ? name : undefined;\n}\n\nfunction parseBoundedPluginId(\n\targs: string[],\n\tindex: number,\n\tresult: Args,\n\toption: \"--plugin\" | \"--disable-plugin\",\n\tvalues: string[],\n): number {\n\tconst raw = args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a plugin id` });\n\t\treturn index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a non-empty plugin id` });\n\t\treturn index + 1;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tif (values.length >= MAX_PLUGIN_CLI_IDS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tvalues.push(value);\n\treturn index + 1;\n}\n\nfunction parsePluginProfileValue(args: string[], index: number, result: Args, rawValue?: string): number {\n\tconst raw = rawValue ?? args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a profile id\" });\n\t\treturn rawValue === undefined ? index : index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a non-empty profile id\" });\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `--plugin-profile id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tresult.pluginProfile = value;\n\treturn rawValue === undefined ? index + 1 : index;\n}\n\nexport function parseArgs(args: string[]): Args {\n\tconst result: Args = {\n\t\tmessages: [],\n\t\tfileArgs: [],\n\t\tdiagnostics: [],\n\t};\n\n\tfor (let i = 0; i < args.length; i++) {\n\t\tconst arg = args[i];\n\n\t\tif (arg === \"--\") {\n\t\t\tfor (const positionalArg of args.slice(i + 1)) {\n\t\t\t\tif (positionalArg.startsWith(\"@\")) {\n\t\t\t\t\tresult.fileArgs.push(positionalArg.slice(1));\n\t\t\t\t} else {\n\t\t\t\t\tresult.messages.push(positionalArg);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t} else if (arg === \"--help\" || arg === \"-h\") {\n\t\t\tresult.help = true;\n\t\t} else if (arg === \"--version\" || arg === \"-v\") {\n\t\t\tresult.version = true;\n\t\t} else if (arg === \"--mode\" && i + 1 < args.length) {\n\t\t\tconst mode = args[++i];\n\t\t\tif (mode === \"text\" || mode === \"json\" || mode === \"rpc\") {\n\t\t\t\tresult.mode = mode;\n\t\t\t}\n\t\t} else if (arg === \"--continue\" || arg === \"-c\") {\n\t\t\tresult.continue = true;\n\t\t} else if (arg === \"--resume\" || arg === \"-r\") {\n\t\t\tresult.resume = true;\n\t\t} else if (arg === \"--provider\" && i + 1 < args.length) {\n\t\t\tresult.provider = args[++i];\n\t\t} else if ((arg === \"--model\" || arg === \"-m\") && i + 1 < args.length) {\n\t\t\tresult.model = args[++i];\n\t\t} else if (arg === \"--api-key\" && i + 1 < args.length) {\n\t\t\tresult.apiKey = args[++i];\n\t\t} else if (arg === \"--system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.systemPrompt = args[++i];\n\t\t} else if (arg === \"--append-system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.appendSystemPrompt = result.appendSystemPrompt ?? [];\n\t\t\tresult.appendSystemPrompt.push(args[++i]);\n\t\t} else if (arg === \"--name\" || arg === \"-n\") {\n\t\t\tif (i + 1 < args.length) {\n\t\t\t\tresult.name = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--name requires a value\" });\n\t\t\t}\n\t\t} else if (arg === \"--no-session\") {\n\t\t\tresult.noSession = true;\n\t\t} else if (arg === \"--session\" && i + 1 < args.length) {\n\t\t\tresult.session = args[++i];\n\t\t} else if (arg === \"--session-id\" && i + 1 < args.length) {\n\t\t\tresult.sessionId = args[++i];\n\t\t} else if (arg === \"--fork\" && i + 1 < args.length) {\n\t\t\tresult.fork = args[++i];\n\t\t} else if (arg === \"--session-dir\" && i + 1 < args.length) {\n\t\t\tresult.sessionDir = args[++i];\n\t\t} else if (arg === \"--suite\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suite = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-create\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteCreate = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-create requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--clone-from\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.cloneFrom = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--clone-from requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-delete\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteDelete = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-delete requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-reset\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteReset = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-reset requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--serve\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tconst port = raw !== undefined && /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\tif (Number.isInteger(port) && port <= 65535) {\n\t\t\t\tresult.serve = port;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve requires a valid TCP port (0-65535)\" });\n\t\t\t\tif (raw !== undefined) i++;\n\t\t\t}\n\t\t} else if (arg === \"--subagent-runner\") {\n\t\t\tresult.subagentRunner = true;\n\t\t} else if (arg === \"--serve-workspace-root\") {\n\t\t\tconst dir = args[i + 1];\n\t\t\tif (dir === undefined || dir.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve-workspace-root requires a directory\" });\n\t\t\t} else {\n\t\t\t\tresult.serveWorkspaceRoots = result.serveWorkspaceRoots ?? [];\n\t\t\t\tresult.serveWorkspaceRoots.push(dir);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--models\" && i + 1 < args.length) {\n\t\t\tresult.models = args[++i].split(\",\").map((s) => s.trim());\n\t\t} else if (arg === \"--no-tools\" || arg === \"-nt\") {\n\t\t\tresult.noTools = true;\n\t\t} else if (arg === \"--no-builtin-tools\" || arg === \"-nbt\") {\n\t\t\tresult.noBuiltinTools = true;\n\t\t} else if ((arg === \"--tools\" || arg === \"-t\") && i + 1 < args.length) {\n\t\t\tresult.tools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if ((arg === \"--exclude-tools\" || arg === \"-xt\") && i + 1 < args.length) {\n\t\t\tresult.excludeTools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if (arg === \"--thinking\" && i + 1 < args.length) {\n\t\t\tconst level = args[++i];\n\t\t\tif (isValidThinkingLevel(level)) {\n\t\t\t\tresult.thinking = level;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Invalid thinking level \"${level}\". Valid values: ${VALID_THINKING_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--print\" || arg === \"-p\") {\n\t\t\tresult.print = true;\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"@\") && (!next.startsWith(\"-\") || next.startsWith(\"---\"))) {\n\t\t\t\tresult.messages.push(next);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--export\" && i + 1 < args.length) {\n\t\t\tresult.export = args[++i];\n\t\t} else if (arg === \"--trace\") {\n\t\t\t// View command: bare --trace targets the most recent session; a\n\t\t\t// following non-option token is the session id or trace/session path.\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"-\")) {\n\t\t\t\tresult.trace = next;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.trace = \"\";\n\t\t\t}\n\t\t} else if (arg === \"--trace-json\") {\n\t\t\tresult.traceJson = true;\n\t\t} else if (arg === \"--trace-kind\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires a comma-separated kind list\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst kinds = raw\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((kind) => kind.trim())\n\t\t\t\t\t.filter((kind) => kind.length > 0);\n\t\t\t\tconst invalid = kinds.filter((kind) => !isValidTraceKind(kind));\n\t\t\t\tif (kinds.length === 0) {\n\t\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires at least one trace kind\" });\n\t\t\t\t} else if (invalid.length > 0) {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace kind(s) \"${invalid.join(\", \")}\". Valid values: ${TRACE_KINDS_V1.join(\", \")}`,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.traceKind = kinds;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--trace-limit\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-limit requires a positive integer\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst limit = /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\t\tif (Number.isInteger(limit) && limit > 0) {\n\t\t\t\t\tresult.traceLimit = limit;\n\t\t\t\t} else {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace limit \"${raw}\". Expected a positive integer`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--no-plugins\" || arg === \"-np\") {\n\t\t\tresult.noPlugins = true;\n\t\t} else if (arg === \"--no-trace\") {\n\t\t\tresult.noTrace = true;\n\t\t} else if (arg === \"--log-level\") {\n\t\t\tconst level = args[i + 1];\n\t\t\tif (level === undefined || level.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--log-level requires a level\" });\n\t\t\t} else if (!isValidHostLogLevel(level)) {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid log level \"${level}\". Valid values: ${VALID_LOG_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.logLevel = level;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--plugin-profile\") {\n\t\t\ti = parsePluginProfileValue(args, i, result);\n\t\t} else if (arg.startsWith(\"--plugin-profile=\")) {\n\t\t\tparsePluginProfileValue(args, i, result, arg.slice(\"--plugin-profile=\".length));\n\t\t} else if (arg === \"--plugin-scope\" || arg.startsWith(\"--plugin-scope=\")) {\n\t\t\tconst raw = arg === \"--plugin-scope\" ? args[i + 1] : arg.slice(\"--plugin-scope=\".length);\n\t\t\tif (arg === \"--plugin-scope\") i++;\n\t\t\tif (raw !== \"global\" && raw !== \"project\") {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope must be global or project\" });\n\t\t\t} else if (result.pluginSelectionScope !== undefined) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope may be specified only once\" });\n\t\t\t} else {\n\t\t\t\tresult.pluginSelectionScope = raw;\n\t\t\t}\n\t\t} else if (arg === \"--plugin\") {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--plugin\", result.plugins);\n\t\t} else if (arg.startsWith(\"--plugin=\")) {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\tconst value = arg.slice(\"--plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.plugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.plugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--disable-plugin\") {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--disable-plugin\", result.disabledPlugins);\n\t\t} else if (arg.startsWith(\"--disable-plugin=\")) {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\tconst value = arg.slice(\"--disable-plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--disable-plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.disabledPlugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.disabledPlugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--skill\" && i + 1 < args.length) {\n\t\t\tresult.skills = result.skills ?? [];\n\t\t\tresult.skills.push(args[++i]);\n\t\t} else if (arg === \"--prompt-template\" && i + 1 < args.length) {\n\t\t\tresult.promptTemplates = result.promptTemplates ?? [];\n\t\t\tresult.promptTemplates.push(args[++i]);\n\t\t} else if (arg === \"--theme\" && i + 1 < args.length) {\n\t\t\tresult.themes = result.themes ?? [];\n\t\t\tresult.themes.push(args[++i]);\n\t\t} else if (arg === \"--use-theme\") {\n\t\t\tconst themeName = args[i + 1];\n\t\t\tif (themeName === undefined || themeName.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--use-theme requires a theme name\" });\n\t\t\t} else {\n\t\t\t\tresult.useTheme = themeName;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--no-skills\" || arg === \"-ns\") {\n\t\t\tresult.noSkills = true;\n\t\t} else if (arg === \"--no-prompt-templates\" || arg === \"-np\") {\n\t\t\tresult.noPromptTemplates = true;\n\t\t} else if (arg === \"--no-themes\") {\n\t\t\tresult.noThemes = true;\n\t\t} else if (arg === \"--no-context-files\" || arg === \"-nc\") {\n\t\t\tresult.noContextFiles = true;\n\t\t} else if (arg === \"--list-models\") {\n\t\t\t// Check if next arg is a search pattern (not a flag or file arg)\n\t\t\tif (i + 1 < args.length && !args[i + 1].startsWith(\"-\") && !args[i + 1].startsWith(\"@\")) {\n\t\t\t\tresult.listModels = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.listModels = true;\n\t\t\t}\n\t\t} else if (arg === \"--tui-mode\") {\n\t\t\tconst mode = args[i + 1];\n\t\t\tif (mode === \"regular\" || mode === \"fullscreen\") {\n\t\t\t\tresult.tuiMode = mode;\n\t\t\t\ti++;\n\t\t\t} else if (mode === undefined || mode.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--tui-mode requires regular or fullscreen\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid TUI mode \"${mode}\". Valid values: regular, fullscreen`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--verbose\") {\n\t\t\tresult.verbose = true;\n\t\t} else if (arg === \"--offline\") {\n\t\t\tresult.offline = true;\n\t\t} else if (arg.startsWith(\"@\")) {\n\t\t\tresult.fileArgs.push(arg.slice(1)); // Remove @ prefix\n\t\t} else if (arg.startsWith(\"--\")) {\n\t\t\t// Unknown long options are errors: extension-registered CLI flags no\n\t\t\t// longer exist, so there is nothing left that could claim them.\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg.split(\"=\")[0]}` });\n\t\t\ti++;\n\t\t} else if (arg.startsWith(\"-\") && !arg.startsWith(\"--\")) {\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg}` });\n\t\t} else if (!arg.startsWith(\"-\")) {\n\t\t\tresult.messages.push(arg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function printHelp(): void {\n\tconsole.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools\n\n${chalk.bold(\"Usage:\")}\n ${APP_NAME} [options] [--] [@files...] [messages...]\n\n${chalk.bold(\"Commands:\")}\n ${APP_NAME} install <source> [-l] Install extension source and add to settings\n ${APP_NAME} remove <source> [-l] Remove extension source from settings\n ${APP_NAME} uninstall <source> [-l] Alias for remove\n ${APP_NAME} update [source|self|agent-forge] Update Agent Forge, extensions, or model catalogs\n ${APP_NAME} list List installed extensions from settings\n ${APP_NAME} config [-l] Open TUI to enable/disable package resources (Tab switches scope)\n ${APP_NAME} auth <command> Print credentials or check provider readiness\n ${APP_NAME} <command> --help Show help for install/remove/uninstall/update/list/config/auth\n\n${chalk.bold(\"Options:\")}\n --provider <name> Provider name (default: google)\n --model <pattern> Model pattern or ID (supports \"provider/id\" and optional \":<thinking>\")\n --api-key <key> API key (defaults to env vars)\n --system-prompt <text> System prompt (default: coding assistant prompt)\n --append-system-prompt <text> Append text or file contents to the system prompt (can be used multiple times)\n --mode <mode> Output mode: text (default), json, or rpc\n --print, -p Non-interactive mode: process prompt and exit\n --continue, -c Continue previous session\n --resume, -r Select a session to resume\n --session <path|id> Use specific session file or partial UUID\n --session-id <id> Use exact project session ID, creating it if missing\n --fork <path|id> Fork specific session file or partial UUID into a new session\n --session-dir <dir> Directory for session storage and lookup\n --suite <id> Suite (方案) for this run: assistant (default) or coding; new sessions only\n --suite-create <id> Create a user suite workspace and exit; add --clone-from <id> to copy one\n --suite-delete <id> Delete a user suite workspace (active session references refuse) and exit\n --suite-reset <id> Reset a builtin suite to factory contents (shows a diff) and exit\n --serve <port> (Experimental, local trust only) Serve the coding-agent session runtime over the WebSocket gateway (default: 127.0.0.1; HTTP surface: /healthz plus token-protected artifact reads) and exit on SIGINT/SIGTERM\n Durable journal: <agentDir>/remote-server-journal.jsonl (never the process cwd)\n --serve-workspace-root <dir> Opt-in --serve boundary: remote creates must run inside one of these roots (repeatable); without it any local directory is allowed\n --subagent-runner (Experimental) Run as a headless subagent runner: serve the subagent-task protocol on stdio for a parent session's runner pool (D-045)\n --no-session Don't save session (ephemeral)\n --name, -n <name> Set session display name\n --models <patterns> Comma-separated model patterns for Ctrl+P cycling\n Supports globs (anthropic/*, *sonnet*) and fuzzy matching\n --no-tools, -nt Disable all tools by default (built-in and plugin)\n --no-builtin-tools, -nbt Disable built-in tools by default but keep plugin/custom tools enabled\n --tools, -t <tools> Comma-separated allowlist of tool names to enable\n Applies to built-in, plugin, and custom tools\n --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable\n Applies to built-in, plugin, and custom tools\n --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max\n --no-plugins, -np Disable capability plugin discovery (D-028 escape hatch)\n --no-trace Disable session trace collection (no .trace.jsonl file is written)\n --log-level <level> Host log level: debug, info (default), warn, error\n --plugin-profile <id> Select a builtin capability plugin profile for this run\n --plugin <id> Select a plugin within the profile (repeatable)\n --disable-plugin <id> Disable a plugin within the profile (repeatable)\n --plugin-scope <scope> Read the explicit selection from global or project storage\n plugin catalog list List installed/available ecosystem plugins (independent namespace)\n --skill <path> Load a skill file or directory (can be used multiple times)\n --no-skills, -ns Disable skills discovery and loading\n --prompt-template <path> Load a prompt template file or directory (can be used multiple times)\n --no-prompt-templates, -np Disable prompt template discovery and loading\n --theme <path> Load a theme file or directory (can be used multiple times)\n --use-theme <name[/name]> Set the initial interactive theme for this run\n --no-themes Disable theme discovery and loading\n --no-context-files, -nc Disable AGENTS.md and CLAUDE.md discovery and loading\n --export <file> Export session file to HTML and exit\n --trace <session> View a session trace file as a text timeline and exit; <session> is a session id/prefix or trace/session file path, omit it for the most recent session\n --trace-json With --trace, output the structured trace records as JSON instead of the text timeline\n --trace-kind <k1,k2> With --trace, show only records of these kinds (comma-separated); valid kinds: ${TRACE_KINDS_V1.join(\", \")}\n --trace-limit <n> With --trace, show only the last N records (positive integer)\n --list-models [search] List available models (with optional fuzzy search)\n --verbose Force verbose startup (overrides quietStartup setting)\n --tui-mode <mode> TUI mode: regular (default) or fullscreen\n --offline Disable startup network operations (same as AGENT_FORGE_OFFLINE=1)\n -- End option parsing; treat remaining arguments as messages/files\n --help, -h Show this help\n --version, -v Show version number\n\n${chalk.bold(\"Examples:\")}\n # Print a provider API key for an external client\n ${APP_NAME} auth print-api-key --provider openai\n\n # Print an OAuth bearer token for an external client (refreshes if expired)\n ${APP_NAME} auth print-bearer-token --provider openai-codex\n\n # Interactive mode\n ${APP_NAME}\n\n # Interactive mode with initial prompt\n ${APP_NAME} \"List all .ts files in src/\"\n\n # Include files in initial message\n ${APP_NAME} @prompt.md @image.png \"What color is the sky?\"\n\n # Non-interactive mode (process and exit)\n ${APP_NAME} -p \"List all .ts files in src/\"\n\n # Prompt beginning with a dash\n ${APP_NAME} -p -- \"- Summarize these points\"\n\n # Multiple messages (interactive)\n ${APP_NAME} \"Read package.json\" \"What dependencies do we have?\"\n\n # Continue previous session\n ${APP_NAME} --continue \"What did we discuss?\"\n\n # Start a named session\n ${APP_NAME} --name \"Refactor auth module\"\n\n # Use different model\n ${APP_NAME} --provider openai --model gpt-4o-mini \"Help me refactor this code\"\n\n # Use model with provider prefix (no --provider needed)\n ${APP_NAME} --model openai/gpt-4o \"Help me refactor this code\"\n\n # Use model with thinking level shorthand\n ${APP_NAME} --model sonnet:high \"Solve this complex problem\"\n\n # Limit model cycling to specific models\n ${APP_NAME} --models claude-sonnet,claude-haiku,gpt-4o\n\n # Limit to a specific provider with glob pattern\n ${APP_NAME} --models \"github-copilot/*\"\n\n # Cycle models with fixed thinking levels\n ${APP_NAME} --models sonnet:high,haiku:low\n\n # Start with a specific thinking level\n ${APP_NAME} --thinking high \"Solve this complex problem\"\n\n # Read-only mode (no file modifications possible)\n ${APP_NAME} --tools read,grep,find,ls -p \"Review the code in src/\"\n\n # Disable one tool while keeping the rest available\n ${APP_NAME} --exclude-tools ask_question\n\n # Export a session file to HTML\n ${APP_NAME} --export ~/${CONFIG_DIR_NAME}/agent/sessions/--path--/session.jsonl\n ${APP_NAME} --export session.jsonl output.html\n\n${chalk.bold(\"Environment Variables:\")}\n ANTHROPIC_AUTH_TOKEN - Anthropic bearer auth token\n ANTHROPIC_API_KEY - Anthropic Claude API key\n ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth token (alternative to API key)\n ANT_LING_API_KEY - Ant Ling API key\n OPENAI_API_KEY - OpenAI GPT API key\n AZURE_OPENAI_API_KEY - Azure OpenAI API key\n AZURE_OPENAI_BASE_URL - Azure OpenAI/Cognitive Services base URL (e.g. https://{resource}.openai.azure.com)\n AZURE_OPENAI_RESOURCE_NAME - Azure OpenAI resource name (alternative to base URL)\n AZURE_OPENAI_API_VERSION - Azure OpenAI API version (default: v1)\n AZURE_OPENAI_DEPLOYMENT_NAME_MAP - Azure OpenAI model=deployment map (comma-separated)\n DEEPSEEK_API_KEY - DeepSeek API key\n NVIDIA_API_KEY - NVIDIA NIM API key\n GEMINI_API_KEY - Google Gemini API key\n GROQ_API_KEY - Groq API key\n CEREBRAS_API_KEY - Cerebras API key\n XAI_API_KEY - xAI Grok API key\n FIREWORKS_API_KEY - Fireworks API key\n TOGETHER_API_KEY - Together AI API key\n BASETEN_API_KEY - Baseten API key\n OPENROUTER_API_KEY - OpenRouter API key\n AI_GATEWAY_API_KEY - Vercel AI Gateway API key\n ZAI_API_KEY - ZAI Coding Plan API key (Global)\n ZAI_CODING_CN_API_KEY - ZAI Coding Plan API key (China)\n MISTRAL_API_KEY - Mistral API key\n MINIMAX_API_KEY - MiniMax API key\n MOONSHOT_API_KEY - Moonshot AI API key\n OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key\n KIMI_API_KEY - Kimi For Coding API key\n CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)\n CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)\n CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)\n QWEN_TOKEN_PLAN_API_KEY - Qwen Token Plan API key (international region)\n QWEN_TOKEN_PLAN_CN_API_KEY - Qwen Token Plan API key (China region)\n XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)\n XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)\n XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)\n XIAOMI_TOKEN_PLAN_SGP_API_KEY - Xiaomi MiMo Token Plan API key (Singapore region)\n AWS_PROFILE - AWS profile for Amazon Bedrock\n AWS_ACCESS_KEY_ID - AWS access key for Amazon Bedrock\n AWS_SECRET_ACCESS_KEY - AWS secret key for Amazon Bedrock\n AWS_BEARER_TOKEN_BEDROCK - Bedrock API key (bearer token)\n AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)\n ${ENV_AGENT_DIR.padEnd(32)} - Config directory (default: ~/${CONFIG_DIR_NAME}/agent)\n ${ENV_SESSION_DIR.padEnd(32)} - Session storage directory (overridden by --session-dir)\n AGENT_FORGE_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)\n AGENT_FORGE_OFFLINE - Disable startup network operations when set to 1/true/yes\n\n${chalk.bold(\"Built-in Tool Names:\")}\n read - Read file contents\n bash - Execute bash commands\n powershell - Execute PowerShell commands on Windows\n edit - Edit files with find/replace\n write - Write files (creates/overwrites)\n grep - Search file contents (read-only, off by default)\n find - Find files by glob pattern (read-only, off by default)\n ls - List directory contents (read-only, off by default)\n`);\n}\n"]}
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGzF,8EAA8E;AAC9E,2EAA2E;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAwFnE,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAEnG,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAErE,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAyB;IACzE,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAqB,CAAC,CAAC;AAAA,CACxD;AAED,uFAAuF;AACvF,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAW;IACvD,OAAQ,cAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAAA,CAC5D;AAED,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAA0B;IAC3E,OAAO,qBAAqB,CAAC,QAAQ,CAAC,KAAsB,CAAC,CAAC;AAAA,CAC9D;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAsB;IACvE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO,IAAI,CAAC,MAAM,GAAG,CAA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AQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ,eAAe,eAAe;IACtC,QAAQ;;EAEV,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2ClC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,mCAAmC,eAAe;IAC1E,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;;;;EAI5B,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC;;;;;;;;;CASnC,CAAC,CAAC;AAAA,CACF","sourcesContent":["/**\n * CLI argument parsing and help display\n */\n\nimport type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_SESSION_DIR } from \"../config.ts\";\nimport type { HostLogLevel } from \"../core/logger.ts\";\nimport type { TuiMode } from \"../core/settings-manager.ts\";\n// TRACE_KINDS_V1 is a value import, but observability-types.ts has no runtime\n// edges (its two imports are type-only), so no import cycle can form here.\nimport { TRACE_KINDS_V1 } from \"../plugins/observability-types.ts\";\n\nexport type Mode = \"text\" | \"json\" | \"rpc\";\n\nexport interface Args {\n\tprovider?: string;\n\tmodel?: string;\n\tapiKey?: string;\n\tsystemPrompt?: string;\n\tappendSystemPrompt?: string[];\n\tthinking?: ThinkingLevel;\n\tcontinue?: boolean;\n\tresume?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n\tmode?: Mode;\n\tname?: string;\n\tnoSession?: boolean;\n\t/** Explicit suite/profile migration on resume (--rebind-suite): adopt the current plugin set when the session binding drifted. */\n\trebindSuite?: boolean;\n\tsession?: string;\n\tsessionId?: string;\n\tfork?: string;\n\tsessionDir?: string;\n\t/** Suite (方案) id for session workspace and context assembly. */\n\tsuite?: string;\n\t/** One-shot lifecycle action: create the user suite workspace (设计 §9). */\n\tsuiteCreate?: string;\n\t/** Companion of --suite-create: clone the source suite workspace. */\n\tcloneFrom?: string;\n\t/** One-shot lifecycle action: delete the user suite workspace (设计 §9). */\n\tsuiteDelete?: string;\n\t/** One-shot lifecycle action: reset a builtin suite to factory contents (设计 §9). */\n\tsuiteReset?: string;\n\t/** Serve the coding-agent session runtime over TCP on the given port. */\n\tserve?: number;\n\t/** Opt-in `--serve` workspace boundary: remote creates must resolve inside one of these roots (repeatable). */\n\tserveWorkspaceRoots?: string[];\n\t/**\n\t * Run as a headless subagent runner (D-045 pooled increment 2b): serve the\n\t * subagent-task command surface on stdio for a parent session's runner pool.\n\t */\n\tsubagentRunner?: boolean;\n\tmodels?: string[];\n\ttools?: string[];\n\texcludeTools?: string[];\n\tnoTools?: boolean;\n\tnoBuiltinTools?: boolean;\n\tnoPlugins?: boolean;\n\t/** Disable session trace collection: equivalent to SDK `traceEnabled: false`. */\n\tnoTrace?: boolean;\n\t/** Host log level. Overrides AGENT_FORGE_LOG_LEVEL; default \"info\". */\n\tlogLevel?: HostLogLevel;\n\t/** Explicit builtin plugin profile for this run. */\n\tpluginProfile?: string;\n\t/** Explicit plugin IDs selected for the profile. */\n\tplugins?: string[];\n\t/** Explicit plugin IDs disabled for the profile. */\n\tdisabledPlugins?: string[];\n\t/** Persistence scope for explicit plugin selection: global by default. */\n\tpluginSelectionScope?: \"global\" | \"project\";\n\tprint?: boolean;\n\texport?: string;\n\t/** View a session's trace file (session id, path, or empty for the most recent session). */\n\ttrace?: string;\n\t/** Structured records output for --trace (设计 §8 第 3 期). */\n\ttraceJson?: boolean;\n\t/** With --trace, show only records whose kind is in this whitelist (TRACE_KINDS_V1 members). */\n\ttraceKind?: string[];\n\t/** With --trace, show only the last N records (positive integer). */\n\ttraceLimit?: number;\n\tnoSkills?: boolean;\n\tskills?: string[];\n\tpromptTemplates?: string[];\n\tnoPromptTemplates?: boolean;\n\tthemes?: string[];\n\tuseTheme?: string;\n\tnoThemes?: boolean;\n\tnoContextFiles?: boolean;\n\tlistModels?: string | true;\n\toffline?: boolean;\n\ttuiMode?: TuiMode;\n\tverbose?: boolean;\n\tmessages: string[];\n\tfileArgs: string[];\n\tdiagnostics: Array<{ type: \"warning\" | \"error\"; message: string }>;\n}\n\nconst VALID_THINKING_LEVELS = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\n\nconst VALID_LOG_LEVELS = [\"debug\", \"info\", \"warn\", \"error\"] as const;\n\nexport function isValidHostLogLevel(level: string): level is HostLogLevel {\n\treturn VALID_LOG_LEVELS.includes(level as HostLogLevel);\n}\n\n/** Single source of valid `--trace-kind` values: the TRACE_KINDS_V1 runtime mirror. */\nexport function isValidTraceKind(kind: string): boolean {\n\treturn (TRACE_KINDS_V1 as readonly string[]).includes(kind);\n}\n\n/** Keep CLI plugin selection bounded before it reaches profile resolution. */\nexport const MAX_PLUGIN_CLI_ID_CHARS = 128;\nexport const MAX_PLUGIN_CLI_IDS = 128;\n\nexport function isValidThinkingLevel(level: string): level is ThinkingLevel {\n\treturn VALID_THINKING_LEVELS.includes(level as ThinkingLevel);\n}\n\nexport function normalizeSessionName(value: string): string | undefined {\n\tconst name = value.trim();\n\treturn name.length > 0 ? name : undefined;\n}\n\nfunction parseBoundedPluginId(\n\targs: string[],\n\tindex: number,\n\tresult: Args,\n\toption: \"--plugin\" | \"--disable-plugin\",\n\tvalues: string[],\n): number {\n\tconst raw = args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a plugin id` });\n\t\treturn index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: `${option} requires a non-empty plugin id` });\n\t\treturn index + 1;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tif (values.length >= MAX_PLUGIN_CLI_IDS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `${option} accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t});\n\t\treturn index + 1;\n\t}\n\tvalues.push(value);\n\treturn index + 1;\n}\n\nfunction parsePluginProfileValue(args: string[], index: number, result: Args, rawValue?: string): number {\n\tconst raw = rawValue ?? args[index + 1];\n\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a profile id\" });\n\t\treturn rawValue === undefined ? index : index;\n\t}\n\tconst value = raw.trim();\n\tif (value.length === 0) {\n\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-profile requires a non-empty profile id\" });\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tif (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\tresult.diagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `--plugin-profile id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t});\n\t\treturn rawValue === undefined ? index + 1 : index;\n\t}\n\tresult.pluginProfile = value;\n\treturn rawValue === undefined ? index + 1 : index;\n}\n\nexport function parseArgs(args: string[]): Args {\n\tconst result: Args = {\n\t\tmessages: [],\n\t\tfileArgs: [],\n\t\tdiagnostics: [],\n\t};\n\n\tfor (let i = 0; i < args.length; i++) {\n\t\tconst arg = args[i];\n\n\t\tif (arg === \"--\") {\n\t\t\tfor (const positionalArg of args.slice(i + 1)) {\n\t\t\t\tif (positionalArg.startsWith(\"@\")) {\n\t\t\t\t\tresult.fileArgs.push(positionalArg.slice(1));\n\t\t\t\t} else {\n\t\t\t\t\tresult.messages.push(positionalArg);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t} else if (arg === \"--help\" || arg === \"-h\") {\n\t\t\tresult.help = true;\n\t\t} else if (arg === \"--version\" || arg === \"-v\") {\n\t\t\tresult.version = true;\n\t\t} else if (arg === \"--mode\" && i + 1 < args.length) {\n\t\t\tconst mode = args[++i];\n\t\t\tif (mode === \"text\" || mode === \"json\" || mode === \"rpc\") {\n\t\t\t\tresult.mode = mode;\n\t\t\t}\n\t\t} else if (arg === \"--continue\" || arg === \"-c\") {\n\t\t\tresult.continue = true;\n\t\t} else if (arg === \"--resume\" || arg === \"-r\") {\n\t\t\tresult.resume = true;\n\t\t} else if (arg === \"--provider\" && i + 1 < args.length) {\n\t\t\tresult.provider = args[++i];\n\t\t} else if ((arg === \"--model\" || arg === \"-m\") && i + 1 < args.length) {\n\t\t\tresult.model = args[++i];\n\t\t} else if (arg === \"--api-key\" && i + 1 < args.length) {\n\t\t\tresult.apiKey = args[++i];\n\t\t} else if (arg === \"--system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.systemPrompt = args[++i];\n\t\t} else if (arg === \"--append-system-prompt\" && i + 1 < args.length) {\n\t\t\tresult.appendSystemPrompt = result.appendSystemPrompt ?? [];\n\t\t\tresult.appendSystemPrompt.push(args[++i]);\n\t\t} else if (arg === \"--name\" || arg === \"-n\") {\n\t\t\tif (i + 1 < args.length) {\n\t\t\t\tresult.name = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--name requires a value\" });\n\t\t\t}\n\t\t} else if (arg === \"--no-session\") {\n\t\t\tresult.noSession = true;\n\t\t} else if (arg === \"--rebind-suite\") {\n\t\t\tresult.rebindSuite = true;\n\t\t} else if (arg === \"--session\" && i + 1 < args.length) {\n\t\t\tresult.session = args[++i];\n\t\t} else if (arg === \"--session-id\" && i + 1 < args.length) {\n\t\t\tresult.sessionId = args[++i];\n\t\t} else if (arg === \"--fork\" && i + 1 < args.length) {\n\t\t\tresult.fork = args[++i];\n\t\t} else if (arg === \"--session-dir\" && i + 1 < args.length) {\n\t\t\tresult.sessionDir = args[++i];\n\t\t} else if (arg === \"--suite\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suite = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-create\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteCreate = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-create requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--clone-from\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.cloneFrom = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--clone-from requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-delete\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteDelete = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-delete requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--suite-reset\") {\n\t\t\tconst id = args[i + 1];\n\t\t\tif (id !== undefined && !id.startsWith(\"-\")) {\n\t\t\t\tresult.suiteReset = id;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--suite-reset requires a suite id\" });\n\t\t\t}\n\t\t} else if (arg === \"--serve\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tconst port = raw !== undefined && /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\tif (Number.isInteger(port) && port <= 65535) {\n\t\t\t\tresult.serve = port;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve requires a valid TCP port (0-65535)\" });\n\t\t\t\tif (raw !== undefined) i++;\n\t\t\t}\n\t\t} else if (arg === \"--subagent-runner\") {\n\t\t\tresult.subagentRunner = true;\n\t\t} else if (arg === \"--serve-workspace-root\") {\n\t\t\tconst dir = args[i + 1];\n\t\t\tif (dir === undefined || dir.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--serve-workspace-root requires a directory\" });\n\t\t\t} else {\n\t\t\t\tresult.serveWorkspaceRoots = result.serveWorkspaceRoots ?? [];\n\t\t\t\tresult.serveWorkspaceRoots.push(dir);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--models\" && i + 1 < args.length) {\n\t\t\tresult.models = args[++i].split(\",\").map((s) => s.trim());\n\t\t} else if (arg === \"--no-tools\" || arg === \"-nt\") {\n\t\t\tresult.noTools = true;\n\t\t} else if (arg === \"--no-builtin-tools\" || arg === \"-nbt\") {\n\t\t\tresult.noBuiltinTools = true;\n\t\t} else if ((arg === \"--tools\" || arg === \"-t\") && i + 1 < args.length) {\n\t\t\tresult.tools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if ((arg === \"--exclude-tools\" || arg === \"-xt\") && i + 1 < args.length) {\n\t\t\tresult.excludeTools = args[++i]\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((s) => s.trim())\n\t\t\t\t.filter((name) => name.length > 0);\n\t\t} else if (arg === \"--thinking\" && i + 1 < args.length) {\n\t\t\tconst level = args[++i];\n\t\t\tif (isValidThinkingLevel(level)) {\n\t\t\t\tresult.thinking = level;\n\t\t\t} else {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Invalid thinking level \"${level}\". Valid values: ${VALID_THINKING_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--print\" || arg === \"-p\") {\n\t\t\tresult.print = true;\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"@\") && (!next.startsWith(\"-\") || next.startsWith(\"---\"))) {\n\t\t\t\tresult.messages.push(next);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--export\" && i + 1 < args.length) {\n\t\t\tresult.export = args[++i];\n\t\t} else if (arg === \"--trace\") {\n\t\t\t// View command: bare --trace targets the most recent session; a\n\t\t\t// following non-option token is the session id or trace/session path.\n\t\t\tconst next = args[i + 1];\n\t\t\tif (next !== undefined && !next.startsWith(\"-\")) {\n\t\t\t\tresult.trace = next;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tresult.trace = \"\";\n\t\t\t}\n\t\t} else if (arg === \"--trace-json\") {\n\t\t\tresult.traceJson = true;\n\t\t} else if (arg === \"--trace-kind\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires a comma-separated kind list\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst kinds = raw\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((kind) => kind.trim())\n\t\t\t\t\t.filter((kind) => kind.length > 0);\n\t\t\t\tconst invalid = kinds.filter((kind) => !isValidTraceKind(kind));\n\t\t\t\tif (kinds.length === 0) {\n\t\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-kind requires at least one trace kind\" });\n\t\t\t\t} else if (invalid.length > 0) {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace kind(s) \"${invalid.join(\", \")}\". Valid values: ${TRACE_KINDS_V1.join(\", \")}`,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.traceKind = kinds;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--trace-limit\") {\n\t\t\tconst raw = args[i + 1];\n\t\t\tif (raw === undefined || raw.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--trace-limit requires a positive integer\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tconst limit = /^\\d+$/.test(raw) ? Number(raw) : Number.NaN;\n\t\t\t\tif (Number.isInteger(limit) && limit > 0) {\n\t\t\t\t\tresult.traceLimit = limit;\n\t\t\t\t} else {\n\t\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: `Invalid trace limit \"${raw}\". Expected a positive integer`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (arg === \"--no-plugins\" || arg === \"-np\") {\n\t\t\tresult.noPlugins = true;\n\t\t} else if (arg === \"--no-trace\") {\n\t\t\tresult.noTrace = true;\n\t\t} else if (arg === \"--log-level\") {\n\t\t\tconst level = args[i + 1];\n\t\t\tif (level === undefined || level.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--log-level requires a level\" });\n\t\t\t} else if (!isValidHostLogLevel(level)) {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid log level \"${level}\". Valid values: ${VALID_LOG_LEVELS.join(\", \")}`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.logLevel = level;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--plugin-profile\") {\n\t\t\ti = parsePluginProfileValue(args, i, result);\n\t\t} else if (arg.startsWith(\"--plugin-profile=\")) {\n\t\t\tparsePluginProfileValue(args, i, result, arg.slice(\"--plugin-profile=\".length));\n\t\t} else if (arg === \"--plugin-scope\" || arg.startsWith(\"--plugin-scope=\")) {\n\t\t\tconst raw = arg === \"--plugin-scope\" ? args[i + 1] : arg.slice(\"--plugin-scope=\".length);\n\t\t\tif (arg === \"--plugin-scope\") i++;\n\t\t\tif (raw !== \"global\" && raw !== \"project\") {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope must be global or project\" });\n\t\t\t} else if (result.pluginSelectionScope !== undefined) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin-scope may be specified only once\" });\n\t\t\t} else {\n\t\t\t\tresult.pluginSelectionScope = raw;\n\t\t\t}\n\t\t} else if (arg === \"--plugin\") {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--plugin\", result.plugins);\n\t\t} else if (arg.startsWith(\"--plugin=\")) {\n\t\t\tresult.plugins = result.plugins ?? [];\n\t\t\tconst value = arg.slice(\"--plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.plugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.plugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--disable-plugin\") {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\ti = parseBoundedPluginId(args, i, result, \"--disable-plugin\", result.disabledPlugins);\n\t\t} else if (arg.startsWith(\"--disable-plugin=\")) {\n\t\t\tresult.disabledPlugins = result.disabledPlugins ?? [];\n\t\t\tconst value = arg.slice(\"--disable-plugin=\".length).trim();\n\t\t\tif (value.length === 0) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--disable-plugin requires a non-empty plugin id\" });\n\t\t\t} else if (value.length > MAX_PLUGIN_CLI_ID_CHARS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin plugin id must be at most ${MAX_PLUGIN_CLI_ID_CHARS} characters`,\n\t\t\t\t});\n\t\t\t} else if (result.disabledPlugins.length >= MAX_PLUGIN_CLI_IDS) {\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `--disable-plugin accepts at most ${MAX_PLUGIN_CLI_IDS} plugin ids`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresult.disabledPlugins.push(value);\n\t\t\t}\n\t\t} else if (arg === \"--skill\" && i + 1 < args.length) {\n\t\t\tresult.skills = result.skills ?? [];\n\t\t\tresult.skills.push(args[++i]);\n\t\t} else if (arg === \"--prompt-template\" && i + 1 < args.length) {\n\t\t\tresult.promptTemplates = result.promptTemplates ?? [];\n\t\t\tresult.promptTemplates.push(args[++i]);\n\t\t} else if (arg === \"--theme\" && i + 1 < args.length) {\n\t\t\tresult.themes = result.themes ?? [];\n\t\t\tresult.themes.push(args[++i]);\n\t\t} else if (arg === \"--use-theme\") {\n\t\t\tconst themeName = args[i + 1];\n\t\t\tif (themeName === undefined || themeName.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--use-theme requires a theme name\" });\n\t\t\t} else {\n\t\t\t\tresult.useTheme = themeName;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (arg === \"--no-skills\" || arg === \"-ns\") {\n\t\t\tresult.noSkills = true;\n\t\t} else if (arg === \"--no-prompt-templates\" || arg === \"-np\") {\n\t\t\tresult.noPromptTemplates = true;\n\t\t} else if (arg === \"--no-themes\") {\n\t\t\tresult.noThemes = true;\n\t\t} else if (arg === \"--no-context-files\" || arg === \"-nc\") {\n\t\t\tresult.noContextFiles = true;\n\t\t} else if (arg === \"--list-models\") {\n\t\t\t// Check if next arg is a search pattern (not a flag or file arg)\n\t\t\tif (i + 1 < args.length && !args[i + 1].startsWith(\"-\") && !args[i + 1].startsWith(\"@\")) {\n\t\t\t\tresult.listModels = args[++i];\n\t\t\t} else {\n\t\t\t\tresult.listModels = true;\n\t\t\t}\n\t\t} else if (arg === \"--tui-mode\") {\n\t\t\tconst mode = args[i + 1];\n\t\t\tif (mode === \"regular\" || mode === \"fullscreen\") {\n\t\t\t\tresult.tuiMode = mode;\n\t\t\t\ti++;\n\t\t\t} else if (mode === undefined || mode.startsWith(\"-\")) {\n\t\t\t\tresult.diagnostics.push({ type: \"error\", message: \"--tui-mode requires regular or fullscreen\" });\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t\tresult.diagnostics.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: `Invalid TUI mode \"${mode}\". Valid values: regular, fullscreen`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (arg === \"--verbose\") {\n\t\t\tresult.verbose = true;\n\t\t} else if (arg === \"--offline\") {\n\t\t\tresult.offline = true;\n\t\t} else if (arg.startsWith(\"@\")) {\n\t\t\tresult.fileArgs.push(arg.slice(1)); // Remove @ prefix\n\t\t} else if (arg.startsWith(\"--\")) {\n\t\t\t// Unknown long options are errors: extension-registered CLI flags no\n\t\t\t// longer exist, so there is nothing left that could claim them.\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg.split(\"=\")[0]}` });\n\t\t\ti++;\n\t\t} else if (arg.startsWith(\"-\") && !arg.startsWith(\"--\")) {\n\t\t\tresult.diagnostics.push({ type: \"error\", message: `Unknown option: ${arg}` });\n\t\t} else if (!arg.startsWith(\"-\")) {\n\t\t\tresult.messages.push(arg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function printHelp(): void {\n\tconsole.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools\n\n${chalk.bold(\"Usage:\")}\n ${APP_NAME} [options] [--] [@files...] [messages...]\n\n${chalk.bold(\"Commands:\")}\n ${APP_NAME} install <source> [-l] Install extension source and add to settings\n ${APP_NAME} remove <source> [-l] Remove extension source from settings\n ${APP_NAME} uninstall <source> [-l] Alias for remove\n ${APP_NAME} update [source|self|agent-forge] Update Agent Forge, extensions, or model catalogs\n ${APP_NAME} list List installed extensions from settings\n ${APP_NAME} config [-l] Open TUI to enable/disable package resources (Tab switches scope)\n ${APP_NAME} auth <command> Print credentials or check provider readiness\n ${APP_NAME} <command> --help Show help for install/remove/uninstall/update/list/config/auth\n\n${chalk.bold(\"Options:\")}\n --provider <name> Provider name (default: google)\n --model <pattern> Model pattern or ID (supports \"provider/id\" and optional \":<thinking>\")\n --api-key <key> API key (defaults to env vars)\n --system-prompt <text> System prompt (default: coding assistant prompt)\n --append-system-prompt <text> Append text or file contents to the system prompt (can be used multiple times)\n --mode <mode> Output mode: text (default), json, or rpc\n --print, -p Non-interactive mode: process prompt and exit\n --continue, -c Continue previous session\n --resume, -r Select a session to resume\n --session <path|id> Use specific session file or partial UUID\n --session-id <id> Use exact project session ID, creating it if missing\n --fork <path|id> Fork specific session file or partial UUID into a new session\n --session-dir <dir> Directory for session storage and lookup\n --suite <id> Suite (方案) for this run: assistant (default) or coding; new sessions only\n --suite-create <id> Create a user suite workspace and exit; add --clone-from <id> to copy one\n --suite-delete <id> Delete a user suite workspace (active session references refuse) and exit\n --suite-reset <id> Reset a builtin suite to factory contents (shows a diff) and exit\n --serve <port> (Experimental, local trust only) Serve the coding-agent session runtime over the WebSocket gateway (default: 127.0.0.1; HTTP surface: /healthz plus token-protected artifact reads) and exit on SIGINT/SIGTERM\n Durable journal: <agentDir>/remote-server-journal.jsonl (never the process cwd)\n --serve-workspace-root <dir> Opt-in --serve boundary: remote creates must run inside one of these roots (repeatable); without it any local directory is allowed\n --subagent-runner (Experimental) Run as a headless subagent runner: serve the subagent-task protocol on stdio for a parent session's runner pool (D-045)\n --no-session Don't save session (ephemeral)\n --name, -n <name> Set session display name\n --models <patterns> Comma-separated model patterns for Ctrl+P cycling\n Supports globs (anthropic/*, *sonnet*) and fuzzy matching\n --no-tools, -nt Disable all tools by default (built-in and plugin)\n --no-builtin-tools, -nbt Disable built-in tools by default but keep plugin/custom tools enabled\n --tools, -t <tools> Comma-separated allowlist of tool names to enable\n Applies to built-in, plugin, and custom tools\n --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable\n Applies to built-in, plugin, and custom tools\n --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max\n --no-plugins, -np Disable capability plugin discovery (D-028 escape hatch)\n --no-trace Disable session trace collection (no .trace.jsonl file is written)\n --log-level <level> Host log level: debug, info (default), warn, error\n --plugin-profile <id> Select a builtin capability plugin profile for this run\n --plugin <id> Select a plugin within the profile (repeatable)\n --disable-plugin <id> Disable a plugin within the profile (repeatable)\n --plugin-scope <scope> Read the explicit selection from global or project storage\n plugin catalog list List installed/available ecosystem plugins (independent namespace)\n --skill <path> Load a skill file or directory (can be used multiple times)\n --no-skills, -ns Disable skills discovery and loading\n --prompt-template <path> Load a prompt template file or directory (can be used multiple times)\n --no-prompt-templates, -np Disable prompt template discovery and loading\n --theme <path> Load a theme file or directory (can be used multiple times)\n --use-theme <name[/name]> Set the initial interactive theme for this run\n --no-themes Disable theme discovery and loading\n --no-context-files, -nc Disable AGENTS.md and CLAUDE.md discovery and loading\n --export <file> Export session file to HTML and exit\n --trace <session> View a session trace file as a text timeline and exit; <session> is a session id/prefix or trace/session file path, omit it for the most recent session\n --trace-json With --trace, output the structured trace records as JSON instead of the text timeline\n --trace-kind <k1,k2> With --trace, show only records of these kinds (comma-separated); valid kinds: ${TRACE_KINDS_V1.join(\", \")}\n --trace-limit <n> With --trace, show only the last N records (positive integer)\n --list-models [search] List available models (with optional fuzzy search)\n --verbose Force verbose startup (overrides quietStartup setting)\n --tui-mode <mode> TUI mode: regular (default) or fullscreen\n --offline Disable startup network operations (same as AGENT_FORGE_OFFLINE=1)\n -- End option parsing; treat remaining arguments as messages/files\n --help, -h Show this help\n --version, -v Show version number\n\n${chalk.bold(\"Examples:\")}\n # Print a provider API key for an external client\n ${APP_NAME} auth print-api-key --provider openai\n\n # Print an OAuth bearer token for an external client (refreshes if expired)\n ${APP_NAME} auth print-bearer-token --provider openai-codex\n\n # Interactive mode\n ${APP_NAME}\n\n # Interactive mode with initial prompt\n ${APP_NAME} \"List all .ts files in src/\"\n\n # Include files in initial message\n ${APP_NAME} @prompt.md @image.png \"What color is the sky?\"\n\n # Non-interactive mode (process and exit)\n ${APP_NAME} -p \"List all .ts files in src/\"\n\n # Prompt beginning with a dash\n ${APP_NAME} -p -- \"- Summarize these points\"\n\n # Multiple messages (interactive)\n ${APP_NAME} \"Read package.json\" \"What dependencies do we have?\"\n\n # Continue previous session\n ${APP_NAME} --continue \"What did we discuss?\"\n\n # Start a named session\n ${APP_NAME} --name \"Refactor auth module\"\n\n # Use different model\n ${APP_NAME} --provider openai --model gpt-4o-mini \"Help me refactor this code\"\n\n # Use model with provider prefix (no --provider needed)\n ${APP_NAME} --model openai/gpt-4o \"Help me refactor this code\"\n\n # Use model with thinking level shorthand\n ${APP_NAME} --model sonnet:high \"Solve this complex problem\"\n\n # Limit model cycling to specific models\n ${APP_NAME} --models claude-sonnet,claude-haiku,gpt-4o\n\n # Limit to a specific provider with glob pattern\n ${APP_NAME} --models \"github-copilot/*\"\n\n # Cycle models with fixed thinking levels\n ${APP_NAME} --models sonnet:high,haiku:low\n\n # Start with a specific thinking level\n ${APP_NAME} --thinking high \"Solve this complex problem\"\n\n # Read-only mode (no file modifications possible)\n ${APP_NAME} --tools read,grep,find,ls -p \"Review the code in src/\"\n\n # Disable one tool while keeping the rest available\n ${APP_NAME} --exclude-tools ask_question\n\n # Export a session file to HTML\n ${APP_NAME} --export ~/${CONFIG_DIR_NAME}/agent/sessions/--path--/session.jsonl\n ${APP_NAME} --export session.jsonl output.html\n\n${chalk.bold(\"Environment Variables:\")}\n ANTHROPIC_AUTH_TOKEN - Anthropic bearer auth token\n ANTHROPIC_API_KEY - Anthropic Claude API key\n ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth token (alternative to API key)\n ANT_LING_API_KEY - Ant Ling API key\n OPENAI_API_KEY - OpenAI GPT API key\n AZURE_OPENAI_API_KEY - Azure OpenAI API key\n AZURE_OPENAI_BASE_URL - Azure OpenAI/Cognitive Services base URL (e.g. https://{resource}.openai.azure.com)\n AZURE_OPENAI_RESOURCE_NAME - Azure OpenAI resource name (alternative to base URL)\n AZURE_OPENAI_API_VERSION - Azure OpenAI API version (default: v1)\n AZURE_OPENAI_DEPLOYMENT_NAME_MAP - Azure OpenAI model=deployment map (comma-separated)\n DEEPSEEK_API_KEY - DeepSeek API key\n NVIDIA_API_KEY - NVIDIA NIM API key\n GEMINI_API_KEY - Google Gemini API key\n GROQ_API_KEY - Groq API key\n CEREBRAS_API_KEY - Cerebras API key\n XAI_API_KEY - xAI Grok API key\n FIREWORKS_API_KEY - Fireworks API key\n TOGETHER_API_KEY - Together AI API key\n BASETEN_API_KEY - Baseten API key\n OPENROUTER_API_KEY - OpenRouter API key\n AI_GATEWAY_API_KEY - Vercel AI Gateway API key\n ZAI_API_KEY - ZAI Coding Plan API key (Global)\n ZAI_CODING_CN_API_KEY - ZAI Coding Plan API key (China)\n MISTRAL_API_KEY - Mistral API key\n MINIMAX_API_KEY - MiniMax API key\n MOONSHOT_API_KEY - Moonshot AI API key\n OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key\n KIMI_API_KEY - Kimi For Coding API key\n CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)\n CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)\n CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)\n QWEN_TOKEN_PLAN_API_KEY - Qwen Token Plan API key (international region)\n QWEN_TOKEN_PLAN_CN_API_KEY - Qwen Token Plan API key (China region)\n XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)\n XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)\n XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)\n XIAOMI_TOKEN_PLAN_SGP_API_KEY - Xiaomi MiMo Token Plan API key (Singapore region)\n AWS_PROFILE - AWS profile for Amazon Bedrock\n AWS_ACCESS_KEY_ID - AWS access key for Amazon Bedrock\n AWS_SECRET_ACCESS_KEY - AWS secret key for Amazon Bedrock\n AWS_BEARER_TOKEN_BEDROCK - Bedrock API key (bearer token)\n AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)\n ${ENV_AGENT_DIR.padEnd(32)} - Config directory (default: ~/${CONFIG_DIR_NAME}/agent)\n ${ENV_SESSION_DIR.padEnd(32)} - Session storage directory (overridden by --session-dir)\n AGENT_FORGE_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)\n AGENT_FORGE_OFFLINE - Disable startup network operations when set to 1/true/yes\n\n${chalk.bold(\"Built-in Tool Names:\")}\n read - Read file contents\n bash - Execute bash commands\n powershell - Execute PowerShell commands on Windows\n edit - Edit files with find/replace\n write - Write files (creates/overwrites)\n grep - Search file contents (read-only, off by default)\n find - Find files by glob pattern (read-only, off by default)\n ls - List directory contents (read-only, off by default)\n`);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-command.d.ts","sourceRoot":"","sources":["../../src/cli/plugin-command.ts"],"names":[],"mappings":"AAQA,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,+BAA+B,EAGpC,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,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,sCAAsC,CAAC,OAAO,EAAE;IACrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;CACrC,GAAG,OAAO,CAAC;IAAE,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAWnG;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CACjD,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,sBAA2B,GAClC,OAAO,CAAC,OAAO,CAAC,CAyBlB","sourcesContent":["import { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"../plugins/ecosystem/bootstrap-factory-manifest.ts\";\nimport { defaultPluginHostFactsV1, projectPluginScopeRefV1 } from \"../plugins/ecosystem/default-active-bindings.ts\";\nimport {\n\tcreateDefaultPluginMarketWiringV1,\n\ttype DefaultPluginMarketWiringV1,\n} from \"../plugins/ecosystem/default-plugin-market.ts\";\nimport {\n\tcreatePluginEcosystemCliV1,\n\tcreatePluginSelectionStoreV1,\n\tcreatePluginStateStoreV1,\n\ttype PluginDistributionV1,\n\ttype PluginEcosystemCliAcquisitionV1,\n\ttype PluginEcosystemCliResponseV1,\n\ttype PluginEcosystemCliV1,\n\ttype PluginEcosystemRegistryV1,\n\ttype PluginInstallerV1,\n\ttype PluginSelectionStoreV1,\n\ttype PluginStateStoreV1,\n} from \"../plugins/ecosystem/index.ts\";\nimport { listBuiltinPluginManifestsV1 } from \"../profile/plugin-profiles.ts\";\nimport type { PluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\nimport { createPluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\n\nexport interface PluginCommandOptionsV1 {\n\treadonly agentDir?: string;\n\t/** Working directory used for the project-local selection store. */\n\treadonly cwd?: string;\n\treadonly host?: {\n\t\treadonly os: string;\n\t\treadonly arch: string;\n\t\treadonly runtime: readonly { readonly name: string; readonly version: string }[];\n\t\treadonly apiVersion: string;\n\t\treadonly hostFeatures: readonly string[];\n\t};\n\t/** Optional host-owned boundaries used by install/update/remove commands. */\n\treadonly registry?: PluginEcosystemRegistryV1;\n\treadonly installer?: PluginInstallerV1;\n\t/** Optional host-owned multi-source package resolution used by install/update. */\n\treadonly acquisition?: PluginEcosystemCliAcquisitionV1;\n\t/** Optional host-owned package download boundary used by install/update. */\n\treadonly distribution?: PluginDistributionV1;\n\t/** Override persistence in tests or an embedding host; defaults remain agentDir files. */\n\treadonly stateStore?: PluginStateStoreV1;\n\t/** Override the project-local persistence boundary in tests or an embedding host. */\n\treadonly projectStateStore?: PluginStateStoreV1;\n\treadonly selectionStore?: PluginSelectionStoreV1;\n\treadonly projectSelectionStore?: PluginSelectionStoreV1;\n\treadonly write?: (line: string) => void;\n}\n\nfunction printResponse(response: PluginEcosystemCliResponseV1, write: (line: string) => void): void {\n\twrite(response.text);\n\tif (response.status !== \"succeeded\") process.exitCode = 1;\n}\n\ninterface MarketCliOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\treadonly market?: DefaultPluginMarketWiringV1;\n\treadonly overrides?: PluginCommandOptionsV1;\n}\n\nfunction buildMarketCli(options: MarketCliOptionsV1): PluginEcosystemCliV1 {\n\tconst { market, overrides } = options;\n\treturn createPluginEcosystemCliV1({\n\t\thost: overrides?.host ?? defaultPluginHostFactsV1(),\n\t\tmanifests: listBuiltinPluginManifestsV1(),\n\t\tregistry: overrides?.registry ?? market?.cliRegistry,\n\t\t// Multi-source acquisition (`plugin install <ref>`) rides along with the\n\t\t// default market wiring; a fully host-injected stack replaces it wholesale.\n\t\t...(overrides?.acquisition === undefined && market?.acquisition === undefined\n\t\t\t? {}\n\t\t\t: { acquisition: overrides?.acquisition ?? market?.acquisition }),\n\t\tinstaller: overrides?.installer ?? market?.installer,\n\t\t...(overrides?.distribution !== undefined || market?.distribution !== undefined\n\t\t\t? { distribution: overrides?.distribution ?? market!.distribution }\n\t\t\t: {}),\n\t\tstateStore:\n\t\t\toverrides?.stateStore ??\n\t\t\tmarket?.stateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.agentDir, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectStateStore:\n\t\t\toverrides?.projectStateStore ??\n\t\t\tmarket?.projectStateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectScopeRef: projectPluginScopeRefV1(options.cwd),\n\t\tselectionStore:\n\t\t\toverrides?.selectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.agentDir, \".plugin-selection.json\") }),\n\t\tprojectSelectionStore:\n\t\t\toverrides?.projectSelectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, \".plugin-selection.json\") }),\n\t});\n}\n\n/**\n * Default TUI manager controller over the default marketplace wiring. The\n * controller reads the global or project state store per scope; callers must\n * invoke `close` after the config screen closes.\n */\nexport async function createDefaultPluginManagerControllerV1(options: {\n\treadonly agentDir?: string;\n\treadonly cwd?: string;\n\treadonly scope: \"global\" | \"project\";\n}): Promise<{ readonly controller: PluginManagerControllerV1; readonly close: () => Promise<void> }> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market = await createDefaultPluginMarketWiringV1({ agentDir, cwd });\n\tconst cli = buildMarketCli({ agentDir, cwd, market });\n\tconst controller = createPluginManagerControllerV1({\n\t\tregistry: market.registry,\n\t\tstateStore: options.scope === \"project\" ? market.projectStateStore : market.stateStore,\n\t\tcli,\n\t});\n\treturn { controller, close: market.close };\n}\n\n/**\n * Handle the independent ecosystem command namespace before legacy package\n * commands. Install/update/remove default to the disk install store plus an\n * optional configured marketplace origin; host injection of registry and\n * installer still wins entirely.\n */\nexport async function handlePluginEcosystemCommand(\n\targs: readonly string[],\n\toptions: PluginCommandOptionsV1 = {},\n): Promise<boolean> {\n\tif (args[0] !== \"plugin\") return false;\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\t// Batch update convenience (0.85.7 user seat finding: a factory range bump\n\t// left seven plugins outdated and the per-plugin hint meant seven manual\n\t// commands). The ecosystem CLI protocol is unchanged — this outer layer\n\t// composes `state list` + one `update` per active plugin.\n\tif (args[1] === \"update\" && args[2] === \"--all\") {\n\t\tawait runBatchUpdate(args.slice(3), options, write);\n\t\treturn true;\n\t}\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst response = await cli.execute({ argv: args.slice(1) });\n\t\tprintResponse(response, write);\n\t\treturn true;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n\ninterface BatchUpdateEntry {\n\treadonly pluginId: string;\n\treadonly scope: string;\n\treadonly lifecycle: string;\n}\n\nasync function runBatchUpdate(\n\trestArgs: readonly string[],\n\toptions: PluginCommandOptionsV1,\n\twrite: (line: string) => void,\n): Promise<void> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst scopeIndex = restArgs.indexOf(\"--scope\");\n\tconst scope = scopeIndex !== -1 && restArgs[scopeIndex + 1] === \"project\" ? \"project\" : \"global\";\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst listResponse = await cli.execute({ argv: [\"state\", \"list\", \"--scope\", scope] });\n\t\tif (listResponse.status !== \"succeeded\") {\n\t\t\tprintResponse(listResponse, write);\n\t\t\treturn;\n\t\t}\n\t\tconst entries = ((listResponse.data?.entries ?? []) as readonly BatchUpdateEntry[]).filter(\n\t\t\t(entry) => entry.lifecycle === \"active\" && entry.scope === scope,\n\t\t);\n\t\tif (entries.length === 0) {\n\t\t\twrite(\"No active plugins to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst updated: string[] = [];\n\t\tconst current: string[] = [];\n\t\tconst failed: string[] = [];\n\t\tfor (const entry of entries) {\n\t\t\t// Factory-listed first-party plugins upgrade through the npm range the\n\t\t\t// bootstrap warnings name (`install <npmName>@^range`): the default disk\n\t\t\t// registry only resolves already-installed versions, so a bare `update`\n\t\t\t// there re-resolves the current version and reports nothing to do.\n\t\t\t// Non-factory plugins keep the bare `update` registry semantics.\n\t\t\tconst factoryEntry = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.find((item) => item.pluginId === entry.pluginId);\n\t\t\tconst argv = factoryEntry\n\t\t\t\t? [\"install\", `${factoryEntry.npmName}@${factoryEntry.range ?? \"latest\"}`, \"--scope\", scope]\n\t\t\t\t: [\"update\", entry.pluginId, \"--scope\", scope];\n\t\t\tconst response = await cli.execute({ argv });\n\t\t\tif (response.status === \"succeeded\") {\n\t\t\t\tupdated.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t} else if (response.error?.code === \"already_installed\") {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t} else {\n\t\t\t\tfailed.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t}\n\t\t}\n\t\tconst summary = [\n\t\t\t`updated ${updated.length}${updated.length > 0 ? ` (${updated.join(\", \")})` : \"\"}`,\n\t\t\t`already up to date ${current.length}${current.length > 0 ? ` (${current.join(\", \")})` : \"\"}`,\n\t\t\t`failed ${failed.length}${failed.length > 0 ? ` (${failed.join(\", \")})` : \"\"}`,\n\t\t].join(\"; \");\n\t\twrite(`plugin update --all [${scope}]: ${summary}`);\n\t\tif (failed.length > 0) process.exitCode = 1;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n"]}
1
+ {"version":3,"file":"plugin-command.d.ts","sourceRoot":"","sources":["../../src/cli/plugin-command.ts"],"names":[],"mappings":"AAQA,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,+BAA+B,EAGpC,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAGhF,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE;QACf,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,SAAS;YAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACjF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;KACzC,CAAC;IACF,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IAC9C,QAAQ,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IACvC,kFAAkF;IAClF,QAAQ,CAAC,WAAW,CAAC,EAAE,+BAA+B,CAAC;IACvD,4EAA4E;IAC5E,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAC7C,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC,qFAAqF;IACrF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IAChD,QAAQ,CAAC,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACjD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,sBAAsB,CAAC;IACxD,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAmDD;;;;GAIG;AACH,wBAAsB,sCAAsC,CAAC,OAAO,EAAE;IACrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;CACrC,GAAG,OAAO,CAAC;IAAE,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAWnG;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CACjD,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,sBAA2B,GAClC,OAAO,CAAC,OAAO,CAAC,CAgClB","sourcesContent":["import { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"../plugins/ecosystem/bootstrap-factory-manifest.ts\";\nimport { defaultPluginHostFactsV1, projectPluginScopeRefV1 } from \"../plugins/ecosystem/default-active-bindings.ts\";\nimport {\n\tcreateDefaultPluginMarketWiringV1,\n\ttype DefaultPluginMarketWiringV1,\n} from \"../plugins/ecosystem/default-plugin-market.ts\";\nimport {\n\tcreatePluginEcosystemCliV1,\n\tcreatePluginSelectionStoreV1,\n\tcreatePluginStateStoreV1,\n\ttype PluginDistributionV1,\n\ttype PluginEcosystemCliAcquisitionV1,\n\ttype PluginEcosystemCliResponseV1,\n\ttype PluginEcosystemCliV1,\n\ttype PluginEcosystemRegistryV1,\n\ttype PluginInstallerV1,\n\ttype PluginSelectionStoreV1,\n\ttype PluginStateStoreV1,\n} from \"../plugins/ecosystem/index.ts\";\nimport { listBuiltinPluginManifestsV1 } from \"../profile/plugin-profiles.ts\";\nimport type { PluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\nimport { createPluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\n\nexport interface PluginCommandOptionsV1 {\n\treadonly agentDir?: string;\n\t/** Working directory used for the project-local selection store. */\n\treadonly cwd?: string;\n\treadonly host?: {\n\t\treadonly os: string;\n\t\treadonly arch: string;\n\t\treadonly runtime: readonly { readonly name: string; readonly version: string }[];\n\t\treadonly apiVersion: string;\n\t\treadonly hostFeatures: readonly string[];\n\t};\n\t/** Optional host-owned boundaries used by install/update/remove commands. */\n\treadonly registry?: PluginEcosystemRegistryV1;\n\treadonly installer?: PluginInstallerV1;\n\t/** Optional host-owned multi-source package resolution used by install/update. */\n\treadonly acquisition?: PluginEcosystemCliAcquisitionV1;\n\t/** Optional host-owned package download boundary used by install/update. */\n\treadonly distribution?: PluginDistributionV1;\n\t/** Override persistence in tests or an embedding host; defaults remain agentDir files. */\n\treadonly stateStore?: PluginStateStoreV1;\n\t/** Override the project-local persistence boundary in tests or an embedding host. */\n\treadonly projectStateStore?: PluginStateStoreV1;\n\treadonly selectionStore?: PluginSelectionStoreV1;\n\treadonly projectSelectionStore?: PluginSelectionStoreV1;\n\treadonly write?: (line: string) => void;\n}\n\nfunction printResponse(response: PluginEcosystemCliResponseV1, write: (line: string) => void): void {\n\twrite(response.text);\n\tif (response.status !== \"succeeded\") process.exitCode = 1;\n}\n\ninterface MarketCliOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\treadonly market?: DefaultPluginMarketWiringV1;\n\treadonly overrides?: PluginCommandOptionsV1;\n}\n\nfunction buildMarketCli(options: MarketCliOptionsV1): PluginEcosystemCliV1 {\n\tconst { market, overrides } = options;\n\treturn createPluginEcosystemCliV1({\n\t\thost: overrides?.host ?? defaultPluginHostFactsV1(),\n\t\tmanifests: listBuiltinPluginManifestsV1(),\n\t\tregistry: overrides?.registry ?? market?.cliRegistry,\n\t\t// Multi-source acquisition (`plugin install <ref>`) rides along with the\n\t\t// default market wiring; a fully host-injected stack replaces it wholesale.\n\t\t...(overrides?.acquisition === undefined && market?.acquisition === undefined\n\t\t\t? {}\n\t\t\t: { acquisition: overrides?.acquisition ?? market?.acquisition }),\n\t\tinstaller: overrides?.installer ?? market?.installer,\n\t\t...(overrides?.distribution !== undefined || market?.distribution !== undefined\n\t\t\t? { distribution: overrides?.distribution ?? market!.distribution }\n\t\t\t: {}),\n\t\tstateStore:\n\t\t\toverrides?.stateStore ??\n\t\t\tmarket?.stateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.agentDir, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectStateStore:\n\t\t\toverrides?.projectStateStore ??\n\t\t\tmarket?.projectStateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectScopeRef: projectPluginScopeRefV1(options.cwd),\n\t\tselectionStore:\n\t\t\toverrides?.selectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.agentDir, \".plugin-selection.json\") }),\n\t\tprojectSelectionStore:\n\t\t\toverrides?.projectSelectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, \".plugin-selection.json\") }),\n\t});\n}\n\n/**\n * Default TUI manager controller over the default marketplace wiring. The\n * controller reads the global or project state store per scope; callers must\n * invoke `close` after the config screen closes.\n */\nexport async function createDefaultPluginManagerControllerV1(options: {\n\treadonly agentDir?: string;\n\treadonly cwd?: string;\n\treadonly scope: \"global\" | \"project\";\n}): Promise<{ readonly controller: PluginManagerControllerV1; readonly close: () => Promise<void> }> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market = await createDefaultPluginMarketWiringV1({ agentDir, cwd });\n\tconst cli = buildMarketCli({ agentDir, cwd, market });\n\tconst controller = createPluginManagerControllerV1({\n\t\tregistry: market.registry,\n\t\tstateStore: options.scope === \"project\" ? market.projectStateStore : market.stateStore,\n\t\tcli,\n\t});\n\treturn { controller, close: market.close };\n}\n\n/**\n * Handle the independent ecosystem command namespace before legacy package\n * commands. Install/update/remove default to the disk install store plus an\n * optional configured marketplace origin; host injection of registry and\n * installer still wins entirely.\n */\nexport async function handlePluginEcosystemCommand(\n\targs: readonly string[],\n\toptions: PluginCommandOptionsV1 = {},\n): Promise<boolean> {\n\tif (args[0] !== \"plugin\") return false;\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\t// Batch update convenience (0.85.7 user seat finding: a factory range bump\n\t// left seven plugins outdated and the per-plugin hint meant seven manual\n\t// commands). The ecosystem CLI protocol is unchanged — this outer layer\n\t// composes `state list` + one `update` per active plugin.\n\tif (args[1] === \"update\" && args[2] === \"--all\") {\n\t\tawait runBatchUpdate(args.slice(3), options, write);\n\t\treturn true;\n\t}\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst response = await cli.execute({ argv: args.slice(1) });\n\t\tprintResponse(response, write);\n\t\t// CRM seat finding F3: installing a plugin does not select it — without\n\t\t// this hint the next session reports the tool as unavailable.\n\t\tif (response.status === \"succeeded\" && response.command === \"install\") {\n\t\t\twrite(\n\t\t\t\t\"note: this plugin is installed but not yet selected by a profile; to activate its tools run: agent-forge plugin selection set <profile> <pluginId>\",\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n\ninterface BatchUpdateEntry {\n\treadonly pluginId: string;\n\treadonly scope: string;\n\treadonly lifecycle: string;\n}\n\nasync function runBatchUpdate(\n\trestArgs: readonly string[],\n\toptions: PluginCommandOptionsV1,\n\twrite: (line: string) => void,\n): Promise<void> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst scopeIndex = restArgs.indexOf(\"--scope\");\n\tconst scope = scopeIndex !== -1 && restArgs[scopeIndex + 1] === \"project\" ? \"project\" : \"global\";\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst listResponse = await cli.execute({ argv: [\"state\", \"list\", \"--scope\", scope] });\n\t\tif (listResponse.status !== \"succeeded\") {\n\t\t\tprintResponse(listResponse, write);\n\t\t\treturn;\n\t\t}\n\t\tconst entries = ((listResponse.data?.entries ?? []) as readonly BatchUpdateEntry[]).filter(\n\t\t\t(entry) => entry.lifecycle === \"active\" && entry.scope === scope,\n\t\t);\n\t\tif (entries.length === 0) {\n\t\t\twrite(\"No active plugins to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst updated: string[] = [];\n\t\tconst current: string[] = [];\n\t\tconst failed: string[] = [];\n\t\tfor (const entry of entries) {\n\t\t\t// Factory-listed first-party plugins upgrade through the npm range the\n\t\t\t// bootstrap warnings name (`install <npmName>@^range`): the default disk\n\t\t\t// registry only resolves already-installed versions, so a bare `update`\n\t\t\t// there re-resolves the current version and reports nothing to do.\n\t\t\t// Non-factory plugins keep the bare `update` registry semantics.\n\t\t\tconst factoryEntry = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.find((item) => item.pluginId === entry.pluginId);\n\t\t\tconst argv = factoryEntry\n\t\t\t\t? [\"install\", `${factoryEntry.npmName}@${factoryEntry.range ?? \"latest\"}`, \"--scope\", scope]\n\t\t\t\t: [\"update\", entry.pluginId, \"--scope\", scope];\n\t\t\tconst response = await cli.execute({ argv });\n\t\t\tif (response.status === \"succeeded\") {\n\t\t\t\tupdated.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t} else if (response.error?.code === \"already_installed\") {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t} else {\n\t\t\t\tfailed.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t}\n\t\t}\n\t\tconst summary = [\n\t\t\t`updated ${updated.length}${updated.length > 0 ? ` (${updated.join(\", \")})` : \"\"}`,\n\t\t\t`already up to date ${current.length}${current.length > 0 ? ` (${current.join(\", \")})` : \"\"}`,\n\t\t\t`failed ${failed.length}${failed.length > 0 ? ` (${failed.join(\", \")})` : \"\"}`,\n\t\t].join(\"; \");\n\t\twrite(`plugin update --all [${scope}]: ${summary}`);\n\t\tif (failed.length > 0) process.exitCode = 1;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n"]}
@@ -87,6 +87,11 @@ export async function handlePluginEcosystemCommand(args, options = {}) {
87
87
  const cli = buildMarketCli({ agentDir, cwd, market, overrides: options });
88
88
  const response = await cli.execute({ argv: args.slice(1) });
89
89
  printResponse(response, write);
90
+ // CRM seat finding F3: installing a plugin does not select it — without
91
+ // this hint the next session reports the tool as unavailable.
92
+ if (response.status === "succeeded" && response.command === "install") {
93
+ write("note: this plugin is installed but not yet selected by a profile; to activate its tools run: agent-forge plugin selection set <profile> <pluginId>");
94
+ }
90
95
  return true;
91
96
  }
92
97
  finally {