@remixhq/core 0.1.8 → 0.1.9

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/collab.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  reserveAvailableDirPath,
5
5
  reserveDirectory,
6
6
  writeCollabBinding
7
- } from "./chunk-FAZUMWBS.js";
7
+ } from "./chunk-GEHSFPCD.js";
8
8
  import {
9
9
  assertRepoSnapshotUnchanged,
10
10
  buildRepoFingerprint,
@@ -25,10 +25,12 @@ import {
25
25
  getGitCommonDir,
26
26
  getHeadCommitHash,
27
27
  getRemoteOriginUrl,
28
+ getWorkspaceDiff,
28
29
  getWorkspaceSnapshot,
29
30
  getWorktreeStatus,
30
31
  hardResetToCommit,
31
32
  importGitBundle,
33
+ listUntrackedFiles,
32
34
  normalizeGitRemote,
33
35
  preserveWorkspaceChanges,
34
36
  reapplyPreservedWorkspaceChanges,
@@ -36,7 +38,7 @@ import {
36
38
  summarizeUnifiedDiff,
37
39
  validateUnifiedDiff,
38
40
  writeTempUnifiedDiffBackup
39
- } from "./chunk-RREREIGW.js";
41
+ } from "./chunk-J3J4PBQ7.js";
40
42
  import {
41
43
  REMIX_ERROR_CODES
42
44
  } from "./chunk-GC2MOT3U.js";
@@ -91,6 +93,26 @@ function unwrapResponseObject(resp, label) {
91
93
  }
92
94
  return obj;
93
95
  }
96
+ var DEFAULT_PAGINATION_LIMIT = 25;
97
+ var MAX_PAGINATION_LIMIT = 50;
98
+ function normalizePagination(params) {
99
+ const rawLimit = typeof params?.limit === "number" && Number.isFinite(params.limit) ? Math.trunc(params.limit) : DEFAULT_PAGINATION_LIMIT;
100
+ const rawOffset = typeof params?.offset === "number" && Number.isFinite(params.offset) ? Math.trunc(params.offset) : 0;
101
+ return {
102
+ limit: Math.max(1, Math.min(MAX_PAGINATION_LIMIT, rawLimit)),
103
+ offset: Math.max(0, rawOffset)
104
+ };
105
+ }
106
+ function paginateOverfetchedItems(items, params) {
107
+ const pagination = normalizePagination(params);
108
+ return {
109
+ items: items.slice(0, pagination.limit),
110
+ pagination: {
111
+ ...pagination,
112
+ hasMore: items.length > pagination.limit
113
+ }
114
+ };
115
+ }
94
116
  function unwrapMergeRequest(resp) {
95
117
  return unwrapResponseObject(resp, "merge request");
96
118
  }
@@ -1054,6 +1076,7 @@ async function collabAdd(params) {
1054
1076
  }
1055
1077
  const { backupPath } = await writeTempUnifiedDiffBackup(diff, "remix-add");
1056
1078
  try {
1079
+ await pollAppReady(params.api, binding.currentAppId);
1057
1080
  if (submissionSnapshot) {
1058
1081
  await assertRepoSnapshotUnchanged(repoRoot, submissionSnapshot, {
1059
1082
  operation: "`remix collab add` auto-sync",
@@ -1201,6 +1224,107 @@ async function collabRecordTurn(params) {
1201
1224
  return unwrapResponseObject(resp, "collab turn");
1202
1225
  }
1203
1226
 
1227
+ // src/application/collab/collabFinalizeTurn.ts
1228
+ function collectWarnings(value) {
1229
+ if (!Array.isArray(value)) return [];
1230
+ return value.filter((entry) => typeof entry === "string" && entry.trim().length > 0);
1231
+ }
1232
+ async function collabFinalizeTurn(params) {
1233
+ const repoRoot = await findGitRoot(params.cwd);
1234
+ const binding = await readCollabBinding(repoRoot);
1235
+ if (!binding) {
1236
+ throw new RemixError("Repository is not bound to Remix.", {
1237
+ exitCode: 2,
1238
+ hint: "Run `remix collab init` first."
1239
+ });
1240
+ }
1241
+ const prompt = params.prompt.trim();
1242
+ const assistantResponse = params.assistantResponse.trim();
1243
+ if (!prompt) throw new RemixError("Prompt is required.", { exitCode: 2 });
1244
+ if (!assistantResponse) throw new RemixError("Assistant response is required.", { exitCode: 2 });
1245
+ const diffSource = params.diffSource ?? (params.diff ? "external" : "worktree");
1246
+ const externalDiff = params.diff?.trim() ?? "";
1247
+ const workspaceDiff = diffSource === "worktree" ? await getWorkspaceDiff(repoRoot) : null;
1248
+ const hasChangedTurn = diffSource === "external" ? externalDiff.length > 0 : Boolean(workspaceDiff?.diff.trim());
1249
+ const currentHeadCommitHash = await getHeadCommitHash(repoRoot);
1250
+ const idempotencyKey = params.idempotencyKey?.trim() || buildDeterministicIdempotencyKey({
1251
+ kind: "collab_finalize_turn_v1",
1252
+ appId: binding.currentAppId,
1253
+ upstreamAppId: binding.upstreamAppId,
1254
+ headCommitHash: currentHeadCommitHash,
1255
+ modeHint: hasChangedTurn ? "changed_turn" : "no_diff_turn",
1256
+ prompt,
1257
+ assistantResponse,
1258
+ externalDiff: diffSource === "external" ? externalDiff : null
1259
+ });
1260
+ if (diffSource === "external" && !hasChangedTurn) {
1261
+ throw new RemixError("External diff is empty.", {
1262
+ exitCode: 2,
1263
+ hint: "Pass a non-empty diff when using external diff submission, or omit the external diff so finalize-turn can inspect the live worktree."
1264
+ });
1265
+ }
1266
+ if (hasChangedTurn) {
1267
+ const localHeadBefore = currentHeadCommitHash;
1268
+ const capturedUntrackedPathsCandidate = diffSource === "worktree" ? await listUntrackedFiles(repoRoot) : [];
1269
+ const changeStep = await collabAdd({
1270
+ api: params.api,
1271
+ cwd: repoRoot,
1272
+ prompt,
1273
+ assistantResponse,
1274
+ diff: diffSource === "external" ? externalDiff : null,
1275
+ diffSource,
1276
+ sync: params.sync,
1277
+ allowBranchMismatch: params.allowBranchMismatch,
1278
+ idempotencyKey,
1279
+ actor: params.actor
1280
+ });
1281
+ const localHeadAfter = await getHeadCommitHash(repoRoot);
1282
+ const warnings = [
1283
+ ...collectWarnings(changeStep.warnings),
1284
+ ...diffSource === "external" && params.sync !== false ? [
1285
+ "Automatic local discard+sync was skipped because the diff came from an external source and may not match the current worktree."
1286
+ ] : []
1287
+ ];
1288
+ const autoSyncRequested = params.sync !== false;
1289
+ const autoSyncEligible = diffSource === "worktree";
1290
+ return {
1291
+ mode: "changed_turn",
1292
+ idempotencyKey,
1293
+ changeStep,
1294
+ collabTurn: null,
1295
+ autoSync: {
1296
+ requested: autoSyncRequested,
1297
+ eligible: autoSyncEligible,
1298
+ attempted: autoSyncRequested && autoSyncEligible,
1299
+ applied: autoSyncRequested && autoSyncEligible,
1300
+ trackedChangesDiscarded: autoSyncRequested && autoSyncEligible,
1301
+ capturedUntrackedPathsCandidate,
1302
+ localHeadBefore,
1303
+ localHeadAfter,
1304
+ localRepoMutated: autoSyncRequested && autoSyncEligible && localHeadBefore !== localHeadAfter
1305
+ },
1306
+ warnings
1307
+ };
1308
+ }
1309
+ const collabTurn = await collabRecordTurn({
1310
+ api: params.api,
1311
+ cwd: repoRoot,
1312
+ prompt,
1313
+ assistantResponse,
1314
+ allowBranchMismatch: params.allowBranchMismatch,
1315
+ idempotencyKey,
1316
+ actor: params.actor
1317
+ });
1318
+ return {
1319
+ mode: "no_diff_turn",
1320
+ idempotencyKey,
1321
+ changeStep: null,
1322
+ collabTurn,
1323
+ autoSync: null,
1324
+ warnings: []
1325
+ };
1326
+ }
1327
+
1204
1328
  // src/application/collab/collabApprove.ts
1205
1329
  async function collabApprove(params) {
1206
1330
  if (params.mode === "sync-target-repo") {
@@ -1468,17 +1592,22 @@ async function collabListMergeRequests(params) {
1468
1592
  appId: params.appId,
1469
1593
  queue: params.queue
1470
1594
  });
1595
+ const pageRequest = normalizePagination(params);
1471
1596
  const resp = await params.api.listMergeRequests({
1472
1597
  queue: params.queue,
1473
1598
  appId,
1474
1599
  status: params.status,
1475
- kind: params.kind ?? "merge"
1600
+ kind: params.kind ?? "merge",
1601
+ limit: pageRequest.limit + 1,
1602
+ offset: pageRequest.offset
1476
1603
  });
1477
1604
  const mergeRequests = unwrapResponseObject(resp, "merge requests");
1605
+ const page = paginateOverfetchedItems(mergeRequests, params);
1478
1606
  return {
1479
1607
  queue: params.queue,
1480
1608
  appId: appId ?? null,
1481
- mergeRequests
1609
+ mergeRequests: page.items,
1610
+ pagination: page.pagination
1482
1611
  };
1483
1612
  }
1484
1613
 
@@ -1521,12 +1650,24 @@ async function collabListMembers(params) {
1521
1650
  scope: params.scope,
1522
1651
  targetId: params.targetId
1523
1652
  });
1524
- const resp = params.scope === "organization" ? await params.api.listOrganizationMembers(targetId) : params.scope === "project" ? await params.api.listProjectMembers(targetId) : await params.api.listAppMembers(targetId);
1653
+ const pageRequest = normalizePagination(params);
1654
+ const resp = params.scope === "organization" ? await params.api.listOrganizationMembers(targetId, {
1655
+ limit: pageRequest.limit + 1,
1656
+ offset: pageRequest.offset
1657
+ }) : params.scope === "project" ? await params.api.listProjectMembers(targetId, {
1658
+ limit: pageRequest.limit + 1,
1659
+ offset: pageRequest.offset
1660
+ }) : await params.api.listAppMembers(targetId, {
1661
+ limit: pageRequest.limit + 1,
1662
+ offset: pageRequest.offset
1663
+ });
1525
1664
  const members = params.scope === "organization" ? unwrapResponseObject(resp, "members") : params.scope === "project" ? unwrapResponseObject(resp, "members") : unwrapResponseObject(resp, "members");
1665
+ const page = paginateOverfetchedItems(members, params);
1526
1666
  return {
1527
1667
  scopeType: params.scope,
1528
1668
  targetId,
1529
- members
1669
+ members: page.items,
1670
+ pagination: page.pagination
1530
1671
  };
1531
1672
  }
1532
1673
  async function collabUpdateMemberRole(params) {
@@ -1739,9 +1880,18 @@ async function collabInvite(params) {
1739
1880
 
1740
1881
  // src/application/collab/collabList.ts
1741
1882
  async function collabList(params) {
1742
- const resp = await params.api.listApps({ forked: "all" });
1883
+ const pageRequest = normalizePagination(params);
1884
+ const resp = await params.api.listApps({
1885
+ forked: params.forked ?? "all",
1886
+ limit: pageRequest.limit + 1,
1887
+ offset: pageRequest.offset
1888
+ });
1743
1889
  const apps = unwrapResponseObject(resp, "apps");
1744
- return { apps };
1890
+ const page = paginateOverfetchedItems(apps, params);
1891
+ return {
1892
+ apps: page.items,
1893
+ pagination: page.pagination
1894
+ };
1745
1895
  }
1746
1896
 
1747
1897
  // src/application/collab/collabReconcile.ts
@@ -2315,6 +2465,7 @@ export {
2315
2465
  collabAdd,
2316
2466
  collabApprove,
2317
2467
  collabCheckout,
2468
+ collabFinalizeTurn,
2318
2469
  collabInit,
2319
2470
  collabInvite,
2320
2471
  collabList,
package/dist/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export { CliError, REMIX_ERROR_CODES, CliError as RemixError, RemixErrorCode } f
2
2
  export { CoreConfig, ResolveConfigOptions, configSchema, resolveConfig } from './config.js';
3
3
  export { S as SessionStore, a as StoredSession, c as createStoredSessionTokenProvider, s as shouldRefreshSoon, b as storedSessionSchema } from './tokenProvider-BWTusyj4.js';
4
4
  export { createLocalSessionStore, createSupabaseAuthHelpers } from './auth.js';
5
- export { AgentMemoryItem, AgentMemoryKind, AgentMemorySearchItem, AgentMemorySearchResponse, AgentMemorySummary, AgentMemoryTimelineResponse, ApiClient, AppReconcileResponse, Bundle, BundlePlatform, BundleStatus, ChangeStepDiffResponse, InitiateBundleRequest, MergeRequest, MergeRequestReview, MergeRequestStatus, ReconcilePreflightResponse, SyncLocalResponse, SyncUpstreamResponse, createApiClient } from './api.js';
5
+ export { AgentMemoryItem, AgentMemoryKind, AgentMemorySearchItem, AgentMemorySearchResponse, AgentMemorySummary, AgentMemoryTimelineResponse, ApiClient, AppContext, AppContextAccessPath, AppReconcileResponse, Bundle, BundlePlatform, BundleStatus, ChangeStepDiffResponse, InitiateBundleRequest, InvitationRecord, MergeRequest, MergeRequestReview, MergeRequestStatus, ReconcilePreflightResponse, SyncLocalResponse, SyncUpstreamResponse, createApiClient } from './api.js';
6
6
  import 'zod';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createApiClient
3
- } from "./chunk-4276ARDF.js";
3
+ } from "./chunk-XC2FV57P.js";
4
4
  import {
5
5
  createLocalSessionStore,
6
6
  createStoredSessionTokenProvider,
package/dist/repo.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  requireCurrentBranch,
28
28
  summarizeUnifiedDiff,
29
29
  writeTempUnifiedDiffBackup
30
- } from "./chunk-RREREIGW.js";
30
+ } from "./chunk-J3J4PBQ7.js";
31
31
  import "./chunk-GC2MOT3U.js";
32
32
  import "./chunk-YZ34ICNN.js";
33
33
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remixhq/core",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Remix core library",
5
5
  "homepage": "https://github.com/RemixDotOne/remix-core",
6
6
  "license": "MIT",