@codyswann/lisa 5.1.7 → 5.2.0
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/all/copy-overwrite/scripts/lib/github-attestation-provider.mjs +15 -0
- package/all/copy-overwrite/scripts/lib/npm-update-allocate.mjs +32 -39
- package/all/copy-overwrite/scripts/lib/npm-update-authorization.mjs +12 -2
- package/all/copy-overwrite/scripts/lib/npm-update-checkpoint.mjs +10 -30
- package/all/copy-overwrite/scripts/lib/npm-update-execution-adapter.mjs +4 -1
- package/all/copy-overwrite/scripts/lib/npm-update-helper-graph.mjs +1 -1
- package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +4 -0
- package/all/copy-overwrite/scripts/lib/npm-update-hosted-hook.mjs +2 -1
- package/all/copy-overwrite/scripts/lib/npm-update-invariants.mjs +15 -1
- package/all/copy-overwrite/scripts/lib/npm-update-leaf-contract.mjs +41 -9
- package/all/copy-overwrite/scripts/lib/npm-update-leaf.mjs +23 -35
- package/all/copy-overwrite/scripts/lib/npm-update-policy.mjs +41 -6
- package/all/copy-overwrite/scripts/lib/npm-update-recovery.mjs +16 -3
- package/all/copy-overwrite/scripts/lib/npm-update-tracker-jira.mjs +300 -0
- package/all/copy-overwrite/scripts/lib/npm-update-tracker-linear.mjs +304 -0
- package/all/copy-overwrite/scripts/lib/npm-update-tracker-wire.mjs +298 -0
- package/all/copy-overwrite/scripts/lib/npm-update-tracker.mjs +179 -0
- package/all/copy-overwrite/scripts/lisa-npm-updater.mjs +16 -2
- package/all/copy-overwrite/scripts/lisa-work-item.mjs +1 -1
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +62 -14
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +96 -0
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +55 -18
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/scripts/two-channel-couplings.json +1 -1
- package/typescript/copy-overwrite/.prettierignore +4 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// This file is managed by Lisa and IS replaced on each `lisa` run.
|
|
2
|
+
// Do not edit directly — durable changes belong upstream in Lisa.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file npm-update-tracker-linear.mjs
|
|
6
|
+
* @description Linear GraphQL tracker adapter for the npm updater (CodySwannGT/lisa#4859).
|
|
7
|
+
* Issues are normalized into the GitHub-issue record the claim, hold, quality and
|
|
8
|
+
* checkpoint checks already read; managed text is stored inside one exact fence.
|
|
9
|
+
* @module npm-updater
|
|
10
|
+
*/
|
|
11
|
+
import { required } from "./npm-update-invariants.mjs";
|
|
12
|
+
import { sha256 } from "./github-attestation-verifier.mjs";
|
|
13
|
+
import { trackerContract } from "../lisa-work-item.mjs";
|
|
14
|
+
import {
|
|
15
|
+
trackerCredentials,
|
|
16
|
+
jsonCall,
|
|
17
|
+
fence,
|
|
18
|
+
unfence,
|
|
19
|
+
lifecycleName,
|
|
20
|
+
vocabularyRefusal,
|
|
21
|
+
vendorLabels,
|
|
22
|
+
linearClosed as closed,
|
|
23
|
+
linearSearchResult as searchResult,
|
|
24
|
+
completeLinearConnections as completeConnections,
|
|
25
|
+
} from "./npm-update-tracker-wire.mjs";
|
|
26
|
+
|
|
27
|
+
const VIEWER = "query LisaNpmViewer { viewer { id } }";
|
|
28
|
+
const TEAM =
|
|
29
|
+
"query LisaNpmTeam($key: String!) { teams(filter: { key: { eq: $key } }) { nodes { id key states { nodes { id name type } } } } }";
|
|
30
|
+
const MEMBER =
|
|
31
|
+
"query LisaNpmMember($id: String!, $key: String!) { user(id: $id) { id active teams(filter: { key: { eq: $key } }) { nodes { id } } } }";
|
|
32
|
+
const ISSUES =
|
|
33
|
+
"query LisaNpmIssues($filter: IssueFilter!) { issues(filter: $filter, first: 100, includeArchived: true) { nodes { number archivedAt state { type } } pageInfo { hasNextPage } } }";
|
|
34
|
+
const ISSUE =
|
|
35
|
+
"query LisaNpmIssue($id: String!) { issue(id: $id) { id identifier number title description priority archivedAt state { name type } assignee { id } labels(first: 100) { nodes { name } pageInfo { hasNextPage } } children(first: 100) { nodes { id } pageInfo { hasNextPage } } inverseRelations(first: 100) { nodes { type issue { state { type } archivedAt } } pageInfo { hasNextPage } } } }";
|
|
36
|
+
const COMMENTS =
|
|
37
|
+
"query LisaNpmComments($id: String!, $after: String) { issue(id: $id) { comments(first: 100, after: $after) { nodes { id body user { id } botActor { id } } pageInfo { hasNextPage endCursor } } } }";
|
|
38
|
+
const COMMENT =
|
|
39
|
+
"query LisaNpmComment($id: String!) { comment(id: $id) { id body user { id } issue { identifier } } }";
|
|
40
|
+
const CREATE =
|
|
41
|
+
"mutation LisaNpmIssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { number identifier } } }";
|
|
42
|
+
const UPDATE =
|
|
43
|
+
"mutation LisaNpmIssueUpdate($id: String!, $input: IssueUpdateInput!) { issueUpdate(id: $id, input: $input) { success } }";
|
|
44
|
+
const COMMENT_CREATE =
|
|
45
|
+
"mutation LisaNpmCommentCreate($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { id body issue { identifier } } } }";
|
|
46
|
+
/** Linear's priority scale: 3 is Medium. */
|
|
47
|
+
const MEDIUM = 3;
|
|
48
|
+
|
|
49
|
+
/** The API key's own user is the only identity a Linear write can prove. */
|
|
50
|
+
function commentRecord(node) {
|
|
51
|
+
return {
|
|
52
|
+
id: node.id,
|
|
53
|
+
body: unfence(node.body),
|
|
54
|
+
// The classifier reads the Markdown as written: a fence a human typed stays a fence.
|
|
55
|
+
prose: String(node.body ?? ""),
|
|
56
|
+
user: node.user
|
|
57
|
+
? { id: node.user.id, type: "User" }
|
|
58
|
+
: { id: node.botActor?.id, type: "Bot" },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class LinearTracker {
|
|
63
|
+
constructor(config, env, transport = globalThis.fetch) {
|
|
64
|
+
const credentials = trackerCredentials(config, env);
|
|
65
|
+
this.provider = "linear";
|
|
66
|
+
this.key = config.linear.teamKey.trim().toUpperCase();
|
|
67
|
+
this.lifecycle = trackerContract(config).lifecycle;
|
|
68
|
+
this.url = credentials.baseUrl;
|
|
69
|
+
this.authorization = credentials.authorization;
|
|
70
|
+
this.transport = transport;
|
|
71
|
+
this.ids = new Map();
|
|
72
|
+
}
|
|
73
|
+
async graphql(query, variables, purpose) {
|
|
74
|
+
const reply = await jsonCall(
|
|
75
|
+
this.transport,
|
|
76
|
+
this.url,
|
|
77
|
+
{
|
|
78
|
+
method: "POST",
|
|
79
|
+
authorization: this.authorization,
|
|
80
|
+
body: { query, variables },
|
|
81
|
+
},
|
|
82
|
+
purpose
|
|
83
|
+
);
|
|
84
|
+
required(
|
|
85
|
+
reply && !reply.errors && reply.data,
|
|
86
|
+
"tracker provider refused request"
|
|
87
|
+
);
|
|
88
|
+
return reply.data;
|
|
89
|
+
}
|
|
90
|
+
/** One operation's single top-level field. */
|
|
91
|
+
async field(query, variables, name) {
|
|
92
|
+
return (await this.graphql(query, variables, "unclassified"))[name];
|
|
93
|
+
}
|
|
94
|
+
ref(number) {
|
|
95
|
+
return `${this.key}-${number}`;
|
|
96
|
+
}
|
|
97
|
+
async viewer() {
|
|
98
|
+
this.viewerId ??= (
|
|
99
|
+
await this.graphql(VIEWER, {}, "unclassified")
|
|
100
|
+
).viewer?.id;
|
|
101
|
+
required(typeof this.viewerId === "string", "tracker identity unavailable");
|
|
102
|
+
return this.viewerId;
|
|
103
|
+
}
|
|
104
|
+
async team() {
|
|
105
|
+
if (this.teamNode) return this.teamNode;
|
|
106
|
+
const nodes = (await this.graphql(TEAM, { key: this.key }, "repository"))
|
|
107
|
+
.teams?.nodes;
|
|
108
|
+
required(
|
|
109
|
+
Array.isArray(nodes) && nodes.length === 1 && nodes[0].key === this.key,
|
|
110
|
+
"configured Linear team differs"
|
|
111
|
+
);
|
|
112
|
+
this.teamNode = nodes[0];
|
|
113
|
+
return this.teamNode;
|
|
114
|
+
}
|
|
115
|
+
async stateId(name) {
|
|
116
|
+
const matches = (await this.team()).states.nodes.filter(
|
|
117
|
+
state => state.name.toLowerCase() === name.toLowerCase()
|
|
118
|
+
);
|
|
119
|
+
if (matches.length !== 1) throw vocabularyRefusal("Linear");
|
|
120
|
+
return matches[0].id;
|
|
121
|
+
}
|
|
122
|
+
/** Mutations address the issue by its stable id, learned from an exact identifier read. */
|
|
123
|
+
async issueId(number) {
|
|
124
|
+
if (!this.ids.has(number)) await this.issue(number);
|
|
125
|
+
return this.ids.get(number);
|
|
126
|
+
}
|
|
127
|
+
async issue(number) {
|
|
128
|
+
required(
|
|
129
|
+
Number.isSafeInteger(number) && number > 0,
|
|
130
|
+
"invalid live issue number"
|
|
131
|
+
);
|
|
132
|
+
const node = (await this.graphql(ISSUE, { id: this.ref(number) }, "issue"))
|
|
133
|
+
.issue;
|
|
134
|
+
required(
|
|
135
|
+
node?.identifier === this.ref(number) && node.number === number,
|
|
136
|
+
"live issue scope differs"
|
|
137
|
+
);
|
|
138
|
+
completeConnections(node);
|
|
139
|
+
this.ids.set(number, node.id);
|
|
140
|
+
return {
|
|
141
|
+
number,
|
|
142
|
+
title: node.title,
|
|
143
|
+
body: unfence(node.description),
|
|
144
|
+
state: closed(node) ? "closed" : "open",
|
|
145
|
+
labels: [
|
|
146
|
+
lifecycleName(this.lifecycle, node.state?.name),
|
|
147
|
+
"type:Task",
|
|
148
|
+
...(node.priority === MEDIUM ? ["priority:medium"] : []),
|
|
149
|
+
...vendorLabels(
|
|
150
|
+
this.lifecycle,
|
|
151
|
+
(node.labels?.nodes ?? []).map(label => label.name)
|
|
152
|
+
),
|
|
153
|
+
].map(name => ({ name })),
|
|
154
|
+
assignees: node.assignee
|
|
155
|
+
? [{ login: node.assignee.id, type: "User" }]
|
|
156
|
+
: [],
|
|
157
|
+
comments: await this.comments(number),
|
|
158
|
+
children: node.children?.nodes ?? [],
|
|
159
|
+
blockers: (node.inverseRelations?.nodes ?? [])
|
|
160
|
+
.filter(relation => relation.type === "blocks")
|
|
161
|
+
.map(relation => ({
|
|
162
|
+
state: closed(relation.issue) ? "closed" : "open",
|
|
163
|
+
})),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async comments(number) {
|
|
167
|
+
const entries = [];
|
|
168
|
+
let after = null;
|
|
169
|
+
for (let page = 1; page <= 20; page++) {
|
|
170
|
+
const connection = (
|
|
171
|
+
await this.graphql(
|
|
172
|
+
COMMENTS,
|
|
173
|
+
{ id: this.ref(number), after },
|
|
174
|
+
"issue-comments"
|
|
175
|
+
)
|
|
176
|
+
).issue?.comments;
|
|
177
|
+
required(
|
|
178
|
+
Array.isArray(connection?.nodes),
|
|
179
|
+
"provider page is not an array"
|
|
180
|
+
);
|
|
181
|
+
entries.push(...connection.nodes.map(commentRecord));
|
|
182
|
+
if (!connection.pageInfo?.hasNextPage) return entries;
|
|
183
|
+
after = connection.pageInfo.endCursor;
|
|
184
|
+
}
|
|
185
|
+
throw new Error("npm updater: provider pagination exceeded bound");
|
|
186
|
+
}
|
|
187
|
+
async searchPrior(proposal) {
|
|
188
|
+
const filter = {
|
|
189
|
+
team: { key: { eq: this.key } },
|
|
190
|
+
description: { contains: `Selection key: ${proposal.selectionKey}` },
|
|
191
|
+
};
|
|
192
|
+
return searchResult(
|
|
193
|
+
(await this.graphql(ISSUES, { filter }, "issue-search")).issues
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
async relationships() {
|
|
197
|
+
const filter = {
|
|
198
|
+
team: { key: { eq: this.key } },
|
|
199
|
+
or: [
|
|
200
|
+
{ title: { containsIgnoreCase: "npm" } },
|
|
201
|
+
{ description: { containsIgnoreCase: "npm" } },
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
...searchResult(
|
|
206
|
+
(await this.graphql(ISSUES, { filter }, "issue-search")).issues
|
|
207
|
+
),
|
|
208
|
+
query: `Linear team ${this.key}: title or description contains "npm", all states`,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
async vocabulary() {
|
|
212
|
+
const states = (await this.team()).states.nodes.map(state =>
|
|
213
|
+
lifecycleName(this.lifecycle, state.name)
|
|
214
|
+
);
|
|
215
|
+
return ["type:Task", "priority:medium", ...states];
|
|
216
|
+
}
|
|
217
|
+
async ensureRole() {
|
|
218
|
+
throw vocabularyRefusal("Linear");
|
|
219
|
+
}
|
|
220
|
+
async createLeaf(draft) {
|
|
221
|
+
const input = {
|
|
222
|
+
teamId: (await this.team()).id,
|
|
223
|
+
title: draft.title,
|
|
224
|
+
description: fence(draft.body),
|
|
225
|
+
stateId: await this.stateId(this.lifecycle.ready),
|
|
226
|
+
priority: MEDIUM,
|
|
227
|
+
assigneeId: draft.assignees[0],
|
|
228
|
+
};
|
|
229
|
+
const created = (await this.graphql(CREATE, { input }, "issue"))
|
|
230
|
+
.issueCreate;
|
|
231
|
+
const number = created?.issue?.number;
|
|
232
|
+
required(
|
|
233
|
+
created?.success === true &&
|
|
234
|
+
Number.isSafeInteger(number) &&
|
|
235
|
+
created.issue.identifier === this.ref(number),
|
|
236
|
+
"tracker create readback differs"
|
|
237
|
+
);
|
|
238
|
+
return { number };
|
|
239
|
+
}
|
|
240
|
+
async assignable(maintainer) {
|
|
241
|
+
const user = await this.field(
|
|
242
|
+
MEMBER,
|
|
243
|
+
{ id: maintainer, key: this.key },
|
|
244
|
+
"user"
|
|
245
|
+
);
|
|
246
|
+
required(
|
|
247
|
+
user?.id === maintainer &&
|
|
248
|
+
user.active === true &&
|
|
249
|
+
user.teams?.nodes?.length === 1,
|
|
250
|
+
"trusted maintainer is not currently assignable"
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
async update(number, input) {
|
|
254
|
+
const id = await this.issueId(number);
|
|
255
|
+
const reply = await this.graphql(UPDATE, { id, input }, "issue");
|
|
256
|
+
required(reply.issueUpdate?.success === true, "tracker update refused");
|
|
257
|
+
}
|
|
258
|
+
async assign(number, maintainer) {
|
|
259
|
+
await this.update(number, { assigneeId: maintainer });
|
|
260
|
+
}
|
|
261
|
+
async transition(issue, roles) {
|
|
262
|
+
await this.update(issue.number, {
|
|
263
|
+
stateId: await this.stateId(roles.claimed),
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
async comment(number, text) {
|
|
267
|
+
const input = { issueId: await this.issueId(number), body: fence(text) };
|
|
268
|
+
const created = (
|
|
269
|
+
await this.graphql(COMMENT_CREATE, { input }, "issue-comments")
|
|
270
|
+
).commentCreate;
|
|
271
|
+
required(
|
|
272
|
+
created?.success === true &&
|
|
273
|
+
created.comment?.issue?.identifier === this.ref(number) &&
|
|
274
|
+
created.comment.body === fence(text),
|
|
275
|
+
"checkpoint write readback differs"
|
|
276
|
+
);
|
|
277
|
+
return created.comment;
|
|
278
|
+
}
|
|
279
|
+
async durableComment(number, text) {
|
|
280
|
+
const created = await this.comment(number, text);
|
|
281
|
+
const read = await this.field(COMMENT, { id: created.id }, "comment");
|
|
282
|
+
required(
|
|
283
|
+
read?.id === created.id &&
|
|
284
|
+
read.issue?.identifier === this.ref(number) &&
|
|
285
|
+
read.body === fence(text),
|
|
286
|
+
"checkpoint immediate readback differs"
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
async isManagedActor(user) {
|
|
290
|
+
return user?.type === "User" && user.id === (await this.viewer());
|
|
291
|
+
}
|
|
292
|
+
async proveClaim(descriptor) {
|
|
293
|
+
const id = descriptor.claimCommentId;
|
|
294
|
+
const comment = await this.field(COMMENT, { id }, "comment");
|
|
295
|
+
required(
|
|
296
|
+
comment?.id === descriptor.claimCommentId &&
|
|
297
|
+
comment.issue?.identifier === descriptor.workItem &&
|
|
298
|
+
comment.user?.id === (await this.viewer()) &&
|
|
299
|
+
typeof comment.body === "string" &&
|
|
300
|
+
sha256(unfence(comment.body)) === descriptor.claimSha256,
|
|
301
|
+
"current tracker claim differs"
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// This file is managed by Lisa and IS replaced on each `lisa` run.
|
|
2
|
+
// Do not edit directly — durable changes belong upstream in Lisa.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file npm-update-tracker-wire.mjs
|
|
6
|
+
* @description Credentials, bounded JSON transport and the lossless managed-text codecs
|
|
7
|
+
* shared by the npm updater's Jira and Linear adapters (CodySwannGT/lisa#4859).
|
|
8
|
+
* @module npm-updater
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
required,
|
|
12
|
+
operatorRefusal,
|
|
13
|
+
withProviderOperation,
|
|
14
|
+
} from "./npm-update-invariants.mjs";
|
|
15
|
+
import { jiraServerOrigin } from "../lisa-work-item.mjs";
|
|
16
|
+
|
|
17
|
+
const RESPONSE_BOUND = 3_145_728;
|
|
18
|
+
const NOTHING_CREATED =
|
|
19
|
+
"Add it as a repository secret and pass it to the npm updater workflow. Nothing was created.";
|
|
20
|
+
|
|
21
|
+
/** A fixed operator sentence naming exactly one missing variable or key; never its value. */
|
|
22
|
+
function missing(name, what) {
|
|
23
|
+
return operatorRefusal(
|
|
24
|
+
"tracker credential is absent",
|
|
25
|
+
`${name} is not set, so the npm updater cannot ${what}. ${NOTHING_CREATED}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Jira login, token and base URL. The site comes only from committed config
|
|
31
|
+
* (never JIRA_SERVER), because that origin receives the token.
|
|
32
|
+
*/
|
|
33
|
+
function jiraCredentials(config, env) {
|
|
34
|
+
const token = env.JIRA_API_TOKEN || env.ATLASSIAN_API_TOKEN;
|
|
35
|
+
if (!token) throw missing("JIRA_API_TOKEN", "create Jira work items");
|
|
36
|
+
const login = env.JIRA_LOGIN || String(config.atlassian?.email ?? "").trim();
|
|
37
|
+
if (!login) throw missing("JIRA_LOGIN", "create Jira work items");
|
|
38
|
+
const cloudId = String(config.atlassian?.cloudId ?? "").trim();
|
|
39
|
+
const server = String(config.atlassian?.site ?? "");
|
|
40
|
+
if (!cloudId && !server)
|
|
41
|
+
throw operatorRefusal(
|
|
42
|
+
"tracker site is absent",
|
|
43
|
+
"Neither atlassian.cloudId nor atlassian.site is configured, so the npm updater cannot reach Jira. Nothing was created."
|
|
44
|
+
);
|
|
45
|
+
const baseUrl = cloudId
|
|
46
|
+
? `https://api.atlassian.com/ex/jira/${encodeURIComponent(cloudId)}`
|
|
47
|
+
: jiraServerOrigin(server);
|
|
48
|
+
const basic = Buffer.from(`${login}:${token}`).toString("base64");
|
|
49
|
+
return { baseUrl, authorization: `Basic ${basic}` };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Linear accepts LINEAR_API_KEY or the workspace-scoped LINEAR_API_KEY_<workspace>. */
|
|
53
|
+
function linearCredentials(config, env) {
|
|
54
|
+
const suffix = String(config.linear?.workspace ?? "")
|
|
55
|
+
.toLowerCase()
|
|
56
|
+
.replace(/-/g, "_");
|
|
57
|
+
const key = env.LINEAR_API_KEY || (suffix && env[`LINEAR_API_KEY_${suffix}`]);
|
|
58
|
+
if (!key) throw missing("LINEAR_API_KEY", "create Linear work items");
|
|
59
|
+
return { baseUrl: "https://api.linear.app/graphql", authorization: key };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Resolved before any provider call, so a gap can never follow a partial write. */
|
|
63
|
+
export function trackerCredentials(config, env) {
|
|
64
|
+
required(
|
|
65
|
+
config.tracker === "jira" || config.tracker === "linear",
|
|
66
|
+
"configured tracker has no API adapter"
|
|
67
|
+
);
|
|
68
|
+
return config.tracker === "jira"
|
|
69
|
+
? jiraCredentials(config, env)
|
|
70
|
+
: linearCredentials(config, env);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Bytes past the bound are never buffered: a declared length refuses unread, a stream stops mid-read. */
|
|
74
|
+
async function boundedText(response) {
|
|
75
|
+
const declared = Number(response.headers.get("content-length") ?? 0);
|
|
76
|
+
if (declared > RESPONSE_BOUND) {
|
|
77
|
+
await response.body?.cancel();
|
|
78
|
+
required(false, "provider response exceeds bound");
|
|
79
|
+
}
|
|
80
|
+
const reader = response.body?.getReader();
|
|
81
|
+
const chunks = [];
|
|
82
|
+
let size = 0;
|
|
83
|
+
for (let next = await reader?.read(); next && !next.done; ) {
|
|
84
|
+
size += next.value.byteLength;
|
|
85
|
+
if (size > RESPONSE_BOUND) {
|
|
86
|
+
await reader.cancel();
|
|
87
|
+
required(false, "provider response exceeds bound");
|
|
88
|
+
}
|
|
89
|
+
chunks.push(next.value);
|
|
90
|
+
next = await reader.read();
|
|
91
|
+
}
|
|
92
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(
|
|
93
|
+
Buffer.concat(chunks)
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** One bounded JSON request; a refused status is opaque, never echoed. */
|
|
98
|
+
export async function jsonCall(transport, url, request, purpose) {
|
|
99
|
+
const method = request.method ?? "GET";
|
|
100
|
+
return withProviderOperation(purpose, method, async () => {
|
|
101
|
+
const response = await transport(url, {
|
|
102
|
+
method,
|
|
103
|
+
headers: {
|
|
104
|
+
Accept: "application/json",
|
|
105
|
+
Authorization: request.authorization,
|
|
106
|
+
...(request.body === undefined
|
|
107
|
+
? {}
|
|
108
|
+
: { "Content-Type": "application/json" }),
|
|
109
|
+
},
|
|
110
|
+
body:
|
|
111
|
+
request.body === undefined ? undefined : JSON.stringify(request.body),
|
|
112
|
+
redirect: "error",
|
|
113
|
+
signal: AbortSignal.timeout(30_000),
|
|
114
|
+
});
|
|
115
|
+
const text = await boundedText(response);
|
|
116
|
+
required(response.ok, "tracker provider refused request");
|
|
117
|
+
return text ? JSON.parse(text) : null;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Jira stores rich text as ADF; a single code block keeps every managed byte, markers included. */
|
|
122
|
+
export function adfCodeBlock(text) {
|
|
123
|
+
return {
|
|
124
|
+
type: "doc",
|
|
125
|
+
version: 1,
|
|
126
|
+
content: [
|
|
127
|
+
{
|
|
128
|
+
type: "codeBlock",
|
|
129
|
+
content: text ? [{ type: "text", text }] : [],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Text nodes of any ADF subtree, in document order. */
|
|
136
|
+
function textNodes(node) {
|
|
137
|
+
if (!node || typeof node !== "object") return [];
|
|
138
|
+
if (node.type === "text") return [String(node.text ?? "")];
|
|
139
|
+
return (Array.isArray(node.content) ? node.content : []).flatMap(textNodes);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The managed form (exactly one code block) reads back losslessly. Anything a
|
|
144
|
+
* human wrote reads as its paragraphs joined by newlines: enough to classify a
|
|
145
|
+
* hold, and never equal to a managed body because it was not one code block.
|
|
146
|
+
*/
|
|
147
|
+
export function adfText(document) {
|
|
148
|
+
const blocks = Array.isArray(document?.content) ? document.content : [];
|
|
149
|
+
if (blocks.length === 1 && blocks[0]?.type === "codeBlock")
|
|
150
|
+
return textNodes(blocks[0]).join("");
|
|
151
|
+
return blocks.map(block => textNodes(block).join("")).join("\n");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Backticks inside code are made inert so a projected code boundary cannot be closed early. */
|
|
155
|
+
function inert(text) {
|
|
156
|
+
return String(text ?? "").replace(/`/g, "'");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** One ADF node as Markdown-shaped prose: code stays inside a code boundary. */
|
|
160
|
+
function proseOf(node) {
|
|
161
|
+
if (!node || typeof node !== "object") return "";
|
|
162
|
+
if (node.type === "codeBlock")
|
|
163
|
+
return `\n\`\`\`\n${inert(textNodes(node).join(""))}\n\`\`\`\n`;
|
|
164
|
+
if (node.type === "text")
|
|
165
|
+
return (Array.isArray(node.marks) ? node.marks : []).some(
|
|
166
|
+
mark => mark?.type === "code"
|
|
167
|
+
)
|
|
168
|
+
? `\`${inert(node.text).replace(/\n/g, " ")}\``
|
|
169
|
+
: String(node.text ?? "");
|
|
170
|
+
if (node.type === "hardBreak") return "\n";
|
|
171
|
+
const inline = node.type === "paragraph" || node.type === "heading";
|
|
172
|
+
return (Array.isArray(node.content) ? node.content : [])
|
|
173
|
+
.map(proseOf)
|
|
174
|
+
.join(inline ? "" : "\n");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* What the human-hold classifier reads for a Jira comment. Unlike adfText
|
|
179
|
+
* (the lossless managed-record form), a code block or inline code keeps a
|
|
180
|
+
* Markdown code boundary, so a marker written inside an example is
|
|
181
|
+
* documentation, never a release — the same rule GitHub and Linear text get.
|
|
182
|
+
*/
|
|
183
|
+
export function adfProse(document) {
|
|
184
|
+
return proseOf(document);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const OPEN = "````lisa\n";
|
|
188
|
+
const CLOSE = "\n````";
|
|
189
|
+
|
|
190
|
+
/** Linear stores Markdown; a four-backtick fence nests the leaf's own ``` blocks unchanged. */
|
|
191
|
+
export function fence(text) {
|
|
192
|
+
return `${OPEN}${text}${CLOSE}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Exact managed fence → its bytes; any other body (a human's) is returned as written. */
|
|
196
|
+
export function unfence(body) {
|
|
197
|
+
const value = String(body ?? "");
|
|
198
|
+
return value.startsWith(OPEN) &&
|
|
199
|
+
value.endsWith(CLOSE) &&
|
|
200
|
+
value.length >= OPEN.length + CLOSE.length
|
|
201
|
+
? value.slice(OPEN.length, -CLOSE.length)
|
|
202
|
+
: value;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* A vendor status read back in any letter case is reported in the configured
|
|
207
|
+
* spelling, the way the build-intake skills match it; other names pass unchanged.
|
|
208
|
+
*/
|
|
209
|
+
export function lifecycleName(lifecycle, name) {
|
|
210
|
+
const value = String(name ?? "");
|
|
211
|
+
return (
|
|
212
|
+
lifecycle.roles.find(role => role.toLowerCase() === value.toLowerCase()) ??
|
|
213
|
+
value
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Statuses, issue types and priorities are workflow configuration; the updater never provisions them. */
|
|
218
|
+
export function vocabularyRefusal(vendor) {
|
|
219
|
+
return operatorRefusal(
|
|
220
|
+
"tracker vocabulary lacks a lifecycle role",
|
|
221
|
+
`The ${vendor} project is missing a status, issue type or priority the npm updater needs (Task, Medium priority, and the configured ready and in-progress statuses). Add it in ${vendor} or change the lifecycle configuration. Nothing was created.`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Jira's documented 32,767-character rich-text field limit, refused before that write. */
|
|
226
|
+
export function withinJiraLimit(text) {
|
|
227
|
+
if (typeof text !== "string" || text.length > 32_767)
|
|
228
|
+
throw operatorRefusal(
|
|
229
|
+
"managed text exceeds the Jira field limit",
|
|
230
|
+
"A description or comment the npm updater must write is longer than Jira's 32,767-character limit, so it stopped before writing it."
|
|
231
|
+
);
|
|
232
|
+
return text;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** A ticket that exists but never reached Ready is named, so the operator can finish or remove it. */
|
|
236
|
+
export function strandedRefusal(ref, ready) {
|
|
237
|
+
return operatorRefusal(
|
|
238
|
+
"created work item is not build-ready",
|
|
239
|
+
`${ref} was created but could not be moved to ${ready}. Move it to ${ready} by hand or fix the workflow transition, then rerun.`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Typed labels are free text anyone can add, so a label spelled like a
|
|
245
|
+
* lifecycle status, a `type:` or a `priority:` is dropped before it can stand
|
|
246
|
+
* in for the value derived from the tracker's own fields. Other labels, such
|
|
247
|
+
* as the human-hold marker, pass through.
|
|
248
|
+
*/
|
|
249
|
+
export function vendorLabels(lifecycle, names) {
|
|
250
|
+
const reserved = new Set(lifecycle.roles.map(role => role.toLowerCase()));
|
|
251
|
+
return (names ?? []).filter(name => {
|
|
252
|
+
const value = String(name).toLowerCase();
|
|
253
|
+
return (
|
|
254
|
+
!reserved.has(value) &&
|
|
255
|
+
!value.startsWith("type:") &&
|
|
256
|
+
!value.startsWith("priority:")
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Linear connection helpers, shared here to keep the Linear adapter within its size budget.
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Labels, sub-issues and relations decide holds and blockers, so a partial
|
|
265
|
+
* page is never read as the whole inventory: one more page refuses.
|
|
266
|
+
*/
|
|
267
|
+
export function completeLinearConnections(node) {
|
|
268
|
+
const partial = ["labels", "children", "inverseRelations"].some(
|
|
269
|
+
name => node[name]?.pageInfo?.hasNextPage !== false
|
|
270
|
+
);
|
|
271
|
+
if (partial)
|
|
272
|
+
throw operatorRefusal(
|
|
273
|
+
"issue connection is incomplete",
|
|
274
|
+
"This Linear issue has more than 100 labels, sub-issues or relations, so the npm updater cannot confirm there is no hold or open blocker. Remove the extra ones or handle this update by hand."
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** Completed, cancelled and archived issues are closed history, never claimable. */
|
|
279
|
+
export function linearClosed(node) {
|
|
280
|
+
return (
|
|
281
|
+
Boolean(node?.archivedAt) ||
|
|
282
|
+
["completed", "canceled"].includes(node?.state?.type)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** A GraphQL connection page in the bounded search shape discoverPrior already checks. */
|
|
287
|
+
export function linearSearchResult(connection) {
|
|
288
|
+
const nodes = connection?.nodes;
|
|
289
|
+
required(Array.isArray(nodes), "tracker search reply differs");
|
|
290
|
+
return {
|
|
291
|
+
incomplete_results: connection.pageInfo?.hasNextPage !== false,
|
|
292
|
+
total_count: nodes.length,
|
|
293
|
+
items: nodes.map(node => ({
|
|
294
|
+
number: node.number,
|
|
295
|
+
state: linearClosed(node) ? "closed" : "open",
|
|
296
|
+
})),
|
|
297
|
+
};
|
|
298
|
+
}
|