@sjawhar/pi-legion 19.7.1 → 19.8.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/dist/legion.js +25 -27
- package/package.json +1 -1
package/dist/legion.js
CHANGED
|
@@ -16968,6 +16968,8 @@ var ArtifactCreatedEventPayloadSchema = object({
|
|
|
16968
16968
|
name: artifactFields.name.optional()
|
|
16969
16969
|
}).optional()
|
|
16970
16970
|
});
|
|
16971
|
+
var ArtifactRenamedEventPayloadSchema = strictObject({ artifact: ArtifactSchema, previous_name: string2() }).readonly();
|
|
16972
|
+
var ArtifactRemovedEventPayloadSchema = strictObject({ artifact: ArtifactSchema }).readonly();
|
|
16971
16973
|
var artifactVersionEventPayloadFields = {
|
|
16972
16974
|
artifact_id: string2(),
|
|
16973
16975
|
name: string2(),
|
|
@@ -17063,15 +17065,16 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
|
|
|
17063
17065
|
message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
|
|
17064
17066
|
};
|
|
17065
17067
|
}
|
|
17066
|
-
var ARTIFACT_SOURCE_RULE = "
|
|
17068
|
+
var ARTIFACT_SOURCE_RULE = "Give at most one of path and content. A call with neither makes an empty document under the name, which a person or an agent writes in afterwards with dispatch doc-edit.";
|
|
17067
17069
|
var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
|
|
17068
17070
|
function brokenParts(parts) {
|
|
17069
17071
|
const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
|
|
17070
17072
|
return broken.length === 0 ? undefined : broken.join(" ");
|
|
17071
17073
|
}
|
|
17072
17074
|
var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
|
|
17075
|
+
var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
|
|
17073
17076
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
17074
|
-
var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so
|
|
17077
|
+
var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
|
|
17075
17078
|
var ARTIFACT_NAME_EXISTS_RULE = "An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. Send the upload again with force (--force) to write the next version.";
|
|
17076
17079
|
var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
|
|
17077
17080
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
@@ -17085,19 +17088,16 @@ function artifactProblem(value) {
|
|
|
17085
17088
|
const input = value;
|
|
17086
17089
|
const ownerOrSourceProblem = brokenParts([
|
|
17087
17090
|
[artifactOwner.check(value), artifactOwner.message],
|
|
17088
|
-
[
|
|
17089
|
-
typeof input.path === "string" !== (typeof input.content === "string"),
|
|
17090
|
-
ARTIFACT_SOURCE_RULE
|
|
17091
|
-
]
|
|
17091
|
+
[typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
|
|
17092
17092
|
]);
|
|
17093
17093
|
if (ownerOrSourceProblem !== undefined)
|
|
17094
17094
|
return ownerOrSourceProblem;
|
|
17095
|
-
if (typeof input.
|
|
17095
|
+
if (typeof input.path === "string" || typeof input.name !== "string")
|
|
17096
17096
|
return;
|
|
17097
17097
|
const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
|
|
17098
17098
|
if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
|
|
17099
17099
|
return;
|
|
17100
|
-
return `${
|
|
17100
|
+
return `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
|
|
17101
17101
|
}
|
|
17102
17102
|
var documentEditOwner = documentOwnerValidation(true);
|
|
17103
17103
|
var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
|
|
@@ -17648,7 +17648,7 @@ var dispatchToolSpecs = [
|
|
|
17648
17648
|
name: "dispatch_artifact",
|
|
17649
17649
|
example: { issue: "DSP-1", name: "design.md", content: `# Design
|
|
17650
17650
|
` },
|
|
17651
|
-
description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit.
|
|
17651
|
+
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force, so a title typed twice never empties the document that holds it. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
|
|
17652
17652
|
arguments: (z) => ({
|
|
17653
17653
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
17654
17654
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
@@ -20834,8 +20834,9 @@ class DispatchClient {
|
|
|
20834
20834
|
return { status: response.status, payload: await this.#response(method, url, response) };
|
|
20835
20835
|
}
|
|
20836
20836
|
async#upload(path, input, key) {
|
|
20837
|
-
if (
|
|
20837
|
+
if (input.file === undefined) {
|
|
20838
20838
|
return this.#json("POST", path, input, undefined, undefined, key);
|
|
20839
|
+
}
|
|
20839
20840
|
const form = new FormData;
|
|
20840
20841
|
form.set("name", input.name);
|
|
20841
20842
|
if (input.summary !== undefined)
|
|
@@ -23476,13 +23477,17 @@ function withoutFinalLineFeed(text) {
|
|
|
23476
23477
|
return text.endsWith(`
|
|
23477
23478
|
`) ? text.slice(0, -1) : text;
|
|
23478
23479
|
}
|
|
23480
|
+
var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
|
|
23479
23481
|
async function artifactCommand(context) {
|
|
23480
23482
|
const { args, client, actor, input, documentOwner, issue } = context;
|
|
23481
23483
|
const summary = optionalString(args, "summary");
|
|
23482
23484
|
const name = stringArg(args, "name");
|
|
23483
23485
|
const content = optionalString(args, "content");
|
|
23486
|
+
const path = optionalString(args, "path");
|
|
23487
|
+
const options = { name, ...summary === undefined ? {} : { summary }, actor };
|
|
23484
23488
|
const artifactOwner = documentOwner();
|
|
23485
|
-
|
|
23489
|
+
const blank = content === undefined || goBlankPattern.test(content);
|
|
23490
|
+
if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
|
|
23486
23491
|
const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
|
|
23487
23492
|
if (held !== undefined) {
|
|
23488
23493
|
throw new ToolInputError(input.tool, [
|
|
@@ -23490,7 +23495,7 @@ async function artifactCommand(context) {
|
|
|
23490
23495
|
]);
|
|
23491
23496
|
}
|
|
23492
23497
|
}
|
|
23493
|
-
if (
|
|
23498
|
+
if (!blank) {
|
|
23494
23499
|
let stored;
|
|
23495
23500
|
try {
|
|
23496
23501
|
stored = await client.markdownRoundTrip(content);
|
|
@@ -23503,19 +23508,12 @@ async function artifactCommand(context) {
|
|
|
23503
23508
|
throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
|
|
23504
23509
|
}
|
|
23505
23510
|
}
|
|
23506
|
-
const artifactInput =
|
|
23507
|
-
|
|
23508
|
-
file: input.uploadBytes === undefined ? Bun.file(resolvePath(input.cwd,
|
|
23509
|
-
type: Bun.file(resolvePath(input.cwd,
|
|
23510
|
-
})
|
|
23511
|
-
|
|
23512
|
-
actor
|
|
23513
|
-
} : {
|
|
23514
|
-
name,
|
|
23515
|
-
content,
|
|
23516
|
-
...summary === undefined ? {} : { summary },
|
|
23517
|
-
actor
|
|
23518
|
-
};
|
|
23511
|
+
const artifactInput = path !== undefined ? {
|
|
23512
|
+
...options,
|
|
23513
|
+
file: input.uploadBytes === undefined ? Bun.file(resolvePath(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
|
|
23514
|
+
type: Bun.file(resolvePath(input.cwd, path)).type
|
|
23515
|
+
})
|
|
23516
|
+
} : content !== undefined ? { ...options, content } : options;
|
|
23519
23517
|
const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
|
|
23520
23518
|
const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
|
|
23521
23519
|
const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
|
|
@@ -23524,7 +23522,7 @@ async function artifactCommand(context) {
|
|
|
23524
23522
|
});
|
|
23525
23523
|
return {
|
|
23526
23524
|
text: [
|
|
23527
|
-
`Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
|
|
23525
|
+
path === undefined && content === undefined ? `Made ${result.artifact.name} as an empty document (artifact slug ${result.artifact.slug}; ${artifactRef}). Write in it with dispatch doc-edit.${await notSubscribed(uploadOwner, input.subscriptions)}` : `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
|
|
23528
23526
|
...adviceLines
|
|
23529
23527
|
].join(`
|
|
23530
23528
|
`),
|
|
@@ -28484,7 +28482,7 @@ import { logger as logger3 } from "@oh-my-pi/pi-utils";
|
|
|
28484
28482
|
// package.json
|
|
28485
28483
|
var package_default = {
|
|
28486
28484
|
name: "@sjawhar/pi-legion",
|
|
28487
|
-
version: "19.
|
|
28485
|
+
version: "19.8.0",
|
|
28488
28486
|
license: "Apache-2.0",
|
|
28489
28487
|
type: "module",
|
|
28490
28488
|
omp: {
|