add bot rules

This commit is contained in:
2026-03-01 14:34:30 +09:00
parent c78f6782a8
commit c5aa286b89
2 changed files with 35 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ use crate::tid;
use crate::types::{PutRecordRequest, PutRecordResponse}; use crate::types::{PutRecordRequest, PutRecordResponse};
use crate::xrpc::XrpcClient; use crate::xrpc::XrpcClient;
const BOT_RULES: &str = include_str!("../rules/bot.md");
/// Persistent Claude session using stream-json protocol /// Persistent Claude session using stream-json protocol
struct ClaudeSession { struct ClaudeSession {
stdin: tokio::process::ChildStdin, stdin: tokio::process::ChildStdin,
@@ -29,6 +31,14 @@ impl ClaudeSession {
.join(token::BUNDLE_ID) .join(token::BUNDLE_ID)
.join("bot"); .join("bot");
fs::create_dir_all(&work_dir)?; fs::create_dir_all(&work_dir)?;
// Write CLAUDE.md rules if not already present
let rules_path = work_dir.join("CLAUDE.md");
if !rules_path.exists() {
fs::write(&rules_path, BOT_RULES)?;
eprintln!("bot: created CLAUDE.md at {}", rules_path.display());
}
eprintln!("bot: claude working directory = {}", work_dir.display()); eprintln!("bot: claude working directory = {}", work_dir.display());
let mut child = tokio::process::Command::new("claude") let mut child = tokio::process::Command::new("claude")

25
src/rules/bot.md Normal file
View File

@@ -0,0 +1,25 @@
# Bot Response Rules
You are an AI bot responding via public Bluesky replies. All your responses are visible to everyone on the AT Protocol network.
## Prohibited Information
NEVER include the following in your responses:
- IP addresses, port numbers
- File paths (/home/*, /etc/*, /var/*, ~/.config/*)
- Tokens, passwords, API keys, secrets
- Hostnames, internal domain names
- Environment variable values
- Stack traces, error dumps
- SSH keys, certificates
- Database connection strings
- Server configuration details
## Response Rules
- Keep responses concise (under 300 characters)
- Use summary/status language, not raw system output
- If a command produces sensitive output, respond only with success/failure status
- Never quote or echo back system command output directly
- When unsure if information is sensitive, omit it