Config: prompts inline OR file; embed default system prompt inline #6

Closed
opened 2026-07-04 21:59:25 +08:00 by weiwen · 1 comment
Owner

Relates to #5 (does not block / is not blocked by it — see Ordering).

Let a prompt be given either inline as a string or as a file path, uniformly across the config, and use that to simplify how the default system prompt ships.

Motivation

  • The system prompt currently lives in a separate ~/.config/evie/SYSTEM.md, auto-created with a default by Config::ensure_system_prompt() (src/config.rs:129). Embedding that default inline in the generated config.toml is equivalent for the user (still an editable default) but drops a whole file + code path.
  • #5 adds schedule prompts as file-only (prompt_file). Short one-line prompts are awkward in separate files; long prompts are awkward inline. Let the user choose per field.

Scope

  • Introduce a small config representation that accepts one of two keys — an inline string or a *_file path — and resolves to a String at load time (expand_tilde + read for the file case). Options: a #[serde(untagged)] enum, or an Option<String> + Option<PathBuf> pair validated so exactly one is set.
  • System prompt: support inline system_prompt = \"...\" alongside the existing system_prompt_file. Change default_toml() to embed the default prompt inline, and remove ensure_system_prompt() and the SYSTEM.md auto-create. Existing configs pointing at a system_prompt_file keep working (the file variant of the type).
  • Schedule prompts (once #5 exists): the same type applies to prompt / prompt_file.
  • Validation: exactly one of the inline/file variants per field; supplying both or neither is a startup config error.

Ordering

  • The system-prompt half depends on nothing and can land independently.
  • Whichever of #5 / #6 lands first, the other adopts the shared type: if #6 lands first, #5's schedule prompts use it directly (prompt | prompt_file); if #5 lands first, this issue retrofits its prompt_file field.

Acceptance

  • system_prompt (inline) and system_prompt_file (path) both work; default config ships the prompt inline; no SYSTEM.md is auto-created.
  • A [[schedule]] entry works with either prompt or prompt_file.
  • Supplying both, or neither, for any such field is a startup config error.
  • Existing file-based configs keep working unchanged.
Relates to #5 (does not block / is not blocked by it — see Ordering). Let a prompt be given **either** inline as a string **or** as a file path, uniformly across the config, and use that to simplify how the default system prompt ships. ## Motivation - The system prompt currently lives in a separate `~/.config/evie/SYSTEM.md`, auto-created with a default by `Config::ensure_system_prompt()` (`src/config.rs:129`). Embedding that default **inline in the generated `config.toml`** is equivalent for the user (still an editable default) but drops a whole file + code path. - #5 adds schedule prompts as file-only (`prompt_file`). Short one-line prompts are awkward in separate files; long prompts are awkward inline. Let the user choose per field. ## Scope - Introduce a small config representation that accepts one of two keys — an inline string or a `*_file` path — and resolves to a `String` at load time (`expand_tilde` + read for the file case). Options: a `#[serde(untagged)]` enum, or an `Option<String>` + `Option<PathBuf>` pair validated so exactly one is set. - **System prompt:** support inline `system_prompt = \"...\"` alongside the existing `system_prompt_file`. Change `default_toml()` to embed the default prompt inline, and **remove `ensure_system_prompt()`** and the SYSTEM.md auto-create. Existing configs pointing at a `system_prompt_file` keep working (the file variant of the type). - **Schedule prompts (once #5 exists):** the same type applies to `prompt` / `prompt_file`. - Validation: exactly one of the inline/file variants per field; supplying both or neither is a startup config error. ## Ordering - The system-prompt half depends on nothing and can land independently. - Whichever of #5 / #6 lands first, the other adopts the shared type: if #6 lands first, #5's schedule prompts use it directly (`prompt` | `prompt_file`); if #5 lands first, this issue retrofits its `prompt_file` field. ## Acceptance - `system_prompt` (inline) and `system_prompt_file` (path) both work; default config ships the prompt inline; no SYSTEM.md is auto-created. - A `[[schedule]]` entry works with either `prompt` or `prompt_file`. - Supplying both, or neither, for any such field is a startup config error. - Existing file-based configs keep working unchanged.
weiwen changed title from Config: accept prompts inline OR as a file path to Config: prompts inline OR file; embed default system prompt inline 2026-07-04 22:09:21 +08:00
Author
Owner

Implemented on sandcastle/issue-6 (commit 1d4247e).

Changes:

  • PiConfig now accepts either system_prompt (inline string) or system_prompt_file (file path); exactly one must be present (validated at startup).
  • resolved_system_prompt is populated at load time: inline prompts are written to <config_dir>/system_prompt.md, file prompts used as-is.
  • default_toml() embeds the default prompt inline via TOML multi-line string system_prompt = """...""".
  • Removed ensure_system_prompt() and SYSTEM.md auto-create.
  • Existing file-based configs continue to work unchanged.
  • 9 new unit tests covering inline, file, both, neither, resolution, and default config.

Files changed: src/config.rs, src/main.rs, src/pi.rs, CONTEXT.md

Implemented on `sandcastle/issue-6` (commit 1d4247e). Changes: - `PiConfig` now accepts either `system_prompt` (inline string) or `system_prompt_file` (file path); exactly one must be present (validated at startup). - `resolved_system_prompt` is populated at load time: inline prompts are written to `<config_dir>/system_prompt.md`, file prompts used as-is. - `default_toml()` embeds the default prompt inline via TOML multi-line string `system_prompt = """..."""`. - Removed `ensure_system_prompt()` and SYSTEM.md auto-create. - Existing file-based configs continue to work unchanged. - 9 new unit tests covering inline, file, both, neither, resolution, and default config. Files changed: `src/config.rs`, `src/main.rs`, `src/pi.rs`, `CONTEXT.md`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
weiwen/evie#6
No description provided.