@kabmo-labs/kabmo 0.38.0 → 0.38.2
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/dist/client/index.html +1 -1
- package/dist/client/index.js +421 -420
- package/dist/client/static/js/{CsvGrid-90zfbn7f.js → CsvGrid-4dpsfdrf.js} +1 -1
- package/dist/client/static/js/{DocxView-vwq2rf16.js → DocxView-crdgc0jd.js} +1 -1
- package/dist/client/static/js/{DrawioView-bvx7eqcz.js → DrawioView-1ts9y0yk.js} +1 -1
- package/dist/client/static/js/{ImageView-q6xfmbrq.js → ImageView-w2hyp129.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-qatdaw3n.js → LayoutWrapper-pdvfkncm.js} +1 -1
- package/dist/client/static/js/{Modal-6jx1fvfb.js → Modal-2sx1tgqr.js} +1 -1
- package/dist/client/static/js/{PdfView-tkv2d2zs.js → PdfView-72c123a9.js} +1 -1
- package/dist/client/static/js/{SessionsView-rbnecykz.js → SessionsView-a8921ysr.js} +1 -1
- package/dist/client/static/js/{SheetView-t08g8kdr.js → SheetView-8xh69wgk.js} +1 -1
- package/dist/client/static/js/{SvgPreview-9vh6mdcp.js → SvgPreview-z3fm87h6.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-bxcn33e1.js → abnfDiagram-O67JEVCF-25r2p3vh.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-40ggw6e8.js → architectureDiagram-NJMV4G6O-z3n19xwk.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-k41cvjrd.js → blockDiagram-BEXU5L5S-vzamgz9s.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rdcmn6ac.js → c4Diagram-YGBWAQC7-jejafgn0.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-txbmbkxv.js → classDiagram-v2-NBCMYWYE-qfa6mj0q.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-bxzh3qj1.js → cose-bilkent-JH36ORCC-9vzdgmk1.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-abx5343b.js → cynefinDiagram-VND7K2PF-a3k3w1t5.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-baj278kt.js → dagre-6A5THRUB-gf04dvxj.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-vqvhdc5m.js → diagram-22UHCM2B-a9e0a684.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-w328rfx0.js → diagram-3UASUU5V-fb73gfjd.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-zzcmwnm8.js → diagram-ATOU4E4O-yb9n3t30.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-8yw39mmj.js → diagram-CDSNMT55-adhbhw28.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-zgc386pv.js → diagram-MLGK6HIB-v4yxyb8r.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-efmvvscm.js → diagram-MPIPVDR6-94ttsqy2.js} +1 -1
- package/dist/client/static/js/{dockerfile-bp5dre33.js → dockerfile-mrranatf.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-p66h0dzq.js → ebnfDiagram-ZINNZB2B-jj4f3pyq.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-g0jjxcqd.js → elk-276RUBZZ-mtnkhyte.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-39gat96z.js → erDiagram-OPXOYQCR-18qdkhm5.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-zmz4grtx.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-nsjv1zt4.js → ganttDiagram-FUAMR5RP-vz28h061.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-r4vnkcy3.js → gitGraphDiagram-X574FWY7-cgq3r4rz.js} +1 -1
- package/dist/client/static/js/{index-73jwm4d5.js → index-12p63902.js} +1 -1
- package/dist/client/static/js/{index-h8h5c2r8.js → index-1c7294vk.js} +1 -1
- package/dist/client/static/js/{index-9wtg6ywn.js → index-2xb54jt3.js} +1 -1
- package/dist/client/static/js/{index-da10qpns.js → index-4hsxaa87.js} +1 -1
- package/dist/client/static/js/{index-5y0bvq4q.js → index-5v9v41ap.js} +2 -2
- package/dist/client/static/js/{index-rgp69pa8.js → index-6d5qj0kb.js} +1 -1
- package/dist/client/static/js/{index-11bdd235.js → index-6j9h1fa7.js} +1 -1
- package/dist/client/static/js/{index-dkseg29t.js → index-6k2x281j.js} +2 -2
- package/dist/client/static/js/{index-tzm90bsz.js → index-6rt7gs1j.js} +1 -1
- package/dist/client/static/js/{index-5ebhb94w.js → index-737w2mqf.js} +1 -1
- package/dist/client/static/js/{index-c15r8jd3.js → index-95t1hwr8.js} +1 -1
- package/dist/client/static/js/{index-vnn7m9yp.js → index-a5ptb956.js} +1 -1
- package/dist/client/static/js/{index-2drjp9ks.js → index-aa6qdgmv.js} +1 -1
- package/dist/client/static/js/{index-gwhx66f4.js → index-ajtd1q1h.js} +1 -1
- package/dist/client/static/js/{index-rf0p3v7q.js → index-arvqarv3.js} +1 -1
- package/dist/client/static/js/{index-ra38ggke.js → index-bgcp21ed.js} +1 -1
- package/dist/client/static/js/{index-rqrcw8nj.js → index-d146s9g3.js} +1 -1
- package/dist/client/static/js/{index-st202rjv.js → index-d8kjsgpt.js} +7 -7
- package/dist/client/static/js/{index-z0cpp5bc.js → index-dr7nhha9.js} +1 -1
- package/dist/client/static/js/{index-6ax2z70w.js → index-enxfdvdq.js} +1 -1
- package/dist/client/static/js/{index-dfgdn3fj.js → index-fqhpxzyb.js} +1 -1
- package/dist/client/static/js/{index-24yyj78e.js → index-gbdvr4rt.js} +1 -1
- package/dist/client/static/js/{index-50z4ek83.js → index-hp8kfk9z.js} +1 -1
- package/dist/client/static/js/{index-ha75kff0.js → index-kf9t3mzv.js} +1 -1
- package/dist/client/static/js/{index-hzx81cjq.js → index-naz3px72.js} +1 -1
- package/dist/client/static/js/{index-1qszrvzk.js → index-njqpkcvw.js} +1 -1
- package/dist/client/static/js/{index-e1pr3k50.js → index-qxb8k6py.js} +1 -1
- package/dist/client/static/js/{index-a74k07z2.js → index-rtd9frp1.js} +1 -1
- package/dist/client/static/js/{index-2ndq1ngv.js → index-s16h2nmv.js} +1 -1
- package/dist/client/static/js/{index-k9xsvab3.js → index-s910y31q.js} +1 -1
- package/dist/client/static/js/{index-tv61v3t3.js → index-we2ezmn7.js} +1 -1
- package/dist/client/static/js/{index-0kxqzafy.js → index-y5y7smet.js} +1 -1
- package/dist/client/static/js/{index-tfsaj5d1.js → index-z72wf7q4.js} +1 -1
- package/dist/client/static/js/{index-vxd4gykh.js → index-zdbvm01f.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-e39pvm4j.js → infoDiagram-VRGFBTTK-jjwckbr9.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rqhszgvp.js → ishikawaDiagram-OU5B5YK6-qzk5gejf.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-wgy5qrsv.js → journeyDiagram-ZHPQQLJL-maccpg3q.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-b8bxn0h1.js → kanban-definition-PNTS6WVX-xv2azgws.js} +1 -1
- package/dist/client/static/js/{mermaid.core-vb5ehtre.js → mermaid.core-e4ys760s.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-t4p38s38.js → mindmap-definition-NLK3R4M7-b779wz81.js} +1 -1
- package/dist/client/static/js/one-dark-pro-kckm8epj.js +1 -0
- package/dist/client/static/js/one-light-0v7rg9a7.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-3gp4madx.js → pegDiagram-GJSIUBJH-8sgdmhnw.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-0cbm773h.js → pieDiagram-5QR66LMP-nz6n95d6.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-jwg7fc9f.js → quadrantDiagram-O4NWA36T-47dpygk5.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-38xh691s.js → railroadDiagram-XR7U4H2S-wv0bvwve.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-gpddawxh.js → requirementDiagram-PLB6GJNP-w3r8r837.js} +1 -1
- package/dist/client/static/js/{rust-bx3ecv4n.js → rust-42c4h7e4.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s6t6bbhk.js → sankeyDiagram-IPEJSGJF-t55rjgad.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-wkq51pmb.js → sequenceDiagram-PO4LG4MO-yfwjwy37.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-xtwexf8k.js → sizeCapture-INFHLROL-nq6hy7ce.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-jnwsqa7y.js → stateDiagram-v2-GCMORJYK-4xy0atqh.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-mnkkqcbx.js → swimlanes-2SLR337P-np47cy1q.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-6xmrz03n.js → swimlanesDiagram-TC7HE7FX-56rk9kxv.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-rxq6heqh.js → timeline-definition-EJHVYXUP-rb0gnm35.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-dz94f57t.js → usecaseDiagram-POWQR4AR-gatkznan.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-5mmvkhsq.js → vennDiagram-UO4OBE2U-r3f5xjjq.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-dctdntpa.js → wardleyDiagram-VNRHLVJA-tpass65t.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-njyfrqkv.js → xychartDiagram-PMCCYNJV-8xkh67cw.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/changes/capture-bash.server.ts +69 -4
- package/src/server/lib/changes/capture-fs.server.ts +2 -10
- package/src/server/lib/changes/capture-races.test.ts +107 -0
- package/src/server/lib/changes/capture-scan.test.ts +157 -0
- package/src/server/lib/changes/capture-test-util.ts +1 -1
- package/src/server/lib/changes/capture-types.ts +3 -1
- package/src/server/lib/changes/capture-write.server.ts +50 -0
- package/src/server/lib/changes/capture.server.ts +33 -18
- package/src/server/lib/changes/capture.test.ts +48 -0
- package/src/server/lib/changes/classify-command.test.ts +20 -0
- package/src/server/lib/changes/classify-command.ts +46 -23
- package/src/server/lib/changes/classify-git.ts +12 -11
- package/src/server/lib/changes/classify-tokenize.ts +9 -1
- package/src/server/lib/changes/journal.server.ts +3 -1
- package/src/server/lib/changes/omp-fallback.server.ts +48 -0
- package/src/server/lib/changes/omp-fallback.test.ts +75 -0
- package/src/server/lib/changes/reader.server.ts +28 -0
- package/src/server/lib/changes/scan.server.ts +56 -1
- package/src/server/lib/changes/sessions.server.ts +65 -0
- package/src/server/lib/changes/sessions.test.ts +52 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-f6jpcqyq.js +0 -1
- package/dist/client/static/js/one-dark-pro-dhybn1ff.js +0 -1
- package/dist/client/static/js/one-light-bqg77ay0.js +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which sessions share a working directory.
|
|
8
|
+
*
|
|
9
|
+
* The scan layer is the one place a concurrent session can be misattributed: a
|
|
10
|
+
* `git status` or a directory diff sees the other session's file too. Before a
|
|
11
|
+
* scan records a path, it asks this module for the OTHER sessions in the same
|
|
12
|
+
* cwd and skips a path one of them already recorded in the window.
|
|
13
|
+
*
|
|
14
|
+
* The cwd comes from each journal's `session` header, so the map is stable for
|
|
15
|
+
* a session's lifetime. It is cached by the `changes/` root's path + mtime: a
|
|
16
|
+
* new session directory changes the mtime, and a different data root changes
|
|
17
|
+
* the path.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
import { changesRoot } from '@/server/lib/changes/paths.server';
|
|
23
|
+
import { parseJournalLine } from '@/server/lib/changes/records';
|
|
24
|
+
|
|
25
|
+
interface CwdCache {
|
|
26
|
+
root: string;
|
|
27
|
+
rootMtime: number;
|
|
28
|
+
byCwd: Map<string, string[]>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare global {
|
|
32
|
+
// eslint-disable-next-line no-var
|
|
33
|
+
var __kabmoSessionsByCwd: CwdCache | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Session ids whose journal header names `cwd`, excluding `excludeSessionId`. */
|
|
37
|
+
export async function sessionsInCwd(cwd: string, excludeSessionId: string): Promise<string[]> {
|
|
38
|
+
const root = changesRoot();
|
|
39
|
+
const info = await stat(root).catch(() => null);
|
|
40
|
+
if (!info) return [];
|
|
41
|
+
|
|
42
|
+
let cache = globalThis.__kabmoSessionsByCwd;
|
|
43
|
+
if (!cache || cache.root !== root || cache.rootMtime !== info.mtimeMs) {
|
|
44
|
+
cache = { root, rootMtime: info.mtimeMs, byCwd: await buildByCwd(root) };
|
|
45
|
+
globalThis.__kabmoSessionsByCwd = cache;
|
|
46
|
+
}
|
|
47
|
+
return (cache.byCwd.get(cwd) ?? []).filter((id) => id !== excludeSessionId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function buildByCwd(root: string): Promise<Map<string, string[]>> {
|
|
51
|
+
const byCwd = new Map<string, string[]>();
|
|
52
|
+
const entries = await readdir(root, { withFileTypes: true }).catch(() => []);
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
if (!entry.isDirectory()) continue;
|
|
55
|
+
const file = path.join(root, entry.name, 'changes.jsonl');
|
|
56
|
+
// The header is the first line; a slice keeps a 20 MB journal cheap to read.
|
|
57
|
+
const head = await Bun.file(file).slice(0, 1024).text().catch(() => '');
|
|
58
|
+
const record = parseJournalLine(head.split('\n')[0] ?? '');
|
|
59
|
+
if (record?.type !== 'session') continue;
|
|
60
|
+
const list = byCwd.get(record.cwd) ?? [];
|
|
61
|
+
list.push(entry.name);
|
|
62
|
+
byCwd.set(record.cwd, list);
|
|
63
|
+
}
|
|
64
|
+
return byCwd;
|
|
65
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which sessions share a cwd, from each journal's `session` header.
|
|
8
|
+
*
|
|
9
|
+
* The scan's cross-check depends on this: a path another session in the same
|
|
10
|
+
* cwd already recorded must not be attributed to the current command.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
14
|
+
import * as fsp from 'node:fs/promises';
|
|
15
|
+
import * as os from 'node:os';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import { ChangeJournal } from '@/server/lib/changes/journal.server';
|
|
18
|
+
import { sessionsInCwd } from '@/server/lib/changes/sessions.server';
|
|
19
|
+
|
|
20
|
+
let dataDir = '';
|
|
21
|
+
let original: string | undefined;
|
|
22
|
+
|
|
23
|
+
beforeAll(async () => {
|
|
24
|
+
original = Bun.env.KABMO_DATA_DIR;
|
|
25
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-sessions-'));
|
|
26
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
27
|
+
const a = new ChangeJournal('sess-a', '/repo');
|
|
28
|
+
const b = new ChangeJournal('sess-b', '/repo');
|
|
29
|
+
const c = new ChangeJournal('sess-c', '/other');
|
|
30
|
+
await a.recordNote({ at: 1, reason: 'opaque-command' });
|
|
31
|
+
await b.recordNote({ at: 1, reason: 'opaque-command' });
|
|
32
|
+
await c.recordNote({ at: 1, reason: 'opaque-command' });
|
|
33
|
+
await Promise.all([a.flush(), b.flush(), c.flush()]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterAll(async () => {
|
|
37
|
+
if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
38
|
+
else Bun.env.KABMO_DATA_DIR = original;
|
|
39
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('sessionsInCwd', () => {
|
|
43
|
+
test('returns the other sessions in the same cwd', async () => {
|
|
44
|
+
expect((await sessionsInCwd('/repo', 'sess-a')).sort()).toEqual(['sess-b']);
|
|
45
|
+
expect((await sessionsInCwd('/repo', 'sess-x')).sort()).toEqual(['sess-a', 'sess-b']);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('does not mix a different cwd', async () => {
|
|
49
|
+
expect(await sessionsInCwd('/other', 'sess-a')).toEqual(['sess-c']);
|
|
50
|
+
expect(await sessionsInCwd('/none', 'sess-a')).toEqual([]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-5y0bvq4q.js";import"./index-c15r8jd3.js";import{ah}from"./index-dfgdn3fj.js";export{ah as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{MA}from"./index-st202rjv.js";export{MA as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LA}from"./index-st202rjv.js";export{LA as default};
|