@pellux/goodvibes-agent 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md CHANGED
@@ -17,12 +17,12 @@ Current package docs:
17
17
  Important baseline constraints:
18
18
 
19
19
  - Agent installs one executable: `goodvibes-agent`.
20
- - Current package version is recorded in `package.json` and `CHANGELOG.md`; the latest completed `1.0.x` release in this tree is `1.0.1`.
20
+ - Current package version is recorded in `package.json` and `CHANGELOG.md`; the latest completed `1.0.x` release in this tree is `1.0.3`.
21
21
  - Agent uses Bun `1.3.10` or newer and TypeScript-authored source.
22
22
  - Agent depends on `@pellux/goodvibes-sdk@0.33.35`.
23
23
  - Agent connects to a GoodVibes host owned outside this product.
24
24
  - Agent does not start, stop, restart, install, uninstall, or own the connected GoodVibes host.
25
- - User-facing Agent workspace actions, slash commands, command policy metadata, model tools, settings, local registries, and connected-host capability boundaries are model-visible through Agent-owned tools. Mutations remain explicit and confirmation-gated.
25
+ - User-facing Agent workspace actions, built-in panels, top-level CLI mirrors, fixed shortcuts, configurable keybindings, slash commands, command policy metadata, model tools, settings, local registries, and connected-host capability boundaries are model-visible through Agent-owned tools. Mutations remain explicit and confirmation-gated.
26
26
  - Agent Knowledge uses only `/api/goodvibes-agent/knowledge/*`; there is no default knowledge or non-Agent product fallback.
27
27
  - Agent supports isolated Agent homes with `GOODVIBES_AGENT_HOME=<path>` and named profile homes with `goodvibes-agent profiles create <name> --template <starter> --yes` plus `--agent-profile <name>`.
28
28
  - Agent supports connected-host URL overrides with `--runtime-url http://host:port` or `GOODVIBES_AGENT_RUNTIME_URL=http://host:port`; these only change the Agent connection target.
@@ -44,7 +44,7 @@ After setup has been applied once, the TUI opens directly into the Agent operato
44
44
 
45
45
  Press `/` inside the Agent workspace to search every workspace action by name, category, command, or detail. Use that finder before reaching for shell commands; CLI subcommands are scriptable mirrors of these TUI workflows.
46
46
 
47
- The model can inspect and use the same harness surface through Agent-owned tools. `agent_harness` exposes workspace action discovery, slash-command discovery, command policy metadata, command execution with confirmation, model tool discovery, settings inspection/mutation, and connected-host posture. Workspace action discovery can include editor field schemas with `includeParameters:true`, including starter-template defaults for profile creation and selected-routine defaults for routine schedule promotion when `recordId` is supplied. Selection-based local workspace actions accept a local `recordId`, so the model can use the same note promotion and local registry flows as the TUI. First-class model tools cover the main product workflows directly: Agent Knowledge, Agent Knowledge ingest, Agent-local memory/notes/personas/skills/routines, operator actions, notifications, channel sends, reminders, generated media, and work plans.
47
+ The model can inspect and use the same harness surface through Agent-owned tools. `agent_harness` exposes workspace action discovery, built-in panel discovery/routing, top-level CLI mirror discovery, fixed shortcut and configurable keybinding discovery, keybinding mutation with confirmation, slash-command discovery, command policy metadata, command execution with confirmation, model tool discovery, settings inspection/mutation, and connected-host posture. CLI mirror modes are read-only catalog/parser inspection and point the model to the matching in-process tool, workspace action, setting mode, or slash-command mirror. Panel modes expose catalog/open state and route visible panel/workspace changes through the current Agent shell bridge with confirmation. Shortcut modes expose the fixed runtime/editor shortcuts and the live keybindings table; confirmed keybinding edits write the same `keybindings.json` file the user edits and reload the runtime manager. Workspace action discovery can include editor field schemas with `includeParameters:true`, including starter-template defaults for profile creation and selected-routine defaults for routine schedule promotion when `recordId` is supplied. Selection-based local workspace actions accept a local `recordId`, so the model can use the same note promotion and local registry flows as the TUI. First-class model tools cover the main product workflows directly: Agent Knowledge, Agent Knowledge ingest, Agent-local memory/notes/personas/skills/routines, operator actions, notifications, channel sends, reminders, generated media, and work plans.
48
48
 
49
49
  Use the Artifacts area for concrete files and generated output: attach images to prompts, export conversations or saved sessions, ingest local source files and URL lists into Agent Knowledge, import bookmarks or browser history, inspect source records, and generate media artifacts from confirmed prompts.
50
50
 
@@ -122,7 +122,7 @@ Use `/channels` inside the TUI for channel readiness and exact confirmed sends.
122
122
 
123
123
  The main assistant conversation can perform narrow confirmed operator actions when the user explicitly asks for a specific target: approve/deny/cancel one approval, run/pause/resume one automation job, cancel/retry one automation run, or run one schedule. Those calls use only public connected-host routes, require confirmation, and do not create, edit, or delete automation definitions.
124
124
 
125
- When the main assistant conversation needs to change Agent settings or run a user-facing harness action, it should use `agent_harness` rather than generic SDK context/settings tools. Setting descriptors report writability, workspace visibility, and lock reasons; secret-backed settings store raw values through the secret manager; connected-host lifecycle settings stay read-only in Agent; and destructive local record deletion requires explicit confirmation.
125
+ When the main assistant conversation needs to change Agent settings, change Agent keybindings, or run a user-facing harness action, it should use `agent_harness` rather than generic SDK context/settings tools. Setting descriptors report writability, workspace visibility, and lock reasons; keybinding descriptors report fixed shortcuts, resolved bindings, defaults, custom state, and config path; secret-backed settings store raw values through the secret manager; connected-host lifecycle settings stay read-only in Agent; and destructive local record deletion requires explicit confirmation.
126
126
 
127
127
  ## Connected GoodVibes Host
128
128
 
@@ -43,16 +43,22 @@ Host-management and coding-first commands that would imply connected-host lifecy
43
43
 
44
44
  The main Agent model has an Agent-owned harness bridge rather than generic SDK settings/context control. Use these model tools as the supported parity layer:
45
45
 
46
- - `agent_harness`: inspect workspace categories/actions, inspect slash commands and command policy metadata, run concrete workspace or slash-command mirrors with confirmation, inspect model tools, inspect or change Agent settings, and inspect connected-host posture.
46
+ - `agent_harness`: inspect workspace categories/actions, inspect built-in panels, inspect top-level CLI mirrors, inspect fixed shortcuts and configurable keybindings, inspect slash commands and command policy metadata, run concrete workspace or slash-command mirrors with confirmation, inspect model tools, inspect or change Agent settings/keybindings, and inspect connected-host posture.
47
47
  - `agent_local_registry`: inspect and maintain Agent-local memory, notes, personas, skills, skill bundles, and routines. Deleting local records requires `confirm:true` and `explicitUserRequest`.
48
48
  - `agent_knowledge` and `agent_knowledge_ingest`: ask/search and ingest into the isolated Agent Knowledge segment.
49
49
  - `agent_operator_briefing` and `agent_operator_action`: inspect connected work/approval/automation posture, or run exact confirmed approval/automation actions.
50
50
  - `agent_work_plan`: keep the visible Agent-local work plan current from the conversation.
51
51
  - `agent_channel_send`, `agent_notify`, `agent_reminder_schedule`, and `agent_media_generate`: perform confirmed external delivery, notification, reminder, or media actions when the user explicitly asks.
52
52
 
53
- `agent_harness` discovery modes are read-only. `summary` reports the model access map; `commands` and `command` return command descriptions plus effect/confirmation/preferred-tool/boundary policy metadata; `workspace_actions` lists Agent workspace actions and can inline editor field schemas with `includeParameters:true`; `workspace_action` returns one action with its editor schema; `tools` can inline model tool JSON schemas with `includeParameters:true`; `settings` returns setting descriptors plus setting policy; and `connected_host` returns the connected-host route families, allowed capabilities, blocked capabilities, and first-class tool availability.
53
+ `agent_harness` discovery modes are read-only. `summary` reports the model access map; `panels` and `panel` return the built-in panel catalog, current open/focused state, and each panel's matching Agent workspace route; `cli_commands` and `cli_command` return top-level package CLI mirror metadata, parser output, blocked command tokens, and preferred in-process model routes; `shortcuts` returns fixed runtime/editor shortcuts plus configurable keybindings; `keybindings` and `keybinding` return the live resolved keybinding table, default bindings, custom state, and config path; `commands` and `command` return slash-command descriptions plus effect/confirmation/preferred-tool/boundary policy metadata; `workspace_actions` lists Agent workspace actions and can inline editor field schemas with `includeParameters:true`; `workspace_action` returns one action with its editor schema; `tools` can inline model tool JSON schemas with `includeParameters:true`; `settings` returns setting descriptors plus setting policy; and `connected_host` returns the connected-host route families, allowed capabilities, blocked capabilities, and first-class tool availability.
54
54
 
55
- Setting writes, setting resets, slash-command invocation, workspace-action invocation, local record deletion, channel sends, notifications, reminders, media generation, and connected-host operator mutations require explicit user request and confirmation. Secret-backed settings are stored through the secret manager, and connected-host lifecycle/listener settings remain read-only in Agent.
55
+ `set_keybinding` and `reset_keybinding` are confirmation-gated control modes. They write the same Agent `keybindings.json` file exposed by `/keybindings`, reload the runtime keybinding manager, and leave fixed runtime/editor shortcuts read-only.
56
+
57
+ `open_panel` is a confirmation-gated UI routing mode. It hands a visible panel/workspace route to the current Agent shell bridge and does not mutate connected-host lifecycle, listener posture, or external accounts.
58
+
59
+ CLI mirror modes are catalog and parser inspection only. When the user asks the model to operate from inside the main conversation, use the returned first-class model tool, workspace action, setting mode, or confirmed slash-command mirror instead of launching a hidden nested `goodvibes-agent` process.
60
+
61
+ Setting writes, setting resets, keybinding writes/resets, slash-command invocation, workspace-action invocation, local record deletion, channel sends, notifications, reminders, media generation, and connected-host operator mutations require explicit user request and confirmation. Secret-backed settings are stored through the secret manager, and connected-host lifecycle/listener settings remain read-only in Agent.
56
62
 
57
63
  Selection-based local workspace actions use the same bridge. `agent_harness` reports the required model tool for each local action; for actions that depend on the TUI selection, call `run_workspace_action` with the selected local `recordId`. Note promotion actions can prefill and create memory, personas, skills, routines, or isolated Agent Knowledge URL ingests through the matching first-class model tool. Profile creation schemas include the current runtime starter-template inventory, and routine schedule schemas prefill the selected routine when `recordId` or a `routineId` field matches a local routine.
58
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pellux/goodvibes-agent",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "description": "GoodVibes personal operator assistant TUI with a proactive Agent product brain, isolated Agent Knowledge, local profiles, routines, skills, personas, and explicit build delegation.",
6
6
  "type": "module",
package/src/cli/help.ts CHANGED
@@ -131,6 +131,15 @@ type CommandHelp = {
131
131
  readonly examples?: readonly string[];
132
132
  };
133
133
 
134
+ export interface GoodVibesCommandHelpDescriptor {
135
+ readonly command: string;
136
+ readonly aliases: readonly string[];
137
+ readonly summary: string;
138
+ readonly usage: readonly string[];
139
+ readonly subcommands: readonly string[];
140
+ readonly examples: readonly string[];
141
+ }
142
+
134
143
  const COMMAND_HELP: Record<string, CommandHelp> = {
135
144
  run: {
136
145
  usage: ['run [prompt] [--output text|json|stream-json]', 'exec [prompt]'],
@@ -416,6 +425,23 @@ export function hasGoodVibesCommandHelp(topic: string): boolean {
416
425
  return COMMAND_HELP[normalizeHelpTopic(topic)] !== undefined;
417
426
  }
418
427
 
428
+ export function describeGoodVibesCommandHelp(topic: string): GoodVibesCommandHelpDescriptor | null {
429
+ const normalized = normalizeHelpTopic(topic);
430
+ const help = COMMAND_HELP[normalized];
431
+ if (!help) return null;
432
+ return {
433
+ command: normalized,
434
+ aliases: Object.entries(HELP_ALIASES)
435
+ .filter(([, target]) => target === normalized)
436
+ .map(([alias]) => alias)
437
+ .sort(),
438
+ summary: help.summary,
439
+ usage: help.usage,
440
+ subcommands: help.subcommands ?? [],
441
+ examples: help.examples ?? [],
442
+ };
443
+ }
444
+
419
445
  export function renderGoodVibesCommandHelp(topic: string, binary = 'goodvibes-agent'): string {
420
446
  const normalized = normalizeHelpTopic(topic);
421
447
  const help = COMMAND_HELP[normalized];
@@ -0,0 +1,152 @@
1
+ import type { GoodVibesCliCommand } from '../cli/types.ts';
2
+ import { describeGoodVibesCommandHelp } from '../cli/help.ts';
3
+ import {
4
+ listBlockedGoodVibesCliCommandTokens,
5
+ listGoodVibesCliCommandTokens,
6
+ listGoodVibesCliCommands,
7
+ parseGoodVibesCli,
8
+ } from '../cli/parser.ts';
9
+ import { describeCliCommandPolicy } from './agent-harness-metadata.ts';
10
+
11
+ export interface AgentHarnessCliArgs {
12
+ readonly query?: unknown;
13
+ readonly command?: unknown;
14
+ readonly cliCommand?: unknown;
15
+ readonly commandName?: unknown;
16
+ readonly limit?: unknown;
17
+ }
18
+
19
+ function readString(value: unknown): string {
20
+ return typeof value === 'string' ? value.trim() : '';
21
+ }
22
+
23
+ function readLimit(value: unknown, fallback: number): number {
24
+ const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
25
+ if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return fallback;
26
+ return Math.max(1, Math.min(500, Math.trunc(parsed)));
27
+ }
28
+
29
+ function cliCommandTokens(command: GoodVibesCliCommand): readonly string[] {
30
+ if (command === 'unknown') return [];
31
+ if (command === 'tui') return ['(no command)'];
32
+ return listGoodVibesCliCommandTokens()
33
+ .filter((token) => parseGoodVibesCli([token]).command === command)
34
+ .sort();
35
+ }
36
+
37
+ function fallbackCliSummary(command: GoodVibesCliCommand): string {
38
+ if (command === 'tui') return 'Launch the interactive Agent TUI.';
39
+ if (command === 'help') return 'Print top-level or command-specific help.';
40
+ if (command === 'version') return 'Print the installed Agent package version.';
41
+ return 'Inspect the CLI help for this Agent package command.';
42
+ }
43
+
44
+ function describeCliCommand(command: GoodVibesCliCommand): Record<string, unknown> {
45
+ const help = describeGoodVibesCommandHelp(command);
46
+ const tokens = cliCommandTokens(command);
47
+ return {
48
+ name: command,
49
+ tokens,
50
+ invocation: command === 'tui' ? 'goodvibes-agent' : `goodvibes-agent ${tokens[0] ?? command}`,
51
+ helpTopic: help?.command ?? command,
52
+ summary: help?.summary ?? fallbackCliSummary(command),
53
+ usage: help?.usage ?? (command === 'tui' ? ['goodvibes-agent [OPTIONS]'] : [`goodvibes-agent ${command} [ARGS]`]),
54
+ aliases: help?.aliases ?? tokens.filter((token) => token !== command),
55
+ subcommands: help?.subcommands ?? [],
56
+ examples: help?.examples ?? [],
57
+ policy: describeCliCommandPolicy(command),
58
+ };
59
+ }
60
+
61
+ function cliCommandMatches(command: Record<string, unknown>, query: string): boolean {
62
+ if (!query) return true;
63
+ return [
64
+ command.name,
65
+ command.tokens,
66
+ command.summary,
67
+ command.usage,
68
+ command.aliases,
69
+ command.subcommands,
70
+ command.examples,
71
+ command.policy,
72
+ ].map((value) => JSON.stringify(value)).join('\n').toLowerCase().includes(query.toLowerCase());
73
+ }
74
+
75
+ export function totalHarnessCliCommands(): number {
76
+ return listGoodVibesCliCommands().filter((command) => command !== 'unknown').length;
77
+ }
78
+
79
+ export function blockedHarnessCliCommandTokens(): readonly string[] {
80
+ return listBlockedGoodVibesCliCommandTokens();
81
+ }
82
+
83
+ export function listHarnessCliCommands(args: AgentHarnessCliArgs): readonly Record<string, unknown>[] {
84
+ const query = readString(args.query);
85
+ const limit = readLimit(args.limit, 200);
86
+ return listGoodVibesCliCommands()
87
+ .filter((command) => command !== 'unknown')
88
+ .map(describeCliCommand)
89
+ .filter((command) => cliCommandMatches(command, query))
90
+ .sort((a, b) => String(a.name).localeCompare(String(b.name)))
91
+ .slice(0, limit);
92
+ }
93
+
94
+ function cliTokensFromArgs(args: AgentHarnessCliArgs): readonly string[] {
95
+ const raw = readString(args.cliCommand) || readString(args.command) || readString(args.commandName) || readString(args.query);
96
+ if (!raw) return [];
97
+ const tokens = raw.split(/\s+/).filter((token) => token.length > 0);
98
+ if (tokens[0] === 'goodvibes-agent' || tokens[0]?.endsWith('/goodvibes-agent')) return tokens.slice(1);
99
+ return tokens;
100
+ }
101
+
102
+ export function describeHarnessCliCommand(args: AgentHarnessCliArgs): Record<string, unknown> {
103
+ const tokens = cliTokensFromArgs(args);
104
+ if (tokens.length === 0) return describeCliCommand('tui');
105
+ const parsed = parseGoodVibesCli(tokens);
106
+ if (parsed.command === 'unknown') {
107
+ return {
108
+ supported: false,
109
+ token: parsed.rawCommand ?? tokens[0],
110
+ errors: parsed.errors,
111
+ blockedTokens: blockedHarnessCliCommandTokens(),
112
+ policy: describeCliCommandPolicy(parsed.rawCommand ?? tokens[0] ?? 'unknown'),
113
+ };
114
+ }
115
+ return {
116
+ ...describeCliCommand(parsed.command),
117
+ parsed: {
118
+ command: parsed.command,
119
+ rawCommand: parsed.rawCommand,
120
+ commandArgs: parsed.commandArgs,
121
+ positionals: parsed.positionals,
122
+ flags: {
123
+ provider: parsed.flags.provider,
124
+ model: parsed.flags.model,
125
+ agentProfile: parsed.flags.agentProfile,
126
+ runtimeUrl: parsed.flags.runtimeUrl,
127
+ workingDir: parsed.flags.workingDir,
128
+ help: parsed.flags.help,
129
+ version: parsed.flags.version,
130
+ print: parsed.flags.print,
131
+ outputFormat: parsed.flags.outputFormat,
132
+ configOverrides: parsed.flags.configOverrides.map((override) => {
133
+ const index = override.indexOf('=');
134
+ return index < 0 ? override : `${override.slice(0, index)}=<redacted>`;
135
+ }),
136
+ enableFeatures: parsed.flags.enableFeatures,
137
+ disableFeatures: parsed.flags.disableFeatures,
138
+ noAltScreen: parsed.flags.noAltScreen,
139
+ port: parsed.flags.port,
140
+ hostname: parsed.flags.hostname,
141
+ open: parsed.flags.open,
142
+ continueLast: parsed.flags.continueLast,
143
+ resume: parsed.flags.resume,
144
+ session: parsed.flags.session,
145
+ fork: parsed.flags.fork,
146
+ rawOutput: parsed.flags.rawOutput,
147
+ acceptRawOutputRisk: parsed.flags.acceptRawOutputRisk,
148
+ },
149
+ errors: parsed.errors,
150
+ },
151
+ };
152
+ }
@@ -0,0 +1,262 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
+ import type { CommandContext } from '../input/command-registry.ts';
4
+ import {
5
+ ACTION_DESCRIPTIONS,
6
+ DEFAULT_KEYBINDINGS,
7
+ type KeyAction,
8
+ type KeyCombo,
9
+ type KeybindingsManager,
10
+ } from '../input/keybindings.ts';
11
+
12
+ const FIXED_SHORTCUTS: readonly Record<string, string>[] = [
13
+ { key: 'Enter', description: 'Send prompt' },
14
+ { key: 'Shift+Enter / Ctrl+J', description: 'Insert newline' },
15
+ { key: 'Up / Down', description: 'Navigate input history, lists, and scrollable overlays' },
16
+ { key: 'Tab', description: 'Autocomplete slash command or file mention' },
17
+ { key: 'Esc', description: 'Close overlays, pickers, and transient input modes' },
18
+ { key: '? / F1', description: 'Toggle help overlay' },
19
+ { key: 'F2 / /shortcuts', description: 'Open keyboard shortcut reference' },
20
+ { key: '/keybindings', description: 'List configurable keybindings and config path' },
21
+ ];
22
+
23
+ interface HarnessKeybindingArgs {
24
+ readonly query?: unknown;
25
+ readonly actionId?: unknown;
26
+ readonly key?: unknown;
27
+ readonly fields?: unknown;
28
+ readonly combo?: unknown;
29
+ readonly combos?: unknown;
30
+ readonly value?: unknown;
31
+ readonly limit?: unknown;
32
+ }
33
+
34
+ type KeybindingsOverrideFile = Record<string, unknown>;
35
+
36
+ function readString(value: unknown): string {
37
+ return typeof value === 'string' ? value.trim() : '';
38
+ }
39
+
40
+ function readLimit(value: unknown, fallback: number): number {
41
+ const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
42
+ if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return fallback;
43
+ return Math.max(1, Math.min(500, Math.trunc(parsed)));
44
+ }
45
+
46
+ function readFieldMap(value: unknown): Readonly<Record<string, string>> {
47
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) return {};
48
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, typeof entry === 'string' ? entry : String(entry)]));
49
+ }
50
+
51
+ function requireKeybindingsManager(context: CommandContext): KeybindingsManager {
52
+ const manager = context.workspace.keybindingsManager;
53
+ if (!manager) throw new Error('workspace.keybindingsManager is unavailable in this Agent runtime');
54
+ return manager;
55
+ }
56
+
57
+ function isKeyAction(action: string): action is KeyAction {
58
+ return Object.hasOwn(ACTION_DESCRIPTIONS, action);
59
+ }
60
+
61
+ function actionFromArgs(args: HarnessKeybindingArgs): KeyAction | null {
62
+ const action = readString(args.actionId || args.key || args.query);
63
+ return action && isKeyAction(action) ? action : null;
64
+ }
65
+
66
+ function readBoolean(value: unknown): boolean | undefined {
67
+ if (typeof value === 'boolean') return value;
68
+ if (typeof value !== 'string') return undefined;
69
+ const normalized = value.trim().toLowerCase();
70
+ if (['true', 'yes', 'y', '1', 'on'].includes(normalized)) return true;
71
+ if (['false', 'no', 'n', '0', 'off'].includes(normalized)) return false;
72
+ return undefined;
73
+ }
74
+
75
+ function normalizeCombo(value: unknown): KeyCombo | null {
76
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) return null;
77
+ const raw = value as Record<string, unknown>;
78
+ const key = readString(raw.key);
79
+ if (!key) return null;
80
+ const combo: KeyCombo = { key };
81
+ const ctrl = readBoolean(raw.ctrl);
82
+ const shift = readBoolean(raw.shift);
83
+ const alt = readBoolean(raw.alt);
84
+ if (ctrl !== undefined) combo.ctrl = ctrl;
85
+ if (shift !== undefined) combo.shift = shift;
86
+ if (alt !== undefined) combo.alt = alt;
87
+ return combo;
88
+ }
89
+
90
+ function parseComboLabel(value: string): KeyCombo | null {
91
+ const parts = value.split('+').map((part) => part.trim()).filter(Boolean);
92
+ if (parts.length === 0) return null;
93
+ const key = parts.at(-1);
94
+ if (!key) return null;
95
+ const combo: KeyCombo = { key: key.length === 1 ? key.toLowerCase() : key.toLowerCase() };
96
+ for (const part of parts.slice(0, -1)) {
97
+ const normalized = part.toLowerCase();
98
+ if (normalized === 'ctrl' || normalized === 'control') combo.ctrl = true;
99
+ else if (normalized === 'shift') combo.shift = true;
100
+ else if (normalized === 'alt' || normalized === 'option') combo.alt = true;
101
+ else return null;
102
+ }
103
+ return combo;
104
+ }
105
+
106
+ function combosFromArgs(args: HarnessKeybindingArgs): KeyCombo[] {
107
+ if (Array.isArray(args.combos)) {
108
+ const combos = args.combos.map(normalizeCombo);
109
+ if (combos.every((combo): combo is KeyCombo => combo !== null)) return combos;
110
+ throw new Error('set_keybinding combos must be objects with key and optional boolean ctrl/shift/alt fields.');
111
+ }
112
+ const combo = normalizeCombo(args.combo);
113
+ if (combo) return [combo];
114
+ const fields = readFieldMap(args.fields);
115
+ const fieldCombo = normalizeCombo(fields);
116
+ if (fieldCombo) return [fieldCombo];
117
+ const labelCombo = parseComboLabel(readString(args.value));
118
+ if (labelCombo) return [labelCombo];
119
+ throw new Error('set_keybinding requires combo, combos, fields.key, or a value such as "Ctrl+G".');
120
+ }
121
+
122
+ function comboFingerprint(combo: KeyCombo): string {
123
+ return `${combo.key}:${combo.ctrl ? 1 : 0}:${combo.shift ? 1 : 0}:${combo.alt ? 1 : 0}`;
124
+ }
125
+
126
+ function combosEqual(left: readonly KeyCombo[], right: readonly KeyCombo[]): boolean {
127
+ if (left.length !== right.length) return false;
128
+ return left.every((combo, index) => comboFingerprint(combo) === comboFingerprint(right[index]));
129
+ }
130
+
131
+ function describeCombo(manager: KeybindingsManager, combo: KeyCombo): Record<string, unknown> {
132
+ return {
133
+ key: combo.key,
134
+ ctrl: combo.ctrl === true,
135
+ shift: combo.shift === true,
136
+ alt: combo.alt === true,
137
+ label: manager.formatCombo(combo),
138
+ };
139
+ }
140
+
141
+ function bindingMatches(entry: { readonly action: KeyAction; readonly description: string; readonly combos: KeyCombo[] }, query: string): boolean {
142
+ if (!query) return true;
143
+ const haystack = [
144
+ entry.action,
145
+ entry.description,
146
+ ...entry.combos.map((combo) => comboFingerprint(combo)),
147
+ ].join('\n').toLowerCase();
148
+ return haystack.includes(query.toLowerCase());
149
+ }
150
+
151
+ function describeBinding(manager: KeybindingsManager, action: KeyAction, combos: KeyCombo[]): Record<string, unknown> {
152
+ const defaults = DEFAULT_KEYBINDINGS[action];
153
+ const customized = !combosEqual(combos, defaults);
154
+ return {
155
+ action,
156
+ description: ACTION_DESCRIPTIONS[action],
157
+ bindings: combos.map((combo) => describeCombo(manager, combo)),
158
+ labels: combos.map((combo) => manager.formatCombo(combo)),
159
+ defaultBindings: defaults.map((combo) => describeCombo(manager, combo)),
160
+ customized,
161
+ source: customized ? 'custom' : 'default',
162
+ };
163
+ }
164
+
165
+ function readOverrideFile(configPath: string): KeybindingsOverrideFile {
166
+ if (!existsSync(configPath)) return {};
167
+ const parsed = JSON.parse(readFileSync(configPath, 'utf-8')) as unknown;
168
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
169
+ throw new Error(`Keybindings config ${configPath} must contain a JSON object.`);
170
+ }
171
+ return parsed as KeybindingsOverrideFile;
172
+ }
173
+
174
+ function writeOverrideFile(configPath: string, overrides: KeybindingsOverrideFile): void {
175
+ mkdirSync(dirname(configPath), { recursive: true });
176
+ writeFileSync(configPath, `${JSON.stringify(overrides, null, 2)}\n`, 'utf-8');
177
+ }
178
+
179
+ export function totalHarnessKeybindings(context: CommandContext): number {
180
+ return context.workspace.keybindingsManager?.getAll().length ?? 0;
181
+ }
182
+
183
+ export function totalHarnessShortcuts(context: CommandContext): number {
184
+ return totalHarnessKeybindings(context) + FIXED_SHORTCUTS.length;
185
+ }
186
+
187
+ export function listHarnessShortcuts(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
188
+ const keybindings = listHarnessKeybindings(context, args);
189
+ const query = readString(args.query).toLowerCase();
190
+ const fixed = FIXED_SHORTCUTS
191
+ .filter((shortcut) => !query || `${shortcut.key}\n${shortcut.description}`.toLowerCase().includes(query))
192
+ .slice(0, readLimit(args.limit, 200))
193
+ .map((shortcut) => ({ ...shortcut, source: 'fixed', userEditable: false }));
194
+ return {
195
+ configPath: keybindings.configPath,
196
+ fixedShortcuts: fixed,
197
+ configurableKeybindings: keybindings.keybindings,
198
+ returned: fixed.length + Number(keybindings.returned ?? 0),
199
+ total: totalHarnessShortcuts(context),
200
+ policy: 'Fixed shortcuts are runtime/editor controls. Configurable keybindings can be changed with set_keybinding/reset_keybinding.',
201
+ };
202
+ }
203
+
204
+ export function listHarnessKeybindings(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
205
+ const manager = requireKeybindingsManager(context);
206
+ const query = readString(args.query);
207
+ const entries = manager.getAll()
208
+ .filter((entry) => bindingMatches(entry, query))
209
+ .slice(0, readLimit(args.limit, 200))
210
+ .map((entry) => describeBinding(manager, entry.action, entry.combos));
211
+ return {
212
+ configPath: manager.getConfigPath(),
213
+ keybindings: entries,
214
+ returned: entries.length,
215
+ total: manager.getAll().length,
216
+ policy: 'Reads the live resolved keybindings. set_keybinding/reset_keybinding write the same keybindings.json file the user can edit and reload the runtime manager.',
217
+ };
218
+ }
219
+
220
+ export function describeHarnessKeybinding(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> | null {
221
+ const manager = requireKeybindingsManager(context);
222
+ const action = actionFromArgs(args);
223
+ if (!action) return null;
224
+ const entry = manager.getAll().find((candidate) => candidate.action === action);
225
+ return entry ? {
226
+ configPath: manager.getConfigPath(),
227
+ ...describeBinding(manager, entry.action, entry.combos),
228
+ } : null;
229
+ }
230
+
231
+ export function setHarnessKeybinding(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
232
+ const manager = requireKeybindingsManager(context);
233
+ const action = actionFromArgs(args);
234
+ if (!action) throw new Error('set_keybinding requires a valid keybinding action id.');
235
+ const combos = combosFromArgs(args);
236
+ const configPath = manager.getConfigPath();
237
+ const overrides = readOverrideFile(configPath);
238
+ overrides[action] = combos.length === 1 ? combos[0] : combos;
239
+ writeOverrideFile(configPath, overrides);
240
+ manager.loadFromDisk();
241
+ return {
242
+ status: 'updated',
243
+ configPath,
244
+ keybinding: describeHarnessKeybinding(context, { actionId: action }),
245
+ };
246
+ }
247
+
248
+ export function resetHarnessKeybinding(context: CommandContext, args: HarnessKeybindingArgs): Record<string, unknown> {
249
+ const manager = requireKeybindingsManager(context);
250
+ const action = actionFromArgs(args);
251
+ if (!action) throw new Error('reset_keybinding requires a valid keybinding action id.');
252
+ const configPath = manager.getConfigPath();
253
+ const overrides = readOverrideFile(configPath);
254
+ delete overrides[action];
255
+ writeOverrideFile(configPath, overrides);
256
+ manager.loadFromDisk();
257
+ return {
258
+ status: 'reset',
259
+ configPath,
260
+ keybinding: describeHarnessKeybinding(context, { actionId: action }),
261
+ };
262
+ }
@@ -1,4 +1,6 @@
1
1
  import type { ToolRegistry } from '@pellux/goodvibes-sdk/platform/tools';
2
+ import type { CommandContext } from '../input/command-registry.ts';
3
+ import { resolveAgentConnectedHostConnection } from '../agent/routine-schedule-promotion.ts';
2
4
 
3
5
  export interface CommandExecutionPolicy {
4
6
  readonly effect: 'read-only' | 'local-state' | 'connected-host-state' | 'external-network' | 'ui-navigation' | 'session-lifecycle' | 'delegated-work' | 'mixed' | 'unknown';
@@ -132,6 +134,96 @@ export function describeCommandPolicy(commandName: string): CommandExecutionPoli
132
134
  };
133
135
  }
134
136
 
137
+ export function describeCliCommandPolicy(commandName: string): CommandExecutionPolicy {
138
+ const root = commandName.trim().toLowerCase();
139
+ const confirmation = 'agent_harness CLI command modes are discovery-only. Use first-class model tools, workspace actions, slash-command mirrors, or an explicit external shell request to execute equivalent CLI workflows.';
140
+ if ([
141
+ 'app',
142
+ 'bridge',
143
+ 'control-plane',
144
+ 'controlplane',
145
+ 'cp',
146
+ 'daemon',
147
+ 'http-listener',
148
+ 'launch',
149
+ 'listener',
150
+ 'remote',
151
+ 'serve',
152
+ 'server',
153
+ 'service',
154
+ 'services',
155
+ 'start',
156
+ 'surface',
157
+ 'surfaces',
158
+ 'web',
159
+ 'webhook',
160
+ ].includes(root)) {
161
+ return {
162
+ effect: 'unknown',
163
+ confirmation,
164
+ boundary: 'Blocked package CLI token. Agent can launch its own TUI and use public connected-host routes, but it does not manage connected-host lifecycle, listeners, servers, bridges, remotes, web surfaces, or webhook listeners.',
165
+ };
166
+ }
167
+ if (root === 'tui' || root === 'onboarding' || root === 'help' || root === 'version' || root === 'completion') {
168
+ return {
169
+ effect: root === 'tui' || root === 'onboarding' ? 'ui-navigation' : 'read-only',
170
+ confirmation,
171
+ preferredModelTool: root === 'onboarding' || root === 'tui' ? 'agent_harness workspace/workspace_actions' : 'agent_harness cli_commands/cli_command',
172
+ boundary: 'Top-level CLI launch, setup, help, version, and completion commands are package entrypoint surfaces; use in-process workspace and slash-command bridges from the model when operating inside the TUI.',
173
+ };
174
+ }
175
+ if (root === 'run') {
176
+ return {
177
+ effect: 'mixed',
178
+ confirmation,
179
+ boundary: 'The CLI run command starts a non-interactive Agent turn from a process entrypoint. Do not create hidden nested turns from agent_harness; answer the user directly in the current conversation.',
180
+ };
181
+ }
182
+ if (root === 'status' || root === 'doctor' || root === 'auth' || root === 'compat' || root === 'models' || root === 'providers' || root === 'tasks') {
183
+ return {
184
+ effect: 'read-only',
185
+ confirmation,
186
+ preferredModelTool: root === 'tasks' ? 'agent_operator_briefing' : 'agent_harness connected_host/settings/tools',
187
+ boundary: 'Diagnostics and posture commands are readable from Agent-owned settings, provider, model, and connected-host capability surfaces without taking connected-host lifecycle ownership.',
188
+ };
189
+ }
190
+ if (root === 'profiles' || root === 'personas' || root === 'skills' || root === 'memory' || root === 'routines' || root === 'sessions' || root === 'bundle') {
191
+ return {
192
+ effect: 'local-state',
193
+ confirmation,
194
+ preferredModelTool: root === 'profiles' ? 'agent_harness workspace_actions/run_workspace_action' : 'agent_local_registry',
195
+ boundary: 'Local library/profile/session/bundle CLI commands operate on Agent-local data. Mutations require explicit user intent and should use first-class Agent-local tools where available.',
196
+ };
197
+ }
198
+ if (root === 'knowledge' || root === 'ask' || root === 'search') {
199
+ return {
200
+ effect: 'mixed',
201
+ confirmation,
202
+ preferredModelTool: root === 'knowledge' ? 'agent_knowledge or agent_knowledge_ingest' : 'agent_knowledge',
203
+ boundary: 'Agent Knowledge CLI commands must stay on isolated Agent Knowledge routes and never fall back to default or non-Agent knowledge spaces.',
204
+ };
205
+ }
206
+ if (root === 'delegate') {
207
+ return {
208
+ effect: 'delegated-work',
209
+ confirmation,
210
+ boundary: 'Delegation is explicit user-directed work only; no hidden background review or separate Agent job should be created implicitly.',
211
+ };
212
+ }
213
+ if (root === 'subscription' || root === 'secrets' || root === 'pair') {
214
+ return {
215
+ effect: root === 'pair' ? 'external-network' : 'mixed',
216
+ confirmation,
217
+ boundary: 'Provider subscription, secret, and pairing flows can expose credentials or external account state. Use only explicit user-directed flows and prefer secret refs over raw values.',
218
+ };
219
+ }
220
+ return {
221
+ effect: 'unknown',
222
+ confirmation,
223
+ boundary: 'Inspect the CLI help, parser result, and preferred model routes before using an equivalent command path.',
224
+ };
225
+ }
226
+
135
227
  function toolIsAvailable(toolRegistry: ToolRegistry, toolName: string): boolean {
136
228
  return toolRegistry.getToolDefinitions().some((tool) => tool.name === toolName);
137
229
  }
@@ -264,6 +356,22 @@ export function connectedHostRouteFamilies(): readonly Record<string, unknown>[]
264
356
  ];
265
357
  }
266
358
 
359
+ export function connectedHostSummary(context: CommandContext, toolRegistry: ToolRegistry): Record<string, unknown> {
360
+ const shellPaths = context.workspace.shellPaths;
361
+ const homeDirectory = shellPaths?.homeDirectory ?? context.platform.configManager.getHomeDirectory() ?? '';
362
+ const connection = resolveAgentConnectedHostConnection(context.platform.configManager, homeDirectory);
363
+ return {
364
+ baseUrl: connection.baseUrl,
365
+ operatorToken: connection.token ? 'configured' : 'missing',
366
+ tokenPath: connection.tokenPath,
367
+ ownership: 'external-connected-host',
368
+ lifecycle: 'GoodVibes Agent can use public connected-host operator routes, but does not start, stop, restart, install, expose, or mutate the host listener.',
369
+ routeFamilies: connectedHostRouteFamilies(),
370
+ capabilities: connectedHostCapabilityMap(toolRegistry),
371
+ blockedCapabilities: blockedConnectedHostCapabilities(),
372
+ };
373
+ }
374
+
267
375
  export function blockedConnectedHostCapabilities(): readonly Record<string, unknown>[] {
268
376
  return [
269
377
  {