thumbgate 1.25.2 → 1.26.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/README.md +62 -31
- package/adapters/claude/.mcp.json +2 -2
- package/adapters/mcp/server-stdio.js +84 -7
- package/adapters/opencode/opencode.json +1 -1
- package/bin/cli.js +390 -14
- package/config/mcp-allowlists.json +3 -0
- package/package.json +16 -3
- package/public/agents-cost-savings.html +2 -0
- package/public/index.html +10 -2
- package/public/numbers.html +2 -2
- package/scripts/action-receipts.js +324 -0
- package/scripts/cli-schema.js +24 -0
- package/scripts/context-manager.js +10 -0
- package/scripts/dashboard.js +6 -1
- package/scripts/gates-engine.js +68 -9
- package/scripts/install-shim.js +84 -0
- package/scripts/llm-client.js +90 -4
- package/scripts/local-model-profile.js +15 -8
- package/scripts/meta-agent-loop.js +9 -5
- package/scripts/noop-detect.js +285 -0
- package/scripts/operational-dashboard.js +160 -0
- package/scripts/plan-gate.js +243 -0
- package/scripts/repeat-metric.js +121 -0
- package/scripts/silent-failure-cluster.js +22 -3
- package/scripts/thompson-sampling.js +20 -5
- package/scripts/tool-registry.js +50 -0
- package/scripts/trajectory-scorer.js +63 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Trajectory Scorer — Strategic Drift Detection.
|
|
6
|
+
*
|
|
7
|
+
* Measures the "Semantic Distance" between the original user intent
|
|
8
|
+
* (from primer.md) and the current set of changed files.
|
|
9
|
+
*
|
|
10
|
+
* If the agent modifies too many unrelated files, it triggers a safety block.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const { execSync } = require('child_process');
|
|
16
|
+
|
|
17
|
+
function getTrajectoryScore(options = {}) {
|
|
18
|
+
const projectRoot = options.projectRoot || process.cwd();
|
|
19
|
+
const primerPath = path.join(projectRoot, 'primer.md');
|
|
20
|
+
|
|
21
|
+
if (!fs.existsSync(primerPath)) return { score: 0, isDrifting: false, drift: false };
|
|
22
|
+
|
|
23
|
+
const intent = fs.readFileSync(primerPath, 'utf8').toLowerCase();
|
|
24
|
+
|
|
25
|
+
// Get currently modified files (unstaged + staged)
|
|
26
|
+
let changedFiles = options.changedFiles;
|
|
27
|
+
if (!changedFiles) {
|
|
28
|
+
try {
|
|
29
|
+
const output = execSync('git diff --name-only HEAD', { cwd: projectRoot, encoding: 'utf8' });
|
|
30
|
+
changedFiles = output.split('\n').filter(f => f.trim());
|
|
31
|
+
} catch {
|
|
32
|
+
return { score: 0, isDrifting: false, drift: false };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (changedFiles.length === 0) return { score: 0, isDrifting: false, drift: false };
|
|
37
|
+
|
|
38
|
+
// Calculate drift: How many changed files are NOT mentioned in the intent?
|
|
39
|
+
let driftCount = 0;
|
|
40
|
+
for (const file of changedFiles) {
|
|
41
|
+
const base = path.basename(file).toLowerCase();
|
|
42
|
+
if (!intent.includes(base)) {
|
|
43
|
+
driftCount++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const driftRatio = driftCount / changedFiles.length;
|
|
48
|
+
const isDrifting = driftRatio > 0.6 && changedFiles.length > 3;
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
score: Number((1 - driftRatio).toFixed(2)),
|
|
52
|
+
changedCount: changedFiles.length,
|
|
53
|
+
driftCount,
|
|
54
|
+
isDrifting,
|
|
55
|
+
message: isDrifting
|
|
56
|
+
? `🚫 THUMBGATE: Strategic Drift Detected. You have modified ${changedFiles.length} files, but ${driftCount} of them were not mentioned in the original intent. Please refocus or update the intent.`
|
|
57
|
+
: null
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
getTrajectoryScore
|
|
63
|
+
};
|