cvm-server 0.9.0 → 0.9.1
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.
- package/README.md +165 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,92 +1,204 @@
|
|
|
1
|
-
# CVM
|
|
1
|
+
# CVM: Stateful Task Engine for Claude
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Stop Claude from losing track. CVM is a passive state machine that Claude queries for tasks, maintaining perfect execution flow across complex operations.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/cvm-server)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- MongoDB support for production deployments
|
|
9
|
-
- MCP (Model Context Protocol) integration
|
|
10
|
-
- Automatic versioning with conventional commits
|
|
7
|
+
## The Problem
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
"Claude, analyze these 1000 files and create a report" → Claude gets confused, loses context, forgets what it's doing.
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
## The Solution
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
CVM is a passive MCP server that holds program state. You write a program with loops and logic, but Claude only sees one task at a time. Claude asks "what's next?", completes the task, and asks again.
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
The magic: CVM never pushes tasks. Claude pulls tasks when ready, maintaining perfect control while CVM quietly manages state between requests.
|
|
16
|
+
|
|
17
|
+
## What CVM Really Is
|
|
18
|
+
|
|
19
|
+
CVM is an **algorithmic TODO manager**. Think of it as:
|
|
20
|
+
- A TODO list that can have loops ("do this 5 times")
|
|
21
|
+
- A TODO list that can have conditions ("if X then do Y")
|
|
22
|
+
- A TODO list that maintains variables between tasks
|
|
23
|
+
- A TODO list shaped like a program
|
|
24
|
+
|
|
25
|
+
When your program hits `CC("analyze this file")`, CVM doesn't call Claude. Instead:
|
|
26
|
+
1. CVM creates a TODO: "analyze this file"
|
|
27
|
+
2. CVM pauses execution and waits
|
|
28
|
+
3. Claude asks CVM: "What should I do next?"
|
|
29
|
+
4. CVM responds: "analyze this file"
|
|
30
|
+
5. Claude does the analysis and submits the result
|
|
31
|
+
6. CVM updates its state and moves to the next instruction
|
|
21
32
|
|
|
22
|
-
|
|
33
|
+
**CVM is completely passive** - it never initiates anything. Claude drives everything.
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
## Try It Now
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
Save this as `counter.ts`:
|
|
38
|
+
```typescript
|
|
39
|
+
function main() {
|
|
40
|
+
let count = 0;
|
|
41
|
+
while (count < 5) {
|
|
42
|
+
const next = CC("Current number is " + count + ". What's the next number?");
|
|
43
|
+
count = +next;
|
|
44
|
+
console.log("Count is now: " + count);
|
|
45
|
+
}
|
|
46
|
+
return count; // Returns 5
|
|
47
|
+
}
|
|
48
|
+
main();
|
|
29
49
|
```
|
|
30
50
|
|
|
31
|
-
|
|
51
|
+
Then tell Claude: **"Run counter.ts with CVM"**
|
|
32
52
|
|
|
33
|
-
|
|
53
|
+
What actually happens:
|
|
54
|
+
- CVM loads the program and starts execution
|
|
55
|
+
- When it hits `CC()`, CVM creates a task and waits
|
|
56
|
+
- Claude asks CVM for tasks using `getTask()`
|
|
57
|
+
- CVM gives Claude: "Current number is 0. What's the next number?"
|
|
58
|
+
- Claude figures out the answer is "1" and submits it
|
|
59
|
+
- CVM continues the loop with count=1
|
|
60
|
+
- Process repeats until done
|
|
34
61
|
|
|
35
|
-
|
|
36
|
-
- `CVM_DATA_DIR` - Data directory for file storage (default: ".cvm")
|
|
37
|
-
- `CVM_LOG_LEVEL` - Logging level: "debug", "info" (default), "warn", "error"
|
|
38
|
-
- `MONGODB_URI` - MongoDB connection string (required only for mongodb storage)
|
|
62
|
+
## How It Works
|
|
39
63
|
|
|
40
|
-
|
|
64
|
+
CVM is a passive MCP server. Claude actively drives execution:
|
|
41
65
|
|
|
42
|
-
|
|
66
|
+
```
|
|
67
|
+
Claude: load("counter", "...program code...")
|
|
68
|
+
Claude: start("counter", "exec-123")
|
|
69
|
+
Claude: getTask("exec-123") → CVM: "Current number is 0. What's the next number?"
|
|
70
|
+
Claude: submitTask("exec-123", "1") → CVM sets count=1, continues loop
|
|
71
|
+
Claude: getTask("exec-123") → CVM: "Current number is 1. What's the next number?"
|
|
72
|
+
Claude: submitTask("exec-123", "2") → CVM sets count=2, continues loop
|
|
73
|
+
...
|
|
74
|
+
Claude: getTask("exec-123") → CVM: "Execution completed with result: 5"
|
|
75
|
+
```
|
|
43
76
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
77
|
+
## Why This Architecture
|
|
78
|
+
|
|
79
|
+
**Traditional approach**: Claude tries to maintain state in its context window
|
|
80
|
+
- ❌ Loses track in complex flows
|
|
81
|
+
- ❌ Forgets variables between steps
|
|
82
|
+
- ❌ Can't handle real loops or conditions reliably
|
|
83
|
+
|
|
84
|
+
**CVM approach**: State lives in CVM, Claude just processes individual tasks
|
|
85
|
+
- ✅ Perfect state management
|
|
86
|
+
- ✅ Real loops and conditions that work
|
|
87
|
+
- ✅ Claude's context stays clean
|
|
88
|
+
- ✅ Complex workflows become simple task sequences
|
|
89
|
+
|
|
90
|
+
## Real Example
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
function main() {
|
|
94
|
+
const files = fs.listFiles("./docs", { filter: "*.txt" });
|
|
95
|
+
const summaries = [];
|
|
96
|
+
|
|
97
|
+
for (const file of files) {
|
|
98
|
+
// This creates a task for Claude, doesn't "call" Claude
|
|
99
|
+
const content = CC("Read and summarize this file: " + file);
|
|
100
|
+
// Now we can use objects!
|
|
101
|
+
summaries.push({
|
|
102
|
+
filename: file,
|
|
103
|
+
summary: content
|
|
104
|
+
});
|
|
105
|
+
console.log("Processed: " + file);
|
|
55
106
|
}
|
|
107
|
+
|
|
108
|
+
// Convert summaries array to JSON for the final task
|
|
109
|
+
const summariesJson = JSON.stringify(summaries);
|
|
110
|
+
const report = CC("Create a final report from these file summaries: " + summariesJson);
|
|
111
|
+
console.log("Final Report: " + report);
|
|
112
|
+
|
|
113
|
+
return report;
|
|
56
114
|
}
|
|
115
|
+
main();
|
|
57
116
|
```
|
|
58
117
|
|
|
59
|
-
|
|
118
|
+
CVM turns this into a dynamic TODO list:
|
|
119
|
+
1. Task: "Read and summarize this file: ./docs/file1.txt"
|
|
120
|
+
2. Task: "Read and summarize this file: ./docs/file2.txt"
|
|
121
|
+
3. Task: "Read and summarize this file: ./docs/file3.txt"
|
|
122
|
+
4. Task: "Create a final report from these summaries: [...]"
|
|
123
|
+
|
|
124
|
+
Claude works through these tasks one by one, while CVM maintains the loop state, the summaries array, and the execution position.
|
|
125
|
+
|
|
126
|
+
## Key Concepts
|
|
127
|
+
|
|
128
|
+
### CC() - Cognitive Context
|
|
129
|
+
`CC(prompt)` doesn't mean "call Claude". It means:
|
|
130
|
+
- Create a task with this prompt
|
|
131
|
+
- Pause execution here
|
|
132
|
+
- Wait for Claude to ask for the next task
|
|
133
|
+
- Resume when Claude provides a result
|
|
60
134
|
|
|
61
|
-
|
|
135
|
+
### CVM is Passive
|
|
136
|
+
- CVM never sends messages to Claude
|
|
137
|
+
- CVM never initiates actions
|
|
138
|
+
- CVM only responds when Claude asks
|
|
139
|
+
- Claude drives everything via MCP tools
|
|
62
140
|
|
|
141
|
+
### State Management
|
|
142
|
+
While Claude processes tasks, CVM maintains:
|
|
143
|
+
- All variables and their values
|
|
144
|
+
- Current execution position
|
|
145
|
+
- Loop counters and conditions
|
|
146
|
+
- Arrays, objects, and complex data structures
|
|
147
|
+
|
|
148
|
+
## Installation
|
|
149
|
+
|
|
150
|
+
Add to Claude's `.mcp.json`:
|
|
63
151
|
```json
|
|
64
152
|
{
|
|
65
153
|
"mcpServers": {
|
|
66
154
|
"cvm": {
|
|
67
155
|
"command": "npx",
|
|
68
|
-
"args": ["cvm-server"],
|
|
156
|
+
"args": ["cvm-server@latest"],
|
|
69
157
|
"env": {
|
|
70
|
-
"CVM_STORAGE_TYPE": "
|
|
71
|
-
"
|
|
158
|
+
"CVM_STORAGE_TYPE": "file",
|
|
159
|
+
"CVM_DATA_DIR": ".cvm"
|
|
72
160
|
}
|
|
73
161
|
}
|
|
74
162
|
}
|
|
75
163
|
}
|
|
76
164
|
```
|
|
77
165
|
|
|
78
|
-
##
|
|
166
|
+
## MCP Tools
|
|
167
|
+
|
|
168
|
+
Claude uses these tools to interact with CVM:
|
|
169
|
+
|
|
170
|
+
- **`load(programId, source)`** - Load a program into CVM
|
|
171
|
+
- **`loadFile(programId, filePath)`** - Load from file
|
|
172
|
+
- **`start(programId, executionId)`** - Start execution
|
|
173
|
+
- **`getTask(executionId)`** - Get next task (CVM waits for this)
|
|
174
|
+
- **`submitTask(executionId, result)`** - Submit task result
|
|
175
|
+
- **`status(executionId)`** - Check execution state
|
|
176
|
+
|
|
177
|
+
## Language Features
|
|
178
|
+
|
|
179
|
+
CVM executes a TypeScript-like language:
|
|
180
|
+
- Variables, arrays, objects, loops, conditions
|
|
181
|
+
- String/array operations
|
|
182
|
+
- Object literals and property access
|
|
183
|
+
- `JSON.stringify()` and `JSON.parse()`
|
|
184
|
+
- `CC()` for task creation
|
|
185
|
+
- `fs.listFiles()` for file operations
|
|
186
|
+
- `console.log()` for output
|
|
187
|
+
|
|
188
|
+
[→ Full API Documentation](docs/API.md)
|
|
189
|
+
|
|
190
|
+
## Use Cases
|
|
191
|
+
|
|
192
|
+
Perfect for any workflow where Claude needs to process many items systematically:
|
|
193
|
+
- Document analysis pipelines
|
|
194
|
+
- Data extraction from multiple sources
|
|
195
|
+
- Report generation with multiple inputs
|
|
196
|
+
- Any task requiring loops with AI processing
|
|
79
197
|
|
|
80
|
-
|
|
198
|
+
## Summary
|
|
81
199
|
|
|
82
|
-
|
|
83
|
-
you may not use this file except in compliance with the License.
|
|
84
|
-
You may obtain a copy of the License at
|
|
200
|
+
CVM is a passive, stateful task engine. It turns programs into smart TODO lists that Claude can work through systematically without losing context. The program defines the workflow, Claude provides the intelligence, and CVM quietly maintains the state between them.
|
|
85
201
|
|
|
86
|
-
|
|
202
|
+
---
|
|
87
203
|
|
|
88
|
-
|
|
89
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
90
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
91
|
-
See the License for the specific language governing permissions and
|
|
92
|
-
limitations under the License.
|
|
204
|
+
Copyright 2025 Ladislav Sopko. Licensed under Apache 2.0.
|