p-backlog 0.14.1 → 0.14.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/CHANGELOG.md +27 -0
- package/README.md +2 -2
- package/README.ru.md +2 -2
- package/dist/cli.js +520 -222
- package/dist/web/assets/{CodeTab-D7apweTn.js → CodeTab-CrRDpMQh.js} +1 -1
- package/dist/web/assets/{CostTab-Cbq-tBpi.js → CostTab-BBAyNzSe.js} +1 -1
- package/dist/web/assets/{EffectTab-CSJBH_A_.js → EffectTab-BSiY4Ej5.js} +1 -1
- package/dist/web/assets/{Figure-BkubK2zp.js → Figure-DuFa51KM.js} +1 -1
- package/dist/web/assets/{OverviewTab-D1S-xV7F.js → OverviewTab-ChSinrbI.js} +1 -1
- package/dist/web/assets/{Page-DcJkvJR8.js → Page-C8ao190U.js} +5 -5
- package/dist/web/assets/QualityTab-rRNWstc4.js +1 -0
- package/dist/web/assets/{ShareBar-CVoET5r9.js → ShareBar-DjuCpNjt.js} +1 -1
- package/dist/web/assets/{StatsPage-CC1pIw6W.js → StatsPage-Gn54gdFG.js} +1 -1
- package/dist/web/assets/{StatsTabState-DsgM-E6r.js → StatsTabState-S_mi91lw.js} +1 -1
- package/dist/web/assets/{StatsTable-Dfk5L9ju.js → StatsTable-IYYRM2hR.js} +1 -1
- package/dist/web/assets/{UnavailableRepos-DEI_jdL7.js → UnavailableRepos-DxEo8cjP.js} +1 -1
- package/dist/web/assets/{index-CrooTAtB.js → index-DiPBdbhX.js} +2 -2
- package/dist/web/assets/start-BvKCcZHI.css +1 -0
- package/dist/web/assets/start-rahY3Hwq.js +257 -0
- package/dist/web/assets/{use-grain-panel-C8dF5mz1.js → use-grain-panel--2mR_bEC.js} +1 -1
- package/dist/web/assets/{web-paths-Cv9UykyI.js → web-paths-DK4pi1mp.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/skill/backlog/SKILL.md +1 -0
- package/skill/backlog-en/SKILL.md +1 -0
- package/dist/web/assets/QualityTab-Bvo5sLJL.js +0 -1
- package/dist/web/assets/start-CTwcHqnH.js +0 -257
- package/dist/web/assets/start-D3XxrO_Y.css +0 -1
package/dist/cli.js
CHANGED
|
@@ -19,13 +19,20 @@ function formatLocalDay(date) {
|
|
|
19
19
|
return isoDatePart(formatLocalIso(date));
|
|
20
20
|
}
|
|
21
21
|
function formatLocalIso(date) {
|
|
22
|
+
return localIso(date, "");
|
|
23
|
+
}
|
|
24
|
+
function formatLocalIsoWithMilliseconds(date) {
|
|
25
|
+
const milliseconds = date.getMilliseconds();
|
|
26
|
+
return localIso(date, milliseconds === 0 ? "" : `.${String(milliseconds).padStart(3, "0")}`);
|
|
27
|
+
}
|
|
28
|
+
function localIso(date, fraction) {
|
|
22
29
|
const pad = (value) => String(Math.abs(value)).padStart(2, "0");
|
|
23
30
|
const offsetMinutes = -date.getTimezoneOffset();
|
|
24
31
|
const sign = offsetMinutes >= 0 ? "+" : "-";
|
|
25
32
|
const offset = `${sign}${pad(Math.trunc(offsetMinutes / 60))}:${pad(offsetMinutes % 60)}`;
|
|
26
33
|
const day = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
27
34
|
const time = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
28
|
-
return `${day}T${time}${offset}`;
|
|
35
|
+
return `${day}T${time}${fraction}${offset}`;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
// src/core/numbers.ts
|
|
@@ -108,7 +115,7 @@ var SERVE_COMMAND_NAME = "serve";
|
|
|
108
115
|
|
|
109
116
|
// src/cli/main.ts
|
|
110
117
|
import { homedir } from "node:os";
|
|
111
|
-
import { dirname as dirname13, resolve as
|
|
118
|
+
import { dirname as dirname13, resolve as resolve7 } from "node:path";
|
|
112
119
|
import { fileURLToPath } from "node:url";
|
|
113
120
|
|
|
114
121
|
// src/core/store/runs.ts
|
|
@@ -340,26 +347,14 @@ async function withAvailableLocks(paths, action, { waitLimitMs = DEFAULT_WAIT_LI
|
|
|
340
347
|
);
|
|
341
348
|
}
|
|
342
349
|
async function releasingAfter(held, action, onErrorAfterPublish) {
|
|
343
|
-
let outcome;
|
|
344
350
|
try {
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
async function releaseFailures(held) {
|
|
354
|
-
const failures = await Promise.all(
|
|
355
|
-
held.map(
|
|
356
|
-
(lock) => release(lock).then(
|
|
357
|
-
() => [],
|
|
358
|
-
(error) => [{ path: lock.path, error }]
|
|
359
|
-
)
|
|
360
|
-
)
|
|
361
|
-
);
|
|
362
|
-
return failures.flat();
|
|
351
|
+
return await action();
|
|
352
|
+
} finally {
|
|
353
|
+
const failures = await Promise.all(held.map((lock) => release(lock).catch((error) => ({ path: lock.path, error }))));
|
|
354
|
+
for (const failure of failures) {
|
|
355
|
+
if (failure) onErrorAfterPublish(failure.path, failure.error);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
363
358
|
}
|
|
364
359
|
async function acquire(path, { waitLimitMs = DEFAULT_WAIT_LIMIT_MS }) {
|
|
365
360
|
const lock = lockPathOf(path);
|
|
@@ -1176,12 +1171,12 @@ import { execFile } from "node:child_process";
|
|
|
1176
1171
|
var NOT_FOUND = 127;
|
|
1177
1172
|
var FAILED = 1;
|
|
1178
1173
|
function execProgram(file, args, { timeoutMs } = {}) {
|
|
1179
|
-
return new Promise((
|
|
1174
|
+
return new Promise((resolve8) => {
|
|
1180
1175
|
execFile(file, args, { timeout: timeoutMs }, (error, stdout, stderr) => {
|
|
1181
1176
|
const output = `${stdout}${stderr}`.trim();
|
|
1182
|
-
if (error === null)
|
|
1183
|
-
else if (error.code === "ENOENT")
|
|
1184
|
-
else
|
|
1177
|
+
if (error === null) resolve8({ code: 0, output });
|
|
1178
|
+
else if (error.code === "ENOENT") resolve8({ code: NOT_FOUND, output: error.message });
|
|
1179
|
+
else resolve8({ code: typeof error.code === "number" ? error.code : FAILED, output: output || error.message });
|
|
1185
1180
|
});
|
|
1186
1181
|
});
|
|
1187
1182
|
}
|
|
@@ -1542,6 +1537,8 @@ function checkProblem(p) {
|
|
|
1542
1537
|
return `Project ${p.projectId}: could not read the git branches in ${p.repo} (a broken ref or a git failure) \u2014 missing code files of its tasks were not checked`;
|
|
1543
1538
|
case "merge-state-unknown":
|
|
1544
1539
|
return `Project ${p.projectId}: git in ${p.repo} could not tell whether ${pluralEn(p.branches.length, "branch", "branches")} ${p.branches.join(", ")} landed in the current branch (shallow clone, unrelated history or a git failure) \u2014 tasks created there were checked as usual, without waiting for the merge`;
|
|
1540
|
+
case "late-commits-unknown":
|
|
1541
|
+
return `Project ${p.projectId}: git in ${p.repo} could not read the late commits or the reflog of ${pluralEn(p.taskIds.length, "task", "tasks")} ${p.taskIds.join(", ")} (shallow clone or a git failure) \u2014 their code edits were not checked, the next run will try again`;
|
|
1545
1542
|
case "prefix-shared":
|
|
1546
1543
|
return `Projects ${p.projectIds.join(", ")} share the prefix ${p.prefix} \u2014 their task IDs collide. Change prefix in project.md of one of them`;
|
|
1547
1544
|
}
|
|
@@ -1813,6 +1810,8 @@ function checkProblem2(p) {
|
|
|
1813
1810
|
return `\u041F\u0440\u043E\u0435\u043A\u0442 ${p.projectId}: \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0432\u0435\u0442\u043A\u0438 git \u0432 ${p.repo} (\u0431\u0438\u0442\u0430\u044F \u0441\u0441\u044B\u043B\u043A\u0430 \u0432 refs \u0438\u043B\u0438 \u0441\u0431\u043E\u0439 git) \u2014 \u043F\u0440\u043E\u043F\u0430\u0432\u0448\u0438\u0435 \u0444\u0430\u0439\u043B\u044B \u043A\u043E\u0434\u0430 \u0435\u0433\u043E \u0437\u0430\u0434\u0430\u0447 \u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u044B`;
|
|
1814
1811
|
case "merge-state-unknown":
|
|
1815
1812
|
return `\u041F\u0440\u043E\u0435\u043A\u0442 ${p.projectId}: git \u0432 ${p.repo} \u043D\u0435 \u0441\u043C\u043E\u0433 \u043E\u0442\u0432\u0435\u0442\u0438\u0442\u044C, ${p.branches.length === 1 ? "\u0432\u043B\u0438\u0442\u0430 \u043B\u0438 \u0432\u0435\u0442\u043A\u0430" : "\u0432\u043B\u0438\u0442\u044B \u043B\u0438 \u0432\u0435\u0442\u043A\u0438"} ${p.branches.join(", ")} \u0432 \u0442\u0435\u043A\u0443\u0449\u0443\u044E (\u043D\u0435\u043F\u043E\u043B\u043D\u044B\u0439 \u043A\u043B\u043E\u043D, \u043D\u0435\u0441\u0432\u044F\u0437\u0430\u043D\u043D\u0430\u044F \u0438\u0441\u0442\u043E\u0440\u0438\u044F \u0438\u043B\u0438 \u0441\u0431\u043E\u0439 git) \u2014 \u0441\u043E\u0437\u0434\u0430\u043D\u043D\u044B\u0435 \u0442\u0430\u043C \u0437\u0430\u0434\u0430\u0447\u0438 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u044B \u043A\u0430\u043A \u043E\u0431\u044B\u0447\u043D\u044B\u0435, \u0431\u0435\u0437 \u043E\u0436\u0438\u0434\u0430\u043D\u0438\u044F \u0441\u043B\u0438\u044F\u043D\u0438\u044F`;
|
|
1813
|
+
case "late-commits-unknown":
|
|
1814
|
+
return `\u041F\u0440\u043E\u0435\u043A\u0442 ${p.projectId}: git \u0432 ${p.repo} \u043D\u0435 \u0441\u043C\u043E\u0433 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u043F\u043E\u0437\u0434\u043D\u0438\u0435 \u043A\u043E\u043C\u043C\u0438\u0442\u044B \u0438\u043B\u0438 reflog ${p.taskIds.length === 1 ? "\u0437\u0430\u0434\u0430\u0447\u0438" : "\u0437\u0430\u0434\u0430\u0447"} ${p.taskIds.join(", ")} (\u043D\u0435\u043F\u043E\u043B\u043D\u044B\u0439 \u043A\u043B\u043E\u043D \u0438\u043B\u0438 \u0441\u0431\u043E\u0439 git) \u2014 \u043F\u0440\u0430\u0432\u043A\u0438 \u0438\u0445 \u043A\u043E\u0434\u0430 \u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u044B, \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0441\u044F \u043F\u0440\u0438 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u043C \u0437\u0430\u043F\u0443\u0441\u043A\u0435`;
|
|
1816
1815
|
case "prefix-shared":
|
|
1817
1816
|
return `\u0423 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432 ${p.projectIds.join(", ")} \u043E\u0434\u0438\u043D \u043F\u0440\u0435\u0444\u0438\u043A\u0441 ${p.prefix} \u2014 ID \u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043F\u0435\u0440\u0435\u0441\u0435\u043A\u0430\u044E\u0442\u0441\u044F. \u0421\u043C\u0435\u043D\u0438\u0442\u0435 prefix \u0432 project.md \u043E\u0434\u043D\u043E\u0433\u043E \u0438\u0437 \u043D\u0438\u0445`;
|
|
1818
1817
|
}
|
|
@@ -1874,6 +1873,9 @@ function hookMessage(language, projectId, text) {
|
|
|
1874
1873
|
function isBacklogHookFeedback(text) {
|
|
1875
1874
|
return text.startsWith(STOP_HOOK_FEEDBACK_PREFIX) && LANGUAGES.some((language) => text.includes(`${coreMessages(language).hookMark} `));
|
|
1876
1875
|
}
|
|
1876
|
+
function isBacklogHookReason(text) {
|
|
1877
|
+
return /^\S+ [^\s:]+:/u.test(text) && LANGUAGES.some((language) => text.startsWith(`${coreMessages(language).hookMark} `));
|
|
1878
|
+
}
|
|
1877
1879
|
|
|
1878
1880
|
// src/core/store/journal-compaction.ts
|
|
1879
1881
|
import { basename as basename4, join as join10 } from "node:path";
|
|
@@ -1960,7 +1962,8 @@ var journalEventSchema = z7.discriminatedUnion("kind", [
|
|
|
1960
1962
|
mode: recordedEnum(CHECK_MODES),
|
|
1961
1963
|
method: recordedEnum(CHECK_METHODS).optional(),
|
|
1962
1964
|
...legacyMethodFlagsSchema.shape,
|
|
1963
|
-
match: recordedEnum(DUPLICATE_MATCHES).optional()
|
|
1965
|
+
match: recordedEnum(DUPLICATE_MATCHES).optional(),
|
|
1966
|
+
model: z7.string().trim().min(1).optional().catch(void 0)
|
|
1964
1967
|
}),
|
|
1965
1968
|
z7.object({ ...eventBase, kind: z7.literal("candidate-gone"), evidence: z7.enum(CANDIDATE_EVIDENCE) }),
|
|
1966
1969
|
z7.object({ ...eventBase, kind: z7.literal("candidate-filtered"), symbol: z7.string() })
|
|
@@ -1989,7 +1992,7 @@ function hasUnknownValue(event) {
|
|
|
1989
1992
|
}
|
|
1990
1993
|
function createdEvent(task, now, via, provenance = {}) {
|
|
1991
1994
|
return {
|
|
1992
|
-
at:
|
|
1995
|
+
at: formatLocalIsoWithMilliseconds(now),
|
|
1993
1996
|
task: task.id,
|
|
1994
1997
|
via,
|
|
1995
1998
|
kind: "created",
|
|
@@ -2004,7 +2007,7 @@ function createdEvent(task, now, via, provenance = {}) {
|
|
|
2004
2007
|
};
|
|
2005
2008
|
}
|
|
2006
2009
|
function changeEvents(before, after, now, via, headCommit) {
|
|
2007
|
-
const at =
|
|
2010
|
+
const at = formatLocalIsoWithMilliseconds(now);
|
|
2008
2011
|
const events = [];
|
|
2009
2012
|
if (before.status !== after.status) {
|
|
2010
2013
|
const resolution = isClosed(after.status) ? after.resolution : void 0;
|
|
@@ -2029,19 +2032,23 @@ function withoutUndoneClosings(ordered) {
|
|
|
2029
2032
|
}
|
|
2030
2033
|
return kept;
|
|
2031
2034
|
}
|
|
2035
|
+
function chronologicalEvents(events) {
|
|
2036
|
+
return [...events].sort((a, b) => Date.parse(a.at) - Date.parse(b.at));
|
|
2037
|
+
}
|
|
2032
2038
|
function statusBeforeAutoClose(journal, epicId) {
|
|
2033
|
-
const
|
|
2039
|
+
const autoCloses = journal.filter((event) => event.task === epicId && event.kind === "status" && event.resolution === "epic-done");
|
|
2040
|
+
const autoClose = chronologicalEvents(autoCloses).at(-1);
|
|
2034
2041
|
return autoClose?.kind === "status" && !isClosed(autoClose.from) ? autoClose.from : "backlog";
|
|
2035
2042
|
}
|
|
2036
2043
|
function deletedEvent(task, now, via) {
|
|
2037
|
-
return { at:
|
|
2044
|
+
return { at: formatLocalIsoWithMilliseconds(now), task: task.id, via, kind: "deleted", snapshot: snapshotOf(task) };
|
|
2038
2045
|
}
|
|
2039
2046
|
function snapshotOf(task) {
|
|
2040
2047
|
return Object.fromEntries(SNAPSHOT_FIELDS.map((field) => [field, task[field]]));
|
|
2041
2048
|
}
|
|
2042
2049
|
|
|
2043
2050
|
// src/core/journal/episodes.ts
|
|
2044
|
-
function candidateEvents(sightings, states, now, mode) {
|
|
2051
|
+
function candidateEvents(sightings, states, now, mode, model) {
|
|
2045
2052
|
const at = formatLocalIso(now);
|
|
2046
2053
|
return dedupeSightings(sightings).filter((sighting) => states.get(episodeKey(sighting.task, sighting.evidence)) !== "open").map((sighting) => ({
|
|
2047
2054
|
at,
|
|
@@ -2051,7 +2058,8 @@ function candidateEvents(sightings, states, now, mode) {
|
|
|
2051
2058
|
evidence: sighting.evidence,
|
|
2052
2059
|
mode,
|
|
2053
2060
|
...sighting.method === void 0 ? {} : { method: sighting.method },
|
|
2054
|
-
...sighting.match === void 0 ? {} : { match: sighting.match }
|
|
2061
|
+
...sighting.match === void 0 ? {} : { match: sighting.match },
|
|
2062
|
+
...model === void 0 ? {} : { model }
|
|
2055
2063
|
}));
|
|
2056
2064
|
}
|
|
2057
2065
|
function filteredEvents(filtered, states, now) {
|
|
@@ -2332,13 +2340,22 @@ function retainedLines(lines, liveTaskIds, since) {
|
|
|
2332
2340
|
const keepsHistory = (task) => liveTaskIds.has(task) || (lastSeen.get(task) ?? 0) >= since;
|
|
2333
2341
|
const reportStarts = reportStartEvents(events, keepsHistory);
|
|
2334
2342
|
const openers = episodeOpeners(events);
|
|
2343
|
+
const lastVerifications = lastVerificationWithCommitByTask(events);
|
|
2335
2344
|
const firstRecent = lines.findIndex(({ event }) => event !== null && isRecent(event));
|
|
2336
2345
|
return lines.filter(({ event }, position) => {
|
|
2337
2346
|
if (event === null) return firstRecent !== -1 && position > firstRecent;
|
|
2338
|
-
if (reportStarts.has(event)
|
|
2347
|
+
if (reportStarts.has(event)) return true;
|
|
2348
|
+
if (liveTaskIds.has(event.task) && (openers.has(event) || lastVerifications.get(event.task) === event)) return true;
|
|
2339
2349
|
return EPISODE_KINDS.has(event.kind) ? isRecent(event) : keepsHistory(event.task);
|
|
2340
2350
|
});
|
|
2341
2351
|
}
|
|
2352
|
+
function lastVerificationWithCommitByTask(events) {
|
|
2353
|
+
const lastByTask = /* @__PURE__ */ new Map();
|
|
2354
|
+
for (const event of events) {
|
|
2355
|
+
if (event.kind === "verified" && event.commit !== void 0) lastByTask.set(event.task, event);
|
|
2356
|
+
}
|
|
2357
|
+
return lastByTask;
|
|
2358
|
+
}
|
|
2342
2359
|
function reportStartEvents(events, keepsHistory) {
|
|
2343
2360
|
const journalSince = earliestEvent(events);
|
|
2344
2361
|
const adoptionStart = oldestTask(events.filter((event) => !keepsHistory(event.task)));
|
|
@@ -2509,7 +2526,7 @@ import { dirname as dirname4 } from "node:path";
|
|
|
2509
2526
|
|
|
2510
2527
|
// src/core/model/integrity.ts
|
|
2511
2528
|
function integrityErrors(candidate, index) {
|
|
2512
|
-
const
|
|
2529
|
+
const resolve8 = (id) => id === candidate.id ? candidate : index.byId.get(id);
|
|
2513
2530
|
const errors = [];
|
|
2514
2531
|
if (candidate.blockedBy.includes(candidate.id)) errors.push({ code: "self-block" });
|
|
2515
2532
|
if (candidate.related.includes(candidate.id)) errors.push({ code: "self-related" });
|
|
@@ -2518,7 +2535,7 @@ function integrityErrors(candidate, index) {
|
|
|
2518
2535
|
if (candidate.type === "task" && children.length > 0) {
|
|
2519
2536
|
errors.push({ code: "referenced-as-epic", children: children.map((task) => task.id) });
|
|
2520
2537
|
}
|
|
2521
|
-
const cycle = findBlockerCycle(candidate,
|
|
2538
|
+
const cycle = findBlockerCycle(candidate, resolve8);
|
|
2522
2539
|
if (cycle) errors.push({ code: "blocker-cycle", cycle });
|
|
2523
2540
|
if (candidate.resolution !== void 0 && candidate.status !== RESOLUTION_STATUS[candidate.resolution]) {
|
|
2524
2541
|
errors.push({ code: "resolution-needs-status", resolution: candidate.resolution, status: RESOLUTION_STATUS[candidate.resolution] });
|
|
@@ -2550,14 +2567,14 @@ function taskWarnings(task, index) {
|
|
|
2550
2567
|
function missingReferenceProblem(id, file) {
|
|
2551
2568
|
return file === void 0 ? { code: "reference-missing", id } : { code: "reference-unparsed", id, fileKind: file };
|
|
2552
2569
|
}
|
|
2553
|
-
function findBlockerCycle(start,
|
|
2570
|
+
function findBlockerCycle(start, resolve8) {
|
|
2554
2571
|
const visited = /* @__PURE__ */ new Set();
|
|
2555
2572
|
const walk = (task, path) => {
|
|
2556
2573
|
for (const blockerId of task.blockedBy) {
|
|
2557
2574
|
if (blockerId === start.id) return [...path, blockerId];
|
|
2558
2575
|
if (visited.has(blockerId)) continue;
|
|
2559
2576
|
visited.add(blockerId);
|
|
2560
|
-
const blocker =
|
|
2577
|
+
const blocker = resolve8(blockerId);
|
|
2561
2578
|
const cycle = blocker ? walk(blocker, [...path, blockerId]) : null;
|
|
2562
2579
|
if (cycle) return cycle;
|
|
2563
2580
|
}
|
|
@@ -3423,7 +3440,7 @@ function createLimiter(maxRunning) {
|
|
|
3423
3440
|
running++;
|
|
3424
3441
|
return Promise.resolve();
|
|
3425
3442
|
}
|
|
3426
|
-
return new Promise((
|
|
3443
|
+
return new Promise((resolve8) => waiting.push(resolve8));
|
|
3427
3444
|
};
|
|
3428
3445
|
return async (task) => {
|
|
3429
3446
|
await acquire2();
|
|
@@ -3785,6 +3802,9 @@ function movedPlan(id, from, to) {
|
|
|
3785
3802
|
function judgedByCommits(task, anchors) {
|
|
3786
3803
|
return task.source !== void 0 && anchors.get(task.id)?.kind === "none";
|
|
3787
3804
|
}
|
|
3805
|
+
function namesCommitsSinceMark(task, anchors) {
|
|
3806
|
+
return judgedByCommits(task, anchors) || anchors.get(task.id)?.kind === "changed";
|
|
3807
|
+
}
|
|
3788
3808
|
function anchorState(task, facts) {
|
|
3789
3809
|
return anchorStateIn(task, task.source === void 0 ? void 0 : facts.texts.get(sourcePath(task.source)));
|
|
3790
3810
|
}
|
|
@@ -3811,7 +3831,7 @@ function presenceOffDisk(path, branches) {
|
|
|
3811
3831
|
}
|
|
3812
3832
|
}
|
|
3813
3833
|
function livesOnAnotherBranch(path, facts) {
|
|
3814
|
-
return !committedIn(facts.committedHere, path) && committedIn(facts.
|
|
3834
|
+
return !committedIn(facts.committedHere, path) && committedIn(facts.onBranchTips, path);
|
|
3815
3835
|
}
|
|
3816
3836
|
function committedIn(files, path) {
|
|
3817
3837
|
return [...files].some((file) => isWithin(file, path));
|
|
@@ -4265,7 +4285,7 @@ function fileVersion({ mode = "", object = "", path = "" } = {}) {
|
|
|
4265
4285
|
// src/core/check/rewritten-branch.ts
|
|
4266
4286
|
var DETACHED_HEAD_EXIT = 1;
|
|
4267
4287
|
var NOT_AN_ANCESTOR_EXIT2 = 1;
|
|
4268
|
-
var
|
|
4288
|
+
var REBASE_STEP = /^(?:rebase|pull)\b.*(?:\([a-z-]+\)|finished): /;
|
|
4269
4289
|
var AMEND = /^commit \(amend\):/;
|
|
4270
4290
|
var REWRITTEN_BY_UPDATE_REFS = /^rewritten during rebase$/;
|
|
4271
4291
|
function currentBranchRewroteTipOf(repo, git) {
|
|
@@ -4273,35 +4293,49 @@ function currentBranchRewroteTipOf(repo, git) {
|
|
|
4273
4293
|
const stepLines = /* @__PURE__ */ new Map();
|
|
4274
4294
|
const stepLine = (step, index) => remembered(stepLines, index, () => lineOfStep(repo, step, git));
|
|
4275
4295
|
return async (tip) => {
|
|
4276
|
-
const
|
|
4277
|
-
if (
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
if (
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
if (line === "leaves-line") return "not-rewritten";
|
|
4287
|
-
if (line === "unknown") rewrite = "unknown";
|
|
4296
|
+
const line = await (history ??= currentLineHistory(repo, git));
|
|
4297
|
+
if (line.kind === "unreadable") return "unknown";
|
|
4298
|
+
const rewrite = await newestRewriteOf(repo, tip, line.stepsNewestFirst, git);
|
|
4299
|
+
if (rewrite.kind === "none") return "not-rewritten";
|
|
4300
|
+
if (rewrite.kind === "unknown") return "unknown";
|
|
4301
|
+
let answer = "rewritten";
|
|
4302
|
+
for (const [index, step] of line.stepsNewestFirst.slice(0, rewrite.stepIndex + 1).entries()) {
|
|
4303
|
+
const stepAnswer = await stepLine(step, index);
|
|
4304
|
+
if (stepAnswer === "leaves-line") return "not-rewritten";
|
|
4305
|
+
if (stepAnswer === "unknown") answer = "unknown";
|
|
4288
4306
|
}
|
|
4289
|
-
return
|
|
4307
|
+
return answer;
|
|
4290
4308
|
};
|
|
4291
4309
|
}
|
|
4292
|
-
async function
|
|
4310
|
+
async function currentLineHistory(repo, git) {
|
|
4293
4311
|
const symbolicHead = await git(repo, ["symbolic-ref", "-q", "HEAD"]);
|
|
4294
|
-
|
|
4295
|
-
const
|
|
4296
|
-
if (
|
|
4297
|
-
const reflog = outputLines(stdoutOf(await git(repo, ["log", "--walk-reflogs", `--format=%H${FIELD}%P${FIELD}%gs`,
|
|
4312
|
+
const detached = symbolicHead.status === "exited" && symbolicHead.exitCode === DETACHED_HEAD_EXIT;
|
|
4313
|
+
const ref = detached ? "HEAD" : outputLine(stdoutOf(symbolicHead));
|
|
4314
|
+
if (ref === null) return { kind: "unreadable" };
|
|
4315
|
+
const reflog = outputLines(stdoutOf(await git(repo, ["log", "--walk-reflogs", `--format=%H${FIELD}%P${FIELD}%gs`, ref, "--"])));
|
|
4298
4316
|
if (reflog === null) return { kind: "unreadable" };
|
|
4299
|
-
const movesNewestFirst = reflog.map(
|
|
4317
|
+
const movesNewestFirst = reflog.map(lineMove);
|
|
4300
4318
|
const stepsNewestFirst = movesNewestFirst.flatMap((to, index) => {
|
|
4301
4319
|
const from = movesNewestFirst[index + 1];
|
|
4302
4320
|
return from === void 0 ? [] : [{ from: from.commit, to }];
|
|
4303
4321
|
});
|
|
4304
|
-
return { kind: "read",
|
|
4322
|
+
return { kind: "read", stepsNewestFirst };
|
|
4323
|
+
}
|
|
4324
|
+
async function newestRewriteOf(repo, commit, stepsNewestFirst, git) {
|
|
4325
|
+
const rewrites = stepsNewestFirst.flatMap(({ from, to }, stepIndex) => isRewrite(to) ? [{ from, stepIndex }] : []);
|
|
4326
|
+
if (rewrites.length === 0) return { kind: "none" };
|
|
4327
|
+
const revisions = [commit, "--not", ...rewrites.map(({ from }) => from)];
|
|
4328
|
+
const outsideRewrittenLines = outputLines(stdoutOf(await git(repo, ["rev-list", "-n1", "--stdin"], revisions.map((revision) => `${revision}
|
|
4329
|
+
`).join(""))));
|
|
4330
|
+
if (outsideRewrittenLines === null) return { kind: "unknown" };
|
|
4331
|
+
if (outsideRewrittenLines.length > 0) return { kind: "none" };
|
|
4332
|
+
for (const { from, stepIndex } of rewrites) {
|
|
4333
|
+
if (from === commit) return { kind: "found", stepIndex };
|
|
4334
|
+
const isAncestor = await git(repo, ["merge-base", "--is-ancestor", commit, from]);
|
|
4335
|
+
if (isAncestor.status === "ok") return { kind: "found", stepIndex };
|
|
4336
|
+
if (isAncestor.status !== "exited" || isAncestor.exitCode !== NOT_AN_ANCESTOR_EXIT2) return { kind: "unknown" };
|
|
4337
|
+
}
|
|
4338
|
+
return { kind: "none" };
|
|
4305
4339
|
}
|
|
4306
4340
|
async function lineOfStep(repo, { from, to }, git) {
|
|
4307
4341
|
if (isRewrite(to) || to.parents.includes(from)) return "keeps-line";
|
|
@@ -4310,9 +4344,9 @@ async function lineOfStep(repo, { from, to }, git) {
|
|
|
4310
4344
|
return fromIsAncestor.status === "exited" && fromIsAncestor.exitCode === NOT_AN_ANCESTOR_EXIT2 ? "leaves-line" : "unknown";
|
|
4311
4345
|
}
|
|
4312
4346
|
function isRewrite({ subject }) {
|
|
4313
|
-
return
|
|
4347
|
+
return REBASE_STEP.test(subject) || AMEND.test(subject) || REWRITTEN_BY_UPDATE_REFS.test(subject);
|
|
4314
4348
|
}
|
|
4315
|
-
function
|
|
4349
|
+
function lineMove(line) {
|
|
4316
4350
|
const [commit = "", parents = "", subject = ""] = line.split(FIELD);
|
|
4317
4351
|
return { commit, parents: parents.split(" ").filter((parent) => parent !== ""), subject };
|
|
4318
4352
|
}
|
|
@@ -4325,6 +4359,7 @@ var STATUS_CODE_WIDTH = 3;
|
|
|
4325
4359
|
var RENAME_OR_COPY = /^[RC]/;
|
|
4326
4360
|
var DELETED_FILE_HEADER = /^deleted file mode /m;
|
|
4327
4361
|
var ORIGINAL_PATH_FOLLOWS = /^(?:[RC].|.[RC])/;
|
|
4362
|
+
var BRANCH_REFS = ["refs/heads", "refs/remotes"];
|
|
4328
4363
|
var LOG_FORMAT = `--format=${RECORD}%H${FIELD}%h${FIELD}%cI${FIELD}%P${FIELD}%s`;
|
|
4329
4364
|
var FACTS_HISTORY_OPTIONS = ["--full-history"];
|
|
4330
4365
|
async function locateRepo(repo, git = runGitOutcome) {
|
|
@@ -4340,7 +4375,7 @@ async function locateRepo(repo, git = runGitOutcome) {
|
|
|
4340
4375
|
function trustCommandIn(stderr) {
|
|
4341
4376
|
return stderr.split("\n").map((line) => line.trim()).find((line) => TRUST_COMMAND.test(line));
|
|
4342
4377
|
}
|
|
4343
|
-
async function collectRepoFacts(repo, pathMarks,
|
|
4378
|
+
async function collectRepoFacts(repo, pathMarks, gitOutcome = runGitOutcome) {
|
|
4344
4379
|
const git = asGitRunner(gitOutcome);
|
|
4345
4380
|
const paths = [...pathMarks.keys()];
|
|
4346
4381
|
const [location, files] = await Promise.all([locateRepo(repo, gitOutcome), sourceFiles(repo, paths)]);
|
|
@@ -4352,20 +4387,27 @@ async function collectRepoFacts(repo, pathMarks, known, gitOutcome = runGitOutco
|
|
|
4352
4387
|
hasCommits && paths.length > 0 ? pathLog(repo, [sinceEarliestMark(pathMarks, paths)], paths, git) : "",
|
|
4353
4388
|
hasCommits && missing.length > 0 ? git(repo, [...logArgs([sinceEarliestMark(pathMarks, missing)]), "--diff-filter=R"]) : "",
|
|
4354
4389
|
git(repo, ["status", "--porcelain=v1", "-z", "--untracked-files=no"]),
|
|
4355
|
-
branchHistoryOf(repo, location, missing,
|
|
4390
|
+
branchHistoryOf(repo, location, missing, git)
|
|
4356
4391
|
]);
|
|
4357
4392
|
if (log === null || renames === null || status === null) return withoutHistory({ history: "unreadable" });
|
|
4358
4393
|
const dirty = withinRepo(parseStatus(status), prefix);
|
|
4359
4394
|
return { history: "read", commits: parseLog(log), renames: parseLog(renames), dirtyModifiedAt: await modificationTimes(repo, dirty), branches, ...files };
|
|
4360
4395
|
}
|
|
4361
|
-
async function branchHistoryOf(repo, location, paths,
|
|
4396
|
+
async function branchHistoryOf(repo, location, paths, git = runGit) {
|
|
4362
4397
|
if (location.history !== "read") return unknownBranches(location.history);
|
|
4363
|
-
const [here,
|
|
4364
|
-
return here === null ||
|
|
4398
|
+
const [here, onTips] = await Promise.all([location.hasCommits ? committedPaths(repo, "HEAD", paths, git) : [], pathsOnBranchTips(repo, paths, git)]);
|
|
4399
|
+
return here === null || onTips === null ? { kind: "unreadable" } : { kind: "read", committedHere: new Set(here), onBranchTips: new Set(onTips) };
|
|
4365
4400
|
}
|
|
4366
|
-
function
|
|
4367
|
-
|
|
4368
|
-
return [
|
|
4401
|
+
async function pathsOnBranchTips(repo, paths, git) {
|
|
4402
|
+
const inside = paths.filter(isInsideRepo);
|
|
4403
|
+
if (inside.length === 0) return [];
|
|
4404
|
+
const tips = outputLines(await git(repo, ["for-each-ref", "--format=%(objectname)", ...BRANCH_REFS]));
|
|
4405
|
+
if (tips === null) return null;
|
|
4406
|
+
const uniqueTips = [...new Set(tips)];
|
|
4407
|
+
const atTip = (tip, path) => `${tip}:./${path}`;
|
|
4408
|
+
const ids = await objectIds(git, repo, [...uniqueTips, ...uniqueTips.flatMap((tip) => inside.map((path) => atTip(tip, path)))]);
|
|
4409
|
+
if (ids === null || !uniqueTips.every((tip) => ids.has(tip))) return null;
|
|
4410
|
+
return inside.filter((path) => uniqueTips.some((tip) => ids.has(atTip(tip, path))));
|
|
4369
4411
|
}
|
|
4370
4412
|
async function pathsEverCommitted(repo, paths) {
|
|
4371
4413
|
const location = await locateRepo(repo);
|
|
@@ -4410,10 +4452,13 @@ function diffsSince(repo, git = runGit, diffFrom = diffsFrom(repo, git)) {
|
|
|
4410
4452
|
};
|
|
4411
4453
|
}
|
|
4412
4454
|
function headCommitsAt(repo, git) {
|
|
4413
|
-
let moves
|
|
4455
|
+
let moves;
|
|
4414
4456
|
return async (moment) => {
|
|
4415
4457
|
moves ??= headMovesNewestFirst(repo, git);
|
|
4416
|
-
|
|
4458
|
+
const known = await moves;
|
|
4459
|
+
if (known === null) return { kind: "unknown" };
|
|
4460
|
+
const move = known.find(({ at }) => at <= moment.getTime());
|
|
4461
|
+
return move === void 0 ? { kind: "none" } : { kind: "found", commit: move.commit };
|
|
4417
4462
|
};
|
|
4418
4463
|
}
|
|
4419
4464
|
function headLineOf(repo, gitOutcome, ancestryOf) {
|
|
@@ -4449,8 +4494,9 @@ async function lineOfNonAncestor(repo, commit, git, rewroteTip) {
|
|
|
4449
4494
|
}
|
|
4450
4495
|
}
|
|
4451
4496
|
async function headMovesNewestFirst(repo, git) {
|
|
4452
|
-
const reflog = await git(repo, ["log", "--walk-reflogs", "--date=unix", `--format=%H${FIELD}%gd`, "HEAD"]);
|
|
4453
|
-
|
|
4497
|
+
const reflog = await git(repo, ["log", "--ignore-missing", "--walk-reflogs", "--date=unix", `--format=%H${FIELD}%gd`, "HEAD"]);
|
|
4498
|
+
if (reflog === null) return null;
|
|
4499
|
+
return reflog.split("\n").flatMap((line) => {
|
|
4454
4500
|
const [commit = "", selector = ""] = line.split(FIELD);
|
|
4455
4501
|
const seconds = REFLOG_MOMENT.exec(selector)?.[1];
|
|
4456
4502
|
return seconds === void 0 ? [] : [{ commit, at: Number(seconds) * SECOND_MS }];
|
|
@@ -4564,15 +4610,23 @@ function taskBases(repo, marks, gitOutcome = runGitOutcome) {
|
|
|
4564
4610
|
const reflogCommit = () => headCommitAt(new Date(reviewMark(task)));
|
|
4565
4611
|
const recorded = commitAtMark(task, marks);
|
|
4566
4612
|
if (recorded === void 0) return reflogCommit();
|
|
4567
|
-
|
|
4568
|
-
|
|
4613
|
+
const found = { kind: "found", commit: recorded };
|
|
4614
|
+
const line = await headLine(recorded);
|
|
4615
|
+
if (line === "missing") {
|
|
4616
|
+
const fromReflog = await reflogCommit();
|
|
4617
|
+
return fromReflog.kind === "found" && await headLine(fromReflog.commit) === "other-branch" ? found : fromReflog;
|
|
4618
|
+
}
|
|
4619
|
+
if (line === "other-branch" && task.verified !== void 0) return reflogCommit();
|
|
4620
|
+
return found;
|
|
4569
4621
|
});
|
|
4570
4622
|
const bases = /* @__PURE__ */ new Map();
|
|
4571
4623
|
const baseOf = (task) => remembered(bases, task.id, async () => {
|
|
4572
4624
|
const since = new Date(reviewMark(task));
|
|
4573
4625
|
const noCommitAtMark = async () => ({ kind: "approximate", since, markLine: await cloneCompleteness() === "full" ? "this-line" : "unknown" });
|
|
4574
|
-
const
|
|
4575
|
-
if (
|
|
4626
|
+
const lookup = await markCommit(task);
|
|
4627
|
+
if (lookup.kind === "none") return noCommitAtMark();
|
|
4628
|
+
if (lookup.kind === "unknown") return { kind: "unknown" };
|
|
4629
|
+
const { commit } = lookup;
|
|
4576
4630
|
const line = await headLine(commit);
|
|
4577
4631
|
switch (line) {
|
|
4578
4632
|
case "this-line":
|
|
@@ -4608,16 +4662,6 @@ function markLineOf(base) {
|
|
|
4608
4662
|
return "unknown";
|
|
4609
4663
|
}
|
|
4610
4664
|
}
|
|
4611
|
-
function seenFromHead(line) {
|
|
4612
|
-
switch (line) {
|
|
4613
|
-
case "this-line":
|
|
4614
|
-
case "unknown":
|
|
4615
|
-
return true;
|
|
4616
|
-
case "other-branch":
|
|
4617
|
-
case "missing":
|
|
4618
|
-
return false;
|
|
4619
|
-
}
|
|
4620
|
-
}
|
|
4621
4665
|
|
|
4622
4666
|
// src/core/check/current-source.ts
|
|
4623
4667
|
var LATER_COMMITS_TO_SEARCH = 5;
|
|
@@ -4704,15 +4748,15 @@ async function projectCheckouts(project, { workingRoots, ...context }) {
|
|
|
4704
4748
|
return [{ path: workingRoots.worktree, linkedWorktree: workingRoots.worktree !== workingRoots.main, holdsCwd: true }, ...others];
|
|
4705
4749
|
}
|
|
4706
4750
|
async function explicitSourceRepo(project, lookup, source) {
|
|
4707
|
-
const [choice] =
|
|
4751
|
+
const [choice] = await sourceChoices(await projectCheckouts(project, lookup), [{ source }]);
|
|
4708
4752
|
return choice === void 0 ? void 0 : repoChoice(choice.checkout, choice.settled || choice.checkout.holdsCwd);
|
|
4709
4753
|
}
|
|
4710
4754
|
async function taskRepo(project, lookup, task, marks) {
|
|
4711
|
-
const [choice] =
|
|
4755
|
+
const [choice] = await sourceChoices(await projectCheckouts(project, lookup), [ownedSource(task, marks)]);
|
|
4712
4756
|
return choice === void 0 ? void 0 : repoChoice(choice.checkout, choice.settled);
|
|
4713
4757
|
}
|
|
4714
4758
|
async function tasksByCheckout(checkouts, tasks, marks) {
|
|
4715
|
-
const
|
|
4759
|
+
const choices = await sourceChoices(
|
|
4716
4760
|
checkouts,
|
|
4717
4761
|
tasks.map((task) => ownedSource(task, marks))
|
|
4718
4762
|
);
|
|
@@ -4720,7 +4764,7 @@ async function tasksByCheckout(checkouts, tasks, marks) {
|
|
|
4720
4764
|
return checkouts.flatMap((checkout) => {
|
|
4721
4765
|
const own = chosen.filter(({ choice }) => choice?.checkout === checkout);
|
|
4722
4766
|
const unsettled = new Set(own.filter(({ choice }) => choice?.settled === false).map(({ task }) => task.id));
|
|
4723
|
-
return own.length === 0 ? [] : [{ checkout, tasks: own.map(({ task }) => task), unsettled
|
|
4767
|
+
return own.length === 0 ? [] : [{ checkout, tasks: own.map(({ task }) => task), unsettled }];
|
|
4724
4768
|
});
|
|
4725
4769
|
}
|
|
4726
4770
|
function repoChoice({ path }, recordable) {
|
|
@@ -4731,8 +4775,8 @@ function ownedSource(task, marks) {
|
|
|
4731
4775
|
}
|
|
4732
4776
|
async function sourceChoices(checkouts, tasks) {
|
|
4733
4777
|
const [first] = checkouts;
|
|
4734
|
-
if (first === void 0) return
|
|
4735
|
-
if (checkouts.length === 1) return
|
|
4778
|
+
if (first === void 0) return tasks.map(() => void 0);
|
|
4779
|
+
if (checkouts.length === 1) return tasks.map(() => ({ checkout: first, settled: true }));
|
|
4736
4780
|
const [onDisk, ownerOf] = await Promise.all([Promise.all(tasks.map((task) => checkoutsWithSource(checkouts, task.source))), ownerCheckouts(checkouts, tasks)]);
|
|
4737
4781
|
const ownerHistories = await askHistories(
|
|
4738
4782
|
checkouts,
|
|
@@ -4743,14 +4787,13 @@ async function sourceChoices(checkouts, tasks) {
|
|
|
4743
4787
|
tasks.flatMap((task, index) => otherQuestions(checkouts, task, onDisk[index] ?? [], ownerOf(task), ownerHistories))
|
|
4744
4788
|
);
|
|
4745
4789
|
const histories = mergedHistories(ownerHistories, otherHistories);
|
|
4746
|
-
|
|
4790
|
+
return Promise.all(
|
|
4747
4791
|
tasks.map((task, index) => {
|
|
4748
4792
|
const path = task.source === void 0 ? void 0 : sourcePath(task.source);
|
|
4749
4793
|
const traceIn = (checkout) => path === void 0 ? "none" : traceOf(histories, checkout, path);
|
|
4750
4794
|
return sourceChoice(checkouts, first, task, { onDisk: onDisk[index] ?? [], owner: ownerOf(task), traceIn });
|
|
4751
4795
|
})
|
|
4752
4796
|
);
|
|
4753
|
-
return { choices, histories };
|
|
4754
4797
|
}
|
|
4755
4798
|
async function sourceChoice(checkouts, first, task, evidence2) {
|
|
4756
4799
|
if (task.source === void 0) return { checkout: first, settled: true };
|
|
@@ -5027,14 +5070,22 @@ function lookupProjectForDir(known, dir, dirRoots, context) {
|
|
|
5027
5070
|
return lookupProjectCanonicalizing(known, dir, dirRoots, strictly(context));
|
|
5028
5071
|
}
|
|
5029
5072
|
async function lookupProjectForRecordedDir(known, dir, { lookupRepoRoot, worktreeRepos }, context) {
|
|
5030
|
-
const dirRoots = await lookupRepoRoot(dir);
|
|
5031
5073
|
const leniently = { ...context, canonicalize: realpathThroughExistingAncestor };
|
|
5032
|
-
const
|
|
5074
|
+
const live = await lookupLiveProject(known, dir, lookupRepoRoot, leniently);
|
|
5075
|
+
const owners = recordedOwnersOf(known, dir, worktreeRepos, leniently);
|
|
5076
|
+
const current = live ?? owners.at(-1)?.lookup ?? { broken: [] };
|
|
5077
|
+
const pastOwners = owners.slice(0, -1);
|
|
5078
|
+
const ownerAt = (at) => Math.max(
|
|
5079
|
+
0,
|
|
5080
|
+
owners.findLastIndex(({ since }) => since <= at)
|
|
5081
|
+
);
|
|
5082
|
+
return (at) => pastOwners[ownerAt(at)]?.lookup ?? current;
|
|
5083
|
+
}
|
|
5084
|
+
async function lookupLiveProject(known, dir, lookupRepoRoot, context) {
|
|
5085
|
+
const dirRoots = await lookupRepoRoot(dir);
|
|
5086
|
+
const byPath = lookupProjectCanonicalizing(known, dir, dirRoots, context);
|
|
5033
5087
|
if ("project" in byPath || byPath.broken.length > 0 || dirRoots !== "not-in-repo") return byPath;
|
|
5034
|
-
|
|
5035
|
-
if (byLiveAncestor !== null) return byLiveAncestor;
|
|
5036
|
-
const recordedWorktree = recordedWorktreeOf(dir, worktreeRepos, context);
|
|
5037
|
-
return recordedWorktree === null ? byPath : lookupProjectCanonicalizing(known, dir, recordedWorktree, leniently);
|
|
5088
|
+
return lookupThroughLiveAncestor(known, dir, lookupRepoRoot, context);
|
|
5038
5089
|
}
|
|
5039
5090
|
async function lookupThroughLiveAncestor(known, dir, lookupRepoRoot, context) {
|
|
5040
5091
|
const ancestor = attemptReportingFailureSync(dir, nearestExistingAncestor, context.onUnreadable);
|
|
@@ -5044,11 +5095,13 @@ async function lookupThroughLiveAncestor(known, dir, lookupRepoRoot, context) {
|
|
|
5044
5095
|
}
|
|
5045
5096
|
function unreadableDirHasNoRepo() {
|
|
5046
5097
|
}
|
|
5047
|
-
function
|
|
5048
|
-
const path = attemptReportingFailureSync(dir, realpathThroughExistingAncestor, onUnreadable);
|
|
5049
|
-
if (path === null) return
|
|
5050
|
-
const [deepest] = Object.entries(worktreeRepos).filter(([
|
|
5051
|
-
|
|
5098
|
+
function recordedOwnersOf(known, dir, worktreeRepos, context) {
|
|
5099
|
+
const path = attemptReportingFailureSync(dir, realpathThroughExistingAncestor, context.onUnreadable);
|
|
5100
|
+
if (path === null) return [];
|
|
5101
|
+
const [deepest] = Object.entries(worktreeRepos).filter(([worktree2]) => isSameOrInside(path, worktree2)).sort(([a], [b]) => b.length - a.length);
|
|
5102
|
+
if (deepest === void 0) return [];
|
|
5103
|
+
const [worktree, tenures] = deepest;
|
|
5104
|
+
return tenures.toSorted((a, b) => a.since - b.since).map(({ main, since }) => ({ since, lookup: lookupProjectCanonicalizing(known, dir, { worktree, main }, context) }));
|
|
5052
5105
|
}
|
|
5053
5106
|
function lookupProjectCanonicalizing(known, dir, dirRoots, context) {
|
|
5054
5107
|
const roots = matchingRoots(dir, dirRoots, context);
|
|
@@ -5484,8 +5537,8 @@ async function commitsKnownAtMark({ repo, tasks, facts, anchors, git = runGit, b
|
|
|
5484
5537
|
if (task.source === void 0 || !judgedByCommits(task, anchors)) return [];
|
|
5485
5538
|
const path = sourcePath(task.source);
|
|
5486
5539
|
const changes = commitsTouchingSince(facts.commits, path, reviewMark(task));
|
|
5487
|
-
const
|
|
5488
|
-
return
|
|
5540
|
+
const lookup = changes.length === 0 ? null : await bases.markCommit(task);
|
|
5541
|
+
return lookup?.kind === "found" ? [{ taskId: task.id, site: { commit: lookup.commit, path }, changes }] : [];
|
|
5489
5542
|
})
|
|
5490
5543
|
);
|
|
5491
5544
|
const questions = asked.flat();
|
|
@@ -5527,7 +5580,10 @@ async function commitsArrivedLate(question) {
|
|
|
5527
5580
|
if (question.facts.history !== "read") return NO_LATE_ARRIVALS;
|
|
5528
5581
|
const { repo, git = runGitOutcome, bases = taskBases(repo, question.marks, git) } = question;
|
|
5529
5582
|
const history = { repo, git: asGitRunner(git), bases };
|
|
5530
|
-
const
|
|
5583
|
+
const sources = await lookedUpSources(question, bases);
|
|
5584
|
+
const marked = sources.flatMap(({ lookup, ...source }) => lookup.kind === "found" ? [{ ...source, markCommit: lookup.commit }] : []);
|
|
5585
|
+
const markUnknown = sources.flatMap(({ task, lookup }) => lookup.kind === "unknown" ? [{ taskId: task.id, commits: null }] : []);
|
|
5586
|
+
const arrivals = [...markUnknown, ...await arrivalsOf(history, marked)];
|
|
5531
5587
|
return {
|
|
5532
5588
|
late: new Map(arrivals.flatMap(({ taskId, commits }) => commits === null ? [] : [[taskId, commits]])),
|
|
5533
5589
|
unknown: new Set(arrivals.filter(({ commits }) => commits === null).map(({ taskId }) => taskId))
|
|
@@ -5551,14 +5607,14 @@ async function arrivalsOf(history, marked) {
|
|
|
5551
5607
|
);
|
|
5552
5608
|
return [...unknown, ...byMarkCommit.flat()];
|
|
5553
5609
|
}
|
|
5554
|
-
async function
|
|
5610
|
+
async function lookedUpSources({ tasks, facts, anchors, knownCommits }, bases) {
|
|
5555
5611
|
const sourcesByTask = await Promise.all(
|
|
5556
5612
|
tasks.map(async (task) => {
|
|
5557
|
-
if (task.source === void 0 || !
|
|
5613
|
+
if (task.source === void 0 || !namesCommitsSinceMark(task, anchors)) return [];
|
|
5558
5614
|
const path = sourcePath(task.source);
|
|
5559
5615
|
if (!facts.existing.has(path) || !isInsideRepo(path) || changedByDate(task, path, facts, knownCommits)) return [];
|
|
5560
|
-
const
|
|
5561
|
-
return
|
|
5616
|
+
const lookup = await bases.markCommit(task);
|
|
5617
|
+
return lookup.kind === "none" ? [] : [{ task, path, mark: reviewMark(task), lookup }];
|
|
5562
5618
|
})
|
|
5563
5619
|
);
|
|
5564
5620
|
return sourcesByTask.flat();
|
|
@@ -5877,8 +5933,8 @@ async function projectReview(project, allTasks, { checkouts, git = runGitOutcome
|
|
|
5877
5933
|
if (checkouts.length === 0)
|
|
5878
5934
|
return { ...nothing, candidates: scope.mode === "full" ? duplicateCandidates(tasks) : [], unchecked: [...evidenceOf(tasks, "source-changed"), ...evidenceOf(tasks, "source-missing")] };
|
|
5879
5935
|
const reviews = await Promise.all(
|
|
5880
|
-
(await tasksByCheckout(checkouts, tasks, scope.marks)).map(async ({ checkout, tasks: own, unsettled
|
|
5881
|
-
const review = await repoReview(project, own, { ...scope, repo: checkout.path, git
|
|
5936
|
+
(await tasksByCheckout(checkouts, tasks, scope.marks)).map(async ({ checkout, tasks: own, unsettled }) => {
|
|
5937
|
+
const review = await repoReview(project, own, { ...scope, repo: checkout.path, git });
|
|
5882
5938
|
return { ...review, plans: checkout.linkedWorktree ? [] : review.plans.filter((plan) => !unsettled.has(plan.id)) };
|
|
5883
5939
|
})
|
|
5884
5940
|
);
|
|
@@ -5898,7 +5954,7 @@ async function projectReview(project, allTasks, { checkouts, git = runGitOutcome
|
|
|
5898
5954
|
}
|
|
5899
5955
|
async function repoReview(project, tasks, scope) {
|
|
5900
5956
|
const { repo, marks, mode, onUnreadable, git } = scope;
|
|
5901
|
-
const facts = await collectRepoFacts(repo, earliestMarks(tasks),
|
|
5957
|
+
const facts = await collectRepoFacts(repo, earliestMarks(tasks), git);
|
|
5902
5958
|
for (const [path, error] of facts.unreadable) onUnreadable(join18(repo, path), error);
|
|
5903
5959
|
const skipped = new Set(tasks.filter((task) => task.source !== void 0 && facts.unreadable.has(sourcePath(task.source))).map((task) => task.id));
|
|
5904
5960
|
const readable = tasks.filter((task) => !skipped.has(task.id));
|
|
@@ -5917,7 +5973,7 @@ async function repoReview(project, tasks, scope) {
|
|
|
5917
5973
|
return {
|
|
5918
5974
|
...judged,
|
|
5919
5975
|
skipped: [...skipped],
|
|
5920
|
-
problems: [...historyProblems(project, repo, facts), ...mergeProblems],
|
|
5976
|
+
problems: [...historyProblems(project, repo, facts), ...lateCommitsProblems(project, repo, lateUnknown), ...mergeProblems],
|
|
5921
5977
|
unchecked: uncheckedEvidence(tasks, anchors, facts, lateUnknown),
|
|
5922
5978
|
symbols: mode === "full" ? repoSymbolNames(repo, readable, context) : /* @__PURE__ */ new Map()
|
|
5923
5979
|
};
|
|
@@ -6004,7 +6060,7 @@ function involvedTaskIds({ kept, filtered, plans }) {
|
|
|
6004
6060
|
return [.../* @__PURE__ */ new Set([...kept.map((candidate) => candidate.task.id), ...filtered.map((sighting) => sighting.task), ...plans.map((plan) => plan.id)])];
|
|
6005
6061
|
}
|
|
6006
6062
|
function uncheckedEvidence(tasks, anchors, { history, branches, existing }, lateUnknown) {
|
|
6007
|
-
const changeUnchecked = tasks.filter((task) => history
|
|
6063
|
+
const changeUnchecked = tasks.filter((task) => judgedByCommits(task, anchors) && (history !== "read" || lateUnknown.has(task.id)));
|
|
6008
6064
|
const missingUnchecked = branches.kind === "unreadable" ? tasks.filter((task) => task.source !== void 0 && !existing.has(sourcePath(task.source))) : [];
|
|
6009
6065
|
return [...evidenceOf(changeUnchecked, "source-changed"), ...evidenceOf(missingUnchecked, "source-missing")];
|
|
6010
6066
|
}
|
|
@@ -6023,6 +6079,9 @@ function historyProblems(project, repo, facts) {
|
|
|
6023
6079
|
return [{ kind: "project-history-unreadable", projectId: project.id, repo }];
|
|
6024
6080
|
}
|
|
6025
6081
|
}
|
|
6082
|
+
function lateCommitsProblems(project, repo, lateUnknown) {
|
|
6083
|
+
return lateUnknown.size === 0 ? [] : [{ kind: "late-commits-unknown", projectId: project.id, repo, taskIds: [...lateUnknown] }];
|
|
6084
|
+
}
|
|
6026
6085
|
function earliestMarks(tasks) {
|
|
6027
6086
|
const marks = /* @__PURE__ */ new Map();
|
|
6028
6087
|
for (const task of tasks) {
|
|
@@ -6110,7 +6169,7 @@ function candidateOutcome(reviews) {
|
|
|
6110
6169
|
unjudged: new Set(reviews.flatMap((review) => [...review.awaitingMerge, ...review.skipped]))
|
|
6111
6170
|
};
|
|
6112
6171
|
}
|
|
6113
|
-
async function recordCandidates(root, tasks, { candidates, filtered, unchecked, unjudged }, { mode, now, projectIds, messages, warn: warn2 }) {
|
|
6172
|
+
async function recordCandidates(root, tasks, { candidates, filtered, unchecked, unjudged }, { mode, now, projectIds, messages, warn: warn2, model }) {
|
|
6114
6173
|
const projectOf2 = new Map(tasks.map((task) => [task.id, task.projectId]));
|
|
6115
6174
|
for (const projectId of projectIds) {
|
|
6116
6175
|
const dir = join19(root, projectId);
|
|
@@ -6125,7 +6184,7 @@ async function recordCandidates(root, tasks, { candidates, filtered, unchecked,
|
|
|
6125
6184
|
const states = episodeStates(journal.events);
|
|
6126
6185
|
const sightings = found.map(sightingOf);
|
|
6127
6186
|
const gone = endsGone ? candidateGoneEvents({ sightings, reviewed, unchecked: unchecked.get(projectId) ?? [] }, states, now) : [];
|
|
6128
|
-
await appendJournal(dir, [...candidateEvents(sightings, states, now, mode), ...gone, ...filteredEvents(filteredHere, states, now)], (_path, error) => reportFailure2(error));
|
|
6187
|
+
await appendJournal(dir, [...candidateEvents(sightings, states, now, mode, model), ...gone, ...filteredEvents(filteredHere, states, now)], (_path, error) => reportFailure2(error));
|
|
6129
6188
|
} catch (error) {
|
|
6130
6189
|
reportFailure2(error);
|
|
6131
6190
|
}
|
|
@@ -6301,6 +6360,7 @@ var PROBLEM_NEEDS_REVIEW = {
|
|
|
6301
6360
|
"project-history-unreadable": false,
|
|
6302
6361
|
"project-branches-unreadable": false,
|
|
6303
6362
|
"merge-state-unknown": false,
|
|
6363
|
+
"late-commits-unknown": false,
|
|
6304
6364
|
"prefix-shared": false
|
|
6305
6365
|
};
|
|
6306
6366
|
function needsReview({ candidates, problems: problems3 }) {
|
|
@@ -6354,7 +6414,7 @@ function collectEvent(item, event) {
|
|
|
6354
6414
|
item.transitions.push({ at, from: event.from, to: event.to, resolution: event.resolution, via: event.via, undo: event.undo });
|
|
6355
6415
|
return;
|
|
6356
6416
|
case "candidate":
|
|
6357
|
-
item.candidates.push({ at, evidence: event.evidence, method: recordedMethodOf(event), match: event.match ?? UNKNOWN });
|
|
6417
|
+
item.candidates.push({ at, evidence: event.evidence, method: recordedMethodOf(event), match: event.match ?? UNKNOWN, model: event.model });
|
|
6358
6418
|
return;
|
|
6359
6419
|
case "candidate-filtered":
|
|
6360
6420
|
item.filtered.push(at);
|
|
@@ -7123,6 +7183,14 @@ function methodAccuracy(histories, span2) {
|
|
|
7123
7183
|
function matchAccuracy(histories, span2) {
|
|
7124
7184
|
return splitAccuracy(histories, span2, { evidence: MATCH_EVIDENCE, keys: RECORDED_MATCHES, keyOf: (candidate) => candidate.match });
|
|
7125
7185
|
}
|
|
7186
|
+
function modelAccuracy(histories, span2) {
|
|
7187
|
+
const byModel = /* @__PURE__ */ new Map();
|
|
7188
|
+
for (const episode of episodesOf(histories, ({ at, model }) => model !== void 0 && span2.contains(at))) {
|
|
7189
|
+
const { model } = episode.candidate;
|
|
7190
|
+
if (model !== void 0) remembered(byModel, model, () => []).push(episode);
|
|
7191
|
+
}
|
|
7192
|
+
return [...byModel].sort(([a], [b]) => a.localeCompare(b)).map(([model, episodes]) => ({ model, ...outcomeCounts(episodes) }));
|
|
7193
|
+
}
|
|
7126
7194
|
function splitAccuracy(histories, span2, { evidence: evidence2, keys, keyOf }) {
|
|
7127
7195
|
const episodes = episodesOf(histories, (candidate) => candidate.evidence === evidence2 && span2.contains(candidate.at));
|
|
7128
7196
|
return countsPerKey(episodes, keys, keyOf).map(([by, counts]) => ({ evidence: evidence2, by, ...counts }));
|
|
@@ -7226,7 +7294,8 @@ var claudeEventSchema = z13.object({
|
|
|
7226
7294
|
session_id: z13.string().optional(),
|
|
7227
7295
|
turn_id: z13.string().optional(),
|
|
7228
7296
|
stop_hook_active: z13.boolean().optional(),
|
|
7229
|
-
last_assistant_message: z13.string().nullish()
|
|
7297
|
+
last_assistant_message: z13.string().nullish(),
|
|
7298
|
+
model: z13.string().trim().min(1).optional().catch(void 0)
|
|
7230
7299
|
});
|
|
7231
7300
|
var cursorEventSchema = z13.object({
|
|
7232
7301
|
workspace_roots: z13.tuple([z13.string()], z13.string()),
|
|
@@ -7252,7 +7321,7 @@ function formatStopAnswer(agent, answer) {
|
|
|
7252
7321
|
function parseClaudeEvent(text) {
|
|
7253
7322
|
const event = parseJson(text, claudeEventSchema);
|
|
7254
7323
|
if (event === null) return null;
|
|
7255
|
-
return { cwd: event.cwd, session: event.session_id, turn: event.turn_id ?? digest(event.last_assistant_message), skip: event.stop_hook_active === true };
|
|
7324
|
+
return { cwd: event.cwd, session: event.session_id, turn: event.turn_id ?? digest(event.last_assistant_message), skip: event.stop_hook_active === true, model: event.model };
|
|
7256
7325
|
}
|
|
7257
7326
|
function parseCursorEvent(text) {
|
|
7258
7327
|
const event = parseJson(text, cursorEventSchema);
|
|
@@ -7325,7 +7394,16 @@ async function runHook(args, io) {
|
|
|
7325
7394
|
if (!("project" in lookup)) return EXIT.ok;
|
|
7326
7395
|
const { project } = lookup;
|
|
7327
7396
|
if (!await isFirstHookOfTurn(agent, event, io)) return EXIT.ok;
|
|
7328
|
-
const { candidates } = await checkBacklog(io.backlogRoot, loaded, {
|
|
7397
|
+
const { candidates } = await checkBacklog(io.backlogRoot, loaded, {
|
|
7398
|
+
projectIds: [project.id],
|
|
7399
|
+
mode: "changed",
|
|
7400
|
+
now: io.now(),
|
|
7401
|
+
context,
|
|
7402
|
+
messages: io.core,
|
|
7403
|
+
warn: io.warn,
|
|
7404
|
+
workingRoots: repoRootsOf(cwdRoots),
|
|
7405
|
+
model: event.model
|
|
7406
|
+
});
|
|
7329
7407
|
const lowPriority = new Set(loaded.tasks.filter((task) => task.priority === "low").map((task) => task.id));
|
|
7330
7408
|
const pinpointed = candidates.filter((candidate) => !(candidate.kind === "source-changed" && candidate.method === "file"));
|
|
7331
7409
|
const worthTelling = pinpointed.filter((candidate) => !lowPriority.has(candidate.task.id));
|
|
@@ -7499,7 +7577,7 @@ async function readOrigin(dir) {
|
|
|
7499
7577
|
return branch === null || branch === DETACHED_HEAD ? { commit } : { branch, commit };
|
|
7500
7578
|
}
|
|
7501
7579
|
async function readHeadCommit(dir) {
|
|
7502
|
-
return await gitLine(dir, ["rev-parse", "
|
|
7580
|
+
return await gitLine(dir, ["rev-parse", "HEAD"]) ?? void 0;
|
|
7503
7581
|
}
|
|
7504
7582
|
async function gitLine(dir, args) {
|
|
7505
7583
|
return outputLine(await runGit(dir, args));
|
|
@@ -7658,7 +7736,7 @@ async function removeProject(positionals, confirm, io) {
|
|
|
7658
7736
|
if (id === void 0 || rest.length > 0) throw usageError(projectCommand, io.language);
|
|
7659
7737
|
if (confirm !== id) throw new UsageError(io.cli.confirmProjectDelete(id));
|
|
7660
7738
|
const loaded = await loadBacklog(io.backlogRoot);
|
|
7661
|
-
const taskCount = loaded.tasks.filter((task) => task.projectId === id).length;
|
|
7739
|
+
const taskCount = [...loaded.tasks, ...unparsedTasks(loaded.errors)].filter((task) => task.projectId === id).length;
|
|
7662
7740
|
const result = await deleteProject(io.backlogRoot, id);
|
|
7663
7741
|
if (!result.ok) {
|
|
7664
7742
|
io.warn(io.cli.projectNotFound(id));
|
|
@@ -8160,7 +8238,7 @@ import { dirname as dirname8, join as join27 } from "node:path";
|
|
|
8160
8238
|
|
|
8161
8239
|
// src/core/journal/closed-in-web.ts
|
|
8162
8240
|
function tasksClosedInWeb(tasks, journals) {
|
|
8163
|
-
const chronologicalStatusEvents = journals.flatMap(({ events }) => events.filter((event) => event.kind === "status"))
|
|
8241
|
+
const chronologicalStatusEvents = chronologicalEvents(journals.flatMap(({ events }) => events.filter((event) => event.kind === "status")));
|
|
8164
8242
|
const statusEventsOf = groupBy(chronologicalStatusEvents, (event) => event.task);
|
|
8165
8243
|
const lastClosingOf = (id) => withoutUndoneClosings(statusEventsOf.get(id) ?? []).findLast(isClosingChange);
|
|
8166
8244
|
return tasks.filter((task) => isClosed(task.status) && lastClosingOf(task.id)?.via === "web").map((task) => task.id);
|
|
@@ -8802,15 +8880,16 @@ function effectReport(context, code, wholeBacklog) {
|
|
|
8802
8880
|
const estimate = estimator(estimateSamples(retainedFixes(wholeBacklog.histories, now), code));
|
|
8803
8881
|
const adopted = projects.map((project) => ({ project, units: unitsSinceAdoption(project, histories, statsWindow) }));
|
|
8804
8882
|
const periodUnits = projects.flatMap(unitsOf).filter((unit) => statsWindow.contains(Date.parse(unit.date)));
|
|
8883
|
+
const totals2 = totalsOf(
|
|
8884
|
+
deferred,
|
|
8885
|
+
adopted.flatMap(({ units }) => units),
|
|
8886
|
+
estimate
|
|
8887
|
+
);
|
|
8805
8888
|
return {
|
|
8806
8889
|
...context.head,
|
|
8807
8890
|
periods: grainPeriods(now),
|
|
8808
8891
|
unavailableRepos: code.unavailableRepos,
|
|
8809
|
-
totals:
|
|
8810
|
-
deferred,
|
|
8811
|
-
adopted.flatMap(({ units }) => units),
|
|
8812
|
-
estimate
|
|
8813
|
-
),
|
|
8892
|
+
totals: projects.length > 0 ? totals2 : { ...totals2, noiseShare: null, noiseMissing: "no-repos" },
|
|
8814
8893
|
weeks: effectPeriodsOf(weekWindows(now), deferred, periodUnits, estimate),
|
|
8815
8894
|
days: effectPeriodsOf(dayWindows(now), deferred, periodUnits, estimate),
|
|
8816
8895
|
projects: adopted.map(
|
|
@@ -8895,7 +8974,7 @@ function totalsOf(deferred, units, estimate) {
|
|
|
8895
8974
|
};
|
|
8896
8975
|
}
|
|
8897
8976
|
function noiseOf(realLines, deferredTasks, deferredLines, estimatedLines) {
|
|
8898
|
-
if (realLines === 0) return { noiseShare: null, noiseMissing: "no-
|
|
8977
|
+
if (realLines === 0) return { noiseShare: null, noiseMissing: "no-lines" };
|
|
8899
8978
|
if (deferredTasks === 0) return { noiseShare: null, noiseMissing: "no-deferred-tasks" };
|
|
8900
8979
|
if (estimatedLines === null) return { noiseShare: null, noiseMissing: "estimate-pending" };
|
|
8901
8980
|
return { noiseShare: Math.min(1, deferredLines / (realLines + estimatedLines)), noiseMissing: null };
|
|
@@ -9004,6 +9083,7 @@ function qualityReport(context, graphs) {
|
|
|
9004
9083
|
accuracyDays: accuracyDays(histories, now),
|
|
9005
9084
|
methodAccuracy: methodAccuracy(histories, period2),
|
|
9006
9085
|
matchAccuracy: matchAccuracy(histories, period2),
|
|
9086
|
+
modelAccuracy: modelAccuracy(histories, period2),
|
|
9007
9087
|
graph: { projects: graphs, filter: graphFilterEffect(histories, period2) },
|
|
9008
9088
|
categories: categoryBreakdown(openTasks, histories, period2),
|
|
9009
9089
|
found: foundBreakdown(histories, period2),
|
|
@@ -9103,7 +9183,8 @@ function totalTokens(tokens) {
|
|
|
9103
9183
|
// src/core/stats/cost/pricing.ts
|
|
9104
9184
|
var FAST_MODEL_MARKER = ":fast";
|
|
9105
9185
|
var LONG_PROMPT_MARKER = ":long-prompt";
|
|
9106
|
-
var
|
|
9186
|
+
var OPENAI_LONG_PROMPT_TOKENS = 272e3;
|
|
9187
|
+
var OPENAI_LONG_OUTPUT_FACTOR = 1.5;
|
|
9107
9188
|
var FAST_PRICE_FACTOR = 2;
|
|
9108
9189
|
var CACHE_WRITE_5M_FACTOR = 1.25;
|
|
9109
9190
|
var CACHE_WRITE_1H_FACTOR = 2;
|
|
@@ -9125,16 +9206,26 @@ var PRICE_TABLE = /* @__PURE__ */ new Map([
|
|
|
9125
9206
|
["claude-sonnet-5", { input: 2, output: 10, cacheRead: 0.2 }],
|
|
9126
9207
|
["claude-sonnet-4-6", { input: 3, output: 15, cacheRead: 0.3 }],
|
|
9127
9208
|
["claude-sonnet-4-5", { input: 3, output: 15, cacheRead: 0.3 }],
|
|
9128
|
-
["claude-haiku-5-5", { input: 0.1, output: 0.5, cacheRead: 0.01, longPrompt: { input: 0.5, output: 2.5, cacheRead: 0.05 } }],
|
|
9129
|
-
["claude-haiku-4-5", { input: 1, output: 5, cacheRead: 0.1 }]
|
|
9209
|
+
["claude-haiku-5-5", { input: 0.1, output: 0.5, cacheRead: 0.01, longPrompt: { threshold: 1e5, input: 0.5, output: 2.5, cacheRead: 0.05 } }],
|
|
9210
|
+
["claude-haiku-4-5", { input: 1, output: 5, cacheRead: 0.1 }],
|
|
9211
|
+
["gpt-6.2-astra", openAiPrice({ input: 8, output: 40, cacheRead: 0.4 })],
|
|
9212
|
+
["gpt-6.2-sol", openAiPrice({ input: 2, output: 10, cacheRead: 0.1 })],
|
|
9213
|
+
["gpt-6.1-sol", openAiPrice({ input: 2, output: 10, cacheRead: 0.1 })],
|
|
9214
|
+
["gpt-6.1-terra", openAiPrice({ input: 1, output: 5, cacheRead: 0.05 })],
|
|
9215
|
+
["gpt-6-astra", openAiPrice({ input: 10, output: 50, cacheRead: 1 })],
|
|
9216
|
+
["gpt-6-luna", openAiPrice({ input: 0.1, output: 0.5, cacheRead: 0.01 })]
|
|
9130
9217
|
]);
|
|
9131
|
-
var DATED_SUFFIX =
|
|
9218
|
+
var DATED_SUFFIX = /-(?:\d{8}|\d{4}-\d{2}-\d{2})$/;
|
|
9132
9219
|
var BRACKET_SUFFIX = /\[[^\]]*\]$/;
|
|
9220
|
+
function openAiPrice({ input, output, cacheRead }) {
|
|
9221
|
+
return { input, output, cacheRead, longPrompt: { threshold: OPENAI_LONG_PROMPT_TOKENS, input: input * 2, output: output * OPENAI_LONG_OUTPUT_FACTOR, cacheRead: cacheRead * 2 } };
|
|
9222
|
+
}
|
|
9133
9223
|
function baseModelId(model) {
|
|
9134
9224
|
return model.replace(BRACKET_SUFFIX, "").replace(DATED_SUFFIX, "");
|
|
9135
9225
|
}
|
|
9136
9226
|
function modelKey({ model, fast, tokens }) {
|
|
9137
|
-
const
|
|
9227
|
+
const threshold = PRICE_TABLE.get(baseModelId(model))?.longPrompt?.threshold;
|
|
9228
|
+
const longPrompt = threshold !== void 0 && promptTokens(tokens) > threshold;
|
|
9138
9229
|
return `${model}${fast ? FAST_MODEL_MARKER : ""}${longPrompt ? LONG_PROMPT_MARKER : ""}`;
|
|
9139
9230
|
}
|
|
9140
9231
|
function stripMarker(key, marker) {
|
|
@@ -9173,16 +9264,20 @@ function costOf(key, tokens) {
|
|
|
9173
9264
|
// src/core/stats/cost/cost-report.ts
|
|
9174
9265
|
var COST_TOTALS_DAYS = 7;
|
|
9175
9266
|
function costReport({ buckets, runs, projectOf: projectOf2, projectId, now, scan }) {
|
|
9176
|
-
const
|
|
9177
|
-
const
|
|
9178
|
-
|
|
9179
|
-
const scopedRuns = filterByProject(
|
|
9180
|
-
runs.filter((run) => run.command !== SERVE_COMMAND_NAME),
|
|
9267
|
+
const projectOfTimed = ({ item, at }) => projectOf2(item.cwd, at);
|
|
9268
|
+
const timedBuckets = filterByProject(
|
|
9269
|
+
timed(buckets, (bucket) => bucket.slot),
|
|
9181
9270
|
projectId,
|
|
9182
|
-
|
|
9271
|
+
projectOfTimed
|
|
9272
|
+
);
|
|
9273
|
+
const timedRuns = filterByProject(
|
|
9274
|
+
timed(
|
|
9275
|
+
runs.filter((run) => run.command !== SERVE_COMMAND_NAME),
|
|
9276
|
+
(run) => run.at
|
|
9277
|
+
),
|
|
9278
|
+
projectId,
|
|
9279
|
+
projectOfTimed
|
|
9183
9280
|
);
|
|
9184
|
-
const timedBuckets = timed(scopedBuckets, (bucket) => bucket.slot);
|
|
9185
|
-
const timedRuns = timed(scopedRuns, (run) => run.at);
|
|
9186
9281
|
const within = (period2) => ({ buckets: itemsWithin(timedBuckets, period2), runs: itemsWithin(timedRuns, period2) });
|
|
9187
9282
|
const reported = within(lastDaysPeriod(now, STATS_DAYS));
|
|
9188
9283
|
return {
|
|
@@ -9277,14 +9372,18 @@ var transcriptStateSchema = z17.object({
|
|
|
9277
9372
|
lastMessageId: z17.string().nullable(),
|
|
9278
9373
|
lastMessageTokens: tokenCountsSchema.nullable().optional(),
|
|
9279
9374
|
pending: z17.record(z17.string(), estimatedKindSchema),
|
|
9280
|
-
pendingEstimates: z17.array(z17.object({ kind: estimatedKindSchema, chars: z17.number(), slot: z17.string(), cwd: z17.string() }))
|
|
9375
|
+
pendingEstimates: z17.array(z17.object({ kind: estimatedKindSchema, chars: z17.number(), slot: z17.string(), cwd: z17.string() })),
|
|
9376
|
+
codex: z17.object({ cwd: z17.string(), total: tokenCountsSchema.nullable(), toolDirectories: z17.record(z17.string(), z17.string()).optional() }).optional()
|
|
9281
9377
|
});
|
|
9282
9378
|
|
|
9283
9379
|
// src/core/usage/usage-cache.ts
|
|
9284
9380
|
var USAGE_CACHE_FILE = ".usage-cache.json";
|
|
9285
|
-
var USAGE_CACHE_VERSION =
|
|
9381
|
+
var USAGE_CACHE_VERSION = 7;
|
|
9286
9382
|
var bucketsSchema = z18.array(usageBucketSchema);
|
|
9287
|
-
var
|
|
9383
|
+
var worktreeTenureSchema = z18.object({ main: z18.string(), since: z18.number() });
|
|
9384
|
+
var SINCE_EVER = 0;
|
|
9385
|
+
var worktreeTenuresSchema = z18.union([z18.array(worktreeTenureSchema), z18.string().transform((main) => [{ main, since: SINCE_EVER }])]);
|
|
9386
|
+
var worktreeReposSchema = z18.record(z18.string(), worktreeTenuresSchema);
|
|
9288
9387
|
var usageCacheEntrySchema = z18.object({
|
|
9289
9388
|
size: z18.number(),
|
|
9290
9389
|
mtimeMs: z18.number().optional(),
|
|
@@ -9347,15 +9446,19 @@ async function computeCostReport({ usage: { cache, scan }, runs, known, projectI
|
|
|
9347
9446
|
context,
|
|
9348
9447
|
{ lookupRepoRoot, worktreeRepos: cache.worktreeRepos }
|
|
9349
9448
|
);
|
|
9350
|
-
return costReport({ buckets, runs, projectOf: (cwd) => projectIds.get(cwd) ?? null, projectId, now, scan });
|
|
9449
|
+
return costReport({ buckets, runs, projectOf: (cwd, at) => projectIds.get(cwd)?.(at) ?? null, projectId, now, scan });
|
|
9351
9450
|
}
|
|
9352
9451
|
async function projectIdsOfCwds(cwds, known, context, recordedRepos) {
|
|
9353
9452
|
const projectIdOf = async (cwd) => {
|
|
9354
|
-
const
|
|
9355
|
-
|
|
9453
|
+
const lookupAt = await lookupProjectForRecordedDir(known, cwd, recordedRepos, context);
|
|
9454
|
+
const projectIdAt = (at) => projectIdIn(lookupAt(at));
|
|
9455
|
+
return [cwd, projectIdAt];
|
|
9356
9456
|
};
|
|
9357
9457
|
return new Map(await Promise.all([...new Set(cwds)].map(projectIdOf)));
|
|
9358
9458
|
}
|
|
9459
|
+
function projectIdIn(lookup) {
|
|
9460
|
+
return "project" in lookup ? lookup.project.id : null;
|
|
9461
|
+
}
|
|
9359
9462
|
|
|
9360
9463
|
// src/server/stats-api.ts
|
|
9361
9464
|
var REPORT_TTL_MS = 5 * MINUTE_MS;
|
|
@@ -9574,8 +9677,8 @@ async function removeProject2(c, id, { root, readLanguage, changeHub }) {
|
|
|
9574
9677
|
function revisionEvents(c, changeHub, closed) {
|
|
9575
9678
|
return streamSSE(c, async (stream) => {
|
|
9576
9679
|
const stopSending = changeHub.onRevision((revision) => void stream.writeSSE({ event: "change", data: JSON.stringify(revision) }));
|
|
9577
|
-
const { promise: ended, resolve:
|
|
9578
|
-
const end = () =>
|
|
9680
|
+
const { promise: ended, resolve: resolve8 } = Promise.withResolvers();
|
|
9681
|
+
const end = () => resolve8();
|
|
9579
9682
|
stream.onAbort(end);
|
|
9580
9683
|
closed.addEventListener("abort", end);
|
|
9581
9684
|
if (closed.aborted) end();
|
|
@@ -9830,14 +9933,22 @@ var PACKAGE_RUNNERS = /* @__PURE__ */ new Set(["npx", "bunx", "pnpx"]);
|
|
|
9830
9933
|
var RUNNER_SUBCOMMANDS = { pnpm: ["dlx", "exec"], yarn: ["dlx", "exec"], npm: ["exec", "x"], bun: ["x"] };
|
|
9831
9934
|
var BIN_RUNNERS = /* @__PURE__ */ new Set(["yarn"]);
|
|
9832
9935
|
function invokesBacklog(script) {
|
|
9833
|
-
return simpleCommands(script).some(
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9936
|
+
return simpleCommands(script).some(isBacklogCommand);
|
|
9937
|
+
}
|
|
9938
|
+
function invokesOnlyBacklog(script) {
|
|
9939
|
+
const commands = simpleCommands(script);
|
|
9940
|
+
return commands.length > 0 && commands.every(isBacklogCommand);
|
|
9941
|
+
}
|
|
9942
|
+
function isSingleShellCommand(script) {
|
|
9943
|
+
return simpleCommands(script).length === 1;
|
|
9944
|
+
}
|
|
9945
|
+
function isBacklogCommand(command2) {
|
|
9946
|
+
const [program, ...args] = programWords(command2.split(/\s+/));
|
|
9947
|
+
if (program === void 0) return false;
|
|
9948
|
+
const name = executableName(program);
|
|
9949
|
+
if (name === BACKLOG_BIN || BIN_RUNNERS.has(name) && args[0] === BACKLOG_BIN) return true;
|
|
9950
|
+
const runnerArgs = packageRunnerArguments(name, args);
|
|
9951
|
+
return runnerArgs !== null && runsBacklogPackage(runnerArgs);
|
|
9841
9952
|
}
|
|
9842
9953
|
function programWords(words) {
|
|
9843
9954
|
let rest = dropWhile(words, (word) => word === "" || ENV_ASSIGNMENT.test(word) || SHELL_KEYWORDS.has(word));
|
|
@@ -10121,13 +10232,13 @@ function registerToolUseBlock(raw, state) {
|
|
|
10121
10232
|
if (block.data.name === BASH_TOOL) {
|
|
10122
10233
|
const input = bashInputSchema.safeParse(block.data.input);
|
|
10123
10234
|
if (!input.success || !invokesBacklog(input.data.command)) return;
|
|
10124
|
-
state
|
|
10125
|
-
forgetOldestPending(state);
|
|
10235
|
+
rememberToolCall(state, block.data.id, "cli");
|
|
10126
10236
|
}
|
|
10127
10237
|
}
|
|
10128
|
-
function
|
|
10238
|
+
function rememberToolCall(state, id, kind) {
|
|
10239
|
+
state.pending[id] = kind;
|
|
10129
10240
|
const ids = Object.keys(state.pending);
|
|
10130
|
-
for (const
|
|
10241
|
+
for (const expiredId of ids.slice(0, Math.max(0, ids.length - PENDING_TOOL_LIMIT))) Reflect.deleteProperty(state.pending, expiredId);
|
|
10131
10242
|
}
|
|
10132
10243
|
function flushEstimates(state) {
|
|
10133
10244
|
return state.lastModel === null ? [] : drainEstimates(state, state.lastModel);
|
|
@@ -10138,14 +10249,14 @@ function drainEstimates(state, model) {
|
|
|
10138
10249
|
cwd: estimate.cwd,
|
|
10139
10250
|
model,
|
|
10140
10251
|
kind: estimate.kind,
|
|
10141
|
-
tokens:
|
|
10252
|
+
tokens: { ...ZERO_TOKENS, cacheWrite5m: estimateTextTokens(estimate.chars) },
|
|
10142
10253
|
hookTurns: 0
|
|
10143
10254
|
}));
|
|
10144
10255
|
state.pendingEstimates = [];
|
|
10145
10256
|
return buckets;
|
|
10146
10257
|
}
|
|
10147
|
-
function
|
|
10148
|
-
return
|
|
10258
|
+
function estimateTextTokens(chars) {
|
|
10259
|
+
return Math.ceil(chars / CHARS_PER_TOKEN);
|
|
10149
10260
|
}
|
|
10150
10261
|
function isToolResultOnly(content) {
|
|
10151
10262
|
return Array.isArray(content) && content.length > 0 && content.every((block) => toolResultBlockSchema.safeParse(block).success);
|
|
@@ -10169,6 +10280,143 @@ function slotOf(timestamp) {
|
|
|
10169
10280
|
return Number.isNaN(moment) ? "" : new Date(moment - moment % ZONE_OFFSET_STEP_MS).toISOString();
|
|
10170
10281
|
}
|
|
10171
10282
|
|
|
10283
|
+
// src/core/usage/attribute-codex.ts
|
|
10284
|
+
import { resolve as resolve4 } from "node:path";
|
|
10285
|
+
import { z as z20 } from "zod";
|
|
10286
|
+
var ROLLOUT_MARKERS = /"type"\s*:\s*"(?:session_meta|turn_context|token_count|message|function_call(?:_output)?|custom_tool_call(?:_output)?)"/u;
|
|
10287
|
+
var INLINE_SHELL_FIELDS = /\b(cmd|workdir)\s*:\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\[\s\S]|[^`\\])*`)/gu;
|
|
10288
|
+
var APP_TOOL_CALL = /\btools\.(\w+)\s*\(/gu;
|
|
10289
|
+
var SKILL_READER = /^\s*(?:cat|sed|head|tail|nl|Get-Content)\b/iu;
|
|
10290
|
+
var STOP_HOOK_PROMPT = /^<hook_prompt hook_run_id="stop:[^"]+">\s*([\s\S]*?)<\/hook_prompt>$/u;
|
|
10291
|
+
var rolloutSchema = z20.object({
|
|
10292
|
+
type: z20.string(),
|
|
10293
|
+
timestamp: z20.string(),
|
|
10294
|
+
payload: z20.object({
|
|
10295
|
+
type: z20.string().optional(),
|
|
10296
|
+
cwd: z20.string().optional(),
|
|
10297
|
+
model: z20.string().min(1).optional()
|
|
10298
|
+
}).passthrough()
|
|
10299
|
+
});
|
|
10300
|
+
var usageSchema2 = z20.object({
|
|
10301
|
+
input_tokens: z20.number().nonnegative(),
|
|
10302
|
+
cached_input_tokens: z20.number().nonnegative().default(0),
|
|
10303
|
+
cache_write_input_tokens: z20.number().nonnegative().default(0),
|
|
10304
|
+
output_tokens: z20.number().nonnegative()
|
|
10305
|
+
});
|
|
10306
|
+
var eventSchema = z20.object({ info: z20.object({ total_token_usage: usageSchema2, last_token_usage: usageSchema2.optional() }) });
|
|
10307
|
+
var messageSchema = z20.object({ role: z20.string(), content: z20.array(z20.object({ text: z20.string().optional() })) });
|
|
10308
|
+
var callSchema = z20.object({ name: z20.string(), call_id: z20.string(), arguments: z20.string().optional(), input: z20.string().optional() });
|
|
10309
|
+
var shellSchema = z20.object({ cmd: z20.string().optional(), command: z20.string().optional(), workdir: z20.string().optional() });
|
|
10310
|
+
var textOutputSchema = z20.object({ type: z20.literal("input_text"), text: z20.string() });
|
|
10311
|
+
var resultSchema = z20.object({ call_id: z20.string(), output: z20.union([z20.string(), z20.array(z20.unknown())]) });
|
|
10312
|
+
function attributeCodexLine(line, state) {
|
|
10313
|
+
if (!ROLLOUT_MARKERS.test(line)) return [];
|
|
10314
|
+
const event = parseJson(line, rolloutSchema);
|
|
10315
|
+
if (event === null) return [];
|
|
10316
|
+
const codex = state.codex ??= { cwd: "", total: null };
|
|
10317
|
+
const { type, timestamp, payload } = event;
|
|
10318
|
+
if (type === "session_meta" || type === "turn_context") {
|
|
10319
|
+
codex.cwd = payload.cwd ?? codex.cwd;
|
|
10320
|
+
state.lastModel = payload.model ?? state.lastModel;
|
|
10321
|
+
return [];
|
|
10322
|
+
}
|
|
10323
|
+
const context = { cwd: codex.cwd, model: state.lastModel ?? "unknown", slot: slotOf(timestamp) };
|
|
10324
|
+
if (type === "event_msg" && payload.type === "token_count") return tokenBuckets(payload, state, codex, context);
|
|
10325
|
+
if (type === "response_item") return responseBuckets(payload, state, codex, context);
|
|
10326
|
+
return [];
|
|
10327
|
+
}
|
|
10328
|
+
function tokenBuckets(payload, state, codex, context) {
|
|
10329
|
+
const event = eventSchema.safeParse(payload);
|
|
10330
|
+
if (!event.success) return [];
|
|
10331
|
+
const { total_token_usage: usage, last_token_usage: last } = event.data.info;
|
|
10332
|
+
const total = tokensOf(usage);
|
|
10333
|
+
const tokens = codex.total === null ? tokensOf(last ?? usage) : tokensGrowth(codex.total, total);
|
|
10334
|
+
codex.total = total;
|
|
10335
|
+
if (!state.hookOpen || totalTokens(tokens) === 0) return [];
|
|
10336
|
+
const model = modelKey({ model: context.model, fast: false, tokens });
|
|
10337
|
+
return [{ ...context, model, kind: "hook", tokens, hookTurns: 0 }];
|
|
10338
|
+
}
|
|
10339
|
+
function tokensOf(usage) {
|
|
10340
|
+
const cacheRead = Math.min(usage.input_tokens, usage.cached_input_tokens);
|
|
10341
|
+
const cacheWrite5m = Math.min(usage.input_tokens - cacheRead, usage.cache_write_input_tokens);
|
|
10342
|
+
return { input: usage.input_tokens - cacheRead - cacheWrite5m, output: usage.output_tokens, cacheWrite5m, cacheWrite1h: 0, cacheRead };
|
|
10343
|
+
}
|
|
10344
|
+
function responseBuckets(payload, state, codex, context) {
|
|
10345
|
+
switch (payload.type) {
|
|
10346
|
+
case "message": {
|
|
10347
|
+
const message = messageSchema.safeParse(payload);
|
|
10348
|
+
if (!message.success || message.data.role !== "user") return [];
|
|
10349
|
+
state.hookOpen = message.data.content.some(({ text }) => isBacklogPrompt(text?.trim() ?? ""));
|
|
10350
|
+
return state.hookOpen ? [{ ...context, kind: "hook", tokens: ZERO_TOKENS, hookTurns: 1 }] : [];
|
|
10351
|
+
}
|
|
10352
|
+
case "function_call":
|
|
10353
|
+
case "custom_tool_call": {
|
|
10354
|
+
const call = callSchema.safeParse(payload);
|
|
10355
|
+
if (call.success) rememberBacklogCall(call.data, state, codex);
|
|
10356
|
+
return [];
|
|
10357
|
+
}
|
|
10358
|
+
case "function_call_output":
|
|
10359
|
+
case "custom_tool_call_output":
|
|
10360
|
+
return toolOutputBuckets(payload, state, codex, context);
|
|
10361
|
+
case void 0:
|
|
10362
|
+
default:
|
|
10363
|
+
return [];
|
|
10364
|
+
}
|
|
10365
|
+
}
|
|
10366
|
+
function isBacklogPrompt(text) {
|
|
10367
|
+
return isBacklogHookFeedback(text) || isBacklogHookReason(STOP_HOOK_PROMPT.exec(text)?.[1] ?? "");
|
|
10368
|
+
}
|
|
10369
|
+
function rememberBacklogCall(call, state, codex) {
|
|
10370
|
+
const { commands, workdir } = shellDetails(call);
|
|
10371
|
+
if (commands.length === 0) return;
|
|
10372
|
+
if (commands.every(invokesOnlyBacklog)) rememberToolCall(state, call.call_id, "cli");
|
|
10373
|
+
else if (commands.every(readsBacklogSkill)) rememberToolCall(state, call.call_id, "skill");
|
|
10374
|
+
if (workdir && Object.hasOwn(state.pending, call.call_id)) {
|
|
10375
|
+
codex.toolDirectories ??= {};
|
|
10376
|
+
const cwd = resolve4(codex.cwd, workdir);
|
|
10377
|
+
codex.toolDirectories = { ...codex.toolDirectories, [call.call_id]: cwd };
|
|
10378
|
+
}
|
|
10379
|
+
for (const id of Object.keys(codex.toolDirectories ?? {})) {
|
|
10380
|
+
if (!Object.hasOwn(state.pending, id) && codex.toolDirectories !== void 0) Reflect.deleteProperty(codex.toolDirectories, id);
|
|
10381
|
+
}
|
|
10382
|
+
}
|
|
10383
|
+
function shellDetails(call) {
|
|
10384
|
+
if (call.name === "exec_command" || call.name === "shell_command") {
|
|
10385
|
+
const shell = parseJson(call.arguments ?? "", shellSchema);
|
|
10386
|
+
const command2 = shell?.cmd ?? shell?.command;
|
|
10387
|
+
return { commands: command2 === void 0 ? [] : [command2], workdir: shell?.workdir };
|
|
10388
|
+
}
|
|
10389
|
+
if (call.name !== "exec" || !call.input?.includes("tools.exec_command")) return { commands: [] };
|
|
10390
|
+
const tools = [...call.input.matchAll(APP_TOOL_CALL)];
|
|
10391
|
+
if (tools.some(([, name]) => name !== "exec_command")) return { commands: [] };
|
|
10392
|
+
const commands = [];
|
|
10393
|
+
const workdirs = [];
|
|
10394
|
+
for (const [, field, literal = ""] of call.input.matchAll(INLINE_SHELL_FIELDS)) {
|
|
10395
|
+
const fields = field === "cmd" ? commands : workdirs;
|
|
10396
|
+
fields.push(parseJson(literal, z20.string()) ?? literal.slice(1, -1).replaceAll("\\n", "\n"));
|
|
10397
|
+
}
|
|
10398
|
+
if (commands.length !== tools.length || workdirs.length > 0 && commands.length !== 1) return { commands: [] };
|
|
10399
|
+
return { commands, workdir: workdirs[0] };
|
|
10400
|
+
}
|
|
10401
|
+
function readsBacklogSkill(command2) {
|
|
10402
|
+
return SKILL_READER.test(command2) && command2.replaceAll("\\", "/").includes(`/${SKILL_NAME}/SKILL.md`) && isSingleShellCommand(command2);
|
|
10403
|
+
}
|
|
10404
|
+
function toolOutputBuckets(payload, state, codex, context) {
|
|
10405
|
+
const result = resultSchema.safeParse(payload);
|
|
10406
|
+
if (!result.success) return [];
|
|
10407
|
+
const { call_id: id, output } = result.data;
|
|
10408
|
+
if (!Object.hasOwn(state.pending, id)) return [];
|
|
10409
|
+
const kind = state.pending[id];
|
|
10410
|
+
Reflect.deleteProperty(state.pending, id);
|
|
10411
|
+
const directories = codex.toolDirectories ?? {};
|
|
10412
|
+
const cwd = Object.hasOwn(directories, id) ? directories[id] ?? context.cwd : context.cwd;
|
|
10413
|
+
Reflect.deleteProperty(directories, id);
|
|
10414
|
+
if (state.hookOpen || kind === void 0) return [];
|
|
10415
|
+
const chars = typeof output === "string" ? output.length : output.reduce((total, part) => total + (textOutputSchema.safeParse(part).data?.text.length ?? 0), 0);
|
|
10416
|
+
if (chars === 0) return [];
|
|
10417
|
+
return [{ ...context, cwd, kind, tokens: { ...ZERO_TOKENS, input: estimateTextTokens(chars) }, hookTurns: 0 }];
|
|
10418
|
+
}
|
|
10419
|
+
|
|
10172
10420
|
// src/core/usage/transcripts.ts
|
|
10173
10421
|
var FINGERPRINT_BYTES = 256;
|
|
10174
10422
|
var ABANDONED_LINE_MS = 10 * 60 * 1e3;
|
|
@@ -10196,13 +10444,30 @@ async function listedFile(path) {
|
|
|
10196
10444
|
const stats = await statOrNull(path);
|
|
10197
10445
|
return stats === null ? [] : [{ path, size: stats.size, mtimeMs: stats.mtimeMs }];
|
|
10198
10446
|
}
|
|
10199
|
-
async function
|
|
10447
|
+
async function listCodexTranscripts(home2, now, onUnreadable) {
|
|
10448
|
+
const retained = retainedSince(now);
|
|
10449
|
+
const bySession = /* @__PURE__ */ new Map();
|
|
10450
|
+
for (const folder of ["sessions", "archived_sessions"]) {
|
|
10451
|
+
const entries = await attemptReportingFailure(join33(home2, folder), (path) => listDir(path, { recursive: true }), onUnreadable);
|
|
10452
|
+
for (const entry of entries ?? []) {
|
|
10453
|
+
if (!entry.isFile() || !entry.name.startsWith("rollout-") || !entry.name.endsWith(".jsonl") || bySession.has(entry.name)) continue;
|
|
10454
|
+
const path = join33(entry.parentPath, entry.name);
|
|
10455
|
+
const stat3 = await attemptReportingFailure(path, statOrNull, onUnreadable);
|
|
10456
|
+
if (stat3 !== null && stat3.mtimeMs >= retained) bySession.set(entry.name, { path, size: stat3.size, mtimeMs: stat3.mtimeMs, codex: true });
|
|
10457
|
+
}
|
|
10458
|
+
}
|
|
10459
|
+
return [...bySession.values()];
|
|
10460
|
+
}
|
|
10461
|
+
async function scanTranscripts({ files, cache, byteBudget, now, onUnreadable }) {
|
|
10200
10462
|
let remainingBudget = byteBudget;
|
|
10201
10463
|
const listedFiles = {};
|
|
10202
10464
|
for (const file of files) {
|
|
10203
|
-
const
|
|
10204
|
-
|
|
10205
|
-
|
|
10465
|
+
const read = () => scanFile(file, cache.files[file.path], remainingBudget, { longestReadableLine: byteBudget, now });
|
|
10466
|
+
const result = onUnreadable === void 0 ? await read() : await attemptReportingFailure(file.path, read, onUnreadable);
|
|
10467
|
+
if (result !== null) {
|
|
10468
|
+
listedFiles[file.path] = result.entry;
|
|
10469
|
+
remainingBudget -= result.budgetUsed;
|
|
10470
|
+
}
|
|
10206
10471
|
await yieldToEventLoop();
|
|
10207
10472
|
}
|
|
10208
10473
|
const stillReported = deletedStillReported(listedFiles, now);
|
|
@@ -10262,16 +10527,19 @@ async function scanChunk(file, start, chunkSize, { longestReadableLine, now }) {
|
|
|
10262
10527
|
return { size: file.size, offset: start.offset + (lineTooLong ? chunk.length : 0), state: start.state, buckets: start.buckets };
|
|
10263
10528
|
}
|
|
10264
10529
|
const bucketsByKey = new Map(start.buckets.map((bucket) => [bucketKey(bucket), bucket]));
|
|
10530
|
+
const readLine = file.codex ? attributeCodexLine : attributeClaudeLine;
|
|
10265
10531
|
for (const line of chunk.subarray(0, readableLength).toString("utf8").split("\n")) {
|
|
10266
|
-
|
|
10267
|
-
const parsed = parseJson(line, transcriptLineSchema);
|
|
10268
|
-
if (parsed === null) continue;
|
|
10269
|
-
for (const addition of attributeLine(parsed, start.state)) addBucket(bucketsByKey, addition);
|
|
10532
|
+
for (const addition of readLine(line, start.state)) addBucket(bucketsByKey, addition);
|
|
10270
10533
|
}
|
|
10271
10534
|
const offset = start.offset + readableLength;
|
|
10272
10535
|
if (offset === file.size) for (const addition of flushEstimates(start.state)) addBucket(bucketsByKey, addition);
|
|
10273
10536
|
return { size: file.size, offset, state: start.state, buckets: [...bucketsByKey.values()] };
|
|
10274
10537
|
}
|
|
10538
|
+
function attributeClaudeLine(line, state) {
|
|
10539
|
+
if (!COUNTED_LINE_MARKERS.some((marker) => line.includes(marker))) return [];
|
|
10540
|
+
const parsed = parseJson(line, transcriptLineSchema);
|
|
10541
|
+
return parsed === null ? [] : attributeLine(parsed, state);
|
|
10542
|
+
}
|
|
10275
10543
|
async function continues(file, previous) {
|
|
10276
10544
|
if (file.size < previous.size) return false;
|
|
10277
10545
|
if (file.size === previous.size && file.mtimeMs === previous.mtimeMs) return true;
|
|
@@ -10287,7 +10555,7 @@ async function fingerprintOf3(path, offset) {
|
|
|
10287
10555
|
});
|
|
10288
10556
|
}
|
|
10289
10557
|
function yieldToEventLoop() {
|
|
10290
|
-
return new Promise((
|
|
10558
|
+
return new Promise((resolve8) => setImmediate(resolve8));
|
|
10291
10559
|
}
|
|
10292
10560
|
function addBucket(buckets, addition) {
|
|
10293
10561
|
const key = bucketKey(addition);
|
|
@@ -10307,32 +10575,32 @@ var DEFAULT_INTERVAL_MS = MINUTE_MS;
|
|
|
10307
10575
|
var CATCH_UP_DELAY_MS = 100;
|
|
10308
10576
|
var NOT_LISTED = { listed: false, filesTotal: 0, filesDone: 0, bytesLeft: 0 };
|
|
10309
10577
|
var STOPPED = { running: false };
|
|
10310
|
-
function createUsageScanner({ root, claudeProjectsDir: claudeProjectsDir2, byteBudget = DEFAULT_BYTE_BUDGET, intervalMs = DEFAULT_INTERVAL_MS, warn: warn2, now = () => /* @__PURE__ */ new Date() }) {
|
|
10578
|
+
function createUsageScanner({ root, claudeProjectsDir: claudeProjectsDir2, codexHome, byteBudget = DEFAULT_BYTE_BUDGET, intervalMs = DEFAULT_INTERVAL_MS, warn: warn2, now = () => /* @__PURE__ */ new Date() }) {
|
|
10311
10579
|
let cache = null;
|
|
10312
10580
|
let scan = NOT_LISTED;
|
|
10313
10581
|
let revision = 0;
|
|
10314
10582
|
let inFlight = null;
|
|
10315
10583
|
let schedule = STOPPED;
|
|
10316
|
-
const
|
|
10584
|
+
const reportPathError = warnPathErrors((line) => void warn2(() => line));
|
|
10317
10585
|
const runsTail = createJsonlTail(join34(root, RUNS_FILE), cliRunSchema);
|
|
10318
|
-
const
|
|
10586
|
+
const newOutsideOwners = outsideWorktreeRecorder();
|
|
10319
10587
|
const setScan = (next) => {
|
|
10320
10588
|
if (!scanEquals(scan, next)) revision += 1;
|
|
10321
10589
|
scan = next;
|
|
10322
10590
|
};
|
|
10323
10591
|
const runPass = async () => {
|
|
10324
|
-
const published = cache ?? emptyUsageCache();
|
|
10325
10592
|
const current = cache ?? await readUsageCache(root);
|
|
10326
|
-
const
|
|
10593
|
+
const moment = now();
|
|
10594
|
+
const files = await transcriptFiles(claudeProjectsDir2, codexHome, moment, reportPathError);
|
|
10327
10595
|
setScan(progressBefore(files, current));
|
|
10328
|
-
const result = await scanTranscripts({ files, cache: current, byteBudget, now:
|
|
10596
|
+
const result = await scanTranscripts({ files, cache: current, byteBudget, now: moment, onUnreadable: reportPathError });
|
|
10329
10597
|
const { values: runs } = await runsTail.read();
|
|
10330
|
-
const added = await
|
|
10331
|
-
const next = added.length === 0 ? result.cache : { ...result.cache, worktreeRepos:
|
|
10332
|
-
if (cacheChanged(
|
|
10598
|
+
const added = await newOutsideOwners(result.cache, runs);
|
|
10599
|
+
const next = added.length === 0 ? result.cache : { ...result.cache, worktreeRepos: withNewOwners(result.cache.worktreeRepos, added, now()) };
|
|
10600
|
+
if (cacheChanged(cache ?? emptyUsageCache(), next)) revision += 1;
|
|
10333
10601
|
cache = next;
|
|
10334
10602
|
setScan({ listed: true, filesTotal: files.length, filesDone: result.filesDone, bytesLeft: result.bytesLeft });
|
|
10335
|
-
if (result.bytesRead > 0 || result.prunedBuckets > 0 || added.length > 0) await writeUsageCache(root, next,
|
|
10603
|
+
if (result.bytesRead > 0 || result.prunedBuckets > 0 || added.length > 0) await writeUsageCache(root, next, reportPathError);
|
|
10336
10604
|
return result.bytesRead >= byteBudget ? "budget-spent" : "settled";
|
|
10337
10605
|
};
|
|
10338
10606
|
const scanOnce = () => {
|
|
@@ -10365,22 +10633,49 @@ function createUsageScanner({ root, claudeProjectsDir: claudeProjectsDir2, byteB
|
|
|
10365
10633
|
snapshot: () => ({ cache: cache ?? emptyUsageCache(), scan, revision })
|
|
10366
10634
|
};
|
|
10367
10635
|
}
|
|
10636
|
+
async function transcriptFiles(claudeDir2, codexHome, now, onUnreadable) {
|
|
10637
|
+
const claudeFiles = attemptReportingFailure(claudeDir2, listTranscripts, onUnreadable);
|
|
10638
|
+
const codexFiles = codexHome === void 0 ? [] : listCodexTranscripts(codexHome, now, onUnreadable);
|
|
10639
|
+
const [claude, codex] = await Promise.all([claudeFiles, codexFiles]);
|
|
10640
|
+
return [...claude ?? [], ...codex];
|
|
10641
|
+
}
|
|
10642
|
+
var IN_OWN_REPO = "in-own-repo";
|
|
10368
10643
|
function outsideWorktreeRecorder() {
|
|
10369
|
-
const
|
|
10370
|
-
const
|
|
10371
|
-
const
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
return
|
|
10644
|
+
const lookupNewCwd = cachedRepoRoots({ onUnreadable: unreadableDirHasNoRepo });
|
|
10645
|
+
const lookupChangedCwd = cachedRepoRoots({ onUnreadable: unreadableDirHasNoRepo, ttlMs: 0 });
|
|
10646
|
+
const settledCwds = /* @__PURE__ */ new Map();
|
|
10647
|
+
const isStillSettled = async (cwd) => {
|
|
10648
|
+
const settled = settledCwds.get(cwd);
|
|
10649
|
+
if (settled === void 0) return false;
|
|
10650
|
+
return settled === IN_OWN_REPO || await worktreeCreatedAt(settled.worktree) === settled.createdAt;
|
|
10651
|
+
};
|
|
10652
|
+
const observeOutsideOwner = async (cwd) => {
|
|
10653
|
+
if (await isStillSettled(cwd) || !existsSync2(cwd)) return null;
|
|
10654
|
+
const roots = await (settledCwds.has(cwd) ? lookupChangedCwd : lookupNewCwd)(cwd);
|
|
10655
|
+
if (typeof roots === "string") return null;
|
|
10656
|
+
if (relativeInside(roots.main, roots.worktree) !== null) {
|
|
10657
|
+
settledCwds.set(cwd, IN_OWN_REPO);
|
|
10658
|
+
return null;
|
|
10659
|
+
}
|
|
10660
|
+
const createdAt = await worktreeCreatedAt(roots.worktree);
|
|
10661
|
+
settledCwds.set(cwd, { worktree: roots.worktree, createdAt });
|
|
10662
|
+
return { ...roots, createdAt };
|
|
10375
10663
|
};
|
|
10376
10664
|
return async (scanned, runs) => {
|
|
10377
10665
|
const cwds = new Set([...usageBucketsOf(scanned), ...runs].map((entry) => entry.cwd));
|
|
10378
|
-
const
|
|
10379
|
-
const
|
|
10380
|
-
|
|
10381
|
-
return [...new Map(outside.map(({ worktree, main }) => [worktree, main])).entries()];
|
|
10666
|
+
const observed = await Promise.all([...cwds].filter((cwd) => isAbsolute4(cwd)).map(observeOutsideOwner));
|
|
10667
|
+
const newOwners = observed.filter((owner) => owner !== null).filter((owner) => scanned.worktreeRepos[owner.worktree]?.at(-1)?.main !== owner.main);
|
|
10668
|
+
return [...new Map(newOwners.map((owner) => [owner.worktree, owner])).values()];
|
|
10382
10669
|
};
|
|
10383
10670
|
}
|
|
10671
|
+
async function worktreeCreatedAt(worktree) {
|
|
10672
|
+
const gitFile = await attemptReportingFailure(join34(worktree, ".git"), statOrNull, unreadableDirHasNoRepo);
|
|
10673
|
+
return gitFile?.mtimeMs ?? null;
|
|
10674
|
+
}
|
|
10675
|
+
function withNewOwners(worktreeRepos, owners, now) {
|
|
10676
|
+
const tenuresOf = ({ worktree, main, createdAt }) => [...worktreeRepos[worktree] ?? [], { main, since: createdAt ?? now.getTime() }];
|
|
10677
|
+
return { ...worktreeRepos, ...Object.fromEntries(owners.map((owner) => [owner.worktree, tenuresOf(owner)])) };
|
|
10678
|
+
}
|
|
10384
10679
|
function scanEquals(a, b) {
|
|
10385
10680
|
return a.listed === b.listed && a.filesTotal === b.filesTotal && a.filesDone === b.filesDone && a.bytesLeft === b.bytesLeft;
|
|
10386
10681
|
}
|
|
@@ -10419,7 +10714,7 @@ async function startServer({ root, port, home: home2, env, platform, log, warn:
|
|
|
10419
10714
|
const readLanguage = () => readLanguageOrLocale(root, env, onLanguageUnreadable);
|
|
10420
10715
|
const readMessages = () => readLanguage().then(serverMessages);
|
|
10421
10716
|
const warnLocalized = localizedWarn(readLanguage, warn2);
|
|
10422
|
-
const usage = createUsageScanner({ root, claudeProjectsDir: claudeProjectsDir(env, home2), warn: warnLocalized, now });
|
|
10717
|
+
const usage = createUsageScanner({ root, claudeProjectsDir: claudeProjectsDir(env, home2), codexHome: env.CODEX_HOME || join35(home2, ".codex"), warn: warnLocalized, now });
|
|
10423
10718
|
const memory = createMemorySampler({ now });
|
|
10424
10719
|
const changes = createChangeFeed({ root, debounceMs: CHANGE_DEBOUNCE_MS, warn: warnLocalized });
|
|
10425
10720
|
const allowedHosts = /* @__PURE__ */ new Set();
|
|
@@ -10449,10 +10744,10 @@ async function startServer({ root, port, home: home2, env, platform, log, warn:
|
|
|
10449
10744
|
return { port: actualPort, close };
|
|
10450
10745
|
}
|
|
10451
10746
|
function closeOnStopSignal(server) {
|
|
10452
|
-
return new Promise((
|
|
10747
|
+
return new Promise((resolve8, reject) => {
|
|
10453
10748
|
const stop = () => {
|
|
10454
10749
|
for (const signal3 of STOP_SIGNALS) process.off(signal3, stop);
|
|
10455
|
-
server.close().then(
|
|
10750
|
+
server.close().then(resolve8, reject);
|
|
10456
10751
|
};
|
|
10457
10752
|
for (const signal3 of STOP_SIGNALS) process.once(signal3, stop);
|
|
10458
10753
|
});
|
|
@@ -10462,10 +10757,10 @@ function listenFailure(error, port, messages) {
|
|
|
10462
10757
|
return messages.listenFailed(reason);
|
|
10463
10758
|
}
|
|
10464
10759
|
function listen(app, port) {
|
|
10465
|
-
return new Promise((
|
|
10760
|
+
return new Promise((resolve8, reject) => {
|
|
10466
10761
|
const server = serve({ fetch: app.fetch, hostname: LOOPBACK_HOST, port }, (info) => {
|
|
10467
10762
|
server.off("error", reject);
|
|
10468
|
-
|
|
10763
|
+
resolve8({ server, port: info.port });
|
|
10469
10764
|
});
|
|
10470
10765
|
server.once("error", reject);
|
|
10471
10766
|
server.on("request", (_request, response) => response.on("finish", () => dropIdleWhenClosing(server)));
|
|
@@ -10476,7 +10771,7 @@ function dropIdleWhenClosing(server) {
|
|
|
10476
10771
|
setImmediate(() => server.closeIdleConnections());
|
|
10477
10772
|
}
|
|
10478
10773
|
function closeServer(server) {
|
|
10479
|
-
return new Promise((
|
|
10774
|
+
return new Promise((resolve8, reject) => server.close((error) => error ? reject(error) : resolve8()));
|
|
10480
10775
|
}
|
|
10481
10776
|
function startBackground({ usage, memory, maintain, messages, log, warn: warn2 }) {
|
|
10482
10777
|
usage.start();
|
|
@@ -10528,7 +10823,8 @@ import { setTimeout as sleep3 } from "node:timers/promises";
|
|
|
10528
10823
|
// src/cli/service/service.ts
|
|
10529
10824
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
10530
10825
|
function serviceEnvironment(launch) {
|
|
10531
|
-
|
|
10826
|
+
const { CODEX_HOME } = launch.env;
|
|
10827
|
+
return { BACKLOG_DIR: launch.backlogRoot, PORT: String(launch.port), PATH: launch.env.PATH ?? "", HOME: launch.home, ...CODEX_HOME ? { CODEX_HOME } : {} };
|
|
10532
10828
|
}
|
|
10533
10829
|
async function numberRecordedIn(file, pattern, parse2, encoding = "utf8") {
|
|
10534
10830
|
const text = await readFile3(file, encoding).catch((error) => {
|
|
@@ -10900,11 +11196,11 @@ function reportFailure({ failed: failed2, code, output }, io) {
|
|
|
10900
11196
|
}
|
|
10901
11197
|
|
|
10902
11198
|
// src/cli/agents/grouped-stop-hooks.ts
|
|
10903
|
-
import { z as
|
|
11199
|
+
import { z as z21 } from "zod";
|
|
10904
11200
|
|
|
10905
11201
|
// src/cli/agents/json-config.ts
|
|
10906
11202
|
import { mkdir as mkdir10, readFile as readFile4, realpath } from "node:fs/promises";
|
|
10907
|
-
import { dirname as dirname12, resolve as
|
|
11203
|
+
import { dirname as dirname12, resolve as resolve5 } from "node:path";
|
|
10908
11204
|
var MAX_LINK_HOPS = 40;
|
|
10909
11205
|
async function readJsonConfig(path, schema) {
|
|
10910
11206
|
const text = await readConfigText(path);
|
|
@@ -10950,7 +11246,7 @@ async function danglingLinkTarget(path) {
|
|
|
10950
11246
|
for (let hop = 0; hop < MAX_LINK_HOPS; hop++) {
|
|
10951
11247
|
const link2 = await linkTargetOrNull(current);
|
|
10952
11248
|
if (link2 === null) return current;
|
|
10953
|
-
current =
|
|
11249
|
+
current = resolve5(dirname12(current), link2);
|
|
10954
11250
|
}
|
|
10955
11251
|
return current;
|
|
10956
11252
|
}
|
|
@@ -10963,9 +11259,9 @@ function commandOfHook(hook) {
|
|
|
10963
11259
|
const command2 = typeof hook === "object" && hook !== null ? hook.command : void 0;
|
|
10964
11260
|
return typeof command2 === "string" ? command2 : void 0;
|
|
10965
11261
|
}
|
|
10966
|
-
var stopGroupSchema =
|
|
10967
|
-
var groupedConfigSchema =
|
|
10968
|
-
hooks:
|
|
11262
|
+
var stopGroupSchema = z21.object({ hooks: z21.array(z21.unknown()).optional() }).passthrough();
|
|
11263
|
+
var groupedConfigSchema = z21.object({
|
|
11264
|
+
hooks: z21.object({ Stop: z21.array(stopGroupSchema).optional() }).passthrough().optional()
|
|
10969
11265
|
}).passthrough();
|
|
10970
11266
|
function refreshOurHook(lists, hook, { isOurs, isCurrent }) {
|
|
10971
11267
|
const ours = lists.flatMap((list) => list.flatMap((entry, index) => isOurs(entry) ? [{ list, index, entry }] : []));
|
|
@@ -11044,11 +11340,11 @@ function removeClaudeStopHook(settings) {
|
|
|
11044
11340
|
}
|
|
11045
11341
|
|
|
11046
11342
|
// src/cli/agents/cursor-hooks.ts
|
|
11047
|
-
import { z as
|
|
11343
|
+
import { z as z22 } from "zod";
|
|
11048
11344
|
var CURSOR_HOOKS_VERSION = 1;
|
|
11049
|
-
var cursorConfigSchema =
|
|
11050
|
-
version:
|
|
11051
|
-
hooks:
|
|
11345
|
+
var cursorConfigSchema = z22.object({
|
|
11346
|
+
version: z22.number().optional(),
|
|
11347
|
+
hooks: z22.object({ stop: z22.array(z22.unknown()).optional() }).passthrough().optional()
|
|
11052
11348
|
}).passthrough();
|
|
11053
11349
|
function addCursorStopHook(file, hook, ourHook) {
|
|
11054
11350
|
return addStopHookIn(
|
|
@@ -11400,7 +11696,7 @@ var statusCommand = taskFieldCommand({
|
|
|
11400
11696
|
});
|
|
11401
11697
|
|
|
11402
11698
|
// src/cli/commands/take.ts
|
|
11403
|
-
import { resolve as
|
|
11699
|
+
import { resolve as resolve6 } from "node:path";
|
|
11404
11700
|
var takeCommand = {
|
|
11405
11701
|
name: "take",
|
|
11406
11702
|
usage: (language) => cliMessages(language).takeUsage(),
|
|
@@ -11474,7 +11770,7 @@ function repoRelativePath(io, project, loaded, path) {
|
|
|
11474
11770
|
const typed = sourcePath(path);
|
|
11475
11771
|
const roots = cwdGitRoots(io);
|
|
11476
11772
|
if (roots === null || !cwdBelongsTo(project, loaded, io)) return typed;
|
|
11477
|
-
return pathFromProjectRepo(project, roots, repoContext(io),
|
|
11773
|
+
return pathFromProjectRepo(project, roots, repoContext(io), resolve6(realpathOrNull(io.cwd) ?? io.cwd, typed));
|
|
11478
11774
|
}
|
|
11479
11775
|
async function takeAll(index, chosen, io) {
|
|
11480
11776
|
const write = taskWriter(io, index);
|
|
@@ -11661,14 +11957,16 @@ async function readStdin() {
|
|
|
11661
11957
|
var home = homedir();
|
|
11662
11958
|
var backlogRoot = resolveBacklogRoot(process.env, home);
|
|
11663
11959
|
var cliPath = fileURLToPath(import.meta.url);
|
|
11664
|
-
var packageRoot =
|
|
11960
|
+
var packageRoot = resolve7(dirname13(cliPath), "..");
|
|
11665
11961
|
var argv = process.argv.slice(2);
|
|
11666
11962
|
var warn = (line) => void process.stderr.write(`${line}
|
|
11667
11963
|
`);
|
|
11668
11964
|
var CLOSED_READER_CODES = ["EPIPE", "EOF"];
|
|
11669
|
-
process.stdout
|
|
11670
|
-
|
|
11671
|
-
|
|
11965
|
+
for (const output of [process.stdout, process.stderr]) {
|
|
11966
|
+
output.on("error", (error) => {
|
|
11967
|
+
if (!hasAnyErrorCode(error, CLOSED_READER_CODES)) throw error;
|
|
11968
|
+
});
|
|
11969
|
+
}
|
|
11672
11970
|
var exitCode = await runCli(argv, {
|
|
11673
11971
|
cwd: process.cwd(),
|
|
11674
11972
|
home,
|