@moberg_hr/work-tree 1.16.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -142
- package/dist/answer-2J4XLIP7.js +63 -0
- package/dist/answer-2J4XLIP7.js.map +1 -0
- package/dist/attach-CZKRNPAJ.js +59 -0
- package/dist/attach-CZKRNPAJ.js.map +1 -0
- package/dist/bin.js +26 -11924
- package/dist/bin.js.map +1 -1
- package/dist/block-RAIDCJ4F.js +84 -0
- package/dist/block-RAIDCJ4F.js.map +1 -0
- package/dist/broadcast-BSI5NDDB.js +104 -0
- package/dist/broadcast-BSI5NDDB.js.map +1 -0
- package/dist/catchup-VVOPL2S5.js +51 -0
- package/dist/catchup-VVOPL2S5.js.map +1 -0
- package/dist/chunk-3JWTO5VZ.js +135 -0
- package/dist/chunk-3JWTO5VZ.js.map +1 -0
- package/dist/chunk-4BOK2GXL.js +210 -0
- package/dist/chunk-4BOK2GXL.js.map +1 -0
- package/dist/chunk-5QK7GB5K.js +112 -0
- package/dist/chunk-5QK7GB5K.js.map +1 -0
- package/dist/chunk-6AQRYLOB.js +16 -0
- package/dist/chunk-6AQRYLOB.js.map +1 -0
- package/dist/chunk-6FTIY5M6.js +120 -0
- package/dist/chunk-6FTIY5M6.js.map +1 -0
- package/dist/chunk-6H3MLDGG.js +48 -0
- package/dist/chunk-6H3MLDGG.js.map +1 -0
- package/dist/chunk-77XFJQGC.js +103 -0
- package/dist/chunk-77XFJQGC.js.map +1 -0
- package/dist/chunk-7HEB6SQS.js +257 -0
- package/dist/chunk-7HEB6SQS.js.map +1 -0
- package/dist/chunk-7NAXFBFI.js +206 -0
- package/dist/chunk-7NAXFBFI.js.map +1 -0
- package/dist/chunk-7NCW3LUT.js +358 -0
- package/dist/chunk-7NCW3LUT.js.map +1 -0
- package/dist/chunk-7OLPI334.js +537 -0
- package/dist/chunk-7OLPI334.js.map +1 -0
- package/dist/chunk-ABQYKTG4.js +38 -0
- package/dist/chunk-ABQYKTG4.js.map +1 -0
- package/dist/chunk-AH5TM3NB.js +21 -0
- package/dist/chunk-AH5TM3NB.js.map +1 -0
- package/dist/chunk-AKMPF72Y.js +274 -0
- package/dist/chunk-AKMPF72Y.js.map +1 -0
- package/dist/chunk-BR6OPEE4.js +162 -0
- package/dist/chunk-BR6OPEE4.js.map +1 -0
- package/dist/chunk-C2BK6EBN.js +162 -0
- package/dist/chunk-C2BK6EBN.js.map +1 -0
- package/dist/chunk-C2THFSXA.js +37 -0
- package/dist/chunk-C2THFSXA.js.map +1 -0
- package/dist/chunk-C7W5TMFB.js +308 -0
- package/dist/chunk-C7W5TMFB.js.map +1 -0
- package/dist/chunk-CLGVSX36.js +668 -0
- package/dist/chunk-CLGVSX36.js.map +1 -0
- package/dist/chunk-CVAVYDXO.js +295 -0
- package/dist/chunk-CVAVYDXO.js.map +1 -0
- package/dist/chunk-DW4JPVXB.js +41 -0
- package/dist/chunk-DW4JPVXB.js.map +1 -0
- package/dist/chunk-FPKERDK7.js +142 -0
- package/dist/chunk-FPKERDK7.js.map +1 -0
- package/dist/chunk-FR3EWVXI.js +188 -0
- package/dist/chunk-FR3EWVXI.js.map +1 -0
- package/dist/chunk-H5LKMR45.js +117 -0
- package/dist/chunk-H5LKMR45.js.map +1 -0
- package/dist/chunk-HIZBWYPL.js +267 -0
- package/dist/chunk-HIZBWYPL.js.map +1 -0
- package/dist/chunk-HSICXDMZ.js +41 -0
- package/dist/chunk-HSICXDMZ.js.map +1 -0
- package/dist/chunk-HUXS3VAI.js +90 -0
- package/dist/chunk-HUXS3VAI.js.map +1 -0
- package/dist/chunk-HWUINPIL.js +151 -0
- package/dist/chunk-HWUINPIL.js.map +1 -0
- package/dist/chunk-IXKVCR4Y.js +487 -0
- package/dist/chunk-IXKVCR4Y.js.map +1 -0
- package/dist/chunk-JNBYNRFS.js +54 -0
- package/dist/chunk-JNBYNRFS.js.map +1 -0
- package/dist/chunk-JYTMT5DF.js +421 -0
- package/dist/chunk-JYTMT5DF.js.map +1 -0
- package/dist/chunk-KGZ6OZ2T.js +102 -0
- package/dist/chunk-KGZ6OZ2T.js.map +1 -0
- package/dist/chunk-LMIEEDDC.js +9 -0
- package/dist/chunk-LMIEEDDC.js.map +1 -0
- package/dist/chunk-LNHSBM4L.js +26 -0
- package/dist/chunk-LNHSBM4L.js.map +1 -0
- package/dist/chunk-M4FVCAT6.js +2406 -0
- package/dist/chunk-M4FVCAT6.js.map +1 -0
- package/dist/chunk-N4EYQKSM.js +104 -0
- package/dist/chunk-N4EYQKSM.js.map +1 -0
- package/dist/chunk-NDWSLQPB.js +112 -0
- package/dist/chunk-NDWSLQPB.js.map +1 -0
- package/dist/chunk-O3QTWVSK.js +323 -0
- package/dist/chunk-O3QTWVSK.js.map +1 -0
- package/dist/chunk-P3BL4EOP.js +37 -0
- package/dist/chunk-P3BL4EOP.js.map +1 -0
- package/dist/chunk-PN44M5EE.js +887 -0
- package/dist/chunk-PN44M5EE.js.map +1 -0
- package/dist/chunk-Q6WZCO45.js +47 -0
- package/dist/chunk-Q6WZCO45.js.map +1 -0
- package/dist/chunk-QBAZG4CY.js +230 -0
- package/dist/chunk-QBAZG4CY.js.map +1 -0
- package/dist/chunk-R2LN3JJJ.js +132 -0
- package/dist/chunk-R2LN3JJJ.js.map +1 -0
- package/dist/chunk-RCYI7SRA.js +15 -0
- package/dist/chunk-RCYI7SRA.js.map +1 -0
- package/dist/chunk-RYNBBSLY.js +67 -0
- package/dist/chunk-RYNBBSLY.js.map +1 -0
- package/dist/chunk-S5HJT7CM.js +30 -0
- package/dist/chunk-S5HJT7CM.js.map +1 -0
- package/dist/chunk-SNAQOHNL.js +285 -0
- package/dist/chunk-SNAQOHNL.js.map +1 -0
- package/dist/chunk-SOCPIHCS.js +181 -0
- package/dist/chunk-SOCPIHCS.js.map +1 -0
- package/dist/chunk-TUC4QY4O.js +147 -0
- package/dist/chunk-TUC4QY4O.js.map +1 -0
- package/dist/chunk-TUFQJXXO.js +19 -0
- package/dist/chunk-TUFQJXXO.js.map +1 -0
- package/dist/chunk-UFY7C5PP.js +90 -0
- package/dist/chunk-UFY7C5PP.js.map +1 -0
- package/dist/chunk-UQ35KLHH.js +34 -0
- package/dist/chunk-UQ35KLHH.js.map +1 -0
- package/dist/chunk-VJ7SVDED.js +177 -0
- package/dist/chunk-VJ7SVDED.js.map +1 -0
- package/dist/chunk-VJNSIDOA.js +23 -0
- package/dist/chunk-VJNSIDOA.js.map +1 -0
- package/dist/chunk-WF5SBVPZ.js +190 -0
- package/dist/chunk-WF5SBVPZ.js.map +1 -0
- package/dist/chunk-WMJIU3YW.js +29 -0
- package/dist/chunk-WMJIU3YW.js.map +1 -0
- package/dist/chunk-XJDEROHY.js +19 -0
- package/dist/chunk-XJDEROHY.js.map +1 -0
- package/dist/chunk-YKODIG22.js +221 -0
- package/dist/chunk-YKODIG22.js.map +1 -0
- package/dist/chunk-YNKWLC45.js +122 -0
- package/dist/chunk-YNKWLC45.js.map +1 -0
- package/dist/chunk-YZDD5YGE.js +165 -0
- package/dist/chunk-YZDD5YGE.js.map +1 -0
- package/dist/chunk-YZWADOEW.js +151 -0
- package/dist/chunk-YZWADOEW.js.map +1 -0
- package/dist/chunk-ZJN5RWZD.js +76 -0
- package/dist/chunk-ZJN5RWZD.js.map +1 -0
- package/dist/chunk-ZSHWP2VS.js +22 -0
- package/dist/chunk-ZSHWP2VS.js.map +1 -0
- package/dist/chunk-ZXPYWZL5.js +307 -0
- package/dist/chunk-ZXPYWZL5.js.map +1 -0
- package/dist/cleanup-LDBGWEKZ.js +192 -0
- package/dist/cleanup-LDBGWEKZ.js.map +1 -0
- package/dist/cli-UATB4RM2.js +18 -0
- package/dist/cli-UATB4RM2.js.map +1 -0
- package/dist/command-hook-installer-SGEJTZ2Y.js +204 -0
- package/dist/command-hook-installer-SGEJTZ2Y.js.map +1 -0
- package/dist/completion-MXX5TRIV.js +118 -0
- package/dist/completion-MXX5TRIV.js.map +1 -0
- package/dist/config-IEIU7A66.js +410 -0
- package/dist/config-IEIU7A66.js.map +1 -0
- package/dist/console-reporter-XU6VFUZE.js +10 -0
- package/dist/console-reporter-XU6VFUZE.js.map +1 -0
- package/dist/diff-K47HB6SA.js +582 -0
- package/dist/diff-K47HB6SA.js.map +1 -0
- package/dist/digest-FBZTBXQO.js +100 -0
- package/dist/digest-FBZTBXQO.js.map +1 -0
- package/dist/fork-BKI5UNNS.js +120 -0
- package/dist/fork-BKI5UNNS.js.map +1 -0
- package/dist/hook-SLMZT5OV.js +220 -0
- package/dist/hook-SLMZT5OV.js.map +1 -0
- package/dist/hydrate-Y2AAMZTA.js +121 -0
- package/dist/hydrate-Y2AAMZTA.js.map +1 -0
- package/dist/init-7ESFTYZC.js +187 -0
- package/dist/init-7ESFTYZC.js.map +1 -0
- package/dist/install-skills-O34BHFHD.js +14 -0
- package/dist/install-skills-O34BHFHD.js.map +1 -0
- package/dist/install-skills-bin.js +12 -0
- package/dist/install-skills-bin.js.map +1 -0
- package/dist/list-KEF73NLQ.js +126 -0
- package/dist/list-KEF73NLQ.js.map +1 -0
- package/dist/move-FKT2P5LY.js +313 -0
- package/dist/move-FKT2P5LY.js.map +1 -0
- package/dist/note-WGM6LCP2.js +78 -0
- package/dist/note-WGM6LCP2.js.map +1 -0
- package/dist/overlaps-FRLMMIGC.js +56 -0
- package/dist/overlaps-FRLMMIGC.js.map +1 -0
- package/dist/pin-MQ5ZE37R.js +45 -0
- package/dist/pin-MQ5ZE37R.js.map +1 -0
- package/dist/pr-527S5HXB.js +122 -0
- package/dist/pr-527S5HXB.js.map +1 -0
- package/dist/prune-AIS5YEXP.js +92 -0
- package/dist/prune-AIS5YEXP.js.map +1 -0
- package/dist/pty-host-RWIS55N4.js +826 -0
- package/dist/pty-host-RWIS55N4.js.map +1 -0
- package/dist/read-AP6T3ZGN.js +57 -0
- package/dist/read-AP6T3ZGN.js.map +1 -0
- package/dist/recent-IE3LYQ65.js +111 -0
- package/dist/recent-IE3LYQ65.js.map +1 -0
- package/dist/remove-YGUTSKZP.js +108 -0
- package/dist/remove-YGUTSKZP.js.map +1 -0
- package/dist/report-KM4OZCZB.js +16 -0
- package/dist/report-KM4OZCZB.js.map +1 -0
- package/dist/resume-UUP6R2IE.js +81 -0
- package/dist/resume-UUP6R2IE.js.map +1 -0
- package/dist/run-V4755W7C.js +263 -0
- package/dist/run-V4755W7C.js.map +1 -0
- package/dist/screen-DNX4K23V.js +58 -0
- package/dist/screen-DNX4K23V.js.map +1 -0
- package/dist/search-3JZXLCR2.js +46 -0
- package/dist/search-3JZXLCR2.js.map +1 -0
- package/dist/section-TXLC5XO3.js +79 -0
- package/dist/section-TXLC5XO3.js.map +1 -0
- package/dist/send-6X46WZLC.js +87 -0
- package/dist/send-6X46WZLC.js.map +1 -0
- package/dist/sessions-T3QDTNP7.js +135 -0
- package/dist/sessions-T3QDTNP7.js.map +1 -0
- package/dist/snooze-KYSFXLPY.js +65 -0
- package/dist/snooze-KYSFXLPY.js.map +1 -0
- package/dist/start-SQSDQK4F.js +56 -0
- package/dist/start-SQSDQK4F.js.map +1 -0
- package/dist/state-4DFV6SHG.js +147 -0
- package/dist/state-4DFV6SHG.js.map +1 -0
- package/dist/status-H5OW4LYE.js +118 -0
- package/dist/status-H5OW4LYE.js.map +1 -0
- package/dist/stop-HC7XPSSP.js +45 -0
- package/dist/stop-HC7XPSSP.js.map +1 -0
- package/dist/sync-ITK5UYGM.js +96 -0
- package/dist/sync-ITK5UYGM.js.map +1 -0
- package/dist/time-GN6B4QD6.js +111 -0
- package/dist/time-GN6B4QD6.js.map +1 -0
- package/dist/todo-LWMQY6XW.js +152 -0
- package/dist/todo-LWMQY6XW.js.map +1 -0
- package/dist/tree-7BMORJ6J.js +235 -0
- package/dist/tree-7BMORJ6J.js.map +1 -0
- package/dist/update-6LQNLRA4.js +57 -0
- package/dist/update-6LQNLRA4.js.map +1 -0
- package/dist/wait-MZOZQ3CI.js +57 -0
- package/dist/wait-MZOZQ3CI.js.map +1 -0
- package/dist/wd-bin.js +21 -11912
- package/dist/wd-bin.js.map +1 -1
- package/dist/web/assets/PtyView-BrP-ENHg.css +1 -0
- package/dist/web/assets/PtyView-DYvawzWb.js +90 -0
- package/dist/web/assets/PtyView-DYvawzWb.js.map +1 -0
- package/dist/web/assets/index-C5lJhIwK.js +116 -0
- package/dist/web/assets/index-C5lJhIwK.js.map +1 -0
- package/dist/web/assets/index-L8mjakHP.css +1 -0
- package/dist/web/index.html +3 -5
- package/dist/web-IC3P7EHZ.js +7689 -0
- package/dist/web-IC3P7EHZ.js.map +1 -0
- package/npm-shrinkwrap.json +6947 -0
- package/package.json +52 -34
- package/plugins/work-tree/.claude-plugin/plugin.json +1 -1
- package/plugins/work-tree/skills/wd-review/SKILL.md +4 -4
- package/plugins/work-tree/skills/work-sessions/SKILL.md +62 -0
- package/scripts/postinstall.mjs +15 -45
- package/dist/web/assets/index-B9H3vCtL.js +0 -107
- package/dist/web/assets/index-B9H3vCtL.js.map +0 -1
- package/dist/web/assets/index-BseMpW5i.css +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
sessionStatusView
|
|
4
|
+
} from "./chunk-6H3MLDGG.js";
|
|
5
|
+
import {
|
|
6
|
+
buildDigest,
|
|
7
|
+
loadHistory,
|
|
8
|
+
loadManifest,
|
|
9
|
+
promptEntries,
|
|
10
|
+
readSessionActivity,
|
|
11
|
+
readStatus,
|
|
12
|
+
scopeHashForPaths,
|
|
13
|
+
workSteps
|
|
14
|
+
} from "./chunk-M4FVCAT6.js";
|
|
15
|
+
import {
|
|
16
|
+
sessionIdFor
|
|
17
|
+
} from "./chunk-7NCW3LUT.js";
|
|
18
|
+
import {
|
|
19
|
+
agentOf,
|
|
20
|
+
lineTimeOf,
|
|
21
|
+
readJsonlSince
|
|
22
|
+
} from "./chunk-PN44M5EE.js";
|
|
23
|
+
|
|
24
|
+
// src/core/conversations/digest-source.ts
|
|
25
|
+
function digestWindow(sinceMs, now = Date.now()) {
|
|
26
|
+
return Math.max(sinceMs !== void 0 && Number.isFinite(sinceMs) ? sinceMs : now - 24 * 36e5, now - 14 * 24 * 36e5);
|
|
27
|
+
}
|
|
28
|
+
var READ_CONCURRENCY = 3;
|
|
29
|
+
async function mapLimit(items, limit, fn) {
|
|
30
|
+
const out = new Array(items.length);
|
|
31
|
+
let next = 0;
|
|
32
|
+
await Promise.all(
|
|
33
|
+
Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
34
|
+
for (let i = next++; i < items.length; i = next++) out[i] = await fn(items[i]);
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function createDigestSource(deps = {}) {
|
|
40
|
+
const now = deps.now ?? Date.now;
|
|
41
|
+
let cache = /* @__PURE__ */ new Map();
|
|
42
|
+
return {
|
|
43
|
+
async collect(asked) {
|
|
44
|
+
const t0 = now();
|
|
45
|
+
const sinceMs = digestWindow(asked, t0);
|
|
46
|
+
const next = /* @__PURE__ */ new Map();
|
|
47
|
+
const inputs = await mapLimit(
|
|
48
|
+
loadHistory().filter((s) => !s.archivedAt || Date.parse(s.archivedAt) >= sinceMs),
|
|
49
|
+
READ_CONCURRENCY,
|
|
50
|
+
async (s) => {
|
|
51
|
+
const id = sessionIdFor(s);
|
|
52
|
+
const status = readStatus(id);
|
|
53
|
+
const attention = status ? sessionStatusView(status, s, readSessionActivity(s).lastActivity ?? 0) : null;
|
|
54
|
+
const transcripts = [];
|
|
55
|
+
const work = [];
|
|
56
|
+
let partial = false;
|
|
57
|
+
const conv = agentOf(s).conversation;
|
|
58
|
+
for (const t of conv?.files(s) ?? []) {
|
|
59
|
+
if (t.mtimeMs < sinceMs) continue;
|
|
60
|
+
const key = `${t.file}:${t.size}:${t.mtimeMs}`;
|
|
61
|
+
const hit = cache.get(key);
|
|
62
|
+
const reuse = !!hit && hit.sinceMs <= sinceMs;
|
|
63
|
+
const read = reuse ? null : await readJsonlSince(t.file, sinceMs, lineTimeOf(conv));
|
|
64
|
+
const all = read ? conv.entries(read.lines) : [];
|
|
65
|
+
const win = reuse ? hit.win : { entries: promptEntries(all), partial: read.partial };
|
|
66
|
+
const steps = reuse ? hit.steps : workSteps(all).steps;
|
|
67
|
+
next.set(key, { sinceMs: reuse ? hit.sinceMs : sinceMs, win, steps });
|
|
68
|
+
transcripts.push(win.entries);
|
|
69
|
+
work.push(steps);
|
|
70
|
+
if (win.partial) partial = true;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
sessionId: id,
|
|
74
|
+
target: s.target,
|
|
75
|
+
branch: s.branch,
|
|
76
|
+
isGroup: s.isGroup,
|
|
77
|
+
lastAccessedAt: s.lastAccessedAt,
|
|
78
|
+
archivedAt: s.archivedAt ?? null,
|
|
79
|
+
status: attention ? { state: attention.state, summary: attention.summary, updatedAt: attention.updatedAt } : null,
|
|
80
|
+
transcripts,
|
|
81
|
+
transcriptsPartial: partial,
|
|
82
|
+
work,
|
|
83
|
+
checkpoints: loadManifest(scopeHashForPaths(s.paths)).entries,
|
|
84
|
+
diffStat: deps.diffStatFor?.(id) ?? null,
|
|
85
|
+
ci: await deps.ciFor?.(id) ?? null
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
cache = next;
|
|
90
|
+
return {
|
|
91
|
+
since: new Date(sinceMs).toISOString(),
|
|
92
|
+
generatedAt: new Date(t0).toISOString(),
|
|
93
|
+
sessions: buildDigest(inputs, sinceMs)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
createDigestSource
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=chunk-KGZ6OZ2T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/conversations/digest-source.ts"],"sourcesContent":["import { loadHistory } from '../sessions/history.js';\nimport { sessionStatusView } from '../status/turn-activity.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { readStatus } from '../status/session-status.js';\nimport { readSessionActivity } from '../sessions/session-activity.js';\nimport { readJsonlSince } from './jsonl.js';\nimport { lineTimeOf } from '../agents/index.js';\nimport { agentOf } from '../agents/index.js';\nimport type { ConversationEntry } from '../agents/types.js';\nimport { loadManifest } from '../diff/checkpoint.js';\nimport { scopeHashForPaths } from '../diff/scope-manager.js';\nimport { buildDigest, promptEntries } from './digest.js';\nimport { workSteps, type WorkStep } from './work-time.js';\nimport type { DiffStat, DigestResponse, SessionCi } from '../api-types.js';\n\n/**\n * Gathers the digest's inputs from disk (history, transcripts touched in\n * the window, checkpoint manifests, status rows) and builds it — for the\n * Today tab and `work digest` alike. Pure assembly lives in digest.ts.\n *\n * What only a running work web knows comes in through `deps`: the diff-stat\n * cache and the PR watch's state (the CLI asks work web for those, or goes\n * without). It never runs Claude, gh or git: a digest is a read.\n */\n\n/** Default: the last 24 hours; never more than two weeks back. */\nexport function digestWindow(sinceMs: number | undefined, now = Date.now()): number {\n return Math.max(sinceMs !== undefined && Number.isFinite(sinceMs) ? sinceMs : now - 24 * 3_600_000, now - 14 * 24 * 3_600_000);\n}\n\nexport interface DigestDeps {\n diffStatFor?: (sessionId: string) => DiffStat | null;\n ciFor?: (sessionId: string) => SessionCi | null | Promise<SessionCi | null>;\n now?: () => number;\n}\n\nexport interface DigestSource {\n collect(sinceMs?: number): Promise<DigestResponse>;\n}\n\n/** Sessions read at once: each can mean reading up to 64 MB of transcript. */\nconst READ_CONCURRENCY = 3;\n\n/** `fn` over `items`, at most `limit` at a time, results in order. */\nasync function mapLimit<T, R>(items: T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]> {\n const out: R[] = new Array(items.length);\n let next = 0;\n await Promise.all(\n Array.from({ length: Math.min(limit, items.length) }, async () => {\n for (let i = next++; i < items.length; i = next++) out[i] = await fn(items[i]);\n }),\n );\n return out;\n}\n\n/**\n * A digest source that keeps what it already read of each transcript — its\n * prompts only (promptEntries) — by file identity (path, size, mtime):\n * changing the window re-reads only what changed since, and the cache holds\n * just the files of the last digest. The CLI makes one per run; work web\n * keeps one.\n */\nexport function createDigestSource(deps: DigestDeps = {}): DigestSource {\n const now = deps.now ?? Date.now;\n let cache = new Map<string, { sinceMs: number; win: PromptWindow; steps: WorkStep[] }>();\n return {\n async collect(asked) {\n const t0 = now();\n const sinceMs = digestWindow(asked, t0);\n const next = new Map<string, { sinceMs: number; win: PromptWindow; steps: WorkStep[] }>();\n const inputs = await mapLimit(\n loadHistory().filter((s) => !s.archivedAt || Date.parse(s.archivedAt) >= sinceMs),\n READ_CONCURRENCY,\n async (s) => {\n const id = sessionIdFor(s);\n const status = readStatus(id);\n const attention = status ? sessionStatusView(status, s, readSessionActivity(s).lastActivity ?? 0) : null;\n const transcripts: ConversationEntry[][] = [];\n const work: WorkStep[][] = [];\n let partial = false;\n // Its conversations, as its agent keeps them (none when work can't read them).\n const conv = agentOf(s).conversation;\n for (const t of conv?.files(s) ?? []) {\n if (t.mtimeMs < sinceMs) continue;\n const key = `${t.file}:${t.size}:${t.mtimeMs}`;\n const hit = cache.get(key);\n const reuse = !!hit && hit.sinceMs <= sinceMs;\n // The agent's work steps come from the whole read, before it is slimmed to prompts.\n const read = reuse ? null : await readJsonlSince(t.file, sinceMs, lineTimeOf(conv!));\n const all = read ? conv!.entries(read.lines) : [];\n const win = reuse ? hit.win : { entries: promptEntries(all), partial: read!.partial };\n const steps = reuse ? hit.steps : workSteps(all).steps;\n next.set(key, { sinceMs: reuse ? hit.sinceMs : sinceMs, win, steps });\n transcripts.push(win.entries);\n work.push(steps);\n if (win.partial) partial = true;\n }\n return {\n sessionId: id,\n target: s.target,\n branch: s.branch,\n isGroup: s.isGroup,\n lastAccessedAt: s.lastAccessedAt,\n archivedAt: s.archivedAt ?? null,\n status: attention ? { state: attention.state, summary: attention.summary, updatedAt: attention.updatedAt } : null,\n transcripts,\n transcriptsPartial: partial,\n work,\n checkpoints: loadManifest(scopeHashForPaths(s.paths)).entries,\n diffStat: deps.diffStatFor?.(id) ?? null,\n ci: (await deps.ciFor?.(id)) ?? null,\n };\n },\n );\n cache = next;\n return {\n since: new Date(sinceMs).toISOString(),\n generatedAt: new Date(t0).toISOString(),\n sessions: buildDigest(inputs, sinceMs),\n };\n },\n };\n}\n\n/** A read window reduced to the prompts the digest uses (whether the file's start was left unread). */\ninterface PromptWindow {\n entries: ConversationEntry[];\n partial: boolean;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["declare const __WORK2_VERSION__: string;\n\n/**\n * Inlined at build time from package.json#version. When running via `tsx`\n * (dev mode) the define isn't applied, so we fall back to a placeholder.\n */\nexport const VERSION: string = typeof __WORK2_VERSION__ !== 'undefined' ? __WORK2_VERSION__ : 'dev';\n"],"mappings":";;;AAMO,IAAM,UAAkB,OAA2C,UAAoB;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/core/platform/package-root.ts
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
var cached;
|
|
8
|
+
function packageRoot() {
|
|
9
|
+
if (cached !== void 0) return cached;
|
|
10
|
+
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
for (; ; ) {
|
|
12
|
+
try {
|
|
13
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
|
|
14
|
+
if (pkg.name === "@moberg_hr/work-tree") return cached = dir;
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
const up = path.dirname(dir);
|
|
18
|
+
if (up === dir) return cached = null;
|
|
19
|
+
dir = up;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
packageRoot
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=chunk-LNHSBM4L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/platform/package-root.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * The folder of work's own package.json — the installed package, or this\n * repo in dev. Found by walking up from this module, so it holds wherever\n * the code sits: bundled into dist/ (a chunk next to bin.js) or a source\n * file several folders under src/. Files shipped beside dist/ (dist/web, the\n * skills under plugins/) are found from here, never by counting `..`.\n */\nlet cached: string | null | undefined;\nexport function packageRoot(): string | null {\n if (cached !== undefined) return cached;\n let dir = path.dirname(fileURLToPath(import.meta.url));\n for (;;) {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')) as { name?: unknown };\n if (pkg.name === '@moberg_hr/work-tree') return (cached = dir);\n } catch {\n /* none here */\n }\n const up = path.dirname(dir);\n if (up === dir) return (cached = null);\n dir = up;\n }\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAS9B,IAAI;AACG,SAAS,cAA6B;AAC3C,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI,MAAM,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AACrD,aAAS;AACP,QAAI;AACF,YAAM,MAAM,KAAK,MAAM,GAAG,aAAa,KAAK,KAAK,KAAK,cAAc,GAAG,MAAM,CAAC;AAC9E,UAAI,IAAI,SAAS,uBAAwB,QAAQ,SAAS;AAAA,IAC5D,QAAQ;AAAA,IAER;AACA,UAAM,KAAK,KAAK,QAAQ,GAAG;AAC3B,QAAI,OAAO,IAAK,QAAQ,SAAS;AACjC,UAAM;AAAA,EACR;AACF;","names":[]}
|