@use-aistack/cli 0.16.6 → 0.16.8

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/README.md CHANGED
@@ -31,7 +31,9 @@ npx @use-aistack/cli sync --verbose
31
31
  AISTACK_DEBUG=1 npx @use-aistack/cli sync # the same, for a hook or a script
32
32
  ```
33
33
 
34
- The lines go to stderr and hold counts and durations only: no paths, prompts, or database values. Paste them into a bug report.
34
+ The lines go to stderr and hold counts, durations, and safe error codes: no paths, prompts, or database values. Paste them into a bug report. Expected Git discovery misses are summarized as informational messages; incomplete Cursor sessions are grouped into one warning.
35
+
36
+ Partial history still contributes dated usage. The review marks it as partial, and the backend retains previously recorded evidence. Missing models, harnesses, dates, and workflow readings are not cleared by a partial sync. Repeated readings are not added together. An existing model is updated only when the incoming reading covers all its stored token buckets and recorded cost; otherwise the stored model reading stays. A complete scan can still apply corrections through the normal daily replacement path.
35
37
 
36
38
  ### `npx @use-aistack/cli sync --auto on` / `off`
37
39
 
@@ -19127,6 +19127,11 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits) {
19127
19127
  const readDone = traceTimer("cursor history read");
19128
19128
  let context;
19129
19129
  let retrySmallPage = false;
19130
+ let unresolved = 0;
19131
+ let corrupted = 0;
19132
+ let ambiguous = 0;
19133
+ let stage = "reader setup";
19134
+ const signal = AbortSignal.timeout(12e4);
19130
19135
  try {
19131
19136
  const reader = await Promise.resolve().then(() => (init_lib(), lib_exports));
19132
19137
  const options = {
@@ -19136,7 +19141,7 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits) {
19136
19141
  traceError("cursor source diagnostic", diagnostic, "warn");
19137
19142
  out.complete = false;
19138
19143
  },
19139
- signal: AbortSignal.timeout(12e4)
19144
+ signal
19140
19145
  };
19141
19146
  context = reader.createSessionReadContext({ ...options, sourceReadLimits });
19142
19147
  const config = { ...options, readContext: context };
@@ -19145,6 +19150,7 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits) {
19145
19150
  const pageDone = traceTimer(
19146
19151
  offset === 0 ? "cursor session listing" : "cursor session page"
19147
19152
  );
19153
+ stage = "session listing";
19148
19154
  const page = await reader.listSessionSummaries({
19149
19155
  ...config,
19150
19156
  offset,
@@ -19155,28 +19161,26 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits) {
19155
19161
  for (const summary of page.data) {
19156
19162
  stats.filesFound++;
19157
19163
  if (summary.resolutionState === "ambiguous") {
19158
- trace(
19159
- "cursor session resolution incomplete \xB7 ambiguous source",
19160
- "warn"
19161
- );
19162
19164
  out.complete = false;
19163
19165
  }
19164
19166
  try {
19167
+ stage = "session read";
19165
19168
  const session = await reader.getSession(summary.id, config);
19166
19169
  if (session.resolutionState !== "complete" || session.messages.some((m) => m.metadata?.corrupted)) {
19167
- trace(
19168
- "cursor session incomplete \xB7 unresolved or corrupted messages",
19169
- "warn"
19170
- );
19170
+ if (session.resolutionState !== "complete") unresolved++;
19171
+ if (session.messages.some((m) => m.metadata?.corrupted))
19172
+ corrupted++;
19171
19173
  out.complete = false;
19172
19174
  }
19175
+ stage = "token evidence";
19173
19176
  const tokens = await readTokenEvidence(root, session);
19174
19177
  out.sessions.push({ session, tokens });
19175
19178
  stats.filesRead++;
19176
19179
  onProgress?.(stats.filesRead, page.pagination.total);
19177
19180
  } catch (error) {
19178
19181
  if (isPageByteLimit(error)) throw error;
19179
- traceError("cursor history", error);
19182
+ if (traceErrorCode(error) === "SESSION_AMBIGUOUS") ambiguous++;
19183
+ else traceError(`cursor ${stage}`, error, "warn");
19180
19184
  out.complete = false;
19181
19185
  stats.filesUnreadable++;
19182
19186
  } finally {
@@ -19195,7 +19199,9 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits) {
19195
19199
  offset += page.data.length;
19196
19200
  }
19197
19201
  } catch (error) {
19198
- traceError("cursor history", error);
19202
+ traceError(`cursor ${stage}`, error);
19203
+ if (signal.aborted)
19204
+ traceError("cursor read deadline", signal.reason, "warn");
19199
19205
  retrySmallPage = isPageByteLimit(error) && sourceReadLimits?.sqlitePageRows !== 1;
19200
19206
  stats.unreadableFiles.push({
19201
19207
  path: "history",
@@ -19228,6 +19234,12 @@ async function readLocalOnce(root, before, onProgress, sourceReadLimits) {
19228
19234
  );
19229
19235
  out.complete = false;
19230
19236
  }
19237
+ if (unresolved || corrupted || ambiguous) {
19238
+ trace(
19239
+ `cursor partial history \xB7 ${unresolved} sessions unresolved, ${corrupted} with corrupted messages, ${ambiguous} skipped with conflicting copies${ambiguous ? " (SESSION_AMBIGUOUS)" : ""} \xB7 available dated usage retained`,
19240
+ "warn"
19241
+ );
19242
+ }
19231
19243
  readDone(
19232
19244
  `${stats.filesRead}/${stats.filesFound} sessions read, ${stats.filesUnreadable} unreadable${out.complete ? "" : ", incomplete"}`,
19233
19245
  out.complete ? "success" : "warn"