agentplane 0.3.3 → 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.
@@ -0,0 +1,97 @@
1
+ import path from "node:path";
2
+ import { readFile } from "node:fs/promises";
3
+ import { DEFAULT_WORKFLOW_TEMPLATE, buildWorkflowFromTemplates, diagnosticsSummary, publishWorkflowCandidate, resolveWorkflowPaths, } from "../workflow-runtime/index.js";
4
+ import { CliError } from "./errors.js";
5
+ export function buildWorkflowRuntimeContext(opts) {
6
+ return {
7
+ workflow: {
8
+ mode: opts.workflowMode,
9
+ version: 1,
10
+ approvals: {
11
+ require_plan: opts.approvals.requirePlanApproval,
12
+ require_verify: opts.approvals.requireVerifyApproval,
13
+ require_network: opts.approvals.requireNetworkApproval,
14
+ },
15
+ },
16
+ runtime: {
17
+ repo_name: path.basename(opts.gitRoot) || "repo",
18
+ repo_root: opts.gitRoot,
19
+ timestamp: opts.timestamp ?? new Date().toISOString(),
20
+ },
21
+ };
22
+ }
23
+ async function readIfPresent(absPath) {
24
+ try {
25
+ return await readFile(absPath, "utf8");
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ export async function ensureWorkflowArtifacts(opts) {
32
+ const workflowPaths = resolveWorkflowPaths(opts.gitRoot);
33
+ const [beforeWorkflow, beforeLastKnownGood, beforeLegacyWorkflow] = await Promise.all([
34
+ readIfPresent(workflowPaths.workflowPath),
35
+ readIfPresent(workflowPaths.lastKnownGoodPath),
36
+ workflowPaths.legacyWorkflowPath === workflowPaths.workflowPath
37
+ ? Promise.resolve(null)
38
+ : readIfPresent(workflowPaths.legacyWorkflowPath),
39
+ ]);
40
+ const built = buildWorkflowFromTemplates({
41
+ baseTemplate: DEFAULT_WORKFLOW_TEMPLATE,
42
+ projectOverrideTemplate: opts.projectOverrideTemplate,
43
+ runtimeContext: buildWorkflowRuntimeContext({
44
+ gitRoot: opts.gitRoot,
45
+ workflowMode: opts.workflowMode,
46
+ approvals: opts.approvals,
47
+ }),
48
+ });
49
+ if (built.diagnostics.some((diagnostic) => diagnostic.severity === "ERROR")) {
50
+ throw new CliError({
51
+ exitCode: 3,
52
+ code: "E_VALIDATION",
53
+ message: `Failed to generate WORKFLOW.md: ${diagnosticsSummary(built.diagnostics)}`,
54
+ context: {
55
+ diagnostics: built.diagnostics.map((diagnostic) => ({
56
+ severity: diagnostic.severity,
57
+ code: diagnostic.code,
58
+ path: diagnostic.path,
59
+ message: diagnostic.message,
60
+ })),
61
+ },
62
+ });
63
+ }
64
+ const published = await publishWorkflowCandidate(opts.gitRoot, built.text);
65
+ if (!published.ok) {
66
+ throw new CliError({
67
+ exitCode: 3,
68
+ code: "E_VALIDATION",
69
+ message: `Failed to publish WORKFLOW.md: ${diagnosticsSummary(published.diagnostics)}`,
70
+ context: {
71
+ diagnostics: published.diagnostics.map((diagnostic) => ({
72
+ severity: diagnostic.severity,
73
+ code: diagnostic.code,
74
+ path: diagnostic.path,
75
+ message: diagnostic.message,
76
+ })),
77
+ },
78
+ });
79
+ }
80
+ const changedPaths = [];
81
+ if (beforeWorkflow !== built.text)
82
+ changedPaths.push(workflowPaths.workflowPath);
83
+ if (beforeLastKnownGood !== built.text)
84
+ changedPaths.push(workflowPaths.lastKnownGoodPath);
85
+ if (workflowPaths.legacyWorkflowPath !== workflowPaths.workflowPath &&
86
+ beforeLegacyWorkflow !== null) {
87
+ changedPaths.push(workflowPaths.legacyWorkflowPath);
88
+ }
89
+ const commitPaths = [
90
+ ...new Set(changedPaths.map((absPath) => path.relative(opts.gitRoot, absPath))),
91
+ ];
92
+ return {
93
+ installPaths: [workflowPaths.workflowPath, workflowPaths.lastKnownGoodPath],
94
+ commitPaths,
95
+ changedPaths,
96
+ };
97
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentplane",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Agent Plane CLI for task workflows, recipes, and project automation.",
5
5
  "keywords": [
6
6
  "agentplane",
@@ -55,7 +55,7 @@
55
55
  "prepublishOnly": "node ../../scripts/enforce-github-publish.mjs && npm run prepack"
56
56
  },
57
57
  "dependencies": {
58
- "@agentplaneorg/core": "0.3.3",
58
+ "@agentplaneorg/core": "0.3.4",
59
59
  "yauzl": "^2.10.0"
60
60
  },
61
61
  "devDependencies": {