replicas-cli 0.3.519 → 0.3.520
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/index.cjs +104 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24579,11 +24579,45 @@ replicas gpu delete
|
|
|
24579
24579
|
});
|
|
24580
24580
|
|
|
24581
24581
|
// ../shared/src/routes/issues.ts
|
|
24582
|
-
|
|
24582
|
+
function readUnknownIssueValues(parse3) {
|
|
24583
|
+
const unknown2 = [];
|
|
24584
|
+
unknownValues = unknown2;
|
|
24585
|
+
try {
|
|
24586
|
+
return { result: parse3(), unknown: unknown2 };
|
|
24587
|
+
} finally {
|
|
24588
|
+
unknownValues = null;
|
|
24589
|
+
}
|
|
24590
|
+
}
|
|
24591
|
+
function parseIssueContractRecord(schema, value, at, report) {
|
|
24592
|
+
const { result, unknown: unknown2 } = readUnknownIssueValues(() => external_exports.safeParse(schema, value, { reportInput: true }));
|
|
24593
|
+
if (result.success) {
|
|
24594
|
+
if (unknown2.length) report.kept++;
|
|
24595
|
+
for (const raw of unknown2) report.problems.add(`${at || "snapshot"} unknown_value ${raw.slice(0, 40)}`);
|
|
24596
|
+
return result.data;
|
|
24597
|
+
}
|
|
24598
|
+
for (const issue3 of result.error.issues) {
|
|
24599
|
+
const path12 = [at, ...issue3.path.map((key) => typeof key === "number" || UUID_RE.test(String(key)) ? "*" : String(key))].filter(Boolean).join(".");
|
|
24600
|
+
report.problems.add(`${path12} ${issue3.code}${issue3.code === "invalid_value" ? ` ${String(issue3.input).slice(0, 40)}` : ""}`);
|
|
24601
|
+
}
|
|
24602
|
+
report.dropped++;
|
|
24603
|
+
return void 0;
|
|
24604
|
+
}
|
|
24605
|
+
function parseIssueContractResponse(schema, value, report) {
|
|
24606
|
+
const rows = isRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, raw]) => {
|
|
24607
|
+
const field2 = schema.shape[key];
|
|
24608
|
+
return [key, field2 instanceof external_exports.ZodArray && Array.isArray(raw) ? raw.filter((row) => parseIssueContractRecord(field2.element, row, key, report) !== void 0) : raw];
|
|
24609
|
+
})) : value;
|
|
24610
|
+
const parsed = external_exports.safeParse(schema, rows);
|
|
24611
|
+
if (!parsed.success) for (const issue3 of parsed.error.issues) report.problems.add(`${issue3.path.join(".")} ${issue3.code}`);
|
|
24612
|
+
return parsed.data;
|
|
24613
|
+
}
|
|
24614
|
+
var ISSUE_STATUSES, ISSUE_PRIORITIES, ISSUE_ACTOR_TYPES, ISSUE_SUBSCRIBER_ROLES, ISSUE_RELATION_TYPES, ISSUE_PULL_REQUEST_STATES, normalizeIssueStatus, ISSUE_STATUSES_HEADER, issueStatusSchema, issuePrioritySchema, issueSubscriberRoleSchema, issueRelationTypeSchema, issuePullRequestStateSchema, ISSUE_STATUS_LABELS, ISSUE_PRIORITY_LABELS, unknownValues, knownOrRaw, createIssueContractReport, knownIssueActorSchema, issueActorSchema, ISSUE_KEY_RE, timestamp, nullableTimestamp, issueSchema, issueSubscriberSchema, issueRelationSchema, issuePullRequestSchema, issueCommentSchema, change, nullableId, issueEventDataSchemas, issueEventBase, v, issueEventVariants, created, laterVariants, issueEventSchema, clientMutationId, title, description, body, createIssueRequestSchema, updateIssueRequestSchema, issueActorRequestSchema, createIssueCommentRequestSchema, updateIssueCommentRequestSchema, createIssueRelationRequestSchema, linkIssuePullRequestRequestSchema, updateIssuePullRequestRequestSchema, issueMutationRequestSchema, updateIssueSettingsRequestSchema, listIssuesQuerySchema, issueDetailResponseSchema, listIssuesResponseSchema, issueDirectoryUserSchema, issueDirectoryWorkspaceSchema, issuesBootstrapResponseSchema, issuesDeltaQuerySchema, issuesDeltaResponseSchema, issueInboxQuerySchema, markIssueInboxReadRequestSchema, ISSUE_COMMANDS;
|
|
24583
24615
|
var init_issues = __esm({
|
|
24584
24616
|
"../shared/src/routes/issues.ts"() {
|
|
24585
24617
|
"use strict";
|
|
24586
24618
|
init_zod();
|
|
24619
|
+
init_type_guards();
|
|
24620
|
+
init_uuid();
|
|
24587
24621
|
init_manager();
|
|
24588
24622
|
init_workspaces();
|
|
24589
24623
|
ISSUE_STATUSES = ["backlog", "todo", "in_progress", "review", "approved", "done", "canceled", "duplicate"];
|
|
@@ -24607,10 +24641,12 @@ var init_issues = __esm({
|
|
|
24607
24641
|
unknownValues?.push(value);
|
|
24608
24642
|
return true;
|
|
24609
24643
|
})]);
|
|
24610
|
-
|
|
24644
|
+
createIssueContractReport = () => ({ problems: /* @__PURE__ */ new Set(), dropped: 0, kept: 0 });
|
|
24645
|
+
knownIssueActorSchema = external_exports.object({
|
|
24611
24646
|
type: external_exports.enum(ISSUE_ACTOR_TYPES),
|
|
24612
24647
|
id: external_exports.string().toLowerCase().uuid()
|
|
24613
24648
|
});
|
|
24649
|
+
issueActorSchema = knownIssueActorSchema.extend({ type: knownOrRaw(knownIssueActorSchema.shape.type) });
|
|
24614
24650
|
ISSUE_KEY_RE = /^[A-Z][A-Z0-9]{0,9}$/;
|
|
24615
24651
|
timestamp = external_exports.string();
|
|
24616
24652
|
nullableTimestamp = timestamp.nullable();
|
|
@@ -24724,8 +24760,8 @@ var init_issues = __esm({
|
|
|
24724
24760
|
parent_id: external_exports.string().uuid().optional(),
|
|
24725
24761
|
manager_id: external_exports.string().uuid().optional(),
|
|
24726
24762
|
sort_order: external_exports.number().finite().optional(),
|
|
24727
|
-
assignees: external_exports.array(
|
|
24728
|
-
subscribers: external_exports.array(
|
|
24763
|
+
assignees: external_exports.array(knownIssueActorSchema).max(20).optional(),
|
|
24764
|
+
subscribers: external_exports.array(knownIssueActorSchema).max(50).optional(),
|
|
24729
24765
|
client_mutation_id: clientMutationId
|
|
24730
24766
|
});
|
|
24731
24767
|
updateIssueRequestSchema = external_exports.object({
|
|
@@ -24739,7 +24775,7 @@ var init_issues = __esm({
|
|
|
24739
24775
|
sort_order: external_exports.number().finite().optional(),
|
|
24740
24776
|
client_mutation_id: clientMutationId
|
|
24741
24777
|
});
|
|
24742
|
-
issueActorRequestSchema =
|
|
24778
|
+
issueActorRequestSchema = knownIssueActorSchema.partial().extend({ client_mutation_id: clientMutationId });
|
|
24743
24779
|
createIssueCommentRequestSchema = external_exports.object({
|
|
24744
24780
|
id: external_exports.string().uuid().optional(),
|
|
24745
24781
|
body,
|
|
@@ -40203,7 +40239,7 @@ var CLI_VERSION;
|
|
|
40203
40239
|
var init_cli_version = __esm({
|
|
40204
40240
|
"../shared/src/cli-version.ts"() {
|
|
40205
40241
|
"use strict";
|
|
40206
|
-
CLI_VERSION = "0.3.
|
|
40242
|
+
CLI_VERSION = "0.3.520";
|
|
40207
40243
|
}
|
|
40208
40244
|
});
|
|
40209
40245
|
|
|
@@ -56395,6 +56431,46 @@ var init_preview = __esm({
|
|
|
56395
56431
|
}
|
|
56396
56432
|
});
|
|
56397
56433
|
|
|
56434
|
+
// ../shared/src/media-url.ts
|
|
56435
|
+
function readImageSize(read) {
|
|
56436
|
+
let bytes = read(0);
|
|
56437
|
+
let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
56438
|
+
const ascii = (at, length) => String.fromCharCode(...bytes.subarray(at, at + length));
|
|
56439
|
+
const size = (width, height, exif2 = false) => width > 0 && height > 0 ? { width, height, exif: exif2 } : null;
|
|
56440
|
+
if (bytes.length >= 24 && ascii(1, 3) === "PNG") return size(view.getUint32(16), view.getUint32(20));
|
|
56441
|
+
if (bytes.length >= 10 && ascii(0, 3) === "GIF") return size(view.getUint16(6, true), view.getUint16(8, true));
|
|
56442
|
+
if (bytes.length >= 31 && ascii(0, 4) === "RIFF" && ascii(8, 4) === "WEBP") {
|
|
56443
|
+
const chunk = ascii(12, 4);
|
|
56444
|
+
if (chunk === "VP8X") return size(1 + (view.getUint32(24, true) & 16777215), 1 + (view.getUint32(27, true) & 16777215));
|
|
56445
|
+
if (chunk === "VP8 ") return size(view.getUint16(26, true) & 16383, view.getUint16(28, true) & 16383);
|
|
56446
|
+
if (chunk === "VP8L") {
|
|
56447
|
+
const bits = view.getUint32(21, true);
|
|
56448
|
+
return size(1 + (bits & 16383), 1 + (bits >> 14 & 16383));
|
|
56449
|
+
}
|
|
56450
|
+
return null;
|
|
56451
|
+
}
|
|
56452
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) return null;
|
|
56453
|
+
let exif = false;
|
|
56454
|
+
for (let at = 2; ; ) {
|
|
56455
|
+
bytes = read(at);
|
|
56456
|
+
view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
56457
|
+
if (bytes.length < 9 || bytes[0] !== 255) return null;
|
|
56458
|
+
const marker = bytes[1];
|
|
56459
|
+
if (marker === 225) exif = true;
|
|
56460
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return size(view.getUint16(7), view.getUint16(5), exif);
|
|
56461
|
+
at += 2 + view.getUint16(2);
|
|
56462
|
+
}
|
|
56463
|
+
}
|
|
56464
|
+
var REPLICAS_WEB_ORIGIN, withImageSize;
|
|
56465
|
+
var init_media_url = __esm({
|
|
56466
|
+
"../shared/src/media-url.ts"() {
|
|
56467
|
+
"use strict";
|
|
56468
|
+
init_urls();
|
|
56469
|
+
REPLICAS_WEB_ORIGIN = new URL(DEFAULT_WEB_APP_URL).origin;
|
|
56470
|
+
withImageSize = (url2, size) => size ? `${url2}#w=${size.width}&h=${size.height}` : url2;
|
|
56471
|
+
}
|
|
56472
|
+
});
|
|
56473
|
+
|
|
56398
56474
|
// src/commands/media.ts
|
|
56399
56475
|
function publicMediaUrl(mediaId, token) {
|
|
56400
56476
|
return `${MONOLITH_URL}/v1/media/public/${mediaId}/${token}`;
|
|
@@ -56455,11 +56531,13 @@ async function uploadOne(filePath, displayName, kind, options) {
|
|
|
56455
56531
|
const fileName = import_path6.default.basename(absPath);
|
|
56456
56532
|
const ext = import_path6.default.extname(absPath).slice(1).toLowerCase();
|
|
56457
56533
|
const contentType = mediaInfo(ext)?.contentType ?? "application/octet-stream";
|
|
56458
|
-
|
|
56534
|
+
const body2 = import_fs7.default.readFileSync(absPath);
|
|
56535
|
+
const media2 = await uploadMedia(new Blob([body2], { type: contentType }), fileName, {
|
|
56459
56536
|
kind,
|
|
56460
56537
|
display_name: displayName,
|
|
56461
56538
|
session_id: options.sessionId || void 0
|
|
56462
56539
|
});
|
|
56540
|
+
return { media: media2, imageSize: kind === MEDIA_KIND.IMAGE ? readImageSize((offset) => body2.subarray(offset)) : null };
|
|
56463
56541
|
}
|
|
56464
56542
|
async function mediaUploadCommand(filePaths, options) {
|
|
56465
56543
|
if (filePaths.length === 0) {
|
|
@@ -56497,7 +56575,7 @@ async function mediaUploadCommand(filePaths, options) {
|
|
|
56497
56575
|
);
|
|
56498
56576
|
const shareResults = await Promise.allSettled(
|
|
56499
56577
|
results.map(
|
|
56500
|
-
(result, i) => result.status === "fulfilled" && shared[i] ? shareMedia(result.value.id) : Promise.resolve(null)
|
|
56578
|
+
(result, i) => result.status === "fulfilled" && shared[i] ? shareMedia(result.value.media.id) : Promise.resolve(null)
|
|
56501
56579
|
)
|
|
56502
56580
|
);
|
|
56503
56581
|
const config3 = readAgentConfig();
|
|
@@ -56506,7 +56584,7 @@ async function mediaUploadCommand(filePaths, options) {
|
|
|
56506
56584
|
for (let i = 0; i < results.length; i++) {
|
|
56507
56585
|
const result = results[i];
|
|
56508
56586
|
if (result.status === "fulfilled") {
|
|
56509
|
-
const media2 = result.value;
|
|
56587
|
+
const { media: media2, imageSize } = result.value;
|
|
56510
56588
|
const shareResult = shareResults[i];
|
|
56511
56589
|
const publicUrl = shareResult?.status === "fulfilled" ? shareResult.value ?? void 0 : void 0;
|
|
56512
56590
|
if (shared[i]) {
|
|
@@ -56526,7 +56604,7 @@ async function mediaUploadCommand(filePaths, options) {
|
|
|
56526
56604
|
name: names[i],
|
|
56527
56605
|
media: media2,
|
|
56528
56606
|
public_url: publicUrl,
|
|
56529
|
-
embed: !shared[i] || publicUrl ? formatMediaEmbed(names[i], media2, publicUrl) : void 0,
|
|
56607
|
+
embed: !shared[i] || publicUrl ? formatMediaEmbed(names[i], media2, publicUrl && withImageSize(publicUrl, imageSize && !imageSize.exif ? imageSize : null)) : void 0,
|
|
56530
56608
|
organization_url: options.access === "organization" && !shared[i] ? getOrganizationMediaUrl(media2.organization_id, media2.id) : void 0,
|
|
56531
56609
|
dashboard_url: config3?.workspace_id ? getWorkspaceDashboardUrl(config3.workspace_id, { mode: "media", mediaId: media2.id }) : void 0
|
|
56532
56610
|
});
|
|
@@ -56596,6 +56674,7 @@ var init_media3 = __esm({
|
|
|
56596
56674
|
init_api2();
|
|
56597
56675
|
init_config();
|
|
56598
56676
|
init_monolith_url();
|
|
56677
|
+
init_media_url();
|
|
56599
56678
|
init_output();
|
|
56600
56679
|
init_src();
|
|
56601
56680
|
MEDIA_ACCESS_VALUES = ["organization", "public"];
|
|
@@ -56695,18 +56774,24 @@ var init_media_gif = __esm({
|
|
|
56695
56774
|
// src/commands/issue.ts
|
|
56696
56775
|
async function callIssueTool(name, args, schema) {
|
|
56697
56776
|
if (!isAgentMode() && !getApiKey()) throw new Error("replicas issue needs an API key: run `replicas login --api-key`, or use it inside a workspace.");
|
|
56777
|
+
let response;
|
|
56698
56778
|
try {
|
|
56699
|
-
|
|
56779
|
+
response = await orgAuthenticatedFetch(`/v1/issue-commands/${name}`, { method: "POST", body: args, headers: { [ISSUE_STATUSES_HEADER]: "1" } });
|
|
56700
56780
|
} catch (error62) {
|
|
56701
56781
|
if (error62 instanceof ApiError && error62.status === 404 && error62.message === "Not found") throw new Error("Issues are not enabled for this organization");
|
|
56702
56782
|
throw error62;
|
|
56703
56783
|
}
|
|
56784
|
+
const report = createIssueContractReport();
|
|
56785
|
+
const parsed = parseIssueContractResponse(schema, response, report);
|
|
56786
|
+
if (parsed === void 0) throw new Error(`Unexpected response from the server: ${[...report.problems].join("; ")}`);
|
|
56787
|
+
if (report.dropped) console.error(import_chalk29.default.yellow(`Skipped ${report.dropped} record(s) this CLI can't read: ${[...report.problems].filter((problem) => !problem.includes("unknown_value")).join("; ")}`));
|
|
56788
|
+
return parsed;
|
|
56704
56789
|
}
|
|
56705
56790
|
async function uploadAttachments(files) {
|
|
56706
56791
|
if (!files?.length) return void 0;
|
|
56707
56792
|
if (!isAgentMode()) throw new Error("--attach works inside a workspace. Elsewhere, embed an image URL in the markdown.");
|
|
56708
56793
|
const uploaded = await Promise.all(files.map((file2) => uploadOne(file2, import_node_path2.default.basename(file2), resolveKind(import_node_path2.default.extname(file2).slice(1).toLowerCase()), {})));
|
|
56709
|
-
return uploaded.map((media2) => media2.id);
|
|
56794
|
+
return uploaded.map(({ media: media2 }) => media2.id);
|
|
56710
56795
|
}
|
|
56711
56796
|
function readText(inline, file2, what) {
|
|
56712
56797
|
if (inline !== void 0 && file2 !== void 0) throw new Error(`Pass either --${what} or --${what}-file, not both`);
|
|
@@ -56776,23 +56861,23 @@ async function issueCommentCommand(issue3, body2, options) {
|
|
|
56776
56861
|
const text4 = readText(body2, options.file, "file") ?? "";
|
|
56777
56862
|
const media_ids = await uploadAttachments(options.attach);
|
|
56778
56863
|
if (!text4.trim() && !media_ids) throw new Error("Pass the comment text, --file, or --attach");
|
|
56779
|
-
output2(await callIssueTool(ISSUE_COMMANDS.comment, { issue: issue3, body: text4, media_ids },
|
|
56864
|
+
output2(await callIssueTool(ISSUE_COMMANDS.comment, { issue: issue3, body: text4, media_ids }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} Commented on ${issue3}`));
|
|
56780
56865
|
}
|
|
56781
56866
|
function issueActorCommand(tool, done) {
|
|
56782
56867
|
return async (issue3, who) => {
|
|
56783
|
-
output2(await callIssueTool(tool, { issue: issue3, who },
|
|
56868
|
+
output2(await callIssueTool(tool, { issue: issue3, who }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} ${done} ${who ?? "you"} ${tool.startsWith("un") ? "from" : "to"} ${issue3}`));
|
|
56784
56869
|
};
|
|
56785
56870
|
}
|
|
56786
56871
|
async function issueLinkPrCommand(issue3, url2) {
|
|
56787
|
-
output2(await callIssueTool(ISSUE_COMMANDS.linkPr, { issue: issue3, url: url2 },
|
|
56872
|
+
output2(await callIssueTool(ISSUE_COMMANDS.linkPr, { issue: issue3, url: url2 }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} Linked ${url2} to ${issue3}`));
|
|
56788
56873
|
}
|
|
56789
56874
|
async function issueUnlinkPrCommand(issue3, url2) {
|
|
56790
|
-
output2(await callIssueTool(ISSUE_COMMANDS.unlinkPr, { issue: issue3, url: url2 },
|
|
56875
|
+
output2(await callIssueTool(ISSUE_COMMANDS.unlinkPr, { issue: issue3, url: url2 }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} Unlinked ${url2} from ${issue3}`));
|
|
56791
56876
|
}
|
|
56792
56877
|
async function issueRelateCommand(issue3, type, related) {
|
|
56793
|
-
output2(await callIssueTool(ISSUE_COMMANDS.relate, { issue: issue3, type, related_issue: related },
|
|
56878
|
+
output2(await callIssueTool(ISSUE_COMMANDS.relate, { issue: issue3, type, related_issue: related }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} ${issue3} ${type.replace("_", " ")} ${related}`));
|
|
56794
56879
|
}
|
|
56795
|
-
var import_node_fs2, import_node_path2, import_chalk29, mutationSchema, csv, printMutation;
|
|
56880
|
+
var import_node_fs2, import_node_path2, import_chalk29, mutationSchema, noData, csv, printMutation;
|
|
56796
56881
|
var init_issue = __esm({
|
|
56797
56882
|
"src/commands/issue.ts"() {
|
|
56798
56883
|
"use strict";
|
|
@@ -56806,6 +56891,7 @@ var init_issue = __esm({
|
|
|
56806
56891
|
init_output();
|
|
56807
56892
|
init_media3();
|
|
56808
56893
|
mutationSchema = external_exports.object({ issue: issueSchema });
|
|
56894
|
+
noData = external_exports.looseObject({});
|
|
56809
56895
|
csv = (value) => value?.split(",").map((entry) => entry.trim()).filter(Boolean).join(",");
|
|
56810
56896
|
printMutation = ({ issue: issue3 }) => console.log(`${import_chalk29.default.green("\u2713")} ${import_chalk29.default.cyan(issue3.identifier)} ${issue3.title} (${issue3.status})`);
|
|
56811
56897
|
}
|