sidekick-shared 0.26.6 → 0.27.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/CHANGELOG.md +14 -0
- package/README.md +54 -20
- package/dist/humanPrompt.d.ts +27 -0
- package/dist/humanPrompt.js +93 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +17 -10
- package/dist/modelContext.js +4 -0
- package/dist/modelInfo.js +26 -1
- package/dist/node.d.ts +4 -0
- package/dist/node.js +9 -2
- package/dist/promptHistory.d.ts +108 -0
- package/dist/promptHistory.js +616 -0
- package/dist/schemas/sessionEvent.d.ts +25 -0
- package/dist/schemas/sessionEvent.js +3 -0
- package/dist/transcript.d.ts +6 -0
- package/dist/transcript.js +3 -0
- package/dist/types/sessionEvent.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-only collection of human-typed prompts from Claude Code and Codex
|
|
3
|
+
* session logs, scoped to a set of workspace roots.
|
|
4
|
+
*
|
|
5
|
+
* Parse-only: no redaction and no network I/O. Scope fails closed — a prompt
|
|
6
|
+
* is returned only when the working directory recorded on its log line (or,
|
|
7
|
+
* for Codex, its session/turn context) realpath-resolves to an allowed root
|
|
8
|
+
* or somewhere inside one. Every bound stops cleanly and is reported in
|
|
9
|
+
* `boundsHit`; nothing is silently truncated and no bound throws.
|
|
10
|
+
*/
|
|
11
|
+
import { type HumanPromptProvider } from './humanPrompt';
|
|
12
|
+
export type PromptHistoryProvider = HumanPromptProvider;
|
|
13
|
+
export type PromptHistoryBound = 'maxSessions' | 'maxFileBytes' | 'maxTotalBytes' | 'deadline' | 'aborted';
|
|
14
|
+
export interface PromptHistoryBounds {
|
|
15
|
+
/** Session files read in one call (unchanged files do not count). Default 1000. */
|
|
16
|
+
maxSessions?: number;
|
|
17
|
+
/** Bytes a single file may need read in this pass. Default 16 MiB. */
|
|
18
|
+
maxFileBytes?: number;
|
|
19
|
+
/** Bytes read across all files in this call. Default 256 MiB. */
|
|
20
|
+
maxTotalBytes?: number;
|
|
21
|
+
/** Wall-clock budget for the call. Default 30 000 ms. */
|
|
22
|
+
deadlineMs?: number;
|
|
23
|
+
}
|
|
24
|
+
/** Codex parse state carried across resumes (Claude lines are self-describing). */
|
|
25
|
+
export interface PromptHistoryResumeState {
|
|
26
|
+
cwd?: string;
|
|
27
|
+
gitBranch?: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
/** Session is not interactive (non-human source, fork, or missing metadata). */
|
|
30
|
+
excluded?: boolean;
|
|
31
|
+
/** `session_meta` has been seen. */
|
|
32
|
+
meta?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface PromptHistoryCursorSession {
|
|
35
|
+
provider: PromptHistoryProvider;
|
|
36
|
+
sessionId: string;
|
|
37
|
+
size: number;
|
|
38
|
+
mtimeMs: number;
|
|
39
|
+
/** Ordinal of the last human prompt seen in this file, or -1 when none. */
|
|
40
|
+
lastOrdinal: number;
|
|
41
|
+
/** Byte offset just past the last complete line processed. */
|
|
42
|
+
offset: number;
|
|
43
|
+
state?: PromptHistoryResumeState;
|
|
44
|
+
}
|
|
45
|
+
/** JSON-serializable resume point. Keys are opaque; they never contain paths. */
|
|
46
|
+
export interface PromptHistoryCursor {
|
|
47
|
+
version: 1;
|
|
48
|
+
sessions: Record<string, PromptHistoryCursorSession>;
|
|
49
|
+
}
|
|
50
|
+
export interface PromptHistoryUsage {
|
|
51
|
+
/** Uncached input tokens. */
|
|
52
|
+
inputTokens?: number;
|
|
53
|
+
outputTokens?: number;
|
|
54
|
+
cacheReadTokens?: number;
|
|
55
|
+
cacheWriteTokens?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface PromptHistoryEntry {
|
|
58
|
+
provider: PromptHistoryProvider;
|
|
59
|
+
sessionId: string;
|
|
60
|
+
/** Stable index of this prompt among the session's human prompts (0-based). */
|
|
61
|
+
ordinal: number;
|
|
62
|
+
/** ISO timestamp from the log line; never synthesized. */
|
|
63
|
+
timestamp: string;
|
|
64
|
+
/** Full prompt text, untruncated. */
|
|
65
|
+
text: string;
|
|
66
|
+
/** Realpath of the working directory; always inside an allowed root. */
|
|
67
|
+
cwd: string;
|
|
68
|
+
gitBranch?: string;
|
|
69
|
+
/** Model of the first assistant response to this prompt, when known. */
|
|
70
|
+
model?: string;
|
|
71
|
+
/** Usage of that first answering model call, when known. */
|
|
72
|
+
usage?: PromptHistoryUsage;
|
|
73
|
+
}
|
|
74
|
+
export interface PromptHistoryStats {
|
|
75
|
+
sessionsScanned: number;
|
|
76
|
+
sessionsSkippedUnchanged: number;
|
|
77
|
+
/** Scanned sessions with human prompts but none inside the allowed roots. */
|
|
78
|
+
sessionsOutOfScope: number;
|
|
79
|
+
filesOverSizeLimit: number;
|
|
80
|
+
/** Codex sessions skipped as non-interactive (subagent, fork, unknown source). */
|
|
81
|
+
sessionsNotInteractive: number;
|
|
82
|
+
/** Human prompts dropped because the log line had no usable timestamp. */
|
|
83
|
+
promptsMissingTimestamp: number;
|
|
84
|
+
/** Human prompts dropped because their cwd was missing or outside the roots. */
|
|
85
|
+
promptsOutOfScope: number;
|
|
86
|
+
}
|
|
87
|
+
export interface CollectPromptHistoryOptions {
|
|
88
|
+
/** Absolute workspace roots; realpath-normalized internally. */
|
|
89
|
+
workspacePaths: string[];
|
|
90
|
+
/** Add git worktree siblings of each root. Default true. */
|
|
91
|
+
includeWorktrees?: boolean;
|
|
92
|
+
/** Default both. */
|
|
93
|
+
providers?: PromptHistoryProvider[];
|
|
94
|
+
/** Drop prompts older than this (and skip files not modified since). */
|
|
95
|
+
since?: Date;
|
|
96
|
+
cursor?: PromptHistoryCursor;
|
|
97
|
+
bounds?: PromptHistoryBounds;
|
|
98
|
+
signal?: AbortSignal;
|
|
99
|
+
}
|
|
100
|
+
export interface PromptHistoryResult {
|
|
101
|
+
/** Ordered by provider, session, then ordinal. */
|
|
102
|
+
entries: PromptHistoryEntry[];
|
|
103
|
+
cursor: PromptHistoryCursor;
|
|
104
|
+
stats: PromptHistoryStats;
|
|
105
|
+
boundsHit: PromptHistoryBound[];
|
|
106
|
+
}
|
|
107
|
+
/** Collect human-typed prompts from Claude Code and Codex logs under the given roots. */
|
|
108
|
+
export declare function collectPromptHistory(options: CollectPromptHistoryOptions): Promise<PromptHistoryResult>;
|