@staff0rd/assist 0.285.0 → 0.286.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 +36 -36
- package/dist/index.js +56 -34
- 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.286.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -18878,23 +18878,20 @@ function matchMarker(text3, tag) {
|
|
|
18878
18878
|
}
|
|
18879
18879
|
|
|
18880
18880
|
// src/commands/sessions/shared/parseSessionFile.ts
|
|
18881
|
-
async function parseSessionFile(filePath) {
|
|
18881
|
+
async function parseSessionFile(filePath, origin = "wsl") {
|
|
18882
18882
|
let handle;
|
|
18883
18883
|
try {
|
|
18884
18884
|
handle = await fs25.promises.open(filePath, "r");
|
|
18885
|
-
const
|
|
18886
|
-
const { bytesRead } = await handle.read(buf, 0, buf.length, 0);
|
|
18887
|
-
const lines = buf.toString("utf8", 0, bytesRead).split("\n").filter(Boolean);
|
|
18888
|
-
const meta = extractSessionMeta(lines);
|
|
18885
|
+
const meta = extractSessionMeta(await readHeadLines(handle));
|
|
18889
18886
|
if (!meta.sessionId) return null;
|
|
18890
18887
|
const timestamp = meta.timestamp || (await fs25.promises.stat(filePath)).mtime.toISOString();
|
|
18891
|
-
const project = meta.cwd ? path46.basename(meta.cwd) : dirNameToProject(filePath);
|
|
18892
18888
|
return {
|
|
18893
18889
|
sessionId: meta.sessionId,
|
|
18894
18890
|
name: meta.name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
18895
|
-
project,
|
|
18891
|
+
project: deriveProject(meta.cwd, filePath, origin),
|
|
18896
18892
|
cwd: meta.cwd,
|
|
18897
18893
|
timestamp,
|
|
18894
|
+
origin,
|
|
18898
18895
|
...deriveHistoryFields(meta.commandName, meta.commandArgs, meta.name)
|
|
18899
18896
|
};
|
|
18900
18897
|
} catch {
|
|
@@ -18903,6 +18900,15 @@ async function parseSessionFile(filePath) {
|
|
|
18903
18900
|
await handle?.close();
|
|
18904
18901
|
}
|
|
18905
18902
|
}
|
|
18903
|
+
async function readHeadLines(handle) {
|
|
18904
|
+
const buf = Buffer.alloc(16384);
|
|
18905
|
+
const { bytesRead } = await handle.read(buf, 0, buf.length, 0);
|
|
18906
|
+
return buf.toString("utf8", 0, bytesRead).split("\n").filter(Boolean);
|
|
18907
|
+
}
|
|
18908
|
+
function deriveProject(cwd, filePath, origin) {
|
|
18909
|
+
if (!cwd) return dirNameToProject(filePath);
|
|
18910
|
+
return origin === "windows" ? path46.win32.basename(cwd) : path46.basename(cwd);
|
|
18911
|
+
}
|
|
18906
18912
|
function dirNameToProject(filePath) {
|
|
18907
18913
|
const dirName = path46.basename(path46.dirname(filePath));
|
|
18908
18914
|
const parts = dirName.split("--");
|
|
@@ -18910,38 +18916,52 @@ function dirNameToProject(filePath) {
|
|
|
18910
18916
|
}
|
|
18911
18917
|
|
|
18912
18918
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
18919
|
+
function sessionRoots() {
|
|
18920
|
+
const roots = [
|
|
18921
|
+
{ dir: path47.join(os.homedir(), ".claude", "projects"), origin: "wsl" }
|
|
18922
|
+
];
|
|
18923
|
+
const windowsRoot = loadConfig().sessions?.windowsProjectsRoot;
|
|
18924
|
+
if (windowsRoot) roots.push({ dir: windowsRoot, origin: "windows" });
|
|
18925
|
+
return roots;
|
|
18926
|
+
}
|
|
18913
18927
|
async function discoverSessionJsonlPaths() {
|
|
18914
|
-
const
|
|
18915
|
-
let projectDirs;
|
|
18916
|
-
try {
|
|
18917
|
-
projectDirs = await fs26.promises.readdir(projectsDir);
|
|
18918
|
-
} catch {
|
|
18919
|
-
return [];
|
|
18920
|
-
}
|
|
18921
|
-
const paths = [];
|
|
18928
|
+
const results = [];
|
|
18922
18929
|
await Promise.all(
|
|
18923
|
-
|
|
18924
|
-
|
|
18925
|
-
let entries;
|
|
18930
|
+
sessionRoots().map(async ({ dir, origin }) => {
|
|
18931
|
+
let projectDirs;
|
|
18926
18932
|
try {
|
|
18927
|
-
|
|
18933
|
+
projectDirs = await fs26.promises.readdir(dir);
|
|
18928
18934
|
} catch {
|
|
18929
18935
|
return;
|
|
18930
18936
|
}
|
|
18931
|
-
|
|
18932
|
-
|
|
18933
|
-
|
|
18934
|
-
|
|
18937
|
+
await Promise.all(
|
|
18938
|
+
projectDirs.map(async (dirName) => {
|
|
18939
|
+
const dirPath = path47.join(dir, dirName);
|
|
18940
|
+
let entries;
|
|
18941
|
+
try {
|
|
18942
|
+
entries = await fs26.promises.readdir(dirPath);
|
|
18943
|
+
} catch {
|
|
18944
|
+
return;
|
|
18945
|
+
}
|
|
18946
|
+
for (const file of entries) {
|
|
18947
|
+
if (file.endsWith(".jsonl"))
|
|
18948
|
+
results.push({ path: path47.join(dirPath, file), origin });
|
|
18949
|
+
}
|
|
18950
|
+
})
|
|
18951
|
+
);
|
|
18935
18952
|
})
|
|
18936
18953
|
);
|
|
18937
|
-
return
|
|
18954
|
+
return results;
|
|
18955
|
+
}
|
|
18956
|
+
async function discoverSessionFiles() {
|
|
18957
|
+
return (await discoverSessionJsonlPaths()).map((p) => p.path);
|
|
18938
18958
|
}
|
|
18939
18959
|
async function discoverSessions() {
|
|
18940
18960
|
const paths = await discoverSessionJsonlPaths();
|
|
18941
18961
|
const sessions = [];
|
|
18942
18962
|
await Promise.all(
|
|
18943
|
-
paths.map(async (filePath) => {
|
|
18944
|
-
const session = await parseSessionFile(filePath);
|
|
18963
|
+
paths.map(async ({ path: filePath, origin }) => {
|
|
18964
|
+
const session = await parseSessionFile(filePath, origin);
|
|
18945
18965
|
if (session) sessions.push(session);
|
|
18946
18966
|
})
|
|
18947
18967
|
);
|
|
@@ -18967,10 +18987,10 @@ async function watchClaudeSessionId(options2) {
|
|
|
18967
18987
|
async function findLatestSessionId(options2) {
|
|
18968
18988
|
const paths = await discoverSessionJsonlPaths();
|
|
18969
18989
|
let latest = null;
|
|
18970
|
-
for (const filePath of paths) {
|
|
18990
|
+
for (const { path: filePath, origin } of paths) {
|
|
18971
18991
|
const createdMs = await createdSince(filePath, options2.sinceMs);
|
|
18972
18992
|
if (createdMs === null) continue;
|
|
18973
|
-
const meta = await parseSessionFile(filePath);
|
|
18993
|
+
const meta = await parseSessionFile(filePath, origin);
|
|
18974
18994
|
if (!meta?.cwd || options2.isClaimed(meta.sessionId)) continue;
|
|
18975
18995
|
if (path48.resolve(meta.cwd) !== path48.resolve(options2.cwd)) continue;
|
|
18976
18996
|
if (!latest || createdMs > latest.createdMs)
|
|
@@ -19209,11 +19229,13 @@ function cleanUserText(value) {
|
|
|
19209
19229
|
import * as path49 from "path";
|
|
19210
19230
|
async function findSessionJsonlPath(sessionId) {
|
|
19211
19231
|
const paths = await discoverSessionJsonlPaths();
|
|
19212
|
-
const direct = paths.find(
|
|
19213
|
-
|
|
19232
|
+
const direct = paths.find(
|
|
19233
|
+
(p) => path49.basename(p.path, ".jsonl") === sessionId
|
|
19234
|
+
);
|
|
19235
|
+
if (direct) return direct.path;
|
|
19214
19236
|
for (const p of paths) {
|
|
19215
|
-
const meta = await parseSessionFile(p);
|
|
19216
|
-
if (meta?.sessionId === sessionId) return p;
|
|
19237
|
+
const meta = await parseSessionFile(p.path, p.origin);
|
|
19238
|
+
if (meta?.sessionId === sessionId) return p.path;
|
|
19217
19239
|
}
|
|
19218
19240
|
return null;
|
|
19219
19241
|
}
|
|
@@ -19611,7 +19633,7 @@ ${firstMessage}`);
|
|
|
19611
19633
|
|
|
19612
19634
|
// src/commands/sessions/summarise/index.ts
|
|
19613
19635
|
async function summarise4(options2) {
|
|
19614
|
-
const files = await
|
|
19636
|
+
const files = await discoverSessionFiles();
|
|
19615
19637
|
if (files.length === 0) {
|
|
19616
19638
|
console.log(chalk161.yellow("No sessions found."));
|
|
19617
19639
|
return;
|