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,726 @@
1
+ Below is a **minimal architecture that fits ~1500 LOC total** while keeping **every file <500 LOC**, modular, and aligned with:
2
+
3
+ * NodeJS
4
+ * MongoDB (native driver)
5
+ * EJS
6
+ * Vue3 CDN
7
+ * Tailwind CDN
8
+ * DaisyUI CDN
9
+ * zero build tools
10
+
11
+ The system has **two binaries**:
12
+
13
+ ```
14
+ /server -> config control plane
15
+ /cli -> runtime CLI
16
+ ```
17
+
18
+ ---
19
+
20
+ # 1. Project Structure
21
+
22
+ ```
23
+ supercli/
24
+
25
+ server/
26
+ app.js
27
+ db.js
28
+
29
+ routes/
30
+ commands.js
31
+ config.js
32
+ specs.js
33
+ mcp.js
34
+
35
+ services/
36
+ configService.js
37
+
38
+ views/
39
+ layout.ejs
40
+ commands.ejs
41
+ command-edit.ejs
42
+ specs.ejs
43
+ mcp.ejs
44
+
45
+ public/
46
+ app.js
47
+
48
+ cli/
49
+ supercli.js
50
+ config.js
51
+ executor.js
52
+
53
+ adapters/
54
+ openapi.js
55
+ mcp.js
56
+ http.js
57
+ ```
58
+
59
+ Approx LOC:
60
+
61
+ ```
62
+ server
63
+ app.js 150
64
+ db.js 30
65
+ routes/* 350
66
+ services/* 200
67
+ views 200
68
+ public/app.js 150
69
+
70
+ cli
71
+ supercli.js 150
72
+ config.js 120
73
+ executor.js 120
74
+ adapters/* 200
75
+ ```
76
+
77
+ Total ≈ **1500 LOC**
78
+
79
+ ---
80
+
81
+ # 2. MongoDB Schema
82
+
83
+ No ODM.
84
+
85
+ Collections:
86
+
87
+ ```
88
+ commands
89
+ specs
90
+ mcp
91
+ settings
92
+ ```
93
+
94
+ ---
95
+
96
+ ## commands
97
+
98
+ ```
99
+ {
100
+ _id: ObjectId,
101
+
102
+ namespace: "referential",
103
+ resource: "users",
104
+ action: "fetch",
105
+
106
+ description: "Fetch user",
107
+
108
+ adapter: "openapi",
109
+
110
+ adapterConfig: {
111
+ spec: "referential-api",
112
+ operationId: "getUser"
113
+ },
114
+
115
+ args: [
116
+ {
117
+ name: "id",
118
+ type: "string",
119
+ required: true
120
+ }
121
+ ],
122
+
123
+ createdAt: ISODate(),
124
+ updatedAt: ISODate()
125
+ }
126
+ ```
127
+
128
+ ---
129
+
130
+ ## specs
131
+
132
+ ```
133
+ {
134
+ _id: ObjectId,
135
+ name: "referential-api",
136
+ url: "https://api.company.com/openapi.json",
137
+ auth: "none"
138
+ }
139
+ ```
140
+
141
+ ---
142
+
143
+ ## mcp
144
+
145
+ ```
146
+ {
147
+ _id: ObjectId,
148
+ name: "ai-tools",
149
+ url: "https://mcp.company.com"
150
+ }
151
+ ```
152
+
153
+ ---
154
+
155
+ ## settings
156
+
157
+ ```
158
+ {
159
+ key: "config_version",
160
+ value: "1"
161
+ }
162
+ ```
163
+
164
+ ---
165
+
166
+ # 3. Server Runtime
167
+
168
+ ## server/app.js
169
+
170
+ Responsibilities:
171
+
172
+ ```
173
+ express server
174
+ view engine
175
+ static assets
176
+ mount routes
177
+ ```
178
+
179
+ Example skeleton:
180
+
181
+ ```javascript
182
+ const express = require("express")
183
+ const path = require("path")
184
+
185
+ const commands = require("./routes/commands")
186
+ const config = require("./routes/config")
187
+ const specs = require("./routes/specs")
188
+ const mcp = require("./routes/mcp")
189
+
190
+ const app = express()
191
+
192
+ app.use(express.json())
193
+ app.use(express.urlencoded({ extended:true }))
194
+
195
+ app.set("view engine","ejs")
196
+ app.set("views",path.join(__dirname,"views"))
197
+
198
+ app.use("/static",express.static("public"))
199
+
200
+ app.use("/api/config",config)
201
+ app.use("/api/commands",commands)
202
+ app.use("/api/specs",specs)
203
+ app.use("/api/mcp",mcp)
204
+
205
+ app.get("/",(req,res)=>res.redirect("/commands"))
206
+
207
+ app.listen(3000)
208
+ ```
209
+
210
+ ---
211
+
212
+ # 4. Config Service
213
+
214
+ Central piece.
215
+
216
+ ## services/configService.js
217
+
218
+ Responsibilities:
219
+
220
+ ```
221
+ aggregate commands
222
+ attach specs
223
+ return CLI config
224
+ ```
225
+
226
+ Example response:
227
+
228
+ ```
229
+ {
230
+ version: "12",
231
+ ttl: 3600,
232
+ commands: [...]
233
+ }
234
+ ```
235
+
236
+ Pseudo:
237
+
238
+ ```javascript
239
+ async function getCLIConfig(db){
240
+
241
+ const commands = await db.collection("commands").find().toArray()
242
+
243
+ const version = await db.collection("settings")
244
+ .findOne({key:"config_version"})
245
+
246
+ return {
247
+ version: version.value,
248
+ ttl: 3600,
249
+ commands
250
+ }
251
+
252
+ }
253
+ ```
254
+
255
+ ---
256
+
257
+ # 5. CLI Config Endpoint
258
+
259
+ ## GET
260
+
261
+ ```
262
+ /api/config
263
+ ```
264
+
265
+ Response:
266
+
267
+ ```
268
+ {
269
+ version: "12",
270
+ ttl: 3600,
271
+ commands: [...]
272
+ }
273
+ ```
274
+
275
+ ---
276
+
277
+ # 6. CLI Runtime
278
+
279
+ Binary:
280
+
281
+ ```
282
+ cli/supercli.js
283
+ ```
284
+
285
+ Usage:
286
+
287
+ ```
288
+ supercli <namespace> <resource> <action> [args]
289
+ ```
290
+
291
+ Example:
292
+
293
+ ```
294
+ supercli referential users fetch --id 42
295
+ ```
296
+
297
+ ---
298
+
299
+ # 7. CLI Cache
300
+
301
+ Location:
302
+
303
+ ```
304
+ ~/.supercli/config.json
305
+ ```
306
+
307
+ Structure:
308
+
309
+ ```
310
+ {
311
+ version: "12",
312
+ fetchedAt: 1700000,
313
+ ttl: 3600,
314
+ commands: [...]
315
+ }
316
+ ```
317
+
318
+ ---
319
+
320
+ ## cli/config.js
321
+
322
+ Responsibilities:
323
+
324
+ ```
325
+ load cache
326
+ check ttl
327
+ fetch remote config
328
+ ```
329
+
330
+ Pseudo:
331
+
332
+ ```javascript
333
+ async function loadConfig(){
334
+
335
+ if(cacheExists()){
336
+ if(ttlValid()){
337
+ return readCache()
338
+ }
339
+ }
340
+
341
+ const res = await fetch(SERVER+"/api/config")
342
+ const cfg = await res.json()
343
+
344
+ writeCache(cfg)
345
+
346
+ return cfg
347
+ }
348
+ ```
349
+
350
+ ---
351
+
352
+ # 8. CLI Command Parsing
353
+
354
+ Example input:
355
+
356
+ ```
357
+ supercli referential users fetch --id 42
358
+ ```
359
+
360
+ Parse:
361
+
362
+ ```
363
+ namespace = referential
364
+ resource = users
365
+ action = fetch
366
+ args = { id:42 }
367
+ ```
368
+
369
+ Minimal parser:
370
+
371
+ ```
372
+ process.argv
373
+ ```
374
+
375
+ ---
376
+
377
+ # 9. Command Resolution
378
+
379
+ Inside CLI:
380
+
381
+ ```
382
+ cmd = config.commands.find(
383
+ c.namespace==ns &&
384
+ c.resource==res &&
385
+ c.action==act
386
+ )
387
+ ```
388
+
389
+ ---
390
+
391
+ # 10. Executor
392
+
393
+ ## cli/executor.js
394
+
395
+ Responsibilities:
396
+
397
+ ```
398
+ select adapter
399
+ execute command
400
+ ```
401
+
402
+ Example:
403
+
404
+ ```
405
+ switch(adapter)
406
+ ```
407
+
408
+ ```
409
+ openapi
410
+ mcp
411
+ http
412
+ ```
413
+
414
+ ---
415
+
416
+ Example:
417
+
418
+ ```javascript
419
+ async function execute(cmd,args){
420
+
421
+ if(cmd.adapter==="openapi"){
422
+ return openapi.execute(cmd,args)
423
+ }
424
+
425
+ if(cmd.adapter==="mcp"){
426
+ return mcp.execute(cmd,args)
427
+ }
428
+
429
+ }
430
+ ```
431
+
432
+ ---
433
+
434
+ # 11. OpenAPI Adapter
435
+
436
+ ## adapters/openapi.js
437
+
438
+ Responsibilities:
439
+
440
+ ```
441
+ fetch spec
442
+ resolve operation
443
+ build request
444
+ execute
445
+ ```
446
+
447
+ Pseudo:
448
+
449
+ ```
450
+ load spec
451
+ find operationId
452
+ resolve path
453
+ replace params
454
+ call API
455
+ ```
456
+
457
+ Example:
458
+
459
+ ```javascript
460
+ async function execute(cmd,args){
461
+
462
+ const spec = await fetchSpec(cmd.adapterConfig.spec)
463
+
464
+ const op = findOperation(spec,cmd.adapterConfig.operationId)
465
+
466
+ const url = buildUrl(op,args)
467
+
468
+ const res = await fetch(url)
469
+
470
+ return res.json()
471
+
472
+ }
473
+ ```
474
+
475
+ ---
476
+
477
+ # 12. MCP Adapter
478
+
479
+ ## adapters/mcp.js
480
+
481
+ Example request:
482
+
483
+ ```
484
+ POST /tool
485
+ ```
486
+
487
+ Body:
488
+
489
+ ```
490
+ {
491
+ tool:"summarize",
492
+ input:{...}
493
+ }
494
+ ```
495
+
496
+ ---
497
+
498
+ # 13. Web UI
499
+
500
+ Server-rendered using **EJS + Vue CDN**.
501
+
502
+ Pages:
503
+
504
+ ```
505
+ /commands
506
+ /commands/new
507
+ /specs
508
+ /mcp
509
+ ```
510
+
511
+ ---
512
+
513
+ # 14. layout.ejs
514
+
515
+ Includes:
516
+
517
+ ```
518
+ tailwind CDN
519
+ daisyUI CDN
520
+ vue CDN
521
+ ```
522
+
523
+ Example:
524
+
525
+ ```
526
+ https://cdn.tailwindcss.com
527
+ https://cdn.jsdelivr.net/npm/daisyui
528
+ https://unpkg.com/vue@3
529
+ ```
530
+
531
+ ---
532
+
533
+ # 15. Commands Page
534
+
535
+ Table view:
536
+
537
+ ```
538
+ namespace
539
+ resource
540
+ action
541
+ adapter
542
+ ```
543
+
544
+ Example row:
545
+
546
+ ```
547
+ referential users fetch openapi
548
+ ```
549
+
550
+ Buttons:
551
+
552
+ ```
553
+ edit
554
+ delete
555
+ ```
556
+
557
+ ---
558
+
559
+ # 16. Command Editor
560
+
561
+ Fields:
562
+
563
+ ```
564
+ namespace
565
+ resource
566
+ action
567
+ adapter
568
+ description
569
+ adapterConfig
570
+ args
571
+ ```
572
+
573
+ Args UI:
574
+
575
+ ```
576
+ + add arg
577
+ name
578
+ type
579
+ required
580
+ ```
581
+
582
+ Handled by Vue.
583
+
584
+ ---
585
+
586
+ # 17. Vue App
587
+
588
+ Single file:
589
+
590
+ ```
591
+ public/app.js
592
+ ```
593
+
594
+ Example:
595
+
596
+ ```javascript
597
+ const app = Vue.createApp({
598
+
599
+ data(){
600
+ return {
601
+ commands:[],
602
+ loading:true
603
+ }
604
+ },
605
+
606
+ async mounted(){
607
+ const r = await fetch("/api/commands")
608
+ this.commands = await r.json()
609
+ this.loading=false
610
+ }
611
+
612
+ })
613
+
614
+ app.mount("#app")
615
+ ```
616
+
617
+ ---
618
+
619
+ # 18. Config Version Bump
620
+
621
+ Whenever command/spec/mcp changes:
622
+
623
+ ```
624
+ db.settings.updateOne(
625
+ {key:"config_version"},
626
+ {$inc:{value:1}}
627
+ )
628
+ ```
629
+
630
+ This forces CLI refresh.
631
+
632
+ ---
633
+
634
+ # 19. Example CLI Session
635
+
636
+ ```
637
+ supercli help
638
+ ```
639
+
640
+ Output:
641
+
642
+ ```
643
+ namespaces:
644
+ referential
645
+ ai
646
+ infra
647
+ ```
648
+
649
+ ---
650
+
651
+ ```
652
+ supercli referential
653
+ ```
654
+
655
+ ```
656
+ resources:
657
+ users
658
+ groups
659
+ ```
660
+
661
+ ---
662
+
663
+ ```
664
+ supercli referential users
665
+ ```
666
+
667
+ ```
668
+ actions:
669
+ fetch
670
+ list
671
+ create
672
+ ```
673
+
674
+ ---
675
+
676
+ ```
677
+ supercli referential users fetch --id 42
678
+ ```
679
+
680
+ Result:
681
+
682
+ ```
683
+ {
684
+ id:42,
685
+ name:"Alice"
686
+ }
687
+ ```
688
+
689
+ ---
690
+
691
+ # 20. Key Design Principle
692
+
693
+ The CLI **knows nothing about commands**.
694
+
695
+ It only understands:
696
+
697
+ ```
698
+ namespace resource action
699
+ ```
700
+
701
+ Everything else is **data-driven**.
702
+
703
+ ---
704
+
705
+ # 21. Why This Architecture Works
706
+
707
+ It creates a **platform primitive**:
708
+
709
+ ```
710
+ cloud defined CLI
711
+ ```
712
+
713
+ Which can orchestrate:
714
+
715
+ ```
716
+ APIs
717
+ AI tools
718
+ infra
719
+ automation
720
+ ```
721
+
722
+ Through a single runtime.
723
+
724
+ ---
725
+
726
+ If you'd like, I can also show you the **3 killer features that would make this project explode on GitHub (and differentiate it from existing CLIs)**.