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.
- package/assets/AGENTS.md +4 -4
- package/assets/agents/CODER.json +14 -10
- package/assets/agents/CREATOR.json +8 -6
- package/assets/agents/DOCS.json +9 -6
- package/assets/agents/INTEGRATOR.json +9 -6
- package/assets/agents/ORCHESTRATOR.json +8 -6
- package/assets/agents/PLANNER.json +8 -5
- package/assets/agents/REDMINE.json +6 -3
- package/assets/agents/REVIEWER.json +8 -6
- package/assets/agents/TESTER.json +8 -4
- package/assets/agents/UPDATER.json +6 -4
- package/assets/agents/UPGRADER.json +7 -6
- package/assets/policy/dod.code.md +2 -2
- package/assets/policy/dod.core.md +16 -2
- package/assets/policy/dod.docs.md +2 -2
- package/assets/policy/incidents.md +44 -1
- package/assets/policy/workflow.direct.md +8 -4
- package/bin/agentplane.js +59 -9
- package/bin/dist-guard.js +78 -10
- package/bin/runtime-context.d.ts +3 -0
- package/bin/runtime-context.js +13 -0
- package/bin/runtime-watch.d.ts +26 -0
- package/bin/runtime-watch.js +116 -0
- package/bin/stale-dist-policy.d.ts +6 -0
- package/bin/stale-dist-policy.js +44 -0
- package/dist/.build-manifest.json +2485 -5
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend.js +9 -12
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine-backend.js +23 -18
- package/dist/backends/task-backend/shared/constants.d.ts +1 -0
- package/dist/backends/task-backend/shared/constants.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/constants.js +1 -0
- package/dist/backends/task-backend/shared/doc.d.ts +1 -0
- package/dist/backends/task-backend/shared/doc.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/doc.js +4 -1
- package/dist/backends/task-backend/shared/export.js +3 -3
- package/dist/cli/bootstrap-guide.d.ts +2 -3
- package/dist/cli/bootstrap-guide.d.ts.map +1 -1
- package/dist/cli/bootstrap-guide.js +16 -35
- package/dist/cli/command-guide.d.ts +14 -1
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +71 -47
- package/dist/cli/run-cli/catalog.d.ts +7 -0
- package/dist/cli/run-cli/catalog.d.ts.map +1 -0
- package/dist/cli/run-cli/catalog.js +22 -0
- 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 +11 -0
- package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core.js +37 -29
- package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-config.js +2 -0
- package/dist/cli/run-cli/commands/init/write-workflow.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-workflow.js +6 -55
- package/dist/cli/run-cli/commands/init.js +5 -14
- package/dist/cli/run-cli/error-guidance.d.ts +9 -0
- package/dist/cli/run-cli/error-guidance.d.ts.map +1 -0
- package/dist/cli/run-cli/error-guidance.js +180 -0
- package/dist/cli/run-cli/globals.d.ts +22 -0
- package/dist/cli/run-cli/globals.d.ts.map +1 -0
- package/dist/cli/run-cli/globals.js +197 -0
- package/dist/cli/run-cli/update-warning.d.ts +6 -0
- package/dist/cli/run-cli/update-warning.d.ts.map +1 -0
- package/dist/cli/run-cli/update-warning.js +64 -0
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +5 -476
- package/dist/cli/spec/docs-render.d.ts.map +1 -1
- package/dist/cli/spec/docs-render.js +14 -1
- package/dist/commands/doctor/archive.d.ts +4 -0
- package/dist/commands/doctor/archive.d.ts.map +1 -0
- package/dist/commands/doctor/archive.js +211 -0
- package/dist/commands/doctor/fixes.d.ts +9 -0
- package/dist/commands/doctor/fixes.d.ts.map +1 -0
- package/dist/commands/doctor/fixes.js +40 -0
- package/dist/commands/doctor/layering.d.ts +2 -0
- package/dist/commands/doctor/layering.d.ts.map +1 -0
- package/dist/commands/doctor/layering.js +87 -0
- package/dist/commands/doctor/runtime.d.ts +4 -0
- package/dist/commands/doctor/runtime.d.ts.map +1 -0
- package/dist/commands/doctor/runtime.js +56 -0
- package/dist/commands/doctor/workflow.d.ts +6 -0
- package/dist/commands/doctor/workflow.d.ts.map +1 -0
- package/dist/commands/doctor/workflow.js +62 -0
- package/dist/commands/doctor/workspace.d.ts +2 -0
- package/dist/commands/doctor/workspace.d.ts.map +1 -0
- package/dist/commands/doctor/workspace.js +165 -0
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +16 -342
- package/dist/commands/doctor.spec.d.ts +1 -0
- package/dist/commands/doctor.spec.d.ts.map +1 -1
- package/dist/commands/doctor.spec.js +15 -1
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +19 -0
- package/dist/commands/release/apply.command.d.ts +2 -8
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +158 -387
- package/dist/commands/release/apply.mutation.d.ts +7 -0
- package/dist/commands/release/apply.mutation.d.ts.map +1 -0
- package/dist/commands/release/apply.mutation.js +107 -0
- package/dist/commands/release/apply.preflight.d.ts +25 -0
- package/dist/commands/release/apply.preflight.d.ts.map +1 -0
- package/dist/commands/release/apply.preflight.js +338 -0
- package/dist/commands/release/apply.reporting.d.ts +4 -0
- package/dist/commands/release/apply.reporting.d.ts.map +1 -0
- package/dist/commands/release/apply.reporting.js +24 -0
- package/dist/commands/release/apply.types.d.ts +46 -0
- package/dist/commands/release/apply.types.d.ts.map +1 -0
- package/dist/commands/release/apply.types.js +1 -0
- package/dist/commands/runtime.command.d.ts +28 -0
- package/dist/commands/runtime.command.d.ts.map +1 -0
- package/dist/commands/runtime.command.js +169 -0
- package/dist/commands/shared/task-store.d.ts.map +1 -1
- package/dist/commands/shared/task-store.js +7 -3
- package/dist/commands/task/add.d.ts.map +1 -1
- package/dist/commands/task/add.js +3 -33
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +2 -2
- package/dist/commands/task/close-duplicate.d.ts.map +1 -1
- package/dist/commands/task/close-duplicate.js +2 -2
- package/dist/commands/task/close-noop.d.ts.map +1 -1
- package/dist/commands/task/close-noop.js +2 -2
- package/dist/commands/task/comment.js +2 -2
- package/dist/commands/task/derive.d.ts.map +1 -1
- package/dist/commands/task/derive.js +3 -3
- package/dist/commands/task/doc-template.d.ts +10 -0
- package/dist/commands/task/doc-template.d.ts.map +1 -0
- package/dist/commands/task/doc-template.js +104 -0
- package/dist/commands/task/doc.d.ts.map +1 -1
- package/dist/commands/task/doc.js +36 -1
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +7 -4
- package/dist/commands/task/migrate-doc.command.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.command.js +5 -1
- package/dist/commands/task/migrate-doc.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.js +136 -2
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +4 -110
- package/dist/commands/task/new.spec.js +3 -3
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +5 -4
- package/dist/commands/task/scaffold.d.ts.map +1 -1
- package/dist/commands/task/scaffold.js +7 -52
- package/dist/commands/task/set-status.d.ts.map +1 -1
- package/dist/commands/task/set-status.js +2 -2
- package/dist/commands/task/shared/dependencies.d.ts +15 -0
- package/dist/commands/task/shared/dependencies.d.ts.map +1 -0
- package/dist/commands/task/shared/dependencies.js +143 -0
- package/dist/commands/task/shared/docs.d.ts +21 -0
- package/dist/commands/task/shared/docs.d.ts.map +1 -0
- package/dist/commands/task/shared/docs.js +121 -0
- package/dist/commands/task/shared/listing.d.ts +20 -0
- package/dist/commands/task/shared/listing.d.ts.map +1 -0
- package/dist/commands/task/shared/listing.js +127 -0
- package/dist/commands/task/shared/tags.d.ts +24 -0
- package/dist/commands/task/shared/tags.d.ts.map +1 -0
- package/dist/commands/task/shared/tags.js +177 -0
- package/dist/commands/task/shared/transitions.d.ts +42 -0
- package/dist/commands/task/shared/transitions.d.ts.map +1 -0
- package/dist/commands/task/shared/transitions.js +175 -0
- package/dist/commands/task/shared.d.ts +5 -106
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +5 -681
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +7 -5
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +9 -25
- package/dist/commands/task/verify-show.command.d.ts.map +1 -1
- package/dist/commands/task/verify-show.command.js +5 -1
- package/dist/commands/upgrade/apply.d.ts +44 -0
- package/dist/commands/upgrade/apply.d.ts.map +1 -0
- package/dist/commands/upgrade/apply.js +180 -0
- package/dist/commands/upgrade/report.d.ts +21 -0
- package/dist/commands/upgrade/report.d.ts.map +1 -0
- package/dist/commands/upgrade/report.js +81 -0
- package/dist/commands/upgrade/source.d.ts +35 -0
- package/dist/commands/upgrade/source.d.ts.map +1 -0
- package/dist/commands/upgrade/source.js +109 -0
- package/dist/commands/upgrade/types.d.ts +31 -0
- package/dist/commands/upgrade/types.d.ts.map +1 -0
- package/dist/commands/upgrade/types.js +1 -0
- package/dist/commands/upgrade.d.ts +1 -35
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +68 -332
- package/dist/commands/workflow-build.command.d.ts.map +1 -1
- package/dist/commands/workflow-build.command.js +9 -15
- package/dist/shared/diagnostics.d.ts +23 -0
- package/dist/shared/diagnostics.d.ts.map +1 -0
- package/dist/shared/diagnostics.js +57 -0
- package/dist/shared/errors.d.ts +2 -0
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +2 -0
- package/dist/shared/repo-cli-version.d.ts +13 -0
- package/dist/shared/repo-cli-version.d.ts.map +1 -0
- package/dist/shared/repo-cli-version.js +63 -0
- package/dist/shared/runtime-source.d.ts +33 -0
- package/dist/shared/runtime-source.d.ts.map +1 -0
- package/dist/shared/runtime-source.js +156 -0
- package/dist/shared/version-compare.d.ts +7 -0
- package/dist/shared/version-compare.d.ts.map +1 -0
- package/dist/shared/version-compare.js +30 -0
- package/dist/shared/workflow-artifacts.d.ts +37 -0
- package/dist/shared/workflow-artifacts.d.ts.map +1 -0
- package/dist/shared/workflow-artifacts.js +97 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/upgrade/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,CAAC,CAAC;IAClB,KAAK,EAAE,sBAAsB,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;IACnC,cAAc,EAAE,wBAAwB,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IACxD,WAAW,EAAE,OAAO,CAAC;IACrB,wBAAwB,EAAE,OAAO,GAAG,IAAI,CAAC;IACzC,yBAAyB,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C,0BAA0B,EAAE,OAAO,CAAC;IACpC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EACL,MAAM,GACN,mBAAmB,GACnB,MAAM,GACN,cAAc,GACd,sBAAsB,GACtB,aAAa,GACb,iBAAiB,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,44 +12,10 @@ export type UpgradeFlags = {
|
|
|
12
12
|
backup: boolean;
|
|
13
13
|
yes: boolean;
|
|
14
14
|
};
|
|
15
|
-
type GitHubRelease = {
|
|
16
|
-
tag_name?: string;
|
|
17
|
-
assets?: {
|
|
18
|
-
name?: string;
|
|
19
|
-
browser_download_url?: string;
|
|
20
|
-
}[];
|
|
21
|
-
tarball_url?: string;
|
|
22
|
-
};
|
|
23
|
-
export declare function normalizeFrameworkSourceForUpgrade(source: string): {
|
|
24
|
-
source: string;
|
|
25
|
-
owner: string;
|
|
26
|
-
repo: string;
|
|
27
|
-
migrated: boolean;
|
|
28
|
-
};
|
|
29
|
-
export declare function resolveUpgradeDownloadFromRelease(opts: {
|
|
30
|
-
release: GitHubRelease;
|
|
31
|
-
owner: string;
|
|
32
|
-
repo: string;
|
|
33
|
-
assetName: string;
|
|
34
|
-
checksumName: string;
|
|
35
|
-
}): {
|
|
36
|
-
kind: "assets";
|
|
37
|
-
bundleUrl: string;
|
|
38
|
-
checksumUrl: string;
|
|
39
|
-
} | {
|
|
40
|
-
kind: "tarball";
|
|
41
|
-
tarballUrl: string;
|
|
42
|
-
};
|
|
43
|
-
export declare function resolveRepoTarballUrl(opts: {
|
|
44
|
-
release: GitHubRelease;
|
|
45
|
-
owner: string;
|
|
46
|
-
repo: string;
|
|
47
|
-
explicitTag?: string;
|
|
48
|
-
}): string;
|
|
49
15
|
export declare function cmdUpgradeParsed(opts: {
|
|
50
16
|
cwd: string;
|
|
51
17
|
rootOverride?: string;
|
|
52
18
|
flags: UpgradeFlags;
|
|
53
19
|
}): Promise<number>;
|
|
54
|
-
export {};
|
|
20
|
+
export { normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, } from "./upgrade/source.js";
|
|
55
21
|
//# sourceMappingURL=upgrade.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AA4CA,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAuMF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsiBlB;AAED,OAAO,EACL,kCAAkC,EAClC,qBAAqB,EACrB,iCAAiC,GAClC,MAAM,qBAAqB,CAAC"}
|
package/dist/commands/upgrade.js
CHANGED
|
@@ -1,61 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { loadConfig, resolveProject
|
|
6
|
-
import {
|
|
5
|
+
import { loadConfig, resolveProject } from "@agentplaneorg/core";
|
|
6
|
+
import { fileExists, getPathKind } from "../cli/fs-utils.js";
|
|
7
7
|
import { downloadToFile, fetchJson } from "../cli/http.js";
|
|
8
8
|
import { parseSha256Text, sha256File } from "../cli/checksum.js";
|
|
9
9
|
import { extractArchive } from "../cli/archive.js";
|
|
10
|
-
import { invalidFieldMessage, invalidValueMessage, requiredFieldMessage, warnMessage, } from "../cli/output.js";
|
|
11
10
|
import { exitCodeForError } from "../cli/exit-codes.js";
|
|
11
|
+
import { warnMessage } from "../cli/output.js";
|
|
12
12
|
import { CliError } from "../shared/errors.js";
|
|
13
|
+
import { ensureWorkflowArtifacts } from "../shared/workflow-artifacts.js";
|
|
13
14
|
import { ensureNetworkApproved } from "./shared/network-approval.js";
|
|
14
|
-
import { execFileAsync, gitEnv } from "./shared/git.js";
|
|
15
15
|
import { getVersion } from "../meta/version.js";
|
|
16
|
+
import { applyManagedFiles, cleanupAutoUpgradeArtifacts, createUpgradeCommit, ensureCleanTrackedTreeForUpgrade, persistUpgradeState, } from "./upgrade/apply.js";
|
|
17
|
+
import { printUpgradeDryRun, writeUpgradeAgentReview } from "./upgrade/report.js";
|
|
18
|
+
import { describeUpgradeSource, loadFrameworkManifestFromPath, normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, resolveUpgradeRoot, } from "./upgrade/source.js";
|
|
16
19
|
const DEFAULT_UPGRADE_ASSET = "agentplane-upgrade.tar.gz";
|
|
17
20
|
const DEFAULT_UPGRADE_CHECKSUM_ASSET = "agentplane-upgrade.tar.gz.sha256";
|
|
18
21
|
const UPGRADE_DOWNLOAD_TIMEOUT_MS = 60_000;
|
|
19
22
|
const UPGRADE_RELEASE_METADATA_TIMEOUT_MS = 15_000;
|
|
20
|
-
function describeUpgradeSource(opts) {
|
|
21
|
-
if (opts.bundleLayout === "local_assets")
|
|
22
|
-
return "local installed agentplane CLI assets";
|
|
23
|
-
if (opts.bundleLayout === "repo_tarball")
|
|
24
|
-
return "GitHub repo tarball fallback";
|
|
25
|
-
if (opts.hasExplicitBundle)
|
|
26
|
-
return "explicit upgrade bundle";
|
|
27
|
-
if (opts.useRemote)
|
|
28
|
-
return "GitHub release bundle";
|
|
29
|
-
return "upgrade bundle";
|
|
30
|
-
}
|
|
31
|
-
async function safeRemovePath(targetPath) {
|
|
32
|
-
try {
|
|
33
|
-
await rm(targetPath, { recursive: true, force: true });
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
// best-effort cleanup
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function cleanupAutoUpgradeArtifacts(opts) {
|
|
40
|
-
for (const backupPath of opts.createdBackups) {
|
|
41
|
-
await safeRemovePath(backupPath);
|
|
42
|
-
}
|
|
43
|
-
// Keep durable state files at .upgrade root; remove transient per-run agent artifacts.
|
|
44
|
-
await safeRemovePath(path.join(opts.upgradeStateDir, "agent"));
|
|
45
|
-
}
|
|
46
23
|
const ASSETS_DIR_URL = new URL("../../assets/", import.meta.url);
|
|
47
|
-
async function loadFrameworkManifestFromPath(manifestPath) {
|
|
48
|
-
const text = await readFile(manifestPath, "utf8");
|
|
49
|
-
const parsed = JSON.parse(text);
|
|
50
|
-
if (parsed?.schema_version !== 1 || !Array.isArray(parsed?.files)) {
|
|
51
|
-
throw new CliError({
|
|
52
|
-
exitCode: 3,
|
|
53
|
-
code: "E_VALIDATION",
|
|
54
|
-
message: "Invalid framework.manifest.json (expected schema_version=1 and files array).",
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return parsed;
|
|
58
|
-
}
|
|
59
24
|
function isDeniedUpgradePath(relPath) {
|
|
60
25
|
if (relPath === ".agentplane/config.json")
|
|
61
26
|
return true;
|
|
@@ -75,89 +40,6 @@ function isDeniedUpgradePath(relPath) {
|
|
|
75
40
|
return true;
|
|
76
41
|
return false;
|
|
77
42
|
}
|
|
78
|
-
function parseGitHubRepo(source) {
|
|
79
|
-
const trimmed = source.trim();
|
|
80
|
-
if (!trimmed)
|
|
81
|
-
throw new Error(requiredFieldMessage("config.framework.source"));
|
|
82
|
-
if (!trimmed.includes("github.com")) {
|
|
83
|
-
throw new Error(invalidFieldMessage("config.framework.source", "GitHub URL"));
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
const url = new URL(trimmed);
|
|
87
|
-
const parts = url.pathname.replaceAll(".git", "").split("/").filter(Boolean);
|
|
88
|
-
if (parts.length < 2)
|
|
89
|
-
throw new Error(invalidValueMessage("GitHub repo URL", trimmed, "owner/repo"));
|
|
90
|
-
return { owner: parts[0], repo: parts[1] };
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
throw new Error(invalidValueMessage("GitHub repo URL", trimmed, "owner/repo"));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export function normalizeFrameworkSourceForUpgrade(source) {
|
|
97
|
-
const { owner, repo } = parseGitHubRepo(source);
|
|
98
|
-
if (owner === "basilisk-labs" && repo === "agent-plane") {
|
|
99
|
-
return {
|
|
100
|
-
source: `https://github.com/${owner}/agentplane`,
|
|
101
|
-
owner,
|
|
102
|
-
repo: "agentplane",
|
|
103
|
-
migrated: true,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
return { source: `https://github.com/${owner}/${repo}`, owner, repo, migrated: false };
|
|
107
|
-
}
|
|
108
|
-
export function resolveUpgradeDownloadFromRelease(opts) {
|
|
109
|
-
const assets = Array.isArray(opts.release.assets) ? opts.release.assets : [];
|
|
110
|
-
const asset = assets.find((a) => a?.name === opts.assetName);
|
|
111
|
-
const checksumAsset = assets.find((a) => a?.name === opts.checksumName);
|
|
112
|
-
if (asset?.browser_download_url && checksumAsset?.browser_download_url) {
|
|
113
|
-
return {
|
|
114
|
-
kind: "assets",
|
|
115
|
-
bundleUrl: asset.browser_download_url,
|
|
116
|
-
checksumUrl: checksumAsset.browser_download_url,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
const tarballUrl = typeof opts.release.tarball_url === "string" ? opts.release.tarball_url : "";
|
|
120
|
-
if (!tarballUrl) {
|
|
121
|
-
throw new CliError({
|
|
122
|
-
exitCode: exitCodeForError("E_NETWORK"),
|
|
123
|
-
code: "E_NETWORK",
|
|
124
|
-
message: `Upgrade assets not found in ${opts.owner}/${opts.repo} release`,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return { kind: "tarball", tarballUrl };
|
|
128
|
-
}
|
|
129
|
-
function buildCodeloadTarGzUrl(opts) {
|
|
130
|
-
// Prefer codeload over api.github.com tarball_url. It is less brittle and does not require
|
|
131
|
-
// GitHub API-specific behavior/rate limits.
|
|
132
|
-
const tag = opts.tag.trim();
|
|
133
|
-
if (!tag)
|
|
134
|
-
throw new Error("tag is required");
|
|
135
|
-
return `https://codeload.github.com/${opts.owner}/${opts.repo}/tar.gz/${encodeURIComponent(tag)}`;
|
|
136
|
-
}
|
|
137
|
-
export function resolveRepoTarballUrl(opts) {
|
|
138
|
-
const tag = (typeof opts.explicitTag === "string" && opts.explicitTag.trim()) ||
|
|
139
|
-
(typeof opts.release.tag_name === "string" && opts.release.tag_name.trim()) ||
|
|
140
|
-
"";
|
|
141
|
-
if (tag)
|
|
142
|
-
return buildCodeloadTarGzUrl({ owner: opts.owner, repo: opts.repo, tag });
|
|
143
|
-
const tarballUrl = typeof opts.release.tarball_url === "string" ? opts.release.tarball_url : "";
|
|
144
|
-
if (tarballUrl)
|
|
145
|
-
return tarballUrl;
|
|
146
|
-
throw new CliError({
|
|
147
|
-
exitCode: exitCodeForError("E_NETWORK"),
|
|
148
|
-
code: "E_NETWORK",
|
|
149
|
-
message: "GitHub release did not provide tag_name or tarball_url; cannot fall back to repo tarball.",
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
async function resolveUpgradeRoot(extractedDir) {
|
|
153
|
-
const entries = await readdir(extractedDir, { withFileTypes: true });
|
|
154
|
-
const dirs = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
155
|
-
const files = entries.filter((entry) => entry.isFile()).map((entry) => entry.name);
|
|
156
|
-
if (files.length === 0 && dirs.length === 1) {
|
|
157
|
-
return path.join(extractedDir, dirs[0]);
|
|
158
|
-
}
|
|
159
|
-
return extractedDir;
|
|
160
|
-
}
|
|
161
43
|
function isAllowedUpgradePath(relPath) {
|
|
162
44
|
if (relPath === "AGENTS.md")
|
|
163
45
|
return true;
|
|
@@ -308,73 +190,9 @@ function normalizeUpgradeVersionLabel(input) {
|
|
|
308
190
|
return trimmed;
|
|
309
191
|
return `v${trimmed}`;
|
|
310
192
|
}
|
|
311
|
-
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
env: gitEnv(),
|
|
315
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
316
|
-
});
|
|
317
|
-
const dirty = String(stdout ?? "")
|
|
318
|
-
.split(/\r?\n/u)
|
|
319
|
-
.map((line) => line.trimEnd())
|
|
320
|
-
.filter((line) => line.length > 0);
|
|
321
|
-
if (dirty.length === 0)
|
|
322
|
-
return;
|
|
323
|
-
throw new CliError({
|
|
324
|
-
exitCode: exitCodeForError("E_GIT"),
|
|
325
|
-
code: "E_GIT",
|
|
326
|
-
message: "Upgrade --auto requires a clean tracked working tree.\n" +
|
|
327
|
-
`Found tracked changes:\n${dirty.map((line) => ` ${line}`).join("\n")}`,
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
async function createUpgradeCommit(opts) {
|
|
331
|
-
const uniquePaths = [...new Set(opts.paths.filter(Boolean))];
|
|
332
|
-
if (uniquePaths.length === 0)
|
|
333
|
-
return null;
|
|
334
|
-
await execFileAsync("git", ["add", "--", ...uniquePaths], {
|
|
335
|
-
cwd: opts.gitRoot,
|
|
336
|
-
env: gitEnv(),
|
|
337
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
338
|
-
});
|
|
339
|
-
const { stdout: stagedOut } = await execFileAsync("git", ["diff", "--cached", "--name-only", "-z"], {
|
|
340
|
-
cwd: opts.gitRoot,
|
|
341
|
-
env: gitEnv(),
|
|
342
|
-
encoding: "buffer",
|
|
343
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
344
|
-
});
|
|
345
|
-
const staged = (Buffer.isBuffer(stagedOut) ? stagedOut.toString("utf8") : String(stagedOut ?? ""))
|
|
346
|
-
.split("\0")
|
|
347
|
-
.map((entry) => entry.trim())
|
|
348
|
-
.some(Boolean);
|
|
349
|
-
if (!staged)
|
|
350
|
-
return null;
|
|
351
|
-
const subject = `⬆️ upgrade: apply framework ${opts.versionLabel}`;
|
|
352
|
-
const body = `Upgrade-Version: ${opts.versionLabel}\n` +
|
|
353
|
-
`Source: ${opts.source}\n` +
|
|
354
|
-
`Managed-Changes: add=${opts.additions}, update=${opts.updates}, unchanged=${opts.unchanged}\n` +
|
|
355
|
-
`Incidents-Appended: ${opts.incidentsAppendedCount}\n`;
|
|
356
|
-
try {
|
|
357
|
-
await execFileAsync("git", ["commit", "-m", subject, "-m", body], {
|
|
358
|
-
cwd: opts.gitRoot,
|
|
359
|
-
env: gitEnv(),
|
|
360
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
catch (err) {
|
|
364
|
-
const details = err?.stderr ?? "";
|
|
365
|
-
throw new CliError({
|
|
366
|
-
exitCode: exitCodeForError("E_GIT"),
|
|
367
|
-
code: "E_GIT",
|
|
368
|
-
message: "Upgrade applied but failed to create the upgrade commit.\n" +
|
|
369
|
-
"Fix commit policy/hook issues and commit the staged upgrade files as a dedicated upgrade commit.\n" +
|
|
370
|
-
(String(details).trim() ? `Details:\n${String(details).trim()}` : ""),
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
const { stdout: hashOut } = await execFileAsync("git", ["rev-parse", "HEAD"], {
|
|
374
|
-
cwd: opts.gitRoot,
|
|
375
|
-
env: gitEnv(),
|
|
376
|
-
});
|
|
377
|
-
return { hash: String(hashOut ?? "").trim(), subject };
|
|
193
|
+
function normalizeVersionForConfig(input) {
|
|
194
|
+
const trimmed = input.trim().replace(/^v/i, "");
|
|
195
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
378
196
|
}
|
|
379
197
|
export async function cmdUpgradeParsed(opts) {
|
|
380
198
|
const flags = opts.flags;
|
|
@@ -771,15 +589,7 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
771
589
|
});
|
|
772
590
|
}
|
|
773
591
|
if (flags.dryRun) {
|
|
774
|
-
|
|
775
|
-
for (const rel of additions)
|
|
776
|
-
process.stdout.write(`ADD ${rel}\n`);
|
|
777
|
-
for (const rel of updates)
|
|
778
|
-
process.stdout.write(`UPDATE ${rel}\n`);
|
|
779
|
-
for (const rel of skipped)
|
|
780
|
-
process.stdout.write(`SKIP ${rel}\n`);
|
|
781
|
-
for (const rel of merged)
|
|
782
|
-
process.stdout.write(`MERGE ${rel}\n`);
|
|
592
|
+
printUpgradeDryRun({ additions, updates, skipped, merged });
|
|
783
593
|
return 0;
|
|
784
594
|
}
|
|
785
595
|
const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
|
|
@@ -790,142 +600,64 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
790
600
|
process.stdout.write("Upgrade plan: no managed changes detected\n");
|
|
791
601
|
return 0;
|
|
792
602
|
}
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
`- unchanged: ${skipped.length}\n` +
|
|
804
|
-
`- merged (auto-safe transforms already applied to incoming): ${merged.length}\n\n` +
|
|
805
|
-
`## Managed files (manifest)\n\n` +
|
|
806
|
-
managedFiles.map((p) => `- ${p}`).join("\n") +
|
|
807
|
-
`\n\n` +
|
|
808
|
-
`## Proposed changes\n\n` +
|
|
809
|
-
additions.map((p) => `- ADD ${p}`).join("\n") +
|
|
810
|
-
(additions.length > 0 ? "\n" : "") +
|
|
811
|
-
updates.map((p) => `- UPDATE ${p}`).join("\n") +
|
|
812
|
-
(updates.length > 0 ? "\n" : "") +
|
|
813
|
-
merged.map((p) => `- MERGE ${p}`).join("\n") +
|
|
814
|
-
(merged.length > 0 ? "\n" : "") +
|
|
815
|
-
skipped.map((p) => `- SKIP ${p}`).join("\n") +
|
|
816
|
-
(skipped.length > 0 ? "\n" : "") +
|
|
817
|
-
`\n` +
|
|
818
|
-
`## Next steps\n\n` +
|
|
819
|
-
`1. Review the proposed changes list.\n` +
|
|
820
|
-
`2. Apply changes manually or re-run without \`--agent\` to apply managed files.\n` +
|
|
821
|
-
`3. Run \`agentplane doctor\` (or \`agentplane doctor --fix\`) and ensure checks pass.\n`;
|
|
822
|
-
const constraintsMd = `# Upgrade constraints\n\n` +
|
|
823
|
-
`This upgrade is restricted to framework-managed files only.\n\n` +
|
|
824
|
-
`## Must not touch\n\n` +
|
|
825
|
-
`- .agentplane/tasks/** (task data)\n` +
|
|
826
|
-
`- .agentplane/tasks.json (export snapshot)\n` +
|
|
827
|
-
`- .agentplane/backends/** (backend configuration)\n` +
|
|
828
|
-
`- .agentplane/config.json (project config)\n` +
|
|
829
|
-
`- .git/**\n\n` +
|
|
830
|
-
`## Notes\n\n` +
|
|
831
|
-
`- The upgrade bundle is validated against framework.manifest.json.\n` +
|
|
832
|
-
`- The policy gateway file at workspace root is AGENTS.md or CLAUDE.md.\n`;
|
|
833
|
-
const reportMd = `# Upgrade report (${runId})\n\n` +
|
|
834
|
-
`## Actions taken\n\n` +
|
|
835
|
-
`- [ ] Reviewed plan.md\n` +
|
|
836
|
-
`- [ ] Applied changes (manual or --auto)\n` +
|
|
837
|
-
`- [ ] Ran doctor\n` +
|
|
838
|
-
`- [ ] Ran tests / lint\n\n` +
|
|
839
|
-
`## Notes\n\n` +
|
|
840
|
-
`- \n`;
|
|
841
|
-
await writeFile(path.join(runDir, "plan.md"), planMd, "utf8");
|
|
842
|
-
await writeFile(path.join(runDir, "constraints.md"), constraintsMd, "utf8");
|
|
843
|
-
await writeFile(path.join(runDir, "report.md"), reportMd, "utf8");
|
|
844
|
-
await writeFile(path.join(runDir, "files.json"), JSON.stringify({ additions, updates, skipped, merged }, null, 2) + "\n", "utf8");
|
|
845
|
-
await writeFile(path.join(runDir, "review.json"), JSON.stringify({
|
|
846
|
-
generated_at: new Date().toISOString(),
|
|
847
|
-
counts: {
|
|
848
|
-
total: reviewRecords.length,
|
|
849
|
-
needsSemanticReview: needsReview.length,
|
|
850
|
-
},
|
|
851
|
-
files: reviewRecords,
|
|
852
|
-
}, null, 2) + "\n", "utf8");
|
|
853
|
-
const relRunDir = path.relative(resolved.gitRoot, runDir);
|
|
603
|
+
const { relRunDir, needsReviewCount } = await writeUpgradeAgentReview({
|
|
604
|
+
gitRoot: resolved.gitRoot,
|
|
605
|
+
runRoot: path.join(upgradeStateDir, "agent"),
|
|
606
|
+
manifest,
|
|
607
|
+
additions,
|
|
608
|
+
updates,
|
|
609
|
+
skipped,
|
|
610
|
+
merged,
|
|
611
|
+
reviewRecords,
|
|
612
|
+
});
|
|
854
613
|
process.stdout.write(`Upgrade plan written: ${relRunDir}\n`);
|
|
855
|
-
process.stdout.write(`Review-required files: ${
|
|
614
|
+
process.stdout.write(`Review-required files: ${needsReviewCount}\n`);
|
|
856
615
|
return 0;
|
|
857
616
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
// If policy gateway file is a symlink, avoid overwriting an arbitrary external target.
|
|
869
|
-
// This permits repo-internal symlinks (e.g. the agentplane repo itself) while
|
|
870
|
-
// keeping user workspaces safe.
|
|
871
|
-
try {
|
|
872
|
-
const st = await lstat(destPath);
|
|
873
|
-
if (st.isSymbolicLink()) {
|
|
874
|
-
const linkTarget = await readlink(destPath);
|
|
875
|
-
const targetAbs = path.resolve(path.dirname(destPath), linkTarget);
|
|
876
|
-
const relFromRoot = path.relative(resolved.gitRoot, targetAbs);
|
|
877
|
-
if (relFromRoot.startsWith("..") || path.isAbsolute(relFromRoot)) {
|
|
878
|
-
throw new CliError({
|
|
879
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
880
|
-
code: "E_VALIDATION",
|
|
881
|
-
message: `Refusing to overwrite symlinked ${rel} target outside repo: ${linkTarget}. ` +
|
|
882
|
-
"Replace the symlink with a regular file and retry.",
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
catch (err) {
|
|
888
|
-
const code = err?.code;
|
|
889
|
-
if (code !== "ENOENT")
|
|
890
|
-
throw err;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
await writeFile(destPath, data);
|
|
894
|
-
}
|
|
895
|
-
// Record a baseline copy for future three-way merges.
|
|
896
|
-
const baselineKey = toBaselineKey(rel);
|
|
897
|
-
if (baselineKey && data) {
|
|
898
|
-
const baselinePath = path.join(baselineDirNew, baselineKey);
|
|
899
|
-
await mkdir(path.dirname(baselinePath), { recursive: true });
|
|
900
|
-
await writeFile(baselinePath, data);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
617
|
+
await applyManagedFiles({
|
|
618
|
+
gitRoot: resolved.gitRoot,
|
|
619
|
+
additions,
|
|
620
|
+
updates,
|
|
621
|
+
backup: flags.backup,
|
|
622
|
+
fileContents,
|
|
623
|
+
baselineDir: baselineDirNew,
|
|
624
|
+
createdBackups,
|
|
625
|
+
toBaselineKey,
|
|
626
|
+
});
|
|
903
627
|
const hasManagedMutations = additions.length > 0 || updates.length > 0;
|
|
904
|
-
const
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
await saveConfig(resolved.agentplaneDir, raw);
|
|
913
|
-
}
|
|
914
|
-
await writeFile(statePath, JSON.stringify({
|
|
915
|
-
applied_at: new Date().toISOString(),
|
|
628
|
+
const shouldMutateConfig = await persistUpgradeState({
|
|
629
|
+
agentplaneDir: resolved.agentplaneDir,
|
|
630
|
+
rawConfig: loaded.raw,
|
|
631
|
+
normalizedSourceToPersist,
|
|
632
|
+
expectedCliVersionToPersist: normalizeVersionForConfig(upgradeVersionLabel),
|
|
633
|
+
hasManagedMutations,
|
|
634
|
+
statePath,
|
|
635
|
+
upgradeStateDir,
|
|
916
636
|
source: bundleLayout,
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
637
|
+
reviewRecords,
|
|
638
|
+
additions: additions.length,
|
|
639
|
+
updates: updates.length,
|
|
640
|
+
skipped: skipped.length,
|
|
641
|
+
});
|
|
642
|
+
const orchestratorProfilePath = path.join(resolved.agentplaneDir, "agents", "ORCHESTRATOR.json");
|
|
643
|
+
const workflowArtifacts = (await fileExists(orchestratorProfilePath))
|
|
644
|
+
? await ensureWorkflowArtifacts({
|
|
645
|
+
gitRoot: resolved.gitRoot,
|
|
646
|
+
workflowMode: loaded.config.workflow_mode,
|
|
647
|
+
approvals: {
|
|
648
|
+
requirePlanApproval: loaded.config.agents?.approvals?.require_plan ?? true,
|
|
649
|
+
requireVerifyApproval: loaded.config.agents?.approvals?.require_verify ?? true,
|
|
650
|
+
requireNetworkApproval: loaded.config.agents?.approvals?.require_network ?? true,
|
|
651
|
+
},
|
|
652
|
+
})
|
|
653
|
+
: { installPaths: [], commitPaths: [], changedPaths: [] };
|
|
927
654
|
const commitPaths = [
|
|
928
|
-
...new Set([
|
|
655
|
+
...new Set([
|
|
656
|
+
...additions,
|
|
657
|
+
...updates,
|
|
658
|
+
...workflowArtifacts.commitPaths,
|
|
659
|
+
...(shouldMutateConfig ? [CONFIG_REL_PATH] : []),
|
|
660
|
+
]),
|
|
929
661
|
];
|
|
930
662
|
const commit = await createUpgradeCommit({
|
|
931
663
|
gitRoot: resolved.gitRoot,
|
|
@@ -939,6 +671,9 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
939
671
|
});
|
|
940
672
|
await cleanupAutoUpgradeArtifacts({ upgradeStateDir, createdBackups });
|
|
941
673
|
process.stdout.write(`Upgrade applied: ${additions.length} add, ${updates.length} update, ${skipped.length} unchanged\n`);
|
|
674
|
+
if (workflowArtifacts.changedPaths.length > 0) {
|
|
675
|
+
process.stdout.write(`Workflow artifacts refreshed: ${workflowArtifacts.commitPaths.join(", ")}\n`);
|
|
676
|
+
}
|
|
942
677
|
if (commit) {
|
|
943
678
|
process.stdout.write(`Upgrade commit: ${commit.hash.slice(0, 12)} ${commit.subject}\n`);
|
|
944
679
|
}
|
|
@@ -959,3 +694,4 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
959
694
|
}
|
|
960
695
|
}
|
|
961
696
|
}
|
|
697
|
+
export { normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, } from "./upgrade/source.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-build.command.d.ts","sourceRoot":"","sources":["../../src/commands/workflow-build.command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-build.command.d.ts","sourceRoot":"","sources":["../../src/commands/workflow-build.command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAYvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAgC9D,CAAC;AAWF,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,mBAAmB,CAoEhE,CAAC"}
|
|
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { loadConfig, resolveProject } from "@agentplaneorg/core";
|
|
4
4
|
import { successMessage, warnMessage } from "../cli/output.js";
|
|
5
|
+
import { buildWorkflowRuntimeContext } from "../shared/workflow-artifacts.js";
|
|
5
6
|
import { DEFAULT_WORKFLOW_TEMPLATE, buildWorkflowFromTemplates, diagnosticsSummary, publishWorkflowCandidate, resolveWorkflowPaths, validateWorkflowText, } from "../workflow-runtime/index.js";
|
|
6
7
|
export const workflowBuildSpec = {
|
|
7
8
|
id: ["workflow", "build"],
|
|
@@ -50,22 +51,15 @@ export const runWorkflowBuild = async (ctx, flags) => {
|
|
|
50
51
|
const configLoaded = await loadConfig(resolved.agentplaneDir);
|
|
51
52
|
const workflowPaths = resolveWorkflowPaths(resolved.gitRoot);
|
|
52
53
|
const configApprovals = configLoaded.config.agents?.approvals;
|
|
53
|
-
const runtimeContext = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
require_network: configApprovals?.require_network ?? true,
|
|
61
|
-
},
|
|
54
|
+
const runtimeContext = buildWorkflowRuntimeContext({
|
|
55
|
+
gitRoot: resolved.gitRoot,
|
|
56
|
+
workflowMode: configLoaded.config.workflow_mode,
|
|
57
|
+
approvals: {
|
|
58
|
+
requirePlanApproval: configApprovals?.require_plan ?? true,
|
|
59
|
+
requireVerifyApproval: configApprovals?.require_verify ?? true,
|
|
60
|
+
requireNetworkApproval: configApprovals?.require_network ?? true,
|
|
62
61
|
},
|
|
63
|
-
|
|
64
|
-
repo_name: path.basename(resolved.gitRoot),
|
|
65
|
-
repo_root: resolved.gitRoot,
|
|
66
|
-
timestamp: new Date().toISOString(),
|
|
67
|
-
},
|
|
68
|
-
};
|
|
62
|
+
});
|
|
69
63
|
const overrideTemplate = await maybeReadOverride(workflowPaths);
|
|
70
64
|
const built = buildWorkflowFromTemplates({
|
|
71
65
|
baseTemplate: DEFAULT_WORKFLOW_TEMPLATE,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type DiagnosticNextAction = {
|
|
2
|
+
command: string;
|
|
3
|
+
reason: string;
|
|
4
|
+
reasonCode?: string;
|
|
5
|
+
};
|
|
6
|
+
export type DiagnosticInfo = {
|
|
7
|
+
state: string;
|
|
8
|
+
likelyCause: string;
|
|
9
|
+
nextAction?: DiagnosticNextAction;
|
|
10
|
+
hint?: string;
|
|
11
|
+
};
|
|
12
|
+
type DiagnosticContextRecord = Record<string, unknown>;
|
|
13
|
+
export declare function withDiagnosticContext(context: DiagnosticContextRecord | undefined, diagnostic: DiagnosticInfo): DiagnosticContextRecord;
|
|
14
|
+
export declare function readDiagnosticContext(context: DiagnosticContextRecord | undefined): Partial<DiagnosticInfo>;
|
|
15
|
+
export declare function renderDiagnosticFinding(opts: {
|
|
16
|
+
severity: "ERROR" | "WARN" | "INFO";
|
|
17
|
+
state: string;
|
|
18
|
+
likelyCause: string;
|
|
19
|
+
nextAction?: DiagnosticNextAction;
|
|
20
|
+
details?: string[];
|
|
21
|
+
}): string;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/shared/diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMvD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,uBAAuB,GAAG,SAAS,EAC5C,UAAU,EAAE,cAAc,GACzB,uBAAuB,CAiBzB;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,uBAAuB,GAAG,SAAS,GAC3C,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,MAAM,CAaT"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function readString(value) {
|
|
2
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
3
|
+
}
|
|
4
|
+
export function withDiagnosticContext(context, diagnostic) {
|
|
5
|
+
const base = context ? { ...context } : {};
|
|
6
|
+
return {
|
|
7
|
+
...base,
|
|
8
|
+
diagnostic_state: diagnostic.state,
|
|
9
|
+
diagnostic_likely_cause: diagnostic.likelyCause,
|
|
10
|
+
...(diagnostic.hint ? { diagnostic_hint: diagnostic.hint } : {}),
|
|
11
|
+
...(diagnostic.nextAction
|
|
12
|
+
? {
|
|
13
|
+
diagnostic_next_action_command: diagnostic.nextAction.command,
|
|
14
|
+
diagnostic_next_action_reason: diagnostic.nextAction.reason,
|
|
15
|
+
...(diagnostic.nextAction.reasonCode
|
|
16
|
+
? { diagnostic_next_action_reason_code: diagnostic.nextAction.reasonCode }
|
|
17
|
+
: {}),
|
|
18
|
+
}
|
|
19
|
+
: {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function readDiagnosticContext(context) {
|
|
23
|
+
const state = readString(context?.diagnostic_state);
|
|
24
|
+
const likelyCause = readString(context?.diagnostic_likely_cause);
|
|
25
|
+
const hint = readString(context?.diagnostic_hint);
|
|
26
|
+
const nextActionCommand = readString(context?.diagnostic_next_action_command);
|
|
27
|
+
const nextActionReason = readString(context?.diagnostic_next_action_reason);
|
|
28
|
+
const nextActionReasonCode = readString(context?.diagnostic_next_action_reason_code);
|
|
29
|
+
return {
|
|
30
|
+
state,
|
|
31
|
+
likelyCause,
|
|
32
|
+
hint,
|
|
33
|
+
nextAction: nextActionCommand && nextActionReason
|
|
34
|
+
? {
|
|
35
|
+
command: nextActionCommand,
|
|
36
|
+
reason: nextActionReason,
|
|
37
|
+
...(nextActionReasonCode ? { reasonCode: nextActionReasonCode } : {}),
|
|
38
|
+
}
|
|
39
|
+
: undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function renderDiagnosticFinding(opts) {
|
|
43
|
+
const lines = [`[${opts.severity}] State: ${opts.state}`, `Likely cause: ${opts.likelyCause}`];
|
|
44
|
+
if (opts.nextAction) {
|
|
45
|
+
lines.push(`Next action: ${opts.nextAction.command} (${opts.nextAction.reason})`);
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(opts.details) && opts.details.length > 0) {
|
|
48
|
+
const [first, ...rest] = opts.details;
|
|
49
|
+
if (first)
|
|
50
|
+
lines.push(`Details: ${first}`);
|
|
51
|
+
for (const detail of rest) {
|
|
52
|
+
if (detail.trim())
|
|
53
|
+
lines.push(` - ${detail}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return lines.join("\n");
|
|
57
|
+
}
|