How wildberry-source/open-repoprompt works
Project Type and Purpose
• OpenPrompt is a command-line tool (with a terminal UI) that:
• Scans a local directory tree
• Applies include/exclude filters
• Presents a checkbox-style file selector
• Generates an XML “prompt” of the selected files
• Copies that XML to the OS clipboard
• Enables pasting into any LLM interface
• It’s a modular monolith: a single binary composed of internal packages.
File Structure
• Entry Point: cmd/main.go
• Internal Packages:
• fileutils: recursively read directories, handle include/exclude filters
• preferences: persist/set user preferences (e.g. “last-used filters”)
• prompt: assemble the XML structure, serialize file contents
• prompt/clipboard.go: abstract OS clipboard operations
• ui: terminal UI components (app orchestration, filetree widget)
• Tooling & CI:
• build.sh: local build script
• .github/workflows/release.yml: automated build & release pipeline
• go.mod/go.sum: dependency management
Key README Insights
• Fastest Serialization into XML
• Workflow: Select Dir → Set Filters → Select Files → Add Instructions → Generate & Copy
• External interactions: OS clipboard, target LLM via manual paste
Main Components
a. CLI Entrypoint (cmd/main.go)
b. Terminal UI Layer (internal/ui)
– App orchestrator
– Filetree widget
c. File System Scanner (internal/fileutils)
d. Preferences Manager (internal/preferences)
e. Prompt Generator (internal/prompt)
– XML builder
– Clipboard service
f. Operating System (File System, Clipboard)
g. Developer/User (drives the CLI; pastes into LLM)
Relationships & Data Flow
1. User invokes OpenPrompt via CLI → cmd/main.go
2. Main loads Preferences
↔ internal/preferences
3. UI Layer queries File System Scanner
→ internal/fileutils reads disk
4. UI presents directory tree & filters
↔ internal/ui
5. User selects files & enters instructions
→ internal/ui
6. UI calls Prompt Generator
→ internal/prompt assembles XML
7. Prompt Generator writes to OS Clipboard
→ clipboard.go → OS
8. User pastes XML into target LLM UI
Architectural Patterns & Principles
• Modular Monolith: clearly delineated packages, no cross-dependencies back into cmd
• Layered design:
• Presentation (ui)
• Business logic (fileutils, preferences, prompt)
• Infrastructure (clipboard, file system)
• Single Responsibility per package; DI via simple function calls
Checklist
[ ] Clear labels on every component