@usepowerplant/cli 0.4.35 → 0.4.37

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/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79afb1aa-8532-5f74-8d71-d00555a824ee")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f3583555-81c7-58e0-9c03-15ec7068280a")}catch(e){}}();
3
3
  import { createRequire as __cliCreateRequire } from 'node:module';
4
4
  const require = __cliCreateRequire(import.meta.url);
5
5
  var __create = Object.create;
@@ -56967,6 +56967,96 @@ function encodeRawTranscriptBundle(bundle) {
56967
56967
  return Buffer.concat([prefix, header, bundle.main, ...bundle.parts.map((entry) => entry.body)]);
56968
56968
  }
56969
56969
 
56970
+ // ../core/src/pricingWords.ts
56971
+ var NOT_RECORDED = "not_recorded";
56972
+ var ANTHROPIC_FAST_MODE = {
56973
+ kind: "vendor",
56974
+ url: "https://platform.claude.com/docs/en/build-with-claude/fast-mode",
56975
+ checked_on: "2026-10-22",
56976
+ quote: 'When a request with `speed: "fast"` succeeds, `usage.speed` is `"fast"`.',
56977
+ dated_by: "The beta header the page names, fast-mode-2026-02-01. The page gives no launch date, so this date is inferred."
56978
+ };
56979
+ var ANTHROPIC_SERVICE_TIERS = {
56980
+ kind: "vendor",
56981
+ url: "https://platform.claude.com/docs/en/api/service-tiers",
56982
+ checked_on: "2026-10-22",
56983
+ quote: "The response includes the service tier assigned."
56984
+ };
56985
+ var ANTHROPIC_DATA_RESIDENCY = {
56986
+ kind: "vendor",
56987
+ url: "https://platform.claude.com/docs/en/manage-claude/data-residency",
56988
+ checked_on: "2026-10-22",
56989
+ quote: '"global" (default) and "us"'
56990
+ };
56991
+ var CLAUDE_CODE_NO_REGION_SEEN = { not_available: { from: "2026-06-30", until: "2026-10-09" }, "": { from: "2026-04-17", until: "2026-05-09" } };
56992
+ var claudeCodeNoRegion = (word) => {
56993
+ const seen = CLAUDE_CODE_NO_REGION_SEEN[word];
56994
+ return {
56995
+ kind: "observed",
56996
+ checked_on: "2026-10-22",
56997
+ what: `Claude Code wrote ${JSON.stringify(word)} from ${seen.from} to ${seen.until} (staging); no Anthropic document names it.`,
56998
+ last_observed: seen.until
56999
+ };
57000
+ };
57001
+ var OPENAI_FAST_MODE = {
57002
+ kind: "vendor",
57003
+ url: "https://developers.openai.com/api/docs/guides/fast-mode.md",
57004
+ checked_on: "2026-10-22",
57005
+ quote: 'Priority processing was renamed Fast mode on July 30, 2026. You can use either service_tier: "priority" or service_tier: "fast".'
57006
+ };
57007
+ var OPENAI_GLOBAL = { kind: "observed", checked_on: "2026-10-22", what: "Kept from the table before meanings were dated; no OpenAI document names a region word.", last_observed: null };
57008
+ var CURSOR_MODELS = { kind: "vendor", url: "https://cursor.com/docs/models-and-pricing", checked_on: "2026-10-22", quote: "Fast mode is available at 2x pricing" };
57009
+ var always = (means, source, assumes = null) => [{ means, from: null, until: null, source, assumes }];
57010
+ var fromDate = (from, means, source, assumes = null) => [{ means, from, until: null, source, assumes }];
57011
+ var PROVIDER_WORDS = {
57012
+ anthropic: {
57013
+ // Fast mode began with its beta (fast-mode-2026-02-01), so a Fast record from before it is not what the word means; standard always held.
57014
+ speed: { standard: always("standard", ANTHROPIC_FAST_MODE), fast: fromDate("2026-02-01T00:00:00Z", "fast", ANTHROPIC_FAST_MODE) },
57015
+ // Anthropic's service tier is its priority queue, not Fast mode; usage.speed records Fast.
57016
+ service_tier: { standard: always(null, ANTHROPIC_SERVICE_TIERS) },
57017
+ inference_geo: {
57018
+ global: always("global", ANTHROPIC_DATA_RESIDENCY),
57019
+ us: always("us", ANTHROPIC_DATA_RESIDENCY),
57020
+ // Jenn, 2026-10-22: no until date; the price-word alert reports either word after its last observed date.
57021
+ not_available: always(NOT_RECORDED, claudeCodeNoRegion("not_available")),
57022
+ "": always(NOT_RECORDED, claudeCodeNoRegion(""))
57023
+ }
57024
+ },
57025
+ openai: {
57026
+ speed: {},
57027
+ service_tier: {
57028
+ default: always("standard", OPENAI_FAST_MODE),
57029
+ priority: always("fast", OPENAI_FAST_MODE, "openai.requested-tier-served"),
57030
+ fast: fromDate("2026-07-30T00:00:00Z", "fast", OPENAI_FAST_MODE, "openai.requested-tier-served")
57031
+ },
57032
+ inference_geo: { global: always("global", OPENAI_GLOBAL) }
57033
+ },
57034
+ cursor: {
57035
+ speed: { standard: always("standard", CURSOR_MODELS), fast: always("fast", CURSOR_MODELS) },
57036
+ service_tier: {},
57037
+ inference_geo: {}
57038
+ }
57039
+ };
57040
+ var holdsAt = ({ from, until }, at) => at === null ? from === null && until === null : (from === null || at >= Date.parse(from)) && (until === null || at < Date.parse(until));
57041
+ function readWord(table, word, at) {
57042
+ if (typeof word !== "string" || !Object.hasOwn(table, word)) return { kind: "unlisted" };
57043
+ const meanings = table[word];
57044
+ const time3 = at === null || Number.isNaN(Date.parse(at)) ? null : Date.parse(at);
57045
+ const meaning = meanings.find((candidate) => holdsAt(candidate, time3));
57046
+ if (meaning) return { kind: "meaning", means: meaning.means, assumes: meaning.assumes, last_observed: meaning.source.kind === "observed" ? meaning.source.last_observed : null };
57047
+ const [first, ...rest] = meanings.map(({ from, until }) => ({ from, until }));
57048
+ return { kind: "outside_dates", holds: [first, ...rest] };
57049
+ }
57050
+ var meaningAt = (table, word, at) => {
57051
+ const reading = readWord(table, word, at);
57052
+ return reading.kind === "meaning" ? reading.means : void 0;
57053
+ };
57054
+
57055
+ // ../core/src/priceWords.ts
57056
+ var CLAUDE = PROVIDER_WORDS.anthropic;
57057
+ var claudeCodeSpeed = (value, at) => meaningAt(CLAUDE.speed, value, at);
57058
+ var DAY_MS = 24 * 60 * 60 * 1e3;
57059
+
56970
57060
  // ../core/src/encodedImages.ts
56971
57061
  var BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
56972
57062
  function isEncodedImage(data, mediaType) {
@@ -57733,27 +57823,6 @@ function isRecord(value) {
57733
57823
  return value !== null && typeof value === "object" && !Array.isArray(value);
57734
57824
  }
57735
57825
 
57736
- // ../core/src/pricingWords.ts
57737
- var PROVIDER_WORDS = {
57738
- anthropic: {
57739
- speed: { standard: "standard", fast: "fast" },
57740
- // Anthropic's service tier is its priority queue, not Fast mode; usage.speed records Fast.
57741
- service_tier: { standard: null },
57742
- inference_geo: { global: "global", us: "us" }
57743
- },
57744
- openai: {
57745
- speed: {},
57746
- service_tier: { default: "standard", priority: "fast", fast: "fast" },
57747
- inference_geo: { global: "global" }
57748
- },
57749
- cursor: {
57750
- speed: { standard: "standard", fast: "fast" },
57751
- service_tier: {},
57752
- inference_geo: {}
57753
- }
57754
- };
57755
- var wordFor = (words, value) => typeof value === "string" && Object.hasOwn(words, value) ? words[value] : void 0;
57756
-
57757
57826
  // ../core/src/codexResponseUsage.ts
57758
57827
  var count2 = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
57759
57828
  function readTotals(value) {
@@ -57780,8 +57849,8 @@ function stepFrom(previous, total) {
57780
57849
  outputTokens: total.outputTokens - previous.outputTokens
57781
57850
  };
57782
57851
  }
57783
- function codexServiceTier(value) {
57784
- return wordFor(PROVIDER_WORDS.openai.service_tier, value);
57852
+ function codexServiceTier(value, at) {
57853
+ return meaningAt(PROVIDER_WORDS.openai.service_tier, value, at) ?? void 0;
57785
57854
  }
57786
57855
  function createCodexUsageReader(options = {}) {
57787
57856
  const keepEntries = options.keepEntries ?? true;
@@ -57796,20 +57865,23 @@ function createCodexUsageReader(options = {}) {
57796
57865
  };
57797
57866
  let turnId = null;
57798
57867
  let model = null;
57799
- let tier = "unknown";
57800
57868
  let nativeTier = null;
57869
+ let tierWord = void 0;
57870
+ const tierAt = (at) => tierWord === void 0 ? "unknown" : codexServiceTier(tierWord, at) ?? "unknown";
57801
57871
  let recordSeenOnPage = false;
57802
57872
  let previousTotal = null;
57803
57873
  let onFirstPage = true;
57804
57874
  let counted = 0;
57805
57875
  const responseIds = /* @__PURE__ */ new Set();
57806
57876
  const push = (at, responseId, counts, turnTotal, threadTotal) => {
57877
+ const serviceTier = tierAt(at);
57878
+ if (tierWord !== void 0 && at !== null) summary.speedMode = serviceTier;
57807
57879
  const entry = {
57808
57880
  responseId,
57809
57881
  turnId,
57810
57882
  at,
57811
57883
  model,
57812
- serviceTier: tier,
57884
+ serviceTier,
57813
57885
  nativeServiceTier: nativeTier,
57814
57886
  counts,
57815
57887
  turnTotal,
@@ -57819,7 +57891,7 @@ function createCodexUsageReader(options = {}) {
57819
57891
  if (keepEntries) summary.entries.push(entry);
57820
57892
  options.onEntry?.(entry);
57821
57893
  };
57822
- const noteUncounted = (runningTotal, own2) => {
57894
+ const noteUncounted = (at, runningTotal, own2) => {
57823
57895
  if (runningTotal === null || !onFirstPage || counted > 0) return;
57824
57896
  const gap = {
57825
57897
  inputTokens: Math.max(0, runningTotal.inputTokens - own2.inputTokens),
@@ -57828,7 +57900,7 @@ function createCodexUsageReader(options = {}) {
57828
57900
  outputTokens: Math.max(0, runningTotal.outputTokens - own2.outputTokens)
57829
57901
  };
57830
57902
  if (gap.inputTokens === 0 && gap.outputTokens === 0) return;
57831
- summary.uncounted.push({ counts: gap, serviceTier: tier, nativeServiceTier: nativeTier });
57903
+ summary.uncounted.push({ counts: gap, serviceTier: tierAt(at), nativeServiceTier: nativeTier });
57832
57904
  };
57833
57905
  const startPage = () => {
57834
57906
  recordSeenOnPage = false;
@@ -57866,7 +57938,7 @@ function createCodexUsageReader(options = {}) {
57866
57938
  }
57867
57939
  if (responseId !== null) responseIds.add(responseId);
57868
57940
  const threadTotal = readTotals(payload.thread_token_usage);
57869
- if (firstRecordOnPage && previousTotal === null) noteUncounted(threadTotal, counts);
57941
+ if (firstRecordOnPage && previousTotal === null) noteUncounted(at, threadTotal, counts);
57870
57942
  if (typeof payload.turn_id === "string" && payload.turn_id !== "") turnId = payload.turn_id;
57871
57943
  push(at, responseId, counts, readTotals(payload.turn_token_usage), threadTotal);
57872
57944
  return;
@@ -57875,9 +57947,9 @@ function createCodexUsageReader(options = {}) {
57875
57947
  if (payload.type === "thread_settings_applied") {
57876
57948
  const settings = isRecord(payload.thread_settings) ? payload.thread_settings : null;
57877
57949
  if (settings !== null && settings.service_tier !== void 0) {
57878
- tier = codexServiceTier(settings.service_tier) ?? "unknown";
57950
+ tierWord = settings.service_tier;
57879
57951
  nativeTier = typeof settings.service_tier === "string" ? settings.service_tier : null;
57880
- summary.speedMode = tier;
57952
+ summary.speedMode = tierAt(at);
57881
57953
  }
57882
57954
  return;
57883
57955
  }
@@ -57904,7 +57976,7 @@ function createCodexUsageReader(options = {}) {
57904
57976
  return;
57905
57977
  }
57906
57978
  const last = readTotals(payload.info.last_token_usage) ?? stepFrom(previous, total);
57907
- if (previous === null) noteUncounted(total, last);
57979
+ if (previous === null) noteUncounted(at, total, last);
57908
57980
  push(at, null, last, null, total);
57909
57981
  },
57910
57982
  finish() {
@@ -57933,10 +58005,6 @@ function codexPageTotals(read) {
57933
58005
  return { ...totals, fast: tierKnown ? fast : null };
57934
58006
  }
57935
58007
 
57936
- // ../core/src/priceWords.ts
57937
- var CLAUDE = PROVIDER_WORDS.anthropic;
57938
- var claudeCodeSpeed = (value) => wordFor(CLAUDE.speed, value);
57939
-
57940
58008
  // ../core/src/sessionViews.ts
57941
58009
  function describeSessionSource(source) {
57942
58010
  switch (source) {
@@ -85344,7 +85412,7 @@ function _init2(options = {}, getDefaultIntegrationsImpl) {
85344
85412
  import tls2 from "node:tls";
85345
85413
  var import_undici = __toESM(require_undici(), 1);
85346
85414
  var CLI_VERSION_HEADER = "x-powerplant-cli-version";
85347
- var cliVersion = true ? "0.4.35" : "0.0.0-checkout";
85415
+ var cliVersion = true ? "0.4.37" : "0.0.0-checkout";
85348
85416
  function cliVersionHeaders() {
85349
85417
  return { [CLI_VERSION_HEADER]: cliVersion, "user-agent": `powerplant-cli/${cliVersion}` };
85350
85418
  }
@@ -85512,7 +85580,8 @@ function initCollectorReporting(appEnv, release2, command) {
85512
85580
  // there is no telling a stale daemon's bug from a current one.
85513
85581
  release: release2,
85514
85582
  transport: fetchTransport,
85515
- sendDefaultPii: false,
85583
+ // Omitted dataCollection preserves Sentry 10's restrictive defaults.
85584
+ // An empty object enables sensitive collection.
85516
85585
  beforeSend: (event) => scrubSentryEvent(event),
85517
85586
  beforeBreadcrumb: (breadcrumb) => scrubBreadcrumb(breadcrumb)
85518
85587
  });
@@ -87442,7 +87511,7 @@ async function collectCodexSessions(options = {}) {
87442
87511
  return rank;
87443
87512
  };
87444
87513
  const ranks = new Map([...candidates.values()].map((candidate) => [candidate, rankOf(candidate)]));
87445
- const ordered = [...candidates.values()].sort((a, b2) => ranks.get(b2) - ranks.get(a));
87514
+ const ordered = [...candidates.values()].filter((candidate) => candidate.cwd === void 0 || !options.alreadySynced?.(candidate.cwd, ranks.get(candidate))).sort((a, b2) => ranks.get(b2) - ranks.get(a));
87446
87515
  const chosen = options.maxSessions === void 0 ? ordered : ordered.slice(0, options.maxSessions);
87447
87516
  for (const candidate of ordered.slice(chosen.length)) countReviewersLeftBehind(candidate.thread.threadId);
87448
87517
  const threadNames = chosen.length > 0 ? loadThreadNames(sessionsDir) : /* @__PURE__ */ new Map();
@@ -88265,6 +88334,7 @@ function collectFromStore(db, userDir, options, result, knownIds) {
88265
88334
  countCaptureSkip(result, decision.reason);
88266
88335
  continue;
88267
88336
  }
88337
+ if (cwd !== void 0 && options.alreadySynced?.(cwd, lastUpdatedAt)) continue;
88268
88338
  if (options.locationsOnly) {
88269
88339
  result.sessions.push({
88270
88340
  mtimeMs: lastUpdatedAt,
@@ -88918,7 +88988,7 @@ var LIFECYCLE_JOURNAL_DIRNAME = "lifecycle-journal";
88918
88988
  var LIFECYCLE_JOURNAL_RETENTION_DAYS = 7;
88919
88989
  var LEGACY_LIFECYCLE_JOURNAL_FILENAME = "session-lifecycle.jsonl";
88920
88990
  var DAY_FILE = /^(\d{4}-\d{2}-\d{2})\.jsonl$/;
88921
- var DAY_MS = 24 * 60 * 60 * 1e3;
88991
+ var DAY_MS2 = 24 * 60 * 60 * 1e3;
88922
88992
  function lifecycleJournalDir(home) {
88923
88993
  return path9.join(home, ".config", "powerplant", LIFECYCLE_JOURNAL_DIRNAME);
88924
88994
  }
@@ -88960,7 +89030,7 @@ var legacyEntrySchema = external_exports.object({
88960
89030
  }));
88961
89031
  function lifecycleJournalRetentionFloorMs(nowMs) {
88962
89032
  const day = new Date(nowMs);
88963
- return Date.UTC(day.getUTCFullYear(), day.getUTCMonth(), day.getUTCDate()) - LIFECYCLE_JOURNAL_RETENTION_DAYS * DAY_MS;
89033
+ return Date.UTC(day.getUTCFullYear(), day.getUTCMonth(), day.getUTCDate()) - LIFECYCLE_JOURNAL_RETENTION_DAYS * DAY_MS2;
88964
89034
  }
88965
89035
  function dayFiles(dir) {
88966
89036
  try {
@@ -94060,7 +94130,15 @@ var storedCredentialsSchema = external_exports.object({
94060
94130
  repoDiscoveryBlockedRoots: external_exports.array(external_exports.string()).optional(),
94061
94131
  /** When this enrollment's deep first sync completed; absent = still owed,
94062
94132
  * so the next sync sweeps DEEP_FIRST_SYNC_DAYS instead of the rolling window. */
94063
- deepSyncedAt: external_exports.string().optional()
94133
+ deepSyncedAt: external_exports.string().optional(),
94134
+ /** The capture boundary whose history is uploaded (historyBoundary.ts):
94135
+ * written by each completed deep sweep, and narrowed with the boundary.
94136
+ * Absent with deepSyncedAt set = recorded before this field existed; the
94137
+ * next complete pass records the current boundary. */
94138
+ historyBoundary: external_exports.object({
94139
+ claims: external_exports.array(external_exports.object({ owners: external_exports.array(external_exports.string()), repos: external_exports.array(external_exports.string()).nullable() })),
94140
+ folders: external_exports.array(external_exports.string())
94141
+ }).optional()
94064
94142
  });
94065
94143
  var InvalidStoredCredentialsError = class extends ExpectedCliError {
94066
94144
  };
@@ -94583,7 +94661,7 @@ function parseClaudeCodeTranscript(text) {
94583
94661
  const previousMessage = usageByMessage.get(id);
94584
94662
  const isNewMessage = previousMessage === void 0;
94585
94663
  const speedValue = message3.usage?.speed;
94586
- const observedSpeed = claudeCodeSpeed(speedValue);
94664
+ const observedSpeed = claudeCodeSpeed(speedValue, typeof record2.timestamp === "string" ? record2.timestamp : null);
94587
94665
  const messageSpeed = observedSpeed ?? previousMessage?.speedMode;
94588
94666
  if (speedValue !== void 0) speedMode = observedSpeed ?? "unknown";
94589
94667
  if (message3.usage) {
@@ -94721,6 +94799,7 @@ async function collectClaudeCodeSessions(options = {}) {
94721
94799
  try {
94722
94800
  const cwd = transcriptCwd(transcriptPath);
94723
94801
  const decision = captureDecision(cwd, capture2);
94802
+ if (decision.capture && cwd !== void 0 && options.alreadySynced?.(cwd, mtimeMs)) continue;
94724
94803
  let admission;
94725
94804
  if (decision.capture) {
94726
94805
  admission = { kind: "decided", decision };
@@ -94730,6 +94809,7 @@ async function collectClaudeCodeSessions(options = {}) {
94730
94809
  countCaptureSkip(skips, decision.reason);
94731
94810
  continue;
94732
94811
  }
94812
+ if (options.alreadySyncedRepo && folder.synced.every((child) => options.alreadySyncedRepo(child.repoFullName, mtimeMs))) continue;
94733
94813
  admission = { kind: "parent-folder", folder };
94734
94814
  }
94735
94815
  if (decision.capture && options.locationsOnly) {
@@ -95828,7 +95908,7 @@ import path41 from "node:path";
95828
95908
  var STEADY_SYNC_WINDOW_DAYS = 3;
95829
95909
  var DEEP_FIRST_SYNC_DAYS = 90;
95830
95910
  var DEEP_FIRST_SYNC_MAX_SESSIONS = 100;
95831
- function resolveSyncWindow(explicitSince, deepSyncedAt) {
95911
+ function resolveSyncWindow(explicitSince, deepSweepOwed) {
95832
95912
  if (explicitSince !== void 0) {
95833
95913
  const days = Number(explicitSince);
95834
95914
  if (!Number.isFinite(days) || days <= 0) {
@@ -95836,17 +95916,17 @@ function resolveSyncWindow(explicitSince, deepSyncedAt) {
95836
95916
  }
95837
95917
  return { days, deepSweep: false };
95838
95918
  }
95839
- if (deepSyncedAt === void 0) return { days: DEEP_FIRST_SYNC_DAYS, deepSweep: true };
95919
+ if (deepSweepOwed) return { days: DEEP_FIRST_SYNC_DAYS, deepSweep: true };
95840
95920
  return { days: STEADY_SYNC_WINDOW_DAYS, deepSweep: false };
95841
95921
  }
95842
- var DAY_MS2 = 24 * 60 * 60 * 1e3;
95922
+ var DAY_MS3 = 24 * 60 * 60 * 1e3;
95843
95923
  function resolveScanFloor(window2, nowMs, narrowSinceMs) {
95844
- if (window2.deepSweep || narrowSinceMs === void 0) return nowMs - window2.days * DAY_MS2;
95924
+ if (window2.deepSweep || narrowSinceMs === void 0) return nowMs - window2.days * DAY_MS3;
95845
95925
  return narrowSinceMs;
95846
95926
  }
95847
95927
  function rawShipFloorMs(appEnv, nowMs, explicitSince) {
95848
95928
  if (appEnv !== "development" || explicitSince !== void 0) return null;
95849
- return nowMs - STEADY_SYNC_WINDOW_DAYS * DAY_MS2;
95929
+ return nowMs - STEADY_SYNC_WINDOW_DAYS * DAY_MS3;
95850
95930
  }
95851
95931
  function describeScanReach(window2, narrowSinceMs) {
95852
95932
  if (window2.deepSweep || narrowSinceMs === void 0) {
@@ -97460,10 +97540,39 @@ function supervisorFiles(appEnv, service, background) {
97460
97540
  };
97461
97541
  }
97462
97542
 
97543
+ // ../../apps/syncservice/src/historyBoundary.ts
97544
+ function historyBoundaryOf(capture2) {
97545
+ if (capture2.mode === "scope") return { claims: [], folders: capture2.scopePaths };
97546
+ const claims = capture2.workspaceClaims ?? [{ owners: capture2.allowedOwners, repos: capture2.allowedRepos }];
97547
+ return { claims: claims.map(({ owners, repos }) => ({ owners, repos })), folders: capture2.memberFolders };
97548
+ }
97549
+ function historyBoundaryWidens(next, synced) {
97550
+ const syncedFolders = new Set(synced.folders.map((folder) => folderKey(folder)));
97551
+ if (next.folders.some((folder) => !syncedFolders.has(folderKey(folder)))) return true;
97552
+ return next.claims.some(
97553
+ (claim2) => claim2.repos !== null ? claim2.repos.some((repo) => !synced.claims.some((old) => workspaceClaimsRepo(repo, old))) : claim2.owners.some((owner) => !synced.claims.some((old) => old.repos === null && old.owners.includes(owner)))
97554
+ );
97555
+ }
97556
+ function historyBoundaryAdmits(boundary, cwd, capture2) {
97557
+ if (boundary.folders.length > 0 && isWithinScope(cwd, boundary.folders, capture2.environment)) return true;
97558
+ if (boundary.claims.length === 0) return false;
97559
+ const repo = capture2.repoOf(cwd);
97560
+ return repo !== null && historyBoundaryClaimsRepo(boundary, repo);
97561
+ }
97562
+ function historyBoundaryClaimsRepo(boundary, repoFullName) {
97563
+ return boundary.claims.some((claim2) => workspaceClaimsRepo(repoFullName, claim2));
97564
+ }
97565
+
97463
97566
  // ../../apps/syncservice/src/syncCoverage.ts
97464
97567
  function createSyncCoverage(appEnv, options, credentials, capture2) {
97465
97568
  const now = Date.now();
97466
- const configuredWindow = resolveSyncWindow(options.explicitSince, credentials.deepSyncedAt);
97569
+ const boundary = historyBoundaryOf(capture2);
97570
+ const synced = credentials.deepSyncedAt === void 0 ? void 0 : credentials.historyBoundary;
97571
+ const backfillFrom = synced !== void 0 && historyBoundaryWidens(boundary, synced) ? synced : void 0;
97572
+ const configuredWindow = resolveSyncWindow(
97573
+ options.explicitSince,
97574
+ credentials.deepSyncedAt === void 0 || backfillFrom !== void 0
97575
+ );
97467
97576
  const requestedSinceMs = options.live ? options.narrowSinceMs ?? resolveScanFloor(configuredWindow, now) : resolveScanFloor(configuredWindow, now, options.narrowSinceMs);
97468
97577
  const recovery = !options.dryRun && !options.isNewSession ? options.recovery?.beginPass({
97469
97578
  credentials,
@@ -97477,9 +97586,16 @@ function createSyncCoverage(appEnv, options, credentials, capture2) {
97477
97586
  const rawShipped = recovery?.rawShipped;
97478
97587
  const sinceMs = recovery?.sinceMs ?? requestedSinceMs;
97479
97588
  const window2 = { ...configuredWindow, deepSweep: recovery?.deepSweep ?? (configuredWindow.deepSweep && !options.live) };
97589
+ const historyFloorMs = Math.min(now - STEADY_SYNC_WINDOW_DAYS * 24 * 60 * 60 * 1e3, options.narrowSinceMs ?? Infinity);
97590
+ const backfill = window2.deepSweep ? backfillFrom : void 0;
97591
+ const alreadySynced = backfill && ((cwd, mtimeMs) => mtimeMs < historyFloorMs && historyBoundaryAdmits(backfill, cwd, capture2));
97592
+ const alreadySyncedRepo = backfill && ((repoFullName, mtimeMs) => mtimeMs < historyFloorMs && historyBoundaryClaimsRepo(backfill, repoFullName));
97480
97593
  return {
97481
97594
  sinceMs,
97482
97595
  window: window2,
97596
+ boundary,
97597
+ alreadySynced,
97598
+ alreadySyncedRepo,
97483
97599
  rawShipped,
97484
97600
  canUpload: recovery?.isCurrent,
97485
97601
  onMemoChanged: recovery?.memoChanged,
@@ -97763,10 +97879,10 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97763
97879
  const capture2 = await resolveCapturePolicy(config2, credentials, log3, defaultPolicyDeps, options);
97764
97880
  diagnostic.claimsUnresolved = capture2.mode === "org-repos" && capture2.claimsUnresolved === true;
97765
97881
  const coverage = createSyncCoverage(config2.appEnv, options, credentials, capture2);
97766
- const { sinceMs, rawShipped, window: window2 } = coverage;
97882
+ const { sinceMs, rawShipped, window: window2, alreadySynced, alreadySyncedRepo } = coverage;
97767
97883
  if (window2.deepSweep) {
97768
97884
  log3(
97769
- `First sync for this enrollment, sweeping the last ${window2.days} days and backfilling up to the ${DEEP_FIRST_SYNC_MAX_SESSIONS} most recently active sessions already on this machine (later syncs cover ${STEADY_SYNC_WINDOW_DAYS} days).`
97885
+ (alreadySynced ? `The sync rule now admits more repos or folders, sweeping the last ${window2.days} days and backfilling up to the ${DEEP_FIRST_SYNC_MAX_SESSIONS} most recently active sessions it newly admits ` : `First sync for this enrollment, sweeping the last ${window2.days} days and backfilling up to the ${DEEP_FIRST_SYNC_MAX_SESSIONS} most recently active sessions already on this machine `) + `(later syncs cover ${STEADY_SYNC_WINDOW_DAYS} days).`
97770
97886
  );
97771
97887
  }
97772
97888
  diagnostic.sinceMs = sinceMs;
@@ -97778,6 +97894,8 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97778
97894
  sinceMs,
97779
97895
  capture: capture2,
97780
97896
  maxSessions,
97897
+ alreadySynced,
97898
+ alreadySyncedRepo,
97781
97899
  lifecycle: options.lifecycleJournal?.read(),
97782
97900
  onFileDiagnostic: files.observe("claude-code")
97783
97901
  });
@@ -97793,6 +97911,7 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97793
97911
  sinceMs,
97794
97912
  capture: capture2,
97795
97913
  maxSessions,
97914
+ alreadySynced,
97796
97915
  ...options.codexThreadLinks && { threadLinks: options.codexThreadLinks },
97797
97916
  ...options.codexThreadReads && { threadReads: options.codexThreadReads },
97798
97917
  onFileDiagnostic: files.observe("codex")
@@ -97808,6 +97927,7 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97808
97927
  const cursor = await collectCursorSessions({
97809
97928
  sinceMs,
97810
97929
  capture: capture2,
97930
+ alreadySynced,
97811
97931
  onStructureDiagnostic: structure.observe("cursor")
97812
97932
  });
97813
97933
  diagnostic.cursorUnavailable = cursor.unavailable !== null;
@@ -97838,7 +97958,7 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97838
97958
  `Found ${inWindow.length} local session(s) (${claude.sessions.length} claude, ${codex.sessions.length} codex, ${cursor.sessions.length} cursor) ` + describeScanReach(window2, options.narrowSinceMs) + (active > 0 ? ` (${active} still active)` : "") + (skippedOutOfScope > 0 ? ` \xB7 ${skippedOutOfScope} ${describeSkipReason(capture2)}` : "") + (skippedNoRepo > 0 ? ` \xB7 ${skippedNoRepo} ${describeNoRepoSkipReason(capture2)}` : "") + (codex.skippedSubagentThreads > 0 ? ` \xB7 ${codex.skippedSubagentThreads} codex subagent thread(s) skipped (spend unmeasured)` : "") + (cursor.skippedSubagentComposers > 0 ? ` \xB7 ${cursor.skippedSubagentComposers} cursor subagent thread(s) skipped` : "") + (cursor.skippedNonLocalComposers > 0 ? ` \xB7 ${cursor.skippedNonLocalComposers} cursor session(s) skipped (not local to this machine)` : "") + (cursor.skippedUnreadable > 0 ? ` \xB7 ${cursor.skippedUnreadable} cursor session(s) unreadable, skipped` : "") + tooLarge(claude.skippedTooLarge, "claude transcript(s)") + (claude.unreadable.length > 0 ? ` \xB7 ${claude.unreadable.length} claude transcript(s) unreadable, skipped` : "") + tooLarge(codex.skippedTooLarge, "codex rollout(s)") + (codex.unreadable.length > 0 ? ` \xB7 ${codex.unreadable.length} codex rollout(s) unreadable, skipped` : "") + // The measure for POW-79's follow-up: a merged thread re-uploads whole
97839
97959
  // on every change, so once the largest nears the cap, per-page upload
97840
97960
  // is due.
97841
- (codex.mergedThreads > 0 ? ` \xB7 ${codex.mergedThreads} codex thread(s) merged from split rollouts (largest ${(codex.largestMergedBytes / (1024 * 1024)).toFixed(1)}MB of the ${MAX_TRANSCRIPT_FILE_BYTES / (1024 * 1024)}MB cap)` : "") + tooLarge(cursor.skippedTooLarge, "cursor transcript(s)") + (cursor.truncatedTranscripts > 0 ? ` \xB7 ${cursor.truncatedTranscripts} cursor transcript(s) cut at ${MAX_TRANSCRIPT_FILE_BYTES / (1024 * 1024)}MB (the rest of the conversation stays local)` : "") + (cursor.partiallyInterpreted > 0 ? ` \xB7 ${cursor.partiallyInterpreted} cursor transcript(s) uploaded with records this build does not interpret or the store did not provide (kept where possible, reported in diagnostics)` : "") + (heldBack > 0 ? ` \xB7 ${heldBack} older session(s) held back, the first sync backfills the ${DEEP_FIRST_SYNC_MAX_SESSIONS} most recently active` : "") + "."
97961
+ (codex.mergedThreads > 0 ? ` \xB7 ${codex.mergedThreads} codex thread(s) merged from split rollouts (largest ${(codex.largestMergedBytes / (1024 * 1024)).toFixed(1)}MB of the ${MAX_TRANSCRIPT_FILE_BYTES / (1024 * 1024)}MB cap)` : "") + tooLarge(cursor.skippedTooLarge, "cursor transcript(s)") + (cursor.truncatedTranscripts > 0 ? ` \xB7 ${cursor.truncatedTranscripts} cursor transcript(s) cut at ${MAX_TRANSCRIPT_FILE_BYTES / (1024 * 1024)}MB (the rest of the conversation stays local)` : "") + (cursor.partiallyInterpreted > 0 ? ` \xB7 ${cursor.partiallyInterpreted} cursor transcript(s) uploaded with records this build does not interpret or the store did not provide (kept where possible, reported in diagnostics)` : "") + (heldBack > 0 ? ` \xB7 ${heldBack} older session(s) held back, ${alreadySynced ? "a backfill uploads" : "the first sync backfills"} the ${DEEP_FIRST_SYNC_MAX_SESSIONS} most recently active` : "") + "."
97842
97962
  );
97843
97963
  for (const failure2 of claude.unreadable) log3(` claude transcript skipped, ${failure2}`);
97844
97964
  for (const failure2 of codex.unreadable) log3(` codex rollout skipped, ${failure2}`);
@@ -97850,21 +97970,24 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97850
97970
  log3("Dry run, nothing uploaded.");
97851
97971
  return { sessions: collected, upserted: 0 };
97852
97972
  }
97853
- const markDeepSynced = () => {
97854
- if (!window2.deepSweep) return;
97973
+ const recordSyncedHistory = () => {
97974
+ const synced = credentials.historyBoundary;
97975
+ const narrowed = credentials.deepSyncedAt !== void 0 && (synced === void 0 || !historyBoundaryWidens(coverage.boundary, synced) && historyBoundaryWidens(synced, coverage.boundary));
97976
+ const stamp = window2.deepSweep ? { deepSyncedAt: (/* @__PURE__ */ new Date()).toISOString(), historyBoundary: coverage.boundary } : narrowed ? { historyBoundary: coverage.boundary } : null;
97977
+ if (stamp === null) return;
97855
97978
  const current = loadCredentials(config2.appEnv);
97856
97979
  if (current === null) {
97857
- log3("Deep sync finished, but this machine's credentials are gone, nothing to stamp.");
97980
+ if (window2.deepSweep) log3("Deep sync finished, but this machine's credentials are gone, nothing to stamp.");
97858
97981
  return;
97859
97982
  }
97860
97983
  if (current.token !== credentials.token || current.enrolledAt !== credentials.enrolledAt) {
97861
- log3(
97862
- "Deep sync finished for a superseded enrollment, the current enrollment still owes its own deep sweep."
97863
- );
97984
+ if (window2.deepSweep) {
97985
+ log3("Deep sync finished for a superseded enrollment, the current enrollment still owes its own deep sweep.");
97986
+ }
97864
97987
  return;
97865
97988
  }
97866
- saveCredentials(config2.appEnv, { ...current, deepSyncedAt: (/* @__PURE__ */ new Date()).toISOString() });
97867
- log3(`Deep sync complete, future syncs cover the last ${STEADY_SYNC_WINDOW_DAYS} days.`);
97989
+ saveCredentials(config2.appEnv, { ...current, ...stamp });
97990
+ if (window2.deepSweep) log3(`Deep sync complete, future syncs cover the last ${STEADY_SYNC_WINDOW_DAYS} days.`);
97868
97991
  };
97869
97992
  const collectedCompletely = coverage.complete(diagnostic);
97870
97993
  if (items.length === 0) {
@@ -97873,7 +97996,7 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97873
97996
  log3("Deep sync not stamped, a workspace's claims are unresolved; the sweep re-runs next pass.");
97874
97997
  }
97875
97998
  } else if (collectedCompletely) {
97876
- markDeepSynced();
97999
+ recordSyncedHistory();
97877
98000
  }
97878
98001
  return { sessions: collected, upserted: 0, coverage: coverage.summary(collectedCompletely) };
97879
98002
  }
@@ -97993,7 +98116,7 @@ async function runSyncPassInternal(config2, options, diagnostic, turn) {
97993
98116
  }
97994
98117
  }
97995
98118
  const complete = coverage.complete(diagnostic, raw, rawEligible);
97996
- if (complete) markDeepSynced();
98119
+ if (complete) recordSyncedHistory();
97997
98120
  return { sessions: collected, upserted, coverage: coverage.summary(complete) };
97998
98121
  }
97999
98122
  async function runSyncPass(config2, options = {}) {
@@ -100668,7 +100791,10 @@ function syncHeader(i) {
100668
100791
  var AGENT_TITLE_MAX = 48;
100669
100792
  function recentAgentItems(i) {
100670
100793
  if (i.memberSessions === null) return null;
100671
- const recent = i.memberSessions.filter((session) => i.now - Date.parse(session.lastActivityAt) < RECENT_SESSION_WINDOW_MS).filter((session) => session.archived !== true && session.subagent !== true && session.standaloneReview !== true).sort((a, b2) => Date.parse(b2.lastActivityAt) - Date.parse(a.lastActivityAt)).map((session) => agentRow(session, i)).filter((row) => row.agent?.status !== "ended").sort((a, b2) => Number(b2.agent?.status === "working") - Number(a.agent?.status === "working"));
100794
+ const recent = i.memberSessions.filter((session) => i.now - Date.parse(session.lastActivityAt) < RECENT_SESSION_WINDOW_MS).filter((session) => session.archived !== true && session.subagent !== true && session.standaloneReview !== true).sort((a, b2) => Date.parse(b2.lastActivityAt) - Date.parse(a.lastActivityAt)).map((session) => ({
100795
+ row: agentRow(session, i),
100796
+ localMachine: i.credentials !== null && session.machineId === i.credentials.machineId
100797
+ })).filter(({ row }) => row.agent?.status !== "ended").sort((a, b2) => Number(b2.row.agent?.status === "working") - Number(a.row.agent?.status === "working"));
100672
100798
  const rows = recent.length === 0 ? [{ type: "status", mark: "muted", title: i.memberSessionsIncomplete ? "No sessions found in the partial list" : "No eligible sessions in the latest results" }] : groupedAgentRows(recent.slice(0, RECENT_SESSION_VISIBLE_LIMIT), i.platform);
100673
100799
  if (i.memberSessionsIncomplete) rows.push({
100674
100800
  type: "status",
@@ -100684,10 +100810,13 @@ function recentAgentItems(i) {
100684
100810
  });
100685
100811
  return rows;
100686
100812
  }
100687
- function groupedAgentRows(rows, platform2) {
100688
- const openable2 = rows.filter((row) => row.agent?.harness !== void 0);
100689
- const unavailable = rows.filter((row) => row.agent?.harness === void 0);
100690
- return [...openable2, ...unavailable.length > 0 ? [{ type: "section", title: `Not on this ${platform2 === "darwin" ? "Mac" : "PC"}` }, ...unavailable] : []];
100813
+ function groupedAgentRows(sessions, platform2) {
100814
+ const available = [];
100815
+ const elsewhere = [];
100816
+ for (const { row, localMachine } of sessions) {
100817
+ (localMachine || row.agent?.harness !== void 0 ? available : elsewhere).push(row);
100818
+ }
100819
+ return [...available, ...elsewhere.length > 0 ? [{ type: "section", title: `Not on this ${platform2 === "darwin" ? "Mac" : "PC"}` }, ...elsewhere] : []];
100691
100820
  }
100692
100821
  function agentRow(session, i) {
100693
100822
  const name = session.title ?? session.repoDir ?? "Untitled session";
@@ -103320,7 +103449,7 @@ function runResumeSession(source, sessionId, deps = {}) {
103320
103449
  }
103321
103450
 
103322
103451
  // src/version.ts
103323
- var CLI_VERSION = true ? "0.4.35" : "0.0.0-checkout";
103452
+ var CLI_VERSION = true ? "0.4.37" : "0.0.0-checkout";
103324
103453
  var CLI_RELEASE_BUILD = true ? true : false;
103325
103454
  var CLI_DEVELOPMENT_COPY = false;
103326
103455
  function updateRefusal(tarball, developmentCopy = CLI_DEVELOPMENT_COPY) {
@@ -105205,20 +105334,24 @@ async function wakeMenus() {
105205
105334
  }
105206
105335
  }
105207
105336
  async function runCommand() {
105208
- await main();
105209
- if (!process.exitCode) await shellPathOffer?.();
105210
- }
105211
- runCommand().catch(async (error63) => {
105212
- if (error63 instanceof ExpectedCliError) {
105213
- printExpectedError(error63, process.stderr, process.env);
105214
- } else {
105215
- console.error(error63);
105337
+ try {
105338
+ await main();
105339
+ if (!process.exitCode) await shellPathOffer?.();
105340
+ } catch (error63) {
105341
+ if (error63 instanceof ExpectedCliError) {
105342
+ printExpectedError(error63, process.stderr, process.env);
105343
+ } else {
105344
+ console.error(error63);
105345
+ }
105346
+ if (process.env.POWERPLANT_NATIVE_DIAGNOSTICS === "1") console.error(nativeFailureRecord(error63));
105347
+ reportCollectorError(error63, `powerplant-cli-${cliCommand}`);
105348
+ await flushReporting();
105349
+ process.exitCode = 1;
105350
+ } finally {
105351
+ await wakeMenus();
105216
105352
  }
105217
- if (process.env.POWERPLANT_NATIVE_DIAGNOSTICS === "1") console.error(nativeFailureRecord(error63));
105218
- reportCollectorError(error63, `powerplant-cli-${cliCommand}`);
105219
- await flushReporting();
105220
- process.exitCode = 1;
105221
- }).finally(wakeMenus);
105353
+ }
105354
+ void runCommand();
105222
105355
  /*! Bundled license information:
105223
105356
 
105224
105357
  undici/lib/web/fetch/body.js:
@@ -105228,4 +105361,4 @@ undici/lib/web/websocket/frame.js:
105228
105361
  (*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> *)
105229
105362
  */
105230
105363
 
105231
- //# debugId=79afb1aa-8532-5f74-8d71-d00555a824ee
105364
+ //# debugId=f3583555-81c7-58e0-9c03-15ec7068280a
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usepowerplant/cli",
3
- "version": "0.4.35",
3
+ "version": "0.4.37",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },