@intentius/chant 0.124.57 → 0.124.59

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 (163) hide show
  1. package/dist/ci-product-words.d.ts +47 -2
  2. package/dist/ci-product-words.d.ts.map +1 -1
  3. package/dist/ci-product-words.js +59 -1
  4. package/dist/ci-product.d.ts +26 -2
  5. package/dist/ci-product.d.ts.map +1 -1
  6. package/dist/ci-product.js +25 -2
  7. package/dist/cli/commands/init.d.ts +2 -0
  8. package/dist/cli/commands/init.d.ts.map +1 -1
  9. package/dist/cli/commands/init.js +1 -1
  10. package/dist/cli/handlers/build.d.ts.map +1 -1
  11. package/dist/cli/handlers/build.js +5 -1
  12. package/dist/cli/handlers/init.d.ts.map +1 -1
  13. package/dist/cli/handlers/init.js +16 -0
  14. package/dist/cli/handlers/lifecycle-drift.d.ts +2 -1
  15. package/dist/cli/handlers/lifecycle-drift.d.ts.map +1 -1
  16. package/dist/cli/handlers/lifecycle-drift.js +4 -2
  17. package/dist/cli/handlers/lock.d.ts.map +1 -1
  18. package/dist/cli/handlers/lock.js +45 -2
  19. package/dist/cli/handlers/serve.d.ts.map +1 -1
  20. package/dist/cli/handlers/serve.js +9 -0
  21. package/dist/cli/main.d.ts.map +1 -1
  22. package/dist/cli/main.js +11 -3
  23. package/dist/cli/mcp/product-tools.d.ts +40 -7
  24. package/dist/cli/mcp/product-tools.d.ts.map +1 -1
  25. package/dist/cli/mcp/product-tools.js +58 -15
  26. package/dist/cli/mcp/read-only.d.ts +2 -1
  27. package/dist/cli/mcp/read-only.d.ts.map +1 -1
  28. package/dist/cli/mcp/read-only.js +2 -1
  29. package/dist/cli/mcp/server.d.ts +11 -0
  30. package/dist/cli/mcp/server.d.ts.map +1 -1
  31. package/dist/cli/mcp/server.js +15 -3
  32. package/dist/cli/mcp-config.d.ts +4 -1
  33. package/dist/cli/mcp-config.d.ts.map +1 -1
  34. package/dist/cli/mcp-config.js +6 -2
  35. package/dist/cli/parse-args.d.ts.map +1 -1
  36. package/dist/cli/parse-args.js +27 -0
  37. package/dist/cli/registry.d.ts +14 -0
  38. package/dist/cli/registry.d.ts.map +1 -1
  39. package/dist/components/pr-pipeline.d.ts +56 -0
  40. package/dist/components/pr-pipeline.d.ts.map +1 -1
  41. package/dist/components/pr-pipeline.js +55 -2
  42. package/dist/components/product-pipeline.d.ts +18 -1
  43. package/dist/components/product-pipeline.d.ts.map +1 -1
  44. package/dist/components/product-pipeline.js +8 -2
  45. package/dist/drift-record.d.ts +5 -0
  46. package/dist/drift-record.d.ts.map +1 -1
  47. package/dist/e2e-harness/driver.d.ts.map +1 -1
  48. package/dist/e2e-harness/driver.js +97 -0
  49. package/dist/e2e-harness/forgejo.d.ts +5 -1
  50. package/dist/e2e-harness/forgejo.d.ts.map +1 -1
  51. package/dist/e2e-harness/forgejo.js +35 -0
  52. package/dist/e2e-harness/index.d.ts +7 -0
  53. package/dist/e2e-harness/index.d.ts.map +1 -1
  54. package/dist/e2e-harness/index.js +10 -1
  55. package/dist/e2e-harness/ports.d.ts +31 -0
  56. package/dist/e2e-harness/ports.d.ts.map +1 -1
  57. package/dist/e2e-harness/scenario.d.ts.map +1 -1
  58. package/dist/e2e-harness/scenario.js +9 -5
  59. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  60. package/dist/e2e-harness/schemas/index.d.ts +22 -1
  61. package/dist/e2e-harness/schemas/index.d.ts.map +1 -1
  62. package/dist/e2e-harness/schemas/index.js +1 -1
  63. package/dist/e2e-harness/steps.d.ts.map +1 -1
  64. package/dist/e2e-harness/steps.js +4 -0
  65. package/dist/lifecycle/lock-beat.d.ts +27 -0
  66. package/dist/lifecycle/lock-beat.d.ts.map +1 -0
  67. package/dist/lifecycle/lock-beat.js +84 -0
  68. package/dist/lifecycle/resource-lock.d.ts +54 -1
  69. package/dist/lifecycle/resource-lock.d.ts.map +1 -1
  70. package/dist/lifecycle/resource-lock.js +128 -7
  71. package/dist/mcp/types.d.ts +9 -0
  72. package/dist/mcp/types.d.ts.map +1 -1
  73. package/dist/op/activities/activity-contracts.d.ts +4 -4
  74. package/dist/op/index.d.ts +1 -1
  75. package/dist/op/index.d.ts.map +1 -1
  76. package/dist/op/index.js +1 -1
  77. package/dist/op/op-waves-notify.d.ts.map +1 -1
  78. package/dist/op/op-waves-notify.js +11 -0
  79. package/dist/op/op-waves-run.d.ts +28 -1
  80. package/dist/op/op-waves-run.d.ts.map +1 -1
  81. package/dist/op/op-waves-run.js +92 -7
  82. package/dist/op/op-waves.d.ts +12 -1
  83. package/dist/op/op-waves.d.ts.map +1 -1
  84. package/dist/op/op-waves.js +9 -2
  85. package/dist/release-floors.d.ts +1 -1
  86. package/dist/release-floors.js +1 -1
  87. package/dist/template-request/index.d.ts +9 -0
  88. package/dist/template-request/index.d.ts.map +1 -0
  89. package/dist/template-request/index.js +8 -0
  90. package/dist/template-request/request-body.d.ts +21 -0
  91. package/dist/template-request/request-body.d.ts.map +1 -0
  92. package/dist/template-request/request-body.js +86 -0
  93. package/dist/template-request/template-request.d.ts +100 -0
  94. package/dist/template-request/template-request.d.ts.map +1 -0
  95. package/dist/template-request/template-request.js +149 -0
  96. package/dist/template-request/template-request.schema.json +100 -0
  97. package/dist/template-request/template-spec.d.ts +83 -0
  98. package/dist/template-request/template-spec.d.ts.map +1 -0
  99. package/dist/template-request/template-spec.js +146 -0
  100. package/dist/template-request/template.schema.json +114 -0
  101. package/dist/template-request/validate.d.ts +4 -0
  102. package/dist/template-request/validate.d.ts.map +1 -0
  103. package/dist/template-request/validate.js +21 -0
  104. package/dist/wave-runtime.mjs +298 -298
  105. package/dist/workspace/drift-cli.d.ts +13 -1
  106. package/dist/workspace/drift-cli.d.ts.map +1 -1
  107. package/dist/workspace/drift-cli.js +19 -3
  108. package/package.json +8 -1
  109. package/src/ci-product-words.test.ts +23 -0
  110. package/src/ci-product-words.ts +68 -3
  111. package/src/ci-product.ts +31 -1
  112. package/src/cli/commands/init.ts +3 -1
  113. package/src/cli/handlers/build.ts +5 -1
  114. package/src/cli/handlers/init.ts +18 -0
  115. package/src/cli/handlers/lifecycle-drift.test.ts +52 -0
  116. package/src/cli/handlers/lifecycle-drift.ts +4 -2
  117. package/src/cli/handlers/lock.ts +41 -2
  118. package/src/cli/handlers/serve.ts +9 -0
  119. package/src/cli/main.ts +11 -3
  120. package/src/cli/mcp/product-tools.test.ts +56 -1
  121. package/src/cli/mcp/product-tools.ts +66 -15
  122. package/src/cli/mcp/read-only.ts +2 -1
  123. package/src/cli/mcp/server.ts +20 -5
  124. package/src/cli/mcp-config.test.ts +52 -2
  125. package/src/cli/mcp-config.ts +6 -3
  126. package/src/cli/parse-args.ts +19 -0
  127. package/src/cli/registry.ts +14 -0
  128. package/src/components/pr-pipeline.ts +87 -2
  129. package/src/components/product-actions.test.ts +76 -0
  130. package/src/components/product-pipeline.ts +21 -2
  131. package/src/drift-record.ts +5 -0
  132. package/src/e2e-harness/driver.test.ts +163 -0
  133. package/src/e2e-harness/driver.ts +86 -1
  134. package/src/e2e-harness/forgejo.ts +42 -1
  135. package/src/e2e-harness/index.ts +11 -1
  136. package/src/e2e-harness/ports.ts +33 -0
  137. package/src/e2e-harness/scenario.ts +8 -6
  138. package/src/e2e-harness/schemas/README.md +11 -2
  139. package/src/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  140. package/src/e2e-harness/schemas/index.ts +5 -1
  141. package/src/e2e-harness/schemas.test.ts +44 -1
  142. package/src/e2e-harness/steps.ts +4 -0
  143. package/src/lifecycle/lock-beat.ts +99 -0
  144. package/src/lifecycle/resource-lock-liveness.test.ts +289 -0
  145. package/src/lifecycle/resource-lock.ts +143 -8
  146. package/src/mcp/types.ts +9 -0
  147. package/src/op/index.ts +1 -0
  148. package/src/op/op-waves-notify.ts +11 -0
  149. package/src/op/op-waves-preview.test.ts +167 -0
  150. package/src/op/op-waves-run.ts +116 -8
  151. package/src/op/op-waves.ts +20 -3
  152. package/src/release-floors.ts +1 -1
  153. package/src/template-request/__fixtures__/request-body.md +41 -0
  154. package/src/template-request/index.ts +8 -0
  155. package/src/template-request/request-body.ts +91 -0
  156. package/src/template-request/template-request.schema.json +100 -0
  157. package/src/template-request/template-request.test.ts +315 -0
  158. package/src/template-request/template-request.ts +234 -0
  159. package/src/template-request/template-spec.ts +176 -0
  160. package/src/template-request/template.schema.json +114 -0
  161. package/src/template-request/validate.ts +28 -0
  162. package/src/workspace/drift-cli.test.ts +35 -1
  163. package/src/workspace/drift-cli.ts +21 -3
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * `chant workspace drift [dir] --member <name> [--read <read>] [--resource
3
- * <addr>] [--env <env>] [--stream] [-o <file>]` (behold#995): one member's
3
+ * <addr>] [--stack <name>] [--env <env>] [--stream] [-o <file>]` (behold#995): one member's
4
4
  * drift, read by the engine that owns it, as chant's drift record
5
5
  * (`../drift-record.ts`, #4451).
6
6
  *
@@ -13,6 +13,14 @@
13
13
  * | `choudoufu` | `ownership` | the same, through `choudoufu live-plan -json` (and `live-ls`), or `--read plan` for live-plan with a plan beside it; `--resource <addr>` passes `choudoufu live-plan -resource=<addr>`'s stream through |
14
14
  * | `pulumi` | `refresh` | `chant lifecycle drift` in the member's reader project: the pulumi lexicon's `readDrift`, `pulumi refresh --preview-only --json --target <urn>` per resource in the checked-in export, or `plunge drift --resource <urn> --stream` for a member on plunge; `--resource <urn>` reads that URN alone (#4455) |
15
15
  *
16
+ * `--stack <name>` reads that stack's export for a `pulumi` member, from the
17
+ * index store (`refs/chant/snapshots`), where a member of several stacks
18
+ * holds one export each. Without it the member reads the export its store
19
+ * holds, which is the right one only for a member of one stack. A store with
20
+ * no export for the stack answers `no-drift-read`, naming the stack; it never
21
+ * falls back to another stack's export or the checked-in file. Any other kind
22
+ * answers `read-unsupported`.
23
+ *
16
24
  * Any other kind has no drift read and answers `no-drift-read`. A member of
17
25
  * a package's kind runs in the reader project `workspace graph` writes for it
18
26
  * (`./kind-readers.ts`), under the member's own toolchain, so chant core
@@ -43,6 +51,8 @@ export type DriftErrorCode = (typeof DRIFT_ERROR_CODES)[number];
43
51
  export declare const DRIFT_READS_BY_KIND: Record<string, readonly DriftRead[]>;
44
52
  /** The kinds whose engine reads one resource on its own, for `--resource`. */
45
53
  export declare const DRIFT_RESOURCE_KINDS: readonly string[];
54
+ /** The kinds whose engine keeps one export per stack, for `--stack`. */
55
+ export declare const DRIFT_STACK_KINDS: readonly string[];
46
56
  /** The document `workspace drift` prints: a drift document with the read contract's head. */
47
57
  export type WorkspaceDriftDocument = DriftDocument & {
48
58
  contract: number;
@@ -59,6 +69,8 @@ export interface DriftQuery {
59
69
  member: string;
60
70
  read?: string;
61
71
  resource?: string;
72
+ /** The stack whose stored export is read (`--stack`), for a pulumi member. */
73
+ stack?: string;
62
74
  env?: string;
63
75
  components?: boolean;
64
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"drift-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/drift-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAiBL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAWzB,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,yUAcY,CAAC;AAC3C,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,oGAAoG;AACpG,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAKpE,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAA4B,CAAC;AAa/E,6FAA6F;AAC7F,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAqG5G;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAgFpF;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,sBAAsB,CAQjG;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsC5E"}
1
+ {"version":3,"file":"drift-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/drift-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAiBL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAWzB,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,yUAcY,CAAC;AAC3C,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,oGAAoG;AACpG,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAKpE,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAA4B,CAAC;AAa/E,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAe,CAAC;AAE/D,6FAA6F;AAC7F,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAqG5G;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAoFpF;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,sBAAsB,CAQjG;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuC5E"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * `chant workspace drift [dir] --member <name> [--read <read>] [--resource
3
- * <addr>] [--env <env>] [--stream] [-o <file>]` (behold#995): one member's
3
+ * <addr>] [--stack <name>] [--env <env>] [--stream] [-o <file>]` (behold#995): one member's
4
4
  * drift, read by the engine that owns it, as chant's drift record
5
5
  * (`../drift-record.ts`, #4451).
6
6
  *
@@ -13,6 +13,14 @@
13
13
  * | `choudoufu` | `ownership` | the same, through `choudoufu live-plan -json` (and `live-ls`), or `--read plan` for live-plan with a plan beside it; `--resource <addr>` passes `choudoufu live-plan -resource=<addr>`'s stream through |
14
14
  * | `pulumi` | `refresh` | `chant lifecycle drift` in the member's reader project: the pulumi lexicon's `readDrift`, `pulumi refresh --preview-only --json --target <urn>` per resource in the checked-in export, or `plunge drift --resource <urn> --stream` for a member on plunge; `--resource <urn>` reads that URN alone (#4455) |
15
15
  *
16
+ * `--stack <name>` reads that stack's export for a `pulumi` member, from the
17
+ * index store (`refs/chant/snapshots`), where a member of several stacks
18
+ * holds one export each. Without it the member reads the export its store
19
+ * holds, which is the right one only for a member of one stack. A store with
20
+ * no export for the stack answers `no-drift-read`, naming the stack; it never
21
+ * falls back to another stack's export or the checked-in file. Any other kind
22
+ * answers `read-unsupported`.
23
+ *
16
24
  * Any other kind has no drift read and answers `no-drift-read`. A member of
17
25
  * a package's kind runs in the reader project `workspace graph` writes for it
18
26
  * (`./kind-readers.ts`), under the member's own toolchain, so chant core
@@ -76,7 +84,9 @@ export const DRIFT_RESOURCE_KINDS = ["choudoufu", "pulumi"];
76
84
  * the read was refused.
77
85
  */
78
86
  const MEMBER_REFUSED_EXITS = [1, 3];
79
- const USAGE = "chant workspace drift [dir] --member <name> [--read <state|plan|refresh|live-read|ownership>] [--resource <addr>] [--env <env>] [--components] [--stream] [-o <file>]";
87
+ const USAGE = "chant workspace drift [dir] --member <name> [--read <state|plan|refresh|live-read|ownership>] [--resource <addr>] [--stack <name>] [--env <env>] [--components] [--stream] [-o <file>]";
88
+ /** The kinds whose engine keeps one export per stack, for `--stack`. */
89
+ export const DRIFT_STACK_KINDS = ["pulumi"];
80
90
  class DriftReadFailure extends Error {
81
91
  constructor(code, message) {
82
92
  super(message);
@@ -171,7 +181,7 @@ function chantRecords(member, diffOut, componentsOut, observedAt, version) {
171
181
  function memberArgv(kind, query, read) {
172
182
  if (kind === "chant")
173
183
  return ["lifecycle", "diff", query.env, "--live", "--json"];
174
- return ["lifecycle", "drift", ".", "--member", query.member, "--read", read, ...(query.resource !== undefined ? ["--resource", query.resource] : [])];
184
+ return ["lifecycle", "drift", ".", "--member", query.member, "--read", read, ...(query.resource !== undefined ? ["--resource", query.resource] : []), ...(query.stack !== undefined ? ["--stack", query.stack] : [])];
175
185
  }
176
186
  /**
177
187
  * Read one member's drift and return the stream lines, placed on its graph.
@@ -198,6 +208,11 @@ export async function readWorkspaceDrift(query) {
198
208
  if (query.resource !== undefined && !DRIFT_RESOURCE_KINDS.includes(entry.kind)) {
199
209
  throw new DriftReadFailure("resource-unsupported", `--resource reads one resource through choudoufu live-plan -resource, pulumi refresh --target or plunge drift --resource; ${query.member} is kind ${entry.kind}`);
200
210
  }
211
+ if (query.stack !== undefined && !DRIFT_STACK_KINDS.includes(entry.kind)) {
212
+ throw new DriftReadFailure("read-unsupported", `--stack reads a stack's export from the index store, which a ${DRIFT_STACK_KINDS.join(" or ")} member has; ${query.member} is kind ${entry.kind}`);
213
+ }
214
+ if (query.stack !== undefined && query.stack.trim() === "")
215
+ throw new DriftReadFailure("read-unsupported", "--stack needs a stack name");
201
216
  if (entry.kind === "chant" && !query.env)
202
217
  throw new DriftReadFailure("env-required", `${query.member} is a chant member, read live through chant lifecycle diff <env> --live: add --env <env>`);
203
218
  const { registry: kinds, problems } = loadKindRegistry(declaration.pins, located.rootOnDisk);
@@ -298,6 +313,7 @@ export async function runWorkspaceDrift(ctx) {
298
313
  member: members[0],
299
314
  ...(args.driftRead !== undefined ? { read: args.driftRead } : {}),
300
315
  ...(args.resource !== undefined ? { resource: args.resource } : {}),
316
+ ...(args.carveStack !== undefined ? { stack: args.carveStack } : {}),
301
317
  ...(args.env !== undefined ? { env: args.env } : {}),
302
318
  ...(args.components ? { components: true } : {}),
303
319
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.124.57",
3
+ "version": "0.124.59",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -93,6 +93,13 @@
93
93
  "import": "./dist/op/activities/index.js",
94
94
  "default": "./src/op/activities/index.ts"
95
95
  },
96
+ "./template-request": {
97
+ "development": "./src/template-request/index.ts",
98
+ "types": "./dist/template-request/index.d.ts",
99
+ "import": "./dist/template-request/index.js",
100
+ "default": "./src/template-request/index.ts"
101
+ },
102
+ "./template-request/*.schema.json": "./src/template-request/*.schema.json",
96
103
  "./components": {
97
104
  "development": "./src/components/index.ts",
98
105
  "types": "./dist/components/index.d.ts",
@@ -92,6 +92,29 @@ describe("the comment grammar (moved from terragucci's comment.ts)", () => {
92
92
  expect(parseProductComment(pw, "/plywood lock everything")).toMatchObject({ kind: "refused" });
93
93
  });
94
94
 
95
+ test("an action command names one member and one action, and nothing else (#4653)", () => {
96
+ const words = assertProductWords({ ...TERRAGUCCI, commands: { ...TERRAGUCCI.commands, action: "action" as const } });
97
+ expect(parseProductComment(words, "/terragucci action apps/orders action.aws_lambda_invoke.rotate")).toEqual({ kind: "action", member: "apps/orders", address: "action.aws_lambda_invoke.rotate" });
98
+ expect(parseProductComment(words, "/terragucci action apps/orders module.app.action.aws_lambda_invoke.rotate")).toEqual({ kind: "action", member: "apps/orders", address: "module.app.action.aws_lambda_invoke.rotate" });
99
+ expect(parseProductComment(words, '/terragucci action apps/orders module.app["blue"].action.t.l[0]')).toEqual({ kind: "action", member: "apps/orders", address: 'module.app["blue"].action.t.l[0]' });
100
+ for (const bad of [
101
+ "/terragucci action",
102
+ "/terragucci action apps/orders",
103
+ "/terragucci action apps/orders action.t.l extra",
104
+ "/terragucci action ../etc action.t.l",
105
+ "/terragucci action apps/orders -target=x",
106
+ "/terragucci action apps/orders action.t.l;id",
107
+ "/terragucci action apps/orders $(id)",
108
+ "/terragucci action apps/orders action.t.l\nrm",
109
+ ]) {
110
+ expect(parseProductComment(words, bad.replace("\\n", "\n"))).toMatchObject({ kind: "refused" });
111
+ }
112
+ // A product without the word does not read it.
113
+ expect(parseProductComment(tg, "/terragucci action apps/orders action.t.l")).toMatchObject({ kind: "refused", reason: expect.stringMatching(/the commands are/) });
114
+ expect(commentLine(words, "action")).toBe("/terragucci action");
115
+ expect(productWordsProblems(words, { jobs: ["plan", "apply", "lock", "unlock", "agent"] })).toContain("commands.action needs a action job, and the pipeline has none");
116
+ });
117
+
95
118
  test("an alias reads only where its variable turns it on", () => {
96
119
  expect(parseProductComment(tg, "atlantis plan -d envs/dev/orders")).toBeUndefined();
97
120
  expect(parseProductComment(tg, "atlantis plan -d ./envs/dev/orders/", { TG_ATLANTIS_COMMENTS: "1" })).toEqual({ kind: "plan", member: "envs/dev/orders" });
@@ -29,10 +29,14 @@ export type CiProductStage = "plan" | "apply" | "record" | "check" | "drift" | "
29
29
  /** Every stage slot, in the order {@link assertProductWords} reports them. */
30
30
  export const CI_PRODUCT_STAGES: readonly CiProductStage[] = ["plan", "apply", "record", "check", "drift", "lock", "approval", "control"];
31
31
 
32
- /** The commands a comment may name. Each one needs a job in the pipeline that answers it. */
33
- export type CiProductCommand = "plan" | "apply" | "lock" | "unlock" | "agent";
32
+ /**
33
+ * The commands a comment may name. Each one needs a job in the pipeline that
34
+ * answers it. `action` (#4653) asks for a day-2 action on one member, which
35
+ * runs under a gated request.
36
+ */
37
+ export type CiProductCommand = "plan" | "apply" | "lock" | "unlock" | "agent" | "action";
34
38
 
35
- export const CI_PRODUCT_COMMANDS: readonly CiProductCommand[] = ["plan", "apply", "lock", "unlock", "agent"];
39
+ export const CI_PRODUCT_COMMANDS: readonly CiProductCommand[] = ["plan", "apply", "lock", "unlock", "agent", "action"];
36
40
 
37
41
  /**
38
42
  * What an approval of a product's waves binds to (ruling B, 2026-10-27).
@@ -454,6 +458,12 @@ export type ParsedProductComment =
454
458
  | { kind: "unlock" }
455
459
  /** An ask for the agent: data, never split or run. */
456
460
  | { kind: "agent"; ask: string }
461
+ /**
462
+ * A day-2 action (#4653): `<member> <action>`, such as `apps/orders
463
+ * module.app.action.aws_lambda_invoke.rotate` or a stack's action name.
464
+ * The engine's lexicon checks the action against the member's plan.
465
+ */
466
+ | { kind: "action"; member: string; address: string }
457
467
  | { kind: "refused"; reason: string };
458
468
 
459
469
  /** A member as a comment may name it: path segments, no leading dash, no shell or glob syntax. */
@@ -465,6 +475,12 @@ const MEMBER = /^[A-Za-z0-9_][A-Za-z0-9_.\/-]{0,199}$/;
465
475
  * It never reaches a shell: the job reads the comment from a variable.
466
476
  */
467
477
  const TARGET = /^[A-Za-z0-9_][A-Za-z0-9_.:\/\[\]"*@=+$,-]{0,499}$/;
478
+ /**
479
+ * An action as a comment may name it (#4653): a Terraform action address,
480
+ * module steps and instance keys included, or a configured action's name.
481
+ * No leading dash, no spaces, no shell or glob syntax.
482
+ */
483
+ const ACTION = /^[A-Za-z_][A-Za-z0-9_.\[\]"-]{0,299}$/;
468
484
  /** The longest ask an agent comment may carry. */
469
485
  export const PRODUCT_COMMENT_ASK_MAX = 2000;
470
486
  /** Commands a comment never runs, named in the reply so nobody waits on them. */
@@ -530,6 +546,15 @@ export function parseProductComment(words: CiProductWords, body: unknown, env: R
530
546
  if (/[\u0000-\u0008\u000b-\u001f\u007f]/.test(ask)) return { kind: "refused", reason: "an ask is plain text, with no control characters" };
531
547
  return { kind: "agent", ask };
532
548
  }
549
+ case "action": {
550
+ const usage = `${line} takes a ${words.noun[0]} and an action: \`${prefix} ${typed} <${words.noun[0]}> <action>\``;
551
+ if (parts.length !== 4) return { kind: "refused", reason: usage };
552
+ const member = parts[2]!;
553
+ const address = parts[3]!;
554
+ if (!MEMBER.test(member) || member.split("/").some((s) => s === "" || s === "." || s === "..")) return { kind: "refused", reason: `the ${words.noun[0]} is a name or a path from the repository root` };
555
+ if (!ACTION.test(address)) return { kind: "refused", reason: "an action is an action address or name, with no spaces or shell characters" };
556
+ return { kind: "action", member, address };
557
+ }
533
558
  case "apply": {
534
559
  if (parts.length === 2) return { kind: "apply" };
535
560
  const m = parts.length === 3 ? /^wave-([1-9][0-9]{0,3})$/.exec(parts[2]!) : null;
@@ -563,3 +588,43 @@ export function parseProductComment(words: CiProductWords, body: unknown, env: R
563
588
  }
564
589
  }
565
590
  }
591
+
592
+ /**
593
+ * The variables the generated action job (#4654) hands the product's action
594
+ * verb: the comment that started it, on a comment, and the dispatch's two
595
+ * inputs, on a dispatch. The values reach the job as variables and never as
596
+ * shell text; {@link productActionFromEnv} reads them.
597
+ */
598
+ export const PRODUCT_ACTION_ENV = { comment: "CHANT_ACTION_COMMENT", member: "CHANT_ACTION_MEMBER", action: "CHANT_ACTION" } as const;
599
+
600
+ /** The flag the generated action job passes the product's action verb, so it reads {@link PRODUCT_ACTION_ENV} (#4654). */
601
+ export const PRODUCT_ACTION_EVENT_FLAG = "--from-event";
602
+
603
+ /** What an action job was asked for (#4654): a member and an action, from a comment or a dispatch. */
604
+ export type ProductActionRequest = { kind: "action"; member: string; address: string; from: "comment" | "dispatch" } | { kind: "refused"; reason: string };
605
+
606
+ /**
607
+ * The action an action job was started for (#4654), read from
608
+ * {@link PRODUCT_ACTION_ENV}: a comment, parsed as {@link parseProductComment}
609
+ * parses it, else the dispatch's member and action, checked by the same
610
+ * rules. A product's action verb calls this under
611
+ * {@link PRODUCT_ACTION_EVENT_FLAG}.
612
+ */
613
+ export function productActionFromEnv(words: CiProductWords, env: Record<string, string | undefined>): ProductActionRequest {
614
+ const typed = commandWord(words, "action");
615
+ if (typed === undefined) return { kind: "refused", reason: `${words.product} names no action command, so no job answers one` };
616
+ const comment = env[PRODUCT_ACTION_ENV.comment]?.trim();
617
+ if (comment) {
618
+ const parsed = parseProductComment(words, comment, env);
619
+ if (parsed?.kind === "action") return { ...parsed, from: "comment" };
620
+ if (parsed?.kind === "refused") return parsed;
621
+ return { kind: "refused", reason: `the comment is not \`/${words.product} ${typed} <${words.noun[0]}> <action>\`` };
622
+ }
623
+ const member = env[PRODUCT_ACTION_ENV.member]?.trim() ?? "";
624
+ const action = env[PRODUCT_ACTION_ENV.action]?.trim() ?? "";
625
+ if (member === "" || action === "") return { kind: "refused", reason: `a dispatched action names a ${words.noun[0]} and an action` };
626
+ if (/\s/.test(member) || /\s/.test(action)) return { kind: "refused", reason: `a ${words.noun[0]} and an action are one word each` };
627
+ const parsed = parseProductComment(words, `/${words.product} ${typed} ${member} ${action}`, {});
628
+ if (parsed?.kind === "action") return { ...parsed, from: "dispatch" };
629
+ return parsed?.kind === "refused" ? parsed : { kind: "refused", reason: `a dispatched action names a ${words.noun[0]} and an action` };
630
+ }
package/src/ci-product.ts CHANGED
@@ -40,6 +40,9 @@ export {
40
40
  notifyWaveLabel,
41
41
  overrideLine,
42
42
  parseProductComment,
43
+ productActionFromEnv,
44
+ PRODUCT_ACTION_ENV,
45
+ PRODUCT_ACTION_EVENT_FLAG,
43
46
  productContext,
44
47
  productStatusContext,
45
48
  productWaveGate,
@@ -59,6 +62,7 @@ export {
59
62
  type CiProductWordsInput,
60
63
  type OverrideLineInput,
61
64
  type ParsedProductComment,
65
+ type ProductActionRequest,
62
66
  } from "./ci-product-words";
63
67
  export { driftNotifyFields, productNotifySource, productNotifyWords, productSendOptions, type DriftNotifyInput } from "./notify-product";
64
68
 
@@ -110,7 +114,19 @@ export {
110
114
  type ProductPipelineJobs,
111
115
  type ProductPipelineOptions,
112
116
  } from "./components/product-pipeline";
113
- export { prApplyComment, prCommentLockJobs, prCommentPreviewJob, prLoopSetup, engineSetupLines, withProductBin, type PrCommentLockJob, type PrCommentPreviewJob } from "./components/pr-pipeline";
117
+ export { prActionJob, PR_ACTION_JOB, prApplyComment, prCommentLockJobs, prCommentPreviewJob, prLoopSetup, engineSetupLines, withProductBin, type PrActionJob, type PrActionJobOptions, type PrCommentLockJob, type PrCommentPreviewJob } from "./components/pr-pipeline";
118
+
119
+ /**
120
+ * Day-2 actions in the product pipeline (#4654): the `action` comment
121
+ * command counted as answered by the product's own workflow
122
+ * (`productPipelineJobs(forge, env, { words, actions: true })`), or the
123
+ * pipeline's own action job (`actionJob`, `build --pr-loop --action-job`),
124
+ * which answers the comment and a dispatch with a member and an action
125
+ * input, and runs the product's action verb with `--from-event`. The verb
126
+ * reads what was asked with `productActionFromEnv`. A product
127
+ * feature-detects on this floor.
128
+ */
129
+ export const PRODUCT_ACTIONS_FLOOR = "0.124.58";
114
130
  export { CI_SERVICES_FLOOR, engineServices, githubServices, gitlabServices, serviceWaitLine, servicesJobEnv, type CiService } from "./components/ci-services";
115
131
  export { renderPrNote, prStatusContext, prApproveCommand, prApproveCommands, prApproveTargets, prMergeSentence, type PrMemberDetail } from "./pr-loop";
116
132
  export { upsertPlanNote } from "./pr-post";
@@ -214,6 +230,20 @@ export { parseRequiresList, PR_APPLY_REQUIRES, type PrApplyRequire } from "./pr-
214
230
  */
215
231
  export const PRODUCT_MCP_HOOK_FLOOR = OTLP_EXPORTER_FLOOR;
216
232
  export type { ProductMcpContext, ProductMcpHook } from "./cli/mcp/product-tools";
233
+
234
+ /**
235
+ * The `--propose` tier (chant#4655): `runChantInProcess(["serve", "mcp",
236
+ * "--read-only", "--propose"], words, { mcp: hook })`, or `propose: true` on
237
+ * the hook, serves the read-only server's tools plus the product tools that
238
+ * declare `forgeWrite: true` on their `McpToolContribution`, tools that open
239
+ * a pull request or a comment and do nothing else. A product's own tool and
240
+ * hook types widen from `readOnly: true` to `readOnly: true` or `forgeWrite:
241
+ * true` for these, and its hook gains `propose?: boolean`. Feature-detect on
242
+ * `PRODUCT_MCP_PROPOSE_FLOOR`: on an older chant the read-only server drops a
243
+ * `forgeWrite` tool, and `--propose` is not a flag it parses.
244
+ */
245
+ export { PRODUCT_MCP_PROPOSE_FLOOR, PRODUCT_TOOL_PROPOSE_WORDS } from "./cli/mcp/product-tools";
246
+ export type { McpToolContribution } from "./mcp/types";
217
247
  export {
218
248
  activeOtlp,
219
249
  configureOtlp,
@@ -34,6 +34,8 @@ export interface InitOptions {
34
34
  skipMcp?: boolean;
35
35
  /** Register `chant serve mcp --read-only` in `.mcp.json` (`--mcp-read-only`, chant#4543) */
36
36
  mcpReadOnly?: boolean;
37
+ /** With `mcpReadOnly`, register `chant serve mcp --read-only --propose` (`--propose`, chant#4655) */
38
+ mcpPropose?: boolean;
37
39
  /** Skip interactive install prompt */
38
40
  skipInstall?: boolean;
39
41
  /**
@@ -439,7 +441,7 @@ export async function initCommand(options: InitOptions): Promise<InitResult> {
439
441
  if (!options.skipMcp) {
440
442
  writeIfNotExists(
441
443
  mcpConfigPath(targetDir),
442
- generateMcpConfig(detectPackageManager(targetDir), { readOnly: options.mcpReadOnly }),
444
+ generateMcpConfig(detectPackageManager(targetDir), { readOnly: options.mcpReadOnly, propose: options.mcpPropose }),
443
445
  MCP_CONFIG_FILENAME,
444
446
  createdFiles,
445
447
  warnings,
@@ -54,7 +54,9 @@ async function engineSetupFor(path: string): Promise<string[]> {
54
54
  * `--apply-before-merge` (#4301) writes the apply job that applies an open
55
55
  * pull request before it merges, beside the record job.
56
56
  * `--preview-comment` (#4620) writes the jobs that answer the product's plan
57
- * comment with a preview of the pull request's head.
57
+ * comment with a preview of the pull request's head. `--action-job` (#4654)
58
+ * writes the job that answers the product's action comment and a dispatch
59
+ * with a member and an action.
58
60
  * `--pr-runner`, `--pr-variable`, `--pr-secret` and `--parallelism` (#4625)
59
61
  * set each stage's runner, the plan and apply jobs' variables and passed
60
62
  * secrets, and how many members the plan plans at once.
@@ -82,6 +84,8 @@ function prLoopOption(args: CommandContext["args"], reportUrl: string | undefine
82
84
  ...(args.prEnv ? { prEnvironment: true } : {}),
83
85
  ...(args.applyBeforeMerge ? { applyBeforeMerge: true } : {}),
84
86
  ...(args.previewComment ? { previewComment: true } : {}),
87
+ // #4654: the job that answers the action comment and the action dispatch.
88
+ ...(args.actionJob ? { actionJob: true } : {}),
85
89
  // #4628: the note carries its target commit, and a push marks the open notes stale.
86
90
  ...(args.staleNotes ? { staleNotes: true } : {}),
87
91
  ...(args.requires ? { applyRequires: args.requires } : {}),
@@ -6,6 +6,23 @@ export async function runInit(ctx: CommandContext): Promise<number> {
6
6
 
7
7
  if (args.migrateFrom !== undefined) return runInitFrom(ctx);
8
8
 
9
+ // chant#4655 — --propose registers the read-only server's propose tier, so it needs --mcp-read-only.
10
+ if (args.propose === true && args.mcpReadOnly !== true) {
11
+ console.error(formatError({
12
+ message: "chant init --propose needs --mcp-read-only",
13
+ hint: "Usage: chant init --mcp-read-only --propose (registers chant serve mcp --read-only --propose in .mcp.json)",
14
+ }));
15
+ return 1;
16
+ }
17
+
18
+ // chant#4655 — --dry-run prints the .mcp.json init would register and writes nothing.
19
+ if (args.dryRun === true) {
20
+ const { detectPackageManager, generateMcpConfig } = await import("../mcp-config");
21
+ const target = args.path === "." || args.path === undefined ? process.cwd() : args.path;
22
+ console.log(generateMcpConfig(detectPackageManager(target), { readOnly: args.mcpReadOnly, propose: args.propose }));
23
+ return 0;
24
+ }
25
+
9
26
  if (!args.lexicon) {
10
27
  console.error(formatError({
11
28
  message: "Missing --lexicon flag",
@@ -23,6 +40,7 @@ export async function runInit(ctx: CommandContext): Promise<number> {
23
40
  force: args.force,
24
41
  skipMcp: args.skipMcp,
25
42
  mcpReadOnly: args.mcpReadOnly,
43
+ mcpPropose: args.propose,
26
44
  skipInstall: true,
27
45
  });
28
46
  await printInitResult(result, { skipInstall: false, cwd: args.path });
@@ -0,0 +1,52 @@
1
+ /**
2
+ * `chant lifecycle drift --stack <name>` hands the stack to each lexicon's
3
+ * `readDrift`, which is how `chant workspace drift --stack` reaches a pulumi
4
+ * member's reader project.
5
+ */
6
+ import { mkdtempSync, rmSync } from "node:fs";
7
+ import { tmpdir } from "node:os";
8
+ import { join } from "node:path";
9
+ import { afterEach, describe, expect, test, vi } from "vitest";
10
+ import type { ReadDriftOptions } from "../../drift-record";
11
+ import { parseArgs } from "../parse-args";
12
+ import type { CommandContext } from "../registry";
13
+ import { runLifecycleDrift } from "./lifecycle-drift";
14
+
15
+ const dirs: string[] = [];
16
+ afterEach(() => {
17
+ vi.restoreAllMocks();
18
+ for (const d of dirs.splice(0)) rmSync(d, { recursive: true, force: true });
19
+ });
20
+
21
+ async function run(argv: string[], answer: (o: ReadDriftOptions) => unknown): Promise<{ seen: ReadDriftOptions[]; code: number; out: string[] }> {
22
+ const dir = mkdtempSync(join(tmpdir(), "lifecycle-drift-"));
23
+ dirs.push(dir);
24
+ vi.spyOn(process, "cwd").mockReturnValue(dir);
25
+ const out: string[] = [];
26
+ vi.spyOn(console, "log").mockImplementation((line: string) => void out.push(line));
27
+ vi.spyOn(process.stdout, "write").mockImplementation((chunk: string | Uint8Array) => (out.push(String(chunk)), true));
28
+ const seen: ReadDriftOptions[] = [];
29
+ const plugin = { name: "fake", readDrift: async (o: ReadDriftOptions) => (seen.push(o), answer(o)) };
30
+ const code = await runLifecycleDrift({ args: parseArgs(argv), plugins: [plugin] } as unknown as CommandContext);
31
+ return { seen, code, out };
32
+ }
33
+
34
+ describe("chant lifecycle drift --stack", () => {
35
+ test("the lexicon's readDrift gets the stack", async () => {
36
+ const { seen, code } = await run(["lifecycle", "drift", ".", "--member", "shop", "--stack", "prod-eu"], () => ({ lines: [] }));
37
+ expect(code).toBe(0);
38
+ expect(seen).toHaveLength(1);
39
+ expect(seen[0]).toMatchObject({ member: "shop", stack: "prod-eu" });
40
+ });
41
+
42
+ test("without it the option is absent", async () => {
43
+ const { seen } = await run(["lifecycle", "drift", ".", "--member", "shop"], () => ({ lines: [] }));
44
+ expect(seen[0]).not.toHaveProperty("stack");
45
+ });
46
+
47
+ test("a refusal is the one stdout line, exit 1", async () => {
48
+ const { code, out } = await run(["lifecycle", "drift", ".", "--member", "shop", "--stack", "x"], () => ({ refused: { code: "no-drift-read", message: "no export for stack x" } }));
49
+ expect(code).toBe(1);
50
+ expect(JSON.parse(out.join("")).refused).toEqual({ code: "no-drift-read", message: "fake: no export for stack x" });
51
+ });
52
+ });
@@ -12,7 +12,8 @@
12
12
  * never imports a lexicon to read drift.
13
13
  *
14
14
  * `--member` names the workspace member the records are for; it defaults to
15
- * the project directory's name. A lexicon that refuses the read (a read its
15
+ * the project directory's name. `--stack` names the stack to read, for a
16
+ * lexicon whose store holds one export per stack (pulumi). A lexicon that refuses the read (a read its
16
17
  * engine has not got, or one resource on an engine that cannot read one on
17
18
  * its own) makes the command print `{"refused": {code, message}}` as its
18
19
  * only stdout line and exit 3, so the workspace command can name the
@@ -33,7 +34,7 @@ import type { CommandContext } from "../registry";
33
34
  */
34
35
  export const DRIFT_REFUSED_EXIT = CHANT_EXIT.failed;
35
36
 
36
- const USAGE = "chant lifecycle drift [--member <name>] [--read <state|plan|refresh|live-read|ownership>] [--resource <addr>]";
37
+ const USAGE = "chant lifecycle drift [--member <name>] [--read <state|plan|refresh|live-read|ownership>] [--resource <addr>] [--stack <name>]";
37
38
 
38
39
  function refuse(code: ReadDriftRefusalCode, message: string): number {
39
40
  console.log(JSON.stringify({ refused: { code, message } }));
@@ -63,6 +64,7 @@ export async function runLifecycleDrift(ctx: CommandContext): Promise<number> {
63
64
  config: config as Record<string, unknown>,
64
65
  ...(read !== undefined ? { read: read as DriftRead } : {}),
65
66
  ...(args.resource !== undefined ? { resource: args.resource } : {}),
67
+ ...(args.carveStack !== undefined ? { stack: args.carveStack } : {}),
66
68
  observedAt,
67
69
  });
68
70
  if ("refused" in answer) return refuse(answer.refused.code, `${plugin.name}: ${answer.refused.message}`);
@@ -9,6 +9,7 @@
9
9
  * chant lock --list [--gate <name>] [--json]
10
10
  * chant lock --alive <run>
11
11
  * chant unlock --pr <n> [<target>...] [--gate <name>] [--json]
12
+ * chant unlock --run <id> [--gate <name>] [--json]
12
13
  * ```
13
14
  *
14
15
  * The targets are names: the components `chant components pr-plan` selects,
@@ -35,6 +36,11 @@
35
36
  * finished, `alive` while it runs or when nobody can say. The lock tag's
36
37
  * shell asks it before taking a lease over.
37
38
  *
39
+ * `chant unlock --run <id>` (#4660) frees every row run `<id>` holds on the
40
+ * gate and drops its place in the queue, for a hold whose run is gone and
41
+ * that no beat or forge answer has freed. `--beat <run> --parent <pid>` is
42
+ * the heartbeat side process of a hold (../../lifecycle/lock-beat.ts).
43
+ *
38
44
  * `--forge` reads which holders are still open, so a lock whose pull
39
45
  * request merged or closed is taken over, and, with `--head`, posts the
40
46
  * `chant/lock` status on that commit. Without it every lock counts as held.
@@ -138,6 +144,22 @@ export async function runLock(ctx: CommandContext): Promise<number> {
138
144
  return 0;
139
145
  }
140
146
 
147
+ if (args.beatRun !== undefined) {
148
+ if (args.parentPid === undefined) return fail("--beat needs the process it beats for: --beat <run> --parent <pid>");
149
+ const { beatLockRows, lockBeatSeconds } = await import("../../lifecycle/resource-lock");
150
+ const { runBeatLoop } = await import("../../lifecycle/lock-beat");
151
+ const run = args.beatRun;
152
+ await runBeatLoop({
153
+ gate,
154
+ run,
155
+ parent: args.parentPid,
156
+ intervalMs: lockBeatSeconds(process.env) * 1000,
157
+ beat: (at) => beatLockRows(gate, run, at),
158
+ log: (line) => console.error(line),
159
+ });
160
+ return 0;
161
+ }
162
+
141
163
  if (args.list) {
142
164
  if (targetsOf(ctx).length > 0 || args.pr !== undefined) return fail("--list prints every lock; drop the targets and --pr");
143
165
  let file;
@@ -168,7 +190,7 @@ export async function runLock(ctx: CommandContext): Promise<number> {
168
190
  if (rows.length === 0) console.error(formatInfo(`no target locks on ${gate}`));
169
191
  for (const [target, l] of rows) console.log(`${target}\tpull request ${l.pr}\t${l.stage}\t${l.by}\t${l.at}`);
170
192
  if (leased.length === 0) console.error(formatInfo(`no apply rows held on ${gate}`));
171
- for (const { key, holder } of leased) console.log(`${key}\trun ${holder.run}\t${holder.at}${holder.url ? `\t${holder.url}` : ""}`);
193
+ for (const { key, holder } of leased) console.log(`${key}\trun ${holder.run}\t${holder.at}${holder.url ? `\t${holder.url}` : ""}${holder.beat ? `\tbeat ${holder.beat}` : ""}`);
172
194
  return 0;
173
195
  }
174
196
 
@@ -244,7 +266,24 @@ export async function runUnlock(ctx: CommandContext): Promise<number> {
244
266
  const { args } = ctx;
245
267
  const gate = gateOf(ctx);
246
268
  if (typeof gate !== "string") return fail(gate.error);
247
- if (args.pr === undefined) return fail("chant unlock needs the pull or merge request whose locks it releases: --pr <n>");
269
+ if (args.unlockRun !== undefined) {
270
+ if (args.pr !== undefined || targetsOf(ctx).length > 0) return fail("--run frees the rows of one run; drop --pr and the targets");
271
+ const { clearRunLockRows } = await import("../../lifecycle/resource-lock");
272
+ let cleared;
273
+ try {
274
+ cleared = await clearRunLockRows(gate, args.unlockRun);
275
+ } catch (err) {
276
+ return fail(`could not clear run ${args.unlockRun} from ${gate}: ${err instanceof Error ? err.message : String(err)}`);
277
+ }
278
+ if (args.json) {
279
+ console.log(JSON.stringify({ gate, run: args.unlockRun, released: cleared.released, waited: cleared.waited, pushed: cleared.pushed }, null, 2));
280
+ return 0;
281
+ }
282
+ if (cleared.released.length === 0 && !cleared.waited) console.error(formatInfo(`run ${args.unlockRun} holds no row and waits for none on ${gate}`));
283
+ else console.error(formatSuccess(`freed ${cleared.released.length > 0 ? cleared.released.join(", ") : "no row"}${cleared.waited ? " and took run " + args.unlockRun + " out of the queue" : ""} on ${gate}`));
284
+ return 0;
285
+ }
286
+ if (args.pr === undefined) return fail("chant unlock needs the pull or merge request whose locks it releases: --pr <n>, or the run whose rows it frees: --run <id>");
248
287
  const targets = targetsOf(ctx);
249
288
  let result;
250
289
  try {
@@ -10,6 +10,14 @@ export async function runServeLsp(ctx: CommandContext): Promise<number> {
10
10
  }
11
11
 
12
12
  export async function runServeMcp(ctx: CommandContext): Promise<number> {
13
+ // chant#4655 — --propose is a tier of the read-only server, never of the ordinary one.
14
+ if (ctx.args.propose === true && ctx.args.readOnly !== true) {
15
+ console.error(formatError({
16
+ message: "chant serve mcp --propose needs --read-only",
17
+ hint: "Usage: chant serve mcp --read-only --propose (serves the read tools and a product's tools that open pull requests)",
18
+ }));
19
+ return 1;
20
+ }
13
21
  const { McpServer } = await import("../mcp/server");
14
22
  // #2700 — main() hands over no plugins only at a workspace root with no
15
23
  // lexicon of its own (anywhere else it refuses first). There the lexicons
@@ -29,6 +37,7 @@ export async function runServeMcp(ctx: CommandContext): Promise<number> {
29
37
  instructions,
30
38
  workspace: { cwd: process.cwd() },
31
39
  ...(ctx.args.readOnly === true ? { readOnly: true } : {}),
40
+ ...(ctx.args.propose === true ? { propose: true } : {}),
32
41
  ...(product ? { product } : {}),
33
42
  });
34
43
  await server.start();
package/src/cli/main.ts CHANGED
@@ -19,6 +19,7 @@ import { dispatchCommandGroup, collectCommandGroups, formatCommandGroupsHelp, ty
19
19
  import type { LexiconPlugin } from "../lexicon";
20
20
  import { parseArgs } from "./parse-args";
21
21
  import { flushAndExit, waitForStreamDrain } from "./flush";
22
+ import { setOwnChantCommand } from "../lifecycle/lock-beat";
22
23
 
23
24
  export { parseArgs, waitForStreamDrain };
24
25
 
@@ -675,7 +676,8 @@ Ops:
675
676
  posts chant/lock on --head. Exits 3 when another open
676
677
  pull request holds a target. --list prints the locks
677
678
  unlock [<target>...] Release the locks a pull request holds (--pr <n>,
678
- --gate <name>, --json)
679
+ --gate <name>, --json). --run <id> frees the rows a
680
+ run holds or waits for on the gate instead
679
681
  graph Show Op dependency graph (--stacks for cross-stack order,
680
682
  --format ir|mermaid|dot|layout for the lint-gated graph IR,
681
683
  a Mermaid flowchart, Graphviz DOT, or node positions;
@@ -1362,7 +1364,9 @@ Local:
1362
1364
  Servers:
1363
1365
  serve lsp Start the LSP server (stdio)
1364
1366
  serve mcp Start the MCP server (stdio); --read-only serves only
1365
- the tools that read (ledger, graph, runs) and run nothing
1367
+ the tools that read (ledger, graph, runs) and run nothing;
1368
+ --read-only --propose also serves a product's tools that
1369
+ open pull requests and comments, and nothing that approves
1366
1370
 
1367
1371
  Project:
1368
1372
  update (alias: sync) Sync lexicon types into .chant/types/ (does not install
@@ -1389,7 +1393,9 @@ Options:
1389
1393
  records its lineage in .chant/workspace.lock.json
1390
1394
  --skill <name> Init: install only this skill from the lexicon
1391
1395
  --skip-mcp Init: scaffold without writing the project's .mcp.json
1392
- --mcp-read-only Init: register \`chant serve mcp --read-only\` in .mcp.json
1396
+ --mcp-read-only Init: register \`chant serve mcp --read-only\` in .mcp.json;
1397
+ with --propose, \`chant serve mcp --read-only --propose\`.
1398
+ Init --dry-run prints that .mcp.json and writes nothing
1393
1399
  --fix Auto-fix fixable issues (lint command)
1394
1400
  --force Force overwrite existing files (import command)
1395
1401
  -w, --watch Watch for changes and rebuild/re-lint (build, lint)
@@ -2198,6 +2204,8 @@ async function main(): Promise<void> {
2198
2204
  // whole CLI through the npm .bin shim / a symlinked checkout).
2199
2205
  const isMain = isEntryPoint(process.argv[1], import.meta.url);
2200
2206
  if (isMain) {
2207
+ // #4660: a row hold starts its heartbeat as this chant, run again.
2208
+ setOwnChantCommand([process.execPath, ...process.execArgv, process.argv[1]!]);
2201
2209
  main().catch(async (err) => {
2202
2210
  const verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
2203
2211
  // #4116: a failure to import a package the project has not installed is named as such first.