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,731 @@
1
+ HUMAN:
2
+ Write down spec for CLI + WebUI for configuration
3
+
4
+ Tech stack: NodeJS, MongoDB, EJS, TailwindCDN,DaisyUICDN, Vue3CDN (No deps) (modular) (< 500 LOC per file)
5
+
6
+ AI:
7
+ ## 1. Overview
8
+
9
+ **SUPERCLI** is a **cloud-defined dynamic CLI** whose commands are generated from a central configuration.
10
+ Configuration is managed through a **Web UI** and stored in **MongoDB**.
11
+
12
+ The CLI runtime loads command definitions from the cloud, caches them locally, and executes commands through adapters such as:
13
+
14
+ * OpenAPI
15
+ * MCP servers
16
+ * HTTP
17
+ * Custom integrations
18
+
19
+ ---
20
+
21
+ # 2. System Architecture
22
+
23
+ ```
24
+ +-------------------+
25
+ | Web UI |
26
+ | Vue + EJS + TW |
27
+ +---------+---------+
28
+ |
29
+ |
30
+ REST / RPC API
31
+ |
32
+ v
33
+ +-------------------+
34
+ | NodeJS Backend |
35
+ | config service |
36
+ +---------+---------+
37
+ |
38
+ v
39
+ MongoDB
40
+ |
41
+ |
42
+ CLI fetches config
43
+ |
44
+ v
45
+ +-------------------+
46
+ | SUPERCLI |
47
+ | local runtime |
48
+ +-------------------+
49
+ ```
50
+
51
+ ---
52
+
53
+ # 3. Core Concepts
54
+
55
+ ## Command
56
+
57
+ A command is defined as:
58
+
59
+ ```
60
+ namespace resource action
61
+ ```
62
+
63
+ Example:
64
+
65
+ ```
66
+ referential users fetch
67
+ ```
68
+
69
+ Execution:
70
+
71
+ ```
72
+ supercli referential users fetch --id 42
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Adapters
78
+
79
+ Execution backends.
80
+
81
+ Supported adapters:
82
+
83
+ ```
84
+ openapi
85
+ mcp
86
+ http
87
+ shell
88
+ custom
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Namespaces
94
+
95
+ Logical grouping.
96
+
97
+ Examples:
98
+
99
+ ```
100
+ referential
101
+ infra
102
+ billing
103
+ ai
104
+ ```
105
+
106
+ ---
107
+
108
+ # 4. MongoDB Data Model
109
+
110
+ ## commands
111
+
112
+ ```
113
+ {
114
+ _id,
115
+ namespace: "referential",
116
+ resource: "users",
117
+ action: "fetch",
118
+
119
+ description: "Fetch a user",
120
+
121
+ adapter: "openapi",
122
+
123
+ adapterConfig: {
124
+ specId: "referential-api",
125
+ operationId: "getUser"
126
+ },
127
+
128
+ arguments: [
129
+ {
130
+ name: "id",
131
+ type: "string",
132
+ required: true
133
+ }
134
+ ],
135
+
136
+ createdAt,
137
+ updatedAt
138
+ }
139
+ ```
140
+
141
+ ---
142
+
143
+ ## openapi_specs
144
+
145
+ ```
146
+ {
147
+ _id,
148
+ name: "referential-api",
149
+ url: "https://api.company.com/openapi.json",
150
+ auth: "oauth"
151
+ }
152
+ ```
153
+
154
+ ---
155
+
156
+ ## mcp_servers
157
+
158
+ ```
159
+ {
160
+ _id,
161
+ name: "ai-tools",
162
+ url: "https://mcp.company.com"
163
+ }
164
+ ```
165
+
166
+ ---
167
+
168
+ ## adapters_custom
169
+
170
+ ```
171
+ {
172
+ _id,
173
+ name: "deployLambda",
174
+ type: "node",
175
+ file: "integrations/deployLambda.js"
176
+ }
177
+ ```
178
+
179
+ ---
180
+
181
+ ## settings
182
+
183
+ ```
184
+ {
185
+ key: "config_version",
186
+ value: "abc123"
187
+ }
188
+ ```
189
+
190
+ Used for CLI cache invalidation.
191
+
192
+ ---
193
+
194
+ # 5. CLI Specification
195
+
196
+ ## Binary
197
+
198
+ ```
199
+ supercli
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Command Syntax
205
+
206
+ ```
207
+ supercli <namespace> <resource> <action> [args]
208
+ ```
209
+
210
+ Example:
211
+
212
+ ```
213
+ supercli referential users fetch --id 42
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Built-in Commands
219
+
220
+ ### help
221
+
222
+ ```
223
+ supercli help
224
+ ```
225
+
226
+ Lists namespaces.
227
+
228
+ ---
229
+
230
+ ### config refresh
231
+
232
+ ```
233
+ supercli config refresh
234
+ ```
235
+
236
+ Forces cache refresh.
237
+
238
+ ---
239
+
240
+ ### config show
241
+
242
+ ```
243
+ supercli config show
244
+ ```
245
+
246
+ Displays current configuration version.
247
+
248
+ ---
249
+
250
+ # 6. CLI Config Cache
251
+
252
+ Location:
253
+
254
+ ```
255
+ ~/.supercli/config.json
256
+ ```
257
+
258
+ Example:
259
+
260
+ ```
261
+ {
262
+ version: "abc123",
263
+ ttl: 3600,
264
+ fetched_at: 17000000,
265
+ commands: []
266
+ }
267
+ ```
268
+
269
+ ---
270
+
271
+ ## Cache Algorithm
272
+
273
+ Startup:
274
+
275
+ ```
276
+ if cache.exists():
277
+ if ttl expired:
278
+ fetch new config
279
+ else:
280
+ fetch config
281
+ ```
282
+
283
+ ---
284
+
285
+ # 7. CLI Config Fetch API
286
+
287
+ ### GET
288
+
289
+ ```
290
+ GET /api/config
291
+ ```
292
+
293
+ Response:
294
+
295
+ ```
296
+ {
297
+ version: "abc123",
298
+ ttl: 3600,
299
+ commands: [...]
300
+ }
301
+ ```
302
+
303
+ ---
304
+
305
+ # 8. CLI Execution Flow
306
+
307
+ Example command:
308
+
309
+ ```
310
+ supercli referential users fetch --id 42
311
+ ```
312
+
313
+ Flow:
314
+
315
+ 1 parse CLI arguments
316
+
317
+ 2 load config
318
+
319
+ 3 find command
320
+
321
+ ```
322
+ referential.users.fetch
323
+ ```
324
+
325
+ 4 select adapter
326
+
327
+ ```
328
+ openapi
329
+ ```
330
+
331
+ 5 execute adapter
332
+
333
+ ---
334
+
335
+ # 9. Adapter Interface
336
+
337
+ NodeJS module interface:
338
+
339
+ ```
340
+ execute(command, args, context)
341
+ ```
342
+
343
+ Example:
344
+
345
+ ```
346
+ module.exports = async function(command, args, ctx) {
347
+ }
348
+ ```
349
+
350
+ ---
351
+
352
+ # 10. OpenAPI Adapter
353
+
354
+ Responsibilities:
355
+
356
+ * load spec
357
+ * map operationId
358
+ * build request
359
+ * execute HTTP call
360
+
361
+ Example mapping:
362
+
363
+ ```
364
+ operationId: getUser
365
+ ```
366
+
367
+ Request:
368
+
369
+ ```
370
+ GET /users/{id}
371
+ ```
372
+
373
+ ---
374
+
375
+ # 11. MCP Adapter
376
+
377
+ Execution:
378
+
379
+ ```
380
+ POST MCP server tool call
381
+ ```
382
+
383
+ Config example:
384
+
385
+ ```
386
+ {
387
+ server: "ai-tools",
388
+ tool: "summarize"
389
+ }
390
+ ```
391
+
392
+ ---
393
+
394
+ # 12. Backend API Specification
395
+
396
+ ## Config
397
+
398
+ ### GET
399
+
400
+ ```
401
+ /api/config
402
+ ```
403
+
404
+ Returns CLI config.
405
+
406
+ ---
407
+
408
+ ## Commands CRUD
409
+
410
+ ### GET
411
+
412
+ ```
413
+ /api/commands
414
+ ```
415
+
416
+ ---
417
+
418
+ ### POST
419
+
420
+ ```
421
+ /api/commands
422
+ ```
423
+
424
+ ---
425
+
426
+ ### PUT
427
+
428
+ ```
429
+ /api/commands/:id
430
+ ```
431
+
432
+ ---
433
+
434
+ ### DELETE
435
+
436
+ ```
437
+ /api/commands/:id
438
+ ```
439
+
440
+ ---
441
+
442
+ ## OpenAPI specs
443
+
444
+ ```
445
+ /api/openapi
446
+ ```
447
+
448
+ ---
449
+
450
+ ## MCP servers
451
+
452
+ ```
453
+ /api/mcp
454
+ ```
455
+
456
+ ---
457
+
458
+ # 13. Backend Folder Structure
459
+
460
+ ```
461
+ /server
462
+
463
+ app.js
464
+
465
+ /routes
466
+ commands.js
467
+ config.js
468
+ openapi.js
469
+ mcp.js
470
+
471
+ /services
472
+ configService.js
473
+ adapterRegistry.js
474
+
475
+ /adapters
476
+ openapi.js
477
+ mcp.js
478
+ http.js
479
+ shell.js
480
+
481
+ /views
482
+ layout.ejs
483
+ commands.ejs
484
+ command-edit.ejs
485
+ openapi.ejs
486
+ mcp.ejs
487
+
488
+ /public
489
+ /js
490
+ /css
491
+ ```
492
+
493
+ ---
494
+
495
+ # 14. Web UI Specification
496
+
497
+ Rendered using:
498
+
499
+ ```
500
+ EJS + Vue3 CDN
501
+ Tailwind CDN
502
+ DaisyUI CDN
503
+ ```
504
+
505
+ ---
506
+
507
+ # 15. Web UI Pages
508
+
509
+ ## Dashboard
510
+
511
+ Shows:
512
+
513
+ * number of commands
514
+ * namespaces
515
+ * adapters
516
+
517
+ ---
518
+
519
+ ## Commands
520
+
521
+ List of commands.
522
+
523
+ Table:
524
+
525
+ ```
526
+ namespace
527
+ resource
528
+ action
529
+ adapter
530
+ description
531
+ ```
532
+
533
+ Actions:
534
+
535
+ ```
536
+ edit
537
+ delete
538
+ ```
539
+
540
+ ---
541
+
542
+ ## Command Editor
543
+
544
+ Fields:
545
+
546
+ ```
547
+ namespace
548
+ resource
549
+ action
550
+ description
551
+ adapter
552
+ adapter config
553
+ arguments
554
+ ```
555
+
556
+ Arguments editor:
557
+
558
+ ```
559
+ name
560
+ type
561
+ required
562
+ ```
563
+
564
+ ---
565
+
566
+ ## OpenAPI Specs
567
+
568
+ List:
569
+
570
+ ```
571
+ name
572
+ url
573
+ auth
574
+ ```
575
+
576
+ Button:
577
+
578
+ ```
579
+ import spec
580
+ ```
581
+
582
+ ---
583
+
584
+ ## MCP Servers
585
+
586
+ List:
587
+
588
+ ```
589
+ name
590
+ url
591
+ ```
592
+
593
+ ---
594
+
595
+ # 16. Vue UI Structure
596
+
597
+ Single Vue app:
598
+
599
+ ```
600
+ window.app = Vue.createApp({})
601
+ ```
602
+
603
+ Components:
604
+
605
+ ```
606
+ CommandList
607
+ CommandEditor
608
+ SpecList
609
+ MCPList
610
+ ```
611
+
612
+ All inline modules.
613
+
614
+ ---
615
+
616
+ # 17. Example WebUI Page
617
+
618
+ ```
619
+ /commands
620
+ ```
621
+
622
+ Table:
623
+
624
+ ```
625
+ +------------+----------+--------+----------+
626
+ | namespace | resource | action | adapter |
627
+ +------------+----------+--------+----------+
628
+ | referential| users | fetch | openapi |
629
+ ```
630
+
631
+ Button:
632
+
633
+ ```
634
+ Create command
635
+ ```
636
+
637
+ ---
638
+
639
+ # 18. Security
640
+
641
+ Authentication optional for v1.
642
+
643
+ Possible future:
644
+
645
+ ```
646
+ JWT
647
+ API tokens
648
+ ```
649
+
650
+ ---
651
+
652
+ # 19. Config Versioning
653
+
654
+ Whenever config changes:
655
+
656
+ ```
657
+ settings.config_version++
658
+ ```
659
+
660
+ CLI detects version mismatch and refreshes.
661
+
662
+ ---
663
+
664
+ # 20. File Size Constraints
665
+
666
+ All files:
667
+
668
+ ```
669
+ < 500 LOC
670
+ ```
671
+
672
+ Strategy:
673
+
674
+ * small service modules
675
+ * simple routes
676
+ * lightweight adapters
677
+
678
+ ---
679
+
680
+ # 21. Example CLI Usage
681
+
682
+ ```
683
+ supercli help
684
+ ```
685
+
686
+ ```
687
+ supercli referential
688
+ ```
689
+
690
+ ```
691
+ supercli referential users
692
+ ```
693
+
694
+ ```
695
+ supercli referential users fetch --id 42
696
+ ```
697
+
698
+ ---
699
+
700
+ # 22. MVP Scope
701
+
702
+ Included:
703
+
704
+ * dynamic CLI commands
705
+ * config cloud sync
706
+ * OpenAPI adapter
707
+ * MCP adapter
708
+ * Web UI config
709
+
710
+ Excluded:
711
+
712
+ * RBAC
713
+ * workflow engine
714
+ * plugin marketplace
715
+
716
+ ---
717
+
718
+ # 23. Future Extensions
719
+
720
+ Potential additions:
721
+
722
+ * workflow commands
723
+ * CLI auto-complete
724
+ * role-based commands
725
+ * CLI auth profiles
726
+ * SDK generation
727
+ * command analytics
728
+
729
+ ---
730
+
731
+ If you want, I can also design the **actual Mongo schema + CLI runtime architecture that fits in ~1500 LOC total**, which would make a very clean OSS project.