buildpartner 0.4.2 → 0.8.0-dev.20260430072343
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/bin/cli.js +11 -22
- package/dist/bin/cli.js.map +1 -1
- package/dist/src/api-client.d.ts +1 -1
- package/dist/src/api-client.js +9 -1
- package/dist/src/api-client.js.map +1 -1
- package/dist/src/commands/reset.js +1 -1
- package/dist/src/commands/reset.js.map +1 -1
- package/dist/src/mcp/server.d.ts +1 -5
- package/dist/src/mcp/server.js +20 -75
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/store/local-store.d.ts +13 -2
- package/dist/src/store/local-store.js +21 -0
- package/dist/src/store/local-store.js.map +1 -1
- package/package.json +2 -6
- package/dist/src/classifiers/activity-classifier.d.ts +0 -12
- package/dist/src/classifiers/activity-classifier.js +0 -300
- package/dist/src/classifiers/activity-classifier.js.map +0 -1
- package/dist/src/classifiers/path-detector.d.ts +0 -33
- package/dist/src/classifiers/path-detector.js +0 -98
- package/dist/src/classifiers/path-detector.js.map +0 -1
- package/dist/src/commands/log-session.d.ts +0 -7
- package/dist/src/commands/log-session.js +0 -23
- package/dist/src/commands/log-session.js.map +0 -1
- package/dist/src/commands/sync.d.ts +0 -6
- package/dist/src/commands/sync.js +0 -36
- package/dist/src/commands/sync.js.map +0 -1
- package/dist/src/installer/hook-installer.d.ts +0 -19
- package/dist/src/installer/hook-installer.js +0 -114
- package/dist/src/installer/hook-installer.js.map +0 -1
- package/dist/src/installer/mcp-installer.d.ts +0 -9
- package/dist/src/installer/mcp-installer.js +0 -80
- package/dist/src/installer/mcp-installer.js.map +0 -1
- package/dist/src/installer/skill-installer.d.ts +0 -5
- package/dist/src/installer/skill-installer.js +0 -55
- package/dist/src/installer/skill-installer.js.map +0 -1
- package/dist/src/installer/skill-sync.d.ts +0 -10
- package/dist/src/installer/skill-sync.js +0 -80
- package/dist/src/installer/skill-sync.js.map +0 -1
- package/dist/src/mcp/catch-up.d.ts +0 -6
- package/dist/src/mcp/catch-up.js +0 -28
- package/dist/src/mcp/catch-up.js.map +0 -1
- package/dist/src/mcp/tools/ai-profile.d.ts +0 -88
- package/dist/src/mcp/tools/ai-profile.js +0 -123
- package/dist/src/mcp/tools/ai-profile.js.map +0 -1
- package/dist/src/mcp/tools/classify-session.d.ts +0 -31
- package/dist/src/mcp/tools/classify-session.js +0 -34
- package/dist/src/mcp/tools/classify-session.js.map +0 -1
- package/dist/src/mcp/tools/get-knowledge.d.ts +0 -25
- package/dist/src/mcp/tools/get-knowledge.js +0 -31
- package/dist/src/mcp/tools/get-knowledge.js.map +0 -1
- package/dist/src/mcp/tools/get-profile.d.ts +0 -1
- package/dist/src/mcp/tools/get-profile.js +0 -14
- package/dist/src/mcp/tools/get-profile.js.map +0 -1
- package/dist/src/mcp/tools/get-stats.d.ts +0 -32
- package/dist/src/mcp/tools/get-stats.js +0 -45
- package/dist/src/mcp/tools/get-stats.js.map +0 -1
- package/dist/src/mcp/tools/get-suggestions.d.ts +0 -7
- package/dist/src/mcp/tools/get-suggestions.js +0 -65
- package/dist/src/mcp/tools/get-suggestions.js.map +0 -1
- package/dist/src/mcp/tools/get-training.d.ts +0 -48
- package/dist/src/mcp/tools/get-training.js +0 -102
- package/dist/src/mcp/tools/get-training.js.map +0 -1
- package/dist/src/mcp/tools/log-highlight.d.ts +0 -24
- package/dist/src/mcp/tools/log-highlight.js +0 -25
- package/dist/src/mcp/tools/log-highlight.js.map +0 -1
- package/dist/src/mcp/tools/quest.d.ts +0 -4
- package/dist/src/mcp/tools/quest.js +0 -8
- package/dist/src/mcp/tools/quest.js.map +0 -1
- package/dist/src/mcp/tools/web-search.d.ts +0 -15
- package/dist/src/mcp/tools/web-search.js +0 -17
- package/dist/src/mcp/tools/web-search.js.map +0 -1
- package/dist/src/readers/extract-signals.d.ts +0 -23
- package/dist/src/readers/extract-signals.js +0 -50
- package/dist/src/readers/extract-signals.js.map +0 -1
- package/dist/src/readers/history-reader.d.ts +0 -28
- package/dist/src/readers/history-reader.js +0 -83
- package/dist/src/readers/history-reader.js.map +0 -1
- package/dist/src/readers/session-reader.d.ts +0 -75
- package/dist/src/readers/session-reader.js +0 -191
- package/dist/src/readers/session-reader.js.map +0 -1
- package/dist/src/readers/session-sync.d.ts +0 -24
- package/dist/src/readers/session-sync.js +0 -114
- package/dist/src/readers/session-sync.js.map +0 -1
- package/dist/src/readers/stats-reader.d.ts +0 -38
- package/dist/src/readers/stats-reader.js +0 -125
- package/dist/src/readers/stats-reader.js.map +0 -1
- package/skills/bp-claude-coach/SKILL.md +0 -314
- package/skills/bp-enhance-claude-md/SKILL.md +0 -62
- package/skills/bp-expert-advice/SKILL.md +0 -62
- package/skills/bp-flex-socials/SKILL.md +0 -54
- package/skills/bp-full-audit/SKILL.md +0 -145
- package/skills/bp-generate-personalized-training-data/SKILL.md +0 -145
- package/skills/bp-improve-skill/SKILL.md +0 -115
- package/skills/bp-interview/SKILL.md +0 -64
- package/skills/bp-interview-me/SKILL.md +0 -120
- package/skills/bp-life-story/SKILL.md +0 -68
- package/skills/bp-log-experience/SKILL.md +0 -72
- package/skills/bp-open-dashboard/SKILL.md +0 -31
- package/skills/bp-quest-status/SKILL.md +0 -52
- package/skills/bp-recap-week/SKILL.md +0 -53
- package/skills/bp-setup-coach/SKILL.md +0 -64
- package/skills/bp-shorts-ideation/SKILL.md +0 -108
- package/skills/bp-shorts-script/SKILL.md +0 -126
- package/skills/bp-youtube-ideation/SKILL.md +0 -99
- package/skills/bp-youtube-script/SKILL.md +0 -149
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts classification signals from a parsed session.
|
|
3
|
-
* This is pure data extraction - no scoring or classification.
|
|
4
|
-
* The server handles all classification logic.
|
|
5
|
-
*/
|
|
6
|
-
export function extractSignals(parsed) {
|
|
7
|
-
const toolCounts = {};
|
|
8
|
-
const writeEditPaths = [];
|
|
9
|
-
const bashCommands = [];
|
|
10
|
-
const mcpServers = new Set();
|
|
11
|
-
const skills = [];
|
|
12
|
-
for (const tc of parsed.toolCalls) {
|
|
13
|
-
toolCounts[tc.name] = (toolCounts[tc.name] || 0) + 1;
|
|
14
|
-
if ((tc.name === "Write" || tc.name === "Edit") && tc.input.file_path) {
|
|
15
|
-
writeEditPaths.push(tc.input.file_path);
|
|
16
|
-
}
|
|
17
|
-
if (tc.name === "Bash" && tc.input.command) {
|
|
18
|
-
bashCommands.push(tc.input.command);
|
|
19
|
-
}
|
|
20
|
-
if (tc.name.startsWith("mcp__")) {
|
|
21
|
-
mcpServers.add(tc.name.split("__")[1] || "");
|
|
22
|
-
}
|
|
23
|
-
if (tc.name === "Skill" && tc.input.skill) {
|
|
24
|
-
skills.push(tc.input.skill);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
let durationMinutes = 0;
|
|
28
|
-
if (parsed.startTime && parsed.endTime) {
|
|
29
|
-
durationMinutes = Math.round((new Date(parsed.endTime).getTime() - new Date(parsed.startTime).getTime()) / 60000);
|
|
30
|
-
}
|
|
31
|
-
const estimatedTokens = parsed.toolCalls.length * 1500 + parsed.userPromptCount * 2000;
|
|
32
|
-
const projectName = parsed.projectPath.split("/").filter(Boolean).pop() || "";
|
|
33
|
-
return {
|
|
34
|
-
timestamp: parsed.startTime || new Date().toISOString(),
|
|
35
|
-
end_time: parsed.endTime,
|
|
36
|
-
project_name: projectName,
|
|
37
|
-
user_prompt_count: parsed.userPromptCount,
|
|
38
|
-
duration_minutes: durationMinutes,
|
|
39
|
-
estimated_tokens: estimatedTokens,
|
|
40
|
-
summary: parsed.summary || "",
|
|
41
|
-
permission_mode: parsed.permissionMode,
|
|
42
|
-
tool_counts: toolCounts,
|
|
43
|
-
files_touched: parsed.filesTouched,
|
|
44
|
-
write_edit_paths: writeEditPaths,
|
|
45
|
-
bash_commands: bashCommands,
|
|
46
|
-
mcp_servers_used: [...mcpServers],
|
|
47
|
-
skills_invoked: skills,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=extract-signals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-signals.js","sourceRoot":"","sources":["../../../src/readers/extract-signals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH,MAAM,UAAU,cAAc,CAAC,MAAqB;IAClD,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QAClC,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAErD,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,OAAO,IAAI,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YACtE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,SAAmB,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC3C,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAiB,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,IAAI,EAAE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
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export interface HistoryEntry {
|
|
2
|
-
display: string;
|
|
3
|
-
timestamp: number;
|
|
4
|
-
project: string;
|
|
5
|
-
sessionId: string;
|
|
6
|
-
pastedContents?: Record<string, unknown>;
|
|
7
|
-
}
|
|
8
|
-
export interface HistorySummary {
|
|
9
|
-
totalEntries: number;
|
|
10
|
-
uniqueSessions: number;
|
|
11
|
-
uniqueProjects: string[];
|
|
12
|
-
firstTimestamp: number | null;
|
|
13
|
-
lastTimestamp: number | null;
|
|
14
|
-
sessionsByProject: Record<string, Set<string>>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Parse ~/.claude/history.jsonl — the prompt history log.
|
|
18
|
-
* Each line is a JSON object representing a user prompt submission.
|
|
19
|
-
*/
|
|
20
|
-
export declare function readHistory(): HistoryEntry[];
|
|
21
|
-
/**
|
|
22
|
-
* Get a summary of history data: session counts, project list, date range.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getHistorySummary(): HistorySummary;
|
|
25
|
-
/**
|
|
26
|
-
* Get all unique session IDs grouped by project path.
|
|
27
|
-
*/
|
|
28
|
-
export declare function getSessionsByProject(): Record<string, string[]>;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { homedir } from "os";
|
|
4
|
-
const HISTORY_PATH = join(homedir(), ".claude", "history.jsonl");
|
|
5
|
-
/**
|
|
6
|
-
* Parse ~/.claude/history.jsonl — the prompt history log.
|
|
7
|
-
* Each line is a JSON object representing a user prompt submission.
|
|
8
|
-
*/
|
|
9
|
-
export function readHistory() {
|
|
10
|
-
let raw;
|
|
11
|
-
try {
|
|
12
|
-
raw = readFileSync(HISTORY_PATH, "utf-8");
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
const entries = [];
|
|
18
|
-
for (const line of raw.split("\n")) {
|
|
19
|
-
const trimmed = line.trim();
|
|
20
|
-
if (!trimmed)
|
|
21
|
-
continue;
|
|
22
|
-
try {
|
|
23
|
-
const obj = JSON.parse(trimmed);
|
|
24
|
-
if (obj.sessionId && obj.timestamp) {
|
|
25
|
-
entries.push(obj);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// Skip malformed lines
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return entries;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get a summary of history data: session counts, project list, date range.
|
|
36
|
-
*/
|
|
37
|
-
export function getHistorySummary() {
|
|
38
|
-
const entries = readHistory();
|
|
39
|
-
const sessions = new Set();
|
|
40
|
-
const sessionsByProject = {};
|
|
41
|
-
let firstTimestamp = null;
|
|
42
|
-
let lastTimestamp = null;
|
|
43
|
-
for (const entry of entries) {
|
|
44
|
-
sessions.add(entry.sessionId);
|
|
45
|
-
if (!sessionsByProject[entry.project]) {
|
|
46
|
-
sessionsByProject[entry.project] = new Set();
|
|
47
|
-
}
|
|
48
|
-
sessionsByProject[entry.project].add(entry.sessionId);
|
|
49
|
-
if (firstTimestamp === null || entry.timestamp < firstTimestamp) {
|
|
50
|
-
firstTimestamp = entry.timestamp;
|
|
51
|
-
}
|
|
52
|
-
if (lastTimestamp === null || entry.timestamp > lastTimestamp) {
|
|
53
|
-
lastTimestamp = entry.timestamp;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
totalEntries: entries.length,
|
|
58
|
-
uniqueSessions: sessions.size,
|
|
59
|
-
uniqueProjects: Object.keys(sessionsByProject).sort(),
|
|
60
|
-
firstTimestamp,
|
|
61
|
-
lastTimestamp,
|
|
62
|
-
sessionsByProject,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get all unique session IDs grouped by project path.
|
|
67
|
-
*/
|
|
68
|
-
export function getSessionsByProject() {
|
|
69
|
-
const entries = readHistory();
|
|
70
|
-
const map = {};
|
|
71
|
-
for (const entry of entries) {
|
|
72
|
-
if (!map[entry.project]) {
|
|
73
|
-
map[entry.project] = new Set();
|
|
74
|
-
}
|
|
75
|
-
map[entry.project].add(entry.sessionId);
|
|
76
|
-
}
|
|
77
|
-
const result = {};
|
|
78
|
-
for (const [project, sessions] of Object.entries(map)) {
|
|
79
|
-
result[project] = [...sessions];
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=history-reader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"history-reader.js","sourceRoot":"","sources":["../../../src/readers/history-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAmB7B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiB,CAAC;YAChD,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,EAAE,C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QACb,iBAAiB;KAClB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAgC,EAAE,CAAC;IAE5C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,CAAC;QACD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,MAAM,GAA6B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/** A single message in a session JSONL file. */
|
|
2
|
-
export interface SessionMessage {
|
|
3
|
-
type: "user" | "assistant" | "summary" | "system" | "progress" | "file-history-snapshot";
|
|
4
|
-
userType?: "external" | "internal";
|
|
5
|
-
message?: {
|
|
6
|
-
role: string;
|
|
7
|
-
content: string | ContentBlock[];
|
|
8
|
-
model?: string;
|
|
9
|
-
};
|
|
10
|
-
uuid?: string;
|
|
11
|
-
parentUuid?: string | null;
|
|
12
|
-
timestamp?: string;
|
|
13
|
-
sessionId?: string;
|
|
14
|
-
cwd?: string;
|
|
15
|
-
version?: string;
|
|
16
|
-
gitBranch?: string;
|
|
17
|
-
permissionMode?: string;
|
|
18
|
-
summary?: string;
|
|
19
|
-
slug?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface ContentBlock {
|
|
22
|
-
type: "text" | "tool_use" | "tool_result" | "thinking";
|
|
23
|
-
text?: string;
|
|
24
|
-
thinking?: string;
|
|
25
|
-
name?: string;
|
|
26
|
-
input?: Record<string, unknown>;
|
|
27
|
-
id?: string;
|
|
28
|
-
}
|
|
29
|
-
/** Parsed session with extracted metadata. */
|
|
30
|
-
export interface ParsedSession {
|
|
31
|
-
sessionId: string;
|
|
32
|
-
projectPath: string;
|
|
33
|
-
projectDirName: string;
|
|
34
|
-
startTime: string | null;
|
|
35
|
-
endTime: string | null;
|
|
36
|
-
userPromptCount: number;
|
|
37
|
-
toolCalls: ToolCall[];
|
|
38
|
-
filesTouched: string[];
|
|
39
|
-
summary: string | null;
|
|
40
|
-
gitBranch: string | null;
|
|
41
|
-
slug: string | null;
|
|
42
|
-
permissionMode: string | null;
|
|
43
|
-
}
|
|
44
|
-
export interface ToolCall {
|
|
45
|
-
name: string;
|
|
46
|
-
input: Record<string, unknown>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Convert a project working directory to the Claude projects folder name.
|
|
50
|
-
* e.g. "/Users/austinmarchese/code/incubator-website" -> "-Users-austinmarchese-code-incubator-website"
|
|
51
|
-
*/
|
|
52
|
-
export declare function projectPathToDirName(projectPath: string): string;
|
|
53
|
-
/**
|
|
54
|
-
* List all project directories in ~/.claude/projects/
|
|
55
|
-
*/
|
|
56
|
-
export declare function listProjects(): string[];
|
|
57
|
-
/**
|
|
58
|
-
* List all session JSONL files for a given project directory name.
|
|
59
|
-
*/
|
|
60
|
-
export declare function listSessionFiles(projectDirName: string): string[];
|
|
61
|
-
/**
|
|
62
|
-
* List ALL session JSONL files across all projects.
|
|
63
|
-
*/
|
|
64
|
-
export declare function listAllSessionFiles(): {
|
|
65
|
-
projectDirName: string;
|
|
66
|
-
filePath: string;
|
|
67
|
-
}[];
|
|
68
|
-
/**
|
|
69
|
-
* Parse a single session JSONL file into structured data.
|
|
70
|
-
*/
|
|
71
|
-
export declare function parseSession(filePath: string): ParsedSession | null;
|
|
72
|
-
/**
|
|
73
|
-
* Parse all sessions across all projects.
|
|
74
|
-
*/
|
|
75
|
-
export declare function parseAllSessions(): ParsedSession[];
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { readFileSync, readdirSync, statSync } from "fs";
|
|
2
|
-
import { join, basename } from "path";
|
|
3
|
-
import { homedir } from "os";
|
|
4
|
-
const PROJECTS_DIR = join(homedir(), ".claude", "projects");
|
|
5
|
-
/**
|
|
6
|
-
* Convert a project working directory to the Claude projects folder name.
|
|
7
|
-
* e.g. "/Users/austinmarchese/code/incubator-website" -> "-Users-austinmarchese-code-incubator-website"
|
|
8
|
-
*/
|
|
9
|
-
export function projectPathToDirName(projectPath) {
|
|
10
|
-
return projectPath.replace(/\//g, "-");
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* List all project directories in ~/.claude/projects/
|
|
14
|
-
*/
|
|
15
|
-
export function listProjects() {
|
|
16
|
-
try {
|
|
17
|
-
return readdirSync(PROJECTS_DIR).filter((name) => {
|
|
18
|
-
const full = join(PROJECTS_DIR, name);
|
|
19
|
-
return statSync(full).isDirectory();
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* List all session JSONL files for a given project directory name.
|
|
28
|
-
*/
|
|
29
|
-
export function listSessionFiles(projectDirName) {
|
|
30
|
-
const dir = join(PROJECTS_DIR, projectDirName);
|
|
31
|
-
try {
|
|
32
|
-
return readdirSync(dir)
|
|
33
|
-
.filter((f) => f.endsWith(".jsonl"))
|
|
34
|
-
.map((f) => join(dir, f));
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* List ALL session JSONL files across all projects.
|
|
42
|
-
*/
|
|
43
|
-
export function listAllSessionFiles() {
|
|
44
|
-
const results = [];
|
|
45
|
-
for (const projectDir of listProjects()) {
|
|
46
|
-
for (const filePath of listSessionFiles(projectDir)) {
|
|
47
|
-
results.push({ projectDirName: projectDir, filePath });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return results;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Parse a single session JSONL file into structured data.
|
|
54
|
-
*/
|
|
55
|
-
export function parseSession(filePath) {
|
|
56
|
-
let raw;
|
|
57
|
-
try {
|
|
58
|
-
raw = readFileSync(filePath, "utf-8");
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
const messages = [];
|
|
64
|
-
for (const line of raw.split("\n")) {
|
|
65
|
-
const trimmed = line.trim();
|
|
66
|
-
if (!trimmed)
|
|
67
|
-
continue;
|
|
68
|
-
try {
|
|
69
|
-
messages.push(JSON.parse(trimmed));
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
// Skip malformed lines
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (messages.length === 0)
|
|
76
|
-
return null;
|
|
77
|
-
let sessionId = "";
|
|
78
|
-
let projectPath = "";
|
|
79
|
-
let startTime = null;
|
|
80
|
-
let endTime = null;
|
|
81
|
-
let userPromptCount = 0;
|
|
82
|
-
let summary = null;
|
|
83
|
-
let gitBranch = null;
|
|
84
|
-
let slug = null;
|
|
85
|
-
let permissionMode = null;
|
|
86
|
-
const toolCalls = [];
|
|
87
|
-
const filesSet = new Set();
|
|
88
|
-
for (const msg of messages) {
|
|
89
|
-
// Extract session metadata from any message that has it
|
|
90
|
-
if (msg.sessionId && !sessionId)
|
|
91
|
-
sessionId = msg.sessionId;
|
|
92
|
-
if (msg.cwd && !projectPath)
|
|
93
|
-
projectPath = msg.cwd;
|
|
94
|
-
if (msg.gitBranch && !gitBranch)
|
|
95
|
-
gitBranch = msg.gitBranch;
|
|
96
|
-
if (msg.slug && !slug)
|
|
97
|
-
slug = msg.slug;
|
|
98
|
-
if (msg.permissionMode && !permissionMode)
|
|
99
|
-
permissionMode = msg.permissionMode;
|
|
100
|
-
// Track timestamps
|
|
101
|
-
if (msg.timestamp) {
|
|
102
|
-
if (!startTime || msg.timestamp < startTime)
|
|
103
|
-
startTime = msg.timestamp;
|
|
104
|
-
if (!endTime || msg.timestamp > endTime)
|
|
105
|
-
endTime = msg.timestamp;
|
|
106
|
-
}
|
|
107
|
-
// Count user prompts (external only, not subagent messages)
|
|
108
|
-
if (msg.type === "user" && msg.userType === "external") {
|
|
109
|
-
userPromptCount++;
|
|
110
|
-
}
|
|
111
|
-
// Extract summary
|
|
112
|
-
if (msg.type === "summary" && msg.summary) {
|
|
113
|
-
summary = msg.summary;
|
|
114
|
-
}
|
|
115
|
-
// Extract tool calls from assistant messages
|
|
116
|
-
if (msg.type === "assistant" && msg.message?.content) {
|
|
117
|
-
const content = msg.message.content;
|
|
118
|
-
if (Array.isArray(content)) {
|
|
119
|
-
for (const block of content) {
|
|
120
|
-
if (block.type === "tool_use" && block.name) {
|
|
121
|
-
const input = block.input || {};
|
|
122
|
-
toolCalls.push({ name: block.name, input });
|
|
123
|
-
// Extract file paths from tool inputs
|
|
124
|
-
const filePath = input.file_path ||
|
|
125
|
-
input.path ||
|
|
126
|
-
"";
|
|
127
|
-
if (filePath && filePath.startsWith("/")) {
|
|
128
|
-
filesSet.add(filePath);
|
|
129
|
-
}
|
|
130
|
-
// Extract file paths from Bash commands
|
|
131
|
-
if (block.name === "Bash" && typeof input.command === "string") {
|
|
132
|
-
extractFilePathsFromCommand(input.command, filesSet);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// Fall back to deriving sessionId from filename
|
|
140
|
-
if (!sessionId) {
|
|
141
|
-
sessionId = basename(filePath, ".jsonl");
|
|
142
|
-
}
|
|
143
|
-
// Derive project dir name from file path
|
|
144
|
-
const parts = filePath.split("/");
|
|
145
|
-
const projectsIdx = parts.indexOf("projects");
|
|
146
|
-
const projectDirName = projectsIdx >= 0 ? parts[projectsIdx + 1] || "" : "";
|
|
147
|
-
return {
|
|
148
|
-
sessionId,
|
|
149
|
-
projectPath,
|
|
150
|
-
projectDirName,
|
|
151
|
-
startTime,
|
|
152
|
-
endTime,
|
|
153
|
-
userPromptCount,
|
|
154
|
-
toolCalls,
|
|
155
|
-
filesTouched: [...filesSet].sort(),
|
|
156
|
-
summary,
|
|
157
|
-
gitBranch,
|
|
158
|
-
slug,
|
|
159
|
-
permissionMode,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Parse all sessions across all projects.
|
|
164
|
-
*/
|
|
165
|
-
export function parseAllSessions() {
|
|
166
|
-
const sessions = [];
|
|
167
|
-
for (const { filePath } of listAllSessionFiles()) {
|
|
168
|
-
const parsed = parseSession(filePath);
|
|
169
|
-
if (parsed && parsed.userPromptCount > 0) {
|
|
170
|
-
sessions.push(parsed);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return sessions.sort((a, b) => {
|
|
174
|
-
if (!a.startTime || !b.startTime)
|
|
175
|
-
return 0;
|
|
176
|
-
return a.startTime.localeCompare(b.startTime);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/** Best-effort extraction of file paths from shell commands. */
|
|
180
|
-
function extractFilePathsFromCommand(command, filesSet) {
|
|
181
|
-
const pathRegex = /\/[\w./-]+\.\w+/g;
|
|
182
|
-
const matches = command.match(pathRegex);
|
|
183
|
-
if (matches) {
|
|
184
|
-
for (const filePath of matches) {
|
|
185
|
-
if (!filePath.includes("node_modules") && !filePath.startsWith("/dev/") && !filePath.startsWith("/tmp/")) {
|
|
186
|
-
filesSet.add(filePath);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=session-reader.js.map
|
|
@@ -1 +0,0 @@
|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OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACzC,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared session scanning and syncing utilities.
|
|
3
|
-
* Used by setup (backfill), catch-up (missed sessions), and log-session (hook).
|
|
4
|
-
*/
|
|
5
|
-
import { type SessionSignals } from "./extract-signals.js";
|
|
6
|
-
/**
|
|
7
|
-
* Scan all session files and extract signals.
|
|
8
|
-
*/
|
|
9
|
-
export declare function scanAllSessions(): SessionSignals[];
|
|
10
|
-
/**
|
|
11
|
-
* Scan session files modified after a cutoff timestamp.
|
|
12
|
-
*/
|
|
13
|
-
export declare function scanRecentSessions(cutoffMs: number): SessionSignals[];
|
|
14
|
-
/**
|
|
15
|
-
* Find and extract signals from the most recently modified session file.
|
|
16
|
-
*/
|
|
17
|
-
export declare function scanMostRecentSession(): SessionSignals | null;
|
|
18
|
-
/**
|
|
19
|
-
* Sync sessions to the server in batches. Server deduplicates.
|
|
20
|
-
*/
|
|
21
|
-
export declare function syncToServer(sessions: SessionSignals[], token: string, onProgress?: (synced: number) => void): Promise<{
|
|
22
|
-
synced: number;
|
|
23
|
-
failed: boolean;
|
|
24
|
-
}>;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared session scanning and syncing utilities.
|
|
3
|
-
* Used by setup (backfill), catch-up (missed sessions), and log-session (hook).
|
|
4
|
-
*/
|
|
5
|
-
import { readdirSync, statSync } from "fs";
|
|
6
|
-
import { join } from "path";
|
|
7
|
-
import { homedir } from "os";
|
|
8
|
-
import { parseSession, parseAllSessions } from "./session-reader.js";
|
|
9
|
-
import { extractSignals } from "./extract-signals.js";
|
|
10
|
-
import { API_BASE } from "../api-client.js";
|
|
11
|
-
const PROJECTS_DIR = join(homedir(), ".claude", "projects");
|
|
12
|
-
const BATCH_SIZE = 25;
|
|
13
|
-
const SYNC_TIMEOUT_MS = 30000;
|
|
14
|
-
/**
|
|
15
|
-
* Scan all session files and extract signals.
|
|
16
|
-
*/
|
|
17
|
-
export function scanAllSessions() {
|
|
18
|
-
return parseAllSessions().map(s => extractSignals(s));
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Scan session files modified after a cutoff timestamp.
|
|
22
|
-
*/
|
|
23
|
-
export function scanRecentSessions(cutoffMs) {
|
|
24
|
-
const results = [];
|
|
25
|
-
try {
|
|
26
|
-
for (const projectDir of readdirSync(PROJECTS_DIR)) {
|
|
27
|
-
const fullDir = join(PROJECTS_DIR, projectDir);
|
|
28
|
-
if (!statSync(fullDir).isDirectory())
|
|
29
|
-
continue;
|
|
30
|
-
for (const file of readdirSync(fullDir)) {
|
|
31
|
-
if (!file.endsWith(".jsonl"))
|
|
32
|
-
continue;
|
|
33
|
-
const fullPath = join(fullDir, file);
|
|
34
|
-
if (statSync(fullPath).mtimeMs < cutoffMs)
|
|
35
|
-
continue;
|
|
36
|
-
const parsed = parseSession(fullPath);
|
|
37
|
-
if (!parsed || parsed.userPromptCount === 0)
|
|
38
|
-
continue;
|
|
39
|
-
results.push(extractSignals(parsed));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// Can't read projects dir
|
|
45
|
-
}
|
|
46
|
-
return results;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Find and extract signals from the most recently modified session file.
|
|
50
|
-
*/
|
|
51
|
-
export function scanMostRecentSession() {
|
|
52
|
-
let newest = null;
|
|
53
|
-
try {
|
|
54
|
-
for (const projectDir of readdirSync(PROJECTS_DIR)) {
|
|
55
|
-
const fullDir = join(PROJECTS_DIR, projectDir);
|
|
56
|
-
if (!statSync(fullDir).isDirectory())
|
|
57
|
-
continue;
|
|
58
|
-
for (const file of readdirSync(fullDir)) {
|
|
59
|
-
if (!file.endsWith(".jsonl"))
|
|
60
|
-
continue;
|
|
61
|
-
const fullPath = join(fullDir, file);
|
|
62
|
-
const mtime = statSync(fullPath).mtimeMs;
|
|
63
|
-
if (!newest || mtime > newest.mtime) {
|
|
64
|
-
newest = { path: fullPath, mtime };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
if (!newest)
|
|
73
|
-
return null;
|
|
74
|
-
// Only process if modified in the last 5 minutes
|
|
75
|
-
if (Date.now() - newest.mtime > 5 * 60 * 1000)
|
|
76
|
-
return null;
|
|
77
|
-
const parsed = parseSession(newest.path);
|
|
78
|
-
if (!parsed || parsed.userPromptCount === 0)
|
|
79
|
-
return null;
|
|
80
|
-
return extractSignals(parsed);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Sync sessions to the server in batches. Server deduplicates.
|
|
84
|
-
*/
|
|
85
|
-
export async function syncToServer(sessions, token, onProgress) {
|
|
86
|
-
let synced = 0;
|
|
87
|
-
let failed = false;
|
|
88
|
-
for (let i = 0; i < sessions.length; i += BATCH_SIZE) {
|
|
89
|
-
const batch = sessions.slice(i, i + BATCH_SIZE);
|
|
90
|
-
try {
|
|
91
|
-
const res = await fetch(`${API_BASE}/api/buildpartner/sync`, {
|
|
92
|
-
method: "POST",
|
|
93
|
-
headers: {
|
|
94
|
-
"Authorization": `Bearer ${token}`,
|
|
95
|
-
"Content-Type": "application/json",
|
|
96
|
-
},
|
|
97
|
-
body: JSON.stringify({ sessions: batch }),
|
|
98
|
-
signal: AbortSignal.timeout(SYNC_TIMEOUT_MS),
|
|
99
|
-
});
|
|
100
|
-
if (res.ok) {
|
|
101
|
-
synced += batch.length;
|
|
102
|
-
onProgress?.(synced);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
failed = true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
failed = true;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return { synced, failed };
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=session-sync.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-sync.js","sourceRoot":"","sources":["../../../src/readers/session-sync.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAC5D,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,IAAI,CAAC;QACH,KAAK,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AE,MAAM;gBACd,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,KAAK,EAAE;oBAClC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;gBACzC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC;aAC7C,CAAC,CAAC;YACH,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;gBACvB,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,IAAI,CAAC;YAChB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface DailyActivity {
|
|
2
|
-
date: string;
|
|
3
|
-
messageCount: number;
|
|
4
|
-
sessionCount: number;
|
|
5
|
-
toolCallCount: number;
|
|
6
|
-
}
|
|
7
|
-
export interface StatsCache {
|
|
8
|
-
version: number;
|
|
9
|
-
lastComputedDate: string;
|
|
10
|
-
dailyActivity: DailyActivity[];
|
|
11
|
-
}
|
|
12
|
-
export interface StatsSummary {
|
|
13
|
-
totalDays: number;
|
|
14
|
-
totalMessages: number;
|
|
15
|
-
totalSessions: number;
|
|
16
|
-
totalToolCalls: number;
|
|
17
|
-
firstDate: string | null;
|
|
18
|
-
lastDate: string | null;
|
|
19
|
-
currentStreak: number;
|
|
20
|
-
bestStreak: number;
|
|
21
|
-
dailyActivity: DailyActivity[];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Read and parse ~/.claude/stats-cache.json
|
|
25
|
-
*/
|
|
26
|
-
export declare function readStatsCache(): StatsCache | null;
|
|
27
|
-
/**
|
|
28
|
-
* Compute a full stats summary from the cache.
|
|
29
|
-
*/
|
|
30
|
-
export declare function getStatsSummary(): StatsSummary | null;
|
|
31
|
-
/**
|
|
32
|
-
* Get activity for a specific date range.
|
|
33
|
-
*/
|
|
34
|
-
export declare function getActivityInRange(startDate: string, endDate: string): DailyActivity[];
|
|
35
|
-
/**
|
|
36
|
-
* Get activity for the current week (Mon–Sun).
|
|
37
|
-
*/
|
|
38
|
-
export declare function getThisWeekActivity(): DailyActivity[];
|