droid-mode 0.1.2 → 0.1.4

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 CHANGED
@@ -131,8 +131,8 @@ npx droid-mode init
131
131
 
132
132
  QUICK START
133
133
  1. Discover MCP servers dm servers
134
- 2. Index tools from server dm index --server <name>
135
- 3. Run a workflow dm run --server <name> --tools a,b --workflow file.js
134
+ 2. Hydrate a tool dm hydrate <tool> --server <name>
135
+ 3. Call the tool dm call <tool> --server <name>
136
136
  ```
137
137
 
138
138
  ```bash
@@ -181,9 +181,9 @@ dm daemon stop # Stop daemon
181
181
  | 1 | `dm servers` | List of configured MCP servers | ~10 |
182
182
  | 2 | `dm index --server X` | Tool names, descriptions, required params | ~50 |
183
183
  | 3 | `dm search "query" --server X` | Filtered tools matching keyword | ~20 |
184
- | 4 | `dm hydrate tool1 tool2 --server X` | Full JSON schemas + TypeScript types | on-demand |
185
- | 5 | `dm call tool --server X` | Execute tool, get result | 0 |
186
- | 6 | `dm run --workflow file.js --server X` | Procedural multi-tool workflow | 0 |
184
+ | 4 | `dm hydrate tool --server X` | Full JSON schema + TypeScript types | on-demand |
185
+ | **5** | **`dm call tool --server X`** | **Execute tool directly (primary)** | **0** |
186
+ | 6 | `dm run --workflow file.js --server X` | Multi-tool workflow (advanced) | 0 |
187
187
 
188
188
  ---
189
189
 
@@ -202,8 +202,8 @@ dm daemon stop # Stop daemon
202
202
 
203
203
  | Command | Description |
204
204
  |---------|-------------|
205
- | `dm call <tool> --server <name>` | Call a single tool |
206
- | `dm run --workflow <file> --tools <a,b> --server <name>` | Execute procedural workflow |
205
+ | `dm call <tool> --server <name>` | **Primary**: Call a single tool (interactive use) |
206
+ | `dm run --workflow <file> --tools <a,b> --server <name>` | Advanced: Multi-tool workflow automation |
207
207
 
208
208
  ### Daemon
209
209
 
@@ -224,7 +224,26 @@ dm daemon stop # Stop daemon
224
224
 
225
225
  ---
226
226
 
227
- ## Workflows
227
+ ## Direct Tool Calls (Primary)
228
+
229
+ For most use cases, use `dm call` to execute tools directly:
230
+
231
+ ```bash
232
+ # Hydrate once (caches schema)
233
+ dm hydrate list_collections --server context-repo
234
+
235
+ # Call directly - results returned as JSON
236
+ dm call list_collections --server context-repo
237
+ dm call list_collections --server context-repo --args '{"limit": 5}'
238
+ ```
239
+
240
+ No workflow file needed. This is the **preferred method** for interactive use and single-tool operations.
241
+
242
+ ---
243
+
244
+ ## Workflows (Advanced)
245
+
246
+ > **Note**: Workflows are for **multi-tool orchestration** with loops, conditionals, or pre-programmed patterns. For simple single-tool calls, use `dm call` instead.
228
247
 
229
248
  Workflows let you run procedural logic across multiple MCP tools in a sandboxed environment.
230
249
 
@@ -342,33 +361,39 @@ For best results with AI agents, add this snippet to your project's `AGENTS.md`
342
361
  ```markdown
343
362
  ## Droid Mode (MCP Tool Access)
344
363
 
345
- Access MCP tools without context bloat. Load schemas on-demand, execute via code.
364
+ Access MCP tools without context bloat. Hydrate schemas on-demand, call tools directly.
346
365
 
347
366
  ### Commands
348
367
 
349
- - Discover servers: `./.factory/skills/droid-mode/bin/dm servers`
350
- - List tools: `./.factory/skills/droid-mode/bin/dm index --server <name>`
351
- - Hydrate schema: `./.factory/skills/droid-mode/bin/dm hydrate <tool> --server <name>`
352
- - Execute workflow: `./.factory/skills/droid-mode/bin/dm run --server <name> --tools a,b --workflow file.js`
368
+ ```bash
369
+ # 1. Discover
370
+ dm servers
371
+ dm index --server <name>
372
+
373
+ # 2. Prepare (one-time per tool)
374
+ dm hydrate <tool> --server <name>
353
375
 
354
- ### Critical Conventions
376
+ # 3. Execute (primary - direct call)
377
+ dm call <tool> --server <name>
378
+ dm call <tool> --server <name> --args '{"key": "value"}'
355
379
 
356
- - **CLI flags use snake_case**: `--tools list_collections`
357
- - **Workflow `t.` accessors use camelCase**: `t.listCollections({})`
358
- - **Path resolution**: Try workspace path first (`./.factory/`), then personal (`~/.factory/`)
380
+ # 4. Advanced: Multi-tool workflows (for complex automation only)
381
+ dm run --server <name> --tools a,b --workflow file.js
382
+ ```
359
383
 
360
- ### Sandbox Restrictions
384
+ **Use `dm call` for everyday tool calls. Use `dm run` only for multi-tool orchestration.**
361
385
 
362
- Workflows run in a sandboxed VM. **Blocked**: `require()`, `import()`, `fetch`, `process`, `node:fs`, `node:http`
386
+ ### Path Resolution
363
387
 
364
- **Allowed**: `t.*` (tool calls), `log()`, `sleep()`, `assert()`
388
+ Try workspace first: `./.factory/skills/droid-mode/bin/dm`
389
+ Fallback to personal: `~/.factory/skills/droid-mode/bin/dm`
365
390
 
366
391
  ### Gotchas
367
392
 
368
- - **Keep commands minimal**: Don't add timing, progress bars, or diagnostics unless requested
369
- - **macOS compatibility**: Avoid GNU-specific flags (`date +%s%3N`, `sed -i`, `grep -P`)
370
- - **Surgical execution**: Execute exactly what's needed, nothing more
371
- - **Disabled servers work**: `"disabled": true` prevents context bloat but servers remain accessible via dm
393
+ - **Use `dm call` for single tools** - Don't create workflow files for simple calls
394
+ - **Keep commands minimal** - No timing, progress bars, or diagnostics unless requested
395
+ - **macOS compatibility** - Avoid GNU-specific flags (`date +%s%3N`, `sed -i`, `grep -P`)
396
+ - **Disabled servers work** - `"disabled": true` prevents context bloat but servers remain accessible
372
397
  ```
373
398
 
374
399
  </details>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "droid-mode",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Progressive Code-Mode MCP integration for Factory.ai Droid - access MCP tools without context bloat",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",
@@ -35,11 +35,14 @@ If workspace path fails with "not found", use personal path.
35
35
  |-------|---------|---------|
36
36
  | 1 | `dm servers` | Discover available MCP servers |
37
37
  | 2 | `dm index --server X` | List tools (name, description, required params) |
38
- | 3 | `dm hydrate tool1 tool2 --server X` | Get full schemas + TypeScript types |
39
- | 4 | `dm run --workflow file.js --tools a,b --server X` | Execute procedural workflow |
38
+ | 3 | `dm hydrate tool --server X` | Get full schema + TypeScript types |
39
+ | **4** | **`dm call tool --server X`** | **Execute tool directly (primary)** |
40
+ | 5 | `dm run --workflow file.js --server X` | Multi-tool workflow (advanced) |
40
41
 
41
42
  All commands accept `--server <name>`. If only one server exists, it's auto-selected.
42
43
 
44
+ **Use `dm call` for single tool calls. Use `dm run` only for multi-tool workflows.**
45
+
43
46
  ## Key Insight
44
47
 
45
48
  Servers with `disabled: true` in `mcp.json` are **fully available** to droid-mode:
@@ -59,22 +62,30 @@ All droid-mode commands are safe to rerun:
59
62
 
60
63
  No cleanup required between invocations.
61
64
 
62
- ## Tool Execution Options
65
+ ## Tool Execution
66
+
67
+ **Primary: Direct Call (`dm call`)**
63
68
 
64
- **Option 1: Direct MCP Call (Single Tool)**
69
+ For single tool calls (most common use case):
65
70
 
66
71
  ```bash
67
- # 1. Hydrate the tool schema
68
- dm hydrate search_documents --server contextrepo
72
+ # Hydrate once (caches schema)
73
+ dm hydrate list_collections --server context-repo
69
74
 
70
- # 2. Call via MCP server directly (tool now available in context)
75
+ # Call directly - no workflow file needed
76
+ dm call list_collections --server context-repo
77
+ dm call list_collections --server context-repo --args '{"limit": 5}'
71
78
  ```
72
79
 
73
- No workflow file needed for single tool calls.
80
+ Results returned directly as JSON. This is the **preferred method** for interactive use.
81
+
82
+ **Advanced: Workflows (`dm run`)**
74
83
 
75
- **Option 2: Procedural Workflow (Multiple Tools)**
84
+ For multi-tool orchestration with loops, conditionals, or pre-programmed patterns:
76
85
 
77
- For loops, conditionals, or chaining multiple calls, use `dm run`:
86
+ ```bash
87
+ dm run --server context-repo --tools a,b,c --workflow script.js
88
+ ```
78
89
 
79
90
  | Input | Flag | Required | Example |
80
91
  |-------|------|----------|---------|
@@ -82,6 +93,8 @@ For loops, conditionals, or chaining multiple calls, use `dm run`:
82
93
  | Tool list | `--tools` | Yes | `search,query` |
83
94
  | Server name | `--server` | If multiple servers | `contextrepo` |
84
95
 
96
+ Use workflows for complex automation, not everyday single-tool calls.
97
+
85
98
  ## Naming Convention
86
99
 
87
100
  Tool names use **snake_case** in CLI flags but **camelCase** in workflow code:
@@ -81,7 +81,17 @@ export function createToolApi(opts) {
81
81
  hasStructured: !!res?.structured,
82
82
  textLength: (res?.text || "").length,
83
83
  };
84
- return res.structured ?? (res.text ? { text: res.text } : res.raw);
84
+ // Return structured data if available
85
+ if (res.structured) return res.structured;
86
+ // Auto-parse JSON text responses for better workflow UX
87
+ if (res.text) {
88
+ try {
89
+ return JSON.parse(res.text);
90
+ } catch {
91
+ return { text: res.text };
92
+ }
93
+ }
94
+ return res.raw;
85
95
  } catch (err) {
86
96
  lastError = err;
87
97
  traceItem.retries = attempt;