@aviaratech/ai-delivery 0.3.27 → 0.3.29
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 +18 -0
- package/dist/currentTrackingScenario.test.d.ts +1 -0
- package/dist/currentTrackingScenario.test.js +486 -0
- package/dist/currentTrackingScenario.test.js.map +1 -0
- package/dist/directoryIndependent.test.js +47 -0
- package/dist/directoryIndependent.test.js.map +1 -1
- package/dist/issueIntake.test.js +18 -3
- 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/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 +12 -11
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +19 -3
package/README.md
CHANGED
|
@@ -252,6 +252,24 @@ Legacy transitions remain explicit preservation operations. Inspection returns e
|
|
|
252
252
|
|
|
253
253
|
The remote contract is `ai-delivery.mcp@2`. CLI and MCP call the same owners. Issue listing/search preserve native filters, pagination, literal search boundaries and repository-qualified relationships. Issue updates preserve typed journals, history-before-rewrite and native reasoned closure. `issue_info.worktree` is null. Offline `migrate:legacy-issues --input-file` remains a read-only plan. Public exports expose remote delivery, metadata, digest utilities and explicit setup; removed executable policy/stage/evidence APIs are not exported.
|
|
254
254
|
|
|
255
|
+
### Synthetic tracking replay and quick reference
|
|
256
|
+
|
|
257
|
+
Pass `repo: "owner/name"` to MCP calls or global `--repo owner/name` to the CLI, including outside Git. The following operations are shipped:
|
|
258
|
+
|
|
259
|
+
| Operation | MCP tool | CLI command and key inputs |
|
|
260
|
+
| --- | --- | --- |
|
|
261
|
+
| List / search | `issue_list` / `issue_search` | `list` / `search --query <literal-text>`; native filters and pagination |
|
|
262
|
+
| Read / check readiness | `issue_info` / `issue_ready_check` | `info --issue N` / `ready:check --issue N` |
|
|
263
|
+
| Create a sized child | `issue_create` | `create --title <title> --fields-file <typed.json> --parent P --priority P2` |
|
|
264
|
+
| Rewrite with prior history | `issue_update` | `update --issue N --fields-file <typed.json> --preserve-history` |
|
|
265
|
+
| Reparent one issue | `issue_update` | `update --issue N --parent P`; repeat separately for each issue |
|
|
266
|
+
| Record a typed journal | `issue_comment` | See the [typed journal contract](#typed-issue-journals); the MCP call returns the authored comment identity and readback |
|
|
267
|
+
| Close with a reason | `issue_update` | `update --issue N --state closed --close-reason not_planned --superseded-by S` |
|
|
268
|
+
|
|
269
|
+
Typed JSON contains the issue contract fields, including Issue Type, Points, problem, outcome, acceptance and non-goals. CLI repository, parent and priority selectors use their documented flags. Inspect each result: rewrites return the preserved history comment; creation and reparenting return native readback. Reasoned closure returns `closure` evidence, supersession and the authored comment from `issue_update`; `issue_info` supplies state and Project status without the closure-reason evidence. A successful readiness check does not start an issue.
|
|
270
|
+
|
|
271
|
+
`src/currentTrackingScenario.test.ts` composes these operations through one real SDK client/server session outside Git. Only external GitHub/auth ports are synthetic; settings, discovery, schemas, dispatch and owners run normally. Stored issue fields, parent membership, exact escaped history whitespace, comments, closure and configured Project Done are checked after writes. Invalid schemas and unsupported batch/defer requests must leave stored state and native write counts unchanged. Batch operations, trigger-based deferral and WIP enforcement remain unshipped; parking a draft is a separate operation. This synthetic replay does not complete the broader tracking parent or prove a live backlog replay.
|
|
272
|
+
|
|
255
273
|
## Blocker overrides and delivery health
|
|
256
274
|
|
|
257
275
|
`create`, `start` and `update` accept `--blocks <issue-numbers>` to add the
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
7
|
+
import { test, vi } from 'vitest';
|
|
8
|
+
import * as githubClients from './github/client.js';
|
|
9
|
+
import { syntheticDiscoveryClients, syntheticDiscoveryConfig } from './fixtures/discovery.js';
|
|
10
|
+
import { createAiDeliveryMcpServer } from './mcp/index.js';
|
|
11
|
+
import { canonicalIssueBody } from './issue.js';
|
|
12
|
+
// Only the external GitHub/auth port is replaced. Reads reflect stored writes;
|
|
13
|
+
// unexpected endpoints and foreign targets fail instead of returning canned success.
|
|
14
|
+
function trackingRepository() {
|
|
15
|
+
const issues = new Map();
|
|
16
|
+
const comments = [];
|
|
17
|
+
const events = [];
|
|
18
|
+
let writes = 0;
|
|
19
|
+
const add = (number, title, body, parent) => {
|
|
20
|
+
const value = {
|
|
21
|
+
number,
|
|
22
|
+
id: 100 + number,
|
|
23
|
+
node_id: `ISSUE${String(number)}`,
|
|
24
|
+
title,
|
|
25
|
+
body,
|
|
26
|
+
state: 'open',
|
|
27
|
+
type: { name: 'Task' },
|
|
28
|
+
labels: [],
|
|
29
|
+
html_url: `https://github.com/example/widget/issues/${String(number)}`,
|
|
30
|
+
updated_at: '2026-10-07T00:00:00Z',
|
|
31
|
+
parent,
|
|
32
|
+
status: parent === null ? null : 'Active',
|
|
33
|
+
reason: null,
|
|
34
|
+
...(parent === null ? {} : { points: 2, priority: 'High' }),
|
|
35
|
+
};
|
|
36
|
+
issues.set(number, value);
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
39
|
+
add(10, 'Original tracking parent', 'Original unsized parent', null);
|
|
40
|
+
add(20, 'Replacement tracking parent', 'Replacement unsized parent', null);
|
|
41
|
+
add(17, ' Legacy <tracking> & title\r\n', '\nLegacy & backlog <tag>\t \r\n', 10);
|
|
42
|
+
add(18, 'Second tracking issue', canonicalIssueBody({
|
|
43
|
+
title: 'Second tracking issue',
|
|
44
|
+
issueType: 'Task',
|
|
45
|
+
points: 2,
|
|
46
|
+
problem: 'A second executable issue needs a new parent.',
|
|
47
|
+
outcome: 'The issue retains its contract when reparented.',
|
|
48
|
+
acceptanceCriteria: [
|
|
49
|
+
{
|
|
50
|
+
behavior: 'A parent update returns the new native parent.',
|
|
51
|
+
verifiedBy: 'The scenario checks persisted parent membership.',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
outOfScope: ['Changing the executable work.'],
|
|
55
|
+
openQuestions: [],
|
|
56
|
+
draft: false,
|
|
57
|
+
}), 10);
|
|
58
|
+
const get = (number) => {
|
|
59
|
+
assert.equal(typeof number, 'number');
|
|
60
|
+
const issue = issues.get(number);
|
|
61
|
+
assert.ok(issue, `Unknown synthetic issue ${String(number)}`);
|
|
62
|
+
return issue;
|
|
63
|
+
};
|
|
64
|
+
const target = (input) => {
|
|
65
|
+
if ('owner' in input)
|
|
66
|
+
assert.equal(input.owner, 'example');
|
|
67
|
+
if ('repo' in input)
|
|
68
|
+
assert.equal(input.repo, 'widget');
|
|
69
|
+
if ('name' in input)
|
|
70
|
+
assert.equal(input.name, 'widget');
|
|
71
|
+
if ('org' in input)
|
|
72
|
+
assert.equal(input.org, 'example');
|
|
73
|
+
};
|
|
74
|
+
const mutation = (event) => {
|
|
75
|
+
writes += 1;
|
|
76
|
+
events.push(event);
|
|
77
|
+
};
|
|
78
|
+
const values = (issue) => [
|
|
79
|
+
...(issue.points === undefined
|
|
80
|
+
? []
|
|
81
|
+
: [
|
|
82
|
+
{
|
|
83
|
+
issue_field_id: 101,
|
|
84
|
+
issue_field_name: 'Estimate',
|
|
85
|
+
data_type: 'single_select',
|
|
86
|
+
value: String(issue.points),
|
|
87
|
+
single_select_option: { name: String(issue.points) },
|
|
88
|
+
},
|
|
89
|
+
]),
|
|
90
|
+
...(issue.priority === undefined
|
|
91
|
+
? []
|
|
92
|
+
: [
|
|
93
|
+
{
|
|
94
|
+
issue_field_id: 102,
|
|
95
|
+
issue_field_name: 'Urgency',
|
|
96
|
+
data_type: 'single_select',
|
|
97
|
+
value: issue.priority,
|
|
98
|
+
single_select_option: { name: issue.priority },
|
|
99
|
+
},
|
|
100
|
+
]),
|
|
101
|
+
];
|
|
102
|
+
const listSubIssues = async (input) => {
|
|
103
|
+
target(input);
|
|
104
|
+
get(input.issue_number);
|
|
105
|
+
return { data: structuredClone([...issues.values()].filter((issue) => issue.parent === input.issue_number)) };
|
|
106
|
+
};
|
|
107
|
+
const rest = {
|
|
108
|
+
issues: {
|
|
109
|
+
get: async (input) => {
|
|
110
|
+
target(input);
|
|
111
|
+
return { data: structuredClone(get(input.issue_number)) };
|
|
112
|
+
},
|
|
113
|
+
listForRepo: async (input) => {
|
|
114
|
+
target(input);
|
|
115
|
+
assert.equal(input.page, 1);
|
|
116
|
+
return {
|
|
117
|
+
data: structuredClone([...issues.values()].filter((issue) => input.state === 'all' || issue.state === input.state)),
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
listSubIssues,
|
|
121
|
+
create: async (input) => {
|
|
122
|
+
target(input);
|
|
123
|
+
assert.equal(issues.has(31), false, 'the scenario creates exactly one child');
|
|
124
|
+
assert.equal(input.type, 'Task');
|
|
125
|
+
const issue = add(31, input.title, input.body, null);
|
|
126
|
+
mutation('issue:create:31');
|
|
127
|
+
return { data: structuredClone(issue) };
|
|
128
|
+
},
|
|
129
|
+
update: async (input) => {
|
|
130
|
+
target(input);
|
|
131
|
+
const issue = get(input.issue_number);
|
|
132
|
+
for (const key of ['title', 'body', 'state'])
|
|
133
|
+
if (typeof input[key] === 'string')
|
|
134
|
+
issue[key] = input[key];
|
|
135
|
+
if (typeof input.type === 'string')
|
|
136
|
+
issue.type = { name: input.type };
|
|
137
|
+
if (typeof input.state_reason === 'string')
|
|
138
|
+
issue.reason = input.state_reason.toUpperCase();
|
|
139
|
+
mutation(`issue:update:${String(issue.number)}`);
|
|
140
|
+
return { data: structuredClone(issue) };
|
|
141
|
+
},
|
|
142
|
+
addSubIssue: async (input) => {
|
|
143
|
+
target(input);
|
|
144
|
+
const parent = get(input.issue_number);
|
|
145
|
+
const child = [...issues.values()].find((issue) => issue.id === input.sub_issue_id);
|
|
146
|
+
assert.ok(child);
|
|
147
|
+
assert.equal(child.parent, null);
|
|
148
|
+
child.parent = parent.number;
|
|
149
|
+
mutation(`parent:add:${String(child.number)}:${String(parent.number)}`);
|
|
150
|
+
return { data: structuredClone(child) };
|
|
151
|
+
},
|
|
152
|
+
removeSubIssue: async (input) => {
|
|
153
|
+
target(input);
|
|
154
|
+
const child = [...issues.values()].find((issue) => issue.id === input.sub_issue_id);
|
|
155
|
+
assert.ok(child);
|
|
156
|
+
assert.equal(child.parent, input.issue_number);
|
|
157
|
+
child.parent = null;
|
|
158
|
+
mutation(`parent:remove:${String(child.number)}`);
|
|
159
|
+
return { data: structuredClone(child) };
|
|
160
|
+
},
|
|
161
|
+
listComments: async (input) => {
|
|
162
|
+
target(input);
|
|
163
|
+
const issue = get(input.issue_number);
|
|
164
|
+
return {
|
|
165
|
+
data: structuredClone(comments.filter((comment) => comment.issue_url.endsWith(`/issues/${String(issue.number)}`))),
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
createComment: async (input) => {
|
|
169
|
+
target(input);
|
|
170
|
+
const issue = get(input.issue_number);
|
|
171
|
+
const id = 101 + comments.length;
|
|
172
|
+
const comment = {
|
|
173
|
+
id,
|
|
174
|
+
body: input.body,
|
|
175
|
+
html_url: `${issue.html_url}#issuecomment-${String(id)}`,
|
|
176
|
+
issue_url: `https://api.github.com/repos/example/widget/issues/${String(issue.number)}`,
|
|
177
|
+
user: { login: 'operator' },
|
|
178
|
+
};
|
|
179
|
+
comments.push(comment);
|
|
180
|
+
mutation(`comment:create:${String(id)}`);
|
|
181
|
+
return { data: structuredClone(comment) };
|
|
182
|
+
},
|
|
183
|
+
getComment: async (input) => {
|
|
184
|
+
target(input);
|
|
185
|
+
const comment = comments.find((value) => value.id === input.comment_id);
|
|
186
|
+
assert.ok(comment);
|
|
187
|
+
events.push(`comment:read:${String(comment.id)}`);
|
|
188
|
+
return { data: structuredClone(comment) };
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
search: {
|
|
192
|
+
issuesAndPullRequests: async (input) => {
|
|
193
|
+
assert.equal(input.page, 1);
|
|
194
|
+
assert.equal(typeof input.q, 'string');
|
|
195
|
+
const match = /^repo:example\/widget is:issue "(Legacy|Replacement)"$/u.exec(input.q);
|
|
196
|
+
assert.ok(match, 'search must retain repository and literal text boundaries');
|
|
197
|
+
const items = [...issues.values()].filter((issue) => `${issue.title}\n${issue.body}`.includes(match[1]));
|
|
198
|
+
return { data: { total_count: items.length, incomplete_results: false, items: structuredClone(items) } };
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
paginate: async (method, input) => {
|
|
202
|
+
assert.equal(method, listSubIssues);
|
|
203
|
+
return (await method(input)).data;
|
|
204
|
+
},
|
|
205
|
+
request: async (route, input) => {
|
|
206
|
+
target(input);
|
|
207
|
+
if (route === 'GET /orgs/{org}/issue-fields')
|
|
208
|
+
return {
|
|
209
|
+
data: [
|
|
210
|
+
{
|
|
211
|
+
id: 101,
|
|
212
|
+
name: 'Estimate',
|
|
213
|
+
data_type: 'single_select',
|
|
214
|
+
options: [{ name: '1' }, { name: '2' }, { name: '4' }],
|
|
215
|
+
},
|
|
216
|
+
{ id: 102, name: 'Urgency', data_type: 'single_select', options: [{ name: 'High' }, { name: 'Low' }] },
|
|
217
|
+
],
|
|
218
|
+
};
|
|
219
|
+
const issue = get(input.issue_number);
|
|
220
|
+
if (route === 'POST /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values') {
|
|
221
|
+
for (const field of input.issue_field_values) {
|
|
222
|
+
if (field.field_id === 101)
|
|
223
|
+
issue.points = Number(field.value);
|
|
224
|
+
else {
|
|
225
|
+
assert.equal(field.field_id, 102);
|
|
226
|
+
issue.priority = field.value;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
mutation(`fields:${String(issue.number)}`);
|
|
230
|
+
}
|
|
231
|
+
else
|
|
232
|
+
assert.equal(route, 'GET /repos/{owner}/{repo}/issues/{issue_number}/issue-field-values');
|
|
233
|
+
return { data: values(issue) };
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
const discovery = syntheticDiscoveryClients();
|
|
237
|
+
const page = (nodes) => ({ nodes, pageInfo: { hasNextPage: false, endCursor: null } });
|
|
238
|
+
const projectItem = (issue) => ({
|
|
239
|
+
id: `ITEM${String(issue.number)}`,
|
|
240
|
+
isArchived: false,
|
|
241
|
+
content: { id: issue.node_id },
|
|
242
|
+
fieldValueByName: {
|
|
243
|
+
name: issue.status,
|
|
244
|
+
optionId: `STATUS-${String(['Queued', 'Active', 'Waiting', 'Shipped'].indexOf(issue.status))}`,
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
const graphql = async (query, input) => {
|
|
248
|
+
target(input);
|
|
249
|
+
if (query.includes('blockedBy(first:')) {
|
|
250
|
+
const issue = get(input.number);
|
|
251
|
+
return {
|
|
252
|
+
repository: {
|
|
253
|
+
issue: {
|
|
254
|
+
parent: issue.parent === null
|
|
255
|
+
? null
|
|
256
|
+
: {
|
|
257
|
+
id: get(issue.parent).node_id,
|
|
258
|
+
number: issue.parent,
|
|
259
|
+
repository: { nameWithOwner: 'example/widget' },
|
|
260
|
+
},
|
|
261
|
+
blockedBy: page([]),
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
if (query.includes('IssueClosureReadback')) {
|
|
267
|
+
const issue = get(input.number);
|
|
268
|
+
return {
|
|
269
|
+
repository: {
|
|
270
|
+
issue: {
|
|
271
|
+
number: issue.number,
|
|
272
|
+
repository: { nameWithOwner: 'example/widget' },
|
|
273
|
+
state: issue.state.toUpperCase(),
|
|
274
|
+
stateReason: issue.reason,
|
|
275
|
+
duplicateOf: null,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
if (query.includes('ProjectDeliveryItems'))
|
|
281
|
+
return {
|
|
282
|
+
organization: {
|
|
283
|
+
projectV2: { items: page([...issues.values()].filter((issue) => issue.status !== null).map(projectItem)) },
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
if (query.includes('AddProjectDeliveryItem')) {
|
|
287
|
+
const issue = [...issues.values()].find((value) => value.node_id === input.contentId);
|
|
288
|
+
assert.ok(issue);
|
|
289
|
+
assert.equal(input.projectId, 'PROJECT-1');
|
|
290
|
+
mutation(`project:add:${String(issue.number)}`);
|
|
291
|
+
return { addProjectV2ItemById: { item: { id: `ITEM${String(issue.number)}` } } };
|
|
292
|
+
}
|
|
293
|
+
if (query.includes('UpdateProjectDeliveryStatus')) {
|
|
294
|
+
const issue = get(Number(String(input.itemId).slice(4)));
|
|
295
|
+
assert.equal(input.projectId, 'PROJECT-1');
|
|
296
|
+
assert.equal(input.fieldId, 'STATUS-FIELD');
|
|
297
|
+
const status = ['Queued', 'Active', 'Waiting', 'Shipped'][Number(String(input.optionId).slice(7))];
|
|
298
|
+
assert.ok(status);
|
|
299
|
+
issue.status = status;
|
|
300
|
+
mutation(`project:status:${String(issue.number)}:${status}`);
|
|
301
|
+
return { updateProjectV2ItemFieldValue: { projectV2Item: { id: input.itemId } } };
|
|
302
|
+
}
|
|
303
|
+
if (query.includes('ProjectDeliveryItemReadback')) {
|
|
304
|
+
const issue = get(Number(String(input.itemId).slice(4)));
|
|
305
|
+
return { node: { ...projectItem(issue), project: { id: 'PROJECT-1', number: 1 } } };
|
|
306
|
+
}
|
|
307
|
+
return discovery.graphql(query, input);
|
|
308
|
+
};
|
|
309
|
+
return {
|
|
310
|
+
issues,
|
|
311
|
+
comments,
|
|
312
|
+
events,
|
|
313
|
+
rest,
|
|
314
|
+
graphql,
|
|
315
|
+
snapshot: () => structuredClone({ issues: [...issues.values()], comments, writes }),
|
|
316
|
+
writes: () => writes,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
test('composes shipped tracking through one non-Git MCP session with persisted readbacks and inert refusals', async () => {
|
|
320
|
+
const root = mkdtempSync(join(tmpdir(), 'delivery-tracking-scenario-'));
|
|
321
|
+
const fixture = trackingRepository();
|
|
322
|
+
vi.stubEnv('AI_DELIVERY_CONFIG', join(root, 'operator.json'));
|
|
323
|
+
writeFileSync(join(root, 'operator.json'), JSON.stringify({
|
|
324
|
+
schemaVersion: 'ai-delivery.user@1',
|
|
325
|
+
roles: {
|
|
326
|
+
author: { authSource: 'personal', identity: 'host-author', credentialEnv: { token: 'SYNTHETIC_TOKEN' } },
|
|
327
|
+
reviewer: {
|
|
328
|
+
identity: 'app-reviewer',
|
|
329
|
+
credentialEnv: { appId: 'APP_ID', installationId: 'INSTALLATION_ID', privateKeyPath: 'KEY_PATH' },
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
project: 1,
|
|
333
|
+
checkoutRoots: [],
|
|
334
|
+
pointsField: 'Estimate',
|
|
335
|
+
priorityField: 'Urgency',
|
|
336
|
+
statusField: 'Flow',
|
|
337
|
+
statuses: syntheticDiscoveryConfig.native.project.statuses,
|
|
338
|
+
}));
|
|
339
|
+
vi.spyOn(githubClients, 'createDeliveryGitHubClients').mockImplementation(async (input) => {
|
|
340
|
+
assert.equal(input.role, 'author');
|
|
341
|
+
return {
|
|
342
|
+
role: 'author',
|
|
343
|
+
authSource: 'personal',
|
|
344
|
+
authenticatedAuthor: async () => ({ actorLogin: 'operator', credentialIdentity: 'user:1' }),
|
|
345
|
+
rest: fixture.rest,
|
|
346
|
+
graphql: fixture.graphql,
|
|
347
|
+
};
|
|
348
|
+
});
|
|
349
|
+
const server = createAiDeliveryMcpServer({ repoRoot: root });
|
|
350
|
+
const client = new Client({ name: 'tracking-scenario', version: '1' });
|
|
351
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
352
|
+
async function call(name, args) {
|
|
353
|
+
const result = await client.callTool({ name, arguments: { repo: 'example/widget', ...args } });
|
|
354
|
+
assert.equal(result.isError, undefined, JSON.stringify(result));
|
|
355
|
+
return JSON.parse(result.content[0].text);
|
|
356
|
+
}
|
|
357
|
+
async function refuse(name, args) {
|
|
358
|
+
const before = fixture.snapshot();
|
|
359
|
+
const refused = await client.callTool({ name, arguments: { repo: 'example/widget', ...args } }).then((result) => result.isError === true, () => true);
|
|
360
|
+
assert.equal(refused, true, name);
|
|
361
|
+
assert.deepEqual(fixture.snapshot(), before, `${name} must not mutate stored native state or write count`);
|
|
362
|
+
}
|
|
363
|
+
const fields = {
|
|
364
|
+
issueType: 'Task',
|
|
365
|
+
points: 2,
|
|
366
|
+
problem: 'Legacy tracking needs a portable replacement.',
|
|
367
|
+
outcome: 'Replacement tracking has an explicit native readback.',
|
|
368
|
+
acceptanceCriteria: [
|
|
369
|
+
{
|
|
370
|
+
behavior: 'Invalid tracking requests leave native state unchanged.',
|
|
371
|
+
verifiedBy: 'The synthetic MCP scenario compares stored state and writes.',
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
outOfScope: ['Implementing batch or deferral.'],
|
|
375
|
+
openQuestions: [],
|
|
376
|
+
context: {
|
|
377
|
+
files: ['src/currentTrackingScenario.test.ts'],
|
|
378
|
+
evidence: ['https://github.com/example/widget/issues/17'],
|
|
379
|
+
},
|
|
380
|
+
draft: false,
|
|
381
|
+
};
|
|
382
|
+
try {
|
|
383
|
+
await server.connect(serverTransport);
|
|
384
|
+
await client.connect(clientTransport);
|
|
385
|
+
assert.equal(existsSync(join(root, '.git')), false);
|
|
386
|
+
const tools = (await client.listTools()).tools.map((tool) => tool.name);
|
|
387
|
+
for (const name of ['issue_list', 'issue_search', 'issue_update', 'issue_create', 'issue_comment', 'issue_info'])
|
|
388
|
+
assert.ok(tools.includes(name));
|
|
389
|
+
const original = await call('issue_list', {
|
|
390
|
+
parentIssueNumber: 10,
|
|
391
|
+
state: 'all',
|
|
392
|
+
});
|
|
393
|
+
assert.deepEqual(original.issues.map((issue) => issue.number), [17, 18]);
|
|
394
|
+
const found = await call('issue_search', { query: 'Legacy', state: 'all' });
|
|
395
|
+
assert.deepEqual(found.issues.map((issue) => issue.number), [17]);
|
|
396
|
+
await refuse('issue_update', { issueNumber: 17, points: 'two' });
|
|
397
|
+
const rewritten = await call('issue_update', {
|
|
398
|
+
...fields,
|
|
399
|
+
issueNumber: 17,
|
|
400
|
+
title: 'Replacement tracking issue',
|
|
401
|
+
preserveHistory: true,
|
|
402
|
+
});
|
|
403
|
+
const expectedHistory = '<details>\n<summary>Previous issue title and body</summary>\n\nTitle:\n<pre> Legacy <tracking> & title\r\n</pre>\n\nBody:\n<pre>\nLegacy & backlog <tag>\t \r\n</pre>\n\n</details>';
|
|
404
|
+
assert.equal(rewritten.historyComment.body, expectedHistory);
|
|
405
|
+
assert.equal(fixture.comments[0].body, expectedHistory);
|
|
406
|
+
assert.equal(fixture.comments[0].user.login, 'operator');
|
|
407
|
+
const historyRead = fixture.events.indexOf('comment:read:101');
|
|
408
|
+
assert.ok(historyRead >= 0 && historyRead < fixture.events.indexOf('issue:update:17'));
|
|
409
|
+
assert.equal(rewritten.title, fixture.issues.get(17).title);
|
|
410
|
+
assert.equal(rewritten.body, fixture.issues.get(17).body);
|
|
411
|
+
const created = await call('issue_create', {
|
|
412
|
+
...fields,
|
|
413
|
+
title: 'Replacement sized child',
|
|
414
|
+
priority: 'High',
|
|
415
|
+
parentIssueNumber: 20,
|
|
416
|
+
});
|
|
417
|
+
assert.equal(created.created.number, 31);
|
|
418
|
+
const child = await call('issue_info', { issueNumber: created.created.number });
|
|
419
|
+
assert.equal(child.points, 2);
|
|
420
|
+
assert.equal(child.priority, 'High');
|
|
421
|
+
assert.equal(child.issueType, 'Task');
|
|
422
|
+
assert.equal(child.parentIssueNumber, 20);
|
|
423
|
+
assert.equal(child.projectStatus, 'Todo');
|
|
424
|
+
assert.equal(fixture.issues.get(31).parent, 20);
|
|
425
|
+
await refuse('issue_batch', { issues: [17, 18], parentIssueNumber: 20 });
|
|
426
|
+
for (const issueNumber of [17, 18]) {
|
|
427
|
+
const moved = await call('issue_update', { issueNumber, parentIssueNumber: 20 });
|
|
428
|
+
assert.equal(moved.parentIssueNumber, 20);
|
|
429
|
+
assert.equal(fixture.issues.get(issueNumber).parent, 20);
|
|
430
|
+
}
|
|
431
|
+
assert.deepEqual((await call('issue_list', { parentIssueNumber: 10, state: 'all' })).issues, []);
|
|
432
|
+
assert.deepEqual((await call('issue_list', { parentIssueNumber: 20, state: 'all' })).issues.map((issue) => issue.number), [17, 18, 31]);
|
|
433
|
+
for (const number of [10, 20])
|
|
434
|
+
assert.equal((await call('issue_info', { issueNumber: number })).points, undefined);
|
|
435
|
+
const journal = await call('issue_comment', {
|
|
436
|
+
issueNumber: 31,
|
|
437
|
+
kind: 'progress',
|
|
438
|
+
summary: 'Tracking replay is verified.',
|
|
439
|
+
status: 'In progress',
|
|
440
|
+
done: ['Reparented two issues individually.'],
|
|
441
|
+
decisionNeeded: 'None',
|
|
442
|
+
keyNumbers: [],
|
|
443
|
+
evidence: [created.created.url],
|
|
444
|
+
nextStep: 'Review',
|
|
445
|
+
nextDate: '2026-10-09',
|
|
446
|
+
});
|
|
447
|
+
const storedJournal = fixture.comments.find((comment) => comment.id === journal.commentId);
|
|
448
|
+
assert.equal(storedJournal.body, journal.body);
|
|
449
|
+
assert.equal(storedJournal.html_url, journal.url);
|
|
450
|
+
assert.equal(storedJournal.user.login, 'operator');
|
|
451
|
+
assert.match(journal.body, /Tracking replay is verified/u);
|
|
452
|
+
await refuse('issue_defer', { issueNumber: 17, trigger: 'After review' });
|
|
453
|
+
await refuse('issue_update', { issueNumber: 17, defer: { trigger: 'After review' } });
|
|
454
|
+
const closed = await call('issue_update', { issueNumber: 17, state: 'closed', closeReason: 'not_planned', supersededBy: 31 });
|
|
455
|
+
assert.equal(closed.closure.state, 'closed');
|
|
456
|
+
assert.equal(closed.closure.closeReason, 'not_planned');
|
|
457
|
+
assert.equal(closed.closure.supersededBy, 31);
|
|
458
|
+
assert.equal(closed.projectStatus, 'Done');
|
|
459
|
+
assert.equal(fixture.issues.get(17).reason, 'NOT_PLANNED');
|
|
460
|
+
assert.equal(fixture.issues.get(17).status, 'Shipped');
|
|
461
|
+
assert.equal(fixture.comments.find((comment) => comment.id === closed.closure.comment.commentId).body, 'Requested closure reason: not_planned.\nSuperseded by example/widget#31.');
|
|
462
|
+
const final = await call('issue_info', { issueNumber: 17 });
|
|
463
|
+
assert.equal(final.state, 'closed');
|
|
464
|
+
assert.equal(final.parentIssueNumber, 20);
|
|
465
|
+
assert.equal(final.projectStatus, 'Done');
|
|
466
|
+
const finalSearch = await call('issue_search', {
|
|
467
|
+
query: 'Replacement',
|
|
468
|
+
state: 'all',
|
|
469
|
+
});
|
|
470
|
+
assert.deepEqual(finalSearch.issues.map(({ number, state }) => ({ number, state })), [
|
|
471
|
+
{ number: 20, state: 'open' },
|
|
472
|
+
{ number: 17, state: 'closed' },
|
|
473
|
+
{ number: 31, state: 'open' },
|
|
474
|
+
]);
|
|
475
|
+
assert.ok(fixture.writes() > 0);
|
|
476
|
+
assert.equal(existsSync(join(root, '.git')), false);
|
|
477
|
+
}
|
|
478
|
+
finally {
|
|
479
|
+
await client.close();
|
|
480
|
+
await server.close();
|
|
481
|
+
vi.restoreAllMocks();
|
|
482
|
+
vi.unstubAllEnvs();
|
|
483
|
+
rmSync(root, { recursive: true, force: true });
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
//# sourceMappingURL=currentTrackingScenario.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currentTrackingScenario.test.js","sourceRoot":"","sources":["../src/currentTrackingScenario.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,WAAW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AAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -30,6 +30,53 @@ const userSettings = {
|
|
|
30
30
|
statuses: { blocked: 'Waiting', done: 'Shipped', inProgress: 'Active', todo: 'Queued' },
|
|
31
31
|
};
|
|
32
32
|
describe('directory-independent user configuration', () => {
|
|
33
|
+
it('publishes repository guidance during initialization before a tool is called outside Git', async () => {
|
|
34
|
+
const root = mkdtempSync(join(tmpdir(), 'delivery-discovery-guidance-'));
|
|
35
|
+
const previous = process.env.AI_DELIVERY_CONFIG;
|
|
36
|
+
process.env.AI_DELIVERY_CONFIG = join(root, 'user.json');
|
|
37
|
+
writeFileSync(process.env.AI_DELIVERY_CONFIG, JSON.stringify(userSettings));
|
|
38
|
+
const server = createAiDeliveryMcpServer({ repoRoot: root });
|
|
39
|
+
const client = new Client({ name: 'discovery-guidance-fixture', version: '1' });
|
|
40
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
41
|
+
try {
|
|
42
|
+
await server.connect(serverTransport);
|
|
43
|
+
await client.connect(clientTransport);
|
|
44
|
+
const instructions = client.getInstructions();
|
|
45
|
+
assert.equal(typeof instructions, 'string', 'initialize must provide guidance before deferred tool discovery');
|
|
46
|
+
assert.match(instructions ?? '', /\brepo\b/u);
|
|
47
|
+
assert.match(instructions ?? '', /\bissue_info\b/u);
|
|
48
|
+
// This observes real protocol metadata, not whether an agent follows it.
|
|
49
|
+
const listed = await client.listTools();
|
|
50
|
+
for (const name of ['issue_info', 'issue_ready_check']) {
|
|
51
|
+
const tool = listed.tools.find((candidate) => candidate.name === name);
|
|
52
|
+
assert.ok(tool);
|
|
53
|
+
const properties = tool.inputSchema.properties;
|
|
54
|
+
assert.equal(typeof properties.repo?.description, 'string', `${name} must describe its repository input`);
|
|
55
|
+
assert.match(properties.repo?.description ?? '', /owner\/name/u);
|
|
56
|
+
}
|
|
57
|
+
for (const arguments_ of [
|
|
58
|
+
{ issueNumber: 17, repo: 'example/widget', cached: true },
|
|
59
|
+
{ issueNumber: 17, repository: 'example/widget' },
|
|
60
|
+
{ issueNumber: 17, repo: 'invalid' },
|
|
61
|
+
]) {
|
|
62
|
+
const rejected = await client.callTool({ name: 'issue_info', arguments: arguments_ });
|
|
63
|
+
assert.equal(rejected.isError, true);
|
|
64
|
+
assert.match(JSON.stringify(rejected), /Invalid arguments/u);
|
|
65
|
+
assert.doesNotMatch(JSON.stringify(rejected), /SYNTHETIC_TOKEN|Git remotes/u);
|
|
66
|
+
}
|
|
67
|
+
assert.equal(existsSync(join(root, '.git')), false);
|
|
68
|
+
assert.equal(existsSync(join(root, '.issue-cli')), false);
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
await client.close();
|
|
72
|
+
await server.close();
|
|
73
|
+
if (previous === undefined)
|
|
74
|
+
delete process.env.AI_DELIVERY_CONFIG;
|
|
75
|
+
else
|
|
76
|
+
process.env.AI_DELIVERY_CONFIG = previous;
|
|
77
|
+
rmSync(root, { recursive: true, force: true });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
33
80
|
it('resolves an explicit repository in a non-Git directory without repository policy', async () => {
|
|
34
81
|
const root = mkdtempSync(join(tmpdir(), 'delivery-directory-'));
|
|
35
82
|
const previous = process.env.AI_DELIVERY_CONFIG;
|