ghagga-core 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/agents/consensus.d.ts +2 -1
- package/dist/agents/consensus.d.ts.map +1 -1
- package/dist/agents/consensus.js +4 -2
- package/dist/agents/consensus.js.map +1 -1
- package/dist/agents/prompts.d.ts +10 -1
- package/dist/agents/prompts.d.ts.map +1 -1
- package/dist/agents/prompts.js +24 -2
- package/dist/agents/prompts.js.map +1 -1
- package/dist/agents/simple.d.ts +2 -1
- package/dist/agents/simple.d.ts.map +1 -1
- package/dist/agents/simple.js +4 -2
- package/dist/agents/simple.js.map +1 -1
- package/dist/agents/workflow.d.ts +2 -1
- package/dist/agents/workflow.d.ts.map +1 -1
- package/dist/agents/workflow.js +12 -3
- package/dist/agents/workflow.js.map +1 -1
- package/dist/format.d.ts +11 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +84 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/engram-client.d.ts +38 -0
- package/dist/memory/engram-client.d.ts.map +1 -0
- package/dist/memory/engram-client.js +153 -0
- package/dist/memory/engram-client.js.map +1 -0
- package/dist/memory/engram-mapping.d.ts +83 -0
- package/dist/memory/engram-mapping.d.ts.map +1 -0
- package/dist/memory/engram-mapping.js +159 -0
- package/dist/memory/engram-mapping.js.map +1 -0
- package/dist/memory/engram-types.d.ts +51 -0
- package/dist/memory/engram-types.d.ts.map +1 -0
- package/dist/memory/engram-types.js +12 -0
- package/dist/memory/engram-types.js.map +1 -0
- package/dist/memory/engram.d.ts +76 -0
- package/dist/memory/engram.d.ts.map +1 -0
- package/dist/memory/engram.js +194 -0
- package/dist/memory/engram.js.map +1 -0
- package/dist/memory/persist.d.ts +5 -5
- package/dist/memory/persist.d.ts.map +1 -1
- package/dist/memory/persist.js +23 -24
- package/dist/memory/persist.js.map +1 -1
- package/dist/memory/search.d.ts +6 -5
- package/dist/memory/search.d.ts.map +1 -1
- package/dist/memory/search.js +7 -8
- package/dist/memory/search.js.map +1 -1
- package/dist/memory/sqlite.d.ts +49 -0
- package/dist/memory/sqlite.d.ts.map +1 -0
- package/dist/memory/sqlite.js +349 -0
- package/dist/memory/sqlite.js.map +1 -0
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +167 -58
- package/dist/pipeline.js.map +1 -1
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +12 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/tools/cpd.d.ts.map +1 -1
- package/dist/tools/cpd.js +20 -9
- package/dist/tools/cpd.js.map +1 -1
- package/dist/tools/runner.d.ts +5 -2
- package/dist/tools/runner.d.ts.map +1 -1
- package/dist/tools/runner.js +37 -18
- package/dist/tools/runner.js.map +1 -1
- package/dist/tools/semgrep.d.ts.map +1 -1
- package/dist/tools/semgrep.js +21 -4
- package/dist/tools/semgrep.js.map +1 -1
- package/dist/tools/trivy.d.ts.map +1 -1
- package/dist/tools/trivy.js +6 -2
- package/dist/tools/trivy.js.map +1 -1
- package/dist/types.d.ts +133 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/token-budget.d.ts.map +1 -1
- package/dist/utils/token-budget.js +5 -0
- package/dist/utils/token-budget.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engram-backed memory storage.
|
|
3
|
+
*
|
|
4
|
+
* Implements the MemoryStorage interface by mapping each method to HTTP
|
|
5
|
+
* calls against Engram's REST API (localhost:7437). Uses native fetch()
|
|
6
|
+
* with no external dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Graceful degradation: the async factory performs a health check. If
|
|
9
|
+
* Engram is unreachable it returns null so the caller can fall back to
|
|
10
|
+
* SQLite. During operation, individual method calls catch HTTP errors
|
|
11
|
+
* and return safe defaults — the review never fails because of Engram.
|
|
12
|
+
*/
|
|
13
|
+
import { EngramClient } from './engram-client.js';
|
|
14
|
+
import { toMemoryObservationRow, toMemoryObservationDetail, toEngramSaveData, } from './engram-mapping.js';
|
|
15
|
+
export class EngramMemoryStorage {
|
|
16
|
+
client;
|
|
17
|
+
/**
|
|
18
|
+
* Maps GHAGGA numeric IDs → Engram original IDs (string | number).
|
|
19
|
+
* Populated by searchObservations(), listObservations(), and saveObservation().
|
|
20
|
+
* Used by getObservation() and deleteObservation() to resolve the real Engram ID.
|
|
21
|
+
*/
|
|
22
|
+
idMap = new Map();
|
|
23
|
+
nextId = 1;
|
|
24
|
+
constructor(client) {
|
|
25
|
+
this.client = client;
|
|
26
|
+
}
|
|
27
|
+
// ─── Factory ────────────────────────────────────────────────────
|
|
28
|
+
/**
|
|
29
|
+
* Async factory — creates an instance after verifying Engram is reachable.
|
|
30
|
+
*
|
|
31
|
+
* Config resolution order:
|
|
32
|
+
* 1. Explicit `config` parameter
|
|
33
|
+
* 2. Environment variables (GHAGGA_ENGRAM_HOST, GHAGGA_ENGRAM_TIMEOUT)
|
|
34
|
+
* 3. Defaults (http://localhost:7437, 5000ms)
|
|
35
|
+
*
|
|
36
|
+
* Returns null if Engram is not reachable (caller should fall back to SQLite).
|
|
37
|
+
*/
|
|
38
|
+
static async create(config) {
|
|
39
|
+
const fullConfig = {
|
|
40
|
+
host: config?.host ?? process.env.GHAGGA_ENGRAM_HOST ?? 'http://localhost:7437',
|
|
41
|
+
timeout: config?.timeout ?? Number(process.env.GHAGGA_ENGRAM_TIMEOUT ?? '5') * 1000,
|
|
42
|
+
};
|
|
43
|
+
const client = new EngramClient(fullConfig);
|
|
44
|
+
const healthy = await client.healthCheck();
|
|
45
|
+
if (!healthy) {
|
|
46
|
+
console.warn('[ghagga:engram] Engram server not reachable at %s — falling back to SQLite', fullConfig.host);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return new EngramMemoryStorage(client);
|
|
50
|
+
}
|
|
51
|
+
// ─── Hot-path methods ───────────────────────────────────────────
|
|
52
|
+
async searchObservations(project, query, options = {}) {
|
|
53
|
+
const { limit = 10, type } = options;
|
|
54
|
+
const results = await this.client.search(query, project, limit);
|
|
55
|
+
let mapped = results.map((obs) => {
|
|
56
|
+
const row = toMemoryObservationRow(obs);
|
|
57
|
+
this.trackId(row.id, obs.id);
|
|
58
|
+
return row;
|
|
59
|
+
});
|
|
60
|
+
// Client-side type filter (Engram may not support it natively)
|
|
61
|
+
if (type) {
|
|
62
|
+
mapped = mapped.filter((r) => r.type === type);
|
|
63
|
+
}
|
|
64
|
+
return mapped;
|
|
65
|
+
}
|
|
66
|
+
async saveObservation(data) {
|
|
67
|
+
const payload = toEngramSaveData(data);
|
|
68
|
+
const result = await this.client.save(payload);
|
|
69
|
+
if (!result) {
|
|
70
|
+
// Graceful degradation: return a synthetic row so the pipeline continues
|
|
71
|
+
console.warn('[ghagga:engram] saveObservation: Engram save failed, returning synthetic row');
|
|
72
|
+
return {
|
|
73
|
+
id: -1,
|
|
74
|
+
type: data.type,
|
|
75
|
+
title: data.title,
|
|
76
|
+
content: data.content,
|
|
77
|
+
filePaths: data.filePaths ?? null,
|
|
78
|
+
severity: data.severity ?? null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const row = toMemoryObservationRow(result);
|
|
82
|
+
this.trackId(row.id, result.id);
|
|
83
|
+
return row;
|
|
84
|
+
}
|
|
85
|
+
// ─── Session methods ────────────────────────────────────────────
|
|
86
|
+
async createSession(data) {
|
|
87
|
+
const sessionId = await this.client.createSession(data.project);
|
|
88
|
+
if (sessionId == null) {
|
|
89
|
+
console.warn('[ghagga:engram] createSession failed, returning synthetic id');
|
|
90
|
+
return { id: -1 };
|
|
91
|
+
}
|
|
92
|
+
return { id: sessionId };
|
|
93
|
+
}
|
|
94
|
+
async endSession(sessionId, summary) {
|
|
95
|
+
// Skip if session was never properly created
|
|
96
|
+
if (sessionId === -1)
|
|
97
|
+
return;
|
|
98
|
+
await this.client.endSession(sessionId, summary);
|
|
99
|
+
}
|
|
100
|
+
/** No-op — HTTP connections don't need explicit cleanup. */
|
|
101
|
+
async close() {
|
|
102
|
+
// Nothing to clean up for HTTP-based storage
|
|
103
|
+
}
|
|
104
|
+
// ─── Management methods ─────────────────────────────────────────
|
|
105
|
+
async listObservations(options = {}) {
|
|
106
|
+
const { project, type, limit = 20 } = options;
|
|
107
|
+
// Use search with empty query to list all observations
|
|
108
|
+
const results = await this.client.search('', project, limit);
|
|
109
|
+
let mapped = results.map((obs) => {
|
|
110
|
+
const detail = toMemoryObservationDetail(obs);
|
|
111
|
+
this.trackId(detail.id, obs.id);
|
|
112
|
+
return detail;
|
|
113
|
+
});
|
|
114
|
+
// Client-side type filter
|
|
115
|
+
if (type) {
|
|
116
|
+
mapped = mapped.filter((r) => r.type === type);
|
|
117
|
+
}
|
|
118
|
+
// Client-side offset (Engram may not support it natively)
|
|
119
|
+
if (options.offset && options.offset > 0) {
|
|
120
|
+
mapped = mapped.slice(options.offset);
|
|
121
|
+
}
|
|
122
|
+
return mapped;
|
|
123
|
+
}
|
|
124
|
+
async getObservation(id) {
|
|
125
|
+
const realId = this.idMap.get(id);
|
|
126
|
+
if (realId == null) {
|
|
127
|
+
console.warn('[ghagga:engram] getObservation: ID %d not found in local map. ' +
|
|
128
|
+
'Run searchObservations or listObservations first.', id);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const obs = await this.client.getObservation(realId);
|
|
132
|
+
if (!obs)
|
|
133
|
+
return null;
|
|
134
|
+
return toMemoryObservationDetail(obs);
|
|
135
|
+
}
|
|
136
|
+
async deleteObservation(id) {
|
|
137
|
+
const realId = this.idMap.get(id);
|
|
138
|
+
if (realId == null) {
|
|
139
|
+
console.warn('[ghagga:engram] deleteObservation: ID %d not found in local map.', id);
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const deleted = await this.client.deleteObservation(realId);
|
|
143
|
+
if (deleted) {
|
|
144
|
+
this.idMap.delete(id);
|
|
145
|
+
}
|
|
146
|
+
return deleted;
|
|
147
|
+
}
|
|
148
|
+
async getStats() {
|
|
149
|
+
const stats = await this.client.getStats();
|
|
150
|
+
if (!stats) {
|
|
151
|
+
return {
|
|
152
|
+
totalObservations: 0,
|
|
153
|
+
byType: {},
|
|
154
|
+
byProject: {},
|
|
155
|
+
oldestObservation: null,
|
|
156
|
+
newestObservation: null,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
// Map Engram stats to GHAGGA's MemoryStats shape
|
|
160
|
+
const byProject = {};
|
|
161
|
+
if (stats.projects) {
|
|
162
|
+
for (const p of stats.projects) {
|
|
163
|
+
byProject[p] = 0; // Engram doesn't provide per-project counts in stats
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
totalObservations: stats.total_observations,
|
|
168
|
+
byType: {}, // Engram stats endpoint doesn't break down by type
|
|
169
|
+
byProject,
|
|
170
|
+
oldestObservation: null, // Not provided by Engram stats
|
|
171
|
+
newestObservation: null, // Not provided by Engram stats
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Not supported by the Engram HTTP API.
|
|
176
|
+
* Use the `engram` CLI directly for bulk operations.
|
|
177
|
+
*/
|
|
178
|
+
async clearObservations(_options) {
|
|
179
|
+
console.warn('[ghagga:engram] clearObservations is not supported with the Engram backend. ' +
|
|
180
|
+
'Use the "engram" CLI directly for bulk deletion.');
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
// ─── Internal helpers ───────────────────────────────────────────
|
|
184
|
+
/**
|
|
185
|
+
* Track the mapping between a GHAGGA numeric ID and the original Engram ID.
|
|
186
|
+
* This allows getObservation() and deleteObservation() to resolve the real ID.
|
|
187
|
+
*/
|
|
188
|
+
trackId(numericId, engramId) {
|
|
189
|
+
if (!this.idMap.has(numericId)) {
|
|
190
|
+
this.idMap.set(numericId, engramId);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=engram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engram.js","sourceRoot":"","sources":["../../src/memory/engram.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAe;IAE7B;;;;OAIG;IACK,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IAC3C,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAoB,MAAoB;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,mEAAmE;IAEnE;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAA8B;QAChD,MAAM,UAAU,GAAiB;YAC/B,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,uBAAuB;YAC/E,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,GAAG,CAAC,GAAG,IAAI;SACpF,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;QAE3C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CACV,4EAA4E,EAC5E,UAAU,CAAC,IAAI,CAChB,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC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QAC1D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF"}
|
package/dist/memory/persist.d.ts
CHANGED
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
* and saves them as memory observations so future reviews of
|
|
6
6
|
* the same project can benefit from past context.
|
|
7
7
|
*/
|
|
8
|
-
import type { ReviewResult } from '../types.js';
|
|
8
|
+
import type { MemoryStorage, ReviewResult } from '../types.js';
|
|
9
9
|
/**
|
|
10
10
|
* Persist notable review findings as memory observations.
|
|
11
11
|
*
|
|
12
12
|
* Creates a memory session for the review, extracts significant
|
|
13
|
-
* findings, strips private data, and saves them via
|
|
14
|
-
* Gracefully handles
|
|
13
|
+
* findings, strips private data, and saves them via MemoryStorage.
|
|
14
|
+
* Gracefully handles storage errors without propagating them.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param storage - Memory storage backend (SQLite or PostgreSQL)
|
|
17
17
|
* @param project - Project identifier (e.g., "owner/repo")
|
|
18
18
|
* @param prNumber - Pull request number
|
|
19
19
|
* @param result - The completed review result
|
|
20
20
|
*/
|
|
21
|
-
export declare function persistReviewObservations(
|
|
21
|
+
export declare function persistReviewObservations(storage: MemoryStorage, project: string, prNumber: number, result: ReviewResult): Promise<void>;
|
|
22
22
|
//# sourceMappingURL=persist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/memory/persist.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/memory/persist.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAkC,MAAM,aAAa,CAAC;AAoC/F;;;;;;;;;;;GAWG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,CAAC,CA4Df"}
|
package/dist/memory/persist.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* and saves them as memory observations so future reviews of
|
|
6
6
|
* the same project can benefit from past context.
|
|
7
7
|
*/
|
|
8
|
-
import { saveObservation, createMemorySession, endMemorySession } from 'ghagga-db';
|
|
9
8
|
import { stripPrivateData } from './privacy.js';
|
|
10
9
|
// ─── Helpers ────────────────────────────────────────────────────
|
|
11
10
|
/**
|
|
@@ -34,30 +33,31 @@ function findingToObservationType(finding) {
|
|
|
34
33
|
* We only save high and critical findings to avoid noise.
|
|
35
34
|
*/
|
|
36
35
|
function isSignificantFinding(finding) {
|
|
37
|
-
return finding.severity === 'critical' || finding.severity === 'high';
|
|
36
|
+
return finding.severity === 'critical' || finding.severity === 'high' || finding.severity === 'medium';
|
|
38
37
|
}
|
|
39
38
|
// ─── Main Function ──────────────────────────────────────────────
|
|
40
39
|
/**
|
|
41
40
|
* Persist notable review findings as memory observations.
|
|
42
41
|
*
|
|
43
42
|
* Creates a memory session for the review, extracts significant
|
|
44
|
-
* findings, strips private data, and saves them via
|
|
45
|
-
* Gracefully handles
|
|
43
|
+
* findings, strips private data, and saves them via MemoryStorage.
|
|
44
|
+
* Gracefully handles storage errors without propagating them.
|
|
46
45
|
*
|
|
47
|
-
* @param
|
|
46
|
+
* @param storage - Memory storage backend (SQLite or PostgreSQL)
|
|
48
47
|
* @param project - Project identifier (e.g., "owner/repo")
|
|
49
48
|
* @param prNumber - Pull request number
|
|
50
49
|
* @param result - The completed review result
|
|
51
50
|
*/
|
|
52
|
-
export async function persistReviewObservations(
|
|
51
|
+
export async function persistReviewObservations(storage, project, prNumber, result) {
|
|
53
52
|
try {
|
|
54
|
-
if (!
|
|
53
|
+
if (!storage)
|
|
55
54
|
return;
|
|
56
|
-
|
|
57
|
-
// Create a memory session for this review
|
|
58
|
-
const session = await createMemorySession(typedDb, { project, prNumber });
|
|
59
|
-
// Extract significant findings as observations
|
|
55
|
+
// Extract significant findings first — skip session if nothing to persist
|
|
60
56
|
const significantFindings = result.findings.filter(isSignificantFinding);
|
|
57
|
+
if (significantFindings.length === 0)
|
|
58
|
+
return;
|
|
59
|
+
// Create a memory session for this review
|
|
60
|
+
const session = await storage.createSession({ project, prNumber });
|
|
61
61
|
for (const finding of significantFindings) {
|
|
62
62
|
const sanitizedMessage = stripPrivateData(finding.message);
|
|
63
63
|
const sanitizedSuggestion = finding.suggestion
|
|
@@ -71,29 +71,28 @@ export async function persistReviewObservations(db, project, prNumber, result) {
|
|
|
71
71
|
]
|
|
72
72
|
.filter(Boolean)
|
|
73
73
|
.join('\n');
|
|
74
|
-
await saveObservation(
|
|
74
|
+
await storage.saveObservation({
|
|
75
75
|
sessionId: session.id,
|
|
76
76
|
project,
|
|
77
77
|
type: findingToObservationType(finding),
|
|
78
78
|
title: `${finding.category}: ${sanitizedMessage.slice(0, 80)}`,
|
|
79
79
|
content,
|
|
80
80
|
filePaths: [finding.file],
|
|
81
|
+
severity: finding.severity,
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
// Save a summary observation for the overall review
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
}
|
|
85
|
+
await storage.saveObservation({
|
|
86
|
+
sessionId: session.id,
|
|
87
|
+
project,
|
|
88
|
+
type: 'decision',
|
|
89
|
+
title: `PR #${prNumber} review: ${result.status}`,
|
|
90
|
+
content: stripPrivateData(result.summary),
|
|
91
|
+
topicKey: `pr-${prNumber}-review`,
|
|
92
|
+
filePaths: significantFindings.map((f) => f.file),
|
|
93
|
+
});
|
|
95
94
|
// End the session with a summary
|
|
96
|
-
await
|
|
95
|
+
await storage.endSession(session.id, `Review of PR #${prNumber}: ${result.status} with ${significantFindings.length} significant findings.`);
|
|
97
96
|
}
|
|
98
97
|
catch (error) {
|
|
99
98
|
// Memory persistence is optional — never let it break the pipeline
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist.js","sourceRoot":"","sources":["../../src/memory/persist.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"persist.js","sourceRoot":"","sources":["../../src/memory/persist.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,mEAAmE;AAEnE;;;GAGG;AACH,SAAS,wBAAwB,CAAC,OAAsB;IACtD,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,UAAU;YACb,OAAO,WAAW,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,QAAQ,CAAC;QAClB,KAAK,aAAa;YAChB,OAAO,SAAS,CAAC;QACnB,KAAK,OAAO,CAAC;QACb,KAAK,iBAAiB;YACpB,OAAO,SAAS,CAAC;QACnB,KAAK,gBAAgB;YACnB,OAAO,UAAU,CAAC;QACpB;YACE,OAAO,UAAU,CAAC;IACtB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,oBAAoB,CAAC,OAAsB;IAClD,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACzG,CAAC;AAED,mEAAmE;AAEnE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAAsB,EACtB,OAAe,EACf,QAAgB,EAChB,MAAoB;IAEpB,IAAI,CAAC;QACH,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,0EAA0E;QAC1E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BACzB,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B,CAAC,CAAC;QACL,CAAC;QAED,oDAAoD;QACpD,MAAM,OAAO,CAAC,eAAe,CAAC;YAC5B,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,OAAO;YACP,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,OAAO,QAAQ,YAAY,MAAM,CAAC,MAAM,EAAE;YACjD,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC;YACzC,QAAQ,EAAE,MAAM,QAAQ,SAAS;YACjC,SAAS,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAClD,CAAC,CAAC;QAEH,iCAAiC;QACjC,MAAM,OAAO,CAAC,UAAU,CACtB,OAAO,CAAC,EAAE,EACV,iBAAiB,QAAQ,KAAK,MAAM,CAAC,MAAM,SAAS,mBAAmB,CAAC,MAAM,wBAAwB,CACvG,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mEAAmE;QACnE,OAAO,CAAC,IAAI,CACV,6DAA6D,EAC7D,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/memory/search.d.ts
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
* Memory search — retrieves relevant past observations for prompt injection.
|
|
3
3
|
*
|
|
4
4
|
* Builds a search query from the file paths in the current diff,
|
|
5
|
-
* then uses
|
|
6
|
-
*
|
|
5
|
+
* then uses the MemoryStorage interface to find observations from
|
|
6
|
+
* past reviews of the same project.
|
|
7
7
|
*/
|
|
8
|
+
import type { MemoryStorage } from '../types.js';
|
|
8
9
|
/**
|
|
9
10
|
* Search past review observations for context relevant to the current diff.
|
|
10
11
|
*
|
|
11
12
|
* Returns a formatted string suitable for injection into agent prompts,
|
|
12
|
-
* or null if no relevant observations are found (or if
|
|
13
|
+
* or null if no relevant observations are found (or if storage is unavailable).
|
|
13
14
|
*
|
|
14
|
-
* @param
|
|
15
|
+
* @param storage - Memory storage backend (SQLite or PostgreSQL)
|
|
15
16
|
* @param project - Project identifier (e.g., "owner/repo")
|
|
16
17
|
* @param fileList - List of file paths in the current diff
|
|
17
18
|
* @returns Formatted memory context string, or null
|
|
18
19
|
*/
|
|
19
|
-
export declare function searchMemoryForContext(
|
|
20
|
+
export declare function searchMemoryForContext(storage: MemoryStorage, project: string, fileList: string[]): Promise<string | null>;
|
|
20
21
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/memory/search.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/memory/search.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwCjD;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgCxB"}
|
package/dist/memory/search.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Memory search — retrieves relevant past observations for prompt injection.
|
|
3
3
|
*
|
|
4
4
|
* Builds a search query from the file paths in the current diff,
|
|
5
|
-
* then uses
|
|
6
|
-
*
|
|
5
|
+
* then uses the MemoryStorage interface to find observations from
|
|
6
|
+
* past reviews of the same project.
|
|
7
7
|
*/
|
|
8
|
-
import { searchObservations } from 'ghagga-db';
|
|
9
8
|
import { formatMemoryContext } from './context.js';
|
|
10
9
|
// ─── Helpers ────────────────────────────────────────────────────
|
|
11
10
|
/**
|
|
@@ -42,22 +41,22 @@ function buildSearchQuery(fileList) {
|
|
|
42
41
|
* Search past review observations for context relevant to the current diff.
|
|
43
42
|
*
|
|
44
43
|
* Returns a formatted string suitable for injection into agent prompts,
|
|
45
|
-
* or null if no relevant observations are found (or if
|
|
44
|
+
* or null if no relevant observations are found (or if storage is unavailable).
|
|
46
45
|
*
|
|
47
|
-
* @param
|
|
46
|
+
* @param storage - Memory storage backend (SQLite or PostgreSQL)
|
|
48
47
|
* @param project - Project identifier (e.g., "owner/repo")
|
|
49
48
|
* @param fileList - List of file paths in the current diff
|
|
50
49
|
* @returns Formatted memory context string, or null
|
|
51
50
|
*/
|
|
52
|
-
export async function searchMemoryForContext(
|
|
51
|
+
export async function searchMemoryForContext(storage, project, fileList) {
|
|
53
52
|
try {
|
|
54
|
-
if (!
|
|
53
|
+
if (!storage)
|
|
55
54
|
return null;
|
|
56
55
|
const query = buildSearchQuery(fileList);
|
|
57
56
|
if (!query)
|
|
58
57
|
return null;
|
|
59
58
|
// Search with a reasonable limit — we don't want to flood the prompt
|
|
60
|
-
const observations = await searchObservations(
|
|
59
|
+
const observations = await storage.searchObservations(project, query, { limit: 3 });
|
|
61
60
|
if (!observations || observations.length === 0)
|
|
62
61
|
return null;
|
|
63
62
|
// Format observations for prompt injection
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/memory/search.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/memory/search.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,mEAAmE;AAEnE;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CAAC,QAAkB;IAC1C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,QAAQ,IAAI,QA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2CAA2C;QAC3C,OAAO,mBAAmB,CACxB,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACzB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,OAAO,EAAE,GAAG,CAAC,OAAO;SACrB,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,8DAA8D;QAC9D,OAAO,CAAC,IAAI,CACV,uDAAuD,EACvD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite-backed memory storage using sql.js (pure WASM).
|
|
3
|
+
*
|
|
4
|
+
* Thread safety: This class is NOT thread-safe. It operates as an in-memory
|
|
5
|
+
* database with manual file persistence via close(). Designed for single-process
|
|
6
|
+
* environments (CLI, GitHub Action).
|
|
7
|
+
*/
|
|
8
|
+
import type { MemoryStorage, MemoryObservationRow, MemoryObservationDetail, MemoryStats, ListObservationsOptions } from '../types.js';
|
|
9
|
+
export declare class SqliteMemoryStorage implements MemoryStorage {
|
|
10
|
+
private db;
|
|
11
|
+
private filePath;
|
|
12
|
+
private constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Async factory — handles WASM initialization and file loading.
|
|
15
|
+
* If filePath exists, loads the existing DB. Otherwise, creates a fresh one.
|
|
16
|
+
*/
|
|
17
|
+
static create(filePath: string): Promise<SqliteMemoryStorage>;
|
|
18
|
+
searchObservations(project: string, query: string, options?: {
|
|
19
|
+
limit?: number;
|
|
20
|
+
type?: string;
|
|
21
|
+
}): Promise<MemoryObservationRow[]>;
|
|
22
|
+
saveObservation(data: {
|
|
23
|
+
sessionId?: number;
|
|
24
|
+
project: string;
|
|
25
|
+
type: string;
|
|
26
|
+
title: string;
|
|
27
|
+
content: string;
|
|
28
|
+
topicKey?: string;
|
|
29
|
+
filePaths?: string[];
|
|
30
|
+
severity?: string;
|
|
31
|
+
}): Promise<MemoryObservationRow>;
|
|
32
|
+
createSession(data: {
|
|
33
|
+
project: string;
|
|
34
|
+
prNumber?: number;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
id: number;
|
|
37
|
+
}>;
|
|
38
|
+
endSession(sessionId: number, summary: string): Promise<void>;
|
|
39
|
+
private mapToDetail;
|
|
40
|
+
listObservations(options?: ListObservationsOptions): Promise<MemoryObservationDetail[]>;
|
|
41
|
+
getObservation(id: number): Promise<MemoryObservationDetail | null>;
|
|
42
|
+
deleteObservation(id: number): Promise<boolean>;
|
|
43
|
+
getStats(): Promise<MemoryStats>;
|
|
44
|
+
clearObservations(options?: {
|
|
45
|
+
project?: string;
|
|
46
|
+
}): Promise<number>;
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=sqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/memory/sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AA+DtI,qBAAa,mBAAoB,YAAW,aAAa;IAErD,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,QAAQ;IAFlB,OAAO;IAKP;;;OAGG;WACU,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuB7D,kBAAkB,CACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;K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