secufusion-mcp 1.0.9 → 1.0.10
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 +4 -2
- package/index.js +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ Manages a structured JSON state file (`.secufusion-state.json`) keyed to the cur
|
|
|
115
115
|
| `pending_acs` | array | No | Array of strings for pending tasks (For `initialize`/`update`) |
|
|
116
116
|
| `completed_acs` | array | No | Array of completed AC strings (For `update`) |
|
|
117
117
|
| `next_step` | string | No | **CRITICAL for `update`**: A clear instruction on what to do next to allow instant resumption. |
|
|
118
|
-
| `reference_file_path` | string | No | Path to a reference file with standard coding patterns |
|
|
118
|
+
| `reference_file_path` | string | No | Path to a reference file with standard coding patterns (auto-compressed to save tokens) |
|
|
119
119
|
|
|
120
120
|
**Example — Starting a new task:**
|
|
121
121
|
```json
|
|
@@ -256,6 +256,7 @@ These rules are enforced automatically — the AI will never violate them:
|
|
|
256
256
|
✅ No hardcoded UAT/Prod IPs or environment URLs
|
|
257
257
|
✅ Every JPA @Entity change accompanied by a Flyway .sql migration
|
|
258
258
|
✅ State in .secufusion-state.json must be fully resolved before PR is raised
|
|
259
|
+
✅ Token Efficiency: Every tool response includes a 📊 Telemetry receipt tracking input/output tokens, cost, and the Session Total
|
|
259
260
|
```
|
|
260
261
|
|
|
261
262
|
---
|
|
@@ -266,8 +267,9 @@ These rules are enforced automatically — the AI will never violate them:
|
|
|
266
267
|
|---|---|
|
|
267
268
|
| `.secufusion-state.json` | Living task blueprint — tracks pending/completed ACs per branch |
|
|
268
269
|
| `.rejected-patterns.json` | Cumulative log of all rejected patterns across sessions |
|
|
270
|
+
| `.secufusion-tokens.json` | Persistent tracking of session-wide LLM token usage and cost |
|
|
269
271
|
|
|
270
|
-
> **Tip:** Commit
|
|
272
|
+
> **Tip:** Commit `.secufusion-state.json` and `.rejected-patterns.json` to your repo. Do **not** commit `.secufusion-tokens.json`.
|
|
271
273
|
|
|
272
274
|
---
|
|
273
275
|
|
package/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { execSync } from "child_process";
|
|
|
24
24
|
// ─────────────────────────────────────────────
|
|
25
25
|
const STATE_FILE = ".secufusion-state.json";
|
|
26
26
|
const REJECTED_FILE = ".rejected-patterns.json";
|
|
27
|
+
const TOKEN_FILE = ".secufusion-tokens.json";
|
|
27
28
|
/** Resolve a path relative to cwd (where the MCP server is invoked). */
|
|
28
29
|
function resolve(file) {
|
|
29
30
|
return path.resolve(process.cwd(), file);
|
|
@@ -71,8 +72,22 @@ function appendTelemetry(response, inputChars) {
|
|
|
71
72
|
const outputTokens = Math.ceil(outputChars / 4);
|
|
72
73
|
const inputCost = (inputTokens / 1000000) * 3.0;
|
|
73
74
|
const outputCost = (outputTokens / 1000000) * 15.0;
|
|
74
|
-
const totalCost =
|
|
75
|
-
|
|
75
|
+
const totalCost = inputCost + outputCost;
|
|
76
|
+
// Track Session Totals
|
|
77
|
+
const tokenFilePath = resolve(TOKEN_FILE);
|
|
78
|
+
let session = { inputTokens: 0, outputTokens: 0, totalCost: 0 };
|
|
79
|
+
const existing = readFileSafe(tokenFilePath);
|
|
80
|
+
if (existing) {
|
|
81
|
+
try {
|
|
82
|
+
session = JSON.parse(existing);
|
|
83
|
+
}
|
|
84
|
+
catch { }
|
|
85
|
+
}
|
|
86
|
+
session.inputTokens += inputTokens;
|
|
87
|
+
session.outputTokens += outputTokens;
|
|
88
|
+
session.totalCost += totalCost;
|
|
89
|
+
writeFile(tokenFilePath, JSON.stringify(session, null, 2));
|
|
90
|
+
const telemetry = `\n\n> 📊 Telemetry\n> **Request:** Input: ~${inputTokens} | Output: ~${outputTokens} | Cost: ${totalCost.toFixed(4)}\n> **Session Total:** Input: ~${session.inputTokens} | Output: ~${session.outputTokens} | Cost: ${session.totalCost.toFixed(4)}`;
|
|
76
91
|
if (response.content && response.content.length > 0 && response.content[0].type === "text") {
|
|
77
92
|
response.content[0].text += telemetry;
|
|
78
93
|
}
|