@agent-deck/backend 1.4.4 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/bootstrap/authoring-guide.d.ts +3 -0
- package/dist/bootstrap/authoring-guide.d.ts.map +1 -0
- package/dist/bootstrap/authoring-guide.js +19 -0
- package/dist/bootstrap/authoring-guide.js.map +1 -0
- package/dist/bootstrap/cursor-project-slug.d.ts +9 -0
- package/dist/bootstrap/cursor-project-slug.d.ts.map +1 -0
- package/dist/bootstrap/cursor-project-slug.js +15 -0
- package/dist/bootstrap/cursor-project-slug.js.map +1 -0
- package/dist/bootstrap/digest-cursor-session.d.ts +11 -0
- package/dist/bootstrap/digest-cursor-session.d.ts.map +1 -0
- package/dist/bootstrap/digest-cursor-session.js +162 -0
- package/dist/bootstrap/digest-cursor-session.js.map +1 -0
- package/dist/bootstrap/digest-session.d.ts +3 -0
- package/dist/bootstrap/digest-session.d.ts.map +1 -0
- package/dist/bootstrap/digest-session.js +356 -0
- package/dist/bootstrap/digest-session.js.map +1 -0
- package/dist/bootstrap/enumerate-cursor.d.ts +13 -0
- package/dist/bootstrap/enumerate-cursor.d.ts.map +1 -0
- package/dist/bootstrap/enumerate-cursor.js +105 -0
- package/dist/bootstrap/enumerate-cursor.js.map +1 -0
- package/dist/bootstrap/enumerate.d.ts +7 -0
- package/dist/bootstrap/enumerate.d.ts.map +1 -0
- package/dist/bootstrap/enumerate.js +49 -0
- package/dist/bootstrap/enumerate.js.map +1 -0
- package/dist/bootstrap/extractors.d.ts +18 -0
- package/dist/bootstrap/extractors.d.ts.map +1 -0
- package/dist/bootstrap/extractors.js +97 -0
- package/dist/bootstrap/extractors.js.map +1 -0
- package/dist/bootstrap/feedback-lexicon.d.ts +7 -0
- package/dist/bootstrap/feedback-lexicon.d.ts.map +1 -0
- package/dist/bootstrap/feedback-lexicon.js +24 -0
- package/dist/bootstrap/feedback-lexicon.js.map +1 -0
- package/dist/bootstrap/feedback-moments.d.ts +3 -0
- package/dist/bootstrap/feedback-moments.d.ts.map +1 -0
- package/dist/bootstrap/feedback-moments.js +77 -0
- package/dist/bootstrap/feedback-moments.js.map +1 -0
- package/dist/bootstrap/handoff.d.ts +5 -0
- package/dist/bootstrap/handoff.d.ts.map +1 -0
- package/dist/bootstrap/handoff.js +22 -0
- package/dist/bootstrap/handoff.js.map +1 -0
- package/dist/bootstrap/index.d.ts +8 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +20 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/real-intent.d.ts +14 -0
- package/dist/bootstrap/real-intent.d.ts.map +1 -0
- package/dist/bootstrap/real-intent.js +127 -0
- package/dist/bootstrap/real-intent.js.map +1 -0
- package/dist/bootstrap/run-bootstrap.d.ts +25 -0
- package/dist/bootstrap/run-bootstrap.d.ts.map +1 -0
- package/dist/bootstrap/run-bootstrap.js +221 -0
- package/dist/bootstrap/run-bootstrap.js.map +1 -0
- package/dist/mcp-tools/register.d.ts.map +1 -1
- package/dist/mcp-tools/register.js +20 -4
- package/dist/mcp-tools/register.js.map +1 -1
- package/dist/models/database.d.ts +33 -1
- package/dist/models/database.d.ts.map +1 -1
- package/dist/models/database.js +171 -0
- package/dist/models/database.js.map +1 -1
- package/dist/playbooks/patch-manager.d.ts +5 -2
- package/dist/playbooks/patch-manager.d.ts.map +1 -1
- package/dist/playbooks/patch-manager.js +93 -3
- package/dist/playbooks/patch-manager.js.map +1 -1
- package/dist/routes/feedback-signals.d.ts +4 -0
- package/dist/routes/feedback-signals.d.ts.map +1 -0
- package/dist/routes/feedback-signals.js +167 -0
- package/dist/routes/feedback-signals.js.map +1 -0
- package/dist/routes/playbook-patches.d.ts.map +1 -1
- package/dist/routes/playbook-patches.js +14 -2
- package/dist/routes/playbook-patches.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/package.json +6 -2
- package/static-ui/assets/index-B1w2Pair.css +1 -0
- package/static-ui/assets/index-ByDRJHcA.js +481 -0
- package/static-ui/index.html +2 -2
- package/static-ui/assets/index-C-RU5M5m.js +0 -468
- package/static-ui/assets/index-Dz443SMq.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-guide.d.ts","sourceRoot":"","sources":["../../src/bootstrap/authoring-guide.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,mCAAmC,CAAC;AAE1D,eAAO,MAAM,wBAAwB,kpCAapC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTHORING_GUIDE_MARKDOWN = exports.GUIDE_REF = void 0;
|
|
4
|
+
exports.GUIDE_REF = 'pb_session_bootstrap_authoring';
|
|
5
|
+
exports.AUTHORING_GUIDE_MARKDOWN = `# Session Bootstrap Authoring Guide (${exports.GUIDE_REF})
|
|
6
|
+
|
|
7
|
+
Use these local session digests (Claude Code and/or Cursor) to propose reusable playbooks. Do not auto-register a playbook.
|
|
8
|
+
|
|
9
|
+
1. Read the manifest at the handoff path.
|
|
10
|
+
2. For the bound deck workspace, load matching digests:
|
|
11
|
+
- \`workspaceRoot === boundRoot\` **or**
|
|
12
|
+
- \`workspaceSlug === encodeCursorProjectSlug(boundRoot)\` (Unix: strip leading \`/\`, replace \`/\` and \`_\` with \`-\`)
|
|
13
|
+
- Host is irrelevant for matching — Claude and Cursor digests for the same repo share \`workspaceSlug\`.
|
|
14
|
+
3. Cluster digests by task shape (not wording). \`host\` is a hint, not a hard split unless lessons clearly diverge.
|
|
15
|
+
4. Per cluster draft a playbook: triggers ← recurring \`intents\` (already unwrapped from Cursor \`<user_query>\` envelopes); Gotchas ← \`negative\` \`feedbackMoments\`; Techniques ← \`positive\`; generalize names and paths.
|
|
16
|
+
5. File only via \`propose_playbook_patch\` with \`kind: "create"\` and \`new_playbook: { title, triggers, body }\` — never \`register_playbook\`.
|
|
17
|
+
6. Multi-workspace: use one bound deck per run; re-bind and re-run authoring for other workspaces.
|
|
18
|
+
`;
|
|
19
|
+
//# sourceMappingURL=authoring-guide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-guide.js","sourceRoot":"","sources":["../../src/bootstrap/authoring-guide.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,gCAAgC,CAAC;AAE7C,QAAA,wBAAwB,GAAG,wCAAwC,iBAAS;;;;;;;;;;;;;CAaxF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirrors how Cursor names `~/.cursor/projects/<slug>` from an absolute workspace path (Unix).
|
|
3
|
+
* Used only for --workspace selection and authoring-guide match — never to invent abs paths from slugs.
|
|
4
|
+
*
|
|
5
|
+
* Observed Cursor behavior: strip leading `/`, replace `/` and `_` with `-` (underscores in
|
|
6
|
+
* path segments become hyphens in the slug).
|
|
7
|
+
*/
|
|
8
|
+
export declare function encodeCursorProjectSlug(absPath: string): string;
|
|
9
|
+
//# sourceMappingURL=cursor-project-slug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-project-slug.d.ts","sourceRoot":"","sources":["../../src/bootstrap/cursor-project-slug.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG/D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeCursorProjectSlug = encodeCursorProjectSlug;
|
|
4
|
+
/**
|
|
5
|
+
* Mirrors how Cursor names `~/.cursor/projects/<slug>` from an absolute workspace path (Unix).
|
|
6
|
+
* Used only for --workspace selection and authoring-guide match — never to invent abs paths from slugs.
|
|
7
|
+
*
|
|
8
|
+
* Observed Cursor behavior: strip leading `/`, replace `/` and `_` with `-` (underscores in
|
|
9
|
+
* path segments become hyphens in the slug).
|
|
10
|
+
*/
|
|
11
|
+
function encodeCursorProjectSlug(absPath) {
|
|
12
|
+
const normalized = absPath.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
13
|
+
return normalized.replace(/^\//, '').replaceAll('/', '-').replaceAll('_', '-');
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=cursor-project-slug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-project-slug.js","sourceRoot":"","sources":["../../src/bootstrap/cursor-project-slug.ts"],"names":[],"mappings":";;AAOA,0DAGC;AAVD;;;;;;GAMG;AACH,SAAgB,uBAAuB,CAAC,OAAe;IACrD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SessionDigest } from '@agent-deck/shared';
|
|
2
|
+
export type DigestCursorSessionOptions = {
|
|
3
|
+
/** Absolute --workspace path when this project was selected via slug encode match. */
|
|
4
|
+
workspaceRoot?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Cursor agent-transcript JSONL → SessionDigest (F1C).
|
|
8
|
+
* `projectSlug` becomes workspaceLabel + workspaceSlug; workspaceRoot is abs --workspace when provided, else the slug (opaque).
|
|
9
|
+
*/
|
|
10
|
+
export declare function digestCursorSession(sessionId: string, lines: unknown[], projectSlug: string, options?: DigestCursorSessionOptions): SessionDigest;
|
|
11
|
+
//# sourceMappingURL=digest-cursor-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-cursor-session.d.ts","sourceRoot":"","sources":["../../src/bootstrap/digest-cursor-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAU7E,MAAM,MAAM,0BAA0B,GAAG;IACvC,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AA2BF;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EAAE,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,0BAA+B,GACvC,aAAa,CAuFf"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.digestCursorSession = digestCursorSession;
|
|
4
|
+
const shared_1 = require("@agent-deck/shared");
|
|
5
|
+
const extractors_1 = require("./extractors");
|
|
6
|
+
const feedback_moments_1 = require("./feedback-moments");
|
|
7
|
+
const real_intent_1 = require("./real-intent");
|
|
8
|
+
const EPOCH_ISO = '1970-01-01T00:00:00.000Z';
|
|
9
|
+
const DIGEST_BYTE_BUDGET = 4096;
|
|
10
|
+
/** Skip tiny intents after envelope unwrap (shared quality floor with Claude shortening floor spirit). */
|
|
11
|
+
const MIN_INTENT_TEXT_LENGTH = 8;
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return typeof value === 'object' && value !== null;
|
|
14
|
+
}
|
|
15
|
+
function toIsoTimestamp(value) {
|
|
16
|
+
if (typeof value !== 'string' || Number.isNaN(Date.parse(value))) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return new Date(value).toISOString();
|
|
20
|
+
}
|
|
21
|
+
function increment(counts, values) {
|
|
22
|
+
for (const value of values) {
|
|
23
|
+
if (value) {
|
|
24
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function sortedCounts(counts) {
|
|
29
|
+
return [...counts.entries()]
|
|
30
|
+
.map(([value, count]) => ({ value, count }))
|
|
31
|
+
.sort((left, right) => right.count - left.count || left.value.localeCompare(right.value));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Cursor agent-transcript JSONL → SessionDigest (F1C).
|
|
35
|
+
* `projectSlug` becomes workspaceLabel + workspaceSlug; workspaceRoot is abs --workspace when provided, else the slug (opaque).
|
|
36
|
+
*/
|
|
37
|
+
function digestCursorSession(sessionId, lines, projectSlug, options = {}) {
|
|
38
|
+
const workspaceRoot = options.workspaceRoot ?? projectSlug;
|
|
39
|
+
const workspaceLabel = projectSlug;
|
|
40
|
+
const workspaceSlug = projectSlug;
|
|
41
|
+
let startedAt;
|
|
42
|
+
let endedAt;
|
|
43
|
+
let skippedLineCount = 0;
|
|
44
|
+
let turnCount = 0;
|
|
45
|
+
const intents = [];
|
|
46
|
+
const toolCounts = new Map();
|
|
47
|
+
const commandCounts = new Map();
|
|
48
|
+
const fileCounts = new Map();
|
|
49
|
+
for (const line of lines) {
|
|
50
|
+
try {
|
|
51
|
+
if (!isRecord(line)) {
|
|
52
|
+
skippedLineCount += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const timestamp = toIsoTimestamp(line.timestamp);
|
|
56
|
+
if (timestamp) {
|
|
57
|
+
startedAt ??= timestamp;
|
|
58
|
+
endedAt = timestamp;
|
|
59
|
+
}
|
|
60
|
+
const action = (0, extractors_1.summarizeAssistantAction)(line);
|
|
61
|
+
increment(toolCounts, action.toolNames);
|
|
62
|
+
increment(commandCounts, action.bashCommands.map(extractors_1.normalizeBashCommand).filter(Boolean));
|
|
63
|
+
increment(fileCounts, action.filePaths);
|
|
64
|
+
if ((0, real_intent_1.isRealUserIntent)(line)) {
|
|
65
|
+
turnCount += 1;
|
|
66
|
+
const text = (0, real_intent_1.extractUserText)(line);
|
|
67
|
+
if (text !== null && text.length >= MIN_INTENT_TEXT_LENGTH && intents.length < 40) {
|
|
68
|
+
intents.push({
|
|
69
|
+
text: text.slice(0, 280),
|
|
70
|
+
...(timestamp ? { at: timestamp } : {}),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
skippedLineCount += 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const allCommands = sortedCounts(commandCounts).map(({ value: command, count }) => ({
|
|
80
|
+
command,
|
|
81
|
+
count,
|
|
82
|
+
}));
|
|
83
|
+
let feedbackMoments = [];
|
|
84
|
+
try {
|
|
85
|
+
feedbackMoments = (0, feedback_moments_1.extractFeedbackMoments)(lines).filter((moment) => !looksLikeSkillBoilerplate(moment.userReaction));
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
skippedLineCount += 1;
|
|
89
|
+
}
|
|
90
|
+
const digest = {
|
|
91
|
+
schemaVersion: 1,
|
|
92
|
+
host: 'cursor',
|
|
93
|
+
sessionId,
|
|
94
|
+
workspaceRoot,
|
|
95
|
+
workspaceLabel,
|
|
96
|
+
workspaceSlug,
|
|
97
|
+
startedAt: startedAt ?? EPOCH_ISO,
|
|
98
|
+
endedAt: endedAt ?? EPOCH_ISO,
|
|
99
|
+
turnCount,
|
|
100
|
+
skippedLineCount,
|
|
101
|
+
intents,
|
|
102
|
+
commands: allCommands.slice(0, 40),
|
|
103
|
+
tools: sortedCounts(toolCounts)
|
|
104
|
+
.slice(0, 40)
|
|
105
|
+
.map(({ value: name, count }) => ({ name, count })),
|
|
106
|
+
skills: [],
|
|
107
|
+
topFiles: [...fileCounts.entries()]
|
|
108
|
+
.map(([filePath, edits]) => ({ path: filePath, edits }))
|
|
109
|
+
.sort((left, right) => right.edits - left.edits || left.path.localeCompare(right.path))
|
|
110
|
+
.slice(0, 20),
|
|
111
|
+
feedbackMoments,
|
|
112
|
+
outcome: (0, extractors_1.deriveOutcome)(allCommands),
|
|
113
|
+
};
|
|
114
|
+
return finalizeCursorDigest(digest);
|
|
115
|
+
}
|
|
116
|
+
function looksLikeSkillBoilerplate(text) {
|
|
117
|
+
return (text.includes('Base directory for this skill:') ||
|
|
118
|
+
text.includes('<HARD-GATE>') ||
|
|
119
|
+
(text.length > 400 && text.includes('# ') && text.includes('Skill')));
|
|
120
|
+
}
|
|
121
|
+
function finalizeCursorDigest(digest) {
|
|
122
|
+
const parsed = shared_1.SessionDigestSchema.safeParse(digest);
|
|
123
|
+
if (!parsed.success) {
|
|
124
|
+
return {
|
|
125
|
+
schemaVersion: 1,
|
|
126
|
+
host: 'cursor',
|
|
127
|
+
sessionId: 'unknown',
|
|
128
|
+
workspaceRoot: '',
|
|
129
|
+
startedAt: EPOCH_ISO,
|
|
130
|
+
endedAt: EPOCH_ISO,
|
|
131
|
+
turnCount: 0,
|
|
132
|
+
intents: [],
|
|
133
|
+
commands: [],
|
|
134
|
+
tools: [],
|
|
135
|
+
skills: [],
|
|
136
|
+
topFiles: [],
|
|
137
|
+
feedbackMoments: [],
|
|
138
|
+
outcome: { signal: 'unknown' },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
let current = parsed.data;
|
|
142
|
+
// Shared NFR-2: drop list payloads until under budget; never truncate identity fields.
|
|
143
|
+
for (let guard = 0; guard < 200 && Buffer.byteLength(JSON.stringify(current), 'utf8') > DIGEST_BYTE_BUDGET; guard += 1) {
|
|
144
|
+
let changed = false;
|
|
145
|
+
for (const field of ['feedbackMoments', 'topFiles', 'tools', 'commands', 'intents']) {
|
|
146
|
+
if (Buffer.byteLength(JSON.stringify(current), 'utf8') <= DIGEST_BYTE_BUDGET) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
const items = current[field];
|
|
150
|
+
if (Array.isArray(items) && items.length > 0) {
|
|
151
|
+
current = { ...current, [field]: items.slice(0, -1) };
|
|
152
|
+
changed = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!changed) {
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const again = shared_1.SessionDigestSchema.safeParse(current);
|
|
160
|
+
return again.success ? again.data : parsed.data;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=digest-cursor-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-cursor-session.js","sourceRoot":"","sources":["../../src/bootstrap/digest-cursor-session.ts"],"names":[],"mappings":";;AA4CA,kDA4FC;AAxID,+CAA6E;AAC7E,6CAA6F;AAC7F,yDAA4D;AAC5D,+CAAkE;AAElE,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAC7C,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,0GAA0G;AAC1G,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAOjC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,SAAS,CAAC,MAA2B,EAAE,MAAgB;IAC9D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,YAAY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E,SAAS,CAAU,EAAE,CAAC;YAC7F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,kBAAkB,EAAE,CAAC;gBAC7E,MAAM;YACR,CAAC;YACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7C,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACtD,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM;QACR,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,4BAAmB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-session.d.ts","sourceRoot":"","sources":["../../src/bootstrap/digest-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA6C7E,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,aAAa,CAmHhF"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.digestSession = digestSession;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const shared_1 = require("@agent-deck/shared");
|
|
9
|
+
const cursor_project_slug_1 = require("./cursor-project-slug");
|
|
10
|
+
const extractors_1 = require("./extractors");
|
|
11
|
+
const feedback_moments_1 = require("./feedback-moments");
|
|
12
|
+
const real_intent_1 = require("./real-intent");
|
|
13
|
+
const EPOCH_ISO = '1970-01-01T00:00:00.000Z';
|
|
14
|
+
const DIGEST_BYTE_BUDGET = 4096;
|
|
15
|
+
const MIN_INTENT_TEXT_LENGTH = 40;
|
|
16
|
+
const MIN_COMMAND_TEXT_LENGTH = 20;
|
|
17
|
+
const MIN_SCALAR_TEXT_LENGTH = 20;
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === 'object' && value !== null;
|
|
20
|
+
}
|
|
21
|
+
function toIsoTimestamp(value) {
|
|
22
|
+
if (typeof value !== 'string' || Number.isNaN(Date.parse(value))) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return new Date(value).toISOString();
|
|
26
|
+
}
|
|
27
|
+
function increment(counts, values) {
|
|
28
|
+
for (const value of values) {
|
|
29
|
+
if (value) {
|
|
30
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function sortedCounts(counts) {
|
|
35
|
+
return [...counts.entries()]
|
|
36
|
+
.map(([value, count]) => ({ value, count }))
|
|
37
|
+
.sort((left, right) => right.count - left.count || left.value.localeCompare(right.value));
|
|
38
|
+
}
|
|
39
|
+
function digestSession(sessionId, lines) {
|
|
40
|
+
let workspaceRoot = '';
|
|
41
|
+
let workspaceLabel;
|
|
42
|
+
let gitBranch;
|
|
43
|
+
let startedAt;
|
|
44
|
+
let endedAt;
|
|
45
|
+
let skippedLineCount = 0;
|
|
46
|
+
let turnCount = 0;
|
|
47
|
+
const intents = [];
|
|
48
|
+
const toolCounts = new Map();
|
|
49
|
+
const commandCounts = new Map();
|
|
50
|
+
const skillCounts = new Map();
|
|
51
|
+
const fileCounts = new Map();
|
|
52
|
+
for (const line of lines) {
|
|
53
|
+
try {
|
|
54
|
+
if (!isRecord(line) || typeof line.type !== 'string') {
|
|
55
|
+
skippedLineCount += 1;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const transcriptLine = line;
|
|
59
|
+
if (!workspaceRoot && typeof transcriptLine.cwd === 'string') {
|
|
60
|
+
workspaceRoot = transcriptLine.cwd;
|
|
61
|
+
workspaceLabel = node_path_1.default.basename(transcriptLine.cwd);
|
|
62
|
+
}
|
|
63
|
+
if (gitBranch === undefined && typeof transcriptLine.gitBranch === 'string') {
|
|
64
|
+
gitBranch = transcriptLine.gitBranch;
|
|
65
|
+
}
|
|
66
|
+
const timestamp = toIsoTimestamp(transcriptLine.timestamp);
|
|
67
|
+
if (timestamp) {
|
|
68
|
+
startedAt ??= timestamp;
|
|
69
|
+
endedAt = timestamp;
|
|
70
|
+
}
|
|
71
|
+
const action = (0, extractors_1.summarizeAssistantAction)(line);
|
|
72
|
+
increment(toolCounts, action.toolNames);
|
|
73
|
+
increment(commandCounts, action.bashCommands.map(extractors_1.normalizeBashCommand).filter(Boolean));
|
|
74
|
+
increment(skillCounts, action.skills);
|
|
75
|
+
increment(fileCounts, action.filePaths);
|
|
76
|
+
// Skills may appear in slash/command-name chrome that is not a real intent (F1.2).
|
|
77
|
+
const rawUserText = (0, real_intent_1.extractRawUserText)(line);
|
|
78
|
+
if (rawUserText) {
|
|
79
|
+
increment(skillCounts, (0, extractors_1.extractSkillsFromUserText)(rawUserText));
|
|
80
|
+
}
|
|
81
|
+
if ((0, real_intent_1.isRealUserIntent)(line)) {
|
|
82
|
+
turnCount += 1;
|
|
83
|
+
const text = (0, real_intent_1.extractUserText)(line);
|
|
84
|
+
if (text !== null) {
|
|
85
|
+
if (intents.length < 40) {
|
|
86
|
+
intents.push({
|
|
87
|
+
text: text.slice(0, 280),
|
|
88
|
+
...(timestamp ? { at: timestamp } : {}),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
skippedLineCount += 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const allCommands = sortedCounts(commandCounts).map(({ value: command, count }) => ({
|
|
99
|
+
command,
|
|
100
|
+
count,
|
|
101
|
+
}));
|
|
102
|
+
const commands = allCommands.slice(0, 40);
|
|
103
|
+
const tools = sortedCounts(toolCounts)
|
|
104
|
+
.slice(0, 40)
|
|
105
|
+
.map(({ value: name, count }) => ({ name, count }));
|
|
106
|
+
const skills = sortedCounts(skillCounts)
|
|
107
|
+
.slice(0, 40)
|
|
108
|
+
.map(({ value: name, count }) => ({ name, count }));
|
|
109
|
+
const topFiles = [...fileCounts.entries()]
|
|
110
|
+
.map(([path, edits]) => ({ path, edits }))
|
|
111
|
+
.sort((left, right) => right.edits - left.edits || left.path.localeCompare(right.path))
|
|
112
|
+
.slice(0, 20);
|
|
113
|
+
let feedbackMoments = [];
|
|
114
|
+
try {
|
|
115
|
+
feedbackMoments = (0, feedback_moments_1.extractFeedbackMoments)(lines);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
skippedLineCount += 1;
|
|
119
|
+
}
|
|
120
|
+
// Transcript lines may lack timestamps; epoch placeholders keep digestion deterministic.
|
|
121
|
+
const workspaceSlug = workspaceRoot ? (0, cursor_project_slug_1.encodeCursorProjectSlug)(workspaceRoot) : undefined;
|
|
122
|
+
const digest = {
|
|
123
|
+
schemaVersion: 1,
|
|
124
|
+
host: 'claude',
|
|
125
|
+
sessionId,
|
|
126
|
+
workspaceRoot,
|
|
127
|
+
...(workspaceLabel ? { workspaceLabel } : {}),
|
|
128
|
+
...(workspaceSlug ? { workspaceSlug } : {}),
|
|
129
|
+
...(gitBranch === undefined ? {} : { gitBranch }),
|
|
130
|
+
startedAt: startedAt ?? EPOCH_ISO,
|
|
131
|
+
endedAt: endedAt ?? EPOCH_ISO,
|
|
132
|
+
turnCount,
|
|
133
|
+
skippedLineCount,
|
|
134
|
+
intents,
|
|
135
|
+
commands,
|
|
136
|
+
tools,
|
|
137
|
+
skills,
|
|
138
|
+
topFiles,
|
|
139
|
+
feedbackMoments,
|
|
140
|
+
outcome: (0, extractors_1.deriveOutcome)(allCommands),
|
|
141
|
+
};
|
|
142
|
+
return finalizeDigest(digest);
|
|
143
|
+
}
|
|
144
|
+
function digestByteLength(digest) {
|
|
145
|
+
return Buffer.byteLength(JSON.stringify(digest), 'utf8');
|
|
146
|
+
}
|
|
147
|
+
function trimArrayField(digest, field) {
|
|
148
|
+
const items = digest[field];
|
|
149
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
150
|
+
return digest;
|
|
151
|
+
}
|
|
152
|
+
return { ...digest, [field]: items.slice(0, items.length - 1) };
|
|
153
|
+
}
|
|
154
|
+
function shortenIntentTexts(digest, nextLength) {
|
|
155
|
+
return {
|
|
156
|
+
...digest,
|
|
157
|
+
intents: digest.intents.map((intent) => ({
|
|
158
|
+
...intent,
|
|
159
|
+
text: intent.text.slice(0, nextLength),
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function shortenCommands(digest, nextLength) {
|
|
164
|
+
return {
|
|
165
|
+
...digest,
|
|
166
|
+
commands: digest.commands.map((command) => ({
|
|
167
|
+
...command,
|
|
168
|
+
command: command.command.slice(0, nextLength),
|
|
169
|
+
})),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function shortenFeedbackMoments(digest, delta) {
|
|
173
|
+
return {
|
|
174
|
+
...digest,
|
|
175
|
+
feedbackMoments: digest.feedbackMoments.map((moment) => ({
|
|
176
|
+
...moment,
|
|
177
|
+
agentAction: moment.agentAction.slice(0, Math.max(40, moment.agentAction.length - delta)),
|
|
178
|
+
userReaction: moment.userReaction.slice(0, Math.max(40, moment.userReaction.length - delta)),
|
|
179
|
+
...(moment.followupChange
|
|
180
|
+
? {
|
|
181
|
+
followupChange: moment.followupChange.slice(0, Math.max(20, moment.followupChange.length - delta)),
|
|
182
|
+
}
|
|
183
|
+
: {}),
|
|
184
|
+
})),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function truncateString(value, minLength, delta) {
|
|
188
|
+
if (value.length <= minLength) {
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
return value.slice(0, Math.max(minLength, value.length - delta));
|
|
192
|
+
}
|
|
193
|
+
function truncateScalarFields(digest, delta) {
|
|
194
|
+
// Never truncate sessionId / workspaceRoot — they are identity keys used for
|
|
195
|
+
// --workspace filtering (F1.5). Prefer dropping list payloads instead.
|
|
196
|
+
return {
|
|
197
|
+
...digest,
|
|
198
|
+
...(digest.workspaceLabel !== undefined
|
|
199
|
+
? { workspaceLabel: truncateString(digest.workspaceLabel, MIN_SCALAR_TEXT_LENGTH, delta) }
|
|
200
|
+
: {}),
|
|
201
|
+
...(digest.gitBranch !== undefined && digest.gitBranch !== null
|
|
202
|
+
? { gitBranch: truncateString(digest.gitBranch, MIN_SCALAR_TEXT_LENGTH, delta) }
|
|
203
|
+
: {}),
|
|
204
|
+
outcome: digest.outcome.evidence
|
|
205
|
+
? {
|
|
206
|
+
signal: digest.outcome.signal,
|
|
207
|
+
evidence: truncateString(digest.outcome.evidence, MIN_SCALAR_TEXT_LENGTH, delta),
|
|
208
|
+
}
|
|
209
|
+
: digest.outcome,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function truncateArrayStringFields(digest, delta) {
|
|
213
|
+
return {
|
|
214
|
+
...digest,
|
|
215
|
+
tools: digest.tools.map((tool) => ({
|
|
216
|
+
...tool,
|
|
217
|
+
name: truncateString(tool.name, MIN_SCALAR_TEXT_LENGTH, delta),
|
|
218
|
+
})),
|
|
219
|
+
skills: digest.skills.map((skill) => ({
|
|
220
|
+
...skill,
|
|
221
|
+
name: truncateString(skill.name, MIN_SCALAR_TEXT_LENGTH, delta),
|
|
222
|
+
})),
|
|
223
|
+
topFiles: digest.topFiles.map((file) => ({
|
|
224
|
+
...file,
|
|
225
|
+
path: truncateString(file.path, MIN_SCALAR_TEXT_LENGTH, delta),
|
|
226
|
+
})),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function minimalUnknownDigest(turnCount = 0) {
|
|
230
|
+
return {
|
|
231
|
+
schemaVersion: 1,
|
|
232
|
+
host: 'claude',
|
|
233
|
+
sessionId: 'unknown',
|
|
234
|
+
workspaceRoot: '',
|
|
235
|
+
startedAt: EPOCH_ISO,
|
|
236
|
+
endedAt: EPOCH_ISO,
|
|
237
|
+
turnCount,
|
|
238
|
+
intents: [],
|
|
239
|
+
commands: [],
|
|
240
|
+
tools: [],
|
|
241
|
+
skills: [],
|
|
242
|
+
topFiles: [],
|
|
243
|
+
feedbackMoments: [],
|
|
244
|
+
outcome: { signal: 'unknown' },
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function enforceByteBudget(digest) {
|
|
248
|
+
let current = digest;
|
|
249
|
+
if (digestByteLength(current) <= DIGEST_BYTE_BUDGET) {
|
|
250
|
+
return current;
|
|
251
|
+
}
|
|
252
|
+
const arrayFields = [
|
|
253
|
+
'feedbackMoments',
|
|
254
|
+
'topFiles',
|
|
255
|
+
'skills',
|
|
256
|
+
'tools',
|
|
257
|
+
'commands',
|
|
258
|
+
'intents',
|
|
259
|
+
];
|
|
260
|
+
for (let guard = 0; guard < 500 && digestByteLength(current) > DIGEST_BYTE_BUDGET; guard += 1) {
|
|
261
|
+
let changed = false;
|
|
262
|
+
for (const field of arrayFields) {
|
|
263
|
+
if (digestByteLength(current) <= DIGEST_BYTE_BUDGET) {
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
const items = current[field];
|
|
267
|
+
if (Array.isArray(items) && items.length > 0) {
|
|
268
|
+
current = trimArrayField(current, field);
|
|
269
|
+
changed = true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const maxIntentLength = current.intents.reduce((max, intent) => Math.max(max, intent.text.length), 0);
|
|
273
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET && maxIntentLength > MIN_INTENT_TEXT_LENGTH) {
|
|
274
|
+
current = shortenIntentTexts(current, Math.max(MIN_INTENT_TEXT_LENGTH, maxIntentLength - 20));
|
|
275
|
+
changed = true;
|
|
276
|
+
}
|
|
277
|
+
const maxCommandLength = current.commands.reduce((max, command) => Math.max(max, command.command.length), 0);
|
|
278
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET && maxCommandLength > MIN_COMMAND_TEXT_LENGTH) {
|
|
279
|
+
current = shortenCommands(current, Math.max(MIN_COMMAND_TEXT_LENGTH, maxCommandLength - 20));
|
|
280
|
+
changed = true;
|
|
281
|
+
}
|
|
282
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET && current.feedbackMoments.length > 0) {
|
|
283
|
+
current = shortenFeedbackMoments(current, 20);
|
|
284
|
+
changed = true;
|
|
285
|
+
}
|
|
286
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET && current.outcome.evidence) {
|
|
287
|
+
current = {
|
|
288
|
+
...current,
|
|
289
|
+
outcome: {
|
|
290
|
+
signal: current.outcome.signal,
|
|
291
|
+
evidence: current.outcome.evidence.slice(0, Math.max(20, current.outcome.evidence.length - 20)),
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
changed = true;
|
|
295
|
+
}
|
|
296
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET && current.workspaceLabel !== undefined) {
|
|
297
|
+
const { workspaceLabel: _workspaceLabel, ...rest } = current;
|
|
298
|
+
current = rest;
|
|
299
|
+
changed = true;
|
|
300
|
+
}
|
|
301
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET && current.outcome.evidence !== undefined) {
|
|
302
|
+
current = { ...current, outcome: { signal: current.outcome.signal } };
|
|
303
|
+
changed = true;
|
|
304
|
+
}
|
|
305
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET) {
|
|
306
|
+
current = truncateScalarFields(current, 20);
|
|
307
|
+
changed = true;
|
|
308
|
+
}
|
|
309
|
+
if (digestByteLength(current) > DIGEST_BYTE_BUDGET) {
|
|
310
|
+
current = truncateArrayStringFields(current, 20);
|
|
311
|
+
changed = true;
|
|
312
|
+
}
|
|
313
|
+
if (!changed) {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const parsed = shared_1.SessionDigestSchema.safeParse(current);
|
|
318
|
+
if (parsed.success) {
|
|
319
|
+
return parsed.data;
|
|
320
|
+
}
|
|
321
|
+
return minimalUnknownDigest(current.turnCount);
|
|
322
|
+
}
|
|
323
|
+
function finalizeDigest(digest) {
|
|
324
|
+
const parsed = shared_1.SessionDigestSchema.safeParse(digest);
|
|
325
|
+
if (parsed.success) {
|
|
326
|
+
return enforceByteBudget(parsed.data);
|
|
327
|
+
}
|
|
328
|
+
const d = isRecord(digest) ? digest : {};
|
|
329
|
+
const coerced = shared_1.SessionDigestSchema.safeParse({
|
|
330
|
+
schemaVersion: 1,
|
|
331
|
+
host: d.host === 'cursor' || d.host === 'claude' ? d.host : 'claude',
|
|
332
|
+
sessionId: typeof d.sessionId === 'string' ? d.sessionId : 'unknown',
|
|
333
|
+
workspaceRoot: typeof d.workspaceRoot === 'string' ? d.workspaceRoot : '',
|
|
334
|
+
...(typeof d.workspaceLabel === 'string' ? { workspaceLabel: d.workspaceLabel } : {}),
|
|
335
|
+
...(typeof d.workspaceSlug === 'string' ? { workspaceSlug: d.workspaceSlug } : {}),
|
|
336
|
+
...(d.gitBranch === null || typeof d.gitBranch === 'string' ? { gitBranch: d.gitBranch } : {}),
|
|
337
|
+
startedAt: typeof d.startedAt === 'string' ? d.startedAt : EPOCH_ISO,
|
|
338
|
+
endedAt: typeof d.endedAt === 'string' ? d.endedAt : EPOCH_ISO,
|
|
339
|
+
turnCount: typeof d.turnCount === 'number' && Number.isInteger(d.turnCount) && d.turnCount >= 0 ? d.turnCount : 0,
|
|
340
|
+
...(typeof d.skippedLineCount === 'number'
|
|
341
|
+
? { skippedLineCount: Math.max(0, Math.floor(d.skippedLineCount)) }
|
|
342
|
+
: {}),
|
|
343
|
+
intents: Array.isArray(d.intents) ? d.intents.slice(0, 40) : [],
|
|
344
|
+
commands: [],
|
|
345
|
+
tools: [],
|
|
346
|
+
skills: [],
|
|
347
|
+
topFiles: [],
|
|
348
|
+
feedbackMoments: [],
|
|
349
|
+
outcome: { signal: 'unknown' },
|
|
350
|
+
});
|
|
351
|
+
if (coerced.success) {
|
|
352
|
+
return enforceByteBudget(coerced.data);
|
|
353
|
+
}
|
|
354
|
+
return minimalUnknownDigest();
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=digest-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-session.js","sourceRoot":"","sources":["../../src/bootstrap/digest-session.ts"],"names":[],"mappings":";;;;;AA8CA,sCAmHC;AAjKD,0DAA6B;AAC7B,+CAA6E;AAC7E,+DAAgE;AAChE,6CAAwH;AACxH,yDAA4D;AAC5D,+CAAsF;AAEtF,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAC7C,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AASlC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,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C,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE;YACnE,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;QAC/D,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,eAAe,EAAE,EAAE;QACnB,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;KAC/B,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,oBAAoB,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EnumeratedSession } from './enumerate';
|
|
2
|
+
export type EnumeratedCursorSession = EnumeratedSession & {
|
|
3
|
+
projectSlug: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Walk `~/.cursor/projects/<slug>/agent-transcripts/` for parent session JSONL.
|
|
7
|
+
* Supports `<sessionId>/<sessionId>.jsonl` and legacy flat `*.jsonl`.
|
|
8
|
+
* Excludes nested subagents directories.
|
|
9
|
+
*/
|
|
10
|
+
export declare function enumerateCursorSessions(projectsDir: string): EnumeratedCursorSession[];
|
|
11
|
+
/** Skip Cursor project dirs that are not real workspace path encodings. */
|
|
12
|
+
export declare function isJunkCursorProjectSlug(slug: string): boolean;
|
|
13
|
+
//# sourceMappingURL=enumerate-cursor.d.ts.map
|