@code-insights/cli 3.5.1 → 3.6.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dashboard-dist/assets/{index-CyMrlee5.js → index-BaKju1iW.js} +166 -151
  3. package/dashboard-dist/assets/index-_SWpRg6C.css +1 -0
  4. package/dashboard-dist/index.html +2 -2
  5. package/dist/db/migrate.d.ts +1 -0
  6. package/dist/db/migrate.d.ts.map +1 -1
  7. package/dist/db/migrate.js +10 -3
  8. package/dist/db/migrate.js.map +1 -1
  9. package/dist/db/schema.d.ts +2 -2
  10. package/dist/db/schema.d.ts.map +1 -1
  11. package/dist/db/schema.js +2 -1
  12. package/dist/db/schema.js.map +1 -1
  13. package/dist/types.d.ts +1 -0
  14. package/dist/types.d.ts.map +1 -1
  15. package/dist/utils/telemetry.js +1 -1
  16. package/dist/utils/telemetry.js.map +1 -1
  17. package/package.json +1 -1
  18. package/server-dist/export/agent-rules.d.ts +3 -0
  19. package/server-dist/export/agent-rules.d.ts.map +1 -0
  20. package/server-dist/export/agent-rules.js +153 -0
  21. package/server-dist/export/agent-rules.js.map +1 -0
  22. package/server-dist/export/knowledge-base.d.ts +33 -0
  23. package/server-dist/export/knowledge-base.d.ts.map +1 -0
  24. package/server-dist/export/knowledge-base.js +234 -0
  25. package/server-dist/export/knowledge-base.js.map +1 -0
  26. package/server-dist/llm/export-prompts.d.ts +57 -0
  27. package/server-dist/llm/export-prompts.d.ts.map +1 -0
  28. package/server-dist/llm/export-prompts.js +225 -0
  29. package/server-dist/llm/export-prompts.js.map +1 -0
  30. package/server-dist/routes/export.d.ts.map +1 -1
  31. package/server-dist/routes/export.js +305 -18
  32. package/server-dist/routes/export.js.map +1 -1
  33. package/dashboard-dist/assets/index-CFvScypR.css +0 -1
  34. package/dashboard-dist/dist/assets/index-CFvScypR.css +0 -1
  35. package/dashboard-dist/dist/assets/index-CyMrlee5.js +0 -592
  36. package/dashboard-dist/dist/favicon.svg +0 -18
  37. package/dashboard-dist/dist/index.html +0 -33
  38. package/server-dist/dist/index.d.ts +0 -20
  39. package/server-dist/dist/index.d.ts.map +0 -1
  40. package/server-dist/dist/index.js +0 -109
  41. package/server-dist/dist/index.js.map +0 -1
  42. package/server-dist/dist/llm/analysis.d.ts +0 -84
  43. package/server-dist/dist/llm/analysis.d.ts.map +0 -1
  44. package/server-dist/dist/llm/analysis.js +0 -550
  45. package/server-dist/dist/llm/analysis.js.map +0 -1
  46. package/server-dist/dist/llm/client.d.ts +0 -27
  47. package/server-dist/dist/llm/client.d.ts.map +0 -1
  48. package/server-dist/dist/llm/client.js +0 -71
  49. package/server-dist/dist/llm/client.js.map +0 -1
  50. package/server-dist/dist/llm/index.d.ts +0 -7
  51. package/server-dist/dist/llm/index.d.ts.map +0 -1
  52. package/server-dist/dist/llm/index.js +0 -5
  53. package/server-dist/dist/llm/index.js.map +0 -1
  54. package/server-dist/dist/llm/prompts.d.ts +0 -109
  55. package/server-dist/dist/llm/prompts.d.ts.map +0 -1
  56. package/server-dist/dist/llm/prompts.js +0 -381
  57. package/server-dist/dist/llm/prompts.js.map +0 -1
  58. package/server-dist/dist/llm/providers/anthropic.d.ts +0 -3
  59. package/server-dist/dist/llm/providers/anthropic.d.ts.map +0 -1
  60. package/server-dist/dist/llm/providers/anthropic.js +0 -45
  61. package/server-dist/dist/llm/providers/anthropic.js.map +0 -1
  62. package/server-dist/dist/llm/providers/gemini.d.ts +0 -3
  63. package/server-dist/dist/llm/providers/gemini.d.ts.map +0 -1
  64. package/server-dist/dist/llm/providers/gemini.js +0 -51
  65. package/server-dist/dist/llm/providers/gemini.js.map +0 -1
  66. package/server-dist/dist/llm/providers/ollama.d.ts +0 -12
  67. package/server-dist/dist/llm/providers/ollama.d.ts.map +0 -1
  68. package/server-dist/dist/llm/providers/ollama.js +0 -61
  69. package/server-dist/dist/llm/providers/ollama.js.map +0 -1
  70. package/server-dist/dist/llm/providers/openai.d.ts +0 -3
  71. package/server-dist/dist/llm/providers/openai.d.ts.map +0 -1
  72. package/server-dist/dist/llm/providers/openai.js +0 -40
  73. package/server-dist/dist/llm/providers/openai.js.map +0 -1
  74. package/server-dist/dist/llm/types.d.ts +0 -22
  75. package/server-dist/dist/llm/types.d.ts.map +0 -1
  76. package/server-dist/dist/llm/types.js +0 -5
  77. package/server-dist/dist/llm/types.js.map +0 -1
  78. package/server-dist/dist/routes/analysis.d.ts +0 -4
  79. package/server-dist/dist/routes/analysis.d.ts.map +0 -1
  80. package/server-dist/dist/routes/analysis.js +0 -370
  81. package/server-dist/dist/routes/analysis.js.map +0 -1
  82. package/server-dist/dist/routes/analytics.d.ts +0 -4
  83. package/server-dist/dist/routes/analytics.d.ts.map +0 -1
  84. package/server-dist/dist/routes/analytics.js +0 -57
  85. package/server-dist/dist/routes/analytics.js.map +0 -1
  86. package/server-dist/dist/routes/config.d.ts +0 -4
  87. package/server-dist/dist/routes/config.d.ts.map +0 -1
  88. package/server-dist/dist/routes/config.js +0 -108
  89. package/server-dist/dist/routes/config.js.map +0 -1
  90. package/server-dist/dist/routes/export.d.ts +0 -4
  91. package/server-dist/dist/routes/export.d.ts.map +0 -1
  92. package/server-dist/dist/routes/export.js +0 -52
  93. package/server-dist/dist/routes/export.js.map +0 -1
  94. package/server-dist/dist/routes/insights.d.ts +0 -4
  95. package/server-dist/dist/routes/insights.d.ts.map +0 -1
  96. package/server-dist/dist/routes/insights.js +0 -80
  97. package/server-dist/dist/routes/insights.js.map +0 -1
  98. package/server-dist/dist/routes/messages.d.ts +0 -4
  99. package/server-dist/dist/routes/messages.d.ts.map +0 -1
  100. package/server-dist/dist/routes/messages.js +0 -19
  101. package/server-dist/dist/routes/messages.js.map +0 -1
  102. package/server-dist/dist/routes/projects.d.ts +0 -4
  103. package/server-dist/dist/routes/projects.d.ts.map +0 -1
  104. package/server-dist/dist/routes/projects.js +0 -32
  105. package/server-dist/dist/routes/projects.js.map +0 -1
  106. package/server-dist/dist/routes/sessions.d.ts +0 -4
  107. package/server-dist/dist/routes/sessions.d.ts.map +0 -1
  108. package/server-dist/dist/routes/sessions.js +0 -65
  109. package/server-dist/dist/routes/sessions.js.map +0 -1
  110. package/server-dist/dist/routes/telemetry.d.ts +0 -4
  111. package/server-dist/dist/routes/telemetry.d.ts.map +0 -1
  112. package/server-dist/dist/routes/telemetry.js +0 -21
  113. package/server-dist/dist/routes/telemetry.js.map +0 -1
  114. package/server-dist/dist/utils.d.ts +0 -6
  115. package/server-dist/dist/utils.d.ts.map +0 -1
  116. package/server-dist/dist/utils.js +0 -9
  117. package/server-dist/dist/utils.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-rules.js","sourceRoot":"","sources":["../../src/export/agent-rules.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,2EAA2E;AAI3E,SAAS,aAAa,CAAC,GAAkB;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAsB,EAAE,QAAsB;IAC7E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,mDAAmD,CAAC;IAEtF,oDAAoD;IACpD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,CAAC;IAC9F,MAAM,OAAO,GAAG,KAAK,CAAC,MA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AE,CAAC;oBACnE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC3D,gBAAgB,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,IAAI,IAAI,iBAAiB,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC;gBACrF,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,33 @@
1
+ export interface SessionRow {
2
+ id: string;
3
+ project_name: string | null;
4
+ generated_title: string | null;
5
+ custom_title: string | null;
6
+ started_at: string | null;
7
+ ended_at: string | null;
8
+ message_count: number | null;
9
+ estimated_cost_usd: number | null;
10
+ session_character: string | null;
11
+ source_tool: string | null;
12
+ }
13
+ export interface InsightRow {
14
+ id: string;
15
+ session_id: string;
16
+ project_id: string;
17
+ project_name: string | null;
18
+ type: string;
19
+ title: string;
20
+ content: string;
21
+ summary: string | null;
22
+ bullets: string | null;
23
+ confidence: number | null;
24
+ source: string | null;
25
+ metadata: string | null;
26
+ timestamp: string;
27
+ created_at: string;
28
+ scope: string | null;
29
+ analysis_version: string | null;
30
+ linked_insight_ids: string | null;
31
+ }
32
+ export declare function formatKnowledgeBase(sessions: SessionRow[], insights: InsightRow[]): string;
33
+ //# sourceMappingURL=knowledge-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-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AAE,UAAU,EAAE,GAAG,MAAM,CA2F1F"}
@@ -0,0 +1,234 @@
1
+ // Knowledge Base template formatter
2
+ // Produces human-readable markdown organized by session, with rich insight content
3
+ function parseBullets(raw) {
4
+ if (!raw)
5
+ return [];
6
+ try {
7
+ const parsed = JSON.parse(raw);
8
+ return Array.isArray(parsed) ? parsed : [];
9
+ }
10
+ catch {
11
+ return [];
12
+ }
13
+ }
14
+ function parseMetadata(raw) {
15
+ if (!raw)
16
+ return {};
17
+ try {
18
+ const parsed = JSON.parse(raw);
19
+ return typeof parsed === 'object' && parsed !== null ? parsed : {};
20
+ }
21
+ catch {
22
+ return {};
23
+ }
24
+ }
25
+ function renderSummary(insight, lines) {
26
+ const meta = parseMetadata(insight.metadata);
27
+ const bullets = parseBullets(insight.bullets);
28
+ lines.push('### Summary');
29
+ const outcome = meta.outcome;
30
+ if (outcome)
31
+ lines.push(`**Outcome:** ${outcome}`);
32
+ if (insight.content)
33
+ lines.push(insight.content);
34
+ for (const bullet of bullets)
35
+ lines.push(`- ${bullet}`);
36
+ }
37
+ function renderDecisions(insights, lines) {
38
+ lines.push('### Decisions');
39
+ lines.push('');
40
+ for (const insight of insights) {
41
+ const meta = parseMetadata(insight.metadata);
42
+ lines.push(`#### ${insight.title}`);
43
+ const situation = meta.situation;
44
+ if (situation)
45
+ lines.push(`**Situation:** ${situation}`);
46
+ const choice = meta.choice;
47
+ if (choice)
48
+ lines.push(`**Choice:** ${choice}`);
49
+ const reasoning = meta.reasoning;
50
+ if (reasoning)
51
+ lines.push(`**Reasoning:** ${reasoning}`);
52
+ const alternatives = meta.alternatives;
53
+ if (alternatives && alternatives.length > 0) {
54
+ lines.push('');
55
+ lines.push('**Alternatives Considered:**');
56
+ for (const alt of alternatives) {
57
+ if (typeof alt === 'string') {
58
+ lines.push(`- ${alt}`);
59
+ }
60
+ else if (alt.option) {
61
+ const reason = alt.rejected_because ? ` — rejected because ${alt.rejected_because}` : '';
62
+ lines.push(`- ${alt.option}${reason}`);
63
+ }
64
+ }
65
+ }
66
+ const trade_offs = meta.trade_offs;
67
+ if (trade_offs)
68
+ lines.push(`**Trade-offs:** ${trade_offs}`);
69
+ const revisit_when = meta.revisit_when;
70
+ if (revisit_when)
71
+ lines.push(`**Revisit When:** ${revisit_when}`);
72
+ // Fallback to raw content when no structured metadata is present
73
+ if (!situation && !choice && !reasoning && insight.content)
74
+ lines.push(insight.content);
75
+ lines.push('');
76
+ }
77
+ }
78
+ function renderLearnings(insights, lines) {
79
+ lines.push('### Learnings');
80
+ lines.push('');
81
+ for (const insight of insights) {
82
+ const meta = parseMetadata(insight.metadata);
83
+ lines.push(`#### ${insight.title}`);
84
+ const symptom = meta.symptom;
85
+ if (symptom)
86
+ lines.push(`**What Happened:** ${symptom}`);
87
+ const root_cause = meta.root_cause;
88
+ if (root_cause)
89
+ lines.push(`**Root Cause:** ${root_cause}`);
90
+ const takeaway = meta.takeaway;
91
+ if (takeaway)
92
+ lines.push(`**Takeaway:** ${takeaway}`);
93
+ const applies_when = meta.applies_when;
94
+ if (applies_when)
95
+ lines.push(`**Applies When:** ${applies_when}`);
96
+ if (!symptom && !root_cause && !takeaway && insight.content)
97
+ lines.push(insight.content);
98
+ lines.push('');
99
+ }
100
+ }
101
+ function renderTechniques(insights, lines) {
102
+ lines.push('### Techniques');
103
+ lines.push('');
104
+ for (const insight of insights) {
105
+ const meta = parseMetadata(insight.metadata);
106
+ lines.push(`#### ${insight.title}`);
107
+ const context = meta.context;
108
+ if (context)
109
+ lines.push(`**Context:** ${context}`);
110
+ const applicability = meta.applicability;
111
+ if (applicability)
112
+ lines.push(`**Applicability:** ${applicability}`);
113
+ if (insight.content)
114
+ lines.push(insight.content);
115
+ lines.push('');
116
+ }
117
+ }
118
+ function renderPromptQuality(insight, lines) {
119
+ const meta = parseMetadata(insight.metadata);
120
+ lines.push('### Prompt Quality');
121
+ const score = meta.efficiencyScore;
122
+ const reduction = meta.potentialMessageReduction;
123
+ if (score !== undefined)
124
+ lines.push(`**Efficiency:** ${score}/100`);
125
+ if (reduction !== undefined)
126
+ lines.push(`**Potential Savings:** ${reduction} fewer messages`);
127
+ const antiPatterns = meta.antiPatterns;
128
+ if (antiPatterns && antiPatterns.length > 0) {
129
+ lines.push('');
130
+ lines.push('**Anti-Patterns:**');
131
+ for (const pattern of antiPatterns) {
132
+ const countStr = pattern.count !== undefined ? ` (seen ${pattern.count}x)` : '';
133
+ const fixStr = pattern.fix ? ` — Fix: ${pattern.fix}` : '';
134
+ lines.push(`- ${pattern.name ?? 'Unknown'}${countStr}${fixStr}`);
135
+ }
136
+ }
137
+ const wastedTurns = meta.wastedTurns;
138
+ if (wastedTurns && wastedTurns.length > 0) {
139
+ lines.push('');
140
+ lines.push('**Wasted Turns:**');
141
+ for (const turn of wastedTurns) {
142
+ const msgStr = turn.messageIndex !== undefined ? `Msg #${turn.messageIndex}` : 'Message';
143
+ lines.push(`- ${msgStr}: ${turn.reason ?? ''}`);
144
+ if (turn.suggestedRewrite) {
145
+ lines.push(` - Better: "${turn.suggestedRewrite}"`);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ export function formatKnowledgeBase(sessions, insights) {
151
+ const now = new Date().toISOString().split('T')[0];
152
+ const lines = [
153
+ `# Code Insights Export`,
154
+ `> Exported on ${now} — ${sessions.length} session${sessions.length !== 1 ? 's' : ''}, ${insights.length} insight${insights.length !== 1 ? 's' : ''}`,
155
+ '',
156
+ ];
157
+ if (insights.length === 0) {
158
+ lines.push('> **Note:** No insights found for the selected sessions. Run analysis on sessions first to generate insights.');
159
+ lines.push('');
160
+ }
161
+ // Build a map of session_id -> insights grouped by type
162
+ const insightsBySession = new Map();
163
+ for (const insight of insights) {
164
+ if (!insightsBySession.has(insight.session_id)) {
165
+ insightsBySession.set(insight.session_id, new Map());
166
+ }
167
+ const byType = insightsBySession.get(insight.session_id);
168
+ const list = byType.get(insight.type) ?? [];
169
+ list.push(insight);
170
+ byType.set(insight.type, list);
171
+ }
172
+ for (const session of sessions) {
173
+ const title = session.custom_title ?? session.generated_title ?? session.id;
174
+ lines.push(`## Session: ${title}`);
175
+ const metaLine1 = [];
176
+ if (session.project_name)
177
+ metaLine1.push(`**Project:** ${session.project_name}`);
178
+ if (session.session_character)
179
+ metaLine1.push(`**Character:** ${session.session_character}`);
180
+ if (session.source_tool)
181
+ metaLine1.push(`**Source:** ${session.source_tool}`);
182
+ if (session.estimated_cost_usd != null) {
183
+ metaLine1.push(`**Cost:** $${Number(session.estimated_cost_usd).toFixed(2)}`);
184
+ }
185
+ if (metaLine1.length > 0)
186
+ lines.push(metaLine1.join(' | '));
187
+ const metaLine2 = [];
188
+ if (session.started_at && session.ended_at) {
189
+ metaLine2.push(`**Period:** ${session.started_at} — ${session.ended_at}`);
190
+ }
191
+ else if (session.started_at) {
192
+ metaLine2.push(`**Period:** ${session.started_at}`);
193
+ }
194
+ if (session.message_count != null)
195
+ metaLine2.push(`**Messages:** ${session.message_count}`);
196
+ if (metaLine2.length > 0)
197
+ lines.push(metaLine2.join(' | '));
198
+ lines.push('');
199
+ const byType = insightsBySession.get(session.id);
200
+ if (!byType || byType.size === 0) {
201
+ lines.push('*No insights for this session.*');
202
+ lines.push('');
203
+ continue;
204
+ }
205
+ const summaries = byType.get('summary');
206
+ if (summaries) {
207
+ for (const s of summaries) {
208
+ renderSummary(s, lines);
209
+ lines.push('');
210
+ }
211
+ }
212
+ const decisions = byType.get('decision');
213
+ if (decisions) {
214
+ renderDecisions(decisions, lines);
215
+ }
216
+ const learnings = byType.get('learning');
217
+ if (learnings) {
218
+ renderLearnings(learnings, lines);
219
+ }
220
+ const techniques = byType.get('technique');
221
+ if (techniques) {
222
+ renderTechniques(techniques, lines);
223
+ }
224
+ const pqInsights = byType.get('prompt_quality');
225
+ if (pqInsights) {
226
+ for (const pq of pqInsights) {
227
+ renderPromptQuality(pq, lines);
228
+ lines.push('');
229
+ }
230
+ }
231
+ }
232
+ return lines.join('\n');
233
+ }
234
+ //# sourceMappingURL=knowledge-base.js.map
@@ -0,0 +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YACf,SAAS;QACX,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;gBAC1B,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACxB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,SAAS,EAAE,CAAC;YACd,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,SAAS,EAAE,CAAC;YACd,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,UAAU,EAAE,CAAC;YACf,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAChD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;gBAC5B,mBAAmB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,57 @@
1
+ export type ExportFormat = 'agent-rules' | 'knowledge-brief' | 'obsidian' | 'notion';
2
+ export type ExportScope = 'project' | 'all';
3
+ export type ExportDepth = 'essential' | 'standard' | 'comprehensive';
4
+ export declare const DEPTH_CAPS: Record<ExportDepth, number>;
5
+ export interface ExportInsightRow {
6
+ id: string;
7
+ type: string;
8
+ title: string;
9
+ content: string;
10
+ summary: string;
11
+ confidence: number;
12
+ project_name: string;
13
+ timestamp: string;
14
+ }
15
+ export interface ExportContext {
16
+ scope: ExportScope;
17
+ format: ExportFormat;
18
+ depth: ExportDepth;
19
+ projectName?: string;
20
+ sessionCount: number;
21
+ projectCount: number;
22
+ dateRange: {
23
+ from: string;
24
+ to: string;
25
+ };
26
+ exportDate: string;
27
+ }
28
+ /**
29
+ * Apply depth cap and token budget guard, returning the insights to send to the LLM.
30
+ * Also returns totalInsights (before cap) for metadata.
31
+ */
32
+ export declare function applyDepthCap(insights: ExportInsightRow[], depth: ExportDepth): {
33
+ capped: ExportInsightRow[];
34
+ totalInsights: number;
35
+ };
36
+ /**
37
+ * Format insights for LLM input, grouped by type.
38
+ * Includes project_name on each insight for scope-awareness.
39
+ */
40
+ export declare function buildInsightContext(insights: ExportInsightRow[]): string;
41
+ export declare const AGENT_RULES_PROJECT_SYSTEM_PROMPT: (projectName: string) => string;
42
+ export declare const AGENT_RULES_ALL_SYSTEM_PROMPT = "You are a technical writer converting AI coding session insights from multiple projects into agent instruction rules. Produce imperative instructions suitable for a CLAUDE.md or .cursorrules file.\n\nFor each rule you produce, classify its scope:\n\n- PROJECT-SPECIFIC: The rule references a specific project, framework version, library, or codebase structure that only applies to that project. Prefix with \"[project-name]\" e.g. \"[code-insights] USE WAL mode for SQLite\"\n\n- UNIVERSAL: The rule is a general engineering practice, debugging technique, or prompting pattern that applies across any project. No prefix needed.\n\nWhen in doubt, label as PROJECT-SPECIFIC.\n\nStructure the output as:\n## Universal Rules\n(rules that apply to any project)\n\n## Project-Specific Rules\n### {project-name}\n(rules specific to this project)\n\nAdditional rules:\n- Deduplicate overlapping insights \u2014 merge into single rules\n- Use imperative mood: \"USE X\", \"DO NOT Y\", \"WHEN Z, do W\"\n- Group by topic within each section\n- Prioritize by confidence and frequency\n- Include a \"Prompt Hygiene\" section with universal anti-patterns (if any exist)\n- Output clean markdown only \u2014 no preamble, no meta-commentary";
43
+ export declare const KNOWLEDGE_BRIEF_PROJECT_SYSTEM_PROMPT: (projectName: string) => string;
44
+ export declare const KNOWLEDGE_BRIEF_ALL_SYSTEM_PROMPT = "You are a technical writer creating a knowledge handoff document from AI coding sessions across multiple projects. Produce a readable markdown document summarizing decisions, learnings, and techniques.\n\nStructure:\n- Cross-cutting themes section at the top (patterns that appear across projects)\n- Then organize by project, each with:\n - Key decisions (with reasoning and trade-offs noted)\n - Learnings (grouped by topic)\n - Techniques worth reusing\n\nOutput clean markdown only \u2014 no preamble, no meta-commentary.";
45
+ export declare const OBSIDIAN_PROJECT_SYSTEM_PROMPT: (projectName: string, exportDate: string) => string;
46
+ export declare const OBSIDIAN_ALL_SYSTEM_PROMPT: (exportDate: string) => string;
47
+ export declare const NOTION_PROJECT_SYSTEM_PROMPT: (projectName: string) => string;
48
+ export declare const NOTION_ALL_SYSTEM_PROMPT = "Produce Notion-compatible markdown covering multiple projects. Use:\n- Toggle blocks (\u25B6 **Section Name**) for collapsible sections\n- Callout blocks (> [!note] content) for key decisions\n- Tables for structured comparisons where appropriate\n- No wikilinks \u2014 use standard markdown links only\n\nOrganize content by project with a cross-cutting themes section first. Output clean markdown only \u2014 no preamble, no meta-commentary.";
49
+ /**
50
+ * Select the appropriate system prompt for the given format and scope.
51
+ */
52
+ export declare function getExportSystemPrompt(ctx: ExportContext): string;
53
+ /**
54
+ * Build the user prompt that combines the export context header with the insight data.
55
+ */
56
+ export declare function buildExportUserPrompt(ctx: ExportContext, insightContext: string): string;
57
+ //# sourceMappingURL=export-prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-prompts.d.ts","sourceRoot":"","sources":["../../src/llm/export-prompts.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,iBAAiB,GAAG,UAAU,GAAG,QA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X,CAAC;AAE/D,eAAO,MAAM,iCAAiC,qhBAWgB,CAAC;AAE/D,eAAO,MAAM,8BAA8B,GAAI,aAAa,MAAM,EAAE,YAAY,MAAM,WAaxB,CAAC;AAE/D,eAAO,MAAM,0BAA0B,GAAI,YAAY,MAAM,WAaC,CAAC;AAE/D,eAAO,MAAM,4BAA4B,GAAI,aAAa,MAAM,WAQF,CAAC;AAE/D,eAAO,MAAM,wBAAwB,gcAQyB,CAAC;AAE/D;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA2BhE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAYxF"}
@@ -0,0 +1,225 @@
1
+ // LLM prompts for cross-session export synthesis.
2
+ // Each format has two scope variants (project vs. all).
3
+ // The LLM returns raw markdown — no JSON parsing needed.
4
+ export const DEPTH_CAPS = {
5
+ essential: 25,
6
+ standard: 80,
7
+ comprehensive: 200,
8
+ };
9
+ // Rough token estimate per insight (title + content + metadata summary).
10
+ // Used to enforce the hard 60k input token ceiling within the depth cap.
11
+ const AVG_TOKENS_PER_INSIGHT = 300;
12
+ const MAX_EXPORT_INPUT_TOKENS = 60000;
13
+ /**
14
+ * Apply depth cap and token budget guard, returning the insights to send to the LLM.
15
+ * Also returns totalInsights (before cap) for metadata.
16
+ */
17
+ export function applyDepthCap(insights, depth) {
18
+ const totalInsights = insights.length;
19
+ const depthCap = DEPTH_CAPS[depth];
20
+ // Apply depth cap first
21
+ let capped = insights.slice(0, depthCap);
22
+ // Token budget guard within the depth cap — safety net for unusually large insights
23
+ let tokenEstimate = 0;
24
+ const tokenBudgeted = [];
25
+ for (const insight of capped) {
26
+ tokenEstimate += AVG_TOKENS_PER_INSIGHT;
27
+ if (tokenEstimate > MAX_EXPORT_INPUT_TOKENS)
28
+ break;
29
+ tokenBudgeted.push(insight);
30
+ }
31
+ capped = tokenBudgeted;
32
+ return { capped, totalInsights };
33
+ }
34
+ /**
35
+ * Format insights for LLM input, grouped by type.
36
+ * Includes project_name on each insight for scope-awareness.
37
+ */
38
+ export function buildInsightContext(insights) {
39
+ const grouped = {};
40
+ for (const insight of insights) {
41
+ const key = insight.type;
42
+ if (!grouped[key])
43
+ grouped[key] = [];
44
+ grouped[key].push(insight);
45
+ }
46
+ const sections = [];
47
+ const typeOrder = ['decision', 'learning', 'technique', 'prompt_quality', 'summary'];
48
+ const typeLabels = {
49
+ decision: 'DECISIONS',
50
+ learning: 'LEARNINGS',
51
+ technique: 'TECHNIQUES',
52
+ prompt_quality: 'PROMPT QUALITY',
53
+ summary: 'SESSION SUMMARIES',
54
+ };
55
+ for (const type of typeOrder) {
56
+ const items = grouped[type];
57
+ if (!items || items.length === 0)
58
+ continue;
59
+ const label = typeLabels[type] ?? type.toUpperCase();
60
+ sections.push(`## ${label}\n`);
61
+ for (const item of items) {
62
+ const projectTag = item.project_name ? ` [${item.project_name}]` : '';
63
+ const confidence = Math.round(item.confidence * 100);
64
+ sections.push(`### ${item.title}${projectTag} (confidence: ${confidence}%)\n${item.content || item.summary}\n`);
65
+ }
66
+ }
67
+ return sections.join('\n');
68
+ }
69
+ // ─── System prompts ──────────────────────────────────────────────────────────
70
+ export const AGENT_RULES_PROJECT_SYSTEM_PROMPT = (projectName) => `\
71
+ You are a technical writer converting AI coding session insights into agent \
72
+ instruction rules for the project "${projectName}". Produce imperative \
73
+ instructions suitable for a CLAUDE.md or .cursorrules file.
74
+
75
+ Rules:
76
+ - Deduplicate overlapping insights — merge into single rules
77
+ - Use imperative mood: "USE X", "DO NOT Y", "WHEN Z, do W"
78
+ - Group by topic (not by session)
79
+ - Include REVISIT conditions where relevant
80
+ - Prioritize by confidence and frequency
81
+ - If decisions evolved over time, note the current decision and why it changed
82
+ - Include a "Prompt Hygiene" section aggregating anti-patterns from prompt quality insights (if any exist)
83
+ - Output clean markdown only — no preamble, no meta-commentary`;
84
+ export const AGENT_RULES_ALL_SYSTEM_PROMPT = `\
85
+ You are a technical writer converting AI coding session insights from multiple \
86
+ projects into agent instruction rules. Produce imperative instructions suitable \
87
+ for a CLAUDE.md or .cursorrules file.
88
+
89
+ For each rule you produce, classify its scope:
90
+
91
+ - PROJECT-SPECIFIC: The rule references a specific project, framework version, \
92
+ library, or codebase structure that only applies to that project. \
93
+ Prefix with "[project-name]" e.g. "[code-insights] USE WAL mode for SQLite"
94
+
95
+ - UNIVERSAL: The rule is a general engineering practice, debugging technique, \
96
+ or prompting pattern that applies across any project. \
97
+ No prefix needed.
98
+
99
+ When in doubt, label as PROJECT-SPECIFIC.
100
+
101
+ Structure the output as:
102
+ ## Universal Rules
103
+ (rules that apply to any project)
104
+
105
+ ## Project-Specific Rules
106
+ ### {project-name}
107
+ (rules specific to this project)
108
+
109
+ Additional rules:
110
+ - Deduplicate overlapping insights — merge into single rules
111
+ - Use imperative mood: "USE X", "DO NOT Y", "WHEN Z, do W"
112
+ - Group by topic within each section
113
+ - Prioritize by confidence and frequency
114
+ - Include a "Prompt Hygiene" section with universal anti-patterns (if any exist)
115
+ - Output clean markdown only — no preamble, no meta-commentary`;
116
+ export const KNOWLEDGE_BRIEF_PROJECT_SYSTEM_PROMPT = (projectName) => `\
117
+ You are a technical writer creating a project knowledge handoff document for "${projectName}". \
118
+ Produce a readable markdown document summarizing decisions, learnings, and techniques from AI coding sessions.
119
+
120
+ Structure:
121
+ - Executive summary (3-5 sentences covering the project's trajectory and key architectural bets)
122
+ - Key decisions (with reasoning and trade-offs noted)
123
+ - Learnings (grouped by topic)
124
+ - Techniques worth reusing
125
+
126
+ Output clean markdown only — no preamble, no meta-commentary.`;
127
+ export const KNOWLEDGE_BRIEF_ALL_SYSTEM_PROMPT = `\
128
+ You are a technical writer creating a knowledge handoff document from AI coding sessions across multiple projects. \
129
+ Produce a readable markdown document summarizing decisions, learnings, and techniques.
130
+
131
+ Structure:
132
+ - Cross-cutting themes section at the top (patterns that appear across projects)
133
+ - Then organize by project, each with:
134
+ - Key decisions (with reasoning and trade-offs noted)
135
+ - Learnings (grouped by topic)
136
+ - Techniques worth reusing
137
+
138
+ Output clean markdown only — no preamble, no meta-commentary.`;
139
+ export const OBSIDIAN_PROJECT_SYSTEM_PROMPT = (projectName, exportDate) => `\
140
+ Produce markdown with YAML frontmatter suitable for Obsidian for the project "${projectName}". \
141
+ Start with exactly this frontmatter block:
142
+
143
+ ---
144
+ date: ${exportDate}
145
+ project: ${projectName}
146
+ tags: [code-insights, decisions, learnings, techniques]
147
+ type: knowledge-export
148
+ ---
149
+
150
+ Use [[wikilinks]] for cross-references between concepts where appropriate. \
151
+ Group content by topic, not by session. \
152
+ Output clean markdown only — no preamble, no meta-commentary.`;
153
+ export const OBSIDIAN_ALL_SYSTEM_PROMPT = (exportDate) => `\
154
+ Produce markdown with YAML frontmatter suitable for Obsidian covering multiple projects. \
155
+ Start with exactly this frontmatter block:
156
+
157
+ ---
158
+ date: ${exportDate}
159
+ project: multiple
160
+ tags: [code-insights, decisions, learnings, techniques]
161
+ type: knowledge-export
162
+ ---
163
+
164
+ Use [[wikilinks]] for cross-references between concepts where appropriate. \
165
+ Organize content by project with a cross-cutting themes section first. \
166
+ Output clean markdown only — no preamble, no meta-commentary.`;
167
+ export const NOTION_PROJECT_SYSTEM_PROMPT = (projectName) => `\
168
+ Produce Notion-compatible markdown for the project "${projectName}". Use:
169
+ - Toggle blocks (▶ **Section Name**) for collapsible sections
170
+ - Callout blocks (> [!note] content) for key decisions
171
+ - Tables for structured comparisons where appropriate
172
+ - No wikilinks — use standard markdown links only
173
+
174
+ Group content by topic, not by session. \
175
+ Output clean markdown only — no preamble, no meta-commentary.`;
176
+ export const NOTION_ALL_SYSTEM_PROMPT = `\
177
+ Produce Notion-compatible markdown covering multiple projects. Use:
178
+ - Toggle blocks (▶ **Section Name**) for collapsible sections
179
+ - Callout blocks (> [!note] content) for key decisions
180
+ - Tables for structured comparisons where appropriate
181
+ - No wikilinks — use standard markdown links only
182
+
183
+ Organize content by project with a cross-cutting themes section first. \
184
+ Output clean markdown only — no preamble, no meta-commentary.`;
185
+ /**
186
+ * Select the appropriate system prompt for the given format and scope.
187
+ */
188
+ export function getExportSystemPrompt(ctx) {
189
+ const { format, scope, projectName = 'unknown', exportDate } = ctx;
190
+ switch (format) {
191
+ case 'agent-rules':
192
+ return scope === 'project'
193
+ ? AGENT_RULES_PROJECT_SYSTEM_PROMPT(projectName)
194
+ : AGENT_RULES_ALL_SYSTEM_PROMPT;
195
+ case 'knowledge-brief':
196
+ return scope === 'project'
197
+ ? KNOWLEDGE_BRIEF_PROJECT_SYSTEM_PROMPT(projectName)
198
+ : KNOWLEDGE_BRIEF_ALL_SYSTEM_PROMPT;
199
+ case 'obsidian':
200
+ return scope === 'project'
201
+ ? OBSIDIAN_PROJECT_SYSTEM_PROMPT(projectName, exportDate)
202
+ : OBSIDIAN_ALL_SYSTEM_PROMPT(exportDate);
203
+ case 'notion':
204
+ return scope === 'project'
205
+ ? NOTION_PROJECT_SYSTEM_PROMPT(projectName)
206
+ : NOTION_ALL_SYSTEM_PROMPT;
207
+ default:
208
+ return AGENT_RULES_PROJECT_SYSTEM_PROMPT(projectName);
209
+ }
210
+ }
211
+ /**
212
+ * Build the user prompt that combines the export context header with the insight data.
213
+ */
214
+ export function buildExportUserPrompt(ctx, insightContext) {
215
+ const scopeDescription = ctx.scope === 'project'
216
+ ? `Project: ${ctx.projectName}`
217
+ : `All projects (${ctx.projectCount} project${ctx.projectCount !== 1 ? 's' : ''})`;
218
+ const header = [
219
+ `Source: ${scopeDescription}`,
220
+ `Sessions analyzed: ${ctx.sessionCount}`,
221
+ `Date range: ${ctx.dateRange.from} to ${ctx.dateRange.to}`,
222
+ ].join('\n');
223
+ return `${header}\n\n${insightContext}`;
224
+ }
225
+ //# sourceMappingURL=export-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-prompts.js","sourceRoot":"","sources":["../../src/llm/export-prompts.ts"],"names":[],"mappings":"AAAA,kDAA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8BAA8B,CAAC,WAAW,EAAE,UAAU,CAAC;gBACzD,CAAC,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAE7C,KAAK,QAAQ;YACX,OAAO,KAAK,KAAK,SAAS;gBACxB,CAAC,CAAC,4BAA4B,CAAC,WAAW,CAAC;gBAC3C,CAAC,CAAC,wBAAwB,CAAC;QAE/B;YACE,OAAO,iCAAiC,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAkB,EAAE,cAAsB;IAC9E,MAAM,gBAAgB,GAAG,GAAG,CAAC,KAAK,KAAK,SAAS;QAC9C,CAAC,CAAC,YAAY,GAAG,CAAC,WAAW,EAAE;QAC/B,CAAC,CAAC,iBAAiB,GAAG,CAAC,YAAY,WAAW,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;IAErF,MAAM,MAAM,GAAG;QACb,WAAW,gBAAgB,EAAE;QAC7B,sBAAsB,GAAG,CAAC,YAAY,EAAE;QACxC,eAAe,GAAG,CAAC,SAAS,CAAC,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE;KAC3D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO,GAAG,MAAM,OAAO,cAAc,EAAE,CAAC;AAC1C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/routes/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,QAAA,MAAM,GAAG,4EAAa,CAAC;AAyDvB,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/routes/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAoB5B,QAAA,MAAM,GAAG,4EAAa,CAAC;AAsZvB,eAAe,GAAG,CAAC"}