superacli 1.0.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 (69) hide show
  1. package/.env.example +14 -0
  2. package/README.md +173 -0
  3. package/cli/adapters/http.js +72 -0
  4. package/cli/adapters/mcp.js +193 -0
  5. package/cli/adapters/openapi.js +160 -0
  6. package/cli/ask.js +208 -0
  7. package/cli/config.js +133 -0
  8. package/cli/executor.js +117 -0
  9. package/cli/help-json.js +46 -0
  10. package/cli/mcp-local.js +72 -0
  11. package/cli/plan-runtime.js +32 -0
  12. package/cli/planner.js +67 -0
  13. package/cli/skills.js +240 -0
  14. package/cli/supercli.js +704 -0
  15. package/docs/features/adapters.md +25 -0
  16. package/docs/features/agent-friendly.md +28 -0
  17. package/docs/features/ask.md +32 -0
  18. package/docs/features/config-sync.md +22 -0
  19. package/docs/features/execution-plans.md +25 -0
  20. package/docs/features/observability.md +22 -0
  21. package/docs/features/skills.md +25 -0
  22. package/docs/features/storage.md +25 -0
  23. package/docs/features/workflows.md +33 -0
  24. package/docs/initial/AGENTS_FRIENDLY_TOOLS.md +553 -0
  25. package/docs/initial/agent-friendly.md +447 -0
  26. package/docs/initial/architecture.md +436 -0
  27. package/docs/initial/built-in-mcp-server.md +64 -0
  28. package/docs/initial/command-plan.md +532 -0
  29. package/docs/initial/core-features-2.md +428 -0
  30. package/docs/initial/core-features.md +366 -0
  31. package/docs/initial/dag.md +20 -0
  32. package/docs/initial/description.txt +9 -0
  33. package/docs/initial/idea.txt +564 -0
  34. package/docs/initial/initial-spec-details.md +726 -0
  35. package/docs/initial/initial-spec.md +731 -0
  36. package/docs/initial/mcp-local-mode.md +53 -0
  37. package/docs/initial/mcp-sse-mode.md +54 -0
  38. package/docs/initial/skills-support.md +246 -0
  39. package/docs/initial/storage-adapter-example.md +155 -0
  40. package/docs/initial/supercli-vs-gwc.md +109 -0
  41. package/examples/mcp-sse/install-demo.js +86 -0
  42. package/examples/mcp-sse/server.js +81 -0
  43. package/examples/mcp-stdio/install-demo.js +78 -0
  44. package/examples/mcp-stdio/server.js +50 -0
  45. package/package.json +21 -0
  46. package/server/app.js +59 -0
  47. package/server/public/app.js +18 -0
  48. package/server/routes/ask.js +92 -0
  49. package/server/routes/commands.js +126 -0
  50. package/server/routes/config.js +58 -0
  51. package/server/routes/jobs.js +122 -0
  52. package/server/routes/mcp.js +79 -0
  53. package/server/routes/plans.js +134 -0
  54. package/server/routes/specs.js +79 -0
  55. package/server/services/configService.js +88 -0
  56. package/server/storage/adapter.js +32 -0
  57. package/server/storage/file.js +64 -0
  58. package/server/storage/mongo.js +55 -0
  59. package/server/views/command-edit.ejs +110 -0
  60. package/server/views/commands.ejs +49 -0
  61. package/server/views/jobs.ejs +72 -0
  62. package/server/views/layout.ejs +42 -0
  63. package/server/views/mcp.ejs +80 -0
  64. package/server/views/partials/foot.ejs +5 -0
  65. package/server/views/partials/head.ejs +27 -0
  66. package/server/views/specs.ejs +91 -0
  67. package/tests/test-cli.js +367 -0
  68. package/tests/test-mcp.js +189 -0
  69. package/tests/test-openapi.js +101 -0
@@ -0,0 +1,532 @@
1
+ The idea of **Command Plans** is extremely powerful because it makes the CLI **predictable, safe, and explainable for agents** before execution. It turns SUPERCLI from a simple command runner into a **deterministic execution planner**.
2
+
3
+ Below is a **practical spec that fits your stack and architecture**.
4
+
5
+ ---
6
+
7
+ # 1. Concept
8
+
9
+ A **Command Plan** is a dry-run execution graph returned by SUPERCLI before the command actually runs.
10
+
11
+ Instead of executing:
12
+
13
+ ```bash
14
+ supercli referential users fetch --id 42
15
+ ```
16
+
17
+ An agent can request:
18
+
19
+ ```bash
20
+ supercli plan referential users fetch --id 42
21
+ ```
22
+
23
+ Response:
24
+
25
+ ```json
26
+ {
27
+ "version": "1.0",
28
+ "command": "referential.users.fetch",
29
+ "plan_id": "plan_abc123",
30
+ "steps": [
31
+ {
32
+ "step": 1,
33
+ "type": "resolve_command",
34
+ "description": "Resolve command definition from config cache"
35
+ },
36
+ {
37
+ "step": 2,
38
+ "type": "validate_args",
39
+ "description": "Validate input arguments"
40
+ },
41
+ {
42
+ "step": 3,
43
+ "type": "adapter_request",
44
+ "adapter": "openapi",
45
+ "method": "GET",
46
+ "url": "/users/{id}"
47
+ },
48
+ {
49
+ "step": 4,
50
+ "type": "transform_output",
51
+ "description": "Normalize response into output schema"
52
+ }
53
+ ],
54
+ "estimated_duration_ms": 80,
55
+ "side_effects": false
56
+ }
57
+ ```
58
+
59
+ The agent can then decide to:
60
+
61
+ ```bash
62
+ supercli execute plan_abc123
63
+ ```
64
+
65
+ ---
66
+
67
+ # 2. Plan Lifecycle
68
+
69
+ ### Create Plan
70
+
71
+ ```bash
72
+ supercli plan <namespace> <resource> <action> [args]
73
+ ```
74
+
75
+ Example:
76
+
77
+ ```bash
78
+ supercli plan referential users fetch --id 42
79
+ ```
80
+
81
+ ### Execute Plan
82
+
83
+ ```bash
84
+ supercli execute <plan_id>
85
+ ```
86
+
87
+ ### Inspect Plan
88
+
89
+ ```bash
90
+ supercli plan inspect <plan_id>
91
+ ```
92
+
93
+ ### Cancel Plan
94
+
95
+ ```bash
96
+ supercli plan cancel <plan_id>
97
+ ```
98
+
99
+ ---
100
+
101
+ # 3. Plan Storage (MongoDB)
102
+
103
+ Collection:
104
+
105
+ ```
106
+ plans
107
+ ```
108
+
109
+ Document:
110
+
111
+ ```json
112
+ {
113
+ "_id": "plan_abc123",
114
+ "command": "referential.users.fetch",
115
+ "args": {
116
+ "id": "42"
117
+ },
118
+ "steps": [],
119
+ "status": "planned",
120
+ "created_at": "2026-03-08T10:00:00Z",
121
+ "expires_at": "2026-03-08T10:05:00Z"
122
+ }
123
+ ```
124
+
125
+ TTL index:
126
+
127
+ ```
128
+ expires_at
129
+ ```
130
+
131
+ Plans auto-delete.
132
+
133
+ ---
134
+
135
+ # 4. Step Types
136
+
137
+ The runtime produces standardized steps.
138
+
139
+ ### resolve_command
140
+
141
+ Load command spec.
142
+
143
+ ### validate_args
144
+
145
+ Validate arguments schema.
146
+
147
+ ### adapter_request
148
+
149
+ External API call.
150
+
151
+ Example:
152
+
153
+ ```json
154
+ {
155
+ "type": "adapter_request",
156
+ "adapter": "openapi",
157
+ "method": "GET",
158
+ "url": "/users/{id}"
159
+ }
160
+ ```
161
+
162
+ ### transform_output
163
+
164
+ Normalize response to schema.
165
+
166
+ ### side_effect_operation
167
+
168
+ For mutating commands.
169
+
170
+ Example:
171
+
172
+ ```json
173
+ {
174
+ "type": "side_effect_operation",
175
+ "resource": "users",
176
+ "operation": "create"
177
+ }
178
+ ```
179
+
180
+ ---
181
+
182
+ # 5. Safety Flags
183
+
184
+ Plans explicitly show risk.
185
+
186
+ Example:
187
+
188
+ ```json
189
+ {
190
+ "side_effects": true,
191
+ "risk_level": "medium"
192
+ }
193
+ ```
194
+
195
+ Risk levels:
196
+
197
+ ```
198
+ safe
199
+ low
200
+ medium
201
+ high
202
+ destructive
203
+ ```
204
+
205
+ Example destructive command:
206
+
207
+ ```bash
208
+ supercli infra cluster delete
209
+ ```
210
+
211
+ Plan:
212
+
213
+ ```json
214
+ {
215
+ "risk_level": "destructive"
216
+ }
217
+ ```
218
+
219
+ Agents can refuse automatically.
220
+
221
+ ---
222
+
223
+ # 6. Dependency Graph
224
+
225
+ Plans can include dependencies.
226
+
227
+ Example:
228
+
229
+ ```bash
230
+ supercli infra deploy service
231
+ ```
232
+
233
+ Plan:
234
+
235
+ ```json
236
+ {
237
+ "steps": [
238
+ {"step":1,"type":"build"},
239
+ {"step":2,"type":"push_image","depends_on":[1]},
240
+ {"step":3,"type":"deploy","depends_on":[2]}
241
+ ]
242
+ }
243
+ ```
244
+
245
+ This creates a **directed execution graph**.
246
+
247
+ ---
248
+
249
+ # 7. HTTP API
250
+
251
+ SUPERCLI server exposes plan endpoints.
252
+
253
+ ### Create Plan
254
+
255
+ ```
256
+ POST /api/plans
257
+ ```
258
+
259
+ Body:
260
+
261
+ ```json
262
+ {
263
+ "command": "referential.users.fetch",
264
+ "args": {"id": "42"}
265
+ }
266
+ ```
267
+
268
+ Response:
269
+
270
+ ```json
271
+ {
272
+ "plan_id": "plan_abc123"
273
+ }
274
+ ```
275
+
276
+ ---
277
+
278
+ ### Inspect Plan
279
+
280
+ ```
281
+ GET /api/plans/:id
282
+ ```
283
+
284
+ ---
285
+
286
+ ### Execute Plan
287
+
288
+ ```
289
+ POST /api/plans/:id/execute
290
+ ```
291
+
292
+ ---
293
+
294
+ # 8. CLI Implementation Structure (NodeJS)
295
+
296
+ ```
297
+ /cli
298
+ plan.js
299
+ execute.js
300
+
301
+ /runtime
302
+ planner.js
303
+ executor.js
304
+
305
+ /adapters
306
+ openapi.js
307
+ mcp.js
308
+ ```
309
+
310
+ ---
311
+
312
+ # 9. Planner Logic
313
+
314
+ File:
315
+
316
+ ```
317
+ runtime/planner.js
318
+ ```
319
+
320
+ Pseudo:
321
+
322
+ ```javascript
323
+ async function createPlan(command, args) {
324
+
325
+ const spec = await loadCommandSpec(command)
326
+
327
+ const steps = []
328
+
329
+ steps.push({
330
+ type: "resolve_command"
331
+ })
332
+
333
+ steps.push({
334
+ type: "validate_args"
335
+ })
336
+
337
+ if (spec.adapter === "openapi") {
338
+ steps.push({
339
+ type: "adapter_request",
340
+ method: spec.method,
341
+ url: spec.path
342
+ })
343
+ }
344
+
345
+ steps.push({
346
+ type: "transform_output"
347
+ })
348
+
349
+ return {
350
+ steps,
351
+ side_effects: spec.mutation === true
352
+ }
353
+ }
354
+ ```
355
+
356
+ ---
357
+
358
+ # 10. Execution Engine
359
+
360
+ Executor runs steps sequentially.
361
+
362
+ ```
363
+ runtime/executor.js
364
+ ```
365
+
366
+ Pseudo:
367
+
368
+ ```javascript
369
+ async function executePlan(plan) {
370
+
371
+ for (const step of plan.steps) {
372
+
373
+ switch(step.type) {
374
+
375
+ case "adapter_request":
376
+ await callAdapter(step)
377
+ break
378
+
379
+ case "validate_args":
380
+ validateArgs(plan.args)
381
+ break
382
+ }
383
+
384
+ }
385
+
386
+ }
387
+ ```
388
+
389
+ ---
390
+
391
+ # 11. WebUI Plan Viewer
392
+
393
+ Route:
394
+
395
+ ```
396
+ /plans/:id
397
+ ```
398
+
399
+ UI displays:
400
+
401
+ ```
402
+ Execution Plan
403
+
404
+ 1 Resolve command
405
+ 2 Validate arguments
406
+ 3 Call OpenAPI GET /users/{id}
407
+ 4 Transform output
408
+ ```
409
+
410
+ With badges:
411
+
412
+ ```
413
+ SAFE
414
+ NO SIDE EFFECTS
415
+ ```
416
+
417
+ ---
418
+
419
+ # 12. Agent Workflow
420
+
421
+ Agents now use:
422
+
423
+ ### discover commands
424
+
425
+ ```
426
+ supercli commands
427
+ ```
428
+
429
+ ### inspect command
430
+
431
+ ```
432
+ supercli inspect referential users fetch
433
+ ```
434
+
435
+ ### plan execution
436
+
437
+ ```
438
+ supercli plan referential users fetch --id 42
439
+ ```
440
+
441
+ ### evaluate risk
442
+
443
+ ### execute
444
+
445
+ ```
446
+ supercli execute plan_abc123
447
+ ```
448
+
449
+ This gives **LLMs deterministic control**.
450
+
451
+ ---
452
+
453
+ # 13. Massive Future Feature
454
+
455
+ Plans could support **multi-command orchestration**.
456
+
457
+ Example:
458
+
459
+ ```bash
460
+ supercli plan workflow create-user-and-assign-role
461
+ ```
462
+
463
+ Plan:
464
+
465
+ ```
466
+ 1 create user
467
+ 2 fetch role
468
+ 3 assign role
469
+ ```
470
+
471
+ Agents get a **complete DAG**.
472
+
473
+ ---
474
+
475
+ # 14. Why This Is Very Powerful
476
+
477
+ Most CLIs are:
478
+
479
+ ```
480
+ execute-only
481
+ ```
482
+
483
+ SUPERCLI becomes:
484
+
485
+ ```
486
+ discoverable
487
+ introspectable
488
+ plannable
489
+ executable
490
+ ```
491
+
492
+ This aligns perfectly with **AI tool ecosystems** like:
493
+
494
+ * Model Context Protocol
495
+ * LangChain
496
+ * OpenAI API
497
+
498
+ ---
499
+
500
+ # 15. Final Architecture
501
+
502
+ SUPERCLI becomes **four layers**:
503
+
504
+ ```
505
+ CLI
506
+ Planner
507
+ Executor
508
+ Adapters
509
+ ```
510
+
511
+ Adapters:
512
+
513
+ ```
514
+ OpenAPI
515
+ MCP
516
+ GraphQL
517
+ Custom
518
+ ```
519
+
520
+ Planner guarantees:
521
+
522
+ ```
523
+ determinism
524
+ safety
525
+ inspectability
526
+ ```
527
+
528
+ ---
529
+
530
+ If you want, I can also show the **next evolution that would make SUPERCLI extremely unique**:
531
+
532
+ **"Self-Generating CLIs"** — where SUPERCLI automatically converts an entire **OpenAPI spec into a fully functional CLI namespace with zero code.**