agentplane 0.2.21 → 0.2.23

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 (47) hide show
  1. package/assets/AGENTS.md +2 -1
  2. package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
  3. package/dist/backends/task-backend/local-backend.js +27 -7
  4. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  5. package/dist/cli/run-cli/command-catalog.js +60 -12
  6. package/dist/cli/run-cli/commands/core.d.ts +2 -0
  7. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  8. package/dist/cli/run-cli/commands/core.js +32 -5
  9. package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -1
  10. package/dist/cli/run-cli/commands/init/write-agents.js +33 -1
  11. package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
  12. package/dist/cli/run-cli/commands/init/write-config.js +3 -1
  13. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  14. package/dist/cli/run-cli/commands/init.js +47 -7
  15. package/dist/cli/run-cli.d.ts.map +1 -1
  16. package/dist/cli/run-cli.js +1 -3
  17. package/dist/cli/spec/docs-render.d.ts.map +1 -1
  18. package/dist/cli/spec/docs-render.js +13 -6
  19. package/dist/commands/backend/sync.command.d.ts +3 -2
  20. package/dist/commands/backend/sync.command.d.ts.map +1 -1
  21. package/dist/commands/backend/sync.command.js +13 -15
  22. package/dist/commands/pr/pr.command.d.ts +1 -1
  23. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  24. package/dist/commands/pr/pr.command.js +15 -15
  25. package/dist/commands/task/block.d.ts.map +1 -1
  26. package/dist/commands/task/block.js +15 -18
  27. package/dist/commands/task/finish.d.ts.map +1 -1
  28. package/dist/commands/task/finish.js +14 -7
  29. package/dist/commands/task/plan.d.ts.map +1 -1
  30. package/dist/commands/task/plan.js +14 -2
  31. package/dist/commands/task/ready.d.ts.map +1 -1
  32. package/dist/commands/task/ready.js +6 -8
  33. package/dist/commands/task/set-status.d.ts.map +1 -1
  34. package/dist/commands/task/set-status.js +18 -23
  35. package/dist/commands/task/shared.d.ts +16 -1
  36. package/dist/commands/task/shared.d.ts.map +1 -1
  37. package/dist/commands/task/shared.js +54 -3
  38. package/dist/commands/task/start-ready.d.ts.map +1 -1
  39. package/dist/commands/task/start-ready.js +6 -15
  40. package/dist/commands/task/start.d.ts.map +1 -1
  41. package/dist/commands/task/start.js +18 -23
  42. package/dist/commands/upgrade.d.ts.map +1 -1
  43. package/dist/commands/upgrade.js +67 -19
  44. package/package.json +2 -2
  45. package/dist/cli/parse/lifecycle.d.ts +0 -64
  46. package/dist/cli/parse/lifecycle.d.ts.map +0 -1
  47. package/dist/cli/parse/lifecycle.js +0 -285
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AAmCA,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;AAEF,KAAK,aAAa,GAAG;IACnB,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;AAg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AgB,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,CAiqBlB"}
@@ -627,6 +627,61 @@ export async function cmdUpgradeParsed(opts) {
627
627
  const currentTextForReview = existingBuf ? existingBuf.toString("utf8") : null;
628
628
  const baselineKey = toBaselineKey(rel);
629
629
  const baselineText = baselineKey ? await readBaselineText(baselineKey) : null;
630
+ const hasBaseline = baselineText !== null;
631
+ const changedCurrentVsBaseline = hasBaseline && currentTextForReview !== null
632
+ ? textChangedForType({
633
+ type: entry.type,
634
+ aText: currentTextForReview,
635
+ bText: baselineText,
636
+ })
637
+ : null;
638
+ const changedIncomingVsBaseline = hasBaseline
639
+ ? textChangedForType({
640
+ type: entry.type,
641
+ aText: incomingTextOriginal,
642
+ bText: baselineText,
643
+ })
644
+ : null;
645
+ const currentAndIncomingEqual = currentTextForReview === null
646
+ ? false
647
+ : textChangedForType({
648
+ type: entry.type,
649
+ aText: currentTextForReview,
650
+ bText: incomingTextOriginal,
651
+ }) === false;
652
+ // Fast-path: if incoming already equals local, semantic merge/snapshots are unnecessary.
653
+ if (currentTextForReview !== null && currentAndIncomingEqual) {
654
+ skipped.push(rel);
655
+ reviewRecords.push({
656
+ relPath: rel,
657
+ mergeStrategy: entry.merge_strategy,
658
+ hasBaseline,
659
+ changedCurrentVsBaseline,
660
+ changedIncomingVsBaseline,
661
+ currentDiffersFromIncoming: false,
662
+ needsSemanticReview: false,
663
+ mergeApplied: false,
664
+ mergePath: "none",
665
+ });
666
+ continue;
667
+ }
668
+ // No local edits vs baseline: file can be safely replaced with incoming without semantic merge.
669
+ if (currentTextForReview !== null && changedCurrentVsBaseline === false) {
670
+ updates.push(rel);
671
+ fileContents.set(rel, data);
672
+ reviewRecords.push({
673
+ relPath: rel,
674
+ mergeStrategy: entry.merge_strategy,
675
+ hasBaseline,
676
+ changedCurrentVsBaseline,
677
+ changedIncomingVsBaseline,
678
+ currentDiffersFromIncoming: true,
679
+ needsSemanticReview: false,
680
+ mergeApplied: false,
681
+ mergePath: "none",
682
+ });
683
+ continue;
684
+ }
630
685
  let mergeApplied = false;
631
686
  let mergePath = "none";
632
687
  // Merge logic only needs text for a small subset of managed files.
@@ -675,21 +730,6 @@ export async function cmdUpgradeParsed(opts) {
675
730
  }
676
731
  }
677
732
  }
678
- const hasBaseline = baselineText !== null;
679
- let changedCurrentVsBaseline = null;
680
- let changedIncomingVsBaseline = null;
681
- if (baselineText !== null) {
682
- changedCurrentVsBaseline = textChangedForType({
683
- type: entry.type,
684
- aText: currentTextForReview,
685
- bText: baselineText,
686
- });
687
- changedIncomingVsBaseline = textChangedForType({
688
- type: entry.type,
689
- aText: incomingTextOriginal,
690
- bText: baselineText,
691
- });
692
- }
693
733
  const proposedText = data.toString("utf8");
694
734
  const currentDiffersFromIncoming = currentTextForReview === null
695
735
  ? false
@@ -703,9 +743,11 @@ export async function cmdUpgradeParsed(opts) {
703
743
  : currentDiffersFromIncoming &&
704
744
  Boolean(changedCurrentVsBaseline) &&
705
745
  Boolean(changedIncomingVsBaseline);
706
- const noBaselineConflict = baselineText === null ? currentDiffersFromIncoming : false;
707
- const mergeNotAppliedConflict = mergeApplied ? false : currentDiffersFromIncoming;
708
- const needsSemanticReview = baselineConflict || noBaselineConflict || mergeNotAppliedConflict;
746
+ const unresolvedLocalEditsConflict = baselineText === null
747
+ ? false
748
+ : currentDiffersFromIncoming && Boolean(changedCurrentVsBaseline) && !mergeApplied;
749
+ const parseFailedConflict = mergePath === "parseFailed";
750
+ const needsSemanticReview = baselineConflict || unresolvedLocalEditsConflict || parseFailedConflict;
709
751
  reviewRecords.push({
710
752
  relPath: rel,
711
753
  mergeStrategy: entry.merge_strategy,
@@ -752,7 +794,14 @@ export async function cmdUpgradeParsed(opts) {
752
794
  process.stdout.write(`MERGE ${rel}\n`);
753
795
  return 0;
754
796
  }
797
+ const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
755
798
  if (flags.mode === "agent") {
799
+ // Fast no-op path: nothing to apply and no semantic review candidates.
800
+ // Skip generating per-run artifacts to keep agent-mode upgrades cheap.
801
+ if (additions.length === 0 && updates.length === 0 && needsReview.length === 0) {
802
+ process.stdout.write("Upgrade plan: no managed changes detected\n");
803
+ return 0;
804
+ }
756
805
  const agentDir = path.join(upgradeStateDir, "agent");
757
806
  const runId = new Date().toISOString().replaceAll(":", "-").replaceAll(".", "-");
758
807
  const runDir = path.join(agentDir, runId);
@@ -805,7 +854,6 @@ export async function cmdUpgradeParsed(opts) {
805
854
  await writeFile(path.join(runDir, "constraints.md"), constraintsMd, "utf8");
806
855
  await writeFile(path.join(runDir, "report.md"), reportMd, "utf8");
807
856
  await writeFile(path.join(runDir, "files.json"), JSON.stringify({ additions, updates, skipped, merged }, null, 2) + "\n", "utf8");
808
- const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
809
857
  await writeFile(path.join(runDir, "review.json"), JSON.stringify({
810
858
  generated_at: new Date().toISOString(),
811
859
  counts: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentplane",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "description": "Agent Plane CLI for task workflows, recipes, and project automation.",
5
5
  "keywords": [
6
6
  "agentplane",
@@ -55,7 +55,7 @@
55
55
  "prepublishOnly": "node ../../scripts/enforce-github-publish.mjs && npm run prepack"
56
56
  },
57
57
  "dependencies": {
58
- "@agentplaneorg/core": "0.2.21",
58
+ "@agentplaneorg/core": "0.2.23",
59
59
  "yauzl": "^2.10.0"
60
60
  },
61
61
  "devDependencies": {
@@ -1,64 +0,0 @@
1
- export type UsageStrings = {
2
- usage: string;
3
- example: string;
4
- };
5
- export type ParsedStart = {
6
- taskId: string;
7
- author: string;
8
- body: string;
9
- commitFromComment: boolean;
10
- commitEmoji: string | undefined;
11
- commitAllow: string[];
12
- commitAutoAllow: boolean;
13
- commitAllowTasks: boolean;
14
- commitRequireClean: boolean;
15
- confirmStatusCommit: boolean;
16
- force: boolean;
17
- quiet: boolean;
18
- };
19
- export type ParsedBlock = ParsedStart;
20
- export type ParsedVerify = {
21
- taskId: string;
22
- args: string[];
23
- };
24
- export type ParsedFinish = {
25
- taskIds: string[];
26
- author: string;
27
- body: string;
28
- commit: string | undefined;
29
- force: boolean;
30
- commitFromComment: boolean;
31
- commitEmoji: string | undefined;
32
- commitAllow: string[];
33
- commitAutoAllow: boolean;
34
- commitAllowTasks: boolean;
35
- commitRequireClean: boolean;
36
- statusCommit: boolean;
37
- statusCommitEmoji: string | undefined;
38
- statusCommitAllow: string[];
39
- statusCommitAutoAllow: boolean;
40
- statusCommitRequireClean: boolean;
41
- confirmStatusCommit: boolean;
42
- quiet: boolean;
43
- };
44
- export declare function parseStart(opts: {
45
- taskIdToken: string | undefined;
46
- args: string[];
47
- usage: UsageStrings;
48
- }): ParsedStart;
49
- export declare function parseBlock(opts: {
50
- taskIdToken: string | undefined;
51
- args: string[];
52
- usage: UsageStrings;
53
- }): ParsedBlock;
54
- export declare function parseVerify(opts: {
55
- taskIdToken: string | undefined;
56
- args: string[];
57
- usage: UsageStrings;
58
- }): ParsedVerify;
59
- export declare function parseFinish(opts: {
60
- commandToken: string | undefined;
61
- args: string[];
62
- usage: UsageStrings;
63
- }): ParsedFinish;
64
- //# sourceMappingURL=lifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/cli/parse/lifecycle.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,OAAO,CAA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YAAY,CAAC;CACrB,GAAG,WAAW,CAEd;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB,GAAG,WAAW,CAEd;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB,GAAG,YAAY,CAGf;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAChC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB,GAAG,YAAY,CA2Jf"}
@@ -1,285 +0,0 @@
1
- import { CliError } from "../../shared/errors.js";
2
- import { exitCodeForError } from "../exit-codes.js";
3
- import { usageMessage } from "../output.js";
4
- function usageError(u) {
5
- return new CliError({
6
- exitCode: exitCodeForError("E_USAGE"),
7
- code: "E_USAGE",
8
- message: usageMessage(u.usage, u.example),
9
- });
10
- }
11
- function requireTaskId(taskIdToken, u) {
12
- if (!taskIdToken || taskIdToken.startsWith("-"))
13
- throw usageError(u);
14
- return taskIdToken;
15
- }
16
- function parseLifecycleLike(opts) {
17
- const taskId = requireTaskId(opts.taskIdToken, opts.usage);
18
- let author = "";
19
- let body = "";
20
- let commitFromComment = false;
21
- let commitEmoji;
22
- const commitAllow = [];
23
- let commitAutoAllow = false;
24
- let commitAllowTasks = true;
25
- let commitRequireClean = false;
26
- let confirmStatusCommit = false;
27
- let force = false;
28
- let quiet = false;
29
- for (let i = 0; i < opts.args.length; i++) {
30
- const arg = opts.args[i];
31
- if (!arg)
32
- continue;
33
- if (arg === "--author") {
34
- const next = opts.args[i + 1];
35
- if (!next)
36
- throw usageError(opts.usage);
37
- author = next;
38
- i++;
39
- continue;
40
- }
41
- if (arg === "--body") {
42
- const next = opts.args[i + 1];
43
- if (!next)
44
- throw usageError(opts.usage);
45
- body = next;
46
- i++;
47
- continue;
48
- }
49
- if (arg === "--commit-from-comment") {
50
- commitFromComment = true;
51
- continue;
52
- }
53
- if (arg === "--commit-emoji") {
54
- const next = opts.args[i + 1];
55
- if (!next)
56
- throw usageError(opts.usage);
57
- commitEmoji = next;
58
- i++;
59
- continue;
60
- }
61
- if (arg === "--commit-allow") {
62
- const next = opts.args[i + 1];
63
- if (!next)
64
- throw usageError(opts.usage);
65
- commitAllow.push(next);
66
- i++;
67
- continue;
68
- }
69
- if (arg === "--commit-auto-allow") {
70
- commitAutoAllow = true;
71
- continue;
72
- }
73
- if (arg === "--commit-allow-tasks") {
74
- commitAllowTasks = true;
75
- continue;
76
- }
77
- if (arg === "--commit-require-clean") {
78
- commitRequireClean = true;
79
- continue;
80
- }
81
- if (arg === "--confirm-status-commit") {
82
- confirmStatusCommit = true;
83
- continue;
84
- }
85
- if (arg === "--force") {
86
- force = true;
87
- continue;
88
- }
89
- if (arg === "--quiet") {
90
- quiet = true;
91
- continue;
92
- }
93
- if (arg.startsWith("--"))
94
- throw usageError(opts.usage);
95
- }
96
- if (!author || !body)
97
- throw usageError(opts.usage);
98
- return {
99
- taskId,
100
- author,
101
- body,
102
- commitFromComment,
103
- commitEmoji,
104
- commitAllow,
105
- commitAutoAllow,
106
- commitAllowTasks,
107
- commitRequireClean,
108
- confirmStatusCommit,
109
- force,
110
- quiet,
111
- };
112
- }
113
- export function parseStart(opts) {
114
- return parseLifecycleLike(opts);
115
- }
116
- export function parseBlock(opts) {
117
- return parseLifecycleLike(opts);
118
- }
119
- export function parseVerify(opts) {
120
- const taskId = requireTaskId(opts.taskIdToken, opts.usage);
121
- return { taskId, args: opts.args };
122
- }
123
- export function parseFinish(opts) {
124
- let finishArgs = opts.args;
125
- const taskIds = [];
126
- if (opts.commandToken && !opts.commandToken.startsWith("--")) {
127
- taskIds.push(opts.commandToken);
128
- }
129
- else if (opts.commandToken?.startsWith("-")) {
130
- finishArgs = [opts.commandToken, ...opts.args];
131
- }
132
- let argIndex = 0;
133
- while (argIndex < finishArgs.length) {
134
- const arg = finishArgs[argIndex];
135
- if (!arg || arg.startsWith("--"))
136
- break;
137
- taskIds.push(arg);
138
- argIndex += 1;
139
- }
140
- const flagArgs = finishArgs.slice(argIndex);
141
- if (taskIds.length === 0)
142
- throw usageError(opts.usage);
143
- let author = "";
144
- let body = "";
145
- let commit;
146
- let force = false;
147
- let commitFromComment = false;
148
- let commitEmoji;
149
- const commitAllow = [];
150
- let commitAutoAllow = false;
151
- let commitAllowTasks = true;
152
- let commitRequireClean = false;
153
- let statusCommit = false;
154
- let statusCommitEmoji;
155
- const statusCommitAllow = [];
156
- let statusCommitAutoAllow = false;
157
- let statusCommitRequireClean = false;
158
- let confirmStatusCommit = false;
159
- let quiet = false;
160
- for (let i = 0; i < flagArgs.length; i++) {
161
- const arg = flagArgs[i];
162
- if (!arg)
163
- continue;
164
- if (arg === "--author") {
165
- const next = flagArgs[i + 1];
166
- if (!next)
167
- throw usageError(opts.usage);
168
- author = next;
169
- i++;
170
- continue;
171
- }
172
- if (arg === "--body") {
173
- const next = flagArgs[i + 1];
174
- if (!next)
175
- throw usageError(opts.usage);
176
- body = next;
177
- i++;
178
- continue;
179
- }
180
- if (arg === "--commit") {
181
- const next = flagArgs[i + 1];
182
- if (!next)
183
- throw usageError(opts.usage);
184
- commit = next;
185
- i++;
186
- continue;
187
- }
188
- if (arg === "--force") {
189
- force = true;
190
- continue;
191
- }
192
- if (arg === "--commit-from-comment") {
193
- commitFromComment = true;
194
- continue;
195
- }
196
- if (arg === "--commit-emoji") {
197
- const next = flagArgs[i + 1];
198
- if (!next)
199
- throw usageError(opts.usage);
200
- commitEmoji = next;
201
- i++;
202
- continue;
203
- }
204
- if (arg === "--commit-allow") {
205
- const next = flagArgs[i + 1];
206
- if (!next)
207
- throw usageError(opts.usage);
208
- commitAllow.push(next);
209
- i++;
210
- continue;
211
- }
212
- if (arg === "--commit-auto-allow") {
213
- commitAutoAllow = true;
214
- continue;
215
- }
216
- if (arg === "--commit-allow-tasks") {
217
- commitAllowTasks = true;
218
- continue;
219
- }
220
- if (arg === "--commit-require-clean") {
221
- commitRequireClean = true;
222
- continue;
223
- }
224
- if (arg === "--status-commit") {
225
- statusCommit = true;
226
- continue;
227
- }
228
- if (arg === "--status-commit-emoji") {
229
- const next = flagArgs[i + 1];
230
- if (!next)
231
- throw usageError(opts.usage);
232
- statusCommitEmoji = next;
233
- i++;
234
- continue;
235
- }
236
- if (arg === "--status-commit-allow") {
237
- const next = flagArgs[i + 1];
238
- if (!next)
239
- throw usageError(opts.usage);
240
- statusCommitAllow.push(next);
241
- i++;
242
- continue;
243
- }
244
- if (arg === "--status-commit-auto-allow") {
245
- statusCommitAutoAllow = true;
246
- continue;
247
- }
248
- if (arg === "--status-commit-require-clean") {
249
- statusCommitRequireClean = true;
250
- continue;
251
- }
252
- if (arg === "--confirm-status-commit") {
253
- confirmStatusCommit = true;
254
- continue;
255
- }
256
- if (arg === "--quiet") {
257
- quiet = true;
258
- continue;
259
- }
260
- if (arg.startsWith("--"))
261
- throw usageError(opts.usage);
262
- }
263
- if (!author || !body)
264
- throw usageError(opts.usage);
265
- return {
266
- taskIds,
267
- author,
268
- body,
269
- commit,
270
- force,
271
- commitFromComment,
272
- commitEmoji,
273
- commitAllow,
274
- commitAutoAllow,
275
- commitAllowTasks,
276
- commitRequireClean,
277
- statusCommit,
278
- statusCommitEmoji,
279
- statusCommitAllow,
280
- statusCommitAutoAllow,
281
- statusCommitRequireClean,
282
- confirmStatusCommit,
283
- quiet,
284
- };
285
- }