agentplane 0.3.2 → 0.3.4

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 (205) hide show
  1. package/assets/AGENTS.md +4 -4
  2. package/assets/agents/CODER.json +14 -10
  3. package/assets/agents/CREATOR.json +8 -6
  4. package/assets/agents/DOCS.json +9 -6
  5. package/assets/agents/INTEGRATOR.json +9 -6
  6. package/assets/agents/ORCHESTRATOR.json +8 -6
  7. package/assets/agents/PLANNER.json +8 -5
  8. package/assets/agents/REDMINE.json +6 -3
  9. package/assets/agents/REVIEWER.json +8 -6
  10. package/assets/agents/TESTER.json +8 -4
  11. package/assets/agents/UPDATER.json +6 -4
  12. package/assets/agents/UPGRADER.json +7 -6
  13. package/assets/policy/dod.code.md +2 -2
  14. package/assets/policy/dod.core.md +16 -2
  15. package/assets/policy/dod.docs.md +2 -2
  16. package/assets/policy/incidents.md +44 -1
  17. package/assets/policy/workflow.direct.md +8 -4
  18. package/bin/agentplane.js +59 -9
  19. package/bin/dist-guard.js +78 -10
  20. package/bin/runtime-context.d.ts +3 -0
  21. package/bin/runtime-context.js +13 -0
  22. package/bin/runtime-watch.d.ts +26 -0
  23. package/bin/runtime-watch.js +116 -0
  24. package/bin/stale-dist-policy.d.ts +6 -0
  25. package/bin/stale-dist-policy.js +44 -0
  26. package/dist/.build-manifest.json +2485 -5
  27. package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
  28. package/dist/backends/task-backend/local-backend.js +9 -12
  29. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  30. package/dist/backends/task-backend/redmine-backend.js +23 -18
  31. package/dist/backends/task-backend/shared/constants.d.ts +1 -0
  32. package/dist/backends/task-backend/shared/constants.d.ts.map +1 -1
  33. package/dist/backends/task-backend/shared/constants.js +1 -0
  34. package/dist/backends/task-backend/shared/doc.d.ts +1 -0
  35. package/dist/backends/task-backend/shared/doc.d.ts.map +1 -1
  36. package/dist/backends/task-backend/shared/doc.js +4 -1
  37. package/dist/backends/task-backend/shared/export.js +3 -3
  38. package/dist/cli/bootstrap-guide.d.ts +2 -3
  39. package/dist/cli/bootstrap-guide.d.ts.map +1 -1
  40. package/dist/cli/bootstrap-guide.js +16 -35
  41. package/dist/cli/command-guide.d.ts +14 -1
  42. package/dist/cli/command-guide.d.ts.map +1 -1
  43. package/dist/cli/command-guide.js +71 -47
  44. package/dist/cli/run-cli/catalog.d.ts +7 -0
  45. package/dist/cli/run-cli/catalog.d.ts.map +1 -0
  46. package/dist/cli/run-cli/catalog.js +22 -0
  47. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  48. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  49. package/dist/cli/run-cli/command-catalog.js +11 -0
  50. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  51. package/dist/cli/run-cli/commands/core.js +37 -29
  52. package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
  53. package/dist/cli/run-cli/commands/init/write-config.js +2 -0
  54. package/dist/cli/run-cli/commands/init/write-workflow.d.ts.map +1 -1
  55. package/dist/cli/run-cli/commands/init/write-workflow.js +6 -55
  56. package/dist/cli/run-cli/commands/init.js +5 -14
  57. package/dist/cli/run-cli/error-guidance.d.ts +9 -0
  58. package/dist/cli/run-cli/error-guidance.d.ts.map +1 -0
  59. package/dist/cli/run-cli/error-guidance.js +180 -0
  60. package/dist/cli/run-cli/globals.d.ts +22 -0
  61. package/dist/cli/run-cli/globals.d.ts.map +1 -0
  62. package/dist/cli/run-cli/globals.js +197 -0
  63. package/dist/cli/run-cli/update-warning.d.ts +6 -0
  64. package/dist/cli/run-cli/update-warning.d.ts.map +1 -0
  65. package/dist/cli/run-cli/update-warning.js +64 -0
  66. package/dist/cli/run-cli.d.ts.map +1 -1
  67. package/dist/cli/run-cli.js +5 -476
  68. package/dist/cli/spec/docs-render.d.ts.map +1 -1
  69. package/dist/cli/spec/docs-render.js +14 -1
  70. package/dist/commands/doctor/archive.d.ts +4 -0
  71. package/dist/commands/doctor/archive.d.ts.map +1 -0
  72. package/dist/commands/doctor/archive.js +211 -0
  73. package/dist/commands/doctor/fixes.d.ts +9 -0
  74. package/dist/commands/doctor/fixes.d.ts.map +1 -0
  75. package/dist/commands/doctor/fixes.js +40 -0
  76. package/dist/commands/doctor/layering.d.ts +2 -0
  77. package/dist/commands/doctor/layering.d.ts.map +1 -0
  78. package/dist/commands/doctor/layering.js +87 -0
  79. package/dist/commands/doctor/runtime.d.ts +4 -0
  80. package/dist/commands/doctor/runtime.d.ts.map +1 -0
  81. package/dist/commands/doctor/runtime.js +56 -0
  82. package/dist/commands/doctor/workflow.d.ts +6 -0
  83. package/dist/commands/doctor/workflow.d.ts.map +1 -0
  84. package/dist/commands/doctor/workflow.js +62 -0
  85. package/dist/commands/doctor/workspace.d.ts +2 -0
  86. package/dist/commands/doctor/workspace.d.ts.map +1 -0
  87. package/dist/commands/doctor/workspace.js +165 -0
  88. package/dist/commands/doctor.run.d.ts.map +1 -1
  89. package/dist/commands/doctor.run.js +16 -342
  90. package/dist/commands/doctor.spec.d.ts +1 -0
  91. package/dist/commands/doctor.spec.d.ts.map +1 -1
  92. package/dist/commands/doctor.spec.js +15 -1
  93. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  94. package/dist/commands/guard/impl/commands.js +19 -0
  95. package/dist/commands/release/apply.command.d.ts +2 -8
  96. package/dist/commands/release/apply.command.d.ts.map +1 -1
  97. package/dist/commands/release/apply.command.js +158 -387
  98. package/dist/commands/release/apply.mutation.d.ts +7 -0
  99. package/dist/commands/release/apply.mutation.d.ts.map +1 -0
  100. package/dist/commands/release/apply.mutation.js +107 -0
  101. package/dist/commands/release/apply.preflight.d.ts +25 -0
  102. package/dist/commands/release/apply.preflight.d.ts.map +1 -0
  103. package/dist/commands/release/apply.preflight.js +338 -0
  104. package/dist/commands/release/apply.reporting.d.ts +4 -0
  105. package/dist/commands/release/apply.reporting.d.ts.map +1 -0
  106. package/dist/commands/release/apply.reporting.js +24 -0
  107. package/dist/commands/release/apply.types.d.ts +46 -0
  108. package/dist/commands/release/apply.types.d.ts.map +1 -0
  109. package/dist/commands/release/apply.types.js +1 -0
  110. package/dist/commands/runtime.command.d.ts +28 -0
  111. package/dist/commands/runtime.command.d.ts.map +1 -0
  112. package/dist/commands/runtime.command.js +169 -0
  113. package/dist/commands/shared/task-store.d.ts.map +1 -1
  114. package/dist/commands/shared/task-store.js +7 -3
  115. package/dist/commands/task/add.d.ts.map +1 -1
  116. package/dist/commands/task/add.js +3 -33
  117. package/dist/commands/task/block.d.ts.map +1 -1
  118. package/dist/commands/task/block.js +2 -2
  119. package/dist/commands/task/close-duplicate.d.ts.map +1 -1
  120. package/dist/commands/task/close-duplicate.js +2 -2
  121. package/dist/commands/task/close-noop.d.ts.map +1 -1
  122. package/dist/commands/task/close-noop.js +2 -2
  123. package/dist/commands/task/comment.js +2 -2
  124. package/dist/commands/task/derive.d.ts.map +1 -1
  125. package/dist/commands/task/derive.js +3 -3
  126. package/dist/commands/task/doc-template.d.ts +10 -0
  127. package/dist/commands/task/doc-template.d.ts.map +1 -0
  128. package/dist/commands/task/doc-template.js +104 -0
  129. package/dist/commands/task/doc.d.ts.map +1 -1
  130. package/dist/commands/task/doc.js +36 -1
  131. package/dist/commands/task/finish.d.ts.map +1 -1
  132. package/dist/commands/task/finish.js +7 -4
  133. package/dist/commands/task/migrate-doc.command.d.ts.map +1 -1
  134. package/dist/commands/task/migrate-doc.command.js +5 -1
  135. package/dist/commands/task/migrate-doc.d.ts.map +1 -1
  136. package/dist/commands/task/migrate-doc.js +136 -2
  137. package/dist/commands/task/new.d.ts.map +1 -1
  138. package/dist/commands/task/new.js +4 -110
  139. package/dist/commands/task/new.spec.js +3 -3
  140. package/dist/commands/task/plan.d.ts.map +1 -1
  141. package/dist/commands/task/plan.js +5 -4
  142. package/dist/commands/task/scaffold.d.ts.map +1 -1
  143. package/dist/commands/task/scaffold.js +7 -52
  144. package/dist/commands/task/set-status.d.ts.map +1 -1
  145. package/dist/commands/task/set-status.js +2 -2
  146. package/dist/commands/task/shared/dependencies.d.ts +15 -0
  147. package/dist/commands/task/shared/dependencies.d.ts.map +1 -0
  148. package/dist/commands/task/shared/dependencies.js +143 -0
  149. package/dist/commands/task/shared/docs.d.ts +21 -0
  150. package/dist/commands/task/shared/docs.d.ts.map +1 -0
  151. package/dist/commands/task/shared/docs.js +121 -0
  152. package/dist/commands/task/shared/listing.d.ts +20 -0
  153. package/dist/commands/task/shared/listing.d.ts.map +1 -0
  154. package/dist/commands/task/shared/listing.js +127 -0
  155. package/dist/commands/task/shared/tags.d.ts +24 -0
  156. package/dist/commands/task/shared/tags.d.ts.map +1 -0
  157. package/dist/commands/task/shared/tags.js +177 -0
  158. package/dist/commands/task/shared/transitions.d.ts +42 -0
  159. package/dist/commands/task/shared/transitions.d.ts.map +1 -0
  160. package/dist/commands/task/shared/transitions.js +175 -0
  161. package/dist/commands/task/shared.d.ts +5 -106
  162. package/dist/commands/task/shared.d.ts.map +1 -1
  163. package/dist/commands/task/shared.js +5 -681
  164. package/dist/commands/task/start.d.ts.map +1 -1
  165. package/dist/commands/task/start.js +7 -5
  166. package/dist/commands/task/verify-record.d.ts.map +1 -1
  167. package/dist/commands/task/verify-record.js +9 -25
  168. package/dist/commands/task/verify-show.command.d.ts.map +1 -1
  169. package/dist/commands/task/verify-show.command.js +5 -1
  170. package/dist/commands/upgrade/apply.d.ts +44 -0
  171. package/dist/commands/upgrade/apply.d.ts.map +1 -0
  172. package/dist/commands/upgrade/apply.js +180 -0
  173. package/dist/commands/upgrade/report.d.ts +21 -0
  174. package/dist/commands/upgrade/report.d.ts.map +1 -0
  175. package/dist/commands/upgrade/report.js +81 -0
  176. package/dist/commands/upgrade/source.d.ts +35 -0
  177. package/dist/commands/upgrade/source.d.ts.map +1 -0
  178. package/dist/commands/upgrade/source.js +109 -0
  179. package/dist/commands/upgrade/types.d.ts +31 -0
  180. package/dist/commands/upgrade/types.d.ts.map +1 -0
  181. package/dist/commands/upgrade/types.js +1 -0
  182. package/dist/commands/upgrade.d.ts +1 -35
  183. package/dist/commands/upgrade.d.ts.map +1 -1
  184. package/dist/commands/upgrade.js +68 -332
  185. package/dist/commands/workflow-build.command.d.ts.map +1 -1
  186. package/dist/commands/workflow-build.command.js +9 -15
  187. package/dist/shared/diagnostics.d.ts +23 -0
  188. package/dist/shared/diagnostics.d.ts.map +1 -0
  189. package/dist/shared/diagnostics.js +57 -0
  190. package/dist/shared/errors.d.ts +2 -0
  191. package/dist/shared/errors.d.ts.map +1 -1
  192. package/dist/shared/errors.js +2 -0
  193. package/dist/shared/repo-cli-version.d.ts +13 -0
  194. package/dist/shared/repo-cli-version.d.ts.map +1 -0
  195. package/dist/shared/repo-cli-version.js +63 -0
  196. package/dist/shared/runtime-source.d.ts +33 -0
  197. package/dist/shared/runtime-source.d.ts.map +1 -0
  198. package/dist/shared/runtime-source.js +156 -0
  199. package/dist/shared/version-compare.d.ts +7 -0
  200. package/dist/shared/version-compare.d.ts.map +1 -0
  201. package/dist/shared/version-compare.js +30 -0
  202. package/dist/shared/workflow-artifacts.d.ts +37 -0
  203. package/dist/shared/workflow-artifacts.d.ts.map +1 -0
  204. package/dist/shared/workflow-artifacts.js +97 -0
  205. package/package.json +2 -2
@@ -1,12 +1,8 @@
1
- import os from "node:os";
2
- import path from "node:path";
3
1
  import { loadConfig, resolveProject, } from "@agentplaneorg/core";
4
2
  import { mapCoreError } from "./error-map.js";
5
3
  import { exitCodeForError } from "./exit-codes.js";
6
- import { warnMessage } from "./output.js";
7
- import { fetchLatestNpmVersion, readUpdateCheckCache, resolveUpdateCheckCachePath, shouldCheckNow, UPDATE_CHECK_SCHEMA_VERSION, UPDATE_CHECK_TIMEOUT_MS, UPDATE_CHECK_TTL_MS, writeUpdateCheckCache, } from "./update-check.js";
8
4
  import { loadDotEnv } from "../shared/env.js";
9
- import { CliError, formatJsonError } from "../shared/errors.js";
5
+ import { CliError } from "../shared/errors.js";
10
6
  import { resolveContext } from "../usecases/context/resolve-context.js";
11
7
  import { getVersion } from "../meta/version.js";
12
8
  import { getApprovalRequirements } from "../commands/shared/approval-requirements.js";
@@ -14,478 +10,11 @@ import { parseCommandArgv } from "./spec/parse.js";
14
10
  import { helpSpec } from "./spec/help.js";
15
11
  import { usageError } from "./spec/errors.js";
16
12
  import { suggestOne } from "./spec/suggest.js";
17
- import { COMMANDS } from "./run-cli/command-catalog.js";
18
- import { getReasonCodeMeta } from "./reason-codes.js";
19
- const GLOBAL_FLAGS = [
20
- { key: "help", forms: ["--help", "-h"], takesValue: false, scoped: false },
21
- { key: "version", forms: ["--version", "-v"], takesValue: false, scoped: false },
22
- { key: "noUpdateCheck", forms: ["--no-update-check"], takesValue: false, scoped: false },
23
- { key: "allowNetwork", forms: ["--allow-network"], takesValue: false, scoped: true },
24
- { key: "jsonErrors", forms: ["--json-errors"], takesValue: false, scoped: true },
25
- { key: "outputMode", forms: ["--output"], takesValue: true, scoped: false },
26
- { key: "root", forms: ["--root"], takesValue: true, scoped: false },
27
- ];
28
- const GLOBAL_FLAG_FORMS = new Map(GLOBAL_FLAGS.flatMap((def) => def.forms.map((form) => [form, def])));
13
+ import { matchCommandCatalog } from "./run-cli/catalog.js";
14
+ import { prescanJsonErrors, parseGlobalArgs, resolveOutputMode, runWithOutputMode, } from "./run-cli/globals.js";
15
+ import { writeError } from "./run-cli/error-guidance.js";
16
+ import { maybeWarnOnUpdate } from "./run-cli/update-warning.js";
29
17
  const HELP_TAIL_OPTIONS = new Set(["--compact", "--json"]);
30
- function prescanJsonErrors(argv) {
31
- // If parseGlobalArgs throws (e.g. missing --root value), we still want to honor
32
- // `--json-errors` in the "scoped global" zone (before the command id).
33
- let hasRest = false;
34
- for (let i = 0; i < argv.length; i++) {
35
- const arg = argv[i];
36
- if (!arg)
37
- continue;
38
- const def = GLOBAL_FLAG_FORMS.get(arg);
39
- if (!def) {
40
- // First non-global token is treated as the start of the command id.
41
- hasRest = true;
42
- break;
43
- }
44
- if (def.key === "jsonErrors" && !hasRest)
45
- return true;
46
- if (def.takesValue) {
47
- // Skip the value if present; do not throw on missing value here.
48
- i++;
49
- }
50
- }
51
- return false;
52
- }
53
- function parseGlobalArgs(argv) {
54
- let help = false;
55
- let version = false;
56
- let noUpdateCheck = false;
57
- let jsonErrors = false;
58
- let root;
59
- let allowNetwork = false;
60
- let outputMode;
61
- const rest = [];
62
- for (let i = 0; i < argv.length; i++) {
63
- const arg = argv[i];
64
- if (!arg)
65
- continue;
66
- const def = GLOBAL_FLAG_FORMS.get(arg);
67
- if (!def) {
68
- rest.push(arg);
69
- continue;
70
- }
71
- // Scoped globals are only recognized before the command id token.
72
- if (def.scoped && rest.length > 0) {
73
- rest.push(arg);
74
- continue;
75
- }
76
- switch (def.key) {
77
- case "help": {
78
- help = true;
79
- break;
80
- }
81
- case "version": {
82
- version = true;
83
- break;
84
- }
85
- case "noUpdateCheck": {
86
- noUpdateCheck = true;
87
- break;
88
- }
89
- case "allowNetwork": {
90
- allowNetwork = true;
91
- break;
92
- }
93
- case "jsonErrors": {
94
- jsonErrors = true;
95
- break;
96
- }
97
- case "root": {
98
- const next = argv[i + 1];
99
- if (!next) {
100
- throw new CliError({
101
- exitCode: 2,
102
- code: "E_USAGE",
103
- message: "Missing value after --root (expected repository path)",
104
- });
105
- }
106
- root = next;
107
- i++;
108
- break;
109
- }
110
- case "outputMode": {
111
- const next = argv[i + 1];
112
- if (!next) {
113
- throw new CliError({
114
- exitCode: 2,
115
- code: "E_USAGE",
116
- message: "Missing value after --output (expected text|json)",
117
- });
118
- }
119
- const normalized = next.trim().toLowerCase();
120
- if (normalized !== "text" && normalized !== "json") {
121
- throw new CliError({
122
- exitCode: 2,
123
- code: "E_USAGE",
124
- message: `Invalid value for --output: ${next} (expected text|json)`,
125
- });
126
- }
127
- outputMode = normalized;
128
- i++;
129
- break;
130
- }
131
- default: {
132
- // Exhaustive by construction; keep a defensive fallback.
133
- rest.push(arg);
134
- break;
135
- }
136
- }
137
- }
138
- return {
139
- globals: { help, version, noUpdateCheck, root, jsonErrors, allowNetwork, outputMode },
140
- rest,
141
- };
142
- }
143
- const OUTPUT_MODE_ENV = "AGENTPLANE_OUTPUT";
144
- function resolveOutputMode(modeFromFlag) {
145
- if (modeFromFlag)
146
- return modeFromFlag;
147
- const fromEnv = process.env[OUTPUT_MODE_ENV]?.trim().toLowerCase();
148
- if (!fromEnv || fromEnv === "text")
149
- return "text";
150
- if (fromEnv === "json")
151
- return "json";
152
- throw new CliError({
153
- exitCode: 2,
154
- code: "E_USAGE",
155
- message: `Invalid ${OUTPUT_MODE_ENV}: ${fromEnv} (expected text|json)`,
156
- });
157
- }
158
- function chunkToString(chunk, encoding) {
159
- if (typeof chunk === "string")
160
- return chunk;
161
- if (chunk instanceof Uint8Array)
162
- return Buffer.from(chunk).toString(encoding);
163
- return String(chunk);
164
- }
165
- async function runWithOutputMode(opts) {
166
- if (opts.mode === "text")
167
- return await opts.run();
168
- const stdoutWrite = process.stdout.write.bind(process.stdout);
169
- const stderrWrite = process.stderr.write.bind(process.stderr);
170
- let stdout = "";
171
- let stderr = "";
172
- process.stdout.write = ((chunk, ...rest) => {
173
- const encoding = typeof rest[0] === "string" ? rest[0] : undefined;
174
- stdout += chunkToString(chunk, encoding);
175
- const callback = rest.find((item) => typeof item === "function");
176
- callback?.(null);
177
- return true;
178
- });
179
- process.stderr.write = ((chunk, ...rest) => {
180
- const encoding = typeof rest[0] === "string" ? rest[0] : undefined;
181
- stderr += chunkToString(chunk, encoding);
182
- const callback = rest.find((item) => typeof item === "function");
183
- callback?.(null);
184
- return true;
185
- });
186
- try {
187
- const exitCode = await opts.run();
188
- let parsed;
189
- const trimmedStdout = stdout.trim();
190
- if (trimmedStdout.length > 0) {
191
- try {
192
- parsed = JSON.parse(trimmedStdout);
193
- }
194
- catch {
195
- parsed = undefined;
196
- }
197
- }
198
- const payload = {
199
- schema_version: 1,
200
- mode: "agent_json_v1",
201
- command: opts.command,
202
- ok: exitCode === 0,
203
- exit_code: exitCode,
204
- stdout: trimmedStdout,
205
- stderr: stderr.trim(),
206
- };
207
- if (parsed !== undefined) {
208
- payload.data = parsed;
209
- }
210
- stdoutWrite(`${JSON.stringify(payload, null, 2)}\n`);
211
- return exitCode;
212
- }
213
- finally {
214
- process.stdout.write = stdoutWrite;
215
- process.stderr.write = stderrWrite;
216
- }
217
- }
218
- function matchCommandCatalog(tokens) {
219
- let best = null;
220
- for (const entry of COMMANDS) {
221
- const id = entry.spec.id;
222
- if (tokens.length < id.length)
223
- continue;
224
- let ok = true;
225
- for (const [i, seg] of id.entries()) {
226
- if (tokens[i] !== seg) {
227
- ok = false;
228
- break;
229
- }
230
- }
231
- if (!ok)
232
- continue;
233
- if (!best || id.length > best.consumed) {
234
- best = { entry, consumed: id.length };
235
- }
236
- }
237
- return best;
238
- }
239
- function writeError(err, jsonErrors) {
240
- const guidance = resolveErrorGuidance(err);
241
- const contextReasonCode = typeof err.context?.reason_code === "string" ? String(err.context.reason_code) : undefined;
242
- const reasonCode = contextReasonCode ?? guidance.nextAction?.reasonCode;
243
- const reasonDecode = getReasonCodeMeta(reasonCode);
244
- if (jsonErrors) {
245
- process.stdout.write(`${formatJsonError(err, {
246
- hint: guidance.hint,
247
- nextAction: guidance.nextAction,
248
- reasonDecode,
249
- })}\n`);
250
- }
251
- else {
252
- const header = `error [${err.code}]`;
253
- if (err.message.includes("\n")) {
254
- process.stderr.write(`${header}\n${err.message}\n`);
255
- }
256
- else {
257
- process.stderr.write(`${header}: ${err.message}\n`);
258
- }
259
- if (guidance.hint) {
260
- process.stderr.write(`hint: ${guidance.hint}\n`);
261
- }
262
- if (guidance.nextAction) {
263
- process.stderr.write(`next_action: ${guidance.nextAction.command} (${guidance.nextAction.reason})\n`);
264
- }
265
- if (reasonDecode) {
266
- process.stderr.write(`reason_code: ${reasonDecode.code} [${reasonDecode.category}] ${reasonDecode.summary}\n`);
267
- process.stderr.write(`reason_action: ${reasonDecode.action}\n`);
268
- }
269
- }
270
- }
271
- const AGENTPLANE_HOME_ENV = "AGENTPLANE_HOME";
272
- function resolveAgentplaneHome() {
273
- const overridden = process.env[AGENTPLANE_HOME_ENV]?.trim();
274
- if (overridden)
275
- return overridden;
276
- return path.join(os.homedir(), ".agentplane");
277
- }
278
- function resolveErrorGuidance(err) {
279
- const command = typeof err.context?.command === "string" ? err.context.command : undefined;
280
- const reasonCode = typeof err.context?.reason_code === "string" ? String(err.context.reason_code) : undefined;
281
- const usage = command ? `agentplane help ${command} --compact` : "agentplane help";
282
- switch (err.code) {
283
- case "E_USAGE": {
284
- if (reasonCode === "sync_backend_mismatch") {
285
- return {
286
- hint: "Configured backend id mismatch. Check active backend and retry with a matching id.",
287
- nextAction: {
288
- command: "agentplane config show",
289
- reason: "inspect active backend id before running sync",
290
- reasonCode: "sync_backend_mismatch",
291
- },
292
- };
293
- }
294
- return {
295
- hint: `See \`${usage}\` for usage.`,
296
- nextAction: {
297
- command: usage,
298
- reason: "inspect required arguments and flags",
299
- reasonCode: "usage_help",
300
- },
301
- };
302
- }
303
- case "E_GIT": {
304
- if (reasonCode === "reconcile_git_state_unreadable") {
305
- return {
306
- hint: "Reconcile check could not read git state.",
307
- nextAction: {
308
- command: "git status --short --untracked-files=no",
309
- reason: "confirm repository state is readable before mutating commands",
310
- reasonCode: "reconcile_git_state_unreadable",
311
- },
312
- };
313
- }
314
- if (command?.startsWith("branch")) {
315
- return {
316
- hint: "Check git repo/branch; run `git branch` or pass --root <path>.",
317
- nextAction: {
318
- command: "git branch",
319
- reason: "inspect repository branch state",
320
- reasonCode: "git_branch_state",
321
- },
322
- };
323
- }
324
- if (command === "guard commit" || command === "commit") {
325
- return {
326
- hint: "Check git status/index; stage changes and retry.",
327
- nextAction: {
328
- command: "git status --short",
329
- reason: "inspect staged/unstaged changes before commit",
330
- reasonCode: "git_index_state",
331
- },
332
- };
333
- }
334
- return {
335
- hint: "Check git repo context; pass --root <path> if needed.",
336
- nextAction: {
337
- command: "git status --short --untracked-files=no",
338
- reason: "confirm repository context and tracked changes",
339
- reasonCode: "git_context",
340
- },
341
- };
342
- }
343
- case "E_NETWORK": {
344
- return {
345
- hint: "Check network access and credentials.",
346
- nextAction: {
347
- command: "agentplane preflight --json",
348
- reason: "recheck approvals and network requirements",
349
- reasonCode: "network_gate",
350
- },
351
- };
352
- }
353
- case "E_BACKEND": {
354
- if (command?.includes("sync")) {
355
- return {
356
- hint: "Check backend config under .agentplane/backends and retry.",
357
- nextAction: {
358
- command: "agentplane config show",
359
- reason: "verify backend config path and active settings",
360
- reasonCode: "backend_sync_config",
361
- },
362
- };
363
- }
364
- return {
365
- hint: "Check backend config under .agentplane/backends.",
366
- nextAction: {
367
- command: "agentplane config show",
368
- reason: "inspect backend configuration",
369
- reasonCode: "backend_config",
370
- },
371
- };
372
- }
373
- case "E_VALIDATION": {
374
- if (reasonCode === "reconcile_task_scan_failed" ||
375
- reasonCode === "reconcile_task_scan_incomplete") {
376
- return {
377
- hint: "Reconcile check failed due to task scan drift or parse/read errors.",
378
- nextAction: {
379
- command: "agentplane task list --strict-read",
380
- reason: "surface task scan/read failures before retrying mutating commands",
381
- reasonCode: reasonCode,
382
- },
383
- };
384
- }
385
- return {
386
- hint: "Fix invalid config/input shape and rerun.",
387
- nextAction: {
388
- command: "agentplane preflight --json",
389
- reason: "pinpoint validation failure in one report",
390
- reasonCode: "validation_preflight",
391
- },
392
- };
393
- }
394
- default: {
395
- return {};
396
- }
397
- }
398
- }
399
- const UPDATE_CHECK_PACKAGE = "agentplane";
400
- const UPDATE_CHECK_URL = `https://registry.npmjs.org/${UPDATE_CHECK_PACKAGE}/latest`;
401
- function parseVersionParts(version) {
402
- const cleaned = version.trim().replace(/^v/i, "").split("+")[0] ?? "";
403
- const [mainRaw, prereleaseRaw] = cleaned.split("-", 2);
404
- const main = (mainRaw ?? "")
405
- .split(".")
406
- .filter((part) => part.length > 0)
407
- .map((part) => {
408
- const parsed = Number.parseInt(part, 10);
409
- return Number.isFinite(parsed) ? parsed : 0;
410
- });
411
- return { main, prerelease: prereleaseRaw ? prereleaseRaw.trim() : null };
412
- }
413
- function compareVersions(left, right) {
414
- const a = parseVersionParts(left);
415
- const b = parseVersionParts(right);
416
- const length = Math.max(a.main.length, b.main.length);
417
- for (let i = 0; i < length; i++) {
418
- const partA = a.main[i] ?? 0;
419
- const partB = b.main[i] ?? 0;
420
- if (partA !== partB)
421
- return partA > partB ? 1 : -1;
422
- }
423
- if (a.prerelease === b.prerelease)
424
- return 0;
425
- if (a.prerelease === null)
426
- return 1;
427
- if (b.prerelease === null)
428
- return -1;
429
- return a.prerelease.localeCompare(b.prerelease);
430
- }
431
- function isTruthyEnv(value) {
432
- if (!value)
433
- return false;
434
- const normalized = value.trim().toLowerCase();
435
- return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
436
- }
437
- async function maybeWarnOnUpdate(opts) {
438
- if (opts.skip || opts.jsonErrors)
439
- return;
440
- if (isTruthyEnv(process.env.AGENTPLANE_NO_UPDATE_CHECK))
441
- return;
442
- const now = new Date();
443
- const cachePath = resolveUpdateCheckCachePath(resolveAgentplaneHome());
444
- const cache = await readUpdateCheckCache(cachePath);
445
- if (cache && !shouldCheckNow(cache.checked_at, now, UPDATE_CHECK_TTL_MS)) {
446
- if (cache.status === "ok" &&
447
- cache.latest_version &&
448
- compareVersions(cache.latest_version, opts.currentVersion) > 0) {
449
- const message = `Update available: ${UPDATE_CHECK_PACKAGE} ${opts.currentVersion} → ${cache.latest_version}. Run: npm i -g ${UPDATE_CHECK_PACKAGE}@latest`;
450
- process.stderr.write(`${warnMessage(message)}\n`);
451
- }
452
- return;
453
- }
454
- const result = await fetchLatestNpmVersion({
455
- url: UPDATE_CHECK_URL,
456
- timeoutMs: UPDATE_CHECK_TIMEOUT_MS,
457
- etag: cache?.etag ?? null,
458
- });
459
- const nextCache = {
460
- schema_version: UPDATE_CHECK_SCHEMA_VERSION,
461
- checked_at: now.toISOString(),
462
- latest_version: cache?.latest_version ?? null,
463
- etag: cache?.etag ?? null,
464
- status: "error",
465
- };
466
- if (result.status === "ok") {
467
- nextCache.status = "ok";
468
- nextCache.latest_version = result.latestVersion;
469
- nextCache.etag = result.etag;
470
- }
471
- else if (result.status === "not_modified") {
472
- nextCache.status = "not_modified";
473
- nextCache.etag = result.etag ?? nextCache.etag;
474
- }
475
- try {
476
- await writeUpdateCheckCache(cachePath, nextCache);
477
- }
478
- catch {
479
- // Best-effort cache: ignore write failures.
480
- }
481
- const latest = result.status === "ok" ? result.latestVersion : nextCache.latest_version;
482
- if (!latest || result.status === "error")
483
- return;
484
- if (compareVersions(latest, opts.currentVersion) <= 0)
485
- return;
486
- const message = `Update available: ${UPDATE_CHECK_PACKAGE} ${opts.currentVersion} → ${latest}. Run: npm i -g ${UPDATE_CHECK_PACKAGE}@latest`;
487
- process.stderr.write(`${warnMessage(message)}\n`);
488
- }
489
18
  async function maybeResolveProject(opts) {
490
19
  try {
491
20
  return await resolveProject({
@@ -1 +1 @@
1
- {"version":3,"file":"docs-render.d.ts","sourceRoot":"","sources":["../../../src/cli/spec/docs-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAmCjD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAsGnE"}
1
+ {"version":3,"file":"docs-render.d.ts","sourceRoot":"","sources":["../../../src/cli/spec/docs-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAgDjD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAsGnE"}
@@ -6,6 +6,7 @@ function escText(text) {
6
6
  .replaceAll("&", "&amp;")
7
7
  .replaceAll("<", "&lt;")
8
8
  .replaceAll(">", "&gt;")
9
+ .replaceAll("*", String.raw `\*`)
9
10
  .replaceAll("`", "\\`");
10
11
  }
11
12
  function toAnchor(text) {
@@ -34,6 +35,18 @@ function formatDefaultValue(value) {
34
35
  return "[unserializable]";
35
36
  }
36
37
  }
38
+ function normalizeGeneratedMdx(text) {
39
+ let normalized = text;
40
+ for (;;) {
41
+ const next = normalized
42
+ .replaceAll(/\n{3,}/g, "\n\n")
43
+ .replaceAll("```\n- ", "```\n\n- ")
44
+ .replaceAll(/\n(- [^\n]+)\n```/g, "\n$1\n\n```");
45
+ if (next === normalized)
46
+ return normalized;
47
+ normalized = next;
48
+ }
49
+ }
37
50
  export function renderCliDocsMdx(specs) {
38
51
  const byGroup = new Map();
39
52
  for (const s of specs) {
@@ -121,5 +134,5 @@ export function renderCliDocsMdx(specs) {
121
134
  ...bodyLines,
122
135
  "",
123
136
  ];
124
- return lines.join("\n");
137
+ return normalizeGeneratedMdx(lines.join("\n"));
125
138
  }
@@ -0,0 +1,4 @@
1
+ export declare function checkDoneTaskCommitInvariants(repoRoot: string, opts?: {
2
+ fullArchive?: boolean;
3
+ }): Promise<string[]>;
4
+ //# sourceMappingURL=archive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/archive.ts"],"names":[],"mappings":"AA6IA,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CA2FnB"}