getprismo 0.1.30 → 0.1.31

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 CHANGED
@@ -719,7 +719,7 @@ no install needed. npx runs it directly.
719
719
  | `receipt` | run receipt for reads, repeats, output, artifacts, likely influence, and next-run scope |
720
720
  | `replay` | incident replay with root cause and recovery prompt |
721
721
  | `timeline` | recurring context-waste patterns across recent sessions |
722
- | `instructions audit` | instruction ROI audit for CLAUDE.md / AGENTS.md dead-weight rules |
722
+ | `instructions audit` | instruction ROI audit for CLAUDE.md / AGENTS.md violations, partial compliance, duplicates, and influence-unknown rules |
723
723
  | `boundaries` | multi-agent boundary check for shared files/artifacts and worktree overlap |
724
724
  | `scan --usage` | full repo scan with local usage data |
725
725
  | `scan --optimizer-fit` | recommend which token-optimization path fits your repo/session |
@@ -83,9 +83,11 @@ module.exports = function createInstructionsAudit(deps) {
83
83
  let generatedArtifactMentions = 0;
84
84
  let repeatedReadMentions = 0;
85
85
  let repeatedCommandMentions = 0;
86
+ let failureMentions = 0;
86
87
  let loopSessions = 0;
87
88
  for (const session of sessions) {
88
89
  toolOutputTokens += Number(session.estimatedToolTokens || 0);
90
+ failureMentions += Number(session.failureMentions || 0);
89
91
  if (session.loopSuspicion) loopSessions += 1;
90
92
  for (const item of session.repeatedPathMentions || []) {
91
93
  evidenceText.push(item.value);
@@ -107,10 +109,55 @@ module.exports = function createInstructionsAudit(deps) {
107
109
  generatedArtifactMentions,
108
110
  repeatedReadMentions,
109
111
  repeatedCommandMentions,
112
+ failureMentions,
110
113
  loopSessions,
111
114
  };
112
115
  }
113
116
 
117
+ function normalizeEvidenceTerm(value) {
118
+ return normalizeRule(String(value || "").replace(/['"`]/g, ""));
119
+ }
120
+
121
+ function extractRuleTerms(ruleText) {
122
+ const source = String(ruleText || "");
123
+ const terms = [];
124
+ const pathPattern = /(?:[\w.@-]+\/)+[\w.@+-]+\.[A-Za-z0-9]{1,12}|[\w.@+-]+\.[A-Za-z0-9]{1,12}/g;
125
+ for (const match of source.matchAll(pathPattern)) terms.push(match[0]);
126
+
127
+ const beforeEditMatch = source.match(/\b(?:edit|editing|change|changing|modify|modifying|touch|touching)\s+([A-Za-z0-9_./@-]+(?:\s+[A-Za-z0-9_./@-]+){0,2})/i);
128
+ if (beforeEditMatch) terms.push(beforeEditMatch[1]);
129
+
130
+ return Array.from(new Set(terms.map(normalizeEvidenceTerm).filter((term) => term.length >= 3)));
131
+ }
132
+
133
+ function getRitualComplianceSignal(rule, evidence) {
134
+ const text = rule.normalized;
135
+ const asksReadBeforeEdit =
136
+ /\b(?:always|must|first|before|prior to)\b/.test(text) &&
137
+ /\b(?:read|review|check|inspect|open)\b/.test(text) &&
138
+ /\b(?:before|prior to)\b/.test(text) &&
139
+ /\b(?:edit|editing|change|changing|modify|modifying|touch|touching)\b/.test(text);
140
+ if (!asksReadBeforeEdit) return null;
141
+
142
+ const terms = extractRuleTerms(rule.text);
143
+ if (terms.length < 2) return null;
144
+
145
+ const matchedTerms = terms.filter((term) => evidence.text.includes(term));
146
+ const enoughRitualEvidence = matchedTerms.length >= 2;
147
+ const outcomeStillNoisy =
148
+ evidence.failureMentions > 0 ||
149
+ evidence.repeatedCommandMentions >= 3 ||
150
+ evidence.toolOutputTokens >= 25000 ||
151
+ evidence.loopSessions > 0;
152
+
153
+ if (!enoughRitualEvidence || !outcomeStillNoisy) return null;
154
+ return {
155
+ terms,
156
+ matchedTerms,
157
+ reason: "read-before-edit ritual appeared in session evidence, but noisy/failing session evidence suggests it may not have constrained the final work",
158
+ };
159
+ }
160
+
114
161
  function classifyRule(rule, evidence, duplicateCount) {
115
162
  const text = rule.normalized;
116
163
  const evidenceHits = rule.keywords.filter((keyword) => evidence.text.includes(keyword));
@@ -132,15 +179,24 @@ module.exports = function createInstructionsAudit(deps) {
132
179
 
133
180
  if (evidenceHits.length) signals.push("session-correlated");
134
181
  if (asksNoArtifacts || asksNoOutputFlood || asksNarrowReads) signals.push("guardrail");
182
+ const ritualCompliance = getRitualComplianceSignal(rule, evidence);
183
+ if (ritualCompliance) {
184
+ concerns.push("paraphrased-not-applied");
185
+ signals.push("ritual-compliance");
186
+ }
135
187
 
136
188
  let status = "unclear";
137
189
  let recommendation = "Keep for now, but review after more sessions.";
138
190
  let score = 35;
139
191
 
140
192
  if (concerns.includes("violated-by-session-evidence")) {
141
- status = "ignored-or-ineffective";
193
+ status = "observably-violated";
142
194
  score = 15;
143
- recommendation = `Move this rule into a live guardrail/firewall or make it more specific; session evidence suggests it is not changing behavior.`;
195
+ recommendation = `Keep the intent, but move it into a live guardrail/firewall or make it more enforceable; session evidence shows a measurable violation.`;
196
+ } else if (concerns.includes("paraphrased-not-applied")) {
197
+ status = "partial-compliance";
198
+ score = 40;
199
+ recommendation = "Rewrite this as an observable acceptance check; the session appears to perform the read/check ritual but still shows failure or noisy follow-through.";
144
200
  } else if (signals.includes("session-correlated") && signals.includes("directive")) {
145
201
  status = "pulling-weight";
146
202
  score = 80;
@@ -154,9 +210,9 @@ module.exports = function createInstructionsAudit(deps) {
154
210
  score = 25;
155
211
  recommendation = "Deduplicate this rule so it is paid for once, not in every instruction file.";
156
212
  } else if (concerns.includes("low-signal")) {
157
- status = "dead-weight-candidate";
158
- score = 20;
159
- recommendation = "Rewrite with observable behavior or remove if it is generic preference text.";
213
+ status = "influence-unknown";
214
+ score = 45;
215
+ recommendation = "Do not prune automatically. This rule has no grep-able behavioral signal; use A/B ablation or rewrite it into observable instructions.";
160
216
  } else if (rule.tokens > 80) {
161
217
  status = "trim-candidate";
162
218
  score = 30;
@@ -170,6 +226,7 @@ module.exports = function createInstructionsAudit(deps) {
170
226
  signals,
171
227
  concerns,
172
228
  evidenceHits,
229
+ partialCompliance: ritualCompliance || null,
173
230
  recommendation,
174
231
  };
175
232
  }
@@ -189,10 +246,13 @@ module.exports = function createInstructionsAudit(deps) {
189
246
 
190
247
  const byStatus = {};
191
248
  for (const rule of auditedRules) byStatus[rule.status] = (byStatus[rule.status] || 0) + 1;
192
- const deadWeight = auditedRules.filter((rule) => ["dead-weight-candidate", "ignored-or-ineffective", "duplicate", "trim-candidate"].includes(rule.status));
249
+ const prunable = auditedRules.filter((rule) => ["observably-violated", "duplicate", "trim-candidate"].includes(rule.status));
250
+ const partialCompliance = auditedRules.filter((rule) => rule.status === "partial-compliance");
251
+ const influenceUnknown = auditedRules.filter((rule) => rule.status === "influence-unknown");
193
252
  const pullingWeight = auditedRules.filter((rule) => rule.status === "pulling-weight" || rule.status === "guardrail-no-recent-violation");
194
253
  const duplicatedRules = auditedRules.filter((rule) => (duplicates.get(rule.normalized) || 0) > 1);
195
- const wastedTokensPerLoad = deadWeight.reduce((sum, rule) => sum + Number(rule.tokens || 0), 0);
254
+ const prunableTokensPerLoad = prunable.reduce((sum, rule) => sum + Number(rule.tokens || 0), 0);
255
+ const sortedPrunable = prunable.sort((a, b) => a.score - b.score || b.tokens - a.tokens);
196
256
 
197
257
  return {
198
258
  schemaVersion: 1,
@@ -208,20 +268,30 @@ module.exports = function createInstructionsAudit(deps) {
208
268
  generatedArtifactMentions: evidence.generatedArtifactMentions,
209
269
  repeatedReadMentions: evidence.repeatedReadMentions,
210
270
  repeatedCommandMentions: evidence.repeatedCommandMentions,
271
+ failureMentions: evidence.failureMentions,
211
272
  loopSessions: evidence.loopSessions,
212
273
  },
213
274
  summary: {
214
275
  totalRules: auditedRules.length,
215
276
  byStatus,
216
- deadWeightCandidates: deadWeight.length,
277
+ prunableCandidates: prunable.length,
278
+ partialCompliance: partialCompliance.length,
279
+ influenceUnknown: influenceUnknown.length,
217
280
  duplicatedRules: duplicatedRules.length,
218
- wastedTokensPerLoad,
281
+ prunableTokensPerLoad,
282
+ deadWeightCandidates: prunable.length,
283
+ wastedTokensPerLoad: prunableTokensPerLoad,
219
284
  },
220
285
  pullingWeight: pullingWeight.sort((a, b) => b.score - a.score).slice(0, 10),
221
- deadWeight: deadWeight.sort((a, b) => a.score - b.score || b.tokens - a.tokens).slice(0, 20),
286
+ prunable: sortedPrunable.slice(0, 20),
287
+ partialCompliance: partialCompliance.sort((a, b) => a.score - b.score || b.tokens - a.tokens).slice(0, 20),
288
+ influenceUnknown: influenceUnknown.sort((a, b) => b.tokens - a.tokens).slice(0, 20),
289
+ deadWeight: sortedPrunable.slice(0, 20),
222
290
  rules: auditedRules,
223
291
  next: [
224
- deadWeight.length ? "Trim or rewrite dead-weight candidates first." : "No obvious dead-weight rules detected yet.",
292
+ prunable.length ? "Fix observably violated, duplicate, or trim-safe rules first." : "No safely prunable rules detected yet.",
293
+ partialCompliance.length ? "Rewrite partial-compliance rules as observable acceptance checks." : null,
294
+ influenceUnknown.length ? "Treat influence-unknown rules as A/B ablation candidates, not safe deletes." : null,
225
295
  duplicatedRules.length ? "Deduplicate repeated rules across CLAUDE.md / AGENTS.md / Codex instruction files." : null,
226
296
  evidence.sessions.length < 5 ? "Run this again after more sessions; multi-session evidence makes instruction ROI stronger." : null,
227
297
  `${NPX_COMMAND} firewall <task> for rules that only matter in one workflow.`,
@@ -242,7 +312,9 @@ module.exports = function createInstructionsAudit(deps) {
242
312
  lines.push(`Files: ${audit.files.map((file) => `${file.path} (${formatTokenCount(file.tokens)} tokens)`).join(", ")}`);
243
313
  lines.push(`Rules: ${audit.summary.totalRules}`);
244
314
  lines.push(`Sessions analyzed: ${audit.sessionsAnalyzed}`);
245
- lines.push(`Dead-weight candidates: ${audit.summary.deadWeightCandidates} (~${formatTokenCount(audit.summary.wastedTokensPerLoad)} tokens/load)`);
315
+ lines.push(`Safely prunable candidates: ${audit.summary.prunableCandidates} (~${formatTokenCount(audit.summary.prunableTokensPerLoad)} tokens/load)`);
316
+ lines.push(`Partial compliance: ${audit.summary.partialCompliance}`);
317
+ lines.push(`Influence unknown: ${audit.summary.influenceUnknown}`);
246
318
  lines.push(`Duplicates: ${audit.summary.duplicatedRules}`);
247
319
  lines.push("");
248
320
  lines.push("Pulling Weight");
@@ -254,9 +326,9 @@ module.exports = function createInstructionsAudit(deps) {
254
326
  lines.push("- No high-confidence useful rules detected yet.");
255
327
  }
256
328
  lines.push("");
257
- lines.push("Dead Weight / Rewrite Candidates");
258
- if (audit.deadWeight.length) {
259
- audit.deadWeight.slice(0, 8).forEach((rule) => {
329
+ lines.push("Safely Prunable / Rewrite Candidates");
330
+ if (audit.prunable.length) {
331
+ audit.prunable.slice(0, 8).forEach((rule) => {
260
332
  lines.push(`- ${rule.file}:${rule.line} [${rule.status}] ${rule.text}`);
261
333
  lines.push(` ${rule.recommendation}`);
262
334
  });
@@ -264,6 +336,29 @@ module.exports = function createInstructionsAudit(deps) {
264
336
  lines.push("- No obvious candidates.");
265
337
  }
266
338
  lines.push("");
339
+ lines.push("Partial Compliance / Ritual Without Proof");
340
+ if (audit.partialCompliance.length) {
341
+ audit.partialCompliance.slice(0, 6).forEach((rule) => {
342
+ lines.push(`- ${rule.file}:${rule.line} [${rule.status}] ${rule.text}`);
343
+ if (rule.partialCompliance?.matchedTerms?.length) {
344
+ lines.push(` Matched: ${rule.partialCompliance.matchedTerms.join(", ")}`);
345
+ }
346
+ lines.push(` ${rule.recommendation}`);
347
+ });
348
+ } else {
349
+ lines.push("- None detected.");
350
+ }
351
+ lines.push("");
352
+ lines.push("Influence Unknown / A-B Candidates");
353
+ if (audit.influenceUnknown.length) {
354
+ audit.influenceUnknown.slice(0, 6).forEach((rule) => {
355
+ lines.push(`- ${rule.file}:${rule.line} [${rule.status}] ${rule.text}`);
356
+ lines.push(` ${rule.recommendation}`);
357
+ });
358
+ } else {
359
+ lines.push("- None detected.");
360
+ }
361
+ lines.push("");
267
362
  lines.push("Next");
268
363
  audit.next.forEach((item, index) => lines.push(`${index + 1}. ${item}`));
269
364
  return lines.join("\n");
@@ -122,7 +122,7 @@ function createMcpTools(deps) {
122
122
  tool: { type: "string", enum: ["all", "codex", "claude", "cursor"], description: "Which local session logs to inspect." },
123
123
  limit: limitProperty,
124
124
  }),
125
- makeTool("prismo_instructions_audit", "Audit persistent instruction files for useful rules, duplicates, and dead-weight candidates.", {
125
+ makeTool("prismo_instructions_audit", "Audit persistent instruction files for useful rules, observable violations, partial compliance, duplicates, and influence-unknown rules.", {
126
126
  path: pathProperty,
127
127
  limit: limitProperty,
128
128
  }),
@@ -355,7 +355,7 @@ Commands:
355
355
  cc Show Claude Code token cost, cache cost, and all-time totals.
356
356
  cursor Show Cursor session data, AI authorship, and AI-generated file tracking.
357
357
  receipt Generate a run receipt for reads, repeats, output, artifacts, and next-run scope.
358
- instructions Audit CLAUDE.md / AGENTS.md rule ROI and dead-weight candidates.
358
+ instructions Audit CLAUDE.md / AGENTS.md rule ROI, violations, partial compliance, duplicates, and influence-unknown rules.
359
359
  timeline Show recurring context-waste patterns across recent sessions.
360
360
  replay Reconstruct why a session went sideways and print a recovery prompt.
361
361
  boundaries Check whether parallel agents are isolated or overlapping.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getprismo",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "Local AI coding workflow scanner for Codex, Claude Code, Cursor, and token-waste diagnostics.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/shanirsh/prismodev#readme",