@metabob/minibob 0.1.2

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 (174) hide show
  1. package/ARCHITECTURE.md +255 -0
  2. package/CHANGELOG.md +112 -0
  3. package/README.md +380 -0
  4. package/bin/minibob.js +36 -0
  5. package/dist/acp-gossip.d.ts +72 -0
  6. package/dist/acp-gossip.d.ts.map +1 -0
  7. package/dist/acp-gossip.js +156 -0
  8. package/dist/acp-gossip.js.map +1 -0
  9. package/dist/acp.d.ts +62 -0
  10. package/dist/acp.d.ts.map +1 -0
  11. package/dist/acp.js +292 -0
  12. package/dist/acp.js.map +1 -0
  13. package/dist/activity.d.ts +157 -0
  14. package/dist/activity.d.ts.map +1 -0
  15. package/dist/activity.js +518 -0
  16. package/dist/activity.js.map +1 -0
  17. package/dist/agent-runtime.d.ts +104 -0
  18. package/dist/agent-runtime.d.ts.map +1 -0
  19. package/dist/boredom.d.ts +125 -0
  20. package/dist/boredom.d.ts.map +1 -0
  21. package/dist/boredom.js +244 -0
  22. package/dist/boredom.js.map +1 -0
  23. package/dist/cli/acp-server.d.ts +23 -0
  24. package/dist/cli/acp-server.d.ts.map +1 -0
  25. package/dist/cli/burrow.d.ts +26 -0
  26. package/dist/cli/burrow.d.ts.map +1 -0
  27. package/dist/cli/doctor.d.ts +22 -0
  28. package/dist/cli/doctor.d.ts.map +1 -0
  29. package/dist/cli/goal.d.ts +22 -0
  30. package/dist/cli/goal.d.ts.map +1 -0
  31. package/dist/cli/index.d.ts +47 -0
  32. package/dist/cli/index.d.ts.map +1 -0
  33. package/dist/cli/instance-registry.d.ts +78 -0
  34. package/dist/cli/instance-registry.d.ts.map +1 -0
  35. package/dist/cli/observe.d.ts +35 -0
  36. package/dist/cli/observe.d.ts.map +1 -0
  37. package/dist/cli/vessel.d.ts +14 -0
  38. package/dist/cli/vessel.d.ts.map +1 -0
  39. package/dist/composition-observer.d.ts +96 -0
  40. package/dist/composition-observer.d.ts.map +1 -0
  41. package/dist/config.d.ts +36 -0
  42. package/dist/config.d.ts.map +1 -0
  43. package/dist/config.js +128 -0
  44. package/dist/config.js.map +1 -0
  45. package/dist/docker/Dockerfile +35 -0
  46. package/dist/environment.d.ts +72 -0
  47. package/dist/environment.d.ts.map +1 -0
  48. package/dist/environment.js +142 -0
  49. package/dist/environment.js.map +1 -0
  50. package/dist/goal-processor.d.ts +165 -0
  51. package/dist/goal-processor.d.ts.map +1 -0
  52. package/dist/helm/minibob-cluster/Chart.yaml +13 -0
  53. package/dist/helm/minibob-cluster/templates/_helpers.tpl +60 -0
  54. package/dist/helm/minibob-cluster/templates/configmap.yaml +11 -0
  55. package/dist/helm/minibob-cluster/templates/deployment.yaml +108 -0
  56. package/dist/helm/minibob-cluster/templates/secret.yaml +10 -0
  57. package/dist/helm/minibob-cluster/templates/service.yaml +37 -0
  58. package/dist/helm/minibob-cluster/values-local.yaml +41 -0
  59. package/dist/helm/minibob-cluster/values-production.yaml +57 -0
  60. package/dist/helm/minibob-cluster/values-testing-cluster.yaml +43 -0
  61. package/dist/helm/minibob-cluster/values.yaml +127 -0
  62. package/dist/improviser.d.ts +74 -0
  63. package/dist/improviser.d.ts.map +1 -0
  64. package/dist/impulse-filter.d.ts +74 -0
  65. package/dist/impulse-filter.d.ts.map +1 -0
  66. package/dist/impulse.d.ts +92 -0
  67. package/dist/impulse.d.ts.map +1 -0
  68. package/dist/impulse.js +234 -0
  69. package/dist/impulse.js.map +1 -0
  70. package/dist/lib.d.ts +29 -0
  71. package/dist/lib.d.ts.map +1 -0
  72. package/dist/lib.js +18561 -0
  73. package/dist/lib.js.map +98 -0
  74. package/dist/lifecycle-hooks.d.ts +99 -0
  75. package/dist/lifecycle-hooks.d.ts.map +1 -0
  76. package/dist/lifecycle-hooks.js +135 -0
  77. package/dist/lifecycle-hooks.js.map +1 -0
  78. package/dist/llm.d.ts +31 -0
  79. package/dist/llm.d.ts.map +1 -0
  80. package/dist/llm.js +349 -0
  81. package/dist/llm.js.map +1 -0
  82. package/dist/mcp-activity-bridge.d.ts +66 -0
  83. package/dist/mcp-activity-bridge.d.ts.map +1 -0
  84. package/dist/mcp-activity-bridge.js +126 -0
  85. package/dist/mcp-activity-bridge.js.map +1 -0
  86. package/dist/mcp.d.ts +216 -0
  87. package/dist/mcp.d.ts.map +1 -0
  88. package/dist/mcp.js +292 -0
  89. package/dist/mcp.js.map +1 -0
  90. package/dist/memory-agent.d.ts +92 -0
  91. package/dist/memory-agent.d.ts.map +1 -0
  92. package/dist/memory-agent.js +277 -0
  93. package/dist/memory-agent.js.map +1 -0
  94. package/dist/runtime-mapping.d.ts +97 -0
  95. package/dist/runtime-mapping.d.ts.map +1 -0
  96. package/dist/search-first-executor.d.ts +113 -0
  97. package/dist/search-first-executor.d.ts.map +1 -0
  98. package/dist/session.d.ts +48 -0
  99. package/dist/session.d.ts.map +1 -0
  100. package/dist/template-extractor.d.ts +9 -0
  101. package/dist/template-extractor.d.ts.map +1 -0
  102. package/dist/template-generator.d.ts +12 -0
  103. package/dist/template-generator.d.ts.map +1 -0
  104. package/dist/tools.d.ts +58 -0
  105. package/dist/tools.d.ts.map +1 -0
  106. package/dist/tools.js +771 -0
  107. package/dist/tools.js.map +1 -0
  108. package/dist/types.d.ts +503 -0
  109. package/dist/types.d.ts.map +1 -0
  110. package/dist/types.js +8 -0
  111. package/dist/types.js.map +1 -0
  112. package/dist/understanding/analyzer.d.ts +55 -0
  113. package/dist/understanding/analyzer.d.ts.map +1 -0
  114. package/dist/understanding/explorer.d.ts +73 -0
  115. package/dist/understanding/explorer.d.ts.map +1 -0
  116. package/dist/understanding/index.d.ts +7 -0
  117. package/dist/understanding/index.d.ts.map +1 -0
  118. package/dist/understanding/types.d.ts +136 -0
  119. package/dist/understanding/types.d.ts.map +1 -0
  120. package/dist/validation.d.ts +29 -0
  121. package/dist/validation.d.ts.map +1 -0
  122. package/dist/validation.js +106 -0
  123. package/dist/validation.js.map +1 -0
  124. package/dist/vessel-bootstrap.d.ts +190 -0
  125. package/dist/vessel-bootstrap.d.ts.map +1 -0
  126. package/dist/vessel-registry.d.ts +229 -0
  127. package/dist/vessel-registry.d.ts.map +1 -0
  128. package/index.ts +1329 -0
  129. package/package.json +54 -0
  130. package/src/acp-gossip.ts +193 -0
  131. package/src/acp.ts +362 -0
  132. package/src/activity.ts +1464 -0
  133. package/src/agent-runtime.ts +365 -0
  134. package/src/boredom.ts +423 -0
  135. package/src/cli/acp-server.ts +377 -0
  136. package/src/cli/burrow.ts +896 -0
  137. package/src/cli/doctor.ts +526 -0
  138. package/src/cli/goal.ts +224 -0
  139. package/src/cli/index.ts +147 -0
  140. package/src/cli/instance-registry.ts +271 -0
  141. package/src/cli/observe.ts +682 -0
  142. package/src/cli/vessel.ts +287 -0
  143. package/src/components/SystemOverview.tsx +331 -0
  144. package/src/composition-observer.ts +449 -0
  145. package/src/config.ts +172 -0
  146. package/src/environment.ts +167 -0
  147. package/src/goal-processor.ts +654 -0
  148. package/src/improviser.ts +591 -0
  149. package/src/impulse-filter.ts +273 -0
  150. package/src/impulse.ts +311 -0
  151. package/src/lib.ts +147 -0
  152. package/src/lifecycle-hooks.ts +181 -0
  153. package/src/llm.ts +434 -0
  154. package/src/mcp-activity-bridge.ts +158 -0
  155. package/src/mcp.ts +747 -0
  156. package/src/memory-agent.ts +316 -0
  157. package/src/runtime-mapping.ts +527 -0
  158. package/src/search-first-executor.ts +666 -0
  159. package/src/session.ts +141 -0
  160. package/src/template-extractor.ts +256 -0
  161. package/src/template-generator.ts +130 -0
  162. package/src/tools.ts +924 -0
  163. package/src/types.ts +497 -0
  164. package/src/understanding/analyzer.ts +354 -0
  165. package/src/understanding/explorer.ts +488 -0
  166. package/src/understanding/index.ts +27 -0
  167. package/src/understanding/types.ts +153 -0
  168. package/src/validation.ts +125 -0
  169. package/src/vessel-bootstrap.ts +440 -0
  170. package/src/vessel-registry.ts +621 -0
  171. package/templates/core/edit-file.json +85 -0
  172. package/templates/understanding/diagnose-problem.json +32 -0
  173. package/templates/understanding/explore-codebase-v2.json +57 -0
  174. package/templates/understanding/explore-codebase.json +37 -0
package/src/lib.ts ADDED
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @metabob/minibob - Library Entry Point
3
+ *
4
+ * Public API for using minibob as a library (not CLI).
5
+ * Import this when using minibob from other applications like metabob-opencode.
6
+ *
7
+ * Example:
8
+ * import { ActivityExecutor, ImpulseStore } from "@metabob/minibob"
9
+ */
10
+
11
+ // =============================================================================
12
+ // ACTIVITY EXECUTION
13
+ // =============================================================================
14
+
15
+ export { ActivityExecutor, loadTemplate, loadTemplateFromMCPOrLocal } from "./activity"
16
+ export type { ExecutorConfig, ExecuteOptions } from "./activity"
17
+
18
+ // =============================================================================
19
+ // IMPULSE SYSTEM
20
+ // =============================================================================
21
+
22
+ export {
23
+ createImpulse,
24
+ loadImpulses,
25
+ formatImpulsesForContext,
26
+ storeActivityOutput,
27
+ getImpulseStore,
28
+ } from "./impulse"
29
+
30
+ // =============================================================================
31
+ // SESSION TRACKING
32
+ // =============================================================================
33
+
34
+ export {
35
+ createSession,
36
+ getSession,
37
+ recordExecution,
38
+ completeSession,
39
+ getActiveSessions,
40
+ clearSessions,
41
+ } from "./session"
42
+ export type { SessionTracker, SessionExecutionItem } from "./session"
43
+
44
+ // =============================================================================
45
+ // MCP CLIENT
46
+ // =============================================================================
47
+
48
+ export { initializeMCP, getMCPClient, isMCPEnabled, MCPClient } from "./mcp"
49
+ export type { MCPConfig } from "./mcp"
50
+
51
+ // =============================================================================
52
+ // TOOLS
53
+ // =============================================================================
54
+
55
+ export { createToolHandlers, getAllToolDefinitions } from "./tools"
56
+ export type { ToolHandlerOptions, ToolDefinition } from "./tools"
57
+
58
+ // =============================================================================
59
+ // TYPES
60
+ // =============================================================================
61
+
62
+ export type {
63
+ ActivityTemplate,
64
+ ActivityExecution,
65
+ ActivityTask,
66
+ TaskResult,
67
+ Impulse,
68
+ ImpulsePointer,
69
+ Message,
70
+ ToolHandler,
71
+ ToolResult,
72
+ } from "./types"
73
+
74
+ // =============================================================================
75
+ // ACP PROTOCOL (for vessel-to-vessel communication)
76
+ // =============================================================================
77
+
78
+ export { handleACPRequest } from "./acp"
79
+ export type { ACPServerConfig } from "./acp"
80
+
81
+ // =============================================================================
82
+ // BOREDOM SYSTEM (background task execution)
83
+ // =============================================================================
84
+
85
+ export {
86
+ initializeBoredom,
87
+ startBoredom,
88
+ markBoredomActivity,
89
+ type BoredomExecutorConfig,
90
+ type BoredomTask,
91
+ type BoredomTaskResult,
92
+ } from "./boredom"
93
+
94
+ // =============================================================================
95
+ // SEARCH-FIRST EXECUTION (goal decomposition with activity reuse)
96
+ // =============================================================================
97
+ // Temporarily disabled due to TypeScript strict mode issues
98
+ // TODO: Fix type errors in search-first-executor module
99
+ // export {
100
+ // SearchFirstExecutor,
101
+ // type SearchFirstConfig,
102
+ // type GoalStep,
103
+ // type StepResult,
104
+ // } from "./search-first-executor"
105
+
106
+ // =============================================================================
107
+ // SESSION MEMORY AGENT
108
+ // =============================================================================
109
+
110
+ export { SessionMemoryAgent } from "./memory-agent"
111
+
112
+ // =============================================================================
113
+ // LIFECYCLE HOOKS
114
+ // =============================================================================
115
+
116
+ export { LifecycleHooks } from "./lifecycle-hooks"
117
+
118
+ // =============================================================================
119
+ // GOAL PROCESSOR (goal-driven execution)
120
+ // =============================================================================
121
+
122
+ export { GoalProcessor } from "./goal-processor"
123
+ export type { Goal, ActivityRecommendation, GoalResult } from "./goal-processor"
124
+
125
+ // =============================================================================
126
+ // CONFIGURATION
127
+ // =============================================================================
128
+
129
+ export { loadConfig, generateManifest, configSummary } from "./config"
130
+ export type { RuntimeContext } from "./config"
131
+
132
+ // =============================================================================
133
+ // UNDERSTANDING (application analysis and comprehension)
134
+ // =============================================================================
135
+ // Temporarily disabled due to TypeScript strict mode issues
136
+ // TODO: Fix type errors in understanding module
137
+ // export { CodeExplorer, ApplicationAnalyzer } from "./understanding"
138
+ // export type {
139
+ // CodeStructure,
140
+ // DirectoryNode,
141
+ // Dependencies,
142
+ // FileAnalysis,
143
+ // AnalyzeOptions,
144
+ // Analysis,
145
+ // Diagnosis,
146
+ // Pattern
147
+ // } from "./understanding"
@@ -0,0 +1,181 @@
1
+ /**
2
+ * LifecycleHooks - Execution lifecycle management for activities
3
+ *
4
+ * Moved from metabob-opencode to minibob as part of library integration.
5
+ * Simplified version for minibob's use case.
6
+ *
7
+ * Provides hooks for:
8
+ * - Pre-prompt: Run before each task (e.g., SessionMemoryAgent)
9
+ * - Post-prompt: Run after each task (e.g., cleanup, logging)
10
+ * - Activity complete: Run when activity finishes
11
+ */
12
+
13
+ import type { ActivityExecution, TaskResult } from "./types"
14
+
15
+ export namespace LifecycleHooks {
16
+ /**
17
+ * Hook execution context
18
+ */
19
+ export interface ActivityContext {
20
+ activityId: string
21
+ templateId: string
22
+ variables: Record<string, unknown>
23
+ reason?: string
24
+ }
25
+
26
+ export interface TaskContext extends ActivityContext {
27
+ taskId: string
28
+ taskDescription: string
29
+ prompt: string
30
+ }
31
+
32
+ /**
33
+ * Hook definitions
34
+ */
35
+ export interface Hooks {
36
+ /**
37
+ * Run before each task prompt is sent to LLM
38
+ * Use case: Prepare context, load impulses, analyze intent
39
+ */
40
+ onBeforePrompt?: (context: TaskContext) => Promise<void>
41
+
42
+ /**
43
+ * Run after each task completes
44
+ * Use case: Cleanup, logging, metrics
45
+ */
46
+ onAfterPrompt?: (context: TaskContext, result: TaskResult) => Promise<void>
47
+
48
+ /**
49
+ * Run when activity execution completes
50
+ * Use case: Final cleanup, reporting, notifications
51
+ */
52
+ onActivityComplete?: (execution: ActivityExecution) => Promise<void>
53
+
54
+ /**
55
+ * Run when activity execution fails
56
+ * Use case: Error handling, rollback, notifications
57
+ */
58
+ onActivityFailed?: (execution: ActivityExecution, error: Error) => Promise<void>
59
+ }
60
+
61
+ /**
62
+ * Registered hooks
63
+ */
64
+ let registeredHooks: Hooks = {}
65
+
66
+ /**
67
+ * Register lifecycle hooks
68
+ *
69
+ * Example:
70
+ * ```ts
71
+ * LifecycleHooks.register({
72
+ * onBeforePrompt: async (context) => {
73
+ * // Prepare context with SessionMemoryAgent
74
+ * const intent = await SessionMemoryAgent.analyzeIntent({
75
+ * promptText: context.prompt,
76
+ * })
77
+ * await SessionMemoryAgent.prepare({ intent })
78
+ * },
79
+ * onActivityComplete: async (execution) => {
80
+ * console.log(`Activity ${execution.id} completed in ${execution.metrics?.duration}ms`)
81
+ * }
82
+ * })
83
+ * ```
84
+ */
85
+ export function register(hooks: Hooks): void {
86
+ registeredHooks = { ...registeredHooks, ...hooks }
87
+ console.log("[LifecycleHooks] Registered hooks:", Object.keys(hooks))
88
+ }
89
+
90
+ /**
91
+ * Clear all registered hooks
92
+ * Useful for testing
93
+ */
94
+ export function clear(): void {
95
+ registeredHooks = {}
96
+ console.log("[LifecycleHooks] All hooks cleared")
97
+ }
98
+
99
+ /**
100
+ * Execute onBeforePrompt hook
101
+ */
102
+ export async function executeBeforePrompt(context: TaskContext): Promise<void> {
103
+ if (!registeredHooks.onBeforePrompt) {
104
+ return
105
+ }
106
+
107
+ try {
108
+ await registeredHooks.onBeforePrompt(context)
109
+ } catch (error) {
110
+ console.warn("[LifecycleHooks] onBeforePrompt hook failed (non-blocking):", {
111
+ error: error instanceof Error ? error.message : String(error),
112
+ taskId: context.taskId,
113
+ })
114
+ // Non-blocking: Continue execution even if hook fails
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Execute onAfterPrompt hook
120
+ */
121
+ export async function executeAfterPrompt(context: TaskContext, result: TaskResult): Promise<void> {
122
+ if (!registeredHooks.onAfterPrompt) {
123
+ return
124
+ }
125
+
126
+ try {
127
+ await registeredHooks.onAfterPrompt(context, result)
128
+ } catch (error) {
129
+ console.warn("[LifecycleHooks] onAfterPrompt hook failed (non-blocking):", {
130
+ error: error instanceof Error ? error.message : String(error),
131
+ taskId: context.taskId,
132
+ })
133
+ // Non-blocking: Continue execution even if hook fails
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Execute onActivityComplete hook
139
+ */
140
+ export async function executeActivityComplete(execution: ActivityExecution): Promise<void> {
141
+ if (!registeredHooks.onActivityComplete) {
142
+ return
143
+ }
144
+
145
+ try {
146
+ await registeredHooks.onActivityComplete(execution)
147
+ } catch (error) {
148
+ console.warn("[LifecycleHooks] onActivityComplete hook failed (non-blocking):", {
149
+ error: error instanceof Error ? error.message : String(error),
150
+ activityId: execution.id,
151
+ })
152
+ // Non-blocking
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Execute onActivityFailed hook
158
+ */
159
+ export async function executeActivityFailed(execution: ActivityExecution, activityError: Error): Promise<void> {
160
+ if (!registeredHooks.onActivityFailed) {
161
+ return
162
+ }
163
+
164
+ try {
165
+ await registeredHooks.onActivityFailed(execution, activityError)
166
+ } catch (error) {
167
+ console.warn("[LifecycleHooks] onActivityFailed hook failed (non-blocking):", {
168
+ error: error instanceof Error ? error.message : String(error),
169
+ activityId: execution.id,
170
+ })
171
+ // Non-blocking
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Get currently registered hooks (for inspection/testing)
177
+ */
178
+ export function getRegistered(): Readonly<Hooks> {
179
+ return registeredHooks
180
+ }
181
+ }