mixdog 0.9.169 → 0.9.171

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.
Files changed (168) hide show
  1. package/README.md +64 -17
  2. package/package.json +1 -1
  3. package/src/agents/front-worker/AGENT.md +0 -2
  4. package/src/agents/heavy-worker/AGENT.md +1 -6
  5. package/src/agents/maintainer/AGENT.md +2 -0
  6. package/src/agents/worker/AGENT.md +0 -5
  7. package/src/agents/writer/AGENT.md +1 -1
  8. package/src/defaults/skills/code-tidy/SKILL.md +122 -58
  9. package/src/defaults/skills/code-tidy/references/agent-cleanup.md +149 -0
  10. package/src/defaults/skills/code-tidy/references/dead-code.md +71 -0
  11. package/src/defaults/skills/computer-use/SKILL.md +12 -6
  12. package/src/defaults/skills/setup/SKILL.md +31 -11
  13. package/src/defaults/skills/setup/references/actions.md +67 -9
  14. package/src/defaults/skills/setup/references/surfaces.md +21 -14
  15. package/src/headless-exec.mjs +17 -1
  16. package/src/lib/rules-builder.cjs +115 -24
  17. package/src/output-styles/common.md +1 -1
  18. package/src/output-styles/detailed.md +1 -1
  19. package/src/output-styles/extreme-minimal.md +1 -1
  20. package/src/output-styles/minimal.md +1 -1
  21. package/src/output-styles/simple.md +1 -1
  22. package/src/rules/agent/40-cycle1-agent.md +1 -1
  23. package/src/rules/agent/AGENT.md +13 -0
  24. package/src/rules/lead/LEAD.md +30 -0
  25. package/src/rules/routes/common.md +4 -0
  26. package/src/rules/shared/05-parallel-calls.md +15 -0
  27. package/src/rules/shared/10-tool-workflow.md +13 -32
  28. package/src/rules/shared/15-skills.md +2 -3
  29. package/src/rules/shared/20-research.md +2 -4
  30. package/src/rules/shared/30-exploration.md +6 -24
  31. package/src/rules/shared/40-editing.md +1 -1
  32. package/src/rules/shared/45-destructive.md +9 -0
  33. package/src/rules/shared/50-execution.md +0 -8
  34. package/src/rules/shared/70-delivery.md +1 -1
  35. package/src/rules/shared/80-memory.md +3 -5
  36. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +12 -14
  37. package/src/runtime/agent/orchestrator/config.mjs +29 -6
  38. package/src/runtime/agent/orchestrator/context/role-instructions.mjs +1 -1
  39. package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +1 -1
  40. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +15 -15
  41. package/src/runtime/agent/orchestrator/providers/anthropic-turn-reminder.mjs +96 -0
  42. package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +22 -1
  43. package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +14 -1
  44. package/src/runtime/agent/orchestrator/providers/cursor-wire-normalization.mjs +1 -0
  45. package/src/runtime/agent/orchestrator/providers/cursor-wire-protobuf.mjs +7 -1
  46. package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +53 -15
  47. package/src/runtime/agent/orchestrator/providers/cursor.mjs +11 -2
  48. package/src/runtime/agent/orchestrator/providers/gemini.mjs +4 -9
  49. package/src/runtime/agent/orchestrator/providers/lib/grok-tool-schema.mjs +33 -7
  50. package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +8 -5
  51. package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +2 -1
  52. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +10 -0
  53. package/src/runtime/agent/orchestrator/session/batching-nudge.mjs +461 -0
  54. package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.mjs +25 -13
  55. package/src/runtime/agent/orchestrator/session/cache/read-cache.mjs +19 -25
  56. package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +10 -15
  57. package/src/runtime/agent/orchestrator/session/cache/text-cache-budget.mjs +26 -0
  58. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +20 -25
  59. package/src/runtime/agent/orchestrator/session/context-utils.mjs +3 -3
  60. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +35 -13
  61. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +8 -3
  62. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +1 -1
  63. package/src/runtime/agent/orchestrator/session/loop/usage.mjs +14 -0
  64. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +15 -6
  65. package/src/runtime/agent/orchestrator/session/manager/prefetch-bridge.mjs +4 -2
  66. package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +62 -0
  67. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +28 -15
  68. package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +35 -1
  69. package/src/runtime/agent/orchestrator/session/runtime-user-context.mjs +43 -0
  70. package/src/runtime/agent/orchestrator/session/store/fs-probe.mjs +9 -1
  71. package/src/runtime/agent/orchestrator/session/store/load-cache.mjs +34 -10
  72. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +39 -5
  73. package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +28 -11
  74. package/src/runtime/agent/orchestrator/session/store.mjs +23 -32
  75. package/src/runtime/agent/orchestrator/session/tool-batch.mjs +25 -0
  76. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +13 -13
  77. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +1 -1
  78. package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +5 -2
  79. package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +1 -1
  80. package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +6 -2
  81. package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +2 -2
  82. package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +1 -1
  83. package/src/runtime/agent/orchestrator/tools/tool-batch-trace.mjs +14 -8
  84. package/src/runtime/computer-bridge/action-schema.mjs +2 -2
  85. package/src/runtime/computer-bridge/core-actions.mjs +1 -0
  86. package/src/runtime/computer-bridge/error-recovery.mjs +1 -1
  87. package/src/runtime/computer-bridge/pending-continuation.mjs +25 -10
  88. package/src/runtime/computer-bridge/tool-defs.mjs +1 -1
  89. package/src/runtime/memory/lib/embedding-model-config.mjs +5 -1
  90. package/src/runtime/memory/lib/query-handlers.mjs +17 -3
  91. package/src/runtime/memory/lib/recall-format.mjs +34 -11
  92. package/src/runtime/memory/lib/session-ingest.mjs +1 -1
  93. package/src/runtime/shared/config-patch.mjs +49 -0
  94. package/src/runtime/shared/json-snapshot.mjs +32 -0
  95. package/src/runtime/shared/llm/usage-ledger.mjs +11 -0
  96. package/src/runtime/shared/pristine-execution-contract.json +4 -0
  97. package/src/runtime/shared/pristine-execution.mjs +26 -5
  98. package/src/runtime/shared/provider-accounts.mjs +9 -7
  99. package/src/runtime/shared/schema-value-error.mjs +5 -0
  100. package/src/runtime/shared/tool-surface.mjs +1 -1
  101. package/src/runtime/tidy/rules/__tests__/no-any-cast.yml +12 -0
  102. package/src/runtime/tidy/rules/__tests__/no-boolean-literal-compare.yml +24 -0
  103. package/src/runtime/tidy/rules/__tests__/no-debug-statement.yml +26 -0
  104. package/src/runtime/tidy/rules/__tests__/no-nested-ternary.yml +15 -0
  105. package/src/runtime/tidy/rules/c/no-nested-ternary.yml +10 -0
  106. package/src/runtime/tidy/rules/cpp/no-nested-ternary.yml +10 -0
  107. package/src/runtime/tidy/rules/csharp/no-nested-ternary.yml +10 -0
  108. package/src/runtime/tidy/rules/java/no-nested-ternary.yml +10 -0
  109. package/src/runtime/tidy/rules/javascript/no-boolean-literal-compare.yml +23 -0
  110. package/src/runtime/tidy/rules/javascript/no-debug-statement.yml +10 -0
  111. package/src/runtime/tidy/rules/javascript/no-nested-ternary.yml +10 -0
  112. package/src/runtime/tidy/rules/python/no-boolean-literal-compare.yml +15 -0
  113. package/src/runtime/tidy/rules/python/no-debug-statement.yml +10 -0
  114. package/src/runtime/tidy/rules/python/no-nested-ternary.yml +10 -0
  115. package/src/runtime/tidy/rules/rust/no-debug-statement.yml +7 -0
  116. package/src/runtime/tidy/rules/tsx/no-any-cast.yml +7 -0
  117. package/src/runtime/tidy/rules/tsx/no-boolean-literal-compare.yml +23 -0
  118. package/src/runtime/tidy/rules/tsx/no-debug-statement.yml +10 -0
  119. package/src/runtime/tidy/rules/tsx/no-nested-ternary.yml +10 -0
  120. package/src/runtime/tidy/rules/typescript/no-any-cast.yml +9 -0
  121. package/src/runtime/tidy/rules/typescript/no-boolean-literal-compare.yml +23 -0
  122. package/src/runtime/tidy/rules/typescript/no-debug-statement.yml +10 -0
  123. package/src/runtime/tidy/rules/typescript/no-nested-ternary.yml +10 -0
  124. package/src/session-runtime/config-lifecycle.mjs +36 -31
  125. package/src/session-runtime/context-inspection.mjs +311 -0
  126. package/src/session-runtime/context-status.mjs +34 -5
  127. package/src/session-runtime/internal-tool-executor.mjs +4 -2
  128. package/src/session-runtime/model-route-api.mjs +5 -4
  129. package/src/session-runtime/orchestration.mjs +7 -2
  130. package/src/session-runtime/provider-catalog-cache.mjs +5 -1
  131. package/src/session-runtime/provider-models.mjs +8 -8
  132. package/src/session-runtime/resource-api.mjs +22 -5
  133. package/src/session-runtime/runtime-bootstrap.mjs +2 -2
  134. package/src/session-runtime/runtime-core.mjs +8 -1
  135. package/src/session-runtime/runtime-facade.mjs +2 -2
  136. package/src/session-runtime/settings-api.mjs +11 -0
  137. package/src/session-runtime/setup-tool/executor.mjs +102 -18
  138. package/src/session-runtime/setup-tool/extended-actions.mjs +177 -0
  139. package/src/session-runtime/setup-tool/settings-contract.mjs +138 -0
  140. package/src/session-runtime/setup-tool/tool-defs.mjs +28 -9
  141. package/src/session-runtime/setup-tool/ui-requests.mjs +66 -0
  142. package/src/session-runtime/tool-defs.mjs +2 -2
  143. package/src/session-runtime/tool-policy-refresh.mjs +4 -2
  144. package/src/session-runtime/workflow-agents-api.mjs +11 -2
  145. package/src/standalone/provider-admin.mjs +1 -1
  146. package/src/standalone/session-protocol.mjs +3 -0
  147. package/src/standalone/session-service.mjs +21 -5
  148. package/src/tui/app/app-view.jsx +4 -1
  149. package/src/tui/app/doctor.mjs +150 -159
  150. package/src/tui/app/usage-context-panels.mjs +7 -1
  151. package/src/tui/components/ContextInspector.jsx +119 -0
  152. package/src/tui/components/ContextPanel.jsx +34 -12
  153. package/src/tui/dist/index.mjs +600 -417
  154. package/src/tui/session/agent-job-feed.mjs +4 -0
  155. package/src/tui/session/notification-plan.mjs +3 -0
  156. package/src/tui/session/session-api-ext.mjs +3 -0
  157. package/src/tui/session/session-api.mjs +2 -2
  158. package/src/ui/context-inspection.mjs +44 -0
  159. package/src/ui/streaming-markdown-heal.mjs +21 -7
  160. package/src/workflows/default/WORKFLOW.md +1 -6
  161. package/src/rules/agent/00-common.md +0 -9
  162. package/src/rules/agent/00-core.md +0 -10
  163. package/src/rules/lead/01-general.md +0 -20
  164. package/src/rules/lead/02-persona.md +0 -4
  165. package/src/rules/lead/lead-brief.md +0 -11
  166. package/src/rules/shared/00-general.md +0 -11
  167. package/src/rules/shared/75-goal.md +0 -11
  168. package/src/runtime/agent/orchestrator/providers/anthropic-fable-history.mjs +0 -86
@@ -46,8 +46,10 @@ observed target, and leave windows where they were.
46
46
  messages, including clicks, scrolling, and value/text input. This avoids
47
47
  unnecessary window activation, physical pointer travel, and animation waits.
48
48
  Check the returned effect; message delivery alone is not success.
49
- Background work uses activity status and result evidence, not a floating
50
- cursor effect over other windows. Real-pointer effects are foreground-only.
49
+ Both delivery modes show cursor and input feedback. Background uses a
50
+ target-bound virtual pointer without moving the user's physical pointer;
51
+ its feedback must not float above unrelated foreground windows. Foreground
52
+ decorates the real pointer. Visual feedback is not proof of action success.
51
53
  A background semantic action may queue behind foreground work to protect
52
54
  focus; waiting for that guard never switches its delivery mode.
53
55
  - **Foreground (explicit):** use when the target/gesture requires real pointer
@@ -99,15 +101,17 @@ observed target, and leave windows where they were.
99
101
  report `pixel_unavailable`; do not substitute a screen grab.
100
102
  - If the user intervenes, preserve their cursor and focus. Worker termination
101
103
  and input cleanup must finish before resuming; a failed cleanup is not cleared
102
- by a resume request. Ask the user to press Stop for verified cleanup recovery.
104
+ by a resume request. Ask the user to press `Ctrl+Alt+Esc` (emergency Stop)
105
+ for verified cleanup recovery.
103
106
  If target-local release remains unconfirmed, the user must inspect/recover
104
107
  that window; restarting the host alone does not prove release. Never operate
105
108
  recovery controls for the user. Obtain a new observation after an interruption.
106
109
  Use `wait_for_user` to keep the task waiting without sending input. The host
107
110
  may resume ordinary physical-input interruptions after its configured quiet
108
- interval; renewed input resets that interval. Explicit stops and uncertain
109
- observation/cleanup never auto-resume. The user can also use the overlay's
110
- pause/resume icon. Never click it or change the idle policy on their behalf.
111
+ interval; renewed input resets that interval. Explicit pauses/stops and
112
+ uncertain observation/cleanup never auto-resume. The overlay has one
113
+ Pause/Resume toggle: Pause retains the task; emergency Stop cancels it.
114
+ Never operate these controls or change the idle policy on the user's behalf.
111
115
  While paused, only `list`, `diagnose` and `wait_for_user` are available.
112
116
  Chat text alone does not clear the host. After `resumed`, capture fresh state;
113
117
  after `timeout` or `cancelled`, no input is authorized. Never replay the
@@ -126,6 +130,8 @@ observed target, and leave windows where they were.
126
130
  `query` / `role` narrow the element list, `include_noninteractive` widens
127
131
  it to static text, and `continuation` pages a list cut at `max_elements`.
128
132
  Frame size and encoding are the host's; unreadable detail is a `zoom`.
133
+ For `zoom`, pass `frame_id` and `region` without `window_id`, `app`, or
134
+ `screen`: the frame already identifies the exact source window.
129
135
  3. `act` with 1–6 simple actions. The first is an input action (`click`,
130
136
  `double_click`, `move`, `drag`, `scroll`, `type`, or `key`), using a fresh
131
137
  `ref`, an `element` mark, or `x`/`y` in `act.input.frame_id` when a target
@@ -24,8 +24,8 @@ supported `setup` action, and read its result as the change receipt.
24
24
  - API keys, OAuth credentials, tokens, and usage sign-ins stay out of tool
25
25
  arguments and the transcript. Open the Providers surface and let the user
26
26
  enter them.
27
- - A mutation follows the active workflow's approval rules. `open` and `status`
28
- are read-only.
27
+ - A mutation follows the active workflow's approval rules. Status, catalog,
28
+ definition, MCP-config and Instructions reads do not change persisted settings.
29
29
  - Most changes affect new sessions. Report `appliedToCurrentSession` and
30
30
  `appliesTo` exactly when the result supplies them.
31
31
  - This skill does not own source edits, builds, installation deployment,
@@ -41,8 +41,11 @@ supported `setup` action, and read its result as the change receipt.
41
41
  or is not exposed.
42
42
  3. For a supported mutation, send only the fields the user intends to change.
43
43
  Partial route and profile updates preserve omitted fields.
44
- 4. Read the mutation result. Call the narrow `status` domain afterward only
45
- when the result does not already prove the persisted value.
44
+ 4. Read the mutation result, including `saved`, `scope`, `appliesTo`,
45
+ `appliedToCurrentSession`, and `requiresReload` when present. Background
46
+ installation receipts are not evidence of completed installation.
47
+ Call the narrow `status` domain afterward only when the receipt does not
48
+ already prove the persisted value.
46
49
  5. Report what changed and whether it applies now or in a new session.
47
50
 
48
51
  Completion means the persisted state or UI handoff is evidenced, not merely
@@ -57,15 +60,26 @@ that a call returned without transport error.
57
60
 
58
61
  ## High-signal distinctions
59
62
 
60
- - Main model, agent models, and Web Search model are separate routes. An agent
61
- override with an empty provider restores Main inheritance.
63
+ - Main model, agent models, and Web Search model are separate routes. Omitted
64
+ fields preserve the selected route. An explicitly empty agent or Web Search
65
+ provider restores Main inheritance; omission never resets it. Disabling an
66
+ agent preserves its route for re-enabling.
62
67
  - Web Search model selection and Web Search tool exposure are separate.
63
68
  - Memory master state controls the capability; recap controls background
64
69
  cycles only. Core Memory content is managed by the `memory` tool.
65
- - Git, Memory, and Office have installation state separate from enabled state.
66
- Browser Use, Computer Use, and voice are managed through Built-in UI cards;
67
- `set_first_use_approval` controls once-per-session first-use approval for
70
+ - Built-ins have installation state separate from enabled state. Browser Use,
71
+ Computer Use, and voice actions require this conversation open in the local
72
+ Desktop window. `set_first_use_approval` controls first-use approval for
68
73
  Browser Use and Computer Use only, not voice.
74
+ - Desktop appearance changes affect the Desktop host, not a paired phone.
75
+ Display language is independent of profile response language. A required
76
+ reload is reported, never performed automatically.
77
+ - Read definitions before editing them; use skill-creator when authoring a
78
+ skill. Setup persists the supported definition fields. Workflow and agent
79
+ ids are stable identities, distinct from their display names.
80
+ - Read Instructions before replacing them and pass the returned text as
81
+ `expectedContent`. `projectPath:null` means Common Instructions; otherwise
82
+ use an exact registered Project root. Keep the returned backup.
69
83
  - MCP servers and plugins are machine-global integrations whose visibility may
70
84
  be scoped to selected Projects.
71
85
  - User skills are machine-global. Enabled plugin skills and built-in skills are
@@ -80,10 +94,16 @@ that a call returned without transport error.
80
94
  pretending a window opened.
81
95
  - For an MCP failure, inspect the reported transport error before changing
82
96
  command, arguments, directory, environment, URL, headers, or enabled state.
97
+ - MCP reads intentionally omit raw connection values that may contain secrets.
98
+ Partial edits preserve those values. Use environment-variable names for
99
+ credentials; never request or echo their values.
83
100
  - For an unavailable built-in, distinguish not installed, installed but
84
101
  disabled, and bridge inactive.
85
- - If a requested setting is UI-only, navigate there when possible and hand
86
- control to the user. Do not imitate the missing action by editing storage.
102
+ - Desktop requests require a single live claimant and a confirmed receipt.
103
+ A timeout or cancelled request is not success. If execution already started,
104
+ inspect state before retrying; do not resubmit a possibly completed mutation.
105
+ - Notification permission/subscription, pairing credentials, and authentication
106
+ remain user-operated UI handoffs. Do not imitate them by editing storage.
87
107
  - Unknown keys and retired configuration are diagnostics, not permission for
88
108
  direct cleanup.
89
109
 
@@ -7,7 +7,8 @@ authority for required fields and accepted values.
7
7
 
8
8
  - `status` reads one domain: summary, model, agents, workflow, websearch,
9
9
  output-style, profile, autoclear, compaction, memory, features, local-provider, shell,
10
- providers, mcp, skills, plugins, update, or onboarding.
10
+ providers, mcp, skills, plugins, update, onboarding, capabilities, desktop,
11
+ appearance, projects, connection, schedules, or webhooks.
11
12
  - `open` navigates to a supported UI surface. Read `surfaces.md` for targets and
12
13
  UI-only settings.
13
14
 
@@ -26,9 +27,9 @@ authority for required fields and accepted values.
26
27
  | Memory capability | `set_memory_enabled` |
27
28
  | Background memory cycles | `set_recap_enabled` |
28
29
  | Web Search tool exposure | `set_web_search_enabled` |
29
- | Git, Office, or Local Provider enabled state | `set_builtin_enabled` |
30
+ | Git, Office, Code Tidy, Local Provider, Browser, Computer, or voice enabled state | `set_builtin_enabled` |
30
31
  | One approval per session before the first Browser Use or Computer Use call (`name`: browser or computer; on by default) | `set_first_use_approval` |
31
- | Git, Memory, Office, or Local Provider runtime preparation | `install_builtin` |
32
+ | Git, Memory, Office, Code Tidy, Local Provider, Browser, Computer, or voice preparation | `install_builtin` |
32
33
  | Managed local model installation (use the local-provider skill) | `install_local_model` |
33
34
  | Start or resume a background runtime/model download | `start_local_installation` |
34
35
  | Pause a shared local download, retaining partial files | `cancel_local_installation` |
@@ -53,19 +54,43 @@ authority for required fields and accepted values.
53
54
  | Refresh a plugin checkout | `update_plugin` |
54
55
  | Enable or disable a plugin | `set_plugin_enabled` |
55
56
  | Remove a plugin | `remove_plugin` |
57
+ | Available hosted models and their options; optionally native-search capable only | `list_models` |
58
+ | Agent orchestration, independent of workflow instructions | `set_orchestration_mode` |
59
+ | Safe MCP edit metadata, excluding raw connection/credential values | `get_mcp_server` |
60
+ | Read a workflow, agent, or skill definition | `read_definition` |
61
+ | Create a workflow, agent, or machine-global user skill | `create_definition` |
62
+ | Partially edit a workflow, agent, or machine-global user skill | `save_definition` |
63
+ | Delete a user workflow/agent definition or override | `delete_definition` |
64
+ | Save a schedule/webhook; explicitly overwrite to edit | `save_automation` |
65
+ | Delete an existing schedule/webhook | `delete_automation` |
66
+ | Enable/disable a schedule/webhook | `set_automation_enabled` |
67
+ | Webhook listener enabled state, port, or domain | `set_webhook_config` |
68
+ | Desktop keep-awake, usage pin, or Computer observe-only state | `set_desktop_settings` |
69
+ | Desktop theme, display language, side panels, or zoom | `set_appearance` |
70
+ | Register a Project and optionally set its display alias | `save_project` |
71
+ | Unregister a Project without deleting its files | `remove_project` |
72
+ | Read Project/Common Instructions before editing | `get_instructions` |
73
+ | Replace unchanged Project/Common Instructions and retain a backup | `set_instructions` |
74
+ | Revoke one linked device; re-pairing restores access | `revoke_linked_device` |
75
+ | Managed local model context allocation; null restores automatic | `set_local_context` |
56
76
 
57
77
  ## Routes and workflow
58
78
 
59
79
  Inspect `status model`, `status agents`, `status websearch`, or `status
60
80
  workflow` before changing the corresponding domain.
61
81
 
62
- - A partial route preserves omitted values.
82
+ - A partial route preserves omitted values. Main routes also accept
83
+ `modelParameters` and `contextPercent`; agent routes accept `disabled`.
84
+ Use the model catalog for actual available options, not remembered model ids.
63
85
  - Setting an agent route provider to an empty string removes the override and
64
86
  restores Main inheritance.
65
87
  - A Web Search route must support native web search; tool exposure is changed
66
88
  separately.
67
- - Workflow definitions and custom agent definitions are edited through their
68
- supported UI or file workflow, not through undocumented setup keys.
89
+ - Definition actions use `definitionKind` (workflow, agent, skill). Read first,
90
+ then supply only changed fields. Workflow/agent ids cannot be renamed through
91
+ a save; change their display name instead. User skills may be renamed with
92
+ `originalName` and `name`. Skill deletion is not exposed; disable it instead.
93
+ - Changing orchestration does not rewrite workflow instructions or agents.
69
94
 
70
95
  ## Providers and authentication
71
96
 
@@ -86,7 +111,11 @@ values through chat.
86
111
 
87
112
  - Output style changes do not rewrite the current answer already in progress.
88
113
  - Profile response language and Desktop display language are separate.
89
- - Auto-clear supports a global or provider-specific idle duration.
114
+ - Auto-clear supports global/provider idle durations, `minContextPercent`,
115
+ `reset`, and `resetProvider`. A reset and a duration are mutually exclusive;
116
+ provider reset requires a provider.
117
+ - Compaction supports `enabled` and either `mainBufferTokens` or
118
+ `mainBufferPercent`. Changing representation replaces the previous budget.
90
119
  - Memory master state controls tools, core injection, and background cycles.
91
120
  `set_recap_enabled` changes only the background cycles.
92
121
  - Core Memory entries are read and changed with the `memory` tool, not setup.
@@ -102,8 +131,10 @@ bridge state.
102
131
  - Git installation may prepare system Git.
103
132
  - Office installation may prepare LibreOffice dependencies and global Noto
104
133
  fonts as well as the runtime component.
105
- - Browser Use, Computer Use, and voice installation/toggles are UI-owned.
106
- Computer Use is Windows-only.
134
+ - Browser Use, Computer Use, and voice installation/toggles use the same
135
+ `install_builtin` and `set_builtin_enabled` actions through a live Desktop
136
+ receipt. Computer Use is Windows-only. These actions do not approve OS
137
+ permission dialogs or first-use tool approval on the user's behalf.
107
138
  - Environment feature overrides are diagnostics for headless or benchmark
108
139
  environments, not ordinary user settings.
109
140
 
@@ -118,8 +149,35 @@ bridge state.
118
149
  skills and MCP integrations it contributes.
119
150
  - MCP mutation results include reconnection state. Diagnose the returned error
120
151
  before making another change.
152
+ - MCP add requires name plus command or URL. Save uses `originalName` (defaults
153
+ to name), so changing `name` with `originalName` renames the existing server.
154
+ Omitted fields remain unchanged. Switching transport requires a complete new
155
+ transport. Raw credential fields are not accepted; `env_vars`,
156
+ `bearer_token_env_var`, and `env_http_headers` reference existing environment
157
+ variables without exposing their values.
158
+ - Environment/header maps are partial patches. Omitted keys are preserved;
159
+ `null` explicitly removes one key, including a stored credential.
121
160
  - Plugin enablement moves its contributed skills and MCP integrations together.
122
161
 
162
+ ## Desktop, Projects, and automation
163
+
164
+ - `status capabilities` lists supported actions and deliberate handoffs.
165
+ - Desktop-only operations require the owning conversation visible in the local
166
+ Desktop app. They affect the Desktop host, not a paired phone. Never claim a
167
+ persisted change from merely delivering a request.
168
+ - A display-language change returns `requiresReload`; setup does not reload,
169
+ quit, deploy, or restart the app.
170
+ - A Project removal unregisters it only. Instruction edits require the exact
171
+ previous content and return a retained backup path.
172
+ - Inspect schedules/webhooks before editing. `overwrite:true` updates an
173
+ existing named entry and preserves omitted fields; a new schedule needs
174
+ instructions plus exactly one of cron `time` or one-shot `at`.
175
+ - Attachment contents and webhook signing secrets are not returned by setup.
176
+ Omitted attachments and existing webhook secrets are preserved. Copy a
177
+ signing secret through the Webhooks UI, never chat.
178
+ - Enabling or creating automation may start its background worker. This is a
179
+ persisted automation change, not permission to run an unrelated task now.
180
+
123
181
  ## Update
124
182
 
125
183
  Use `status update` and `set_auto_update` for persisted update settings. An
@@ -48,25 +48,32 @@ execution returns `opened:false` with guidance to relay to the user.
48
48
  Provider authentication is intentionally hidden from the remote web app; guide
49
49
  the user to Desktop.
50
50
 
51
- ## UI-owned settings
51
+ ## Desktop-backed settings
52
+
53
+ Setup can read and change Desktop appearance, keep-awake, usage pin,
54
+ Computer observe-only, Browser/Computer/voice installation and toggles,
55
+ Projects, Instructions, and linked-device revocation through the attached
56
+ Desktop. A receipt identifies `scope:desktop-host`; appearance is not applied
57
+ to the paired browser. No Desktop claimant means no confirmed change.
58
+
59
+ Schedules/webhooks and workflow/agent/skill definitions use their runtime
60
+ actions directly. These do not require clicking their Desktop rails.
61
+
62
+ ## User-operated UI handoffs
52
63
 
53
64
  The setup tool does not mutate:
54
65
 
55
- - Desktop display language, theme, side panels, notifications, or keep-awake;
56
- - GitHub CLI connection;
57
- - web-app pairing and linked devices;
58
- - Project registration, naming, or Project/Common Instructions;
59
- - workflow-pack and agent-definition authoring;
60
- - Browser Use, Computer Use, or voice install/toggle state;
61
- - schedules and webhooks.
66
+ - API keys, OAuth, usage sign-in, and GitHub CLI connection;
67
+ - notification permission and subscription on the receiving device;
68
+ - web-app pairing credentials and OS permission dialogs;
69
+ - TUI-local theme palettes (use `/theme`; Desktop themes are separate).
62
70
 
63
- Use `open` where a target exists, then let the user act. Schedules and webhooks
64
- live on their Desktop rails and have no setup action. Never simulate a missing
65
- action by editing local storage, configuration files, or database rows.
71
+ Use `open` where a target exists, then let the user act. Never simulate a
72
+ missing or denied operation by editing storage or switching surfaces.
66
73
 
67
74
  ## TUI notes
68
75
 
69
- The TUI settings hub exposes system shell and Memory cycle controls in addition
70
- to common settings. A visible control does not imply a setup mutation exists;
71
- use the tool schema as the API boundary.
76
+ The TUI settings hub exposes system shell in addition to common settings.
77
+ Desktop-host actions need the Desktop app; opening the TUI is not a substitute.
78
+ Use the schema and `status capabilities` as the supported API boundary.
72
79
 
@@ -9,6 +9,7 @@ import {
9
9
  } from './runtime/shared/pristine-execution.mjs';
10
10
  import { hasActiveBackgroundTasks } from './runtime/shared/background-tasks.mjs';
11
11
  import { installProcessSignalCleanup } from './runtime/shared/process-shutdown.mjs';
12
+ import { closeUsageLedgers } from './runtime/shared/llm/usage-ledger.mjs';
12
13
  import { stopStandaloneMemoryRuntimesForProcess } from './standalone/memory-runtime-proxy.mjs';
13
14
  import { shutdownDaemonForRuntimeRoot } from './standalone/session-client.mjs';
14
15
  import { applyUsageDelta, createSessionStats } from './ui/session-stats.mjs';
@@ -563,6 +564,7 @@ export async function runHeadlessExec({
563
564
  runtimeFactory = null,
564
565
  memoryRuntimeCleanup = stopStandaloneMemoryRuntimesForProcess,
565
566
  daemonRuntimeCleanup = shutdownDaemonForRuntimeRoot,
567
+ usageLedgerCleanup = closeUsageLedgers,
566
568
  hasActiveTasks = hasActiveBackgroundTasks,
567
569
  installSignalCleanupFn = installProcessSignalCleanup,
568
570
  } = {}) {
@@ -629,6 +631,14 @@ export async function runHeadlessExec({
629
631
  } catch (error) {
630
632
  errors.push(error);
631
633
  }
634
+ try {
635
+ // The usage ledger lives inside the pristine root. Its open SQLite
636
+ // handle blocks the root removal below on Windows (EBUSY) for the whole
637
+ // rmSync retry budget, so release it once the last usage row is in.
638
+ usageLedgerCleanup();
639
+ } catch (error) {
640
+ errors.push(error);
641
+ }
632
642
  let resourceCleanupFailed = false;
633
643
  if (boundary?.runtimeRoot) {
634
644
  try {
@@ -650,8 +660,14 @@ export async function runHeadlessExec({
650
660
  }
651
661
  }
652
662
  try {
663
+ // The answer is already final here. A root whose memory daemon is still
664
+ // winding down (its pg.log stays open for a while) must not hold the
665
+ // exit for the default ≈128s retry budget; 10 linear retries ≈ 5.5s,
666
+ // and the periodic orphan sweep reclaims whatever is left.
653
667
  const cleanupResult = boundary?.cleanup(
654
- resourceCleanupFailed ? { preserveRoot: true } : { tolerateRootRemovalFailure: true }
668
+ resourceCleanupFailed
669
+ ? { preserveRoot: true }
670
+ : { tolerateRootRemovalFailure: true, rootRemovalRetries: 10 }
655
671
  );
656
672
  if (cleanupResult?.rootRemovalError) {
657
673
  writeErr(
@@ -19,14 +19,10 @@
19
19
  *
20
20
  * Source files (rules/):
21
21
  * - shared/*.md — ordered universal policies (Lead + agent BP1, identical full set)
22
- * - lead/lead-tool.md — Lead-specific control-tower / delegation / ToolSearch guidance
23
- * - lead/lead-brief.md — Lead brief contract (delegating workflows only)
24
- * - lead/01-general.md — Lead general
25
- * - lead/02-persona.md — Lead communication personality
22
+ * - lead/LEAD.md — Lead role: user communication, agent briefing (agent-gated), tone
26
23
  * - output-styles/common.md — shared built-in output composition policy
27
24
  * - output-styles/<name>.md — selected built-in depth variant or standalone user style
28
- * - agent/00-core.md — universal agent constraints (BP3, all profiles)
29
- * - agent/00-common.md — public-agent-only extras (BP3 full profile)
25
+ * - agent/AGENT.md — common agent contract: chain of command, handoff (BP3, all profiles)
30
26
  * - agent/10..50-*.md — per-hidden-agent bodies (consumed by loadScopedRoleInstructions)
31
27
  *
32
28
  * Core memory snapshot is injected separately from the memory worker (pgdata)
@@ -274,25 +270,119 @@ function buildSharedToolContent({ PLUGIN_ROOT, omitTools = [], allowTools = null
274
270
  return omitToolRoutes(readMarkdownDirectory(SHARED_DIR), omitTools, allowTools);
275
271
  }
276
272
 
277
- function buildLeadRoleContent({ PLUGIN_ROOT, DATA_DIR, includeLeadBrief = true }) {
278
- const RULES_DIR = path.join(PLUGIN_ROOT, 'rules');
279
- const LEAD_DIR = path.join(RULES_DIR, 'lead');
280
- const general = readOptional(path.join(LEAD_DIR, '01-general.md'));
281
- const persona = readOptional(path.join(LEAD_DIR, '02-persona.md'));
273
+ // Route policy: `rules/routes/*.md` files bound to a provider and/or model
274
+ // family through frontmatter (`providers: a, b` exact ids; `models: gemini-*`
275
+ // lowercase globs tested against the model id and its `/`-leaf). A listed key
276
+ // restricts; an unlisted key is unrestricted, so a file without frontmatter
277
+ // applies to every route. The body is static rules appended to BP1;
278
+ // `turn-reminder: <one line>` rides the user turn's trailing <system-reminder>
279
+ // block (read once before the turn's first response); `round-reminder: <one
280
+ // line>` is appended after every tool round (delivered as the provider's
281
+ // turn-scoped system message where it supports one, else as the runtime
282
+ // <system-reminder>). Frontmatter never reaches the model.
283
+ function parseRouteFrontmatter(markdown) {
284
+ const match = String(markdown || '').match(/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/);
285
+ const meta = {};
286
+ if (!match) return meta;
287
+ for (const line of match[1].split(/\r?\n/)) {
288
+ const kv = line.match(/^([A-Za-z0-9_-]+):\s*(.*?)\s*$/);
289
+ if (kv) meta[kv[1].toLowerCase()] = kv[2];
290
+ }
291
+ return meta;
292
+ }
293
+
294
+ function routeList(value) {
295
+ return String(value || '')
296
+ .split(',')
297
+ .map((item) => item.trim().replace(/^['"]|['"]$/g, '').toLowerCase())
298
+ .filter(Boolean);
299
+ }
300
+
301
+ function routePatternMatches(pattern, value) {
302
+ const source = pattern
303
+ .split('*')
304
+ .map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
305
+ .join('.*');
306
+ return new RegExp(`^${source}$`).test(value);
307
+ }
308
+
309
+ function routeRulesApply(meta, provider, model) {
310
+ const providers = routeList(meta.providers);
311
+ const models = routeList(meta.models);
312
+ const providerId = String(provider || '')
313
+ .trim()
314
+ .toLowerCase();
315
+ const modelId = String(model || '')
316
+ .trim()
317
+ .toLowerCase();
318
+ const modelLeaf = modelId.split('/').pop() || '';
319
+ if (providers.length && !providers.includes(providerId)) return false;
320
+ if (models.length && !models.some((p) => routePatternMatches(p, modelId) || routePatternMatches(p, modelLeaf))) {
321
+ return false;
322
+ }
323
+ return true;
324
+ }
325
+
326
+ // The route files that apply to this provider/model, in name order.
327
+ function matchingRouteFiles({ PLUGIN_ROOT, provider, model }) {
328
+ const ROUTES_DIR = path.join(PLUGIN_ROOT, 'rules', 'routes');
329
+ let names;
330
+ try {
331
+ names = fs
332
+ .readdirSync(ROUTES_DIR)
333
+ .filter((name) => name.endsWith('.md'))
334
+ .sort();
335
+ } catch {
336
+ return [];
337
+ }
338
+ const files = [];
339
+ for (const name of names) {
340
+ const raw = readOptional(path.join(ROUTES_DIR, name));
341
+ if (!raw) continue;
342
+ const meta = parseRouteFrontmatter(raw);
343
+ if (routeRulesApply(meta, provider, model)) files.push({ raw, meta });
344
+ }
345
+ return files;
346
+ }
347
+
348
+ function buildRouteRulesContent({ PLUGIN_ROOT, provider = null, model = null, omitTools = [], allowTools = null } = {}) {
282
349
  const parts = [];
350
+ for (const { raw } of matchingRouteFiles({ PLUGIN_ROOT, provider, model })) {
351
+ const body = stripFrontmatter(raw);
352
+ if (body) parts.push(body);
353
+ }
354
+ return omitToolRoutes(parts.join('\n'), omitTools, allowTools);
355
+ }
283
356
 
284
- if (includeLeadBrief) {
285
- const briefLead = readOptional(path.join(LEAD_DIR, 'lead-brief.md'));
286
- if (briefLead) parts.push(briefLead);
357
+ // One frontmatter line for the route: the unrestricted files (`common.md`)
358
+ // come first, then whatever a file naming `models:` or `providers:` adds for
359
+ // that key — additions extend the common line, they never replace it.
360
+ function routeFrontmatterLine({ PLUGIN_ROOT, provider, model }, key) {
361
+ const lines = { general: [], specific: [] };
362
+ for (const { meta } of matchingRouteFiles({ PLUGIN_ROOT, provider, model })) {
363
+ const line = String(meta[key] || '').trim();
364
+ if (!line) continue;
365
+ lines[routeList(meta.models).length || routeList(meta.providers).length ? 'specific' : 'general'].push(line);
287
366
  }
367
+ return [...lines.general, ...lines.specific].join(' ');
368
+ }
288
369
 
289
- // Delegation-free workflows (Solo, headless) never expose the `agent` tool,
290
- // so Lead guidance marked `<!-- tools: agent -->` is dropped there and kept
291
- // verbatim for delegating workflows.
292
- if (general) parts.push(omitToolRoutes(general, includeLeadBrief ? [] : ['agent']));
293
- if (persona) parts.push(persona);
370
+ function buildRouteRoundReminderContent({ PLUGIN_ROOT, provider = null, model = null } = {}) {
371
+ return routeFrontmatterLine({ PLUGIN_ROOT, provider, model }, 'round-reminder');
372
+ }
294
373
 
295
- return parts.join('\n\n');
374
+ function buildRouteTurnReminderContent({ PLUGIN_ROOT, provider = null, model = null } = {}) {
375
+ return routeFrontmatterLine({ PLUGIN_ROOT, provider, model }, 'turn-reminder');
376
+ }
377
+
378
+ function buildLeadRoleContent({ PLUGIN_ROOT, DATA_DIR, includeLeadBrief = true }) {
379
+ const RULES_DIR = path.join(PLUGIN_ROOT, 'rules');
380
+ const lead = readOptional(path.join(RULES_DIR, 'lead', 'LEAD.md'));
381
+ if (!lead) return '';
382
+ // Delegation-free workflows (Solo, headless) never expose the `agent` tool,
383
+ // so Lead guidance marked `<!-- tools: agent -->` (briefing, completion
384
+ // notifications) is dropped there and kept verbatim for delegating workflows.
385
+ return omitToolRoutes(lead, includeLeadBrief ? [] : ['agent']);
296
386
  }
297
387
 
298
388
  function buildLeadMetaContent({ PLUGIN_ROOT, DATA_DIR }) {
@@ -371,9 +461,7 @@ function buildAgentRoleContent({ PLUGIN_ROOT, profile = 'full' }) {
371
461
  if (String(profile || 'full') === 'retrieval') {
372
462
  return buildAgentRetrievalInjectionContent({ PLUGIN_ROOT });
373
463
  }
374
- const core = readOptional(path.join(AGENT_DIR, '00-core.md'));
375
- const common = readOptional(path.join(AGENT_DIR, '00-common.md'));
376
- return [core, common].filter(Boolean).join('\n\n');
464
+ return readOptional(path.join(AGENT_DIR, 'AGENT.md')) || '';
377
465
  }
378
466
 
379
467
  /**
@@ -386,7 +474,7 @@ function buildAgentRoleContent({ PLUGIN_ROOT, profile = 'full' }) {
386
474
  */
387
475
  function buildAgentRetrievalInjectionContent({ PLUGIN_ROOT }) {
388
476
  const AGENT_DIR = path.join(PLUGIN_ROOT, 'rules', 'agent');
389
- const core = readOptional(path.join(AGENT_DIR, '00-core.md'));
477
+ const core = readOptional(path.join(AGENT_DIR, 'AGENT.md'));
390
478
  // Full ordered shared policy now ships via BP1 for retrieval
391
479
  // roles too; no compact duplicate here.
392
480
  const parts = [];
@@ -397,6 +485,9 @@ function buildAgentRetrievalInjectionContent({ PLUGIN_ROOT }) {
397
485
 
398
486
  module.exports = {
399
487
  buildSharedToolContent,
488
+ buildRouteRulesContent,
489
+ buildRouteRoundReminderContent,
490
+ buildRouteTurnReminderContent,
400
491
  buildLeadRoleContent,
401
492
  buildLeadMetaContent,
402
493
  buildLeadLanguageContent,
@@ -16,4 +16,4 @@ partial: true
16
16
  - Follow explicit requests for depth; never pad. Omit tangents, unsolicited
17
17
  advice or offers, raw dumps, and process recaps.
18
18
  - Apply the selected depth to substantive answers, not preambles or progress
19
- updates. Progress reports only new material findings, not a full summary.
19
+ updates.
@@ -5,7 +5,7 @@ description: Concrete explanation with full requested depth
5
5
  aliases: verbose, full
6
6
  ---
7
7
 
8
- ## Depth Variation
8
+ ## Depth
9
9
 
10
10
  - Explain the reasoning, mechanisms, evidence, trade-offs, and implications
11
11
  supporting the answer. Include relevant examples and edge cases.
@@ -5,7 +5,7 @@ description: Final decision or direct answer in one or two sentences
5
5
  aliases: extreme, extreme-simple, one-line, mono
6
6
  ---
7
7
 
8
- ## Depth Variation
8
+ ## Depth
9
9
 
10
10
  - Give the direct answer or result; for a cause question, give the
11
11
  determining cause.
@@ -5,7 +5,7 @@ description: Conclusion, core cause, and one decisive fact
5
5
  aliases: brief, short
6
6
  ---
7
7
 
8
- ## Depth Variation
8
+ ## Depth
9
9
 
10
10
  - State the conclusion and determining cause, adding one decisive fact or
11
11
  immediate consequence when useful.
@@ -5,7 +5,7 @@ description: Concise summary with the essential explanation
5
5
  aliases: default, concise, handoff
6
6
  ---
7
7
 
8
- ## Depth Variation
8
+ ## Depth
9
9
 
10
10
  - Give a self-contained summary: answer, core causal sequence, strongest
11
11
  evidence, and direct consequences.
@@ -29,4 +29,4 @@ For `SECOND_LAYER`, output only a shorter narrative in the source language.
29
29
  This is intentionally lossy compression: about half the input length is a
30
30
  target, not a pass/fail threshold. Prioritize main flow, latest conclusions,
31
31
  corrections and conditions; omit secondary detail. Do not output JSON, indexes,
32
- search metadata, a verification report, fences or preamble. Make no tool calls.
32
+ search metadata, a verification report, fences or preamble.
@@ -0,0 +1,13 @@
1
+ # Agent
2
+
3
+ - Lead's latest brief is your request and overrides any internal rule; Lead
4
+ owns user approval. Execute within the assigned scope and permissions without
5
+ reapproval; escalate only scope changes, unapproved destructive actions or
6
+ blockers to Lead.
7
+ - Do not review or verify unless your `AGENT.md` assigns it; Lead owns
8
+ verification.
9
+ - Communicate in English. Call tools immediately, with no preamble or progress
10
+ text; your only text is the final handoff, sent once the work is done.
11
+ - Handoff: outcome, key `file:line`, material risk or blocker, unresolved tool
12
+ failures, and the assigned verification result — fragments, max 30 lines;
13
+ never raw logs, process narration, or brief restatement.
@@ -0,0 +1,30 @@
1
+ # Lead
2
+
3
+ - You are Mixdog, a coding agent.
4
+ - The user's latest explicit request overrides any internal rule; drive it to
5
+ completion.
6
+ - The user sees only your text, not tool calls or thinking. Before the first
7
+ tool call, state in one line what you are about to do; afterwards bring the
8
+ user only material findings, direction or scope changes, unapproved
9
+ destructive actions, blockers or meaningful delays — never per-call
10
+ narration or plan repeats.
11
+ - Mid-task: a replacement supersedes, an addition folds in, a status question
12
+ gets a brief answer while work continues.
13
+ - Context is managed automatically: never propose stopping or stop on your own
14
+ judgment.
15
+ - Be a grounded, candid, and attentive collaborator: natural and respectful,
16
+ without flattery, forced humor, mimicry, or stereotyping.
17
+ <!-- tools: agent -->
18
+ - An agent sees only its brief, never this conversation. Brief the task,
19
+ purpose, scope and completion criteria in the user's exact terms, plus the
20
+ context it needs — findings synthesized into paths, lines and the exact
21
+ change or question, never "based on your findings". Assign within each
22
+ agent's role and permissions, never the same work twice. Fresh or respawned
23
+ agents get a complete brief, continuing agents only what changed; interrupt
24
+ only to cancel. Clear English, no fixed fields or repeated rules.
25
+ <!-- tools: agent -->
26
+ - Agent completion arrives by automatic notification: when an agent tool
27
+ result says so, finish other work not waiting on it and end the turn instead
28
+ of waiting in-turn; never predict or fabricate an agent's result. Resume
29
+ collection and review when the notification arrives; pending agent work is
30
+ not a completed request.
@@ -0,0 +1,4 @@
1
+ ---
2
+ turn-reminder: Batch: all independent calls in one response; several targets → one array argument.
3
+ round-reminder: Batch: all independent calls in one response; several targets → one array argument.
4
+ ---