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.
- package/.env.example +14 -0
- package/README.md +173 -0
- package/cli/adapters/http.js +72 -0
- package/cli/adapters/mcp.js +193 -0
- package/cli/adapters/openapi.js +160 -0
- package/cli/ask.js +208 -0
- package/cli/config.js +133 -0
- package/cli/executor.js +117 -0
- package/cli/help-json.js +46 -0
- package/cli/mcp-local.js +72 -0
- package/cli/plan-runtime.js +32 -0
- package/cli/planner.js +67 -0
- package/cli/skills.js +240 -0
- package/cli/supercli.js +704 -0
- package/docs/features/adapters.md +25 -0
- package/docs/features/agent-friendly.md +28 -0
- package/docs/features/ask.md +32 -0
- package/docs/features/config-sync.md +22 -0
- package/docs/features/execution-plans.md +25 -0
- package/docs/features/observability.md +22 -0
- package/docs/features/skills.md +25 -0
- package/docs/features/storage.md +25 -0
- package/docs/features/workflows.md +33 -0
- package/docs/initial/AGENTS_FRIENDLY_TOOLS.md +553 -0
- package/docs/initial/agent-friendly.md +447 -0
- package/docs/initial/architecture.md +436 -0
- package/docs/initial/built-in-mcp-server.md +64 -0
- package/docs/initial/command-plan.md +532 -0
- package/docs/initial/core-features-2.md +428 -0
- package/docs/initial/core-features.md +366 -0
- package/docs/initial/dag.md +20 -0
- package/docs/initial/description.txt +9 -0
- package/docs/initial/idea.txt +564 -0
- package/docs/initial/initial-spec-details.md +726 -0
- package/docs/initial/initial-spec.md +731 -0
- package/docs/initial/mcp-local-mode.md +53 -0
- package/docs/initial/mcp-sse-mode.md +54 -0
- package/docs/initial/skills-support.md +246 -0
- package/docs/initial/storage-adapter-example.md +155 -0
- package/docs/initial/supercli-vs-gwc.md +109 -0
- package/examples/mcp-sse/install-demo.js +86 -0
- package/examples/mcp-sse/server.js +81 -0
- package/examples/mcp-stdio/install-demo.js +78 -0
- package/examples/mcp-stdio/server.js +50 -0
- package/package.json +21 -0
- package/server/app.js +59 -0
- package/server/public/app.js +18 -0
- package/server/routes/ask.js +92 -0
- package/server/routes/commands.js +126 -0
- package/server/routes/config.js +58 -0
- package/server/routes/jobs.js +122 -0
- package/server/routes/mcp.js +79 -0
- package/server/routes/plans.js +134 -0
- package/server/routes/specs.js +79 -0
- package/server/services/configService.js +88 -0
- package/server/storage/adapter.js +32 -0
- package/server/storage/file.js +64 -0
- package/server/storage/mongo.js +55 -0
- package/server/views/command-edit.ejs +110 -0
- package/server/views/commands.ejs +49 -0
- package/server/views/jobs.ejs +72 -0
- package/server/views/layout.ejs +42 -0
- package/server/views/mcp.ejs +80 -0
- package/server/views/partials/foot.ejs +5 -0
- package/server/views/partials/head.ejs +27 -0
- package/server/views/specs.ejs +91 -0
- package/tests/test-cli.js +367 -0
- package/tests/test-mcp.js +189 -0
- package/tests/test-openapi.js +101 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
The main risk of a **cloud-defined CLI** is that as commands grow (hundreds → thousands), the CLI becomes **slow, heavy, and chatty**.
|
|
2
|
+
|
|
3
|
+
The trick used by large systems (like Kubernetes or Terraform) is **lazy resolution + namespace indexing**.
|
|
4
|
+
|
|
5
|
+
The CLI **never loads the whole command universe**.
|
|
6
|
+
|
|
7
|
+
Instead it resolves commands **progressively**.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# 1. The Problem at Scale
|
|
12
|
+
|
|
13
|
+
If the server sends the full config:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
10 namespaces
|
|
17
|
+
200 resources
|
|
18
|
+
2000 commands
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The CLI cache becomes:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
5–10 MB JSON
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Problems:
|
|
28
|
+
|
|
29
|
+
* slow startup
|
|
30
|
+
* slow autocomplete
|
|
31
|
+
* frequent config refreshes
|
|
32
|
+
* unnecessary data
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
# 2. The Solution: Hierarchical Command Index
|
|
37
|
+
|
|
38
|
+
Instead of returning **all commands**, the API exposes a **tree index**.
|
|
39
|
+
|
|
40
|
+
Think of commands as a **filesystem**.
|
|
41
|
+
|
|
42
|
+
Example structure:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
/
|
|
46
|
+
├ referential
|
|
47
|
+
│ ├ users
|
|
48
|
+
│ │ ├ fetch
|
|
49
|
+
│ │ ├ list
|
|
50
|
+
│ │ └ create
|
|
51
|
+
│ └ groups
|
|
52
|
+
│
|
|
53
|
+
├ infra
|
|
54
|
+
│ └ service
|
|
55
|
+
│ ├ deploy
|
|
56
|
+
│ └ logs
|
|
57
|
+
│
|
|
58
|
+
└ ai
|
|
59
|
+
└ summarize
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The CLI only loads **what the user navigates**.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
# 3. Progressive Resolution
|
|
67
|
+
|
|
68
|
+
Example CLI session:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
supercli <TAB>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
CLI requests:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
GET /api/tree
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Response:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"namespaces": [
|
|
85
|
+
"referential",
|
|
86
|
+
"infra",
|
|
87
|
+
"ai"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
User continues:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
supercli referential <TAB>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
CLI calls:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
GET /api/tree/referential
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Response:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"resources": [
|
|
111
|
+
"users",
|
|
112
|
+
"groups"
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
Next:
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
supercli referential users <TAB>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Request:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
GET /api/tree/referential/users
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Response:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"actions": [
|
|
136
|
+
"fetch",
|
|
137
|
+
"list",
|
|
138
|
+
"create"
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
Finally execution:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
supercli referential users fetch
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
CLI fetches full command:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
GET /api/command/referential/users/fetch
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
# 4. CLI Cache Structure
|
|
160
|
+
|
|
161
|
+
Instead of one big config file:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
~/.supercli/
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Use segmented cache.
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
~/.supercli/cache/
|
|
171
|
+
|
|
172
|
+
namespaces.json
|
|
173
|
+
referential.resources.json
|
|
174
|
+
referential.users.actions.json
|
|
175
|
+
command.referential.users.fetch.json
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
This keeps each cache file tiny.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
# 5. CLI Runtime Algorithm
|
|
183
|
+
|
|
184
|
+
Command parsing:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
supercli referential users fetch --id 42
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Resolution steps:
|
|
191
|
+
|
|
192
|
+
1. resolve namespace
|
|
193
|
+
2. resolve resource
|
|
194
|
+
3. resolve action
|
|
195
|
+
4. fetch command spec
|
|
196
|
+
|
|
197
|
+
Pseudo logic:
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
resolveNamespace()
|
|
201
|
+
resolveResource()
|
|
202
|
+
resolveAction()
|
|
203
|
+
fetchCommand()
|
|
204
|
+
execute()
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Each step is cached.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
# 6. Why This Scales
|
|
212
|
+
|
|
213
|
+
With **5000 commands**:
|
|
214
|
+
|
|
215
|
+
| Strategy | Data loaded |
|
|
216
|
+
| ------------ | ----------- |
|
|
217
|
+
| Full config | 5–10 MB |
|
|
218
|
+
| Tree index | ~2 KB |
|
|
219
|
+
| Command spec | ~1 KB |
|
|
220
|
+
|
|
221
|
+
CLI startup remains **instant**.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
# 7. Server-Side Index
|
|
226
|
+
|
|
227
|
+
Server stores commands normally.
|
|
228
|
+
|
|
229
|
+
But builds an index:
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
namespace
|
|
233
|
+
resource
|
|
234
|
+
action
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Mongo query:
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
db.commands.distinct("namespace")
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
or:
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
db.commands.distinct("resource",{namespace:"referential"})
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Very fast.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
# 8. Autocomplete Becomes Cheap
|
|
254
|
+
|
|
255
|
+
Shell autocomplete simply queries the CLI.
|
|
256
|
+
|
|
257
|
+
Example:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
__supercli_complete referential users
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
CLI resolves locally from cache or calls:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
GET /api/tree/referential/users
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Latency:
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
<20ms
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
# 9. Bonus Trick: ETags
|
|
278
|
+
|
|
279
|
+
Each tree response includes an **etag**.
|
|
280
|
+
|
|
281
|
+
Example:
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
ETag: tree-v42
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
CLI requests:
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
If-None-Match: tree-v42
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Server returns:
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
304 Not Modified
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Meaning:
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
zero bandwidth
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
# 10. Further Optimization: Namespace Packs
|
|
308
|
+
|
|
309
|
+
Large organizations may have:
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
10000 commands
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Namespaces can be grouped:
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
referential
|
|
319
|
+
infra
|
|
320
|
+
billing
|
|
321
|
+
ai
|
|
322
|
+
platform
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
CLI can preload frequently used namespaces.
|
|
326
|
+
|
|
327
|
+
Example config:
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
~/.supercli/profile.json
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
{
|
|
335
|
+
"prefetch": ["referential","infra"]
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
# 11. Lazy Adapter Loading
|
|
342
|
+
|
|
343
|
+
Another important trick.
|
|
344
|
+
|
|
345
|
+
Adapters are loaded **only when needed**.
|
|
346
|
+
|
|
347
|
+
Example:
|
|
348
|
+
|
|
349
|
+
```
|
|
350
|
+
adapters/
|
|
351
|
+
openapi.js
|
|
352
|
+
mcp.js
|
|
353
|
+
http.js
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Runtime:
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
require("./adapters/"+adapter)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
So a user running **OpenAPI commands** never loads MCP code.
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
# 12. Execution Shortcut
|
|
367
|
+
|
|
368
|
+
For frequently used commands, cache the spec:
|
|
369
|
+
|
|
370
|
+
```
|
|
371
|
+
~/.supercli/cache/command.hash
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Next run:
|
|
375
|
+
|
|
376
|
+
```
|
|
377
|
+
skip server entirely
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
# 13. Resulting Performance
|
|
383
|
+
|
|
384
|
+
With the above design:
|
|
385
|
+
|
|
386
|
+
| Metric | Value |
|
|
387
|
+
| ----------------- | ------------ |
|
|
388
|
+
| CLI startup | <10 ms |
|
|
389
|
+
| Autocomplete | <20 ms |
|
|
390
|
+
| Command execution | network only |
|
|
391
|
+
| Cache size | <200 KB |
|
|
392
|
+
|
|
393
|
+
Even with **thousands of commands**.
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
# 14. The Elegant Part
|
|
398
|
+
|
|
399
|
+
The CLI becomes:
|
|
400
|
+
|
|
401
|
+
```
|
|
402
|
+
a command resolver
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Not:
|
|
406
|
+
|
|
407
|
+
```
|
|
408
|
+
a command registry
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Which is why it scales.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
# 15. Final Architecture
|
|
416
|
+
|
|
417
|
+
```
|
|
418
|
+
Web UI
|
|
419
|
+
|
|
|
420
|
+
v
|
|
421
|
+
Control Plane API
|
|
422
|
+
|
|
|
423
|
+
MongoDB commands
|
|
424
|
+
|
|
|
425
|
+
Hierarchical index
|
|
426
|
+
|
|
|
427
|
+
CLI runtime
|
|
428
|
+
|
|
|
429
|
+
Adapter execution
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
The CLI stays **tiny and fast**, while the **command universe can grow arbitrarily**.
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
If you want, I can also show you **one design tweak that would make SUPERCLI extremely attractive to AI agents and MCP ecosystems**, which could position it as a **universal tool registry for LLMs**.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Absolutely — that’s a **natural extension** and fits perfectly with the SUPERCLI philosophy. Here’s why it’s interesting and how it would work:
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 💡 Built-in MCP Server for SUPERCLI
|
|
6
|
+
|
|
7
|
+
### What it Enables
|
|
8
|
+
|
|
9
|
+
1. **Dynamic Agent Integration**
|
|
10
|
+
|
|
11
|
+
* Agents can connect over **MCP (Modular Control Protocol)** using SSE/STDIO.
|
|
12
|
+
* Commands, schemas, and DAGs are automatically exposed in a structured, versioned way.
|
|
13
|
+
* No need for agents to hardcode knowledge of SUPERCLI commands.
|
|
14
|
+
|
|
15
|
+
2. **Real-Time Event Streaming**
|
|
16
|
+
|
|
17
|
+
* Long-running commands can stream progress, logs, or DAG step completion via SSE.
|
|
18
|
+
* Agents can monitor execution, abort, or react dynamically without polling.
|
|
19
|
+
|
|
20
|
+
3. **Single-Call Semantics Preserved**
|
|
21
|
+
|
|
22
|
+
* The MCP server is just a transport layer. Execution is still **one-shot** per command.
|
|
23
|
+
* Optional DAG exposure can be streamed as events or included inline.
|
|
24
|
+
|
|
25
|
+
4. **Composable in Multi-Agent Systems**
|
|
26
|
+
|
|
27
|
+
* Multiple agents can subscribe to the MCP server.
|
|
28
|
+
* One agent triggers a command; others can observe DAG progress, results, or metadata.
|
|
29
|
+
|
|
30
|
+
5. **OSS-Friendly**
|
|
31
|
+
|
|
32
|
+
* Exposing SUPERCLI over MCP provides a **standardized API** for agentic workflows.
|
|
33
|
+
* Makes SUPERCLI a drop-in alternative to proprietary agent-driven CLIs like gws but **open source and ecosystem-agnostic**.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### Example Flow
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
Agent connects → subscribes to SUPERCLI MCP SSE
|
|
41
|
+
Agent sends: fetch users --id 42
|
|
42
|
+
Server computes DAG → executes steps
|
|
43
|
+
Server streams: DAG nodes as events (if requested) + final structured result
|
|
44
|
+
Agent consumes JSON, makes decisions, possibly triggers downstream commands
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Optional DAG**: Could be streamed incrementally, reducing token usage for very large workflows.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### Key Benefits
|
|
52
|
+
|
|
53
|
+
| Benefit | Why It Matters |
|
|
54
|
+
| ---------------------------- | -------------------------------------------------------------- |
|
|
55
|
+
| Real-time visibility | Agents can reason mid-execution or report status |
|
|
56
|
+
| Schema introspection via MCP | Agents discover commands dynamically, no prior hardcoding |
|
|
57
|
+
| Standardized transport | MCP SSE/STDIO works for both CLI clients and agentic pipelines |
|
|
58
|
+
| OSS extensibility | Any team can deploy SUPERCLI + MCP server internally or externally |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
If you want, I can **draft a full architecture diagram and flow** showing **SUPERCLI + built-in MCP server**, including optional DAG streaming, single-shot execution, and agent discovery — essentially how SUPERCLI becomes an **open, AI-first alternative to gws with universal applicability**.
|
|
63
|
+
|
|
64
|
+
Do you want me to do that next?
|