@meshpoint/cli 1.5.0 → 1.6.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 +1 -1
- package/dist/bin.js +36 -13
- package/dist/import/discover.js +154 -55
- package/dist/import/distill.js +29 -10
- package/dist/import/offer.js +27 -0
- package/dist/import/report.js +2 -0
- package/dist/import/run.js +75 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ The session-start inject shows each item's id prefix so the skill can retract wh
|
|
|
105
105
|
|
|
106
106
|
## Importing old sessions
|
|
107
107
|
|
|
108
|
-
`meshpoint import sessions` seeds a repository from the transcripts your harnesses already keep: `~/.claude/projects/*/*.jsonl` (cwd and gitBranch per record), `~/.codex/sessions/**/rollout-*.jsonl` (session_meta has cwd and git), `~/.pi/agent/sessions/*/*.jsonl`, opencode's `storage/{session,message,part}`, Antigravity chats under `~/.gemini/tmp/<sha256 of the directory>/chats/`. Each session maps to a project through its directory's origin remote. Every session is distilled with your own agent CLI (`claude -p --tools "" --setting-sources ""`, or `codex exec`) using the checkpoint skill's rules; a second call per branch merges duplicates, keys conventions, marks recurring gotchas and names live items the proposals supersede; items naming files the checkout no longer has are dropped and listed. The proposal and a report (sessions per harness, span, most-touched files, items by kind, recurring gotchas first) land under `~/.local/state/meshpoint/import/`. Nothing is uploaded without `--apply`; `--with-turns` adds the last 30 days of turns as sessions. Current repo and 90 days by default; `--since <days>` past that or `--all-repos` asks y/N first.
|
|
108
|
+
`meshpoint import sessions` seeds a repository from the transcripts your harnesses already keep: `~/.claude/projects/*/*.jsonl` (cwd and gitBranch per record), `~/.codex/sessions/**/rollout-*.jsonl` (session_meta has cwd and git), `~/.pi/agent/sessions/*/*.jsonl`, opencode's `storage/{session,message,part}`, Antigravity chats under `~/.gemini/tmp/<sha256 of the directory>/chats/`. Each session maps to a project through its directory's origin remote. Every session is distilled with your own agent CLI (`claude -p --tools "" --setting-sources ""`, or `codex exec`) using the checkpoint skill's rules; a second call per branch merges duplicates, keys conventions, marks recurring gotchas and names live items the proposals supersede; items naming files the checkout no longer has are dropped and listed. Every item carries a verbatim quote from the transcript as evidence, checked against the transcript; items without one are dropped. Per-session results are cached under the state directory, so a rerun distills only new or changed sessions (`--fresh` ignores the cache). Items from a recorded branch that is gone or already merged land on the current branch. The proposal and a report (sessions per harness, span, most-touched files, items by kind, recurring gotchas first) land under `~/.local/state/meshpoint/import/`. Nothing is uploaded without `--apply`; `--with-turns` adds the last 30 days of turns as sessions. Current repo and 90 days by default; `--since <days>` past that or `--all-repos` asks y/N first. `meshpoint connect <harness>` inside a repository ends with a count of past sessions found for it and the command to import them.
|
|
109
109
|
|
|
110
110
|
## Refs, verification and the edit hook
|
|
111
111
|
|
package/dist/bin.js
CHANGED
|
@@ -24,9 +24,28 @@ import { api, ApiError, canOpenBrowser, deviceLogin, freshConfig, login } from "
|
|
|
24
24
|
import { detectHarnesses, renderDetected } from "./detect.js";
|
|
25
25
|
import { renderDoctor, runDoctor } from "./doctor.js";
|
|
26
26
|
import { confirmItems, parseItemArgs, parseItems, putItems, retractItems } from "./items.js";
|
|
27
|
+
import { importOffer } from "./import/offer.js";
|
|
27
28
|
import { applyProposalFile, DEFAULT_SINCE_DAYS, importSessions } from "./import/run.js";
|
|
28
29
|
import { detectRunner } from "./import/runner.js";
|
|
29
30
|
import { Spool } from "./spool.js";
|
|
31
|
+
const IMPORT_USAGE = ` import sessions [--since <days>] [--all-repos] [--with-turns] [--apply | --propose] [--yes] [--fresh]
|
|
32
|
+
[--runner claude|codex] [--model <m>] [--min-turns <n>] [--from <items.json>] [--help]
|
|
33
|
+
read this machine's harness transcripts (Claude Code, Codex, pi,
|
|
34
|
+
opencode, Antigravity, Cursor) for the current repo and the last
|
|
35
|
+
90 days, distill them into items with your own agent CLI, and
|
|
36
|
+
write a proposal + report under ~/.local/state/meshpoint/import/.
|
|
37
|
+
Every item carries a verbatim transcript quote as evidence;
|
|
38
|
+
items without one are dropped. Per-session results are cached
|
|
39
|
+
there too, so a rerun only distills new or changed sessions
|
|
40
|
+
(--fresh ignores the cache). Items from a branch that is gone or
|
|
41
|
+
already merged land on the default branch.
|
|
42
|
+
Nothing is uploaded without --apply; older than 90 days or
|
|
43
|
+
--all-repos asks first (--yes skips). --with-turns also uploads
|
|
44
|
+
the last 30 days of turns as sessions. Review the saved
|
|
45
|
+
items.json, delete or edit entries, then upload exactly that
|
|
46
|
+
file with --apply --from <items.json>; or --propose sends the
|
|
47
|
+
proposal to the console, where it is reviewed and applied.
|
|
48
|
+
`;
|
|
30
49
|
const USAGE = `meshpoint <command>
|
|
31
50
|
|
|
32
51
|
login [--base-url <url>] [--agent <name>] [--org <id>] [--device | --browser]
|
|
@@ -74,19 +93,7 @@ const USAGE = `meshpoint <command>
|
|
|
74
93
|
stdin form takes a JSON array of {kind, title, body}
|
|
75
94
|
items retract <id>... retract items on the current branch; an id may be a prefix
|
|
76
95
|
items confirm <id>... confirm items on the current branch (counts toward their rank)
|
|
77
|
-
|
|
78
|
-
[--runner claude|codex] [--model <m>] [--min-turns <n>] [--from <items.json>]
|
|
79
|
-
read this machine's harness transcripts (Claude Code, Codex, pi,
|
|
80
|
-
opencode, Antigravity, Cursor) for the current repo and the last
|
|
81
|
-
90 days, distill them into items with your own agent CLI, and
|
|
82
|
-
write a proposal + report under ~/.local/state/meshpoint/import/.
|
|
83
|
-
Nothing is uploaded without --apply; older than 90 days or
|
|
84
|
-
--all-repos asks first (--yes skips). --with-turns also uploads
|
|
85
|
-
the last 30 days of turns as sessions. Review the saved
|
|
86
|
-
items.json, delete or edit entries, then upload exactly that
|
|
87
|
-
file with --apply --from <items.json>; or --propose sends the
|
|
88
|
-
proposal to the console, where it is reviewed and applied.
|
|
89
|
-
tap claude-code | codex | cursor | antigravity [<event>] | openclaw
|
|
96
|
+
${IMPORT_USAGE} tap claude-code | codex | cursor | antigravity [<event>] | openclaw
|
|
90
97
|
hook entry point; reads one hook payload on stdin
|
|
91
98
|
`;
|
|
92
99
|
const TAP_HARNESSES = new Set(["claude-code", "codex", "cursor", "antigravity", "openclaw"]);
|
|
@@ -246,6 +253,17 @@ async function main(argv) {
|
|
|
246
253
|
console.log(connectOpencode({ remove, ...(configDir ? { configDir } : {}) }));
|
|
247
254
|
else
|
|
248
255
|
throw new Error("connect supports: claude-code, codex, cursor, antigravity, pi, opencode, openclaw");
|
|
256
|
+
if (!remove) {
|
|
257
|
+
// Past sessions for this repository are worth a line; the offer never fails the connect.
|
|
258
|
+
try {
|
|
259
|
+
const offer = importOffer({ repo: repoContext(process.cwd()), env: process.env, runner: detectRunner(process.env)?.name ?? null });
|
|
260
|
+
if (offer)
|
|
261
|
+
console.log(`\n${offer}`);
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
// unreadable store or no git
|
|
265
|
+
}
|
|
266
|
+
}
|
|
249
267
|
return 0;
|
|
250
268
|
}
|
|
251
269
|
case "items": {
|
|
@@ -274,6 +292,10 @@ async function main(argv) {
|
|
|
274
292
|
case "import": {
|
|
275
293
|
if (rest[0] !== "sessions")
|
|
276
294
|
throw new Error("import supports: sessions");
|
|
295
|
+
if (rest.includes("--help") || rest.includes("-h")) {
|
|
296
|
+
process.stdout.write(IMPORT_USAGE);
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
277
299
|
const config = await requireConfig();
|
|
278
300
|
const repo = repoContext(process.cwd());
|
|
279
301
|
const from = flag(rest, "--from");
|
|
@@ -304,6 +326,7 @@ async function main(argv) {
|
|
|
304
326
|
apply: rest.includes("--apply"),
|
|
305
327
|
propose: rest.includes("--propose"),
|
|
306
328
|
yes: rest.includes("--yes"),
|
|
329
|
+
fresh: rest.includes("--fresh"),
|
|
307
330
|
minTurns,
|
|
308
331
|
runner,
|
|
309
332
|
stateDir: stateDir(),
|
package/dist/import/discover.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { closeSync, existsSync, openSync, readdirSync, readFileSync, readSync, statSync } from "node:fs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { projectIdFromRemote } from "@meshpoint/sdk";
|
|
@@ -8,6 +8,43 @@ import { parseAntigravityTranscript } from "../antigravity/transcript.js";
|
|
|
8
8
|
import { parseTranscript as parseClaudeCodeTranscript } from "../claude-code/transcript.js";
|
|
9
9
|
import { parseCodexTranscript } from "../codex/transcript.js";
|
|
10
10
|
import { parseCursorTranscript } from "../cursor/transcript.js";
|
|
11
|
+
// The first records of a JSONL file, enough for the header fields, without reading the rest.
|
|
12
|
+
const HEAD_BYTES = 64 * 1024;
|
|
13
|
+
function headRecords(file) {
|
|
14
|
+
const fd = openSync(file, "r");
|
|
15
|
+
try {
|
|
16
|
+
const buf = Buffer.alloc(HEAD_BYTES);
|
|
17
|
+
const n = readSync(fd, buf, 0, HEAD_BYTES, 0);
|
|
18
|
+
const lines = buf.subarray(0, n).toString("utf8").split("\n");
|
|
19
|
+
if (n === HEAD_BYTES)
|
|
20
|
+
lines.pop();
|
|
21
|
+
const out = [];
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
if (!line.trim())
|
|
24
|
+
continue;
|
|
25
|
+
try {
|
|
26
|
+
const v = JSON.parse(line);
|
|
27
|
+
if (isRecord(v))
|
|
28
|
+
out.push(v);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
closeSync(fd);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Modification time, or null when the file predates the window.
|
|
41
|
+
function mtimeIn(file, since) {
|
|
42
|
+
const m = statSync(file).mtimeMs;
|
|
43
|
+
return m < since ? null : m;
|
|
44
|
+
}
|
|
45
|
+
function skimmed(harness, file, id, cwd, branch, mtime) {
|
|
46
|
+
return { harness, file, id, cwd, branch, startedAt: mtime, endedAt: mtime, entries: [], project: null, skimmed: true };
|
|
47
|
+
}
|
|
11
48
|
function isRecord(v) {
|
|
12
49
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
13
50
|
}
|
|
@@ -79,19 +116,18 @@ export function gitProjectResolver() {
|
|
|
79
116
|
};
|
|
80
117
|
}
|
|
81
118
|
// --- readers -----------------------------------------------------------------------------------
|
|
82
|
-
function claudeCode(
|
|
83
|
-
const root = env.CLAUDE_CONFIG_DIR || path.join(home, ".claude");
|
|
119
|
+
function claudeCode(ctx) {
|
|
120
|
+
const root = ctx.env.CLAUDE_CONFIG_DIR || path.join(ctx.home, ".claude");
|
|
84
121
|
const out = [];
|
|
85
122
|
for (const file of walk(path.join(root, "projects"), (f) => f.endsWith(".jsonl"), 2)) {
|
|
86
123
|
try {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
if (entries.length === 0)
|
|
124
|
+
const mtime = mtimeIn(file, ctx.since);
|
|
125
|
+
if (mtime === null)
|
|
90
126
|
continue;
|
|
91
127
|
let cwd = null;
|
|
92
128
|
let branch = null;
|
|
93
129
|
let id = path.basename(file, ".jsonl");
|
|
94
|
-
for (const r of
|
|
130
|
+
for (const r of headRecords(file)) {
|
|
95
131
|
if (typeof r.cwd === "string" && !cwd)
|
|
96
132
|
cwd = r.cwd;
|
|
97
133
|
if (typeof r.gitBranch === "string" && !branch)
|
|
@@ -101,7 +137,17 @@ function claudeCode(home, env) {
|
|
|
101
137
|
if (cwd && branch)
|
|
102
138
|
break;
|
|
103
139
|
}
|
|
104
|
-
|
|
140
|
+
const gate = ctx.gate(cwd);
|
|
141
|
+
if (gate === "skip")
|
|
142
|
+
continue;
|
|
143
|
+
if (gate === "skim") {
|
|
144
|
+
out.push(skimmed("claude-code", file, id, cwd, branch, mtime));
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const entries = parseClaudeCodeTranscript(readFileSync(file, "utf8"));
|
|
148
|
+
if (entries.length === 0)
|
|
149
|
+
continue;
|
|
150
|
+
out.push({ harness: "claude-code", file, id, cwd, branch, ...span(entries, mtime), entries, project: null });
|
|
105
151
|
}
|
|
106
152
|
catch {
|
|
107
153
|
continue;
|
|
@@ -109,28 +155,31 @@ function claudeCode(home, env) {
|
|
|
109
155
|
}
|
|
110
156
|
return out;
|
|
111
157
|
}
|
|
112
|
-
function codex(
|
|
113
|
-
const root = env.CODEX_HOME || path.join(home, ".codex");
|
|
158
|
+
function codex(ctx) {
|
|
159
|
+
const root = ctx.env.CODEX_HOME || path.join(ctx.home, ".codex");
|
|
114
160
|
const out = [];
|
|
115
161
|
for (const file of walk(path.join(root, "sessions"), (f) => path.basename(f).startsWith("rollout-") && f.endsWith(".jsonl"), 4)) {
|
|
116
162
|
try {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
if (entries.length === 0)
|
|
163
|
+
const mtime = mtimeIn(file, ctx.since);
|
|
164
|
+
if (mtime === null)
|
|
120
165
|
continue;
|
|
121
|
-
const meta =
|
|
166
|
+
const meta = headRecords(file).find((r) => r.type === "session_meta");
|
|
122
167
|
const payload = isRecord(meta?.payload) ? meta.payload : {};
|
|
123
168
|
const git = isRecord(payload.git) ? payload.git : {};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
169
|
+
const id = typeof payload.id === "string" ? payload.id : path.basename(file, ".jsonl");
|
|
170
|
+
const cwd = typeof payload.cwd === "string" ? payload.cwd : null;
|
|
171
|
+
const branch = typeof git.branch === "string" ? git.branch : null;
|
|
172
|
+
const gate = ctx.gate(cwd);
|
|
173
|
+
if (gate === "skip")
|
|
174
|
+
continue;
|
|
175
|
+
if (gate === "skim") {
|
|
176
|
+
out.push(skimmed("codex", file, id, cwd, branch, mtime));
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const entries = parseCodexTranscript(readFileSync(file, "utf8"));
|
|
180
|
+
if (entries.length === 0)
|
|
181
|
+
continue;
|
|
182
|
+
out.push({ harness: "codex", file, id, cwd, branch, ...span(entries, mtime), entries, project: null });
|
|
134
183
|
}
|
|
135
184
|
catch {
|
|
136
185
|
continue;
|
|
@@ -149,13 +198,25 @@ function textOf(content) {
|
|
|
149
198
|
.join("\n")
|
|
150
199
|
.trim();
|
|
151
200
|
}
|
|
152
|
-
function pi(
|
|
153
|
-
const root = env.PI_CODING_AGENT_DIR || path.join(home, ".pi", "agent");
|
|
201
|
+
function pi(ctx) {
|
|
202
|
+
const root = ctx.env.PI_CODING_AGENT_DIR || path.join(ctx.home, ".pi", "agent");
|
|
154
203
|
const out = [];
|
|
155
204
|
for (const file of walk(path.join(root, "sessions"), (f) => f.endsWith(".jsonl"), 2)) {
|
|
156
205
|
try {
|
|
206
|
+
const mtime = mtimeIn(file, ctx.since);
|
|
207
|
+
if (mtime === null)
|
|
208
|
+
continue;
|
|
209
|
+
const head = headRecords(file).find((r) => r.type === "session");
|
|
210
|
+
const id = typeof head?.id === "string" ? head.id : path.basename(file, ".jsonl");
|
|
211
|
+
const cwd = typeof head?.cwd === "string" ? head.cwd : null;
|
|
212
|
+
const gate = ctx.gate(cwd);
|
|
213
|
+
if (gate === "skip")
|
|
214
|
+
continue;
|
|
215
|
+
if (gate === "skim") {
|
|
216
|
+
out.push(skimmed("pi", file, id, cwd, null, mtime));
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
157
219
|
const records = readJsonl(file);
|
|
158
|
-
const head = records.find((r) => r.type === "session");
|
|
159
220
|
const entries = [];
|
|
160
221
|
for (const r of records) {
|
|
161
222
|
if (r.type !== "message" || !isRecord(r.message))
|
|
@@ -170,16 +231,7 @@ function pi(home, env) {
|
|
|
170
231
|
}
|
|
171
232
|
if (entries.length === 0)
|
|
172
233
|
continue;
|
|
173
|
-
out.push({
|
|
174
|
-
harness: "pi",
|
|
175
|
-
file,
|
|
176
|
-
id: typeof head?.id === "string" ? head.id : path.basename(file, ".jsonl"),
|
|
177
|
-
cwd: typeof head?.cwd === "string" ? head.cwd : null,
|
|
178
|
-
branch: null,
|
|
179
|
-
...span(entries, statSync(file).mtimeMs),
|
|
180
|
-
entries,
|
|
181
|
-
project: null,
|
|
182
|
-
});
|
|
234
|
+
out.push({ harness: "pi", file, id, cwd, branch: null, ...span(entries, mtime), entries, project: null });
|
|
183
235
|
}
|
|
184
236
|
catch {
|
|
185
237
|
continue;
|
|
@@ -187,14 +239,25 @@ function pi(home, env) {
|
|
|
187
239
|
}
|
|
188
240
|
return out;
|
|
189
241
|
}
|
|
190
|
-
function opencode(
|
|
191
|
-
const root = path.join(env.XDG_DATA_HOME || path.join(home, ".local", "share"), "opencode", "storage");
|
|
242
|
+
function opencode(ctx) {
|
|
243
|
+
const root = path.join(ctx.env.XDG_DATA_HOME || path.join(ctx.home, ".local", "share"), "opencode", "storage");
|
|
192
244
|
const out = [];
|
|
193
245
|
for (const file of walk(path.join(root, "session"), (f) => f.endsWith(".json"), 2)) {
|
|
194
246
|
try {
|
|
247
|
+
const mtime = mtimeIn(file, ctx.since);
|
|
248
|
+
if (mtime === null)
|
|
249
|
+
continue;
|
|
195
250
|
const s = JSON.parse(readFileSync(file, "utf8"));
|
|
196
251
|
if (typeof s.id !== "string")
|
|
197
252
|
continue;
|
|
253
|
+
const cwd = typeof s.directory === "string" ? s.directory : null;
|
|
254
|
+
const gate = ctx.gate(cwd);
|
|
255
|
+
if (gate === "skip")
|
|
256
|
+
continue;
|
|
257
|
+
if (gate === "skim") {
|
|
258
|
+
out.push(skimmed("opencode", file, s.id, cwd, null, mtime));
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
198
261
|
const msgDir = path.join(root, "message", s.id);
|
|
199
262
|
const messages = walk(msgDir, (f) => f.endsWith(".json"), 0)
|
|
200
263
|
.map((f) => JSON.parse(readFileSync(f, "utf8")))
|
|
@@ -218,10 +281,10 @@ function opencode(home, env) {
|
|
|
218
281
|
harness: "opencode",
|
|
219
282
|
file,
|
|
220
283
|
id: s.id,
|
|
221
|
-
cwd
|
|
284
|
+
cwd,
|
|
222
285
|
branch: null,
|
|
223
|
-
startedAt: Number(time.created ?? 0) || span(entries,
|
|
224
|
-
endedAt: Number(time.updated ?? 0) || span(entries,
|
|
286
|
+
startedAt: Number(time.created ?? 0) || span(entries, mtime).startedAt,
|
|
287
|
+
endedAt: Number(time.updated ?? 0) || span(entries, mtime).endedAt,
|
|
225
288
|
entries,
|
|
226
289
|
project: null,
|
|
227
290
|
});
|
|
@@ -234,14 +297,26 @@ function opencode(home, env) {
|
|
|
234
297
|
}
|
|
235
298
|
// Antigravity keeps chats under a sha256 of the project directory; the directory itself is not
|
|
236
299
|
// stored. Candidate directories are the cwds other harnesses recorded plus the user's code roots.
|
|
237
|
-
function antigravity(
|
|
238
|
-
const root = env.GEMINI_CLI_HOME || path.join(home, ".gemini");
|
|
300
|
+
function antigravity(ctx, candidates) {
|
|
301
|
+
const root = ctx.env.GEMINI_CLI_HOME || path.join(ctx.home, ".gemini");
|
|
239
302
|
const byHash = new Map();
|
|
240
303
|
for (const dir of candidates)
|
|
241
304
|
byHash.set(createHash("sha256").update(dir).digest("hex"), dir);
|
|
242
305
|
const out = [];
|
|
243
306
|
for (const file of walk(path.join(root, "tmp"), (f) => f.endsWith(".json") && path.basename(path.dirname(f)) === "chats", 3)) {
|
|
244
307
|
try {
|
|
308
|
+
const mtime = mtimeIn(file, ctx.since);
|
|
309
|
+
if (mtime === null)
|
|
310
|
+
continue;
|
|
311
|
+
// The directory hash is the folder name; the chat file may repeat it.
|
|
312
|
+
const dirHash = path.basename(path.dirname(path.dirname(file)));
|
|
313
|
+
const gate = ctx.gate(byHash.get(dirHash) ?? null);
|
|
314
|
+
if (gate === "skip")
|
|
315
|
+
continue;
|
|
316
|
+
if (gate === "skim") {
|
|
317
|
+
out.push(skimmed("antigravity", file, path.basename(file, ".json"), byHash.get(dirHash) ?? null, null, mtime));
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
245
320
|
const s = JSON.parse(readFileSync(file, "utf8"));
|
|
246
321
|
const messages = Array.isArray(s.messages) ? s.messages : [];
|
|
247
322
|
const jsonl = messages
|
|
@@ -271,15 +346,26 @@ function antigravity(home, env, candidates) {
|
|
|
271
346
|
return out;
|
|
272
347
|
}
|
|
273
348
|
// Cursor documents no transcript store; anything that looks like one under ~/.cursor is tried.
|
|
274
|
-
function cursor(
|
|
275
|
-
const root = path.join(home, ".cursor");
|
|
349
|
+
function cursor(ctx) {
|
|
350
|
+
const root = path.join(ctx.home, ".cursor");
|
|
276
351
|
const out = [];
|
|
277
352
|
for (const file of walk(root, (f) => /transcript/i.test(f) && (f.endsWith(".jsonl") || f.endsWith(".json")), 5)) {
|
|
278
353
|
try {
|
|
354
|
+
const mtime = mtimeIn(file, ctx.since);
|
|
355
|
+
if (mtime === null)
|
|
356
|
+
continue;
|
|
357
|
+
const id = path.basename(file).replace(/\.jsonl?$/, "");
|
|
358
|
+
const gate = ctx.gate(null);
|
|
359
|
+
if (gate === "skip")
|
|
360
|
+
continue;
|
|
361
|
+
if (gate === "skim") {
|
|
362
|
+
out.push(skimmed("cursor", file, id, null, null, mtime));
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
279
365
|
const entries = parseCursorTranscript(readFileSync(file, "utf8"));
|
|
280
366
|
if (entries.length === 0)
|
|
281
367
|
continue;
|
|
282
|
-
out.push({ harness: "cursor", file, id
|
|
368
|
+
out.push({ harness: "cursor", file, id, cwd: null, branch: null, ...span(entries, mtime), entries, project: null });
|
|
283
369
|
}
|
|
284
370
|
catch {
|
|
285
371
|
continue;
|
|
@@ -292,19 +378,33 @@ export function discoverSessions(opts = {}) {
|
|
|
292
378
|
const env = opts.env ?? process.env;
|
|
293
379
|
const home = opts.home ?? homedir();
|
|
294
380
|
const wanted = new Set(opts.harnesses ?? ALL_HARNESSES);
|
|
381
|
+
const projectOf = opts.projectOf ?? gitProjectResolver();
|
|
382
|
+
// Every directory seen in a header, including skipped sessions, helps map Antigravity chats.
|
|
383
|
+
const seen = new Set();
|
|
384
|
+
const gate = (cwd) => {
|
|
385
|
+
if (cwd)
|
|
386
|
+
seen.add(cwd);
|
|
387
|
+
if (!opts.project)
|
|
388
|
+
return "full";
|
|
389
|
+
const project = cwd ? projectOf(cwd) : null;
|
|
390
|
+
if (project === opts.project)
|
|
391
|
+
return "full";
|
|
392
|
+
return project === null ? "skim" : "skip";
|
|
393
|
+
};
|
|
394
|
+
const ctx = { home, env, since: opts.since ?? 0, gate };
|
|
295
395
|
const sessions = [];
|
|
296
396
|
if (wanted.has("claude-code"))
|
|
297
|
-
sessions.push(...claudeCode(
|
|
397
|
+
sessions.push(...claudeCode(ctx));
|
|
298
398
|
if (wanted.has("codex"))
|
|
299
|
-
sessions.push(...codex(
|
|
399
|
+
sessions.push(...codex(ctx));
|
|
300
400
|
if (wanted.has("pi"))
|
|
301
|
-
sessions.push(...pi(
|
|
401
|
+
sessions.push(...pi(ctx));
|
|
302
402
|
if (wanted.has("opencode"))
|
|
303
|
-
sessions.push(...opencode(
|
|
403
|
+
sessions.push(...opencode(ctx));
|
|
304
404
|
if (wanted.has("cursor"))
|
|
305
|
-
sessions.push(...cursor(
|
|
405
|
+
sessions.push(...cursor(ctx));
|
|
306
406
|
if (wanted.has("antigravity")) {
|
|
307
|
-
const candidates = new Set(
|
|
407
|
+
const candidates = new Set([...seen, ...(opts.roots ?? [])]);
|
|
308
408
|
for (const rootName of ["Code", "code", "src", "projects", "work", "dev"]) {
|
|
309
409
|
const root = path.join(home, rootName);
|
|
310
410
|
if (!existsSync(root))
|
|
@@ -317,10 +417,9 @@ export function discoverSessions(opts = {}) {
|
|
|
317
417
|
// unreadable root
|
|
318
418
|
}
|
|
319
419
|
}
|
|
320
|
-
sessions.push(...antigravity(
|
|
420
|
+
sessions.push(...antigravity(ctx, candidates));
|
|
321
421
|
}
|
|
322
422
|
// OpenClaw keeps no transcript on disk that hooks or this reader can see.
|
|
323
|
-
const projectOf = opts.projectOf ?? gitProjectResolver();
|
|
324
423
|
for (const s of sessions)
|
|
325
424
|
s.project = s.cwd ? projectOf(s.cwd) : null;
|
|
326
425
|
return sessions.sort((a, b) => b.endedAt - a.endedAt);
|
package/dist/import/distill.js
CHANGED
|
@@ -6,10 +6,12 @@ export const HEAD_CHARS = 20_000;
|
|
|
6
6
|
export const TAIL_CHARS = 40_000;
|
|
7
7
|
export const SESSION_ITEMS_MAX = 20;
|
|
8
8
|
export const BRANCH_ITEMS_MAX = 60;
|
|
9
|
+
export const EVIDENCE_CHARS = 200;
|
|
9
10
|
const KEY_RE = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
|
|
10
11
|
const RULES = `Write what a teammate's agent would need to resume work in this repository correctly, as items.
|
|
11
|
-
Each item is {"kind", "title", "body"}. kind is one of: decision (a choice made and why), gotcha (something that bit or will bite), convention (how things are done here), fact (a stable truth about the code or environment), status (where the work stands), todo (an agreed next step).
|
|
12
|
+
Each item is {"kind", "title", "body", "evidence"}. kind is one of: decision (a choice made and why), gotcha (something that bit or will bite), convention (how things are done here), fact (a stable truth about the code or environment), status (where the work stands), todo (an agreed next step).
|
|
12
13
|
title is one line. body is one to three sentences, concrete: file names by repo-relative path, commands, values, reasons.
|
|
14
|
+
evidence is a quote of at most ${EVIDENCE_CHARS} characters copied verbatim from the transcript that supports the item; an item without a real quote is discarded.
|
|
13
15
|
Rules: only what this session established, never invent; prefer durable knowledge over moment-to-moment detail; at most one status; no secrets, tokens or credentials; skip chit-chat and anything true of every project.`;
|
|
14
16
|
export function renderTranscript(entries) {
|
|
15
17
|
const lines = entries.map((e) => `[${e.role}] ${e.text}${e.paths.length ? `\n(files: ${e.paths.slice(0, 8).join(", ")})` : ""}`);
|
|
@@ -33,35 +35,49 @@ export function sessionPrompt(s) {
|
|
|
33
35
|
function isRecord(v) {
|
|
34
36
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
const squash = (s) => s.replace(/\s+/g, " ").trim();
|
|
39
|
+
// Items whose quote is not in the transcript are unsupported and left out.
|
|
40
|
+
export function parseProposedWith(raw, session, transcript) {
|
|
37
41
|
let parsed;
|
|
38
42
|
try {
|
|
39
43
|
parsed = jsonBlock(raw);
|
|
40
44
|
}
|
|
41
45
|
catch {
|
|
42
|
-
return [];
|
|
46
|
+
return { items: [], unsupported: 0 };
|
|
43
47
|
}
|
|
44
48
|
if (!Array.isArray(parsed))
|
|
45
|
-
return [];
|
|
46
|
-
const
|
|
49
|
+
return { items: [], unsupported: 0 };
|
|
50
|
+
const haystack = transcript === undefined ? null : squash(transcript);
|
|
51
|
+
const items = [];
|
|
52
|
+
let unsupported = 0;
|
|
47
53
|
for (const v of parsed) {
|
|
48
54
|
if (!isRecord(v) || typeof v.kind !== "string" || !KINDS.includes(v.kind))
|
|
49
55
|
continue;
|
|
50
56
|
if (typeof v.title !== "string" || !v.title.trim() || typeof v.body !== "string" || !v.body.trim())
|
|
51
57
|
continue;
|
|
58
|
+
const quote = typeof v.evidence === "string" ? squash(v.evidence).slice(0, EVIDENCE_CHARS) : "";
|
|
59
|
+
if (haystack !== null && (!quote || !haystack.includes(quote))) {
|
|
60
|
+
unsupported++;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
52
63
|
const item = { kind: v.kind, title: redact(v.title.trim().slice(0, 200)), body: redact(v.body.trim().slice(0, 2000)), sessions: [session] };
|
|
53
64
|
if (typeof v.key === "string" && KEY_RE.test(v.key))
|
|
54
65
|
item.key = v.key;
|
|
55
66
|
if (v.recurring === true)
|
|
56
67
|
item.recurring = true;
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
if (quote)
|
|
69
|
+
item.evidence = redact(quote);
|
|
70
|
+
items.push(item);
|
|
71
|
+
if (items.length >= SESSION_ITEMS_MAX)
|
|
59
72
|
break;
|
|
60
73
|
}
|
|
61
|
-
return
|
|
74
|
+
return { items, unsupported };
|
|
75
|
+
}
|
|
76
|
+
export function parseProposed(raw, session, transcript) {
|
|
77
|
+
return parseProposedWith(raw, session, transcript).items;
|
|
62
78
|
}
|
|
63
79
|
export async function distillSession(runner, s) {
|
|
64
|
-
return
|
|
80
|
+
return parseProposedWith(await runner.run(sessionPrompt(s)), s.id, renderTranscript(s.entries));
|
|
65
81
|
}
|
|
66
82
|
export function consolidatePrompt(items, live) {
|
|
67
83
|
return [
|
|
@@ -72,8 +88,9 @@ export function consolidatePrompt(items, live) {
|
|
|
72
88
|
"- Give conventions a short stable \"key\" (letters, digits, . _ : / -) such as test-runner or deploy-target.",
|
|
73
89
|
"- Mark a gotcha \"recurring\": true when the same problem appears in two or more sessions.",
|
|
74
90
|
"- Drop every status item (they describe a past moment) and todos that read as finished.",
|
|
91
|
+
"- Keep \"evidence\" (a verbatim transcript quote) from the newest source item that was merged; never write new evidence.",
|
|
75
92
|
"- Items already live on the branch are listed; do not repeat them, and when a proposed item supersedes a live one, add \"supersedes\": [\"<live id>\"].",
|
|
76
|
-
`- Output only a JSON array of at most ${BRANCH_ITEMS_MAX} items: {"kind","title","body","key"?,"recurring"?,"supersedes"?,"sessions"}.`,
|
|
93
|
+
`- Output only a JSON array of at most ${BRANCH_ITEMS_MAX} items: {"kind","title","body","evidence"?,"key"?,"recurring"?,"supersedes"?,"sessions"}.`,
|
|
77
94
|
"",
|
|
78
95
|
`Live items on the branch:\n${JSON.stringify(live.map((i) => ({ id: i.id, kind: i.kind, title: i.title, body: i.body })))}`,
|
|
79
96
|
"",
|
|
@@ -109,6 +126,8 @@ export function parseMerged(raw, fallback) {
|
|
|
109
126
|
item.key = v.key;
|
|
110
127
|
if (v.recurring === true)
|
|
111
128
|
item.recurring = true;
|
|
129
|
+
if (typeof v.evidence === "string" && v.evidence.trim())
|
|
130
|
+
item.evidence = redact(squash(v.evidence).slice(0, EVIDENCE_CHARS));
|
|
112
131
|
if (Array.isArray(v.supersedes))
|
|
113
132
|
item.supersedes = v.supersedes.filter((x) => typeof x === "string").slice(0, 20);
|
|
114
133
|
out.push(item);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ALL_HARNESSES, discoverSessions } from "./discover.js";
|
|
2
|
+
import { DEFAULT_SINCE_DAYS } from "./run.js";
|
|
3
|
+
// After `meshpoint connect` inside a repository: say how much history is waiting to be imported.
|
|
4
|
+
// Header-only discovery, no model call, no upload, text only.
|
|
5
|
+
export const OFFER_MIN_TURNS = 6;
|
|
6
|
+
const SECONDS_PER_SESSION = 30;
|
|
7
|
+
const WORKERS = 2;
|
|
8
|
+
export function importOffer(opts) {
|
|
9
|
+
if (!opts.repo)
|
|
10
|
+
return null;
|
|
11
|
+
const now = opts.now ?? Date.now;
|
|
12
|
+
const since = now() - DEFAULT_SINCE_DAYS * 86_400_000;
|
|
13
|
+
const discover = opts.discover ?? discoverSessions;
|
|
14
|
+
const sessions = discover({ env: opts.env, ...(opts.home ? { home: opts.home } : {}), harnesses: ALL_HARNESSES, since, project: opts.repo.project, roots: [opts.repo.root] }).filter((s) => s.project === opts.repo.project && s.endedAt >= since && s.entries.length >= OFFER_MIN_TURNS);
|
|
15
|
+
if (sessions.length === 0)
|
|
16
|
+
return null;
|
|
17
|
+
const byHarness = new Map();
|
|
18
|
+
for (const s of sessions)
|
|
19
|
+
byHarness.set(s.harness, (byHarness.get(s.harness) ?? 0) + 1);
|
|
20
|
+
const first = new Date(Math.min(...sessions.map((s) => s.startedAt))).toISOString().slice(0, 10);
|
|
21
|
+
const last = new Date(Math.max(...sessions.map((s) => s.endedAt))).toISOString().slice(0, 10);
|
|
22
|
+
const head = `${sessions.length} past session${sessions.length === 1 ? "" : "s"} found for this repository (${[...byHarness].map(([h, n]) => `${h} ${n}`).join(", ")}), ${first} to ${last}.`;
|
|
23
|
+
if (!opts.runner)
|
|
24
|
+
return `${head}\nNo agent CLI (claude or codex) on PATH to distill them; install one, then run: meshpoint import sessions --propose`;
|
|
25
|
+
const minutes = Math.ceil((sessions.length * SECONDS_PER_SESSION) / WORKERS / 60);
|
|
26
|
+
return `${head}\nDistill them with your ${opts.runner} into a proposal for review: meshpoint import sessions --propose (about ${minutes} minute${minutes === 1 ? "" : "s"}).`;
|
|
27
|
+
}
|
package/dist/import/report.js
CHANGED
|
@@ -22,6 +22,8 @@ export function renderReport(results, unmapped, skipped) {
|
|
|
22
22
|
const paths = topPaths(r.sessions);
|
|
23
23
|
if (paths.length)
|
|
24
24
|
lines.push(`most touched: ${paths.join(", ")}`);
|
|
25
|
+
if (r.folded.length)
|
|
26
|
+
lines.push(`folded into ${r.folded[0]?.into}: ${r.folded.map((f) => `${f.branch} (${f.why})`).join(", ")}`);
|
|
25
27
|
for (const b of r.branches) {
|
|
26
28
|
const kinds = new Map();
|
|
27
29
|
for (const i of b.items)
|
package/dist/import/run.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { createInterface } from "node:readline";
|
|
5
6
|
import { MeshpointClient } from "@meshpoint/sdk";
|
|
@@ -15,6 +16,32 @@ export const TURNS_WINDOW_DAYS = 30;
|
|
|
15
16
|
const DISTILL_CONCURRENCY = 2;
|
|
16
17
|
const ALL_ITEMS_BUDGET = 100_000;
|
|
17
18
|
const CAPTURE_SESSIONS_MAX = 100;
|
|
19
|
+
export function gitBranchState(root, branch, defaultBranch) {
|
|
20
|
+
const ok = (args) => spawnSync("git", ["-C", root, ...args], { stdio: "ignore", timeout: 2000 }).status === 0;
|
|
21
|
+
const local = ok(["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`]);
|
|
22
|
+
const remote = !local && ok(["rev-parse", "--verify", "--quiet", `refs/remotes/origin/${branch}`]);
|
|
23
|
+
if (!local && !remote)
|
|
24
|
+
return "gone";
|
|
25
|
+
return ok(["merge-base", "--is-ancestor", local ? branch : `origin/${branch}`, defaultBranch]) ? "merged" : "live";
|
|
26
|
+
}
|
|
27
|
+
function fileStamp(file) {
|
|
28
|
+
try {
|
|
29
|
+
const st = statSync(file);
|
|
30
|
+
return { mtime: st.mtimeMs, size: st.size };
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function readCache(file, stamp) {
|
|
37
|
+
try {
|
|
38
|
+
const c = JSON.parse(readFileSync(file, "utf8"));
|
|
39
|
+
return c.mtime === stamp.mtime && c.size === stamp.size && Array.isArray(c.items) ? c.items : null;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
18
45
|
async function askTty(question) {
|
|
19
46
|
if (!process.stdin.isTTY)
|
|
20
47
|
return false;
|
|
@@ -43,15 +70,20 @@ export async function importSessions(opts) {
|
|
|
43
70
|
const confirm = opts.confirm ?? askTty;
|
|
44
71
|
const discover = opts.discover ?? discoverSessions;
|
|
45
72
|
const since = now() - opts.sinceDays * 86_400_000;
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
if (!opts.allRepos && !opts.current)
|
|
74
|
+
throw new Error("not inside a git repo with an origin remote; pass --all-repos to import every repository");
|
|
75
|
+
// Outside --all-repos only this repository's transcripts are read in full; the rest is skimmed or skipped.
|
|
76
|
+
const all = discover({
|
|
77
|
+
...(opts.env ? { env: opts.env } : {}),
|
|
78
|
+
...(opts.home ? { home: opts.home } : {}),
|
|
79
|
+
since,
|
|
80
|
+
...(opts.allRepos || !opts.current ? {} : { project: opts.current.project, roots: [opts.current.root] }),
|
|
81
|
+
});
|
|
82
|
+
const inWindow = all.filter((s) => s.endedAt >= since && (s.skimmed || s.entries.length >= opts.minTurns));
|
|
48
83
|
const unmapped = inWindow.filter((s) => s.project === null);
|
|
49
|
-
let selected = inWindow.filter((s) => s.project !== null);
|
|
50
|
-
if (!opts.allRepos)
|
|
51
|
-
if (!opts.current)
|
|
52
|
-
throw new Error("not inside a git repo with an origin remote; pass --all-repos to import every repository");
|
|
84
|
+
let selected = inWindow.filter((s) => s.project !== null && !s.skimmed);
|
|
85
|
+
if (!opts.allRepos)
|
|
53
86
|
selected = selected.filter((s) => s.project === opts.current.project);
|
|
54
|
-
}
|
|
55
87
|
const empty = { results: [], unmapped, reportFile: "", itemsFiles: [], uploaded: { items: 0, turns: 0 }, proposals: [], cancelled: false };
|
|
56
88
|
if (selected.length === 0) {
|
|
57
89
|
log(`no sessions found${opts.allRepos ? "" : ` for ${opts.current?.project}`} in the last ${opts.sinceDays} days (${inWindow.length} in the window, ${unmapped.length} unmapped)`);
|
|
@@ -79,16 +111,27 @@ export async function importSessions(opts) {
|
|
|
79
111
|
const uploaded = { items: 0, turns: 0 };
|
|
80
112
|
const sent = [];
|
|
81
113
|
const outDir = path.join(opts.stateDir, "import");
|
|
82
|
-
|
|
114
|
+
const cacheDir = path.join(outDir, "cache");
|
|
115
|
+
mkdirSync(cacheDir, { recursive: true, mode: 0o700 });
|
|
116
|
+
const branchState = opts.branchState ?? gitBranchState;
|
|
83
117
|
for (const [project, sessions] of byProject) {
|
|
84
118
|
const root = opts.current?.project === project ? opts.current.root : (sessions.find((s) => s.cwd && existsSync(s.cwd))?.cwd ?? "");
|
|
85
119
|
const defaultBranch = opts.current?.project === project ? opts.current.defaultBranch : "master";
|
|
86
|
-
const result = { project, root, sessions, branches: [], errors: [] };
|
|
120
|
+
const result = { project, root, sessions, branches: [], folded: [], errors: [] };
|
|
87
121
|
log(`${project}: distilling ${sessions.length} session${sessions.length === 1 ? "" : "s"} with ${opts.runner.name}`);
|
|
88
122
|
const proposals = await mapPool(sessions, DISTILL_CONCURRENCY, async (s) => {
|
|
123
|
+
const stamp = fileStamp(s.file);
|
|
124
|
+
const cacheFile = path.join(cacheDir, `${safe(s.harness)}-${safe(s.id)}.json`);
|
|
125
|
+
const cached = stamp && !opts.fresh ? readCache(cacheFile, stamp) : null;
|
|
126
|
+
if (cached) {
|
|
127
|
+
log(` ${s.harness} ${s.id.slice(0, 8)} (${s.entries.length} turns): ${cached.length} proposed (cached)`);
|
|
128
|
+
return { s, items: cached };
|
|
129
|
+
}
|
|
89
130
|
try {
|
|
90
|
-
const items = await distillSession(opts.runner, s);
|
|
91
|
-
log(` ${s.harness} ${s.id.slice(0, 8)} (${s.entries.length} turns): ${items.length} proposed`);
|
|
131
|
+
const { items, unsupported } = await distillSession(opts.runner, s);
|
|
132
|
+
log(` ${s.harness} ${s.id.slice(0, 8)} (${s.entries.length} turns): ${items.length} proposed${unsupported ? `, ${unsupported} unsupported` : ""}`);
|
|
133
|
+
if (stamp)
|
|
134
|
+
writeFileSync(cacheFile, JSON.stringify({ ...stamp, items }), { mode: 0o600 });
|
|
92
135
|
return { s, items };
|
|
93
136
|
}
|
|
94
137
|
catch (err) {
|
|
@@ -98,9 +141,24 @@ export async function importSessions(opts) {
|
|
|
98
141
|
});
|
|
99
142
|
// Oldest first, so the consolidation pass can treat later sessions as newer.
|
|
100
143
|
proposals.sort((a, b) => a.s.endedAt - b.s.endedAt);
|
|
144
|
+
// A branch that is gone or already merged gets no items of its own: they go to the default branch.
|
|
145
|
+
const placement = new Map();
|
|
146
|
+
const place = (recorded) => {
|
|
147
|
+
if (recorded === defaultBranch || !root)
|
|
148
|
+
return recorded;
|
|
149
|
+
const known = placement.get(recorded);
|
|
150
|
+
if (known)
|
|
151
|
+
return known;
|
|
152
|
+
const state = branchState(root, recorded, defaultBranch);
|
|
153
|
+
const target = state === "live" ? recorded : defaultBranch;
|
|
154
|
+
if (state !== "live")
|
|
155
|
+
result.folded.push({ branch: recorded, into: defaultBranch, why: state });
|
|
156
|
+
placement.set(recorded, target);
|
|
157
|
+
return target;
|
|
158
|
+
};
|
|
101
159
|
const byBranch = new Map();
|
|
102
160
|
for (const p of proposals) {
|
|
103
|
-
const branch = p.s.branch ?? defaultBranch;
|
|
161
|
+
const branch = place(p.s.branch ?? defaultBranch);
|
|
104
162
|
byBranch.set(branch, [...(byBranch.get(branch) ?? []), ...p.items]);
|
|
105
163
|
}
|
|
106
164
|
const client = (branch) => new MeshpointClient({ baseUrl: opts.config.baseUrl, token: opts.config.token, project, branch, ...(opts.fetch ? { fetch: opts.fetch } : {}) });
|
|
@@ -178,6 +236,9 @@ export async function importSessions(opts) {
|
|
|
178
236
|
}
|
|
179
237
|
results.push(result);
|
|
180
238
|
}
|
|
239
|
+
for (const r of results)
|
|
240
|
+
if (r.folded.length)
|
|
241
|
+
log(` ${r.project}: folded into ${r.folded[0]?.into}: ${r.folded.map((f) => `${f.branch} (${f.why})`).join(", ")}`);
|
|
181
242
|
const report = renderReport(results, unmapped, { openclaw: "keeps no transcript on disk; nothing to import", cursor: "transcript store is undocumented; only files named like transcripts under ~/.cursor are tried" });
|
|
182
243
|
const reportFile = path.join(outDir, `report-${new Date(now()).toISOString().slice(0, 10)}.txt`);
|
|
183
244
|
writeFileSync(reportFile, `${report}\n`, { mode: 0o600 });
|
|
@@ -264,6 +325,7 @@ export function readProposal(file) {
|
|
|
264
325
|
refs: Array.isArray(i.refs) ? i.refs.filter((x) => typeof x === "string") : [],
|
|
265
326
|
...(typeof i.key === "string" && i.key ? { key: i.key } : {}),
|
|
266
327
|
...(i.recurring === true ? { recurring: true } : {}),
|
|
328
|
+
...(typeof i.evidence === "string" && i.evidence.trim() ? { evidence: i.evidence.trim() } : {}),
|
|
267
329
|
...(Array.isArray(i.supersedes) ? { supersedes: i.supersedes.filter((x) => typeof x === "string") } : {}),
|
|
268
330
|
...(typeof i.created_at === "number" ? { created_at: i.created_at } : {}),
|
|
269
331
|
...(Array.isArray(i.harnesses) ? { harnesses: i.harnesses.filter((x) => typeof x === "string") } : {}),
|