agentplane 0.2.25 → 0.3.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.
Files changed (221) hide show
  1. package/README.md +3 -1
  2. package/assets/AGENTS.md +123 -526
  3. package/assets/agents/UPGRADER.json +10 -9
  4. package/assets/framework.manifest.json +112 -7
  5. package/assets/policy/check-routing.mjs +180 -0
  6. package/assets/policy/dod.code.md +25 -0
  7. package/assets/policy/dod.core.md +32 -0
  8. package/assets/policy/dod.docs.md +32 -0
  9. package/assets/policy/examples/migration-note.md +6 -0
  10. package/assets/policy/examples/pr-note.md +16 -0
  11. package/assets/policy/examples/unit-test-pattern.md +19 -0
  12. package/assets/policy/governance.md +37 -0
  13. package/assets/policy/incidents.md +36 -0
  14. package/assets/policy/security.must.md +7 -0
  15. package/assets/policy/workflow.branch_pr.md +34 -0
  16. package/assets/policy/workflow.direct.md +46 -0
  17. package/assets/policy/workflow.md +9 -0
  18. package/assets/policy/workflow.release.md +31 -0
  19. package/assets/policy/workflow.upgrade.md +20 -0
  20. package/bin/agentplane.js +47 -57
  21. package/bin/dist-guard.js +124 -0
  22. package/dist/.build-manifest.json +11 -0
  23. package/dist/agents/agents-template.d.ts +7 -0
  24. package/dist/agents/agents-template.d.ts.map +1 -1
  25. package/dist/agents/agents-template.js +41 -2
  26. package/dist/backends/task-backend/local-backend.d.ts +2 -0
  27. package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
  28. package/dist/backends/task-backend/local-backend.js +12 -1
  29. package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -1
  30. package/dist/backends/task-backend/redmine/mapping.js +26 -1
  31. package/dist/backends/task-backend/redmine-backend.d.ts +4 -0
  32. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  33. package/dist/backends/task-backend/redmine-backend.js +92 -9
  34. package/dist/backends/task-backend/shared/types.d.ts +1 -0
  35. package/dist/backends/task-backend/shared/types.d.ts.map +1 -1
  36. package/dist/backends/task-index.d.ts.map +1 -1
  37. package/dist/backends/task-index.js +8 -1
  38. package/dist/cli/command-guide.d.ts.map +1 -1
  39. package/dist/cli/command-guide.js +39 -17
  40. package/dist/cli/command-snippets.d.ts +24 -0
  41. package/dist/cli/command-snippets.d.ts.map +1 -0
  42. package/dist/cli/command-snippets.js +23 -0
  43. package/dist/cli/reason-codes.d.ts +9 -0
  44. package/dist/cli/reason-codes.d.ts.map +1 -0
  45. package/dist/cli/reason-codes.js +79 -0
  46. package/dist/cli/recipes-bundled.d.ts +1 -0
  47. package/dist/cli/recipes-bundled.d.ts.map +1 -1
  48. package/dist/cli/recipes-bundled.js +4 -1
  49. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  50. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  51. package/dist/cli/run-cli/command-catalog.js +40 -1
  52. package/dist/cli/run-cli/commands/config.d.ts +5 -0
  53. package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
  54. package/dist/cli/run-cli/commands/config.js +86 -1
  55. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  56. package/dist/cli/run-cli/commands/core.js +57 -2
  57. package/dist/cli/run-cli/commands/ide.d.ts.map +1 -1
  58. package/dist/cli/run-cli/commands/ide.js +8 -3
  59. package/dist/cli/run-cli/commands/init/recipes.d.ts +5 -1
  60. package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
  61. package/dist/cli/run-cli/commands/init/recipes.js +24 -4
  62. package/dist/cli/run-cli/commands/init/ui.d.ts.map +1 -1
  63. package/dist/cli/run-cli/commands/init/ui.js +1 -2
  64. package/dist/cli/run-cli/commands/init/write-agents.d.ts +2 -0
  65. package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -1
  66. package/dist/cli/run-cli/commands/init/write-agents.js +24 -5
  67. package/dist/cli/run-cli/commands/init/write-workflow.d.ts +12 -0
  68. package/dist/cli/run-cli/commands/init/write-workflow.d.ts.map +1 -0
  69. package/dist/cli/run-cli/commands/init/write-workflow.js +58 -0
  70. package/dist/cli/run-cli/commands/init.d.ts +4 -1
  71. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  72. package/dist/cli/run-cli/commands/init.js +126 -48
  73. package/dist/cli/run-cli.d.ts.map +1 -1
  74. package/dist/cli/run-cli.js +195 -8
  75. package/dist/commands/backend/sync.command.d.ts.map +1 -1
  76. package/dist/commands/backend/sync.command.js +7 -6
  77. package/dist/commands/backend.d.ts.map +1 -1
  78. package/dist/commands/backend.js +2 -0
  79. package/dist/commands/doctor.run.d.ts.map +1 -1
  80. package/dist/commands/doctor.run.js +107 -16
  81. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  82. package/dist/commands/guard/impl/commands.js +12 -6
  83. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  84. package/dist/commands/recipes/impl/commands/install.js +36 -13
  85. package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
  86. package/dist/commands/recipes/impl/scenario.js +25 -0
  87. package/dist/commands/recipes/impl/types.d.ts +4 -0
  88. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  89. package/dist/commands/release/apply.command.d.ts.map +1 -1
  90. package/dist/commands/release/apply.command.js +9 -4
  91. package/dist/commands/release/plan.command.d.ts.map +1 -1
  92. package/dist/commands/release/plan.command.js +9 -3
  93. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  94. package/dist/commands/scenario/impl/commands.js +74 -3
  95. package/dist/commands/scenario/impl/report.d.ts +8 -0
  96. package/dist/commands/scenario/impl/report.d.ts.map +1 -1
  97. package/dist/commands/scenario/impl/report.js +1 -0
  98. package/dist/commands/shared/reconcile-check.d.ts +7 -0
  99. package/dist/commands/shared/reconcile-check.d.ts.map +1 -0
  100. package/dist/commands/shared/reconcile-check.js +60 -0
  101. package/dist/commands/sync.command.d.ts.map +1 -1
  102. package/dist/commands/sync.command.js +9 -2
  103. package/dist/commands/task/add.d.ts.map +1 -1
  104. package/dist/commands/task/add.js +32 -0
  105. package/dist/commands/task/doc.command.d.ts.map +1 -1
  106. package/dist/commands/task/doc.command.js +1 -0
  107. package/dist/commands/task/finish.d.ts.map +1 -1
  108. package/dist/commands/task/finish.js +11 -1
  109. package/dist/commands/task/list.d.ts.map +1 -1
  110. package/dist/commands/task/list.js +2 -1
  111. package/dist/commands/task/list.spec.d.ts.map +1 -1
  112. package/dist/commands/task/list.spec.js +7 -0
  113. package/dist/commands/task/new.d.ts.map +1 -1
  114. package/dist/commands/task/new.js +41 -4
  115. package/dist/commands/task/next.d.ts.map +1 -1
  116. package/dist/commands/task/next.js +2 -1
  117. package/dist/commands/task/next.spec.d.ts.map +1 -1
  118. package/dist/commands/task/next.spec.js +7 -0
  119. package/dist/commands/task/plan.d.ts.map +1 -1
  120. package/dist/commands/task/plan.js +7 -1
  121. package/dist/commands/task/search.d.ts.map +1 -1
  122. package/dist/commands/task/search.js +2 -1
  123. package/dist/commands/task/search.spec.d.ts.map +1 -1
  124. package/dist/commands/task/search.spec.js +7 -0
  125. package/dist/commands/task/shared.d.ts +14 -0
  126. package/dist/commands/task/shared.d.ts.map +1 -1
  127. package/dist/commands/task/shared.js +58 -1
  128. package/dist/commands/task/start-ready.js +1 -1
  129. package/dist/commands/task/verify-record.d.ts.map +1 -1
  130. package/dist/commands/task/verify-record.js +2 -0
  131. package/dist/commands/upgrade.command.d.ts.map +1 -1
  132. package/dist/commands/upgrade.command.js +2 -2
  133. package/dist/commands/upgrade.d.ts.map +1 -1
  134. package/dist/commands/upgrade.js +263 -294
  135. package/dist/commands/workflow-build.command.d.ts +8 -0
  136. package/dist/commands/workflow-build.command.d.ts.map +1 -0
  137. package/dist/commands/workflow-build.command.js +103 -0
  138. package/dist/commands/workflow-playbook.command.d.ts +10 -0
  139. package/dist/commands/workflow-playbook.command.d.ts.map +1 -0
  140. package/dist/commands/workflow-playbook.command.js +173 -0
  141. package/dist/commands/workflow-restore.command.d.ts +5 -0
  142. package/dist/commands/workflow-restore.command.d.ts.map +1 -0
  143. package/dist/commands/workflow-restore.command.js +30 -0
  144. package/dist/commands/workflow.command.d.ts +6 -0
  145. package/dist/commands/workflow.command.d.ts.map +1 -0
  146. package/dist/commands/workflow.command.js +36 -0
  147. package/dist/harness/dynamic-tool-contract.d.ts +29 -0
  148. package/dist/harness/dynamic-tool-contract.d.ts.map +1 -0
  149. package/dist/harness/dynamic-tool-contract.js +86 -0
  150. package/dist/harness/hooks-lifecycle.d.ts +27 -0
  151. package/dist/harness/hooks-lifecycle.d.ts.map +1 -0
  152. package/dist/harness/hooks-lifecycle.js +67 -0
  153. package/dist/harness/index.d.ts +9 -0
  154. package/dist/harness/index.d.ts.map +1 -0
  155. package/dist/harness/index.js +8 -0
  156. package/dist/harness/reconcile.d.ts +37 -0
  157. package/dist/harness/reconcile.d.ts.map +1 -0
  158. package/dist/harness/reconcile.js +42 -0
  159. package/dist/harness/retry-policy.d.ts +31 -0
  160. package/dist/harness/retry-policy.d.ts.map +1 -0
  161. package/dist/harness/retry-policy.js +33 -0
  162. package/dist/harness/scheduler.d.ts +18 -0
  163. package/dist/harness/scheduler.d.ts.map +1 -0
  164. package/dist/harness/scheduler.js +55 -0
  165. package/dist/harness/state-machine.d.ts +17 -0
  166. package/dist/harness/state-machine.d.ts.map +1 -0
  167. package/dist/harness/state-machine.js +70 -0
  168. package/dist/harness/token-accounting.d.ts +19 -0
  169. package/dist/harness/token-accounting.d.ts.map +1 -0
  170. package/dist/harness/token-accounting.js +77 -0
  171. package/dist/harness/workspace-safety.d.ts +14 -0
  172. package/dist/harness/workspace-safety.d.ts.map +1 -0
  173. package/dist/harness/workspace-safety.js +62 -0
  174. package/dist/recipes/bundled-recipes.d.ts +4 -0
  175. package/dist/recipes/bundled-recipes.d.ts.map +1 -1
  176. package/dist/recipes/bundled-recipes.js +11 -0
  177. package/dist/shared/errors.d.ts +6 -0
  178. package/dist/shared/errors.d.ts.map +1 -1
  179. package/dist/shared/errors.js +1 -0
  180. package/dist/shared/policy-gateway.d.ts +15 -0
  181. package/dist/shared/policy-gateway.d.ts.map +1 -0
  182. package/dist/shared/policy-gateway.js +49 -0
  183. package/dist/shared/protected-paths.d.ts.map +1 -1
  184. package/dist/shared/protected-paths.js +1 -0
  185. package/dist/shared/runtime-artifacts.d.ts +2 -2
  186. package/dist/shared/runtime-artifacts.d.ts.map +1 -1
  187. package/dist/shared/runtime-artifacts.js +4 -0
  188. package/dist/workflow-runtime/build.d.ts +4 -0
  189. package/dist/workflow-runtime/build.d.ts.map +1 -0
  190. package/dist/workflow-runtime/build.js +126 -0
  191. package/dist/workflow-runtime/enforcement.d.ts +3 -0
  192. package/dist/workflow-runtime/enforcement.d.ts.map +1 -0
  193. package/dist/workflow-runtime/enforcement.js +10 -0
  194. package/dist/workflow-runtime/file-ops.d.ts +11 -0
  195. package/dist/workflow-runtime/file-ops.d.ts.map +1 -0
  196. package/dist/workflow-runtime/file-ops.js +248 -0
  197. package/dist/workflow-runtime/fix.d.ts +9 -0
  198. package/dist/workflow-runtime/fix.d.ts.map +1 -0
  199. package/dist/workflow-runtime/fix.js +107 -0
  200. package/dist/workflow-runtime/index.d.ts +11 -0
  201. package/dist/workflow-runtime/index.d.ts.map +1 -0
  202. package/dist/workflow-runtime/index.js +10 -0
  203. package/dist/workflow-runtime/markdown.d.ts +10 -0
  204. package/dist/workflow-runtime/markdown.d.ts.map +1 -0
  205. package/dist/workflow-runtime/markdown.js +147 -0
  206. package/dist/workflow-runtime/observability.d.ts +12 -0
  207. package/dist/workflow-runtime/observability.d.ts.map +1 -0
  208. package/dist/workflow-runtime/observability.js +14 -0
  209. package/dist/workflow-runtime/paths.d.ts +3 -0
  210. package/dist/workflow-runtime/paths.d.ts.map +1 -0
  211. package/dist/workflow-runtime/paths.js +11 -0
  212. package/dist/workflow-runtime/template.d.ts +7 -0
  213. package/dist/workflow-runtime/template.d.ts.map +1 -0
  214. package/dist/workflow-runtime/template.js +94 -0
  215. package/dist/workflow-runtime/types.d.ts +68 -0
  216. package/dist/workflow-runtime/types.d.ts.map +1 -0
  217. package/dist/workflow-runtime/types.js +1 -0
  218. package/dist/workflow-runtime/validate.d.ts +8 -0
  219. package/dist/workflow-runtime/validate.d.ts.map +1 -0
  220. package/dist/workflow-runtime/validate.js +331 -0
  221. package/package.json +3 -3
@@ -0,0 +1,331 @@
1
+ import path from "node:path";
2
+ import { diagnosticsToValidationResult } from "./markdown.js";
3
+ const ROOT_KEYS = new Set([
4
+ "version",
5
+ "mode",
6
+ "owners",
7
+ "approvals",
8
+ "retry_policy",
9
+ "timeouts",
10
+ "in_scope_paths",
11
+ ]);
12
+ function push(diags, diagnostic) {
13
+ diags.push(diagnostic);
14
+ }
15
+ function isRecord(value) {
16
+ return !!value && typeof value === "object" && !Array.isArray(value);
17
+ }
18
+ function expectBoolean(diags, value, pathName, required) {
19
+ if (value === undefined) {
20
+ if (required) {
21
+ push(diags, {
22
+ code: "WF_SCHEMA_MISSING",
23
+ severity: "ERROR",
24
+ path: pathName,
25
+ message: `${pathName} is required.`,
26
+ });
27
+ }
28
+ return undefined;
29
+ }
30
+ if (typeof value !== "boolean") {
31
+ push(diags, {
32
+ code: "WF_SCHEMA_TYPE",
33
+ severity: "ERROR",
34
+ path: pathName,
35
+ message: `${pathName} must be a boolean.`,
36
+ });
37
+ return undefined;
38
+ }
39
+ return value;
40
+ }
41
+ function expectString(diags, value, pathName, required) {
42
+ if (value === undefined) {
43
+ if (required) {
44
+ push(diags, {
45
+ code: "WF_SCHEMA_MISSING",
46
+ severity: "ERROR",
47
+ path: pathName,
48
+ message: `${pathName} is required.`,
49
+ });
50
+ }
51
+ return undefined;
52
+ }
53
+ if (typeof value !== "string") {
54
+ push(diags, {
55
+ code: "WF_SCHEMA_TYPE",
56
+ severity: "ERROR",
57
+ path: pathName,
58
+ message: `${pathName} must be a string.`,
59
+ });
60
+ return undefined;
61
+ }
62
+ if (value.trim().length === 0) {
63
+ push(diags, {
64
+ code: "WF_SCHEMA_RANGE",
65
+ severity: "ERROR",
66
+ path: pathName,
67
+ message: `${pathName} must be non-empty.`,
68
+ });
69
+ return undefined;
70
+ }
71
+ return value;
72
+ }
73
+ function expectIntegerInRange(diags, value, pathName, min, max, required) {
74
+ if (value === undefined) {
75
+ if (required) {
76
+ push(diags, {
77
+ code: "WF_SCHEMA_MISSING",
78
+ severity: "ERROR",
79
+ path: pathName,
80
+ message: `${pathName} is required.`,
81
+ });
82
+ }
83
+ return undefined;
84
+ }
85
+ if (typeof value !== "number" || !Number.isInteger(value)) {
86
+ push(diags, {
87
+ code: "WF_SCHEMA_TYPE",
88
+ severity: "ERROR",
89
+ path: pathName,
90
+ message: `${pathName} must be an integer.`,
91
+ });
92
+ return undefined;
93
+ }
94
+ if (value < min || value > max) {
95
+ push(diags, {
96
+ code: "WF_SCHEMA_RANGE",
97
+ severity: "ERROR",
98
+ path: pathName,
99
+ message: `${pathName} must be in [${min}, ${max}].`,
100
+ });
101
+ return undefined;
102
+ }
103
+ return value;
104
+ }
105
+ function validateUnknownKeys(diags, raw) {
106
+ for (const key of Object.keys(raw)) {
107
+ if (!ROOT_KEYS.has(key)) {
108
+ push(diags, {
109
+ code: "WF_SCHEMA_UNKNOWN_KEY",
110
+ severity: "ERROR",
111
+ path: `front_matter.${key}`,
112
+ message: `Unknown front matter key: ${key}`,
113
+ });
114
+ }
115
+ }
116
+ }
117
+ function validateMode(diags, value) {
118
+ const mode = expectString(diags, value, "front_matter.mode", true);
119
+ if (!mode)
120
+ return undefined;
121
+ if (mode !== "direct" && mode !== "branch_pr") {
122
+ push(diags, {
123
+ code: "WF_SCHEMA_ENUM",
124
+ severity: "ERROR",
125
+ path: "front_matter.mode",
126
+ message: "front_matter.mode must be one of: direct, branch_pr.",
127
+ });
128
+ return undefined;
129
+ }
130
+ return mode;
131
+ }
132
+ function validateOwners(diags, value, knownAgentIds) {
133
+ if (!isRecord(value)) {
134
+ push(diags, {
135
+ code: value === undefined ? "WF_SCHEMA_MISSING" : "WF_SCHEMA_TYPE",
136
+ severity: "ERROR",
137
+ path: "front_matter.owners",
138
+ message: "front_matter.owners must be an object.",
139
+ });
140
+ return undefined;
141
+ }
142
+ const orchestrator = expectString(diags, value.orchestrator, "front_matter.owners.orchestrator", true);
143
+ if (!orchestrator)
144
+ return undefined;
145
+ if (knownAgentIds && !knownAgentIds.has(orchestrator)) {
146
+ push(diags, {
147
+ code: "WF_OWNER_NOT_FOUND",
148
+ severity: "ERROR",
149
+ path: "front_matter.owners.orchestrator",
150
+ message: `Owner ${orchestrator} was not found in .agentplane/agents/*.json.`,
151
+ });
152
+ }
153
+ return { orchestrator };
154
+ }
155
+ function validateApprovals(diags, value) {
156
+ if (!isRecord(value)) {
157
+ push(diags, {
158
+ code: value === undefined ? "WF_SCHEMA_MISSING" : "WF_SCHEMA_TYPE",
159
+ severity: "ERROR",
160
+ path: "front_matter.approvals",
161
+ message: "front_matter.approvals must be an object.",
162
+ });
163
+ return undefined;
164
+ }
165
+ const require_plan = expectBoolean(diags, value.require_plan, "front_matter.approvals.require_plan", true);
166
+ const require_verify = expectBoolean(diags, value.require_verify, "front_matter.approvals.require_verify", true);
167
+ const require_network = expectBoolean(diags, value.require_network, "front_matter.approvals.require_network", true);
168
+ if (require_plan === undefined || require_verify === undefined || require_network === undefined) {
169
+ return undefined;
170
+ }
171
+ return { require_plan, require_verify, require_network };
172
+ }
173
+ function validateRetryPolicy(diags, value) {
174
+ if (!isRecord(value)) {
175
+ push(diags, {
176
+ code: value === undefined ? "WF_SCHEMA_MISSING" : "WF_SCHEMA_TYPE",
177
+ severity: "ERROR",
178
+ path: "front_matter.retry_policy",
179
+ message: "front_matter.retry_policy must be an object.",
180
+ });
181
+ return undefined;
182
+ }
183
+ const normal_exit_continuation = expectBoolean(diags, value.normal_exit_continuation, "front_matter.retry_policy.normal_exit_continuation", true);
184
+ const abnormal_backoff = expectString(diags, value.abnormal_backoff, "front_matter.retry_policy.abnormal_backoff", true);
185
+ if (abnormal_backoff && abnormal_backoff !== "exponential") {
186
+ push(diags, {
187
+ code: "WF_SCHEMA_ENUM",
188
+ severity: "ERROR",
189
+ path: "front_matter.retry_policy.abnormal_backoff",
190
+ message: "front_matter.retry_policy.abnormal_backoff must be exponential.",
191
+ });
192
+ }
193
+ const max_attempts = expectIntegerInRange(diags, value.max_attempts, "front_matter.retry_policy.max_attempts", 1, 100, true);
194
+ if (normal_exit_continuation === undefined || !abnormal_backoff || max_attempts === undefined) {
195
+ return undefined;
196
+ }
197
+ return {
198
+ normal_exit_continuation,
199
+ abnormal_backoff: "exponential",
200
+ max_attempts,
201
+ };
202
+ }
203
+ function validateTimeouts(diags, value) {
204
+ if (!isRecord(value)) {
205
+ push(diags, {
206
+ code: value === undefined ? "WF_SCHEMA_MISSING" : "WF_SCHEMA_TYPE",
207
+ severity: "ERROR",
208
+ path: "front_matter.timeouts",
209
+ message: "front_matter.timeouts must be an object.",
210
+ });
211
+ return undefined;
212
+ }
213
+ const stall_seconds = expectIntegerInRange(diags, value.stall_seconds, "front_matter.timeouts.stall_seconds", 1, 86_400, true);
214
+ if (stall_seconds === undefined)
215
+ return undefined;
216
+ return { stall_seconds };
217
+ }
218
+ function validateScopePaths(diags, value, repoRoot) {
219
+ if (!Array.isArray(value)) {
220
+ push(diags, {
221
+ code: value === undefined ? "WF_SCHEMA_MISSING" : "WF_SCHEMA_TYPE",
222
+ severity: "ERROR",
223
+ path: "front_matter.in_scope_paths",
224
+ message: "front_matter.in_scope_paths must be an array.",
225
+ });
226
+ return undefined;
227
+ }
228
+ const normalized = value
229
+ .map((item) => (typeof item === "string" ? item.trim() : ""))
230
+ .filter((item) => item.length > 0);
231
+ if (normalized.length === 0) {
232
+ push(diags, {
233
+ code: "WF_SCHEMA_RANGE",
234
+ severity: "ERROR",
235
+ path: "front_matter.in_scope_paths",
236
+ message: "front_matter.in_scope_paths must contain at least one path.",
237
+ });
238
+ return undefined;
239
+ }
240
+ if (repoRoot) {
241
+ for (const p of normalized) {
242
+ const candidate = path.resolve(repoRoot, p.replaceAll(/[*]{1,2}$/g, ""));
243
+ const rootPrefix = `${path.resolve(repoRoot)}${path.sep}`;
244
+ if (!(candidate === path.resolve(repoRoot) || candidate.startsWith(rootPrefix))) {
245
+ push(diags, {
246
+ code: "WF_PATH_OUTSIDE_ROOT",
247
+ severity: "ERROR",
248
+ path: "front_matter.in_scope_paths",
249
+ message: `Path escapes repository root: ${p}`,
250
+ });
251
+ }
252
+ }
253
+ }
254
+ return normalized;
255
+ }
256
+ export function validateWorkflowDocument(document, opts) {
257
+ const diags = [];
258
+ const raw = document.frontMatterRaw;
259
+ if (!isRecord(raw)) {
260
+ push(diags, {
261
+ code: "WF_FRONTMATTER_NOT_OBJECT",
262
+ severity: "ERROR",
263
+ path: "front_matter",
264
+ message: "Workflow front matter must decode to an object.",
265
+ });
266
+ return diagnosticsToValidationResult(diags);
267
+ }
268
+ validateUnknownKeys(diags, raw);
269
+ const version = expectIntegerInRange(diags, raw.version, "front_matter.version", 1, Number.MAX_SAFE_INTEGER, true);
270
+ const mode = validateMode(diags, raw.mode);
271
+ const owners = validateOwners(diags, raw.owners, opts?.knownAgentIds ?? null);
272
+ const approvals = validateApprovals(diags, raw.approvals);
273
+ const retry_policy = validateRetryPolicy(diags, raw.retry_policy);
274
+ const timeouts = validateTimeouts(diags, raw.timeouts);
275
+ const in_scope_paths = validateScopePaths(diags, raw.in_scope_paths, opts?.repoRoot);
276
+ if (opts?.config && mode && opts.config.workflow_mode !== mode) {
277
+ push(diags, {
278
+ code: "WF_POLICY_MISMATCH",
279
+ severity: "ERROR",
280
+ path: "front_matter.mode",
281
+ message: `workflow mode mismatch: WORKFLOW.md=${mode}, config=${opts.config.workflow_mode}`,
282
+ });
283
+ }
284
+ if (opts?.config && approvals) {
285
+ const cfgApprovals = opts.config.agents?.approvals;
286
+ if (cfgApprovals) {
287
+ if (cfgApprovals.require_plan !== approvals.require_plan) {
288
+ push(diags, {
289
+ code: "WF_POLICY_MISMATCH",
290
+ severity: "WARN",
291
+ path: "front_matter.approvals.require_plan",
292
+ message: "Approval mismatch with .agentplane/config.json (require_plan).",
293
+ });
294
+ }
295
+ if (cfgApprovals.require_verify !== approvals.require_verify) {
296
+ push(diags, {
297
+ code: "WF_POLICY_MISMATCH",
298
+ severity: "WARN",
299
+ path: "front_matter.approvals.require_verify",
300
+ message: "Approval mismatch with .agentplane/config.json (require_verify).",
301
+ });
302
+ }
303
+ if (cfgApprovals.require_network !== approvals.require_network) {
304
+ push(diags, {
305
+ code: "WF_POLICY_MISMATCH",
306
+ severity: "WARN",
307
+ path: "front_matter.approvals.require_network",
308
+ message: "Approval mismatch with .agentplane/config.json (require_network).",
309
+ });
310
+ }
311
+ }
312
+ }
313
+ if (version !== undefined &&
314
+ mode &&
315
+ owners &&
316
+ approvals &&
317
+ retry_policy &&
318
+ timeouts &&
319
+ in_scope_paths) {
320
+ document.frontMatter = {
321
+ version,
322
+ mode,
323
+ owners,
324
+ approvals,
325
+ retry_policy,
326
+ timeouts,
327
+ in_scope_paths,
328
+ };
329
+ }
330
+ return diagnosticsToValidationResult(diags);
331
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentplane",
3
- "version": "0.2.25",
3
+ "version": "0.3.1",
4
4
  "description": "Agent Plane CLI for task workflows, recipes, and project automation.",
5
5
  "keywords": [
6
6
  "agentplane",
@@ -48,14 +48,14 @@
48
48
  },
49
49
  "scripts": {
50
50
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true}); require('node:fs').rmSync('tsconfig.tsbuildinfo',{force:true});\"",
51
- "build": "tsc -b",
51
+ "build": "tsc -b && node ../../scripts/write-build-manifest.mjs .",
52
52
  "typecheck": "tsc -b",
53
53
  "prepare": "npm run build",
54
54
  "prepack": "npm run clean && npm run build",
55
55
  "prepublishOnly": "node ../../scripts/enforce-github-publish.mjs && npm run prepack"
56
56
  },
57
57
  "dependencies": {
58
- "@agentplaneorg/core": "0.2.25",
58
+ "@agentplaneorg/core": "0.3.1",
59
59
  "yauzl": "^2.10.0"
60
60
  },
61
61
  "devDependencies": {