prompt_objects 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. checksums.yaml +7 -0
  2. data/CLAUDE.md +108 -0
  3. data/Gemfile +10 -0
  4. data/Gemfile.lock +231 -0
  5. data/IMPLEMENTATION_PLAN.md +1073 -0
  6. data/LICENSE +21 -0
  7. data/README.md +73 -0
  8. data/Rakefile +27 -0
  9. data/design-doc-v2.md +1232 -0
  10. data/exe/prompt_objects +572 -0
  11. data/exe/prompt_objects_mcp +34 -0
  12. data/frontend/.gitignore +3 -0
  13. data/frontend/index.html +13 -0
  14. data/frontend/package-lock.json +4417 -0
  15. data/frontend/package.json +32 -0
  16. data/frontend/postcss.config.js +6 -0
  17. data/frontend/src/App.tsx +95 -0
  18. data/frontend/src/components/CapabilitiesPanel.tsx +44 -0
  19. data/frontend/src/components/ChatPanel.tsx +251 -0
  20. data/frontend/src/components/Dashboard.tsx +83 -0
  21. data/frontend/src/components/Header.tsx +141 -0
  22. data/frontend/src/components/MarkdownMessage.tsx +153 -0
  23. data/frontend/src/components/MessageBus.tsx +55 -0
  24. data/frontend/src/components/ModelSelector.tsx +112 -0
  25. data/frontend/src/components/NotificationPanel.tsx +134 -0
  26. data/frontend/src/components/POCard.tsx +56 -0
  27. data/frontend/src/components/PODetail.tsx +117 -0
  28. data/frontend/src/components/PromptPanel.tsx +51 -0
  29. data/frontend/src/components/SessionsPanel.tsx +174 -0
  30. data/frontend/src/components/ThreadsSidebar.tsx +119 -0
  31. data/frontend/src/components/index.ts +11 -0
  32. data/frontend/src/hooks/useWebSocket.ts +363 -0
  33. data/frontend/src/index.css +37 -0
  34. data/frontend/src/main.tsx +10 -0
  35. data/frontend/src/store/index.ts +246 -0
  36. data/frontend/src/types/index.ts +146 -0
  37. data/frontend/tailwind.config.js +25 -0
  38. data/frontend/tsconfig.json +30 -0
  39. data/frontend/vite.config.ts +29 -0
  40. data/lib/prompt_objects/capability.rb +46 -0
  41. data/lib/prompt_objects/cli.rb +431 -0
  42. data/lib/prompt_objects/connectors/base.rb +73 -0
  43. data/lib/prompt_objects/connectors/mcp.rb +524 -0
  44. data/lib/prompt_objects/environment/exporter.rb +83 -0
  45. data/lib/prompt_objects/environment/git.rb +118 -0
  46. data/lib/prompt_objects/environment/importer.rb +159 -0
  47. data/lib/prompt_objects/environment/manager.rb +401 -0
  48. data/lib/prompt_objects/environment/manifest.rb +218 -0
  49. data/lib/prompt_objects/environment.rb +283 -0
  50. data/lib/prompt_objects/human_queue.rb +144 -0
  51. data/lib/prompt_objects/llm/anthropic_adapter.rb +137 -0
  52. data/lib/prompt_objects/llm/factory.rb +84 -0
  53. data/lib/prompt_objects/llm/gemini_adapter.rb +209 -0
  54. data/lib/prompt_objects/llm/openai_adapter.rb +104 -0
  55. data/lib/prompt_objects/llm/response.rb +61 -0
  56. data/lib/prompt_objects/loader.rb +32 -0
  57. data/lib/prompt_objects/mcp/server.rb +167 -0
  58. data/lib/prompt_objects/mcp/tools/get_conversation.rb +60 -0
  59. data/lib/prompt_objects/mcp/tools/get_pending_requests.rb +54 -0
  60. data/lib/prompt_objects/mcp/tools/inspect_po.rb +73 -0
  61. data/lib/prompt_objects/mcp/tools/list_prompt_objects.rb +37 -0
  62. data/lib/prompt_objects/mcp/tools/respond_to_request.rb +68 -0
  63. data/lib/prompt_objects/mcp/tools/send_message.rb +71 -0
  64. data/lib/prompt_objects/message_bus.rb +97 -0
  65. data/lib/prompt_objects/primitive.rb +13 -0
  66. data/lib/prompt_objects/primitives/http_get.rb +72 -0
  67. data/lib/prompt_objects/primitives/list_files.rb +95 -0
  68. data/lib/prompt_objects/primitives/read_file.rb +81 -0
  69. data/lib/prompt_objects/primitives/write_file.rb +73 -0
  70. data/lib/prompt_objects/prompt_object.rb +415 -0
  71. data/lib/prompt_objects/registry.rb +88 -0
  72. data/lib/prompt_objects/server/api/routes.rb +297 -0
  73. data/lib/prompt_objects/server/app.rb +174 -0
  74. data/lib/prompt_objects/server/file_watcher.rb +113 -0
  75. data/lib/prompt_objects/server/public/assets/index-2acS2FYZ.js +77 -0
  76. data/lib/prompt_objects/server/public/assets/index-DXU5uRXQ.css +1 -0
  77. data/lib/prompt_objects/server/public/index.html +14 -0
  78. data/lib/prompt_objects/server/websocket_handler.rb +619 -0
  79. data/lib/prompt_objects/server.rb +166 -0
  80. data/lib/prompt_objects/session/store.rb +826 -0
  81. data/lib/prompt_objects/universal/add_capability.rb +74 -0
  82. data/lib/prompt_objects/universal/add_primitive.rb +113 -0
  83. data/lib/prompt_objects/universal/ask_human.rb +109 -0
  84. data/lib/prompt_objects/universal/create_capability.rb +219 -0
  85. data/lib/prompt_objects/universal/create_primitive.rb +170 -0
  86. data/lib/prompt_objects/universal/list_capabilities.rb +55 -0
  87. data/lib/prompt_objects/universal/list_primitives.rb +145 -0
  88. data/lib/prompt_objects/universal/modify_primitive.rb +180 -0
  89. data/lib/prompt_objects/universal/request_primitive.rb +287 -0
  90. data/lib/prompt_objects/universal/think.rb +41 -0
  91. data/lib/prompt_objects/universal/verify_primitive.rb +173 -0
  92. data/lib/prompt_objects.rb +62 -0
  93. data/objects/coordinator.md +48 -0
  94. data/objects/greeter.md +30 -0
  95. data/objects/reader.md +33 -0
  96. data/prompt_objects.gemspec +50 -0
  97. data/templates/basic/.gitignore +2 -0
  98. data/templates/basic/manifest.yml +7 -0
  99. data/templates/basic/objects/basic.md +32 -0
  100. data/templates/developer/.gitignore +5 -0
  101. data/templates/developer/manifest.yml +17 -0
  102. data/templates/developer/objects/code_reviewer.md +33 -0
  103. data/templates/developer/objects/coordinator.md +39 -0
  104. data/templates/developer/objects/debugger.md +35 -0
  105. data/templates/empty/.gitignore +5 -0
  106. data/templates/empty/manifest.yml +14 -0
  107. data/templates/empty/objects/.gitkeep +0 -0
  108. data/templates/empty/objects/assistant.md +41 -0
  109. data/templates/minimal/.gitignore +5 -0
  110. data/templates/minimal/manifest.yml +7 -0
  111. data/templates/minimal/objects/assistant.md +41 -0
  112. data/templates/writer/.gitignore +5 -0
  113. data/templates/writer/manifest.yml +17 -0
  114. data/templates/writer/objects/coordinator.md +33 -0
  115. data/templates/writer/objects/editor.md +33 -0
  116. data/templates/writer/objects/researcher.md +34 -0
  117. metadata +343 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1ad31b1bb32afdf58701be9b0b163314ce9944a1e2df465f81540e36c5e7aa10
4
+ data.tar.gz: 865fdc2ee3c868cbc48ac86e4034472e71ea12b51a31d99b71bc446a50a45eb9
5
+ SHA512:
6
+ metadata.gz: 1c1cdf27920d51f61ce89feb4df5f7eb8f6d9c37f43ba53c7578d56193fcf9e3016fc465a0d4e4fcac3a74d9c15ac09ecb3031b867f5b04ac155d2e5bb6aeb75
7
+ data.tar.gz: abf9df3fff47f105b8e0b516784712c980a155f0adf1b2fc770f329aabde0144d8f4e4b139627d5cc6d734c1041abfc5dc85fc5e65f6dd4a8d023545e6f1bdcb
data/CLAUDE.md ADDED
@@ -0,0 +1,108 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **PromptObjects** is a Ruby framework where markdown files with LLM-backed behavior act as first-class autonomous entities. The core insight: **everything is a capability**—primitives (Ruby code) and Prompt-Objects (markdown files) share the same interface, differing only in interpretation complexity.
8
+
9
+ **Current Status**: Design phase—`design-doc-v2.md` contains the full specification, `IMPLEMENTATION_PLAN.md` has detailed phased build plans. No implementation code exists yet.
10
+
11
+ ## Architecture
12
+
13
+ ```
14
+ ENVIRONMENT
15
+ ├── CAPABILITY REGISTRY
16
+ │ ├── PRIMITIVES (Ruby) - deterministic interpretation
17
+ │ └── PROMPT-OBJECTS (Markdown) - semantic interpretation via LLM
18
+ ├── MESSAGE BUS - routes messages, logs for visualization
19
+ └── TERMINAL UI (Charm) - capability bar, message log, conversation, input
20
+ ```
21
+
22
+ ### Unified Capability Interface
23
+ Both primitives and Prompt-Objects implement:
24
+ ```ruby
25
+ class Capability
26
+ def name # string identifier
27
+ def description # what this capability does
28
+ def receive(message, context:) # handle message, return response
29
+ end
30
+ ```
31
+
32
+ ### Prompt-Object Structure
33
+ Markdown files with two parts:
34
+ - **Frontmatter (YAML)**: Configuration (name, description, capabilities)
35
+ - **Body (Markdown)**: Identity and behavior (becomes LLM system prompt)
36
+
37
+ Example:
38
+ ```markdown
39
+ ---
40
+ name: reader
41
+ description: Helps people understand files
42
+ capabilities:
43
+ - read_file
44
+ - list_files
45
+ ---
46
+
47
+ # Reader
48
+ ## Identity
49
+ You are a careful, thoughtful file reader...
50
+ ```
51
+
52
+ ### Universal Capabilities
53
+ Available to all Prompt-Objects automatically (no frontmatter declaration needed):
54
+ - `ask_human` - pause for human input/confirmation
55
+ - `think` - internal reasoning (not shown to human)
56
+ - `request_capability` - ask environment for new capability
57
+
58
+ ## Technology Stack
59
+
60
+ - **Ruby** - core implementation
61
+ - **LLM APIs** - OpenAI, Anthropic, Gemini (adapter pattern)
62
+ - **Charm** - Terminal UI (Bubble Tea for interaction, Lipgloss for styling, Glamour for markdown)
63
+ - **MCP** - Model Context Protocol integration
64
+
65
+ ### TUI Architecture Note
66
+
67
+ The TUI uses a **single Bubble Tea program** with internal screen states (picker, wizard, main). Do NOT run multiple sequential `Bubbletea.run` calls—this causes terminal state corruption. See `docs/phase-8-environments.md` for details.
68
+
69
+ ## Planned File Structure
70
+
71
+ ```
72
+ prompt_objects/
73
+ ├── exe/prompt_objects # CLI entrypoint
74
+ ├── lib/
75
+ │ ├── prompt_objects.rb # Main entry
76
+ │ └── prompt_objects/
77
+ │ ├── environment.rb # Runtime container
78
+ │ ├── capability.rb # Base interface
79
+ │ ├── prompt_object.rb # PO implementation
80
+ │ ├── primitive.rb # Primitive tool wrapper
81
+ │ ├── loader.rb # Parses frontmatter + body
82
+ │ ├── registry.rb # Capability registration
83
+ │ ├── message_bus.rb # Message routing and logging
84
+ │ ├── llm/ # LLM adapters
85
+ │ ├── primitives/ # Built-in primitives (read_file, etc.)
86
+ │ ├── universal/ # Universal capabilities
87
+ │ ├── mcp/ # MCP integration
88
+ │ └── ui/ # Charm-based terminal UI
89
+ ├── objects/ # Where Prompt-Objects live (.md files)
90
+ └── primitives/ # Optional user-defined primitives
91
+ ```
92
+
93
+ ## Implementation Phases
94
+
95
+ 1. **Core Loop**: Capability base, PromptObject, Loader, single LLM adapter, simple REPL
96
+ 2. **Primitives & Binding**: Primitive base, built-in primitives, Registry
97
+ 3. **Multi-Capability**: Message bus with logging, PO↔PO communication
98
+ 4. **Self-Modification**: Universal capabilities including create_capability
99
+ 5. **Polish & UI**: Full Charm integration, all UI components
100
+ 6. **Demo Ready**: Error handling, testing, practice runs
101
+
102
+ ## Key Concepts
103
+
104
+ - **Semantic Binding**: Natural language → capability call (visible in message log)
105
+ - **PO↔PO Communication**: Prompt-Objects can call each other as capabilities
106
+ - **Self-Modification**: System can create new Prompt-Objects at runtime (with human approval)
107
+ - **Human-in-the-Loop**: POs ask for confirmation on dangerous actions, clarification when ambiguous
108
+ - **Non-blocking Human Queue**: When POs need human input (`ask_human`), they suspend (via Fibers) and queue a notification. Multiple POs can wait simultaneously. Human responds via notification panel, PO resumes automatically.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in prompt_objects.gemspec
6
+ gemspec
7
+
8
+ # Ruby 3.4+ compatibility - base64 moved out of stdlib
9
+ gem "base64"
10
+
data/Gemfile.lock ADDED
@@ -0,0 +1,231 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ prompt_objects (0.1.0)
5
+ anthropic (~> 1.0)
6
+ async-websocket (~> 0.28)
7
+ falcon (~> 0.50)
8
+ front_matter_parser (~> 1.0)
9
+ listen (~> 3.9)
10
+ mcp (~> 0.4)
11
+ rack (~> 3.0)
12
+ ruby-openai (~> 7.0)
13
+ sqlite3 (~> 2.0)
14
+
15
+ GEM
16
+ remote: https://rubygems.org/
17
+ specs:
18
+ addressable (2.8.8)
19
+ public_suffix (>= 2.0.2, < 8.0)
20
+ anthropic (1.16.3)
21
+ connection_pool
22
+ ast (2.4.3)
23
+ async (2.35.2)
24
+ console (~> 1.29)
25
+ fiber-annotation
26
+ io-event (~> 1.11)
27
+ metrics (~> 0.12)
28
+ traces (~> 0.18)
29
+ async-container (0.27.7)
30
+ async (~> 2.22)
31
+ async-container-supervisor (0.9.2)
32
+ async-service
33
+ io-endpoint
34
+ memory (~> 0.7)
35
+ memory-leak (~> 0.5)
36
+ process-metrics
37
+ async-http (0.94.0)
38
+ async (>= 2.10.2)
39
+ async-pool (~> 0.11)
40
+ io-endpoint (~> 0.14)
41
+ io-stream (~> 0.6)
42
+ metrics (~> 0.12)
43
+ protocol-http (~> 0.58)
44
+ protocol-http1 (~> 0.36)
45
+ protocol-http2 (~> 0.22)
46
+ protocol-url (~> 0.2)
47
+ traces (~> 0.10)
48
+ async-http-cache (0.4.6)
49
+ async-http (~> 0.56)
50
+ async-pool (0.11.1)
51
+ async (>= 2.0)
52
+ async-service (0.16.0)
53
+ async
54
+ async-container (~> 0.16)
55
+ string-format (~> 0.2)
56
+ async-websocket (0.30.0)
57
+ async-http (~> 0.76)
58
+ protocol-http (~> 0.34)
59
+ protocol-rack (~> 0.7)
60
+ protocol-websocket (~> 0.17)
61
+ bake (0.24.1)
62
+ bigdecimal
63
+ samovar (~> 2.1)
64
+ base64 (0.3.0)
65
+ bigdecimal (4.0.1)
66
+ connection_pool (3.0.2)
67
+ console (1.34.2)
68
+ fiber-annotation
69
+ fiber-local (~> 1.1)
70
+ json
71
+ date (3.5.1)
72
+ debug (1.11.1)
73
+ irb (~> 1.10)
74
+ reline (>= 0.3.8)
75
+ erb (6.0.1)
76
+ event_stream_parser (1.0.0)
77
+ falcon (0.53.1)
78
+ async
79
+ async-container (~> 0.20)
80
+ async-container-supervisor (~> 0.6)
81
+ async-http (~> 0.75)
82
+ async-http-cache (~> 0.4)
83
+ async-service (~> 0.16)
84
+ bundler
85
+ localhost (~> 1.1)
86
+ openssl (>= 3.0)
87
+ protocol-http (~> 0.31)
88
+ protocol-rack (~> 0.7)
89
+ samovar (~> 2.3)
90
+ faraday (2.14.0)
91
+ faraday-net_http (>= 2.0, < 3.5)
92
+ json
93
+ logger
94
+ faraday-multipart (1.2.0)
95
+ multipart-post (~> 2.0)
96
+ faraday-net_http (3.4.2)
97
+ net-http (~> 0.5)
98
+ ffi (1.17.3-arm64-darwin)
99
+ ffi (1.17.3-x86_64-linux-gnu)
100
+ fiber-annotation (0.2.0)
101
+ fiber-local (1.1.0)
102
+ fiber-storage
103
+ fiber-storage (1.0.1)
104
+ front_matter_parser (1.0.1)
105
+ io-console (0.8.2)
106
+ io-endpoint (0.16.0)
107
+ io-event (1.14.2)
108
+ io-stream (0.11.1)
109
+ irb (1.16.0)
110
+ pp (>= 0.6.0)
111
+ rdoc (>= 4.0.0)
112
+ reline (>= 0.4.2)
113
+ json (2.18.0)
114
+ json-schema (6.1.0)
115
+ addressable (~> 2.8)
116
+ bigdecimal (>= 3.1, < 5)
117
+ json_rpc_handler (0.1.1)
118
+ language_server-protocol (3.17.0.5)
119
+ lint_roller (1.1.0)
120
+ listen (3.9.0)
121
+ rb-fsevent (~> 0.10, >= 0.10.3)
122
+ rb-inotify (~> 0.9, >= 0.9.10)
123
+ localhost (1.6.0)
124
+ logger (1.7.0)
125
+ mapping (1.1.3)
126
+ mcp (0.4.0)
127
+ json-schema (>= 4.1)
128
+ json_rpc_handler (~> 0.1)
129
+ memory (0.12.0)
130
+ bake (~> 0.15)
131
+ console
132
+ msgpack
133
+ memory-leak (0.7.0)
134
+ metrics (0.15.0)
135
+ minitest (5.27.0)
136
+ msgpack (1.8.0)
137
+ multipart-post (2.4.1)
138
+ net-http (0.9.1)
139
+ uri (>= 0.11.1)
140
+ openssl (4.0.0)
141
+ parallel (1.27.0)
142
+ parser (3.3.10.0)
143
+ ast (~> 2.4.1)
144
+ racc
145
+ pp (0.6.3)
146
+ prettyprint
147
+ prettyprint (0.2.0)
148
+ prism (1.7.0)
149
+ process-metrics (0.8.0)
150
+ console (~> 1.8)
151
+ json (~> 2)
152
+ samovar (~> 2.1)
153
+ protocol-hpack (1.5.1)
154
+ protocol-http (0.58.0)
155
+ protocol-http1 (0.36.0)
156
+ protocol-http (~> 0.58)
157
+ protocol-http2 (0.23.0)
158
+ protocol-hpack (~> 1.4)
159
+ protocol-http (~> 0.47)
160
+ protocol-rack (0.21.0)
161
+ io-stream (>= 0.10)
162
+ protocol-http (~> 0.58)
163
+ rack (>= 1.0)
164
+ protocol-url (0.4.0)
165
+ protocol-websocket (0.20.2)
166
+ protocol-http (~> 0.2)
167
+ psych (5.3.1)
168
+ date
169
+ stringio
170
+ public_suffix (7.0.1)
171
+ racc (1.8.1)
172
+ rack (3.2.4)
173
+ rainbow (3.1.1)
174
+ rake (13.3.1)
175
+ rb-fsevent (0.11.2)
176
+ rb-inotify (0.11.1)
177
+ ffi (~> 1.0)
178
+ rdoc (7.0.3)
179
+ erb
180
+ psych (>= 4.0.0)
181
+ tsort
182
+ regexp_parser (2.11.3)
183
+ reline (0.6.3)
184
+ io-console (~> 0.5)
185
+ rubocop (1.82.1)
186
+ json (~> 2.3)
187
+ language_server-protocol (~> 3.17.0.2)
188
+ lint_roller (~> 1.1.0)
189
+ parallel (~> 1.10)
190
+ parser (>= 3.3.0.2)
191
+ rainbow (>= 2.2.2, < 4.0)
192
+ regexp_parser (>= 2.9.3, < 3.0)
193
+ rubocop-ast (>= 1.48.0, < 2.0)
194
+ ruby-progressbar (~> 1.7)
195
+ unicode-display_width (>= 2.4.0, < 4.0)
196
+ rubocop-ast (1.49.0)
197
+ parser (>= 3.3.7.2)
198
+ prism (~> 1.7)
199
+ ruby-openai (7.4.0)
200
+ event_stream_parser (>= 0.3.0, < 2.0.0)
201
+ faraday (>= 1)
202
+ faraday-multipart (>= 1)
203
+ ruby-progressbar (1.13.0)
204
+ samovar (2.4.1)
205
+ console (~> 1.0)
206
+ mapping (~> 1.0)
207
+ sqlite3 (2.9.0-arm64-darwin)
208
+ sqlite3 (2.9.0-x86_64-linux-gnu)
209
+ string-format (0.2.0)
210
+ stringio (3.2.0)
211
+ traces (0.18.2)
212
+ tsort (0.2.0)
213
+ unicode-display_width (3.2.0)
214
+ unicode-emoji (~> 4.1)
215
+ unicode-emoji (4.2.0)
216
+ uri (1.1.1)
217
+
218
+ PLATFORMS
219
+ arm64-darwin-24
220
+ x86_64-linux
221
+
222
+ DEPENDENCIES
223
+ base64
224
+ debug (~> 1.0)
225
+ minitest (~> 5.0)
226
+ prompt_objects!
227
+ rake (~> 13.0)
228
+ rubocop (~> 1.50)
229
+
230
+ BUNDLED WITH
231
+ 2.7.2