agentplane 0.3.2 → 0.3.3
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 +1 -1
- package/assets/agents/CODER.json +4 -3
- package/assets/agents/DOCS.json +1 -1
- package/assets/agents/INTEGRATOR.json +1 -1
- package/assets/agents/ORCHESTRATOR.json +1 -0
- package/assets/agents/PLANNER.json +1 -0
- package/assets/agents/TESTER.json +3 -1
- 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 +2480 -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 +1 -3
- package/dist/cli/bootstrap-guide.d.ts.map +1 -1
- package/dist/cli/bootstrap-guide.js +13 -33
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +27 -34
- 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/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.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 +46 -331
- 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/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":"AA2CA,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,CA4gBlB;AAED,OAAO,EACL,kCAAkC,EAClC,qBAAqB,EACrB,iCAAiC,GAClC,MAAM,qBAAqB,CAAC"}
|
package/dist/commands/upgrade.js
CHANGED
|
@@ -1,61 +1,25 @@
|
|
|
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
13
|
import { ensureNetworkApproved } from "./shared/network-approval.js";
|
|
14
|
-
import { execFileAsync, gitEnv } from "./shared/git.js";
|
|
15
14
|
import { getVersion } from "../meta/version.js";
|
|
15
|
+
import { applyManagedFiles, cleanupAutoUpgradeArtifacts, createUpgradeCommit, ensureCleanTrackedTreeForUpgrade, persistUpgradeState, } from "./upgrade/apply.js";
|
|
16
|
+
import { printUpgradeDryRun, writeUpgradeAgentReview } from "./upgrade/report.js";
|
|
17
|
+
import { describeUpgradeSource, loadFrameworkManifestFromPath, normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, resolveUpgradeRoot, } from "./upgrade/source.js";
|
|
16
18
|
const DEFAULT_UPGRADE_ASSET = "agentplane-upgrade.tar.gz";
|
|
17
19
|
const DEFAULT_UPGRADE_CHECKSUM_ASSET = "agentplane-upgrade.tar.gz.sha256";
|
|
18
20
|
const UPGRADE_DOWNLOAD_TIMEOUT_MS = 60_000;
|
|
19
21
|
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
22
|
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
23
|
function isDeniedUpgradePath(relPath) {
|
|
60
24
|
if (relPath === ".agentplane/config.json")
|
|
61
25
|
return true;
|
|
@@ -75,89 +39,6 @@ function isDeniedUpgradePath(relPath) {
|
|
|
75
39
|
return true;
|
|
76
40
|
return false;
|
|
77
41
|
}
|
|
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
42
|
function isAllowedUpgradePath(relPath) {
|
|
162
43
|
if (relPath === "AGENTS.md")
|
|
163
44
|
return true;
|
|
@@ -308,73 +189,9 @@ function normalizeUpgradeVersionLabel(input) {
|
|
|
308
189
|
return trimmed;
|
|
309
190
|
return `v${trimmed}`;
|
|
310
191
|
}
|
|
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 };
|
|
192
|
+
function normalizeVersionForConfig(input) {
|
|
193
|
+
const trimmed = input.trim().replace(/^v/i, "");
|
|
194
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
378
195
|
}
|
|
379
196
|
export async function cmdUpgradeParsed(opts) {
|
|
380
197
|
const flags = opts.flags;
|
|
@@ -771,15 +588,7 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
771
588
|
});
|
|
772
589
|
}
|
|
773
590
|
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`);
|
|
591
|
+
printUpgradeDryRun({ additions, updates, skipped, merged });
|
|
783
592
|
return 0;
|
|
784
593
|
}
|
|
785
594
|
const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
|
|
@@ -790,140 +599,45 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
790
599
|
process.stdout.write("Upgrade plan: no managed changes detected\n");
|
|
791
600
|
return 0;
|
|
792
601
|
}
|
|
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);
|
|
602
|
+
const { relRunDir, needsReviewCount } = await writeUpgradeAgentReview({
|
|
603
|
+
gitRoot: resolved.gitRoot,
|
|
604
|
+
runRoot: path.join(upgradeStateDir, "agent"),
|
|
605
|
+
manifest,
|
|
606
|
+
additions,
|
|
607
|
+
updates,
|
|
608
|
+
skipped,
|
|
609
|
+
merged,
|
|
610
|
+
reviewRecords,
|
|
611
|
+
});
|
|
854
612
|
process.stdout.write(`Upgrade plan written: ${relRunDir}\n`);
|
|
855
|
-
process.stdout.write(`Review-required files: ${
|
|
613
|
+
process.stdout.write(`Review-required files: ${needsReviewCount}\n`);
|
|
856
614
|
return 0;
|
|
857
615
|
}
|
|
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
|
-
}
|
|
616
|
+
await applyManagedFiles({
|
|
617
|
+
gitRoot: resolved.gitRoot,
|
|
618
|
+
additions,
|
|
619
|
+
updates,
|
|
620
|
+
backup: flags.backup,
|
|
621
|
+
fileContents,
|
|
622
|
+
baselineDir: baselineDirNew,
|
|
623
|
+
createdBackups,
|
|
624
|
+
toBaselineKey,
|
|
625
|
+
});
|
|
903
626
|
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(),
|
|
627
|
+
const shouldMutateConfig = await persistUpgradeState({
|
|
628
|
+
agentplaneDir: resolved.agentplaneDir,
|
|
629
|
+
rawConfig: loaded.raw,
|
|
630
|
+
normalizedSourceToPersist,
|
|
631
|
+
expectedCliVersionToPersist: normalizeVersionForConfig(upgradeVersionLabel),
|
|
632
|
+
hasManagedMutations,
|
|
633
|
+
statePath,
|
|
634
|
+
upgradeStateDir,
|
|
916
635
|
source: bundleLayout,
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
total: reviewRecords.length,
|
|
923
|
-
needsSemanticReview: reviewRecords.filter((r) => r.needsSemanticReview).length,
|
|
924
|
-
},
|
|
925
|
-
files: reviewRecords,
|
|
926
|
-
}, null, 2) + "\n", "utf8");
|
|
636
|
+
reviewRecords,
|
|
637
|
+
additions: additions.length,
|
|
638
|
+
updates: updates.length,
|
|
639
|
+
skipped: skipped.length,
|
|
640
|
+
});
|
|
927
641
|
const commitPaths = [
|
|
928
642
|
...new Set([...additions, ...updates, ...(shouldMutateConfig ? [CONFIG_REL_PATH] : [])]),
|
|
929
643
|
];
|
|
@@ -959,3 +673,4 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
959
673
|
}
|
|
960
674
|
}
|
|
961
675
|
}
|
|
676
|
+
export { normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, } from "./upgrade/source.js";
|
|
@@ -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
|
+
}
|
package/dist/shared/errors.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/shared/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,cAAc,GACd,MAAM,GACN,OAAO,GACP,WAAW,GACX,WAAW,GACX,YAAY,CAAC;AAEjB,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEtC,IAAI,EAAE;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,SAAS,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC;CAMF;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,YAAY,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/shared/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,cAAc,GACd,MAAM,GACN,OAAO,GACP,WAAW,GACX,WAAW,GACX,YAAY,CAAC;AAEjB,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEtC,IAAI,EAAE;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,SAAS,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC;CAMF;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,YAAY,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAiBnF"}
|
package/dist/shared/errors.js
CHANGED
|
@@ -15,6 +15,8 @@ export function formatJsonError(err, guidance) {
|
|
|
15
15
|
code: err.code,
|
|
16
16
|
message: err.message,
|
|
17
17
|
context: err.context ?? undefined,
|
|
18
|
+
state: guidance?.state,
|
|
19
|
+
likely_cause: guidance?.likelyCause,
|
|
18
20
|
hint: guidance?.hint,
|
|
19
21
|
next_action: guidance?.nextAction,
|
|
20
22
|
reason_decode: guidance?.reasonDecode,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentplaneConfig } from "@agentplaneorg/core";
|
|
2
|
+
import type { RuntimeSourceInfo } from "./runtime-source.js";
|
|
3
|
+
export type RepoCliVersionState = "unconfigured" | "satisfied" | "older_than_expected" | "active_version_unresolved";
|
|
4
|
+
export type RepoCliVersionExpectation = {
|
|
5
|
+
expectedVersion: string | null;
|
|
6
|
+
activeVersion: string | null;
|
|
7
|
+
state: RepoCliVersionState;
|
|
8
|
+
summary: string | null;
|
|
9
|
+
recovery: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function getRepoExpectedCliVersion(config: AgentplaneConfig): string | null;
|
|
12
|
+
export declare function evaluateRepoCliVersionExpectation(config: AgentplaneConfig, runtime: RuntimeSourceInfo): RepoCliVersionExpectation;
|
|
13
|
+
//# sourceMappingURL=repo-cli-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-cli-version.d.ts","sourceRoot":"","sources":["../../src/shared/repo-cli-version.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,WAAW,GACX,qBAAqB,GACrB,2BAA2B,CAAC;AAEhC,MAAM,MAAM,yBAAyB,GAAG;IACtC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,mBAAmB,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAKjF;AAqBD,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,iBAAiB,GACzB,yBAAyB,CAuC3B"}
|