@yhong91/vibetime 0.1.54 → 0.1.55
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/bin/vibetime.mjs +9 -53
- package/package.json +1 -1
package/bin/vibetime.mjs
CHANGED
|
@@ -2047,7 +2047,7 @@ function claudeStyleFileMetrics(tool, input) {
|
|
|
2047
2047
|
}
|
|
2048
2048
|
|
|
2049
2049
|
// src/lib/constants.ts
|
|
2050
|
-
var PACKAGE_VERSION = true ? "0.1.
|
|
2050
|
+
var PACKAGE_VERSION = true ? "0.1.55" : "0.1.1";
|
|
2051
2051
|
var GENERATED_MARKER = "Generated by vibetime.";
|
|
2052
2052
|
var DEFAULT_API_URL = "http://121.196.224.82:3001";
|
|
2053
2053
|
var DEFAULT_BACKFILL_BATCH_SIZE = 50;
|
|
@@ -13208,7 +13208,6 @@ async function deleteMachine(remote, id) {
|
|
|
13208
13208
|
var BACKFILL_STATE_SCHEMA_VERSION = 6;
|
|
13209
13209
|
|
|
13210
13210
|
// src/cli.ts
|
|
13211
|
-
var SESSION_REWRITE_DAYS = 7;
|
|
13212
13211
|
function createRegistry() {
|
|
13213
13212
|
const registry = new AdapterRegistry();
|
|
13214
13213
|
registry.register(createCodexAdapter());
|
|
@@ -13288,7 +13287,7 @@ function createCli(ctx, registry) {
|
|
|
13288
13287
|
cli.command("hook", "Read agent hook JSON from stdin and report a throttled event").option("--agent <name>", "Agent name").option("--project <name>", "Project name").option("--min-interval <seconds>", "Minimum seconds between similar hook reports").action((options) => hookCommand(normalizeOptions(options), ctx));
|
|
13289
13288
|
cli.command("sync-local-trigger", "Trigger one background local sync with throttle and locking").option("--min-interval <seconds>", "Minimum seconds between sync triggers").action((options) => syncLocalTriggerCommand(normalizeOptions(options), ctx, registry));
|
|
13290
13289
|
cli.command("sync-local-runner", "Internal background local sync runner").option("--lock-file <path>", "Lock file for the active sync").option("--state-file <path>", "State file for trigger metadata").action((options) => syncLocalRunnerCommand(normalizeOptions(options), ctx, registry));
|
|
13291
|
-
cli.command("backfill [action]", "Inspect local history import candidates").option("--source <source>", "Backfill source").option("--since <time>", "Only include history after this time").option("--until <time>", "Only include history before this time").option("--project <name>", "Project filter").option("--source-root <path>", "Override source history root").option("--include-source-path", "Include local source paths in output").option("--import-run <id>", "Import run id for verify/resume workflows").option("--limit <count>", "Maximum session files to parse").option("--batch-size <count>", "Max rollups per request (also bounded by --batch-bytes)").option("--batch-bytes <bytes>", "Soft byte cap for the JSON body of a single ingest POST").option("--replace", "Replace conflicting records during import (default)").option("--skip-conflicts", "Skip conflicting records instead of replacing them").option("--force", "
|
|
13290
|
+
cli.command("backfill [action]", "Inspect local history import candidates").option("--source <source>", "Backfill source").option("--since <time>", "Only include history after this time").option("--until <time>", "Only include history before this time").option("--project <name>", "Project filter").option("--source-root <path>", "Override source history root").option("--include-source-path", "Include local source paths in output").option("--import-run <id>", "Import run id for verify/resume workflows").option("--limit <count>", "Maximum session files to parse").option("--batch-size <count>", "Max rollups per request (also bounded by --batch-bytes)").option("--batch-bytes <bytes>", "Soft byte cap for the JSON body of a single ingest POST").option("--replace", "Replace conflicting records during import (default)").option("--skip-conflicts", "Skip conflicting records instead of replacing them").option("--force", "Re-import everything and rewrite matching server rollups (history lock unlocked; nothing is deleted)").action((action, options) => backfillCommand({ ...normalizeOptions(options), action }, ctx, registry));
|
|
13292
13291
|
cli.command("token [action] [value]", "Set, show, or clear the persisted API token").option("--remote <url>", "Override API base URL when setting a token").action((action, value, options) => tokenCommand(action, value, normalizeOptions(options), ctx));
|
|
13293
13292
|
cli.command("machine [action]", "List or rename machines (requires login)").option("--name <name>", "New display name (used by `machine rename`)").option("--id <id>", "Machine id (defaults to current machine)").action((action, options) => machineCommand(action, normalizeOptions(options), ctx));
|
|
13294
13293
|
return cli;
|
|
@@ -13307,8 +13306,7 @@ function normalizeOptions(options) {
|
|
|
13307
13306
|
importRun: "import-run",
|
|
13308
13307
|
batchSize: "batch-size",
|
|
13309
13308
|
batchBytes: "batch-bytes",
|
|
13310
|
-
skipConflicts: "skip-conflicts"
|
|
13311
|
-
purgeAll: "purge-all"
|
|
13309
|
+
skipConflicts: "skip-conflicts"
|
|
13312
13310
|
};
|
|
13313
13311
|
for (const [camel, dashed] of Object.entries(aliases)) {
|
|
13314
13312
|
if (normalized[camel] !== void 0 && normalized[dashed] === void 0) {
|
|
@@ -13616,10 +13614,6 @@ async function backfillCommand(options, ctx, registry) {
|
|
|
13616
13614
|
if (action === "verify") {
|
|
13617
13615
|
return backfillVerifyCommand(options, ctx);
|
|
13618
13616
|
}
|
|
13619
|
-
if (options["purge-all"] && !options.force) {
|
|
13620
|
-
write(ctx.stderr, "--purge-all requires --force\n");
|
|
13621
|
-
return 1;
|
|
13622
|
-
}
|
|
13623
13617
|
if (action === "import" && !options["dry-run"]) {
|
|
13624
13618
|
const requested = normalizeBackfillSource(stringOption(options.source) || "all");
|
|
13625
13619
|
const supported = /* @__PURE__ */ new Set(["all", ...BACKFILL_SOURCE_IDS]);
|
|
@@ -13882,7 +13876,7 @@ async function importBackfillPlan(plan, options, ctx, registry) {
|
|
|
13882
13876
|
const remote = resolveRemoteFromOptions(options, ctx);
|
|
13883
13877
|
const remoteKey = backfillRemoteKey(remote?.baseUrl ?? DEFAULT_API_URL);
|
|
13884
13878
|
if (options.force) {
|
|
13885
|
-
await
|
|
13879
|
+
await resetForcedWatermarks(home, remoteKey, options, ctx);
|
|
13886
13880
|
}
|
|
13887
13881
|
const incrementalState = shouldUseIncrementalBackfill(options) ? await readBackfillIncrementalState(home, remoteKey, ctx) : void 0;
|
|
13888
13882
|
if (!options.json) {
|
|
@@ -13898,7 +13892,7 @@ async function importBackfillPlan(plan, options, ctx, registry) {
|
|
|
13898
13892
|
options,
|
|
13899
13893
|
ctx
|
|
13900
13894
|
);
|
|
13901
|
-
const rollups =
|
|
13895
|
+
const rollups = buildSessionRollups(canonicalEvents);
|
|
13902
13896
|
const counts = await uploadSessionRollups(rollups, canonicalEvents.length, options, ctx);
|
|
13903
13897
|
const result = {
|
|
13904
13898
|
importRunId: plan.importRun.importRunId,
|
|
@@ -13916,7 +13910,7 @@ async function importBackfillPlan(plan, options, ctx, registry) {
|
|
|
13916
13910
|
}
|
|
13917
13911
|
return counts.failed > 0 || counts.conflicts > 0 && !options["skip-conflicts"] ? 1 : 0;
|
|
13918
13912
|
}
|
|
13919
|
-
async function
|
|
13913
|
+
async function resetForcedWatermarks(home, remoteKey, options, ctx) {
|
|
13920
13914
|
try {
|
|
13921
13915
|
const file = await readBackfillIncrementalStateFile(home);
|
|
13922
13916
|
delete file.remotes[remoteKey];
|
|
@@ -13925,20 +13919,6 @@ async function purgeForcedSources(sourceDefs, home, remoteKey, options, ctx) {
|
|
|
13925
13919
|
debug(ctx, `Failed to clear backfill watermark: ${error.message}
|
|
13926
13920
|
`);
|
|
13927
13921
|
}
|
|
13928
|
-
const preserveTokens = !options["purge-all"];
|
|
13929
|
-
for (const item of sourceDefs) {
|
|
13930
|
-
try {
|
|
13931
|
-
const deleted = await deleteSessionRollupsBySourceAPI(item.id, options, ctx, preserveTokens);
|
|
13932
|
-
if (!options.json) {
|
|
13933
|
-
const suffix = preserveTokens ? " (token-bearing and sessions older than 7 days kept)" : "";
|
|
13934
|
-
write(ctx.stdout, `purged ${item.id}: ${deleted} old rollups${suffix}
|
|
13935
|
-
`);
|
|
13936
|
-
}
|
|
13937
|
-
} catch (error) {
|
|
13938
|
-
debug(ctx, `Failed to purge ${item.id} rollups: ${error.message}
|
|
13939
|
-
`);
|
|
13940
|
-
}
|
|
13941
|
-
}
|
|
13942
13922
|
}
|
|
13943
13923
|
async function collectCanonicalEvents(sourceDefs, registry, incrementalState, options, ctx) {
|
|
13944
13924
|
const selectedFilesBySource = /* @__PURE__ */ new Map();
|
|
@@ -14058,7 +14038,7 @@ async function sendSessionRollupBatch(rollups, options, ctx) {
|
|
|
14058
14038
|
const result = await postRollupBatch(remote, rollups, {
|
|
14059
14039
|
replace: options["skip-conflicts"] !== true,
|
|
14060
14040
|
machine,
|
|
14061
|
-
allowHistoricalRewrite: options
|
|
14041
|
+
allowHistoricalRewrite: options.force === true
|
|
14062
14042
|
});
|
|
14063
14043
|
if (options.force && result.conflicts === 0) {
|
|
14064
14044
|
for (const rollup of rollups) {
|
|
@@ -14066,7 +14046,7 @@ async function sendSessionRollupBatch(rollups, options, ctx) {
|
|
|
14066
14046
|
try {
|
|
14067
14047
|
await deleteRollupsBySource(remote, rollup.source, machine, {
|
|
14068
14048
|
rollupKey: createImportKey(["rollup", rollup.source, sessionId]),
|
|
14069
|
-
allowHistoricalRewrite: options
|
|
14049
|
+
allowHistoricalRewrite: options.force === true
|
|
14070
14050
|
});
|
|
14071
14051
|
} catch (error) {
|
|
14072
14052
|
debug(ctx, `Failed to delete superseded ${rollup.source} session ${sessionId}: ${error.message}
|
|
@@ -14077,28 +14057,6 @@ async function sendSessionRollupBatch(rollups, options, ctx) {
|
|
|
14077
14057
|
}
|
|
14078
14058
|
return result;
|
|
14079
14059
|
}
|
|
14080
|
-
async function deleteSessionRollupsBySourceAPI(source, options, ctx, preserveTokens) {
|
|
14081
|
-
const remote = resolveRemoteFromOptions(options, ctx);
|
|
14082
|
-
if (!remote) {
|
|
14083
|
-
throw new Error("No fetch available for HTTP delete");
|
|
14084
|
-
}
|
|
14085
|
-
const home = resolveHome3(options, ctx);
|
|
14086
|
-
return deleteRollupsBySource(remote, source, {
|
|
14087
|
-
id: ensureLocalMachineId(home),
|
|
14088
|
-
hostname: defaultMachineName(),
|
|
14089
|
-
platform: process.platform
|
|
14090
|
-
}, {
|
|
14091
|
-
preserveTokens,
|
|
14092
|
-
allowHistoricalRewrite: options["purge-all"] === true
|
|
14093
|
-
});
|
|
14094
|
-
}
|
|
14095
|
-
function selectRollupsForUpload(rollups, options, now = /* @__PURE__ */ new Date()) {
|
|
14096
|
-
if (!options.force || options["purge-all"]) {
|
|
14097
|
-
return rollups;
|
|
14098
|
-
}
|
|
14099
|
-
const cutoff = now.getTime() - SESSION_REWRITE_DAYS * 24 * 60 * 60 * 1e3;
|
|
14100
|
-
return rollups.filter((rollup) => Date.parse(rollup.lastEventAt) >= cutoff);
|
|
14101
|
-
}
|
|
14102
14060
|
function shouldUseIncrementalBackfill(options) {
|
|
14103
14061
|
return !stringOption(options.since) && !stringOption(options.until) && !stringOption(options["source-root"]) && numberOption(options.limit) === void 0;
|
|
14104
14062
|
}
|
|
@@ -14557,7 +14515,7 @@ Usage:
|
|
|
14557
14515
|
vibetime uninstall [--target codex,claude,opencode,pi] [--all] [--dry-run] [--home <path>]
|
|
14558
14516
|
vibetime upgrade [--check]
|
|
14559
14517
|
vibetime hook --agent <name>
|
|
14560
|
-
vibetime backfill discover|plan|import|verify --source codex|claude-code|opencode|pi|all --dry-run [--json] [--batch-size <count>] [--force
|
|
14518
|
+
vibetime backfill discover|plan|import|verify --source codex|claude-code|opencode|pi|all --dry-run [--json] [--batch-size <count>] [--force]
|
|
14561
14519
|
vibetime token set <token>
|
|
14562
14520
|
vibetime token show
|
|
14563
14521
|
vibetime token clear
|
|
@@ -14591,10 +14549,8 @@ Environment:
|
|
|
14591
14549
|
`;
|
|
14592
14550
|
}
|
|
14593
14551
|
export {
|
|
14594
|
-
SESSION_REWRITE_DAYS,
|
|
14595
14552
|
run,
|
|
14596
14553
|
selectBackfillFilesForImport,
|
|
14597
|
-
selectRollupsForUpload,
|
|
14598
14554
|
syncLocalRunnerEntryArgs
|
|
14599
14555
|
};
|
|
14600
14556
|
const code = await run(process.argv.slice(2));process.exitCode = code;
|
package/package.json
CHANGED