@rigour-labs/core 5.3.3 → 5.5.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/dist/context/cache-engine.d.ts +25 -0
- package/dist/context/cache-engine.js +79 -1
- package/dist/context/cache-engine.test.js +37 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/services/context-telemetry-service.d.ts +13 -3
- package/dist/services/context-telemetry-service.js +100 -34
- package/dist/services/context-telemetry-service.test.js +39 -0
- package/dist/services/cursor-usage-client.d.ts +19 -0
- package/dist/services/cursor-usage-client.js +73 -0
- package/dist/services/cursor-usage-normalizer.d.ts +24 -0
- package/dist/services/cursor-usage-normalizer.js +102 -0
- package/dist/services/cursor-usage-sync.test.d.ts +1 -0
- package/dist/services/cursor-usage-sync.test.js +173 -0
- package/dist/services/model-pricing.d.ts +36 -0
- package/dist/services/model-pricing.js +137 -0
- package/dist/services/model-pricing.test.d.ts +1 -0
- package/dist/services/model-pricing.test.js +44 -0
- package/dist/settings.d.ts +15 -2
- package/dist/settings.js +56 -6
- package/dist/storage/context-telemetry.d.ts +9 -0
- package/dist/storage/context-telemetry.js +61 -0
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +1 -1
- package/package.json +6 -6
|
@@ -112,6 +112,67 @@ export async function setContextCacheRecord(record, cwd) {
|
|
|
112
112
|
cacheData[record.cacheKey] = { ...record, createdAt: timestamp };
|
|
113
113
|
await fs.writeJson(fallbackPath, cacheData, { spaces: 2 });
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* List cache records by type (and optional commit). Does not increment hit counts.
|
|
117
|
+
*/
|
|
118
|
+
export async function listContextCacheRecords(opts, cwd) {
|
|
119
|
+
const limit = opts.limit ?? 50;
|
|
120
|
+
if (isSQLiteAvailable()) {
|
|
121
|
+
try {
|
|
122
|
+
const db = await openDatabase();
|
|
123
|
+
if (db) {
|
|
124
|
+
const clauses = [];
|
|
125
|
+
const params = [];
|
|
126
|
+
if (opts.cacheType) {
|
|
127
|
+
clauses.push('cache_type = ?');
|
|
128
|
+
params.push(opts.cacheType);
|
|
129
|
+
}
|
|
130
|
+
if (opts.commitSha) {
|
|
131
|
+
clauses.push('commit_sha = ?');
|
|
132
|
+
params.push(opts.commitSha);
|
|
133
|
+
}
|
|
134
|
+
const where = clauses.length ? `WHERE ${clauses.join(' AND ')}` : '';
|
|
135
|
+
const rows = await db.all(`SELECT * FROM context_cache ${where} ORDER BY COALESCE(last_hit_at, created_at) DESC LIMIT ?`, ...params, limit);
|
|
136
|
+
await db.close();
|
|
137
|
+
return (rows || []).map((row) => ({
|
|
138
|
+
cacheKey: row.cache_key,
|
|
139
|
+
cacheType: row.cache_type,
|
|
140
|
+
repo: row.repo,
|
|
141
|
+
branch: row.branch,
|
|
142
|
+
commitSha: row.commit_sha,
|
|
143
|
+
dependencyFingerprint: row.dependency_fingerprint,
|
|
144
|
+
payloadJson: row.payload_json,
|
|
145
|
+
payloadTokens: row.payload_tokens,
|
|
146
|
+
hitCount: row.hit_count || 0,
|
|
147
|
+
createdAt: row.created_at,
|
|
148
|
+
lastHitAt: row.last_hit_at,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// fallback
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const fallbackPath = path.join(getFallbackDir(cwd), 'context-cache.json');
|
|
157
|
+
if (!(await fs.pathExists(fallbackPath)))
|
|
158
|
+
return [];
|
|
159
|
+
try {
|
|
160
|
+
const cacheData = await fs.readJson(fallbackPath);
|
|
161
|
+
return Object.values(cacheData)
|
|
162
|
+
.filter((entry) => {
|
|
163
|
+
if (opts.cacheType && entry.cacheType !== opts.cacheType)
|
|
164
|
+
return false;
|
|
165
|
+
if (opts.commitSha && entry.commitSha !== opts.commitSha)
|
|
166
|
+
return false;
|
|
167
|
+
return true;
|
|
168
|
+
})
|
|
169
|
+
.sort((a, b) => (b.lastHitAt || b.createdAt || 0) - (a.lastHitAt || a.createdAt || 0))
|
|
170
|
+
.slice(0, limit);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
115
176
|
/**
|
|
116
177
|
* Fetch cached context record by cache key. Increments hit count.
|
|
117
178
|
*/
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export { insertFindings, getFindingsForScan, getDeepFindings } from './findings.
|
|
|
9
9
|
export { reinforcePattern, decayPatterns, getStrongPatterns, getPatterns, getHardRules } from './patterns.js';
|
|
10
10
|
export { checkLocalPatterns, persistAndReinforce, getProjectStats } from './local-memory.js';
|
|
11
11
|
export type { ProjectStats } from './local-memory.js';
|
|
12
|
-
export { recordContextEvent, recordModelUsage, setContextCacheRecord, getContextCacheRecord, recordCheckpointMetric, getContextEvents, getModelUsages, getCheckpointMetrics } from './context-telemetry.js';
|
|
12
|
+
export { recordContextEvent, recordModelUsage, setContextCacheRecord, getContextCacheRecord, listContextCacheRecords, recordCheckpointMetric, getContextEvents, getModelUsages, getCheckpointMetrics } from './context-telemetry.js';
|
|
13
13
|
export type { ContextEvent, ModelUsage, ContextCacheRecord, CheckpointMetric } from './context-telemetry.js';
|
package/dist/storage/index.js
CHANGED
|
@@ -7,4 +7,4 @@ export { insertScan, getRecentScans, getScoreTrendFromDB, getTopIssues } from '.
|
|
|
7
7
|
export { insertFindings, getFindingsForScan, getDeepFindings } from './findings.js';
|
|
8
8
|
export { reinforcePattern, decayPatterns, getStrongPatterns, getPatterns, getHardRules } from './patterns.js';
|
|
9
9
|
export { checkLocalPatterns, persistAndReinforce, getProjectStats } from './local-memory.js';
|
|
10
|
-
export { recordContextEvent, recordModelUsage, setContextCacheRecord, getContextCacheRecord, recordCheckpointMetric, getContextEvents, getModelUsages, getCheckpointMetrics } from './context-telemetry.js';
|
|
10
|
+
export { recordContextEvent, recordModelUsage, setContextCacheRecord, getContextCacheRecord, listContextCacheRecords, recordCheckpointMetric, getContextEvents, getModelUsages, getCheckpointMetrics } from './context-telemetry.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rigour-labs/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "AI-native quality gate engine with local Bayesian learning. AST analysis, drift detection, Fix Packet generation, and agent self-healing across TypeScript, JavaScript, Python, Go, Ruby, and C#.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://rigour.run",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"@xenova/transformers": "^2.17.2",
|
|
67
67
|
"sqlite3": "^5.1.7",
|
|
68
68
|
"openai": "^4.104.0",
|
|
69
|
-
"@rigour-labs/brain-darwin-arm64": "5.
|
|
70
|
-
"@rigour-labs/brain-
|
|
71
|
-
"@rigour-labs/brain-linux-
|
|
72
|
-
"@rigour-labs/brain-win-x64": "5.
|
|
73
|
-
"@rigour-labs/brain-
|
|
69
|
+
"@rigour-labs/brain-darwin-arm64": "5.5.0",
|
|
70
|
+
"@rigour-labs/brain-darwin-x64": "5.5.0",
|
|
71
|
+
"@rigour-labs/brain-linux-x64": "5.5.0",
|
|
72
|
+
"@rigour-labs/brain-win-x64": "5.5.0",
|
|
73
|
+
"@rigour-labs/brain-linux-arm64": "5.5.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/fs-extra": "^11.0.4",
|