@use-aistack/cli 0.23.0 → 0.23.1
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/cursor-worker.js.map +1 -1
- package/dist/index.js +106 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20356,7 +20356,7 @@ var KNOWN_ROW_IDS = /* @__PURE__ */ new Set([
|
|
|
20356
20356
|
]);
|
|
20357
20357
|
|
|
20358
20358
|
// src/version.ts
|
|
20359
|
-
var CLI_VERSION = true ? "0.23.
|
|
20359
|
+
var CLI_VERSION = true ? "0.23.1" : "0.0.0-dev";
|
|
20360
20360
|
|
|
20361
20361
|
// src/api.ts
|
|
20362
20362
|
var BASE_URL = process.env.AISTACK_URL || "https://aistack.to";
|
|
@@ -22200,6 +22200,10 @@ function noteSyntheticTokens(agg, tsMs, tokens) {
|
|
|
22200
22200
|
}
|
|
22201
22201
|
function noteSessionStart(agg, sessionId, tsMs) {
|
|
22202
22202
|
if (tsMs === null) return;
|
|
22203
|
+
const date = utcDateOf(tsMs);
|
|
22204
|
+
const days = agg.sessionDays.get(sessionId);
|
|
22205
|
+
if (days) days.add(date);
|
|
22206
|
+
else agg.sessionDays.set(sessionId, /* @__PURE__ */ new Set([date]));
|
|
22203
22207
|
const held = agg.sessionStarts.get(sessionId);
|
|
22204
22208
|
if (held === void 0 || tsMs < held) {
|
|
22205
22209
|
agg.sessionStarts.set(sessionId, tsMs);
|
|
@@ -22254,6 +22258,7 @@ function createAggregate() {
|
|
|
22254
22258
|
seen: /* @__PURE__ */ new Map(),
|
|
22255
22259
|
usageDays: /* @__PURE__ */ new Map(),
|
|
22256
22260
|
sessionStarts: /* @__PURE__ */ new Map(),
|
|
22261
|
+
sessionDays: /* @__PURE__ */ new Map(),
|
|
22257
22262
|
sessionAccounts: /* @__PURE__ */ new Map()
|
|
22258
22263
|
};
|
|
22259
22264
|
}
|
|
@@ -31088,7 +31093,9 @@ function buildUsageDays(input) {
|
|
|
31088
31093
|
(a, b) => countsTotalOf(b.tokens) - countsTotalOf(a.tokens) || a.model.localeCompare(b.model)
|
|
31089
31094
|
);
|
|
31090
31095
|
const directories2 = [...acc?.projectDirs ?? []];
|
|
31091
|
-
const included = input.deferWorkspace ? directories2.filter(
|
|
31096
|
+
const included = input.deferWorkspace ? directories2.filter(
|
|
31097
|
+
(directory) => !input.deferWorkspace?.(directory, date)
|
|
31098
|
+
) : directories2;
|
|
31092
31099
|
out.set(date, {
|
|
31093
31100
|
harness,
|
|
31094
31101
|
sessions: sessionsByDay.get(date) ?? 0,
|
|
@@ -31210,6 +31217,28 @@ function buildMeasuredDays(input) {
|
|
|
31210
31217
|
};
|
|
31211
31218
|
});
|
|
31212
31219
|
}
|
|
31220
|
+
function markDeletedEvidence(days, input) {
|
|
31221
|
+
const out = [];
|
|
31222
|
+
for (const day of days) {
|
|
31223
|
+
const carried = /* @__PURE__ */ new Set([
|
|
31224
|
+
...(day.usage?.harnesses ?? []).map((h) => h.harness),
|
|
31225
|
+
...(day.workflow?.harnesses ?? []).map((h) => h.harness)
|
|
31226
|
+
]);
|
|
31227
|
+
const partial = [...input.ledgers].filter(
|
|
31228
|
+
([harness, ledger]) => carried.has(harness) && !input.partialHarnesses.has(harness) && ledger.partialDates.has(day.date)
|
|
31229
|
+
).map(([harness]) => harness).sort();
|
|
31230
|
+
const cleared = [...input.clearable].filter(
|
|
31231
|
+
([harness, ledger]) => !carried.has(harness) && ledger.clearDates.has(day.date)
|
|
31232
|
+
).map(([harness]) => harness).sort();
|
|
31233
|
+
if (!day.usage && !day.workflow && cleared.length === 0) continue;
|
|
31234
|
+
out.push({
|
|
31235
|
+
...day,
|
|
31236
|
+
...partial.length ? { partialHarnesses: partial } : {},
|
|
31237
|
+
...cleared.length ? { clearedHarnesses: cleared } : {}
|
|
31238
|
+
});
|
|
31239
|
+
}
|
|
31240
|
+
return out;
|
|
31241
|
+
}
|
|
31213
31242
|
|
|
31214
31243
|
// src/usage/diff.ts
|
|
31215
31244
|
var MAX_DAY_WINDOW = 400;
|
|
@@ -31823,13 +31852,29 @@ function saveGrokDateHints(scope, hints, file = defaultFile) {
|
|
|
31823
31852
|
mkdirSync9(path20.dirname(file), { recursive: true });
|
|
31824
31853
|
writeFileSync9(file, JSON.stringify(cache, null, 2));
|
|
31825
31854
|
}
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
|
|
31831
|
-
|
|
31855
|
+
|
|
31856
|
+
// src/sync/sessionLedger.ts
|
|
31857
|
+
function readSessionLedger(previous, current, floor) {
|
|
31858
|
+
const partialDates = /* @__PURE__ */ new Set();
|
|
31859
|
+
const remembered = /* @__PURE__ */ new Set();
|
|
31860
|
+
const next = {};
|
|
31861
|
+
for (const [id, dates] of Object.entries(previous)) {
|
|
31862
|
+
const kept = dates.filter((date) => date >= floor);
|
|
31863
|
+
if (current.has(id)) {
|
|
31864
|
+
for (const date of kept) remembered.add(date);
|
|
31865
|
+
continue;
|
|
31866
|
+
}
|
|
31867
|
+
for (const date of kept) partialDates.add(date);
|
|
31868
|
+
if (kept.length) next[id] = kept;
|
|
31869
|
+
}
|
|
31870
|
+
for (const [id, dates] of current) {
|
|
31871
|
+
const kept = [...dates].filter((date) => date >= floor).sort();
|
|
31872
|
+
if (kept.length) next[id] = kept;
|
|
31873
|
+
}
|
|
31874
|
+
const clearDates = new Set(
|
|
31875
|
+
[...remembered].filter((date) => !partialDates.has(date))
|
|
31832
31876
|
);
|
|
31877
|
+
return { partialDates, clearDates, next };
|
|
31833
31878
|
}
|
|
31834
31879
|
|
|
31835
31880
|
// src/sync/summary.ts
|
|
@@ -32544,8 +32589,15 @@ async function stageSync(deps) {
|
|
|
32544
32589
|
`historical harnesses (${retentionDays} days): ${historical.map((a) => a.name).join(", ") || "none"}`
|
|
32545
32590
|
);
|
|
32546
32591
|
let dayScansComplete = true;
|
|
32592
|
+
const acknowledgements = [];
|
|
32547
32593
|
const partialHarnesses = /* @__PURE__ */ new Set();
|
|
32548
|
-
const
|
|
32594
|
+
const ledgers = /* @__PURE__ */ new Map();
|
|
32595
|
+
const ledgerFloor = utcDate2(daysSinceMs);
|
|
32596
|
+
const ledgerScope = (harness) => token && config.stack ? grokCacheScope(
|
|
32597
|
+
harness === "grok-build" ? deps.baseUrl : `${deps.baseUrl}\0${harness}`,
|
|
32598
|
+
config.stack.slug,
|
|
32599
|
+
token
|
|
32600
|
+
) : null;
|
|
32549
32601
|
for (const { adapter, recent } of readings) {
|
|
32550
32602
|
if (!recent) continue;
|
|
32551
32603
|
const { aggregate, stats } = recent;
|
|
@@ -32570,8 +32622,19 @@ async function stageSync(deps) {
|
|
|
32570
32622
|
dayScansComplete = false;
|
|
32571
32623
|
partialHarnesses.add(adapter.name);
|
|
32572
32624
|
}
|
|
32573
|
-
|
|
32574
|
-
|
|
32625
|
+
const scope = ledgerScope(adapter.name);
|
|
32626
|
+
const ledger = scope ? readSessionLedger(
|
|
32627
|
+
loadGrokDateHints(scope, deps.sessionLedgerFile),
|
|
32628
|
+
sessionDates ?? aggregate.sessionDays,
|
|
32629
|
+
ledgerFloor
|
|
32630
|
+
) : void 0;
|
|
32631
|
+
if (scope && ledger) {
|
|
32632
|
+
ledgers.set(adapter.name, ledger);
|
|
32633
|
+
acknowledgements.push(
|
|
32634
|
+
() => saveGrokDateHints(scope, ledger.next, deps.sessionLedgerFile)
|
|
32635
|
+
);
|
|
32636
|
+
}
|
|
32637
|
+
const wholeHarnessPartial = partialHarnesses.has(adapter.name);
|
|
32575
32638
|
workflowScans.push({ aggregate: workflow2, local: workflowLocal });
|
|
32576
32639
|
usageScans.push(
|
|
32577
32640
|
buildUsageDays({
|
|
@@ -32582,8 +32645,11 @@ async function stageSync(deps) {
|
|
|
32582
32645
|
accountId: harnessAccountId(adapter.name),
|
|
32583
32646
|
// Old readings can hold a bare folder ID without root provenance.
|
|
32584
32647
|
// A complete scan can replace it, while a partial union cannot tell
|
|
32585
|
-
// whether the new root-scoped ID denotes that same workspace.
|
|
32586
|
-
|
|
32648
|
+
// whether the new root-scoped ID denotes that same workspace. A day
|
|
32649
|
+
// whose sessions were partly deleted is such a union too.
|
|
32650
|
+
...adapter.name === "claude-code" ? {
|
|
32651
|
+
deferWorkspace: (directory, date) => (wholeHarnessPartial || (ledger?.partialDates.has(date) ?? false)) && isClaudeWorkspaceFallback(directory)
|
|
32652
|
+
} : {}
|
|
32587
32653
|
})
|
|
32588
32654
|
);
|
|
32589
32655
|
}
|
|
@@ -32609,44 +32675,33 @@ async function stageSync(deps) {
|
|
|
32609
32675
|
`git history \xB7 skipped (${config.publishWorkflow ? "no harness scanned" : "publishWorkflow off"})`
|
|
32610
32676
|
);
|
|
32611
32677
|
}
|
|
32612
|
-
const
|
|
32613
|
-
|
|
32614
|
-
|
|
32615
|
-
|
|
32616
|
-
|
|
32617
|
-
|
|
32618
|
-
|
|
32619
|
-
|
|
32620
|
-
|
|
32621
|
-
|
|
32622
|
-
|
|
32623
|
-
|
|
32624
|
-
|
|
32625
|
-
|
|
32626
|
-
|
|
32627
|
-
|
|
32628
|
-
|
|
32629
|
-
|
|
32630
|
-
|
|
32631
|
-
|
|
32632
|
-
}
|
|
32633
|
-
acknowledgements.push(() => saveGrokDateHints(scope, current));
|
|
32634
|
-
}
|
|
32635
|
-
if (acknowledgements.length && dayScansComplete)
|
|
32636
|
-
acknowledgePublish = () => {
|
|
32637
|
-
for (const acknowledge of acknowledgements) acknowledge();
|
|
32638
|
-
};
|
|
32639
|
-
const localDays = applyDayConsent(
|
|
32640
|
-
buildMeasuredDays({
|
|
32641
|
-
usage: mergeUsageDays(usageScans),
|
|
32642
|
-
...workflow ? { workflow: workflow.days } : {},
|
|
32643
|
-
from: utcDate2(daysSinceMs),
|
|
32644
|
-
to: utcDate2(now),
|
|
32645
|
-
// A partial scan cannot prove that a formerly dated session disappeared.
|
|
32646
|
-
includeDates: dayScansComplete ? correctionDates : /* @__PURE__ */ new Set()
|
|
32647
|
-
}),
|
|
32648
|
-
config
|
|
32678
|
+
const clearable = new Map(
|
|
32679
|
+
[...ledgers].filter(([harness]) => !partialHarnesses.has(harness))
|
|
32680
|
+
);
|
|
32681
|
+
const clearDates = new Set(
|
|
32682
|
+
[...clearable.values()].flatMap((ledger) => [...ledger.clearDates])
|
|
32683
|
+
);
|
|
32684
|
+
const acknowledgePublish = acknowledgements.length ? () => {
|
|
32685
|
+
for (const acknowledge of acknowledgements) acknowledge();
|
|
32686
|
+
} : void 0;
|
|
32687
|
+
const localDays = markDeletedEvidence(
|
|
32688
|
+
applyDayConsent(
|
|
32689
|
+
buildMeasuredDays({
|
|
32690
|
+
usage: mergeUsageDays(usageScans),
|
|
32691
|
+
...workflow ? { workflow: workflow.days } : {},
|
|
32692
|
+
from: utcDate2(daysSinceMs),
|
|
32693
|
+
to: utcDate2(now),
|
|
32694
|
+
includeDates: clearDates
|
|
32695
|
+
}),
|
|
32696
|
+
config
|
|
32697
|
+
),
|
|
32698
|
+
{ ledgers, clearable, partialHarnesses }
|
|
32649
32699
|
);
|
|
32700
|
+
const deletedDays = localDays.filter((day) => day.partialHarnesses).length;
|
|
32701
|
+
if (deletedDays)
|
|
32702
|
+
trace(
|
|
32703
|
+
`days \xB7 ${deletedDays} with deleted local sessions; the published reading is kept`
|
|
32704
|
+
);
|
|
32650
32705
|
const days = selectDaysToPublish({
|
|
32651
32706
|
local: localDays,
|
|
32652
32707
|
manifest,
|
|
@@ -32863,6 +32918,7 @@ async function runAutoSync(deps) {
|
|
|
32863
32918
|
failure2 = staged.blockedReason;
|
|
32864
32919
|
} else {
|
|
32865
32920
|
const res = await publish(staged.token, staged.bodyJson);
|
|
32921
|
+
staged.acknowledgePublish?.();
|
|
32866
32922
|
url = res.url;
|
|
32867
32923
|
}
|
|
32868
32924
|
}
|