@plures/runebook 0.4.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 (148) hide show
  1. package/ANALYSIS_LADDER.md +231 -0
  2. package/CHANGELOG.md +124 -0
  3. package/INTEGRATIONS.md +242 -0
  4. package/LICENSE +21 -0
  5. package/MEMORY.md +253 -0
  6. package/NIXOS.md +357 -0
  7. package/QUICKSTART.md +157 -0
  8. package/README.md +295 -0
  9. package/RELEASE.md +190 -0
  10. package/ValidationChecklist.md +598 -0
  11. package/docs/demo.md +338 -0
  12. package/docs/llm-integration.md +300 -0
  13. package/docs/parallel-execution-plan.md +160 -0
  14. package/flake.nix +228 -0
  15. package/integrations/README.md +242 -0
  16. package/integrations/demo-steps.sh +64 -0
  17. package/integrations/nvim-runebook.lua +140 -0
  18. package/integrations/tmux-status.sh +51 -0
  19. package/integrations/vim-runebook.vim +77 -0
  20. package/integrations/wezterm-status-simple.lua +48 -0
  21. package/integrations/wezterm-status.lua +76 -0
  22. package/nixos-module.nix +156 -0
  23. package/package.json +76 -0
  24. package/packages/design-dojo/index.js +4 -0
  25. package/packages/design-dojo/package.json +20 -0
  26. package/packages/design-dojo/tokens.css +69 -0
  27. package/playwright.config.ts +16 -0
  28. package/scripts/check-versions.cjs +62 -0
  29. package/scripts/demo.sh +220 -0
  30. package/shell.nix +31 -0
  31. package/src/app.html +13 -0
  32. package/src/cli/index.ts +1050 -0
  33. package/src/lib/agent/analysis-pipeline.ts +347 -0
  34. package/src/lib/agent/analysis-service.ts +171 -0
  35. package/src/lib/agent/analysis.ts +159 -0
  36. package/src/lib/agent/analyzers/heuristic.ts +289 -0
  37. package/src/lib/agent/analyzers/index.ts +7 -0
  38. package/src/lib/agent/analyzers/llm.ts +204 -0
  39. package/src/lib/agent/analyzers/local-search.ts +215 -0
  40. package/src/lib/agent/capture.ts +123 -0
  41. package/src/lib/agent/index.ts +244 -0
  42. package/src/lib/agent/integration.ts +81 -0
  43. package/src/lib/agent/llm/providers/base.ts +99 -0
  44. package/src/lib/agent/llm/providers/index.ts +60 -0
  45. package/src/lib/agent/llm/providers/mock.ts +67 -0
  46. package/src/lib/agent/llm/providers/ollama.ts +151 -0
  47. package/src/lib/agent/llm/providers/openai.ts +153 -0
  48. package/src/lib/agent/llm/sanitizer.ts +170 -0
  49. package/src/lib/agent/llm/types.ts +118 -0
  50. package/src/lib/agent/memory.ts +363 -0
  51. package/src/lib/agent/node-status.ts +56 -0
  52. package/src/lib/agent/node-suggestions.ts +64 -0
  53. package/src/lib/agent/status.ts +80 -0
  54. package/src/lib/agent/suggestions.ts +169 -0
  55. package/src/lib/components/Canvas.svelte +124 -0
  56. package/src/lib/components/ConnectionLine.svelte +46 -0
  57. package/src/lib/components/DisplayNode.svelte +167 -0
  58. package/src/lib/components/InputNode.svelte +158 -0
  59. package/src/lib/components/TerminalNode.svelte +237 -0
  60. package/src/lib/components/Toolbar.svelte +359 -0
  61. package/src/lib/components/TransformNode.svelte +327 -0
  62. package/src/lib/core/index.ts +31 -0
  63. package/src/lib/core/observer.ts +278 -0
  64. package/src/lib/core/redaction.ts +158 -0
  65. package/src/lib/core/shell-adapters/base.ts +325 -0
  66. package/src/lib/core/shell-adapters/bash.ts +110 -0
  67. package/src/lib/core/shell-adapters/index.ts +62 -0
  68. package/src/lib/core/shell-adapters/zsh.ts +105 -0
  69. package/src/lib/core/storage.ts +360 -0
  70. package/src/lib/core/types.ts +176 -0
  71. package/src/lib/design-dojo/Box.svelte +47 -0
  72. package/src/lib/design-dojo/Button.svelte +75 -0
  73. package/src/lib/design-dojo/Input.svelte +65 -0
  74. package/src/lib/design-dojo/List.svelte +38 -0
  75. package/src/lib/design-dojo/Select.svelte +48 -0
  76. package/src/lib/design-dojo/SplitPane.svelte +43 -0
  77. package/src/lib/design-dojo/StatusBar.svelte +61 -0
  78. package/src/lib/design-dojo/Table.svelte +47 -0
  79. package/src/lib/design-dojo/Text.svelte +36 -0
  80. package/src/lib/design-dojo/Toggle.svelte +48 -0
  81. package/src/lib/design-dojo/index.ts +10 -0
  82. package/src/lib/stores/canvas-praxis.ts +268 -0
  83. package/src/lib/stores/canvas.ts +58 -0
  84. package/src/lib/types/agent.ts +78 -0
  85. package/src/lib/types/canvas.ts +71 -0
  86. package/src/lib/utils/storage.ts +326 -0
  87. package/src/lib/utils/yaml-loader.ts +52 -0
  88. package/src/routes/+layout.svelte +5 -0
  89. package/src/routes/+layout.ts +5 -0
  90. package/src/routes/+page.svelte +32 -0
  91. package/src-tauri/Cargo.lock +5735 -0
  92. package/src-tauri/Cargo.toml +38 -0
  93. package/src-tauri/build.rs +3 -0
  94. package/src-tauri/capabilities/default.json +10 -0
  95. package/src-tauri/icons/128x128.png +0 -0
  96. package/src-tauri/icons/128x128@2x.png +0 -0
  97. package/src-tauri/icons/32x32.png +0 -0
  98. package/src-tauri/icons/Square107x107Logo.png +0 -0
  99. package/src-tauri/icons/Square142x142Logo.png +0 -0
  100. package/src-tauri/icons/Square150x150Logo.png +0 -0
  101. package/src-tauri/icons/Square284x284Logo.png +0 -0
  102. package/src-tauri/icons/Square30x30Logo.png +0 -0
  103. package/src-tauri/icons/Square310x310Logo.png +0 -0
  104. package/src-tauri/icons/Square44x44Logo.png +0 -0
  105. package/src-tauri/icons/Square71x71Logo.png +0 -0
  106. package/src-tauri/icons/Square89x89Logo.png +0 -0
  107. package/src-tauri/icons/StoreLogo.png +0 -0
  108. package/src-tauri/icons/icon.icns +0 -0
  109. package/src-tauri/icons/icon.ico +0 -0
  110. package/src-tauri/icons/icon.png +0 -0
  111. package/src-tauri/src/agents/agent1.rs +66 -0
  112. package/src-tauri/src/agents/agent2.rs +80 -0
  113. package/src-tauri/src/agents/agent3.rs +73 -0
  114. package/src-tauri/src/agents/agent4.rs +66 -0
  115. package/src-tauri/src/agents/agent5.rs +68 -0
  116. package/src-tauri/src/agents/agent6.rs +75 -0
  117. package/src-tauri/src/agents/base.rs +52 -0
  118. package/src-tauri/src/agents/mod.rs +17 -0
  119. package/src-tauri/src/core/coordination.rs +117 -0
  120. package/src-tauri/src/core/mod.rs +12 -0
  121. package/src-tauri/src/core/ownership.rs +61 -0
  122. package/src-tauri/src/core/types.rs +132 -0
  123. package/src-tauri/src/execution/mod.rs +5 -0
  124. package/src-tauri/src/execution/runner.rs +143 -0
  125. package/src-tauri/src/lib.rs +161 -0
  126. package/src-tauri/src/main.rs +6 -0
  127. package/src-tauri/src/memory/api.rs +422 -0
  128. package/src-tauri/src/memory/client.rs +156 -0
  129. package/src-tauri/src/memory/encryption.rs +79 -0
  130. package/src-tauri/src/memory/migration.rs +110 -0
  131. package/src-tauri/src/memory/mod.rs +28 -0
  132. package/src-tauri/src/memory/schema.rs +275 -0
  133. package/src-tauri/src/memory/tests.rs +192 -0
  134. package/src-tauri/src/orchestrator/coordinator.rs +232 -0
  135. package/src-tauri/src/orchestrator/mod.rs +13 -0
  136. package/src-tauri/src/orchestrator/planner.rs +304 -0
  137. package/src-tauri/tauri.conf.json +35 -0
  138. package/static/examples/date-time-example.yaml +147 -0
  139. package/static/examples/hello-world.yaml +74 -0
  140. package/static/examples/transform-example.yaml +157 -0
  141. package/static/favicon.png +0 -0
  142. package/static/svelte.svg +1 -0
  143. package/static/tauri.svg +6 -0
  144. package/static/vite.svg +1 -0
  145. package/svelte.config.js +18 -0
  146. package/tsconfig.json +19 -0
  147. package/vite.config.js +45 -0
  148. package/vitest.config.ts +21 -0
@@ -0,0 +1,231 @@
1
+ # Analysis Ladder
2
+
3
+ The Analysis Ladder is a multi-layer approach to analyzing command failures and generating actionable suggestions. It runs in the background, is non-blocking, and never auto-executes commands—only suggests.
4
+
5
+ ## Architecture
6
+
7
+ The analysis pipeline consists of three layers, executed in order:
8
+
9
+ ### Layer 1: Heuristic Classifiers
10
+
11
+ **Purpose**: Fast, deterministic pattern matching for common errors.
12
+
13
+ **Analyzers**:
14
+ - **NixErrorAnalyzer**: Detects Nix-specific errors
15
+ - Missing attributes (e.g., `attribute "cursor" missing`)
16
+ - Flake-parts template path errors
17
+ - buildEnv font conflicts
18
+ - Nix evaluation errors
19
+
20
+ - **GitAuthAnalyzer**: Detects Git/GitHub authentication issues
21
+ - GitHub rate limit errors
22
+ - Git authentication failures
23
+ - Missing token environment variables
24
+
25
+ - **SyntaxErrorAnalyzer**: Detects syntax and command errors
26
+ - Syntax errors with file/line numbers
27
+ - Command not found errors
28
+
29
+ **Characteristics**:
30
+ - High confidence (0.7-0.95)
31
+ - Fast execution (< 100ms)
32
+ - No external dependencies
33
+ - Deterministic results
34
+
35
+ ### Layer 2: Local Search
36
+
37
+ **Purpose**: Search repository and configuration files for context.
38
+
39
+ **Analyzer**:
40
+ - **LocalSearchAnalyzer**: Uses ripgrep (or grep fallback) to search:
41
+ - Repository files (flake.nix, *.nix, *.sh, etc.)
42
+ - Configuration files
43
+ - Environment variable references
44
+ - Related error patterns
45
+
46
+ **Characteristics**:
47
+ - Medium confidence (0.6-0.8)
48
+ - Moderate execution time (100-500ms)
49
+ - Requires repository context
50
+ - May skip if Layer 1 produces high-confidence results
51
+
52
+ ### Layer 3: Optional LLM/MCP (Gated)
53
+
54
+ **Purpose**: Intelligent analysis using language models or MCP.
55
+
56
+ **Analyzer**:
57
+ - **LLMAnalyzer**: Placeholder for future LLM/MCP integration
58
+ - Currently disabled by default
59
+ - Can be enabled via configuration
60
+ - Would provide intelligent, context-aware suggestions
61
+
62
+ **Characteristics**:
63
+ - Variable confidence (depends on model)
64
+ - Slower execution (1-5s)
65
+ - Requires API access
66
+ - Only runs if explicitly enabled
67
+
68
+ ## Job System
69
+
70
+ ### Failure Detection
71
+
72
+ Failures are detected when:
73
+ 1. An `exit_status` event has `success: false` (non-zero exit code)
74
+ 2. Known stderr patterns match error signatures
75
+ 3. Command context is available (command, args, cwd, env)
76
+
77
+ ### Job Queue
78
+
79
+ - **Non-blocking**: Jobs run in the background
80
+ - **Cancelable**: Jobs can be cancelled if pending
81
+ - **Context Windows**: Each job includes:
82
+ - Full command context (command, args, cwd, env)
83
+ - Complete stdout/stderr output
84
+ - Previous commands (last 5)
85
+ - All related events
86
+
87
+ ### Job States
88
+
89
+ - `pending`: Queued, waiting to run
90
+ - `running`: Currently being analyzed
91
+ - `completed`: Analysis finished, suggestions available
92
+ - `cancelled`: User cancelled the job
93
+ - `failed`: Analysis encountered an error
94
+
95
+ ## Structured Suggestions
96
+
97
+ Each suggestion includes:
98
+
99
+ ```typescript
100
+ interface AnalysisSuggestion {
101
+ id: string;
102
+ type: 'command' | 'optimization' | 'shortcut' | 'warning' | 'tip';
103
+ priority: 'low' | 'medium' | 'high';
104
+ title: string;
105
+ description: string;
106
+ confidence: number; // 0.0 to 1.0
107
+ actionableSnippet?: string; // Code snippet or command to fix
108
+ provenance: {
109
+ analyzer: string; // Which analyzer produced this
110
+ layer: number; // Which layer (1, 2, or 3)
111
+ timestamp: number;
112
+ };
113
+ timestamp: number;
114
+ }
115
+ ```
116
+
117
+ ### Confidence Scores
118
+
119
+ - **0.9-1.0**: Very high confidence, likely correct
120
+ - **0.7-0.9**: High confidence, probably correct
121
+ - **0.5-0.7**: Medium confidence, worth checking
122
+ - **< 0.5**: Low confidence, may be speculative
123
+
124
+ ## Usage
125
+
126
+ ### CLI Command
127
+
128
+ ```bash
129
+ # Analyze the last command failure
130
+ runebook analyze last
131
+ ```
132
+
133
+ ### Programmatic API
134
+
135
+ ```typescript
136
+ import { getAnalysisService } from './lib/agent/analysis-service';
137
+ import { createObserver } from './lib/core';
138
+
139
+ const observer = createObserver({ enabled: true });
140
+ await observer.initialize();
141
+
142
+ const analysisService = getAnalysisService();
143
+ analysisService.initialize(store, config);
144
+ analysisService.setEnabled(true);
145
+
146
+ // Process exit status events
147
+ const jobId = await analysisService.processExitStatus(exitStatusEvent);
148
+
149
+ // Get results
150
+ const job = analysisService.getJob(jobId);
151
+ console.log(job.suggestions);
152
+ ```
153
+
154
+ ## Pluggable Analyzers
155
+
156
+ You can create custom analyzers by implementing the `Analyzer` interface:
157
+
158
+ ```typescript
159
+ interface Analyzer {
160
+ name: string;
161
+ layer: number; // 1, 2, or 3
162
+ analyze(context: AnalysisContext, store: EventStore): Promise<AnalysisSuggestion[]>;
163
+ }
164
+ ```
165
+
166
+ Example:
167
+
168
+ ```typescript
169
+ class CustomAnalyzer implements Analyzer {
170
+ name = 'custom-analyzer';
171
+ layer = 1;
172
+
173
+ async analyze(context: AnalysisContext, store: EventStore): Promise<AnalysisSuggestion[]> {
174
+ const suggestions: AnalysisSuggestion[] = [];
175
+
176
+ // Your analysis logic here
177
+ if (context.stderr.includes('your-pattern')) {
178
+ suggestions.push({
179
+ id: `suggestion_${Date.now()}`,
180
+ type: 'warning',
181
+ priority: 'high',
182
+ title: 'Your Title',
183
+ description: 'Your description',
184
+ confidence: 0.8,
185
+ actionableSnippet: '# Your fix here',
186
+ provenance: {
187
+ analyzer: this.name,
188
+ layer: this.layer,
189
+ timestamp: Date.now(),
190
+ },
191
+ timestamp: Date.now(),
192
+ });
193
+ }
194
+
195
+ return suggestions;
196
+ }
197
+ }
198
+
199
+ // Register it
200
+ const queue = new AnalysisJobQueue(store);
201
+ queue.registerAnalyzer(new CustomAnalyzer());
202
+ ```
203
+
204
+ ## Best Practices
205
+
206
+ 1. **Layer 1 First**: Use heuristic analyzers for fast, common errors
207
+ 2. **Layer 2 for Context**: Use local search when you need repository context
208
+ 3. **Layer 3 Sparingly**: Only enable LLM/MCP for complex cases
209
+ 4. **High Confidence**: Prefer high-confidence suggestions (>0.7)
210
+ 5. **Actionable Snippets**: Always include actionable code/commands
211
+ 6. **Provenance**: Track which analyzer produced each suggestion
212
+
213
+ ## Testing
214
+
215
+ Fixture-based tests verify that analyzers produce expected remediations for:
216
+
217
+ - GitHub rate limit / token env issues
218
+ - flake-parts template path errors
219
+ - Nix buildEnv font conflicts
220
+ - Missing attribute "cursor"
221
+
222
+ See `src/lib/agent/__tests__/analysis-pipeline.test.ts` for examples.
223
+
224
+ ## Future Enhancements
225
+
226
+ - [ ] LLM/MCP integration for Layer 3
227
+ - [ ] Learning from user feedback
228
+ - [ ] Cross-session pattern learning
229
+ - [ ] Suggestion ranking and deduplication
230
+ - [ ] Integration with IDE/editor plugins
231
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,124 @@
1
+ ## [0.4.0] — 2026-02-23
2
+
3
+ - feat: replace hand-styled components with design-dojo primitives (#40) (4ffc4b9)
4
+ - test: Playwright e2e coverage for core RuneBook flows + fix InputNode reactive loop (#38) (766f5cf)
5
+ - chore: add copilot instructions and org standards (6412fee)
6
+ - chore: integrate @plures/design-dojo as UI component library (#31) (d057f91)
7
+ - Add Playwright E2E smoke tests (production-like build) (#26) (14cd86d)
8
+ - Fix node button reactivity by using Praxis store dispatch (#25) (7c29e6a)
9
+
10
+ # Changelog
11
+
12
+ All notable changes to RuneBook will be documented in this file.
13
+
14
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
15
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
16
+
17
+ ## [Unreleased]
18
+
19
+ ## [0.3.0] - 2026-01-25
20
+
21
+ ### Added
22
+ - **Praxis Integration**: Integrated @plures/praxis v1.2.0 for reactive state management
23
+ - Type-safe event-driven architecture with defineEvent and defineRule
24
+ - Reactive logic engine replacing manual Svelte stores
25
+ - Improved testability and maintainability of state management
26
+ - Backward-compatible API wrapper for existing components
27
+
28
+ ### Changed
29
+ - Refactored canvas state management to use Praxis reactive engine
30
+ - State updates now use events (AddNodeEvent, UpdateNodeEvent, etc.) for better traceability
31
+ - Improved type safety across the state management layer
32
+
33
+ ## [0.2.0] - 2024-12-27
34
+
35
+ ### Added
36
+ - **Transform Nodes**: New node type for data transformation between nodes
37
+ - Map transform: Apply functions to array elements
38
+ - Filter transform: Filter array elements based on conditions
39
+ - Reduce transform: Aggregate array data into single values
40
+ - Sudolang transform placeholder (planned for future implementation)
41
+ - **Storage System**: Canvas persistence with localStorage and PluresDB
42
+ - LocalStorage adapter for browser-based storage
43
+ - **PluresDB adapter**: Full integration with PluresDB for P2P-enabled storage
44
+ - Switch between storage adapters in UI
45
+ - Export canvases as YAML files
46
+ - Storage abstraction layer with pluggable adapters
47
+ - Transform node button in toolbar
48
+ - Canvas rendering support for transform nodes
49
+ - PluresDB integration (v1.3.1) with key-value API
50
+ - Example canvas file demonstrating transform nodes
51
+ - Storage settings UI to switch between LocalStorage and PluresDB
52
+
53
+ ### Changed
54
+ - Updated all dependencies to latest versions
55
+ - Improved documentation structure
56
+ - README.md now focuses on latest features
57
+ - Version-specific information moved to CHANGELOG.md
58
+ - Toolbar reorganized with save/load options and storage settings
59
+
60
+ ### Security
61
+ - Added "use strict" mode for JavaScript expression execution in transform nodes
62
+ - Input validation for transform node arrays
63
+ - Canvas data validation in storage layer
64
+ - Fixed reduce operation with proper initial value
65
+ - Documented security considerations for transform nodes
66
+ - CodeQL security scan: 0 alerts
67
+
68
+ ### Documentation
69
+ - Created CHANGELOG.md for version history tracking
70
+ - Updated IMPLEMENTATION.md to reflect actual completion status
71
+ - Clarified roadmap items in README.md as implemented vs. planned
72
+ - Added storage documentation to README
73
+ - Added security notes for transform nodes
74
+ - Documented PluresDB integration
75
+
76
+ ## [0.1.0] - 2024-11-21
77
+
78
+ ### Added
79
+ - Initial Tauri + Svelte 5 project structure
80
+ - Canvas UI system with infinite workspace and grid background
81
+ - Three core node types:
82
+ - **Terminal Nodes**: Execute shell commands with reactive output
83
+ - **Input Nodes**: User input widgets (text, number, checkbox, slider)
84
+ - **Display Nodes**: Data visualization (text, JSON, table)
85
+ - Reactive data flow system using Svelte 5 runes
86
+ - YAML canvas loader for save/load functionality
87
+ - Example canvas files:
88
+ - `hello-world.yaml`: Basic echo and input demonstration
89
+ - `date-time-example.yaml`: Multiple terminals and displays
90
+ - Rust backend with Tauri for native system access
91
+ - Terminal command execution with security measures:
92
+ - Direct execution (no shell interpretation)
93
+ - Input validation
94
+ - Environment variable validation
95
+ - Toolbar with node creation and canvas management
96
+ - SVG-based connection rendering
97
+ - Comprehensive documentation:
98
+ - README.md: User guide and getting started
99
+ - QUICKSTART.md: Step-by-step tutorial
100
+ - CONTRIBUTING.md: Developer contribution guide
101
+ - ARCHITECTURE.md: Technical design documentation
102
+ - INTEGRATIONS.md: Future feature plans
103
+ - LICENSE: MIT License
104
+
105
+ ### Security
106
+ - Command execution without shell interpretation to prevent injection attacks
107
+ - Environment variable name validation
108
+ - Input validation for commands and arguments
109
+
110
+ ## [Unreleased]
111
+
112
+ ### Planned Features
113
+ - PluresDB integration for persistent storage
114
+ - MCP (Model Context Protocol) integration for AI assistance
115
+ - Sudolang support for natural language scripting
116
+ - Interactive connection creation (drag from ports)
117
+ - Canvas zoom and pan controls
118
+ - Node deletion UI
119
+ - Keyboard shortcuts
120
+ - Undo/redo functionality
121
+ - WebSocket support for real-time data
122
+ - Plugin system for custom nodes
123
+ - Collaborative editing
124
+ - Canvas search and filtering
@@ -0,0 +1,242 @@
1
+ # Integration Plans
2
+
3
+ ## PluresDB Integration
4
+
5
+ PluresDB will provide persistent storage for canvas definitions, node states, and user data.
6
+
7
+ ### Planned Features
8
+
9
+ - **Canvas Storage**: Save and load canvas configurations from the database
10
+ - **Node State Persistence**: Store terminal outputs and node values
11
+ - **History Tracking**: Version control for canvas changes
12
+ - **Search**: Full-text search across canvas definitions and node content
13
+
14
+ ### Implementation Notes
15
+
16
+ PluresDB integration will be added in a future iteration. The current YAML-based system provides a foundation for understanding the data model.
17
+
18
+ ## MCP (Model Context Protocol) Integration
19
+
20
+ MCP will enable AI assistance within RuneBook workflows.
21
+
22
+ ### Planned Features
23
+
24
+ - **AI Transform Nodes**: Process data using LLM capabilities
25
+ - **Natural Language Commands**: Create and modify canvas elements via text
26
+ - **Code Generation**: Generate terminal commands and scripts
27
+ - **Data Analysis**: Analyze terminal outputs and suggest insights
28
+ - **Autocomplete**: Suggest next nodes based on workflow context
29
+
30
+ ### Use Cases
31
+
32
+ 1. **Command Suggestion**: "Show me disk usage" → generates `du -sh` terminal node
33
+ 2. **Data Transformation**: Transform JSON output to different formats
34
+ 3. **Error Analysis**: Analyze error messages and suggest fixes
35
+ 4. **Workflow Optimization**: Suggest improvements to canvas layouts
36
+
37
+ ### Integration Approach
38
+
39
+ 1. Add MCP client to Tauri backend
40
+ 2. Create MCP server connector nodes
41
+ 3. Implement prompt templates for common operations
42
+ 4. Add AI suggestion UI components
43
+
44
+ ## Sudolang Support
45
+
46
+ Sudolang will provide a natural language interface for creating and manipulating canvas workflows.
47
+
48
+ ### Planned Features
49
+
50
+ - **Natural Language Node Creation**: "Create a terminal that lists files"
51
+ - **Flow Description**: Describe entire workflows in prose
52
+ - **Dynamic Scripting**: Write Sudolang scripts that generate canvas configurations
53
+ - **Interactive Refinement**: Conversational workflow building
54
+
55
+ ### Example Sudolang Workflow
56
+
57
+ ```sudolang
58
+ Create a workflow that:
59
+ 1. Gets the current date
60
+ 2. Lists all files in the current directory
61
+ 3. Counts the number of files
62
+ 4. Displays all information in separate panels
63
+
64
+ Connect the outputs appropriately.
65
+ ```
66
+
67
+ This would automatically generate:
68
+ - A terminal node running `date`
69
+ - A terminal node running `ls`
70
+ - A terminal node running `ls | wc -l`
71
+ - Three display nodes showing the outputs
72
+ - Connections between all nodes
73
+
74
+ ### Implementation Notes
75
+
76
+ Sudolang integration will require:
77
+ 1. Parser for Sudolang syntax
78
+ 2. Code generator that creates canvas YAML
79
+ 3. Interpreter for dynamic execution
80
+ 4. REPL-style interface for interactive development
81
+
82
+ ## Transform Nodes
83
+
84
+ Transform nodes will enable data processing between nodes.
85
+
86
+ ### Types of Transforms
87
+
88
+ 1. **Map**: Transform each item in a collection
89
+ 2. **Filter**: Select items matching criteria
90
+ 3. **Reduce**: Aggregate data into a single value
91
+ 4. **Parse**: Convert between formats (JSON, CSV, XML)
92
+ 5. **Sudolang**: Custom transformations using natural language
93
+
94
+ ### Example
95
+
96
+ ```
97
+ Terminal (ls -l) → Transform (parse file listing) → Display (table view)
98
+ ```
99
+
100
+ ## Ambient Agent Mode (Term-Agent Capabilities)
101
+
102
+ Ambient Agent Mode provides intelligent command analysis and suggestions, similar to term-agent capabilities.
103
+
104
+ ### Implemented Features ✅
105
+
106
+ - **Event Capture**: Automatic capture of terminal commands, outputs, and context
107
+ - **Storage/Memory**: Persistent storage of events and patterns (in-memory or PluresDB)
108
+ - **Analysis Engine**: Pattern detection, failure analysis, performance analysis
109
+ - **Suggestion System**: Generate actionable suggestions (shortcuts, optimizations, warnings)
110
+ - **Headless CLI**: SSH-friendly interface for agent management
111
+ - **Opt-in Design**: Disabled by default, requires explicit enable
112
+ - **Terminal Observer**: Low-level shell event capture with bash/zsh adapters
113
+ - **Analysis Ladder**: 3-layer analysis system (heuristic → local search → optional LLM)
114
+ - **Cognitive Memory**: PluresDB-based persistent storage with Rust API
115
+ - **Event Schema**: Canonical event types for all terminal activities
116
+ - **Memory Schema**: Structured storage for sessions, commands, outputs, errors, insights, suggestions
117
+ - **Security Model**: Secret redaction, opt-in design, local-only storage
118
+ - **Demo Script**: Automated walkthrough (scripts/demo.sh)
119
+
120
+ ### Architecture
121
+
122
+ ```
123
+ Terminal Command → Event Capture → Storage → Analysis → Suggestions
124
+ ↓ ↓ ↓
125
+ Observer Layer Memory Analysis Ladder
126
+ (bash/zsh) (PluresDB) (3 layers)
127
+
128
+ CLI / UI Display
129
+ ```
130
+
131
+ ### Event Schema
132
+
133
+ The system captures canonical event types:
134
+ - `command_start`: Command begins execution
135
+ - `command_end`: Command completes
136
+ - `stdout_chunk`: Incremental stdout output
137
+ - `stderr_chunk`: Incremental stderr output
138
+ - `exit_status`: Command exit code
139
+ - `cwd_change`: Working directory changed
140
+ - `env_change`: Environment variables changed
141
+ - `session_start`: Terminal session started
142
+ - `session_end`: Terminal session ended
143
+
144
+ See [ARCHITECTURE.md](./ARCHITECTURE.md) for full event schema details.
145
+
146
+ ### Memory Schema
147
+
148
+ Cognitive memory storage organizes data into:
149
+ - **Sessions**: Terminal session metadata
150
+ - **Commands**: Normalized command records
151
+ - **Outputs**: Chunked stdout/stderr (optionally compressed)
152
+ - **Errors**: Classified error records
153
+ - **Insights**: AI/heuristic annotations
154
+ - **Suggestions**: Ranked recommendations
155
+ - **Provenance**: Source tracking
156
+
157
+ See [MEMORY.md](./MEMORY.md) for full memory schema details.
158
+
159
+ ### Analysis Ladder
160
+
161
+ Three-layer analysis system:
162
+ 1. **Layer 1**: Heuristic classifiers (fast, deterministic, high confidence)
163
+ 2. **Layer 2**: Local search (context-aware, medium confidence)
164
+ 3. **Layer 3**: Optional LLM/MCP (gated, disabled by default)
165
+
166
+ See [ANALYSIS_LADDER.md](./ANALYSIS_LADDER.md) for full details.
167
+
168
+ ### Usage
169
+
170
+ **Enable via CLI:**
171
+ ```bash
172
+ npm run agent enable
173
+ npm run agent status
174
+ npm run agent suggestions
175
+ npm run analyze last
176
+ npm run memory inspect
177
+ ```
178
+
179
+ **Enable Observer (captures all shell commands):**
180
+ ```bash
181
+ npm run observer enable
182
+ npm run observer events tail
183
+ ```
184
+
185
+ **Enable via Code:**
186
+ ```typescript
187
+ import { initAgent } from './lib/agent/integration';
188
+
189
+ initAgent({
190
+ enabled: true,
191
+ captureEvents: true,
192
+ analyzePatterns: true,
193
+ suggestImprovements: true,
194
+ });
195
+ ```
196
+
197
+ ### Data Policy
198
+
199
+ - **Opt-in by default**: Agent is disabled until explicitly enabled
200
+ - **Local-only storage**: All data stored locally, no external services
201
+ - **Secret redaction**: Automatic detection and redaction of API keys, tokens, passwords
202
+ - **Configurable retention**: Default 30 days, customizable
203
+ - **No background daemon**: Runs only when explicitly enabled
204
+ - **Clear data policy**: User controls what is stored and for how long
205
+
206
+ ### CLI Surface
207
+
208
+ Full headless interface:
209
+ - `npm run agent <command>`: Agent management (enable, disable, status, suggestions, events, clear)
210
+ - `npm run observer <command>`: Observer management (enable, disable, status, events, tail)
211
+ - `npm run analyze <command>`: Analysis commands (last)
212
+ - `npm run memory <command>`: Memory inspection (inspect)
213
+
214
+ ### Demo
215
+
216
+ Run the automated demo:
217
+ ```bash
218
+ bash scripts/demo.sh
219
+ ```
220
+
221
+ Or follow the walkthrough in [docs/demo.md](./docs/demo.md).
222
+
223
+ ### Future Enhancements
224
+
225
+ - GUI integration for suggestions display
226
+ - Advanced ML-based pattern analysis
227
+ - Cross-session pattern learning
228
+ - Suggestion action buttons (apply directly)
229
+ - Nushell adapter for terminal observer
230
+ - Real-time event streaming (WebSocket-based)
231
+
232
+ ## Future Integration Priorities
233
+
234
+ 1. **Phase 1**: Transform nodes with JavaScript ✅
235
+ 2. **Phase 2**: PluresDB for persistence ✅
236
+ 3. **Phase 2.5**: Ambient Agent Mode ✅
237
+ 4. **Phase 3**: MCP for AI assistance
238
+ 5. **Phase 4**: Sudolang for natural language workflows
239
+
240
+ ## Contributing
241
+
242
+ If you'd like to contribute to any of these integrations, please see the main README for contribution guidelines.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 RuneBook Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.