getprismo 0.1.62 → 0.1.64
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 +2 -2
- package/lib/prismo-dev/agent.js +31 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/getprismo)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Token observability and verification for AI coding agents.
|
|
8
8
|
|
|
9
|
-
Prismo
|
|
9
|
+
Prismo reads your local Codex, Claude Code, and Cursor sessions to show where tokens are wasted, by cause, repo, and session, then verifies whether any fix actually reduced usage in later sessions instead of trusting a benchmark. Compression, routing, and context tools are fixes; Prismo is the measurement and verification layer above them. Runs locally, so no code, prompts, or output leave your machine.
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npx getprismo protect
|
package/lib/prismo-dev/agent.js
CHANGED
|
@@ -135,6 +135,33 @@ module.exports = function createAgent(deps) {
|
|
|
135
135
|
return path.join(path.resolve(rootDir || process.cwd()), ".prismo", "enforce-state.json");
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
function policySnapshotPath(rootDir) {
|
|
139
|
+
return path.join(path.resolve(rootDir || process.cwd()), ".prismo", "control-policies.json");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function syncControlPolicies(config, rootDir, options = {}) {
|
|
143
|
+
const endpoint = options.policiesEndpoint || `${apiBase(config)}/v1/dev/workspace/policies/agent`;
|
|
144
|
+
try {
|
|
145
|
+
const response = await requestJson("GET", endpoint, config.token, null, options.timeoutMs || 8000);
|
|
146
|
+
const policies = Array.isArray(response.data?.policies) ? response.data.policies : [];
|
|
147
|
+
const outputPath = policySnapshotPath(rootDir);
|
|
148
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
149
|
+
fs.writeFileSync(outputPath, `${JSON.stringify({
|
|
150
|
+
schemaVersion: 1,
|
|
151
|
+
syncedAt: new Date().toISOString(),
|
|
152
|
+
source: endpoint,
|
|
153
|
+
plan: response.data?.plan || "free",
|
|
154
|
+
policies,
|
|
155
|
+
}, null, 2)}\n`, "utf8");
|
|
156
|
+
return { synced: true, policies: policies.length, path: path.relative(rootDir, outputPath) };
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return {
|
|
159
|
+
synced: false,
|
|
160
|
+
error: error && error.message ? error.message : String(error),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
138
165
|
function summarizeCommand(command) {
|
|
139
166
|
const value = String(command || "").replace(/\s+/g, " ").trim();
|
|
140
167
|
if (!value) return "a repeated command";
|
|
@@ -580,7 +607,9 @@ module.exports = function createAgent(deps) {
|
|
|
580
607
|
// feed and loop/context publishing only need the slower sync cadence, so
|
|
581
608
|
// gate them on syncTelemetry to avoid a burst of small writes every poll.
|
|
582
609
|
const publishLive = options.syncTelemetry !== false;
|
|
610
|
+
let policySync = null;
|
|
583
611
|
if (publishLive) {
|
|
612
|
+
policySync = await syncControlPolicies(config, rootDir, options);
|
|
584
613
|
await sendLiveEvent(config, {
|
|
585
614
|
eventId: `heartbeat-${repo.pathBasename}-${pollTime.slice(0, 16)}`,
|
|
586
615
|
phase: "watching",
|
|
@@ -818,6 +847,7 @@ module.exports = function createAgent(deps) {
|
|
|
818
847
|
autoDetect: autoDetectResult,
|
|
819
848
|
planner: plannerResult,
|
|
820
849
|
sync: syncResult,
|
|
850
|
+
policies: policySync,
|
|
821
851
|
results,
|
|
822
852
|
privacy: {
|
|
823
853
|
rawPrompts: false,
|
|
@@ -988,6 +1018,7 @@ module.exports = function createAgent(deps) {
|
|
|
988
1018
|
runAutoDetect,
|
|
989
1019
|
sendHeartbeat,
|
|
990
1020
|
sendLiveEvent,
|
|
1021
|
+
syncControlPolicies,
|
|
991
1022
|
updateAction,
|
|
992
1023
|
VALID_MODES,
|
|
993
1024
|
};
|
package/package.json
CHANGED