-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand-registry.ts
More file actions
1379 lines (1350 loc) · 45.6 KB
/
command-registry.ts
File metadata and controls
1379 lines (1350 loc) · 45.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { getModelAliasText } from '../config.js';
export type CommandCategory =
| 'core'
| 'safety'
| 'integrations'
| 'engine'
| 'sessions'
| 'shortcuts'
| 'exports'
| 'prompts'
| 'extensions';
export interface CommandDefinition {
name: string;
aliases?: string[];
usage: string;
description: string;
category: CommandCategory;
/** When true the entry appears in help text but not in tab completion. */
helpOnly?: boolean;
/** Extended help text shown by `/help <command>`. */
detailedHelp?: string;
/** Example usages shown by `/help <command>`. */
examples?: string[];
}
const registry: CommandDefinition[] = [];
export function registerCommand(def: CommandDefinition): void {
registry.push(def);
}
export function getRegisteredCommands(): CommandDefinition[] {
return [...registry];
}
export function getCommandNames(): string[] {
const names: string[] = [];
for (const def of registry) {
if (def.helpOnly) continue;
names.push(def.name);
if (def.aliases) {
for (const alias of def.aliases) {
names.push(alias);
}
}
}
return names;
}
export function getCommandsByCategory(): Map<CommandCategory, CommandDefinition[]> {
const map = new Map<CommandCategory, CommandDefinition[]>();
for (const def of registry) {
const list = map.get(def.category);
if (list) {
list.push(def);
} else {
map.set(def.category, [def]);
}
}
return map;
}
/**
* Find a command by its canonical name or any alias.
* Returns the first matching definition, or null.
*/
export function findCommand(nameOrAlias: string): CommandDefinition | null {
const normalized = nameOrAlias.startsWith('/') ? nameOrAlias : `/${nameOrAlias}`;
for (const def of registry) {
if (def.name === normalized) return def;
if (def.aliases?.includes(normalized)) return def;
}
return null;
}
/**
* Find all commands in a category by category name.
*/
export function getCommandsForCategory(categoryName: string): CommandDefinition[] {
const lower = categoryName.toLowerCase();
return registry.filter((def) => def.category === lower);
}
const CATEGORY_ORDER: CommandCategory[] = [
'core',
'safety',
'integrations',
'engine',
'sessions',
'shortcuts',
'exports',
'prompts',
'extensions',
];
const CATEGORY_LABELS: Record<CommandCategory, string> = {
core: 'Core',
safety: 'Safety & Policy',
integrations: 'Integrations',
engine: 'Workflow Engine',
sessions: 'Sessions',
shortcuts: 'Shortcut Commands',
exports: 'Exports',
prompts: 'Prompts & Skills',
extensions: 'Extensions',
};
export function getCategoryOrder(): CommandCategory[] {
return [...CATEGORY_ORDER];
}
export function getCategoryLabel(category: CommandCategory): string {
return CATEGORY_LABELS[category];
}
export function registerAllCommands(): void {
// Avoid double-registration if called more than once
if (registry.length > 0) return;
// ── Core ──────────────────────────────────────────────────────────
registerCommand({
name: '/help',
aliases: ['/commands', '/h'],
usage: '/help [command|category]',
description: 'Show help (optionally for a specific command or category)',
category: 'core',
detailedHelp:
'Show the full command reference, or detailed help for a specific command or category.',
examples: ['/help', '/help model', '/help sessions'],
});
registerCommand({
name: '/capabilities',
aliases: ['/caps'],
usage: '/capabilities [area]',
description: 'Show the CLI grouped by common jobs-to-be-done',
category: 'core',
detailedHelp:
'Summarize the CLI by workflow area instead of raw command count. Useful for discovering the right command family for setup, runtime, workflow-studio, curation, operations, or resources.',
examples: ['/capabilities', '/capabilities workflow', '/caps curation'],
});
registerCommand({
name: '/clear',
aliases: ['/c'],
usage: '/clear',
description: 'Reset conversation history',
category: 'core',
});
registerCommand({
name: '/history',
aliases: ['/hist'],
usage: '/history',
description: 'Show conversation turn count',
category: 'core',
});
registerCommand({
name: '/model',
aliases: ['/m'],
usage: '/model <name>',
description: `Switch model (${getModelAliasText('list')})`,
category: 'core',
detailedHelp: 'Switch the active Claude model for this session.',
examples: ['/model sonnet', '/model haiku', '/model opus'],
});
registerCommand({
name: '/usage',
usage: '/usage on|off',
description: 'Enable or disable usage summaries',
category: 'core',
});
registerCommand({
name: '/metrics',
usage: '/metrics [json] [reset]',
description: 'Show session metrics, token usage, and tool breakdown',
category: 'core',
});
registerCommand({
name: '/whoami',
usage: '/whoami',
description: 'Show full session dashboard (org, model, profile, engine, cost)',
category: 'core',
});
registerCommand({
name: '/cost',
usage: '/cost',
description: 'Show estimated session cost based on token usage',
category: 'core',
});
registerCommand({
name: '/trends',
usage: '/trends [7d|30d|90d|all]',
description: 'Show token usage and cost trends over time',
category: 'core',
detailedHelp:
'Aggregates session metrics from persistent storage. Shows daily breakdown, top sessions by cost, and monthly cost projection.',
examples: ['/trends', '/trends 7d', '/trends 30d', '/trends all'],
});
registerCommand({
name: '/debug',
usage: '/debug on|off',
description: 'Toggle debug logging for this session',
category: 'core',
});
registerCommand({
name: '/copy',
usage: '/copy',
description: 'Copy the last assistant response to clipboard',
category: 'core',
});
registerCommand({
name: '/attach',
usage: '/attach <path>',
description: 'Attach a file or image to the next message',
category: 'core',
});
registerCommand({
name: '/attachments',
usage: '/attachments',
description: 'List staged attachments',
category: 'core',
});
registerCommand({
name: '/attach-clear',
usage: '/attach-clear',
description: 'Clear staged attachments',
category: 'core',
});
// ── Safety & Policy ───────────────────────────────────────────────
registerCommand({
name: '/apply',
usage: '/apply on|off',
description: 'Enable or disable write operations',
category: 'safety',
});
registerCommand({
name: '/agentic',
usage: '/agentic on|off',
description: 'Enable or disable structured MCP metadata',
category: 'safety',
});
registerCommand({
name: '/redact',
usage: '/redact on|off',
description: 'Enable or disable PII redaction',
category: 'safety',
});
registerCommand({
name: '/audit',
usage: '/audit on|off [detail]',
description: 'Toggle tool audit logging (optional excerpts)',
category: 'safety',
});
registerCommand({
name: '/audit-show',
usage: '/audit-show [session] [tool=name] [errors] [limit=20]',
description: 'Show recent audit entries',
category: 'safety',
});
registerCommand({
name: '/audit-clear',
usage: '/audit-clear [session]',
description: 'Clear audit log for a session',
category: 'safety',
});
registerCommand({
name: '/permissions',
usage: '/permissions [list|clear]',
description: 'List or clear stored permissions',
category: 'safety',
});
registerCommand({
name: '/policy',
usage: '/policy list|set|unset|clear|edit|init|import',
description: 'Manage policy overrides',
category: 'safety',
});
registerCommand({
name: '/policy export',
usage: '/policy export [local|global] [out=path] [--unsafe-path]',
description: 'Export policy overrides',
category: 'safety',
helpOnly: true,
});
registerCommand({
name: '/policy import',
usage: '/policy import <path> [merge|replace]',
description: 'Import policy overrides from JSON',
category: 'safety',
helpOnly: true,
});
// ── Integrations ──────────────────────────────────────────────────
registerCommand({
name: '/integrations',
usage: '/integrations',
description: 'Show integration status',
category: 'integrations',
});
registerCommand({
name: '/integrations status',
usage: '/integrations status',
description: 'Alias for /integrations',
category: 'integrations',
helpOnly: true,
});
registerCommand({
name: '/integrations setup',
usage: '/integrations setup [integration]',
description: 'Run integration setup wizard',
category: 'integrations',
helpOnly: true,
});
registerCommand({
name: '/integrations health',
usage: '/integrations health [integration] [--detailed]',
description: 'Show integration readiness and config health',
category: 'integrations',
helpOnly: true,
examples: ['/integrations health', '/integrations health shopify --detailed'],
});
registerCommand({
name: '/integrations limits',
usage: '/integrations limits [integration]',
description: 'Show integration call/error and rate-limit telemetry',
category: 'integrations',
helpOnly: true,
examples: ['/integrations limits', '/integrations limits shopify'],
});
registerCommand({
name: '/integrations logs',
usage: '/integrations logs [integration] [--last 20]',
description: 'Show recent integration audit events',
category: 'integrations',
helpOnly: true,
examples: ['/integrations logs', '/integrations logs shopify --last 50'],
});
// ── Workflow Engine ──────────────────────────────────────────────
registerCommand({
name: '/engine',
usage: '/engine',
description: 'Show workflow engine connection status',
category: 'engine',
detailedHelp: 'Display the current workflow engine connection status and configuration.',
examples: [
'/engine',
'/engine brands',
'/engine config pull acme-co',
'/engine executions acme-co',
],
});
registerCommand({
name: '/engine setup',
usage: '/engine setup',
description: 'Configure the workflow engine connection',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine init',
usage: '/engine init [brand-slug]',
description: 'Initialize .stateset/<brand>/ config-as-code directory with scaffold files',
category: 'engine',
helpOnly: true,
examples: ['/engine init my-brand'],
});
registerCommand({
name: '/engine config',
usage: '/engine config [pull|push|validate|history] <brand>',
description: 'Manage local .stateset brand workflow studio config against the engine',
category: 'engine',
helpOnly: true,
detailedHelp:
'Pull a brand config from the workflow engine into .stateset/<brand>, validate local file consistency, inspect config version history, or push local workflow studio config back to the engine.',
examples: [
'/engine config pull acme-co',
'/engine config history acme-co',
'/engine config validate acme-co',
'/engine config push acme-co',
],
});
registerCommand({
name: '/engine config pull',
usage: '/engine config pull <brand-slug|brand-id>',
description: 'Pull brand workflow studio config into .stateset/<brand>',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine config validate',
usage: '/engine config validate <brand-slug>',
description: 'Validate local brand workflow studio config files',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine config history',
usage: '/engine config history <brand-slug|brand-id>',
description: 'Show config version history for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine config show',
usage: '/engine config show <brand-slug|brand-id>',
description: 'Show the effective remote workflow studio config for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine config push',
usage: '/engine config push <brand-slug>',
description: 'Push local brand workflow studio config to the engine',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine activate',
usage: '/engine activate <brand-slug|brand-id> [config-version]',
description: 'Activate the current config for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine validate',
usage: '/engine validate <brand-slug|brand-id>',
description: 'Run remote engine validation for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine billing',
usage:
'/engine billing <brand-slug|brand-id> | profile <brand> <json-file> | sync <brand> [--limit <n>] | contract <brand> [upsert <json-file>] | periods <brand> [--status <status>] | close-period <brand> <period-id> | rated-outcomes <brand> [filters] | reconciliation <brand>',
description:
'Manage brand billing profile, contract, periods, rated outcomes, and reconciliation',
category: 'engine',
helpOnly: true,
examples: [
'/engine billing acme-co',
'/engine billing sync acme-co --limit 100',
'/engine billing contract acme-co upsert billing-contract.json',
'/engine billing periods acme-co --status open',
'/engine billing rated-outcomes acme-co --period-id <period-id>',
'/engine billing reconciliation acme-co',
],
});
registerCommand({
name: '/engine brands',
usage: '/engine brands [slug]',
description: 'List or search brands in the workflow engine',
category: 'engine',
helpOnly: true,
examples: ['/engine brands', '/engine brands acme-co'],
});
registerCommand({
name: '/engine brands show',
usage: '/engine brands show <brand-slug|brand-id>',
description: 'Show brand details from the workflow engine',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine brands create',
usage: '/engine brands create <json-file>',
description: 'Create a brand from a JSON file (supports template bootstrap)',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine brands bootstrap',
usage:
'/engine brands bootstrap <brand-slug|brand-id> [ecommerce|subscription|knowledge_base] [activate]',
description: 'Create or repair a workflow-studio brand and bootstrap response automation',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine brands update',
usage: '/engine brands update <brand-slug|brand-id> <json-file>',
description: 'Update a brand from a JSON patch file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine onboard',
usage: '/engine onboard <brand-slug|brand-id> [notes]',
description: 'Start an onboarding run for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine onboard list',
usage: '/engine onboard list <brand-slug|brand-id>',
description: 'List onboarding runs for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine onboard show',
usage: '/engine onboard show <brand-slug|brand-id> <run-id>',
description: 'Show a specific onboarding run',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine onboard update',
usage: '/engine onboard update <brand-slug|brand-id> <run-id> <status> [notes]',
description: 'Update onboarding run status or notes',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine migration',
usage: '/engine migration <brand-slug|brand-id>',
description: 'Show migration state for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine migration update',
usage: '/engine migration update <brand-slug|brand-id> <json-file>',
description: 'Update migration state for a brand from a JSON patch file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine parity',
usage: '/engine parity <brand-slug|brand-id> [from] [to]',
description: 'Show parity dashboard for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine health',
usage: '/engine health',
description: 'Check workflow engine health',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine dispatch-health',
usage: '/engine dispatch-health [--tenant-id <tenant-id>] [--limit <n>] [--offset <n>]',
description: 'Show dispatch health dashboard across brands',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine dispatch-guard',
usage:
'/engine dispatch-guard [--tenant-id <tenant-id>] [--apply true|false] [--minimum-health-status warning|critical] [--max-actions <n>]',
description: 'Plan or apply dispatch guard actions for unhealthy brands',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine executions',
usage: '/engine executions <brand-slug|brand-id> [status]',
description: 'List recent workflow executions for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine connectors',
usage:
'/engine connectors <brand-slug|brand-id> [create <json-file>|health <connector-id>|plan [loop-mode] [--source local|platform]|sync [loop-mode] [--source local|platform]|env [loop-mode] [dotenv|shell|json] [out=path] [--unsafe-path]]',
description:
'List connectors, create connectors, plan sync, export local secret env, or run health checks for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine connectors create',
usage: '/engine connectors <brand-slug|brand-id> create <json-file>',
description: 'Create a connector for a brand from a JSON file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine connectors plan',
usage:
'/engine connectors <brand-slug|brand-id> plan [subscriptions|returns|both] [--source local|platform]',
description:
'Show the workflow-studio connector sync plan for a brand from local or platform credentials',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine connectors sync',
usage:
'/engine connectors <brand-slug|brand-id> sync [subscriptions|returns|both] [--source local|platform]',
description:
'Write local connector config and create missing live connectors for a brand from local or platform credentials',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine connectors env',
usage:
'/engine connectors <brand-slug|brand-id> env [subscriptions|returns|both] [dotenv|shell|json] [out=path] [--unsafe-path]',
description: 'Inspect or export brand-scoped connector secret env vars for local workers',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine local',
usage:
'/engine local apply <brand-slug|brand-id> [subscriptions|returns|both] [out=path] [compose=path] [services=a,b,c] [--write-only] [--unsafe-path]',
description: 'Write brand-scoped env and optionally run docker compose for the local stack',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine test',
usage: '/engine test <brand-slug|brand-id> <ticket-id>',
description: 'Dispatch a dry-run workflow-studio test event for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine event',
usage: '/engine event <brand-slug|brand-id> <json-file> [idempotency-key]',
description: 'Ingest a workflow engine event payload from a JSON file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine outcomes',
usage:
'/engine outcomes <brand-slug|brand-id> [filters] | list <brand> [filters] [--limit <n>] [--offset <n>] | record <brand> <json-file>',
description: 'Show outcome summaries, list outcome records, or record an outcome',
category: 'engine',
helpOnly: true,
examples: [
'/engine outcomes acme-co --outcome-type automated_resolution',
'/engine outcomes list acme-co --status confirmed --limit 25',
'/engine outcomes record acme-co outcome.json',
],
});
registerCommand({
name: '/engine analyze',
usage:
'/engine analyze <brand-slug|brand-id> [--source <dir>] [--tickets <file|dir>] [--responses <file|dir>] [--out <dir>] [--apply] [--push] [--json]',
description:
'Analyze local ticket and response exports, generate a workflow config proposal, and optionally apply or push it',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine feedback-sync',
usage:
'/engine feedback-sync <brand-slug|brand-id> [--provider <gorgias|zendesk>] [--limit <n>] [--max-pages <n>] [--since-days <n>] [--analyze] [--apply] [--push] [--json]',
description:
'Sync recent live Gorgias or Zendesk feedback into a normalized local store and optionally analyze or apply the resulting proposal',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine templates',
usage: '/engine templates [key] [version]',
description: 'List or get workflow templates',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine templates create',
usage: '/engine templates create <json-file>',
description: 'Create a workflow template version from a JSON file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine templates update',
usage: '/engine templates update <template-key> <version> <json-file>',
description: 'Update a workflow template version from a JSON file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine policy-sets',
usage: '/engine policy-sets [key]',
description: 'List or get versioned policy sets',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine policy-sets get',
usage: '/engine policy-sets get <policy-set-key> [version]',
description: 'Get a policy set version',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine policy-sets create',
usage: '/engine policy-sets create <json-file>',
description: 'Create a policy set version from a JSON file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine policy-sets update',
usage: '/engine policy-sets update <policy-set-key> <version> <json-file>',
description: 'Update a policy set version from a JSON file',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine dlq',
usage: '/engine dlq <brand-slug|brand-id> [status]',
description: 'List dead-letter queue items for a brand',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine dlq retry',
usage: '/engine dlq retry <brand-slug|brand-id> <dlq-id>',
description: 'Retry a dead-letter queue item',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/engine dlq resolve',
usage: '/engine dlq resolve <brand-slug|brand-id> <dlq-id> [action] [notes]',
description: 'Resolve a dead-letter queue item',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/workflows',
aliases: ['/wf'],
usage: '/workflows [list|start|status|cancel|terminate|restart|review|retry]',
description: 'Manage workflow executions in the engine',
category: 'engine',
detailedHelp:
'List recent workflow executions for a brand, start new ones, check status, review, restart, cancel, terminate, or retry failed workflows.',
examples: [
'/workflows list acme-co',
'/workflows status <workflow-id>',
'/workflows cancel <workflow-id>',
'/workflows review <workflow-id> approve',
],
});
// ── Onboarding ──────────────────────────────────────────────────
registerCommand({
name: '/onboard',
usage: '/onboard [init]',
description: 'Interactive onboarding wizard — brand, integrations, KB, rules, workflow, deploy',
category: 'engine',
detailedHelp:
'Full CLI-first onboarding: create brand → connect integrations → ingest KB from local files → configure rules → build workflow config → write to .stateset/ → deploy to engine. Afterward use /engine config push <brand> for iterative updates.',
examples: ['/onboard', '/onboard init my-brand'],
});
registerCommand({
name: '/onboard init',
usage: '/onboard init [brand-slug]',
description: 'Initialize .stateset/<brand>/ config-as-code directory',
category: 'engine',
helpOnly: true,
});
// ── Fine-tuning ─────────────────────────────────────────────────
registerCommand({
name: '/finetune',
usage: '/finetune [list|export|validate|create|deploy]',
description: 'Fine-tuning pipeline: export evals → create job → deploy model',
category: 'engine',
detailedHelp:
'Manage the fine-tuning lifecycle. Export approved eval data into the SFT and DPO dataset formats used by workflow studio, validate datasets before training, create fine-tune job specs, and deploy fine-tuned models to workflow config.',
examples: [
'/finetune list',
'/finetune export --format all --validation-ratio 0.1',
'/finetune validate .stateset/finetune',
'/finetune create',
'/finetune deploy ft:gpt-4.1:stateset:...',
],
});
registerCommand({
name: '/finetune export',
usage:
'/finetune export [output-dir] [--format all|sft|dpo|openai-sft|studio-sft|trl-sft|studio-dpo|pair-dpo] [--status approved] [--validation-ratio 0.1]',
description: 'Export evals into workflow-studio SFT and DPO dataset files',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/finetune validate',
usage:
'/finetune validate [path] [--format auto|openai-sft|studio-sft|trl-sft|studio-dpo|pair-dpo]',
description: 'Validate exported training datasets before fine-tuning',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/finetune create',
usage: '/finetune create [dataset-file] [--method supervised|dpo]',
description: 'Create a new fine-tuning job spec from a validated dataset',
category: 'engine',
helpOnly: true,
});
registerCommand({
name: '/finetune deploy',
usage: '/finetune deploy <model-id>',
description: 'Deploy a fine-tuned model to workflow config',
category: 'engine',
helpOnly: true,
});
// ── Evals ───────────────────────────────────────────────────────
registerCommand({
name: '/evals',
usage: '/evals [list|create|create-from-response|get|update|delete|export|review|suggest|<id>]',
description: 'Manage evals and fine-tuning training examples',
category: 'shortcuts',
detailedHelp:
'List, create, seed from real responses, review, update, delete, export, or inspect eval records. Use /evals suggest to bootstrap quality criteria, /evals create-from-response to capture live agent outputs, then /finetune export to generate training data.',
examples: [
'/evals list',
'/evals create --name Accuracy --type quality --message "Where is my order?" --preferred "Your order is in transit."',
'/evals create-from-response resp-123 --seed rejected',
'/evals review',
'/evals update <eval-id> --status approved',
'/evals export --out .stateset/evals.json',
'/evals suggest',
],
});
registerCommand({
name: '/evals list',
usage: '/evals list [--limit N] [--offset N]',
description: 'List eval records',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals create',
usage:
'/evals create --name <name> --type <type> [--status <status>] [--message <text>] [--preferred <text>]',
description: 'Create an eval record',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals create-from-response',
usage:
'/evals create-from-response <response-id> [--seed preferred|rejected|none] [--name <name>] [--type <type>]',
description: 'Seed an eval from a stored agent response for curation and DPO review',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals get',
usage: '/evals get <eval-id>',
description: 'Show a single eval record',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals update',
usage: '/evals update <eval-id> [--status <status>] [--preferred <text>] [--rejected <text>]',
description: 'Update an eval record',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals delete',
usage: '/evals delete <eval-id>',
description: 'Delete an eval record',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals export',
usage: '/evals export [eval-id ...] [--out <path>]',
description: 'Export evals in fine-tuning format',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals review',
usage: '/evals review [eval-id] [--status pending]',
description: 'Interactively review pending evals',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/evals suggest',
aliases: ['/evals-suggest'],
usage: '/evals suggest',
description: 'Auto-suggest eval criteria based on conversation patterns',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets',
usage:
'/datasets [list|create|get|update|delete|add-entry|update-entry|delete-entry|import|export|<id>]',
description: 'Manage datasets and dataset entries for training-data curation',
category: 'shortcuts',
detailedHelp:
'List, create, update, delete, import, and export datasets, plus add or update message-based dataset entries used for SFT curation and workflow-studio training loops.',
examples: [
'/datasets list',
'/datasets create --name "Returns Triage"',
'/datasets add-entry <dataset-id> --messages \'[{"role":"user","content":"Where is my order?"}]\'',
'/datasets import <dataset-id> ./train.jsonl',
'/datasets export <dataset-id> --out .stateset/datasets/returns-triage.json',
],
});
registerCommand({
name: '/datasets create',
usage:
'/datasets create --name <name> [--description <text>] [--status active|archived|draft] [--metadata <json>]',
description: 'Create a dataset',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets get',
usage: '/datasets get <dataset-id>',
description: 'Show a dataset with its entries',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets update',
usage:
'/datasets update <dataset-id> [--name <name>] [--description <text>] [--status active|archived|draft] [--metadata <json>]',
description: 'Update dataset metadata',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets delete',
usage: '/datasets delete <dataset-id>',
description: 'Delete a dataset and all of its entries',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets add-entry',
usage: '/datasets add-entry <dataset-id> (--messages <json> | --file <path>)',
description: 'Add a message-based training entry to a dataset',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets update-entry',
usage: '/datasets update-entry <entry-id> (--messages <json> | --file <path>)',
description: 'Update a dataset entry by ID',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets delete-entry',
usage: '/datasets delete-entry <entry-id>',
description: 'Delete a dataset entry by ID',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets import',
usage: '/datasets import <dataset-id> <json|jsonl-file>',
description: 'Bulk import dataset entries from JSON or JSONL',
category: 'shortcuts',
helpOnly: true,
});
registerCommand({
name: '/datasets export',
usage: '/datasets export <dataset-id> [--out <path>]',
description: 'Export a dataset with its entries',
category: 'shortcuts',
helpOnly: true,
});
// ── Rules Generation ────────────────────────────────────────────
registerCommand({
name: '/rules generate',
usage: '/rules generate [brand-slug]',
description: 'Auto-generate rules from KB and business data (with human confirmation)',
category: 'engine',
helpOnly: true,
detailedHelp:
'Analyzes your knowledge base and business context to suggest skip rules, escalation patterns, and response rules. All suggestions require human confirmation.',
examples: ['/rules generate', '/rules generate my-brand'],
});
// ── Sessions ──────────────────────────────────────────────────────
registerCommand({
name: '/session stats',
usage: '/session stats',
description: 'Show session storage statistics',
category: 'sessions',
helpOnly: true,
});
registerCommand({
name: '/session cleanup',
usage: '/session cleanup [days=30] [--dry-run]',