agentel 0.2.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/LICENSE +21 -0
- package/README.md +452 -0
- package/agentlog-spec.md +551 -0
- package/bin/agentlog-recall.js +8 -0
- package/bin/agentlog.js +14 -0
- package/docs/code-reference.md +1108 -0
- package/docs/history-source-handling.md +837 -0
- package/docs/release.md +69 -0
- package/package.json +57 -0
- package/src/archive.js +1130 -0
- package/src/autostart.js +182 -0
- package/src/canonical-events.js +575 -0
- package/src/cli.js +7928 -0
- package/src/collector.js +113 -0
- package/src/commands/logs.js +51 -0
- package/src/commands/server.js +11 -0
- package/src/config.js +240 -0
- package/src/doctor.js +102 -0
- package/src/importers/aider.js +553 -0
- package/src/importers/claude.js +349 -0
- package/src/importers/cline.js +471 -0
- package/src/importers/gemini.js +795 -0
- package/src/importers/providers.js +149 -0
- package/src/importers/shared.js +15 -0
- package/src/importers.js +7063 -0
- package/src/mcp.js +148 -0
- package/src/parser-versions.js +62 -0
- package/src/paths.js +61 -0
- package/src/redaction.js +228 -0
- package/src/repo.js +106 -0
- package/src/search.js +619 -0
- package/src/sources.js +86 -0
- package/src/supervisor.js +217 -0
- package/src/sync.js +677 -0
- package/src/version.js +7 -0
- package/src/web-accounts.js +122 -0
|
@@ -0,0 +1,1108 @@
|
|
|
1
|
+
# Code Reference
|
|
2
|
+
|
|
3
|
+
This is a practical map of the current agentlog codebase. It lists every
|
|
4
|
+
top-level function in `src/` and describes what each one is responsible for.
|
|
5
|
+
Functions exported by a module are called out first; private helpers are still
|
|
6
|
+
listed because many of the importers and CLI flows are intentionally small,
|
|
7
|
+
plain functions rather than classes.
|
|
8
|
+
|
|
9
|
+
## Entry Points
|
|
10
|
+
|
|
11
|
+
### `bin/agentlog.js`
|
|
12
|
+
|
|
13
|
+
Runs `src/cli.main()` with process arguments. This is the installed `agentlog`
|
|
14
|
+
binary.
|
|
15
|
+
|
|
16
|
+
### `bin/agentlog-recall.js`
|
|
17
|
+
|
|
18
|
+
Runs the recall command surface used by installed skills and slash commands.
|
|
19
|
+
|
|
20
|
+
## `src/archive.js`
|
|
21
|
+
|
|
22
|
+
Archive storage, transcript normalization, canonical event persistence,
|
|
23
|
+
markdown rendering, session listing, and reveal-cache reads.
|
|
24
|
+
|
|
25
|
+
Exports:
|
|
26
|
+
|
|
27
|
+
- `archiveRoot(env)`: resolves the root archive object directory from config.
|
|
28
|
+
- `countSessions(env)`: returns total archived sessions and counts by provider.
|
|
29
|
+
- `decodeSegment(value)`: decodes an archive path segment.
|
|
30
|
+
- `encodeSegment(value)`: URL-encodes an archive path segment.
|
|
31
|
+
- `ensureConversationMarkdown(session, env)`: materializes a missing
|
|
32
|
+
`conversation.md` from an existing transcript JSONL.
|
|
33
|
+
- `listSessions(env)`: reads all archived metadata files and returns session
|
|
34
|
+
records sorted newest first, including derived raw source archive paths when
|
|
35
|
+
present.
|
|
36
|
+
- `normalizeMessages(messages)`: normalizes raw messages into indexed,
|
|
37
|
+
timestamped transcript records.
|
|
38
|
+
- `objectPathForSession(session, env)`: computes the archive directory for one
|
|
39
|
+
session using repo/scope, provider, and date.
|
|
40
|
+
- `readTranscript(file)`: reads transcript JSONL into message objects.
|
|
41
|
+
- `readEvents(sessionOrPath)`: reads canonical `events.jsonl` records from a
|
|
42
|
+
session metadata object or event path.
|
|
43
|
+
- `renderConversationMarkdown(session, messages, events)`: renders readable
|
|
44
|
+
Markdown, including redaction marker styling and canonical tool event
|
|
45
|
+
sections.
|
|
46
|
+
- `revealSession(sessionId, env)`: reads the optional unredacted reveal-cache
|
|
47
|
+
JSONL for a session.
|
|
48
|
+
- `stableSessionId(provider, sourcePath, startedAt, messages)`: generates a
|
|
49
|
+
deterministic fallback session id.
|
|
50
|
+
- `toIso(value)`: converts date-ish values to ISO strings.
|
|
51
|
+
- `walk(dir, visit)`: recursively walks a directory tree.
|
|
52
|
+
- `writeSession(input, env)`: redacts, normalizes, writes, indexes, computes
|
|
53
|
+
stats metadata (`messageCount`, `userMessageCount`, `usage`, `models`), and
|
|
54
|
+
copies declared raw source files for one archived session.
|
|
55
|
+
|
|
56
|
+
Internal helpers:
|
|
57
|
+
|
|
58
|
+
- `removeStaleSessionCopies(session, metadataPath, env)`: removes older archive
|
|
59
|
+
copies for the same provider/session id or same source path.
|
|
60
|
+
- `copyRawFiles(input, rawPath)`: copies source files into
|
|
61
|
+
`session=<id>.raw/` and writes the raw manifest. When `sharedRawFiles` is set,
|
|
62
|
+
it stores large source files once under `raw-sources/` and writes manifest
|
|
63
|
+
references from each session.
|
|
64
|
+
- `rawSourceFiles(input)`: collects deduped raw files from `rawFiles`,
|
|
65
|
+
`sourceFiles`, `sourcePath`, and SQLite sidecars.
|
|
66
|
+
- `rawSourceCandidate(value)`: resolves a raw source path, including paths with
|
|
67
|
+
fragment suffixes.
|
|
68
|
+
- `sqliteSidecarFiles(file)`: returns existing SQLite WAL/SHM sidecar
|
|
69
|
+
candidates for database-backed sources.
|
|
70
|
+
- `safeRawFilename(value)`: sanitizes original basenames for raw archive copies.
|
|
71
|
+
- `fileSha256(file)`: hashes a copied raw file for the manifest.
|
|
72
|
+
- `safeRm(file)`: removes files or directories while ignoring missing paths.
|
|
73
|
+
- `safeStat(file)`: stats a path while ignoring missing paths.
|
|
74
|
+
- `safeUnlink(file)`: deletes a file while ignoring missing files.
|
|
75
|
+
- `dedupeAdjacentMessages(messages)`: collapses adjacent duplicate transcript
|
|
76
|
+
messages.
|
|
77
|
+
- `normalizedContent(value)`: whitespace-normalizes message content for
|
|
78
|
+
dedupe.
|
|
79
|
+
- `timestampsNear(left, right)`: treats near-identical timestamps as duplicate
|
|
80
|
+
candidates.
|
|
81
|
+
- `normalizeRole(role)`: maps provider roles into agentlog transcript roles.
|
|
82
|
+
- `yamlString(value)`: serializes frontmatter string values.
|
|
83
|
+
- `markdownLine(value)`: makes a single-line Markdown heading string.
|
|
84
|
+
- `roleLabel(role)`: renders a display label for a transcript role.
|
|
85
|
+
- `normalizePrecomputedEvents(events, session)`: fills session/source fields on
|
|
86
|
+
caller-provided canonical events before archive write.
|
|
87
|
+
- `redactCanonicalEvents(events, options)`: redacts all string values inside
|
|
88
|
+
canonical events.
|
|
89
|
+
- `redactStructuredStrings(value, options)`: recursively redacts strings in
|
|
90
|
+
metadata/event objects.
|
|
91
|
+
- `touchManifest(session, pathsForSession, env)`: updates the archive manifest.
|
|
92
|
+
|
|
93
|
+
## `src/canonical-events.js`
|
|
94
|
+
|
|
95
|
+
Provider-independent event normalization, tool-call text rendering, and
|
|
96
|
+
low-signal filtering.
|
|
97
|
+
|
|
98
|
+
Exports:
|
|
99
|
+
|
|
100
|
+
- `CANONICAL_EVENT_SCHEMA_VERSION`: current event schema id,
|
|
101
|
+
`agentlog.events.v1`.
|
|
102
|
+
- `EVENT_KINDS`: constants for `session.started`, `prompt.submitted`,
|
|
103
|
+
`response.generated`, `tool.called`, and `tool.completed`.
|
|
104
|
+
- `normalizeSessionEvents(session, messages, options)`: maps transcript
|
|
105
|
+
messages into canonical events.
|
|
106
|
+
- `messageToCanonicalEvents(message, session, options)`: maps one message into
|
|
107
|
+
zero or more canonical events.
|
|
108
|
+
- `stableEventId(sessionId, messageIndex, kind, ordinal, content)`: creates a
|
|
109
|
+
deterministic event id.
|
|
110
|
+
- `renderEventText(event)`: returns keyword-searchable text for one event.
|
|
111
|
+
- `renderToolCallText(toolCall)`: renders a normalized tool call into readable
|
|
112
|
+
prose.
|
|
113
|
+
- `isLowSignalToolCall(toolCall)`: filters path-only, numeric-only, and
|
|
114
|
+
oversized tool-call content from search text.
|
|
115
|
+
- `normalizeToolCall(raw, provider)`: normalizes provider tool-call metadata.
|
|
116
|
+
- `normalizeToolResult(raw, provider)`: normalizes provider tool-result
|
|
117
|
+
metadata.
|
|
118
|
+
|
|
119
|
+
## `src/parser-versions.js`
|
|
120
|
+
|
|
121
|
+
Central semantic parser-version table used by import fingerprints, archive
|
|
122
|
+
metadata, and canonical events.
|
|
123
|
+
|
|
124
|
+
Exports:
|
|
125
|
+
|
|
126
|
+
- `PARSER_VERSIONS`: source-type to parser-version string map.
|
|
127
|
+
- `SOURCE_TYPE_ALIASES`: compatibility aliases for older source labels.
|
|
128
|
+
- `canonicalSourceType(sourceType)`: resolves an alias to the canonical source
|
|
129
|
+
type.
|
|
130
|
+
- `parserVersionForSource(sourceType)`: returns the current parser version or
|
|
131
|
+
`null`.
|
|
132
|
+
- `fingerprintPrefix(sourceType)`: returns `<source-type>-v<version>` and
|
|
133
|
+
throws for unknown source types.
|
|
134
|
+
- `assertKnownSourceType(sourceType)`: validates a source type.
|
|
135
|
+
|
|
136
|
+
## `src/version.js`
|
|
137
|
+
|
|
138
|
+
Single package-version source for CLI and MCP surfaces.
|
|
139
|
+
|
|
140
|
+
Exports:
|
|
141
|
+
|
|
142
|
+
- `version`: the value from `package.json`.
|
|
143
|
+
|
|
144
|
+
## `src/autostart.js`
|
|
145
|
+
|
|
146
|
+
Platform-specific background startup integration.
|
|
147
|
+
|
|
148
|
+
Exports:
|
|
149
|
+
|
|
150
|
+
- `autostartStatus()`: reports platform support, enabled state, and target file.
|
|
151
|
+
- `disableAutostart()`: removes the platform autostart entry.
|
|
152
|
+
- `enableAutostart(options)`: writes and optionally loads the platform autostart
|
|
153
|
+
entry.
|
|
154
|
+
- `recallInvocation()`: returns the preferred command/args for invoking
|
|
155
|
+
`agentlog-recall`.
|
|
156
|
+
|
|
157
|
+
Internal helpers:
|
|
158
|
+
|
|
159
|
+
- `autostartTarget()`: chooses the platform-specific autostart target.
|
|
160
|
+
- `macLaunchAgent()`: builds the macOS LaunchAgent definition.
|
|
161
|
+
- `linuxUserUnit()`: builds the systemd user service definition.
|
|
162
|
+
- `windowsTaskFile()`: builds the Windows helper command and task actions.
|
|
163
|
+
- `cliPath()`: resolves the repo-local CLI file.
|
|
164
|
+
- `commandOnPath(command)`: finds an installed command on `PATH`.
|
|
165
|
+
- `shellQuote(value)`: single-quotes a shell value.
|
|
166
|
+
- `unsupportedNote(platform)`: formats unsupported-platform text.
|
|
167
|
+
- `quoteSystemd(value)`: escapes spaces for systemd command lines.
|
|
168
|
+
- `escapeXml(value)`: XML-escapes plist values.
|
|
169
|
+
|
|
170
|
+
## `src/cli.js`
|
|
171
|
+
|
|
172
|
+
The command-line application, init wizard, history web server, recall installers,
|
|
173
|
+
and terminal presentation helpers. Small command handlers that can stand alone
|
|
174
|
+
live under `src/commands/`.
|
|
175
|
+
|
|
176
|
+
Exports:
|
|
177
|
+
|
|
178
|
+
- `main(argv, env)`: dispatches CLI commands.
|
|
179
|
+
- `parseArgs(argv)`: splits positional arguments and `--flags`.
|
|
180
|
+
- `recallSurfaceTemplates()`: returns generated recall command/skill templates.
|
|
181
|
+
|
|
182
|
+
Command handlers:
|
|
183
|
+
|
|
184
|
+
- `initCommand(flags, env)`: runs interactive setup, config writes, source
|
|
185
|
+
discovery, optional imports, and next-step output.
|
|
186
|
+
- `startCommand(env)`: starts the supervisor, detached unless `--foreground`
|
|
187
|
+
already routed to the foreground runner.
|
|
188
|
+
- `stopCommand(env)`: stops the supervisor process.
|
|
189
|
+
- `statusCommand(flags, env)`: prints or returns home, storage, supervisor,
|
|
190
|
+
session, index, collector, sync, and recent archive state.
|
|
191
|
+
- `recentArchivedSessions(env, limit)`: returns recently written session
|
|
192
|
+
metadata for status output.
|
|
193
|
+
- `configCommand(args, env)`: handles `config get` and `config set`.
|
|
194
|
+
- `migrateCommand(flags, env)`: updates storage backend configuration.
|
|
195
|
+
- `syncCommand(flags, env)`: runs archive sync with configured or flag-provided
|
|
196
|
+
remote settings.
|
|
197
|
+
- `autostartCommand(action)`: enables, disables, or reports autostart.
|
|
198
|
+
- `resetCommand(flags, env)`: removes agentlog local state and archive objects.
|
|
199
|
+
- `uninstallCommand(flags, env)`: stops services, removes autostart, and
|
|
200
|
+
optionally removes data.
|
|
201
|
+
- `revealCommand(sessionId, env)`: prints unredacted reveal-cache JSONL.
|
|
202
|
+
- `redactCommand(action, env)`: reapplies redaction to archived sessions.
|
|
203
|
+
- `indexCommand(action, env)`: pauses, resumes, rebuilds, or reports the search
|
|
204
|
+
index.
|
|
205
|
+
- `doctorCommand(flags, env)`: runs diagnostics.
|
|
206
|
+
- `importCommand(args, flags, env)`: imports local sources or web export files.
|
|
207
|
+
- `recallCommand(args, env)`: handles recall server/install/show/reindex flows.
|
|
208
|
+
- `showRecallSession(sessionId, env)`: prints a session through the recall path.
|
|
209
|
+
- `showCommand(sessionId, flags, env)`: prints, opens, or JSON-serializes a
|
|
210
|
+
session.
|
|
211
|
+
- `historyCommand(args, flags, env)`: searches/lists history or launches the web
|
|
212
|
+
viewer.
|
|
213
|
+
- `historyWebCommand(flags, env)`: serves the local history browser/API and
|
|
214
|
+
opens it in the default browser unless `--no-open` is set.
|
|
215
|
+
- `serverCommand(flags, env)`: delegates the compatibility `server` alias to
|
|
216
|
+
the MCP stdio server.
|
|
217
|
+
- `help(topic)`: prints top-level help or topic-specific help.
|
|
218
|
+
- `normalizeHelpTopic(topic)`: resolves help aliases such as `clear` to `reset`.
|
|
219
|
+
- `unknownHelp(topic)`: renders the fallback message for unknown help topics.
|
|
220
|
+
- `formatHelpText(text)`: applies terminal styling to help text.
|
|
221
|
+
- `formatHelpItem(line)`: bolds command/flag columns inside help output.
|
|
222
|
+
|
|
223
|
+
Reset and process helpers:
|
|
224
|
+
|
|
225
|
+
- `waitForSupervisorExit(pid, timeoutMs)`: waits briefly for a supervisor to
|
|
226
|
+
exit.
|
|
227
|
+
- `pidAlive(pid)`: checks whether a process id is alive.
|
|
228
|
+
- `sleep(ms)`: promise-based timeout.
|
|
229
|
+
- `resetTargets(env)`: lists filesystem targets removed by reset.
|
|
230
|
+
- `coalesceTargets(targets)`: removes duplicate/nested reset targets.
|
|
231
|
+
- `isSameOrInside(value, parent)`: checks path containment.
|
|
232
|
+
- `assertSafeResetTarget(targetPath)`: prevents reset from deleting unsafe
|
|
233
|
+
filesystem roots.
|
|
234
|
+
|
|
235
|
+
Session display and API helpers:
|
|
236
|
+
|
|
237
|
+
- `readSessionMarkdown(sessionId, env)`: finds a session and returns its
|
|
238
|
+
Markdown, metadata, and transcript.
|
|
239
|
+
- `sessionViewPayload(view)`: builds the web/API payload for one session.
|
|
240
|
+
- `dedupeTranscriptMessages(messages)`: removes duplicate messages for readable
|
|
241
|
+
view payloads.
|
|
242
|
+
- `normalizedTranscriptContent(value)`: whitespace-normalizes transcript content.
|
|
243
|
+
- `transcriptTimestampsNear(left, right)`: compares transcript timestamps for
|
|
244
|
+
dedupe.
|
|
245
|
+
- `openTarget(target)`: opens a file path or URL with the platform default app.
|
|
246
|
+
- `openFile(file)`: opens a file with the platform default app.
|
|
247
|
+
- `openUrl(url)`: opens a URL with the platform default browser.
|
|
248
|
+
- `historyFilters(flags, defaultLimit)`: builds history filters from CLI flags.
|
|
249
|
+
- `historyFiltersFromSearchParams(params, defaultLimit)`: builds filters from
|
|
250
|
+
web query params.
|
|
251
|
+
- `sessionTreePayload(filters, env)`: groups sessions by repo/scope for the web
|
|
252
|
+
file tree.
|
|
253
|
+
- `repoSessionsPayload(repoKey, filters, offset, env)`: returns paginated
|
|
254
|
+
sessions for one repo/scope group.
|
|
255
|
+
- `sessionRepoKey(session)`: returns the tree key for a session group.
|
|
256
|
+
- `sessionRepoLabel(session)`: returns the tree label for a session group.
|
|
257
|
+
- `displaySessionRepoLabel(session)`: chooses repo, scope, or local path display
|
|
258
|
+
text.
|
|
259
|
+
- `displayScopeLabel(scope)`: turns known scope keys into readable labels.
|
|
260
|
+
- `parseFilterExpression(filter)`: parses combined filter expressions.
|
|
261
|
+
- `clampLimit(value, fallback)`: bounds list/search limits.
|
|
262
|
+
- `historyTitle(base, filters)`: formats terminal history subtitles.
|
|
263
|
+
- `writeJsonResponse(res, payload, status)`: writes a JSON HTTP response.
|
|
264
|
+
|
|
265
|
+
Recall integration helpers:
|
|
266
|
+
|
|
267
|
+
- `addRecallToAgent(target, env)`: installs MCP config or recall command files
|
|
268
|
+
for one agent.
|
|
269
|
+
- `installRecallSurface(target, env, options)`: installs slash-command/skill
|
|
270
|
+
recall surfaces.
|
|
271
|
+
- `normalizeRecallTarget(target)`: maps common source/client aliases to recall
|
|
272
|
+
installer targets.
|
|
273
|
+
- `writeTextFile(file, text)`: writes a text file after ensuring its directory.
|
|
274
|
+
- `genericRecallInstructions()`: common recall workflow text for agents.
|
|
275
|
+
- `claudeRecallCommand()`: generated Claude `/recall` command body.
|
|
276
|
+
- `geminiRecallCommand()`: generated Gemini recall command config.
|
|
277
|
+
- `antigravityRecallSkill()`: generated Antigravity recall skill body.
|
|
278
|
+
- `cursorRecallCommand()`: generated Cursor project `/recall` command body.
|
|
279
|
+
- `cursorRecallRule()`: generated Cursor rule that advertises agentlog recall.
|
|
280
|
+
- `devinRecallSkill()`: generated Devin `/recall` skill body.
|
|
281
|
+
- `opencodeRecallCommand()`: generated OpenCode `/recall` command body.
|
|
282
|
+
- `clineRecallWorkflow()`: generated Cline `/recall.md` workflow body.
|
|
283
|
+
- `aiderRecallInstructions()`: generated Aider loadable recall instructions.
|
|
284
|
+
- `codexRecallSkill()`: generated Codex skill body.
|
|
285
|
+
- `recallArchiveHints()`: shared archive path and filter hints.
|
|
286
|
+
- `commandOnPath(command)`: finds an executable on `PATH`.
|
|
287
|
+
- `shellQuote(value)`: quotes a shell argument.
|
|
288
|
+
- `writeJsonMcpConfig(file, invocation)`: writes an MCP JSON config file.
|
|
289
|
+
- `opencodeConfigFile(env)`: resolves the OpenCode global config path.
|
|
290
|
+
- `writeOpenCodeMcpConfig(file, invocation)`: writes OpenCode's `mcp.agentlog`
|
|
291
|
+
config shape.
|
|
292
|
+
- `readJsonConfigFile(file, fallback)`: reads strict JSON or simple JSONC
|
|
293
|
+
config files.
|
|
294
|
+
- `stripJsonCommentsAndTrailingCommas(text)`: converts common JSONC syntax to
|
|
295
|
+
JSON before parsing.
|
|
296
|
+
- `printRecallAdded(target, file, invocation)`: prints recall install output.
|
|
297
|
+
- `configureClaudeTelemetry()`: merges Claude telemetry settings.
|
|
298
|
+
- `configureGeminiTelemetry()`: merges Gemini CLI telemetry settings.
|
|
299
|
+
- `configureClineTelemetry(env)`: writes Cline OTel environment and launcher
|
|
300
|
+
helper files.
|
|
301
|
+
|
|
302
|
+
Argument, output, and formatting helpers:
|
|
303
|
+
|
|
304
|
+
- `parseRepoFilter(filter)`: parses comma-separated repo filters.
|
|
305
|
+
- `printDiscovery(label, result)`: prints discovery summary rows.
|
|
306
|
+
- `printImportResults(results)`: prints import summary rows.
|
|
307
|
+
- `printPageTitle(title, subtitle)`: prints styled page headers.
|
|
308
|
+
- `printState(label, value, tone)`: prints a labeled status row.
|
|
309
|
+
- `printProviderCounts(counts, emptyText)`: prints counts grouped by provider.
|
|
310
|
+
- `printRecentArchives(sessions)`: prints recent archived sessions.
|
|
311
|
+
- `printSessionList(sessions)`: prints terminal history session rows.
|
|
312
|
+
- `printSearchResults(results)`: prints terminal search results.
|
|
313
|
+
- `providerLabel(provider)`: maps provider keys to display names.
|
|
314
|
+
- `formatWhen(value)`: formats timestamps for display.
|
|
315
|
+
- `truncate(value, max)`: shortens long strings.
|
|
316
|
+
- `wrapText(value, width)`: wraps terminal text.
|
|
317
|
+
- `formatDetails(details)`: formats key/value details.
|
|
318
|
+
- `printInitBanner(env)`: prints the large init banner.
|
|
319
|
+
- `printSection(title)`: prints a boxed section title.
|
|
320
|
+
- `printCheck(label, value)`: prints a success row.
|
|
321
|
+
- `printCommand(label, command)`: prints a suggested command row.
|
|
322
|
+
- `printMuted(text)`: prints muted explanatory text.
|
|
323
|
+
- `box(lines, options)`: draws a terminal box.
|
|
324
|
+
- `center(text, width)`: centers text within a fixed width.
|
|
325
|
+
- `visibleLength(text)`: measures terminal-visible length after ANSI stripping.
|
|
326
|
+
- `color(text, style)`: wraps text in ANSI color/style codes.
|
|
327
|
+
- `compactPath(value)`: shortens paths with `~`.
|
|
328
|
+
- `fullPath(value)`: expands `~` and resolves paths for display.
|
|
329
|
+
- `describeStorage(cfg)`: formats storage backend text.
|
|
330
|
+
|
|
331
|
+
Init wizard helpers:
|
|
332
|
+
|
|
333
|
+
- `chooseStorageSetup(flags, env)`: selects local and remote archive
|
|
334
|
+
destinations.
|
|
335
|
+
- `chooseArchiveDestinations()`: interactive toggle UI for archive destinations.
|
|
336
|
+
- `remoteBackendLabel(backend)`: display label for remote backend keys.
|
|
337
|
+
- `remoteUrlPrompt(backend)`: prompt text for remote endpoint setup.
|
|
338
|
+
- `chooseDataRoot(flags, env)`: asks for the archive data directory.
|
|
339
|
+
- `resolveUserPath(value)`: resolves home-relative, `~/`, and absolute paths.
|
|
340
|
+
- `chooseSetupSettings(flags)`: asks for autostart/recall toggles.
|
|
341
|
+
- `chooseTelemetrySettings(flags)`: asks for post-import OTel bridge toggles.
|
|
342
|
+
- `setupOptionGroups(flags)`: builds setup toggle groups.
|
|
343
|
+
- `chooseImportSince(flags)`: asks which history window to import.
|
|
344
|
+
- `chooseImportSources(flags, discovered)`: asks which discovered sources to
|
|
345
|
+
import.
|
|
346
|
+
- `chooseWatcherSources(flags, discovered, importSources)`: asks which sources
|
|
347
|
+
the supervisor should poll after backfill.
|
|
348
|
+
- `importSourceOptions(discovered)`: builds the source toggle list from
|
|
349
|
+
discovery results.
|
|
350
|
+
- `sourceSummary(result)`: formats discovered source counts.
|
|
351
|
+
- `confirm(question, defaultYes)`: yes/no prompt.
|
|
352
|
+
- `ask(question)`: readline prompt wrapper.
|
|
353
|
+
- `createProgressReporter(options)`: renders updating progress bars for
|
|
354
|
+
discovery/import.
|
|
355
|
+
|
|
356
|
+
Embedded history web app functions:
|
|
357
|
+
|
|
358
|
+
- `historyHtml(token)`: returns the full local web history app HTML.
|
|
359
|
+
- `params(extra)`: builds API query parameters from filter controls.
|
|
360
|
+
- `esc(value)`: HTML-escapes strings.
|
|
361
|
+
- `getJson(path, query)`: fetches a JSON API route.
|
|
362
|
+
- `providerLabel(provider)`: browser-side provider display mapping.
|
|
363
|
+
- `formatWhen(value)`: browser-side timestamp formatting.
|
|
364
|
+
- `renderTree(payload)`: renders the session tree.
|
|
365
|
+
- `renderSearchResults(items)`: renders search result rows.
|
|
366
|
+
- `sessionNode(item, includeExcerpt)`: creates one session button.
|
|
367
|
+
- `loadMoreNode(group)`: creates a repo/group pagination button.
|
|
368
|
+
- `loadMoreRepo(repoKey, marker)`: loads more sessions for one group.
|
|
369
|
+
- `loadSession(id)`: fetches and renders one session.
|
|
370
|
+
- `setLoadingSession(id)`: shows loading state in the detail pane.
|
|
371
|
+
- `setEmptySession(message)`: shows empty/error state in the detail pane.
|
|
372
|
+
- `renderSession(payload)`: renders session header, Markdown, messages, and
|
|
373
|
+
copy controls.
|
|
374
|
+
- `renderMessages(messages)`: renders readable transcript messages.
|
|
375
|
+
- `messageElement(message)`: creates one readable message row.
|
|
376
|
+
- `copyIconSvg()`: returns the copy icon SVG.
|
|
377
|
+
- `messageCopyButton(content)`: creates per-message copy controls.
|
|
378
|
+
- `copyMessageContent(button, content)`: copies one message and updates tooltip
|
|
379
|
+
state.
|
|
380
|
+
- `roleLabel(role)`: browser-side role display mapping.
|
|
381
|
+
- `detectToolName(text)`: returns a detected tool label.
|
|
382
|
+
- `detectToolInvocation(text)`: parses tool/skill invocation text.
|
|
383
|
+
- `toolHeader(tool)`: renders a tool callout header.
|
|
384
|
+
- `renderToolCallout(tool)`: renders a readable tool/skill card.
|
|
385
|
+
- `stripToolInvocationLine(text)`: removes the invocation line from content.
|
|
386
|
+
- `renderRichText(value)`: renders Markdown-ish message content.
|
|
387
|
+
- `renderCode(value)`: renders fenced code blocks.
|
|
388
|
+
- `renderText(value)`: renders paragraph blocks.
|
|
389
|
+
- `renderTextBlock(block)`: renders a block with inline tool callouts.
|
|
390
|
+
- `renderMarkdownBlock(block)`: renders headings, lists, quotes, tables, or
|
|
391
|
+
paragraphs.
|
|
392
|
+
- `isMarkdownTable(lines)`: detects Markdown tables.
|
|
393
|
+
- `splitMarkdownTableRow(line)`: splits table rows.
|
|
394
|
+
- `renderMarkdownTable(lines)`: renders a Markdown table.
|
|
395
|
+
- `renderInline(value)`: renders links, code spans, skill links, and plain
|
|
396
|
+
inline Markdown.
|
|
397
|
+
- `renderInlinePlain(value)`: renders emphasis and redaction chips.
|
|
398
|
+
- `renderMarkdownLink(label, href)`: renders safe links.
|
|
399
|
+
- `renderSkillLink(name, skillPath)`: renders `$skill` links.
|
|
400
|
+
- `compactSkillPath(value)`: shortens skill paths for display.
|
|
401
|
+
- `setView(mode)`: toggles readable and raw Markdown views.
|
|
402
|
+
- `sessionDetailsText(payload)`: builds copyable session details.
|
|
403
|
+
- `copyText(value)`: writes text to the clipboard.
|
|
404
|
+
- `copySessionDetails()`: copies session metadata for pasting into agents.
|
|
405
|
+
- `loadTree()`: fetches and renders the tree.
|
|
406
|
+
- `search()`: runs a search and renders results.
|
|
407
|
+
- `setupCustomSelects()`: wires custom select dropdown behavior.
|
|
408
|
+
- `setSidebarCollapsed(collapsed)`: collapses or expands the tree pane.
|
|
409
|
+
|
|
410
|
+
## `src/commands/logs.js`
|
|
411
|
+
|
|
412
|
+
Supervisor log display.
|
|
413
|
+
|
|
414
|
+
Exports:
|
|
415
|
+
|
|
416
|
+
- `logsCommand(flags, env)`: prints logs or follows appended bytes without
|
|
417
|
+
reprinting the whole file on every change.
|
|
418
|
+
|
|
419
|
+
## `src/commands/server.js`
|
|
420
|
+
|
|
421
|
+
Compatibility command for MCP startup.
|
|
422
|
+
|
|
423
|
+
Exports:
|
|
424
|
+
|
|
425
|
+
- `serverCommand(flags, env, deps)`: runs the same MCP stdio server used by
|
|
426
|
+
`agentlog recall start`.
|
|
427
|
+
|
|
428
|
+
## `src/collector.js`
|
|
429
|
+
|
|
430
|
+
OTLP HTTP collector for local telemetry.
|
|
431
|
+
|
|
432
|
+
Exports:
|
|
433
|
+
|
|
434
|
+
- `startCollector(env, options)`: starts the collector if enabled or forced.
|
|
435
|
+
- `writeTelemetryPayload(req, body, env)`: stores one telemetry payload under
|
|
436
|
+
the archive telemetry directory.
|
|
437
|
+
|
|
438
|
+
Internal helpers:
|
|
439
|
+
|
|
440
|
+
- `isOtlpPath(url)`: recognizes `/v1/logs`, `/v1/traces`, and `/v1/metrics`.
|
|
441
|
+
- `collectBody(req)`: buffers an HTTP request body.
|
|
442
|
+
- `writeJsonResponse(res, payload, status)`: writes JSON HTTP responses.
|
|
443
|
+
- `safeJson(body)`: parses JSON or wraps raw text.
|
|
444
|
+
- `looksLikeJson(body)`: cheaply detects JSON-looking request bodies.
|
|
445
|
+
|
|
446
|
+
## `src/config.js`
|
|
447
|
+
|
|
448
|
+
Config defaults, persistence, and key access.
|
|
449
|
+
|
|
450
|
+
Exports:
|
|
451
|
+
|
|
452
|
+
- `defaultConfig(env)`: returns the default config object.
|
|
453
|
+
- `getConfigKey(key, env)`: reads a dotted config key.
|
|
454
|
+
- `initConfig(options, env)`: creates a config with setup options.
|
|
455
|
+
- `loadConfig(env)`: reads config from disk and merges defaults.
|
|
456
|
+
- `saveConfig(config, env)`: writes config JSON.
|
|
457
|
+
- `setConfigKey(key, value, env)`: updates a dotted config key.
|
|
458
|
+
|
|
459
|
+
Internal helper:
|
|
460
|
+
|
|
461
|
+
- `parseConfigValue(value)`: parses booleans, numbers, JSON, and strings from
|
|
462
|
+
CLI input.
|
|
463
|
+
|
|
464
|
+
## `src/doctor.js`
|
|
465
|
+
|
|
466
|
+
Diagnostic checks for installation, dependencies, config, and source coverage.
|
|
467
|
+
|
|
468
|
+
Export:
|
|
469
|
+
|
|
470
|
+
- `runDoctor(env)`: returns checks, warnings, and source coverage details.
|
|
471
|
+
|
|
472
|
+
Internal helpers:
|
|
473
|
+
|
|
474
|
+
- `sourceCoverage(discovery, cfg)`: compares discovered source counts with
|
|
475
|
+
configured import sources.
|
|
476
|
+
- `coverageRow(source, label, result, configured)`: builds one source coverage
|
|
477
|
+
row.
|
|
478
|
+
- `add(checks, name, ok, detail, remediation)`: appends one diagnostic check.
|
|
479
|
+
- `commandExists(command)`: tests whether a command is on `PATH`.
|
|
480
|
+
- `remoteTargetLabel(cfg)`: formats configured remote archive targets.
|
|
481
|
+
|
|
482
|
+
## `src/importers.js`
|
|
483
|
+
|
|
484
|
+
All local and export importers. More source-specific behavior is documented in
|
|
485
|
+
`docs/history-source-handling.md`.
|
|
486
|
+
|
|
487
|
+
Exports:
|
|
488
|
+
|
|
489
|
+
- `discoverCliHistory(env, options)`: scans all known local sources and reports
|
|
490
|
+
counts.
|
|
491
|
+
- `extractGenericMessagesFromJson(data, source, fallbackTime)`: recursively
|
|
492
|
+
extracts role/content message nodes from arbitrary JSON.
|
|
493
|
+
- `extractText(value, depth)`: converts nested provider content shapes into
|
|
494
|
+
text.
|
|
495
|
+
- `expandImportSources(source, explicitSources)`: resolves `all` or explicit
|
|
496
|
+
source selections.
|
|
497
|
+
- `extractCursorConversations(data, sourceKey, fallbackTime)`: extracts Cursor
|
|
498
|
+
bubble conversations from SQLite JSON blobs.
|
|
499
|
+
- `importCliHistory(options, env)`: dispatches local source imports.
|
|
500
|
+
- `importWebChat(provider, file, options, env)`: imports ChatGPT or Claude.ai
|
|
501
|
+
export files.
|
|
502
|
+
- `normalizeEventRole(role)`: maps provider roles into agentlog roles.
|
|
503
|
+
- `parseClaudeDesktopSessionFile(file, kind)`: parses one Claude Desktop local
|
|
504
|
+
session metadata/audit file.
|
|
505
|
+
- `parseAgentJsonl(file, provider)`: parses generic JSONL agent transcripts.
|
|
506
|
+
- `parseJsonlHistoryFile(file, source, fallbackTime)`: parses generic JSONL
|
|
507
|
+
history records with fallback timestamps.
|
|
508
|
+
- `parseSince(value)`: parses import windows such as `30d` or `all`.
|
|
509
|
+
- `readCursorProjectTranscriptSessions(options)`: reads newer Cursor
|
|
510
|
+
`agent-transcripts` sessions.
|
|
511
|
+
- `readDevinSessionsFromDb(dbPath)`: reads Devin for Terminal sessions from one
|
|
512
|
+
SQLite `sessions.db` file.
|
|
513
|
+
- `readExportJson(file)`: reads a JSON export directly or from ZIP.
|
|
514
|
+
|
|
515
|
+
Import dispatch and generic providers:
|
|
516
|
+
|
|
517
|
+
- `importJsonlProvider(provider, roots, since, options, env)`: imports JSONL
|
|
518
|
+
providers such as Claude Code and Claude SDK jobs.
|
|
519
|
+
- `importClaudeDesktopProvider(provider, since, options, env)`: imports Claude
|
|
520
|
+
Desktop/Workspace metadata and audit sessions.
|
|
521
|
+
- `matchesImportedSessionRepo(session, repo, wantedRepos)`: checks repo filters
|
|
522
|
+
for sessions with repo or scope attribution.
|
|
523
|
+
- `importCodexProvider(provider, since, options, env)`: imports Codex CLI or
|
|
524
|
+
Desktop threads from state DB, rollout files, and Codex supplementary
|
|
525
|
+
summaries when available.
|
|
526
|
+
- `importCursorProvider(provider, since, options, env)`: imports Cursor SQLite
|
|
527
|
+
and Cursor project transcript sessions; supervisor calls set
|
|
528
|
+
`cursorRecovery=false` to skip raw SQLite salvage/backfill.
|
|
529
|
+
- `importStructuredProvider(provider, sessions, since, options, env)`: imports
|
|
530
|
+
pre-normalized structured sources such as Gemini, Antigravity, Cline,
|
|
531
|
+
OpenCode, and Aider.
|
|
532
|
+
- `structuredSessionReplaceSourcePathCopies(provider, sourceType)`: sourcePath
|
|
533
|
+
replacement policy for structured imports; Devin disables replacement because
|
|
534
|
+
many sessions share one SQLite DB.
|
|
535
|
+
- `jsonlProviderSourceType(provider)`: chooses the source type for generic JSONL
|
|
536
|
+
imports such as Claude CLI, Claude SDK, and Codex fallback sessions.
|
|
537
|
+
|
|
538
|
+
Generic parsing helpers:
|
|
539
|
+
|
|
540
|
+
- `stampMessages(messages, sourceType)`: stamps parser version/source metadata
|
|
541
|
+
onto parsed messages.
|
|
542
|
+
- `dedupeAdjacentMessages(messages)`: collapses adjacent duplicate messages.
|
|
543
|
+
- `normalizedContent(value)`: whitespace-normalizes content for dedupe.
|
|
544
|
+
- `timestampsNear(left, right)`: compares timestamps for dedupe.
|
|
545
|
+
- `extractMessage(event, provider)`: extracts one message from common event
|
|
546
|
+
shapes.
|
|
547
|
+
- `extractClaudeMessagesFromEvent(event, provider, context)`: Claude Code/SDK
|
|
548
|
+
JSONL parser for text, thinking, tool calls/results, model, request id, and
|
|
549
|
+
usage metadata, including `apply_patch` shell calls promoted to edit diffs.
|
|
550
|
+
- `updateClaudeParseContext(event, provider, context)`: keeps Claude model,
|
|
551
|
+
session, and cwd context while parsing JSONL records.
|
|
552
|
+
- `extractCodexSummaryMessage(event, provider)`: extracts readable Codex
|
|
553
|
+
reasoning-summary events from rollout JSONL.
|
|
554
|
+
- `codexSummaryText(summary)`: normalizes Codex summary strings or
|
|
555
|
+
`summary_text` parts.
|
|
556
|
+
- `codexSupplementContent(title, content)`: wraps a supplementary Codex document
|
|
557
|
+
with a readable heading.
|
|
558
|
+
- `extractToolCallFromEvent(event, provider)`: normalizes Codex-style function
|
|
559
|
+
call response items into `metadata.toolCalls[]`, including `apply_patch`
|
|
560
|
+
heredocs embedded in shell commands.
|
|
561
|
+
- `toolDisplayName(value)`: turns underscore-separated tool names into display
|
|
562
|
+
labels.
|
|
563
|
+
- `summarizeToolArguments(value)`: builds a short redaction-aware argument
|
|
564
|
+
summary for tool-call metadata.
|
|
565
|
+
- `normalizeWebConversations(provider, data)`: normalizes web export
|
|
566
|
+
conversations.
|
|
567
|
+
- `chatgptMessages(conversation)`: parses ChatGPT export conversation nodes.
|
|
568
|
+
- `claudeMessages(conversation)`: parses Claude.ai export messages.
|
|
569
|
+
- `genericConversationMessages(conversation, source)`: fallback web-export
|
|
570
|
+
parser.
|
|
571
|
+
|
|
572
|
+
Discovery and summary helpers:
|
|
573
|
+
|
|
574
|
+
- `summarizeFiles(files)`: counts files, projects, and oldest mtime.
|
|
575
|
+
- `summarizeCodex(env, source)`: summary wrapper for Codex threads.
|
|
576
|
+
- `summarizeCodexThreads(allThreads, source)`: summarizes Codex CLI/Desktop
|
|
577
|
+
counts.
|
|
578
|
+
- `summarizeClaude()`: summarizes Claude Code CLI files.
|
|
579
|
+
- `summarizeClaudeScan(scan)`: formats Claude scan results.
|
|
580
|
+
- `summarizeClaudeSdk()`: summarizes Claude SDK job files.
|
|
581
|
+
- `summarizeClaudeSdkScan(scan)`: formats SDK job results.
|
|
582
|
+
- `summarizeClaudeDesktop(env, options)`: summarizes Claude app local sessions.
|
|
583
|
+
- `summarizeClaudeDesktopSessions(sessions, kind)`: filters/summarizes Claude
|
|
584
|
+
app session kinds.
|
|
585
|
+
- `summarizeDevin(env, options)`: summarizes Devin CLI SQLite sessions.
|
|
586
|
+
- `summarizeCursor(env, options)`: summarizes Cursor SQLite and transcript
|
|
587
|
+
sessions.
|
|
588
|
+
- `readClineSessions(env, options)`: scans Cline task folders and returns
|
|
589
|
+
normalized sessions.
|
|
590
|
+
- `readOpenCodeSessions(env, options)`: scans OpenCode JSON storage and returns
|
|
591
|
+
normalized sessions.
|
|
592
|
+
- `readAiderSessions(env, options)`: scans Aider markdown history files and
|
|
593
|
+
returns normalized sessions.
|
|
594
|
+
- `summarizeStructuredSessions(sessions, note)`: summarizes structured
|
|
595
|
+
providers.
|
|
596
|
+
- `summarizeStructuredSessionDetails(sessions)`: counts detail keys, artifacts,
|
|
597
|
+
and binary-only stores.
|
|
598
|
+
|
|
599
|
+
Source location and file helpers:
|
|
600
|
+
|
|
601
|
+
- `codexRoots(env)`: returns fallback Codex sessions roots.
|
|
602
|
+
- `claudeRoots()`: returns Claude project root.
|
|
603
|
+
- `jsonlFiles(roots)`: scans roots for JSONL and JSONL zstd files.
|
|
604
|
+
- `claudeFiles()`: returns interactive Claude Code JSONL files.
|
|
605
|
+
- `claudeSdkFiles()`: returns Claude SDK job JSONL files.
|
|
606
|
+
- `scanClaudeProjectFiles(options)`: scans and classifies Claude project JSONL.
|
|
607
|
+
- `isClaudeConversationFile(file)`: tests whether a Claude file is interactive.
|
|
608
|
+
- `classifyClaudeFile(file)`: classifies Claude JSONL as conversation, SDK job,
|
|
609
|
+
or other.
|
|
610
|
+
- `readInitialLines(file, maxLines, maxBytes)`: reads a bounded prefix of a
|
|
611
|
+
large JSONL file.
|
|
612
|
+
- `readCodexThreads(env)`: queries Codex state DB for top-level threads and
|
|
613
|
+
optional `stage1_outputs` summary documents.
|
|
614
|
+
- `sqliteTableExists(dbPath, tableName)`: checks optional SQLite tables before
|
|
615
|
+
querying version-dependent Codex state.
|
|
616
|
+
- `codexStateDb(env)`: resolves Codex state DB path.
|
|
617
|
+
- `codexSupplementaryMessages(thread, fallbackTimestamp)`: converts Codex
|
|
618
|
+
`rollout_summary` and `raw_memory` rows into archived transcript messages.
|
|
619
|
+
- `codexSupplementaryMessage(kind, title, content, timestamp)`: builds one
|
|
620
|
+
supplementary Codex message.
|
|
621
|
+
- `codexSupplementFingerprint(thread)`: hashes Codex supplementary documents
|
|
622
|
+
into the import fingerprint.
|
|
623
|
+
- `summarizeCodexSources(threads)`: counts CLI and Desktop Codex threads.
|
|
624
|
+
|
|
625
|
+
Claude Desktop helpers:
|
|
626
|
+
|
|
627
|
+
- `readClaudeDesktopSessions(options)`: scans Claude app local session roots.
|
|
628
|
+
- `claudeDesktopMetadataMessages(data, kind, startedAt)`: builds fallback
|
|
629
|
+
messages from metadata.
|
|
630
|
+
- `claudeDesktopAuditPath(file)`: resolves sibling audit JSONL path.
|
|
631
|
+
- `readClaudeDesktopAuditMessages(file, kind)`: parses audit events into
|
|
632
|
+
messages.
|
|
633
|
+
- `extractClaudeAssistantText(content)`: keeps assistant text parts.
|
|
634
|
+
- `extractClaudeDesktopUserText(event)`: keeps direct user prompts and selected
|
|
635
|
+
question answers.
|
|
636
|
+
- `normalizeClaudeDesktopCwd(data)`: finds an existing cwd/folder from metadata.
|
|
637
|
+
- `claudeDesktopUncategorizedScope(kind)`: returns uncategorized scope for
|
|
638
|
+
missing cwd.
|
|
639
|
+
- `summarizeClaudeDesktopKinds(sessions)`: counts workspace versus code desktop
|
|
640
|
+
sessions.
|
|
641
|
+
|
|
642
|
+
Cursor helpers:
|
|
643
|
+
|
|
644
|
+
- `cursorWorkspaceDbs(env)`: finds older Cursor `state.vscdb` stores.
|
|
645
|
+
- `cursorGlobalStorageDbs(env)`: finds Cursor's global `state.vscdb` for raw
|
|
646
|
+
salvage.
|
|
647
|
+
- `cursorWorkspaceStorageRoot(env)`: resolves the Cursor workspace storage root.
|
|
648
|
+
- `cursorGlobalStorageRoot(env)`: resolves the Cursor global storage root.
|
|
649
|
+
- `cursorProjectsRoot(env)`: resolves the newer Cursor project transcript root.
|
|
650
|
+
- `cursorProjectTranscriptFiles(env)`: finds Cursor transcript JSON/JSONL files.
|
|
651
|
+
- `groupCursorTranscriptFiles(files, env)`: groups transcript files by session.
|
|
652
|
+
- `parseCursorTranscriptGroup(group)`: normalizes one transcript session group.
|
|
653
|
+
- `parseCursorTranscriptFile(file)`: parses one Cursor transcript file.
|
|
654
|
+
- `parseCursorJsonHistoryFile(file, source, fallbackTime)`: parses Cursor JSON
|
|
655
|
+
transcripts with Cursor-specific tool metadata before generic fallback.
|
|
656
|
+
- `cursorMessagesFromRecord(record, source, fallbackTime)`: converts one Cursor
|
|
657
|
+
record/bubble/event into message and tool-result rows.
|
|
658
|
+
- `cursorToolCallsFromRecord(record)`: extracts Cursor tool, command, edit, and
|
|
659
|
+
diff call metadata.
|
|
660
|
+
- `cursorToolResultsFromRecord(record)`: extracts Cursor tool/command output
|
|
661
|
+
metadata.
|
|
662
|
+
- `cursorUsage(record)`: normalizes Cursor token usage fields when present.
|
|
663
|
+
- `eventTimestamp(event)`: extracts timestamps from common event paths.
|
|
664
|
+
- `offsetTimestamp(fallbackTime, offset)`: creates stable fallback timestamps.
|
|
665
|
+
- `cursorSlugToPath(slug, env)`: decodes Cursor project slugs to existing paths.
|
|
666
|
+
- `addCursorSlugCandidates(candidates, root, tokens)`: generates candidate
|
|
667
|
+
decoded paths.
|
|
668
|
+
- `startsWithTokens(tokens, prefix)`: checks token prefixes.
|
|
669
|
+
- `readCursorSessionsFromDb(dbPath, options)`: reads conversations from one
|
|
670
|
+
Cursor DB; supervisor imports pass `includeRawSalvage=false` so raw SQLite
|
|
671
|
+
backfill stays explicit.
|
|
672
|
+
- `readCursorRows(dbPath)`: queries Cursor `ItemTable`.
|
|
673
|
+
- `readCursorGlobalDiskKvSessionsFromDb(dbPath, options)`: reconstructs Cursor
|
|
674
|
+
global `cursorDiskKV` Composer/Agent sessions from `composerData:<id>` headers
|
|
675
|
+
or inline `conversation` arrays and matching `bubbleId:<id>:<bubble>` rows.
|
|
676
|
+
- `readCursorRawSqliteSalvageSessionsFromDb(dbPath, options)`: streams Cursor
|
|
677
|
+
DB, backup, and WAL bytes for deleted or migrated JSON fragments.
|
|
678
|
+
- `cursorRawSqliteFilesForDb(dbPath)`: returns the Cursor raw-salvage files for
|
|
679
|
+
a SQLite DB.
|
|
680
|
+
- `extractCursorRawSqliteFragmentsFromFile(file)`: streams one raw Cursor DB
|
|
681
|
+
file and extracts parseable `composerData` and `bubbleId` fragments.
|
|
682
|
+
- `extractCursorRawSqliteFragmentsFromText(text, sourcePath)`: test helper for
|
|
683
|
+
the raw Cursor fragment scanner.
|
|
684
|
+
- `extractCursorRawSqliteConversationsFromText(text, sourcePath, fallbackTime)`:
|
|
685
|
+
test helper that converts raw Cursor fragments into conversations.
|
|
686
|
+
- `scanCursorRawSqliteText(text, sourcePath)`: chunk scanner used by raw Cursor
|
|
687
|
+
salvage.
|
|
688
|
+
- `parseCursorRawJsonObjectAt(text, start, maxEnd)`: parses one balanced raw
|
|
689
|
+
JSON object with a fragment-size cap.
|
|
690
|
+
- `cursorRawSqliteSalvageSessionsFromFragments(fragments, options)`: wraps raw
|
|
691
|
+
Cursor conversations into importable sessions.
|
|
692
|
+
- `extractCursorRawSqliteConversationsFromFragments(fragments, fallbackTime)`:
|
|
693
|
+
groups raw Cursor fragments into conversations.
|
|
694
|
+
- `cursorRawComposerDataConversations(fragment, fallbackTime)`: parses recovered
|
|
695
|
+
`composerData:<id>` records.
|
|
696
|
+
- `cursorRawBubbleGroupConversation(composerId, fragments, fallbackTime)`:
|
|
697
|
+
groups recovered `bubbleId:<composerId>:<bubbleId>` records.
|
|
698
|
+
- `cursorCwdFromObject(data)`: infers a Cursor cwd from workspace metadata or
|
|
699
|
+
selected file paths in recovered records.
|
|
700
|
+
- `readSqliteJson(dbPath, query, label)`: runs `sqlite3 -json` for SQLite-backed
|
|
701
|
+
importers.
|
|
702
|
+
- `runSqliteJson(dbPath, query)`: low-level SQLite JSON command runner.
|
|
703
|
+
- `parseSqliteJson(stdout)`: parses `sqlite3 -json` output.
|
|
704
|
+
- `sqliteResultError(result, label)`: formats SQLite errors.
|
|
705
|
+
- `shouldRetrySqliteFromSnapshot(result, dbPath)`: detects live-DB errors that
|
|
706
|
+
can be retried from a snapshot.
|
|
707
|
+
- `readSqliteJsonFromSnapshot(dbPath, query, label)`: copies a live SQLite
|
|
708
|
+
database plus WAL/SHM files to a temp directory when direct reads are locked
|
|
709
|
+
or refused.
|
|
710
|
+
- `copySqliteSnapshotFile(source, target, optional)`: copies SQLite DB/WAL/SHM
|
|
711
|
+
files for snapshot reads.
|
|
712
|
+
- `sqlQuote(value)`: quotes strings for SQLite SQL.
|
|
713
|
+
- `readCursorWorkspaceFolder(workspaceDir)`: reads Cursor workspace folder
|
|
714
|
+
metadata.
|
|
715
|
+
- `cursorBubbleToMessage(bubble, fallbackTime, index)`: converts one Cursor
|
|
716
|
+
bubble into a message.
|
|
717
|
+
- `cursorRole(value)`: maps Cursor bubble roles.
|
|
718
|
+
- `cursorBubbleContext(bubble)`: extracts terminal/file selection context,
|
|
719
|
+
including nested Cursor context fields whose object keys contain file URIs.
|
|
720
|
+
- `dedupeCursorSessions(sessions)`: removes duplicate Cursor sessions, ranking
|
|
721
|
+
project agent transcripts above global `cursorDiskKV` composer records, global
|
|
722
|
+
composer records above workspace SQLite, and `aiService` prompt/apply history
|
|
723
|
+
as a breadcrumb fallback.
|
|
724
|
+
- `mergeCursorRawAssistantOnlySessions(sessions)`: attaches recovered raw
|
|
725
|
+
assistant/tool-only Cursor fragments to matching same-project Cursor sessions
|
|
726
|
+
when the evidence is strong enough.
|
|
727
|
+
- `mergeCursorRawCompanionSessions(sessions)`: attaches raw Cursor companion
|
|
728
|
+
fragments with recovered assistant/tool responses to the best matching
|
|
729
|
+
workspace or agent transcript, then drops contained raw duplicates.
|
|
730
|
+
- `cursorSessionSourcePath(session)`: returns the Cursor archive/source path
|
|
731
|
+
used when scoping incremental duplicate pruning.
|
|
732
|
+
- `pruneCursorArchivedDuplicates(env, state, options)`: removes duplicate
|
|
733
|
+
archived Cursor sessions; supervisor imports pass a touched-source-path scope
|
|
734
|
+
so old unrelated Cursor history is not repaired opportunistically.
|
|
735
|
+
|
|
736
|
+
Cline helpers:
|
|
737
|
+
|
|
738
|
+
- `clineRoots(env)`: resolves VS Code and JetBrains Cline globalStorage roots,
|
|
739
|
+
plus `AGENTLOG_CLINE_ROOT(S)` overrides.
|
|
740
|
+
- `clineTaskDirs(roots)`: finds `tasks/<task-id>` directories under Cline roots.
|
|
741
|
+
- `parseClineTaskDir(dir, root)`: normalizes one Cline task folder.
|
|
742
|
+
- `clineApiMessages(data, fallbackTime, metadata)`: parses
|
|
743
|
+
`api_conversation_history.json` into messages and tool metadata.
|
|
744
|
+
- `clineUiMessages(data, fallbackTime)`: fallback parser for `ui_messages.json`.
|
|
745
|
+
- `clineToolCall(part, metadata)`: normalizes Anthropic-style Cline tool-use
|
|
746
|
+
parts.
|
|
747
|
+
- `clineToolResult(part)`: normalizes Cline tool-result parts.
|
|
748
|
+
- `readClineCheckpointDiffs(taskDir)`: reads checkpoint metadata, diff/patch
|
|
749
|
+
files, search/replace edits, and checkpoint shadow git repos into
|
|
750
|
+
supplementary edit tool calls.
|
|
751
|
+
- `mergeClineCheckpointMessages(messages, checkpointMessages)`: attaches
|
|
752
|
+
checkpoint edit calls to the nearest assistant turn when timestamps allow.
|
|
753
|
+
|
|
754
|
+
OpenCode helpers:
|
|
755
|
+
|
|
756
|
+
- `openCodeStorageRoots(env)`: resolves global and project-scoped OpenCode
|
|
757
|
+
`storage` directories, plus override env vars.
|
|
758
|
+
- `openCodeSessionFiles(root)`: finds session JSON files.
|
|
759
|
+
- `parseOpenCodeSessionFile(file, storageRoot)`: normalizes one OpenCode
|
|
760
|
+
session plus its messages, parts, project metadata, and session diff.
|
|
761
|
+
- `openCodeMessageFiles(storageRoot, sessionId)`: finds message JSON files for
|
|
762
|
+
a session.
|
|
763
|
+
- `openCodePartFiles(storageRoot, messageId)`: finds part JSON files for a
|
|
764
|
+
message.
|
|
765
|
+
- `openCodeToolCall(part)`: normalizes OpenCode tool parts into tool-call
|
|
766
|
+
metadata.
|
|
767
|
+
- `openCodeToolResult(part)`: normalizes OpenCode tool outputs.
|
|
768
|
+
- `openCodeDiffMessage(file, fallbackTime)`: converts `session_diff` JSON into
|
|
769
|
+
a supplementary edit tool call for inline diff rendering.
|
|
770
|
+
|
|
771
|
+
Aider helpers:
|
|
772
|
+
|
|
773
|
+
- `aiderChatHistoryFiles(env)`: finds `.aider.chat.history.md` files or an
|
|
774
|
+
explicit `AIDER_CHAT_HISTORY_FILE` override.
|
|
775
|
+
- `aiderRoots(env)`: returns repo roots to scan for Aider histories, excluding
|
|
776
|
+
unsafe implicit cwd values such as the filesystem root or home directory.
|
|
777
|
+
- `parseAiderChatHistoryFile(file, env)`: normalizes one Aider markdown
|
|
778
|
+
transcript and enriches it with LLM sidecar metadata and conservative git
|
|
779
|
+
diff correlation.
|
|
780
|
+
- `parseAiderHistoryFile(file, options)`: provider-specific Aider parser used
|
|
781
|
+
by the central importer.
|
|
782
|
+
- `parseAiderLlmHistoryText(text)`: extracts model, request id, response, and
|
|
783
|
+
token usage metadata from `.aider.llm.history`.
|
|
784
|
+
- `correlateAiderMessagesWithGit(messages, cwd, options)`: attaches nearby
|
|
785
|
+
Aider auto-commit diffs as assistant edit tool calls, including multiple
|
|
786
|
+
matching commits for a single turn.
|
|
787
|
+
- `aiderMarkdownMessages(text, fallbackTime)`: splits Aider `#### <prompt>`
|
|
788
|
+
headings into user/assistant turns.
|
|
789
|
+
- `aiderSourceFiles(file, env)`: adds optional raw `.aider.llm.history` and
|
|
790
|
+
`.aider.input.history` sidecars.
|
|
791
|
+
|
|
792
|
+
Devin helpers:
|
|
793
|
+
|
|
794
|
+
- `readDevinSessions(env, options)`: resolves the Devin CLI database and reads
|
|
795
|
+
importable sessions.
|
|
796
|
+
- `devinSessionsDb(env)`: returns `AGENTLOG_DEVIN_SESSIONS_DB` or
|
|
797
|
+
the platform default Devin CLI `sessions.db` path.
|
|
798
|
+
- `readDevinSessionRows(dbPath)`: selects visible rows from Devin `sessions`.
|
|
799
|
+
- `readDevinMessageRows(dbPath)`: selects Devin `message_nodes`.
|
|
800
|
+
- `devinPromptMessages(dbPath, sessionId)`: fallback import from
|
|
801
|
+
`prompt_history`.
|
|
802
|
+
- `devinMainChain(rows, mainNodeId)`: follows the selected node chain and drops
|
|
803
|
+
alternate branches.
|
|
804
|
+
- `devinMessagesFromNode(row)`: parses `chat_message` JSON into agentlog
|
|
805
|
+
messages.
|
|
806
|
+
- `devinVisibleContent(content, toolCalls)`: keeps visible prose while dropping
|
|
807
|
+
Devin's `none` placeholders for tool-only assistant nodes.
|
|
808
|
+
- `devinIsContextUserMessage(role, content)`: skips injected Devin context.
|
|
809
|
+
- `devinNormalizeToolCall(call, message)`: converts Devin tool calls into
|
|
810
|
+
normalized metadata.
|
|
811
|
+
- `devinToolCallExtension(message, id)`: reads Devin's richer tool-call display
|
|
812
|
+
metadata extension.
|
|
813
|
+
- `devinPublicToolCall(call)`: returns the redaction-safe tool metadata stored
|
|
814
|
+
in transcripts.
|
|
815
|
+
- `devinNormalizeToolResult(content, message)`: converts Devin tool results
|
|
816
|
+
into normalized metadata.
|
|
817
|
+
- `devinToolCallLine(call)`: legacy readable formatter retained for fallback
|
|
818
|
+
parsing.
|
|
819
|
+
- `devinToolDisplayName(value)`: maps Devin tool names to concise labels.
|
|
820
|
+
- `devinToolArgument(value)`: extracts a useful tool-call argument preview.
|
|
821
|
+
- `devinTitle(messages)`: derives a fallback title from the first user prompt.
|
|
822
|
+
- `devinSessionFingerprint(dbPath, row)`: fingerprints the session row plus DB
|
|
823
|
+
files.
|
|
824
|
+
|
|
825
|
+
Gemini and Antigravity helpers:
|
|
826
|
+
|
|
827
|
+
- `readGeminiCliSessions(options, env)`: reads Gemini CLI session/checkpoint/export
|
|
828
|
+
files and coalesces prompt-log sidecars with richer chat JSONL records when
|
|
829
|
+
they share a session id.
|
|
830
|
+
- `geminiCliHistoryFiles()`: finds candidate Gemini files.
|
|
831
|
+
- `isStructuredHistoryFile(file)`: tests file extensions accepted by structured
|
|
832
|
+
importers.
|
|
833
|
+
- `isGeminiCliHistoryFile(root, file)`: filters Gemini tmp history files.
|
|
834
|
+
- `parseGeminiCliHistoryFile(file)`: parses one Gemini file.
|
|
835
|
+
- `parseGeminiCliJsonl(text, options)` and `parseGeminiCliJson(data, options)`:
|
|
836
|
+
normalize Gemini role/parts history, function calls/results, shell/code
|
|
837
|
+
execution parts, native `toolCalls[].result` entries, usage metadata, and
|
|
838
|
+
checkpoint events.
|
|
839
|
+
- `parseGenericJsonHistory(file, source, fallbackTime)`: generic JSON parser.
|
|
840
|
+
- `parseMarkdownChatFile(file, source, fallbackTime)`: Markdown chat parser.
|
|
841
|
+
- `readWindsurfSessions(options)`: disabled experimental helper retained for
|
|
842
|
+
future Windsurf decoder work.
|
|
843
|
+
- `readAntigravitySessions(options, env)`: reads Antigravity Markdown artifacts and
|
|
844
|
+
counts binary stores.
|
|
845
|
+
- `readMarkdownArtifactSessions({ ... })`: common Markdown artifact reader.
|
|
846
|
+
- `markdownArtifactSession(provider, dir, artifactNames, sourceType, detailKey)`:
|
|
847
|
+
converts one artifact directory into a session.
|
|
848
|
+
- `markdownMessages(text, source, fallbackTime)`: splits Markdown role sections
|
|
849
|
+
into messages.
|
|
850
|
+
- `markdownTitle(text)`: extracts the first Markdown H1.
|
|
851
|
+
- `artifactTitleFromDir(dir)`: turns an artifact directory name into a title.
|
|
852
|
+
- `artifactLabel(file)`: turns an artifact filename into a display label.
|
|
853
|
+
- `inferCwdFromMarkdownFiles(files)`: finds `file://` links and resolves their
|
|
854
|
+
nearest existing directory.
|
|
855
|
+
- `nearestExistingParent(value)`: walks up to the nearest existing path.
|
|
856
|
+
- `geminiProjectCwd(file)`: resolves Gemini temp project roots from
|
|
857
|
+
`.project_root` sidecar files.
|
|
858
|
+
|
|
859
|
+
Low-level import helpers:
|
|
860
|
+
|
|
861
|
+
- `structuredSessionFingerprint(session)`: fingerprints source files by path,
|
|
862
|
+
size, and mtime.
|
|
863
|
+
- `uncategorizedScope(provider)`: returns provider-scoped storage for sessions
|
|
864
|
+
that do not have a reliable cwd.
|
|
865
|
+
- `countFiles(root, predicate)`: counts matching files under a root.
|
|
866
|
+
- `hashId(value)`: returns a short SHA-256 id.
|
|
867
|
+
- `collectFiles(root, visit)`: recursively walks files.
|
|
868
|
+
- `safeStat(file)`: returns `fs.statSync` or null.
|
|
869
|
+
- `fileFingerprint(file, stat)`: creates a file fingerprint string.
|
|
870
|
+
- `reportProgress(options, summary, current, pathValue)`: emits import progress.
|
|
871
|
+
- `recordImportSkip(summary, options, reason, session, details)`: records a
|
|
872
|
+
skip reason and, when requested, a per-session skip explanation.
|
|
873
|
+
- `reportDiscoveryProgress(options, event)`: emits discovery progress.
|
|
874
|
+
- `archivedSessionKeys(env)`: returns archived provider/session keys.
|
|
875
|
+
- `archiveSessionKey(provider, sessionId)`: formats provider/session key.
|
|
876
|
+
- `alreadyImportedFile(state, fingerprint, archived, provider)`: checks file
|
|
877
|
+
import state.
|
|
878
|
+
- `alreadyImported(state, sessionId, fingerprint, archived, provider)`: checks
|
|
879
|
+
session import state.
|
|
880
|
+
- `readTextMaybeZstd(file)`: reads plain or zstd-compressed JSONL.
|
|
881
|
+
- `loadImportState(env)`: reads import state JSON.
|
|
882
|
+
- `saveImportState(state, env)`: writes import state JSON.
|
|
883
|
+
- `firstString(...values)`: returns the first non-empty string.
|
|
884
|
+
- `firstLine(value)`: returns the first non-empty line.
|
|
885
|
+
|
|
886
|
+
## `src/importers/shared.js`
|
|
887
|
+
|
|
888
|
+
Shared importer helpers.
|
|
889
|
+
|
|
890
|
+
Exports:
|
|
891
|
+
|
|
892
|
+
- `parseSince(value)`: parses import windows such as `30d`, `12h`, `60m`, or
|
|
893
|
+
`all`.
|
|
894
|
+
|
|
895
|
+
## `src/mcp.js`
|
|
896
|
+
|
|
897
|
+
MCP stdio server for recall/search tools.
|
|
898
|
+
|
|
899
|
+
Exports:
|
|
900
|
+
|
|
901
|
+
- `runMcpServer(input, output, env)`: reads JSON-RPC messages and writes MCP
|
|
902
|
+
responses over stdio.
|
|
903
|
+
- `handleRequest(message, env)`: handles initialize, tool listing, and tool
|
|
904
|
+
calls.
|
|
905
|
+
- `McpStdioTransport`: exported transport class used by tests or callers.
|
|
906
|
+
|
|
907
|
+
## `src/paths.js`
|
|
908
|
+
|
|
909
|
+
Filesystem path resolution and JSON helpers.
|
|
910
|
+
|
|
911
|
+
Exports:
|
|
912
|
+
|
|
913
|
+
- `ensureBaseDirs(p)`: creates the core agentlog directories.
|
|
914
|
+
- `ensureDir(dir)`: creates one directory recursively.
|
|
915
|
+
- `homeDir(env)`: resolves `AGENTLOG_HOME` or `~/.agentlog`.
|
|
916
|
+
- `paths(env)`: returns all important agentlog paths.
|
|
917
|
+
- `readJson(file, fallback)`: reads JSON with fallback for missing files.
|
|
918
|
+
- `writeJson(file, value)`: writes pretty JSON with private file mode.
|
|
919
|
+
|
|
920
|
+
## `src/redaction.js`
|
|
921
|
+
|
|
922
|
+
Redaction config, env-secret discovery, text redaction, and marker rendering.
|
|
923
|
+
|
|
924
|
+
Exports:
|
|
925
|
+
|
|
926
|
+
- `loadEnvValues(cwd, names, env)`: loads configured env values from process env
|
|
927
|
+
and `.env` files.
|
|
928
|
+
- `loadRedactionConfig(env)`: reads `~/.agentlog/redaction.yaml`.
|
|
929
|
+
- `mergeSummaries(target, source)`: merges redaction count summaries.
|
|
930
|
+
- `parseRedactionYaml(text)`: parses the small supported YAML subset.
|
|
931
|
+
- `redactText(input, options)`: applies built-in, env, high-entropy, and custom
|
|
932
|
+
redactions.
|
|
933
|
+
- `styleRedactionMarkersForMarkdown(input)`: turns `[REDACTED:...]` markers into
|
|
934
|
+
styled Markdown HTML.
|
|
935
|
+
|
|
936
|
+
Internal helpers:
|
|
937
|
+
|
|
938
|
+
- `parseInlineList(value)`: parses YAML inline lists.
|
|
939
|
+
- `stripYamlString(value)`: removes simple YAML quotes.
|
|
940
|
+
- `envFilesFor(cwd)`: walks upward collecting `.env` file candidates.
|
|
941
|
+
- `safeRedactionKind(value)`: normalizes marker kind labels.
|
|
942
|
+
- `escapeHtml(value)`: HTML-escapes marker labels.
|
|
943
|
+
- `replaceMatches(text, regex, replacement, summary, name)`: replaces and counts
|
|
944
|
+
matches.
|
|
945
|
+
- `looksHighEntropy(value)`: detects likely high-entropy env assignments.
|
|
946
|
+
- `increment(summary, key, amount)`: increments a summary count.
|
|
947
|
+
- `escapeRegExp(value)`: escapes a literal for regex construction.
|
|
948
|
+
|
|
949
|
+
## `src/repo.js`
|
|
950
|
+
|
|
951
|
+
Repo identity and path-scope fallback logic.
|
|
952
|
+
|
|
953
|
+
Exports:
|
|
954
|
+
|
|
955
|
+
- `canonicalRepo(cwd)`: returns a repo key from git remote, override file, or
|
|
956
|
+
stable local path hash.
|
|
957
|
+
- `canonicalizeRemote(remote)`: normalizes common git remote URL forms.
|
|
958
|
+
- `normalizePathForHash(cwd)`: resolves and home-normalizes a path before
|
|
959
|
+
hashing.
|
|
960
|
+
- `readRepoOverride(cwd)`: reads `.agentlog-repo` from the current tree.
|
|
961
|
+
|
|
962
|
+
Internal helpers:
|
|
963
|
+
|
|
964
|
+
- `normalizeHostPath(host, repoPath)`: normalizes host/repo strings.
|
|
965
|
+
- `stripGit(value)`: removes trailing `.git`.
|
|
966
|
+
- `runGit(cwd, args)`: executes git commands quietly.
|
|
967
|
+
- `findUp(start, filename)`: searches upward for a file.
|
|
968
|
+
|
|
969
|
+
## `src/search.js`
|
|
970
|
+
|
|
971
|
+
Recall search, history listing, filters, and the event-first keyword index.
|
|
972
|
+
|
|
973
|
+
Exports:
|
|
974
|
+
|
|
975
|
+
- `buildIndex(env)`: reads canonical events when present, falls back to
|
|
976
|
+
transcripts, chunks searchable text, and writes the search index.
|
|
977
|
+
- `chunkText(text, maxTokens, overlap)`: chunks long content for indexing.
|
|
978
|
+
- `listHistorySessions(options, env)`: returns filtered archived session rows.
|
|
979
|
+
- `listRecentSessions(limit, options, env)`: returns recent session rows.
|
|
980
|
+
- `loadIndex(env)`: loads or rebuilds the index.
|
|
981
|
+
- `reindexIfNeeded(env)`: rebuilds the index when stale and not paused.
|
|
982
|
+
- `sessionHistoryTime(session)`: returns display-safe session times, including
|
|
983
|
+
hiding Cursor raw-salvage timestamps that were synthesized from SQLite mtimes.
|
|
984
|
+
- `searchPastSessions(query, options, env)`: searches the event index first,
|
|
985
|
+
then legacy markdown/transcript fallback.
|
|
986
|
+
- `tokenize(text)`: lowercases and tokenizes searchable text.
|
|
987
|
+
|
|
988
|
+
Internal helpers:
|
|
989
|
+
|
|
990
|
+
- `docsForEvents(session, events)`: converts canonical events into index
|
|
991
|
+
documents with event ids, event kinds, message indexes, and rendered text.
|
|
992
|
+
- `docsForTranscript(session, messages)`: builds legacy transcript index
|
|
993
|
+
documents when no event file exists.
|
|
994
|
+
- `searchMarkdownSessions(query, options, env)`: legacy conversation Markdown
|
|
995
|
+
search with `rg`/JS fallback.
|
|
996
|
+
- `searchIndexedSessions(query, options, env)`: searches the event/transcript
|
|
997
|
+
JSON index and aggregates hits by session.
|
|
998
|
+
- `ripgrepMatches(queryTokens, files)`: runs `rg --json`.
|
|
999
|
+
- `jsLineMatches(queryTokens, files)`: slow in-process line search fallback.
|
|
1000
|
+
- `readLineWindow(file, lineNumber, radius)`: reads context around a match.
|
|
1001
|
+
- `inferRoleFromMarkdown(file, lineNumber)`: finds nearest message heading.
|
|
1002
|
+
- `escapeRegex(value)`: escapes query tokens for regex.
|
|
1003
|
+
- `bm25Score(doc, queryTokens, index)`: scores one indexed chunk.
|
|
1004
|
+
- `excerpt(text, queryTokens)`: builds a compact result excerpt.
|
|
1005
|
+
- `inferCallingRepo(cwd)`: infers repo key from caller cwd.
|
|
1006
|
+
- `displayRepoLabel(session)`: chooses repo/scope/path display text.
|
|
1007
|
+
- `displayScopeLabel(scope)`: formats known scope labels.
|
|
1008
|
+
- `compactHomePath(value)`: shortens home-relative paths.
|
|
1009
|
+
- `normalizeSessionFilter(options)`: normalizes provider/source/repo filters.
|
|
1010
|
+
- `normalizeProviderFilter(value)`: maps provider aliases.
|
|
1011
|
+
- `matchesSessionFilter(session, filter)`: applies provider/source/repo/date
|
|
1012
|
+
filters.
|
|
1013
|
+
- `matchesRepoFilter(session, repoFilter)`: matches repo, scope, cwd, or label.
|
|
1014
|
+
- `indexIsStale(indexPath, env)`: detects whether index rebuild is needed.
|
|
1015
|
+
- `parseSinceFilter(value)`: parses search history windows.
|
|
1016
|
+
|
|
1017
|
+
## `src/sources.js`
|
|
1018
|
+
|
|
1019
|
+
Shared source ordering and labels.
|
|
1020
|
+
|
|
1021
|
+
Exports:
|
|
1022
|
+
|
|
1023
|
+
- `SOURCE_GROUPS`: grouped provider/source metadata for UI ordering.
|
|
1024
|
+
- `IMPORT_SOURCE_ORDER`: default source order for `--source all`.
|
|
1025
|
+
- `HISTORY_PROVIDER_OPTIONS`: flattened source option list.
|
|
1026
|
+
- `sourceLabel(source)`: returns display label for a source key.
|
|
1027
|
+
|
|
1028
|
+
## `src/supervisor.js`
|
|
1029
|
+
|
|
1030
|
+
Background process that imports, indexes, collects telemetry, and syncs.
|
|
1031
|
+
|
|
1032
|
+
Exports:
|
|
1033
|
+
|
|
1034
|
+
- `runSupervisorForeground(env)`: runs the supervisor loop in the current
|
|
1035
|
+
process.
|
|
1036
|
+
- `startSupervisorDetached()`: starts the foreground supervisor detached.
|
|
1037
|
+
- `supervisorImportOptionsForSource(source, config)`: builds supervisor import
|
|
1038
|
+
options with the configured rolling window and Cursor raw recovery disabled.
|
|
1039
|
+
- `supervisorImportResultLog(result, source)`: formats supervisor import/prune
|
|
1040
|
+
log lines.
|
|
1041
|
+
- `stopSupervisor(env)`: sends SIGTERM to the recorded supervisor process.
|
|
1042
|
+
- `supervisorStatus(env)`: reports supervisor PID and running state.
|
|
1043
|
+
- `tick(env)`: runs one import, reindex, and sync cycle.
|
|
1044
|
+
|
|
1045
|
+
Internal helpers:
|
|
1046
|
+
|
|
1047
|
+
- `readPid(env)`: reads the supervisor PID file.
|
|
1048
|
+
- `isAlive(pid)`: checks whether a PID is alive.
|
|
1049
|
+
- `log(message, env)`: appends to supervisor log.
|
|
1050
|
+
|
|
1051
|
+
## `src/sync.js`
|
|
1052
|
+
|
|
1053
|
+
Remote archive sync to file targets or S3-compatible object storage. Sync is
|
|
1054
|
+
currently upload-only and writes under a device namespace such as
|
|
1055
|
+
`agentlog/devices/<device>/...`; snapshots write under
|
|
1056
|
+
`agentlog/snapshots/<timestamp>/<device>/...`. Bucket-scoped R2 S3 API URLs such
|
|
1057
|
+
as `https://<account-id>.r2.cloudflarestorage.com/<bucket>` are normalized into
|
|
1058
|
+
endpoint plus bucket during config/target resolution.
|
|
1059
|
+
|
|
1060
|
+
Exports:
|
|
1061
|
+
|
|
1062
|
+
- `configureRemoteFromFlags(flags, env)`: persists remote sync settings from CLI
|
|
1063
|
+
flags.
|
|
1064
|
+
- `hasRemoteTarget(cfg, env)`: reports whether a remote target is configured.
|
|
1065
|
+
- `listLocalArchiveObjects(env, prefix)`: lists local archive objects as remote
|
|
1066
|
+
keys with hashes.
|
|
1067
|
+
- `parseListBucketResult(xml)`: parses S3 ListObjectsV2 XML.
|
|
1068
|
+
- `remoteTargetFromFlags(flags, cfg, env, options)`: resolves a remote target
|
|
1069
|
+
from flags, config, and env.
|
|
1070
|
+
- `remoteObjectPrefix(target, cfg, options)`: returns the device-scoped or
|
|
1071
|
+
snapshot-scoped remote key prefix.
|
|
1072
|
+
- `snapshotArchive(options, env)`: uploads a point-in-time copy to the configured
|
|
1073
|
+
remote target.
|
|
1074
|
+
- `syncArchive(options, env)`: syncs archive objects to configured/flag target.
|
|
1075
|
+
- `syncArchiveIfConfigured(env, options)`: no-ops unless a remote target exists.
|
|
1076
|
+
|
|
1077
|
+
Internal helpers:
|
|
1078
|
+
|
|
1079
|
+
- `syncArchiveToS3(target, options, env)`: uploads changed objects to S3/R2.
|
|
1080
|
+
- `syncArchiveToDirectory(target, options, env)`: copies changed objects to a
|
|
1081
|
+
local/file URL target.
|
|
1082
|
+
- `listS3Objects(target, prefix)`: lists existing remote S3 objects.
|
|
1083
|
+
- `putS3Object(target, key, body)`: uploads one S3 object.
|
|
1084
|
+
- `s3Request(target, request)`: signs and sends one S3-compatible HTTP request.
|
|
1085
|
+
- `authorizationHeader({ target, method, pathName, query, headers, now })`:
|
|
1086
|
+
builds AWS Signature V4 authorization.
|
|
1087
|
+
- `signingKey(secret, date, region)`: derives the SigV4 signing key.
|
|
1088
|
+
- `s3Path(bucket, key)`: builds path-style S3 request paths.
|
|
1089
|
+
- `canonicalQueryString(query, includePrefix)`: canonicalizes query params.
|
|
1090
|
+
- `awsEncode(value)`: AWS URI-encodes a path/query component.
|
|
1091
|
+
- `xmlValue(xml, name)`: extracts one XML tag value.
|
|
1092
|
+
- `decodeXml(value)`: decodes minimal XML entities.
|
|
1093
|
+
- `reportSyncProgress(options, summary, current, total, key)`: emits sync
|
|
1094
|
+
progress.
|
|
1095
|
+
- `loadSyncState(env)`: reads sync state JSON.
|
|
1096
|
+
- `saveSyncState(state, env)`: writes sync state JSON.
|
|
1097
|
+
- `contentTypeForKey(key)`: chooses upload content type.
|
|
1098
|
+
- `walk(dir, visit)`: recursively walks archive files.
|
|
1099
|
+
- `safeStat(file)`: returns stat or null.
|
|
1100
|
+
- `stripPrefix(key, prefix)`: removes configured remote prefix.
|
|
1101
|
+
- `normalizePrefix(prefix)`: normalizes remote prefix.
|
|
1102
|
+
- `fileUrlPath(endpoint)`: converts file URL/string endpoint to path.
|
|
1103
|
+
- `value(input)`: returns the first non-empty config/env value.
|
|
1104
|
+
- `inferRemoteType(endpoint)`: infers remote backend from endpoint.
|
|
1105
|
+
- `sha256Hex(value)`: SHA-256 hex hash.
|
|
1106
|
+
- `hmac(key, value)`: HMAC-SHA256 buffer.
|
|
1107
|
+
- `hmacHex(key, value)`: HMAC-SHA256 hex.
|
|
1108
|
+
- `amzDate(date)`: formats SigV4 date strings.
|