@halfagiraf/clawx 0.1.8 → 0.1.10
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 +34 -7
- package/bin/clawx.js +2 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -480,16 +480,16 @@ clawx chat -d ./my-project
|
|
|
480
480
|
|
|
481
481
|
## Programmatic usage
|
|
482
482
|
|
|
483
|
-
|
|
484
|
-
import { loadConfig, runAgent, createStreamRenderer } from "@halfagiraf/clawx";
|
|
483
|
+
Use clawx as a library in your own scripts and tools.
|
|
485
484
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
});
|
|
485
|
+
**Single task:**
|
|
486
|
+
|
|
487
|
+
```js
|
|
488
|
+
import { loadConfig, runAgent, createStreamRenderer } from "@halfagiraf/clawx";
|
|
491
489
|
|
|
490
|
+
const config = loadConfig(); // reads from ~/.clawx/config or .env
|
|
492
491
|
const renderer = createStreamRenderer();
|
|
492
|
+
|
|
493
493
|
const result = await runAgent(config, {
|
|
494
494
|
prompt: "Create a hello world Express server",
|
|
495
495
|
onEvent: (event) => renderer.onEvent(event),
|
|
@@ -497,6 +497,33 @@ const result = await runAgent(config, {
|
|
|
497
497
|
renderer.finish();
|
|
498
498
|
```
|
|
499
499
|
|
|
500
|
+
**Multi-turn with shared context:**
|
|
501
|
+
|
|
502
|
+
```js
|
|
503
|
+
let messages = [];
|
|
504
|
+
|
|
505
|
+
for (const prompt of ["Create calc.js with add/subtract", "Add tests"]) {
|
|
506
|
+
const result = await runAgent(config, { prompt, messages,
|
|
507
|
+
onEvent: (event) => renderer.onEvent(event),
|
|
508
|
+
});
|
|
509
|
+
messages = result.messages; // carry context forward
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
**Headless for CI/automation:**
|
|
514
|
+
|
|
515
|
+
```js
|
|
516
|
+
const events = [];
|
|
517
|
+
const result = await runAgent(config, {
|
|
518
|
+
prompt: "Generate a Dockerfile for this project",
|
|
519
|
+
onEvent: (event) => events.push(event), // collect instead of printing
|
|
520
|
+
});
|
|
521
|
+
const toolCalls = events.filter(e => e.type === "tool_execution_start");
|
|
522
|
+
console.log(`Done: ${toolCalls.length} tool calls, aborted: ${result.aborted}`);
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
See [examples/](examples/) for runnable scripts.
|
|
526
|
+
|
|
500
527
|
## Troubleshooting
|
|
501
528
|
|
|
502
529
|
### TUI launches a file manager instead of the coding agent (Linux)
|
package/bin/clawx.js
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halfagiraf/clawx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Terminal-first coding agent — runs locally with Ollama, DeepSeek, OpenAI, or any OpenAI-compatible endpoint",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"clawx": "
|
|
7
|
+
"clawx": "bin/clawx.js"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
|
+
"bin/",
|
|
12
13
|
"dist/",
|
|
13
14
|
"README.md",
|
|
14
15
|
"LICENSE",
|