sidekick-shared 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -0
- package/dist/aggregation/EventAggregator.d.ts +172 -0
- package/dist/aggregation/EventAggregator.js +1443 -0
- package/dist/aggregation/FrequencyTracker.d.ts +42 -0
- package/dist/aggregation/FrequencyTracker.js +73 -0
- package/dist/aggregation/HeatmapTracker.d.ts +40 -0
- package/dist/aggregation/HeatmapTracker.js +93 -0
- package/dist/aggregation/PatternExtractor.d.ts +51 -0
- package/dist/aggregation/PatternExtractor.js +171 -0
- package/dist/aggregation/snapshot.d.ts +64 -0
- package/dist/aggregation/snapshot.js +151 -0
- package/dist/aggregation/types.d.ts +121 -0
- package/dist/aggregation/types.js +6 -0
- package/dist/context/composer.d.ts +31 -0
- package/dist/context/composer.js +72 -0
- package/dist/credentials.d.ts +23 -0
- package/dist/credentials.js +96 -0
- package/dist/formatters/eventHighlighter.d.ts +30 -0
- package/dist/formatters/eventHighlighter.js +217 -0
- package/dist/formatters/noiseClassifier.d.ts +73 -0
- package/dist/formatters/noiseClassifier.js +226 -0
- package/dist/formatters/sessionDump.d.ts +38 -0
- package/dist/formatters/sessionDump.js +313 -0
- package/dist/formatters/toolSummary.d.ts +23 -0
- package/dist/formatters/toolSummary.js +230 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +182 -0
- package/dist/parsers/changelogParser.d.ts +25 -0
- package/dist/parsers/changelogParser.js +74 -0
- package/dist/parsers/codexParser.d.ts +76 -0
- package/dist/parsers/codexParser.js +653 -0
- package/dist/parsers/debugLogParser.d.ts +63 -0
- package/dist/parsers/debugLogParser.js +164 -0
- package/dist/parsers/jsonl.d.ts +45 -0
- package/dist/parsers/jsonl.js +57 -0
- package/dist/parsers/openCodeParser.d.ts +64 -0
- package/dist/parsers/openCodeParser.js +581 -0
- package/dist/parsers/planExtractor.d.ts +63 -0
- package/dist/parsers/planExtractor.js +330 -0
- package/dist/parsers/sessionActivityDetector.d.ts +31 -0
- package/dist/parsers/sessionActivityDetector.js +184 -0
- package/dist/parsers/sessionPathResolver.d.ts +230 -0
- package/dist/parsers/sessionPathResolver.js +753 -0
- package/dist/parsers/subagentScanner.d.ts +43 -0
- package/dist/parsers/subagentScanner.js +366 -0
- package/dist/parsers/subagentTraceParser.d.ts +58 -0
- package/dist/parsers/subagentTraceParser.js +346 -0
- package/dist/paths.d.ts +38 -0
- package/dist/paths.js +107 -0
- package/dist/phrases.d.ts +52 -0
- package/dist/phrases.js +1333 -0
- package/dist/providers/claudeCode.d.ts +48 -0
- package/dist/providers/claudeCode.js +465 -0
- package/dist/providers/codex.d.ts +57 -0
- package/dist/providers/codex.js +944 -0
- package/dist/providers/codexDatabase.d.ts +37 -0
- package/dist/providers/codexDatabase.js +148 -0
- package/dist/providers/detect.d.ts +16 -0
- package/dist/providers/detect.js +162 -0
- package/dist/providers/openCode.d.ts +70 -0
- package/dist/providers/openCode.js +1524 -0
- package/dist/providers/openCodeDatabase.d.ts +87 -0
- package/dist/providers/openCodeDatabase.js +232 -0
- package/dist/providers/types.d.ts +154 -0
- package/dist/providers/types.js +12 -0
- package/dist/quota.d.ts +34 -0
- package/dist/quota.js +80 -0
- package/dist/readers/decisions.d.ts +10 -0
- package/dist/readers/decisions.js +27 -0
- package/dist/readers/handoff.d.ts +4 -0
- package/dist/readers/handoff.js +51 -0
- package/dist/readers/helpers.d.ts +7 -0
- package/dist/readers/helpers.js +52 -0
- package/dist/readers/history.d.ts +5 -0
- package/dist/readers/history.js +12 -0
- package/dist/readers/notes.d.ts +10 -0
- package/dist/readers/notes.js +46 -0
- package/dist/readers/plans.d.ts +35 -0
- package/dist/readers/plans.js +247 -0
- package/dist/readers/tasks.d.ts +8 -0
- package/dist/readers/tasks.js +22 -0
- package/dist/report/htmlHelpers.d.ts +18 -0
- package/dist/report/htmlHelpers.js +166 -0
- package/dist/report/htmlReportGenerator.d.ts +11 -0
- package/dist/report/htmlReportGenerator.js +650 -0
- package/dist/report/index.d.ts +8 -0
- package/dist/report/index.js +16 -0
- package/dist/report/logo.d.ts +2 -0
- package/dist/report/logo.js +5 -0
- package/dist/report/openBrowser.d.ts +5 -0
- package/dist/report/openBrowser.js +22 -0
- package/dist/report/transcriptParser.d.ts +12 -0
- package/dist/report/transcriptParser.js +177 -0
- package/dist/report/types.d.ts +43 -0
- package/dist/report/types.js +5 -0
- package/dist/search/advancedFilter.d.ts +62 -0
- package/dist/search/advancedFilter.js +201 -0
- package/dist/search/sessionSearch.d.ts +16 -0
- package/dist/search/sessionSearch.js +93 -0
- package/dist/types/codex.d.ts +276 -0
- package/dist/types/codex.js +14 -0
- package/dist/types/decisionLog.d.ts +23 -0
- package/dist/types/decisionLog.js +8 -0
- package/dist/types/historicalData.d.ts +74 -0
- package/dist/types/historicalData.js +17 -0
- package/dist/types/knowledgeNote.d.ts +40 -0
- package/dist/types/knowledgeNote.js +18 -0
- package/dist/types/opencode.d.ts +268 -0
- package/dist/types/opencode.js +13 -0
- package/dist/types/plan.d.ts +49 -0
- package/dist/types/plan.js +10 -0
- package/dist/types/sessionEvent.d.ts +562 -0
- package/dist/types/sessionEvent.js +11 -0
- package/dist/types/taskPersistence.d.ts +33 -0
- package/dist/types/taskPersistence.js +16 -0
- package/dist/watchers/eventBridge.d.ts +19 -0
- package/dist/watchers/eventBridge.js +162 -0
- package/dist/watchers/factory.d.ts +15 -0
- package/dist/watchers/factory.js +85 -0
- package/dist/watchers/jsonlWatcher.d.ts +30 -0
- package/dist/watchers/jsonlWatcher.js +444 -0
- package/dist/watchers/sqliteWatcher.d.ts +30 -0
- package/dist/watchers/sqliteWatcher.js +278 -0
- package/dist/watchers/types.d.ts +60 -0
- package/dist/watchers/types.js +5 -0
- package/package.json +31 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Subagent execution trace parser.
|
|
4
|
+
*
|
|
5
|
+
* Extends the existing subagent scanner to preserve full conversation events
|
|
6
|
+
* (not just stats) for drill-down trace visualization. Applies noise classification
|
|
7
|
+
* and tool summary formatting from the formatters module.
|
|
8
|
+
*
|
|
9
|
+
* Three-phase parent-child linking:
|
|
10
|
+
* 1. Result-based: match toolUseResult.agentId → parent tool_use_id
|
|
11
|
+
* 2. Team summary: parse <teammate-message> XML blocks
|
|
12
|
+
* 3. Positional fallback: timestamp ordering + proximity
|
|
13
|
+
*
|
|
14
|
+
* @module parsers/subagentTraceParser
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
33
|
+
var ownKeys = function(o) {
|
|
34
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35
|
+
var ar = [];
|
|
36
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
return ownKeys(o);
|
|
40
|
+
};
|
|
41
|
+
return function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.scanSubagentTraces = scanSubagentTraces;
|
|
51
|
+
const fs = __importStar(require("fs"));
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
const toolSummary_1 = require("../formatters/toolSummary");
|
|
54
|
+
const noiseClassifier_1 = require("../formatters/noiseClassifier");
|
|
55
|
+
// ── Constants ──
|
|
56
|
+
const AGENT_FILE_PATTERN = /^agent-(.+)\.jsonl$/;
|
|
57
|
+
// ── Public API ──
|
|
58
|
+
/**
|
|
59
|
+
* Scans and parses subagent traces with full conversation events.
|
|
60
|
+
*
|
|
61
|
+
* Unlike `scanSubagentDir()` which only returns stats, this returns
|
|
62
|
+
* the full conversation trace for each subagent, formatted with tool
|
|
63
|
+
* summaries and noise classification.
|
|
64
|
+
*
|
|
65
|
+
* @param sessionDir - Directory containing the session file
|
|
66
|
+
* @param sessionId - Session ID (filename without .jsonl extension)
|
|
67
|
+
* @returns Array of SubagentTrace objects forming a tree
|
|
68
|
+
*/
|
|
69
|
+
function scanSubagentTraces(sessionDir, sessionId) {
|
|
70
|
+
const subagentsDir = path.join(sessionDir, sessionId, 'subagents');
|
|
71
|
+
try {
|
|
72
|
+
if (!fs.existsSync(subagentsDir))
|
|
73
|
+
return [];
|
|
74
|
+
const files = fs.readdirSync(subagentsDir);
|
|
75
|
+
const traces = [];
|
|
76
|
+
for (const file of files) {
|
|
77
|
+
const match = file.match(AGENT_FILE_PATTERN);
|
|
78
|
+
if (!match)
|
|
79
|
+
continue;
|
|
80
|
+
const agentId = match[1];
|
|
81
|
+
const filePath = path.join(subagentsDir, file);
|
|
82
|
+
const trace = parseAgentTrace(filePath, agentId);
|
|
83
|
+
if (trace)
|
|
84
|
+
traces.push(trace);
|
|
85
|
+
}
|
|
86
|
+
// Link parent-child relationships
|
|
87
|
+
linkTraces(traces);
|
|
88
|
+
// Return only top-level traces (those without parents)
|
|
89
|
+
return traces.filter(t => !t.parentToolUseId);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ── Parsing ──
|
|
96
|
+
function parseAgentTrace(filePath, agentId) {
|
|
97
|
+
try {
|
|
98
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
99
|
+
const lines = content.split('\n').filter(l => l.trim());
|
|
100
|
+
const events = [];
|
|
101
|
+
const toolCalls = [];
|
|
102
|
+
let agentType;
|
|
103
|
+
let description;
|
|
104
|
+
let inputTokens = 0;
|
|
105
|
+
let outputTokens = 0;
|
|
106
|
+
let startTime;
|
|
107
|
+
let endTime;
|
|
108
|
+
for (const line of lines) {
|
|
109
|
+
try {
|
|
110
|
+
const raw = JSON.parse(line);
|
|
111
|
+
const timestamp = new Date(raw.timestamp || Date.now());
|
|
112
|
+
if (!startTime)
|
|
113
|
+
startTime = timestamp;
|
|
114
|
+
endTime = timestamp;
|
|
115
|
+
// Build SessionEvent from raw JSONL
|
|
116
|
+
const sessionEvent = rawToSessionEvent(raw);
|
|
117
|
+
if (!sessionEvent)
|
|
118
|
+
continue;
|
|
119
|
+
// Classify and format
|
|
120
|
+
const hardNoise = (0, noiseClassifier_1.isHardNoise)(sessionEvent);
|
|
121
|
+
const messageClass = (0, noiseClassifier_1.classifyMessage)(sessionEvent);
|
|
122
|
+
const softNoise = (0, noiseClassifier_1.getSoftNoiseReason)(sessionEvent);
|
|
123
|
+
// Compute noise level
|
|
124
|
+
let noiseLevel = 'system';
|
|
125
|
+
switch (sessionEvent.type) {
|
|
126
|
+
case 'user':
|
|
127
|
+
noiseLevel = 'user';
|
|
128
|
+
break;
|
|
129
|
+
case 'assistant':
|
|
130
|
+
noiseLevel = 'ai';
|
|
131
|
+
break;
|
|
132
|
+
case 'tool_use':
|
|
133
|
+
noiseLevel = 'system';
|
|
134
|
+
break;
|
|
135
|
+
case 'tool_result':
|
|
136
|
+
noiseLevel = 'noise';
|
|
137
|
+
break;
|
|
138
|
+
case 'summary':
|
|
139
|
+
noiseLevel = 'system';
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
// Format tool summary
|
|
143
|
+
let toolSummary;
|
|
144
|
+
if (sessionEvent.type === 'tool_use' && sessionEvent.tool) {
|
|
145
|
+
toolSummary = (0, toolSummary_1.formatToolSummary)(sessionEvent.tool.name, sessionEvent.tool.input);
|
|
146
|
+
}
|
|
147
|
+
events.push({
|
|
148
|
+
event: sessionEvent,
|
|
149
|
+
toolSummary,
|
|
150
|
+
noiseLevel,
|
|
151
|
+
messageClassification: messageClass,
|
|
152
|
+
softNoiseReason: softNoise ?? undefined,
|
|
153
|
+
isHardNoise: hardNoise,
|
|
154
|
+
});
|
|
155
|
+
// Extract token usage
|
|
156
|
+
if (raw.type === 'assistant' && raw.message?.usage) {
|
|
157
|
+
const usage = raw.message.usage;
|
|
158
|
+
inputTokens += (usage.input_tokens || 0) + (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0);
|
|
159
|
+
outputTokens += usage.output_tokens || 0;
|
|
160
|
+
}
|
|
161
|
+
// Extract tool calls
|
|
162
|
+
if (raw.type === 'assistant' && Array.isArray(raw.message?.content)) {
|
|
163
|
+
for (const block of raw.message.content) {
|
|
164
|
+
if (block?.type === 'tool_use') {
|
|
165
|
+
toolCalls.push({
|
|
166
|
+
name: block.name,
|
|
167
|
+
input: block.input || {},
|
|
168
|
+
timestamp,
|
|
169
|
+
});
|
|
170
|
+
// Extract agent info from Task tool
|
|
171
|
+
if (block.name === 'Task' && block.input) {
|
|
172
|
+
if (block.input.subagent_type && !agentType) {
|
|
173
|
+
agentType = String(block.input.subagent_type);
|
|
174
|
+
}
|
|
175
|
+
if (block.input.description && !description) {
|
|
176
|
+
description = String(block.input.description);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Extract agent type from system messages
|
|
183
|
+
if (raw.type === 'system' && raw.message?.content) {
|
|
184
|
+
const contentStr = typeof raw.message.content === 'string'
|
|
185
|
+
? raw.message.content
|
|
186
|
+
: JSON.stringify(raw.message.content);
|
|
187
|
+
const typeMatch = contentStr.match(/subagent_type['":\s]+(\w+)/i);
|
|
188
|
+
if (typeMatch && !agentType) {
|
|
189
|
+
agentType = typeMatch[1];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// Skip malformed lines
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (events.length === 0 && !agentType && !description && inputTokens === 0) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const durationMs = startTime && endTime ? endTime.getTime() - startTime.getTime() : undefined;
|
|
201
|
+
return {
|
|
202
|
+
agentId,
|
|
203
|
+
agentType,
|
|
204
|
+
description,
|
|
205
|
+
events,
|
|
206
|
+
children: [],
|
|
207
|
+
stats: {
|
|
208
|
+
agentId,
|
|
209
|
+
agentType,
|
|
210
|
+
description,
|
|
211
|
+
toolCalls,
|
|
212
|
+
inputTokens,
|
|
213
|
+
outputTokens,
|
|
214
|
+
startTime,
|
|
215
|
+
endTime,
|
|
216
|
+
durationMs,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// ── Parent-Child Linking ──
|
|
225
|
+
function linkTraces(traces) {
|
|
226
|
+
const traceById = new Map();
|
|
227
|
+
for (const trace of traces) {
|
|
228
|
+
traceById.set(trace.agentId, trace);
|
|
229
|
+
}
|
|
230
|
+
// Phase 1: Result-based linking
|
|
231
|
+
// Look for tool_result events that contain agentId references
|
|
232
|
+
for (const trace of traces) {
|
|
233
|
+
for (const traceEvent of trace.events) {
|
|
234
|
+
const evt = traceEvent.event;
|
|
235
|
+
if (evt.type === 'tool_use' && evt.tool?.name === 'Task') {
|
|
236
|
+
// The tool_use_id from this call should appear as a result in the parent
|
|
237
|
+
// but we can link via timestamp proximity to child traces
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Phase 2: Team summary linking
|
|
242
|
+
for (const trace of traces) {
|
|
243
|
+
for (const traceEvent of trace.events) {
|
|
244
|
+
const content = traceEvent.event.message?.content;
|
|
245
|
+
if (typeof content === 'string' && content.includes('<teammate-message>')) {
|
|
246
|
+
// Parse teammate agent IDs from XML blocks
|
|
247
|
+
const matches = content.matchAll(/agent[_-]id['":\s]+([a-f0-9]+)/gi);
|
|
248
|
+
for (const match of matches) {
|
|
249
|
+
const childId = match[1];
|
|
250
|
+
const child = traceById.get(childId);
|
|
251
|
+
if (child && child !== trace) {
|
|
252
|
+
child.parentToolUseId = trace.agentId;
|
|
253
|
+
trace.children.push(child);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Phase 3: Positional fallback — timestamp proximity
|
|
260
|
+
// Traces without parents that fall within another trace's time window
|
|
261
|
+
const parentless = traces.filter(t => !t.parentToolUseId);
|
|
262
|
+
for (const child of parentless) {
|
|
263
|
+
if (!child.stats.startTime)
|
|
264
|
+
continue;
|
|
265
|
+
const childStart = child.stats.startTime.getTime();
|
|
266
|
+
// Find a trace that was active (Task tool call) right before this child started
|
|
267
|
+
for (const potential of traces) {
|
|
268
|
+
if (potential === child)
|
|
269
|
+
continue;
|
|
270
|
+
if (potential.parentToolUseId)
|
|
271
|
+
continue; // Already linked
|
|
272
|
+
for (const traceEvent of potential.events) {
|
|
273
|
+
const evt = traceEvent.event;
|
|
274
|
+
if (evt.type === 'tool_use' && evt.tool?.name === 'Task') {
|
|
275
|
+
const taskTime = new Date(evt.timestamp).getTime();
|
|
276
|
+
// Within 2 seconds before child start
|
|
277
|
+
if (taskTime <= childStart && childStart - taskTime < 2000) {
|
|
278
|
+
child.parentToolUseId = potential.agentId;
|
|
279
|
+
potential.children.push(child);
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (child.parentToolUseId)
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// ── Helpers ──
|
|
290
|
+
function rawToSessionEvent(raw) {
|
|
291
|
+
const type = raw.type;
|
|
292
|
+
if (!type)
|
|
293
|
+
return null;
|
|
294
|
+
// Map raw JSONL types to SessionEvent types
|
|
295
|
+
const typeMap = {
|
|
296
|
+
user: 'user',
|
|
297
|
+
assistant: 'assistant',
|
|
298
|
+
tool_use: 'tool_use',
|
|
299
|
+
tool_result: 'tool_result',
|
|
300
|
+
summary: 'summary',
|
|
301
|
+
};
|
|
302
|
+
const mappedType = typeMap[type];
|
|
303
|
+
if (!mappedType)
|
|
304
|
+
return null;
|
|
305
|
+
const message = raw.message;
|
|
306
|
+
const timestamp = raw.timestamp || new Date().toISOString();
|
|
307
|
+
// Extract tool info for tool_use events from content blocks
|
|
308
|
+
let tool;
|
|
309
|
+
let result;
|
|
310
|
+
if (mappedType === 'assistant' && message?.content && Array.isArray(message.content)) {
|
|
311
|
+
// Look for inline tool_use blocks
|
|
312
|
+
for (const block of message.content) {
|
|
313
|
+
if (block.type === 'tool_use') {
|
|
314
|
+
tool = {
|
|
315
|
+
name: block.name,
|
|
316
|
+
input: block.input || {},
|
|
317
|
+
};
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (mappedType === 'tool_result') {
|
|
323
|
+
const msg = raw.message;
|
|
324
|
+
if (msg?.content && Array.isArray(msg.content)) {
|
|
325
|
+
for (const block of msg.content) {
|
|
326
|
+
if (block.type === 'tool_result') {
|
|
327
|
+
result = {
|
|
328
|
+
tool_use_id: block.tool_use_id,
|
|
329
|
+
output: block.content,
|
|
330
|
+
is_error: block.is_error,
|
|
331
|
+
};
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
type: mappedType,
|
|
339
|
+
message: message || { role: 'unknown' },
|
|
340
|
+
timestamp,
|
|
341
|
+
isSidechain: raw.isSidechain,
|
|
342
|
+
permissionMode: raw.permissionMode,
|
|
343
|
+
tool,
|
|
344
|
+
result,
|
|
345
|
+
};
|
|
346
|
+
}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config path resolution and workspace encoding.
|
|
3
|
+
* Mirrors patterns from sidekick-vscode/src/services/SessionPathResolver.ts
|
|
4
|
+
* and TaskPersistenceService.ts
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Gets the Sidekick config directory.
|
|
8
|
+
* ~/.config/sidekick on Unix, %APPDATA%/sidekick on Windows.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getConfigDir(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Gets the path to a project-specific data file.
|
|
13
|
+
* e.g., ~/.config/sidekick/tasks/my-project.json
|
|
14
|
+
*/
|
|
15
|
+
export declare function getProjectDataPath(slug: string, subdomain: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the path to a global data file.
|
|
18
|
+
* e.g., ~/.config/sidekick/historical-data.json
|
|
19
|
+
*/
|
|
20
|
+
export declare function getGlobalDataPath(filename: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Encodes a workspace path to Claude Code's directory naming scheme.
|
|
23
|
+
* Replaces path separators, colons, and underscores with hyphens.
|
|
24
|
+
*
|
|
25
|
+
* From: sidekick-vscode/src/services/SessionPathResolver.ts:35-43
|
|
26
|
+
*/
|
|
27
|
+
export declare function encodeWorkspacePath(workspacePath: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Derives a project slug from a workspace path.
|
|
30
|
+
* Resolves symlinks, then encodes for use as a filename.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getProjectSlug(cwd?: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Derives a project slug WITHOUT resolving symlinks.
|
|
35
|
+
* Matches the VS Code extension's behavior (encodeWorkspacePath on raw path).
|
|
36
|
+
* Use this when reading data written by the extension.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getProjectSlugRaw(cwd?: string): string;
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Config path resolution and workspace encoding.
|
|
4
|
+
* Mirrors patterns from sidekick-vscode/src/services/SessionPathResolver.ts
|
|
5
|
+
* and TaskPersistenceService.ts
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.getConfigDir = getConfigDir;
|
|
42
|
+
exports.getProjectDataPath = getProjectDataPath;
|
|
43
|
+
exports.getGlobalDataPath = getGlobalDataPath;
|
|
44
|
+
exports.encodeWorkspacePath = encodeWorkspacePath;
|
|
45
|
+
exports.getProjectSlug = getProjectSlug;
|
|
46
|
+
exports.getProjectSlugRaw = getProjectSlugRaw;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const os = __importStar(require("os"));
|
|
50
|
+
/**
|
|
51
|
+
* Gets the Sidekick config directory.
|
|
52
|
+
* ~/.config/sidekick on Unix, %APPDATA%/sidekick on Windows.
|
|
53
|
+
*/
|
|
54
|
+
function getConfigDir() {
|
|
55
|
+
if (process.platform === 'win32') {
|
|
56
|
+
return path.join(process.env.APPDATA || os.homedir(), 'sidekick');
|
|
57
|
+
}
|
|
58
|
+
return path.join(os.homedir(), '.config', 'sidekick');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the path to a project-specific data file.
|
|
62
|
+
* e.g., ~/.config/sidekick/tasks/my-project.json
|
|
63
|
+
*/
|
|
64
|
+
function getProjectDataPath(slug, subdomain) {
|
|
65
|
+
return path.join(getConfigDir(), subdomain, `${slug}.json`);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets the path to a global data file.
|
|
69
|
+
* e.g., ~/.config/sidekick/historical-data.json
|
|
70
|
+
*/
|
|
71
|
+
function getGlobalDataPath(filename) {
|
|
72
|
+
return path.join(getConfigDir(), filename);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Encodes a workspace path to Claude Code's directory naming scheme.
|
|
76
|
+
* Replaces path separators, colons, and underscores with hyphens.
|
|
77
|
+
*
|
|
78
|
+
* From: sidekick-vscode/src/services/SessionPathResolver.ts:35-43
|
|
79
|
+
*/
|
|
80
|
+
function encodeWorkspacePath(workspacePath) {
|
|
81
|
+
const normalized = workspacePath.replace(/\\/g, '/');
|
|
82
|
+
return normalized.replace(/[:/_]/g, '-');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Derives a project slug from a workspace path.
|
|
86
|
+
* Resolves symlinks, then encodes for use as a filename.
|
|
87
|
+
*/
|
|
88
|
+
function getProjectSlug(cwd) {
|
|
89
|
+
const dir = cwd || process.cwd();
|
|
90
|
+
let resolved;
|
|
91
|
+
try {
|
|
92
|
+
resolved = fs.realpathSync(dir);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
resolved = path.resolve(dir);
|
|
96
|
+
}
|
|
97
|
+
return encodeWorkspacePath(resolved);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Derives a project slug WITHOUT resolving symlinks.
|
|
101
|
+
* Matches the VS Code extension's behavior (encodeWorkspacePath on raw path).
|
|
102
|
+
* Use this when reading data written by the extension.
|
|
103
|
+
*/
|
|
104
|
+
function getProjectSlugRaw(cwd) {
|
|
105
|
+
const dir = cwd || process.cwd();
|
|
106
|
+
return encodeWorkspacePath(path.resolve(dir));
|
|
107
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Randomized boot-up phrases that give Sidekick some personality.
|
|
3
|
+
* Phrases are organized into thematic categories and picked at random on each launch.
|
|
4
|
+
*
|
|
5
|
+
* This is the canonical source — both the VS Code extension and CLI import from here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SIDEKICK_ENERGY: string[];
|
|
8
|
+
export declare const AI_COMMENTARY: string[];
|
|
9
|
+
export declare const DEV_RELATABLE: string[];
|
|
10
|
+
export declare const DRAMATIC: string[];
|
|
11
|
+
export declare const PUNCHY: string[];
|
|
12
|
+
/** Session monitoring / dashboard-specific humor. */
|
|
13
|
+
export declare const META_MONITORING: string[];
|
|
14
|
+
/** Meta-commentary on this feature and shameless self-promotion. */
|
|
15
|
+
export declare const FOURTH_WALL: string[];
|
|
16
|
+
/** The tangled web between programmers, AI, customers, codebases, and society. */
|
|
17
|
+
export declare const THE_ECOSYSTEM: string[];
|
|
18
|
+
/** Jokes about the AI companies whose models and tools we monitor. */
|
|
19
|
+
export declare const AI_INDUSTRY: string[];
|
|
20
|
+
/** The agent as your personal hype man, life coach, and motivational speaker. */
|
|
21
|
+
export declare const MOTIVATION: string[];
|
|
22
|
+
/** LLMs being sycophantic yes-men optimized for engagement over truth. */
|
|
23
|
+
export declare const SYCOPHANCY: string[];
|
|
24
|
+
/** Existential dread about AI replacing your job and eventually everything else. */
|
|
25
|
+
export declare const OBSOLESCENCE: string[];
|
|
26
|
+
/** Roasting the "just prompt and approve" lifestyle. */
|
|
27
|
+
export declare const VIBE_CODING: string[];
|
|
28
|
+
/** Late night deploys, 3 AM debugging, on-call horror, and weekend engineering. */
|
|
29
|
+
export declare const AFTER_HOURS: string[];
|
|
30
|
+
/** Video game loading screen tips, but for programming. */
|
|
31
|
+
export declare const LOADING_TIPS: string[];
|
|
32
|
+
/** Fake error messages, status codes, and stack traces. */
|
|
33
|
+
export declare const ERROR_MESSAGES: string[];
|
|
34
|
+
/** "Overheard in Slack" and "Overheard in standup" format. */
|
|
35
|
+
export declare const OVERHEARD: string[];
|
|
36
|
+
/** Roasting the worst commit messages humanity has produced. */
|
|
37
|
+
export declare const COMMIT_SINS: string[];
|
|
38
|
+
/** Fake profound wisdom that sounds deep but is just about code. */
|
|
39
|
+
export declare const FORTUNE_COOKIE: string[];
|
|
40
|
+
/** The absurdity of tech hiring, leetcode, and whiteboard interviews. */
|
|
41
|
+
export declare const INTERVIEW_HELL: string[];
|
|
42
|
+
/** Tongue twisters for developers, AI agents, and sidekick enthusiasts. */
|
|
43
|
+
export declare const TONGUE_TWISTERS: string[];
|
|
44
|
+
/** AI rubber duck debugger humor — talking through problems with a bot that listens too well. */
|
|
45
|
+
export declare const RUBBER_DUCK: string[];
|
|
46
|
+
/** Package management pain — dependency hell, version conflicts, and lockfile nightmares. */
|
|
47
|
+
export declare const DEPENDENCY_HELL: string[];
|
|
48
|
+
/** Searching, copying, and the graveyard of duplicate questions. */
|
|
49
|
+
export declare const STACK_OVERFLOW: string[];
|
|
50
|
+
export declare const ALL_PHRASES: string[];
|
|
51
|
+
/** Pick a random phrase from all categories. */
|
|
52
|
+
export declare function getRandomPhrase(): string;
|