(MOT-4172) iii-directory: user prompt library backend#564
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe prompt system adds configurable global and local libraries, frontmatter-based kinds and sources, precedence-aware listing and retrieval, plus registered save and delete APIs with validation and filesystem persistence. ChangesPrompt library
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant PromptAPI
participant PromptLibraries
participant WorkerTemplates
Caller->>PromptAPI: list or get prompt
PromptAPI->>PromptLibraries: collect local and global prompts
PromptAPI->>WorkerTemplates: collect shipped templates
PromptLibraries-->>PromptAPI: classified prompt entries
WorkerTemplates-->>PromptAPI: template entries
PromptAPI-->>Caller: precedence-resolved prompt
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
skill-check — worker0 verified, 47 skipped (no docs/).
Four for four. Nicely done. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
iii-directory/src/fs_source.rs (1)
406-511: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffConsider extracting the shared frontmatter-parsing body.
scan_user_promptsduplicates most ofscan_prompts(read →split_frontmatter→serde_yamlparse → name derivation → description validation →kindmapping). The only real differences are thehas_prompts_segmentgate and duplicate-detection. A sharedparse_prompt_entry(abs) -> Result<FsPrompt, SkipReason>helper would keep the two scanners from drifting.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iii-directory/src/fs_source.rs` around lines 406 - 511, Extract the duplicated prompt frontmatter processing from scan_user_prompts and scan_prompts into a shared parse_prompt_entry helper returning Result<FsPrompt, SkipReason>. Keep file reading, frontmatter splitting/parsing, name derivation and validation, description validation, kind mapping, and error construction in the helper; leave has_prompts_segment filtering and scanner-specific duplicate detection in each caller.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iii-directory/src/functions/prompts.rs`:
- Around line 347-353: Update the frontmatter construction in the format! call
to pass req.name through yaml_quote, matching the existing description handling,
so PromptFrontmatter.name always deserializes as a string for names such as
numeric or boolean-looking values.
- Around line 394-396: Update yaml_quote to use a YAML-aware quoting/escaping
implementation instead of Rust’s {:?} formatting and newline replacement. Ensure
all control characters in the input produce valid YAML double-quoted escapes so
description values round-trip safely through frontmatter.
---
Nitpick comments:
In `@iii-directory/src/fs_source.rs`:
- Around line 406-511: Extract the duplicated prompt frontmatter processing from
scan_user_prompts and scan_prompts into a shared parse_prompt_entry helper
returning Result<FsPrompt, SkipReason>. Keep file reading, frontmatter
splitting/parsing, name derivation and validation, description validation, kind
mapping, and error construction in the helper; leave has_prompts_segment
filtering and scanner-specific duplicate detection in each caller.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b8faa56d-cf49-42e5-b1f2-9a0929ad04fe
📒 Files selected for processing (4)
iii-directory/src/config.rsiii-directory/src/fs_source.rsiii-directory/src/functions/mod.rsiii-directory/src/functions/prompts.rs
What
The prompt library backend in the directory worker: named, user-authored prompts stored on disk, listed and fetched next to the worker-shipped templates, writable by agents and operators. Console picker UX comes separately on the injectable-view base; this PR is only the worker surface it needs.
prompts_folder(default~/.iii/prompts) andlocal_prompts_folder(default./.iii/prompts), mirroring the skills folder pair. Local shadows global shadows worker-shipped on name collision.directory::prompts::listnow merges user library entries with worker-shipped templates and tags every row withsource(user|worker) andkind(command|system, from frontmatter, defaultcommand); filterable by both. The kind split keeps slash-style message templates and full system prompts in one store without conflating them.directory::prompts::getresolves through the same precedence and returnskind+sourcealongside the body.directory::prompts::save: name, description, body, kind; omitbodyand setfromto fork an existing prompt under a new name. Atomic write, overwrite allowed (that is the edit path), firesdirectory::prompts::on-change. Agent-callable on purpose: an orchestrator authors a five-line system prompt for a sub-agent, saves it, and spawns children with it through the existing spawnoptions.system_prompt.directory::prompts::delete: requires exactlyyes: true(worker lifecycle convention); refuses worker-shipped templates and project-local files, removes onlyprompts_folderentries. Fires on-change.FsPromptcarries the frontmatterkind; newscan_user_promptsscans a flat library root with the same frontmatter and name rules as shipped prompts, minus the<ns>/prompts/requirement.Why
One override per provider exists today (the router knob), but there is no catalog: switching system prompts means pasting text by hand, and sub-agents have no way to get purpose-built minimal prompts. With the library, a stored
systemprompt applies rig-wide via the router knob, per session via send options, or per child via spawn options, and agents can author prompts as artifacts. Pairs with #558 (minimal core + playbooks) and the eval runner (#563) as the acceptance gate for any prompt that becomes a rig default.Validation
254 lib tests pass (6 new: save/get round-trip with kind and source, fork seeding, kind and body rejection, delete confirmation + scope, local-shadows-global), clippy strict clean. Then live against a running rig (engine 0.21.6) with this build as a second directory worker:
savewrote~/.iii/prompts/blog-writer.mdwith clean frontmatter;getreturnedkind: system,source: user; fork viafromproducedblog-writer-v2; bothdeletes removed exactly the library files.webandstate::set." Minimal single-purpose sub-agent prompts work through existing surfaces with zero harness changes.Notes for review
list/getresponses gained fields only; existing consumers keep working. The MCP worker's prompt picker sees user entries as ordinary prompts.savewrites only the global library; project-local files are hand-managed by design.op+source), so existing subscribers need no changes.Linear
Closes MOT-4172. Part of MOT-4169 and MOT-4157.
Summary by CodeRabbit
New Features
Bug Fixes