@kitman-sh/cli 0.11.0-rc.6 → 0.11.1

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.
@@ -46,7 +46,7 @@ import {
46
46
  layer4,
47
47
  kitmanMcpServer,
48
48
  RunnerRpcProtocolVersion
49
- } from "./chunk-rtqdqr0v.js";
49
+ } from "./chunk-9z371t6k.js";
50
50
  import {
51
51
  decodeText,
52
52
  mkString,
@@ -58,19 +58,19 @@ import {
58
58
  import {
59
59
  Packument,
60
60
  tarballMatches
61
- } from "./chunk-9a2r12ye.js";
62
- import"./chunk-248msks2.js";
61
+ } from "./chunk-0ca9dqh5.js";
62
+ import"./chunk-bm7hjnrx.js";
63
63
  import {
64
64
  AgentDeclaration,
65
65
  KitDeclarations,
66
66
  describeFlag,
67
67
  Described
68
- } from "./chunk-6pyxykt1.js";
68
+ } from "./chunk-6jceaa1q.js";
69
69
  import {
70
70
  ChildProcessSpawner,
71
71
  make3
72
72
  } from "./chunk-sk6ceghr.js";
73
- import"./chunk-egb7pjjz.js";
73
+ import"./chunk-5326a9ks.js";
74
74
 
75
75
  // packages/sdk/src/build/index.ts
76
76
  class DependencyInstallFailed extends TaggedError2()("DependencyInstallFailed", {
@@ -12,7 +12,7 @@ import {
12
12
  herdrCoreLayer2,
13
13
  herdrCoreTransportLayer2,
14
14
  updateHerdrCore2
15
- } from "./chunk-rtqdqr0v.js";
15
+ } from "./chunk-9z371t6k.js";
16
16
  import"./chunk-3d4d52e5.js";
17
17
  import"./chunk-vtfwjhzh.js";
18
18
  export {
@@ -246,7 +246,7 @@ import {
246
246
  installCommand,
247
247
  checkServicesFile,
248
248
  checkServices
249
- } from "./chunk-rtqdqr0v.js";
249
+ } from "./chunk-9z371t6k.js";
250
250
  import {
251
251
  join,
252
252
  interrupt,
@@ -302,8 +302,8 @@ import {
302
302
  applyAgentEnvironmentMaterialization2,
303
303
  isPathWithin2,
304
304
  skillIdentity2
305
- } from "./chunk-5hx3j5x8.js";
306
- import"./chunk-9a2r12ye.js";
305
+ } from "./chunk-3y7j2s7v.js";
306
+ import"./chunk-0ca9dqh5.js";
307
307
  import {
308
308
  egressAllowed,
309
309
  writeSecretRegistry,
@@ -328,8 +328,8 @@ import {
328
328
  rpcRunFiles,
329
329
  programHostsEnv,
330
330
  undeclaredHostsEnv
331
- } from "./chunk-6pyxykt1.js";
332
- import"./chunk-248msks2.js";
331
+ } from "./chunk-6jceaa1q.js";
332
+ import"./chunk-bm7hjnrx.js";
333
333
  import {
334
334
  nextInt
335
335
  } from "./chunk-nzjb36ad.js";
@@ -337,7 +337,7 @@ import {
337
337
  ChildProcessSpawner,
338
338
  make3
339
339
  } from "./chunk-sk6ceghr.js";
340
- import"./chunk-egb7pjjz.js";
340
+ import"./chunk-5326a9ks.js";
341
341
 
342
342
  // packages/core/src/sync-kit.ts
343
343
  import { createHash } from "crypto";
@@ -7091,6 +7091,81 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
7091
7091
  status: "deferred",
7092
7092
  crashed: `it did not start: ${error.message}`.slice(0, 500)
7093
7093
  })));
7094
+ // packages/agent-runtime/src/deploy-script.ts
7095
+ var deployScript = ".kitman/deploy";
7096
+ var deployTimeout = "3 hours";
7097
+ var detailLimit = 1200;
7098
+ var statusOfExit = (exitCode) => {
7099
+ switch (exitCode) {
7100
+ case 0:
7101
+ return "deployed";
7102
+ case 2:
7103
+ return "rolled_back";
7104
+ case 3:
7105
+ return "rollback_failed";
7106
+ default:
7107
+ return "failed";
7108
+ }
7109
+ };
7110
+ var executableAt = (checkout, revision) => map8(runCommand2("git", ["-C", checkout, "ls-tree", "--end-of-options", revision, "--", deployScript]), (listed) => listed.startsWith("100755 "));
7111
+ var tagCommit = (checkout, tagRef) => exit(runCommand2("git", ["-C", checkout, "rev-parse", "--verify", "--quiet", "--end-of-options", `${tagRef}^{commit}`]));
7112
+ var headOf = (checkout) => map8(all3([
7113
+ runCommand2("git", ["-C", checkout, "rev-parse", "HEAD"]),
7114
+ runCommand2("git", ["-C", checkout, "rev-parse", "HEAD^{tree}"])
7115
+ ]), ([revision, tree]) => ({ revision: revision.trim(), tree: tree.trim(), checks: [] }));
7116
+ var deployDetail = (output, exitCode) => {
7117
+ const last = output.trimEnd().split(`
7118
+ `).at(-1) ?? "";
7119
+ const reported = /^kitman-deploy: \S+ (.+)$/u.exec(last)?.[1]?.trim();
7120
+ if (reported !== undefined && reported !== "")
7121
+ return redactedOutputTail(reported, detailLimit);
7122
+ const ended = exitCode === undefined ? `${deployScript} did not exit in time` : `${deployScript} exited with exit code ${exitCode}`;
7123
+ return `${ended}: ${redactedOutputTail(output, detailLimit - ended.length - 2)}`;
7124
+ };
7125
+ var deployTag = (work, deploy, checkouts, mayRun, timeout = deployTimeout) => gen(function* () {
7126
+ const checkout = yield* checkouts.checkout({ runId: work.runId, id: work.id, baseRevision: work.revision }, work.repoBinding);
7127
+ const tagRef = `refs/tags/${deploy.tag}`;
7128
+ if (!(yield* executableAt(checkout, "HEAD"))) {
7129
+ let tagged = yield* tagCommit(checkout, tagRef);
7130
+ if (isFailure2(tagged)) {
7131
+ yield* ignore(runCommand2("git", ["-C", checkout, "fetch", "--quiet", "origin", `+${tagRef}:${tagRef}`], {
7132
+ env: yield* checkouts.transferEnv(work.repoBinding),
7133
+ timeout: "5 minutes"
7134
+ }));
7135
+ tagged = yield* tagCommit(checkout, tagRef);
7136
+ }
7137
+ if (isFailure2(tagged))
7138
+ return { failed: `The tag ${deploy.tag} is not in ${work.repoBinding.id}'s clone` };
7139
+ if (!(yield* executableAt(checkout, tagRef))) {
7140
+ const none = {
7141
+ status: "none",
7142
+ detail: `Neither ${work.revision} nor ${deploy.tag} has an executable ${deployScript}`
7143
+ };
7144
+ return { ranAt: yield* headOf(checkout), deployed: none };
7145
+ }
7146
+ yield* runCommand2("git", ["-C", checkout, "checkout", "--quiet", "--detach", tagRef]);
7147
+ }
7148
+ if (!mayRun)
7149
+ return { ranAt: yield* headOf(checkout), found: true };
7150
+ const decoder = new TextDecoder;
7151
+ let printed = "";
7152
+ const ran = yield* runProcess2([`${checkout}/${deployScript}`, deploy.tag, ...deploy.previousTag === undefined ? [] : [deploy.previousTag]], {
7153
+ cwd: checkout,
7154
+ env: { GIT_TERMINAL_PROMPT: "0" },
7155
+ timeout,
7156
+ onOutput: (chunk) => sync2(() => {
7157
+ printed = (printed + decoder.decode(chunk, { stream: true })).slice(-shellOutputTailChars2);
7158
+ })
7159
+ });
7160
+ const output = ran.exitCode === undefined ? printed : ran.output;
7161
+ const deployed = {
7162
+ status: statusOfExit(ran.exitCode),
7163
+ ...ran.exitCode === undefined ? undefined : { exitCode: ran.exitCode },
7164
+ detail: deployDetail(output, ran.exitCode)
7165
+ };
7166
+ return { ranAt: yield* headOf(checkout), deployed };
7167
+ });
7168
+
7094
7169
  // packages/agent-runtime/src/half-close-relay.ts
7095
7170
  import { once } from "events";
7096
7171
  import { connect as connect2, createServer as createServer2 } from "net";
@@ -7702,6 +7777,15 @@ var verificationExecutor = (input) => (work) => gen(function* () {
7702
7777
  const checkouts = runCheckouts(input.rootDir, input.gitCredentials);
7703
7778
  if (work.resolve !== undefined)
7704
7779
  return yield* resolveRevisions(work, work.resolve.revisions, checkouts);
7780
+ if (work.deploy !== undefined) {
7781
+ const ran = yield* deployTag(work, work.deploy, checkouts, input.runsDeployScripts === true && work.deploy.runsScript === true, input.deployTimeout);
7782
+ if ("failed" in ran)
7783
+ return { status: "failed", failureSummary: ran.failed };
7784
+ return {
7785
+ status: "completed",
7786
+ evidence: "found" in ran ? { head: ran.ranAt, deployScriptFound: true } : { head: ran.ranAt, deployed: ran.deployed }
7787
+ };
7788
+ }
7705
7789
  if (work.measure !== undefined) {
7706
7790
  const measured = yield* measureRevisions(work, work.measure, checkouts, runIn);
7707
7791
  const outcome = "failed" in measured ? { status: "failed", failureSummary: measured.failed } : { status: "completed", evidence: measured.measured };
@@ -46,6 +46,7 @@ import {
46
46
  as,
47
47
  asSome2,
48
48
  asVoid,
49
+ zipWith,
49
50
  catch_,
50
51
  catchTag,
51
52
  catchTags,
@@ -139,6 +140,7 @@ import {
139
140
  defaultRunnerSettings,
140
141
  shownRunnerSetting,
141
142
  defaultRunnerCapabilities,
143
+ deliveryProviderActions,
142
144
  MemoryStatuses,
143
145
  MemoryScopes,
144
146
  MaxMemoryListLimit,
@@ -215,7 +217,7 @@ import {
215
217
  harnessNames,
216
218
  herdrRunnerCapabilities2,
217
219
  declaredChecks
218
- } from "./chunk-rtqdqr0v.js";
220
+ } from "./chunk-9z371t6k.js";
219
221
  import {
220
222
  Id
221
223
  } from "./chunk-0qz10ek8.js";
@@ -527,10 +529,10 @@ var sandboxMissing = (sandbox, missing) => ({
527
529
  var personalCheckBackend = (agentSandbox, dockerAvailable) => agentSandbox === "srt" || agentSandbox === "docker" && dockerAvailable ? agentSandbox : undefined;
528
530
  var herdrCoreSession = (runnerId, personal) => personal ? undefined : `kitman-${sha2562(runnerId).slice(0, 16)}`;
529
531
  var OpenHerdrCore = Reference("kitman/cli/OpenHerdrCore", {
530
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-x7b9bwk6.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
532
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-ryed23pv.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
531
533
  });
532
534
  var UpdateHerdrCore = Reference("kitman/cli/UpdateHerdrCore", {
533
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-x7b9bwk6.js")), (module) => module.updateHerdrCore(options))
535
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-ryed23pv.js")), (module) => module.updateHerdrCore(options))
534
536
  });
535
537
  var herdrCoreMissing = (error) => {
536
538
  if (isTagged(error, "HerdrCoreMissing"))
@@ -932,7 +934,7 @@ var syncTargets = (harness) => gen(function* () {
932
934
  });
933
935
  var syncKits = (input) => gen(function* () {
934
936
  const fs = yield* FileSystem;
935
- const { syncKitSetup } = yield* promise(() => import("./chunk-7fbpsnt7.js"));
937
+ const { syncKitSetup } = yield* promise(() => import("./chunk-5tp7y1kc.js"));
936
938
  const harnesses = yield* syncTargets(input.harness);
937
939
  const chain = yield* input.client.getKitChain(input.workspaceId);
938
940
  for (const { name, problem } of chain.skipped)
@@ -1850,7 +1852,7 @@ var package_default = {
1850
1852
  };
1851
1853
 
1852
1854
  // apps/cli/src/scaffold.ts
1853
- var cliVersion = "0.11.0-rc.6";
1855
+ var cliVersion = "0.11.1";
1854
1856
  var packageJson = (name, scaffold) => `${JSON.stringify({
1855
1857
  name,
1856
1858
  private: true,
@@ -2047,6 +2049,7 @@ var Usage = [
2047
2049
  " kitman loop list",
2048
2050
  " kitman loop show <loop>",
2049
2051
  " kitman loop starts [--limit <n>] (what Events started, or why they started nothing)",
2052
+ " kitman loop when <loop> <event> on|off (turn an automatic start on or off for the Team)",
2050
2053
  " kitman agent list",
2051
2054
  "",
2052
2055
  "Kits of your own, to deploy with kitman deploy:",
@@ -2055,7 +2058,7 @@ var Usage = [
2055
2058
  "",
2056
2059
  "Approved verifications of the current repository:",
2057
2060
  " kitman verify list",
2058
- ' kitman verify add <name> "<command>" [--cwd <directory>] [--pipeline]',
2061
+ ' kitman verify add <name> "<command>" [--cwd <directory>] [--pipeline] [--reads-target]',
2059
2062
  " kitman verify remove <name>",
2060
2063
  " kitman constraint list",
2061
2064
  ' kitman constraint add "<constraint>"',
@@ -2087,6 +2090,11 @@ var Usage = [
2087
2090
  " kitman release team <team> [merge|milestone|project|inherit]",
2088
2091
  " kitman release project <project> [merge|milestone|project|inherit]",
2089
2092
  "",
2093
+ "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:",
2094
+ " kitman land workspace [default|epic] (setting it needs an owner or admin)",
2095
+ " kitman land team <team> [default|epic|inherit]",
2096
+ " kitman land project <project> [default|epic|inherit]",
2097
+ "",
2090
2098
  "Repositories, Memory and Decisions belong to the Workspace or one Team:",
2091
2099
  " kitman repo list",
2092
2100
  " kitman repo add [--from-current-repo] [--team <team>]",
@@ -2110,7 +2118,7 @@ var Usage = [
2110
2118
  "Every run, loop, agent, verify, constraint, secret, claim, deploy, dev and kit command takes --json."
2111
2119
  ].join(`
2112
2120
  `);
2113
- var agentRuntime = promise(() => import("./chunk-cnzz61ta.js"));
2121
+ var agentRuntime = promise(() => import("./chunk-vpee5tme.js"));
2114
2122
  var TuiLauncher = Reference("kitman/cli/TuiLauncher", {
2115
2123
  defaultValue: () => gen(function* () {
2116
2124
  const tui = yield* tryPromise({
@@ -2207,6 +2215,8 @@ function runEffect(args) {
2207
2215
  return yield* deliveryCommand(args);
2208
2216
  if (command === "release")
2209
2217
  return yield* releaseTriggerCommand(args);
2218
+ if (command === "land")
2219
+ return yield* deliveryTargetCommand(args);
2210
2220
  if (command === "lifecycle")
2211
2221
  return yield* lifecycleCommand(args);
2212
2222
  if (command === "sync")
@@ -2283,6 +2293,8 @@ function parseCommand(args) {
2283
2293
  flags.follow = true;
2284
2294
  else if (arg === "--pipeline")
2285
2295
  flags.pipeline = true;
2296
+ else if (arg === "--reads-target")
2297
+ flags.readsTarget = true;
2286
2298
  else if (arg === "--constraint" || arg === "--add-constraint" || arg === "--remove-constraint") {
2287
2299
  const value = args[++index];
2288
2300
  if (!value)
@@ -2796,6 +2808,46 @@ function releaseTriggerCommand(args) {
2796
2808
  return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
2797
2809
  });
2798
2810
  }
2811
+ var deliveryTargetWords = {
2812
+ default_branch: "on the default branch",
2813
+ epic_branch: "on its epic's branch, and the epic on the default branch once every sub-task is done"
2814
+ };
2815
+ var deliveryTargetLine = (subject, setting) => {
2816
+ const resolved = setting.resolved;
2817
+ return setting.target === null && resolved !== undefined ? `${subject} inherits: each Task lands ${deliveryTargetWords[resolved.target]}, from ${releaseLayerWords[resolved.layer]}` : setting.target === null ? `${subject} inherits its Team's delivery target` : `${subject} lands each Task ${deliveryTargetWords[setting.target]}`;
2818
+ };
2819
+ var deliveryChoices = { default: "default_branch", epic: "epic_branch", inherit: null };
2820
+ var isDeliveryChoice = (given) => Object.hasOwn(deliveryChoices, given);
2821
+ function deliveryTargetCommand(args) {
2822
+ return gen(function* () {
2823
+ const command = parseCommand(args);
2824
+ const apiUrl = yield* resolveApiUrl(command.flags.apiUrl);
2825
+ const client = yield* clientFor(apiUrl, yield* requiredSessionForApi(apiUrl));
2826
+ const workspaceId = yield* activeWorkspaceId(command.flags);
2827
+ const named = command.action === "workspace" ? undefined : requiredArg(command, command.action);
2828
+ const given = command.action === "workspace" ? command.args[0] : command.args[1];
2829
+ if (given !== undefined && !isDeliveryChoice(given))
2830
+ return yield* new CliError({ message: `land ${command.action} takes default, epic or inherit` });
2831
+ if (given === "inherit" && command.action === "workspace")
2832
+ return yield* new CliError({ message: "The Workspace has nothing to inherit from; give default or epic" });
2833
+ const update = given === undefined ? undefined : { target: deliveryChoices[given] };
2834
+ const report = (subject, setting) => command.flags.json ? printJson(setting) : log(deliveryTargetLine(subject, setting));
2835
+ if (command.action === "workspace")
2836
+ return yield* report("The Workspace", update === undefined ? yield* client.getWorkspaceDeliveryTarget(workspaceId) : yield* client.setWorkspaceDeliveryTarget(workspaceId, update));
2837
+ if (command.action === "team") {
2838
+ const team = yield* teamNamed(client, workspaceId, named ?? "");
2839
+ return yield* report(team.key, update === undefined ? yield* client.getTeamDeliveryTarget(team.id) : yield* client.setTeamDeliveryTarget(team.id, update));
2840
+ }
2841
+ if (command.action === "project") {
2842
+ const ref = (named ?? "").trim();
2843
+ const project = (yield* client.listProjects(workspaceId)).items.find((candidate) => candidate.id === ref || candidate.name.toLowerCase() === ref.toLowerCase());
2844
+ if (project === undefined)
2845
+ return yield* new CliError({ message: `No Project named ${ref}` });
2846
+ return yield* report(project.name, update === undefined ? yield* client.getProjectDeliveryTarget(workspaceId, project.id) : yield* client.setProjectDeliveryTarget(workspaceId, project.id, update));
2847
+ }
2848
+ return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
2849
+ });
2850
+ }
2799
2851
  var teamNamed = (client, workspaceId, ref) => flatMap3(client.listTeams(workspaceId), (teams) => teamIn(teams.items, ref));
2800
2852
  var ownerTo = (client, workspaceId, command) => gen(function* () {
2801
2853
  const to = command.flags.to;
@@ -3035,6 +3087,8 @@ function runnerCommand(args) {
3035
3087
  }
3036
3088
  if (command.action === "doctor") {
3037
3089
  const runners = yield* client.listRunners(workspaceId);
3090
+ const askedTeamId = command.flags.team === undefined ? undefined : (yield* teamNamed(client, workspaceId, command.flags.team)).id;
3091
+ const runnerDoctorRowHere = (runner) => zipWith(runnerDoctorRowOnThisMachine(runner), runnerDelivery(client, runner, askedTeamId), (row, delivery) => ({ ...row, ...delivery }));
3038
3092
  if (command.flags.runnerId === undefined && command.args.length === 0 && command.flags.backend === undefined)
3039
3093
  return yield* runners.items.length === 0 ? printRows([{ status: "no_runners", workspaceId, message: "No Runner registered for workspace." }], command.flags.json) : printRows(yield* forEach(runners.items, runnerDoctorRowHere), command.flags.json);
3040
3094
  const runner = command.flags.runnerId === undefined && command.args.length === 0 ? runners.items.find((item) => item.status === "active") ?? runners.items[0] : resolveRunnerRef(runners.items, command.flags.runnerId ?? command.args.join(" "));
@@ -3046,7 +3100,7 @@ function runnerCommand(args) {
3046
3100
  if (command.flags.backend !== "herdr")
3047
3101
  return yield* new CliError({ message: `Unsupported runner backend: ${command.flags.backend}` });
3048
3102
  const readiness = yield* checkHerdrRunnerReadiness(runner);
3049
- return yield* printRows([readiness], command.flags.json);
3103
+ return yield* printRows([{ ...readiness, ...yield* runnerDelivery(client, runner, askedTeamId) }], command.flags.json);
3050
3104
  }
3051
3105
  return yield* printRows([yield* runnerDoctorRowHere(runner)], command.flags.json);
3052
3106
  }
@@ -3061,7 +3115,7 @@ var SandboxHostProbe = Reference("kitman/cli/SandboxHostProbe", {
3061
3115
  });
3062
3116
  var OpenRunnerRpc = Reference("kitman/cli/OpenRunnerRpc", {
3063
3117
  defaultValue: () => (options) => gen(function* () {
3064
- const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-vkgqtwqm.js"));
3118
+ const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-gjt5m6xc.js"));
3065
3119
  return yield* makeRunnerRpcClient({
3066
3120
  runnerId: options.runnerId,
3067
3121
  bearer: options.bearer,
@@ -3487,6 +3541,7 @@ function startCanonicalHerdrRunnerCommand(input) {
3487
3541
  runFiles: { client: rpc, storage },
3488
3542
  postgres: dockerCheckPostgres(input.runnerId, replica.id),
3489
3543
  ...checkDocker === undefined ? undefined : { docker: checkDocker },
3544
+ runsDeployScripts: personal,
3490
3545
  ...sandbox === undefined ? undefined : { sandbox: { ...sandbox, apiUrl: input.apiUrl, hosts: live.settings.checkHosts } }
3491
3546
  })(work);
3492
3547
  };
@@ -3584,7 +3639,7 @@ function mcpCommand(args) {
3584
3639
  if (command.action === "run") {
3585
3640
  if (command.args.length > 0)
3586
3641
  return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
3587
- const { runMcpServerCommand } = yield* promise(() => import("./chunk-bs81bt3q.js"));
3642
+ const { runMcpServerCommand } = yield* promise(() => import("./chunk-hvr790k3.js"));
3588
3643
  return yield* runMcpServerCommand({ flags: command.flags });
3589
3644
  }
3590
3645
  if (command.action !== "setup")
@@ -4035,6 +4090,11 @@ function contextCommand(args) {
4035
4090
  var programLoopLines = (loop) => [
4036
4091
  `${loop.id}${loop.version === undefined ? "" : ` ${loop.version}`} ${loop.layer} kit ${loop.kit} ${loop.digest}`
4037
4092
  ];
4093
+ var whenClauseLines = (loop) => loop.when.map((clause) => {
4094
+ const filter = Object.entries(clause.filter ?? {}).map(([path, value]) => `${path} ${Array.isArray(value) ? value.join("|") : String(value)}`).join(", ");
4095
+ return ` when ${clause.event}${filter === "" ? "" : ` (${filter})`}${clause.optIn === true ? ", opt-in" : ""}${clause.on === undefined ? "" : `: ${clause.on ? "on" : "off"}`}${clause.description === undefined ? "" : `
4096
+ ${clause.description}`}`;
4097
+ });
4038
4098
  function programLoopCommand(command) {
4039
4099
  return gen(function* () {
4040
4100
  const client = yield* loopClientFor(yield* resolveApiUrl(command.flags.apiUrl));
@@ -4052,7 +4112,17 @@ function programLoopCommand(command) {
4052
4112
  const loop = requiredArg(command, "a Loop");
4053
4113
  const teamId = yield* optionalActiveTeamId(command.flags);
4054
4114
  const shown = yield* client.showProgramLoop(yield* activeWorkspaceId(command.flags), loop, teamId === undefined ? {} : { teamId });
4055
- return yield* print(shown, (value) => value.resolved === undefined ? [`${loop} resolves to nothing here`] : programLoopLines(value.resolved));
4115
+ return yield* print(shown, (value) => value.resolved === undefined ? [`${loop} resolves to nothing here`] : [...programLoopLines(value.resolved), ...whenClauseLines(value.resolved)]);
4116
+ }
4117
+ if (command.action === "when") {
4118
+ const [loop, event, state] = command.args;
4119
+ if (loop === undefined || event === undefined || state !== "on" && state !== "off")
4120
+ return yield* new CliError({ message: "Use kitman loop when <loop> <event> on or off" });
4121
+ const switched = yield* client.setLoopWhenClause(yield* activeTeamId(command.flags), loop, {
4122
+ event,
4123
+ on: state === "on"
4124
+ });
4125
+ return yield* print(switched, (value) => value.resolved === undefined ? [`${loop} resolves to nothing here`] : [...programLoopLines(value.resolved), ...whenClauseLines(value.resolved)]);
4056
4126
  }
4057
4127
  return yield* new CliError({ message: `Unknown loop command: ${command.action}` });
4058
4128
  });
@@ -4103,7 +4173,7 @@ function agentCommand(args) {
4103
4173
  }
4104
4174
  function loopCommand(args) {
4105
4175
  const command = parseCommand(args);
4106
- if (["list", "starts", "show"].includes(command.action))
4176
+ if (["list", "starts", "show", "when"].includes(command.action))
4107
4177
  return programLoopCommand(command);
4108
4178
  if (["catalog", "validate", "test"].includes(command.action))
4109
4179
  return loopCatalogCommand(args);
@@ -4685,7 +4755,7 @@ function verifyCommand(args) {
4685
4755
  const print = (value, lines) => command.flags.json ? printJson(value) : forEach(lines(value), (line) => log(line), { discard: true });
4686
4756
  switch (command.action) {
4687
4757
  case "list":
4688
- 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)" : ""}`));
4758
+ 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)" : ""}`));
4689
4759
  case "add": {
4690
4760
  const [name, ...words] = command.args;
4691
4761
  if (name === undefined || words.length === 0)
@@ -4694,7 +4764,8 @@ function verifyCommand(args) {
4694
4764
  name,
4695
4765
  command: words.join(" "),
4696
4766
  ...command.flags.workingDirectory === undefined ? undefined : { workingDirectory: command.flags.workingDirectory },
4697
- pipeline: command.flags.pipeline === true
4767
+ pipeline: command.flags.pipeline === true,
4768
+ readsTarget: command.flags.readsTarget === true
4698
4769
  }), (check) => [`Approved ${check.name}${check.pipeline === true ? " as the pipeline" : ""}: ${check.command}`]);
4699
4770
  }
4700
4771
  case "remove":
@@ -4838,9 +4909,9 @@ function changeRequestCommand(args) {
4838
4909
  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}`);
4839
4910
  });
4840
4911
  }
4841
- var KitWriter = map8(promise(() => import("./chunk-b6m9rfzj.js")), (build) => build.writeKit);
4912
+ var KitWriter = map8(promise(() => import("./chunk-k25zydjm.js")), (build) => build.writeKit);
4842
4913
  var KitBuilder = Reference("kitman/cli/KitBuilder", {
4843
- defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-b6m9rfzj.js")), (build) => build.buildKit(directory))
4914
+ defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-k25zydjm.js")), (build) => build.buildKit(directory))
4844
4915
  });
4845
4916
  var uploadKit = (client, workspaceId, built) => gen(function* () {
4846
4917
  yield* client.uploadKitBundle(workspaceId, built.digest, { bundle: encode2(built.bundle) });
@@ -5519,7 +5590,23 @@ function runnerDoctorRow(runner) {
5519
5590
  maxConcurrentRuns: runner.capabilities.resourceLimits?.maxConcurrentRuns
5520
5591
  };
5521
5592
  }
5522
- var runnerDoctorRowHere = (runner) => map8(runnerServiceState(runnerServiceName(runner.id)), (service) => ({
5593
+ var runnerDelivery = (client, runner, askedTeamId) => {
5594
+ const teamId = runner.ownership.kind === "team" ? runner.ownership.teamId : askedTeamId;
5595
+ const reported = runner.capabilities.runs?.providerActions;
5596
+ const row = (delivery, deliveryUnknownBecause) => {
5597
+ const postures = reported === undefined ? undefined : delivery === "gated" || delivery === "auto" ? deliveryProviderActions(reported, delivery) : Object.fromEntries(Object.entries(deliveryProviderActions(reported, "gated")).map(([action, posture]) => [
5598
+ action,
5599
+ posture === "gated" ? delivery : posture
5600
+ ]));
5601
+ return {
5602
+ delivery,
5603
+ ...deliveryUnknownBecause === undefined ? undefined : { deliveryUnknownBecause },
5604
+ providerActions: postures === undefined ? "" : Object.entries(postures).map(([action, posture]) => `${action}=${posture}`).join(",")
5605
+ };
5606
+ };
5607
+ return teamId === undefined ? succeed6(row("per_team")) : client.getTeamDeliverySettings(teamId).pipe(map8((settings) => row(settings.delivery)), catchTag("KitmanClientError", (error) => succeed6(row("unknown", error.message))));
5608
+ };
5609
+ var runnerDoctorRowOnThisMachine = (runner) => map8(runnerServiceState(runnerServiceName(runner.id)), (service) => ({
5523
5610
  ...runnerDoctorRow(runner),
5524
5611
  ...service === undefined ? undefined : { service }
5525
5612
  }));
package/dist/index.js CHANGED
@@ -14,6 +14,6 @@ if (args[0] === "srt") {
14
14
  const { runOpencodeReader } = await import("./chunk-d9bv70qb.js");
15
15
  runOpencodeReader();
16
16
  } else {
17
- const { runCli } = await import("./chunk-q9pbynx3.js");
17
+ const { runCli } = await import("./chunk-z08mxppz.js");
18
18
  runCli(args);
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/cli",
3
- "version": "0.11.0-rc.6",
3
+ "version": "0.11.1",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {