@aviaratech/ai-delivery 0.3.26 → 0.3.28
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/README.md +11 -5
- package/dist/cliResult.js +1 -1
- package/dist/cliResult.js.map +1 -1
- package/dist/cliResult.test.js +18 -0
- package/dist/cliResult.test.js.map +1 -1
- package/dist/directoryIndependent.test.js +47 -0
- package/dist/directoryIndependent.test.js.map +1 -1
- package/dist/dispatch.d.ts +25 -2
- package/dist/dispatch.js +35 -7
- package/dist/dispatch.js.map +1 -1
- package/dist/issue.d.ts +2 -0
- package/dist/issue.js +17 -0
- package/dist/issue.js.map +1 -1
- package/dist/issueIntake.test.js +372 -12
- package/dist/issueIntake.test.js.map +1 -1
- package/dist/mcp/index.js +9 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +1 -1
- package/dist/mcp/tools.js +6 -3
- package/dist/mcp/tools.js.map +1 -1
- package/dist/pluginPackaging.test.js +8 -0
- package/dist/pluginPackaging.test.js.map +1 -1
- package/dist/pr.js +52 -2
- package/dist/pr.js.map +1 -1
- package/dist/prAssociation.test.js +31 -0
- package/dist/prAssociation.test.js.map +1 -1
- package/dist/review.test.js +133 -0
- package/dist/review.test.js.map +1 -1
- package/dist/start.test.js +1 -0
- package/dist/start.test.js.map +1 -1
- package/dist/stdoutRegression.test.js +2 -2
- package/dist/stdoutRegression.test.js.map +1 -1
- package/dist/targetPolicyDiscovery.test.d.ts +1 -0
- package/dist/targetPolicyDiscovery.test.js +150 -0
- package/dist/targetPolicyDiscovery.test.js.map +1 -0
- package/package.json +1 -1
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/README.md +8 -0
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/cli.js +19 -18
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +19 -3
package/dist/issueIntake.test.js
CHANGED
|
@@ -3,7 +3,9 @@ import { readFileSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
|
3
3
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { join, resolve } from 'node:path';
|
|
6
|
-
import { test } from 'vitest';
|
|
6
|
+
import { afterEach, test, vi } from 'vitest';
|
|
7
|
+
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
8
|
+
import { createAiDeliveryMcpServer } from './mcp/index.js';
|
|
7
9
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
8
10
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
9
11
|
import { z } from 'zod';
|
|
@@ -13,6 +15,7 @@ import { digestValue } from './delivery/common.js';
|
|
|
13
15
|
import { getAiDeliveryMcpTool } from './mcp/tools.js';
|
|
14
16
|
import { IssueFields, ReadyIssue, renderIssueBody, parseIssueBody, ISSUE_BODY_MARKER } from './issueContract.js';
|
|
15
17
|
import { syntheticDiscoveryConfig } from './fixtures/discovery.js';
|
|
18
|
+
afterEach(() => vi.restoreAllMocks());
|
|
16
19
|
const ready = () => IssueFields.parse({
|
|
17
20
|
title: 'Reject invalid widget identifiers before persistence',
|
|
18
21
|
issueType: 'Task',
|
|
@@ -51,11 +54,21 @@ function fixture() {
|
|
|
51
54
|
blockers: false,
|
|
52
55
|
trackingParent: false,
|
|
53
56
|
livePoints: 2,
|
|
57
|
+
projectMember: true,
|
|
58
|
+
projectArchived: false,
|
|
59
|
+
projectFailure: '',
|
|
60
|
+
journalFailure: false,
|
|
61
|
+
branchFailure: false,
|
|
62
|
+
closeAfterBranch: false,
|
|
63
|
+
blockAfterBranch: false,
|
|
54
64
|
};
|
|
55
65
|
const branchWrites = [];
|
|
56
66
|
const branches = [];
|
|
57
67
|
let points = 2;
|
|
58
68
|
let status = 'Queued';
|
|
69
|
+
const statusWrites = [];
|
|
70
|
+
const membershipWrites = [];
|
|
71
|
+
const optionId = () => ({ Queued: 'TODO', Active: 'ACTIVE', Waiting: 'BLOCKED', Shipped: 'DONE' })[status];
|
|
59
72
|
const values = () => [
|
|
60
73
|
{
|
|
61
74
|
issue_field_id: 101,
|
|
@@ -127,6 +140,8 @@ function fixture() {
|
|
|
127
140
|
issue_url: 'https://api.github.com/repos/example/widget/issues/17',
|
|
128
141
|
};
|
|
129
142
|
comments.push(comment);
|
|
143
|
+
if (controls.journalFailure)
|
|
144
|
+
throw new Error('Lost journal response');
|
|
130
145
|
return { data: comment };
|
|
131
146
|
},
|
|
132
147
|
getComment: async (input) => {
|
|
@@ -188,6 +203,12 @@ function fixture() {
|
|
|
188
203
|
const fields = input.input;
|
|
189
204
|
branchWrites.push(fields);
|
|
190
205
|
branches.push({ name: String(fields.name), sha: String(fields.oid) });
|
|
206
|
+
if (controls.closeAfterBranch)
|
|
207
|
+
live.state = 'closed';
|
|
208
|
+
if (controls.blockAfterBranch)
|
|
209
|
+
controls.blockers = true;
|
|
210
|
+
if (controls.branchFailure)
|
|
211
|
+
throw new Error('Lost branch response');
|
|
191
212
|
return { createLinkedBranch: { linkedBranch: { ref: { name: fields.name, target: { oid: fields.oid } } } } };
|
|
192
213
|
}
|
|
193
214
|
if (query.includes('blockedBy(first:'))
|
|
@@ -219,19 +240,44 @@ function fixture() {
|
|
|
219
240
|
items: {
|
|
220
241
|
nodes: [
|
|
221
242
|
{
|
|
222
|
-
id: '
|
|
243
|
+
id: 'OTHER',
|
|
223
244
|
isArchived: false,
|
|
224
|
-
content: { id: '
|
|
225
|
-
fieldValueByName: { name:
|
|
245
|
+
content: { id: 'OTHER-ISSUE' },
|
|
246
|
+
fieldValueByName: { name: 'Queued', optionId: 'TODO' },
|
|
226
247
|
},
|
|
248
|
+
...(controls.projectMember
|
|
249
|
+
? [
|
|
250
|
+
{
|
|
251
|
+
id: 'ITEM17',
|
|
252
|
+
isArchived: controls.projectArchived,
|
|
253
|
+
content: { id: 'ISSUE17' },
|
|
254
|
+
fieldValueByName: { name: status, optionId: optionId() },
|
|
255
|
+
},
|
|
256
|
+
]
|
|
257
|
+
: []),
|
|
227
258
|
],
|
|
228
259
|
pageInfo: { hasNextPage: false, endCursor: null },
|
|
229
260
|
},
|
|
230
261
|
},
|
|
231
262
|
},
|
|
232
263
|
};
|
|
264
|
+
if (query.includes('AddProjectDeliveryItem')) {
|
|
265
|
+
membershipWrites.push(input);
|
|
266
|
+
assert.equal(input.projectId, 'PROJECT');
|
|
267
|
+
assert.equal(input.contentId, 'ISSUE17');
|
|
268
|
+
controls.projectMember = true;
|
|
269
|
+
return { addProjectV2ItemById: { item: { id: 'ITEM17' } } };
|
|
270
|
+
}
|
|
233
271
|
if (query.includes('UpdateProjectDeliveryStatus')) {
|
|
272
|
+
statusWrites.push(input);
|
|
273
|
+
assert.equal(input.projectId, 'PROJECT');
|
|
274
|
+
assert.equal(input.itemId, 'ITEM17');
|
|
275
|
+
assert.equal(input.fieldId, 'STATUS');
|
|
276
|
+
if (input.optionId === 'ACTIVE' && controls.projectFailure === 'before')
|
|
277
|
+
throw new Error('Project write failed');
|
|
234
278
|
status = input.optionId === 'TODO' ? 'Queued' : input.optionId === 'DONE' ? 'Shipped' : 'Active';
|
|
279
|
+
if (input.optionId === 'ACTIVE' && controls.projectFailure === 'after')
|
|
280
|
+
throw new Error('Lost Project response');
|
|
235
281
|
return { updateProjectV2ItemFieldValue: { projectV2Item: { id: 'ITEM17' } } };
|
|
236
282
|
}
|
|
237
283
|
if (query.includes('ProjectDeliveryItemReadback'))
|
|
@@ -240,15 +286,31 @@ function fixture() {
|
|
|
240
286
|
id: 'ITEM17',
|
|
241
287
|
isArchived: false,
|
|
242
288
|
project: { id: 'PROJECT', number: 1 },
|
|
243
|
-
content: {
|
|
244
|
-
|
|
289
|
+
content: {
|
|
290
|
+
id: status === 'Active' && controls.projectFailure === 'readback' ? 'OTHER-ISSUE' : 'ISSUE17',
|
|
291
|
+
},
|
|
292
|
+
fieldValueByName: { name: status, optionId: optionId() },
|
|
245
293
|
},
|
|
246
294
|
};
|
|
247
295
|
throw new Error('Unexpected native query ' + query);
|
|
248
296
|
},
|
|
249
297
|
},
|
|
250
298
|
};
|
|
251
|
-
return {
|
|
299
|
+
return {
|
|
300
|
+
context,
|
|
301
|
+
live,
|
|
302
|
+
writes,
|
|
303
|
+
comments,
|
|
304
|
+
controls,
|
|
305
|
+
branches,
|
|
306
|
+
branchWrites,
|
|
307
|
+
statusWrites,
|
|
308
|
+
membershipWrites,
|
|
309
|
+
getStatus: () => status,
|
|
310
|
+
setStatus: (value) => {
|
|
311
|
+
status = value;
|
|
312
|
+
},
|
|
313
|
+
};
|
|
252
314
|
}
|
|
253
315
|
test('native create validates first, writes canonical fields, reads back metadata and returns warnings', async () => {
|
|
254
316
|
const f = fixture();
|
|
@@ -471,13 +533,14 @@ test('created readiness refusal returns exact retry markers through safe resume
|
|
|
471
533
|
requestId: 'issue68-readiness-recovery',
|
|
472
534
|
});
|
|
473
535
|
const interrupted = await startTrackedIssue(f.context, request);
|
|
474
|
-
if (
|
|
536
|
+
if (interrupted.status !== 'created-not-started')
|
|
475
537
|
assert.fail('Expected a known-created readiness refusal.');
|
|
476
538
|
assert.equal(interrupted.status, 'created-not-started');
|
|
477
539
|
const nativeBody = f.live.body;
|
|
478
540
|
assert.match(nativeBody, /ai-delivery-start-intent: sha256:[a-f0-9]{64}/u);
|
|
479
541
|
assert.match(nativeBody, /ai-delivery-start: sha256:[a-f0-9]{64}/u);
|
|
480
|
-
assert.equal(interrupted.safeResume.arguments.
|
|
542
|
+
assert.equal(interrupted.safeResume.arguments.resumeCreated, undefined);
|
|
543
|
+
assert.equal('body' in interrupted.safeResume.arguments, false);
|
|
481
544
|
assert.equal(f.branchWrites.length, 0);
|
|
482
545
|
assert.equal(f.comments.length, 0);
|
|
483
546
|
assert.equal(f.writes.filter((write) => !('issue_number' in write)).length, 1);
|
|
@@ -602,9 +665,24 @@ test('actual compiled stdio MCP returns every Ready diagnostic before credential
|
|
|
602
665
|
});
|
|
603
666
|
test('intake skill example is Ready and every CLI line has actual required options and an explicit identity', () => {
|
|
604
667
|
const skill = readFileSync(resolve('plugins/ai-delivery/skills/intake-create/SKILL.md'), 'utf8');
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
668
|
+
const examples = [...skill.matchAll(/```json\n([\s\S]*?)\n```/gu)].map((match) => {
|
|
669
|
+
const json = match[1] ?? '';
|
|
670
|
+
return { json, value: JSON.parse(json) };
|
|
671
|
+
});
|
|
672
|
+
const readTool = getAiDeliveryMcpTool('issue_info');
|
|
673
|
+
assert.ok(readTool?.name === 'issue_info');
|
|
674
|
+
const readSchema = readTool.inputSchema;
|
|
675
|
+
for (const example of examples) {
|
|
676
|
+
assert.ok(ReadyIssue.safeParse(example.value).success || readSchema.safeParse(example.value).success, 'each documented JSON example must satisfy its supported contract');
|
|
677
|
+
}
|
|
678
|
+
const readExample = examples.find((example) => readSchema.safeParse(example.value).success);
|
|
679
|
+
assert.ok(readExample, 'the read-first example must use the actual MCP schema');
|
|
680
|
+
const readArguments = readSchema.parse(readExample.value);
|
|
681
|
+
assert.equal(readArguments.repo, 'example/widget');
|
|
682
|
+
assert.equal(readArguments.issueNumber, 17);
|
|
683
|
+
const createExample = examples.find((example) => ReadyIssue.safeParse(example.value).success);
|
|
684
|
+
assert.ok(createExample, 'the creation example must remain Ready');
|
|
685
|
+
const json = createExample.json;
|
|
608
686
|
const root = mkdtempSync(join(tmpdir(), 'intake-cli-'));
|
|
609
687
|
try {
|
|
610
688
|
const fields = join(root, 'issue.json');
|
|
@@ -646,4 +724,286 @@ test('intake skill example is Ready and every CLI line has actual required optio
|
|
|
646
724
|
assert.ok(skill.includes(ISSUE_BODY_MARKER));
|
|
647
725
|
assert.ok(!skill.includes('ai-delivery develop'));
|
|
648
726
|
});
|
|
727
|
+
test('explicit start changes Todo to the configured In Progress option and preserves unrelated items', async () => {
|
|
728
|
+
const f = fixture();
|
|
729
|
+
const result = await startTrackedIssue(f.context, { issueNumber: 17 });
|
|
730
|
+
assert.ok('branch' in result);
|
|
731
|
+
assert.equal(f.getStatus(), 'Active');
|
|
732
|
+
assert.equal(f.statusWrites.length, 1);
|
|
733
|
+
assert.deepEqual(f.statusWrites[0], {
|
|
734
|
+
projectId: 'PROJECT',
|
|
735
|
+
itemId: 'ITEM17',
|
|
736
|
+
fieldId: 'STATUS',
|
|
737
|
+
optionId: 'ACTIVE',
|
|
738
|
+
});
|
|
739
|
+
assert.equal(f.comments.length, 1);
|
|
740
|
+
const retry = await startTrackedIssue(f.context, { issueNumber: 17 });
|
|
741
|
+
assert.ok('reused' in retry && retry.reused);
|
|
742
|
+
assert.equal(f.branchWrites.length, 1);
|
|
743
|
+
assert.equal(f.statusWrites.length, 1);
|
|
744
|
+
assert.equal(f.comments.length, 1);
|
|
745
|
+
});
|
|
746
|
+
test('explicit start adds missing membership only for its exact issue and accepts already active status', async () => {
|
|
747
|
+
for (const member of [true, false]) {
|
|
748
|
+
const f = fixture();
|
|
749
|
+
f.controls.projectMember = member;
|
|
750
|
+
if (member)
|
|
751
|
+
f.setStatus('Active');
|
|
752
|
+
assert.ok('branch' in (await startTrackedIssue(f.context, { issueNumber: 17 })));
|
|
753
|
+
assert.equal(f.getStatus(), 'Active');
|
|
754
|
+
assert.equal(f.membershipWrites.length, member ? 0 : 1);
|
|
755
|
+
assert.equal(f.statusWrites.length, member ? 0 : 1);
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
test.each(['before', 'after', 'readback'])('existing start returns known-issue recovery for Project %s failure', async (failure) => {
|
|
759
|
+
const f = fixture();
|
|
760
|
+
f.controls.projectFailure = failure;
|
|
761
|
+
const result = await startTrackedIssue(f.context, { issueNumber: 17 });
|
|
762
|
+
if (!('status' in result))
|
|
763
|
+
assert.fail('Project failure must not report successful start');
|
|
764
|
+
assert.equal(result.status, 'start-incomplete');
|
|
765
|
+
assert.equal(result.failure.phase, 'project-status');
|
|
766
|
+
assert.equal(result.safeResume.arguments.issueNumber, 17);
|
|
767
|
+
assert.equal(result.safeResume.arguments.repo, 'example/widget');
|
|
768
|
+
assert.equal(result.safeResume.arguments.branch, 'issue/17');
|
|
769
|
+
assert.equal(f.comments.length, 0);
|
|
770
|
+
f.controls.projectFailure = '';
|
|
771
|
+
const resumed = await startTrackedIssue(f.context, getAiDeliveryMcpTool('issue_start').inputSchema.parse(result.safeResume.arguments));
|
|
772
|
+
assert.ok('reused' in resumed && resumed.reused);
|
|
773
|
+
assert.equal(f.getStatus(), 'Active');
|
|
774
|
+
assert.equal(f.branchWrites.length, 1);
|
|
775
|
+
assert.equal(f.comments.length, 1);
|
|
776
|
+
assert.equal(f.writes.length, 0);
|
|
777
|
+
assert.equal(f.statusWrites.length, failure === 'before' ? 2 : 1);
|
|
778
|
+
});
|
|
779
|
+
test.each(['branch', 'journal'])('existing start reconciles a lost %s response without duplicate mutations', async (failure) => {
|
|
780
|
+
const f = fixture();
|
|
781
|
+
f.controls.branchFailure = failure === 'branch';
|
|
782
|
+
f.controls.journalFailure = failure === 'journal';
|
|
783
|
+
const result = await startTrackedIssue(f.context, { issueNumber: 17 });
|
|
784
|
+
if (!('status' in result))
|
|
785
|
+
assert.fail('An uncertain start must retain recovery');
|
|
786
|
+
assert.equal(result.status, 'start-incomplete');
|
|
787
|
+
f.controls.branchFailure = false;
|
|
788
|
+
f.controls.journalFailure = false;
|
|
789
|
+
assert.ok('reused' in (await startTrackedIssue(f.context, result.safeResume.arguments)));
|
|
790
|
+
assert.equal(f.branchWrites.length, 1);
|
|
791
|
+
assert.equal(f.comments.length, 1);
|
|
792
|
+
assert.equal(f.getStatus(), 'Active');
|
|
793
|
+
});
|
|
794
|
+
test('created start retains its exact issue recovery when Project synchronization fails', async () => {
|
|
795
|
+
const f = fixture();
|
|
796
|
+
f.controls.created = false;
|
|
797
|
+
f.controls.projectFailure = 'before';
|
|
798
|
+
const request = {
|
|
799
|
+
title: ready().title,
|
|
800
|
+
body: renderIssueBody(ready()),
|
|
801
|
+
issueType: 'Task',
|
|
802
|
+
points: 2,
|
|
803
|
+
requestId: 'project-recovery',
|
|
804
|
+
};
|
|
805
|
+
const result = await startTrackedIssue(f.context, request);
|
|
806
|
+
if (!('status' in result))
|
|
807
|
+
assert.fail('Expected created recovery');
|
|
808
|
+
assert.equal(result.status, 'created-not-started');
|
|
809
|
+
assert.equal(result.failure.phase, 'project-status');
|
|
810
|
+
f.controls.projectFailure = '';
|
|
811
|
+
assert.ok('reused' in (await startTrackedIssue(f.context, result.safeResume.arguments)));
|
|
812
|
+
assert.equal(f.branchWrites.length, 1);
|
|
813
|
+
assert.equal(f.comments.length, 1);
|
|
814
|
+
assert.equal(f.writes.filter((write) => !('issue_number' in write)).length, 1);
|
|
815
|
+
assert.equal(f.getStatus(), 'Active');
|
|
816
|
+
});
|
|
817
|
+
test.each(['closed', 'blocked', 'parked', 'archived'])('start recovery refuses current %s truth before Project or journal writes', async (state) => {
|
|
818
|
+
const f = fixture();
|
|
819
|
+
f.controls.branchFailure = true;
|
|
820
|
+
const result = await startTrackedIssue(f.context, { issueNumber: 17 });
|
|
821
|
+
if (result.status !== 'start-incomplete')
|
|
822
|
+
assert.fail('Expected recovery');
|
|
823
|
+
f.controls.branchFailure = false;
|
|
824
|
+
if (state === 'closed')
|
|
825
|
+
f.live.state = 'closed';
|
|
826
|
+
if (state === 'blocked')
|
|
827
|
+
f.controls.blockers = true;
|
|
828
|
+
if (state === 'parked')
|
|
829
|
+
f.live.body = renderIssueBody({ ...ready(), draft: true });
|
|
830
|
+
if (state === 'archived')
|
|
831
|
+
f.controls.projectArchived = true;
|
|
832
|
+
const retry = await startTrackedIssue(f.context, result.safeResume.arguments).catch((error) => {
|
|
833
|
+
assert.ok(error instanceof Error);
|
|
834
|
+
return undefined;
|
|
835
|
+
});
|
|
836
|
+
assert.ok(retry === undefined || 'status' in retry, 'Current refusal must not report success');
|
|
837
|
+
assert.equal(f.branchWrites.length, 1);
|
|
838
|
+
assert.equal(f.statusWrites.length, 0);
|
|
839
|
+
assert.equal(f.comments.length, 0);
|
|
840
|
+
});
|
|
841
|
+
test.each(['closeAfterBranch', 'blockAfterBranch'])('start rechecks live eligibility after %s before changing the board', async (control) => {
|
|
842
|
+
const f = fixture();
|
|
843
|
+
f.controls[control] = true;
|
|
844
|
+
const result = await startTrackedIssue(f.context, { issueNumber: 17 });
|
|
845
|
+
assert.ok('status' in result);
|
|
846
|
+
assert.equal(f.statusWrites.length, 0);
|
|
847
|
+
assert.equal(f.comments.length, 0);
|
|
848
|
+
});
|
|
849
|
+
async function bindStartFixture(f) {
|
|
850
|
+
const settings = await import('./config/deliveryConfig.js');
|
|
851
|
+
const issues = await import('./issue.js');
|
|
852
|
+
vi.spyOn(settings, 'loadDeliverySettings').mockResolvedValue({
|
|
853
|
+
roles: { author: { identity: 'author', authSource: 'personal' }, reviewer: { identity: 'reviewer' } },
|
|
854
|
+
});
|
|
855
|
+
vi.spyOn(issues, 'loadDeliveryContext').mockResolvedValue(f.context);
|
|
856
|
+
}
|
|
857
|
+
test('MCP explicit start returns Project recovery and reuses the exact branch on retry', async () => {
|
|
858
|
+
const f = fixture();
|
|
859
|
+
await bindStartFixture(f);
|
|
860
|
+
f.controls.projectFailure = 'after';
|
|
861
|
+
const server = createAiDeliveryMcpServer({ repoRoot: '/unrelated' });
|
|
862
|
+
const client = new Client({ name: 'fictional-start-project', version: '1.0.0' });
|
|
863
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
864
|
+
try {
|
|
865
|
+
await server.connect(serverTransport);
|
|
866
|
+
await client.connect(clientTransport);
|
|
867
|
+
const call = async (arguments_) => {
|
|
868
|
+
const reply = await client.callTool({ name: 'issue_start', arguments: arguments_ });
|
|
869
|
+
assert.equal(reply.isError, undefined);
|
|
870
|
+
return JSON.parse(z.object({ content: z.array(z.object({ type: z.literal('text'), text: z.string() })) }).parse(reply).content[0]
|
|
871
|
+
.text);
|
|
872
|
+
};
|
|
873
|
+
const interrupted = await call({ repo: 'example/widget', issueNumber: 17 });
|
|
874
|
+
assert.equal(interrupted.status, 'start-incomplete');
|
|
875
|
+
assert.ok(interrupted.safeResume);
|
|
876
|
+
assert.equal(f.comments.length, 0);
|
|
877
|
+
f.controls.projectFailure = '';
|
|
878
|
+
const result = await call(interrupted.safeResume.arguments);
|
|
879
|
+
assert.equal(result.branch, 'issue/17');
|
|
880
|
+
assert.equal(result.issueNumber, 17);
|
|
881
|
+
assert.equal(f.getStatus(), 'Active');
|
|
882
|
+
assert.equal(f.statusWrites.length, 1);
|
|
883
|
+
assert.equal(f.branchWrites.length, 1);
|
|
884
|
+
assert.equal(f.comments.length, 1);
|
|
885
|
+
}
|
|
886
|
+
finally {
|
|
887
|
+
await client.close();
|
|
888
|
+
await server.close();
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
test.each(['success', 'failure'])('CLI explicit start shares Project transition and %s output', async (mode) => {
|
|
892
|
+
vi.resetModules();
|
|
893
|
+
const f = fixture();
|
|
894
|
+
await bindStartFixture(f);
|
|
895
|
+
if (mode === 'failure')
|
|
896
|
+
f.controls.projectFailure = 'before';
|
|
897
|
+
const argv = process.argv;
|
|
898
|
+
const exitCode = process.exitCode;
|
|
899
|
+
let stdout = '';
|
|
900
|
+
let completed = () => { };
|
|
901
|
+
const output = new Promise((resolve) => {
|
|
902
|
+
completed = resolve;
|
|
903
|
+
});
|
|
904
|
+
vi.spyOn(process.stdout, 'write').mockImplementation((value) => {
|
|
905
|
+
stdout += String(value);
|
|
906
|
+
if (String(value).startsWith('{'))
|
|
907
|
+
completed();
|
|
908
|
+
return true;
|
|
909
|
+
});
|
|
910
|
+
try {
|
|
911
|
+
process.exitCode = undefined;
|
|
912
|
+
process.argv = [process.execPath, 'ai-delivery', '--repo', 'example/widget', 'start', '--issue', '17'];
|
|
913
|
+
await import('./cli.js');
|
|
914
|
+
await output;
|
|
915
|
+
const result = JSON.parse(stdout);
|
|
916
|
+
if (mode === 'failure') {
|
|
917
|
+
assert.equal(result.status, 'start-incomplete');
|
|
918
|
+
assert.equal(result.safeResume?.arguments.issueNumber, 17);
|
|
919
|
+
assert.equal(process.exitCode, 1);
|
|
920
|
+
assert.equal(f.getStatus(), 'Queued');
|
|
921
|
+
assert.equal(f.comments.length, 0);
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
assert.equal(result.branch, 'issue/17');
|
|
925
|
+
assert.equal(process.exitCode, undefined);
|
|
926
|
+
assert.equal(f.getStatus(), 'Active');
|
|
927
|
+
assert.equal(f.comments.length, 1);
|
|
928
|
+
}
|
|
929
|
+
assert.equal(f.branchWrites.length, 1);
|
|
930
|
+
assert.equal(f.statusWrites.length, 1);
|
|
931
|
+
}
|
|
932
|
+
finally {
|
|
933
|
+
process.argv = argv;
|
|
934
|
+
process.exitCode = exitCode;
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
test('info and unrelated body edits never imply explicit activation', async () => {
|
|
938
|
+
const f = fixture();
|
|
939
|
+
const { issueInfo } = await import('./issue.js');
|
|
940
|
+
await issueInfo(f.context, 17);
|
|
941
|
+
await updateIssue(f.context, {
|
|
942
|
+
issueNumber: 17,
|
|
943
|
+
outcome: 'Reject invalid widgets while retaining deferred execution.',
|
|
944
|
+
});
|
|
945
|
+
assert.equal(f.getStatus(), 'Queued');
|
|
946
|
+
assert.equal(f.statusWrites.length, 0);
|
|
947
|
+
assert.equal(f.branchWrites.length, 0);
|
|
948
|
+
assert.equal(f.comments.length, 0);
|
|
949
|
+
});
|
|
950
|
+
test.each(['project-status', 'journal'])('created recovery after %s preserves a subsequent native park', async (phase) => {
|
|
951
|
+
const f = fixture();
|
|
952
|
+
f.controls.created = false;
|
|
953
|
+
f.controls.projectFailure = phase === 'project-status' ? 'before' : '';
|
|
954
|
+
f.controls.journalFailure = phase === 'journal';
|
|
955
|
+
const result = await startTrackedIssue(f.context, {
|
|
956
|
+
title: ready().title,
|
|
957
|
+
body: renderIssueBody(ready()),
|
|
958
|
+
issueType: 'Task',
|
|
959
|
+
points: 2,
|
|
960
|
+
requestId: 'parked-created-' + phase,
|
|
961
|
+
});
|
|
962
|
+
if (result.status !== 'created-not-started')
|
|
963
|
+
assert.fail('Expected known-created recovery');
|
|
964
|
+
assert.equal(result.failure.phase, phase);
|
|
965
|
+
f.controls.projectFailure = '';
|
|
966
|
+
f.controls.journalFailure = false;
|
|
967
|
+
await updateIssue(f.context, { issueNumber: 17, park: true });
|
|
968
|
+
const parkedBody = f.live.body;
|
|
969
|
+
const writesBeforeRetry = f.writes.length;
|
|
970
|
+
const statusWritesBeforeRetry = f.statusWrites.length;
|
|
971
|
+
const commentsBeforeRetry = f.comments.length;
|
|
972
|
+
const retry = await startTrackedIssue(f.context, getAiDeliveryMcpTool('issue_start').inputSchema.parse(result.safeResume.arguments)).catch((error) => {
|
|
973
|
+
assert.ok(error instanceof Error);
|
|
974
|
+
return undefined;
|
|
975
|
+
});
|
|
976
|
+
assert.equal(f.live.body, parkedBody);
|
|
977
|
+
assert.equal(parseIssueBody(f.live.body, { title: f.live.title }).issue.draft, true);
|
|
978
|
+
assert.equal(f.getStatus(), 'Queued');
|
|
979
|
+
assert.ok(retry === undefined || retry.status !== undefined, 'Parked recovery must not succeed');
|
|
980
|
+
assert.equal(f.writes.length, writesBeforeRetry);
|
|
981
|
+
assert.equal(f.statusWrites.length, statusWritesBeforeRetry);
|
|
982
|
+
assert.equal(f.comments.length, commentsBeforeRetry);
|
|
983
|
+
assert.equal(f.branchWrites.length, 1);
|
|
984
|
+
});
|
|
985
|
+
test('created post-tracking recovery preserves later ready content without replaying tracking writes', async () => {
|
|
986
|
+
const f = fixture();
|
|
987
|
+
f.controls.created = false;
|
|
988
|
+
f.controls.projectFailure = 'before';
|
|
989
|
+
const result = await startTrackedIssue(f.context, {
|
|
990
|
+
title: ready().title,
|
|
991
|
+
body: renderIssueBody(ready()),
|
|
992
|
+
issueType: 'Task',
|
|
993
|
+
points: 2,
|
|
994
|
+
requestId: 'edited-created-recovery',
|
|
995
|
+
});
|
|
996
|
+
if (result.status !== 'created-not-started')
|
|
997
|
+
assert.fail('Expected known-created recovery');
|
|
998
|
+
f.controls.projectFailure = '';
|
|
999
|
+
await updateIssue(f.context, { issueNumber: 17, outcome: 'Deliver the revised current acceptance evidence.' });
|
|
1000
|
+
const revised = f.live.body;
|
|
1001
|
+
const writes = f.writes.length;
|
|
1002
|
+
assert.ok('reused' in
|
|
1003
|
+
(await startTrackedIssue(f.context, getAiDeliveryMcpTool('issue_start').inputSchema.parse(result.safeResume.arguments))));
|
|
1004
|
+
assert.equal(f.live.body, revised);
|
|
1005
|
+
assert.equal(f.writes.length, writes);
|
|
1006
|
+
assert.equal(f.branchWrites.length, 1);
|
|
1007
|
+
assert.equal(f.getStatus(), 'Active');
|
|
1008
|
+
});
|
|
649
1009
|
//# sourceMappingURL=issueIntake.test.js.map
|