p-backlog 0.14.6 → 0.14.7
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/CHANGELOG.md +4 -0
- package/dist/cli.js +46 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.14.7
|
|
6
|
+
|
|
7
|
+
- Costs count each backlog command once in mixed Codex Desktop tool calls and attribute it to the command's project.
|
|
8
|
+
|
|
5
9
|
## 0.14.6
|
|
6
10
|
|
|
7
11
|
- Tasks can carry an optional probability from 0 to 100%. Filter by a range or find tasks without an estimate in the web app and CLI.
|
package/dist/cli.js
CHANGED
|
@@ -116,7 +116,7 @@ var SERVE_COMMAND_NAME = "serve";
|
|
|
116
116
|
// src/cli/main.ts
|
|
117
117
|
import { homedir } from "node:os";
|
|
118
118
|
import { dirname as dirname13, resolve as resolve7 } from "node:path";
|
|
119
|
-
import { fileURLToPath } from "node:url";
|
|
119
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
120
120
|
|
|
121
121
|
// src/core/store/runs.ts
|
|
122
122
|
import { mkdir } from "node:fs/promises";
|
|
@@ -9443,12 +9443,12 @@ var transcriptStateSchema = z18.object({
|
|
|
9443
9443
|
lastMessageTokens: tokenCountsSchema.nullable().optional(),
|
|
9444
9444
|
pending: z18.record(z18.string(), estimatedKindSchema),
|
|
9445
9445
|
pendingEstimates: z18.array(z18.object({ kind: estimatedKindSchema, chars: z18.number(), slot: z18.string(), cwd: z18.string() })),
|
|
9446
|
-
codex: z18.object({ cwd: z18.string(), total: tokenCountsSchema.nullable(), toolDirectories: z18.record(z18.string(), z18.string()).optional() }).optional()
|
|
9446
|
+
codex: z18.object({ cwd: z18.string(), total: tokenCountsSchema.nullable(), desktopCommandEvents: z18.literal(true).optional(), toolDirectories: z18.record(z18.string(), z18.string()).optional() }).optional()
|
|
9447
9447
|
});
|
|
9448
9448
|
|
|
9449
9449
|
// src/core/usage/usage-cache.ts
|
|
9450
9450
|
var USAGE_CACHE_FILE = ".usage-cache.json";
|
|
9451
|
-
var USAGE_CACHE_VERSION =
|
|
9451
|
+
var USAGE_CACHE_VERSION = 8;
|
|
9452
9452
|
var bucketsSchema = z19.array(usageBucketSchema);
|
|
9453
9453
|
var worktreeTenureSchema = z19.object({ main: z19.string(), since: z19.number() });
|
|
9454
9454
|
var SINCE_EVER = 0;
|
|
@@ -10352,11 +10352,14 @@ function slotOf(timestamp) {
|
|
|
10352
10352
|
|
|
10353
10353
|
// src/core/usage/attribute-codex.ts
|
|
10354
10354
|
import { resolve as resolve4 } from "node:path";
|
|
10355
|
+
import { fileURLToPath } from "node:url";
|
|
10355
10356
|
import { z as z21 } from "zod";
|
|
10356
|
-
var ROLLOUT_MARKERS = /"type"\s*:\s*"(?:session_meta|turn_context|token_count|message|function_call(?:_output)?|custom_tool_call(?:_output)?)"/u;
|
|
10357
|
+
var ROLLOUT_MARKERS = /"type"\s*:\s*"(?:session_meta|turn_context|token_count|item_completed|message|function_call(?:_output)?|custom_tool_call(?:_output)?)"/u;
|
|
10357
10358
|
var INLINE_SHELL_FIELDS = /\b(cmd|workdir)\s*:\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\[\s\S]|[^`\\])*`)/gu;
|
|
10358
10359
|
var APP_TOOL_CALL = /\btools\.(\w+)\s*\(/gu;
|
|
10359
10360
|
var SKILL_READER = /^\s*(?:cat|sed|head|tail|nl|Get-Content)\b/iu;
|
|
10361
|
+
var SHELL_PROGRAM = /(?:^|[\\/])(?:bash|zsh|sh|dash|ksh|fish|pwsh|powershell|cmd)(?:\.exe)?$/iu;
|
|
10362
|
+
var SHELL_SCRIPT_FLAG = /^(?:-[il]*c|-command|\/c)$/iu;
|
|
10360
10363
|
var STOP_HOOK_PROMPT = /^<hook_prompt hook_run_id="stop:[^"]+">\s*([\s\S]*?)<\/hook_prompt>$/u;
|
|
10361
10364
|
var rolloutSchema = z21.object({
|
|
10362
10365
|
type: z21.string(),
|
|
@@ -10364,7 +10367,9 @@ var rolloutSchema = z21.object({
|
|
|
10364
10367
|
payload: z21.object({
|
|
10365
10368
|
type: z21.string().optional(),
|
|
10366
10369
|
cwd: z21.string().optional(),
|
|
10367
|
-
model: z21.string().min(1).optional()
|
|
10370
|
+
model: z21.string().min(1).optional(),
|
|
10371
|
+
originator: z21.string().optional(),
|
|
10372
|
+
history_mode: z21.string().optional()
|
|
10368
10373
|
}).passthrough()
|
|
10369
10374
|
});
|
|
10370
10375
|
var usageSchema2 = z21.object({
|
|
@@ -10374,6 +10379,16 @@ var usageSchema2 = z21.object({
|
|
|
10374
10379
|
output_tokens: z21.number().nonnegative()
|
|
10375
10380
|
});
|
|
10376
10381
|
var eventSchema = z21.object({ info: z21.object({ total_token_usage: usageSchema2, last_token_usage: usageSchema2.optional() }) });
|
|
10382
|
+
var completedCommandSchema = z21.object({
|
|
10383
|
+
item: z21.object({
|
|
10384
|
+
type: z21.literal("CommandExecution"),
|
|
10385
|
+
id: z21.string().startsWith("exec-"),
|
|
10386
|
+
source: z21.literal("unified_exec_startup"),
|
|
10387
|
+
cwd: z21.string().min(1),
|
|
10388
|
+
command: z21.tuple([z21.string()], z21.string()),
|
|
10389
|
+
aggregated_output: z21.string()
|
|
10390
|
+
})
|
|
10391
|
+
});
|
|
10377
10392
|
var messageSchema = z21.object({ role: z21.string(), content: z21.array(z21.object({ text: z21.string().optional() })) });
|
|
10378
10393
|
var callSchema = z21.object({ name: z21.string(), call_id: z21.string(), arguments: z21.string().optional(), input: z21.string().optional() });
|
|
10379
10394
|
var shellSchema = z21.object({ cmd: z21.string().optional(), command: z21.string().optional(), workdir: z21.string().optional() });
|
|
@@ -10386,15 +10401,35 @@ function attributeCodexLine(line, state) {
|
|
|
10386
10401
|
const codex = state.codex ??= { cwd: "", total: null };
|
|
10387
10402
|
const { type, timestamp, payload } = event;
|
|
10388
10403
|
if (type === "session_meta" || type === "turn_context") {
|
|
10404
|
+
if (type === "session_meta" && payload.originator === "Codex Desktop" && payload.history_mode === "paginated") codex.desktopCommandEvents = true;
|
|
10389
10405
|
codex.cwd = payload.cwd ?? codex.cwd;
|
|
10390
10406
|
state.lastModel = payload.model ?? state.lastModel;
|
|
10391
10407
|
return [];
|
|
10392
10408
|
}
|
|
10393
10409
|
const context = { cwd: codex.cwd, model: state.lastModel ?? "unknown", slot: slotOf(timestamp) };
|
|
10394
10410
|
if (type === "event_msg" && payload.type === "token_count") return tokenBuckets(payload, state, codex, context);
|
|
10411
|
+
if (type === "event_msg" && payload.type === "item_completed" && codex.desktopCommandEvents && !state.hookOpen) return desktopCommandBuckets(payload, context);
|
|
10395
10412
|
if (type === "response_item") return responseBuckets(payload, state, codex, context);
|
|
10396
10413
|
return [];
|
|
10397
10414
|
}
|
|
10415
|
+
function desktopCommandBuckets(payload, context) {
|
|
10416
|
+
const completed = completedCommandSchema.safeParse(payload);
|
|
10417
|
+
if (!completed.success) return [];
|
|
10418
|
+
const { cwd, command: command2, aggregated_output: output } = completed.data.item;
|
|
10419
|
+
const [program, ...args] = command2;
|
|
10420
|
+
const script = SHELL_PROGRAM.test(program) && SHELL_SCRIPT_FLAG.test(args.at(-2) ?? "") ? args.at(-1) : program;
|
|
10421
|
+
if (script === void 0 || !invokesOnlyBacklog(script)) return [];
|
|
10422
|
+
return estimatedOutput(output.length, "cli", { ...context, cwd: commandDirectory(cwd) });
|
|
10423
|
+
}
|
|
10424
|
+
function commandDirectory(cwd) {
|
|
10425
|
+
if (!cwd.startsWith("file:")) return cwd;
|
|
10426
|
+
try {
|
|
10427
|
+
return fileURLToPath(cwd);
|
|
10428
|
+
} catch (error) {
|
|
10429
|
+
if (!(error instanceof TypeError || error instanceof URIError)) throw error;
|
|
10430
|
+
return cwd;
|
|
10431
|
+
}
|
|
10432
|
+
}
|
|
10398
10433
|
function tokenBuckets(payload, state, codex, context) {
|
|
10399
10434
|
const event = eventSchema.safeParse(payload);
|
|
10400
10435
|
if (!event.success) return [];
|
|
@@ -10439,7 +10474,7 @@ function isBacklogPrompt(text) {
|
|
|
10439
10474
|
function rememberBacklogCall(call, state, codex) {
|
|
10440
10475
|
const { commands, workdir } = shellDetails(call);
|
|
10441
10476
|
if (commands.length === 0) return;
|
|
10442
|
-
if (commands.every(invokesOnlyBacklog)) rememberToolCall(state, call.call_id, "cli");
|
|
10477
|
+
if (!(codex.desktopCommandEvents && call.name === "exec") && commands.every(invokesOnlyBacklog)) rememberToolCall(state, call.call_id, "cli");
|
|
10443
10478
|
else if (commands.every(readsBacklogSkill)) rememberToolCall(state, call.call_id, "skill");
|
|
10444
10479
|
if (workdir && Object.hasOwn(state.pending, call.call_id)) {
|
|
10445
10480
|
codex.toolDirectories ??= {};
|
|
@@ -10483,8 +10518,11 @@ function toolOutputBuckets(payload, state, codex, context) {
|
|
|
10483
10518
|
Reflect.deleteProperty(directories, id);
|
|
10484
10519
|
if (state.hookOpen || kind === void 0) return [];
|
|
10485
10520
|
const chars = typeof output === "string" ? output.length : output.reduce((total, part) => total + (textOutputSchema.safeParse(part).data?.text.length ?? 0), 0);
|
|
10521
|
+
return estimatedOutput(chars, kind, { ...context, cwd });
|
|
10522
|
+
}
|
|
10523
|
+
function estimatedOutput(chars, kind, context) {
|
|
10486
10524
|
if (chars === 0) return [];
|
|
10487
|
-
return [{ ...context,
|
|
10525
|
+
return [{ ...context, kind, tokens: { ...ZERO_TOKENS, input: estimateTextTokens(chars) }, hookTurns: 0 }];
|
|
10488
10526
|
}
|
|
10489
10527
|
|
|
10490
10528
|
// src/core/usage/transcripts.ts
|
|
@@ -12027,7 +12065,7 @@ async function readStdin() {
|
|
|
12027
12065
|
}
|
|
12028
12066
|
var home = homedir();
|
|
12029
12067
|
var backlogRoot = resolveBacklogRoot(process.env, home);
|
|
12030
|
-
var cliPath =
|
|
12068
|
+
var cliPath = fileURLToPath2(import.meta.url);
|
|
12031
12069
|
var packageRoot = resolve7(dirname13(cliPath), "..");
|
|
12032
12070
|
var argv = process.argv.slice(2);
|
|
12033
12071
|
var warn = (line) => void process.stderr.write(`${line}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "p-backlog",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.7",
|
|
4
4
|
"description": "Keep pull requests clean and audit findings safe: a local, autonomous backlog for Claude Code. The agent files out-of-scope issues as Markdown tasks with context and re-checks them as code changes. Optional web UI with metrics.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|