agentplane 0.3.1 → 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.
Files changed (201) hide show
  1. package/assets/AGENTS.md +5 -4
  2. package/assets/agents/CODER.json +4 -3
  3. package/assets/agents/DOCS.json +1 -1
  4. package/assets/agents/INTEGRATOR.json +1 -1
  5. package/assets/agents/ORCHESTRATOR.json +1 -0
  6. package/assets/agents/PLANNER.json +1 -0
  7. package/assets/agents/TESTER.json +3 -1
  8. package/assets/policy/dod.code.md +2 -2
  9. package/assets/policy/dod.core.md +16 -2
  10. package/assets/policy/dod.docs.md +2 -2
  11. package/assets/policy/incidents.md +44 -1
  12. package/assets/policy/workflow.direct.md +10 -5
  13. package/bin/agentplane.js +116 -18
  14. package/bin/dist-guard.js +78 -10
  15. package/bin/runtime-context.d.ts +23 -0
  16. package/bin/runtime-context.js +94 -0
  17. package/bin/runtime-watch.d.ts +26 -0
  18. package/bin/runtime-watch.js +116 -0
  19. package/bin/stale-dist-policy.d.ts +6 -0
  20. package/bin/stale-dist-policy.js +44 -0
  21. package/dist/.build-manifest.json +2480 -5
  22. package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
  23. package/dist/backends/task-backend/local-backend.js +9 -12
  24. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  25. package/dist/backends/task-backend/redmine-backend.js +23 -18
  26. package/dist/backends/task-backend/shared/constants.d.ts +1 -0
  27. package/dist/backends/task-backend/shared/constants.d.ts.map +1 -1
  28. package/dist/backends/task-backend/shared/constants.js +1 -0
  29. package/dist/backends/task-backend/shared/doc.d.ts +1 -0
  30. package/dist/backends/task-backend/shared/doc.d.ts.map +1 -1
  31. package/dist/backends/task-backend/shared/doc.js +4 -1
  32. package/dist/backends/task-backend/shared/export.js +3 -3
  33. package/dist/cli/bootstrap-guide.d.ts +16 -0
  34. package/dist/cli/bootstrap-guide.d.ts.map +1 -0
  35. package/dist/cli/bootstrap-guide.js +112 -0
  36. package/dist/cli/command-guide.d.ts.map +1 -1
  37. package/dist/cli/command-guide.js +62 -203
  38. package/dist/cli/command-snippets.d.ts +2 -2
  39. package/dist/cli/command-snippets.js +2 -2
  40. package/dist/cli/run-cli/catalog.d.ts +7 -0
  41. package/dist/cli/run-cli/catalog.d.ts.map +1 -0
  42. package/dist/cli/run-cli/catalog.js +22 -0
  43. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  44. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  45. package/dist/cli/run-cli/command-catalog.js +11 -0
  46. package/dist/cli/run-cli/commands/core.js +1 -1
  47. package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
  48. package/dist/cli/run-cli/commands/init/write-config.js +2 -0
  49. package/dist/cli/run-cli/commands/init.js +5 -14
  50. package/dist/cli/run-cli/error-guidance.d.ts +9 -0
  51. package/dist/cli/run-cli/error-guidance.d.ts.map +1 -0
  52. package/dist/cli/run-cli/error-guidance.js +180 -0
  53. package/dist/cli/run-cli/globals.d.ts +22 -0
  54. package/dist/cli/run-cli/globals.d.ts.map +1 -0
  55. package/dist/cli/run-cli/globals.js +197 -0
  56. package/dist/cli/run-cli/update-warning.d.ts +6 -0
  57. package/dist/cli/run-cli/update-warning.d.ts.map +1 -0
  58. package/dist/cli/run-cli/update-warning.js +64 -0
  59. package/dist/cli/run-cli.d.ts.map +1 -1
  60. package/dist/cli/run-cli.js +5 -476
  61. package/dist/cli/spec/docs-render.d.ts.map +1 -1
  62. package/dist/cli/spec/docs-render.js +14 -1
  63. package/dist/commands/doctor/archive.d.ts +4 -0
  64. package/dist/commands/doctor/archive.d.ts.map +1 -0
  65. package/dist/commands/doctor/archive.js +211 -0
  66. package/dist/commands/doctor/fixes.d.ts +9 -0
  67. package/dist/commands/doctor/fixes.d.ts.map +1 -0
  68. package/dist/commands/doctor/fixes.js +40 -0
  69. package/dist/commands/doctor/layering.d.ts +2 -0
  70. package/dist/commands/doctor/layering.d.ts.map +1 -0
  71. package/dist/commands/doctor/layering.js +87 -0
  72. package/dist/commands/doctor/runtime.d.ts +4 -0
  73. package/dist/commands/doctor/runtime.d.ts.map +1 -0
  74. package/dist/commands/doctor/runtime.js +56 -0
  75. package/dist/commands/doctor/workflow.d.ts +6 -0
  76. package/dist/commands/doctor/workflow.d.ts.map +1 -0
  77. package/dist/commands/doctor/workflow.js +62 -0
  78. package/dist/commands/doctor/workspace.d.ts +2 -0
  79. package/dist/commands/doctor/workspace.d.ts.map +1 -0
  80. package/dist/commands/doctor/workspace.js +165 -0
  81. package/dist/commands/doctor.run.d.ts.map +1 -1
  82. package/dist/commands/doctor.run.js +16 -305
  83. package/dist/commands/doctor.spec.d.ts +1 -0
  84. package/dist/commands/doctor.spec.d.ts.map +1 -1
  85. package/dist/commands/doctor.spec.js +15 -1
  86. package/dist/commands/finish.run.d.ts.map +1 -1
  87. package/dist/commands/finish.run.js +1 -0
  88. package/dist/commands/finish.spec.d.ts +1 -0
  89. package/dist/commands/finish.spec.d.ts.map +1 -1
  90. package/dist/commands/finish.spec.js +23 -2
  91. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  92. package/dist/commands/guard/impl/commands.js +19 -0
  93. package/dist/commands/release/apply.command.d.ts +2 -7
  94. package/dist/commands/release/apply.command.d.ts.map +1 -1
  95. package/dist/commands/release/apply.command.js +159 -382
  96. package/dist/commands/release/apply.mutation.d.ts +7 -0
  97. package/dist/commands/release/apply.mutation.d.ts.map +1 -0
  98. package/dist/commands/release/apply.mutation.js +107 -0
  99. package/dist/commands/release/apply.preflight.d.ts +25 -0
  100. package/dist/commands/release/apply.preflight.d.ts.map +1 -0
  101. package/dist/commands/release/apply.preflight.js +338 -0
  102. package/dist/commands/release/apply.reporting.d.ts +4 -0
  103. package/dist/commands/release/apply.reporting.d.ts.map +1 -0
  104. package/dist/commands/release/apply.reporting.js +24 -0
  105. package/dist/commands/release/apply.types.d.ts +46 -0
  106. package/dist/commands/release/apply.types.d.ts.map +1 -0
  107. package/dist/commands/release/apply.types.js +1 -0
  108. package/dist/commands/runtime.command.d.ts +28 -0
  109. package/dist/commands/runtime.command.d.ts.map +1 -0
  110. package/dist/commands/runtime.command.js +169 -0
  111. package/dist/commands/shared/task-store.d.ts.map +1 -1
  112. package/dist/commands/shared/task-store.js +7 -3
  113. package/dist/commands/task/add.d.ts.map +1 -1
  114. package/dist/commands/task/add.js +3 -33
  115. package/dist/commands/task/block.d.ts.map +1 -1
  116. package/dist/commands/task/block.js +2 -2
  117. package/dist/commands/task/close-duplicate.d.ts.map +1 -1
  118. package/dist/commands/task/close-duplicate.js +2 -2
  119. package/dist/commands/task/close-noop.d.ts.map +1 -1
  120. package/dist/commands/task/close-noop.js +2 -2
  121. package/dist/commands/task/comment.js +2 -2
  122. package/dist/commands/task/derive.d.ts.map +1 -1
  123. package/dist/commands/task/derive.js +3 -3
  124. package/dist/commands/task/doc-template.d.ts +10 -0
  125. package/dist/commands/task/doc-template.d.ts.map +1 -0
  126. package/dist/commands/task/doc-template.js +104 -0
  127. package/dist/commands/task/doc.d.ts.map +1 -1
  128. package/dist/commands/task/doc.js +36 -1
  129. package/dist/commands/task/finish.d.ts +1 -0
  130. package/dist/commands/task/finish.d.ts.map +1 -1
  131. package/dist/commands/task/finish.js +26 -10
  132. package/dist/commands/task/migrate-doc.command.d.ts.map +1 -1
  133. package/dist/commands/task/migrate-doc.command.js +5 -1
  134. package/dist/commands/task/migrate-doc.d.ts.map +1 -1
  135. package/dist/commands/task/migrate-doc.js +136 -2
  136. package/dist/commands/task/new.d.ts.map +1 -1
  137. package/dist/commands/task/new.js +4 -110
  138. package/dist/commands/task/new.spec.js +3 -3
  139. package/dist/commands/task/plan.d.ts.map +1 -1
  140. package/dist/commands/task/plan.js +5 -4
  141. package/dist/commands/task/scaffold.d.ts.map +1 -1
  142. package/dist/commands/task/scaffold.js +7 -52
  143. package/dist/commands/task/set-status.d.ts.map +1 -1
  144. package/dist/commands/task/set-status.js +2 -2
  145. package/dist/commands/task/shared/dependencies.d.ts +15 -0
  146. package/dist/commands/task/shared/dependencies.d.ts.map +1 -0
  147. package/dist/commands/task/shared/dependencies.js +143 -0
  148. package/dist/commands/task/shared/docs.d.ts +21 -0
  149. package/dist/commands/task/shared/docs.d.ts.map +1 -0
  150. package/dist/commands/task/shared/docs.js +121 -0
  151. package/dist/commands/task/shared/listing.d.ts +20 -0
  152. package/dist/commands/task/shared/listing.d.ts.map +1 -0
  153. package/dist/commands/task/shared/listing.js +127 -0
  154. package/dist/commands/task/shared/tags.d.ts +24 -0
  155. package/dist/commands/task/shared/tags.d.ts.map +1 -0
  156. package/dist/commands/task/shared/tags.js +177 -0
  157. package/dist/commands/task/shared/transitions.d.ts +42 -0
  158. package/dist/commands/task/shared/transitions.d.ts.map +1 -0
  159. package/dist/commands/task/shared/transitions.js +175 -0
  160. package/dist/commands/task/shared.d.ts +5 -106
  161. package/dist/commands/task/shared.d.ts.map +1 -1
  162. package/dist/commands/task/shared.js +5 -681
  163. package/dist/commands/task/start.d.ts.map +1 -1
  164. package/dist/commands/task/start.js +7 -5
  165. package/dist/commands/task/verify-record.d.ts.map +1 -1
  166. package/dist/commands/task/verify-record.js +9 -25
  167. package/dist/commands/task/verify-show.command.d.ts.map +1 -1
  168. package/dist/commands/task/verify-show.command.js +5 -1
  169. package/dist/commands/upgrade/apply.d.ts +44 -0
  170. package/dist/commands/upgrade/apply.d.ts.map +1 -0
  171. package/dist/commands/upgrade/apply.js +180 -0
  172. package/dist/commands/upgrade/report.d.ts +21 -0
  173. package/dist/commands/upgrade/report.d.ts.map +1 -0
  174. package/dist/commands/upgrade/report.js +81 -0
  175. package/dist/commands/upgrade/source.d.ts +35 -0
  176. package/dist/commands/upgrade/source.d.ts.map +1 -0
  177. package/dist/commands/upgrade/source.js +109 -0
  178. package/dist/commands/upgrade/types.d.ts +31 -0
  179. package/dist/commands/upgrade/types.d.ts.map +1 -0
  180. package/dist/commands/upgrade/types.js +1 -0
  181. package/dist/commands/upgrade.command.d.ts.map +1 -1
  182. package/dist/commands/upgrade.command.js +11 -7
  183. package/dist/commands/upgrade.d.ts +1 -35
  184. package/dist/commands/upgrade.d.ts.map +1 -1
  185. package/dist/commands/upgrade.js +54 -320
  186. package/dist/shared/diagnostics.d.ts +23 -0
  187. package/dist/shared/diagnostics.d.ts.map +1 -0
  188. package/dist/shared/diagnostics.js +57 -0
  189. package/dist/shared/errors.d.ts +2 -0
  190. package/dist/shared/errors.d.ts.map +1 -1
  191. package/dist/shared/errors.js +2 -0
  192. package/dist/shared/repo-cli-version.d.ts +13 -0
  193. package/dist/shared/repo-cli-version.d.ts.map +1 -0
  194. package/dist/shared/repo-cli-version.js +63 -0
  195. package/dist/shared/runtime-source.d.ts +33 -0
  196. package/dist/shared/runtime-source.d.ts.map +1 -0
  197. package/dist/shared/runtime-source.js +156 -0
  198. package/dist/shared/version-compare.d.ts +7 -0
  199. package/dist/shared/version-compare.d.ts.map +1 -0
  200. package/dist/shared/version-compare.js +30 -0
  201. package/package.json +2 -2
@@ -0,0 +1,94 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "node:path";
3
+
4
+ /**
5
+ * @typedef {{
6
+ * repoRoot: string;
7
+ * packageRoot: string;
8
+ * repoBin: string;
9
+ * repoCli: string;
10
+ * }} FrameworkCheckout
11
+ */
12
+
13
+ /**
14
+ * @typedef {{
15
+ * cwd: string;
16
+ * thisBin: string;
17
+ * }} FrameworkBinaryContextOptions
18
+ */
19
+
20
+ /**
21
+ * @typedef {{
22
+ * inFrameworkCheckout: boolean;
23
+ * isRepoLocalBinary: boolean;
24
+ * isRepoLocalRuntime: boolean;
25
+ * checkout: FrameworkCheckout | null;
26
+ * thisBin: string;
27
+ * }} FrameworkBinaryContext
28
+ */
29
+
30
+ function fileExists(p) {
31
+ return existsSync(p);
32
+ }
33
+
34
+ /**
35
+ * @param {string} startDir
36
+ * @returns {FrameworkCheckout | null}
37
+ */
38
+ export function findFrameworkCheckout(startDir) {
39
+ let dir = path.resolve(startDir);
40
+ for (;;) {
41
+ const packageRoot = path.join(dir, "packages", "agentplane");
42
+ const repoBin = path.join(packageRoot, "bin", "agentplane.js");
43
+ const repoCli = path.join(packageRoot, "src", "cli.ts");
44
+ if (fileExists(repoBin) && fileExists(repoCli)) {
45
+ return {
46
+ repoRoot: dir,
47
+ packageRoot,
48
+ repoBin,
49
+ repoCli,
50
+ };
51
+ }
52
+
53
+ const parent = path.dirname(dir);
54
+ if (parent === dir) return null;
55
+ dir = parent;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * @param {string} baseDir
61
+ * @param {string} targetPath
62
+ * @returns {boolean}
63
+ */
64
+ export function isPathInside(baseDir, targetPath) {
65
+ const rel = path.relative(path.resolve(baseDir), path.resolve(targetPath));
66
+ return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
67
+ }
68
+
69
+ /**
70
+ * @param {FrameworkBinaryContextOptions} options
71
+ * @returns {FrameworkBinaryContext}
72
+ */
73
+ export function resolveFrameworkBinaryContext(options) {
74
+ const cwd = path.resolve(options.cwd);
75
+ const thisBin = path.resolve(options.thisBin);
76
+ const checkout = findFrameworkCheckout(cwd);
77
+ if (!checkout) {
78
+ return {
79
+ inFrameworkCheckout: false,
80
+ isRepoLocalBinary: false,
81
+ isRepoLocalRuntime: false,
82
+ checkout: null,
83
+ thisBin,
84
+ };
85
+ }
86
+
87
+ return {
88
+ inFrameworkCheckout: true,
89
+ isRepoLocalBinary: path.resolve(checkout.repoBin) === thisBin,
90
+ isRepoLocalRuntime: isPathInside(checkout.packageRoot, thisBin),
91
+ checkout,
92
+ thisBin,
93
+ };
94
+ }
@@ -0,0 +1,26 @@
1
+ export type WatchedRuntimeSnapshotFile = {
2
+ path: string;
3
+ sha256: string;
4
+ size_bytes: number;
5
+ };
6
+
7
+ export type WatchedRuntimeSnapshot = {
8
+ watchedPaths: string[];
9
+ files: WatchedRuntimeSnapshotFile[];
10
+ snapshotHash: string;
11
+ };
12
+
13
+ export type WatchedRuntimeSnapshotComparison = {
14
+ ok: boolean;
15
+ changedPaths: string[];
16
+ };
17
+
18
+ export function getWatchedRuntimePathsForPackage(packageName: string): string[];
19
+ export function collectWatchedRuntimeSnapshot(
20
+ packageDir: string,
21
+ watchedPaths: string[],
22
+ ): Promise<WatchedRuntimeSnapshot>;
23
+ export function compareWatchedRuntimeSnapshots(
24
+ recordedSnapshot: WatchedRuntimeSnapshot,
25
+ currentSnapshot: WatchedRuntimeSnapshot,
26
+ ): WatchedRuntimeSnapshotComparison;
@@ -0,0 +1,116 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readdir, readFile, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+
5
+ const WATCHED_RUNTIME_PATHS = {
6
+ agentplane: [
7
+ "src",
8
+ "bin/agentplane.js",
9
+ "bin/dist-guard.js",
10
+ "bin/runtime-context.js",
11
+ "bin/stale-dist-policy.js",
12
+ ],
13
+ "@agentplaneorg/core": ["src"],
14
+ };
15
+
16
+ function normalizePath(value) {
17
+ return value.split(path.sep).join("/");
18
+ }
19
+
20
+ async function exists(targetPath) {
21
+ try {
22
+ await stat(targetPath);
23
+ return true;
24
+ } catch {
25
+ return false;
26
+ }
27
+ }
28
+
29
+ async function walkFiles(targetPath) {
30
+ const targetStat = await stat(targetPath);
31
+ if (targetStat.isFile()) return [targetPath];
32
+ if (!targetStat.isDirectory()) return [];
33
+
34
+ const entries = await readdir(targetPath, { withFileTypes: true });
35
+ const files = [];
36
+ for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {
37
+ const childPath = path.join(targetPath, entry.name);
38
+ if (entry.isDirectory()) {
39
+ files.push(...(await walkFiles(childPath)));
40
+ continue;
41
+ }
42
+ if (entry.isFile()) files.push(childPath);
43
+ }
44
+ return files;
45
+ }
46
+
47
+ function fileHash(content) {
48
+ return createHash("sha256").update(content).digest("hex");
49
+ }
50
+
51
+ function snapshotHash(files) {
52
+ const digest = createHash("sha256");
53
+ for (const file of files) {
54
+ digest.update(file.path);
55
+ digest.update(":");
56
+ digest.update(file.sha256);
57
+ digest.update("\n");
58
+ }
59
+ return digest.digest("hex");
60
+ }
61
+
62
+ export function getWatchedRuntimePathsForPackage(packageName) {
63
+ return [...(WATCHED_RUNTIME_PATHS[packageName] ?? ["src"])];
64
+ }
65
+
66
+ export async function collectWatchedRuntimeSnapshot(packageDir, watchedPaths) {
67
+ const normalizedWatchedPaths = [...new Set(watchedPaths.map((entry) => normalizePath(entry)))];
68
+
69
+ const absoluteFiles = [];
70
+ for (const watchedPath of normalizedWatchedPaths) {
71
+ const absolutePath = path.join(packageDir, watchedPath);
72
+ if (!(await exists(absolutePath))) continue;
73
+ absoluteFiles.push(...(await walkFiles(absolutePath)));
74
+ }
75
+
76
+ const uniqueAbsoluteFiles = [...new Set(absoluteFiles)].toSorted((a, b) => a.localeCompare(b));
77
+ const files = [];
78
+ for (const absolutePath of uniqueAbsoluteFiles) {
79
+ const content = await readFile(absolutePath);
80
+ files.push({
81
+ path: normalizePath(path.relative(packageDir, absolutePath)),
82
+ sha256: fileHash(content),
83
+ size_bytes: content.byteLength,
84
+ });
85
+ }
86
+
87
+ return {
88
+ watchedPaths: normalizedWatchedPaths,
89
+ files,
90
+ snapshotHash: snapshotHash(files),
91
+ };
92
+ }
93
+
94
+ function snapshotFileMap(snapshot) {
95
+ return new Map(snapshot.files.map((file) => [file.path, file.sha256]));
96
+ }
97
+
98
+ export function compareWatchedRuntimeSnapshots(recordedSnapshot, currentSnapshot) {
99
+ if (
100
+ recordedSnapshot.snapshotHash === currentSnapshot.snapshotHash &&
101
+ recordedSnapshot.files.length === currentSnapshot.files.length
102
+ ) {
103
+ return { ok: true, changedPaths: [] };
104
+ }
105
+
106
+ const recordedMap = snapshotFileMap(recordedSnapshot);
107
+ const currentMap = snapshotFileMap(currentSnapshot);
108
+ const changedPaths = [...new Set([...recordedMap.keys(), ...currentMap.keys()])]
109
+ .filter((filePath) => recordedMap.get(filePath) !== currentMap.get(filePath))
110
+ .toSorted((a, b) => a.localeCompare(b));
111
+
112
+ return {
113
+ ok: changedPaths.length === 0,
114
+ changedPaths,
115
+ };
116
+ }
@@ -0,0 +1,6 @@
1
+ export type StaleDistPolicy = {
2
+ mode: "warn_and_run" | "strict";
3
+ reason: "read_only_diagnostic" | "default";
4
+ };
5
+
6
+ export function classifyStaleDistPolicy(argv?: string[]): StaleDistPolicy;
@@ -0,0 +1,44 @@
1
+ function normalizeArgs(argv) {
2
+ return argv
3
+ .slice(2)
4
+ .map((value) => String(value ?? "").trim())
5
+ .filter(Boolean);
6
+ }
7
+
8
+ function isHelpOrVersionCommand(args) {
9
+ return (
10
+ args.length === 0 ||
11
+ args[0] === "--help" ||
12
+ args[0] === "-h" ||
13
+ args[0] === "--version" ||
14
+ args[0] === "-v" ||
15
+ args[0] === "help"
16
+ );
17
+ }
18
+
19
+ function isConfigInspectionCommand(args) {
20
+ return args[0] === "config" && args[1] === "show";
21
+ }
22
+
23
+ function isTaskInspectionCommand(args) {
24
+ return args[0] === "task" && ["list", "show", "verify-show"].includes(args[1] ?? "");
25
+ }
26
+
27
+ function isRoleOrQuickstartCommand(args) {
28
+ return args[0] === "quickstart" || args[0] === "role";
29
+ }
30
+
31
+ export function classifyStaleDistPolicy(argv = process.argv) {
32
+ const args = normalizeArgs(argv);
33
+ if (
34
+ args[0] === "doctor" ||
35
+ (args[0] === "runtime" && args[1] === "explain") ||
36
+ isHelpOrVersionCommand(args) ||
37
+ isRoleOrQuickstartCommand(args) ||
38
+ isConfigInspectionCommand(args) ||
39
+ isTaskInspectionCommand(args)
40
+ ) {
41
+ return { mode: "warn_and_run", reason: "read_only_diagnostic" };
42
+ }
43
+ return { mode: "strict", reason: "default" };
44
+ }