feat(coding-agent): added advisor CLI flag for runtime advisor enabling
- Added a new `--advisor` flag to argument parsing and launch flag definitions. - Applied the parsed `advisor` flag as a runtime-only override of `advisor.enabled` during startup. - Updated advisor-related docs and added parseArgs tests for `--advisor` behavior and position handling.
This commit is contained in:
+2
-2
@@ -88,7 +88,7 @@ built-in defaults <- global config <- project config <- CLI overlays <-
|
||||
|
||||
From highest to lowest:
|
||||
|
||||
1. **Runtime overrides** — dedicated CLI flags and feature env vars applied in memory for the current process: `--model`, `--smol`, `--slow`, `--plan`, `--approval-mode`, `--auto-approve`/`--yolo`, `--hide-thinking`, `--no-pty`, `--api-key`, and protocol-mode defaults. Never persisted.
|
||||
1. **Runtime overrides** — dedicated CLI flags and feature env vars applied in memory for the current process: `--model`, `--smol`, `--slow`, `--plan`, `--approval-mode`, `--auto-approve`/`--yolo`, `--hide-thinking`, `--advisor`, `--no-pty`, `--api-key`, and protocol-mode defaults. Never persisted.
|
||||
2. **CLI config overlays** — each `--config <file>`; later overlay files override earlier ones.
|
||||
3. **Project settings** — `<cwd>/.omp/settings.json` then `<cwd>/.omp/config.yml` (and contributions from other discovery providers at project level).
|
||||
4. **Global settings** — `~/.omp/agent/config.yml`.
|
||||
@@ -312,7 +312,7 @@ See [Models](./models.md) for the `models.yml` schema and custom-provider defini
|
||||
|
||||
### Advisor
|
||||
|
||||
The advisor is a second model that reviews each completed turn and can inject advice into the primary session. Assign a model with `modelRoles.advisor`, then enable it with `advisor.enabled` or `/advisor on`. There is no `--advisor` flag.
|
||||
The advisor is a second model that reviews each completed turn and can inject advice into the primary session. Assign a model with `modelRoles.advisor`, then enable it with `advisor.enabled`, `/advisor on`, or by launching with the `--advisor` flag.
|
||||
|
||||
See [Advisor and WATCHDOG.md](./advisor-watchdog.md) for runtime behavior, `WATCHDOG.md` discovery, and bounded catch-up semantics.
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface Args {
|
||||
appendSystemPrompt?: string;
|
||||
thinking?: Effort;
|
||||
hideThinking?: boolean;
|
||||
advisor?: boolean;
|
||||
continue?: boolean;
|
||||
resume?: string | true;
|
||||
help?: boolean;
|
||||
@@ -194,6 +195,8 @@ export function parseArgs(inputArgs: string[], extensionFlags?: Map<string, { ty
|
||||
result.noPty = true;
|
||||
} else if (arg === "--hide-thinking") {
|
||||
result.hideThinking = true;
|
||||
} else if (arg === "--advisor") {
|
||||
result.advisor = true;
|
||||
} else if (arg === "--print" || arg === "-p") {
|
||||
result.print = true;
|
||||
} else if (arg === "--no-extensions") {
|
||||
|
||||
@@ -260,6 +260,7 @@ export const VALUELESS_FLAGS: ReadonlySet<string> = new Set([
|
||||
"--no-lsp",
|
||||
"--no-pty",
|
||||
"--hide-thinking",
|
||||
"--advisor",
|
||||
"--print",
|
||||
"--no-extensions",
|
||||
"--no-skills",
|
||||
|
||||
@@ -106,6 +106,9 @@ export default class Index extends Command {
|
||||
"hide-thinking": Flags.boolean({
|
||||
description: "Hide thinking blocks in TUI output (display only, does not disable model thinking)",
|
||||
}),
|
||||
advisor: Flags.boolean({
|
||||
description: "Enable the advisor runtime (passively reviews each turn and injects notes)",
|
||||
}),
|
||||
hook: Flags.string({
|
||||
description: "Load a hook/extension file (can be used multiple times)",
|
||||
multiple: true,
|
||||
|
||||
@@ -1041,6 +1041,10 @@ export async function runRootCommand(
|
||||
if (parsedArgs.hideThinking) {
|
||||
settingsInstance.override("hideThinkingBlock", true);
|
||||
}
|
||||
// Apply --advisor CLI flag (ephemeral, not persisted)
|
||||
if (parsedArgs.advisor) {
|
||||
settingsInstance.override("advisor.enabled", true);
|
||||
}
|
||||
|
||||
await logger.time(
|
||||
"initTheme:final",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { parseArgs } from "@oh-my-pi/pi-coding-agent/cli/args";
|
||||
|
||||
describe("parseArgs — --advisor flag", () => {
|
||||
it("parses --advisor as a boolean flag", () => {
|
||||
const result = parseArgs(["--advisor"]);
|
||||
expect(result.advisor).toBe(true);
|
||||
});
|
||||
|
||||
it("defaults advisor to undefined when flag is not provided", () => {
|
||||
const result = parseArgs([]);
|
||||
expect(result.advisor).toBeUndefined();
|
||||
});
|
||||
|
||||
it("parses --advisor with other flags", () => {
|
||||
const result = parseArgs(["--advisor", "--model", "opus", "hello"]);
|
||||
expect(result.advisor).toBe(true);
|
||||
expect(result.model).toBe("opus");
|
||||
expect(result.messages).toContain("hello");
|
||||
});
|
||||
|
||||
it("parses --advisor in any position", () => {
|
||||
const result1 = parseArgs(["--advisor", "prompt"]);
|
||||
const result2 = parseArgs(["prompt", "--advisor"]);
|
||||
const result3 = parseArgs(["--model", "opus", "--advisor", "prompt"]);
|
||||
|
||||
expect(result1.advisor).toBe(true);
|
||||
expect(result2.advisor).toBe(true);
|
||||
expect(result3.advisor).toBe(true);
|
||||
});
|
||||
|
||||
it("does not consume a value after --advisor", () => {
|
||||
const result = parseArgs(["--advisor", "--model", "opus"]);
|
||||
expect(result.advisor).toBe(true);
|
||||
expect(result.model).toBe("opus");
|
||||
expect(result.messages).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user