replicas-cli 0.3.512 → 0.3.514

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.
Files changed (2) hide show
  1. package/dist/index.cjs +284 -272
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -21776,6 +21776,12 @@ async function fetchWithRedirects(url2, init, attempt = 0) {
21776
21776
  }
21777
21777
  return response;
21778
21778
  }
21779
+ async function readApiErrorBody(response) {
21780
+ const payload = await response.json().catch(() => null);
21781
+ const body2 = payload && typeof payload === "object" ? Object.fromEntries(Object.entries(payload)) : {};
21782
+ const field2 = (key) => typeof body2[key] === "string" ? body2[key] : void 0;
21783
+ return { error: field2("error"), code: field2("code"), details: field2("details"), organizationId: field2("organization_id") };
21784
+ }
21779
21785
  var REDIRECT_STATUSES, MAX_REDIRECTS;
21780
21786
  var init_api_request = __esm({
21781
21787
  "../shared/src/api-request.ts"() {
@@ -22536,6 +22542,7 @@ var init_fallback_chains = __esm({
22536
22542
  init_agent();
22537
22543
  init_types3();
22538
22544
  init_agents();
22545
+ init_types2();
22539
22546
  init_type_guards();
22540
22547
  fallbackHarnessStepSchema = external_exports.object({
22541
22548
  kind: external_exports.literal("harness"),
@@ -24570,11 +24577,263 @@ replicas gpu delete
24570
24577
  }
24571
24578
  });
24572
24579
 
24573
- // ../shared/src/default-skills/replicas-agent/abilities/issues.ts
24574
- var SECTION7, REFERENCE7, ISSUES_ABILITY;
24580
+ // ../shared/src/routes/issues.ts
24581
+ var ISSUE_STATUSES, ISSUE_PRIORITIES, ISSUE_ACTOR_TYPES, ISSUE_SUBSCRIBER_ROLES, ISSUE_RELATION_TYPES, ISSUE_PULL_REQUEST_STATES, normalizeIssueStatus, issueStatusSchema, issuePrioritySchema, issueSubscriberRoleSchema, issueRelationTypeSchema, issuePullRequestStateSchema, ISSUE_STATUS_LABELS, ISSUE_PRIORITY_LABELS, issueActorSchema, ISSUE_KEY_RE, timestamp, nullableTimestamp, issueSchema, issueSubscriberSchema, issueRelationSchema, issuePullRequestSchema, issueCommentSchema, change, nullableId, ISSUE_EVENT_TYPES, issueEventDataSchemas, issueEventBase, issueEventVariant, issueEventSchema, clientMutationId, title, description, body, createIssueRequestSchema, updateIssueRequestSchema, issueActorRequestSchema, createIssueCommentRequestSchema, updateIssueCommentRequestSchema, createIssueRelationRequestSchema, linkIssuePullRequestRequestSchema, updateIssuePullRequestRequestSchema, issueMutationRequestSchema, updateIssueSettingsRequestSchema, listIssuesQuerySchema, issueDetailResponseSchema, listIssuesResponseSchema, issuesDeltaQuerySchema, issueInboxQuerySchema, markIssueInboxReadRequestSchema, ISSUE_COMMANDS;
24575
24582
  var init_issues = __esm({
24583
+ "../shared/src/routes/issues.ts"() {
24584
+ "use strict";
24585
+ init_zod();
24586
+ ISSUE_STATUSES = ["backlog", "todo", "in_progress", "review", "approved", "done", "canceled", "duplicate"];
24587
+ ISSUE_PRIORITIES = ["none", "urgent", "high", "medium", "low"];
24588
+ ISSUE_ACTOR_TYPES = ["user", "workspace", "system"];
24589
+ ISSUE_SUBSCRIBER_ROLES = ["assignee", "creator", "mentioned", "manual"];
24590
+ ISSUE_RELATION_TYPES = ["blocks", "duplicate_of"];
24591
+ ISSUE_PULL_REQUEST_STATES = ["draft", "open", "merged", "closed"];
24592
+ normalizeIssueStatus = (status) => status === "in_review" ? "review" : status;
24593
+ issueStatusSchema = external_exports.preprocess((value) => typeof value === "string" ? normalizeIssueStatus(value) : value, external_exports.enum(ISSUE_STATUSES));
24594
+ issuePrioritySchema = external_exports.enum(ISSUE_PRIORITIES);
24595
+ issueSubscriberRoleSchema = external_exports.enum(ISSUE_SUBSCRIBER_ROLES);
24596
+ issueRelationTypeSchema = external_exports.enum(ISSUE_RELATION_TYPES);
24597
+ issuePullRequestStateSchema = external_exports.enum(ISSUE_PULL_REQUEST_STATES);
24598
+ ISSUE_STATUS_LABELS = { backlog: "Backlog", todo: "Todo", in_progress: "In Progress", review: "Review", approved: "Approved", done: "Done", canceled: "Canceled", duplicate: "Duplicate" };
24599
+ ISSUE_PRIORITY_LABELS = { none: "No priority", urgent: "Urgent", high: "High", medium: "Medium", low: "Low" };
24600
+ issueActorSchema = external_exports.object({
24601
+ type: external_exports.enum(ISSUE_ACTOR_TYPES),
24602
+ id: external_exports.string().toLowerCase().uuid()
24603
+ });
24604
+ ISSUE_KEY_RE = /^[A-Z][A-Z0-9]{0,9}$/;
24605
+ timestamp = external_exports.string();
24606
+ nullableTimestamp = timestamp.nullable();
24607
+ issueSchema = external_exports.object({
24608
+ id: external_exports.string().uuid(),
24609
+ organization_id: external_exports.string().uuid(),
24610
+ number: external_exports.number().int(),
24611
+ identifier: external_exports.string(),
24612
+ title: external_exports.string(),
24613
+ description: external_exports.string(),
24614
+ status: issueStatusSchema,
24615
+ priority: issuePrioritySchema,
24616
+ parent_id: external_exports.string().uuid().nullable(),
24617
+ manager_id: external_exports.string().uuid().nullable(),
24618
+ creator: issueActorSchema,
24619
+ /** Fractional: to move an issue between two others, send the midpoint of their sort orders. */
24620
+ sort_order: external_exports.number(),
24621
+ created_at: timestamp,
24622
+ updated_at: timestamp,
24623
+ completed_at: nullableTimestamp,
24624
+ canceled_at: nullableTimestamp,
24625
+ archived_at: nullableTimestamp
24626
+ });
24627
+ issueSubscriberSchema = external_exports.object({
24628
+ issue_id: external_exports.string().uuid(),
24629
+ subscriber: issueActorSchema,
24630
+ role: issueSubscriberRoleSchema,
24631
+ created_at: timestamp
24632
+ });
24633
+ issueRelationSchema = external_exports.object({
24634
+ id: external_exports.string().uuid(),
24635
+ type: issueRelationTypeSchema,
24636
+ issue_id: external_exports.string().uuid(),
24637
+ related_issue_id: external_exports.string().uuid(),
24638
+ created_at: timestamp
24639
+ });
24640
+ issuePullRequestSchema = external_exports.object({
24641
+ id: external_exports.string().uuid(),
24642
+ issue_id: external_exports.string().uuid(),
24643
+ url: external_exports.string(),
24644
+ pull_request_id: external_exports.string().uuid().nullable(),
24645
+ title: external_exports.string().nullable(),
24646
+ state: issuePullRequestStateSchema,
24647
+ approved: external_exports.boolean(),
24648
+ created_at: timestamp,
24649
+ updated_at: timestamp
24650
+ });
24651
+ issueCommentSchema = external_exports.object({
24652
+ id: external_exports.string().uuid(),
24653
+ issue_id: external_exports.string().uuid(),
24654
+ author: issueActorSchema,
24655
+ body: external_exports.string(),
24656
+ created_at: timestamp,
24657
+ updated_at: timestamp
24658
+ });
24659
+ change = (value) => external_exports.object({ from: value, to: value });
24660
+ nullableId = external_exports.string().uuid().nullable();
24661
+ ISSUE_EVENT_TYPES = [
24662
+ "created",
24663
+ "title_changed",
24664
+ "description_changed",
24665
+ "status_changed",
24666
+ "priority_changed",
24667
+ "parent_changed",
24668
+ "manager_changed",
24669
+ "sort_order_changed",
24670
+ "assignee_added",
24671
+ "assignee_removed",
24672
+ "subscriber_added",
24673
+ "subscriber_removed",
24674
+ "relation_added",
24675
+ "relation_removed",
24676
+ "pr_linked",
24677
+ "pr_unlinked",
24678
+ "pr_state_changed",
24679
+ "comment_added",
24680
+ "comment_edited",
24681
+ "comment_deleted",
24682
+ "archived",
24683
+ "restored"
24684
+ ];
24685
+ issueEventDataSchemas = {
24686
+ created: external_exports.object({ issue: issueSchema }),
24687
+ title_changed: change(external_exports.string()),
24688
+ description_changed: change(external_exports.string()),
24689
+ status_changed: change(issueStatusSchema).extend({ completed_at: nullableTimestamp, canceled_at: nullableTimestamp, reason: external_exports.string().optional() }),
24690
+ priority_changed: change(issuePrioritySchema),
24691
+ parent_changed: change(nullableId),
24692
+ manager_changed: change(nullableId),
24693
+ sort_order_changed: change(external_exports.number()),
24694
+ /** `subscriber` is the row after the change: an unassigned principal stays subscribed with role `manual`. */
24695
+ assignee_added: external_exports.object({ subscriber: issueSubscriberSchema }),
24696
+ assignee_removed: external_exports.object({ subscriber: issueSubscriberSchema }),
24697
+ subscriber_added: external_exports.object({ subscriber: issueSubscriberSchema }),
24698
+ subscriber_removed: external_exports.object({ subscriber: issueSubscriberSchema }),
24699
+ relation_added: external_exports.object({ relation: issueRelationSchema }),
24700
+ relation_removed: external_exports.object({ relation: issueRelationSchema }),
24701
+ pr_linked: external_exports.object({ pull_request: issuePullRequestSchema }),
24702
+ pr_unlinked: external_exports.object({ pull_request: issuePullRequestSchema }),
24703
+ pr_state_changed: external_exports.object({ pull_request: issuePullRequestSchema, from: issuePullRequestStateSchema }),
24704
+ comment_added: external_exports.object({ comment: issueCommentSchema }),
24705
+ comment_edited: external_exports.object({ comment: issueCommentSchema, from: external_exports.string() }),
24706
+ comment_deleted: external_exports.object({ comment: issueCommentSchema }),
24707
+ archived: external_exports.object({ archived_at: timestamp }),
24708
+ restored: external_exports.object({
24709
+ issue: issueSchema,
24710
+ subscribers: external_exports.array(issueSubscriberSchema),
24711
+ relations: external_exports.array(issueRelationSchema),
24712
+ pull_requests: external_exports.array(issuePullRequestSchema)
24713
+ })
24714
+ };
24715
+ issueEventBase = external_exports.object({
24716
+ sync_id: external_exports.number().int(),
24717
+ issue_id: external_exports.string().uuid(),
24718
+ actor: issueActorSchema,
24719
+ /** Echo of the `client_mutation_id` sent with the write, so the writer can settle its optimistic change. */
24720
+ client_mutation_id: external_exports.string().nullable(),
24721
+ created_at: timestamp
24722
+ });
24723
+ issueEventVariant = (type) => issueEventBase.extend({ type: external_exports.literal(type), data: issueEventDataSchemas[type] });
24724
+ issueEventSchema = external_exports.discriminatedUnion("type", [issueEventVariant(ISSUE_EVENT_TYPES[0]), ...ISSUE_EVENT_TYPES.slice(1).map(issueEventVariant)]);
24725
+ clientMutationId = external_exports.string().min(1).max(128).optional();
24726
+ title = external_exports.string().trim().min(1).max(500);
24727
+ description = external_exports.string().max(1e5);
24728
+ body = external_exports.string().trim().min(1).max(1e5);
24729
+ createIssueRequestSchema = external_exports.object({
24730
+ /** Client-generated id, so an optimistic create can be referenced before the server answers. */
24731
+ id: external_exports.string().uuid().optional(),
24732
+ title,
24733
+ description: description.optional(),
24734
+ status: issueStatusSchema.optional(),
24735
+ priority: issuePrioritySchema.optional(),
24736
+ parent_id: external_exports.string().uuid().optional(),
24737
+ manager_id: external_exports.string().uuid().optional(),
24738
+ sort_order: external_exports.number().finite().optional(),
24739
+ assignees: external_exports.array(issueActorSchema).max(20).optional(),
24740
+ subscribers: external_exports.array(issueActorSchema).max(50).optional(),
24741
+ client_mutation_id: clientMutationId
24742
+ });
24743
+ updateIssueRequestSchema = external_exports.object({
24744
+ title: title.optional(),
24745
+ description: description.optional(),
24746
+ status: issueStatusSchema.optional(),
24747
+ priority: issuePrioritySchema.optional(),
24748
+ // PATCH semantics: null clears the parent or Manager, omitting it leaves it unchanged.
24749
+ parent_id: nullableId.optional(),
24750
+ manager_id: nullableId.optional(),
24751
+ sort_order: external_exports.number().finite().optional(),
24752
+ client_mutation_id: clientMutationId
24753
+ });
24754
+ issueActorRequestSchema = issueActorSchema.partial().extend({ client_mutation_id: clientMutationId });
24755
+ createIssueCommentRequestSchema = external_exports.object({
24756
+ id: external_exports.string().uuid().optional(),
24757
+ body,
24758
+ client_mutation_id: clientMutationId
24759
+ });
24760
+ updateIssueCommentRequestSchema = external_exports.object({ body, client_mutation_id: clientMutationId });
24761
+ createIssueRelationRequestSchema = external_exports.object({
24762
+ id: external_exports.string().uuid().optional(),
24763
+ type: issueRelationTypeSchema,
24764
+ related_issue: external_exports.string().min(1),
24765
+ client_mutation_id: clientMutationId
24766
+ });
24767
+ linkIssuePullRequestRequestSchema = external_exports.object({
24768
+ id: external_exports.string().uuid().optional(),
24769
+ url: external_exports.string().url().max(2e3),
24770
+ title: external_exports.string().max(500).optional(),
24771
+ state: issuePullRequestStateSchema.optional(),
24772
+ pull_request_id: external_exports.string().uuid().optional(),
24773
+ client_mutation_id: clientMutationId
24774
+ });
24775
+ updateIssuePullRequestRequestSchema = external_exports.object({
24776
+ state: issuePullRequestStateSchema,
24777
+ client_mutation_id: clientMutationId
24778
+ });
24779
+ issueMutationRequestSchema = external_exports.object({ client_mutation_id: clientMutationId });
24780
+ updateIssueSettingsRequestSchema = external_exports.object({ issue_key: external_exports.string().trim().toUpperCase().regex(ISSUE_KEY_RE) });
24781
+ listIssuesQuerySchema = external_exports.object({
24782
+ status: external_exports.string().optional(),
24783
+ priority: external_exports.string().optional(),
24784
+ assignee: external_exports.string().optional(),
24785
+ subscriber: external_exports.string().optional(),
24786
+ creator: external_exports.string().optional(),
24787
+ manager_id: external_exports.string().optional(),
24788
+ parent_id: external_exports.string().optional(),
24789
+ q: external_exports.string().max(200).optional(),
24790
+ include_archived: external_exports.enum(["true", "false"]).optional(),
24791
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
24792
+ cursor: external_exports.coerce.number().int().min(0).max(2147483647).optional()
24793
+ });
24794
+ issueDetailResponseSchema = external_exports.object({
24795
+ issue: issueSchema,
24796
+ subscribers: external_exports.array(issueSubscriberSchema),
24797
+ relations: external_exports.array(issueRelationSchema),
24798
+ pull_requests: external_exports.array(issuePullRequestSchema),
24799
+ comments: external_exports.array(issueCommentSchema),
24800
+ events: external_exports.array(issueEventSchema),
24801
+ sub_issues: external_exports.array(issueSchema)
24802
+ });
24803
+ listIssuesResponseSchema = external_exports.object({ issues: external_exports.array(issueSchema), next_cursor: external_exports.number().nullable() });
24804
+ issuesDeltaQuerySchema = external_exports.object({
24805
+ after: external_exports.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
24806
+ limit: external_exports.coerce.number().int().min(1).max(1e3).optional()
24807
+ });
24808
+ issueInboxQuerySchema = external_exports.object({
24809
+ limit: external_exports.coerce.number().int().min(1).max(100).optional(),
24810
+ before: external_exports.coerce.number().int().min(1).optional()
24811
+ });
24812
+ markIssueInboxReadRequestSchema = external_exports.object({ sync_id: external_exports.number().int().min(0).optional() });
24813
+ ISSUE_COMMANDS = {
24814
+ create: "create",
24815
+ update: "update",
24816
+ get: "get",
24817
+ list: "list",
24818
+ comment: "comment",
24819
+ assign: "assign",
24820
+ unassign: "unassign",
24821
+ subscribe: "subscribe",
24822
+ unsubscribe: "unsubscribe",
24823
+ linkPr: "link-pr",
24824
+ unlinkPr: "unlink-pr",
24825
+ relate: "relate"
24826
+ };
24827
+ }
24828
+ });
24829
+
24830
+ // ../shared/src/default-skills/replicas-agent/abilities/issues.ts
24831
+ var codeList, SECTION7, REFERENCE7, ISSUES_ABILITY;
24832
+ var init_issues2 = __esm({
24576
24833
  "../shared/src/default-skills/replicas-agent/abilities/issues.ts"() {
24577
24834
  "use strict";
24835
+ init_issues();
24836
+ codeList = (values) => values.map((value) => `\`${value}\``).join(", ");
24578
24837
  SECTION7 = `### Issues
24579
24838
  Track work in Replicas Issues (\`REP-42\`), the shared to-do list of the people and agents in this organization, with \`replicas issue\`.
24580
24839
 
@@ -24609,7 +24868,7 @@ replicas issue unlink-pr REP-42 https://github.com/acme/app/pull/12
24609
24868
  replicas issue relate REP-42 blocks REP-43 | duplicate_of REP-40
24610
24869
  \`\`\`
24611
24870
 
24612
- Statuses: \`backlog\`, \`todo\`, \`in_progress\`, \`in_review\`, \`done\`, \`canceled\`, \`duplicate\`. Priorities: \`none\`, \`urgent\`, \`high\`, \`medium\`, \`low\`.
24871
+ Statuses: ${codeList(ISSUE_STATUSES)}. Priorities: ${codeList(ISSUE_PRIORITIES)}.
24613
24872
 
24614
24873
  ## Events
24615
24874
 
@@ -24625,13 +24884,14 @@ Read the event and act only when it asks something of you: a person's question o
24625
24884
 
24626
24885
  **Keep the status true as you go:**
24627
24886
  1. \`in_progress\` when you start.
24628
- 2. \`in_review\` when you open its pull request: link it with \`replicas issue link-pr\`, set the status yourself, and comment "Ready for review: <url>". Open one pull request per issue where you can. Nothing links or changes status on its own: \`Fixes REP-42\` in a pull request body is only documentation.
24629
- 3. \`done\` when its pull request merges and nothing is left: a linked pull request's merge arrives as an \`<issue_event>\`, and you set the status. \`canceled\` when it won't be done.
24630
-
24631
- **Statuses mean exactly this**, so a person can read only In review and trust the rest:
24632
- - \`in_progress\`: work is underway, including fixing CI, answering review comments, resolving conflicts, or waiting on another pull request.
24633
- - \`in_review\`: waiting only on a person. A linked pull request is open with CI green and needs someone's review or approval; assign that person. Nothing else is in flight. When CI fails or someone pushes changes, move it back to \`in_progress\`.
24634
- - \`done\`: every linked pull request it needs is merged (and deployed when that matters), and nothing is left. Set it yourself after the merge.
24887
+ 2. When you open a pull request for the issue, link it with \`replicas issue link-pr\` and comment "Ready for review: <url>". Link only pull requests that do this issue's work, one pull request per issue where you can. Nothing links on its own: \`Fixes REP-42\` in a pull request body is only documentation. Move the issue to \`review\` once it waits only on a person, and assign that person.
24888
+ 3. Linked pull requests then move the status: when every one is approved (merged counts), Replicas moves the issue to \`approved\`, and when every one is merged, to \`done\`. Pull requests closed without merging don't count. Each move arrives as an \`<issue_event>\` from Replicas. You still own the result: when it isn't really done (more work is left, or a deploy needs watching), move it back and say why.
24889
+
24890
+ **Statuses mean exactly this**, so a person can read only Review and trust the rest:
24891
+ - \`in_progress\`: work is underway: a check is failing, the pull request has conflicts, review comments need answering, work is missing, or it waits on another pull request.
24892
+ - \`review\`: waiting only on a person. A linked pull request is open with no conflicts and nothing failing (CI rerunning after a push is fine), and needs someone's review or approval; assign that person. Move it back to \`in_progress\` only for a conflict, a failing check or missing work, never just because something was pushed, so issues don't bounce.
24893
+ - \`approved\`: every linked pull request is approved, so nothing waits on a person; it just isn't merged or live yet.
24894
+ - \`done\`: every linked pull request it needs is merged (and deployed when that matters), and nothing is left.
24635
24895
  - \`canceled\`: dropped, with a comment saying why.
24636
24896
 
24637
24897
  Keep every property true at all times: status, assignee, linked pull requests (link only the pull requests that do this issue's work; unlink wrong ones with \`replicas issue unlink-pr\` or the app), and the description, when the plan changes. Before ending a turn, check that your issues' statuses match reality.
@@ -26461,7 +26721,7 @@ var init_registry = __esm({
26461
26721
  init_github2();
26462
26722
  init_gitlab();
26463
26723
  init_gpu();
26464
- init_issues();
26724
+ init_issues2();
26465
26725
  init_linear3();
26466
26726
  init_local_computer();
26467
26727
  init_macos();
@@ -27126,7 +27386,7 @@ var init_environment_config_source = __esm({
27126
27386
  });
27127
27387
 
27128
27388
  // ../shared/src/replicas-mcp.ts
27129
- var REPLICAS_MCP_TOOLS, automationToolInputSchema, credentialUserIdDescription, automationBackgroundSchema, automationCreateToolInputSchema, automationUpdateToolInputSchema, chatPath, provider, model, thinkingLevel, title, message, createChatToolInputSchema, forkChatToolInputSchema, renameChatToolInputSchema, runCommandToolInputSchema, environmentMcpPath, createEnvironmentMcpToolInputSchema, updateEnvironmentMcpToolInputSchema, createEnvironmentDeviceToolInputSchema, previewEnvironmentConfigSourceToolInputSchema, applyEnvironmentConfigSourceToolInputSchema;
27389
+ var REPLICAS_MCP_TOOLS, automationToolInputSchema, credentialUserIdDescription, automationBackgroundSchema, automationCreateToolInputSchema, automationUpdateToolInputSchema, chatPath, provider, model, thinkingLevel, title2, message, createChatToolInputSchema, forkChatToolInputSchema, renameChatToolInputSchema, runCommandToolInputSchema, environmentMcpPath, createEnvironmentMcpToolInputSchema, updateEnvironmentMcpToolInputSchema, createEnvironmentDeviceToolInputSchema, previewEnvironmentConfigSourceToolInputSchema, applyEnvironmentConfigSourceToolInputSchema;
27130
27390
  var init_replicas_mcp = __esm({
27131
27391
  "../shared/src/replicas-mcp.ts"() {
27132
27392
  "use strict";
@@ -27237,9 +27497,9 @@ var init_replicas_mcp = __esm({
27237
27497
  scope: external_exports.literal("org").optional().describe("`org` moves a personal automation to the organization so teammates can see and edit it. It cannot be moved back.")
27238
27498
  });
27239
27499
  chatPath = { id: external_exports.string().describe("Workspace ID"), chat_id: external_exports.string().describe("Chat ID") };
27240
- ({ provider, model, thinkingLevel, title, message } = forkChatRequestSchema.shape);
27500
+ ({ provider, model, thinkingLevel, title: title2, message } = forkChatRequestSchema.shape);
27241
27501
  createChatToolInputSchema = external_exports.object({ id: chatPath.id, provider, title: createChatRequestSchema.shape.title });
27242
- forkChatToolInputSchema = external_exports.object({ ...chatPath, provider, model, thinking_level: thinkingLevel, title, message });
27502
+ forkChatToolInputSchema = external_exports.object({ ...chatPath, provider, model, thinking_level: thinkingLevel, title: title2, message });
27243
27503
  renameChatToolInputSchema = external_exports.object({ ...chatPath, display_name: updateChatDisplayNameRequestSchema.shape.displayName });
27244
27504
  runCommandToolInputSchema = external_exports.object({ id: chatPath.id, ...workspaceExecRequestSchema.shape });
27245
27505
  environmentMcpPath = { environment_id: external_exports.string().describe("Environment ID") };
@@ -27493,7 +27753,7 @@ ${MERGE_RULE}
27493
27753
  ${chatRule("the board", "a finding that changes the answer, a ship you started, or a decision you need")}
27494
27754
  `;
27495
27755
  ISSUE_RULES = `- Your work lives in issues in your slice of the organization's Issues, which the Issues tab beside this chat shows the user. Before delegating, turn a request into issues with \`replicas issue create\`: one per independent task, so five small bugs are five issues, and a parent with sub-issues for a big project. Reuse an issue the request is about; find it with \`replicas issue list\`. A title says what the task is about, never a ship, branch or pull request name.
27496
- - Spawn ships with \`issue\`, and pass \`issue\` to \`${REPLICAS_MCP_TOOLS.messageSubagent}\` to point a ship at another one: it is assigned, subscribed and told. Several ships can share an issue. Replicas moves an issue to In progress when a ship starts it. Ships link their pull requests with \`replicas issue link-pr\`, move the issue to In review themselves, and comment their progress, so never restate what an issue shows. Nothing changes an issue's status when a pull request merges: when you hear a ship's pull request merged and the ship is asleep, link it if it isn't and move the issue to Done if that finishes it. Give a ship one issue per pull request where you can. Statuses mean exactly this: In progress, work underway (including fixing CI, review comments, conflicts, or waiting on another pull request); In review, waiting only on a person, with a linked pull request open, CI green, and the person who must review or approve it assigned, and nothing else in flight (move it back to In progress when CI fails or someone pushes changes); Done, every linked pull request it needs merged (and deployed when that matters) and nothing left; Canceled, dropped, with a comment saying why. Keep every property true at all times: status, assignee, linked pull requests (link only the pull requests that do this issue's work; unlink wrong ones with \`replicas issue unlink-pr\` or the app), and the description, when the plan changes. Before ending a turn, check that your issues' statuses match reality, including those of ships that are asleep. Order, reprioritize or cancel issues with \`replicas issue update\`.
27756
+ - Spawn ships with \`issue\`, and pass \`issue\` to \`${REPLICAS_MCP_TOOLS.messageSubagent}\` to point a ship at another one: it is assigned, subscribed and told. Several ships can share an issue. Replicas moves an issue to In progress when a ship starts it. Ships link their pull requests with \`replicas issue link-pr\`, move the issue to Review themselves, and comment their progress, so never restate what an issue shows. Linked pull requests then move the status: Replicas moves an issue to Approved when every linked pull request is approved, and to Done when every one is merged, and each move reaches you as an \`<issue_event>\`. Nothing links on its own, so when a ship is asleep, link its pull request yourself if it isn't linked, and move the issue back when a move isn't really true. Give a ship one issue per pull request where you can. Statuses mean exactly this: In progress, work underway (a failing check, conflicts, review comments to answer, missing work, or waiting on another pull request); Review, waiting only on a person, with a linked pull request open, no conflicts and nothing failing (CI rerunning after a push is fine), and the person who must review or approve it assigned (move it back to In progress only for a conflict, a failing check or missing work, never just because something was pushed, so issues don't bounce); Approved, every linked pull request approved but not yet merged or live; Done, every linked pull request it needs merged (and deployed when that matters) and nothing left; Canceled, dropped, with a comment saying why. Keep every property true at all times: status, assignee, linked pull requests (link only the pull requests that do this issue's work; unlink wrong ones with \`replicas issue unlink-pr\` or the app), and the description, when the plan changes. Before ending a turn, check that your issues' statuses match reality, including those of ships that are asleep. Order, reprioritize or cancel issues with \`replicas issue update\`.
27497
27757
  - You are subscribed to every issue in your slice: comments and changes by ships and people arrive as \`<issue_event>\` blocks. Act on them like ship events. Ships assigned to an issue get its comments too, so never relay a comment to them; pass it only to a ship that isn't on the issue.
27498
27758
  - Ask the user only for decisions you truly can't make. Make routine calls yourself, such as retries, small scope choices or test cleanup. For a decision or merge only they can give, assign them to the issue with \`replicas issue assign\` and comment the question with \`replicas issue comment\`; their reply comes back as an \`<issue_event>\`. Once they answer a question you asked, unassign them with \`replicas issue unassign\` so the issue leaves their "Assigned to you"; they stay subscribed. Ships ask and unassign for their own questions, so leave those to them.
27499
27759
  - A ship with open pull requests is not done when it sends \`finished\`: Replicas fixes their CI failures and review comments automatically, then sends \`ready\` or \`needs_attention\`. On \`needs_attention\`, direct the ship, or assign the user only if you can't decide. On \`ready\` for a pull request that needs a person's review, assign the user with a one-line comment.
@@ -27578,254 +27838,6 @@ var init_tag_blocks = __esm({
27578
27838
  }
27579
27839
  });
27580
27840
 
27581
- // ../shared/src/routes/issues.ts
27582
- var ISSUE_STATUSES, ISSUE_PRIORITIES, ISSUE_ACTOR_TYPES, ISSUE_SUBSCRIBER_ROLES, ISSUE_RELATION_TYPES, ISSUE_PULL_REQUEST_STATES, issueStatusSchema, issuePrioritySchema, issueSubscriberRoleSchema, issueRelationTypeSchema, issuePullRequestStateSchema, ISSUE_STATUS_LABELS, ISSUE_PRIORITY_LABELS, issueActorSchema, ISSUE_KEY_RE, timestamp, nullableTimestamp, issueSchema, issueSubscriberSchema, issueRelationSchema, issuePullRequestSchema, issueCommentSchema, change, nullableId, ISSUE_EVENT_TYPES, issueEventDataSchemas, issueEventBase, issueEventVariant, issueEventSchema, clientMutationId, title2, description, body, createIssueRequestSchema, updateIssueRequestSchema, issueActorRequestSchema, createIssueCommentRequestSchema, updateIssueCommentRequestSchema, createIssueRelationRequestSchema, linkIssuePullRequestRequestSchema, updateIssuePullRequestRequestSchema, issueMutationRequestSchema, updateIssueSettingsRequestSchema, listIssuesQuerySchema, issueDetailResponseSchema, listIssuesResponseSchema, issuesDeltaQuerySchema, issueInboxQuerySchema, markIssueInboxReadRequestSchema, ISSUE_COMMANDS;
27583
- var init_issues2 = __esm({
27584
- "../shared/src/routes/issues.ts"() {
27585
- "use strict";
27586
- init_zod();
27587
- ISSUE_STATUSES = ["backlog", "todo", "in_progress", "in_review", "done", "canceled", "duplicate"];
27588
- ISSUE_PRIORITIES = ["none", "urgent", "high", "medium", "low"];
27589
- ISSUE_ACTOR_TYPES = ["user", "workspace"];
27590
- ISSUE_SUBSCRIBER_ROLES = ["assignee", "creator", "mentioned", "manual"];
27591
- ISSUE_RELATION_TYPES = ["blocks", "duplicate_of"];
27592
- ISSUE_PULL_REQUEST_STATES = ["draft", "open", "merged", "closed"];
27593
- issueStatusSchema = external_exports.enum(ISSUE_STATUSES);
27594
- issuePrioritySchema = external_exports.enum(ISSUE_PRIORITIES);
27595
- issueSubscriberRoleSchema = external_exports.enum(ISSUE_SUBSCRIBER_ROLES);
27596
- issueRelationTypeSchema = external_exports.enum(ISSUE_RELATION_TYPES);
27597
- issuePullRequestStateSchema = external_exports.enum(ISSUE_PULL_REQUEST_STATES);
27598
- ISSUE_STATUS_LABELS = { backlog: "Backlog", todo: "Todo", in_progress: "In Progress", in_review: "In Review", done: "Done", canceled: "Canceled", duplicate: "Duplicate" };
27599
- ISSUE_PRIORITY_LABELS = { none: "No priority", urgent: "Urgent", high: "High", medium: "Medium", low: "Low" };
27600
- issueActorSchema = external_exports.object({
27601
- type: external_exports.enum(ISSUE_ACTOR_TYPES),
27602
- id: external_exports.string().toLowerCase().uuid()
27603
- });
27604
- ISSUE_KEY_RE = /^[A-Z][A-Z0-9]{0,9}$/;
27605
- timestamp = external_exports.string();
27606
- nullableTimestamp = timestamp.nullable();
27607
- issueSchema = external_exports.object({
27608
- id: external_exports.string().uuid(),
27609
- organization_id: external_exports.string().uuid(),
27610
- number: external_exports.number().int(),
27611
- identifier: external_exports.string(),
27612
- title: external_exports.string(),
27613
- description: external_exports.string(),
27614
- status: issueStatusSchema,
27615
- priority: issuePrioritySchema,
27616
- parent_id: external_exports.string().uuid().nullable(),
27617
- manager_id: external_exports.string().uuid().nullable(),
27618
- creator: issueActorSchema,
27619
- /** Fractional: to move an issue between two others, send the midpoint of their sort orders. */
27620
- sort_order: external_exports.number(),
27621
- created_at: timestamp,
27622
- updated_at: timestamp,
27623
- completed_at: nullableTimestamp,
27624
- canceled_at: nullableTimestamp,
27625
- archived_at: nullableTimestamp
27626
- });
27627
- issueSubscriberSchema = external_exports.object({
27628
- issue_id: external_exports.string().uuid(),
27629
- subscriber: issueActorSchema,
27630
- role: issueSubscriberRoleSchema,
27631
- created_at: timestamp
27632
- });
27633
- issueRelationSchema = external_exports.object({
27634
- id: external_exports.string().uuid(),
27635
- type: issueRelationTypeSchema,
27636
- issue_id: external_exports.string().uuid(),
27637
- related_issue_id: external_exports.string().uuid(),
27638
- created_at: timestamp
27639
- });
27640
- issuePullRequestSchema = external_exports.object({
27641
- id: external_exports.string().uuid(),
27642
- issue_id: external_exports.string().uuid(),
27643
- url: external_exports.string(),
27644
- pull_request_id: external_exports.string().uuid().nullable(),
27645
- title: external_exports.string().nullable(),
27646
- state: issuePullRequestStateSchema,
27647
- created_at: timestamp,
27648
- updated_at: timestamp
27649
- });
27650
- issueCommentSchema = external_exports.object({
27651
- id: external_exports.string().uuid(),
27652
- issue_id: external_exports.string().uuid(),
27653
- author: issueActorSchema,
27654
- body: external_exports.string(),
27655
- created_at: timestamp,
27656
- updated_at: timestamp
27657
- });
27658
- change = (value) => external_exports.object({ from: value, to: value });
27659
- nullableId = external_exports.string().uuid().nullable();
27660
- ISSUE_EVENT_TYPES = [
27661
- "created",
27662
- "title_changed",
27663
- "description_changed",
27664
- "status_changed",
27665
- "priority_changed",
27666
- "parent_changed",
27667
- "manager_changed",
27668
- "sort_order_changed",
27669
- "assignee_added",
27670
- "assignee_removed",
27671
- "subscriber_added",
27672
- "subscriber_removed",
27673
- "relation_added",
27674
- "relation_removed",
27675
- "pr_linked",
27676
- "pr_unlinked",
27677
- "pr_state_changed",
27678
- "comment_added",
27679
- "comment_edited",
27680
- "comment_deleted",
27681
- "archived",
27682
- "restored"
27683
- ];
27684
- issueEventDataSchemas = {
27685
- created: external_exports.object({ issue: issueSchema }),
27686
- title_changed: change(external_exports.string()),
27687
- description_changed: change(external_exports.string()),
27688
- status_changed: change(issueStatusSchema).extend({ completed_at: nullableTimestamp, canceled_at: nullableTimestamp }),
27689
- priority_changed: change(issuePrioritySchema),
27690
- parent_changed: change(nullableId),
27691
- manager_changed: change(nullableId),
27692
- sort_order_changed: change(external_exports.number()),
27693
- /** `subscriber` is the row after the change: an unassigned principal stays subscribed with role `manual`. */
27694
- assignee_added: external_exports.object({ subscriber: issueSubscriberSchema }),
27695
- assignee_removed: external_exports.object({ subscriber: issueSubscriberSchema }),
27696
- subscriber_added: external_exports.object({ subscriber: issueSubscriberSchema }),
27697
- subscriber_removed: external_exports.object({ subscriber: issueSubscriberSchema }),
27698
- relation_added: external_exports.object({ relation: issueRelationSchema }),
27699
- relation_removed: external_exports.object({ relation: issueRelationSchema }),
27700
- pr_linked: external_exports.object({ pull_request: issuePullRequestSchema }),
27701
- pr_unlinked: external_exports.object({ pull_request: issuePullRequestSchema }),
27702
- pr_state_changed: external_exports.object({ pull_request: issuePullRequestSchema, from: issuePullRequestStateSchema }),
27703
- comment_added: external_exports.object({ comment: issueCommentSchema }),
27704
- comment_edited: external_exports.object({ comment: issueCommentSchema, from: external_exports.string() }),
27705
- comment_deleted: external_exports.object({ comment: issueCommentSchema }),
27706
- archived: external_exports.object({ archived_at: timestamp }),
27707
- restored: external_exports.object({
27708
- issue: issueSchema,
27709
- subscribers: external_exports.array(issueSubscriberSchema),
27710
- relations: external_exports.array(issueRelationSchema),
27711
- pull_requests: external_exports.array(issuePullRequestSchema)
27712
- })
27713
- };
27714
- issueEventBase = external_exports.object({
27715
- sync_id: external_exports.number().int(),
27716
- issue_id: external_exports.string().uuid(),
27717
- actor: issueActorSchema,
27718
- /** Echo of the `client_mutation_id` sent with the write, so the writer can settle its optimistic change. */
27719
- client_mutation_id: external_exports.string().nullable(),
27720
- created_at: timestamp
27721
- });
27722
- issueEventVariant = (type) => issueEventBase.extend({ type: external_exports.literal(type), data: issueEventDataSchemas[type] });
27723
- issueEventSchema = external_exports.discriminatedUnion("type", [issueEventVariant(ISSUE_EVENT_TYPES[0]), ...ISSUE_EVENT_TYPES.slice(1).map(issueEventVariant)]);
27724
- clientMutationId = external_exports.string().min(1).max(128).optional();
27725
- title2 = external_exports.string().trim().min(1).max(500);
27726
- description = external_exports.string().max(1e5);
27727
- body = external_exports.string().trim().min(1).max(1e5);
27728
- createIssueRequestSchema = external_exports.object({
27729
- /** Client-generated id, so an optimistic create can be referenced before the server answers. */
27730
- id: external_exports.string().uuid().optional(),
27731
- title: title2,
27732
- description: description.optional(),
27733
- status: issueStatusSchema.optional(),
27734
- priority: issuePrioritySchema.optional(),
27735
- parent_id: external_exports.string().uuid().optional(),
27736
- manager_id: external_exports.string().uuid().optional(),
27737
- sort_order: external_exports.number().finite().optional(),
27738
- assignees: external_exports.array(issueActorSchema).max(20).optional(),
27739
- subscribers: external_exports.array(issueActorSchema).max(50).optional(),
27740
- client_mutation_id: clientMutationId
27741
- });
27742
- updateIssueRequestSchema = external_exports.object({
27743
- title: title2.optional(),
27744
- description: description.optional(),
27745
- status: issueStatusSchema.optional(),
27746
- priority: issuePrioritySchema.optional(),
27747
- // PATCH semantics: null clears the parent or Manager, omitting it leaves it unchanged.
27748
- parent_id: nullableId.optional(),
27749
- manager_id: nullableId.optional(),
27750
- sort_order: external_exports.number().finite().optional(),
27751
- client_mutation_id: clientMutationId
27752
- });
27753
- issueActorRequestSchema = issueActorSchema.partial().extend({ client_mutation_id: clientMutationId });
27754
- createIssueCommentRequestSchema = external_exports.object({
27755
- id: external_exports.string().uuid().optional(),
27756
- body,
27757
- client_mutation_id: clientMutationId
27758
- });
27759
- updateIssueCommentRequestSchema = external_exports.object({ body, client_mutation_id: clientMutationId });
27760
- createIssueRelationRequestSchema = external_exports.object({
27761
- id: external_exports.string().uuid().optional(),
27762
- type: issueRelationTypeSchema,
27763
- related_issue: external_exports.string().min(1),
27764
- client_mutation_id: clientMutationId
27765
- });
27766
- linkIssuePullRequestRequestSchema = external_exports.object({
27767
- id: external_exports.string().uuid().optional(),
27768
- url: external_exports.string().url().max(2e3),
27769
- title: external_exports.string().max(500).optional(),
27770
- state: issuePullRequestStateSchema.optional(),
27771
- pull_request_id: external_exports.string().uuid().optional(),
27772
- client_mutation_id: clientMutationId
27773
- });
27774
- updateIssuePullRequestRequestSchema = external_exports.object({
27775
- state: issuePullRequestStateSchema,
27776
- client_mutation_id: clientMutationId
27777
- });
27778
- issueMutationRequestSchema = external_exports.object({ client_mutation_id: clientMutationId });
27779
- updateIssueSettingsRequestSchema = external_exports.object({ issue_key: external_exports.string().trim().toUpperCase().regex(ISSUE_KEY_RE) });
27780
- listIssuesQuerySchema = external_exports.object({
27781
- status: external_exports.string().optional(),
27782
- priority: external_exports.string().optional(),
27783
- assignee: external_exports.string().optional(),
27784
- subscriber: external_exports.string().optional(),
27785
- creator: external_exports.string().optional(),
27786
- manager_id: external_exports.string().optional(),
27787
- parent_id: external_exports.string().optional(),
27788
- q: external_exports.string().max(200).optional(),
27789
- include_archived: external_exports.enum(["true", "false"]).optional(),
27790
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
27791
- cursor: external_exports.coerce.number().int().min(0).max(2147483647).optional()
27792
- });
27793
- issueDetailResponseSchema = external_exports.object({
27794
- issue: issueSchema,
27795
- subscribers: external_exports.array(issueSubscriberSchema),
27796
- relations: external_exports.array(issueRelationSchema),
27797
- pull_requests: external_exports.array(issuePullRequestSchema),
27798
- comments: external_exports.array(issueCommentSchema),
27799
- events: external_exports.array(issueEventSchema),
27800
- sub_issues: external_exports.array(issueSchema)
27801
- });
27802
- listIssuesResponseSchema = external_exports.object({ issues: external_exports.array(issueSchema), next_cursor: external_exports.number().nullable() });
27803
- issuesDeltaQuerySchema = external_exports.object({
27804
- after: external_exports.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
27805
- limit: external_exports.coerce.number().int().min(1).max(1e3).optional()
27806
- });
27807
- issueInboxQuerySchema = external_exports.object({
27808
- limit: external_exports.coerce.number().int().min(1).max(100).optional(),
27809
- before: external_exports.coerce.number().int().min(1).optional()
27810
- });
27811
- markIssueInboxReadRequestSchema = external_exports.object({ sync_id: external_exports.number().int().min(0).optional() });
27812
- ISSUE_COMMANDS = {
27813
- create: "create",
27814
- update: "update",
27815
- get: "get",
27816
- list: "list",
27817
- comment: "comment",
27818
- assign: "assign",
27819
- unassign: "unassign",
27820
- subscribe: "subscribe",
27821
- unsubscribe: "unsubscribe",
27822
- linkPr: "link-pr",
27823
- unlinkPr: "unlink-pr",
27824
- relate: "relate"
27825
- };
27826
- }
27827
- });
27828
-
27829
27841
  // ../shared/src/issue-events.ts
27830
27842
  function parseChange(line, excerpt) {
27831
27843
  const match = line.match(CHANGE_LINE);
@@ -27863,7 +27875,7 @@ var init_issue_events = __esm({
27863
27875
  "../shared/src/issue-events.ts"() {
27864
27876
  "use strict";
27865
27877
  init_zod();
27866
- init_issues2();
27878
+ init_issues();
27867
27879
  init_tag_blocks();
27868
27880
  ISSUE_EVENT_TAG = "issue_event";
27869
27881
  transitionSchema = external_exports.discriminatedUnion("field", [
@@ -40170,7 +40182,7 @@ var CLI_VERSION;
40170
40182
  var init_cli_version = __esm({
40171
40183
  "../shared/src/cli-version.ts"() {
40172
40184
  "use strict";
40173
- CLI_VERSION = "0.3.512";
40185
+ CLI_VERSION = "0.3.514";
40174
40186
  }
40175
40187
  });
40176
40188
 
@@ -51268,7 +51280,7 @@ var init_src = __esm({
51268
51280
  init_automations();
51269
51281
  init_egress2();
51270
51282
  init_feature_flags();
51271
- init_issues2();
51283
+ init_issues();
51272
51284
  init_repo_files();
51273
51285
  init_replica();
51274
51286
  init_admin();
@@ -51434,8 +51446,8 @@ var init_monolith_url = __esm({
51434
51446
 
51435
51447
  // src/lib/authenticated-api.ts
51436
51448
  async function throwResponseError(response) {
51437
- const error62 = await response.json().catch(() => ({ error: "Request failed" }));
51438
- throw new ApiError(error62.error || `Request failed with status ${response.status}`, response.status);
51449
+ const { error: error62 } = await readApiErrorBody(response);
51450
+ throw new ApiError(error62 || `Request failed with status ${response.status}`, response.status);
51439
51451
  }
51440
51452
  async function apiFetch(url2, headers, options) {
51441
51453
  const requestHeaders = new Headers({ "Content-Type": "application/json", ...headers });
@@ -56236,8 +56248,8 @@ async function agentRequest(path12, options) {
56236
56248
  ...isStream ? { duplex: "half" } : {}
56237
56249
  });
56238
56250
  if (!response.ok) {
56239
- const error62 = await response.json().catch(() => ({ error: "Request failed" }));
56240
- throw new AgentRequestError(error62.error || `Request failed with status ${response.status}`, response.status);
56251
+ const { error: error62 } = await readApiErrorBody(response);
56252
+ throw new AgentRequestError(error62 || `Request failed with status ${response.status}`, response.status);
56241
56253
  }
56242
56254
  return response;
56243
56255
  }
@@ -56257,8 +56269,8 @@ async function engineFetch(path12, options) {
56257
56269
  body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0
56258
56270
  });
56259
56271
  if (!response.ok) {
56260
- const error62 = await response.json().catch(() => ({ error: "Request failed" }));
56261
- throw new Error(error62.error || `Request failed with status ${response.status}`);
56272
+ const { error: error62 } = await readApiErrorBody(response);
56273
+ throw new Error(error62 || `Request failed with status ${response.status}`);
56262
56274
  }
56263
56275
  return response.json();
56264
56276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.512",
3
+ "version": "0.3.514",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {