@kodycodes/cli 3.28.1 → 3.28.2

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.
@@ -75,6 +75,800 @@ import { parseArgs } from "node:util";
75
75
  import { statSync } from "node:fs";
76
76
  import { readFile } from "node:fs/promises";
77
77
 
78
+ // src/command-help.ts
79
+ var jsonFlag = ["--json", "Print JSON for agents"];
80
+ var orgFlag = [
81
+ "--org <slug>",
82
+ "Run as this org for one call (else KODY_ORG, then the active org)"
83
+ ];
84
+ var mcpUrlFlag = [
85
+ "--mcp-url <url>",
86
+ "Kody MCP URL (default from KODY_MCP_URL)"
87
+ ];
88
+ var apiUrlFlag = [
89
+ "--api-url <url>",
90
+ "Kody API URL (default from KODY_API_URL)"
91
+ ];
92
+ var tokenFlag = [
93
+ "--token <token>",
94
+ "Scoped API token (prefer the KODY_API_TOKEN env var)"
95
+ ];
96
+ var targetFlag = [
97
+ "--target prod|mock",
98
+ "Where API hops go: real Kody or the built-in local mock"
99
+ ];
100
+ var ecContextFlag = [
101
+ "--context <ec id>",
102
+ "Execution context on this machine (default: the only one registered)"
103
+ ];
104
+ var devTargetFlag = [
105
+ "--target prod|mock",
106
+ "Where API hops go (default mock for kody dev)"
107
+ ];
108
+ var dryRunFlag = [
109
+ "--dry-run",
110
+ "Print the module path and params without invoking"
111
+ ];
112
+ var commandHelpTree = [
113
+ {
114
+ name: "login",
115
+ summary: "Sign in to Kody in the browser (or with a device code)",
116
+ usage: [
117
+ "kody login [--mcp-url <url>] [--org <slug>] [--no-browser | --device]"
118
+ ],
119
+ flags: [
120
+ [
121
+ "--org <slug>",
122
+ "Bind the login to this org (adds or replaces that org login)"
123
+ ],
124
+ ["--no-browser", "Print the sign-in URL instead of opening a browser"],
125
+ ["--device", "Sign in with a device code (headless machines)"],
126
+ mcpUrlFlag
127
+ ]
128
+ },
129
+ {
130
+ name: "logout",
131
+ summary: "Remove the active org login (or one org with --org)",
132
+ usage: ["kody logout [--org <slug>] [--mcp-url <url>] [--api-url <url>]"],
133
+ flags: [
134
+ ["--org <slug>", "Remove only this org login"],
135
+ mcpUrlFlag,
136
+ apiUrlFlag
137
+ ]
138
+ },
139
+ {
140
+ name: "org",
141
+ summary: "List logged-in orgs or switch the active org",
142
+ usage: ["kody org <command> [flags]"],
143
+ subcommands: [
144
+ {
145
+ name: "list",
146
+ summary: "Show logged-in orgs and mark the active one",
147
+ usage: ["kody org list [--json] [--mcp-url <url>]"],
148
+ flags: [jsonFlag, mcpUrlFlag]
149
+ },
150
+ {
151
+ name: "use",
152
+ summary: "Switch the active org (interactive chooser without a slug on a TTY)",
153
+ usage: ["kody org use [<slug>] [--mcp-url <url>]"],
154
+ flags: [mcpUrlFlag]
155
+ }
156
+ ]
157
+ },
158
+ {
159
+ name: "status",
160
+ summary: "Show login, token, and server status",
161
+ usage: ["kody status [--mcp-url <url>] [--api-url <url>]"],
162
+ flags: [mcpUrlFlag, apiUrlFlag]
163
+ },
164
+ {
165
+ name: "auth",
166
+ summary: "Store scoped API tokens and set up Git credentials",
167
+ usage: ["kody auth <command> [flags]"],
168
+ subcommands: [
169
+ {
170
+ name: "bootstrap",
171
+ summary: "Redeem a kody_bc_\u2026 code (or mint one with --scopes) and store the token",
172
+ usage: [
173
+ "kody auth bootstrap (--code <kody_bc_\u2026> | --scopes <list>) (--lifetime short|long | --idle-ttl-seconds <n> --max-lifetime-seconds <n>)",
174
+ " [--token <token>] [--mcp-url <url>] [--api-url <url>]"
175
+ ],
176
+ flags: [
177
+ [
178
+ "--code <kody_bc_\u2026>",
179
+ "One-shot bootstrap code from cliCredentialBootstrap"
180
+ ],
181
+ [
182
+ "--scopes <list>",
183
+ "Mint a code with exactly these scopes (replaces the defaults)"
184
+ ],
185
+ [
186
+ "--lifetime short|long",
187
+ "short = 1h idle / 24h max; long = 14d idle / 3mo max"
188
+ ],
189
+ [
190
+ "--idle-ttl-seconds <n>",
191
+ "Custom idle lifetime (with --max-lifetime-seconds)"
192
+ ],
193
+ [
194
+ "--max-lifetime-seconds <n>",
195
+ "Custom max lifetime (with --idle-ttl-seconds)"
196
+ ],
197
+ tokenFlag,
198
+ mcpUrlFlag,
199
+ apiUrlFlag
200
+ ]
201
+ },
202
+ {
203
+ name: "setup-git",
204
+ summary: "Install a Git credential helper for https://kody.codes/@owner/name.git",
205
+ usage: [
206
+ "kody auth setup-git [--lifetime long|short] [--scopes <list>] [--token <token>] [--mcp-url <url>] [--api-url <url>]"
207
+ ],
208
+ flags: [
209
+ [
210
+ "--lifetime long|short",
211
+ "Lifetime of the minted token (default long)"
212
+ ],
213
+ [
214
+ "--scopes <list>",
215
+ "Extra scopes beyond package:read and package:write"
216
+ ],
217
+ tokenFlag,
218
+ mcpUrlFlag,
219
+ apiUrlFlag
220
+ ]
221
+ },
222
+ {
223
+ name: "remove-git",
224
+ summary: "Remove the Git credential helper and revoke its stored token",
225
+ usage: ["kody auth remove-git [--mcp-url <url>] [--api-url <url>]"],
226
+ flags: [mcpUrlFlag, apiUrlFlag]
227
+ }
228
+ ]
229
+ },
230
+ {
231
+ name: "git-credential",
232
+ summary: "Git credential helper invoked by git after `kody auth setup-git`",
233
+ usage: ["kody git-credential <get|store|erase>"],
234
+ notes: [
235
+ "Not meant for interactive use; git calls it with get, store, or erase."
236
+ ]
237
+ },
238
+ {
239
+ name: "whoami",
240
+ summary: "Show who the CLI acts as and which credential it picked",
241
+ usage: [
242
+ "kody whoami [--org <slug>] [--target prod|mock] [--mcp-url <url>] [--token <token>] [--api-url <url>] [--json]"
243
+ ],
244
+ flags: [orgFlag, targetFlag, mcpUrlFlag, tokenFlag, apiUrlFlag, jsonFlag]
245
+ },
246
+ {
247
+ name: "search",
248
+ summary: "Search capabilities, packages, and docs",
249
+ usage: [
250
+ "kody search [query] [--org <slug>] [--entity <ref>] [--domain <id>] [--limit <n>] [--target prod|mock] [--token <token>] [--api-url <url>] [--json]"
251
+ ],
252
+ flags: [
253
+ orgFlag,
254
+ ["--entity <ref>", "Look up one entity by ref"],
255
+ ["--domain <id>", "Limit results to one capability domain"],
256
+ ["--limit <n>", "Maximum results"],
257
+ targetFlag,
258
+ tokenFlag,
259
+ apiUrlFlag,
260
+ jsonFlag
261
+ ]
262
+ },
263
+ {
264
+ name: "api",
265
+ summary: "Call one Open API operation by operationId",
266
+ usage: [
267
+ "kody api <operationId> [--org <slug>] [--params <json>] [--token <token>] [--api-url <url>] [--json]"
268
+ ],
269
+ flags: [
270
+ orgFlag,
271
+ ["--params <json>", "Flat JSON params (same shape as the MCP api tool)"],
272
+ tokenFlag,
273
+ apiUrlFlag,
274
+ jsonFlag
275
+ ],
276
+ notes: ["Example: kody api usageGet --params '{}'"]
277
+ },
278
+ {
279
+ name: "package",
280
+ summary: "Publish packages and manage who can use them",
281
+ usage: ["kody package <command> [flags]"],
282
+ subcommands: [
283
+ {
284
+ name: "publish",
285
+ summary: "Publish the package in this git repo (packagePublishExternalPush)",
286
+ usage: [
287
+ "kody package publish [<@owner/leaf|package_id>] [--build local|context] [--context <name|cloud>] [--org <slug>] [--params <json>] [--token <token>] [--api-url <url>] [--json]"
288
+ ],
289
+ flags: [
290
+ [
291
+ "--build local|context",
292
+ "Build on this machine or on an execution context"
293
+ ],
294
+ [
295
+ "--context <name|cloud>",
296
+ "Execution context that builds it (with --build context)"
297
+ ],
298
+ orgFlag,
299
+ ["--params <json>", "Extra publish fields, e.g. allow_force"],
300
+ tokenFlag,
301
+ apiUrlFlag,
302
+ jsonFlag
303
+ ]
304
+ },
305
+ {
306
+ name: "collaborators",
307
+ summary: "List the teams and people who can use a package",
308
+ usage: [
309
+ "kody package collaborators <package> [--org <slug>] [--json] [--token <token>] [--api-url <url>]"
310
+ ],
311
+ flags: [orgFlag, jsonFlag, tokenFlag, apiUrlFlag]
312
+ },
313
+ {
314
+ name: "grant",
315
+ summary: "Share a package with a team or user, or change their preset",
316
+ usage: [
317
+ "kody package grant <package> (--team <slug> | --user <username>) [--preset read|use|contribute|manage] [--allow-changes-despite-unmappable-credentials | --disallow-changes-despite-unmappable-credentials] [--org <slug>] [--json]"
318
+ ],
319
+ flags: [
320
+ ["--team <slug>", "Team to share with"],
321
+ [
322
+ "--user <username>",
323
+ "Person to share with (outside the org adds an outside collaborator)"
324
+ ],
325
+ [
326
+ "--preset read|use|contribute|manage",
327
+ "What they can do (default use)"
328
+ ],
329
+ [
330
+ "--allow-changes-despite-unmappable-credentials",
331
+ "Let them change it even if credentials cannot be mapped"
332
+ ],
333
+ [
334
+ "--disallow-changes-despite-unmappable-credentials",
335
+ "Turn that back off"
336
+ ],
337
+ orgFlag,
338
+ jsonFlag
339
+ ]
340
+ },
341
+ {
342
+ name: "revoke",
343
+ summary: "Remove a team, user, or grant from a package",
344
+ usage: [
345
+ "kody package revoke <package> (--team <slug> | --user <username> | --grant <grant_id>) [--org <slug>] [--json]"
346
+ ],
347
+ flags: [
348
+ ["--team <slug>", "Team to remove"],
349
+ ["--user <username>", "Person to remove"],
350
+ ["--grant <grant_id>", "Grant to remove"],
351
+ orgFlag,
352
+ jsonFlag
353
+ ]
354
+ }
355
+ ]
356
+ },
357
+ {
358
+ name: "execute",
359
+ summary: "Run a module on Kody cloud, an execution context, or this machine",
360
+ usage: [
361
+ "kody execute [--org <slug>] [--invoke <ref> | --code <esm> | --file <path>] [--params <json>] [--conversation-id <id>] [--json]",
362
+ " [--credential <key=name>]\u2026 [--context <id|name>] [--fallback chain] [--requires fs,lan] [--chain <a,b,cloud>] [--target prod|mock] [--token <token>] [--api-url <url>] [--local] [--allow-private-network]"
363
+ ],
364
+ flags: [
365
+ orgFlag,
366
+ [
367
+ "--invoke <ref>",
368
+ "Run a package export (kody:@scope/pkg/export, or ./export in a package dir)"
369
+ ],
370
+ ["--code <esm>", "Run this module source"],
371
+ ["--file <path>", "Bundle and run this file"],
372
+ ["--params <json>", "Params passed to the module"],
373
+ ["--conversation-id <id>", "Conversation to attach the run to"],
374
+ [
375
+ "--credential <key=name>",
376
+ "Pick the credential for credential(key) calls (repeatable)"
377
+ ],
378
+ ["--context <id|name>", "Run on one execution context"],
379
+ [
380
+ "--fallback chain",
381
+ "With --context, fall back to the chain when it cannot run"
382
+ ],
383
+ [
384
+ "--requires fs,lan",
385
+ "Skip targets without local files or the local network"
386
+ ],
387
+ ["--chain <a,b,cloud>", "This run's own ordered chain"],
388
+ targetFlag,
389
+ tokenFlag,
390
+ apiUrlFlag,
391
+ ["--local", "Run in local workerd on this machine (Node.js 22+)"],
392
+ [
393
+ "--allow-private-network",
394
+ "Let --local code fetch private and local addresses"
395
+ ],
396
+ [
397
+ "--reset-storage",
398
+ "With --target mock, wipe mock scratch storage first"
399
+ ],
400
+ jsonFlag
401
+ ]
402
+ },
403
+ {
404
+ name: "dev",
405
+ summary: "Serve and test an unpublished package locally",
406
+ usage: ["kody dev [serve] [flags]", "kody dev <command> [flags]"],
407
+ notes: ["With no command, `kody dev` runs `kody dev serve`."],
408
+ subcommands: [
409
+ {
410
+ name: "serve",
411
+ summary: "Serve kody.app.entry on localhost with hot reload (the default)",
412
+ usage: [
413
+ "kody dev serve [--org <slug>] [--target prod|mock] [--reset-storage] [--passthrough <host,\u2026>] [--port <n>] [--app-base-path <path>] [--allow-private-network] [--no-live-reload] [--json] [--ready-file <path>]"
414
+ ],
415
+ flags: [
416
+ orgFlag,
417
+ devTargetFlag,
418
+ [
419
+ "--reset-storage",
420
+ "With --target mock, wipe mock scratch storage first"
421
+ ],
422
+ ["--port <n>", "Exact port (0 = any; default is stable per package)"],
423
+ [
424
+ "--app-base-path <path>",
425
+ "Public mount path stripped before workerd"
426
+ ],
427
+ [
428
+ "--allow-private-network",
429
+ "Let app code fetch private and local addresses"
430
+ ],
431
+ [
432
+ "--no-live-reload",
433
+ "Turn off HTML live reload and the error overlay"
434
+ ],
435
+ [
436
+ "--passthrough <host,\u2026>",
437
+ "With .kody/mocks.ts on mock, let these hosts use the real network"
438
+ ],
439
+ [
440
+ "--json",
441
+ "Stream NDJSON events (ready, rebuild_ok, build_error, \u2026)"
442
+ ],
443
+ [
444
+ "--ready-file <path>",
445
+ "Write { url, port, basePath, pid } once ready"
446
+ ]
447
+ ]
448
+ },
449
+ {
450
+ name: "fetch",
451
+ summary: "Request a path from the running dev server (or a one-shot server)",
452
+ usage: [
453
+ "kody dev fetch <path> [--method <verb>] [--body <file>] [--target prod|mock] [--json] [--no-attach]"
454
+ ],
455
+ flags: [
456
+ ["--method <verb>", "HTTP method (default GET)"],
457
+ ["--body <file>", "Request body file"],
458
+ devTargetFlag,
459
+ jsonFlag,
460
+ [
461
+ "--no-attach",
462
+ "Boot a one-shot server instead of using a running kody dev"
463
+ ]
464
+ ]
465
+ },
466
+ {
467
+ name: "job",
468
+ summary: "Run a job once (never schedules locally)",
469
+ usage: [
470
+ "kody dev job <name> [--target prod|mock] [--dry-run] [--json]"
471
+ ],
472
+ flags: [devTargetFlag, dryRunFlag, jsonFlag]
473
+ },
474
+ {
475
+ name: "webhook",
476
+ summary: "Deliver a webhook payload to the package",
477
+ usage: [
478
+ "kody dev webhook <name> --body <file.json> [--target prod|mock] [--dry-run] [--json]"
479
+ ],
480
+ flags: [
481
+ ["--body <file.json>", "Webhook payload"],
482
+ devTargetFlag,
483
+ dryRunFlag,
484
+ jsonFlag
485
+ ]
486
+ },
487
+ {
488
+ name: "emit",
489
+ summary: "Emit an event to the package's subscriptions",
490
+ usage: [
491
+ "kody dev emit <event> --body <event.json> [--target prod|mock] [--dry-run] [--json]"
492
+ ],
493
+ flags: [
494
+ ["--body <event.json>", "Event payload"],
495
+ devTargetFlag,
496
+ dryRunFlag,
497
+ jsonFlag
498
+ ]
499
+ },
500
+ {
501
+ name: "check",
502
+ summary: "Bundle and run the publish checks without running the package",
503
+ usage: [
504
+ "kody dev check [--target prod|mock] [--offline] [--debug] [--json]"
505
+ ],
506
+ flags: [
507
+ devTargetFlag,
508
+ ["--offline", "Skip the server publish checks"],
509
+ ["--debug", "Print the publish checks call to stderr"],
510
+ jsonFlag
511
+ ]
512
+ }
513
+ ]
514
+ },
515
+ {
516
+ name: "install",
517
+ summary: "Add Kody as an MCP server to local agent clients",
518
+ usage: [
519
+ "kody install [--mcp-url <url>] [--clients <ids>] [--yes] [--project] [--json]"
520
+ ],
521
+ flags: [
522
+ mcpUrlFlag,
523
+ ["--clients <ids>", "Comma-separated client ids"],
524
+ ["--yes", "Skip the confirmation prompt"],
525
+ ["--project", "Write project-level config instead of user-level"],
526
+ jsonFlag
527
+ ]
528
+ },
529
+ {
530
+ name: "skill",
531
+ summary: "Install the Kody agent skill",
532
+ usage: ["kody skill <command> [flags]"],
533
+ subcommands: [
534
+ {
535
+ name: "install",
536
+ summary: "Install the Kody skill for local agents",
537
+ usage: ["kody skill install [--project]"],
538
+ flags: [
539
+ ["--project", "Install into this project instead of your user dir"]
540
+ ]
541
+ }
542
+ ]
543
+ },
544
+ {
545
+ name: "version",
546
+ summary: "Print the CLI version",
547
+ usage: ["kody version"]
548
+ },
549
+ {
550
+ name: "context",
551
+ summary: "Register and manage execution contexts (machines that run your code)",
552
+ usage: ["kody context <command> [flags]"],
553
+ notes: [
554
+ "Execution contexts are an experiment. Turn it on at https://kody.codes/account/experiments."
555
+ ],
556
+ subcommands: [
557
+ {
558
+ name: "register",
559
+ summary: "Register this machine as an execution context",
560
+ usage: ["kody context register --name <name> [--org <slug>] [--json]"],
561
+ flags: [["--name <name>", "Name for this machine"], orgFlag, jsonFlag]
562
+ },
563
+ {
564
+ name: "list",
565
+ summary: "List your execution contexts",
566
+ usage: ["kody context list [--org <slug>] [--json]"],
567
+ flags: [orgFlag, jsonFlag]
568
+ },
569
+ {
570
+ name: "revoke",
571
+ summary: "Revoke a context: kill its key, disconnect it, cancel its runs",
572
+ usage: ["kody context revoke <name|ec id> [--org <slug>] [--json]"],
573
+ flags: [orgFlag, jsonFlag]
574
+ },
575
+ {
576
+ name: "delete",
577
+ summary: "Permanently delete a revoked context",
578
+ usage: ["kody context delete <name|ec id> [--org <slug>] [--json]"],
579
+ flags: [orgFlag, jsonFlag]
580
+ },
581
+ {
582
+ name: "cancel-run",
583
+ summary: "Cancel one run on a context",
584
+ usage: [
585
+ "kody context cancel-run <name|ec id> <run id> [--org <slug>] [--json]"
586
+ ],
587
+ flags: [orgFlag, jsonFlag]
588
+ },
589
+ {
590
+ name: "policy",
591
+ summary: "Show or change which host folders runs on this machine can use",
592
+ usage: ["kody context policy [<command>] [flags]"],
593
+ notes: ["With no command, shows the policy."],
594
+ subcommands: [
595
+ {
596
+ name: "show",
597
+ summary: "Show the host folder policy",
598
+ usage: ["kody context policy show [--json]"],
599
+ flags: [jsonFlag]
600
+ },
601
+ {
602
+ name: "allow",
603
+ summary: "Allow runs to use a host folder",
604
+ usage: ["kody context policy allow <path> [--mode ro|rw] [--json]"],
605
+ flags: [
606
+ ["--mode ro|rw", "Read-only or read-write (default ro)"],
607
+ jsonFlag
608
+ ]
609
+ },
610
+ {
611
+ name: "remove",
612
+ summary: "Remove a host folder from the policy",
613
+ usage: ["kody context policy remove <path> [--json]"],
614
+ flags: [jsonFlag]
615
+ }
616
+ ]
617
+ },
618
+ {
619
+ name: "commands",
620
+ summary: "Turn host commands (your own runs on this machine) on or off",
621
+ usage: [
622
+ "kody context commands [<command>] [--context <name>] [--json]"
623
+ ],
624
+ flags: [["--context <name>", "Context to check or turn off"], jsonFlag],
625
+ notes: ["With no command, shows the status."],
626
+ subcommands: [
627
+ {
628
+ name: "status",
629
+ summary: "Show whether host commands are on",
630
+ usage: ["kody context commands status [--context <name>] [--json]"],
631
+ flags: [["--context <name>", "Context to check"], jsonFlag]
632
+ },
633
+ {
634
+ name: "on",
635
+ summary: "Turn host commands on (only on this machine)",
636
+ usage: ["kody context commands on [--json]"],
637
+ flags: [jsonFlag]
638
+ },
639
+ {
640
+ name: "off",
641
+ summary: "Turn host commands off",
642
+ usage: ["kody context commands off [--context <name>] [--json]"],
643
+ flags: [
644
+ [
645
+ "--context <name>",
646
+ "Context to turn off (works from any machine)"
647
+ ],
648
+ jsonFlag
649
+ ]
650
+ }
651
+ ]
652
+ }
653
+ ]
654
+ },
655
+ {
656
+ name: "chain",
657
+ summary: "Show or change your default execution chain",
658
+ usage: ["kody chain [<command>] [--org <slug>] [--json]"],
659
+ flags: [orgFlag, jsonFlag],
660
+ notes: ["With no command, shows the chain. Offline contexts are skipped."],
661
+ subcommands: [
662
+ {
663
+ name: "show",
664
+ summary: "Show your default chain",
665
+ usage: ["kody chain show [--org <slug>] [--json]"],
666
+ flags: [orgFlag, jsonFlag]
667
+ },
668
+ {
669
+ name: "add",
670
+ summary: "Add a context to your chain (before cloud)",
671
+ usage: ["kody chain add <name> [--org <slug>] [--json]"],
672
+ flags: [orgFlag, jsonFlag]
673
+ },
674
+ {
675
+ name: "remove",
676
+ summary: "Remove a context from your chain",
677
+ usage: ["kody chain remove <name> [--org <slug>] [--json]"],
678
+ flags: [orgFlag, jsonFlag]
679
+ }
680
+ ]
681
+ },
682
+ {
683
+ name: "connect",
684
+ summary: "Register this machine and install the daemon as a background service",
685
+ usage: [
686
+ "kody connect --name <name> [--org <slug>] [--no-install] [--key-storage keyring|file] [--yes]"
687
+ ],
688
+ flags: [
689
+ ["--name <name>", "Name for this machine"],
690
+ orgFlag,
691
+ ["--no-install", "Register only; do not install the background service"],
692
+ ["--key-storage keyring|file", "Where the service reads the machine key"],
693
+ ["--yes", "Skip confirmation prompts"]
694
+ ]
695
+ },
696
+ {
697
+ name: "daemon",
698
+ summary: "Run the execution-context daemon, or manage its background service",
699
+ usage: [
700
+ "kody daemon [--context <ec id>] [--max-concurrent <n>]",
701
+ "kody daemon <command> [flags]"
702
+ ],
703
+ flags: [
704
+ ecContextFlag,
705
+ ["--max-concurrent <n>", "Runs at once (foreground daemon)"]
706
+ ],
707
+ notes: [
708
+ "With no command, runs the daemon in the foreground until Ctrl-C.",
709
+ "The service is systemd --user on Linux (and WSL with systemd), a LaunchAgent on macOS, and a Task Scheduler logon task on Windows."
710
+ ],
711
+ subcommands: [
712
+ {
713
+ name: "install",
714
+ summary: "Install the daemon as a per-user background service",
715
+ usage: [
716
+ "kody daemon install [--context <ec id>] [--max-concurrent <n>] [--key-storage keyring|file] [--yes]"
717
+ ],
718
+ flags: [
719
+ ecContextFlag,
720
+ ["--max-concurrent <n>", "Runs at once"],
721
+ [
722
+ "--key-storage keyring|file",
723
+ "Where the service reads the machine key"
724
+ ],
725
+ ["--yes", "Skip confirmation prompts"]
726
+ ]
727
+ },
728
+ {
729
+ name: "status",
730
+ summary: "Show the service state and each problem with its fix",
731
+ usage: ["kody daemon status [--context <ec id>] [--json]"],
732
+ flags: [ecContextFlag, jsonFlag]
733
+ },
734
+ {
735
+ name: "logs",
736
+ summary: "Print the daemon log",
737
+ usage: [
738
+ "kody daemon logs [--context <ec id>] [--lines <n>] [--follow]"
739
+ ],
740
+ flags: [
741
+ ecContextFlag,
742
+ ["--lines <n>", "Lines from the end (default 100)"],
743
+ ["--follow", "Keep printing new lines"]
744
+ ]
745
+ },
746
+ {
747
+ name: "restart",
748
+ summary: "Restart the service after runs in flight finish",
749
+ usage: ["kody daemon restart [--context <ec id>]"],
750
+ flags: [ecContextFlag]
751
+ },
752
+ {
753
+ name: "start",
754
+ summary: "Start the stopped service",
755
+ usage: ["kody daemon start [--context <ec id>]"],
756
+ flags: [ecContextFlag]
757
+ },
758
+ {
759
+ name: "stop",
760
+ summary: "Stop the service after runs in flight finish, without unregistering",
761
+ usage: ["kody daemon stop [--context <ec id>]"],
762
+ flags: [ecContextFlag],
763
+ notes: [
764
+ "The context shows offline, so chains skip it. It stays stopped until `kody daemon start` or the next login or boot."
765
+ ]
766
+ },
767
+ {
768
+ name: "uninstall",
769
+ summary: "Remove the background service",
770
+ usage: [
771
+ "kody daemon uninstall [--context <ec id>] [--unregister | --no-unregister]"
772
+ ],
773
+ flags: [
774
+ ecContextFlag,
775
+ ["--unregister", "Also revoke the execution context"],
776
+ ["--no-unregister", "Keep the execution context registered"]
777
+ ]
778
+ },
779
+ {
780
+ name: "auto-update",
781
+ summary: "Show or change daemon auto-update on this machine",
782
+ usage: ["kody daemon auto-update [<command>] [--json]"],
783
+ flags: [jsonFlag],
784
+ notes: ["With no command, shows the status."],
785
+ subcommands: [
786
+ {
787
+ name: "status",
788
+ summary: "Show whether auto-update is on",
789
+ usage: ["kody daemon auto-update status [--json]"],
790
+ flags: [jsonFlag]
791
+ },
792
+ {
793
+ name: "on",
794
+ summary: "Turn auto-update on",
795
+ usage: ["kody daemon auto-update on [--json]"],
796
+ flags: [jsonFlag]
797
+ },
798
+ {
799
+ name: "off",
800
+ summary: "Turn auto-update off",
801
+ usage: ["kody daemon auto-update off [--json]"],
802
+ flags: [jsonFlag]
803
+ }
804
+ ]
805
+ }
806
+ ]
807
+ },
808
+ {
809
+ name: "update",
810
+ summary: "Install the latest CLI and restart daemon services after runs finish",
811
+ usage: ["kody update"]
812
+ },
813
+ {
814
+ name: "help",
815
+ summary: "Show help for kody or one command",
816
+ usage: ["kody help [<command> \u2026]"]
817
+ }
818
+ ];
819
+ function findCommandHelp(path) {
820
+ let nodes = commandHelpTree;
821
+ let deepest = null;
822
+ const matched = [];
823
+ for (const segment of path) {
824
+ const node = nodes.find((candidate) => candidate.name === segment);
825
+ if (!node) break;
826
+ deepest = node;
827
+ matched.push(segment);
828
+ nodes = node.subcommands ?? [];
829
+ }
830
+ return deepest ? { node: deepest, path: matched } : null;
831
+ }
832
+ function formatRows(rows) {
833
+ const width = Math.min(Math.max(...rows.map(([left]) => left.length)) + 2, 34);
834
+ return rows.map(
835
+ ([left, right]) => left.length + 2 > width ? ` ${left}
836
+ ${" ".repeat(width)}${right}` : ` ${left.padEnd(width)}${right}`
837
+ ).join("\n");
838
+ }
839
+ function buildCommandHelp(path) {
840
+ const found = findCommandHelp(path);
841
+ if (!found) return null;
842
+ const { node } = found;
843
+ const full = `kody ${found.path.join(" ")}`;
844
+ const sections = [
845
+ `${full}: ${node.summary} (Kody CLI ${readPackageVersion()})`,
846
+ `Usage:
847
+ ${node.usage.map((line) => ` ${line}`).join("\n")}`
848
+ ];
849
+ if (node.subcommands?.length) {
850
+ sections.push(
851
+ `Commands:
852
+ ${formatRows(
853
+ node.subcommands.map((sub) => [sub.name, sub.summary])
854
+ )}`
855
+ );
856
+ }
857
+ sections.push(
858
+ `Flags:
859
+ ${formatRows([
860
+ ...node.flags ?? [],
861
+ ["-h, --help", "Show help for this command"]
862
+ ])}`
863
+ );
864
+ if (node.notes?.length) sections.push(node.notes.join("\n"));
865
+ if (node.subcommands?.length) {
866
+ sections.push(`Run \`${full} <command> --help\` for a command's flags.`);
867
+ }
868
+ return `${sections.join("\n\n")}
869
+ `;
870
+ }
871
+
78
872
  // src/help.ts
79
873
  function formatOrgsHelpBlock(orgs, indent = " ") {
80
874
  if (orgs.length === 0) {
@@ -134,7 +928,7 @@ Usage:
134
928
  kody connect --name <name> [--org <slug>] [--no-install] [--key-storage keyring|file] [--yes]
135
929
  kody daemon [--context <ec id>] [--max-concurrent <n>]
136
930
  kody daemon install [--context <ec id>] [--max-concurrent <n>] [--key-storage keyring|file] [--yes]
137
- kody daemon status [--context <ec id>] [--json] | logs [--lines <n>] [--follow] | restart
931
+ kody daemon status [--context <ec id>] [--json] | logs [--lines <n>] [--follow] | restart | start | stop
138
932
  kody daemon uninstall [--context <ec id>] [--unregister | --no-unregister]
139
933
  kody daemon auto-update [on | off | status] [--json]
140
934
  kody update
@@ -148,6 +942,9 @@ Usage:
148
942
  kody install [--mcp-url <url>] [--clients <ids>] [--yes] [--project] [--json]
149
943
  kody skill install [--project]
150
944
 
945
+ Run \`kody <command> --help\` (or \`kody help <command>\`) for one command's
946
+ usage, flags, and subcommands.
947
+
151
948
  kody connect registers this machine as an execution context and installs
152
949
  \`kody daemon\` as a per-user background service (systemd --user on Linux,
153
950
  a LaunchAgent on macOS, a Task Scheduler logon task on Windows, no admin
@@ -988,21 +1785,22 @@ async function runCli(argv = process.argv.slice(2), io = {}) {
988
1785
  }).catch(() => {
989
1786
  });
990
1787
  }
991
- const jsonFlag = argvIncludesJsonFlag(argv);
1788
+ const jsonFlag2 = argvIncludesJsonFlag(argv);
992
1789
  resetActiveCliCredential();
993
1790
  try {
994
1791
  const parsed = resolveCommand(argv);
995
1792
  const helpMcpUrl = mcpUrlFrom({
996
1793
  mcpUrl: typeof parsed.values["mcp-url"] === "string" ? parsed.values["mcp-url"] : void 0
997
1794
  });
998
- if (parsed.values.help && parsed.command !== "help") {
999
- write(buildUsage({ mcpUrl: helpMcpUrl }));
1795
+ if (parsed.values.help && (parsed.command !== "help" || argv[0] === "help")) {
1796
+ const helpPath = parsed.command === "help" ? parsed.positionals.length > 0 ? parsed.positionals : ["help"] : [parsed.command, ...parsed.positionals];
1797
+ write(buildCommandHelp(helpPath) ?? buildUsage({ mcpUrl: helpMcpUrl }));
1000
1798
  return 0;
1001
1799
  }
1002
1800
  return await dispatch(parsed, write, writeErr);
1003
1801
  } catch (error) {
1004
1802
  const redacted = redactError(error);
1005
- if (jsonFlag) {
1803
+ if (jsonFlag2) {
1006
1804
  write(`${JSON.stringify(formatCliErrorJson(redacted))}
1007
1805
  `);
1008
1806
  }
@@ -1072,8 +1870,8 @@ async function dispatch(parsed, write, writeErr) {
1072
1870
  "`--passthrough` is only used with `execute --target mock` or `kody dev` when `.kody/mocks.ts` is active."
1073
1871
  );
1074
1872
  }
1075
- const orgFlag = typeof parsed.values.org === "string" ? parsed.values.org : void 0;
1076
- if (orgFlag !== void 0 && !orgScopedCommands.has(parsed.command)) {
1873
+ const orgFlag2 = typeof parsed.values.org === "string" ? parsed.values.org : void 0;
1874
+ if (orgFlag2 !== void 0 && !orgScopedCommands.has(parsed.command)) {
1077
1875
  throw new Error(
1078
1876
  `\`--org\` is not used with \`kody ${parsed.command}\`. Use it with login, logout, whoami, search, api, package, execute, or auth.`
1079
1877
  );
@@ -1083,14 +1881,16 @@ async function dispatch(parsed, write, writeErr) {
1083
1881
  `);
1084
1882
  return 0;
1085
1883
  }
1086
- const orgFlagOnly = orgFlag !== void 0 ? orgSlugFromFlag(orgFlag) : void 0;
1884
+ const orgFlagOnly = orgFlag2 !== void 0 ? orgSlugFromFlag(orgFlag2) : void 0;
1087
1885
  const org = resolveOrgSlug({
1088
- flag: orgFlag,
1886
+ flag: orgFlag2,
1089
1887
  activeOrg: loadCredentialStore(mcpUrl)?.activeOrg
1090
1888
  });
1091
1889
  switch (parsed.command) {
1092
1890
  case "help":
1093
- write(buildUsage({ mcpUrl }));
1891
+ write(
1892
+ (parsed.positionals.length > 0 ? buildCommandHelp(parsed.positionals) : null) ?? buildUsage({ mcpUrl })
1893
+ );
1094
1894
  return 0;
1095
1895
  case "context":
1096
1896
  case "chain":
@@ -1405,7 +2205,7 @@ async function dispatch(parsed, write, writeErr) {
1405
2205
  apiUrl: typeof parsed.values["api-url"] === "string" ? parsed.values["api-url"] : void 0
1406
2206
  });
1407
2207
  if (target === "mock") {
1408
- const { ensureMockTarget } = await import("./mock-server-AVHUTXAL.js");
2208
+ const { ensureMockTarget } = await import("./mock-server-TDKUEG5W.js");
1409
2209
  const mock = await ensureMockTarget({
1410
2210
  resetStorage: parsed.values["reset-storage"] === true,
1411
2211
  ...org ? { orgSlug: org } : {}
@@ -1464,7 +2264,7 @@ async function dispatch(parsed, write, writeErr) {
1464
2264
  let closeMock;
1465
2265
  try {
1466
2266
  if (target === "mock") {
1467
- const { ensureMockTarget } = await import("./mock-server-AVHUTXAL.js");
2267
+ const { ensureMockTarget } = await import("./mock-server-TDKUEG5W.js");
1468
2268
  const mock = await ensureMockTarget({
1469
2269
  resetStorage: parsed.values["reset-storage"] === true
1470
2270
  });
@@ -1616,7 +2416,7 @@ async function dispatch(parsed, write, writeErr) {
1616
2416
  }
1617
2417
  try {
1618
2418
  if (target === "mock") {
1619
- const { ensureMockTarget } = await import("./mock-server-AVHUTXAL.js");
2419
+ const { ensureMockTarget } = await import("./mock-server-TDKUEG5W.js");
1620
2420
  const mock = await ensureMockTarget({
1621
2421
  resetStorage: parsed.values["reset-storage"] === true,
1622
2422
  packageId: localPackageRun ? `local:${localPackageRun.kodyId}` : void 0,
@@ -1766,7 +2566,7 @@ async function dispatch(parsed, write, writeErr) {
1766
2566
  runDevServe,
1767
2567
  runDevWebhook,
1768
2568
  tryAttachedDevFetch
1769
- } = await import("./dev-command-MPBKGNZW.js");
2569
+ } = await import("./dev-command-AD3RRODH.js");
1770
2570
  const target = resolveTarget({
1771
2571
  command: "dev",
1772
2572
  flag: typeof parsed.values.target === "string" ? parsed.values.target : void 0
@@ -1794,7 +2594,7 @@ async function dispatch(parsed, write, writeErr) {
1794
2594
  { parsePackageCheckResult, PublishChecksAuthError }
1795
2595
  ] = await Promise.all([
1796
2596
  import("./open-api-client-5BVEGHDF.js"),
1797
- import("./dev-command-MPBKGNZW.js")
2597
+ import("./dev-command-AD3RRODH.js")
1798
2598
  ]);
1799
2599
  let token2;
1800
2600
  try {
@@ -2491,6 +3291,7 @@ export {
2491
3291
  publishCliExitCode,
2492
3292
  publishRefusalMessage,
2493
3293
  apiUrlFrom,
3294
+ cliFlagNames,
2494
3295
  resolveCommand,
2495
3296
  runCli,
2496
3297
  argvIncludesJsonFlag,
@@ -2503,4 +3304,4 @@ export {
2503
3304
  resolvePackagePublishTarget,
2504
3305
  storedApiTokenAfterLoginNotice
2505
3306
  };
2506
- //# sourceMappingURL=chunk-JXUNYHCE.js.map
3307
+ //# sourceMappingURL=chunk-6YL6C3LL.js.map