@kitman-sh/cli 0.14.8 → 0.15.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 (30) hide show
  1. package/dist/{chunk-y0y2gg8d.js → chunk-0ws25xvg.js} +2 -2
  2. package/dist/{chunk-b009hdm0.js → chunk-39ykbhq8.js} +5 -5
  3. package/dist/{chunk-eytzmdna.js → chunk-3n99j4z0.js} +471 -234
  4. package/dist/{chunk-bbf0jzsc.js → chunk-3ns4sbfb.js} +1 -1
  5. package/dist/{chunk-q0x3c0dh.js → chunk-4x7a1qkj.js} +7 -7
  6. package/dist/{chunk-ya4z1n5p.js → chunk-4zc1g45m.js} +7 -7
  7. package/dist/{chunk-6dj39qtt.js → chunk-58hehm8d.js} +1133 -115
  8. package/dist/{chunk-9avbsbvk.js → chunk-5hkdgzh4.js} +1 -1
  9. package/dist/{chunk-xfs1nf75.js → chunk-8393zths.js} +1626 -388
  10. package/dist/{chunk-bpx2zjh7.js → chunk-8wpg3rph.js} +2 -2
  11. package/dist/{chunk-6x43ntsx.js → chunk-b16qxawc.js} +1 -1
  12. package/dist/chunk-cf1hxp43.js +3080 -0
  13. package/dist/chunk-csxxwscf.js +39 -0
  14. package/dist/{chunk-dq21ab8w.js → chunk-djp6t2g6.js} +21 -21
  15. package/dist/{chunk-zpp4jg4a.js → chunk-dx792s4w.js} +1455 -100
  16. package/dist/{chunk-5wrhj4cj.js → chunk-fv2zpgh0.js} +7 -7
  17. package/dist/{chunk-ctpgfdzf.js → chunk-fzaecdgv.js} +3 -3
  18. package/dist/{chunk-79g5zh2p.js → chunk-k2wd9r6t.js} +4 -4
  19. package/dist/chunk-mrkrt2hg.js +4345 -0
  20. package/dist/{chunk-721qyd1a.js → chunk-qkt77rtj.js} +6 -6
  21. package/dist/{chunk-drp4zdwq.js → chunk-rt0qfdtg.js} +15 -7
  22. package/dist/{chunk-cf723a2y.js → chunk-snwjv2sd.js} +678 -40
  23. package/dist/{chunk-bdd62njv.js → chunk-vg78dz3w.js} +259 -57
  24. package/dist/{chunk-wszvkzg8.js → chunk-vq7caqt2.js} +1828 -130
  25. package/dist/{chunk-63m3r0k4.js → chunk-wfz64h9p.js} +4 -4
  26. package/dist/{chunk-hz4t408c.js → chunk-xx711t5r.js} +4 -4
  27. package/dist/index.js +4 -4
  28. package/package.json +2 -1
  29. package/dist/chunk-1rwaetnm.js +0 -526
  30. package/dist/chunk-hrtr5wfq.js +0 -1166
@@ -12,12 +12,11 @@ import {
12
12
  succeed,
13
13
  isSuccess,
14
14
  TaggedError,
15
- make15,
15
+ make16,
16
16
  _await,
17
17
  fail5,
18
18
  succeed5,
19
19
  provide2,
20
- provideMerge,
21
20
  squash,
22
21
  pretty,
23
22
  max2,
@@ -42,7 +41,7 @@ import {
42
41
  andThen2,
43
42
  tap2,
44
43
  result,
45
- map8,
44
+ map9,
46
45
  as,
47
46
  asSome2,
48
47
  asVoid,
@@ -85,14 +84,18 @@ import {
85
84
  optionalKey,
86
85
  Literal,
87
86
  String4,
87
+ Boolean2,
88
88
  Struct,
89
89
  Record,
90
90
  ArraySchema,
91
91
  Union,
92
+ Literals,
93
+ NullOr,
92
94
  isPattern,
93
95
  isMinLength,
94
96
  isMaxLength,
95
97
  fromJsonString,
98
+ Json,
96
99
  toJsonValue,
97
100
  isOneOf,
98
101
  toJsonObject,
@@ -102,10 +105,24 @@ import {
102
105
  isJsonObject,
103
106
  isString2,
104
107
  decodeJsonString,
108
+ decodeJsonStringOption,
105
109
  encodeJsonStringSync,
106
110
  encodePrettyJsonString
107
- } from "./chunk-zpp4jg4a.js";
111
+ } from "./chunk-dx792s4w.js";
108
112
  import {
113
+ tap,
114
+ mapError,
115
+ decodeText,
116
+ run,
117
+ mkString,
118
+ FileSystem,
119
+ Path,
120
+ withDefault,
121
+ option,
122
+ String2
123
+ } from "./chunk-vg78dz3w.js";
124
+ import {
125
+ currentTimeMillis,
109
126
  SecureRandom,
110
127
  layerWebCrypto,
111
128
  runMain,
@@ -126,11 +143,22 @@ import {
126
143
  NetworkHost,
127
144
  RepoBindingProviders,
128
145
  RepoBindingCredentialProviderTypes,
146
+ RepoBindingProvider,
147
+ isBranchName,
148
+ baseBranchLayerWords,
149
+ repositoryKey,
150
+ loopInputFields,
151
+ InputSourceLayers,
152
+ InputSource,
153
+ inputSourceWords,
129
154
  ContextPackModes,
130
155
  DefaultContextPackMode,
131
156
  ProposalStatuses,
132
157
  ProposalTargetTypes,
133
158
  tokenCountWords,
159
+ outlineText,
160
+ outlineMermaid,
161
+ runOutlineText,
134
162
  RunDisplayStates,
135
163
  RunnerExecutionBackend,
136
164
  MaxRunnerConcurrency,
@@ -148,9 +176,11 @@ import {
148
176
  FixFlowRecoveryActions,
149
177
  KitmanAgentCapabilityNames,
150
178
  sha2562,
179
+ runsDeployedTag,
180
+ Deploy,
181
+ DeployTargetRunning,
151
182
  isRunFileRefusalReason,
152
183
  runFileRefusalWords,
153
- repositoryKey,
154
184
  createId,
155
185
  digestSha256,
156
186
  sha256Hasher,
@@ -165,6 +195,8 @@ import {
165
195
  runDisplayLabels,
166
196
  listedSummary,
167
197
  stepFallbackWords,
198
+ ticketOutcomeLabels,
199
+ runGraphLayout,
168
200
  defaultKitName,
169
201
  SetupArchive,
170
202
  KitmanClientError,
@@ -219,27 +251,15 @@ import {
219
251
  harnessNames,
220
252
  herdrRunnerCapabilities2,
221
253
  declaredChecks
222
- } from "./chunk-xfs1nf75.js";
254
+ } from "./chunk-8393zths.js";
223
255
  import {
224
- currentTimeMillis,
225
- tap,
226
- mapError,
227
- decodeText,
228
- run,
229
- mkString,
230
- FileSystem,
231
- Path,
232
- withDefault,
233
- option,
234
- String2
235
- } from "./chunk-bdd62njv.js";
256
+ Id,
257
+ Timestamp
258
+ } from "./chunk-5hkdgzh4.js";
236
259
  import {
237
260
  ChildProcessSpawner,
238
261
  make3
239
- } from "./chunk-79g5zh2p.js";
240
- import {
241
- Id
242
- } from "./chunk-9avbsbvk.js";
262
+ } from "./chunk-k2wd9r6t.js";
243
263
 
244
264
  // apps/cli/src/cli-error.ts
245
265
  function cliErrorCode(error, status) {
@@ -325,6 +345,7 @@ var officialMarketplaceReferences = [
325
345
  source: { type: "npm" },
326
346
  loops: [
327
347
  { id: "build", export: "build" },
348
+ { id: "deploy", export: "deploy" },
328
349
  { id: "errand", export: "errand" },
329
350
  { id: "file-tasks", export: "fileTasks" },
330
351
  { id: "firewatch", export: "firewatch" },
@@ -405,6 +426,251 @@ var notListTypes = new Set([
405
426
  ]);
406
427
  var unbindable = new Set("arguments await break case catch class config const continue debugger default defineKit delete do else enum eval export extends false finally for function if implements import in instanceof interface let new null package private protected public return static super switch this throw true try typeof undefined var void while with yield".split(" "));
407
428
 
429
+ // packages/core/src/release.ts
430
+ var ReleaseState = Literals(["pending", "read", "unreadable"]);
431
+ var ReleaseSource = Literals(["run", "forge"]);
432
+ var ReleaseTask = Struct({ id: String4, key: String4, title: String4 });
433
+ var ReleaseChangeRequest = Struct({
434
+ id: String4,
435
+ provider: RepoBindingProvider,
436
+ number: String4,
437
+ title: String4,
438
+ url: String4,
439
+ sourceBranch: String4,
440
+ targetBranch: String4,
441
+ mergeRevision: String4,
442
+ tasks: ArraySchema(ReleaseTask),
443
+ reverted: optionalKey(Struct({
444
+ at: Timestamp,
445
+ revision: optionalKey(String4),
446
+ release: optionalKey(Struct({ id: String4, tag: String4, version: String4 }))
447
+ }))
448
+ });
449
+ var Release = Struct({
450
+ id: String4,
451
+ workspaceId: String4,
452
+ teamId: optionalKey(String4),
453
+ repoBindingId: String4,
454
+ repository: String4,
455
+ tag: String4,
456
+ version: String4,
457
+ prerelease: Boolean2,
458
+ revision: optionalKey(String4),
459
+ branch: optionalKey(String4),
460
+ previousTag: optionalKey(String4),
461
+ title: optionalKey(String4),
462
+ notes: String4,
463
+ url: optionalKey(String4),
464
+ runId: optionalKey(String4),
465
+ source: ReleaseSource,
466
+ state: ReleaseState,
467
+ publishedAt: Timestamp,
468
+ createdAt: Timestamp
469
+ });
470
+ var ReleaseDeployTarget = Struct({
471
+ target: String4,
472
+ since: optionalKey(Timestamp),
473
+ latest: Deploy
474
+ });
475
+ var ReleaseListItem = Struct({
476
+ ...Release.fields,
477
+ changeRequests: ArraySchema(ReleaseChangeRequest),
478
+ deployTargets: ArraySchema(ReleaseDeployTarget)
479
+ });
480
+ var ReleaseDetail = Struct({
481
+ ...ReleaseListItem.fields,
482
+ previousPrerelease: optionalKey(String4),
483
+ sincePrerelease: optionalKey(ArraySchema(String4))
484
+ });
485
+ var ReleaseList = Struct({
486
+ items: ArraySchema(ReleaseListItem),
487
+ nextCursor: optionalKey(String4)
488
+ });
489
+ var UnreleasedBranch = Struct({
490
+ branch: String4,
491
+ default: Boolean2,
492
+ since: optionalKey(String4),
493
+ sinceHidden: Boolean2,
494
+ changeRequests: ArraySchema(ReleaseChangeRequest),
495
+ truncated: Boolean2,
496
+ mayBeReleased: Boolean2
497
+ });
498
+ var UnreleasedBranches = Struct({
499
+ repoBindingId: String4,
500
+ repository: String4,
501
+ branches: ArraySchema(UnreleasedBranch)
502
+ });
503
+ var ReleaseComparison = Struct({
504
+ from: Release,
505
+ to: Release,
506
+ changeRequests: ArraySchema(ReleaseChangeRequest),
507
+ incomplete: Boolean2
508
+ });
509
+ var WaitingRelease = Struct({
510
+ ...Release.fields,
511
+ changeRequests: ArraySchema(ReleaseChangeRequest),
512
+ latestDeploy: optionalKey(Deploy)
513
+ });
514
+ var DeployTargetView = Struct({
515
+ target: String4,
516
+ listed: Boolean2,
517
+ running: optionalKey(DeployTargetRunning),
518
+ runningRelease: optionalKey(Release),
519
+ waiting: ArraySchema(WaitingRelease),
520
+ waitingTruncated: Boolean2,
521
+ history: ArraySchema(Deploy),
522
+ historyTruncated: Boolean2
523
+ });
524
+ var DeployTargetsView = Struct({
525
+ repoBindingId: String4,
526
+ repository: String4,
527
+ teamId: optionalKey(String4),
528
+ targets: ArraySchema(DeployTargetView)
529
+ });
530
+ var releaseTasks = (changeRequests) => {
531
+ const seen = new Map;
532
+ for (const changeRequest of changeRequests)
533
+ for (const task of changeRequest.tasks)
534
+ if (!seen.has(task.id))
535
+ seen.set(task.id, task);
536
+ return [...seen.values()];
537
+ };
538
+ var releaseDeployState = ({ since, latest }, formatTime) => {
539
+ const failed = runsDeployedTag(latest.status) ? undefined : latest.status.replaceAll("_", " ");
540
+ if (since !== undefined)
541
+ return `runs it since ${formatTime(since)}${failed === undefined ? "" : `, latest deploy ${failed}`}`;
542
+ return `${failed ?? "no longer runs it"}, latest deploy ${formatTime(latest.deployedAt)}`;
543
+ };
544
+ var bangProviders = new Set(["gitlab", "azure-devops", "gitee"]);
545
+ var changeRequestReference = (changeRequest) => `${bangProviders.has(changeRequest.provider) ? "!" : "#"}${changeRequest.number}`;
546
+
547
+ // packages/core/src/when-clause-name.ts
548
+ var eventWhenClauseName = (event) => event.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
549
+ var whenClauseName = (clause) => clause.name ?? eventWhenClauseName(clause.event);
550
+
551
+ // packages/core/src/project-delivery.ts
552
+ var DeliveryState = Literals(["level", "behind", "conflicted", "unknown"]);
553
+ var deliveryStateWords = {
554
+ level: "level with",
555
+ behind: "behind",
556
+ conflicted: "in conflict with",
557
+ unknown: "not yet compared with"
558
+ };
559
+ var ProjectChangeRequest = Struct({
560
+ id: String4,
561
+ provider: RepoBindingProvider,
562
+ number: String4,
563
+ title: String4,
564
+ url: String4
565
+ });
566
+ var DeliveringChangeRequest = Struct({
567
+ ...ProjectChangeRequest.fields,
568
+ sourceBranch: String4,
569
+ targetBranch: String4,
570
+ draft: Boolean2,
571
+ state: DeliveryState
572
+ });
573
+ var UnreleasedProjectTask = Struct({
574
+ ...ReleaseTask.fields,
575
+ milestoneId: optionalKey(String4),
576
+ changeRequests: ArraySchema(ProjectChangeRequest)
577
+ });
578
+ var PublishedRelease = Struct({ runId: String4, tag: String4, revision: String4 });
579
+ var ProjectReleaseRun = Struct({
580
+ runId: String4,
581
+ status: String4,
582
+ outcome: optionalKey(String4),
583
+ failed: Boolean2,
584
+ kind: Literals(["milestone", "project"]),
585
+ milestoneId: optionalKey(String4),
586
+ published: optionalKey(PublishedRelease),
587
+ createdAt: Timestamp
588
+ });
589
+ var AppliedInputDefault = Struct({
590
+ field: String4,
591
+ value: Json,
592
+ layer: Literals(InputSourceLayers),
593
+ when: optionalKey(String4)
594
+ });
595
+ var ReleaseWhenDefaults = Struct({
596
+ when: String4,
597
+ defaults: ArraySchema(AppliedInputDefault)
598
+ });
599
+ var ProjectRepository = Struct({
600
+ repoBindingId: String4,
601
+ repository: String4,
602
+ defaultBranch: String4,
603
+ targetBranch: NullOr(String4),
604
+ branch: String4,
605
+ delivering: optionalKey(DeliveringChangeRequest),
606
+ unreleased: ArraySchema(UnreleasedProjectTask),
607
+ releases: ArraySchema(Release),
608
+ releasesTruncated: Boolean2,
609
+ latestRun: optionalKey(ProjectReleaseRun),
610
+ teamId: optionalKey(String4),
611
+ inputDefaults: ArraySchema(ReleaseWhenDefaults),
612
+ releaseRefused: optionalKey(String4)
613
+ });
614
+ var ProjectDelivery = Struct({ repositories: ArraySchema(ProjectRepository) });
615
+ var ProjectReleaseRequest = Struct({
616
+ milestoneId: optionalKey(String4),
617
+ repoBindingId: optionalKey(String4),
618
+ when: optionalKey(String4),
619
+ preview: optionalKey(Boolean2),
620
+ confirm: optionalKey(String4)
621
+ });
622
+ var ProjectReleasePlan = Struct({
623
+ repoBindingId: String4,
624
+ repository: String4,
625
+ teamId: optionalKey(String4),
626
+ kind: Literals(["milestone", "project"]),
627
+ milestoneId: optionalKey(String4),
628
+ milestoneName: optionalKey(String4),
629
+ when: optionalKey(String4),
630
+ whenClauses: ArraySchema(String4),
631
+ branch: String4,
632
+ base: optionalKey(String4),
633
+ version: optionalKey(String4),
634
+ candidate: Boolean2,
635
+ tag: optionalKey(String4),
636
+ scheme: optionalKey(String4),
637
+ merges: optionalKey(String4),
638
+ continues: optionalKey(PublishedRelease),
639
+ tasks: ArraySchema(ReleaseTask),
640
+ deployTarget: optionalKey(String4),
641
+ input: Record(String4, Json),
642
+ inputSources: ArraySchema(InputSource),
643
+ runId: optionalKey(String4),
644
+ blocked: optionalKey(String4)
645
+ });
646
+ var ProjectReleaseResult = Struct({
647
+ preview: Boolean2,
648
+ plan: String4,
649
+ repositories: ArraySchema(ProjectReleasePlan)
650
+ });
651
+ var projectNameSchemes = [undefined, "auto", "project-name"];
652
+ var releasePlanTagWords = (plan) => {
653
+ if (plan.continues !== undefined)
654
+ return `nothing new: ${plan.continues.tag}, published at ${plan.continues.revision.slice(0, 12)} by the Release that failed, is deployed again`;
655
+ if (plan.tag !== undefined)
656
+ return plan.tag;
657
+ if (plan.version === undefined || !projectNameSchemes.includes(plan.scheme))
658
+ return `the version the ${plan.scheme ?? "auto"} Version Scheme gives`;
659
+ return plan.candidate ? `the next release candidate of ${plan.version}` : plan.version;
660
+ };
661
+ var releasePlanShipWords = (plan) => {
662
+ const shipped = plan.tasks.length === 0 ? "no Task yet" : plan.tasks.map((task) => task.key).join(", ");
663
+ if (plan.continues !== undefined)
664
+ return `Ships what ${plan.continues.tag} holds`;
665
+ return plan.merges === undefined ? `Merges nothing; ships ${shipped}, already merged into ${plan.branch}` : `Merges ChangeRequest ${plan.merges} into ${plan.branch}, then ships ${shipped}`;
666
+ };
667
+ var projectBranchWords = (repository) => {
668
+ if (repository.targetBranch === null || repository.targetBranch === repository.defaultBranch)
669
+ return `Its work merges into ${repository.branch}, the default branch, so nothing needs to deliver it.`;
670
+ return repository.delivering === undefined ? `Its work merges into ${repository.targetBranch}; no open ChangeRequest delivers it into ${repository.defaultBranch}.` : `Its work merges into ${repository.targetBranch}, delivered into ${repository.defaultBranch} by`;
671
+ };
672
+ var releasePlanDeployWords = (plan) => plan.deployTarget === undefined ? "deploys nothing: its Input says deploy: false" : `deploys to ${plan.deployTarget}`;
673
+
408
674
  // apps/cli/src/cli-session.ts
409
675
  var cliSessionExpired = {
410
676
  code: "cli_session_expired",
@@ -448,7 +714,7 @@ var Usage = [
448
714
  " kitman docs read <path> [--json] (a path search printed; a guide's own path reads the whole guide)",
449
715
  "",
450
716
  "Runs:",
451
- ' kitman run start <loop> "<words>" [--input <json>] [--team <team>] [--type <task type>] [--constraint <text>]... [--fresh] [--override-blockers]',
717
+ ' kitman run start <loop> "<words>" [--input <json>|--input <field>=<value>...] [--team <team>|--no-team] [--type <task type>] [--constraint <text>]... [--fresh] [--override-blockers]',
452
718
  " kitman run show <run>",
453
719
  " kitman run intent <run> [--set-goal <text>] [--add-constraint <text>] [--remove-constraint <id>] [--corrections on|off]",
454
720
  " kitman run drift <run> [--dismiss <constraint> --reason <text>]",
@@ -472,8 +738,10 @@ var Usage = [
472
738
  " kitman inbox read|unread|done|undone|unsnooze <task:id|run:id|proposal:id|project_update:id>...",
473
739
  " kitman inbox snooze <task:id|run:id|proposal:id|project_update:id>... --until <time>",
474
740
  " kitman inbox unsubscribe <task>...",
741
+ " kitman cr show <id|url> [--json] (its branches, head and, once merged, the revision it merged as)",
475
742
  " kitman cr approve <id|url> [--summary <text>] (approves the head Kitman last saw; only a person, not an agent or a tool acting for one)",
476
743
  " kitman cr request-changes <id|url> --summary <text>",
744
+ " kitman cr merge-through <id|url> (lets it merge while a person holds its target branch's merge turn)",
477
745
  "",
478
746
  "",
479
747
  "Loops and Agents the Kits deployed here declare (kitman deploy changes them):",
@@ -481,15 +749,19 @@ var Usage = [
481
749
  " kitman loop show <loop>",
482
750
  " kitman loop starts [--limit <n>] (what Events started, or why they started nothing)",
483
751
  " kitman loop when <loop> <event> on|off (turn an automatic start on or off for the Team)",
752
+ " kitman loop input <loop> [--team <team>|--project <project>] [--when <name>] [<field>=<value>...] [--off|--on] [--clear]",
753
+ " (read or set the Workspace's, a Team's or a Project's Input Defaults)",
484
754
  " kitman agent list [--team <team>] (each Agent as the Team's Runs resolve it, or the Workspace's without a Team)",
485
755
  "",
486
756
  "Kits of your own, to deploy with kitman deploy:",
487
757
  " kitman init --kit [dir] (a new Kit with an example Loop and a GitLab pipeline)",
488
- " kitman loop fork <loop> [dir] (a new Kit that spreads a software-engineering Loop, to change it)",
758
+ " kitman loop fork <loop> [dir] (a new Kit that forks a software-engineering Loop, replacing one Step)",
759
+ " kitman loop outline <loop> [dir] [--mermaid] [--out <file>] (the Steps, branches, repeats and ends read from a Kit's source)",
489
760
  "",
490
761
  "Approved verifications of the current repository:",
491
762
  " kitman verify list",
492
763
  ' kitman verify add <name> "<command>" [--cwd <directory>] [--pipeline] [--reads-target]',
764
+ ` kitman verify add <name> "<command>" --command [--cwd <directory>] (a command a Loop's command Step runs)`,
493
765
  " kitman verify remove <name>",
494
766
  " kitman constraint list",
495
767
  ' kitman constraint add "<constraint>"',
@@ -508,6 +780,7 @@ var Usage = [
508
780
  "",
509
781
  "Shared resources Runs claim, such as a deploy target:",
510
782
  " kitman claim list",
783
+ " kitman claim hold <resource> --reason <text> (no Run gets it until released; merge:<RepoBinding id>:<branch> stops merges into that branch)",
511
784
  " kitman claim release <resource> --reason <text>",
512
785
  "",
513
786
  "A private Team, and all it holds, is seen by its members alone:",
@@ -515,12 +788,24 @@ var Usage = [
515
788
  " kitman team open <team>",
516
789
  " kitman team invite <team> <person>",
517
790
  " kitman team delivery <team> gated|auto (only a person, signed in as an owner or admin)",
791
+ " kitman team milestones <team> [<milestone> <state>|none] [--json] (the state each milestone moves a Task to; released is a full Release containing its changes)",
518
792
  " kitman team scope <team> required|optional (whether agents must state a Task's scope; only a person)",
519
793
  "",
520
- "When Release runs: on each merge, when a Milestone is done, or when a Project is done. A Project inherits its Team's, a Team the Workspace's:",
521
- " kitman release workspace [merge|milestone|project] (setting it needs an owner or admin)",
522
- " kitman release team <team> [merge|milestone|project|inherit]",
523
- " kitman release project <project> [merge|milestone|project|inherit]",
794
+ "When Release runs: on each merge, when a Milestone is done, when a Project is done, or only when a person, a Schedule or a Loop starts it (manual). A Project inherits its Team's, a Team the Workspace's:",
795
+ " kitman release workspace [merge|milestone|project|manual] (setting it needs an owner or admin)",
796
+ " kitman release team <team> [merge|milestone|project|manual|inherit]",
797
+ " kitman release project <project> [merge|milestone|project|manual|inherit]",
798
+ " kitman release project <project> branch [<name>|none] (the branch its work merges into; none merges into each repository's default branch)",
799
+ " kitman release milestone <project> <milestone> branch [<name>|none] (made from and delivering into its Project's branch; none takes the Project's)",
800
+ " kitman release task <task> branch [<name>|none] (its own, whatever its Milestone and Project say; none takes theirs)",
801
+ " kitman release list [<repository>] [--no-prereleases] [--limit <n>] [--after <cursor>] [--json] (each Release Kitman recorded, newest first, with where it is deployed, its ChangeRequests and Tasks; with a repository, what each branch merged that no Release contains)",
802
+ " kitman release show <tag> | <release id> | <repository> <tag> [--since <tag>] [--json] (where it is deployed, and the ChangeRequests and Tasks it contains, as read from the forge; --since, those between an earlier Release and it)",
803
+ " kitman release targets [<repository>] [--json] (each Deploy Target in its order: the Release it runs and since when, the Releases cut since that have not reached it with their Tasks and how to deploy one, and its deploys, failures and rollbacks with their Runs)",
804
+ " kitman project show <project> [--json] (per repository: its target branch and the ChangeRequest delivering it, level, behind or in conflict, its Tasks merged and not released, its Releases and latest Release Run, and the Input Defaults its Releases take)",
805
+ " kitman project release <project> [--milestone <milestone>] [--repository <repository>] [--when <clause>] [--yes] [--json] (Release now, as the Milestone's close or else the Project's, with that When Clause's Input Defaults: shows what it tags, ships and deploys, and with --yes starts exactly that plan; after a Release that published its tag and failed, it deploys that tag again, cutting nothing)",
806
+ " kitman deploy-target list <repository> [--json] (its Deploy Targets in its order, then any other a Deploy named, with what each runs)",
807
+ " kitman deploy-target set <repository> <target>...|none (its ordered list, such as staging production, none clears it; a Deploy may name any other target)",
808
+ " kitman deploy-target history [<repository> [<target>]] [--limit <n>] [--json] (the Deploys Kitman recorded, newest first)",
524
809
  "",
525
810
  "Where delivery lands: on the default branch, or a sub-task on its epic's branch and the epic on the default branch once every sub-task is done. A Project inherits its Team's, a Team the Workspace's:",
526
811
  " kitman land workspace [default|epic] (setting it needs an owner or admin)",
@@ -681,6 +966,7 @@ var examples = [
681
966
  "kitman runner attachments my-runner",
682
967
  "kitman runner bootstrap --local --profile local-fast",
683
968
  `kitman run start build "Fix the flaky login test" --team platform`,
969
+ `kitman run start revert !123 "it locks people out of sign-in"`,
684
970
  `kitman run show ${run2}`,
685
971
  `kitman run intent ${run2} --add-constraint "Keep the public API unchanged"`,
686
972
  `kitman run drift ${run2}`,
@@ -715,13 +1001,18 @@ var examples = [
715
1001
  `kitman inbox read task:KIT-42 run:${run2}`,
716
1002
  "kitman inbox snooze task:KIT-42 --until 2026-11-18T09:00",
717
1003
  "kitman inbox unsubscribe KIT-42",
1004
+ "kitman cr show 128",
718
1005
  'kitman cr approve 128 --summary "Looks good"',
719
1006
  'kitman cr request-changes 128 --summary "The migration drops a column still read by the API"',
1007
+ "kitman cr merge-through 128",
720
1008
  "kitman loop list",
721
1009
  "kitman loop show build",
722
1010
  "kitman loop starts --limit 20",
723
1011
  "kitman loop when shepherd change_request.pipeline on",
1012
+ "kitman loop input release --project '0.14.0 - Release flows' --when milestone prerelease=rc",
1013
+ "kitman loop input build --team KIT maxRounds=5",
724
1014
  "kitman loop fork build ./kits/my-build",
1015
+ "kitman loop outline release ./kits/software-engineering --mermaid",
725
1016
  "kitman loop catalog",
726
1017
  `kitman loop validate build --input '{"task":"KIT-42"}'`,
727
1018
  "kitman agent list --team KIT",
@@ -739,6 +1030,7 @@ var examples = [
739
1030
  "kitman network-host add registry.npmjs.org --team platform",
740
1031
  "kitman network-host remove registry.npmjs.org --repo",
741
1032
  "kitman claim list",
1033
+ 'kitman claim hold merge:repo-1:main --reason "0.14.0-rc.1 is cut; fixes only"',
742
1034
  'kitman claim release staging --reason "Rolled back by hand"',
743
1035
  "kitman team list",
744
1036
  "kitman team use platform",
@@ -746,10 +1038,24 @@ var examples = [
746
1038
  "kitman team open platform",
747
1039
  "kitman team invite platform ada@example.com",
748
1040
  "kitman team delivery platform gated",
1041
+ "kitman team milestones platform released Released",
749
1042
  "kitman team scope platform required",
750
1043
  "kitman release workspace merge",
751
1044
  "kitman release team platform milestone",
752
1045
  'kitman release project "Loop stability" inherit',
1046
+ 'kitman release project "Loop stability" branch release/next',
1047
+ 'kitman release milestone "Loop stability" "First cut" branch release/next-m1',
1048
+ "kitman release task KIT-12 branch release/1.x",
1049
+ "kitman release list acme/platform",
1050
+ "kitman release show acme/platform v1.3.0",
1051
+ "kitman release show v1.3.0 --since v1.2.0",
1052
+ "kitman release targets acme/platform",
1053
+ 'kitman project show "0.15.0 - Release flows"',
1054
+ 'kitman project release "0.15.0 - Release flows" --milestone Flows',
1055
+ 'kitman project release "0.15.0 - Release flows" --yes',
1056
+ "kitman deploy-target list acme/platform",
1057
+ "kitman deploy-target set acme/platform staging production",
1058
+ "kitman deploy-target history acme/platform production",
753
1059
  "kitman land workspace default",
754
1060
  "kitman land team platform epic",
755
1061
  'kitman land project "Loop stability" inherit',
@@ -895,7 +1201,7 @@ function herdrRunnerCredentialName(runnerId) {
895
1201
  return `herdr-runner:${runnerId}`;
896
1202
  }
897
1203
  function storedHerdrRunnerCredential(apiUrl, runnerId) {
898
- return map8(readAuthStore(), (auth) => agentCredentialForApi(auth, apiUrl, herdrRunnerCredentialName(runnerId)));
1204
+ return map9(readAuthStore(), (auth) => agentCredentialForApi(auth, apiUrl, herdrRunnerCredentialName(runnerId)));
899
1205
  }
900
1206
  function writeRunnerCredentialFile(path, file) {
901
1207
  return gen(function* () {
@@ -1020,10 +1326,10 @@ var sandboxMissing = (sandbox, missing) => ({
1020
1326
  var personalCheckBackend = (agentSandbox, dockerAvailable) => agentSandbox === "srt" || agentSandbox === "docker" && dockerAvailable ? agentSandbox : undefined;
1021
1327
  var herdrCoreSession = (runnerId, personal) => personal ? undefined : `kitman-${sha2562(runnerId).slice(0, 16)}`;
1022
1328
  var OpenHerdrCore = Reference("kitman/cli/OpenHerdrCore", {
1023
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-63m3r0k4.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
1329
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-wfz64h9p.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
1024
1330
  });
1025
1331
  var UpdateHerdrCore = Reference("kitman/cli/UpdateHerdrCore", {
1026
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-63m3r0k4.js")), (module) => module.updateHerdrCore(options))
1332
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-wfz64h9p.js")), (module) => module.updateHerdrCore(options))
1027
1333
  });
1028
1334
  var herdrCoreMissing = (error) => {
1029
1335
  if (isTagged(error, "HerdrCoreMissing"))
@@ -1215,7 +1521,7 @@ var managedKitmanPath = gen(function* () {
1215
1521
  var installedKitmanVersion = gen(function* () {
1216
1522
  const fs = yield* FileSystem;
1217
1523
  const path = yield* Path;
1218
- return yield* fs.readLink(yield* managedKitmanPath).pipe(map8((target) => path.basename(path.dirname(target))), orElseSucceed(() => {
1524
+ return yield* fs.readLink(yield* managedKitmanPath).pipe(map9((target) => path.basename(path.dirname(target))), orElseSucceed(() => {
1219
1525
  return;
1220
1526
  }));
1221
1527
  });
@@ -1260,7 +1566,7 @@ var downloadManagedKitman = (apiUrl, platform) => gen(function* () {
1260
1566
  const binary = yield* fetchFrom(release.url).pipe(filterOrFail((downloaded) => downloaded.ok, (downloaded) => new CliError({ message: `Downloading kitman ${manifest.version} answered ${downloaded.status}` })), flatMap3((downloaded) => tryPromise({
1261
1567
  try: () => downloaded.arrayBuffer(),
1262
1568
  catch: (error) => new CliError({ message: `Downloading kitman ${manifest.version} failed: ${String(error)}` })
1263
- })), map8((bytes) => new Uint8Array(bytes)));
1569
+ })), map9((bytes) => new Uint8Array(bytes)));
1264
1570
  if (digestSha256(binary, "hex") !== release.sha256)
1265
1571
  return yield* new CliError({
1266
1572
  message: `The downloaded kitman ${manifest.version} for ${os}/${architecture} does not match its sha256; nothing was installed`
@@ -1277,7 +1583,7 @@ var linkManagedKitman = (kitman) => gen(function* () {
1277
1583
  const path = yield* Path;
1278
1584
  const link = yield* managedKitmanPath;
1279
1585
  const nextLink = `${link}.next`;
1280
- const previous = yield* fs.readLink(link).pipe(map8((target) => path.resolve(path.dirname(link), target)), orElseSucceed(() => {
1586
+ const previous = yield* fs.readLink(link).pipe(map9((target) => path.resolve(path.dirname(link), target)), orElseSucceed(() => {
1281
1587
  return;
1282
1588
  }));
1283
1589
  yield* fs.makeDirectory(path.dirname(link), { recursive: true });
@@ -1467,12 +1773,12 @@ var syncTargets = (harness) => gen(function* () {
1467
1773
  });
1468
1774
  var syncKits = (input) => gen(function* () {
1469
1775
  const fs = yield* FileSystem;
1470
- const { syncKitSetup } = yield* promise(() => import("./chunk-ya4z1n5p.js"));
1776
+ const { syncKitSetup } = yield* promise(() => import("./chunk-4zc1g45m.js"));
1471
1777
  const harnesses = yield* syncTargets(input.harness);
1472
1778
  const chain = yield* input.client.getKitChain(input.workspaceId);
1473
1779
  for (const { name, problem } of chain.skipped)
1474
1780
  yield* log(`Warning: skipped Kit ${name}: ${problem}`);
1475
- const kits = yield* forEach(chain.kits, (kit) => map8(flatMap3(setupArchive(input.client, input.workspaceId, kit.setupDigest), decodeArchive), (archive) => ({ name: kit.name, version: kit.version, archive })));
1781
+ const kits = yield* forEach(chain.kits, (kit) => map9(flatMap3(setupArchive(input.client, input.workspaceId, kit.setupDigest), decodeArchive), (archive) => ({ name: kit.name, version: kit.version, archive })));
1476
1782
  const manifest = yield* userHarnessSyncPath;
1477
1783
  const previous = yield* fs.readFileString(manifest).pipe(flatMap3(decodeEffect(SyncedHarnesses)), orElseSucceed(() => ({})));
1478
1784
  const kitman = (yield* runningManagedInstall(process.platform)) ? yield* managedKitmanPath : "kitman";
@@ -1613,7 +1919,7 @@ function idempotencyKey(value, operation) {
1613
1919
  const explicit = value?.trim();
1614
1920
  if (explicit)
1615
1921
  return succeed6(explicit);
1616
- return SecureRandom.pipe(flatMap3((random) => random.uuidV4()), map8((id) => `kitman-cli:${operation}:${id}`), provide3(layerWebCrypto));
1922
+ return SecureRandom.pipe(flatMap3((random) => random.uuidV4()), map9((id) => `kitman-cli:${operation}:${id}`), provide3(layerWebCrypto));
1617
1923
  }
1618
1924
  function segment(value) {
1619
1925
  return encodeURIComponent(value);
@@ -1731,7 +2037,7 @@ var machineRunnerServices = gen(function* () {
1731
2037
  return yield* forEach(files.flatMap((file) => {
1732
2038
  const runnerId = pattern.exec(file)?.[1];
1733
2039
  return runnerId === undefined ? [] : [{ runnerId, file: path.join(directory, file) }];
1734
- }), ({ runnerId, file }) => map8(fs.readFileString(file), (definition) => ({
2040
+ }), ({ runnerId, file }) => map9(fs.readFileString(file), (definition) => ({
1735
2041
  runnerId,
1736
2042
  command: serviceCommand(platform, definition)
1737
2043
  })));
@@ -1746,7 +2052,7 @@ var ownersRunners = (apiUrl) => gen(function* () {
1746
2052
  return;
1747
2053
  const client = yield* clientFor(apiUrl, session);
1748
2054
  const workspaces = (yield* client.listWorkspaces()).items;
1749
- const lists = yield* forEach(workspaces, (workspace) => map8(client.listRunners(workspace.id), (list) => list.items));
2055
+ const lists = yield* forEach(workspaces, (workspace) => map9(client.listRunners(workspace.id), (list) => list.items));
1750
2056
  return new Map(lists.flat().map((runner) => [runner.id, runner]));
1751
2057
  }).pipe(orElseSucceed(() => {
1752
2058
  return;
@@ -1869,7 +2175,7 @@ var machineRunnerCommand = (action, apiUrl, options) => gen(function* () {
1869
2175
 
1870
2176
  // apps/cli/src/repo-binding-setup.ts
1871
2177
  var Git = Reference("kitman/cli/Git", {
1872
- defaultValue: () => (args) => runCommand2("git", args).pipe(map8((stdout) => stdout.trim()))
2178
+ defaultValue: () => (args) => runCommand2("git", args).pipe(map9((stdout) => stdout.trim()))
1873
2179
  });
1874
2180
  var repoBindingInputFromCurrentRepo = flatMap3(Git, repoBindingInput);
1875
2181
  function repoBindingInput(git) {
@@ -2006,8 +2312,8 @@ function initCommand(args) {
2006
2312
  const apiUrl = yield* resolveApiUrl(flags.apiUrl);
2007
2313
  const steps = [];
2008
2314
  const step = (name, outcome, detail) => andThen2(sync2(() => steps.push({ name, outcome, detail })), log(`${name}: ${outcomeLabel[outcome]} (${detail})`));
2009
- const ask = (prompt, fallback) => flags.yes ? succeed6(fallback) : promptLine(fallback === "" ? `${prompt}: ` : `${prompt} [${fallback}]: `).pipe(map8((answer) => answer.trim() || fallback));
2010
- const confirm = (prompt, fallback) => map8(ask(`${prompt} (y/n)`, fallback ? "y" : "n"), (answer) => /^y(es)?$/i.test(answer));
2315
+ const ask = (prompt, fallback) => flags.yes ? succeed6(fallback) : promptLine(fallback === "" ? `${prompt}: ` : `${prompt} [${fallback}]: `).pipe(map9((answer) => answer.trim() || fallback));
2316
+ const confirm = (prompt, fallback) => map9(ask(`${prompt} (y/n)`, fallback ? "y" : "n"), (answer) => /^y(es)?$/i.test(answer));
2011
2317
  const existingSession = yield* sessionForApiWithRefresh(apiUrl);
2012
2318
  const session = existingSession ?? (yield* (yield* Login)(apiUrl));
2013
2319
  yield* step("Login", existingSession === undefined ? "set_up" : "already", apiUrl);
@@ -2192,7 +2498,7 @@ var runnerServiceStep = (apiUrl, runnerId, change, step) => gen(function* () {
2192
2498
  yield* step("Runner service", change.fresh ? "set_up" : "repaired", "started");
2193
2499
  });
2194
2500
  var credentialNote = { missing: ", credential restored", refused: ", credential re-keyed", accepted: "" };
2195
- var machineName = map8(option(String2("KITMAN_RUNNER_NAME")), (name) => getOrElse(name, () => hostname()));
2501
+ var machineName = map9(option(String2("KITMAN_RUNNER_NAME")), (name) => getOrElse(name, () => hostname()));
2196
2502
  var managedRunnerService = (runnerId, apiUrl) => gen(function* () {
2197
2503
  const kitman = yield* managedKitmanPath;
2198
2504
  const bin = (yield* Path).dirname(kitman);
@@ -2313,9 +2619,9 @@ function runnerServiceState(name) {
2313
2619
  return gen(function* () {
2314
2620
  const manager = yield* ServiceManager;
2315
2621
  if (manager.platform === "linux")
2316
- return yield* manager.run("systemctl", ["--user", "is-active", `${name}.service`]).pipe(map8((state) => `systemd: ${state.trim()}`), orElseSucceed(() => "systemd: not running"));
2622
+ return yield* manager.run("systemctl", ["--user", "is-active", `${name}.service`]).pipe(map9((state) => `systemd: ${state.trim()}`), orElseSucceed(() => "systemd: not running"));
2317
2623
  if (manager.platform === "darwin")
2318
- return yield* manager.run("launchctl", ["print", `${yield* launchdDomain}/${launchdLabel(name)}`]).pipe(map8((printed) => `launchd: ${/^\s*state = (\S+)/mu.exec(printed)?.[1] ?? "loaded"}`), orElseSucceed(() => "launchd: not installed"));
2624
+ return yield* manager.run("launchctl", ["print", `${yield* launchdDomain}/${launchdLabel(name)}`]).pipe(map9((printed) => `launchd: ${/^\s*state = (\S+)/mu.exec(printed)?.[1] ?? "loaded"}`), orElseSucceed(() => "launchd: not installed"));
2319
2625
  return;
2320
2626
  });
2321
2627
  }
@@ -2384,9 +2690,588 @@ var package_default = {
2384
2690
  "solid-js": "1.9.18"
2385
2691
  }
2386
2692
  };
2693
+ // apps/cli/src/shipped-steps.generated.json
2694
+ var shipped_steps_generated_default = {
2695
+ backport: [],
2696
+ build: [
2697
+ {
2698
+ name: "reproduced",
2699
+ from: "@kitman-sh/software-engineering",
2700
+ exported: "steps.reproduced"
2701
+ },
2702
+ {
2703
+ name: "implemented",
2704
+ from: "@kitman-sh/software-engineering",
2705
+ exported: "steps.implemented"
2706
+ },
2707
+ {
2708
+ name: "rallied",
2709
+ from: "@kitman-sh/software-engineering",
2710
+ exported: "steps.rallied"
2711
+ },
2712
+ {
2713
+ name: "reviewed",
2714
+ from: "@kitman-sh/software-engineering",
2715
+ exported: "steps.reviewed"
2716
+ },
2717
+ {
2718
+ name: "fixed",
2719
+ from: "@kitman-sh/software-engineering",
2720
+ exported: "steps.fixed"
2721
+ },
2722
+ {
2723
+ name: "afterFix",
2724
+ from: "@kitman-sh/software-engineering"
2725
+ },
2726
+ {
2727
+ name: "opened",
2728
+ from: "@kitman-sh/software-engineering",
2729
+ exported: "steps.opened"
2730
+ },
2731
+ {
2732
+ name: "standing",
2733
+ from: "@kitman-sh/software-engineering",
2734
+ exported: "steps.standing"
2735
+ },
2736
+ {
2737
+ name: "landed",
2738
+ from: "@kitman-sh/software-engineering",
2739
+ exported: "steps.landed"
2740
+ }
2741
+ ],
2742
+ deploy: [
2743
+ {
2744
+ name: "promote",
2745
+ from: "@kitman-sh/software-engineering",
2746
+ exported: "steps.promote"
2747
+ },
2748
+ {
2749
+ name: "guard",
2750
+ from: "@kitman-sh/software-engineering",
2751
+ exported: "steps.guard"
2752
+ },
2753
+ {
2754
+ name: "claim",
2755
+ from: "@kitman-sh/software-engineering",
2756
+ exported: "steps.claim"
2757
+ },
2758
+ {
2759
+ name: "run",
2760
+ from: "@kitman-sh/software-engineering",
2761
+ exported: "steps.run"
2762
+ },
2763
+ {
2764
+ name: "record",
2765
+ from: "@kitman-sh/software-engineering",
2766
+ exported: "steps.record"
2767
+ },
2768
+ {
2769
+ name: "recover",
2770
+ from: "@kitman-sh/software-engineering",
2771
+ exported: "steps.recover"
2772
+ }
2773
+ ],
2774
+ errand: [
2775
+ {
2776
+ name: "done",
2777
+ from: "@kitman-sh/software-engineering",
2778
+ exported: "steps.done"
2779
+ },
2780
+ {
2781
+ name: "opened",
2782
+ from: "@kitman-sh/software-engineering",
2783
+ exported: "steps.opened"
2784
+ }
2785
+ ],
2786
+ "file-tasks": [],
2787
+ hillclimb: [
2788
+ {
2789
+ name: "discovered",
2790
+ from: "@kitman-sh/software-engineering",
2791
+ exported: "steps.discovered"
2792
+ },
2793
+ {
2794
+ name: "harnessed",
2795
+ from: "@kitman-sh/software-engineering",
2796
+ exported: "steps.harnessed"
2797
+ },
2798
+ {
2799
+ name: "climbed",
2800
+ from: "@kitman-sh/software-engineering",
2801
+ exported: "steps.climbed"
2802
+ },
2803
+ {
2804
+ name: "external",
2805
+ from: "@kitman-sh/software-engineering",
2806
+ exported: "steps.external"
2807
+ },
2808
+ {
2809
+ name: "measured",
2810
+ from: "@kitman-sh/software-engineering",
2811
+ exported: "steps.measured"
2812
+ },
2813
+ {
2814
+ name: "rallied",
2815
+ from: "@kitman-sh/software-engineering",
2816
+ exported: "steps.rallied"
2817
+ },
2818
+ {
2819
+ name: "reviewed",
2820
+ from: "@kitman-sh/software-engineering",
2821
+ exported: "steps.reviewed"
2822
+ },
2823
+ {
2824
+ name: "fixed",
2825
+ from: "@kitman-sh/software-engineering",
2826
+ exported: "steps.fixed"
2827
+ },
2828
+ {
2829
+ name: "afterFix",
2830
+ from: "@kitman-sh/software-engineering"
2831
+ },
2832
+ {
2833
+ name: "opened",
2834
+ from: "@kitman-sh/software-engineering",
2835
+ exported: "steps.opened"
2836
+ }
2837
+ ],
2838
+ firewatch: [
2839
+ {
2840
+ name: "folded",
2841
+ from: "@kitman-sh/software-engineering",
2842
+ exported: "steps.folded"
2843
+ },
2844
+ {
2845
+ name: "investigated",
2846
+ from: "@kitman-sh/software-engineering",
2847
+ exported: "steps.investigated"
2848
+ },
2849
+ {
2850
+ name: "concluded",
2851
+ from: "@kitman-sh/software-engineering",
2852
+ exported: "steps.concluded"
2853
+ },
2854
+ {
2855
+ name: "fixOffered",
2856
+ from: "@kitman-sh/software-engineering",
2857
+ exported: "steps.fixOffered"
2858
+ }
2859
+ ],
2860
+ plan: [
2861
+ {
2862
+ name: "drafted",
2863
+ from: "@kitman-sh/software-engineering",
2864
+ exported: "steps.drafted"
2865
+ },
2866
+ {
2867
+ name: "planReviewed",
2868
+ from: "@kitman-sh/software-engineering",
2869
+ exported: "steps.planReviewed"
2870
+ },
2871
+ {
2872
+ name: "chosen",
2873
+ from: "@kitman-sh/software-engineering",
2874
+ exported: "steps.chosen"
2875
+ },
2876
+ {
2877
+ name: "leftForPickup",
2878
+ from: "@kitman-sh/sdk/loop",
2879
+ exported: "leftForPickup"
2880
+ },
2881
+ {
2882
+ name: "filed",
2883
+ from: "@kitman-sh/software-engineering",
2884
+ exported: "steps.filed"
2885
+ },
2886
+ {
2887
+ name: "integrated",
2888
+ from: "@kitman-sh/sdk/loop",
2889
+ exported: "integrated"
2890
+ },
2891
+ {
2892
+ name: "ticketBuilt",
2893
+ from: "@kitman-sh/software-engineering",
2894
+ exported: "steps.ticketBuilt"
2895
+ },
2896
+ {
2897
+ name: "buildTried",
2898
+ from: "@kitman-sh/software-engineering",
2899
+ exported: "steps.buildTried"
2900
+ },
2901
+ {
2902
+ name: "mergeTried",
2903
+ from: "@kitman-sh/software-engineering",
2904
+ exported: "steps.mergeTried"
2905
+ },
2906
+ {
2907
+ name: "retried",
2908
+ from: "@kitman-sh/software-engineering",
2909
+ exported: "steps.retried"
2910
+ },
2911
+ {
2912
+ name: "failureAnswered",
2913
+ from: "@kitman-sh/software-engineering",
2914
+ exported: "steps.failureAnswered"
2915
+ },
2916
+ {
2917
+ name: "delivered",
2918
+ from: "@kitman-sh/software-engineering",
2919
+ exported: "steps.delivered"
2920
+ },
2921
+ {
2922
+ name: "refined",
2923
+ from: "@kitman-sh/software-engineering",
2924
+ exported: "steps.refined"
2925
+ }
2926
+ ],
2927
+ "project-update": [
2928
+ {
2929
+ name: "written",
2930
+ from: "@kitman-sh/software-engineering",
2931
+ exported: "steps.written"
2932
+ },
2933
+ {
2934
+ name: "posted",
2935
+ from: "@kitman-sh/software-engineering",
2936
+ exported: "steps.posted"
2937
+ }
2938
+ ],
2939
+ release: [
2940
+ {
2941
+ name: "deploy",
2942
+ from: "@kitman-sh/software-engineering",
2943
+ exported: "steps.deploy"
2944
+ },
2945
+ {
2946
+ name: "gate",
2947
+ from: "@kitman-sh/software-engineering",
2948
+ exported: "steps.gate"
2949
+ },
2950
+ {
2951
+ name: "cut",
2952
+ from: "@kitman-sh/software-engineering",
2953
+ exported: "steps.cut"
2954
+ },
2955
+ {
2956
+ name: "notes",
2957
+ from: "@kitman-sh/software-engineering",
2958
+ exported: "steps.notes"
2959
+ },
2960
+ {
2961
+ name: "approve",
2962
+ from: "@kitman-sh/software-engineering",
2963
+ exported: "steps.approve"
2964
+ },
2965
+ {
2966
+ name: "land",
2967
+ from: "@kitman-sh/software-engineering",
2968
+ exported: "steps.land"
2969
+ },
2970
+ {
2971
+ name: "publish",
2972
+ from: "@kitman-sh/software-engineering",
2973
+ exported: "steps.publish"
2974
+ }
2975
+ ],
2976
+ "release-set": [
2977
+ {
2978
+ name: "setDrafted",
2979
+ from: "@kitman-sh/software-engineering",
2980
+ exported: "steps.setDrafted"
2981
+ },
2982
+ {
2983
+ name: "setApproved",
2984
+ from: "@kitman-sh/software-engineering",
2985
+ exported: "steps.setApproved"
2986
+ },
2987
+ {
2988
+ name: "setReleased",
2989
+ from: "@kitman-sh/software-engineering",
2990
+ exported: "steps.setReleased"
2991
+ }
2992
+ ],
2993
+ research: [
2994
+ {
2995
+ name: "researched",
2996
+ from: "@kitman-sh/software-engineering",
2997
+ exported: "steps.researched"
2998
+ },
2999
+ {
3000
+ name: "researchReviewed",
3001
+ from: "@kitman-sh/software-engineering",
3002
+ exported: "steps.researchReviewed"
3003
+ }
3004
+ ],
3005
+ hindsight: [
3006
+ {
3007
+ name: "found",
3008
+ from: "@kitman-sh/software-engineering",
3009
+ exported: "steps.found"
3010
+ },
3011
+ {
3012
+ name: "proposed",
3013
+ from: "@kitman-sh/software-engineering",
3014
+ exported: "steps.proposed"
3015
+ },
3016
+ {
3017
+ name: "improved",
3018
+ from: "@kitman-sh/software-engineering",
3019
+ exported: "steps.improved"
3020
+ }
3021
+ ],
3022
+ land: [],
3023
+ "land-epic": [],
3024
+ review: [
3025
+ {
3026
+ name: "ranged",
3027
+ from: "@kitman-sh/software-engineering",
3028
+ exported: "steps.ranged"
3029
+ },
3030
+ {
3031
+ name: "checked",
3032
+ from: "@kitman-sh/software-engineering",
3033
+ exported: "steps.checked"
3034
+ },
3035
+ {
3036
+ name: "seated",
3037
+ from: "@kitman-sh/software-engineering",
3038
+ exported: "steps.seated"
3039
+ },
3040
+ {
3041
+ name: "judged",
3042
+ from: "@kitman-sh/software-engineering",
3043
+ exported: "steps.judged"
3044
+ },
3045
+ {
3046
+ name: "followedUp",
3047
+ from: "@kitman-sh/software-engineering",
3048
+ exported: "steps.followedUp"
3049
+ }
3050
+ ],
3051
+ revert: [],
3052
+ shepherd: [
3053
+ {
3054
+ name: "looked",
3055
+ from: "@kitman-sh/software-engineering",
3056
+ exported: "steps.looked"
3057
+ },
3058
+ {
3059
+ name: "pushShown",
3060
+ from: "@kitman-sh/software-engineering",
3061
+ exported: "steps.pushShown"
3062
+ },
3063
+ {
3064
+ name: "pushSeen",
3065
+ from: "@kitman-sh/software-engineering",
3066
+ exported: "steps.pushSeen"
3067
+ },
3068
+ {
3069
+ name: "reviewReused",
3070
+ from: "@kitman-sh/software-engineering",
3071
+ exported: "steps.reviewReused"
3072
+ },
3073
+ {
3074
+ name: "green",
3075
+ from: "@kitman-sh/sdk/loop",
3076
+ exported: "green"
3077
+ },
3078
+ {
3079
+ name: "filesReviewed",
3080
+ from: "@kitman-sh/software-engineering",
3081
+ exported: "steps.filesReviewed"
3082
+ },
3083
+ {
3084
+ name: "approved",
3085
+ from: "@kitman-sh/software-engineering",
3086
+ exported: "steps.approved"
3087
+ },
3088
+ {
3089
+ name: "headReviewed",
3090
+ from: "@kitman-sh/software-engineering",
3091
+ exported: "steps.headReviewed"
3092
+ },
3093
+ {
3094
+ name: "blockerRechecked",
3095
+ from: "@kitman-sh/software-engineering",
3096
+ exported: "steps.blockerRechecked"
3097
+ },
3098
+ {
3099
+ name: "handedBack",
3100
+ from: "@kitman-sh/software-engineering",
3101
+ exported: "steps.handedBack"
3102
+ },
3103
+ {
3104
+ name: "caughtUp",
3105
+ from: "@kitman-sh/software-engineering",
3106
+ exported: "steps.caughtUp"
3107
+ },
3108
+ {
3109
+ name: "level",
3110
+ from: "@kitman-sh/sdk/loop",
3111
+ exported: "level"
3112
+ },
3113
+ {
3114
+ name: "targetChecked",
3115
+ from: "@kitman-sh/software-engineering",
3116
+ exported: "steps.targetChecked"
3117
+ },
3118
+ {
3119
+ name: "waitedOut",
3120
+ from: "@kitman-sh/software-engineering",
3121
+ exported: "steps.waitedOut"
3122
+ },
3123
+ {
3124
+ name: "targetReread",
3125
+ from: "@kitman-sh/software-engineering",
3126
+ exported: "steps.targetReread"
3127
+ },
3128
+ {
3129
+ name: "answered",
3130
+ from: "@kitman-sh/software-engineering",
3131
+ exported: "steps.answered"
3132
+ },
3133
+ {
3134
+ name: "replied",
3135
+ from: "@kitman-sh/software-engineering",
3136
+ exported: "steps.replied"
3137
+ },
3138
+ {
3139
+ name: "heldReady",
3140
+ from: "@kitman-sh/software-engineering",
3141
+ exported: "steps.heldReady"
3142
+ },
3143
+ {
3144
+ name: "targetWatched",
3145
+ from: "@kitman-sh/software-engineering",
3146
+ exported: "steps.targetWatched"
3147
+ },
3148
+ {
3149
+ name: "targetVerified",
3150
+ from: "@kitman-sh/software-engineering",
3151
+ exported: "steps.targetVerified"
3152
+ },
3153
+ {
3154
+ name: "targetLooked",
3155
+ from: "@kitman-sh/software-engineering",
3156
+ exported: "steps.targetLooked"
3157
+ },
3158
+ {
3159
+ name: "mergedOnTurn",
3160
+ from: "@kitman-sh/software-engineering",
3161
+ exported: "steps.mergedOnTurn"
3162
+ },
3163
+ {
3164
+ name: "landed",
3165
+ from: "@kitman-sh/sdk/loop",
3166
+ exported: "landed"
3167
+ },
3168
+ {
3169
+ name: "roundAllowed",
3170
+ from: "@kitman-sh/software-engineering",
3171
+ exported: "steps.roundAllowed"
3172
+ },
3173
+ {
3174
+ name: "headFixed",
3175
+ from: "@kitman-sh/software-engineering",
3176
+ exported: "steps.headFixed"
3177
+ },
3178
+ {
3179
+ name: "ciFixed",
3180
+ from: "@kitman-sh/software-engineering",
3181
+ exported: "steps.ciFixed"
3182
+ },
3183
+ {
3184
+ name: "reran",
3185
+ from: "@kitman-sh/software-engineering",
3186
+ exported: "steps.reran"
3187
+ },
3188
+ {
3189
+ name: "backported",
3190
+ from: "@kitman-sh/software-engineering",
3191
+ exported: "steps.backported"
3192
+ },
3193
+ {
3194
+ name: "backportStarted",
3195
+ from: "@kitman-sh/software-engineering",
3196
+ exported: "steps.backportStarted"
3197
+ },
3198
+ {
3199
+ name: "epicLanded",
3200
+ from: "@kitman-sh/software-engineering",
3201
+ exported: "steps.epicLanded"
3202
+ },
3203
+ {
3204
+ name: "landingTried",
3205
+ from: "@kitman-sh/software-engineering",
3206
+ exported: "steps.landingTried"
3207
+ },
3208
+ {
3209
+ name: "released",
3210
+ from: "@kitman-sh/software-engineering",
3211
+ exported: "steps.released"
3212
+ }
3213
+ ],
3214
+ sweep: [
3215
+ {
3216
+ name: "listed",
3217
+ from: "@kitman-sh/software-engineering",
3218
+ exported: "steps.listed"
3219
+ },
3220
+ {
3221
+ name: "superseded",
3222
+ from: "@kitman-sh/software-engineering",
3223
+ exported: "steps.superseded"
3224
+ },
3225
+ {
3226
+ name: "closed",
3227
+ from: "@kitman-sh/software-engineering",
3228
+ exported: "steps.closed"
3229
+ },
3230
+ {
3231
+ name: "assessed",
3232
+ from: "@kitman-sh/software-engineering",
3233
+ exported: "steps.assessed"
3234
+ },
3235
+ {
3236
+ name: "batched",
3237
+ from: "@kitman-sh/software-engineering",
3238
+ exported: "steps.batched"
3239
+ },
3240
+ {
3241
+ name: "mended",
3242
+ from: "@kitman-sh/software-engineering",
3243
+ exported: "steps.mended"
3244
+ },
3245
+ {
3246
+ name: "opened",
3247
+ from: "@kitman-sh/software-engineering",
3248
+ exported: "steps.opened"
3249
+ }
3250
+ ],
3251
+ tidy: [
3252
+ {
3253
+ name: "surveyed",
3254
+ from: "@kitman-sh/software-engineering",
3255
+ exported: "steps.surveyed"
3256
+ },
3257
+ {
3258
+ name: "tidied",
3259
+ from: "@kitman-sh/software-engineering",
3260
+ exported: "steps.tidied"
3261
+ },
3262
+ {
3263
+ name: "opened",
3264
+ from: "@kitman-sh/software-engineering",
3265
+ exported: "steps.opened"
3266
+ }
3267
+ ]
3268
+ };
2387
3269
 
2388
- // apps/cli/src/scaffold.ts
2389
- var cliVersion = "0.14.8";
3270
+ // apps/cli/src/scaffold-files.ts
3271
+ var cliVersion = "0.15.0";
3272
+ var shippedLoopSteps = new Map(Object.entries(shipped_steps_generated_default));
3273
+ var loopSteps = (loop) => shippedLoopSteps.get(loop) ?? [];
3274
+ var replacedStep = (loop) => loopSteps(loop).find((step) => step.from === defaultKitName && step.exported?.startsWith("steps.") === true);
2390
3275
  var packageJson = (name, scaffold) => `${JSON.stringify({
2391
3276
  name,
2392
3277
  private: true,
@@ -2401,65 +3286,161 @@ var packageJson = (name, scaffold) => `${JSON.stringify({
2401
3286
  }, null, 2)}
2402
3287
  `;
2403
3288
  var exampleConfig = `import { defineKit } from '@kitman-sh/sdk/loop'
2404
- import greet from './loops/greet'
3289
+ import fix from './loops/fix'
2405
3290
 
2406
3291
  export default defineKit({
2407
- loops: [greet]
3292
+ loops: [fix]
2408
3293
  })
2409
3294
  `;
2410
- var exampleLoop = `import { defineLoop } from '@kitman-sh/sdk/loop'
2411
- import * as Effect from 'effect/Effect'
3295
+ var exampleLoop = `import * as Effect from 'effect/Effect'
2412
3296
  import * as Schema from 'effect/Schema'
2413
- import { Activity } from 'effect/workflow'
3297
+ import { agent, defineLoop, step, verify } from '@kitman-sh/sdk/loop'
3298
+
3299
+ const implementer = agent('implementer')
3300
+
3301
+ export class Fixed extends Schema.TaggedClass<Fixed>()('Fixed', { summary: Schema.String }) {}
3302
+
3303
+ export class CannotFix extends Schema.TaggedError<CannotFix>()('CannotFix', { reason: Schema.String }) {}
3304
+
3305
+ const FixAnswer = Schema.Struct({ fixed: Schema.Boolean, summary: Schema.String })
3306
+
3307
+ /** An agent fixes the ticket on the Run's branch, or says why it cannot. */
3308
+ export const fixed = step('fixed', {
3309
+ payload: { ticket: Schema.String.annotate({ description: 'The ticket to fix.' }) },
3310
+ success: Fixed,
3311
+ error: CannotFix,
3312
+ run: ({ ticket }) =>
3313
+ Effect.gen(function* () {
3314
+ const answer = yield* implementer('fix', { prompt: \`Fix \${ticket}.\`, output: FixAnswer })
3315
+
3316
+ return answer.fixed ? new Fixed({ summary: answer.summary }) : yield* new CannotFix({ reason: answer.summary })
3317
+ })
3318
+ })
3319
+
3320
+ export class Passed extends Schema.TaggedClass<Passed>()('Passed', { revision: Schema.String }) {}
3321
+
3322
+ export class ChecksFailed extends Schema.TaggedError<ChecksFailed>()('ChecksFailed', {
3323
+ failed: Schema.Array(Schema.String)
3324
+ }) {}
3325
+
3326
+ /** Runs the repository's approved checks at the Run's head. */
3327
+ export const checked = step('checked', {
3328
+ payload: {},
3329
+ success: Passed,
3330
+ error: ChecksFailed,
3331
+ run: () =>
3332
+ Effect.gen(function* () {
3333
+ const evidence = yield* verify('checks', {})
3334
+ const failed = evidence.checks.filter(check => check.status === 'failed').map(check => check.name)
3335
+
3336
+ return evidence.passed ? new Passed({ revision: evidence.revision }) : yield* new ChecksFailed({ failed })
3337
+ })
3338
+ })
2414
3339
 
2415
3340
  export default defineLoop({
2416
- id: 'greet',
2417
- title: 'Greet',
2418
- input: Schema.Struct({ name: Schema.String }),
2419
- output: Schema.Struct({ greeting: Schema.String }),
2420
- agents: {},
2421
- checkout: 'none',
2422
- capabilities: [],
2423
- run: ({ name }) =>
2424
- Effect.map(
2425
- Activity.make({ name: 'greet', success: Schema.String, execute: Effect.succeed(\`Hello, \${name}\`) }),
2426
- greeting => ({ greeting })
3341
+ id: 'fix',
3342
+ title: 'Fix',
3343
+ input: Schema.Struct({ ticket: Schema.String.annotate({ description: 'The ticket to fix.' }) }),
3344
+ output: Schema.Struct({
3345
+ status: Schema.Literals(['fixed', 'not_fixed', 'red']),
3346
+ summary: Schema.String.annotate({ description: 'What changed, or why nothing did.' })
3347
+ }),
3348
+ agents: { implementer: 'implementer' },
3349
+ checkout: 'write',
3350
+ capabilities: ['agent_work', 'verify'],
3351
+ run: ({ ticket }) =>
3352
+ Effect.gen(function* () {
3353
+ const { summary } = yield* fixed({ ticket })
3354
+ const { revision } = yield* checked({})
3355
+
3356
+ return { status: 'fixed' as const, summary: \`\${summary} Checks passed at \${revision}.\` }
3357
+ }).pipe(
3358
+ Effect.catchTags({
3359
+ CannotFix: ({ reason }) => Effect.succeed({ status: 'not_fixed' as const, summary: reason }),
3360
+ ChecksFailed: ({ failed }) =>
3361
+ Effect.succeed({ status: 'red' as const, summary: \`Failed: \${failed.join(', ')}\` })
3362
+ })
2427
3363
  ),
2428
3364
  // A build runs each check twice, the second time replaying the first from its journal.
2429
- checks: [{ name: 'greets', script: { input: { name: 'Ada' } } }]
3365
+ checks: [
3366
+ {
3367
+ name: 'fixes',
3368
+ script: {
3369
+ input: { ticket: 'KIT-1' },
3370
+ outputs: { 'fixed/fix': { fixed: true, summary: 'Guarded the empty list.' } }
3371
+ }
3372
+ }
3373
+ ]
2430
3374
  })
2431
3375
  `;
2432
3376
  var exampleTest = `import { expect, test } from 'bun:test'
2433
3377
  import { testLoop } from '@kitman-sh/sdk/loop'
2434
3378
  import * as Effect from 'effect/Effect'
2435
3379
  import * as Exit from 'effect/Exit'
2436
- import greet from './greet'
3380
+ import fix, { checked, ChecksFailed, Fixed, fixed } from './fix'
2437
3381
 
2438
- test('greets by name', async () => {
2439
- const run = await Effect.runPromise(testLoop(greet, { input: { name: 'Ada' } }))
3382
+ test('reports the checks that failed after the fix', async () => {
3383
+ const run = await Effect.runPromise(
3384
+ testLoop(fix, {
3385
+ input: { ticket: 'KIT-1' },
3386
+ steps: {
3387
+ fixed: fixed.succeeded(new Fixed({ summary: 'Guarded the empty list.' })),
3388
+ checked: checked.failed(new ChecksFailed({ failed: ['unit-tests'] }))
3389
+ }
3390
+ })
3391
+ )
2440
3392
 
2441
- expect(run.result).toEqual(Exit.succeed({ greeting: 'Hello, Ada' }))
3393
+ expect(run.result).toEqual(Exit.succeed({ status: 'red', summary: 'Failed: unit-tests' }))
2442
3394
  })
2443
3395
  `;
2444
- var forkConfig = (loop) => `import { defineKit } from '@kitman-sh/sdk/loop'
3396
+ var stepLine = (step) => `// ${step.exported ?? step.name}${step.from === defaultKitName ? "" : ` (from ${step.from})`}${step.exported === undefined ? ", called by another Step" : ""}`;
3397
+ var forkConfig = (loop) => {
3398
+ const replaced = replacedStep(loop);
3399
+ const listed = loopSteps(loop);
3400
+ if (replaced?.exported === undefined)
3401
+ return `import { defineKit } from '@kitman-sh/sdk/loop'
2445
3402
  import { loops } from '${defaultKitName}'
2446
3403
 
2447
3404
  export default defineKit({
2448
3405
  loops: [
2449
3406
  {
2450
3407
  ...loops['${loop}']
2451
- // Change a field of the Loop here, such as title: 'Our ${loop}'.
3408
+ // ${loop} defines no Step of its own to replace; change a field of the Loop here, such as title: 'Our ${loop}'.
2452
3409
  }
2453
3410
  ]
2454
3411
  })
2455
3412
  `;
2456
- var forkTest = (loop) => `import { expect, test } from 'bun:test'
3413
+ const shipped = `shipped${replaced.name.charAt(0).toUpperCase()}${replaced.name.slice(1)}`;
3414
+ return `import { defineKit, defineLoop } from '@kitman-sh/sdk/loop'
3415
+ import { loops, steps } from '${defaultKitName}'
3416
+
3417
+ // ${loop} calls these Steps, in order; a Layer in \`provide\` replaces any exported one:
3418
+ ${listed.map(stepLine).join(`
3419
+ `)}
3420
+ const ${shipped} = ${replaced.exported}.run.defaultValue()
3421
+
3422
+ export default defineKit({
3423
+ loops: [
3424
+ defineLoop({
3425
+ ...loops['${loop}'],
3426
+ // Runs the shipped Step; change what it is asked, or do the work another way, here.
3427
+ provide: ${replaced.exported}.layer(payload => ${shipped}(payload))
3428
+ })
3429
+ ]
3430
+ })
3431
+ `;
3432
+ };
3433
+ var forkTest = (loop) => {
3434
+ const replaced = replacedStep(loop);
3435
+ return `import { expect, test } from 'bun:test'
2457
3436
  import config from './kitman.config'
2458
3437
 
2459
- test('declares the forked Loop', () => {
2460
- expect(config.loops.map(loop => loop.id)).toEqual(['${loop}'])
3438
+ test('${replaced === undefined ? "declares the forked Loop" : `forks ${loop} and replaces ${replaced.name}`}', () => {
3439
+ expect(config.loops.map(loop => loop.id)).toEqual(['${loop}'])${replaced === undefined ? "" : `
3440
+ expect(config.loops[0]?.provide).toBeDefined()`}
2461
3441
  })
2462
3442
  `;
3443
+ };
2463
3444
  var pipeline = (apiUrl, workspaceId) => `# Plans on merge requests and deploys the default branch through a Deploy Binding (see README.md).
2464
3445
  variables:
2465
3446
  KITMAN_API_URL: ${apiUrl}
@@ -2491,7 +3472,7 @@ kitman-deploy:
2491
3472
  var readme = (name, scaffold) => [
2492
3473
  `# ${name}`,
2493
3474
  "",
2494
- scaffold.fork === undefined ? "A Kitman Kit: its Loops and Agents are declared in `kitman.config.ts`." : `A Kitman Kit that forks the \`${scaffold.fork}\` Loop of \`${defaultKitName}\` by spreading it in \`kitman.config.ts\`. Change a field there; once deployed, the fork replaces the installed Loop in its layer.`,
3475
+ scaffold.fork === undefined ? "A Kitman Kit: its Loops and Agents are declared in `kitman.config.ts`. `loops/fix.ts` is a Loop that defines two Steps, and `loops/fix.test.ts` tests it by scripting one." : `A Kitman Kit that forks the \`${scaffold.fork}\` Loop of \`${defaultKitName}\` in \`kitman.config.ts\`, which lists the Steps the Loop calls. ${replacedStep(scaffold.fork) === undefined ? "Change a field there" : "Change what the replaced Step does there, or replace another the same way"}; once deployed, the fork replaces the installed Loop in its layer.`,
2495
3476
  "",
2496
3477
  "1. `bun install`, then `bun test`.",
2497
3478
  "2. `bunx kitman deploy --plan` shows what deploying would change.",
@@ -2501,6 +3482,16 @@ var readme = (name, scaffold) => [
2501
3482
  ""
2502
3483
  ].join(`
2503
3484
  `);
3485
+ var scaffoldFiles = (name, scaffold, target) => ({
3486
+ "package.json": packageJson(name, scaffold),
3487
+ ".gitignore": `node_modules
3488
+ `,
3489
+ ".gitlab-ci.yml": pipeline(target.apiUrl, target.workspaceId),
3490
+ "README.md": readme(name, scaffold),
3491
+ ...scaffold.fork === undefined ? { "kitman.config.ts": exampleConfig, "loops/fix.ts": exampleLoop, "loops/fix.test.ts": exampleTest } : { "kitman.config.ts": forkConfig(scaffold.fork), "kitman.config.test.ts": forkTest(scaffold.fork) }
3492
+ });
3493
+
3494
+ // apps/cli/src/scaffold.ts
2504
3495
  var scaffoldKit = (directory, scaffold = {}) => gen(function* () {
2505
3496
  const fs = yield* FileSystem;
2506
3497
  const path = yield* Path;
@@ -2521,24 +3512,28 @@ var scaffoldKit = (directory, scaffold = {}) => gen(function* () {
2521
3512
  return;
2522
3513
  }));
2523
3514
  const name = path.basename(root).toLowerCase().replace(/[^a-z0-9-._~]/g, "-");
2524
- const files = {
2525
- "package.json": packageJson(name, scaffold),
2526
- ".gitignore": `node_modules
2527
- `,
2528
- ".gitlab-ci.yml": pipeline(config?.apiUrl ?? "<Kitman API URL>", config?.activeWorkspaceId ?? "<workspace id>"),
2529
- "README.md": readme(name, scaffold),
2530
- ...scaffold.fork === undefined ? { "kitman.config.ts": exampleConfig, "loops/greet.ts": exampleLoop, "loops/greet.test.ts": exampleTest } : { "kitman.config.ts": forkConfig(scaffold.fork), "kitman.config.test.ts": forkTest(scaffold.fork) }
2531
- };
3515
+ const files = scaffoldFiles(name, scaffold, {
3516
+ apiUrl: config?.apiUrl ?? "<Kitman API URL>",
3517
+ workspaceId: config?.activeWorkspaceId ?? "<workspace id>"
3518
+ });
2532
3519
  for (const [file, content] of Object.entries(files)) {
2533
3520
  yield* fs.makeDirectory(path.dirname(path.join(root, file)), { recursive: true });
2534
3521
  yield* fs.writeFileString(path.join(root, file), content);
2535
3522
  }
3523
+ if (scaffold.fork !== undefined) {
3524
+ const steps = loopSteps(scaffold.fork);
3525
+ yield* log(steps.length === 0 ? `${scaffold.fork} defines no Step of its own; the fork spreads it.` : [
3526
+ `${scaffold.fork} calls these Steps; the fork replaces the first of its own:`,
3527
+ ...steps.map((step) => ` ${step.name}`)
3528
+ ].join(`
3529
+ `));
3530
+ }
2536
3531
  yield* log(`Scaffolded ${name} in ${root}. Run bun install and bun test there, then read README.md to deploy it.`);
2537
3532
  });
2538
3533
 
2539
3534
  // apps/cli/src/commands.ts
2540
3535
  var ClientId = "kitman-cli";
2541
- var agentRuntime = promise(() => import("./chunk-6dj39qtt.js"));
3536
+ var agentRuntime = promise(() => import("./chunk-58hehm8d.js"));
2542
3537
  var TuiLauncher = Reference("kitman/cli/TuiLauncher", {
2543
3538
  defaultValue: () => gen(function* () {
2544
3539
  const tui = yield* tryPromise({
@@ -2640,6 +3635,10 @@ function runEffect(args) {
2640
3635
  return yield* deliveryCommand(args);
2641
3636
  if (command === "release")
2642
3637
  return yield* releaseTriggerCommand(args);
3638
+ if (command === "project")
3639
+ return yield* projectCommand(args);
3640
+ if (command === "deploy-target")
3641
+ return yield* deployTargetCommand(args);
2643
3642
  if (command === "land")
2644
3643
  return yield* deliveryTargetCommand(args);
2645
3644
  if (command === "lifecycle")
@@ -2676,6 +3675,8 @@ function parseCommand(args) {
2676
3675
  flags.all = true;
2677
3676
  else if (arg === "--fresh")
2678
3677
  flags.fresh = true;
3678
+ else if (arg === "--no-team")
3679
+ flags.noTeam = true;
2679
3680
  else if (arg === "--override-blockers")
2680
3681
  flags.overrideBlockers = true;
2681
3682
  else if (arg === "--local")
@@ -2720,7 +3721,41 @@ function parseCommand(args) {
2720
3721
  flags.pipeline = true;
2721
3722
  else if (arg === "--reads-target")
2722
3723
  flags.readsTarget = true;
2723
- else if (arg === "--constraint" || arg === "--add-constraint" || arg === "--remove-constraint") {
3724
+ else if (arg === "--mermaid")
3725
+ flags.mermaid = true;
3726
+ else if (arg === "--command")
3727
+ flags.asCommand = true;
3728
+ else if (group === "release" && arg === "--no-prereleases")
3729
+ flags.withoutPrereleases = true;
3730
+ else if (group === "release" && arg === "--since") {
3731
+ const value = args[++index];
3732
+ if (!value)
3733
+ throw new Error("--since requires a tag");
3734
+ flags.since = value;
3735
+ } else if (group === "loop" && action === "input" && (arg === "--clear" || arg === "--off" || arg === "--on")) {
3736
+ if (arg === "--clear")
3737
+ flags.clear = true;
3738
+ else
3739
+ flags.whenOff = arg === "--off";
3740
+ } else if (group === "project" && action === "release" && (arg === "--milestone" || arg === "--repository" || arg === "--when")) {
3741
+ const value = args[++index];
3742
+ if (!value)
3743
+ throw new Error(`${arg} requires a value`);
3744
+ if (arg === "--milestone")
3745
+ flags.milestone = value;
3746
+ else if (arg === "--when")
3747
+ flags.when = value;
3748
+ else
3749
+ flags.repository = value;
3750
+ } else if (group === "loop" && action === "input" && (arg === "--project" || arg === "--when")) {
3751
+ const value = args[++index];
3752
+ if (!value)
3753
+ throw new Error(`${arg} requires a value`);
3754
+ if (arg === "--project")
3755
+ flags.project = value;
3756
+ else
3757
+ flags.when = value;
3758
+ } else if (arg === "--constraint" || arg === "--add-constraint" || arg === "--remove-constraint") {
2724
3759
  const value = args[++index];
2725
3760
  if (!value)
2726
3761
  throw new Error(`${arg} requires a value`);
@@ -2902,9 +3937,10 @@ function parseCommand(args) {
2902
3937
  flags.provider = validateRepoBindingProvider(value);
2903
3938
  else if (arg === "--task")
2904
3939
  flags.taskId = value;
2905
- else if (arg === "--input")
3940
+ else if (arg === "--input") {
2906
3941
  flags.input = value;
2907
- else if (arg === "--idempotency-key" || arg === "--key")
3942
+ flags.inputs = [...flags.inputs ?? [], value];
3943
+ } else if (arg === "--idempotency-key" || arg === "--key")
2908
3944
  flags.idempotencyKey = value;
2909
3945
  else if (arg === "--after")
2910
3946
  flags.after = value;
@@ -2970,7 +4006,7 @@ function harnessSync(args) {
2970
4006
  });
2971
4007
  });
2972
4008
  }
2973
- var readStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map8((text) => text.trim()));
4009
+ var readStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map9((text) => text.trim()));
2974
4010
  function promptLine(prompt) {
2975
4011
  return gen(function* () {
2976
4012
  const terminal = yield* Terminal;
@@ -3159,6 +4195,47 @@ function workspaceCommand(args) {
3159
4195
  return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
3160
4196
  });
3161
4197
  }
4198
+ var taskMilestones = [
4199
+ "started",
4200
+ "completed",
4201
+ "failed",
4202
+ "blocked",
4203
+ "change_request_opened",
4204
+ "merged",
4205
+ "released"
4206
+ ];
4207
+ var teamMilestonesCommand = (client, workspaceId, command) => gen(function* () {
4208
+ const listed = yield* teamNamed(client, workspaceId, requiredArg(command, "team"));
4209
+ const [, name, to] = command.args;
4210
+ const milestone = taskMilestones.find((candidate) => candidate === name);
4211
+ if (name !== undefined && milestone === undefined)
4212
+ return yield* new CliError({ message: `No milestone ${name}; give ${taskMilestones.join(", ")}` });
4213
+ const team = yield* client.getTeam(workspaceId, listed.id);
4214
+ const print = ({ milestoneMapping, states }, shown) => printRows(shown.map((entry) => {
4215
+ const mapped = states.find((state) => state.id === milestoneMapping[entry]);
4216
+ if (!command.flags.json)
4217
+ return { milestone: entry, state: mapped?.name ?? "nothing" };
4218
+ return {
4219
+ milestone: entry,
4220
+ ...mapped === undefined ? undefined : { state: mapped.name, stateId: mapped.id }
4221
+ };
4222
+ }), command.flags.json);
4223
+ if (milestone === undefined || to === undefined)
4224
+ return yield* print(team, milestone === undefined ? taskMilestones : [milestone]);
4225
+ const matches = to === "none" ? [] : team.states.filter(({ id, name: called, category }) => category !== "triage" && (id === to || called.toLowerCase() === to.toLowerCase()));
4226
+ const [state] = matches;
4227
+ if (matches.length > 1)
4228
+ return yield* new CliError({
4229
+ message: `${team.key} has ${matches.length} states named ${to}; give the id of one: ${matches.map(({ id }) => id).join(", ")}`
4230
+ });
4231
+ if (state === undefined && to !== "none")
4232
+ return yield* new CliError({ message: `${team.key} has no state ${to} a milestone can move a Task to` });
4233
+ const { [milestone]: _, ...others } = team.milestoneMapping;
4234
+ const updated = yield* client.setMilestoneMapping(workspaceId, team.id, state === undefined ? others : { ...others, [milestone]: state.id });
4235
+ if (command.flags.json)
4236
+ return yield* print(updated, [milestone]);
4237
+ return yield* log(state === undefined ? `${team.key}'s Tasks move nowhere on ${milestone}` : `${team.key}'s Tasks move to ${state.name} on ${milestone}`);
4238
+ });
3162
4239
  function teamCommand(args) {
3163
4240
  return gen(function* () {
3164
4241
  const command = parseCommand(args);
@@ -3190,6 +4267,8 @@ function teamCommand(args) {
3190
4267
  yield* client.updateTeamDeliverySettings(team.id, { delivery, expectedRevision: revision });
3191
4268
  return yield* log(delivery === "auto" ? `${team.key} delivers in full auto: a passing Review of the head approves it, and its Loops merge and release with nobody asked` : `${team.key} is gated: a person approves each merge and release`);
3192
4269
  }
4270
+ if (command.action === "milestones")
4271
+ return yield* teamMilestonesCommand(client, workspaceId, command);
3193
4272
  if (command.action === "scope") {
3194
4273
  const team = yield* teamNamed(client, workspaceId, requiredArg(command, "team"));
3195
4274
  const scope = command.args[1];
@@ -3220,7 +4299,8 @@ var teamIn = (teams, ref) => {
3220
4299
  var releaseTriggerWords = {
3221
4300
  merge: "on each merge",
3222
4301
  milestone: "when each Milestone is done",
3223
- project: "when the Project is done"
4302
+ project: "when the Project is done",
4303
+ manual: "only when a person, a Schedule or a Loop starts it"
3224
4304
  };
3225
4305
  var releaseLayerWords = {
3226
4306
  run: "the Run",
@@ -3233,21 +4313,442 @@ var releaseTriggerLine = (subject, setting) => {
3233
4313
  const resolved = setting.resolved;
3234
4314
  return setting.trigger === null && resolved !== undefined ? `${subject} ${own}: it releases ${releaseTriggerWords[resolved.trigger]}, from ${releaseLayerWords[resolved.layer]}` : setting.trigger === null ? `${subject} inherits its Team's release trigger` : `${subject} ${own}`;
3235
4315
  };
3236
- var releaseChoices = ["merge", "milestone", "project", "inherit"];
4316
+ var releaseChoices = ["merge", "milestone", "project", "manual", "inherit"];
4317
+ var projectNamed = (client, workspaceId, named) => gen(function* () {
4318
+ const ref = named.trim();
4319
+ const project = (yield* client.listProjects(workspaceId)).items.find((candidate) => candidate.id === ref || candidate.name.toLowerCase() === ref.toLowerCase());
4320
+ if (project === undefined)
4321
+ return yield* new CliError({ message: `No Project named ${ref}` });
4322
+ return project;
4323
+ });
4324
+ var targetBranchLine = (subject, layer, setting) => setting.targetBranch === null ? {
4325
+ project: `${subject}'s work merges into each repository's default branch`,
4326
+ milestone: `${subject}'s work merges into its Project's target branch, else each repository's default branch`,
4327
+ task: `${subject}'s work merges into its Milestone's or Project's target branch, else each repository's default branch`
4328
+ }[layer] : {
4329
+ project: `${subject}'s work merges into ${setting.targetBranch}, made from each repository's default branch when missing`,
4330
+ milestone: `${subject}'s work merges into ${setting.targetBranch}, made from and delivering into its Project's target branch, else the default branch`,
4331
+ task: `${subject}'s work merges into ${setting.targetBranch}, whatever its Milestone and Project say`
4332
+ }[layer];
4333
+ var givenBranch = (command, given) => gen(function* () {
4334
+ const branch = given?.trim();
4335
+ if (branch !== undefined && branch !== "none" && !isBranchName(branch))
4336
+ return yield* new CliError({
4337
+ message: `${command} branch takes a branch name git accepts, such as release/next, or none`
4338
+ });
4339
+ return branch === undefined ? undefined : { targetBranch: branch === "none" ? null : branch };
4340
+ });
4341
+ var projectTargetBranchCommand = (client, workspaceId, named, given, json) => gen(function* () {
4342
+ const project = yield* projectNamed(client, workspaceId, named);
4343
+ const update = yield* givenBranch(`release project ${project.name}`, given);
4344
+ const setting = update === undefined ? yield* client.getProjectTargetBranch(workspaceId, project.id) : yield* client.setProjectTargetBranch(workspaceId, project.id, update);
4345
+ return yield* json === true ? printJson(setting) : log(targetBranchLine(project.name, "project", setting));
4346
+ });
4347
+ var milestoneTargetBranchCommand = (client, workspaceId, command) => gen(function* () {
4348
+ const project = yield* projectNamed(client, workspaceId, requiredArg(command, "project"));
4349
+ const ref = (command.args[1] ?? "").trim();
4350
+ const milestone = project.milestones.find((candidate) => candidate.id === ref || candidate.name.toLowerCase() === ref.toLowerCase());
4351
+ if (milestone === undefined)
4352
+ return yield* new CliError({ message: `${project.name} has no Milestone named ${ref}` });
4353
+ if (command.args[2] !== "branch")
4354
+ return yield* new CliError({ message: "release milestone <project> <milestone> takes branch [<name>|none]" });
4355
+ const update = yield* givenBranch(`release milestone ${project.name} ${milestone.name}`, command.args[3]);
4356
+ const setting = update === undefined ? yield* client.getMilestoneTargetBranch(workspaceId, project.id, milestone.id) : yield* client.setMilestoneTargetBranch(workspaceId, project.id, milestone.id, update);
4357
+ return yield* command.flags.json === true ? printJson(setting) : log(targetBranchLine(milestone.name, "milestone", setting));
4358
+ });
4359
+ var taskTargetBranchCommand = (client, workspaceId, command) => gen(function* () {
4360
+ const task = yield* client.getTeamTask(workspaceId, requiredArg(command, "task"));
4361
+ if (command.args[1] !== "branch")
4362
+ return yield* new CliError({ message: "release task <task> takes branch [<name>|none]" });
4363
+ const update = yield* givenBranch(`release task ${task.key}`, command.args[2]);
4364
+ const setting = update === undefined ? yield* client.getTaskTargetBranch(task.id) : yield* client.setTaskTargetBranch(task.id, update);
4365
+ return yield* command.flags.json === true ? printJson(setting) : log(targetBranchLine(task.key, "task", setting));
4366
+ });
4367
+ var repositoryNamed = (client, workspaceId, named) => gen(function* () {
4368
+ const wanted = named.toLowerCase();
4369
+ const matches = (yield* client.listRepoBindings(workspaceId)).items.filter((binding) => `${binding.owner}/${binding.name}`.toLowerCase() === wanted || binding.name.toLowerCase() === wanted);
4370
+ const [binding, ...others] = matches;
4371
+ if (binding === undefined)
4372
+ return yield* new CliError({ message: `No repository of the Workspace is ${named}` });
4373
+ if (others.length > 0)
4374
+ return yield* new CliError({ message: `${named} names ${matches.length} repositories; give it as owner/name` });
4375
+ return binding;
4376
+ });
4377
+ var releaseLine = (release) => [
4378
+ release.tag,
4379
+ release.prerelease ? "prerelease" : "release",
4380
+ release.repository,
4381
+ release.revision?.slice(0, 12) ?? "revision unknown",
4382
+ release.branch === undefined ? undefined : `from ${release.branch}`,
4383
+ release.previousTag === undefined ? undefined : `since ${release.previousTag}`,
4384
+ release.runId === undefined ? "published on the forge" : `by Run ${release.runId}`,
4385
+ release.state === "read" ? undefined : `contents ${release.state}`
4386
+ ].filter((part) => part !== undefined).join(" ");
4387
+ var revertedPart = ({ reverted }) => reverted === undefined ? "" : ` reverted${reverted.release === undefined ? ", in no Release yet" : ` in ${reverted.release.tag}`}`;
4388
+ var changeRequestLine = (changeRequest) => ` ${changeRequestReference(changeRequest)} ${changeRequest.title} merged${changeRequest.mergeRevision === "" ? "" : ` as ${changeRequest.mergeRevision.slice(0, 12)}`} into ${changeRequest.targetBranch}${changeRequest.tasks.length === 0 ? "" : ` ${changeRequest.tasks.map((task) => task.key).join(", ")}`}${revertedPart(changeRequest)}`;
4389
+ var contentsLines = (changeRequests) => {
4390
+ const tasks = releaseTasks(changeRequests);
4391
+ return [
4392
+ ...changeRequests.map(changeRequestLine),
4393
+ ...tasks.length === 0 ? [] : [` Tasks: ${tasks.map((task) => `${task.key} ${task.title}`).join("; ")}`]
4394
+ ];
4395
+ };
4396
+ var contentsState = (release, changeRequests) => release.state === "pending" ? "Kitman has not read what it contains from the forge yet." : release.state === "unreadable" ? "Kitman could not read what it contains from the forge." : changeRequests.length === 0 ? "It contains no ChangeRequest you may see." : "ChangeRequests:";
4397
+ var deployedToLines = (release) => release.deployTargets.map((deployed) => ` ${deployed.target} ${releaseDeployState(deployed, (time) => time)}`);
4398
+ var releaseListLines = (release) => [
4399
+ releaseLine(release),
4400
+ ...release.url === undefined ? [] : [` ${release.url}`],
4401
+ ...release.deployTargets.length === 0 ? [] : [" Deploy Targets:", ...deployedToLines(release).map((line) => ` ${line}`)],
4402
+ ...release.state === "read" && release.changeRequests.length > 0 ? contentsLines(release.changeRequests) : [` ${contentsState(release, release.changeRequests)}`]
4403
+ ];
4404
+ var unreleasedSince = (branch) => branch.since !== undefined ? `since ${branch.since}, the last Release cut from it` : branch.sinceHidden ? "since a Release you may not see" : "no Release cut from it yet";
4405
+ var unreleasedLines = (unreleased) => [
4406
+ "Merged, not in a Release:",
4407
+ ...unreleased.branches.flatMap((branch) => [
4408
+ `${branch.branch}${branch.default ? " (default)" : ""} ${unreleasedSince(branch)} ${branch.changeRequests.length}${branch.truncated ? "+" : ""} ChangeRequests`,
4409
+ ...branch.mayBeReleased ? [
4410
+ " Some may already be released: Kitman lacks what a Release published after they merged contains, or which commit they merged as."
4411
+ ] : [],
4412
+ ...contentsLines(branch.changeRequests)
4413
+ ])
4414
+ ];
4415
+ var releaseNamed = (client, workspaceId, first, tag) => gen(function* () {
4416
+ if (tag === undefined && first.startsWith("release-")) {
4417
+ const byId = yield* client.getRelease(workspaceId, first).pipe(catchIf((error) => error.status === 404, () => undefined_));
4418
+ if (byId !== undefined)
4419
+ return byId.id;
4420
+ }
4421
+ const binding = tag === undefined ? undefined : yield* repositoryNamed(client, workspaceId, first);
4422
+ const wanted = tag ?? first;
4423
+ const found = (yield* client.listReleases(workspaceId, {
4424
+ ...binding === undefined ? undefined : { repoBindingId: binding.id },
4425
+ tag: wanted,
4426
+ limit: binding === undefined ? 10 : 1
4427
+ })).items;
4428
+ const [release, ...others] = found;
4429
+ if (release === undefined)
4430
+ return yield* new CliError({
4431
+ message: binding === undefined ? `No Release is tagged ${wanted}` : `${first} has no Release ${wanted}`
4432
+ });
4433
+ if (others.length > 0)
4434
+ return yield* new CliError({
4435
+ message: `${found.map((item) => item.repository).join(", ")} each have ${wanted}; give the repository first`
4436
+ });
4437
+ return release.id;
4438
+ });
4439
+ function releaseRecordsCommand(client, workspaceId, command) {
4440
+ return gen(function* () {
4441
+ const [first, tag] = command.args;
4442
+ if (command.action === "list") {
4443
+ const binding = first === undefined ? undefined : yield* repositoryNamed(client, workspaceId, first);
4444
+ const listed = yield* client.listReleases(workspaceId, {
4445
+ ...binding === undefined ? undefined : { repoBindingId: binding.id },
4446
+ ...command.flags.withoutPrereleases === true ? { prereleases: false } : undefined,
4447
+ ...command.flags.after === undefined ? undefined : { cursor: command.flags.after },
4448
+ ...command.flags.limit === undefined ? undefined : { limit: command.flags.limit }
4449
+ });
4450
+ const unreleased = binding === undefined ? undefined : yield* client.listUnreleased(workspaceId, binding.id);
4451
+ if (command.flags.json)
4452
+ return yield* printJson(unreleased === undefined ? listed : { ...listed, unreleased });
4453
+ return yield* log([
4454
+ ...listed.items.length === 0 ? ["No Releases"] : listed.items.flatMap(releaseListLines),
4455
+ ...listed.nextCursor === undefined ? [] : [`Older Releases follow: add --after ${listed.nextCursor}`],
4456
+ ...unreleased === undefined ? [] : ["", ...unreleasedLines(unreleased)]
4457
+ ].join(`
4458
+ `));
4459
+ }
4460
+ if (first === undefined)
4461
+ return yield* new CliError({ message: "release show takes a tag, a Release id, or a repository and a tag" });
4462
+ const releaseId = yield* releaseNamed(client, workspaceId, first, tag);
4463
+ const release = yield* client.getRelease(workspaceId, releaseId);
4464
+ if (command.flags.since !== undefined) {
4465
+ const [since] = (yield* client.listReleases(workspaceId, {
4466
+ repoBindingId: release.repoBindingId,
4467
+ tag: command.flags.since,
4468
+ limit: 1
4469
+ })).items;
4470
+ if (since === undefined)
4471
+ return yield* new CliError({ message: `${release.repository} has no Release ${command.flags.since}` });
4472
+ const comparison = yield* client.compareReleases(workspaceId, release.id, since.id);
4473
+ if (command.flags.json)
4474
+ return yield* printJson(comparison);
4475
+ return yield* log([
4476
+ `${comparison.to.tag} since ${comparison.from.tag} ${comparison.to.repository} ${comparison.changeRequests.length} ChangeRequests`,
4477
+ ...comparison.incomplete ? [
4478
+ "Kitman has not read every Release between them, or cannot link one to the other, so some may be missing or extra."
4479
+ ] : [],
4480
+ ...contentsLines(comparison.changeRequests)
4481
+ ].join(`
4482
+ `));
4483
+ }
4484
+ if (command.flags.json)
4485
+ return yield* printJson(release);
4486
+ const lines = [
4487
+ releaseLine(release),
4488
+ ...release.title === undefined ? [] : [release.title],
4489
+ ...release.url === undefined ? [] : [release.url],
4490
+ ...release.previousPrerelease === undefined ? [] : [`Adds ${release.sincePrerelease?.length ?? 0} ChangeRequests to ${release.previousPrerelease}`],
4491
+ ...release.deployTargets.length === 0 ? [] : ["", "Deploy Targets:", ...deployedToLines(release)],
4492
+ "",
4493
+ contentsState(release, release.changeRequests),
4494
+ ...contentsLines(release.changeRequests),
4495
+ ...release.notes === "" ? [] : ["", release.notes]
4496
+ ];
4497
+ return yield* log(lines.join(`
4498
+ `));
4499
+ });
4500
+ }
4501
+ var deployLine = (deploy) => [
4502
+ deploy.deployedAt,
4503
+ deploy.target,
4504
+ deploy.tag,
4505
+ deploy.status,
4506
+ deploy.repository,
4507
+ deploy.revision?.slice(0, 12),
4508
+ deploy.runId === undefined ? undefined : `by Run ${deploy.runId}`,
4509
+ deploy.detail
4510
+ ].filter((part) => part !== undefined).join(" ");
4511
+ var deployTargetLines = (targets) => [
4512
+ `${targets.repository}${targets.order.length === 0 ? " (no ordered list)" : ` order: ${targets.order.join(", ")}`}`,
4513
+ ...targets.targets.length === 0 ? ["No Deploy Targets yet"] : [],
4514
+ ...targets.targets.map((target) => [
4515
+ target.target,
4516
+ target.listed ? undefined : "(not listed)",
4517
+ target.running === undefined ? "runs nothing Kitman knows" : `runs ${target.running.tag}${target.running.revision === undefined ? "" : ` at ${target.running.revision.slice(0, 12)}`} since ${target.running.since}`,
4518
+ target.latest === undefined || target.latest.status === "deployed" ? undefined : `latest: ${target.latest.tag} ${target.latest.status}`
4519
+ ].filter((part) => part !== undefined).join(" "))
4520
+ ];
4521
+ var deployStatusWords = (status) => status.replaceAll("_", " ");
4522
+ var runningLine = (target) => [
4523
+ target.target,
4524
+ target.listed ? undefined : "(not listed)",
4525
+ target.running === undefined ? "runs nothing Kitman knows" : `runs ${target.running.tag}${target.running.revision === undefined ? "" : ` at ${target.running.revision.slice(0, 12)}`} since ${target.running.since}`,
4526
+ target.running !== undefined && target.runningRelease === undefined ? "(no Release of it recorded)" : undefined
4527
+ ].filter((part) => part !== undefined).join(" ");
4528
+ var shellWord = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
4529
+ var deployInput = (view, target, release) => encodeJsonStringSync({ tag: release.tag, target: target.target, promote: false, repoBindingId: view.repoBindingId });
4530
+ var waitingLines = (view, target) => {
4531
+ if (target.waiting.length === 0)
4532
+ return [" Nothing waits to reach it."];
4533
+ return [
4534
+ " Waiting to reach it, newest first:",
4535
+ ...target.waiting.flatMap((release) => [
4536
+ [
4537
+ ` ${release.tag}`,
4538
+ release.prerelease ? "prerelease" : "release",
4539
+ `published ${release.publishedAt}`,
4540
+ release.latestDeploy === undefined ? undefined : `latest deploy ${deployStatusWords(release.latestDeploy.status)} ${release.latestDeploy.deployedAt}`
4541
+ ].filter((part) => part !== undefined).join(" "),
4542
+ ...(release.state === "read" && release.changeRequests.length > 0 ? contentsLines(release.changeRequests) : [` ${contentsState(release, release.changeRequests)}`]).map((line) => ` ${line}`),
4543
+ ` Deploy: kitman run start deploy ${view.teamId === undefined ? "--no-team" : `--team ${view.teamId}`} --input ${shellWord(deployInput(view, target, release))}`
4544
+ ]),
4545
+ ...target.waitingTruncated ? [" and older Releases"] : []
4546
+ ];
4547
+ };
4548
+ var historyLines = (view, target) => {
4549
+ if (target.history.length === 0)
4550
+ return [" No Deploys yet."];
4551
+ return [
4552
+ " Deploys, newest first:",
4553
+ ...target.history.map((deploy) => [
4554
+ ` ${deploy.deployedAt}`,
4555
+ deploy.tag,
4556
+ deployStatusWords(deploy.status),
4557
+ deploy.runId === undefined ? undefined : `by Run ${deploy.runId}`,
4558
+ deploy.detail
4559
+ ].filter((part) => part !== undefined).join(" ")),
4560
+ ...target.historyTruncated ? [` and older Deploys: kitman deploy-target history ${view.repository} ${target.target}`] : []
4561
+ ];
4562
+ };
4563
+ var deployTargetsViewLines = (view) => [
4564
+ view.repository,
4565
+ ...view.targets.length === 0 ? ["No Deploy Targets yet"] : [],
4566
+ ...view.targets.flatMap((target) => [
4567
+ "",
4568
+ runningLine(target),
4569
+ ...waitingLines(view, target),
4570
+ ...historyLines(view, target)
4571
+ ])
4572
+ ];
4573
+ function releaseTargetsCommand(client, workspaceId, command) {
4574
+ return gen(function* () {
4575
+ const [named] = command.args;
4576
+ if (named !== undefined) {
4577
+ const binding = yield* repositoryNamed(client, workspaceId, named);
4578
+ const view = yield* client.getDeployTargetsView(workspaceId, binding.id);
4579
+ if (command.flags.json)
4580
+ return yield* printJson(view);
4581
+ return yield* log(deployTargetsViewLines(view).join(`
4582
+ `));
4583
+ }
4584
+ const bindings = (yield* client.listRepoBindings(workspaceId)).items;
4585
+ const views = (yield* forEach(bindings, (binding) => client.getDeployTargetsView(workspaceId, binding.id))).filter((view) => command.flags.json || view.targets.length > 0);
4586
+ if (command.flags.json)
4587
+ return yield* printJson({ items: views });
4588
+ if (views.length === 0)
4589
+ return yield* log("No Deploy Targets yet");
4590
+ return yield* log(views.map((view) => deployTargetsViewLines(view).join(`
4591
+ `)).join(`
4592
+
4593
+ `));
4594
+ });
4595
+ }
4596
+ function deployTargetCommand(args) {
4597
+ return gen(function* () {
4598
+ const command = parseCommand(args.length === 1 ? [...args, "history"] : args);
4599
+ const apiUrl = yield* resolveApiUrl(command.flags.apiUrl);
4600
+ const client = yield* clientFor(apiUrl, yield* requiredSessionForApi(apiUrl));
4601
+ const workspaceId = yield* activeWorkspaceId(command.flags);
4602
+ const [named, ...rest] = command.args;
4603
+ if (command.action === "history") {
4604
+ const binding = named === undefined ? undefined : yield* repositoryNamed(client, workspaceId, named);
4605
+ const [target] = rest;
4606
+ const listed = yield* client.listDeploys(workspaceId, {
4607
+ ...binding === undefined ? undefined : { repoBindingId: binding.id },
4608
+ ...target === undefined ? undefined : { target },
4609
+ ...command.flags.limit === undefined ? undefined : { limit: command.flags.limit }
4610
+ });
4611
+ if (command.flags.json)
4612
+ return yield* printJson(listed);
4613
+ return yield* log(listed.items.length === 0 ? "No Deploys" : listed.items.map(deployLine).join(`
4614
+ `));
4615
+ }
4616
+ if (command.action !== "list" && command.action !== "set")
4617
+ return yield* new CliError({ message: `Unknown deploy-target command: ${command.action}` });
4618
+ if (named === undefined)
4619
+ return yield* new CliError({ message: `deploy-target ${command.action} takes a repository, as owner/name` });
4620
+ if (command.action === "set" && rest.length === 0)
4621
+ return yield* new CliError({
4622
+ message: "deploy-target set takes the targets in order, or none to clear the list"
4623
+ });
4624
+ const binding = yield* repositoryNamed(client, workspaceId, named);
4625
+ const order = rest.length === 1 && rest[0] === "none" ? [] : rest;
4626
+ const targets = command.action === "set" ? yield* client.setDeployTargets(workspaceId, binding.id, order) : yield* client.getDeployTargets(workspaceId, binding.id);
4627
+ if (command.flags.json)
4628
+ return yield* printJson(targets);
4629
+ return yield* log(deployTargetLines(targets).join(`
4630
+ `));
4631
+ });
4632
+ }
4633
+ var projectRepositoryLines = (repository) => {
4634
+ const delivering = repository.delivering;
4635
+ const branchLine = delivering === undefined || repository.targetBranch === null || repository.targetBranch === repository.defaultBranch ? ` ${projectBranchWords(repository)}` : ` ${projectBranchWords(repository)} ${changeRequestReference(delivering)} ${delivering.title}${delivering.draft ? " (draft)" : ""}, ${deliveryStateWords[delivering.state]} ${delivering.targetBranch}`;
4636
+ const run = repository.latestRun;
4637
+ return [
4638
+ repository.repository,
4639
+ branchLine,
4640
+ ...repository.unreleased.length === 0 ? [` Nothing merged into ${repository.branch} waits for a Release`] : [
4641
+ ` Merged into ${repository.branch}, not yet released:`,
4642
+ ...repository.unreleased.map((task) => ` ${task.key} ${task.title} ${task.changeRequests.map((changeRequest) => changeRequestReference(changeRequest)).join(", ")}`)
4643
+ ],
4644
+ ...repository.releases.length === 0 ? [" No Releases yet"] : [
4645
+ " Releases, newest first:",
4646
+ ...repository.releases.map((release) => ` ${release.tag}${release.prerelease ? " prerelease" : ""} published ${release.publishedAt}${release.branch === undefined ? "" : ` from ${release.branch}`}`),
4647
+ ...repository.releasesTruncated ? [" and older Releases"] : []
4648
+ ],
4649
+ ...run === undefined ? [] : [
4650
+ ` Latest Release Run: ${run.runId} ${run.status}${run.outcome === undefined ? "" : `, ${run.outcome.replaceAll("_", " ")}`}${run.published === undefined ? "" : ` (${run.published.tag})`}${latestRunNext(run)}`
4651
+ ],
4652
+ ...repository.releaseRefused === undefined ? [] : [` Release: ${repository.releaseRefused}`],
4653
+ ...repository.inputDefaults.flatMap((entry) => entry.defaults.length === 0 ? [` When Clause ${entry.when}: no Input Defaults`] : [
4654
+ ` Input Defaults when ${entry.when} starts it:`,
4655
+ ...entry.defaults.map((value) => ` ${value.field} = ${JSON.stringify(value.value)} (from ${inputSourceWords(value)})`)
4656
+ ])
4657
+ ];
4658
+ };
4659
+ var latestRunNext = (run) => !run.failed ? "" : run.published === undefined ? "; it published nothing, so Release now starts again" : `; Release now deploys ${run.published.tag} again, cutting nothing`;
4660
+ var projectReleaseLines = (result) => result.repositories.length === 0 ? ["No repository the Project works in has completed Tasks to release"] : result.repositories.flatMap((plan) => [
4661
+ `${plan.repository}: as ${plan.kind === "milestone" ? `Milestone ${plan.milestoneName ?? plan.milestoneId ?? ""}'s` : "the Project's"} close${plan.when === undefined ? "" : `, When Clause ${plan.when}`}`,
4662
+ ` Tags ${releasePlanTagWords(plan)} on ${plan.branch}${plan.base === undefined ? "" : `, which delivers into ${plan.base}`}`,
4663
+ ` ${releasePlanShipWords(plan)}`,
4664
+ ...plan.tasks.map((task) => ` ${task.key} ${task.title}`),
4665
+ ` ${releasePlanDeployWords(plan).replace(/^d/u, "D")}`,
4666
+ ...plan.inputSources.length === 0 ? [] : [
4667
+ ` Input: ${plan.inputSources.map((source) => `${source.field} from ${inputSourceWords(source)}`).join("; ")}`
4668
+ ],
4669
+ ...plan.blocked === undefined ? [] : [` Starts nothing: ${plan.blocked}`],
4670
+ ...plan.runId === undefined ? [] : [` Started Run ${plan.runId}`]
4671
+ ]);
4672
+ function projectCommand(args) {
4673
+ return gen(function* () {
4674
+ const command = parseCommand(args);
4675
+ if (command.action !== "show" && command.action !== "release")
4676
+ return yield* new CliError({ message: `Unknown project command: ${command.action}` });
4677
+ const [named] = command.args;
4678
+ if (named === undefined)
4679
+ return yield* new CliError({ message: `project ${command.action} takes a Project, by name or id` });
4680
+ const apiUrl = yield* resolveApiUrl(command.flags.apiUrl);
4681
+ const client = yield* clientFor(apiUrl, yield* requiredSessionForApi(apiUrl));
4682
+ const workspaceId = yield* activeWorkspaceId(command.flags);
4683
+ const project = yield* projectNamed(client, workspaceId, named);
4684
+ if (command.action === "show") {
4685
+ const detail = yield* client.getProject(workspaceId, project.id);
4686
+ if (command.flags.json)
4687
+ return yield* printJson(detail);
4688
+ return yield* log([
4689
+ detail.name,
4690
+ ...detail.repositories.length === 0 ? ["No repository has work of it yet"] : detail.repositories.flatMap((repository) => ["", ...projectRepositoryLines(repository)])
4691
+ ].join(`
4692
+ `));
4693
+ }
4694
+ const milestoneRef = command.flags.milestone?.trim().toLowerCase();
4695
+ const milestone = milestoneRef === undefined ? undefined : project.milestones.find((candidate) => candidate.id.toLowerCase() === milestoneRef || candidate.name.toLowerCase() === milestoneRef);
4696
+ if (milestoneRef !== undefined && milestone === undefined)
4697
+ return yield* new CliError({ message: `${project.name} has no Milestone named ${command.flags.milestone}` });
4698
+ const repository = command.flags.repository === undefined ? undefined : yield* repositoryNamed(client, workspaceId, command.flags.repository);
4699
+ const request = {
4700
+ ...milestone === undefined ? undefined : { milestoneId: milestone.id },
4701
+ ...repository === undefined ? undefined : { repoBindingId: repository.id },
4702
+ ...command.flags.when === undefined ? undefined : { when: command.flags.when }
4703
+ };
4704
+ const preview = yield* client.releaseProject(workspaceId, project.id, { ...request, preview: true });
4705
+ if (command.flags.yes !== true) {
4706
+ if (command.flags.json)
4707
+ return yield* printJson(preview);
4708
+ return yield* log([
4709
+ ...projectReleaseLines(preview),
4710
+ ...preview.repositories.some((plan) => plan.blocked === undefined) ? ["", "Nothing started; give --yes to start it"] : []
4711
+ ].join(`
4712
+ `));
4713
+ }
4714
+ if (!command.flags.json)
4715
+ yield* log(projectReleaseLines(preview).join(`
4716
+ `));
4717
+ const started = yield* client.releaseProject(workspaceId, project.id, { ...request, confirm: preview.plan });
4718
+ if (command.flags.json)
4719
+ return yield* printJson({ preview, started });
4720
+ const runs = started.repositories.flatMap((plan) => plan.runId === undefined ? [] : [`${plan.repository}: Run ${plan.runId}`]);
4721
+ const refused = started.repositories.flatMap((plan) => plan.blocked === undefined ? [] : [`${plan.repository}: ${plan.blocked}`]);
4722
+ return yield* log(["", runs.length === 0 ? "Started no Release" : `Started ${runs.join(", ")}`, ...refused].join(`
4723
+ `));
4724
+ });
4725
+ }
3237
4726
  function releaseTriggerCommand(args) {
3238
4727
  return gen(function* () {
3239
4728
  const command = parseCommand(args);
3240
4729
  const apiUrl = yield* resolveApiUrl(command.flags.apiUrl);
3241
4730
  const client = yield* clientFor(apiUrl, yield* requiredSessionForApi(apiUrl));
3242
4731
  const workspaceId = yield* activeWorkspaceId(command.flags);
4732
+ if (command.action === "list" || command.action === "show")
4733
+ return yield* releaseRecordsCommand(client, workspaceId, command);
4734
+ if (command.action === "targets")
4735
+ return yield* releaseTargetsCommand(client, workspaceId, command);
4736
+ if (command.action === "milestone")
4737
+ return yield* milestoneTargetBranchCommand(client, workspaceId, command);
4738
+ if (command.action === "task")
4739
+ return yield* taskTargetBranchCommand(client, workspaceId, command);
3243
4740
  const named = command.action === "workspace" ? undefined : requiredArg(command, command.action);
3244
4741
  const given = command.action === "workspace" ? command.args[0] : command.args[1];
4742
+ if (command.action === "project" && given === "branch")
4743
+ return yield* projectTargetBranchCommand(client, workspaceId, named ?? "", command.args[2], command.flags.json);
3245
4744
  const choice = releaseChoices.find((candidate) => candidate === given);
3246
4745
  if (given !== undefined && choice === undefined)
3247
- return yield* new CliError({ message: `release ${command.action} takes merge, milestone, project or inherit` });
4746
+ return yield* new CliError({
4747
+ message: `release ${command.action} takes ${command.action === "project" ? "merge, milestone, project, manual, inherit or branch" : "merge, milestone, project, manual or inherit"}`
4748
+ });
3248
4749
  if (choice === "inherit" && command.action === "workspace")
3249
4750
  return yield* new CliError({
3250
- message: "The Workspace has nothing to inherit from; give merge, milestone or project"
4751
+ message: "The Workspace has nothing to inherit from; give merge, milestone, project or manual"
3251
4752
  });
3252
4753
  const update = choice === undefined ? undefined : { trigger: choice === "inherit" ? null : choice };
3253
4754
  const report = (subject, setting) => command.flags.json ? printJson(setting) : log(releaseTriggerLine(subject, setting));
@@ -3258,17 +4759,14 @@ function releaseTriggerCommand(args) {
3258
4759
  return yield* report(team.key, update === undefined ? yield* client.getTeamReleaseTrigger(team.id) : yield* client.setTeamReleaseTrigger(team.id, update));
3259
4760
  }
3260
4761
  if (command.action === "project") {
3261
- const ref = (named ?? "").trim();
3262
- const project = (yield* client.listProjects(workspaceId)).items.find((candidate) => candidate.id === ref || candidate.name.toLowerCase() === ref.toLowerCase());
3263
- if (project === undefined)
3264
- return yield* new CliError({ message: `No Project named ${ref}` });
4762
+ const project = yield* projectNamed(client, workspaceId, named ?? "");
3265
4763
  return yield* report(project.name, update === undefined ? yield* client.getProjectReleaseTrigger(workspaceId, project.id) : yield* client.setProjectReleaseTrigger(workspaceId, project.id, update));
3266
4764
  }
3267
4765
  return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
3268
4766
  });
3269
4767
  }
3270
4768
  var deliveryTargetWords = {
3271
- default_branch: "on the default branch",
4769
+ default_branch: "on its own, its Milestone's or its Project's target branch, else the default branch",
3272
4770
  epic_branch: "on its epic's branch, and the epic on the default branch once every sub-task is done"
3273
4771
  };
3274
4772
  var deliveryTargetLine = (subject, setting) => {
@@ -3574,7 +5072,7 @@ var SandboxHostProbe = Reference("kitman/cli/SandboxHostProbe", {
3574
5072
  });
3575
5073
  var OpenRunnerRpc = Reference("kitman/cli/OpenRunnerRpc", {
3576
5074
  defaultValue: () => (options) => gen(function* () {
3577
- const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-721qyd1a.js"));
5075
+ const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-qkt77rtj.js"));
3578
5076
  return yield* makeRunnerRpcClient({
3579
5077
  runnerId: options.runnerId,
3580
5078
  bearer: options.bearer,
@@ -3589,7 +5087,7 @@ var runnerHostSettings = gen(function* () {
3589
5087
  "KITMAN_RUNNER_FULL_ACCESS",
3590
5088
  "SSH_AUTH_SOCK"
3591
5089
  ];
3592
- const environment = Object.fromEntries(yield* forEach(names, (name) => String2(name).pipe(option, map8((value) => [name, getOrUndefined(value)?.trim()]))));
5090
+ const environment = Object.fromEntries(yield* forEach(names, (name) => String2(name).pipe(option, map9((value) => [name, getOrUndefined(value)?.trim()]))));
3593
5091
  return {
3594
5092
  fullAccess: environment["KITMAN_RUNNER_FULL_ACCESS"] === "1",
3595
5093
  sshAgentAvailable: environment["SSH_AUTH_SOCK"] !== undefined,
@@ -3661,6 +5159,7 @@ function startCanonicalHerdrRunnerCommand(input) {
3661
5159
  const startOnce = gen(function* () {
3662
5160
  const {
3663
5161
  AgentBackend,
5162
+ afterMergeRunner,
3664
5163
  agentStepExecutor,
3665
5164
  agentStepSandboxPolicy,
3666
5165
  agentStepExecutionLimit,
@@ -3879,14 +5378,14 @@ function startCanonicalHerdrRunnerCommand(input) {
3879
5378
  }).pipe(tap2((opened) => opened.settledRuns([])))));
3880
5379
  const signals = yield* makeReplicaSignals;
3881
5380
  const bundles = yield* kitmanBundles({
3882
- fetch: (digest) => rpc.bundle(digest).pipe(map8((found) => found.bundle)),
5381
+ fetch: (digest) => rpc.bundle(digest).pipe(map9((found) => found.bundle)),
3883
5382
  cacheDir: bundleCache
3884
5383
  });
3885
5384
  const checkouts = runCheckouts(path.join(runnerRootDir, ".kitman"), rpc.gitCredential);
3886
- yield* controlPlane.client.listRepoBindings(runner.workspaceId).pipe(flatMap3(({ items }) => forEach(items.filter((binding) => binding.status === "active" && (teamId === undefined || binding.teamId === teamId)), (repoBinding) => map8(checkouts.reaches(repoBinding), (reachable) => ({ repoBinding, reachable })), { concurrency: 4 })), tap2((probed) => sync2(() => reached = probed)), catch_((error) => logWarning("runner_repository_probe_failed", error.message)), flatMap3(() => sleep(reached.some((probe) => !probe.reachable) ? repositoryRetryInterval : repositoryProbeInterval)), forever, forkScoped);
5385
+ yield* controlPlane.client.listRepoBindings(runner.workspaceId).pipe(flatMap3(({ items }) => forEach(items.filter((binding) => binding.status === "active" && (teamId === undefined || binding.teamId === teamId)), (repoBinding) => map9(checkouts.reaches(repoBinding), (reachable) => ({ repoBinding, reachable })), { concurrency: 4 })), tap2((probed) => sync2(() => reached = probed)), catch_((error) => logWarning("runner_repository_probe_failed", error.message)), flatMap3(() => sleep(reached.some((probe) => !probe.reachable) ? repositoryRetryInterval : repositoryProbeInterval)), forever, forkScoped);
3887
5386
  yield* suspend3(() => sleep(ownerLogin.expired() ? ownerLoginRetryInterval : ownerLoginInterval)).pipe(andThen2(checkOwnerLogin), forever, forkScoped);
3888
5387
  const platform = yield* context();
3889
- const updated = yield* make15();
5388
+ const updated = yield* make16();
3890
5389
  const scope = yield* scope2;
3891
5390
  const startUpdate = (update) => update.pipe(catch_((error) => andThen2(restartOntoUpdate(input.runnerId), fail5(updated, error))), provideContext2(platform), forkIn(scope), asVoid);
3892
5391
  const refusedForProtocol = container ? updater.stopWhenDrained(new RunnerStopped({ problem: updateRequired })).pipe(catch_((stopped) => fail5(updated, stopped)), forkIn(scope), asVoid) : startUpdate(updater.updateRequired);
@@ -3983,6 +5482,10 @@ function startCanonicalHerdrRunnerCommand(input) {
3983
5482
  checkpoints: rpcStepCheckpoints(rpc, signals, storage),
3984
5483
  transcripts: (work, entries) => rpc.appendTranscript({ workUnitId: work.id, entries }),
3985
5484
  runnerScope: scope,
5485
+ runAfterMerge: (work, worktree, command, args) => {
5486
+ const sandbox = checkSandbox();
5487
+ return afterMergeRunner(sandbox === undefined ? undefined : { ...sandbox, apiUrl: input.apiUrl, hosts: live.settings.checkHosts })(work, worktree, command, args);
5488
+ },
3986
5489
  runAgent: (work, worktree, session, steered, refused, launched) => flatMap3(currentTimeMillis, (now) => agentBackend.execute({
3987
5490
  runnerId: input.runnerId,
3988
5491
  sharedRunner: !personal,
@@ -3996,18 +5499,18 @@ function startCanonicalHerdrRunnerCommand(input) {
3996
5499
  },
3997
5500
  recordRefusal: refused,
3998
5501
  launched,
3999
- revokedSecrets: heartbeatOf(work).pipe(map8((state) => state.revokedSecrets ?? [])),
5502
+ revokedSecrets: heartbeatOf(work).pipe(map9((state) => state.revokedSecrets ?? [])),
4000
5503
  sandbox: {
4001
5504
  backend: work.sandbox ?? sandboxOf(work),
4002
5505
  policy: agentStepSandboxPolicy(work, input.apiUrl, runnerState)
4003
5506
  },
4004
- settled: heartbeatOf(work).pipe(map8((state) => state.settled || state.outputSubmitted === true)),
5507
+ settled: heartbeatOf(work).pipe(map9((state) => state.settled || state.outputSubmitted === true)),
4005
5508
  ...agentStepExecutionLimit(work, now),
4006
5509
  steering: {
4007
5510
  ...signals.steers(work.id),
4008
5511
  report: (note, delivered) => andThen2(delivered ? steered(note) : void_3, rpc.reportSteer({ workUnitId: work.id, messageId: note.messageId, delivered }).pipe(catch_((error) => logWarning("runner_steer_report_failed", error.message))))
4009
5512
  }
4010
- }).pipe(map8((outcome) => agentStepRunOutcome(outcome, {
5513
+ }).pipe(map9((outcome) => agentStepRunOutcome(outcome, {
4011
5514
  sandbox: work.sandbox ?? sandboxOf(work),
4012
5515
  lacksLoginSecret: lacksLoginSecret(work.brief.harness, work.secrets)
4013
5516
  })), catch_((refusal) => succeed6({ status: "failed", summary: refusal.summary }))))
@@ -4037,6 +5540,7 @@ function startCanonicalHerdrRunnerCommand(input) {
4037
5540
  postgres: dockerCheckPostgres(input.runnerId, replica.id),
4038
5541
  ...checkDocker === undefined ? undefined : { docker: checkDocker },
4039
5542
  runsDeployScripts: personal,
5543
+ revokedSecrets: (unit, secrets) => rpc.heartbeat({ workUnitId: unit.id, lease: leaseOf(unit), secrets: [...secrets] }).pipe(map9((state) => state.revokedSecrets ?? [])),
4040
5544
  ...sandbox === undefined ? undefined : { sandbox: { ...sandbox, apiUrl: input.apiUrl, hosts: live.settings.checkHosts } }
4041
5545
  })(work);
4042
5546
  };
@@ -4108,7 +5612,7 @@ function startCanonicalHerdrRunnerCommand(input) {
4108
5612
  });
4109
5613
  return yield* raceFirst(stopWhenRefused(supervised), _await(updated));
4110
5614
  }));
4111
- }).pipe(ensuring2(ignore(controlPlane.client.stopRunnerReplica(input.runnerId, replica.id))), provide3(provideMerge(root, layer3)));
5615
+ }).pipe(ensuring2(ignore(controlPlane.client.stopRunnerReplica(input.runnerId, replica.id))), provide3(root));
4112
5616
  }).pipe(scoped);
4113
5617
  return gen(function* () {
4114
5618
  while (true) {
@@ -4141,7 +5645,7 @@ function mcpCommand(args) {
4141
5645
  if (command.action === "run") {
4142
5646
  if (command.args.length > 0)
4143
5647
  return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
4144
- const { runMcpServerCommand } = yield* promise(() => import("./chunk-eytzmdna.js"));
5648
+ const { runMcpServerCommand } = yield* promise(() => import("./chunk-3n99j4z0.js"));
4145
5649
  return yield* runMcpServerCommand({ flags: command.flags });
4146
5650
  }
4147
5651
  if (command.action !== "setup")
@@ -4592,9 +6096,17 @@ function contextCommand(args) {
4592
6096
  var programLoopLines = (loop) => [
4593
6097
  `${loop.id}${loop.version === undefined ? "" : ` ${loop.version}`} ${loop.layer} kit ${loop.kit} ${loop.digest}`
4594
6098
  ];
6099
+ var inputFieldLines = (loop) => loop.input.map((field) => {
6100
+ const facts = [
6101
+ field.type,
6102
+ field.required ? "required" : "optional",
6103
+ ...field.default === undefined ? [] : [`default ${JSON.stringify(field.default)}`]
6104
+ ];
6105
+ return ` input ${field.name} (${facts.join(", ")})${field.description === undefined ? "" : `: ${field.description}`}`;
6106
+ });
4595
6107
  var whenClauseLines = (loop) => loop.when.map((clause) => {
4596
6108
  const filter = Object.entries(clause.filter ?? {}).map(([path, value]) => `${path} ${Array.isArray(value) ? value.join("|") : String(value)}`).join(", ");
4597
- return ` when ${clause.event}${filter === "" ? "" : ` (${filter})`}${clause.optIn === true ? ", opt-in" : ""}${clause.on === undefined ? "" : `: ${clause.on ? "on" : "off"}`}${clause.description === undefined ? "" : `
6109
+ return ` when ${whenClauseName(clause)}: ${clause.event}${filter === "" ? "" : ` (${filter})`}${clause.optIn === true ? ", opt-in" : ""}${clause.on === undefined ? "" : `: ${clause.on ? "on" : "off"}`}${clause.offBy === undefined ? "" : `, but off for ${clause.offBy === "team" ? "its Team" : "the Workspace"} under Input Defaults (kitman loop input)`}${clause.description === undefined ? "" : `
4598
6110
  ${clause.description}`}`;
4599
6111
  });
4600
6112
  function programLoopCommand(command) {
@@ -4614,7 +6126,11 @@ function programLoopCommand(command) {
4614
6126
  const loop = requiredArg(command, "a Loop");
4615
6127
  const teamId = yield* optionalActiveTeamId(command.flags);
4616
6128
  const shown = yield* client.showProgramLoop(yield* activeWorkspaceId(command.flags), loop, teamId === undefined ? {} : { teamId });
4617
- return yield* print(shown, (value) => value.resolved === undefined ? [`${loop} resolves to nothing here`] : [...programLoopLines(value.resolved), ...whenClauseLines(value.resolved)]);
6129
+ return yield* print(shown, (value) => value.resolved === undefined ? [`${loop} resolves to nothing here`] : [
6130
+ ...programLoopLines(value.resolved),
6131
+ ...inputFieldLines(value.resolved),
6132
+ ...whenClauseLines(value.resolved)
6133
+ ]);
4618
6134
  }
4619
6135
  if (command.action === "when") {
4620
6136
  const [loop, event, state] = command.args;
@@ -4629,7 +6145,7 @@ function programLoopCommand(command) {
4629
6145
  return yield* new CliError({ message: `Unknown loop command: ${command.action}` });
4630
6146
  });
4631
6147
  }
4632
- var docsModule = promise(() => import("./chunk-6x43ntsx.js"));
6148
+ var docsModule = promise(() => import("./chunk-b16qxawc.js"));
4633
6149
  function docsCommand(args) {
4634
6150
  return gen(function* () {
4635
6151
  const command = parseCommand(args);
@@ -4720,12 +6236,109 @@ function agentCommand(args) {
4720
6236
  return yield* new CliError({ message: `Unknown agent command: ${command.action}. Use kitman agent list.` });
4721
6237
  });
4722
6238
  }
6239
+ var runStartInput = (given) => gen(function* () {
6240
+ const [first] = given;
6241
+ if (first === undefined)
6242
+ return;
6243
+ if (given.length === 1 && first.trimStart().startsWith("{"))
6244
+ return yield* parseJsonInput(first, "run start --input");
6245
+ const fields = {};
6246
+ for (const assignment of given) {
6247
+ const parsed = inputAssignment(assignment);
6248
+ if (parsed === undefined || "unset" in parsed)
6249
+ return yield* new CliError({
6250
+ message: `run start --input ${assignment} is neither a JSON object nor <field>=<value>, such as branch=release/1.x`
6251
+ });
6252
+ fields[parsed.field] = parsed.value;
6253
+ }
6254
+ return fields;
6255
+ });
6256
+ var inputAssignment = (assignment) => {
6257
+ const at = assignment.indexOf("=");
6258
+ if (at <= 0)
6259
+ return;
6260
+ const field = assignment.slice(0, at);
6261
+ const text = assignment.slice(at + 1);
6262
+ if (text === "")
6263
+ return { field, unset: true };
6264
+ return { field, value: getOrElse(decodeJsonStringOption(text), () => text) };
6265
+ };
6266
+ var inputDefaultEntryLines = (layer) => (entry) => {
6267
+ const own = Object.entries(entry.values).map(([field, value]) => {
6268
+ const problem = entry.problems.find((candidate) => candidate.field === field);
6269
+ return ` ${field} = ${JSON.stringify(value)} (set here)${problem === undefined ? "" : ` invalid: ${problem.problem}`}`;
6270
+ });
6271
+ const inherited = entry.inherited.filter((value) => entry.values[value.field] === undefined).map((value) => ` ${value.field} = ${JSON.stringify(value.value)} (from ${value.layer === layer ? "this layer's default for every Run" : inputSourceWords(value)})`);
6272
+ const other = entry.problems.filter((problem) => problem.field === "" || entry.values[problem.field] === undefined).map((problem) => ` invalid: ${problem.problem}`);
6273
+ return [
6274
+ ` ${entry.when === undefined ? "every Run" : `When Clause ${entry.when}`}${entry.starts === undefined ? entry.off ? ": off here" : "" : entry.starts.on ? ": starts Runs here" : `: starts no Runs here, ${entry.starts.why ?? "it is off"}`}`,
6275
+ ...own.length + inherited.length + other.length === 0 ? [" nothing set or inherited"] : [],
6276
+ ...own,
6277
+ ...inherited,
6278
+ ...other
6279
+ ];
6280
+ };
6281
+ var inputDefaultsLines = (subject, settings, when) => {
6282
+ if (!settings.resolved)
6283
+ return [`${settings.loop} resolves to nothing for ${subject}`];
6284
+ const shown = settings.defaults.filter((entry) => when === undefined ? entry.when === undefined || entry.off || entry.starts?.on === false || Object.keys(entry.values).length > 0 || entry.problems.length > 0 : entry.when === when);
6285
+ return [
6286
+ `Input Defaults of ${settings.loop} for ${subject}:`,
6287
+ ...shown.flatMap(inputDefaultEntryLines(settings.layer))
6288
+ ];
6289
+ };
6290
+ function loopInputCommand(command) {
6291
+ return gen(function* () {
6292
+ const client = yield* loopClientFor(yield* resolveApiUrl(command.flags.apiUrl));
6293
+ const workspaceId = yield* activeWorkspaceId(command.flags);
6294
+ const [loop, ...assignments] = command.args;
6295
+ if (loop === undefined)
6296
+ return yield* new CliError({
6297
+ message: "Use kitman loop input <loop> [--team <team>|--project <project>] [--when <name>] [<field>=<value>...] [--off|--on] [--clear]"
6298
+ });
6299
+ if (command.flags.team !== undefined && command.flags.project !== undefined)
6300
+ return yield* new CliError({ message: "loop input takes --team or --project, not both" });
6301
+ const parsed = assignments.map((assignment) => ({ assignment, parsed: inputAssignment(assignment) }));
6302
+ const malformed = parsed.find((entry) => entry.parsed === undefined);
6303
+ if (malformed !== undefined)
6304
+ return yield* new CliError({ message: `${malformed.assignment} is not <field>=<value>, such as rounds=5` });
6305
+ const changes = parsed.flatMap((entry) => entry.parsed === undefined ? [] : [entry.parsed]);
6306
+ if (command.flags.clear === true && (changes.length > 0 || command.flags.whenOff !== undefined))
6307
+ return yield* new CliError({ message: "--clear takes no <field>=<value> and no --off or --on" });
6308
+ if (command.flags.whenOff !== undefined && command.flags.when === undefined)
6309
+ return yield* new CliError({ message: "--off and --on need --when <name>: only a When Clause turns off" });
6310
+ const team = command.flags.team === undefined ? undefined : yield* teamNamed(client, workspaceId, command.flags.team);
6311
+ const project = command.flags.project === undefined ? undefined : yield* projectNamed(client, workspaceId, command.flags.project);
6312
+ const scope = {
6313
+ ...team === undefined ? undefined : { teamId: team.id },
6314
+ ...project === undefined ? undefined : { projectId: project.id }
6315
+ };
6316
+ const subject = team !== undefined ? `Team ${team.key}` : project !== undefined ? `Project ${project.name}` : "the Workspace";
6317
+ const when = command.flags.when === undefined ? undefined : { when: command.flags.when };
6318
+ const settings = command.flags.clear === true ? yield* client.clearLoopInputDefaults(workspaceId, loop, { ...scope, ...when }) : changes.length > 0 || command.flags.whenOff !== undefined ? yield* client.setLoopInputDefaults(workspaceId, loop, {
6319
+ ...scope,
6320
+ ...when,
6321
+ values: Object.fromEntries(changes.flatMap((change) => ("value" in change) ? [[change.field, change.value]] : [])),
6322
+ unset: changes.flatMap((change) => ("unset" in change) ? [change.field] : []),
6323
+ ...command.flags.whenOff === undefined ? undefined : { off: command.flags.whenOff }
6324
+ }) : yield* client.getLoopInputDefaults(workspaceId, loop, scope);
6325
+ if (command.flags.json)
6326
+ return yield* printJson(settings);
6327
+ return yield* forEach(inputDefaultsLines(subject, settings, command.flags.when), (line) => log(line), {
6328
+ discard: true
6329
+ });
6330
+ });
6331
+ }
4723
6332
  function loopCommand(args) {
4724
6333
  const command = parseCommand(args);
4725
6334
  if (["list", "starts", "show", "when"].includes(command.action))
4726
6335
  return programLoopCommand(command);
6336
+ if (command.action === "input")
6337
+ return loopInputCommand(command);
4727
6338
  if (["catalog", "validate", "test"].includes(command.action))
4728
6339
  return loopCatalogCommand(args);
6340
+ if (command.action === "outline")
6341
+ return loopOutline(command);
4729
6342
  if (command.action === "fork")
4730
6343
  return scaffoldKit(command.args[1] ?? ".", { fork: requiredArg(command, "a Loop id") });
4731
6344
  return fail7(new CliError({
@@ -4767,9 +6380,9 @@ var taskTypeNamed = (client, workspaceId, named) => flatMap3(client.listTaskType
4767
6380
  var launchContext = (flags) => gen(function* () {
4768
6381
  const git = yield* Git;
4769
6382
  const read = (args) => git(args).pipe(orElseSucceed(() => ""));
4770
- const remoteUrl = yield* read(["remote", "get-url", "origin"]);
6383
+ const remoteUrl = flags.noTeam === true ? "" : yield* read(["remote", "get-url", "origin"]);
4771
6384
  const branch = yield* read(["branch", "--show-current"]);
4772
- const teamId = yield* optionalActiveTeamId(flags);
6385
+ const teamId = flags.noTeam === true ? undefined : yield* optionalActiveTeamId(flags);
4773
6386
  return {
4774
6387
  ...teamId === undefined ? undefined : { teamId },
4775
6388
  ...remoteUrl === "" ? undefined : { remoteUrl },
@@ -4850,7 +6463,9 @@ var driftLines = (drift) => [
4850
6463
  ...drift.reports.length === 0 ? ["No Drift Reports", ...judgementLines(drift)] : shownDriftLines(drift),
4851
6464
  ...drift.boundaries.flatMap((boundary) => boundary.uncheckedReason === undefined ? [] : [`Unchecked at ${boundary.stepKey}: ${boundary.uncheckedReason}`])
4852
6465
  ];
4853
- var graphNodeText = (node) => `${node.name} ${node.kind} ${runDisplayLabels[node.status]}${node.attempts.length > 1 ? `, ${node.attempts.length} attempts` : ""}`;
6466
+ var graphNodeText = (node) => `${node.name} ${node.kind} ${runDisplayLabels[node.status]}${node.outcome === undefined ? "" : `, ${node.outcome}`}${node.attempts.length > 1 ? `, ${node.attempts.length} attempts` : ""}`;
6467
+ var ticketText = (ticket) => `${ticket.key} ${ticket.outcome === undefined ? runDisplayLabels[ticket.status] : ticketOutcomeLabels[ticket.outcome]}`;
6468
+ var graphColumnText = (column) => column.kind === "wave" ? `Wave ${column.wave}: ${column.tickets.map(ticketText).join(" \xB7 ")}` : column.nodes.map(graphNodeText).join(" \xB7 ");
4854
6469
  var displayGlyphs = {
4855
6470
  queued: "\u25CB",
4856
6471
  running: "\u25D0",
@@ -4880,12 +6495,20 @@ var runTokenLines = ({ tokens, tokensWithChildRuns }) => [
4880
6495
  var runShowLines = (shown) => [
4881
6496
  `Run ${shown.run.id}: ${runDisplayLabels[shown.display.state]}${shown.display.retried ? " \xB7 Retried" : ""}`,
4882
6497
  ...shown.display.summary === undefined ? [] : [`Now: ${shown.display.summary}`],
4883
- ...shown.graph.columns.map((column, index) => `${index + 1}. ${column.map(graphNodeText).join(" \xB7 ")}`),
6498
+ ...shown.graph.outline === undefined ? runGraphLayout(shown.graph).map((column, index) => `${index + 1}. ${graphColumnText(column)}`) : [
6499
+ "Outline:",
6500
+ ...runOutlineText(shown.graph.outline).split(`
6501
+ `).map((line) => ` ${line}`)
6502
+ ],
4884
6503
  ...shown.closures.map((closure, index) => index === 0 ? closureLine(closure) : `Earlier: ${closureLine(closure)}`),
4885
6504
  ...alignmentLines(shown.run.alignment),
4886
6505
  ...shown.run.loopDigest === undefined ? [] : [
4887
6506
  `Loop${shown.run.loopVersion === undefined ? "" : ` ${shown.run.loopVersion}`}${shown.run.loopLayer === undefined ? "" : ` from the ${shown.run.loopLayer} layer`}, digest ${shown.run.loopDigest}`
4888
6507
  ],
6508
+ ...shown.header.baseBranch === undefined ? [] : [`Base branch: ${shown.header.baseBranch.branch}, from ${baseBranchLayerWords[shown.header.baseBranch.layer]}`],
6509
+ ...shown.header.inputSources === undefined ? [] : [
6510
+ `Input: ${shown.header.inputSources.map((source) => `${source.field} from ${inputSourceWords(source)}`).join("; ")}`
6511
+ ],
4889
6512
  ...shown.run.failureSummary === undefined ? [] : [`Failure: ${shown.run.failureSummary}`],
4890
6513
  ...runTokenLines(shown),
4891
6514
  ...shown.steps.flatMap((step) => [
@@ -4939,7 +6562,7 @@ var inboxItemLine = (item) => {
4939
6562
  `${item.subject.kind}:${item.subject.id}`
4940
6563
  ].join(" ");
4941
6564
  };
4942
- var inboxSubjectKinds = ["task", "run", "proposal", "memory", "project_update", "runner"];
6565
+ var inboxSubjectKinds = ["task", "run", "proposal", "memory", "project_update", "runner", "project"];
4943
6566
  var inboxSubjectOf = (ref) => {
4944
6567
  const separator = ref.indexOf(":");
4945
6568
  const kind = inboxSubjectKinds.find((known) => known === ref.slice(0, separator));
@@ -5057,7 +6680,7 @@ function transcriptCommand(args) {
5057
6680
  return yield* new CliError({
5058
6681
  message: `Run ${runId} has no ${stepKey === undefined ? "Step attempts" : `attempt of ${stepKey}`}${attempt === undefined ? "" : ` numbered ${attempt}`}`
5059
6682
  });
5060
- const items = yield* forEach(asked, (found) => map8(transcriptAfter(client, runId, found.id, 0), (entries) => ({
6683
+ const items = yield* forEach(asked, (found) => map9(transcriptAfter(client, runId, found.id, 0), (entries) => ({
5061
6684
  stepKey: found.stepKey,
5062
6685
  attempt: found.attempt,
5063
6686
  stepAttemptId: found.id,
@@ -5109,7 +6732,9 @@ function runCommand(args) {
5109
6732
  const [loop, ...words] = command.args;
5110
6733
  if (loop === undefined)
5111
6734
  return yield* new CliError({ message: "run start requires a Loop" });
5112
- const input = command.flags.input === undefined ? undefined : yield* parseJsonInput(command.flags.input, "run start --input");
6735
+ if (command.flags.noTeam === true && command.flags.team !== undefined)
6736
+ return yield* new CliError({ message: "run start takes --team or --no-team, not both" });
6737
+ const input = yield* runStartInput(command.flags.inputs ?? []);
5113
6738
  const workspaceId = yield* activeWorkspaceId(command.flags);
5114
6739
  const taskTypeId = command.flags.taskType === undefined ? undefined : yield* taskTypeNamed(client, workspaceId, command.flags.taskType);
5115
6740
  const started = yield* client.startRun({
@@ -5317,18 +6942,23 @@ function verifyCommand(args) {
5317
6942
  const print = (value, lines) => command.flags.json ? printJson(value) : forEach(lines(value), (line) => log(line), { discard: true });
5318
6943
  switch (command.action) {
5319
6944
  case "list":
5320
- return yield* print(yield* client.listApprovedVerifications(workspaceId, binding.id), (listed) => listed.items.length === 0 ? [`No approved verifications for ${binding.owner}/${binding.name}`] : listed.items.map((check) => `${check.name}: ${check.command}${check.workingDirectory === undefined ? "" : ` (in ${check.workingDirectory})`}${check.pipeline === true ? " (pipeline)" : ""}${check.readsTarget === true ? " (reads the target)" : ""}`));
6945
+ return yield* print(yield* client.listApprovedVerifications(workspaceId, binding.id), (listed) => listed.items.length === 0 ? [`No approved verifications for ${binding.owner}/${binding.name}`] : listed.items.map((check) => `${check.name}: ${check.command}${check.workingDirectory === undefined ? "" : ` (in ${check.workingDirectory})`}${check.pipeline === true ? " (pipeline)" : ""}${check.readsTarget === true ? " (reads the target)" : ""}${check.kind === "command" ? " (command)" : ""}`));
5321
6946
  case "add": {
5322
6947
  const [name, ...words] = command.args;
5323
6948
  if (name === undefined || words.length === 0)
5324
6949
  return yield* new CliError({ message: "verify add requires a name and a command" });
6950
+ if (command.flags.asCommand === true && (command.flags.pipeline === true || command.flags.readsTarget === true))
6951
+ return yield* new CliError({
6952
+ message: "A command runs only in a command Step, so --pipeline and --reads-target do not apply to it"
6953
+ });
5325
6954
  return yield* print(yield* client.approveVerification(workspaceId, binding.id, {
5326
6955
  name,
5327
6956
  command: words.join(" "),
5328
6957
  ...command.flags.workingDirectory === undefined ? undefined : { workingDirectory: command.flags.workingDirectory },
5329
- pipeline: command.flags.pipeline === true,
5330
- readsTarget: command.flags.readsTarget === true
5331
- }), (check) => [`Approved ${check.name}${check.pipeline === true ? " as the pipeline" : ""}: ${check.command}`]);
6958
+ ...command.flags.asCommand === true ? { kind: "command" } : { pipeline: command.flags.pipeline === true, readsTarget: command.flags.readsTarget === true }
6959
+ }), (check) => [
6960
+ `Approved ${check.name}${check.kind === "command" ? " as a command" : check.pipeline === true ? " as the pipeline" : ""}: ${check.command}`
6961
+ ]);
5332
6962
  }
5333
6963
  case "remove":
5334
6964
  return yield* print(yield* client.removeVerification(workspaceId, binding.id, requiredArg(command, "a verification")), (removed) => [`Removed ${removed.removed}`]);
@@ -5337,7 +6967,7 @@ function verifyCommand(args) {
5337
6967
  }
5338
6968
  });
5339
6969
  }
5340
- var secretValueFromStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map8((text) => text.replace(/\r?\n$/, "")));
6970
+ var secretValueFromStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map9((text) => text.replace(/\r?\n$/, "")));
5341
6971
  function secretCommand(args) {
5342
6972
  return gen(function* () {
5343
6973
  const command = parseCommand(args.length === 1 ? [...args, "list"] : args);
@@ -5405,6 +7035,16 @@ function networkHostCommand(args) {
5405
7035
  }
5406
7036
  });
5407
7037
  }
7038
+ var claimLine = (claim) => [
7039
+ claim.resource,
7040
+ ...claim.heldBy === undefined ? [] : [
7041
+ `held by ${claim.heldBy.name ?? claim.heldBy.actorId} since ${claim.heldBy.heldAt}: ${claim.heldBy.reason}${claim.heldBy.letThrough.length === 0 ? "" : `, letting through ${claim.heldBy.letThrough.join(", ")}`}`
7042
+ ],
7043
+ ...claim.runId === undefined ? [] : [
7044
+ `Run ${claim.runId} (${claim.loopId}, ${claim.runStatus})${claim.keptAt === undefined ? "" : ` kept since ${claim.keptAt}${claim.keptReason === undefined ? "" : `: ${claim.keptReason}`}`}`
7045
+ ],
7046
+ ...claim.waiting.length === 0 ? [] : [`${claim.waiting.length} waiting`]
7047
+ ].join(" ");
5408
7048
  function claimCommand(args) {
5409
7049
  return gen(function* () {
5410
7050
  const command = parseCommand(args.length === 1 ? [...args, "list"] : args);
@@ -5413,7 +7053,7 @@ function claimCommand(args) {
5413
7053
  const print = (value, lines) => command.flags.json ? printJson(value) : forEach(lines(value), (line) => log(line), { discard: true });
5414
7054
  switch (command.action) {
5415
7055
  case "list":
5416
- return yield* print(yield* client.listClaims(workspaceId), (listed) => listed.items.length === 0 ? ["No resources are held"] : listed.items.map((claim) => `${claim.resource} Run ${claim.runId} (${claim.loopId}, ${claim.runStatus})${claim.keptAt === undefined ? "" : ` kept since ${claim.keptAt}${claim.keptReason === undefined ? "" : `: ${claim.keptReason}`}`}${claim.waiting.length === 0 ? "" : ` ${claim.waiting.length} waiting`}`));
7056
+ return yield* print(yield* client.listClaims(workspaceId), (listed) => listed.items.length === 0 ? ["No resources are held"] : listed.items.map(claimLine));
5417
7057
  case "release": {
5418
7058
  const resource = requiredArg(command, "a resource");
5419
7059
  const { reason } = command.flags;
@@ -5423,31 +7063,67 @@ function claimCommand(args) {
5423
7063
  `Released ${released.released}`
5424
7064
  ]);
5425
7065
  }
7066
+ case "hold": {
7067
+ const resource = requiredArg(command, "a resource");
7068
+ const { reason } = command.flags;
7069
+ if (reason === undefined)
7070
+ return yield* new CliError({ message: "Give your reason for holding it with --reason <text>" });
7071
+ return yield* print(yield* client.holdClaim(workspaceId, resource, { reason }), (held) => [
7072
+ `Holding ${held.held}: no Run gets it until you let it go with kitman claim release ${held.held} --reason <text>`
7073
+ ]);
7074
+ }
5426
7075
  default:
5427
7076
  return yield* new CliError({ message: `Unknown claim command: ${command.action}` });
5428
7077
  }
5429
7078
  });
5430
7079
  }
5431
7080
  var urlLookupLimit = 100;
5432
- var changeRequestNamed = (client, workspaceId, ref) => gen(function* () {
7081
+ var changeRequestNamed = (client, workspaceId, ref, statuses = ["open", "draft"]) => gen(function* () {
5433
7082
  if (!/^https?:\/\//i.test(ref))
5434
7083
  return yield* client.getChangeRequest(ref);
5435
7084
  const wanted = ref.replace(/\/+$/, "");
5436
7085
  for (const team of (yield* client.listTeams(workspaceId)).items)
5437
- for (const status of ["open", "draft"]) {
7086
+ for (const status of statuses) {
5438
7087
  const found = (yield* client.listChangeRequests(team.id, { status, limit: urlLookupLimit })).items.find((candidate) => candidate.url.replace(/\/+$/, "") === wanted);
5439
7088
  if (found !== undefined)
5440
7089
  return found;
5441
7090
  }
5442
7091
  return yield* new CliError({
5443
- message: `No open or draft ChangeRequest among each Team's ${urlLookupLimit} most recently updated has the URL ${ref}; name it by its id instead`
7092
+ message: `No ${new Intl.ListFormat("en", { type: "disjunction" }).format(statuses)} ChangeRequest among each Team's ${urlLookupLimit} most recently updated has the URL ${ref}; name it by its id instead`
5444
7093
  });
5445
7094
  });
7095
+ var changeRequestText = (changeRequest) => [
7096
+ `${changeRequest.title} (${changeRequest.status})`,
7097
+ `URL: ${changeRequest.url}`,
7098
+ `Branches: ${changeRequest.sourceBranch} -> ${changeRequest.targetBranch}`,
7099
+ ...changeRequest.providerMetadata?.headCommitSha === undefined ? [] : [`Head: ${changeRequest.providerMetadata.headCommitSha}`],
7100
+ ...changeRequest.mergeRevision === undefined ? [] : [`Merged as: ${changeRequest.mergeRevision}`],
7101
+ ...changeRequest.taskIds.length === 0 ? [] : [`Tasks: ${changeRequest.taskIds.join(", ")}`]
7102
+ ].join(`
7103
+ `);
5446
7104
  function changeRequestCommand(args) {
5447
7105
  return gen(function* () {
5448
7106
  const command = parseCommand(args);
5449
7107
  const client = yield* loopClientFor(yield* resolveApiUrl(command.flags.apiUrl));
5450
7108
  const workspaceId = yield* activeWorkspaceId(command.flags);
7109
+ if (command.action === "show") {
7110
+ const shown = yield* changeRequestNamed(client, workspaceId, requiredArg(command, "a ChangeRequest id or URL"), [
7111
+ "open",
7112
+ "draft",
7113
+ "merged",
7114
+ "closed"
7115
+ ]);
7116
+ if (command.flags.json)
7117
+ return yield* printJson(shown);
7118
+ return yield* log(changeRequestText(shown));
7119
+ }
7120
+ if (command.action === "merge-through") {
7121
+ const named = yield* changeRequestNamed(client, workspaceId, requiredArg(command, "a ChangeRequest id or URL"));
7122
+ const through = yield* client.mergeThroughChangeRequest(named.id);
7123
+ if (command.flags.json)
7124
+ return yield* printJson(through);
7125
+ return yield* log(`Letting ${named.title} through ${through.resource}: its Shepherd takes the turn, which stays held for every other Run`);
7126
+ }
5451
7127
  if (command.action !== "approve" && command.action !== "request-changes")
5452
7128
  return yield* new CliError({ message: `Unknown cr command: ${command.action}` });
5453
7129
  const { summary } = command.flags;
@@ -5471,9 +7147,29 @@ function changeRequestCommand(args) {
5471
7147
  yield* log(command.action === "approve" ? `Approved ${short} of ${changeRequest.title}. A Run waiting on approval of ${short} resumes; one waiting on another head does not.` : `Requested changes to ${short} of ${changeRequest.title}`);
5472
7148
  });
5473
7149
  }
5474
- var KitWriter = map8(promise(() => import("./chunk-1rwaetnm.js")), (build) => build.writeKit);
7150
+ var readOutlines = (directory) => flatMap3(promise(() => import("./chunk-mrkrt2hg.js")), (build) => build.readOutlines(directory)).pipe(mapError2((error) => new CliError({ message: error.message })));
7151
+ var loopOutline = (command) => gen(function* () {
7152
+ const path = yield* Path;
7153
+ const loop = requiredArg(command, "a Loop id");
7154
+ const directory = path.resolve(command.args[1] ?? ".");
7155
+ const outlines = yield* readOutlines(directory);
7156
+ const outline = outlines.get(loop);
7157
+ if (outline === undefined)
7158
+ return yield* new CliError({
7159
+ message: `The Kit in ${directory} has no Loop ${loop}; it has ${[...outlines.keys()].join(", ") || "none"}`
7160
+ });
7161
+ const text = command.flags.mermaid === true ? outlineMermaid(loop, outline) : outlineText(outline);
7162
+ if (command.flags.out === undefined)
7163
+ return yield* log(text);
7164
+ const fs = yield* FileSystem;
7165
+ const out = path.resolve(command.flags.out);
7166
+ yield* fs.writeFileString(out, `${text}
7167
+ `).pipe(mapError2((error) => new CliError({ message: error.message })));
7168
+ yield* log(`Wrote the outline of ${loop} to ${out}`);
7169
+ });
7170
+ var KitWriter = map9(promise(() => import("./chunk-mrkrt2hg.js")), (build) => build.writeKit);
5475
7171
  var KitBuilder = Reference("kitman/cli/KitBuilder", {
5476
- defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-1rwaetnm.js")), (build) => build.buildKit(directory))
7172
+ defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-mrkrt2hg.js")), (build) => build.buildKit(directory))
5477
7173
  });
5478
7174
  var uploadKit = (client, workspaceId, built) => gen(function* () {
5479
7175
  yield* client.uploadKitBundle(workspaceId, built.digest, { bundle: encode2(built.bundle) });
@@ -5481,16 +7177,18 @@ var uploadKit = (client, workspaceId, built) => gen(function* () {
5481
7177
  yield* client.uploadKitBundle(workspaceId, digest, { bundle: encode2(archive) });
5482
7178
  });
5483
7179
  var reportOverrides = (built) => forEach(built.overrides, (override) => log(`${override.winner} overrides ${override.what} ${override.name} of ${override.replaced}`), { discard: true });
7180
+ var reportUndescribedInputs = (built) => forEach(built.declarations.loops.flatMap((loop) => loopInputFields(loop.input).filter((field) => field.description === undefined).map((field) => `Loop ${loop.id}: Input field ${field.name} has no description; annotate it with { description }`)), (warning) => error(`Warning: ${warning}`), { discard: true });
5484
7181
  var buildKitInto = (command) => gen(function* () {
5485
7182
  const path = yield* Path;
5486
7183
  const directory = path.resolve(command.args[0] ?? ".");
5487
7184
  const out = path.resolve(command.flags.out ?? path.join(directory, "dist/kit"));
5488
7185
  const built = yield* (yield* KitBuilder)(directory);
5489
7186
  yield* reportOverrides(built);
7187
+ yield* reportUndescribedInputs(built);
5490
7188
  yield* (yield* KitWriter)(directory, built, out).pipe(mapError2(() => new CliError({ message: `${path.join(directory, "package.json")} is not a JSON object` })));
5491
7189
  yield* log(`Built ${built.name} ${built.version} into ${out}`);
5492
7190
  });
5493
- var optionalEnv = (name) => String2(name).pipe(option, map8(getOrUndefined));
7191
+ var optionalEnv = (name) => String2(name).pipe(option, map9(getOrUndefined));
5494
7192
  var ciIdToken = (apiUrl) => gen(function* () {
5495
7193
  const gitlab = yield* optionalEnv("KITMAN_ID_TOKEN");
5496
7194
  if (gitlab !== undefined)
@@ -6167,9 +7865,9 @@ var runnerDelivery = (client, runner, askedTeamId) => {
6167
7865
  providerActions: postures === undefined ? "" : Object.entries(postures).map(([action, posture]) => `${action}=${posture}`).join(",")
6168
7866
  };
6169
7867
  };
6170
- return teamId === undefined ? succeed6(row("per_team")) : client.getTeamDeliverySettings(teamId).pipe(map8((settings) => row(settings.delivery)), catchTag("KitmanClientError", (error) => succeed6(row("unknown", error.message))));
7868
+ return teamId === undefined ? succeed6(row("per_team")) : client.getTeamDeliverySettings(teamId).pipe(map9((settings) => row(settings.delivery)), catchTag("KitmanClientError", (error) => succeed6(row("unknown", error.message))));
6171
7869
  };
6172
- var runnerDoctorRowOnThisMachine = (runner) => map8(runnerServiceState(runnerServiceName(runner.id)), (service) => ({
7870
+ var runnerDoctorRowOnThisMachine = (runner) => map9(runnerServiceState(runnerServiceName(runner.id)), (service) => ({
6173
7871
  ...runnerDoctorRow(runner),
6174
7872
  ...service === undefined ? undefined : { service }
6175
7873
  }));