@kitman-sh/cli 0.11.0-rc.5 → 0.11.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.
@@ -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 };
@@ -35,6 +35,14 @@ import {
35
35
  } from "./chunk-vtfwjhzh.js";
36
36
  import"./chunk-0qz10ek8.js";
37
37
  import"./chunk-c6rbt85q.js";
38
+ import {
39
+ decodeText,
40
+ mkString,
41
+ FileSystem,
42
+ Path,
43
+ withDefault,
44
+ String2
45
+ } from "./chunk-3d4d52e5.js";
38
46
  import {
39
47
  SecureRandom,
40
48
  layerWebCrypto,
@@ -46,31 +54,23 @@ import {
46
54
  layer4,
47
55
  kitmanMcpServer,
48
56
  RunnerRpcProtocolVersion
49
- } from "./chunk-rtqdqr0v.js";
50
- import {
51
- decodeText,
52
- mkString,
53
- FileSystem,
54
- Path,
55
- withDefault,
56
- String2
57
- } from "./chunk-3d4d52e5.js";
57
+ } from "./chunk-9z371t6k.js";
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", {
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-vf1aatbh.js");
17
+ const { runCli } = await import("./chunk-7bktb38f.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.5",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {