@cogit/cli 0.25.6 → 0.26.0
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
CHANGED
|
@@ -79,7 +79,7 @@ cogit open .
|
|
|
79
79
|
|
|
80
80
|
- [Getting started](docs/guide/getting-started.md): what `init` asks, your first session,
|
|
81
81
|
setting up a team
|
|
82
|
-
- [The map](docs/guide/map.md): sessions, branches, the inbox,
|
|
82
|
+
- [The map](docs/guide/map.md): sessions, branches, the inbox, files, search,
|
|
83
83
|
resuming and forking a session
|
|
84
84
|
- [Reading the lineage](docs/guide/reading-the-lineage.md): `log`, `show`, `blame`, `why`,
|
|
85
85
|
`search`
|
|
@@ -21109,12 +21109,6 @@ function projectPaths(root) {
|
|
|
21109
21109
|
conversations: join6(base, "conversations"),
|
|
21110
21110
|
conversation: (id) => join6(base, "conversations", `${id}.jsonl.gz`),
|
|
21111
21111
|
state: (id) => join6(base, "state", `${id}.json`),
|
|
21112
|
-
/**
|
|
21113
|
-
* Which messages this user has marked read (Story 10.3). Local per-user
|
|
21114
|
-
* state: never committed, never shared (`state/` stays ignored by both
|
|
21115
|
-
* policies).
|
|
21116
|
-
*/
|
|
21117
|
-
readState: join6(base, "state", "read.json"),
|
|
21118
21112
|
/** Inbox rows the user dismissed, per session (Story 11.1); also local. */
|
|
21119
21113
|
inboxState: join6(base, "state", "inbox.json"),
|
|
21120
21114
|
/** How the user left the map: open sessions and dragged row widths; also local. */
|
|
@@ -21210,7 +21204,7 @@ async function migrateProject(root) {
|
|
|
21210
21204
|
const next = renameGitignoreLines(text);
|
|
21211
21205
|
if (next !== text) await atomicWrite(gitignore, next).catch(() => void 0);
|
|
21212
21206
|
}
|
|
21213
|
-
const { installGitHooks: installGitHooks2 } = await import("./git-hooks-
|
|
21207
|
+
const { installGitHooks: installGitHooks2 } = await import("./git-hooks-WUFX2JYS.js");
|
|
21214
21208
|
await installGitHooks2(dir).catch(() => void 0);
|
|
21215
21209
|
return true;
|
|
21216
21210
|
}
|
|
@@ -24230,6 +24224,7 @@ function stampedIdentity(stored, here) {
|
|
|
24230
24224
|
var DATA_ELEMENT_ID = "cogit-data";
|
|
24231
24225
|
var LIVE_META_NAME = "cogit-live";
|
|
24232
24226
|
var TOKEN_META_NAME = "cogit-token";
|
|
24227
|
+
var TOKEN_HEADER_NAME = "x-cogit-token";
|
|
24233
24228
|
var PANEL_EDITABLE_KEYS = [
|
|
24234
24229
|
"recorder",
|
|
24235
24230
|
"messageSummaries",
|
|
@@ -24608,26 +24603,6 @@ async function blame(opts) {
|
|
|
24608
24603
|
return hits;
|
|
24609
24604
|
}
|
|
24610
24605
|
|
|
24611
|
-
// src/store/changes.ts
|
|
24612
|
-
async function readProjectChanges(root, hashes) {
|
|
24613
|
-
const wanted = [...new Set(hashes)];
|
|
24614
|
-
if (wanted.length === 0) return /* @__PURE__ */ new Map();
|
|
24615
|
-
const gitRoot = await findGitRoot(root);
|
|
24616
|
-
if (gitRoot === void 0) return /* @__PURE__ */ new Map();
|
|
24617
|
-
const raw = await readCommitChanges(gitRoot, wanted);
|
|
24618
|
-
if (gitRoot === root) return raw;
|
|
24619
|
-
const files = projectFiles(
|
|
24620
|
-
gitRoot,
|
|
24621
|
-
root,
|
|
24622
|
-
new Map([...raw].map(([hash2, change]) => [hash2, change.files]))
|
|
24623
|
-
);
|
|
24624
|
-
const out = /* @__PURE__ */ new Map();
|
|
24625
|
-
for (const [hash2, change] of raw) {
|
|
24626
|
-
out.set(hash2, { ...change, files: files.get(hash2) ?? [] });
|
|
24627
|
-
}
|
|
24628
|
-
return out;
|
|
24629
|
-
}
|
|
24630
|
-
|
|
24631
24606
|
// src/store/events.ts
|
|
24632
24607
|
import { appendFile as appendFile2, mkdir as mkdir5, readFile as readFile7 } from "fs/promises";
|
|
24633
24608
|
import { dirname as dirname7 } from "path";
|
|
@@ -24735,114 +24710,6 @@ function seedEvents(nodes, at) {
|
|
|
24735
24710
|
return events;
|
|
24736
24711
|
}
|
|
24737
24712
|
|
|
24738
|
-
// src/store/read-state.ts
|
|
24739
|
-
var READ_STATE_SCHEMA = 1;
|
|
24740
|
-
var MESSAGE_ID2 = /^h[0-9a-f]{12}$/;
|
|
24741
|
-
var ReadState = external_exports.object({
|
|
24742
|
-
schema: external_exports.literal(READ_STATE_SCHEMA),
|
|
24743
|
-
/** Read message ids (`h` plus 12 hex). */
|
|
24744
|
-
read: external_exports.array(external_exports.string().regex(MESSAGE_ID2)).default([])
|
|
24745
|
-
});
|
|
24746
|
-
async function readReadState(root) {
|
|
24747
|
-
const read = await readJson(projectPaths(root).readState);
|
|
24748
|
-
if (!read.found || "error" in read) return /* @__PURE__ */ new Set();
|
|
24749
|
-
const parsed = ReadState.safeParse(read.value);
|
|
24750
|
-
return new Set(parsed.success ? parsed.data.read : []);
|
|
24751
|
-
}
|
|
24752
|
-
async function setMessageRead(root, id, read) {
|
|
24753
|
-
if (!MESSAGE_ID2.test(id)) throw new Error(`not a message id: ${id}`);
|
|
24754
|
-
const p = projectPaths(root);
|
|
24755
|
-
await withLock(
|
|
24756
|
-
p.lock("read-state"),
|
|
24757
|
-
async () => {
|
|
24758
|
-
const ids = await readReadState(root);
|
|
24759
|
-
if (read) ids.add(id);
|
|
24760
|
-
else ids.delete(id);
|
|
24761
|
-
await atomicWriteJson(p.readState, {
|
|
24762
|
-
schema: READ_STATE_SCHEMA,
|
|
24763
|
-
read: [...ids].sort()
|
|
24764
|
-
});
|
|
24765
|
-
},
|
|
24766
|
-
{ timeoutMs: 2e3 }
|
|
24767
|
-
);
|
|
24768
|
-
}
|
|
24769
|
-
|
|
24770
|
-
// src/view/change.ts
|
|
24771
|
-
function messageChange(commits, changes) {
|
|
24772
|
-
if (commits === void 0 || commits.length === 0) return void 0;
|
|
24773
|
-
const seen = /* @__PURE__ */ new Set();
|
|
24774
|
-
const files = /* @__PURE__ */ new Set();
|
|
24775
|
-
let added = 0;
|
|
24776
|
-
let removed = 0;
|
|
24777
|
-
for (const hash2 of commits) {
|
|
24778
|
-
const change = changes.get(hash2);
|
|
24779
|
-
if (change === void 0 || seen.has(change.full)) continue;
|
|
24780
|
-
seen.add(change.full);
|
|
24781
|
-
added += change.added;
|
|
24782
|
-
removed += change.removed;
|
|
24783
|
-
for (const file2 of change.files) files.add(file2);
|
|
24784
|
-
}
|
|
24785
|
-
if (seen.size === 0) return void 0;
|
|
24786
|
-
return { added, removed, files: files.size };
|
|
24787
|
-
}
|
|
24788
|
-
function attachChanges(sessions, changes) {
|
|
24789
|
-
if (changes.size === 0) return sessions.map((session) => session);
|
|
24790
|
-
return sessions.map((session) => {
|
|
24791
|
-
let changed = false;
|
|
24792
|
-
const nodes = session.nodes.map((node2) => {
|
|
24793
|
-
if (node2.kind !== "message") return node2;
|
|
24794
|
-
const change = messageChange(node2.commits, changes);
|
|
24795
|
-
if (change === void 0) {
|
|
24796
|
-
if (node2.change === void 0) return node2;
|
|
24797
|
-
changed = true;
|
|
24798
|
-
const { change: _dropped, ...rest } = node2;
|
|
24799
|
-
return rest;
|
|
24800
|
-
}
|
|
24801
|
-
changed = true;
|
|
24802
|
-
return { ...node2, change };
|
|
24803
|
-
});
|
|
24804
|
-
return changed ? { ...session, nodes } : session;
|
|
24805
|
-
});
|
|
24806
|
-
}
|
|
24807
|
-
function changeLines(change) {
|
|
24808
|
-
return change.added + change.removed;
|
|
24809
|
-
}
|
|
24810
|
-
function isBigChange(change, threshold) {
|
|
24811
|
-
return changeLines(change) >= threshold;
|
|
24812
|
-
}
|
|
24813
|
-
function unreadMessages(sessions, read) {
|
|
24814
|
-
const out = [];
|
|
24815
|
-
for (const session of sessions) {
|
|
24816
|
-
for (const node2 of session.nodes) {
|
|
24817
|
-
if (node2.kind !== "message" || node2.change === void 0) continue;
|
|
24818
|
-
if (read.has(node2.id)) continue;
|
|
24819
|
-
out.push({
|
|
24820
|
-
sessionId: session.sessionId,
|
|
24821
|
-
sessionTitle: session.title,
|
|
24822
|
-
sessionStartedAt: session.startedAt,
|
|
24823
|
-
messageId: node2.id,
|
|
24824
|
-
label: node2.label ?? node2.id,
|
|
24825
|
-
title: node2.title,
|
|
24826
|
-
...node2.at === void 0 ? {} : { at: node2.at },
|
|
24827
|
-
change: node2.change
|
|
24828
|
-
});
|
|
24829
|
-
}
|
|
24830
|
-
}
|
|
24831
|
-
return out.sort(
|
|
24832
|
-
(a, b) => changeLines(b.change) - changeLines(a.change) || b.change.files - a.change.files || a.title.localeCompare(b.title) || a.messageId.localeCompare(b.messageId)
|
|
24833
|
-
);
|
|
24834
|
-
}
|
|
24835
|
-
function countBigUnread(sessions, read, threshold) {
|
|
24836
|
-
return unreadMessages(sessions, read).filter((message) => isBigChange(message.change, threshold)).length;
|
|
24837
|
-
}
|
|
24838
|
-
function grouped(value) {
|
|
24839
|
-
return String(Math.max(0, Math.trunc(value))).replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
|
24840
|
-
}
|
|
24841
|
-
function formatChange(change) {
|
|
24842
|
-
const files = `${change.files} file${change.files === 1 ? "" : "s"}`;
|
|
24843
|
-
return `+${grouped(change.added)} \u2212${grouped(change.removed)} \xB7 ${files}`;
|
|
24844
|
-
}
|
|
24845
|
-
|
|
24846
24713
|
// src/view/files.ts
|
|
24847
24714
|
function timeOf(at) {
|
|
24848
24715
|
if (at === void 0) return Number.NEGATIVE_INFINITY;
|
|
@@ -25341,43 +25208,6 @@ async function log(opts) {
|
|
|
25341
25208
|
for (const line of formatLog(model, opts.branchesOnly === true)) opts.io.out(line);
|
|
25342
25209
|
return model;
|
|
25343
25210
|
}
|
|
25344
|
-
async function logUnread(opts) {
|
|
25345
|
-
const root = await openProject(opts.dir);
|
|
25346
|
-
const sessions = await loadEffectiveSessions(root, opts.io);
|
|
25347
|
-
const hashes = new Set(
|
|
25348
|
-
sessions.flatMap((entry) => entry.messages.flatMap((message) => message.commits ?? []))
|
|
25349
|
-
);
|
|
25350
|
-
const changes = hashes.size === 0 ? /* @__PURE__ */ new Map() : await readProjectChanges(root, hashes);
|
|
25351
|
-
const read = await readReadState(root);
|
|
25352
|
-
const unread = unreadMessages(
|
|
25353
|
-
sessions.map(({ session, messages }) => ({
|
|
25354
|
-
sessionId: session.sessionId,
|
|
25355
|
-
title: session.title,
|
|
25356
|
-
startedAt: session.startedAt,
|
|
25357
|
-
nodes: messages.map((message) => ({
|
|
25358
|
-
...message,
|
|
25359
|
-
change: messageChange(message.commits, changes)
|
|
25360
|
-
}))
|
|
25361
|
-
})),
|
|
25362
|
-
read
|
|
25363
|
-
);
|
|
25364
|
-
if (opts.json === true) {
|
|
25365
|
-
opts.io.out(JSON.stringify(unread, null, 2));
|
|
25366
|
-
return unread;
|
|
25367
|
-
}
|
|
25368
|
-
for (const line of formatUnread(unread)) opts.io.out(line);
|
|
25369
|
-
return unread;
|
|
25370
|
-
}
|
|
25371
|
-
function formatUnread(messages) {
|
|
25372
|
-
if (messages.length === 0) return ["No unread messages with linked commits."];
|
|
25373
|
-
return messages.map((message) => {
|
|
25374
|
-
const parts = [
|
|
25375
|
-
` ${shortHash(message.messageId)} ${message.label} ${clock(message.at)} ${formatChange(message.change)} ${oneLine3(message.title)}`
|
|
25376
|
-
];
|
|
25377
|
-
parts.push(` \xB7 ${oneLine3(message.sessionTitle)}`);
|
|
25378
|
-
return parts.join("");
|
|
25379
|
-
});
|
|
25380
|
-
}
|
|
25381
25211
|
function normalizeFilePath(file2) {
|
|
25382
25212
|
return file2.replace(/\\/g, "/").replace(/^(\.\/)+/, "").replace(/\/+$/, "");
|
|
25383
25213
|
}
|
|
@@ -25720,7 +25550,7 @@ async function onSessionEnd(ctx) {
|
|
|
25720
25550
|
// package.json
|
|
25721
25551
|
var package_default = {
|
|
25722
25552
|
name: "@cogit/cli",
|
|
25723
|
-
version: "0.
|
|
25553
|
+
version: "0.26.0",
|
|
25724
25554
|
description: "Git remembers what changed. cogit remembers why.",
|
|
25725
25555
|
license: "MIT",
|
|
25726
25556
|
keywords: [
|
|
@@ -26365,6 +26195,7 @@ export {
|
|
|
26365
26195
|
stampedIdentity,
|
|
26366
26196
|
LIVE_META_NAME,
|
|
26367
26197
|
TOKEN_META_NAME,
|
|
26198
|
+
TOKEN_HEADER_NAME,
|
|
26368
26199
|
isPanelEditableKey,
|
|
26369
26200
|
VIEW_SCHEMA,
|
|
26370
26201
|
lastActive,
|
|
@@ -26375,11 +26206,6 @@ export {
|
|
|
26375
26206
|
builtBy,
|
|
26376
26207
|
embedViewModel,
|
|
26377
26208
|
blame,
|
|
26378
|
-
readProjectChanges,
|
|
26379
|
-
readReadState,
|
|
26380
|
-
setMessageRead,
|
|
26381
|
-
attachChanges,
|
|
26382
|
-
countBigUnread,
|
|
26383
26209
|
buildFileHistory,
|
|
26384
26210
|
modelSessions,
|
|
26385
26211
|
loadEffectiveSessions,
|
|
@@ -26390,7 +26216,6 @@ export {
|
|
|
26390
26216
|
show,
|
|
26391
26217
|
formatShow,
|
|
26392
26218
|
log,
|
|
26393
|
-
logUnread,
|
|
26394
26219
|
logFile,
|
|
26395
26220
|
why,
|
|
26396
26221
|
compareVersions,
|