@aviaratech/ai-delivery 0.3.41 → 0.3.43

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 (98) hide show
  1. package/README.md +7 -1
  2. package/dist/agentReadiness.test.js +15 -0
  3. package/dist/agentReadiness.test.js.map +2 -2
  4. package/dist/callerErrors.test.js +11 -1
  5. package/dist/callerErrors.test.js.map +2 -2
  6. package/dist/contributorChecks.test.js +4 -1
  7. package/dist/contributorChecks.test.js.map +2 -2
  8. package/dist/currentConsumer.test.js +3 -2
  9. package/dist/currentConsumer.test.js.map +2 -2
  10. package/dist/currentTrackingScenario.test.js +3 -2
  11. package/dist/currentTrackingScenario.test.js.map +2 -2
  12. package/dist/fixtures/builderReady.d.ts +82 -0
  13. package/dist/fixtures/builderReady.js +56 -0
  14. package/dist/fixtures/builderReady.js.map +7 -0
  15. package/dist/fixtures/inertTarget.d.ts +75 -0
  16. package/dist/fixtures/inertTarget.js +20 -15
  17. package/dist/fixtures/inertTarget.js.map +2 -2
  18. package/dist/fixtures/issue63.d.ts +96 -0
  19. package/dist/fixtures/issue63.js +21 -2
  20. package/dist/fixtures/issue63.js.map +2 -2
  21. package/dist/fixtures/readView.d.ts +9 -1
  22. package/dist/fixtures/readView.js +4 -0
  23. package/dist/fixtures/readView.js.map +2 -2
  24. package/dist/issue.d.ts +2 -2
  25. package/dist/issue.js +96 -27
  26. package/dist/issue.js.map +2 -2
  27. package/dist/issue63Routes.test.js +3 -3
  28. package/dist/issue63Routes.test.js.map +2 -2
  29. package/dist/issueBlockerGuard.test.js +5 -5
  30. package/dist/issueBlockerGuard.test.js.map +2 -2
  31. package/dist/issueContract.d.ts +242 -2
  32. package/dist/issueContract.js +147 -28
  33. package/dist/issueContract.js.map +2 -2
  34. package/dist/issueContract.test.d.ts +20 -0
  35. package/dist/issueContract.test.js +210 -13
  36. package/dist/issueContract.test.js.map +2 -2
  37. package/dist/issueDates.test.js +5 -6
  38. package/dist/issueDates.test.js.map +2 -2
  39. package/dist/issueInfoReadback.test.js +144 -7
  40. package/dist/issueInfoReadback.test.js.map +2 -2
  41. package/dist/issueIntake.test.js +201 -33
  42. package/dist/issueIntake.test.js.map +2 -2
  43. package/dist/issueJournal.js +4 -2
  44. package/dist/issueJournal.js.map +2 -2
  45. package/dist/issueJournal.test.js +22 -0
  46. package/dist/issueJournal.test.js.map +2 -2
  47. package/dist/issueTracking.test.js +4 -1
  48. package/dist/issueTracking.test.js.map +2 -2
  49. package/dist/issueWriteRecovery.test.js +12 -12
  50. package/dist/issueWriteRecovery.test.js.map +2 -2
  51. package/dist/mcp/index.js +3 -3
  52. package/dist/mcp/index.js.map +2 -2
  53. package/dist/mcp/tools.d.ts +155 -5
  54. package/dist/mcp/tools.js +136 -103
  55. package/dist/mcp/tools.js.map +2 -2
  56. package/dist/pluginPackaging.test.js +6 -3
  57. package/dist/pluginPackaging.test.js.map +2 -2
  58. package/dist/pr.d.ts +2 -0
  59. package/dist/pr.js +28 -3
  60. package/dist/pr.js.map +2 -2
  61. package/dist/pr.test.js +0 -7
  62. package/dist/pr.test.js.map +2 -2
  63. package/dist/prAssociation.test.js +82 -9
  64. package/dist/prAssociation.test.js.map +2 -2
  65. package/dist/projectNumbers.test.js +1 -1
  66. package/dist/projectNumbers.test.js.map +1 -1
  67. package/dist/readView.d.ts +32 -3
  68. package/dist/readView.js +29 -12
  69. package/dist/readView.js.map +2 -2
  70. package/dist/readView.test.js +63 -1
  71. package/dist/readView.test.js.map +2 -2
  72. package/dist/releaseWorkflow.test.js +2 -2
  73. package/dist/releaseWorkflow.test.js.map +2 -2
  74. package/dist/review.d.ts +8 -0
  75. package/dist/review.js +30 -2
  76. package/dist/review.js.map +2 -2
  77. package/dist/review.test.js +64 -1
  78. package/dist/review.test.js.map +2 -2
  79. package/dist/services/agentReadinessService.d.ts +2 -1
  80. package/dist/services/agentReadinessService.js +6 -0
  81. package/dist/services/agentReadinessService.js.map +2 -2
  82. package/dist/stdoutRegression.test.js +27 -15
  83. package/dist/stdoutRegression.test.js.map +2 -2
  84. package/dist/targetPolicyEntrypoints.test.js +1 -1
  85. package/dist/targetPolicyEntrypoints.test.js.map +2 -2
  86. package/dist/targetPolicyRoutes.test.js +1 -1
  87. package/dist/targetPolicyRoutes.test.js.map +2 -2
  88. package/dist/targetRepositoryExecution.test.js +11 -3
  89. package/dist/targetRepositoryExecution.test.js.map +2 -2
  90. package/dist/toolOutput.test.js +14 -0
  91. package/dist/toolOutput.test.js.map +2 -2
  92. package/package.json +1 -1
  93. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  94. package/plugins/ai-delivery/plugin.json +1 -1
  95. package/plugins/ai-delivery/runtime/dist/cli.js +130 -124
  96. package/plugins/ai-delivery/runtime/package.json +1 -1
  97. package/plugins/ai-delivery/skills/intake-create/SKILL.md +1 -11
  98. package/plugins/ai-delivery/skills/ticket-design/SKILL.md +29 -0
@@ -24,8 +24,17 @@ import {
24
24
  import { executeTool, startTrackedIssue } from "./dispatch.js";
25
25
  import { digestValue } from "./delivery/common.js";
26
26
  import { getAiDeliveryMcpTool } from "./mcp/tools.js";
27
- import { IssueFields, ReadyIssue, renderIssueBody, parseIssueBody, ISSUE_BODY_MARKER } from "./issueContract.js";
27
+ import {
28
+ IssueFields,
29
+ IssueValidationError,
30
+ ReadyIssue,
31
+ renderIssueBody,
32
+ parseIssueBody,
33
+ ISSUE_BODY_MARKER,
34
+ issueWarnings
35
+ } from "./issueContract.js";
28
36
  import { syntheticDiscoveryConfig } from "./fixtures/discovery.js";
37
+ import { withBuilder } from "./fixtures/builderReady.js";
29
38
  afterEach(() => {
30
39
  vi.restoreAllMocks();
31
40
  vi.unstubAllEnvs();
@@ -34,7 +43,7 @@ test("create renders all five status fields with a UTC timestamp and optional mi
34
43
  vi.spyOn(Date, "now").mockReturnValue(Date.parse("2026-10-16T20:30:00Z"));
35
44
  for (const draft of [false, true]) {
36
45
  const f2 = fixture();
37
- const input = { ...ready(), draft, status: { nextMilestone: "Run checks" } };
46
+ const input = { ...createInput(), draft, status: { nextMilestone: "Run checks" } };
38
47
  const result = await createIssue(f2.context, input);
39
48
  const status = result.body.split("## Status\n\n")[1].split("\n\n## Problem")[0];
40
49
  assert.equal(
@@ -47,11 +56,11 @@ test("create renders all five status fields with a UTC timestamp and optional mi
47
56
  );
48
57
  }
49
58
  const f = fixture();
50
- assert.match((await createIssue(f.context, ready())).body, /\*\*Next milestone:\*\* Not started/u);
59
+ assert.match((await createIssue(f.context, createInput())).body, /\*\*Next milestone:\*\* Not started/u);
51
60
  });
52
61
  test("status-only patches preserve every outside-Status byte including canonical data and start markers", async () => {
53
62
  const f = fixture();
54
- const created = await createIssue(f.context, ready());
63
+ const created = await createIssue(f.context, createInput());
55
64
  f.live.body = created.body + "\n\n<!-- ai-delivery-start-intent: sha256:" + "a".repeat(64) + " -->\n<!-- ai-delivery-start: sha256:" + "b".repeat(64) + " -->";
56
65
  const before = f.live.body;
57
66
  const patch = { issueNumber: 17, status: { nextMilestone: "Await review", blockers: "None" } };
@@ -280,6 +289,7 @@ test("normal-start recovery preserves legacy rendering across repeated exact ret
280
289
  body: renderIssueBody({ ...ready(), legacyBody: "Original operator context.\n" }),
281
290
  issueType: "Task",
282
291
  points: 2,
292
+ priority: "High",
283
293
  requestId: "legacy-status-retry"
284
294
  });
285
295
  await startTrackedIssue(f.context, request);
@@ -315,6 +325,7 @@ test.each([{ points: 4 }, { issueType: "Feature" }])(
315
325
  body: renderIssueBody(ready()),
316
326
  issueType: "Task",
317
327
  points: 2,
328
+ priority: "High",
318
329
  requestId: "contract-metadata-retry"
319
330
  });
320
331
  await startTrackedIssue(f.context, request);
@@ -339,10 +350,10 @@ test("default legacy omission refuses drift between preparation and the history
339
350
  });
340
351
  test("status-only updates preserve embedded metadata and old formatting despite different native metadata", async () => {
341
352
  const f = fixture();
342
- const data = {
353
+ const data = withBuilder({
343
354
  ...ready(),
344
355
  acceptanceCriteria: [{ behavior: "Reject malformed input:\n- Empty input", verifiedBy: "Regression test." }]
345
- };
356
+ });
346
357
  f.live.body = renderIssueBody(data).replace(" - Empty input\n\n Verified", "- Empty input\n Verified") + "\n\n<!-- ai-delivery-start-intent: sha256:" + "a".repeat(64) + " -->\n<!-- ai-delivery-start: sha256:" + "b".repeat(64) + " -->";
347
358
  f.controls.livePoints = 4;
348
359
  f.live.type.name = "Feature";
@@ -396,10 +407,10 @@ test("CLI typed field files reach status privacy validation before configuration
396
407
  });
397
408
  test("status updates retain old multiline canonical formatting and reject ambiguous status blocks", async () => {
398
409
  const f = fixture();
399
- const data = {
410
+ const data = withBuilder({
400
411
  ...ready(),
401
412
  acceptanceCriteria: [{ behavior: "Reject malformed input:\n- Empty input", verifiedBy: "Regression test." }]
402
- };
413
+ });
403
414
  f.live.body = renderIssueBody(data).replace(" - Empty input\n\n Verified", "- Empty input\n Verified");
404
415
  const before = f.live.body.split("\n\n## Problem")[1];
405
416
  const patch = { issueNumber: 17, status: { nextMilestone: "<literal> *text* [link]" } };
@@ -411,21 +422,24 @@ test("status updates retain old multiline canonical formatting and reject ambigu
411
422
  await assert.rejects(updateIssue(f.context, patch), /unambiguous status/u);
412
423
  assert.equal(f.writes.length, writes);
413
424
  });
414
- const ready = () => IssueFields.parse({
415
- title: "Reject invalid widget identifiers before persistence",
416
- issueType: "Task",
417
- points: 2,
418
- problem: "Malformed identifiers reach persistence.",
419
- outcome: "Reject malformed widget identifiers before persistence.",
420
- acceptanceCriteria: [
421
- {
422
- behavior: "An invalid identifier returns an error with zero persistence calls.",
423
- verifiedBy: "A portable mocked persistence regression test."
424
- }
425
- ],
426
- outOfScope: ["Storage changes."],
427
- context: { components: ["widget"], files: [], evidence: [] }
428
- });
425
+ const ready = () => IssueFields.parse(
426
+ withBuilder({
427
+ title: "Reject invalid widget identifiers before persistence",
428
+ issueType: "Task",
429
+ points: 2,
430
+ problem: "Malformed identifiers reach persistence.",
431
+ outcome: "Reject malformed widget identifiers before persistence.",
432
+ acceptanceCriteria: [
433
+ {
434
+ behavior: "An invalid identifier returns an error with zero persistence calls.",
435
+ verifiedBy: "A portable mocked persistence regression test."
436
+ }
437
+ ],
438
+ outOfScope: ["Storage changes."],
439
+ context: { components: ["widget"], files: [], evidence: [] }
440
+ })
441
+ );
442
+ const createInput = () => ({ ...ready(), priority: "High" });
429
443
  function fixture() {
430
444
  const live = {
431
445
  number: 17,
@@ -456,6 +470,7 @@ function fixture() {
456
470
  closeAfterReason: false,
457
471
  trackingParent: false,
458
472
  livePoints: 2,
473
+ livePriority: true,
459
474
  projectMember: true,
460
475
  projectArchived: false,
461
476
  projectFailure: "",
@@ -486,6 +501,14 @@ function fixture() {
486
501
  value: String(controls.livePoints),
487
502
  single_select_option: { name: String(controls.livePoints) }
488
503
  },
504
+ ...controls.livePriority && !controls.capacityMode ? [
505
+ {
506
+ issue_field_id: 102,
507
+ issue_field_name: "Urgency",
508
+ data_type: "single_select",
509
+ single_select_option: { name: "High" }
510
+ }
511
+ ] : [],
489
512
  ...controls.capacityMode ? [
490
513
  {
491
514
  issue_field_id: 102,
@@ -842,7 +865,7 @@ test("canonical new-start intent preserves supplied deferral rather than silentl
842
865
  });
843
866
  const f = fixture();
844
867
  f.controls.created = false;
845
- const request = { ...ready(), body: deferred };
868
+ const request = { ...createInput(), body: deferred };
846
869
  const first = await startTrackedIssue(f.context, request);
847
870
  assert.equal(Reflect.get(first, "status"), "created-not-started");
848
871
  assert.deepEqual(Reflect.get(parseIssueBody(f.live.body, { title: f.live.title }).issue, "deferral"), {
@@ -1315,26 +1338,81 @@ test("WIP refuses observation drift after recording an override and preserves th
1315
1338
  });
1316
1339
  test("native create validates first, writes canonical fields, reads back metadata and returns warnings", async () => {
1317
1340
  const f = fixture();
1318
- await assert.rejects(createIssue(f.context, { ...ready(), openQuestions: ["Select behavior."] }), /open-questions/u);
1341
+ await assert.rejects(
1342
+ createIssue(f.context, { ...createInput(), openQuestions: ["Select behavior."] }),
1343
+ /open-questions/u
1344
+ );
1319
1345
  assert.equal(f.writes.length, 0);
1320
- const result = await createIssue(f.context, ready());
1346
+ const result = await createIssue(f.context, createInput());
1321
1347
  assert.equal(f.writes.length, 1);
1322
1348
  assert.equal(canonicalIssueBody({ ...ready(), body: result.body }), renderIssueBody(ready()));
1323
1349
  assert.equal(parseIssueBody(result.body, { title: result.created.title }).issue.points, 2);
1324
1350
  assert.deepEqual(result.warnings, []);
1325
1351
  assert.equal(f.getStatus(), "Queued");
1326
1352
  });
1353
+ const legacyReady = () => {
1354
+ const { builder: _b, extends: _e, decisions: _d, surface: _s, fences: _f, proof: _p, ...rest } = ready();
1355
+ return { ...rest, acceptanceCriteria: rest.acceptanceCriteria.map(({ examples: _x, ...ac }) => ac) };
1356
+ };
1357
+ const builderMissing = (error) => error instanceof IssueValidationError && error.failures.some((failure) => failure.code === "builder.missing");
1358
+ test("a Ready create without builder gives builder.missing and writes nothing; a draft is captured", async () => {
1359
+ const f = fixture();
1360
+ await assert.rejects(createIssue(f.context, { ...legacyReady(), priority: "High" }), builderMissing);
1361
+ assert.equal(f.writes.length, 0);
1362
+ await createIssue(f.context, { ...legacyReady(), priority: "High", draft: true });
1363
+ assert.match(f.live.body, /\*\*State:\*\* Draft/u);
1364
+ });
1365
+ test("draft-to-Ready without builder gives builder.missing; with builder it succeeds", async () => {
1366
+ const f = fixture();
1367
+ f.live.body = renderIssueBody({ ...legacyReady(), draft: true });
1368
+ const writes = f.writes.length;
1369
+ await assert.rejects(updateIssue(f.context, { issueNumber: 17, draft: false }), builderMissing);
1370
+ assert.equal(f.writes.length, writes);
1371
+ f.live.body = renderIssueBody({ ...ready(), draft: true });
1372
+ await updateIssue(f.context, { issueNumber: 17, draft: false });
1373
+ assert.match(f.live.body, /\*\*State:\*\* Ready/u);
1374
+ });
1375
+ test("a body replacement that turns a draft into Ready needs builder; park keeps it Draft", async () => {
1376
+ const f = fixture();
1377
+ f.live.body = renderIssueBody({ ...legacyReady(), draft: true });
1378
+ const writes = f.writes.length;
1379
+ const legacyBody = renderIssueBody(legacyReady());
1380
+ await assert.rejects(updateIssue(f.context, { issueNumber: 17, body: legacyBody }), builderMissing);
1381
+ assert.equal(f.writes.length, writes);
1382
+ await updateIssue(f.context, { issueNumber: 17, body: legacyBody, park: true });
1383
+ assert.match(f.live.body, /Draft — parked/u);
1384
+ await updateIssue(f.context, { issueNumber: 17, body: renderIssueBody(ready()) });
1385
+ assert.match(f.live.body, /\*\*State:\*\* Ready/u);
1386
+ });
1387
+ test("legacy Ready issues still update and rebuild without builder, and warn builder.unset", async () => {
1388
+ const f = fixture();
1389
+ f.live.body = renderIssueBody(legacyReady());
1390
+ const result = await updateIssue(f.context, {
1391
+ issueNumber: 17,
1392
+ outcome: "Reject malformed widget identifiers early."
1393
+ });
1394
+ assert.ok(result.warnings.some((warning) => warning.code === "builder.unset"));
1395
+ f.live.body = renderIssueBody(legacyReady()).replace("## Outcome", "## Outcome edited");
1396
+ const { builder: _b, extends: _e, decisions: _d, surface: _s, fences: _f, proof: _p, ...rebuild } = ready();
1397
+ const rebuilt = await updateIssue(f.context, {
1398
+ issueNumber: 17,
1399
+ ...rebuild,
1400
+ acceptanceCriteria: legacyReady().acceptanceCriteria
1401
+ });
1402
+ assert.ok(rebuilt.warnings.some((warning) => warning.code === "builder.unset"));
1403
+ assert.equal(f.comments.length, 1, "the hand-edited body went to the history comment");
1404
+ });
1327
1405
  test("incomplete drafts write parked; reviewer-role writes and wrong native repository readback are refused", async () => {
1328
1406
  const f = fixture();
1329
1407
  await createIssue(f.context, { title: "Investigate invalid widget identifiers", draft: true });
1330
1408
  assert.equal(f.getStatus(), "Queued");
1331
1409
  assert.match(f.live.body, /\*\*State:\*\* Draft/u);
1332
1410
  f.controls.role = "reviewer";
1333
- await assert.rejects(createIssue(f.context, ready()), /author role/u);
1411
+ await assert.rejects(createIssue(f.context, createInput()), /author role/u);
1334
1412
  await assert.rejects(updateIssue(f.context, { issueNumber: 17, draft: true }), /author role/u);
1335
1413
  const bad = fixture();
1336
1414
  bad.controls.wrongCreateRepo = true;
1337
- await assert.rejects(createIssue(bad.context, ready()), /created but native tracking did not complete/u);
1415
+ await assert.rejects(createIssue(bad.context, createInput()), /created but native tracking did not complete/u);
1338
1416
  assert.equal(bad.writes.length, 1);
1339
1417
  });
1340
1418
  test("first legacy update retains exact history and full diff, then typed patches preserve unspecified fields", async () => {
@@ -1412,7 +1490,8 @@ test("normal-start canonical retry body keeps exact intent markers through creat
1412
1490
  title: issue.title,
1413
1491
  body: canonical + footer,
1414
1492
  points: 2,
1415
- issueType: "Task"
1493
+ issueType: "Task",
1494
+ priority: "High"
1416
1495
  });
1417
1496
  assert.equal(canonicalIssueBody({ ...issue, body: result.body }), canonical + footer);
1418
1497
  assert.deepEqual(parseIssueBody(result.body, { title: issue.title }).issue, issue);
@@ -1426,6 +1505,7 @@ test("actual normal-start creation and retry reuse the exact canonical body, bra
1426
1505
  body: renderIssueBody(ready()),
1427
1506
  issueType: "Task",
1428
1507
  points: 2,
1508
+ priority: "High",
1429
1509
  requestId: "issue68-normal-start"
1430
1510
  });
1431
1511
  const first = await startTrackedIssue(f.context, request);
@@ -1483,6 +1563,18 @@ test("ordinary start checks typed Draft, Points and live eligibility before bran
1483
1563
  f2.controls.livePoints = 4;
1484
1564
  }
1485
1565
  ],
1566
+ [
1567
+ "priority",
1568
+ (f2) => {
1569
+ f2.controls.livePriority = false;
1570
+ }
1571
+ ],
1572
+ [
1573
+ "issue-type",
1574
+ (f2) => {
1575
+ Reflect.set(f2.live, "type", null);
1576
+ }
1577
+ ],
1486
1578
  [
1487
1579
  "blocked",
1488
1580
  (f2) => {
@@ -1551,6 +1643,7 @@ test("created readiness refusal returns exact retry markers through safe resume
1551
1643
  body: renderIssueBody(ready()),
1552
1644
  issueType: "Task",
1553
1645
  points: 2,
1646
+ priority: "High",
1554
1647
  requestId: "issue68-readiness-recovery"
1555
1648
  });
1556
1649
  const interrupted = await startTrackedIssue(f.context, request);
@@ -1690,11 +1783,16 @@ test(
1690
1783
  "intake skill example is Ready and every CLI line has actual required options and an explicit identity",
1691
1784
  { tags: ["release"] },
1692
1785
  () => {
1693
- const skill = readFileSync(resolve("plugins/ai-delivery/skills/intake-create/SKILL.md"), "utf8");
1694
- const examples = [...skill.matchAll(/```json\n([\s\S]*?)\n```/gu)].map((match) => {
1786
+ const intake = readFileSync(resolve("plugins/ai-delivery/skills/intake-create/SKILL.md"), "utf8");
1787
+ const skill = readFileSync(resolve("plugins/ai-delivery/skills/ticket-design/SKILL.md"), "utf8");
1788
+ const jsonBlocks = (text) => [...text.matchAll(/```json\n([\s\S]*?)\n```/gu)].map((match) => {
1695
1789
  const json2 = match[1] ?? "";
1696
1790
  return { json: json2, value: JSON.parse(json2) };
1697
1791
  });
1792
+ const intakeExamples = jsonBlocks(intake);
1793
+ assert.equal(intakeExamples.length, 1, "intake-create keeps only its read example");
1794
+ assert.ok(!intake.includes("create --title"), "the one Ready create line lives only in ticket-design");
1795
+ const examples = [...intakeExamples, ...jsonBlocks(skill)];
1698
1796
  const readTool = getAiDeliveryMcpTool("issue_info");
1699
1797
  assert.ok(readTool?.name === "issue_info");
1700
1798
  const readSchema = readTool.inputSchema;
@@ -1711,6 +1809,8 @@ test(
1711
1809
  assert.equal(readArguments.issueNumber, 17);
1712
1810
  const createExample = examples.find((example) => ReadyIssue.safeParse(example.value).success);
1713
1811
  assert.ok(createExample, "the creation example must remain Ready");
1812
+ assert.deepEqual(issueWarnings(IssueFields.parse(createExample.value)), []);
1813
+ assert.match(skill, /create --title .*--priority P2/u);
1714
1814
  const json = createExample.json;
1715
1815
  const root = mkdtempSync(join(tmpdir(), "intake-cli-"));
1716
1816
  try {
@@ -1752,8 +1852,8 @@ test(
1752
1852
  } finally {
1753
1853
  rmSync(root, { recursive: true, force: true });
1754
1854
  }
1755
- assert.ok(skill.includes(ISSUE_BODY_MARKER));
1756
- assert.ok(!skill.includes("ai-delivery develop"));
1855
+ assert.ok(intake.includes(ISSUE_BODY_MARKER));
1856
+ assert.ok(!intake.includes("ai-delivery develop") && !skill.includes("ai-delivery develop"));
1757
1857
  }
1758
1858
  );
1759
1859
  test("explicit start changes Todo to the configured In Progress option and preserves unrelated items", async () => {
@@ -1838,6 +1938,7 @@ test("created start retains its exact issue recovery when Project synchronizatio
1838
1938
  body: renderIssueBody(ready()),
1839
1939
  issueType: "Task",
1840
1940
  points: 2,
1941
+ priority: "High",
1841
1942
  requestId: "project-recovery"
1842
1943
  };
1843
1944
  const result = await startTrackedIssue(f.context, request);
@@ -2122,6 +2223,7 @@ test.each(["project-status", "journal"])(
2122
2223
  body: renderIssueBody(ready()),
2123
2224
  issueType: "Task",
2124
2225
  points: 2,
2226
+ priority: "High",
2125
2227
  requestId: "parked-created-" + phase
2126
2228
  });
2127
2229
  if (result.status !== "created-not-started") assert.fail("Expected known-created recovery");
@@ -2159,6 +2261,7 @@ test("created post-tracking recovery preserves later ready content without repla
2159
2261
  body: renderIssueBody(ready()),
2160
2262
  issueType: "Task",
2161
2263
  points: 2,
2264
+ priority: "High",
2162
2265
  requestId: "edited-created-recovery"
2163
2266
  });
2164
2267
  if (result.status !== "created-not-started") assert.fail("Expected known-created recovery");
@@ -2177,4 +2280,69 @@ test("created post-tracking recovery preserves later ready content without repla
2177
2280
  assert.equal(f.branchWrites.length, 1);
2178
2281
  assert.equal(f.getStatus(), "Active");
2179
2282
  });
2283
+ test("update with a body replaces the preserved legacy body instead of appending (ai-delivery#298)", async () => {
2284
+ const f = fixture();
2285
+ const a = "## Decisions\n\n- Decision A\n";
2286
+ const b = a + "- Decision B\n";
2287
+ const created = await createIssue(f.context, { ...createInput(), body: a });
2288
+ f.live.body = created.body;
2289
+ const updated = await updateIssue(f.context, { issueNumber: 17, ...ready(), body: b });
2290
+ const legacy = parseIssueBody(updated.body, { title: updated.title }).issue.legacyBody;
2291
+ assert.equal(legacy, b);
2292
+ assert.equal(updated.body.split("Decision A").length - 1, 2);
2293
+ });
2294
+ test("one full typed-field update repairs a hand-edited body (ai-delivery#298)", async () => {
2295
+ const f = fixture();
2296
+ const created = await createIssue(f.context, { ...createInput(), body: "## Decisions\n\n- Decision A\n" });
2297
+ f.live.body = created.body.replace("- Decision A\n", "- Decision A\n\n- Decision A\n");
2298
+ const withBody = await updateIssue(f.context, {
2299
+ issueNumber: 17,
2300
+ ...ready(),
2301
+ body: "## Decisions\n\n- Decision A\n"
2302
+ });
2303
+ assert.equal(
2304
+ parseIssueBody(withBody.body, { title: withBody.title }).issue.legacyBody,
2305
+ "## Decisions\n\n- Decision A\n"
2306
+ );
2307
+ const repaired = await updateIssue(f.context, { issueNumber: 17, ...ready() });
2308
+ f.live.body = repaired.body;
2309
+ const info = await issueInfo(f.context, 17);
2310
+ assert.equal(parseIssueBody(info.body, { title: info.title }).legacy, false);
2311
+ assert.equal((await readyCheck(f.context, 17)).ready, true);
2312
+ });
2313
+ test("create refuses a non-draft issue without type or Priority in one error and writes nothing", async () => {
2314
+ const codes = async (input) => {
2315
+ const f = fixture();
2316
+ const error = await createIssue(f.context, input).catch((e) => e);
2317
+ assert.ok(error instanceof IssueValidationError);
2318
+ assert.equal(f.writes.length, 0);
2319
+ return error.failures;
2320
+ };
2321
+ const task = await codes(ready());
2322
+ assert.deepEqual(
2323
+ task.map((x) => [x.code, x.fixHint]),
2324
+ [["priority", "Choose priority: High, Low."]]
2325
+ );
2326
+ const { issueType: _type, ...untyped } = createInput();
2327
+ assert.deepEqual(
2328
+ (await codes(untyped)).map((x) => x.code),
2329
+ ["issue-type"]
2330
+ );
2331
+ const { issueType: _both, ...neither } = ready();
2332
+ assert.deepEqual(
2333
+ (await codes(neither)).map((x) => x.code),
2334
+ ["issue-type", "priority"]
2335
+ );
2336
+ });
2337
+ test("create accepts a draft without type or Priority and an epic without Priority", async () => {
2338
+ await createIssue(fixture().context, { title: "Investigate invalid widget identifiers", draft: true });
2339
+ const { points: _points, ...rest } = ready();
2340
+ const result = await createIssue(fixture().context, { ...rest, epic: true });
2341
+ assert.equal(parseIssueBody(result.body, { title: result.created.title }).issue.epic, true);
2342
+ });
2343
+ test("update with a Priority adds no new refusal", async () => {
2344
+ const f = fixture();
2345
+ await updateIssue(f.context, { issueNumber: 17, priority: "High" });
2346
+ assert.ok(f.writes.length > 0);
2347
+ });
2180
2348
  //# sourceMappingURL=issueIntake.test.js.map