@staff0rd/assist 0.851.1 → 0.853.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/dist/commands/sessions/web/bundle.js +404 -404
- package/dist/index.js +569 -351
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.853.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -9012,57 +9012,10 @@ function reportPhaseActivity(item, phaseNumber, totalPhases, phase, claudeSessio
|
|
|
9012
9012
|
import chalk69 from "chalk";
|
|
9013
9013
|
|
|
9014
9014
|
// src/commands/sessions/shared/findSessionJsonlPath.ts
|
|
9015
|
-
import * as
|
|
9016
|
-
|
|
9017
|
-
// src/commands/sessions/shared/discoverSessions.ts
|
|
9018
|
-
import * as fs15 from "fs";
|
|
9019
|
-
import * as os4 from "os";
|
|
9020
|
-
import * as path24 from "path";
|
|
9015
|
+
import * as path22 from "path";
|
|
9021
9016
|
|
|
9022
|
-
// src/commands/sessions/shared/
|
|
9017
|
+
// src/commands/sessions/shared/parseSessionFile.ts
|
|
9023
9018
|
import * as fs11 from "fs";
|
|
9024
|
-
import * as path21 from "path";
|
|
9025
|
-
|
|
9026
|
-
// src/commands/sessions/shared/codex/codexSessionsDir.ts
|
|
9027
|
-
import { existsSync as existsSync32 } from "fs";
|
|
9028
|
-
import * as path20 from "path";
|
|
9029
|
-
function codexSessionsDir() {
|
|
9030
|
-
return path20.join(harnesses.codex.homeDir, "sessions");
|
|
9031
|
-
}
|
|
9032
|
-
function hasCodexSessions() {
|
|
9033
|
-
return existsSync32(codexSessionsDir());
|
|
9034
|
-
}
|
|
9035
|
-
|
|
9036
|
-
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
9037
|
-
var DATE_DEPTH = 3;
|
|
9038
|
-
function isCodexRolloutFile(name) {
|
|
9039
|
-
return name.startsWith("rollout-") && name.endsWith(".jsonl");
|
|
9040
|
-
}
|
|
9041
|
-
async function discoverCodexRolloutPaths() {
|
|
9042
|
-
if (!hasCodexSessions()) return [];
|
|
9043
|
-
return collect(codexSessionsDir(), DATE_DEPTH);
|
|
9044
|
-
}
|
|
9045
|
-
async function collect(dir, depth) {
|
|
9046
|
-
let entries;
|
|
9047
|
-
try {
|
|
9048
|
-
entries = await fs11.promises.readdir(dir, { withFileTypes: true });
|
|
9049
|
-
} catch {
|
|
9050
|
-
return [];
|
|
9051
|
-
}
|
|
9052
|
-
const nested = await Promise.all(
|
|
9053
|
-
entries.map((entry) => collectEntry(dir, entry, depth))
|
|
9054
|
-
);
|
|
9055
|
-
return nested.flat();
|
|
9056
|
-
}
|
|
9057
|
-
async function collectEntry(dir, entry, depth) {
|
|
9058
|
-
const full = path21.join(dir, entry.name);
|
|
9059
|
-
if (entry.isDirectory()) return depth > 0 ? collect(full, depth - 1) : [];
|
|
9060
|
-
return isCodexRolloutFile(entry.name) ? [full] : [];
|
|
9061
|
-
}
|
|
9062
|
-
|
|
9063
|
-
// src/commands/sessions/shared/codex/parseCodexSessionFile.ts
|
|
9064
|
-
import * as fs13 from "fs";
|
|
9065
|
-
import * as path22 from "path";
|
|
9066
9019
|
|
|
9067
9020
|
// src/commands/sessions/shared/deriveHistoryFields.ts
|
|
9068
9021
|
var KNOWN = [
|
|
@@ -9093,119 +9046,14 @@ function deriveSessionType(commandName, name) {
|
|
|
9093
9046
|
return void 0;
|
|
9094
9047
|
}
|
|
9095
9048
|
|
|
9096
|
-
// src/commands/sessions/shared/codex/parseRolloutEntry.ts
|
|
9097
|
-
function parseRolloutEntry(line) {
|
|
9098
|
-
try {
|
|
9099
|
-
const parsed = JSON.parse(line);
|
|
9100
|
-
return parsed && typeof parsed === "object" ? parsed : null;
|
|
9101
|
-
} catch {
|
|
9102
|
-
return null;
|
|
9103
|
-
}
|
|
9104
|
-
}
|
|
9105
|
-
function rolloutPayload(entry) {
|
|
9106
|
-
return entry.payload && typeof entry.payload === "object" ? entry.payload : {};
|
|
9107
|
-
}
|
|
9108
|
-
function rolloutString(value) {
|
|
9109
|
-
return typeof value === "string" ? value : "";
|
|
9110
|
-
}
|
|
9111
|
-
|
|
9112
|
-
// src/commands/sessions/shared/codex/codexRolloutMeta.ts
|
|
9113
|
-
var MAX_FIRST_MESSAGE = 2e3;
|
|
9114
|
-
function codexRolloutMeta(lines2) {
|
|
9115
|
-
const meta = {
|
|
9116
|
-
sessionId: "",
|
|
9117
|
-
cwd: "",
|
|
9118
|
-
timestamp: "",
|
|
9119
|
-
firstMessage: ""
|
|
9120
|
-
};
|
|
9121
|
-
for (const line of lines2) {
|
|
9122
|
-
const entry = parseRolloutEntry(line);
|
|
9123
|
-
if (!entry) continue;
|
|
9124
|
-
applySessionMeta(meta, entry);
|
|
9125
|
-
meta.firstMessage ||= firstUserMessage(entry);
|
|
9126
|
-
if (meta.sessionId && meta.firstMessage) break;
|
|
9127
|
-
}
|
|
9128
|
-
return meta;
|
|
9129
|
-
}
|
|
9130
|
-
function applySessionMeta(meta, entry) {
|
|
9131
|
-
if (entry.type !== "session_meta") return;
|
|
9132
|
-
const payload = rolloutPayload(entry);
|
|
9133
|
-
meta.sessionId ||= rolloutString(payload.session_id);
|
|
9134
|
-
meta.cwd ||= rolloutString(payload.cwd);
|
|
9135
|
-
meta.timestamp ||= rolloutString(payload.timestamp);
|
|
9136
|
-
}
|
|
9137
|
-
function firstUserMessage(entry) {
|
|
9138
|
-
if (entry.type !== "event_msg") return "";
|
|
9139
|
-
const payload = rolloutPayload(entry);
|
|
9140
|
-
if (payload.type !== "user_message") return "";
|
|
9141
|
-
return rolloutString(payload.message).trim().slice(0, MAX_FIRST_MESSAGE);
|
|
9142
|
-
}
|
|
9143
|
-
|
|
9144
|
-
// src/commands/sessions/shared/codex/readCodexHeadLines.ts
|
|
9145
|
-
import * as fs12 from "fs";
|
|
9146
|
-
import * as readline3 from "readline";
|
|
9147
|
-
var DEFAULT_MAX_LINES = 80;
|
|
9148
|
-
async function readCodexHeadLines(filePath, maxLines = DEFAULT_MAX_LINES) {
|
|
9149
|
-
const stream = fs12.createReadStream(filePath, { encoding: "utf8" });
|
|
9150
|
-
const reader = readline3.createInterface({ input: stream });
|
|
9151
|
-
const lines2 = [];
|
|
9152
|
-
try {
|
|
9153
|
-
for await (const line of reader) {
|
|
9154
|
-
if (line) lines2.push(line);
|
|
9155
|
-
if (lines2.length >= maxLines) break;
|
|
9156
|
-
}
|
|
9157
|
-
} catch {
|
|
9158
|
-
return lines2;
|
|
9159
|
-
} finally {
|
|
9160
|
-
reader.close();
|
|
9161
|
-
stream.destroy();
|
|
9162
|
-
}
|
|
9163
|
-
return lines2;
|
|
9164
|
-
}
|
|
9165
|
-
|
|
9166
|
-
// src/commands/sessions/shared/codex/parseCodexSessionFile.ts
|
|
9167
|
-
async function parseCodexSessionFile(filePath) {
|
|
9168
|
-
try {
|
|
9169
|
-
const meta = codexRolloutMeta(await readCodexHeadLines(filePath));
|
|
9170
|
-
if (!meta.sessionId) return null;
|
|
9171
|
-
const name = meta.firstMessage.slice(0, 80);
|
|
9172
|
-
const markers = backlogRunMarkers(meta.firstMessage);
|
|
9173
|
-
return {
|
|
9174
|
-
sessionId: meta.sessionId,
|
|
9175
|
-
name: name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
9176
|
-
project: meta.cwd ? path22.basename(meta.cwd) : "",
|
|
9177
|
-
cwd: meta.cwd,
|
|
9178
|
-
timestamp: meta.timestamp || await mtime(filePath),
|
|
9179
|
-
origin: "wsl",
|
|
9180
|
-
harness: "codex",
|
|
9181
|
-
...deriveHistoryFields(markers.commandName, markers.commandArgs, name)
|
|
9182
|
-
};
|
|
9183
|
-
} catch {
|
|
9184
|
-
return null;
|
|
9185
|
-
}
|
|
9186
|
-
}
|
|
9187
|
-
async function mtime(filePath) {
|
|
9188
|
-
return (await fs13.promises.stat(filePath)).mtime.toISOString();
|
|
9189
|
-
}
|
|
9190
|
-
|
|
9191
|
-
// src/commands/sessions/shared/codex/discoverCodexSessions.ts
|
|
9192
|
-
async function discoverCodexSessions() {
|
|
9193
|
-
const paths = await discoverCodexRolloutPaths();
|
|
9194
|
-
const parsed = await Promise.all(paths.map(parseCodexSessionFile));
|
|
9195
|
-
return parsed.filter((session) => session !== null);
|
|
9196
|
-
}
|
|
9197
|
-
|
|
9198
|
-
// src/commands/sessions/shared/parseSessionFile.ts
|
|
9199
|
-
import * as fs14 from "fs";
|
|
9200
|
-
|
|
9201
9049
|
// src/commands/sessions/shared/deriveProject.ts
|
|
9202
|
-
import * as
|
|
9050
|
+
import * as path20 from "path";
|
|
9203
9051
|
function deriveProject(cwd, filePath, origin) {
|
|
9204
9052
|
if (!cwd) return dirNameToProject(filePath);
|
|
9205
|
-
return origin === "windows" ?
|
|
9053
|
+
return origin === "windows" ? path20.win32.basename(cwd) : path20.basename(cwd);
|
|
9206
9054
|
}
|
|
9207
9055
|
function dirNameToProject(filePath) {
|
|
9208
|
-
const dirName =
|
|
9056
|
+
const dirName = path20.basename(path20.dirname(filePath));
|
|
9209
9057
|
const parts = dirName.split("--");
|
|
9210
9058
|
return parts[parts.length - 1].replace(/-/g, "/");
|
|
9211
9059
|
}
|
|
@@ -9214,10 +9062,10 @@ function dirNameToProject(filePath) {
|
|
|
9214
9062
|
async function parseSessionFile(filePath, origin = "wsl") {
|
|
9215
9063
|
let handle;
|
|
9216
9064
|
try {
|
|
9217
|
-
handle = await
|
|
9065
|
+
handle = await fs11.promises.open(filePath, "r");
|
|
9218
9066
|
const meta = extractSessionMeta(await readHeadLines(handle));
|
|
9219
9067
|
if (!meta.sessionId) return null;
|
|
9220
|
-
const timestamp6 = meta.timestamp || (await
|
|
9068
|
+
const timestamp6 = meta.timestamp || (await fs11.promises.stat(filePath)).mtime.toISOString();
|
|
9221
9069
|
return {
|
|
9222
9070
|
sessionId: meta.sessionId,
|
|
9223
9071
|
name: meta.name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
@@ -9239,34 +9087,32 @@ async function readHeadLines(handle) {
|
|
|
9239
9087
|
return buf.toString("utf8", 0, bytesRead).split("\n").filter(Boolean);
|
|
9240
9088
|
}
|
|
9241
9089
|
|
|
9242
|
-
// src/commands/sessions/shared/
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
];
|
|
9247
|
-
}
|
|
9090
|
+
// src/commands/sessions/shared/discoverSessionJsonlPaths.ts
|
|
9091
|
+
import * as fs12 from "fs";
|
|
9092
|
+
import * as os4 from "os";
|
|
9093
|
+
import * as path21 from "path";
|
|
9248
9094
|
async function discoverSessionJsonlPaths() {
|
|
9249
9095
|
const results = [];
|
|
9250
9096
|
await Promise.all(
|
|
9251
9097
|
sessionRoots().map(async ({ dir, origin }) => {
|
|
9252
9098
|
let projectDirs;
|
|
9253
9099
|
try {
|
|
9254
|
-
projectDirs = await
|
|
9100
|
+
projectDirs = await fs12.promises.readdir(dir);
|
|
9255
9101
|
} catch {
|
|
9256
9102
|
return;
|
|
9257
9103
|
}
|
|
9258
9104
|
await Promise.all(
|
|
9259
9105
|
projectDirs.map(async (dirName) => {
|
|
9260
|
-
const dirPath =
|
|
9106
|
+
const dirPath = path21.join(dir, dirName);
|
|
9261
9107
|
let entries;
|
|
9262
9108
|
try {
|
|
9263
|
-
entries = await
|
|
9109
|
+
entries = await fs12.promises.readdir(dirPath);
|
|
9264
9110
|
} catch {
|
|
9265
9111
|
return;
|
|
9266
9112
|
}
|
|
9267
9113
|
for (const file of entries) {
|
|
9268
9114
|
if (file.endsWith(".jsonl"))
|
|
9269
|
-
results.push({ path:
|
|
9115
|
+
results.push({ path: path21.join(dirPath, file), origin });
|
|
9270
9116
|
}
|
|
9271
9117
|
})
|
|
9272
9118
|
);
|
|
@@ -9274,30 +9120,17 @@ async function discoverSessionJsonlPaths() {
|
|
|
9274
9120
|
);
|
|
9275
9121
|
return results;
|
|
9276
9122
|
}
|
|
9277
|
-
|
|
9278
|
-
return
|
|
9279
|
-
}
|
|
9280
|
-
|
|
9281
|
-
const paths = await discoverSessionJsonlPaths();
|
|
9282
|
-
const sessions = [];
|
|
9283
|
-
await Promise.all(
|
|
9284
|
-
paths.map(async ({ path: filePath, origin }) => {
|
|
9285
|
-
const session = await parseSessionFile(filePath, origin);
|
|
9286
|
-
if (session) sessions.push(session);
|
|
9287
|
-
})
|
|
9288
|
-
);
|
|
9289
|
-
sessions.push(...await discoverCodexSessions());
|
|
9290
|
-
sessions.sort(
|
|
9291
|
-
(a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
|
9292
|
-
);
|
|
9293
|
-
return sessions;
|
|
9123
|
+
function sessionRoots() {
|
|
9124
|
+
return [
|
|
9125
|
+
{ dir: path21.join(os4.homedir(), ".claude", "projects"), origin: "wsl" }
|
|
9126
|
+
];
|
|
9294
9127
|
}
|
|
9295
9128
|
|
|
9296
9129
|
// src/commands/sessions/shared/findSessionJsonlPath.ts
|
|
9297
9130
|
async function findSessionJsonlPath(sessionId) {
|
|
9298
9131
|
const paths = await discoverSessionJsonlPaths();
|
|
9299
9132
|
const direct = paths.find(
|
|
9300
|
-
(p) =>
|
|
9133
|
+
(p) => path22.basename(p.path, ".jsonl") === sessionId
|
|
9301
9134
|
);
|
|
9302
9135
|
if (direct) return direct.path;
|
|
9303
9136
|
for (const p of paths) {
|
|
@@ -10797,14 +10630,14 @@ async function updatePhase(id, phase, options2) {
|
|
|
10797
10630
|
}
|
|
10798
10631
|
|
|
10799
10632
|
// src/commands/backlog/registerUpdatePhaseCommand.ts
|
|
10800
|
-
function
|
|
10633
|
+
function collect(value, previous) {
|
|
10801
10634
|
return [...previous, value];
|
|
10802
10635
|
}
|
|
10803
10636
|
function registerUpdatePhaseCommand(cmd) {
|
|
10804
|
-
cmd.command("update-phase <id> <phase>").alias("edit-phase").description("Modify a plan phase on a backlog item").option("--name <name>", "New phase name").option("--task <task...>", "Replace tasks (repeatable)").option("--manual-check <check...>", "Replace manual checks (repeatable)").option("--add-task <text>", "Append one task (repeatable)",
|
|
10637
|
+
cmd.command("update-phase <id> <phase>").alias("edit-phase").description("Modify a plan phase on a backlog item").option("--name <name>", "New phase name").option("--task <task...>", "Replace tasks (repeatable)").option("--manual-check <check...>", "Replace manual checks (repeatable)").option("--add-task <text>", "Append one task (repeatable)", collect, []).option("--edit-task <n> <text...>", "Replace task n (1-based) in place").option("--remove-task <n>", "Remove task n (1-based)").option(
|
|
10805
10638
|
"--add-check <text>",
|
|
10806
10639
|
"Append one manual check (repeatable)",
|
|
10807
|
-
|
|
10640
|
+
collect,
|
|
10808
10641
|
[]
|
|
10809
10642
|
).option(
|
|
10810
10643
|
"--edit-check <n> <text...>",
|
|
@@ -11189,7 +11022,7 @@ async function updatePlan(id, options2) {
|
|
|
11189
11022
|
}
|
|
11190
11023
|
|
|
11191
11024
|
// src/commands/backlog/registerUpdateCommands.ts
|
|
11192
|
-
function
|
|
11025
|
+
function collect2(value, previous) {
|
|
11193
11026
|
return [...previous, value];
|
|
11194
11027
|
}
|
|
11195
11028
|
function registerUpdateCommands(cmd) {
|
|
@@ -11199,7 +11032,7 @@ function registerUpdateCommands(cmd) {
|
|
|
11199
11032
|
).option("--type <type>", "New type (story or bug)").option("--ac <criterion...>", "Replace acceptance criteria (repeatable)").option(
|
|
11200
11033
|
"--add-ac <text>",
|
|
11201
11034
|
"Append one acceptance criterion (repeatable)",
|
|
11202
|
-
|
|
11035
|
+
collect2,
|
|
11203
11036
|
[]
|
|
11204
11037
|
).option(
|
|
11205
11038
|
"--edit-ac <n> <text...>",
|
|
@@ -11248,12 +11081,12 @@ function isGitRepo(dir) {
|
|
|
11248
11081
|
|
|
11249
11082
|
// src/shared/sweepStagedAttachments.ts
|
|
11250
11083
|
import { readdirSync as readdirSync4, rmSync as rmSync4, statSync as statSync3 } from "fs";
|
|
11251
|
-
import { join as
|
|
11084
|
+
import { join as join37 } from "path";
|
|
11252
11085
|
|
|
11253
11086
|
// src/shared/stagedAttachmentsDir.ts
|
|
11254
11087
|
import { homedir as homedir14 } from "os";
|
|
11255
|
-
import { join as
|
|
11256
|
-
var stagedAttachmentsDir =
|
|
11088
|
+
import { join as join36 } from "path";
|
|
11089
|
+
var stagedAttachmentsDir = join36(homedir14(), ".assist", "attachments");
|
|
11257
11090
|
|
|
11258
11091
|
// src/shared/sweepStagedAttachments.ts
|
|
11259
11092
|
var PANE_PERSIST_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -11266,7 +11099,7 @@ function sweepStagedAttachments(dir = stagedAttachmentsDir, now = Date.now()) {
|
|
|
11266
11099
|
}
|
|
11267
11100
|
for (const name of entries) {
|
|
11268
11101
|
if (!name.startsWith("upload-")) continue;
|
|
11269
|
-
const path109 =
|
|
11102
|
+
const path109 = join37(dir, name);
|
|
11270
11103
|
try {
|
|
11271
11104
|
if (now - statSync3(path109).mtimeMs > PANE_PERSIST_TTL_MS)
|
|
11272
11105
|
rmSync4(path109, { recursive: true, force: true });
|
|
@@ -11498,7 +11331,7 @@ function delay(ms) {
|
|
|
11498
11331
|
|
|
11499
11332
|
// src/commands/sessions/nodes/tailscaleStatus.ts
|
|
11500
11333
|
import { execFile as execFile3 } from "child_process";
|
|
11501
|
-
import { existsSync as
|
|
11334
|
+
import { existsSync as existsSync32 } from "fs";
|
|
11502
11335
|
import { promisify as promisify2 } from "util";
|
|
11503
11336
|
var execFileAsync2 = promisify2(execFile3);
|
|
11504
11337
|
var STATUS_TIMEOUT_MS = 1e4;
|
|
@@ -11510,7 +11343,7 @@ var INSTALLED_CLI = {
|
|
|
11510
11343
|
function tailscaleCli() {
|
|
11511
11344
|
const platform = detectPlatform();
|
|
11512
11345
|
const installed = INSTALLED_CLI[platform];
|
|
11513
|
-
if (installed &&
|
|
11346
|
+
if (installed && existsSync32(installed)) return installed;
|
|
11514
11347
|
return platform === "wsl" ? "tailscale.exe" : "tailscale";
|
|
11515
11348
|
}
|
|
11516
11349
|
async function tailscaleStatus() {
|
|
@@ -11627,7 +11460,7 @@ async function ensureTailscaleServe(port, deps2 = {}) {
|
|
|
11627
11460
|
import { WebSocketServer } from "ws";
|
|
11628
11461
|
|
|
11629
11462
|
// src/commands/sessions/web/handleSocket.ts
|
|
11630
|
-
import { createInterface as
|
|
11463
|
+
import { createInterface as createInterface3 } from "readline";
|
|
11631
11464
|
|
|
11632
11465
|
// src/commands/sessions/daemon/links/isLinkCreate.ts
|
|
11633
11466
|
var CREATE_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -11710,7 +11543,7 @@ async function openDaemonConnection(ws, ctx) {
|
|
|
11710
11543
|
}
|
|
11711
11544
|
}
|
|
11712
11545
|
function relayDaemonLines(conn, ws, repoCwd) {
|
|
11713
|
-
const lines2 =
|
|
11546
|
+
const lines2 = createInterface3({ input: conn });
|
|
11714
11547
|
lines2.on("error", () => {
|
|
11715
11548
|
});
|
|
11716
11549
|
lines2.on("line", (line) => {
|
|
@@ -11786,38 +11619,6 @@ function attachSessionSocket(server, ctx) {
|
|
|
11786
11619
|
});
|
|
11787
11620
|
}
|
|
11788
11621
|
|
|
11789
|
-
// src/shared/createBundleHandler.ts
|
|
11790
|
-
import { createHash } from "crypto";
|
|
11791
|
-
import { readFileSync as readFileSync23, statSync as statSync5 } from "fs";
|
|
11792
|
-
import { dirname as dirname21, join as join40 } from "path";
|
|
11793
|
-
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
11794
|
-
function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
|
|
11795
|
-
const file = join40(dirname21(fileURLToPath4(importMetaUrl)), bundlePath);
|
|
11796
|
-
let cache6;
|
|
11797
|
-
return (req, res) => {
|
|
11798
|
-
const mtimeMs = statSync5(file).mtimeMs;
|
|
11799
|
-
if (cache6?.mtimeMs !== mtimeMs) {
|
|
11800
|
-
const body = readFileSync23(file);
|
|
11801
|
-
const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
11802
|
-
cache6 = { body, etag, mtimeMs };
|
|
11803
|
-
}
|
|
11804
|
-
const headers = {
|
|
11805
|
-
ETag: cache6.etag,
|
|
11806
|
-
"Cache-Control": "no-cache"
|
|
11807
|
-
};
|
|
11808
|
-
if (req.headers["if-none-match"] === cache6.etag) {
|
|
11809
|
-
res.writeHead(304, headers);
|
|
11810
|
-
res.end();
|
|
11811
|
-
return;
|
|
11812
|
-
}
|
|
11813
|
-
res.writeHead(200, {
|
|
11814
|
-
"Content-Type": contentType,
|
|
11815
|
-
...headers
|
|
11816
|
-
});
|
|
11817
|
-
res.end(cache6.body);
|
|
11818
|
-
};
|
|
11819
|
-
}
|
|
11820
|
-
|
|
11821
11622
|
// src/shared/createFallbackHandler.ts
|
|
11822
11623
|
function createFallbackHandler(routes3, htmlHandler2, extra) {
|
|
11823
11624
|
const baseHandler = createRouteHandler(routes3);
|
|
@@ -11837,12 +11638,12 @@ function createFallbackHandler(routes3, htmlHandler2, extra) {
|
|
|
11837
11638
|
}
|
|
11838
11639
|
|
|
11839
11640
|
// src/commands/backlog/resolveRepoLocation.ts
|
|
11840
|
-
import { existsSync as
|
|
11641
|
+
import { existsSync as existsSync33 } from "fs";
|
|
11841
11642
|
function resolveRepoLocation(origin, knownCwd, baseDir) {
|
|
11842
11643
|
if (knownCwd) return { cwd: knownCwd };
|
|
11843
11644
|
const target = cloneTargetDir(origin, baseDir);
|
|
11844
11645
|
if (!target) return {};
|
|
11845
|
-
if (
|
|
11646
|
+
if (existsSync33(target) && getCurrentOrigin(target) === origin)
|
|
11846
11647
|
return { cwd: target };
|
|
11847
11648
|
return { cloneTarget: target };
|
|
11848
11649
|
}
|
|
@@ -11912,6 +11713,148 @@ function applyCwdFromReq(req) {
|
|
|
11912
11713
|
|
|
11913
11714
|
// src/commands/sessions/shared/lookupSessionsById.ts
|
|
11914
11715
|
import * as path26 from "path";
|
|
11716
|
+
|
|
11717
|
+
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
11718
|
+
import * as fs13 from "fs";
|
|
11719
|
+
import * as path24 from "path";
|
|
11720
|
+
|
|
11721
|
+
// src/commands/sessions/shared/codex/codexSessionsDir.ts
|
|
11722
|
+
import { existsSync as existsSync34 } from "fs";
|
|
11723
|
+
import * as path23 from "path";
|
|
11724
|
+
function codexSessionsDir() {
|
|
11725
|
+
return path23.join(harnesses.codex.homeDir, "sessions");
|
|
11726
|
+
}
|
|
11727
|
+
function hasCodexSessions() {
|
|
11728
|
+
return existsSync34(codexSessionsDir());
|
|
11729
|
+
}
|
|
11730
|
+
|
|
11731
|
+
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
11732
|
+
var DATE_DEPTH = 3;
|
|
11733
|
+
function isCodexRolloutFile(name) {
|
|
11734
|
+
return name.startsWith("rollout-") && name.endsWith(".jsonl");
|
|
11735
|
+
}
|
|
11736
|
+
async function discoverCodexRolloutPaths() {
|
|
11737
|
+
if (!hasCodexSessions()) return [];
|
|
11738
|
+
return collect3(codexSessionsDir(), DATE_DEPTH);
|
|
11739
|
+
}
|
|
11740
|
+
async function collect3(dir, depth) {
|
|
11741
|
+
let entries;
|
|
11742
|
+
try {
|
|
11743
|
+
entries = await fs13.promises.readdir(dir, { withFileTypes: true });
|
|
11744
|
+
} catch {
|
|
11745
|
+
return [];
|
|
11746
|
+
}
|
|
11747
|
+
const nested = await Promise.all(
|
|
11748
|
+
entries.map((entry) => collectEntry(dir, entry, depth))
|
|
11749
|
+
);
|
|
11750
|
+
return nested.flat();
|
|
11751
|
+
}
|
|
11752
|
+
async function collectEntry(dir, entry, depth) {
|
|
11753
|
+
const full = path24.join(dir, entry.name);
|
|
11754
|
+
if (entry.isDirectory()) return depth > 0 ? collect3(full, depth - 1) : [];
|
|
11755
|
+
return isCodexRolloutFile(entry.name) ? [full] : [];
|
|
11756
|
+
}
|
|
11757
|
+
|
|
11758
|
+
// src/commands/sessions/shared/codex/parseCodexSessionFile.ts
|
|
11759
|
+
import * as fs15 from "fs";
|
|
11760
|
+
import * as path25 from "path";
|
|
11761
|
+
|
|
11762
|
+
// src/commands/sessions/shared/codex/parseRolloutEntry.ts
|
|
11763
|
+
function parseRolloutEntry(line) {
|
|
11764
|
+
try {
|
|
11765
|
+
const parsed = JSON.parse(line);
|
|
11766
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
11767
|
+
} catch {
|
|
11768
|
+
return null;
|
|
11769
|
+
}
|
|
11770
|
+
}
|
|
11771
|
+
function rolloutPayload(entry) {
|
|
11772
|
+
return entry.payload && typeof entry.payload === "object" ? entry.payload : {};
|
|
11773
|
+
}
|
|
11774
|
+
function rolloutString(value) {
|
|
11775
|
+
return typeof value === "string" ? value : "";
|
|
11776
|
+
}
|
|
11777
|
+
|
|
11778
|
+
// src/commands/sessions/shared/codex/codexRolloutMeta.ts
|
|
11779
|
+
var MAX_FIRST_MESSAGE = 2e3;
|
|
11780
|
+
function codexRolloutMeta(lines2) {
|
|
11781
|
+
const meta = {
|
|
11782
|
+
sessionId: "",
|
|
11783
|
+
cwd: "",
|
|
11784
|
+
timestamp: "",
|
|
11785
|
+
firstMessage: ""
|
|
11786
|
+
};
|
|
11787
|
+
for (const line of lines2) {
|
|
11788
|
+
const entry = parseRolloutEntry(line);
|
|
11789
|
+
if (!entry) continue;
|
|
11790
|
+
applySessionMeta(meta, entry);
|
|
11791
|
+
meta.firstMessage ||= firstUserMessage(entry);
|
|
11792
|
+
if (meta.sessionId && meta.firstMessage) break;
|
|
11793
|
+
}
|
|
11794
|
+
return meta;
|
|
11795
|
+
}
|
|
11796
|
+
function applySessionMeta(meta, entry) {
|
|
11797
|
+
if (entry.type !== "session_meta") return;
|
|
11798
|
+
const payload = rolloutPayload(entry);
|
|
11799
|
+
meta.sessionId ||= rolloutString(payload.session_id);
|
|
11800
|
+
meta.cwd ||= rolloutString(payload.cwd);
|
|
11801
|
+
meta.timestamp ||= rolloutString(payload.timestamp);
|
|
11802
|
+
}
|
|
11803
|
+
function firstUserMessage(entry) {
|
|
11804
|
+
if (entry.type !== "event_msg") return "";
|
|
11805
|
+
const payload = rolloutPayload(entry);
|
|
11806
|
+
if (payload.type !== "user_message") return "";
|
|
11807
|
+
return rolloutString(payload.message).trim().slice(0, MAX_FIRST_MESSAGE);
|
|
11808
|
+
}
|
|
11809
|
+
|
|
11810
|
+
// src/commands/sessions/shared/codex/readCodexHeadLines.ts
|
|
11811
|
+
import * as fs14 from "fs";
|
|
11812
|
+
import * as readline3 from "readline";
|
|
11813
|
+
var DEFAULT_MAX_LINES = 80;
|
|
11814
|
+
async function readCodexHeadLines(filePath, maxLines = DEFAULT_MAX_LINES) {
|
|
11815
|
+
const stream = fs14.createReadStream(filePath, { encoding: "utf8" });
|
|
11816
|
+
const reader = readline3.createInterface({ input: stream });
|
|
11817
|
+
const lines2 = [];
|
|
11818
|
+
try {
|
|
11819
|
+
for await (const line of reader) {
|
|
11820
|
+
if (line) lines2.push(line);
|
|
11821
|
+
if (lines2.length >= maxLines) break;
|
|
11822
|
+
}
|
|
11823
|
+
} catch {
|
|
11824
|
+
return lines2;
|
|
11825
|
+
} finally {
|
|
11826
|
+
reader.close();
|
|
11827
|
+
stream.destroy();
|
|
11828
|
+
}
|
|
11829
|
+
return lines2;
|
|
11830
|
+
}
|
|
11831
|
+
|
|
11832
|
+
// src/commands/sessions/shared/codex/parseCodexSessionFile.ts
|
|
11833
|
+
async function parseCodexSessionFile(filePath) {
|
|
11834
|
+
try {
|
|
11835
|
+
const meta = codexRolloutMeta(await readCodexHeadLines(filePath));
|
|
11836
|
+
if (!meta.sessionId) return null;
|
|
11837
|
+
const name = meta.firstMessage.slice(0, 80);
|
|
11838
|
+
const markers = backlogRunMarkers(meta.firstMessage);
|
|
11839
|
+
return {
|
|
11840
|
+
sessionId: meta.sessionId,
|
|
11841
|
+
name: name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
11842
|
+
project: meta.cwd ? path25.basename(meta.cwd) : "",
|
|
11843
|
+
cwd: meta.cwd,
|
|
11844
|
+
timestamp: meta.timestamp || await mtime(filePath),
|
|
11845
|
+
origin: "wsl",
|
|
11846
|
+
harness: "codex",
|
|
11847
|
+
...deriveHistoryFields(markers.commandName, markers.commandArgs, name)
|
|
11848
|
+
};
|
|
11849
|
+
} catch {
|
|
11850
|
+
return null;
|
|
11851
|
+
}
|
|
11852
|
+
}
|
|
11853
|
+
async function mtime(filePath) {
|
|
11854
|
+
return (await fs15.promises.stat(filePath)).mtime.toISOString();
|
|
11855
|
+
}
|
|
11856
|
+
|
|
11857
|
+
// src/commands/sessions/shared/lookupSessionsById.ts
|
|
11915
11858
|
var CODEX_ROLLOUT_ID_LENGTH = 36;
|
|
11916
11859
|
async function lookupSessionsById(ids) {
|
|
11917
11860
|
const wanted = new Set(ids);
|
|
@@ -14122,20 +14065,20 @@ function handleServerRuns(req, res) {
|
|
|
14122
14065
|
|
|
14123
14066
|
// src/commands/sessions/web/getReviewSynthesis.ts
|
|
14124
14067
|
import { execFile as execFile6 } from "child_process";
|
|
14125
|
-
import { readFileSync as
|
|
14068
|
+
import { readFileSync as readFileSync23 } from "fs";
|
|
14126
14069
|
import { homedir as homedir15 } from "os";
|
|
14127
|
-
import { basename as basename12, join as
|
|
14070
|
+
import { basename as basename12, join as join41 } from "path";
|
|
14128
14071
|
import { promisify as promisify5 } from "util";
|
|
14129
14072
|
|
|
14130
14073
|
// src/commands/sessions/web/findSynthesisForBranch.ts
|
|
14131
|
-
import { existsSync as existsSync35, readdirSync as readdirSync5, statSync as
|
|
14132
|
-
import { basename as basename11, dirname as
|
|
14074
|
+
import { existsSync as existsSync35, readdirSync as readdirSync5, statSync as statSync5 } from "fs";
|
|
14075
|
+
import { basename as basename11, dirname as dirname21, join as join40 } from "path";
|
|
14133
14076
|
function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
14134
|
-
const branchKeyPath =
|
|
14135
|
-
const parent =
|
|
14077
|
+
const branchKeyPath = join40(repoReviewsDir, `${branch2}-`);
|
|
14078
|
+
const parent = dirname21(branchKeyPath);
|
|
14136
14079
|
const branchPrefix = basename11(branchKeyPath);
|
|
14137
14080
|
if (!existsSync35(parent)) return null;
|
|
14138
|
-
const synthesisFiles = readdirSync5(parent).filter((name) => name.startsWith(branchPrefix)).map((name) =>
|
|
14081
|
+
const synthesisFiles = readdirSync5(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join40(parent, name, "synthesis.md")).filter((path109) => existsSync35(path109)).map((path109) => ({ path: path109, mtime: statSync5(path109).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
14139
14082
|
return synthesisFiles[0]?.path ?? null;
|
|
14140
14083
|
}
|
|
14141
14084
|
|
|
@@ -14153,7 +14096,7 @@ async function resolveSynthesisPath(cwd) {
|
|
|
14153
14096
|
runGit2(cwd, ["rev-parse", "--show-toplevel"]),
|
|
14154
14097
|
runGit2(cwd, ["rev-parse", "--abbrev-ref", "HEAD"])
|
|
14155
14098
|
]);
|
|
14156
|
-
const repoReviewsDir =
|
|
14099
|
+
const repoReviewsDir = join41(
|
|
14157
14100
|
homedir15(),
|
|
14158
14101
|
".assist",
|
|
14159
14102
|
"reviews",
|
|
@@ -14170,7 +14113,7 @@ async function getReviewSynthesis(req, res) {
|
|
|
14170
14113
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
14171
14114
|
return;
|
|
14172
14115
|
}
|
|
14173
|
-
respondJson(res, 200, { synthesis:
|
|
14116
|
+
respondJson(res, 200, { synthesis: readFileSync23(path109, "utf8") });
|
|
14174
14117
|
} catch {
|
|
14175
14118
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
14176
14119
|
}
|
|
@@ -14396,7 +14339,7 @@ function describeProtocolGap(node, msg) {
|
|
|
14396
14339
|
// src/commands/sessions/daemon/requestDaemonReply.ts
|
|
14397
14340
|
import { createInterface as createInterface5 } from "readline";
|
|
14398
14341
|
var QUERY_TIMEOUT_MS = 3e3;
|
|
14399
|
-
async function requestDaemonReply(request, replyType) {
|
|
14342
|
+
async function requestDaemonReply(request, replyType, timeoutMs = QUERY_TIMEOUT_MS) {
|
|
14400
14343
|
let socket;
|
|
14401
14344
|
try {
|
|
14402
14345
|
socket = await connectToDaemon();
|
|
@@ -14409,7 +14352,7 @@ async function requestDaemonReply(request, replyType) {
|
|
|
14409
14352
|
socket.destroy();
|
|
14410
14353
|
resolve30(result);
|
|
14411
14354
|
};
|
|
14412
|
-
const timer = setTimeout(() => finish2(void 0),
|
|
14355
|
+
const timer = setTimeout(() => finish2(void 0), timeoutMs);
|
|
14413
14356
|
const lines2 = createInterface5({ input: socket });
|
|
14414
14357
|
lines2.on("error", () => {
|
|
14415
14358
|
});
|
|
@@ -14446,6 +14389,35 @@ async function health(_req, res) {
|
|
|
14446
14389
|
});
|
|
14447
14390
|
}
|
|
14448
14391
|
|
|
14392
|
+
// src/commands/sessions/web/getCwdAndQuery.ts
|
|
14393
|
+
function getCwdAndQuery(req, res) {
|
|
14394
|
+
const cwd = getCwdParam(req, res);
|
|
14395
|
+
if (!cwd) return null;
|
|
14396
|
+
const query = new URL(req.url ?? "/", "http://localhost").searchParams.get("q") ?? "";
|
|
14397
|
+
return { cwd, query };
|
|
14398
|
+
}
|
|
14399
|
+
|
|
14400
|
+
// src/commands/sessions/web/historySearch.ts
|
|
14401
|
+
var SEARCH_TIMEOUT_MS = 15e3;
|
|
14402
|
+
async function historySearch(req, res) {
|
|
14403
|
+
const params = getCwdAndQuery(req, res);
|
|
14404
|
+
if (!params) return;
|
|
14405
|
+
const reply2 = await requestDaemonReply(
|
|
14406
|
+
{ type: "search-history", ...params },
|
|
14407
|
+
"history-search",
|
|
14408
|
+
SEARCH_TIMEOUT_MS
|
|
14409
|
+
);
|
|
14410
|
+
if (!reply2) {
|
|
14411
|
+
respondJson(res, 504, { error: "Daemon did not answer the search" });
|
|
14412
|
+
return;
|
|
14413
|
+
}
|
|
14414
|
+
if (reply2.error) {
|
|
14415
|
+
respondJson(res, 500, { error: reply2.error });
|
|
14416
|
+
return;
|
|
14417
|
+
}
|
|
14418
|
+
respondJson(res, 200, { sessions: reply2.sessions ?? [] });
|
|
14419
|
+
}
|
|
14420
|
+
|
|
14449
14421
|
// src/shared/hotkeys/resolveHotkeys.ts
|
|
14450
14422
|
function resolveHotkeys(overrides) {
|
|
14451
14423
|
const bindings = { ...defaultHotkeys };
|
|
@@ -14535,9 +14507,9 @@ async function repoFiles(cwd) {
|
|
|
14535
14507
|
return files;
|
|
14536
14508
|
}
|
|
14537
14509
|
async function listFiles(req, res) {
|
|
14538
|
-
const
|
|
14539
|
-
if (!
|
|
14540
|
-
const
|
|
14510
|
+
const params = getCwdAndQuery(req, res);
|
|
14511
|
+
if (!params) return;
|
|
14512
|
+
const { cwd, query } = params;
|
|
14541
14513
|
try {
|
|
14542
14514
|
const files = await repoFiles(cwd);
|
|
14543
14515
|
respondJson(res, 200, { files: rankFilePaths(files, query, MAX_RESULTS) });
|
|
@@ -15449,7 +15421,7 @@ async function nextPickup(req, res) {
|
|
|
15449
15421
|
import path29 from "path";
|
|
15450
15422
|
|
|
15451
15423
|
// src/commands/rules/readScopedRules.ts
|
|
15452
|
-
import { existsSync as existsSync37, readFileSync as
|
|
15424
|
+
import { existsSync as existsSync37, readFileSync as readFileSync24 } from "fs";
|
|
15453
15425
|
import path28 from "path";
|
|
15454
15426
|
|
|
15455
15427
|
// src/commands/rules/rulesSectionRange.ts
|
|
@@ -15498,11 +15470,11 @@ function parseRulesSection(content) {
|
|
|
15498
15470
|
}
|
|
15499
15471
|
|
|
15500
15472
|
// src/commands/rules/scopeDirectory.ts
|
|
15501
|
-
import { existsSync as existsSync36, statSync as
|
|
15473
|
+
import { existsSync as existsSync36, statSync as statSync6 } from "fs";
|
|
15502
15474
|
import path27 from "path";
|
|
15503
15475
|
function scopeDirectory(target) {
|
|
15504
15476
|
const resolved = path27.resolve(target);
|
|
15505
|
-
return existsSync36(resolved) &&
|
|
15477
|
+
return existsSync36(resolved) && statSync6(resolved).isDirectory() ? resolved : path27.dirname(resolved);
|
|
15506
15478
|
}
|
|
15507
15479
|
|
|
15508
15480
|
// src/commands/rules/readScopedRules.ts
|
|
@@ -15521,7 +15493,7 @@ function scopedClaudeFiles(target) {
|
|
|
15521
15493
|
}
|
|
15522
15494
|
function readScopedRules(target) {
|
|
15523
15495
|
return scopedClaudeFiles(target).flatMap(
|
|
15524
|
-
(source) => parseRulesSection(
|
|
15496
|
+
(source) => parseRulesSection(readFileSync24(source, "utf8")).map((rule) => ({
|
|
15525
15497
|
...rule,
|
|
15526
15498
|
source
|
|
15527
15499
|
}))
|
|
@@ -16855,13 +16827,13 @@ import { existsSync as existsSync39 } from "fs";
|
|
|
16855
16827
|
// src/commands/run/resolveCommand.ts
|
|
16856
16828
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
16857
16829
|
import { existsSync as existsSync38 } from "fs";
|
|
16858
|
-
import { dirname as
|
|
16830
|
+
import { dirname as dirname22, join as join42, resolve as resolve14 } from "path";
|
|
16859
16831
|
function resolveCommand(command) {
|
|
16860
16832
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
16861
16833
|
try {
|
|
16862
16834
|
const gitPath = execFileSync4("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
16863
|
-
const gitRoot = resolve14(
|
|
16864
|
-
const gitBash =
|
|
16835
|
+
const gitRoot = resolve14(dirname22(gitPath), "..");
|
|
16836
|
+
const gitBash = join42(gitRoot, "bin", "bash.exe");
|
|
16865
16837
|
if (existsSync38(gitBash)) return gitBash;
|
|
16866
16838
|
} catch {
|
|
16867
16839
|
return command;
|
|
@@ -17721,10 +17693,10 @@ async function saveRepoConfig(orm, repoKey, config) {
|
|
|
17721
17693
|
|
|
17722
17694
|
// src/shared/writeRepoConfigCache.ts
|
|
17723
17695
|
import { mkdirSync as mkdirSync12, renameSync as renameSync3, writeFileSync as writeFileSync22 } from "fs";
|
|
17724
|
-
import { dirname as
|
|
17696
|
+
import { dirname as dirname23 } from "path";
|
|
17725
17697
|
function writeRepoConfigCache(repos2) {
|
|
17726
17698
|
const path109 = repoConfigCachePath();
|
|
17727
|
-
mkdirSync12(
|
|
17699
|
+
mkdirSync12(dirname23(path109), { recursive: true });
|
|
17728
17700
|
const cache6 = {
|
|
17729
17701
|
refreshedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17730
17702
|
repos: repos2
|
|
@@ -18039,11 +18011,11 @@ function changedPaths(from, cwd) {
|
|
|
18039
18011
|
}
|
|
18040
18012
|
|
|
18041
18013
|
// src/commands/watch/readBuiltVersion.ts
|
|
18042
|
-
import { join as
|
|
18014
|
+
import { join as join43 } from "path";
|
|
18043
18015
|
function readBuiltVersion(cwd) {
|
|
18044
18016
|
try {
|
|
18045
18017
|
const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
18046
|
-
return readPackageJson(
|
|
18018
|
+
return readPackageJson(join43(root2, "package.json")).version ?? "unknown";
|
|
18047
18019
|
} catch {
|
|
18048
18020
|
return "unknown";
|
|
18049
18021
|
}
|
|
@@ -18094,9 +18066,9 @@ function stripAnsi(text18) {
|
|
|
18094
18066
|
}
|
|
18095
18067
|
|
|
18096
18068
|
// src/commands/sessions/daemon/worktree/watcherLogPath.ts
|
|
18097
|
-
import { createHash
|
|
18069
|
+
import { createHash } from "crypto";
|
|
18098
18070
|
import { homedir as homedir16 } from "os";
|
|
18099
|
-
import { basename as basename13, join as
|
|
18071
|
+
import { basename as basename13, join as join44 } from "path";
|
|
18100
18072
|
|
|
18101
18073
|
// src/commands/sessions/daemon/worktree/canonicalTreePath.ts
|
|
18102
18074
|
import { realpathSync as realpathSync2 } from "fs";
|
|
@@ -18112,9 +18084,9 @@ function canonicalTreePath(path109) {
|
|
|
18112
18084
|
// src/commands/sessions/daemon/worktree/watcherLogPath.ts
|
|
18113
18085
|
function watcherLogPath(cwd) {
|
|
18114
18086
|
const clone = canonicalTreePath(cwd);
|
|
18115
|
-
const key =
|
|
18116
|
-
const dir = process.env.ASSIST_WATCHER_LOG_DIR ??
|
|
18117
|
-
return
|
|
18087
|
+
const key = createHash("sha1").update(clone).digest("hex").slice(0, 8);
|
|
18088
|
+
const dir = process.env.ASSIST_WATCHER_LOG_DIR ?? join44(homedir16(), ".assist", "watchers");
|
|
18089
|
+
return join44(dir, `${basename13(clone) || "root"}-${key}.log`);
|
|
18118
18090
|
}
|
|
18119
18091
|
|
|
18120
18092
|
// src/commands/sessions/web/updates/readUpdateHistory.ts
|
|
@@ -18229,7 +18201,7 @@ async function readRequestBuffer(req, limit) {
|
|
|
18229
18201
|
|
|
18230
18202
|
// src/commands/sessions/web/stageAttachment.ts
|
|
18231
18203
|
import { mkdir as mkdir4, mkdtemp, writeFile as writeFile2 } from "fs/promises";
|
|
18232
|
-
import { extname as extname2, join as
|
|
18204
|
+
import { extname as extname2, join as join45 } from "path";
|
|
18233
18205
|
|
|
18234
18206
|
// src/commands/sessions/web/ghAttachableExtensions.ts
|
|
18235
18207
|
var ghAttachableExtensions = /* @__PURE__ */ new Set([
|
|
@@ -18261,9 +18233,9 @@ function safeBaseName(name) {
|
|
|
18261
18233
|
async function stageAttachment(name, contentType, body) {
|
|
18262
18234
|
const ext = pickExtension(name, contentType);
|
|
18263
18235
|
await mkdir4(stagedAttachmentsDir, { recursive: true });
|
|
18264
|
-
const dir = await mkdtemp(
|
|
18236
|
+
const dir = await mkdtemp(join45(stagedAttachmentsDir, "upload-"));
|
|
18265
18237
|
const alt = safeBaseName(name);
|
|
18266
|
-
const filePath =
|
|
18238
|
+
const filePath = join45(dir, `${alt}.${ext}`);
|
|
18267
18239
|
await writeFile2(filePath, body);
|
|
18268
18240
|
return { dir, filePath, alt };
|
|
18269
18241
|
}
|
|
@@ -18313,16 +18285,16 @@ import { readFile as readFile3, stat as stat4, writeFile as writeFile3 } from "f
|
|
|
18313
18285
|
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
18314
18286
|
import { execFile as execFile10 } from "child_process";
|
|
18315
18287
|
import { existsSync as existsSync40 } from "fs";
|
|
18316
|
-
import { dirname as
|
|
18288
|
+
import { dirname as dirname24, join as join46 } from "path";
|
|
18317
18289
|
import { promisify as promisify10 } from "util";
|
|
18318
18290
|
var execFileAsync9 = promisify10(execFile10);
|
|
18319
18291
|
var TIMEOUT_MS = 15e3;
|
|
18320
18292
|
function findOxfmtScript(root2) {
|
|
18321
18293
|
let dir = root2;
|
|
18322
18294
|
for (; ; ) {
|
|
18323
|
-
const candidate =
|
|
18295
|
+
const candidate = join46(dir, "node_modules", "oxfmt", "bin", "oxfmt");
|
|
18324
18296
|
if (existsSync40(candidate)) return candidate;
|
|
18325
|
-
const parent =
|
|
18297
|
+
const parent = dirname24(dir);
|
|
18326
18298
|
if (parent === dir) return void 0;
|
|
18327
18299
|
dir = parent;
|
|
18328
18300
|
}
|
|
@@ -18390,6 +18362,38 @@ async function writeFileContent(req, res) {
|
|
|
18390
18362
|
}
|
|
18391
18363
|
}
|
|
18392
18364
|
|
|
18365
|
+
// src/shared/createBundleHandler.ts
|
|
18366
|
+
import { createHash as createHash2 } from "crypto";
|
|
18367
|
+
import { readFileSync as readFileSync25, statSync as statSync7 } from "fs";
|
|
18368
|
+
import { dirname as dirname25, join as join47 } from "path";
|
|
18369
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
18370
|
+
function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
|
|
18371
|
+
const file = join47(dirname25(fileURLToPath4(importMetaUrl)), bundlePath);
|
|
18372
|
+
let cache6;
|
|
18373
|
+
return (req, res) => {
|
|
18374
|
+
const mtimeMs = statSync7(file).mtimeMs;
|
|
18375
|
+
if (cache6?.mtimeMs !== mtimeMs) {
|
|
18376
|
+
const body = readFileSync25(file);
|
|
18377
|
+
const etag = `"${createHash2("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
18378
|
+
cache6 = { body, etag, mtimeMs };
|
|
18379
|
+
}
|
|
18380
|
+
const headers = {
|
|
18381
|
+
ETag: cache6.etag,
|
|
18382
|
+
"Cache-Control": "no-cache"
|
|
18383
|
+
};
|
|
18384
|
+
if (req.headers["if-none-match"] === cache6.etag) {
|
|
18385
|
+
res.writeHead(304, headers);
|
|
18386
|
+
res.end();
|
|
18387
|
+
return;
|
|
18388
|
+
}
|
|
18389
|
+
res.writeHead(200, {
|
|
18390
|
+
"Content-Type": contentType,
|
|
18391
|
+
...headers
|
|
18392
|
+
});
|
|
18393
|
+
res.end(cache6.body);
|
|
18394
|
+
};
|
|
18395
|
+
}
|
|
18396
|
+
|
|
18393
18397
|
// src/commands/sessions/web/createCssHandler.ts
|
|
18394
18398
|
import { createHash as createHash3 } from "crypto";
|
|
18395
18399
|
import { readFileSync as readFileSync26 } from "fs";
|
|
@@ -18415,15 +18419,13 @@ function createCssHandler(packageEntry) {
|
|
|
18415
18419
|
};
|
|
18416
18420
|
}
|
|
18417
18421
|
|
|
18418
|
-
// src/commands/sessions/web/
|
|
18419
|
-
var htmlHandler = createHtmlHandler(getHtml);
|
|
18422
|
+
// src/commands/sessions/web/staticRoutes.ts
|
|
18420
18423
|
var faviconHandler = (size) => createBundleHandler(
|
|
18421
18424
|
import.meta.url,
|
|
18422
18425
|
`commands/extension/extension/icons/assist-${size}.png`,
|
|
18423
18426
|
"image/png"
|
|
18424
18427
|
);
|
|
18425
|
-
var
|
|
18426
|
-
"GET /": htmlHandler,
|
|
18428
|
+
var staticRoutes = {
|
|
18427
18429
|
"GET /bundle.js": createBundleHandler(
|
|
18428
18430
|
import.meta.url,
|
|
18429
18431
|
"commands/sessions/web/bundle.js"
|
|
@@ -18449,7 +18451,14 @@ var routes2 = {
|
|
|
18449
18451
|
),
|
|
18450
18452
|
"GET /favicon-16.png": faviconHandler(16),
|
|
18451
18453
|
"GET /favicon-32.png": faviconHandler(32),
|
|
18452
|
-
"GET /favicon-128.png": faviconHandler(128)
|
|
18454
|
+
"GET /favicon-128.png": faviconHandler(128)
|
|
18455
|
+
};
|
|
18456
|
+
|
|
18457
|
+
// src/commands/sessions/web/handleRequest.ts
|
|
18458
|
+
var htmlHandler = createHtmlHandler(getHtml);
|
|
18459
|
+
var routes2 = {
|
|
18460
|
+
"GET /": htmlHandler,
|
|
18461
|
+
...staticRoutes,
|
|
18453
18462
|
"GET /api/health": health,
|
|
18454
18463
|
"GET /api/daemon-log": daemonLogTail,
|
|
18455
18464
|
"GET /api/items": listItems,
|
|
@@ -18474,6 +18483,7 @@ var routes2 = {
|
|
|
18474
18483
|
"GET /api/file": fileContent,
|
|
18475
18484
|
"POST /api/file": writeFileContent,
|
|
18476
18485
|
"GET /api/files": listFiles,
|
|
18486
|
+
"GET /api/history/search": historySearch,
|
|
18477
18487
|
"GET /api/rules": listScopedRules,
|
|
18478
18488
|
"GET /api/jira-site": jiraSite,
|
|
18479
18489
|
"GET /api/harness": harnessCapabilities,
|
|
@@ -45633,6 +45643,37 @@ function buildPrompt5(prompt) {
|
|
|
45633
45643
|
].join("\n");
|
|
45634
45644
|
}
|
|
45635
45645
|
|
|
45646
|
+
// src/commands/sessions/shared/loadSessionTitles.ts
|
|
45647
|
+
import { z as z13 } from "zod";
|
|
45648
|
+
var TITLES_FILE = "session-titles.json";
|
|
45649
|
+
var sessionTitlesSchema = z13.record(z13.string(), z13.string());
|
|
45650
|
+
function loadSessionTitles() {
|
|
45651
|
+
const parsed = sessionTitlesSchema.safeParse(
|
|
45652
|
+
loadJson(TITLES_FILE)
|
|
45653
|
+
);
|
|
45654
|
+
return parsed.success ? parsed.data : {};
|
|
45655
|
+
}
|
|
45656
|
+
function saveSessionTitle(harnessSessionId, title) {
|
|
45657
|
+
const titles2 = loadSessionTitles();
|
|
45658
|
+
if (titles2[harnessSessionId] === title) return false;
|
|
45659
|
+
titles2[harnessSessionId] = title;
|
|
45660
|
+
saveJson(TITLES_FILE, titles2);
|
|
45661
|
+
return true;
|
|
45662
|
+
}
|
|
45663
|
+
|
|
45664
|
+
// src/commands/sessions/daemon/rememberSessionTitle.ts
|
|
45665
|
+
function rememberSessionTitle(session) {
|
|
45666
|
+
const harnessSessionId = session.harness === "codex" ? session.harnessSessionId : session.claudeSessionId;
|
|
45667
|
+
const title = session.title ?? session.generatedTitle;
|
|
45668
|
+
if (!harnessSessionId || !title) return;
|
|
45669
|
+
try {
|
|
45670
|
+
if (saveSessionTitle(harnessSessionId, title))
|
|
45671
|
+
daemonLog(`session ${session.id} title kept for ${harnessSessionId}`);
|
|
45672
|
+
} catch (error) {
|
|
45673
|
+
daemonLog(`session ${session.id} title not saved: ${error}`);
|
|
45674
|
+
}
|
|
45675
|
+
}
|
|
45676
|
+
|
|
45636
45677
|
// src/commands/sessions/daemon/runSessionTitleGeneration.ts
|
|
45637
45678
|
function runSessionTitleGeneration(session, prompt, notify2, fallback) {
|
|
45638
45679
|
if (session.generatedTitle || session.titleGenerationStarted) return;
|
|
@@ -45649,6 +45690,7 @@ function runSessionTitleGeneration(session, prompt, notify2, fallback) {
|
|
|
45649
45690
|
daemonLog(
|
|
45650
45691
|
generated ? `session ${session.id} generated title: ${generated}` : `session ${session.id} title generation failed; falling back to "${title}"`
|
|
45651
45692
|
);
|
|
45693
|
+
rememberSessionTitle(session);
|
|
45652
45694
|
notify2();
|
|
45653
45695
|
}).catch((error) => {
|
|
45654
45696
|
daemonLog(`session ${session.id} title generation errored: ${error}`);
|
|
@@ -46015,6 +46057,7 @@ function bindCodexSession(session, notify2) {
|
|
|
46015
46057
|
}
|
|
46016
46058
|
session.harnessSessionId = sessionId;
|
|
46017
46059
|
daemonLog(`session ${session.id} bound to codex conversation ${sessionId}`);
|
|
46060
|
+
rememberSessionTitle(session);
|
|
46018
46061
|
notify2();
|
|
46019
46062
|
};
|
|
46020
46063
|
schedule();
|
|
@@ -48152,6 +48195,7 @@ function setSessionTitle(sessions, id, title) {
|
|
|
48152
48195
|
if (!s || !normalised) return false;
|
|
48153
48196
|
s.title = normalised;
|
|
48154
48197
|
daemonLog(`session ${id} renamed: ${normalised}`);
|
|
48198
|
+
rememberSessionTitle(s);
|
|
48155
48199
|
return true;
|
|
48156
48200
|
}
|
|
48157
48201
|
|
|
@@ -48249,6 +48293,48 @@ var VerifyTracker = class {
|
|
|
48249
48293
|
}
|
|
48250
48294
|
};
|
|
48251
48295
|
|
|
48296
|
+
// src/commands/sessions/shared/codex/discoverCodexHistoryEntries.ts
|
|
48297
|
+
async function discoverCodexHistoryEntries() {
|
|
48298
|
+
const paths = await discoverCodexRolloutPaths();
|
|
48299
|
+
const parsed = await Promise.all(
|
|
48300
|
+
paths.map(async (filePath) => {
|
|
48301
|
+
const session = await parseCodexSessionFile(filePath);
|
|
48302
|
+
return session ? { session, filePath } : null;
|
|
48303
|
+
})
|
|
48304
|
+
);
|
|
48305
|
+
return parsed.filter((entry) => entry !== null);
|
|
48306
|
+
}
|
|
48307
|
+
|
|
48308
|
+
// src/commands/sessions/shared/discoverHistoryEntries.ts
|
|
48309
|
+
async function discoverHistoryEntries() {
|
|
48310
|
+
const paths = await discoverSessionJsonlPaths();
|
|
48311
|
+
const entries = [];
|
|
48312
|
+
await Promise.all(
|
|
48313
|
+
paths.map(async ({ path: filePath, origin }) => {
|
|
48314
|
+
const session = await parseSessionFile(filePath, origin);
|
|
48315
|
+
if (session) entries.push({ session, filePath });
|
|
48316
|
+
})
|
|
48317
|
+
);
|
|
48318
|
+
entries.push(...await discoverCodexHistoryEntries());
|
|
48319
|
+
const titles2 = loadSessionTitles();
|
|
48320
|
+
for (const { session } of entries) {
|
|
48321
|
+
const title = titles2[session.sessionId];
|
|
48322
|
+
if (title) session.title = title;
|
|
48323
|
+
}
|
|
48324
|
+
entries.sort(
|
|
48325
|
+
(a, b) => new Date(b.session.timestamp).getTime() - new Date(a.session.timestamp).getTime()
|
|
48326
|
+
);
|
|
48327
|
+
return entries;
|
|
48328
|
+
}
|
|
48329
|
+
|
|
48330
|
+
// src/commands/sessions/shared/discoverSessions.ts
|
|
48331
|
+
async function discoverSessionFiles() {
|
|
48332
|
+
return (await discoverSessionJsonlPaths()).map((p) => p.path);
|
|
48333
|
+
}
|
|
48334
|
+
async function discoverSessions() {
|
|
48335
|
+
return (await discoverHistoryEntries()).map((entry) => entry.session);
|
|
48336
|
+
}
|
|
48337
|
+
|
|
48252
48338
|
// src/commands/sessions/daemon/withRepoGroups.ts
|
|
48253
48339
|
function withRepoGroups(sessions) {
|
|
48254
48340
|
const existence = /* @__PURE__ */ new Map();
|
|
@@ -49394,7 +49480,7 @@ function exitAfterFlush(code) {
|
|
|
49394
49480
|
}
|
|
49395
49481
|
|
|
49396
49482
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
49397
|
-
import { createInterface as
|
|
49483
|
+
import { createInterface as createInterface11 } from "readline";
|
|
49398
49484
|
|
|
49399
49485
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateReply.ts
|
|
49400
49486
|
function autoUpdateReply() {
|
|
@@ -49468,6 +49554,199 @@ var handleHelloRequest = (client, m, d) => {
|
|
|
49468
49554
|
m.replayLocal(client);
|
|
49469
49555
|
};
|
|
49470
49556
|
|
|
49557
|
+
// src/commands/sessions/daemon/historySearch/findTranscriptMatch.ts
|
|
49558
|
+
import * as fs55 from "fs";
|
|
49559
|
+
import * as readline5 from "readline";
|
|
49560
|
+
|
|
49561
|
+
// src/commands/sessions/daemon/historySearch/historySnippet.ts
|
|
49562
|
+
var CONTEXT_CHARS = 60;
|
|
49563
|
+
function collapse(text18) {
|
|
49564
|
+
return text18.replace(/\s+/g, " ");
|
|
49565
|
+
}
|
|
49566
|
+
function historySnippet(text18, index2, length) {
|
|
49567
|
+
const start2 = Math.max(0, index2 - CONTEXT_CHARS);
|
|
49568
|
+
const end = Math.min(text18.length, index2 + length + CONTEXT_CHARS);
|
|
49569
|
+
const before = collapse(text18.slice(start2, index2)).trimStart();
|
|
49570
|
+
const after = collapse(text18.slice(index2 + length, end)).trimEnd();
|
|
49571
|
+
return {
|
|
49572
|
+
before: start2 > 0 ? `\u2026${before}` : before,
|
|
49573
|
+
match: collapse(text18.slice(index2, index2 + length)),
|
|
49574
|
+
after: end < text18.length ? `${after}\u2026` : after
|
|
49575
|
+
};
|
|
49576
|
+
}
|
|
49577
|
+
|
|
49578
|
+
// src/commands/sessions/shared/codex/codexToolTarget.ts
|
|
49579
|
+
function codexToolTarget(payload) {
|
|
49580
|
+
const args = parseArguments(payload.arguments);
|
|
49581
|
+
const target = args ? commandText(args) || toolTarget(args) || rolloutString(args.input) : rolloutString(payload.input);
|
|
49582
|
+
return condense(target);
|
|
49583
|
+
}
|
|
49584
|
+
function commandText(args) {
|
|
49585
|
+
const command = args.cmd ?? args.command;
|
|
49586
|
+
if (Array.isArray(command)) return command.map(rolloutString).join(" ");
|
|
49587
|
+
return rolloutString(command);
|
|
49588
|
+
}
|
|
49589
|
+
function parseArguments(value) {
|
|
49590
|
+
if (typeof value !== "string") return null;
|
|
49591
|
+
try {
|
|
49592
|
+
const parsed = JSON.parse(value);
|
|
49593
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
49594
|
+
} catch {
|
|
49595
|
+
return null;
|
|
49596
|
+
}
|
|
49597
|
+
}
|
|
49598
|
+
function condense(value) {
|
|
49599
|
+
return value.replace(/\s+/g, " ").trim().slice(0, 120);
|
|
49600
|
+
}
|
|
49601
|
+
|
|
49602
|
+
// src/commands/sessions/shared/codex/parseCodexTranscriptLines.ts
|
|
49603
|
+
function parseCodexTranscriptLines(lines2) {
|
|
49604
|
+
const messages = [];
|
|
49605
|
+
for (const line of lines2) {
|
|
49606
|
+
const entry = line.trim() ? parseRolloutEntry(line) : null;
|
|
49607
|
+
if (entry) messages.push(...rolloutMessages(entry));
|
|
49608
|
+
}
|
|
49609
|
+
return messages;
|
|
49610
|
+
}
|
|
49611
|
+
function rolloutMessages(entry) {
|
|
49612
|
+
const payload = rolloutPayload(entry);
|
|
49613
|
+
if (entry.type === "event_msg") return chatMessages(payload);
|
|
49614
|
+
if (entry.type === "response_item") return toolMessages(payload);
|
|
49615
|
+
return [];
|
|
49616
|
+
}
|
|
49617
|
+
function chatMessages(payload) {
|
|
49618
|
+
if (payload.type === "user_message")
|
|
49619
|
+
return text17("user", rolloutString(payload.message));
|
|
49620
|
+
if (payload.type === "agent_message")
|
|
49621
|
+
return text17("assistant", rolloutString(payload.message));
|
|
49622
|
+
return [];
|
|
49623
|
+
}
|
|
49624
|
+
function toolMessages(payload) {
|
|
49625
|
+
if (payload.type !== "function_call" && payload.type !== "custom_tool_call")
|
|
49626
|
+
return [];
|
|
49627
|
+
return [
|
|
49628
|
+
{
|
|
49629
|
+
role: "tool",
|
|
49630
|
+
tool: rolloutString(payload.name) || "tool",
|
|
49631
|
+
target: codexToolTarget(payload)
|
|
49632
|
+
}
|
|
49633
|
+
];
|
|
49634
|
+
}
|
|
49635
|
+
function text17(role, value) {
|
|
49636
|
+
const trimmed = value.trim();
|
|
49637
|
+
return trimmed ? [{ role, text: trimmed }] : [];
|
|
49638
|
+
}
|
|
49639
|
+
|
|
49640
|
+
// src/commands/sessions/daemon/historySearch/transcriptLineTexts.ts
|
|
49641
|
+
function transcriptLineTexts(line, harness) {
|
|
49642
|
+
const messages = harness === "codex" ? parseCodexTranscriptLines([line]) : claudeMessages(line);
|
|
49643
|
+
return messages.flatMap((m) => m.role === "tool" ? [] : [m.text]);
|
|
49644
|
+
}
|
|
49645
|
+
function claudeMessages(line) {
|
|
49646
|
+
try {
|
|
49647
|
+
const entry = JSON.parse(line);
|
|
49648
|
+
return entry && typeof entry === "object" ? entryMessages(entry) : [];
|
|
49649
|
+
} catch {
|
|
49650
|
+
return [];
|
|
49651
|
+
}
|
|
49652
|
+
}
|
|
49653
|
+
|
|
49654
|
+
// src/commands/sessions/daemon/historySearch/findTranscriptMatch.ts
|
|
49655
|
+
function escapeRegExp(text18) {
|
|
49656
|
+
return text18.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
|
49657
|
+
}
|
|
49658
|
+
function encodesVerbatimInJson(query) {
|
|
49659
|
+
return JSON.stringify(query) === `"${query}"`;
|
|
49660
|
+
}
|
|
49661
|
+
function rawLinePrefilter(query) {
|
|
49662
|
+
if (!encodesVerbatimInJson(query)) return () => true;
|
|
49663
|
+
const lower = query.toLowerCase();
|
|
49664
|
+
return (line) => line.toLowerCase().includes(lower);
|
|
49665
|
+
}
|
|
49666
|
+
function matchTexts(texts, pattern2) {
|
|
49667
|
+
for (const text18 of texts) {
|
|
49668
|
+
const found = pattern2.exec(text18);
|
|
49669
|
+
if (found) return historySnippet(text18, found.index, found[0].length);
|
|
49670
|
+
}
|
|
49671
|
+
return null;
|
|
49672
|
+
}
|
|
49673
|
+
function queryPattern(query) {
|
|
49674
|
+
return new RegExp(escapeRegExp(query), "i");
|
|
49675
|
+
}
|
|
49676
|
+
async function findTranscriptMatch(filePath, harness, query) {
|
|
49677
|
+
const pattern2 = queryPattern(query);
|
|
49678
|
+
const mayMatch = rawLinePrefilter(query);
|
|
49679
|
+
const stream = fs55.createReadStream(filePath, { encoding: "utf8" });
|
|
49680
|
+
const reader = readline5.createInterface({
|
|
49681
|
+
input: stream,
|
|
49682
|
+
crlfDelay: Infinity
|
|
49683
|
+
});
|
|
49684
|
+
try {
|
|
49685
|
+
for await (const line of reader) {
|
|
49686
|
+
if (!line || !mayMatch(line)) continue;
|
|
49687
|
+
const snippet = matchTexts(transcriptLineTexts(line, harness), pattern2);
|
|
49688
|
+
if (snippet) return snippet;
|
|
49689
|
+
}
|
|
49690
|
+
return null;
|
|
49691
|
+
} catch {
|
|
49692
|
+
return null;
|
|
49693
|
+
} finally {
|
|
49694
|
+
reader.close();
|
|
49695
|
+
stream.destroy();
|
|
49696
|
+
}
|
|
49697
|
+
}
|
|
49698
|
+
function findTitleMatch(title, query) {
|
|
49699
|
+
return title ? matchTexts([title], queryPattern(query)) : null;
|
|
49700
|
+
}
|
|
49701
|
+
|
|
49702
|
+
// src/commands/sessions/daemon/historySearch/searchHistory.ts
|
|
49703
|
+
var BATCH_SIZE = 16;
|
|
49704
|
+
var MAX_RESULTS2 = 100;
|
|
49705
|
+
function inRepo(cwd) {
|
|
49706
|
+
const selectedKey = repoGroupForCwd(cwd)?.origin || cwd;
|
|
49707
|
+
return ({ session }) => {
|
|
49708
|
+
const group = repoGroupForCwd(session.cwd);
|
|
49709
|
+
const key = group?.origin || session.cwd;
|
|
49710
|
+
return key === selectedKey || (group?.clone || session.cwd) === cwd;
|
|
49711
|
+
};
|
|
49712
|
+
}
|
|
49713
|
+
async function matchBatch(batch, query) {
|
|
49714
|
+
const matches = await Promise.all(
|
|
49715
|
+
batch.map(async ({ session, filePath }) => {
|
|
49716
|
+
const snippet = findTitleMatch(session.title, query) ?? await findTranscriptMatch(filePath, session.harness, query);
|
|
49717
|
+
return snippet ? { ...session, snippet } : null;
|
|
49718
|
+
})
|
|
49719
|
+
);
|
|
49720
|
+
return matches.filter((hit) => hit !== null);
|
|
49721
|
+
}
|
|
49722
|
+
async function searchHistory(cwd, query) {
|
|
49723
|
+
const candidates = (await discoverHistoryEntries()).filter(inRepo(cwd));
|
|
49724
|
+
const hits = [];
|
|
49725
|
+
for (let i = 0; i < candidates.length && hits.length < MAX_RESULTS2; i += BATCH_SIZE)
|
|
49726
|
+
hits.push(
|
|
49727
|
+
...await matchBatch(candidates.slice(i, i + BATCH_SIZE), query)
|
|
49728
|
+
);
|
|
49729
|
+
return withRepoGroups(hits.slice(0, MAX_RESULTS2));
|
|
49730
|
+
}
|
|
49731
|
+
|
|
49732
|
+
// src/commands/sessions/daemon/historySearch/handleSearchHistory.ts
|
|
49733
|
+
async function handleSearchHistory(client, data) {
|
|
49734
|
+
const cwd = typeof data.cwd === "string" ? data.cwd : "";
|
|
49735
|
+
const query = typeof data.query === "string" ? data.query.trim() : "";
|
|
49736
|
+
const started = Date.now();
|
|
49737
|
+
try {
|
|
49738
|
+
const sessions = cwd && query ? await searchHistory(cwd, query) : [];
|
|
49739
|
+
daemonLog(
|
|
49740
|
+
`history search cwd=${cwd} chars=${query.length}: ${sessions.length} match(es) in ${Date.now() - started}ms`
|
|
49741
|
+
);
|
|
49742
|
+
sendTo(client, { type: "history-search", sessions });
|
|
49743
|
+
} catch (error) {
|
|
49744
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
49745
|
+
daemonLog(`history search cwd=${cwd} failed: ${message3}`);
|
|
49746
|
+
sendTo(client, { type: "history-search", error: message3 });
|
|
49747
|
+
}
|
|
49748
|
+
}
|
|
49749
|
+
|
|
49471
49750
|
// src/commands/sessions/daemon/creator.ts
|
|
49472
49751
|
function creator(isNew, spawn12) {
|
|
49473
49752
|
return (client, m, d) => {
|
|
@@ -49482,7 +49761,7 @@ function creator(isNew, spawn12) {
|
|
|
49482
49761
|
}
|
|
49483
49762
|
|
|
49484
49763
|
// src/commands/sessions/shared/codex/codexRolloutUsage.ts
|
|
49485
|
-
import * as
|
|
49764
|
+
import * as fs56 from "fs";
|
|
49486
49765
|
|
|
49487
49766
|
// src/commands/sessions/shared/codex/applyTokenInfo.ts
|
|
49488
49767
|
function applyTokenInfo(usage, byId, conversationId, rawInfo) {
|
|
@@ -49545,7 +49824,7 @@ function codexRolloutUsage(lines2) {
|
|
|
49545
49824
|
return usage;
|
|
49546
49825
|
}
|
|
49547
49826
|
async function readCodexRolloutUsage(rolloutPath) {
|
|
49548
|
-
const content = await
|
|
49827
|
+
const content = await fs56.promises.readFile(rolloutPath, "utf8");
|
|
49549
49828
|
return codexRolloutUsage(content.split("\n"));
|
|
49550
49829
|
}
|
|
49551
49830
|
function sessionMetaId(entry) {
|
|
@@ -49693,7 +49972,7 @@ function handleSetStatus(client, m, d) {
|
|
|
49693
49972
|
}
|
|
49694
49973
|
|
|
49695
49974
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
49696
|
-
import * as
|
|
49975
|
+
import * as fs57 from "fs";
|
|
49697
49976
|
|
|
49698
49977
|
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
49699
49978
|
import * as path108 from "path";
|
|
@@ -49704,68 +49983,6 @@ async function findCodexRolloutPath(sessionId) {
|
|
|
49704
49983
|
return paths.find((file) => path108.basename(file).endsWith(suffix)) ?? null;
|
|
49705
49984
|
}
|
|
49706
49985
|
|
|
49707
|
-
// src/commands/sessions/shared/codex/codexToolTarget.ts
|
|
49708
|
-
function codexToolTarget(payload) {
|
|
49709
|
-
const args = parseArguments(payload.arguments);
|
|
49710
|
-
const target = args ? commandText(args) || toolTarget(args) || rolloutString(args.input) : rolloutString(payload.input);
|
|
49711
|
-
return condense(target);
|
|
49712
|
-
}
|
|
49713
|
-
function commandText(args) {
|
|
49714
|
-
const command = args.cmd ?? args.command;
|
|
49715
|
-
if (Array.isArray(command)) return command.map(rolloutString).join(" ");
|
|
49716
|
-
return rolloutString(command);
|
|
49717
|
-
}
|
|
49718
|
-
function parseArguments(value) {
|
|
49719
|
-
if (typeof value !== "string") return null;
|
|
49720
|
-
try {
|
|
49721
|
-
const parsed = JSON.parse(value);
|
|
49722
|
-
return parsed && typeof parsed === "object" ? parsed : null;
|
|
49723
|
-
} catch {
|
|
49724
|
-
return null;
|
|
49725
|
-
}
|
|
49726
|
-
}
|
|
49727
|
-
function condense(value) {
|
|
49728
|
-
return value.replace(/\s+/g, " ").trim().slice(0, 120);
|
|
49729
|
-
}
|
|
49730
|
-
|
|
49731
|
-
// src/commands/sessions/shared/codex/parseCodexTranscriptLines.ts
|
|
49732
|
-
function parseCodexTranscriptLines(lines2) {
|
|
49733
|
-
const messages = [];
|
|
49734
|
-
for (const line of lines2) {
|
|
49735
|
-
const entry = line.trim() ? parseRolloutEntry(line) : null;
|
|
49736
|
-
if (entry) messages.push(...rolloutMessages(entry));
|
|
49737
|
-
}
|
|
49738
|
-
return messages;
|
|
49739
|
-
}
|
|
49740
|
-
function rolloutMessages(entry) {
|
|
49741
|
-
const payload = rolloutPayload(entry);
|
|
49742
|
-
if (entry.type === "event_msg") return chatMessages(payload);
|
|
49743
|
-
if (entry.type === "response_item") return toolMessages(payload);
|
|
49744
|
-
return [];
|
|
49745
|
-
}
|
|
49746
|
-
function chatMessages(payload) {
|
|
49747
|
-
if (payload.type === "user_message")
|
|
49748
|
-
return text17("user", rolloutString(payload.message));
|
|
49749
|
-
if (payload.type === "agent_message")
|
|
49750
|
-
return text17("assistant", rolloutString(payload.message));
|
|
49751
|
-
return [];
|
|
49752
|
-
}
|
|
49753
|
-
function toolMessages(payload) {
|
|
49754
|
-
if (payload.type !== "function_call" && payload.type !== "custom_tool_call")
|
|
49755
|
-
return [];
|
|
49756
|
-
return [
|
|
49757
|
-
{
|
|
49758
|
-
role: "tool",
|
|
49759
|
-
tool: rolloutString(payload.name) || "tool",
|
|
49760
|
-
target: codexToolTarget(payload)
|
|
49761
|
-
}
|
|
49762
|
-
];
|
|
49763
|
-
}
|
|
49764
|
-
function text17(role, value) {
|
|
49765
|
-
const trimmed = value.trim();
|
|
49766
|
-
return trimmed ? [{ role, text: trimmed }] : [];
|
|
49767
|
-
}
|
|
49768
|
-
|
|
49769
49986
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
49770
49987
|
async function parseTranscript(sessionId) {
|
|
49771
49988
|
const filePath = await findSessionJsonlPath(sessionId);
|
|
@@ -49776,7 +49993,7 @@ async function parseTranscript(sessionId) {
|
|
|
49776
49993
|
}
|
|
49777
49994
|
async function readMessages(filePath, parse5) {
|
|
49778
49995
|
try {
|
|
49779
|
-
const raw = await
|
|
49996
|
+
const raw = await fs57.promises.readFile(filePath, "utf8");
|
|
49780
49997
|
return parse5(raw.split("\n"));
|
|
49781
49998
|
} catch {
|
|
49782
49999
|
return [];
|
|
@@ -50011,6 +50228,7 @@ var messageHandlers = {
|
|
|
50011
50228
|
nodes: (client, m) => m.links.sendNodes(client),
|
|
50012
50229
|
"auto-update": (client) => sendTo(client, autoUpdateReply()),
|
|
50013
50230
|
"auto-update-control": handleAutoUpdateControl,
|
|
50231
|
+
"search-history": (client, _m, d) => handleSearchHistory(client, d),
|
|
50014
50232
|
"reload-links": (client, m) => {
|
|
50015
50233
|
daemonLog("reload-links received");
|
|
50016
50234
|
m.links.reload();
|
|
@@ -50100,7 +50318,7 @@ function handleConnection(socket, manager) {
|
|
|
50100
50318
|
};
|
|
50101
50319
|
manager.addClient(client);
|
|
50102
50320
|
manager.clients.greet(client);
|
|
50103
|
-
const lines2 =
|
|
50321
|
+
const lines2 = createInterface11({ input: socket });
|
|
50104
50322
|
lines2.on("error", () => {
|
|
50105
50323
|
});
|
|
50106
50324
|
lines2.on("line", (line) => {
|
|
@@ -50720,14 +50938,14 @@ function registerNodes(sessions) {
|
|
|
50720
50938
|
}
|
|
50721
50939
|
|
|
50722
50940
|
// src/commands/sessions/daemon/requestSessionOutput.ts
|
|
50723
|
-
import { createInterface as
|
|
50941
|
+
import { createInterface as createInterface12 } from "readline";
|
|
50724
50942
|
var OUTPUT_TIMEOUT_MS = 5e3;
|
|
50725
50943
|
async function requestSessionOutput(target) {
|
|
50726
50944
|
const socket = await connectToDaemon().catch(() => {
|
|
50727
50945
|
throw new Error("No sessions daemon is running");
|
|
50728
50946
|
});
|
|
50729
50947
|
try {
|
|
50730
|
-
const lines2 =
|
|
50948
|
+
const lines2 = createInterface12({ input: socket });
|
|
50731
50949
|
lines2.on("error", () => {
|
|
50732
50950
|
});
|
|
50733
50951
|
const reply2 = readDaemonMessage(
|
|
@@ -50829,17 +51047,17 @@ async function renameSession(title) {
|
|
|
50829
51047
|
}
|
|
50830
51048
|
|
|
50831
51049
|
// src/commands/sessions/summarise.ts
|
|
50832
|
-
import * as
|
|
51050
|
+
import * as fs59 from "fs";
|
|
50833
51051
|
import chalk268 from "chalk";
|
|
50834
51052
|
|
|
50835
51053
|
// src/commands/sessions/summarise/shared.ts
|
|
50836
|
-
import * as
|
|
51054
|
+
import * as fs58 from "fs";
|
|
50837
51055
|
function writeSummary(jsonlPath2, summary) {
|
|
50838
|
-
|
|
51056
|
+
fs58.writeFileSync(summaryPathFor(jsonlPath2), `${summary.trim()}
|
|
50839
51057
|
`, "utf8");
|
|
50840
51058
|
}
|
|
50841
51059
|
function hasSummary(jsonlPath2) {
|
|
50842
|
-
return
|
|
51060
|
+
return fs58.existsSync(summaryPathFor(jsonlPath2));
|
|
50843
51061
|
}
|
|
50844
51062
|
function summaryPathFor(jsonlPath2) {
|
|
50845
51063
|
return jsonlPath2.replace(/\.jsonl$/, ".summary");
|
|
@@ -50911,7 +51129,7 @@ function selectCandidates(files, options2) {
|
|
|
50911
51129
|
const candidates = options2.force ? files : files.filter((f) => !hasSummary(f));
|
|
50912
51130
|
candidates.sort((a, b) => {
|
|
50913
51131
|
try {
|
|
50914
|
-
return
|
|
51132
|
+
return fs59.statSync(b).mtimeMs - fs59.statSync(a).mtimeMs;
|
|
50915
51133
|
} catch {
|
|
50916
51134
|
return 0;
|
|
50917
51135
|
}
|