feat: support script paths for system_prompt and scheduled prompts #46

Merged
weiwen merged 2 commits from sandcastle/issue-35 into main 2026-07-06 18:30:16 +08:00
Owner

Summary

  • Introduces PromptSource enum (Literal / Script) in src/prompt_script.rs
  • Values ending in .sh or .py are treated as executable scripts; all others are inline literals
  • Scripts are spawned at point-of-use with a 10-second timeout and env vars EVIE_TRIGGER, EVIE_CHAT_ID, EVIE_NOTES_DIR; cwd is set to notes_dir
  • Missing script files are caught at startup (validate()), not at first use
  • Scheduler errors are logged and the fire is skipped; session-spawn errors propagate as SessionError::Internal

Closes #35

## Summary - Introduces `PromptSource` enum (`Literal` / `Script`) in `src/prompt_script.rs` - Values ending in `.sh` or `.py` are treated as executable scripts; all others are inline literals - Scripts are spawned at point-of-use with a 10-second timeout and env vars `EVIE_TRIGGER`, `EVIE_CHAT_ID`, `EVIE_NOTES_DIR`; cwd is set to `notes_dir` - Missing script files are caught at startup (`validate()`), not at first use - Scheduler errors are logged and the fire is skipped; session-spawn errors propagate as `SessionError::Internal` Closes #35
feat: support script paths for system_prompt and scheduled prompts — closes #35
All checks were successful
CI / check (pull_request) Successful in 1m30s
PR Triage — label changes-requested reviews / triage-review (pull_request) Successful in 1s
9e19aadb25
Introduces `PromptSource` enum (`Literal` / `Script`) in `src/prompt_script.rs`.
Values ending in `.sh` or `.py` are treated as executable scripts; all others
are inline literals.

Key decisions:
- Detection is by file extension (`.sh`/`.py`) after tilde/relative-path
  expansion in `expand_paths`. Paths are resolved relative to the config file's
  directory so the config is portable.
- Validation: missing script files are caught at startup (`validate()`), not at
  first use. Empty literals are still rejected as before.
- Resolution: scripts are spawned at the point of use (session spawn for
  `system_prompt`; cron fire for scheduled prompts) with a 10-second timeout and
  env vars `EVIE_TRIGGER`, `EVIE_CHAT_ID`, `EVIE_NOTES_DIR`; cwd is set to
  `notes_dir`. Empty stdout and non-zero exit are both errors.
- Scheduler errors are logged and the fire is skipped rather than crashing the
  task; session-spawn errors propagate as `SessionError::Internal`.
- Script execution tests are grouped in a single `tokio::test` to avoid Linux
  ETXTBSY races when many shell interpreters are spawned concurrently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
refactor: dedupe script detection, kill timed-out scripts, sync docs
All checks were successful
CI / check (pull_request) Successful in 1m23s
PR Triage — label changes-requested reviews / triage-review (pull_request) Successful in 1s
ac6090c93c
Review refinements for #35:

- config.rs: expand_prompt_path now delegates script detection to
  PromptSource::detect, so config-path expansion and runtime resolution share
  one definition of what counts as a script (no more duplicated .sh/.py
  literals that could drift).
- prompt_script.rs: set kill_on_drop(true) on the script Command so a script
  that hits the 10s timeout is killed rather than left orphaned.
- CONTEXT.md / README.md: document that system_prompt and schedule[].prompt
  accept a script path, per the cross-cutting-config-change standard (§4).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
weiwen merged commit a1787bda58 into main 2026-07-06 18:30:16 +08:00
weiwen deleted branch sandcastle/issue-35 2026-07-06 18:30:16 +08:00
Sign in to join this conversation.
No reviewers
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!46
No description provided.