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.
- package/README.md +3 -1
- package/assets/AGENTS.md +123 -526
- package/assets/agents/UPGRADER.json +10 -9
- package/assets/framework.manifest.json +112 -7
- package/assets/policy/check-routing.mjs +180 -0
- package/assets/policy/dod.code.md +25 -0
- package/assets/policy/dod.core.md +32 -0
- package/assets/policy/dod.docs.md +32 -0
- package/assets/policy/examples/migration-note.md +6 -0
- package/assets/policy/examples/pr-note.md +16 -0
- package/assets/policy/examples/unit-test-pattern.md +19 -0
- package/assets/policy/governance.md +37 -0
- package/assets/policy/incidents.md +36 -0
- package/assets/policy/security.must.md +7 -0
- package/assets/policy/workflow.branch_pr.md +34 -0
- package/assets/policy/workflow.direct.md +46 -0
- package/assets/policy/workflow.md +9 -0
- package/assets/policy/workflow.release.md +31 -0
- package/assets/policy/workflow.upgrade.md +20 -0
- package/bin/agentplane.js +47 -57
- package/bin/dist-guard.js +124 -0
- package/dist/.build-manifest.json +11 -0
- package/dist/agents/agents-template.d.ts +7 -0
- package/dist/agents/agents-template.d.ts.map +1 -1
- package/dist/agents/agents-template.js +41 -2
- package/dist/backends/task-backend/local-backend.d.ts +2 -0
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend.js +12 -1
- package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine/mapping.js +26 -1
- package/dist/backends/task-backend/redmine-backend.d.ts +4 -0
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine-backend.js +92 -9
- package/dist/backends/task-backend/shared/types.d.ts +1 -0
- package/dist/backends/task-backend/shared/types.d.ts.map +1 -1
- package/dist/backends/task-index.d.ts.map +1 -1
- package/dist/backends/task-index.js +8 -1
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +39 -17
- package/dist/cli/command-snippets.d.ts +24 -0
- package/dist/cli/command-snippets.d.ts.map +1 -0
- package/dist/cli/command-snippets.js +23 -0
- package/dist/cli/reason-codes.d.ts +9 -0
- package/dist/cli/reason-codes.d.ts.map +1 -0
- package/dist/cli/reason-codes.js +79 -0
- package/dist/cli/recipes-bundled.d.ts +1 -0
- package/dist/cli/recipes-bundled.d.ts.map +1 -1
- package/dist/cli/recipes-bundled.js +4 -1
- package/dist/cli/run-cli/command-catalog.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog.js +40 -1
- package/dist/cli/run-cli/commands/config.d.ts +5 -0
- package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/config.js +86 -1
- package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core.js +57 -2
- package/dist/cli/run-cli/commands/ide.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/ide.js +8 -3
- package/dist/cli/run-cli/commands/init/recipes.d.ts +5 -1
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.js +24 -4
- package/dist/cli/run-cli/commands/init/ui.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/ui.js +1 -2
- package/dist/cli/run-cli/commands/init/write-agents.d.ts +2 -0
- package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-agents.js +24 -5
- package/dist/cli/run-cli/commands/init/write-workflow.d.ts +12 -0
- package/dist/cli/run-cli/commands/init/write-workflow.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/write-workflow.js +58 -0
- package/dist/cli/run-cli/commands/init.d.ts +4 -1
- package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init.js +126 -48
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +195 -8
- package/dist/commands/backend/sync.command.d.ts.map +1 -1
- package/dist/commands/backend/sync.command.js +7 -6
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +2 -0
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +107 -16
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +12 -6
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/install.js +36 -13
- package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
- package/dist/commands/recipes/impl/scenario.js +25 -0
- package/dist/commands/recipes/impl/types.d.ts +4 -0
- package/dist/commands/recipes/impl/types.d.ts.map +1 -1
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +9 -4
- package/dist/commands/release/plan.command.d.ts.map +1 -1
- package/dist/commands/release/plan.command.js +9 -3
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
- package/dist/commands/scenario/impl/commands.js +74 -3
- package/dist/commands/scenario/impl/report.d.ts +8 -0
- package/dist/commands/scenario/impl/report.d.ts.map +1 -1
- package/dist/commands/scenario/impl/report.js +1 -0
- package/dist/commands/shared/reconcile-check.d.ts +7 -0
- package/dist/commands/shared/reconcile-check.d.ts.map +1 -0
- package/dist/commands/shared/reconcile-check.js +60 -0
- package/dist/commands/sync.command.d.ts.map +1 -1
- package/dist/commands/sync.command.js +9 -2
- package/dist/commands/task/add.d.ts.map +1 -1
- package/dist/commands/task/add.js +32 -0
- package/dist/commands/task/doc.command.d.ts.map +1 -1
- package/dist/commands/task/doc.command.js +1 -0
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +11 -1
- package/dist/commands/task/list.d.ts.map +1 -1
- package/dist/commands/task/list.js +2 -1
- package/dist/commands/task/list.spec.d.ts.map +1 -1
- package/dist/commands/task/list.spec.js +7 -0
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +41 -4
- package/dist/commands/task/next.d.ts.map +1 -1
- package/dist/commands/task/next.js +2 -1
- package/dist/commands/task/next.spec.d.ts.map +1 -1
- package/dist/commands/task/next.spec.js +7 -0
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +7 -1
- package/dist/commands/task/search.d.ts.map +1 -1
- package/dist/commands/task/search.js +2 -1
- package/dist/commands/task/search.spec.d.ts.map +1 -1
- package/dist/commands/task/search.spec.js +7 -0
- package/dist/commands/task/shared.d.ts +14 -0
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +58 -1
- package/dist/commands/task/start-ready.js +1 -1
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +2 -0
- package/dist/commands/upgrade.command.d.ts.map +1 -1
- package/dist/commands/upgrade.command.js +2 -2
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +263 -294
- package/dist/commands/workflow-build.command.d.ts +8 -0
- package/dist/commands/workflow-build.command.d.ts.map +1 -0
- package/dist/commands/workflow-build.command.js +103 -0
- package/dist/commands/workflow-playbook.command.d.ts +10 -0
- package/dist/commands/workflow-playbook.command.d.ts.map +1 -0
- package/dist/commands/workflow-playbook.command.js +173 -0
- package/dist/commands/workflow-restore.command.d.ts +5 -0
- package/dist/commands/workflow-restore.command.d.ts.map +1 -0
- package/dist/commands/workflow-restore.command.js +30 -0
- package/dist/commands/workflow.command.d.ts +6 -0
- package/dist/commands/workflow.command.d.ts.map +1 -0
- package/dist/commands/workflow.command.js +36 -0
- package/dist/harness/dynamic-tool-contract.d.ts +29 -0
- package/dist/harness/dynamic-tool-contract.d.ts.map +1 -0
- package/dist/harness/dynamic-tool-contract.js +86 -0
- package/dist/harness/hooks-lifecycle.d.ts +27 -0
- package/dist/harness/hooks-lifecycle.d.ts.map +1 -0
- package/dist/harness/hooks-lifecycle.js +67 -0
- package/dist/harness/index.d.ts +9 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +8 -0
- package/dist/harness/reconcile.d.ts +37 -0
- package/dist/harness/reconcile.d.ts.map +1 -0
- package/dist/harness/reconcile.js +42 -0
- package/dist/harness/retry-policy.d.ts +31 -0
- package/dist/harness/retry-policy.d.ts.map +1 -0
- package/dist/harness/retry-policy.js +33 -0
- package/dist/harness/scheduler.d.ts +18 -0
- package/dist/harness/scheduler.d.ts.map +1 -0
- package/dist/harness/scheduler.js +55 -0
- package/dist/harness/state-machine.d.ts +17 -0
- package/dist/harness/state-machine.d.ts.map +1 -0
- package/dist/harness/state-machine.js +70 -0
- package/dist/harness/token-accounting.d.ts +19 -0
- package/dist/harness/token-accounting.d.ts.map +1 -0
- package/dist/harness/token-accounting.js +77 -0
- package/dist/harness/workspace-safety.d.ts +14 -0
- package/dist/harness/workspace-safety.d.ts.map +1 -0
- package/dist/harness/workspace-safety.js +62 -0
- package/dist/recipes/bundled-recipes.d.ts +4 -0
- package/dist/recipes/bundled-recipes.d.ts.map +1 -1
- package/dist/recipes/bundled-recipes.js +11 -0
- package/dist/shared/errors.d.ts +6 -0
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +1 -0
- package/dist/shared/policy-gateway.d.ts +15 -0
- package/dist/shared/policy-gateway.d.ts.map +1 -0
- package/dist/shared/policy-gateway.js +49 -0
- package/dist/shared/protected-paths.d.ts.map +1 -1
- package/dist/shared/protected-paths.js +1 -0
- package/dist/shared/runtime-artifacts.d.ts +2 -2
- package/dist/shared/runtime-artifacts.d.ts.map +1 -1
- package/dist/shared/runtime-artifacts.js +4 -0
- package/dist/workflow-runtime/build.d.ts +4 -0
- package/dist/workflow-runtime/build.d.ts.map +1 -0
- package/dist/workflow-runtime/build.js +126 -0
- package/dist/workflow-runtime/enforcement.d.ts +3 -0
- package/dist/workflow-runtime/enforcement.d.ts.map +1 -0
- package/dist/workflow-runtime/enforcement.js +10 -0
- package/dist/workflow-runtime/file-ops.d.ts +11 -0
- package/dist/workflow-runtime/file-ops.d.ts.map +1 -0
- package/dist/workflow-runtime/file-ops.js +248 -0
- package/dist/workflow-runtime/fix.d.ts +9 -0
- package/dist/workflow-runtime/fix.d.ts.map +1 -0
- package/dist/workflow-runtime/fix.js +107 -0
- package/dist/workflow-runtime/index.d.ts +11 -0
- package/dist/workflow-runtime/index.d.ts.map +1 -0
- package/dist/workflow-runtime/index.js +10 -0
- package/dist/workflow-runtime/markdown.d.ts +10 -0
- package/dist/workflow-runtime/markdown.d.ts.map +1 -0
- package/dist/workflow-runtime/markdown.js +147 -0
- package/dist/workflow-runtime/observability.d.ts +12 -0
- package/dist/workflow-runtime/observability.d.ts.map +1 -0
- package/dist/workflow-runtime/observability.js +14 -0
- package/dist/workflow-runtime/paths.d.ts +3 -0
- package/dist/workflow-runtime/paths.d.ts.map +1 -0
- package/dist/workflow-runtime/paths.js +11 -0
- package/dist/workflow-runtime/template.d.ts +7 -0
- package/dist/workflow-runtime/template.d.ts.map +1 -0
- package/dist/workflow-runtime/template.js +94 -0
- package/dist/workflow-runtime/types.d.ts +68 -0
- package/dist/workflow-runtime/types.d.ts.map +1 -0
- package/dist/workflow-runtime/types.js +1 -0
- package/dist/workflow-runtime/validate.d.ts +8 -0
- package/dist/workflow-runtime/validate.d.ts.map +1 -0
- package/dist/workflow-runtime/validate.js +331 -0
- 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.
|
|
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.
|
|
58
|
+
"@agentplaneorg/core": "0.3.1",
|
|
59
59
|
"yauzl": "^2.10.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|