Guide models to read-only inspection: prompt rules, pipes and find in the read-only gate, approval stats

This commit is contained in:
hermes committed 2026-10-06 13:14:09 +00:00
1 parent 8345d0f504
commit 37dfbc3102
7 files changed
+70 -11

No files matched your search

+14 -1
View File
@@ -3,7 +3,12 @@
use std::path::{Path, PathBuf};
pub const DEFAULT_PROMPT: &str = "You are hx, a coding agent working in the user's repository. \
Use the tools to read, edit and run code. Read files before editing them. Keep answers short.";
Use the tools to read, edit and run code. Read files before editing them. Keep answers short.\n\n\
# Working rules\n\
- Inspect with the tools, not scripts: `read` for files, `rg` to search text, `fd` or `find` to list files, `ls`/`tree` for directories.\n\
- Never use node, python, perl, sed or awk to look at files or data; they need user approval every time. Read-only commands (ls cat head tail rg fd find grep wc jq sort, git status/log/diff/show) run without a prompt, also piped into each other.\n\
- One simple command per call: no `;`, `&&`, redirects, `$()`. Those need approval too.\n\
- Script only when the task needs it (build, test, edit), not to explore.";
const CONTEXT_FILES: &[&str] = &["AGENTS.md", "CLAUDE.md"];
@@ -189,6 +194,14 @@ pub fn system_prompt(base: Option<&str>, home: &Path, cwd: &Path) -> String {
mod tests {
use super::*;
#[test]
fn default_prompt_has_working_rules() {
assert!(
DEFAULT_PROMPT.contains("never use node") || DEFAULT_PROMPT.contains("Never use node")
);
assert!(DEFAULT_PROMPT.contains("`rg`"));
}
#[test]
fn prompt_assembly() {
let t = tempfile::tempdir().unwrap();