codetime-cli 0.3.1 → 0.3.3
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/codetime.mjs +18 -44
- package/package.json +2 -2
package/bin/codetime.mjs
CHANGED
|
@@ -972,7 +972,7 @@ import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
|
972
972
|
import path2 from "node:path";
|
|
973
973
|
|
|
974
974
|
// src/lib/constants.ts
|
|
975
|
-
var PACKAGE_VERSION = true ? "0.3.
|
|
975
|
+
var PACKAGE_VERSION = true ? "0.3.3" : "0.1.1";
|
|
976
976
|
var DEFAULT_API_URL = "https://codetime.dev";
|
|
977
977
|
var DEFAULT_BACKFILL_BATCH_SIZE = 50;
|
|
978
978
|
var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
|
|
@@ -2223,12 +2223,12 @@ async function parseCodexSessionFile(filePath, options) {
|
|
|
2223
2223
|
const text = await readFile4(filePath, "utf8");
|
|
2224
2224
|
const lines = text.split("\n").filter(Boolean);
|
|
2225
2225
|
const sourcePathHash = `sha256:${createStableHash(filePath)}`;
|
|
2226
|
-
const serviceTier = await resolveCodexServiceTier(filePath);
|
|
2227
2226
|
const events = [];
|
|
2228
2227
|
let sessionId = sessionIdFromFilePath(filePath, "codex");
|
|
2229
2228
|
let cwd;
|
|
2230
2229
|
let project;
|
|
2231
2230
|
let model;
|
|
2231
|
+
let serviceTier;
|
|
2232
2232
|
let currentTurnId;
|
|
2233
2233
|
let lastTurnIdForComplete;
|
|
2234
2234
|
let turnIdAtLastUserMessage;
|
|
@@ -2274,6 +2274,10 @@ async function parseCodexSessionFile(filePath, options) {
|
|
|
2274
2274
|
cwd = stringField(payload, "cwd") || cwd;
|
|
2275
2275
|
project = cwd ? path7.basename(cwd) : project;
|
|
2276
2276
|
model = stringField(payload, "model") || model;
|
|
2277
|
+
const tier = stringField(payload, "service_tier");
|
|
2278
|
+
if (tier) {
|
|
2279
|
+
serviceTier = tier.toLowerCase();
|
|
2280
|
+
}
|
|
2277
2281
|
continue;
|
|
2278
2282
|
}
|
|
2279
2283
|
if (topType !== "event_msg" && topType !== "response_item") {
|
|
@@ -2333,6 +2337,11 @@ async function parseCodexSessionFile(filePath, options) {
|
|
|
2333
2337
|
break;
|
|
2334
2338
|
}
|
|
2335
2339
|
case "token_count": {
|
|
2340
|
+
const info = objectField(payload, "info");
|
|
2341
|
+
const tierFromInfo = stringField(info, "service_tier") || stringField(payload, "service_tier");
|
|
2342
|
+
if (tierFromInfo) {
|
|
2343
|
+
serviceTier = tierFromInfo.toLowerCase();
|
|
2344
|
+
}
|
|
2336
2345
|
const usage = tokenUsageFromPayload(payload);
|
|
2337
2346
|
if (usage) {
|
|
2338
2347
|
const usageKey = [
|
|
@@ -2545,43 +2554,6 @@ async function parseCodexSessionFile(filePath, options) {
|
|
|
2545
2554
|
}
|
|
2546
2555
|
return events.filter((event) => validateCanonicalEvent(event).valid);
|
|
2547
2556
|
}
|
|
2548
|
-
var codexServiceTierCache = /* @__PURE__ */ new Map();
|
|
2549
|
-
async function resolveCodexServiceTier(sessionFilePath) {
|
|
2550
|
-
const home = inferCodexHomeFromSessionPath(sessionFilePath);
|
|
2551
|
-
if (!home) {
|
|
2552
|
-
return void 0;
|
|
2553
|
-
}
|
|
2554
|
-
if (!codexServiceTierCache.has(home)) {
|
|
2555
|
-
codexServiceTierCache.set(home, await readCodexServiceTier(home));
|
|
2556
|
-
}
|
|
2557
|
-
return codexServiceTierCache.get(home) ?? void 0;
|
|
2558
|
-
}
|
|
2559
|
-
function inferCodexHomeFromSessionPath(sessionFilePath) {
|
|
2560
|
-
if (path7.basename(sessionFilePath) === "history.jsonl") {
|
|
2561
|
-
return path7.dirname(sessionFilePath);
|
|
2562
|
-
}
|
|
2563
|
-
let dir = path7.dirname(sessionFilePath);
|
|
2564
|
-
for (let depth = 0; depth < 10; depth += 1) {
|
|
2565
|
-
const parent = path7.dirname(dir);
|
|
2566
|
-
if (parent === dir) {
|
|
2567
|
-
return void 0;
|
|
2568
|
-
}
|
|
2569
|
-
if (path7.basename(dir) === "sessions") {
|
|
2570
|
-
return parent;
|
|
2571
|
-
}
|
|
2572
|
-
dir = parent;
|
|
2573
|
-
}
|
|
2574
|
-
return void 0;
|
|
2575
|
-
}
|
|
2576
|
-
async function readCodexServiceTier(codexHomePath) {
|
|
2577
|
-
try {
|
|
2578
|
-
const text = await readFile4(path7.join(codexHomePath, "config.toml"), "utf8");
|
|
2579
|
-
const match = text.match(/(?:^|\n)\s*service_tier\s*=\s*["']?([a-z_]+)["']?/i);
|
|
2580
|
-
return match ? match[1].toLowerCase() : null;
|
|
2581
|
-
} catch {
|
|
2582
|
-
return null;
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
2557
|
function rewriteCodexModelForTier(model, serviceTier) {
|
|
2586
2558
|
if (!model) {
|
|
2587
2559
|
return model;
|
|
@@ -4406,7 +4378,7 @@ async function deleteMachine(remote, id) {
|
|
|
4406
4378
|
}
|
|
4407
4379
|
|
|
4408
4380
|
// src/lib/types.ts
|
|
4409
|
-
var BACKFILL_STATE_SCHEMA_VERSION =
|
|
4381
|
+
var BACKFILL_STATE_SCHEMA_VERSION = 4;
|
|
4410
4382
|
|
|
4411
4383
|
// src/cli.ts
|
|
4412
4384
|
function createRegistry() {
|
|
@@ -4676,9 +4648,10 @@ async function backfillCommand(options, ctx, registry) {
|
|
|
4676
4648
|
}
|
|
4677
4649
|
if (action === "import" && !options["dry-run"]) {
|
|
4678
4650
|
const requested = normalizeBackfillSource(stringOption(options.source) || "all");
|
|
4679
|
-
const supported = /* @__PURE__ */ new Set(["all", "codex", "claude-code", "opencode", "pi"]);
|
|
4651
|
+
const supported = /* @__PURE__ */ new Set(["all", "codex", "claude-code", "opencode", "pi", "amp"]);
|
|
4680
4652
|
if (!supported.has(requested)) {
|
|
4681
|
-
write(ctx.stderr,
|
|
4653
|
+
write(ctx.stderr, `Unsupported backfill source: ${requested}
|
|
4654
|
+
`);
|
|
4682
4655
|
return 1;
|
|
4683
4656
|
}
|
|
4684
4657
|
const plan2 = await createBackfillPlanFromOptions(options, ctx, "discover", reg);
|
|
@@ -4900,10 +4873,11 @@ function writeBackfillPlan(plan, options, ctx) {
|
|
|
4900
4873
|
}
|
|
4901
4874
|
async function importBackfillPlan(plan, options, ctx, registry) {
|
|
4902
4875
|
const source = normalizeBackfillSource(stringOption(options.source) || "all");
|
|
4903
|
-
const supportedSources = /* @__PURE__ */ new Set(["codex", "claude-code", "opencode", "pi"]);
|
|
4876
|
+
const supportedSources = /* @__PURE__ */ new Set(["codex", "claude-code", "opencode", "pi", "amp"]);
|
|
4904
4877
|
const home = resolveHome(options, ctx);
|
|
4905
4878
|
if (source !== "all" && !supportedSources.has(source)) {
|
|
4906
|
-
write(ctx.stderr,
|
|
4879
|
+
write(ctx.stderr, `Unsupported backfill source: ${source}
|
|
4880
|
+
`);
|
|
4907
4881
|
return 1;
|
|
4908
4882
|
}
|
|
4909
4883
|
const sourceDefs = registry.all().filter((a) => supportedSources.has(a.id) && (source === "all" || a.id === source)).map((a) => ({ id: a.id, label: a.label, paths: a.sourcePaths(home, ctx.env) }));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codetime-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.3",
|
|
5
5
|
"description": "codetime CLI — install AI-agent hooks (Claude Code, Codex, OpenCode, Pi) and report activity to codetime.dev.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"cac": "^7.0.0",
|
|
37
37
|
"esbuild": "^0.28.0",
|
|
38
|
-
"@codetime/shared": "0.3.
|
|
38
|
+
"@codetime/shared": "0.3.3"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -p tsconfig.json",
|