@sjawhar/pi-legion-envoy 1.53.2 → 1.53.4
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/dist/envoy.js +44 -31
- package/dist/legion.js +1 -1
- package/package.json +1 -1
package/dist/envoy.js
CHANGED
|
@@ -32963,6 +32963,20 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, serverUrl, pro
|
|
|
32963
32963
|
const issue = `${repo}#${legionIssue}`;
|
|
32964
32964
|
return { args: { ...args, issue }, ref, owner: { kind: "issue", issue } };
|
|
32965
32965
|
}
|
|
32966
|
+
function artifactByReference(artifacts, artifactReference, owner) {
|
|
32967
|
+
const byIdOrSlug = artifacts.find((candidate) => candidate.id === artifactReference) ?? artifacts.find((candidate) => candidate.slug === artifactReference);
|
|
32968
|
+
if (byIdOrSlug !== undefined)
|
|
32969
|
+
return byIdOrSlug;
|
|
32970
|
+
const byName = artifacts.filter((candidate) => candidate.name === artifactReference);
|
|
32971
|
+
if (byName.length > 1) {
|
|
32972
|
+
throw new Error(documentReferenceProblem(artifactReference, byName, owner, true));
|
|
32973
|
+
}
|
|
32974
|
+
const [artifact] = byName;
|
|
32975
|
+
if (artifact === undefined) {
|
|
32976
|
+
throw new Error(documentReferenceProblem(artifactReference, artifacts, owner));
|
|
32977
|
+
}
|
|
32978
|
+
return artifact;
|
|
32979
|
+
}
|
|
32966
32980
|
async function resolveArtifact(client, owner, artifactReference) {
|
|
32967
32981
|
if (owner.kind === "project") {
|
|
32968
32982
|
if (artifactReference === undefined) {
|
|
@@ -32977,17 +32991,10 @@ async function resolveArtifact(client, owner, artifactReference) {
|
|
|
32977
32991
|
if (!(error instanceof DispatchServiceError) || error.status !== 404)
|
|
32978
32992
|
throw error;
|
|
32979
32993
|
const artifacts = await client.listProjectArtifacts(owner.project, true);
|
|
32980
|
-
|
|
32981
|
-
|
|
32982
|
-
|
|
32983
|
-
|
|
32984
|
-
if (names.length > 1) {
|
|
32985
|
-
throw new Error(documentReferenceProblem(artifactReference, names, "project", true));
|
|
32986
|
-
}
|
|
32987
|
-
if (names[0] === undefined) {
|
|
32988
|
-
throw new Error(documentReferenceProblem(artifactReference, artifacts, "project"));
|
|
32989
|
-
}
|
|
32990
|
-
return { owner, artifact: names[0] };
|
|
32994
|
+
return {
|
|
32995
|
+
owner,
|
|
32996
|
+
artifact: artifactByReference(artifacts, artifactReference, "project")
|
|
32997
|
+
};
|
|
32991
32998
|
}
|
|
32992
32999
|
}
|
|
32993
33000
|
const issue = await client.getIssue(owner.issue);
|
|
@@ -32995,14 +33002,7 @@ async function resolveArtifact(client, owner, artifactReference) {
|
|
|
32995
33002
|
if (artifactReference === undefined || artifactReference === "spec") {
|
|
32996
33003
|
artifact = issue.artifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
|
|
32997
33004
|
} else {
|
|
32998
|
-
artifact = issue.artifacts
|
|
32999
|
-
if (artifact === undefined) {
|
|
33000
|
-
const names = issue.artifacts.filter((candidate) => candidate.name === artifactReference);
|
|
33001
|
-
if (names.length > 1) {
|
|
33002
|
-
throw new Error(documentReferenceProblem(artifactReference, names, "issue", true));
|
|
33003
|
-
}
|
|
33004
|
-
artifact = names[0];
|
|
33005
|
-
}
|
|
33005
|
+
artifact = artifactByReference(issue.artifacts, artifactReference, "issue");
|
|
33006
33006
|
}
|
|
33007
33007
|
if (!artifact) {
|
|
33008
33008
|
throw new Error(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, "issue"));
|
|
@@ -33295,19 +33295,21 @@ function messageSummary({ message, replies }, graph) {
|
|
|
33295
33295
|
`);
|
|
33296
33296
|
}
|
|
33297
33297
|
async function openArtifactMarks(client, resolved) {
|
|
33298
|
-
const
|
|
33298
|
+
const asksPromise = resolved.owner.kind === "project" ? client.getArtifactAsks(resolved.artifact.id) : Promise.resolve(resolved.issue?.open_asks ?? []);
|
|
33299
|
+
const commentsPromise = resolved.owner.kind === "project" ? client.getArtifactComments(resolved.artifact.id) : client.getComments(resolved.issue?.key ?? "", resolved.artifact.id);
|
|
33300
|
+
const commentsResultPromise = commentsPromise.then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason }));
|
|
33301
|
+
const asks = await asksPromise;
|
|
33299
33302
|
const marks = asks.filter((ask) => ask.state === "open" && ask.anchor?.artifact_id === resolved.artifact.id).map((ask) => `ask ${ask.id}`);
|
|
33300
|
-
|
|
33301
|
-
|
|
33302
|
-
|
|
33303
|
-
} catch (error) {
|
|
33304
|
-
if (error instanceof DispatchServiceError && error.status === 404)
|
|
33303
|
+
const commentsResult = await commentsResultPromise;
|
|
33304
|
+
if (commentsResult.status === "rejected") {
|
|
33305
|
+
if (commentsResult.reason instanceof DispatchServiceError && commentsResult.reason.status === 404) {
|
|
33305
33306
|
return marks;
|
|
33306
|
-
|
|
33307
|
+
}
|
|
33308
|
+
throw commentsResult.reason;
|
|
33307
33309
|
}
|
|
33308
33310
|
return [
|
|
33309
33311
|
...marks,
|
|
33310
|
-
...
|
|
33312
|
+
...commentsResult.value.filter((comment) => !comment.resolved && comment.anchor?.artifact_id === resolved.artifact.id).map((comment) => `comment ${comment.id}`)
|
|
33311
33313
|
];
|
|
33312
33314
|
}
|
|
33313
33315
|
async function executeDispatchTool(input) {
|
|
@@ -33726,8 +33728,14 @@ ${followsAsk(askOwner)}`,
|
|
|
33726
33728
|
const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
|
|
33727
33729
|
const resolved = await resolveArtifact(client, documentOwner(), artifactReference);
|
|
33728
33730
|
const version = optionalNumber(args, "version") ?? ownerArguments.ref?.version;
|
|
33729
|
-
const
|
|
33730
|
-
const
|
|
33731
|
+
const documentPromise = client.docRead(resolved.artifact.id, version);
|
|
33732
|
+
const marksPromise = openArtifactMarks(client, resolved);
|
|
33733
|
+
const marksResultPromise = marksPromise.then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason }));
|
|
33734
|
+
const document = await documentPromise;
|
|
33735
|
+
const marksResult = await marksResultPromise;
|
|
33736
|
+
if (marksResult.status === "rejected")
|
|
33737
|
+
throw marksResult.reason;
|
|
33738
|
+
const marks = marksResult.value;
|
|
33731
33739
|
const approval = approvalLine(resolved.artifact);
|
|
33732
33740
|
const trailer = [
|
|
33733
33741
|
...marks.length === 0 ? [] : [`Open anchored asks/comments: ${marks.join(", ")}`],
|
|
@@ -33862,21 +33870,26 @@ ${trailer.join(`
|
|
|
33862
33870
|
}
|
|
33863
33871
|
};
|
|
33864
33872
|
}
|
|
33865
|
-
const
|
|
33873
|
+
const issueKey = issue();
|
|
33866
33874
|
if (ownerArguments.ref?.kind === "log") {
|
|
33875
|
+
const read = await client.read(issueKey);
|
|
33867
33876
|
return {
|
|
33868
33877
|
text: logSummary(read.issue, read.events),
|
|
33869
33878
|
details: { issue: read.issue.key }
|
|
33870
33879
|
};
|
|
33871
33880
|
}
|
|
33872
33881
|
if (ownerArguments.ref?.kind === "children") {
|
|
33882
|
+
const read = await client.read(issueKey);
|
|
33873
33883
|
return {
|
|
33874
33884
|
text: childrenSummary(read.issue),
|
|
33875
33885
|
details: { issue: read.issue.key }
|
|
33876
33886
|
};
|
|
33877
33887
|
}
|
|
33888
|
+
const readPromise = client.read(issueKey);
|
|
33889
|
+
const referencesPromise = issueReferencesOrUnavailable(client, issueKey);
|
|
33890
|
+
const read = await readPromise;
|
|
33878
33891
|
const [references, graph] = await Promise.all([
|
|
33879
|
-
|
|
33892
|
+
referencesPromise,
|
|
33880
33893
|
graphSections(client, dispatchIssueRef(read.issue.key))
|
|
33881
33894
|
]);
|
|
33882
33895
|
return {
|
package/dist/legion.js
CHANGED
|
@@ -16145,7 +16145,7 @@ import { logger } from "@oh-my-pi/pi-utils";
|
|
|
16145
16145
|
// package.json
|
|
16146
16146
|
var package_default = {
|
|
16147
16147
|
name: "@sjawhar/pi-legion-envoy",
|
|
16148
|
-
version: "1.53.
|
|
16148
|
+
version: "1.53.4",
|
|
16149
16149
|
type: "module",
|
|
16150
16150
|
omp: {
|
|
16151
16151
|
extensions: [
|