@halfagiraf/clawx 0.1.8 → 0.1.9

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 (2) hide show
  1. package/README.md +34 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -480,16 +480,16 @@ clawx chat -d ./my-project
480
480
 
481
481
  ## Programmatic usage
482
482
 
483
- ```typescript
484
- import { loadConfig, runAgent, createStreamRenderer } from "@halfagiraf/clawx";
483
+ Use clawx as a library in your own scripts and tools.
485
484
 
486
- const config = loadConfig({
487
- provider: "openai-completions",
488
- baseUrl: "http://localhost:8080/v1",
489
- model: "qwen2.5-coder-14b-instruct",
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halfagiraf/clawx",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
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": {