Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
docs(spec): sync the prompt-enhancement contract and E2E scenario
zhangsiqiangaab10e3d5dbe
diff --git a/docs/adr/0121-one-shot-composer-prompt-enhancement.md b/docs/adr/0121-one-shot-composer-prompt-enhancement.mdindex 91020eca1..b99b7c2f4 100644--- a/docs/adr/0121-one-shot-composer-prompt-enhancement.md+++ b/docs/adr/0121-one-shot-composer-prompt-enhancement.md@@ -2,7 +2,8 @@- Status: Accepted- Date: 2026-08-24-- Related: Issue #14+- Updated: 2026-09-18 (user-overridable templates; enhancement model pin)+- Related: Issue #14, Issue #562## Context@@ -12,15 +13,61 @@ credentials to the renderer. The feature also needs to honor the model shownin the Composer while remaining safe when that selection changes during anin-flight request.+The first version shipped one fixed system prompt plus a `Draft:\n<draft>`+user message. Users found the rewrite weak, asked for the prompt itself to be+adjustable, and asked to run the rewrite on a cheaper or stronger model than the+conversation's.+## DecisionPrompt enhancement is an allowlisted renderer-to-Electron IPC operation. Therenderer sends the draft and a provider/model/thinking snapshot. Electron mainvalidates the draft, resolves the effective provider and credentials throughthe existing runtime launch resolver, and calls agent-runtime directly for a-single completion. The completion receives only the static enhancement system-prompt and one `Draft:\n<draft>` user message; it has no session history, tools,-attachments, durable turn, or transcript side effect.+single completion. The completion has no session history, tools, attachments,+durable turn, or transcript side effect.++The completion context is a built-in system prompt plus one user message built+from a user template whose `{{draft}}` placeholder receives the draft. The user+template is overridable through `AppSettings.promptEnhancementUserTemplate`, and+its default lives in `packages/shared/src/prompt-enhancement.ts` so the runtime,+the settings UI, and the restore-default action read one copy.+`AppSettings.promptEnhancementCustomTemplate` gates whether the stored template+applies. The switch is enabled only when a usable template exists, so it cannot+choose between two identical states, and saving a template turns it on. Turning+it off keeps the text so turning it back on restores it, and a blank or unusable+template resolves to the default. host-core validates the override before it persists:+it must be a string within `PROMPT_ENHANCEMENT_TEMPLATE_MAX_LENGTH` and carry the+draft variable, and a stored system-prompt override is dropped. The renderer+substitutes every occurrence of the placeholder and strips one matching pair of+wrapping quotation marks from the model's answer.++The system prompt is deliberately not overridable, and it is edited only in+source. It carries the rewrite contract the feature is verified against —+proper-noun preservation, language following without meta notes, the length+brake, and the output contract — so a user-editable copy would let a stored+value silently drop a rule the E2E scenario asserts.++The enhancement carries its own reasoning level through+`AppSettings.promptEnhancementThinkingLevel`, defaulting to `off`, and never+inherits the conversation's effort: a rewrite rarely benefits from reasoning and+reasoning is the slow path. The row lists only the levels the selected model+supports and disables itself when that set is empty, resolving them exactly as a+turn does (binding, then catalog, then provider default). The chosen level is+clamped by that ladder, and switching model re-clamps the stored value. One request is bounded by a 60-second ceiling, because the+provider retry budget alone can spend about a minute and the renderer has no+cancel; expiry fails with `TIMEOUT` rather than retrying on the session model.++The enhancement model and its reasoning level are configured on the Model+configuration page, in their own card titled "Enhancement prompt", because both+are model decisions and the model picker needs a title and a current value rather+than a bare control;+the prompt card keeps only the switch and the template editor. The enhancement+model follows the Composer's current model unless+`promptEnhancementProviderId` / `promptEnhancementModelId` pin another. A pin+whose provider is disabled, whose account is signed out, or whose binding no+longer exists is a preference that cannot be honoured rather than a failure:+main falls back to the Composer model and logs a warning.The renderer owns the interaction state: loading, one-level undo, dismissibleclassified errors, and an edit-generation guard that discards late results.@@ -36,6 +83,14 @@ setup retry behavior; whitespace-only output is a dedicated terminal error.visible selector, while main-side fallback keeps stale or incompletesnapshots safe.- The renderer receives only text and classified error data, never secrets.+- The overridable user template lets a user tune the request without a new IPC+ surface. The cost is that a user template can drop the `<draft>` framing,+ which is why a missing draft variable falls back to the default rather than+ sending a prompt without the user's draft. Keeping the system prompt built in+ bounds that cost: the rewrite rules cannot be edited away.+- Sharing the defaults from `packages/shared` adds a cross-boundary read. It is+ the only arrangement in which the text the settings page shows is the text+ the model receives, and the text "restore default" restores.- The feature has a new typed IPC contract and must keep its UX and E2Escenarios synchronized with the runtime behavior.@@ -47,3 +102,17 @@ setup retry behavior; whitespace-only output is a dedicated terminal error.vendor OAuth bindings are main-owned security material.- Store enhancement history: rejected for v1; one exact undo snapshot issufficient and avoids adding persistence ownership.+- Keep the template in `agent-runtime` and expose the default to the settings+ UI over a new IPC method: rejected because it adds a protocol surface purely+ to display a constant, and lets the displayed default drift from the one in+ force.+- Let the user override the system prompt as well: rejected because that text is+ part of the feature contract. A stored override could remove the proper-noun+ rule or the no-meta-note rule while the spec and E2E scenario still assert+ them, turning a supported configuration into a silent contract violation.+- Store the built-in default text as the user's value when they never edited it:+ rejected because a later product improvement to the defaults would then never+ reach those users; an empty override keeps them on the current default.+- Require the pinned enhancement model to resolve, failing otherwise: rejected+ because a stale pin would disable the action outright, long after the user+ forgot the choice; falling back with a warning keeps the action usable.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 2618e0585..d95762ead 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -142,7 +142,7 @@ Each ADR includes:| 0118 | Keep queued prompts renderer-owned and stop runs at turn boundaries | Accepted || 0119 | Event-Driven Subagent Timeouts | Accepted for implementation (killing policy amended by 0166; `maxTurns` clauses withdrawn by 0253) || 0120 | Bounded Session History Windows | Accepted |-| 0121 | Keep Composer prompt enhancement one-shot and main-owned | Accepted |+| 0121 | Keep Composer prompt enhancement one-shot and main-owned | Accepted (D447; issue #14 / #562) || 0122 | Reserve native width while the work panel is visible | Superseded by 0151 || 0123 | Use native taskbar minimize for Windows/Linux window controls | Accepted || 0124 | Bind Temporary Sessions to Their Own Scratch Workspace | Accepted |diff --git a/docs/spec/03-runtime/04-data-storage.md b/docs/spec/03-runtime/04-data-storage.mdindex d7a96d28f..748e44df6 100644--- a/docs/spec/03-runtime/04-data-storage.md+++ b/docs/spec/03-runtime/04-data-storage.md@@ -227,6 +227,17 @@ The app settings JSON optionally stores `thinkingDisplayMode` (`detailed` or`compact`). Missing values retain detailed presentation. This additive displaypreference neither rewrites stored reasoning nor changes the database schema.+The same blob optionally stores the prompt-enhancement overrides+`promptEnhancementCustomTemplate` (the switch that decides whether a stored+template applies), `promptEnhancementUserTemplate`,+`promptEnhancementProviderId`, `promptEnhancementModelId`, and+`promptEnhancementThinkingLevel` (ADR 0121). An absent or blank user template means the+built-in default applies, so clearing the field stores no key rather than an+empty string. A non-blank user template must contain the draft variable and stay+within `PROMPT_ENHANCEMENT_TEMPLATE_MAX_LENGTH`; host-core rejects a write that+breaks either rule and drops any stored `promptEnhancementSystemPrompt`, which is+no longer read. No schema version bump is required.+New config domains (e.g. MCP servers) start as a namespace; they graduate totables only when they need relations or indexes.diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex 5e9624c97..66484e6d7 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -152,6 +152,26 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (is remaining. The threshold controls when a text-only paste becomes atemporary session-scratch file; it defaults to 600 characters and acceptsinteger values from 1 through 1,000,000.+- **Prompt enhancement** is a card controlling the Composer's Enhance prompt+ action (ADR 0121). It carries a `Use a custom template` switch and the settings+ icon button the subagent rows use for editing, which opens an editor sheet+ (the subagent editor's pattern). The switch gates whether a stored template+ applies, is disabled until one is saved, and turns on when a template is+ saved; turning it off keeps the stored text. The sheet holds the user-template+ editor, which shows the built-in default text when no override is stored and+ offers an insert action for the draft variable; a save that would leave the+ template without that variable is refused. The system prompt is built in and+ exposes no field. Settings search indexes the card, its switch, and the+ template row.+- **Enhancement prompt** is its own card on the Models tab, below Defaults,+ because both fields are model decisions and the model picker needs the+ title/value/control shape the Defaults rows do not have. Its `Default model`+ row uses the same anchored, searchable menu as the Defaults card's row; empty+ means "follow the Composer's current model". Two rows therefore read `Default+ model`, distinguished by their card headings. The reasoning row is a menu+ select listing the levels the selected model actually supports (the row is+ disabled when it supports none), defaults to Off, and has no+ follow-the-session entry. Settings search indexes the card and both rows.- **Thinking display mode** uses a menu select with Detailed (default) andCompact. Detailed retains reasoning text; Compact shows only an activethinking indicator and hides finished thought rows. The global preferencediff --git a/docs/spec/04-ux/12-prompt-enhancement.md b/docs/spec/04-ux/12-prompt-enhancement.mdindex 43ab73e27..e4b33ba5c 100644--- a/docs/spec/04-ux/12-prompt-enhancement.md+++ b/docs/spec/04-ux/12-prompt-enhancement.md@@ -42,22 +42,34 @@ main, and invokes agent-runtime's one-shot completion helper. Vendor OAuthproviders receive a short-lived `ModelAuth` through the existing main-ownedresolver; no key or refresh token crosses into the renderer.-The completion context contains exactly:--1. the static `PROMPT_ENHANCEMENT_SYSTEM_PROMPT` from- `packages/agent-runtime/src/prompt-templates.ts`; and-2. one user message, `Draft:\n<draft text>`.--No prior conversation, tools, attachments, or configurable template are-included. The renderer removes its inline file-reference chip tokens before-the request and restores those chips in their original order and relative-position after the text response; the model is not trusted to preserve opaque-renderer sentinels. The selected thinking level is passed to pi-ai, and-provider setup retries use the existing bounded retry controller. When the-resolved provider is OpenCode Go (or another `opencode.ai` host), the one-shot-forwards the Composer session id as `x-opencode-session`; a request with no-session gets a per-call id. Model output is consumed as plain text and trimmed.-Empty or whitespace-only output is a `PROMPT_ENHANCEMENT_EMPTY` failure.+The completion context is a built-in system prompt plus one user message built+from a user template. The template defaults to+`packages/shared/src/prompt-enhancement.ts` and can be overridden in Settings+(see §5). It carries a `{{draft}}` placeholder; every occurrence is replaced+with the draft text, and the default template keeps the draft inside `<draft>`+tags so draft text reads as content to improve rather than as instructions. The+system prompt is not user-editable and states the role, the rewrite principles,+an explicit do-not list (including leaving code, commands, file paths,+identifiers, and other proper nouns exactly as written), language-following+rules that forbid language meta notes, a length brake, and the output contract.++No prior conversation, tools, attachments, or session state are included. The+renderer removes its inline file-reference chip tokens before the request and+restores those chips in their original order and relative position after the+text response; the model is not trusted to preserve opaque renderer sentinels.+The selected thinking level is passed to pi-ai, and provider setup retries use+the existing bounded retry controller. When the resolved provider is OpenCode Go+(or another `opencode.ai` host), the one-shot forwards the Composer session id+as `x-opencode-session`; a request with no session gets a per-call id. Model+output is consumed as plain text, has one matching pair of wrapping quotation+marks removed, and is trimmed. Empty or whitespace-only output is a+`PROMPT_ENHANCEMENT_EMPTY` failure.++The handler bounds one request with a 60-second ceiling. The provider retry+budget alone can spend about a minute, and the renderer offers no cancel, so on+expiry the action fails with `TIMEOUT` and a message naming the budget and the+setting to change. It does not silently retry on the session model: the user+chose the pinned model, and a hidden second attempt would double the wait.## 4. Failure and race handling@@ -70,3 +82,85 @@ request. If the draft changes, is sent/cleared, or the user switches sessionsbefore the response arrives, the response is discarded and cannot overwritethe newer draft. File chips are not included in the rewrite and are notremoved by success or failure.+++## 5. Configurable user template, model, and reasoning++Settings -> AI hosts a Prompt enhancement card. One row carries a switch —+`Use a custom template` — and the settings icon button the subagent rows use for+editing, which opens an editor sheet. The sheet holds the user template and+saves on `Save`, so closing it abandons the edit; `Cancel` and `Escape` close it,+and a click on the sheet backdrop closes it only when no save is in flight.++| Field | Effect when off or empty |+|---|---|+| `promptEnhancementCustomTemplate` | the built-in user template applies |+| `promptEnhancementUserTemplate` | the built-in user template |++The switch is the gate, not the text, and it is enabled only once a usable+custom template exists. With no saved template it renders disabled with a hint+that saving one unlocks it, because it would otherwise choose between two+identical states. Saving a template turns the switch on, since the user just+wrote one.++Turning the switch off keeps `promptEnhancementUserTemplate`, so turning it back+on restores the user's text instead of discarding it. A stored template with the+switch off, or an enabled switch whose template cannot be found, both resolve to+the built-in template.++The system prompt is not editable and exposes no field. It is part of the+feature contract (proper-noun preservation, language following without meta+notes, the length brake, the output contract), so changing it is a source change+that updates this spec. host-core drops a stored system-prompt override written+by an earlier build, so the store cannot hold a value nothing reads.++The template field shows the built-in default text when no override is stored,+so the editor opens on the value in force. Editing the field back to the exact+default text clears the override rather than storing a frozen copy, so later+improvements to the default still reach users who never customized it. Never+persisting the default text is deliberate.++The field offers an insert action that writes the draft variable at the caret,+and a save that would leave the template without it is refused locally with a+message. host-core enforces the same rules for any writer: a non-blank+`promptEnhancementUserTemplate` must contain `{{draft}}`, the value must be a+string within `PROMPT_ENHANCEMENT_TEMPLATE_MAX_LENGTH`, and a blank value is+stored as absent rather than as an empty string.++### Enhancement model and reasoning++Which model runs the rewrite, and with how much reasoning, are model decisions+and live on Settings -> Models, in their own card titled `Enhancement prompt`,+below the Defaults card. The card has its own title because it carries a+model picker, which — like the default-model row — needs a title, the current+value, and a control, and does not fit the single-control row shape the Defaults+card uses.++| Field | Effect when empty |+|---|---|+| `promptEnhancementProviderId` + `promptEnhancementModelId` | follow the Composer's current model |+| `promptEnhancementThinkingLevel` | `off` |++The card's model row is titled `Default model` and uses the same anchored,+searchable menu as the Defaults card's row, so the page shows one kind of model+picker. Both rows therefore read `Default model`; the card heading is what+separates the conversation's default from the enhancement's. When+`promptEnhancementProviderId` is set, main prefers that pin and logs a warning+plus falls back to the Composer's current model if the pin cannot be resolved: a+stale pin is a preference that cannot be honoured, never a failure that disables+the action.++The reasoning row lists the levels the selected model actually supports, using+the same resolution the Composer applies to a turn: the model binding's+`thinkingLevels`, then the live catalog, then the provider default. A model+without reasoning therefore offers only `Off (no reasoning)` and disables the+row, rather than presenting a ladder it cannot run. With no model pinned the+request follows the conversation's model, whose ladder is not knowable here, so+every canonical level is offered.++The row defaults to `Off`, with no follow-the-session option: the enhancement+never inherits the conversation's effort, because a rewrite rarely benefits from+reasoning and reasoning is the slow path. Changing the model re-clamps the stored+level onto the new model's ladder, and the value written is the clamped one, so a+stored level is always one the model can run. Round-tripping the displayed value+through the same resolver keeps the row and the store in step.diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex e2fbafacd..5cfbe0831 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -7557,7 +7557,7 @@ identify the platform validation still needed.| B / F / Security — Provider copy | E2E-PROVIDER-copy-config-without-credentials || A — App startup | E2E-001, E2E-002, E2E-003, E2E-004, E2E-067, E2E-076, E2E-079, E2E-092, E2E-097, E2E-143, E2E-150, E2E-168, E2E-204 || B — Model config | E2E-005, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209 |-| C — Conversation & stream | E2E-008, E2E-008d, E2E-008a, E2E-009, E2E-010, E2E-011, E2E-011a, E2E-011b, E2E-011d, E2E-011e, E2E-011g, E2E-031, E2E-040, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-052, E2E-053, E2E-054, E2E-055, E2E-059, E2E-059a, E2E-060c, E2E-060d, E2E-061, E2E-061a, E2E-062, E2E-064, E2E-065, E2E-068, E2E-071, E2E-073, E2E-074, E2E-075, E2E-081, E2E-083, E2E-084, E2E-086, E2E-087, E2E-088, E2E-088b, E2E-089, E2E-090, E2E-COMPOSER-narrow-controls, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-106, E2E-109, E2E-111, E2E-114, E2E-116, E2E-117, E2E-118, E2E-119, E2E-120, E2E-121, E2E-218, E2E-219, E2E-AGENTS-001, E2E-142, E2E-144, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-161, E2E-162, E2E-166, E2E-172, E2E-173, E2E-174, E2E-177, E2E-178, E2E-179, E2E-180, E2E-182, E2E-183, E2E-187, E2E-198, E2E-199, E2E-202, E2E-203, E2E-207, E2E-208, E2E-CHAT-content-width-handles, E2E-250, E2E-102i, E2E-PLUGIN-session-orchestrator-real-workers, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-SUBAGENT-resume-a-settled-delegation |+| C — Conversation & stream | E2E-008, E2E-008d, E2E-008a, E2E-009, E2E-010, E2E-011, E2E-011a, E2E-011b, E2E-011d, E2E-011e, E2E-011g, E2E-031, E2E-040, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-052, E2E-053, E2E-054, E2E-055, E2E-059, E2E-059a, E2E-060c, E2E-060d, E2E-061, E2E-061a, E2E-062, E2E-064, E2E-065, E2E-068, E2E-071, E2E-073, E2E-074, E2E-075, E2E-081, E2E-083, E2E-084, E2E-086, E2E-087, E2E-088, E2E-088b, E2E-089, E2E-090, E2E-COMPOSER-narrow-controls, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-106, E2E-109, E2E-111, E2E-114, E2E-116, E2E-117, E2E-118, E2E-119, E2E-120, E2E-121, E2E-218, E2E-259, E2E-219, E2E-AGENTS-001, E2E-142, E2E-144, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-161, E2E-162, E2E-166, E2E-172, E2E-173, E2E-174, E2E-177, E2E-178, E2E-179, E2E-180, E2E-182, E2E-183, E2E-187, E2E-198, E2E-199, E2E-202, E2E-203, E2E-207, E2E-208, E2E-CHAT-content-width-handles, E2E-250, E2E-102i, E2E-PLUGIN-session-orchestrator-real-workers, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-SUBAGENT-resume-a-settled-delegation || D — Workspace | E2E-012, E2E-013, E2E-022B, E2E-024I, E2E-047, E2E-049, E2E-057, E2E-058, E2E-060, E2E-068, E2E-075, E2E-078, E2E-153, E2E-158, E2E-182, E2E-187, E2E-252 || D — Workspace (project ordering) | E2E-253 || E — Tools & permissions | E2E-008a, E2E-014, E2E-015, E2E-016, E2E-017, E2E-018, E2E-019, E2E-024I, E2E-024K, E2E-040, E2E-049, E2E-074, E2E-093, E2E-097, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102d, E2E-102e, E2E-102g, E2E-103, E2E-105, E2E-106, E2E-107, E2E-111, E2E-112, E2E-113, E2E-114, E2E-115, E2E-116, E2E-119, E2E-121, E2E-122, E2E-142, E2E-145, E2E-147, E2E-155, E2E-158, E2E-166, E2E-181, E2E-PLUGIN-imported-pi-package-skills |@@ -7566,7 +7566,7 @@ identify the platform validation still needed.| G — Plugins | E2E-022, E2E-022A, E2E-022B, E2E-022C, E2E-023, E2E-024, E2E-024B, E2E-024C, E2E-024D, E2E-024AA, E2E-024E, E2E-024W, E2E-024F, E2E-024G, E2E-024H, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M, E2E-024N, E2E-024O, E2E-024P, E2E-025, E2E-026, E2E-105, E2E-117, E2E-120, E2E-122, E2E-123, E2E-024Q, E2E-148, E2E-152, E2E-153, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection, E2E-PLUGIN-fs-root-follows-the-calling-session || H — Diagnostics | E2E-027, E2E-031, E2E-034, E2E-042, E2E-096, E2E-098, E2E-104, E2E-107, E2E-108, E2E-109, E2E-110, E2E-113, E2E-115, E2E-116, E2E-118, E2E-121, E2E-146, E2E-146a, E2E-155, E2E-159, E2E-176, E2E-194, E2E-195 || Security | E2E-028, E2E-029, E2E-030, E2E-024J, E2E-024K, E2E-024M, E2E-049, E2E-068, E2E-086, E2E-102c, E2E-102d, E2E-102e, E2E-105, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-113, E2E-115, E2E-116, E2E-117, E2E-119, E2E-121, E2E-122, E2E-123, E2E-142, E2E-148, E2E-151, E2E-153, E2E-158, E2E-187, E2E-196c, E2E-196b, E2E-196, E2E-PLUGIN-fs-root-follows-the-calling-session |-| Quality | E2E-032, E2E-033, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-053, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-103, E2E-AGENTS-001, E2E-021a, E2E-024N, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-111, E2E-114, E2E-117, E2E-118, E2E-119, E2E-120, E2E-122, E2E-123, E2E-142, E2E-143, E2E-144, E2E-145, E2E-146, E2E-147, E2E-148, E2E-150, E2E-151, E2E-153, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-168, E2E-172, E2E-173, E2E-174, E2E-011g, E2E-176, E2E-177, E2E-178, E2E-179, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-196, E2E-201, E2E-204, E2E-202, E2E-203, E2E-205, E2E-206, E2E-207, E2E-208, E2E-209, E2E-210, E2E-218, E2E-219, E2E-250, E2E-252, E2E-102i, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation |+| Quality | E2E-032, E2E-033, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-053, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-103, E2E-AGENTS-001, E2E-021a, E2E-024N, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-111, E2E-114, E2E-117, E2E-118, E2E-119, E2E-120, E2E-122, E2E-123, E2E-142, E2E-143, E2E-144, E2E-145, E2E-146, E2E-147, E2E-148, E2E-150, E2E-151, E2E-153, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-168, E2E-172, E2E-173, E2E-174, E2E-011g, E2E-176, E2E-177, E2E-178, E2E-179, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-196, E2E-201, E2E-204, E2E-202, E2E-203, E2E-205, E2E-206, E2E-207, E2E-208, E2E-209, E2E-210, E2E-218, E2E-259, E2E-219, E2E-250, E2E-252, E2E-102i, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation || Quality (project ordering) | E2E-253 || C — Conversation & stream (IME slash alias) | E2E-255 || E — Tools & permissions (Skill residency) | E2E-254 |@@ -7615,7 +7615,7 @@ identify the platform validation still needed.| M2 (IME slash alias) | E2E-255 || M5 (Skill residency) | E2E-254 || M6 | E2E-104, E2E-105, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-111, E2E-112, E2E-113, E2E-114, E2E-115, E2E-116, E2E-117, E2E-118, E2E-119, E2E-120, E2E-103, E2E-172 |-| M6+ | E2E-121, E2E-122, E2E-148, E2E-150, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-166, E2E-168, E2E-173, E2E-174, E2E-176, E2E-179, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-202, E2E-203, E2E-205, E2E-209, E2E-210, E2E-212, E2E-213, E2E-214, E2E-215, E2E-216, E2E-217, E2E-218, E2E-219, E2E-257, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation |+| M6+ | E2E-121, E2E-122, E2E-148, E2E-150, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-166, E2E-168, E2E-173, E2E-174, E2E-176, E2E-179, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-202, E2E-203, E2E-205, E2E-209, E2E-210, E2E-212, E2E-213, E2E-214, E2E-215, E2E-216, E2E-217, E2E-218, E2E-259, E2E-219, E2E-257, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation || M6+ (Session Orchestrator) | E2E-PLUGIN-session-orchestrator-real-workers || M6+ (Session list responsiveness) | E2E-SESSION-list-refresh-keeps-desktop-responsive || M6+ (Independent session communication) | E2E-SESSION-independent-top-level-communication, E2E-SESSION-hover-card-model-and-links |@@ -11083,6 +11083,14 @@ are withdrawn with ADR 0165.the draft, remains removable, and is dispatched exactly once with theenhanced prompt. Enhancement does not create a transcript row or alter theattachment bytes.+- **Expected**: The Sparkles action is enabled with the image chip present.+ The one-shot request contains only the visible prompt text, completes+ successfully, and rewrites that text. The image chip remains at the front of+ the draft, remains removable, and is dispatched exactly once with the+ enhanced prompt. Enhancement does not create a transcript row or alter the+ attachment bytes. The request is built from the built-in system prompt and the+ effective user template: with no saved override the built-in template applies;+ with an override saved in Settings, that text applies instead (E2E-259).- **Specs linked**: `04-ux/12-prompt-enhancement.md`,`04-ux/08-component-spec.md` §11.3/§11.7–11.8,`03-runtime/01-ipc-protocol.md` §13,@@ -11091,32 +11099,58 @@ are withdrawn with ADR 0165.- **Milestone**: M6+- **Status**: Unit/source-contract-covered; full UI journey Draft (run only in a capable environment when this surface changes)-#### E2E-219: Delegation cards show the resolved thinking level--- **Preconditions**: A project-bound Agent session with two delegation model- bindings: one supports `max`, and one supports no reasoning or only `off`.- The provider stream can start parallel `Task` calls using different models or- subagent definitions, and the session can be reloaded after the turn.-- **Steps**: 1) Start parallel delegates whose requested levels resolve to- `max` for one model and `high` clamped to `off` for the other. 2) Inspect the- live delegation card nodes and open each node in the side dock. 3) Resize to- a narrow conversation/work-panel layout and inspect the node and side-dock- captions with keyboard focus and hover. 4) Finish the turn, reload the- session, and inspect the same card and side-dock details again.-- **Expected**: Each node and its side-dock header use the delegation result's- effective `modelId` and `thinkingLevel`, independently of sibling delegates.- The reasoning-capable node shows the raw canonical `max` value after the- model name; the unsupported node shows only its model name. No- `Off` or `omit` suffix appears. Inheritance and model capability clamping are- reflected without UI re-derivation, the full label remains available through- the accessible name and hover title, and narrow layouts ellipsize without- overflow. Reloaded history matches the live presentation.-- **Specs linked**: `03-runtime/02-agent-runtime.md` §5f,- `04-ux/08-component-spec.md` §5.7, ADR 0202, ADR 0221-- **Acceptance**: C (chat/stream) + Quality+#### E2E-259: Prompt enhancement honors the configurable user template++- **Preconditions**: A configured, authenticated model is available; an Agent+ session has an empty Composer draft; Settings -> AI is reachable.+- **Steps**: 1) Open Settings -> AI and inspect the Prompt enhancement card with+ no saved override: the custom-template switch is off, disabled, and explains+ that saving a template unlocks it, and the row offers only the edit icon+ button. 2) Confirm no field for the system prompt is offered+ anywhere on the card or in the editor. 3) Open the editor; while the sheet is+ open, clear the draft variable token out of the user template and attempt to+ save. 4) Use the insert action to put the draft variable back, save, and+ confirm the sheet closes and the switch is now enabled and on. 5) Enhance a+ Chinese draft+ that also names a file such as `prompt-templates.ts`. 6) Enhance a+ mixed-language draft. 7) Resolve a model that returns the rewritten draft+ wrapped in quotation marks. 8) Reopen the editor, press `Escape`, and confirm+ the edit was abandoned. 9) Reopen the editor, edit the template, and close it+ by clicking the backdrop. 10) Turn the switch off and enhance again, then turn+ it back on and confirm the user's text is still there. 11) Pin an enhancement+ model, disable that provider, and enhance once more. 12) Confirm the reasoning row+ defaults to `Off (no reasoning)` and offers no follow-the-session entry, then+ raise it and enhance again to see the difference.+- **Expected**: With no override the editor opens on the built-in default text,+ so the displayed value equals the value in force, and the card shows no+ system-prompt field at all. Saving a user template without the draft variable+ is refused locally with a message, and no write reaches host-core. With no+ saved template the switch is disabled; after saving one it is enabled and on+ without a separate toggle. `Escape` and+ a backdrop click abandon the edit, leaving the stored value unchanged. With the+ switch off, enhancement uses the built-in template even though a custom one is+ stored; with it on, the stored template applies. Either way the request's system+ prompt is the built-in one and its user message contains the draft inside+ `<draft>` tags with the placeholder substituted. The rewritten draft keeps the+ draft's language, carries no language meta note, keeps `prompt-templates.ts`+ byte-identical, and has the wrapping quotation pair removed. Turning the switch+ off and on again leaves the user's stored text intact. A disabled pinned+ enhancement provider falls back to the Composer's current model, the+ enhancement still succeeds, and the fallback is logged as a warning. The+ reasoning row defaults to `Off (no reasoning)`, offers every canonical level+ plus `Off`, has no follow-the-session entry, and a level the model cannot+ honour is clamped rather than rejected. An enhancement that receives no provider response fails+ within about 60 seconds with `TIMEOUT` and a message naming the budget and the+ setting to change; it does not hang and does not silently retry on the session+ model.+- **Specs linked**: `04-ux/12-prompt-enhancement.md` §3/§5,+ `04-ux/06-settings-ia.md`, `03-runtime/01-ipc-protocol.md` §13,+ `03-runtime/04-data-storage.md`, ADR 0121, D447+- **Acceptance**: C (conversation & stream), Quality- **Milestone**: M6+-- **Status**: Unit/source-contract covered; full multi-provider rendered journey- remains Draft (run only in a capable environment when this surface changes)+- **Status**: Unit/RPC/source-contract-covered for the template resolution,+ validation, and quote stripping; full UI journey Draft (run only in a capable+ environment when this surface changes)#### E2E-220: Local MCP control drives a running desktopdiff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 515fbc8db..cf939589d 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -5987,3 +5987,72 @@ that was sitting at the bottom — including after the turn had finished.toasts they open, which are portaled to `document.body`, also move to the toplayer, because top-layer content paints above them and makes them unusable; anattempt was withdrawn for exactly that reason.++## 2026-09-18 — Prompt enhancement ships a substantive rewrite with user-overridable templates (D447)++- The default enhancement prompt moves from one conservative sentence to a+ structured system prompt plus a templated user message: role, analysis,+ rewrite principles, an explicit do-not list, language-following rules that+ forbid language meta notes, a length brake, and an output contract. The old+ `If the draft is already good, return it with at most minor polish` clause is+ removed: it made the action look inert on short drafts, which is the reported+ complaint.+- Two constraints the old prompt lacked are now explicit: code, commands, file+ paths, identifiers, API names, and other proper nouns must be reproduced+ exactly, and the answer must not open with a language meta note such as+ "The draft is in Chinese". Both are default-value decisions, not+ implementation details, because they change what every user receives.+- The user template becomes an `AppSettings` override+ (`promptEnhancementUserTemplate`) with its default in+ `packages/shared/src/prompt-enhancement.ts`; a blank override means "use the+ default", and editing the field back to the exact default text clears the+ override instead of freezing a copy. Storing the default text as a user value+ was rejected: a later improvement to the default would then never reach those+ users.+- The system prompt stays built in and is not user-editable. It carries rules+ the spec and E2E scenario assert, so a stored override could silently remove+ one; host-core drops such a value if an older build wrote it. Editing the+ system prompt remains a source change with a spec update.+- The user template carries `{{draft}}`. host-core rejects a non-blank user+ template without it, and each template must stay within+ `PROMPT_ENHANCEMENT_TEMPLATE_MAX_LENGTH`; main falls back to the default if an+ unusable value ever reaches the runtime. One matching pair of wrapping+ quotation marks is stripped from the model's answer.+- The settings surface is one row with a `Use a custom template` switch and the+ subagent rows' edit icon button, opening an editor sheet, rather than inline+ textareas or a row of labelled actions: the AI settings tab stays compact and+ the row reads as one control cluster. The switch, not the text, decides whether+ a stored template applies, so turning it off preserves the user's text. It is+ enabled only once a usable template exists and saving one turns it on, because+ an always-enabled switch would choose between two identical states before any+ template was written.+- `promptEnhancementProviderId` / `promptEnhancementModelId` let the rewrite run+ on a model other than the conversation's. An unresolvable pin falls back to+ the Composer's current model with a warning rather than failing the action.+- The enhancement model and reasoning level move to Settings -> Models, in a+ dedicated `Enhancement prompt` card below Defaults, whose model row is titled+ `Default model` like the Defaults card's row (the card heading separates them). Both are decisions about which model+ runs the rewrite, and the model page already owns the one model picker a user+ learns; the prompt card keeps only the prompt. The enhancement-model row reuses+ the default-model row's anchored menu rather than introducing a second picker.+- The enhancement reasoning row lists only the levels the selected model actually+ supports, resolved the same way a turn resolves them (binding `thinkingLevels`,+ then the live catalog, then the provider default), and is disabled when the+ model supports none. An earlier revision offered the full canonical ladder+ regardless of model, which is wrong for a model without reasoning. Switching+ model re-clamps and rewrites the stored level, so a persisted level is always+ runnable.+- The enhancement reasoning level becomes configurable and defaults to `off`; it+ never inherits the conversation's effort. A rewrite rarely benefits from+ reasoning, and reasoning is the slow path, so "follow the session" would+ silently opt every enhancement on a reasoning model into the slowest setting.+ The level is clamped by the resolved model's capabilities.+- One enhancement request is bounded by a 60-second ceiling and fails with+ `TIMEOUT` naming the budget, instead of retrying on the session model. The+ provider retry budget can already spend about a minute, the renderer has no+ cancel, and a hidden second attempt would double the wait. This is a behavior+ change for a slow provider: the action now fails visibly instead of hanging.+- No IPC method, process boundary, storage ownership, or security boundary+ changes; the existing `prompt/enhance` payload is unchanged. See+ `04-ux/12-prompt-enhancement.md` §3 and §5, ADR 0121, and+ `06-delivery/04-e2e-test-plan.md` E2E-259.diff --git a/docs/zh-CN/spec/03-runtime/04-data-storage.md b/docs/zh-CN/spec/03-runtime/04-data-storage.mdindex f1f920d83..7e20d7dca 100644--- a/docs/zh-CN/spec/03-runtime/04-data-storage.md+++ b/docs/zh-CN/spec/03-runtime/04-data-storage.md@@ -1147,6 +1147,14 @@ outbox 排空。渲染器侧的停止绝不重写已有已开始回复的转录主机读取设置时会将缺失、格式错误或超出范围的值规范化为 600,设置写入则验证1–1,000,000 的整数范围。因此现有数据库会在读取时延迟获得默认值,不需要破坏性迁移或第二个设置存储。++同一个应用设置 JSON 还可选存储提示词增强的覆盖值+`promptEnhancementCustomTemplate`(决定已存模板是否生效的开关)、+`promptEnhancementUserTemplate`、`promptEnhancementProviderId`、+`promptEnhancementModelId` 与 `promptEnhancementThinkingLevel`(ADR 0121)。用户模板缺失或为空表示使用内置默认值,+因此清空字段不会写入空字符串而是不写该键。非空的用户模板必须包含草稿变量,且+不得超过 `PROMPT_ENHANCEMENT_TEMPLATE_MAX_LENGTH`;host-core 会拒绝违反任一规则的+写入,并丢弃已不再读取的 `promptEnhancementSystemPrompt`。无需提升 schema 版本。- Plan 和 Goal 工件永远不会根据转录内容重建。开启动,一笔交易标志着每笔 `pending` 批准和每笔 `queued` 或diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.mdindex f03db3068..283d99ae7 100644--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md@@ -89,7 +89,19 @@工具栏上下文环及其弹层是以剩余容量还是已用容量为引导数值;默认为剩余。该阈值决定纯文本粘贴何时转为会话临时文件,默认值为 600 个字符,接受 1 至 1,000,000 的整数。-- **语音**卡:默认转写/朗读绑定(`AppSettings.speech`)。未配置时 Composer 对应入口禁用。Whisper / TTS 不进聊天模型列表。见 `20-speech.md`。+- **提示词增强**卡控制输入框的「增强提示词」操作(ADR 0121)。卡片上有「使用自定义提示词」+- **提示词增强**卡控制输入框的「增强提示词」操作(ADR 0121)。卡片上有「使用自定义提示词」+ 开关,以及子智能体行所用的设置图标按钮,点击后打开编辑弹窗(沿用子智能体编辑器的+ 模式)。开关决定已存模板是否生效,在尚未保存模板时禁用,保存模板后自动打开;关闭+ 开关会保留已存文本。弹窗内含用户模板编辑器;未保存覆盖值时显示内置默认文本,并提供+ 插入草稿变量的操作。会让模板缺少该变量的保存会被拒绝。系统提示词为内置,不提供任何+ 输入项。设置搜索会索引该卡、其开关与模板行。+- **增强提示词**是「模型」页上一张独立卡片,位于「默认项」之后,因为这两项都是+ 模型层面的决定,且模型选择器需要「标题/当前值/控件」的形态,而「默认项」的行形态+ 无法承载。其「默认模型」行使用与「默认项」卡片相同行的锚定可搜索菜单;为空表示+ 「跟随输入框当前模型」。因此会有两行都题为「默认模型」,靠各自卡片标题区分。思考+ 强度行是一个菜单选择器,列出所选模型实际支持的等级(不支持时该行禁用),默认「关闭+ 思考」,且不提供「跟随会话」项。设置搜索会索引该卡与这两行。- **默认项**卡中的**命令 Shell**行:主机发现的本机 PowerShell 5.1、PowerShell 7、cmd、Git Bash 和 ID 为 `windows-powershell`、`windows-pwsh`、`cmd`、`git-bash`的 Bash 和diff --git a/docs/zh-CN/spec/04-ux/12-prompt-enhancement.md b/docs/zh-CN/spec/04-ux/12-prompt-enhancement.mdindex 988aabd83..42428fbf3 100644--- a/docs/zh-CN/spec/04-ux/12-prompt-enhancement.md+++ b/docs/zh-CN/spec/04-ux/12-prompt-enhancement.md@@ -36,15 +36,25 @@ Electron 主进程使用与 agent 回合相同的运行时启动解析器解析提供商通过既有的、由主进程持有的解析器获得短时效的 `ModelAuth`;任何密钥或刷新令牌都不会进入渲染层。-补全上下文恰好包含:--1. 来自 `packages/agent-runtime/src/prompt-templates.ts` 的静态- `PROMPT_ENHANCEMENT_SYSTEM_PROMPT`;以及-2. 一条用户消息 `Draft:\n<draft>`。--不包含任何先前对话、工具、附件或可配置模板。所选思考等级会传给 pi-ai,-提供商初始化的重试沿用既有的有界重试控制器。模型输出按纯文本消费并 trim。-输出为空或仅含空白字符时,记为 `PROMPT_ENHANCEMENT_EMPTY` 失败。+补全上下文由一段内置系统提示词与一条用户消息组成。用户消息来自用户模板,+默认模板位于 `packages/shared/src/prompt-enhancement.ts`,可在设置中覆盖(见 §5)。+用户模板带有 `{{draft}}` 占位符;该占位符的每一次出现都会被替换为草稿文本,+默认模板把草稿放在 `<draft>` 标签内,使草稿文本被当作待改进的内容、而不是+指令。系统提示词不可由用户编辑,它规定了角色、改写原则、明确的禁止清单(包括+代码、命令、文件路径、标识符等专有名词必须原样保留)、禁止输出语言元注释的+语言跟随规则、长度刹车与输出契约。++不包含任何先前对话、工具、附件或会话状态。渲染层在请求前移除内联文件引用的+占位符 token,并在收到文本结果后按原顺序与相对位置恢复这些文件引用块;不信任+模型会保留渲染层的私有标记。所选思考等级会传给 pi-ai,提供商初始化的重试沿用+既有的有界重试控制器。当解析出的提供商为 OpenCode Go(或其他 `opencode.ai`+主机)时,一次性请求会把输入框会话 id 作为 `x-opencode-session` 转发;没有会话+的请求会获得一个按调用生成的 id。模型输出按纯文本消费,去掉一对包裹引号后+trim。输出为空或仅含空白字符时,记为 `PROMPT_ENHANCEMENT_EMPTY` 失败。++处理器为单次请求设置 60 秒上限。仅提供商重试预算就可能耗掉约一分钟,而渲染层没有+取消入口,因此超时后该操作以 `TIMEOUT` 失败,并给出写明预算与可改设置的消息。它不会+静默改用会话模型重试:模型是用户指定的,隐藏的第二次尝试会让等待时间翻倍。## 4. 失败与竞态处理@@ -55,3 +65,63 @@ Electron 主进程使用与 agent 回合相同的运行时启动解析器解析渲染层在发起请求时捕获草稿键与一个编辑代号。若响应到达前草稿发生变化、被发送或清空,或用户切换了会话,则响应被丢弃,不能覆盖更新后的草稿。文件引用块不参与重写,也不会因成功或失败而被移除。++## 5. 可自定义用户模板、模型与思考强度++设置 → AI 中有一张「提示词增强」卡片。一行内是一个开关——「使用自定义提示词」——+以及子智能体行所用的设置图标按钮,点击后打开编辑弹窗。弹窗内是用户模板,点击+「保存」才写入,因此关闭弹窗即放弃本次编辑;`取消` 与 `Esc` 均可关闭,点击弹窗遮罩+只在没有正在保存时关闭。++| 字段 | 关闭或为空时的效果 |+|---|---|+| `promptEnhancementCustomTemplate` | 使用内置用户模板 |+| `promptEnhancementUserTemplate` | 内置用户模板 |++开关决定是否生效,而不是文本本身;只有在存在可用的自定义模板时它才可用。没有已存+模板时该开关显示为禁用并给出提示,说明保存模板后即可启用,否则它只是在两个相同状态+之间切换。保存模板后开关会自动打开,因为用户刚刚写好了模板。++关闭开关会保留 `promptEnhancementUserTemplate`,因此再次打开时会恢复用户的文本而+不是丢弃它。开关关闭但存有模板,或开关打开但模板不可用,两种情况都会解析为内置模板。++系统提示词不可编辑,也不提供任何输入项。它属于功能契约的一部分(专有名词原样+保留、语言跟随且不输出语言元注释、长度刹车、输出契约),要修改它就是修改源码并+同步更新本规格。若早期版本曾写入系统提示词覆盖值,host-core 会将其丢弃,使存储中+不会留下无人读取的值。++未保存覆盖值时,模板字段显示内置默认文本,因此编辑器打开时显示的就是实际生效的+值。把字段编辑回与默认完全相同的文本会清空覆盖,而不是保存一份固化副本,这样后续+对默认值的改进仍能到达从未自定义过的用户。刻意不持久化默认文本。++该字段提供插入操作,在光标处写入草稿变量;若保存会让模板缺少该变量,则会就地拒绝+并给出提示。host-core 对任何写入方都执行同样的规则:非空的+`promptEnhancementUserTemplate` 必须包含 `{{draft}}`;该值必须是不超过+`PROMPT_ENHANCEMENT_TEMPLATE_MAX_LENGTH` 的字符串;空值按不存在存储,而不是空字符串。++### 增强模型与思考强度++改写使用哪个模型、用多大思考强度,属于模型层面的决定,位于设置 → 模型 中一张独立+卡片「增强提示词」内,排在「默认项」卡片之后。该卡之所以自带标题,是因为它包含+一个模型选择器——与默认模型行一样,需要标题、当前值与控件,无法套用「默认项」卡那种+单选控件的行形态。++| 字段 | 为空时的效果 |+|---|---|+| `promptEnhancementProviderId` + `promptEnhancementModelId` | 跟随输入框当前模型 |+| `promptEnhancementThinkingLevel` | `off` |++该卡片的模型行标题为「默认模型」,使用与「默认项」卡片相同行的锚定可搜索菜单,因此该页只呈现一种模型选择交互。+当设置了 `promptEnhancementProviderId` 时,主进程优先使用该指定项;若无法解析,则记录+警告并回退到输入框当前模型:过期的指定项只是无法满足的偏好,绝不会成为使该操作不可用+的失败。++思考强度行列出的,是所选模型**实际支持**的等级,采用的解析方式与 Composer 对一次回合+的做法一致:先取模型绑定的 `thinkingLevels`,再取实时模型目录,最后回退到提供商默认值。+因此不支持思考的模型只会提供「关闭思考」并禁用该行,而不是列出一套它无法运行的能力。+未指定模型时,请求跟随会话模型,而此处无法得知其能力,因此会列出全部规范等级。++该行默认「关闭思考」,且不提供「跟随会话」选项:增强永远不会继承会话的思考强度,因为+改写通常不需要思考,而思考正是慢的那条路。切换模型会把已存等级**重新钳制**到新模型的+能力上,且写入的就是钳制后的值,因此存储中的等级始终是模型能运行的等级。让显示值经过+同一个解析器,可保证该行与存储始终一致。