xtctx 0.3.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +317 -122
- package/LICENSE +21 -21
- package/README.md +154 -121
- package/dist/src/cli/disconnect.d.ts +8 -0
- package/dist/src/cli/disconnect.d.ts.map +1 -0
- package/dist/src/cli/disconnect.js +42 -0
- package/dist/src/cli/disconnect.js.map +1 -0
- package/dist/src/cli/hook.d.ts +7 -0
- package/dist/src/cli/hook.d.ts.map +1 -0
- package/dist/src/cli/hook.js +32 -0
- package/dist/src/cli/hook.js.map +1 -0
- package/dist/src/cli/index.d.ts.map +1 -1
- package/dist/src/cli/index.js +86 -33
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/setup.d.ts +8 -0
- package/dist/src/cli/setup.d.ts.map +1 -0
- package/dist/src/cli/setup.js +76 -0
- package/dist/src/cli/setup.js.map +1 -0
- package/dist/src/cli/status.d.ts +7 -0
- package/dist/src/cli/status.d.ts.map +1 -0
- package/dist/src/cli/status.js +133 -0
- package/dist/src/cli/status.js.map +1 -0
- package/dist/src/config/disconnect.d.ts +34 -0
- package/dist/src/config/disconnect.d.ts.map +1 -0
- package/dist/src/config/disconnect.js +386 -0
- package/dist/src/config/disconnect.js.map +1 -0
- package/dist/src/config/managed-block.d.ts +29 -0
- package/dist/src/config/managed-block.d.ts.map +1 -0
- package/dist/src/config/managed-block.js +67 -0
- package/dist/src/config/managed-block.js.map +1 -0
- package/dist/src/config/mcp-config.d.ts +93 -0
- package/dist/src/config/mcp-config.d.ts.map +1 -0
- package/dist/src/config/mcp-config.js +556 -0
- package/dist/src/config/mcp-config.js.map +1 -0
- package/dist/src/config/setup.d.ts +39 -0
- package/dist/src/config/setup.d.ts.map +1 -0
- package/dist/src/config/setup.js +379 -0
- package/dist/src/config/setup.js.map +1 -0
- package/dist/src/config/skills.d.ts +73 -0
- package/dist/src/config/skills.d.ts.map +1 -0
- package/dist/src/config/skills.js +427 -0
- package/dist/src/config/skills.js.map +1 -0
- package/dist/src/handoff/embeddings.d.ts +26 -0
- package/dist/src/handoff/embeddings.d.ts.map +1 -0
- package/dist/src/handoff/embeddings.js +132 -0
- package/dist/src/handoff/embeddings.js.map +1 -0
- package/dist/src/handoff/sqlite-index.d.ts +52 -0
- package/dist/src/handoff/sqlite-index.d.ts.map +1 -0
- package/dist/src/handoff/sqlite-index.js +905 -0
- package/dist/src/handoff/sqlite-index.js.map +1 -0
- package/dist/src/handoff/types.d.ts +63 -0
- package/dist/src/handoff/types.d.ts.map +1 -0
- package/dist/src/handoff/types.js +2 -0
- package/dist/src/handoff/types.js.map +1 -0
- package/dist/src/handoff/vector.d.ts +4 -0
- package/dist/src/handoff/vector.d.ts.map +1 -0
- package/dist/src/handoff/vector.js +31 -0
- package/dist/src/handoff/vector.js.map +1 -0
- package/dist/src/mcp/server.d.ts +3 -20
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +90 -205
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools/continuity.d.ts +21 -0
- package/dist/src/mcp/tools/continuity.d.ts.map +1 -0
- package/dist/src/mcp/tools/continuity.js +55 -0
- package/dist/src/mcp/tools/continuity.js.map +1 -0
- package/dist/src/mcp/tools/manifest.d.ts +40 -0
- package/dist/src/mcp/tools/manifest.d.ts.map +1 -0
- package/dist/src/mcp/tools/manifest.js +105 -0
- package/dist/src/mcp/tools/manifest.js.map +1 -0
- package/dist/src/mcp/tools/sessions.d.ts +18 -31
- package/dist/src/mcp/tools/sessions.d.ts.map +1 -1
- package/dist/src/mcp/tools/sessions.js +109 -16
- package/dist/src/mcp/tools/sessions.js.map +1 -1
- package/dist/src/runtime/services.d.ts +11 -38
- package/dist/src/runtime/services.d.ts.map +1 -1
- package/dist/src/runtime/services.js +61 -200
- package/dist/src/runtime/services.js.map +1 -1
- package/dist/src/scrapers/antigravity.d.ts +52 -0
- package/dist/src/scrapers/antigravity.d.ts.map +1 -0
- package/dist/src/scrapers/antigravity.js +869 -0
- package/dist/src/scrapers/antigravity.js.map +1 -0
- package/dist/src/scrapers/base.d.ts +53 -1
- package/dist/src/scrapers/base.d.ts.map +1 -1
- package/dist/src/scrapers/base.js +93 -4
- package/dist/src/scrapers/base.js.map +1 -1
- package/dist/src/scrapers/claude-code.d.ts +37 -6
- package/dist/src/scrapers/claude-code.d.ts.map +1 -1
- package/dist/src/scrapers/claude-code.js +214 -40
- package/dist/src/scrapers/claude-code.js.map +1 -1
- package/dist/src/scrapers/codex.d.ts +36 -6
- package/dist/src/scrapers/codex.d.ts.map +1 -1
- package/dist/src/scrapers/codex.js +283 -60
- package/dist/src/scrapers/codex.js.map +1 -1
- package/dist/src/scrapers/copilot-cli.d.ts +34 -0
- package/dist/src/scrapers/copilot-cli.d.ts.map +1 -0
- package/dist/src/scrapers/copilot-cli.js +342 -0
- package/dist/src/scrapers/copilot-cli.js.map +1 -0
- package/dist/src/scrapers/copilot.d.ts +41 -8
- package/dist/src/scrapers/copilot.d.ts.map +1 -1
- package/dist/src/scrapers/copilot.js +256 -118
- package/dist/src/scrapers/copilot.js.map +1 -1
- package/dist/src/scrapers/cursor.d.ts +24 -9
- package/dist/src/scrapers/cursor.d.ts.map +1 -1
- package/dist/src/scrapers/cursor.js +259 -152
- package/dist/src/scrapers/cursor.js.map +1 -1
- package/dist/src/scrapers/index.d.ts +23 -0
- package/dist/src/scrapers/index.d.ts.map +1 -0
- package/dist/src/scrapers/index.js +22 -0
- package/dist/src/scrapers/index.js.map +1 -0
- package/dist/src/scrapers/opencode.d.ts +37 -0
- package/dist/src/scrapers/opencode.d.ts.map +1 -0
- package/dist/src/scrapers/opencode.js +277 -0
- package/dist/src/scrapers/opencode.js.map +1 -0
- package/dist/src/scrapers/registry.d.ts +1 -0
- package/dist/src/scrapers/registry.d.ts.map +1 -1
- package/dist/src/scrapers/registry.js +3 -0
- package/dist/src/scrapers/registry.js.map +1 -1
- package/dist/src/tools/sources.d.ts +28 -0
- package/dist/src/tools/sources.d.ts.map +1 -0
- package/dist/src/tools/sources.js +149 -0
- package/dist/src/tools/sources.js.map +1 -0
- package/dist/src/types/config.d.ts +24 -37
- package/dist/src/types/config.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +0 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +0 -2
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/scraper.d.ts +34 -5
- package/dist/src/types/scraper.d.ts.map +1 -1
- package/dist/src/utils/atomic-file.d.ts +8 -0
- package/dist/src/utils/atomic-file.d.ts.map +1 -0
- package/dist/src/utils/atomic-file.js +15 -0
- package/dist/src/utils/atomic-file.js.map +1 -0
- package/dist/src/utils/errors.d.ts +7 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +16 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/package-info.d.ts +11 -0
- package/dist/src/utils/package-info.d.ts.map +1 -0
- package/dist/src/utils/package-info.js +30 -0
- package/dist/src/utils/package-info.js.map +1 -0
- package/dist/src/utils/project-scope.d.ts +19 -0
- package/dist/src/utils/project-scope.d.ts.map +1 -0
- package/dist/src/utils/project-scope.js +61 -0
- package/dist/src/utils/project-scope.js.map +1 -0
- package/package.json +70 -66
- package/dist/src/api/routes/config.d.ts +0 -4
- package/dist/src/api/routes/config.d.ts.map +0 -1
- package/dist/src/api/routes/config.js +0 -61
- package/dist/src/api/routes/config.js.map +0 -1
- package/dist/src/api/routes/knowledge.d.ts +0 -4
- package/dist/src/api/routes/knowledge.d.ts.map +0 -1
- package/dist/src/api/routes/knowledge.js +0 -40
- package/dist/src/api/routes/knowledge.js.map +0 -1
- package/dist/src/api/routes/search.d.ts +0 -7
- package/dist/src/api/routes/search.d.ts.map +0 -1
- package/dist/src/api/routes/search.js +0 -108
- package/dist/src/api/routes/search.js.map +0 -1
- package/dist/src/api/routes/sources.d.ts +0 -12
- package/dist/src/api/routes/sources.d.ts.map +0 -1
- package/dist/src/api/routes/sources.js +0 -70
- package/dist/src/api/routes/sources.js.map +0 -1
- package/dist/src/api/server.d.ts +0 -26
- package/dist/src/api/server.d.ts.map +0 -1
- package/dist/src/api/server.js +0 -312
- package/dist/src/api/server.js.map +0 -1
- package/dist/src/cli/ingest.d.ts +0 -6
- package/dist/src/cli/ingest.d.ts.map +0 -1
- package/dist/src/cli/ingest.js +0 -11
- package/dist/src/cli/ingest.js.map +0 -1
- package/dist/src/cli/init.d.ts +0 -6
- package/dist/src/cli/init.d.ts.map +0 -1
- package/dist/src/cli/init.js +0 -105
- package/dist/src/cli/init.js.map +0 -1
- package/dist/src/cli/serve.d.ts +0 -7
- package/dist/src/cli/serve.d.ts.map +0 -1
- package/dist/src/cli/serve.js +0 -100
- package/dist/src/cli/serve.js.map +0 -1
- package/dist/src/cli/sync.d.ts +0 -5
- package/dist/src/cli/sync.d.ts.map +0 -1
- package/dist/src/cli/sync.js +0 -13
- package/dist/src/cli/sync.js.map +0 -1
- package/dist/src/compaction/pipeline.d.ts +0 -19
- package/dist/src/compaction/pipeline.d.ts.map +0 -1
- package/dist/src/compaction/pipeline.js +0 -37
- package/dist/src/compaction/pipeline.js.map +0 -1
- package/dist/src/compaction/providers/cli.d.ts +0 -13
- package/dist/src/compaction/providers/cli.d.ts.map +0 -1
- package/dist/src/compaction/providers/cli.js +0 -60
- package/dist/src/compaction/providers/cli.js.map +0 -1
- package/dist/src/compaction/rule-based.d.ts +0 -8
- package/dist/src/compaction/rule-based.d.ts.map +0 -1
- package/dist/src/compaction/rule-based.js +0 -120
- package/dist/src/compaction/rule-based.js.map +0 -1
- package/dist/src/config/loader.d.ts +0 -12
- package/dist/src/config/loader.d.ts.map +0 -1
- package/dist/src/config/loader.js +0 -76
- package/dist/src/config/loader.js.map +0 -1
- package/dist/src/config/mappings/claude-code.d.ts +0 -3
- package/dist/src/config/mappings/claude-code.d.ts.map +0 -1
- package/dist/src/config/mappings/claude-code.js +0 -31
- package/dist/src/config/mappings/claude-code.js.map +0 -1
- package/dist/src/config/mappings/codex.d.ts +0 -3
- package/dist/src/config/mappings/codex.d.ts.map +0 -1
- package/dist/src/config/mappings/codex.js +0 -31
- package/dist/src/config/mappings/codex.js.map +0 -1
- package/dist/src/config/mappings/copilot.d.ts +0 -3
- package/dist/src/config/mappings/copilot.d.ts.map +0 -1
- package/dist/src/config/mappings/copilot.js +0 -33
- package/dist/src/config/mappings/copilot.js.map +0 -1
- package/dist/src/config/mappings/cursor.d.ts +0 -3
- package/dist/src/config/mappings/cursor.d.ts.map +0 -1
- package/dist/src/config/mappings/cursor.js +0 -29
- package/dist/src/config/mappings/cursor.js.map +0 -1
- package/dist/src/config/sync.d.ts +0 -13
- package/dist/src/config/sync.d.ts.map +0 -1
- package/dist/src/config/sync.js +0 -96
- package/dist/src/config/sync.js.map +0 -1
- package/dist/src/ingestion/coordinator.d.ts +0 -37
- package/dist/src/ingestion/coordinator.d.ts.map +0 -1
- package/dist/src/ingestion/coordinator.js +0 -127
- package/dist/src/ingestion/coordinator.js.map +0 -1
- package/dist/src/ingestion/daemon.d.ts +0 -17
- package/dist/src/ingestion/daemon.d.ts.map +0 -1
- package/dist/src/ingestion/daemon.js +0 -35
- package/dist/src/ingestion/daemon.js.map +0 -1
- package/dist/src/ingestion/watcher.d.ts +0 -19
- package/dist/src/ingestion/watcher.d.ts.map +0 -1
- package/dist/src/ingestion/watcher.js +0 -70
- package/dist/src/ingestion/watcher.js.map +0 -1
- package/dist/src/knowledge/autotag.d.ts +0 -3
- package/dist/src/knowledge/autotag.d.ts.map +0 -1
- package/dist/src/knowledge/autotag.js +0 -24
- package/dist/src/knowledge/autotag.js.map +0 -1
- package/dist/src/knowledge/dedup.d.ts +0 -7
- package/dist/src/knowledge/dedup.d.ts.map +0 -1
- package/dist/src/knowledge/dedup.js +0 -15
- package/dist/src/knowledge/dedup.js.map +0 -1
- package/dist/src/knowledge/repository.d.ts +0 -12
- package/dist/src/knowledge/repository.d.ts.map +0 -1
- package/dist/src/knowledge/repository.js +0 -74
- package/dist/src/knowledge/repository.js.map +0 -1
- package/dist/src/mcp/tools/config.d.ts +0 -36
- package/dist/src/mcp/tools/config.d.ts.map +0 -1
- package/dist/src/mcp/tools/config.js +0 -54
- package/dist/src/mcp/tools/config.js.map +0 -1
- package/dist/src/mcp/tools/knowledge.d.ts +0 -17
- package/dist/src/mcp/tools/knowledge.d.ts.map +0 -1
- package/dist/src/mcp/tools/knowledge.js +0 -46
- package/dist/src/mcp/tools/knowledge.js.map +0 -1
- package/dist/src/mcp/tools/search.d.ts +0 -22
- package/dist/src/mcp/tools/search.d.ts.map +0 -1
- package/dist/src/mcp/tools/search.js +0 -30
- package/dist/src/mcp/tools/search.js.map +0 -1
- package/dist/src/mcp/tools/write.d.ts +0 -38
- package/dist/src/mcp/tools/write.d.ts.map +0 -1
- package/dist/src/mcp/tools/write.js +0 -97
- package/dist/src/mcp/tools/write.js.map +0 -1
- package/dist/src/runtime/ingestion.d.ts +0 -17
- package/dist/src/runtime/ingestion.d.ts.map +0 -1
- package/dist/src/runtime/ingestion.js +0 -106
- package/dist/src/runtime/ingestion.js.map +0 -1
- package/dist/src/scrapers/gemini.d.ts +0 -17
- package/dist/src/scrapers/gemini.d.ts.map +0 -1
- package/dist/src/scrapers/gemini.js +0 -245
- package/dist/src/scrapers/gemini.js.map +0 -1
- package/dist/src/store/embeddings.d.ts +0 -9
- package/dist/src/store/embeddings.d.ts.map +0 -1
- package/dist/src/store/embeddings.js +0 -28
- package/dist/src/store/embeddings.js.map +0 -1
- package/dist/src/store/lance.d.ts +0 -25
- package/dist/src/store/lance.d.ts.map +0 -1
- package/dist/src/store/lance.js +0 -74
- package/dist/src/store/lance.js.map +0 -1
- package/dist/src/store/search.d.ts +0 -18
- package/dist/src/store/search.d.ts.map +0 -1
- package/dist/src/store/search.js +0 -55
- package/dist/src/store/search.js.map +0 -1
- package/dist/src/types/compaction.d.ts +0 -29
- package/dist/src/types/compaction.d.ts.map +0 -1
- package/dist/src/types/compaction.js +0 -2
- package/dist/src/types/compaction.js.map +0 -1
- package/dist/src/types/context.d.ts +0 -33
- package/dist/src/types/context.d.ts.map +0 -1
- package/dist/src/types/context.js +0 -18
- package/dist/src/types/context.js.map +0 -1
- package/dist/src/utils/retry.d.ts +0 -11
- package/dist/src/utils/retry.d.ts.map +0 -1
- package/dist/src/utils/retry.js +0 -46
- package/dist/src/utils/retry.js.map +0 -1
- package/dist/src/utils/shutdown.d.ts +0 -25
- package/dist/src/utils/shutdown.d.ts.map +0 -1
- package/dist/src/utils/shutdown.js +0 -56
- package/dist/src/utils/shutdown.js.map +0 -1
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/index-Nuadr5ox.css +0 -1
- package/dist/web/assets/index-aA0u8eXA.js +0 -3504
- package/dist/web/assets/primeicons-C6QP2o4f.woff2 +0 -0
- package/dist/web/assets/primeicons-DMOk5skT.eot +0 -0
- package/dist/web/assets/primeicons-Dr5RGzOO.svg +0 -345
- package/dist/web/assets/primeicons-MpK4pl85.ttf +0 -0
- package/dist/web/assets/primeicons-WjwUDZjB.woff +0 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +0 -21
- package/dist/web/index.html +0 -21
- package/dist/web/site.webmanifest +0 -19
- package/dist/web/vite.svg +0 -1
|
@@ -1,40 +1,70 @@
|
|
|
1
|
-
import { readFile,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { glob } from "glob";
|
|
5
|
+
import { AbstractScraper, estimateTokens, toDate } from "./base.js";
|
|
6
|
+
import { pathMatchesProject } from "../utils/project-scope.js";
|
|
7
|
+
/** VS Code stores Copilot Chat history in workspaceStorage SQLite files. */
|
|
8
|
+
const SESSIONS_KEY = "interactive.sessions";
|
|
9
|
+
const SCRAPER_NAME = "copilot";
|
|
10
|
+
/**
|
|
11
|
+
* Shapes that the Copilot scraper tolerates silently without logging.
|
|
12
|
+
* Each entry documents the shape being accepted and why it is not drift.
|
|
13
|
+
* Anything not listed here that falls outside the happy path MUST warn
|
|
14
|
+
* (or throw, for required-schema violations).
|
|
15
|
+
*/
|
|
16
|
+
export const ACCEPTED_DEGRADATIONS = {
|
|
17
|
+
/** Workspace has no state.vscdb yet — pristine VS Code install. */
|
|
18
|
+
missingStateVscdb: "workspace directory has no state.vscdb yet",
|
|
19
|
+
/** workspaceStorage root missing — VS Code not installed. */
|
|
20
|
+
missingWorkspaceStorage: "workspaceStorage directory does not exist",
|
|
21
|
+
/** better-sqlite3 native module absent — Copilot ingestion is opt-in. */
|
|
22
|
+
missingSqliteBinding: "better-sqlite3 native module unavailable",
|
|
23
|
+
/** State.vscdb has no interactive.sessions row — workspace never used Copilot chat. */
|
|
24
|
+
noInteractiveSessionsKey: "workspaceStorage has no chat history",
|
|
25
|
+
/** ItemTable shape varies across VS Code versions; tolerate open/query failure. */
|
|
26
|
+
unreadableItemTable: "ItemTable row is unreadable or unexpected shape",
|
|
27
|
+
/** A canceled request is intentionally skipped — not drift. */
|
|
28
|
+
canceledRequest: "request was canceled by the user",
|
|
29
|
+
/** Some sessions legitimately have no user-text (agent-only runs); skip silently. */
|
|
30
|
+
emptyUserText: "request has no user-visible text parts",
|
|
31
|
+
/** Empty assistant response (thinking timeout etc.) — not drift. */
|
|
32
|
+
emptyAssistantText: "request has no assistant response text",
|
|
33
|
+
/** Extra/unknown fields alongside known ones are forward-compatible. */
|
|
34
|
+
unknownFieldsAlongside: "unknown sibling field added by a newer VS Code version",
|
|
10
35
|
};
|
|
11
|
-
|
|
12
|
-
|
|
36
|
+
function warnDrift(sourcePath, surprise, recordsAffected) {
|
|
37
|
+
console.warn(`[${SCRAPER_NAME}] schema-drift surprise at ${sourcePath}: ${surprise} ` +
|
|
38
|
+
`(records affected: ${recordsAffected})`);
|
|
39
|
+
}
|
|
40
|
+
export class CopilotScraper extends AbstractScraper {
|
|
41
|
+
workspaceStoragePath;
|
|
42
|
+
projectRoot;
|
|
13
43
|
tool = "copilot";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
constructor(
|
|
45
|
+
/** Path to %APPDATA%/Code/User/workspaceStorage (or a test stand-in). */
|
|
46
|
+
workspaceStoragePath, stateDir, projectRoot) {
|
|
47
|
+
super(stateDir);
|
|
48
|
+
this.workspaceStoragePath = workspaceStoragePath;
|
|
49
|
+
this.projectRoot = projectRoot;
|
|
18
50
|
}
|
|
19
51
|
async detect() {
|
|
20
52
|
try {
|
|
21
|
-
const target = await stat(this.
|
|
22
|
-
return target.
|
|
53
|
+
const target = await stat(this.workspaceStoragePath);
|
|
54
|
+
return target.isDirectory();
|
|
23
55
|
}
|
|
24
56
|
catch {
|
|
25
57
|
return false;
|
|
26
58
|
}
|
|
27
59
|
}
|
|
28
60
|
getStorePaths() {
|
|
29
|
-
return [this.
|
|
61
|
+
return [this.workspaceStoragePath];
|
|
30
62
|
}
|
|
31
63
|
async *scrape(since) {
|
|
32
|
-
|
|
33
|
-
const cutoff = since ?? state.lastTimestamp;
|
|
34
|
-
yield* this.readAllMessages(cutoff);
|
|
64
|
+
yield* this.readAllMessages(since);
|
|
35
65
|
}
|
|
36
66
|
async *fullSync() {
|
|
37
|
-
yield* this.readAllMessages(
|
|
67
|
+
yield* this.readAllMessages();
|
|
38
68
|
}
|
|
39
69
|
parseRaw(raw) {
|
|
40
70
|
const value = raw;
|
|
@@ -54,110 +84,232 @@ export class CopilotScraper {
|
|
|
54
84
|
},
|
|
55
85
|
};
|
|
56
86
|
}
|
|
57
|
-
async getLastScrapedPosition() {
|
|
58
|
-
return this.stateManager.load(this.tool);
|
|
59
|
-
}
|
|
60
|
-
async saveScrapedPosition(state) {
|
|
61
|
-
await this.stateManager.save(this.tool, state);
|
|
62
|
-
}
|
|
63
87
|
async *readAllMessages(since) {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
const dbPaths = await this.resolveDbPaths();
|
|
89
|
+
let Database;
|
|
90
|
+
try {
|
|
91
|
+
// Dynamic import so the module remains optional at startup.
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
Database = (await import("better-sqlite3")).default;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// ACCEPTED_DEGRADATIONS.missingSqliteBinding — opt-in peer dep.
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!Database)
|
|
100
|
+
return;
|
|
101
|
+
for (const dbPath of dbPaths) {
|
|
102
|
+
let db;
|
|
69
103
|
try {
|
|
70
|
-
|
|
104
|
+
db = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
71
105
|
}
|
|
72
106
|
catch {
|
|
107
|
+
// ACCEPTED_DEGRADATIONS.missingStateVscdb — workspace never wrote a db yet.
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
yield* this.readFromDb(db, dbPath, since);
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
db.close();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
*readFromDb(db, dbPath, since) {
|
|
119
|
+
let rawValue;
|
|
120
|
+
try {
|
|
121
|
+
const row = db
|
|
122
|
+
.prepare("SELECT value FROM ItemTable WHERE key = ?")
|
|
123
|
+
.get(SESSIONS_KEY);
|
|
124
|
+
rawValue = row?.value ?? null;
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
// Required table missing / shape changed — this is a real surprise.
|
|
128
|
+
warnDrift(dbPath, `ItemTable query failed: ${err.message}`, 0);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!rawValue) {
|
|
132
|
+
// ACCEPTED_DEGRADATIONS.noInteractiveSessionsKey
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
let sessionsMap;
|
|
136
|
+
try {
|
|
137
|
+
sessionsMap = JSON.parse(rawValue);
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
warnDrift(dbPath, `interactive.sessions value is not valid JSON: ${err.message}`, 0);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!isRecord(sessionsMap)) {
|
|
144
|
+
warnDrift(dbPath, `expected interactive.sessions to be an object, got ${describeType(sessionsMap)}`, 0);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const sinceMs = since ? since.getTime() : 0;
|
|
148
|
+
for (const [sessionKey, rawSession] of Object.entries(sessionsMap)) {
|
|
149
|
+
if (!isRecord(rawSession)) {
|
|
150
|
+
warnDrift(`${dbPath}#${sessionKey}`, `session entry is not an object (got ${describeType(rawSession)})`, 0);
|
|
73
151
|
continue;
|
|
74
152
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
153
|
+
const session = rawSession;
|
|
154
|
+
const sessionId = session.sessionId ?? "unknown";
|
|
155
|
+
if (session.sessionId === undefined) {
|
|
156
|
+
warnDrift(`${dbPath}#${sessionKey}`, "session missing 'sessionId' field — using fallback 'unknown'", 0);
|
|
157
|
+
}
|
|
158
|
+
if (session.creationDate === null || (session.creationDate !== undefined &&
|
|
159
|
+
typeof session.creationDate !== "number" &&
|
|
160
|
+
typeof session.creationDate !== "string")) {
|
|
161
|
+
warnDrift(`${dbPath}#${sessionId}`, `expected 'creationDate' to be a number, got ${describeType(session.creationDate)}`, 0);
|
|
162
|
+
}
|
|
163
|
+
// Copilot only stamps a session-level creationDate — individual turns
|
|
164
|
+
// inherit it. Using creationDate for the scrape cursor drops whole
|
|
165
|
+
// sessions that existed before the cursor but gained NEW turns after
|
|
166
|
+
// it, causing permanent turn loss (P1 from review). Fix: emit every
|
|
167
|
+
// turn every cycle and rely on chunk-ID-based upsert dedupe upstream
|
|
168
|
+
// (the ID basis now includes messageIndex so duplicates collapse
|
|
169
|
+
// safely). Note: sinceMs is still referenced below so that a future
|
|
170
|
+
// per-turn timestamp upgrade only needs a narrow edit.
|
|
171
|
+
void sinceMs;
|
|
172
|
+
const creationDate = toDate(session.creationDate);
|
|
173
|
+
if (session.requests !== undefined && !Array.isArray(session.requests)) {
|
|
174
|
+
// Schema drift: 'requests' was renamed or retyped. This is the
|
|
175
|
+
// highest-risk mutation because it silently empties whole sessions.
|
|
176
|
+
warnDrift(`${dbPath}#${sessionId}`, `expected 'requests' to be an array, got ${describeType(session.requests)}`, 0);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (!("requests" in rawSession)) {
|
|
180
|
+
// 'requests' is missing entirely. If any other non-whitelisted key
|
|
181
|
+
// looks like a request array, it's almost certainly a rename — warn.
|
|
182
|
+
// A truly empty pre-v1 session would have no array-shaped sibling.
|
|
183
|
+
const suspiciousRename = Object.entries(rawSession).find(([k, v]) => k !== "sessionId" && k !== "creationDate" && Array.isArray(v));
|
|
184
|
+
if (suspiciousRename) {
|
|
185
|
+
warnDrift(`${dbPath}#${sessionId}`, `session has no 'requests' key; suspected rename to '${suspiciousRename[0]}'`, 0);
|
|
186
|
+
}
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const requests = Array.isArray(session.requests) ? session.requests : [];
|
|
190
|
+
let messageIndex = 0;
|
|
191
|
+
for (const req of requests) {
|
|
192
|
+
if (!isRecord(req)) {
|
|
193
|
+
warnDrift(`${dbPath}#${sessionId}`, `request entry is not an object (got ${describeType(req)})`, 0);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (req.isCanceled) {
|
|
197
|
+
// ACCEPTED_DEGRADATIONS.canceledRequest
|
|
79
198
|
continue;
|
|
80
199
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
200
|
+
const userText = extractUserText(req);
|
|
201
|
+
if (userText) {
|
|
202
|
+
yield this.parseRaw({
|
|
203
|
+
sessionId,
|
|
204
|
+
role: "user",
|
|
205
|
+
content: userText,
|
|
206
|
+
timestamp: creationDate,
|
|
207
|
+
model: req.model,
|
|
208
|
+
completionType: req.agentId ? "agent" : "chat",
|
|
209
|
+
messageIndex: messageIndex++,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
const assistantText = extractAssistantText(req);
|
|
213
|
+
if (assistantText) {
|
|
214
|
+
yield this.parseRaw({
|
|
215
|
+
sessionId,
|
|
216
|
+
role: "assistant",
|
|
217
|
+
content: assistantText,
|
|
218
|
+
timestamp: creationDate,
|
|
219
|
+
model: req.model,
|
|
220
|
+
completionType: req.agentId ? "agent" : "chat",
|
|
221
|
+
messageIndex: messageIndex++,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
90
224
|
}
|
|
91
225
|
}
|
|
92
226
|
}
|
|
93
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Discovers VS Code workspaceStorage SQLite databases.
|
|
229
|
+
* Pattern: <workspaceStoragePath>/[hash]/state.vscdb
|
|
230
|
+
*/
|
|
231
|
+
async resolveDbPaths() {
|
|
94
232
|
try {
|
|
95
|
-
const target = await stat(this.
|
|
96
|
-
if (target.
|
|
97
|
-
|
|
233
|
+
const target = await stat(this.workspaceStoragePath);
|
|
234
|
+
if (!target.isDirectory()) {
|
|
235
|
+
// The root must be a directory — a non-directory here is drift.
|
|
236
|
+
warnDrift(this.workspaceStoragePath, "expected workspaceStorage to be a directory", 0);
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
const paths = await glob("*/state.vscdb", {
|
|
240
|
+
cwd: this.workspaceStoragePath,
|
|
241
|
+
absolute: true,
|
|
242
|
+
nodir: true,
|
|
243
|
+
});
|
|
244
|
+
if (!this.projectRoot) {
|
|
245
|
+
return paths;
|
|
246
|
+
}
|
|
247
|
+
const filtered = [];
|
|
248
|
+
for (const path of paths) {
|
|
249
|
+
if (await workspaceMatchesProject(path, this.projectRoot)) {
|
|
250
|
+
filtered.push(path);
|
|
251
|
+
}
|
|
98
252
|
}
|
|
99
|
-
|
|
100
|
-
return files
|
|
101
|
-
.filter((file) => file.endsWith(".json"))
|
|
102
|
-
.map((file) => join(this.copilotHistoryPath, file));
|
|
253
|
+
return filtered;
|
|
103
254
|
}
|
|
104
255
|
catch {
|
|
256
|
+
// ACCEPTED_DEGRADATIONS.missingWorkspaceStorage
|
|
105
257
|
return [];
|
|
106
258
|
}
|
|
107
259
|
}
|
|
108
260
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
if (Array.isArray(input.messages)) {
|
|
119
|
-
const sessionId = toStringValue(input.sessionId ?? input.session_id) ?? fallbackSessionId;
|
|
120
|
-
return input.messages
|
|
121
|
-
.filter((entry) => isRecord(entry))
|
|
122
|
-
.map((entry) => mapMessage(entry, sessionId));
|
|
123
|
-
}
|
|
124
|
-
if (Array.isArray(input.conversations)) {
|
|
125
|
-
const rows = [];
|
|
126
|
-
for (const conversation of input.conversations) {
|
|
127
|
-
if (!isRecord(conversation) || !Array.isArray(conversation.messages)) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
const sessionId = toStringValue(conversation.sessionId ?? conversation.session_id ?? conversation.id) ??
|
|
131
|
-
fallbackSessionId;
|
|
132
|
-
for (const message of conversation.messages) {
|
|
133
|
-
if (isRecord(message)) {
|
|
134
|
-
rows.push(mapMessage(message, sessionId));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
261
|
+
async function workspaceMatchesProject(workspaceDbPath, projectRoot) {
|
|
262
|
+
try {
|
|
263
|
+
const raw = await readFile(join(dirname(workspaceDbPath), "workspace.json"), "utf-8");
|
|
264
|
+
const parsed = JSON.parse(raw);
|
|
265
|
+
const folder = typeof parsed.folder === "string" ? parsed.folder : undefined;
|
|
266
|
+
if (!folder) {
|
|
267
|
+
return false;
|
|
137
268
|
}
|
|
138
|
-
|
|
269
|
+
const folderPath = folder.startsWith("file:") ? fileURLToPath(folder) : folder;
|
|
270
|
+
return pathMatchesProject(folderPath, projectRoot);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return false;
|
|
139
274
|
}
|
|
140
|
-
return [];
|
|
141
275
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
276
|
+
/** Concatenates all text parts from a user message. */
|
|
277
|
+
function extractUserText(req) {
|
|
278
|
+
const parts = req.message?.parts;
|
|
279
|
+
if (!Array.isArray(parts)) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
const text = parts
|
|
283
|
+
.map((p) => p.text ?? "")
|
|
284
|
+
.join("\n")
|
|
285
|
+
.trim();
|
|
286
|
+
return text.length > 0 ? text : undefined;
|
|
287
|
+
}
|
|
288
|
+
/** Concatenates all value segments from an assistant response. */
|
|
289
|
+
function extractAssistantText(req) {
|
|
290
|
+
const response = req.response;
|
|
291
|
+
if (!Array.isArray(response)) {
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
const text = response
|
|
295
|
+
.map((r) => r.value ?? "")
|
|
296
|
+
.join("")
|
|
297
|
+
.trim();
|
|
298
|
+
return text.length > 0 ? text : undefined;
|
|
151
299
|
}
|
|
152
300
|
function normalizeRole(value) {
|
|
301
|
+
const ROLE_MAP = {
|
|
302
|
+
user: "user",
|
|
303
|
+
human: "user",
|
|
304
|
+
assistant: "assistant",
|
|
305
|
+
system: "system",
|
|
306
|
+
tool: "tool",
|
|
307
|
+
};
|
|
153
308
|
if (!value) {
|
|
154
309
|
return "system";
|
|
155
310
|
}
|
|
156
311
|
return ROLE_MAP[value.toLowerCase()] ?? "system";
|
|
157
312
|
}
|
|
158
|
-
function inferSessionId(filePath) {
|
|
159
|
-
return basename(filePath).replace(".json", "") || "unknown";
|
|
160
|
-
}
|
|
161
313
|
function toMessageIndex(value) {
|
|
162
314
|
const parsed = Number(value);
|
|
163
315
|
if (Number.isFinite(parsed) && parsed >= 0) {
|
|
@@ -171,28 +323,14 @@ function toStringValue(value) {
|
|
|
171
323
|
}
|
|
172
324
|
return value;
|
|
173
325
|
}
|
|
174
|
-
function toDate(value) {
|
|
175
|
-
if (value instanceof Date) {
|
|
176
|
-
return value;
|
|
177
|
-
}
|
|
178
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
179
|
-
const millis = value > 10_000_000_000 ? value : value * 1000;
|
|
180
|
-
return new Date(millis);
|
|
181
|
-
}
|
|
182
|
-
if (typeof value === "string") {
|
|
183
|
-
const numeric = Number(value);
|
|
184
|
-
if (Number.isFinite(numeric) && value.trim() !== "") {
|
|
185
|
-
const millis = numeric > 10_000_000_000 ? numeric : numeric * 1000;
|
|
186
|
-
return new Date(millis);
|
|
187
|
-
}
|
|
188
|
-
const parsed = new Date(value);
|
|
189
|
-
if (!Number.isNaN(parsed.getTime())) {
|
|
190
|
-
return parsed;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return new Date(0);
|
|
194
|
-
}
|
|
195
326
|
function isRecord(value) {
|
|
196
327
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
197
328
|
}
|
|
329
|
+
function describeType(value) {
|
|
330
|
+
if (value === null)
|
|
331
|
+
return "null";
|
|
332
|
+
if (Array.isArray(value))
|
|
333
|
+
return "array";
|
|
334
|
+
return typeof value;
|
|
335
|
+
}
|
|
198
336
|
//# sourceMappingURL=copilot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../src/scrapers/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,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AC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,OAAO,OAAO,KAAK,CAAC;AACtB,CAAC"}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { CursorChunk } from "../types/scraper.js";
|
|
2
|
+
import { AbstractScraper } from "./base.js";
|
|
3
|
+
/**
|
|
4
|
+
* Shapes the cursor scraper tolerates silently without logging. All other
|
|
5
|
+
* shape surprises warn; missing required tables throw.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ACCEPTED_DEGRADATIONS: {
|
|
8
|
+
/** Store path missing — Cursor not installed on this machine. */
|
|
9
|
+
missingStorePath: string;
|
|
10
|
+
/** Workspace has no composerData yet — empty workspace. */
|
|
11
|
+
emptyWorkspace: string;
|
|
12
|
+
/** A composer whose bubble row is missing — bubble pruned by Cursor. */
|
|
13
|
+
prunedBubble: string;
|
|
14
|
+
/** Empty bubble text (tool-call only, etc.). */
|
|
15
|
+
emptyBubbleText: string;
|
|
16
|
+
/** Forward-compat unknown keys alongside known composer fields. */
|
|
17
|
+
unknownFieldsAlongside: string;
|
|
18
|
+
};
|
|
19
|
+
export declare class CursorScraper extends AbstractScraper<CursorChunk> {
|
|
3
20
|
private readonly cursorStorePath;
|
|
21
|
+
private readonly projectRoot?;
|
|
4
22
|
readonly tool = "cursor";
|
|
5
|
-
|
|
6
|
-
constructor(cursorStorePath: string, stateDir: string);
|
|
23
|
+
constructor(cursorStorePath: string, stateDir: string, projectRoot?: string | undefined);
|
|
7
24
|
detect(): Promise<boolean>;
|
|
8
25
|
getStorePaths(): string[];
|
|
9
26
|
scrape(since?: Date): AsyncIterable<CursorChunk>;
|
|
10
27
|
fullSync(): AsyncIterable<CursorChunk>;
|
|
11
|
-
parseRaw(raw: unknown): CursorChunk;
|
|
12
|
-
getLastScrapedPosition(): Promise<ScraperState>;
|
|
13
|
-
saveScrapedPosition(state: ScraperState): Promise<void>;
|
|
14
28
|
private readAllMessages;
|
|
15
|
-
private
|
|
16
|
-
private
|
|
29
|
+
private readWorkspaceComposers;
|
|
30
|
+
private readComposerMessages;
|
|
31
|
+
private resolveWorkspaceDatabasePaths;
|
|
17
32
|
}
|
|
18
33
|
//# sourceMappingURL=cursor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../src/scrapers/cursor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../src/scrapers/cursor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAA0B,MAAM,WAAW,CAAC;AASpE;;;GAGG;AACH,eAAO,MAAM,qBAAqB;IAChC,iEAAiE;;IAEjE,2DAA2D;;IAE3D,wEAAwE;;IAExE,gDAAgD;;IAEhD,mEAAmE;;CAEpE,CAAC;AAsCF,qBAAa,aAAc,SAAQ,eAAe,CAAC,WAAW,CAAC;IAI3D,OAAO,CAAC,QAAQ,CAAC,eAAe;IAEhC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAL/B,QAAQ,CAAC,IAAI,YAAY;gBAGN,eAAe,EAAE,MAAM,EACxC,QAAQ,EAAE,MAAM,EACC,WAAW,CAAC,EAAE,MAAM,YAAA;IAKjC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAKhC,aAAa,IAAI,MAAM,EAAE;IAIlB,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,aAAa,CAAC,WAAW,CAAC;IAMhD,QAAQ,IAAI,aAAa,CAAC,WAAW,CAAC;YAI9B,eAAe;IA2C9B,OAAO,CAAC,sBAAsB;IAyD9B,OAAO,CAAE,oBAAoB;YA+If,6BAA6B;CA+B5C"}
|