Skip to content

(MOT-4172) feat(iii-directory): prompt library backend + injectable directory UI - #564

Open
rohitg00 wants to merge 1 commit into
mainfrom
directory-prompt-library
Open

(MOT-4172) feat(iii-directory): prompt library backend + injectable directory UI#564
rohitg00 wants to merge 1 commit into
mainfrom
directory-prompt-library

Conversation

@rohitg00

@rohitg00 rohitg00 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What

The directory worker's prompt surface becomes a full library on the injectable-view base.

Backend (folds in the prompt-library work):

  • directory::prompts::save and directory::prompts::delete.
  • kind (command | system) and source (worker | user) on list / get, filterable by both.
  • prompts_folder / local_prompts_folder config, mirroring the skills folders.
  • delete requires yes: true and refuses worker-shipped templates and project-local files.

Injectable UI (the directory page's prompts tab):

  • Lists worker-shipped and user entries with kind and source badges.
  • Create, edit, fork, and delete user entries via the backend; worker-shipped templates render read-only.
  • Monaco body editor, live-refresh on directory::prompts::on-change. The skills tab is unchanged.

Verification

  • cargo build / fmt / clippy clean; 266 lib/bin tests pass.
  • Injectable UI: tsc + esbuild build + biome clean.
  • Live on a running rig: swapped the worker in, then save -> list (source user, kind system) -> get (body round-trips) -> delete (yes: true) -> gone. The prompts tab renders the library with badges and the create/fork/delete editor.

Notes

Console-side prompt selection (composer picker + slash-command prompts) ships separately in #565.

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jul 27, 2026 1:42pm
workers-tech-spec Ready Ready Preview, Comment Jul 27, 2026 1:42pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Prompt library

Layer / File(s) Summary
Prompt roots and metadata
iii-directory/src/config.rs, iii-directory/src/fs_source.rs
Configurable global/local prompt folders are added, and shared filesystem parsing captures trimmed optional kind frontmatter.
Prompt API contracts and registration
iii-directory/src/functions/prompts.rs, iii-directory/src/functions/mod.rs
Prompt list/get models gain metadata and body fields, save/delete types and endpoints are added, and subscriber wiring is updated.
Prompt resolution and mutations
iii-directory/src/functions/prompts.rs
Prompt collection applies local, global, and worker precedence; get returns enriched content, save writes validated atomic markdown, and delete requires confirmation.
Prompt behavior validation
iii-directory/src/functions/prompts.rs
Temporary configurations and integration tests cover roundtrips, forking, validation failures, deletion, and precedence.

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
Loading

Suggested reviewers: andersonleal, sergiofilhowz

Poem

A bunny now saves prompts with care,
In local and global folders there.
Kinds and sources hop in line,
Forks and deletes behave just fine.
“Precedence!” sings the hare.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title matches the prompt library backend work, but the "injectable directory UI" part is misleading because no UI changes are shown. Retitle it to reflect the actual scope, e.g. "(MOT-4172) feat(iii-directory): prompt library backend".
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch directory-prompt-library

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 49 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
iii-directory/src/fs_source.rs (1)

406-511: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Consider extracting the shared frontmatter-parsing body.

scan_user_prompts duplicates most of scan_prompts (read → split_frontmatterserde_yaml parse → name derivation → description validation → kind mapping). The only real differences are the has_prompts_segment gate and duplicate-detection. A shared parse_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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ff0617 and 6682500.

📒 Files selected for processing (4)
  • iii-directory/src/config.rs
  • iii-directory/src/fs_source.rs
  • iii-directory/src/functions/mod.rs
  • iii-directory/src/functions/prompts.rs

Comment thread iii-directory/src/functions/prompts.rs Outdated
Comment thread iii-directory/src/functions/prompts.rs Outdated
The directory worker's prompt surface becomes a real library on the
injectable-view base:

- backend (folded from the prompt-library branch): directory::prompts::save
  and ::delete, kind (command|system) + source (worker|user) on list/get,
  prompts_folder config.
- injectable UI: the prompts tab lists worker-shipped and user entries with
  kind + source badges; create, edit, fork, and delete via save/delete;
  worker-shipped templates render read-only. The skills tab is unchanged.

Console-side prompt selection (composer picker, slash commands) ships as a
separate console PR; this change is directory-only.
@rohitg00
rohitg00 force-pushed the directory-prompt-library branch from 562f083 to 08ab1a7 Compare July 27, 2026 13:41
@rohitg00 rohitg00 changed the title (MOT-4172) iii-directory: user prompt library backend (MOT-4172) feat(iii-directory): prompt library backend + injectable directory UI Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant