ctxmedic 0.3.0 → 0.3.2
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 +31 -7
- package/dist/index.js +17 -9
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -110,13 +110,37 @@ their severity or thresholds, or ignore paths, add `ctxmedic.config.json`:
|
|
|
110
110
|
|
|
111
111
|
To silence a rule for one Markdown file: `<!-- ctxmedic-disable WARN_CONTEXT_BLOAT -- reason -->`.
|
|
112
112
|
|
|
113
|
-
##
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
-
|
|
113
|
+
## What ctxmedic reads and writes
|
|
114
|
+
|
|
115
|
+
ctxmedic is read-only until you approve a fix. Nothing is uploaded: no
|
|
116
|
+
telemetry, no update checks.
|
|
117
|
+
|
|
118
|
+
**Reads**
|
|
119
|
+
- Project AI configs: `CLAUDE.md`, `AGENTS.md`, `.cursor/rules`, `.windsurfrules`,
|
|
120
|
+
`.clinerules`, Copilot instructions, skills, `.mcp.json` and similar
|
|
121
|
+
(full list per tool in [`packages/harnesses`](packages/harnesses/src/index.ts)).
|
|
122
|
+
- Global configs in your home folder, such as `~/.claude/CLAUDE.md` and
|
|
123
|
+
`~/.claude.json`. Skip them with `--no-global`.
|
|
124
|
+
- Local session logs, for the cost report only: `~/.claude/projects`,
|
|
125
|
+
`~/.codex/sessions`, `~/.cursor/projects`. Only token counts and model names are
|
|
126
|
+
kept; prompts are not stored. Skip them with `--no-finops`.
|
|
127
|
+
|
|
128
|
+
**Writes**
|
|
129
|
+
- `~/.ctxmedic/`: visit history (for trends) and a cache of parsed log totals.
|
|
130
|
+
- `<project>/.ctxmedic/backups/`: a copy of every file before a fix changes it,
|
|
131
|
+
so `ctxmedic restore` can undo it. Fixes ask first and refuse to touch files
|
|
132
|
+
with uncommitted changes (`--force` overrides) or outside the project folder
|
|
133
|
+
(`--global` allows your home-folder configs).
|
|
134
|
+
|
|
135
|
+
**Network**
|
|
136
|
+
- Only `consult --ai`, which you run yourself. It replaces secrets with
|
|
137
|
+
`[REDACTED]`, then sends your instruction files either to a local Ollama or,
|
|
138
|
+
after you confirm, to Anthropic or OpenAI with your own key.
|
|
139
|
+
- The UI server (`ctxmedic ui`) listens on `127.0.0.1` only and requires a
|
|
140
|
+
per-run token for writes.
|
|
141
|
+
|
|
142
|
+
Secrets found in configs are always masked in output. To verify that the npm
|
|
143
|
+
package was built from this repo by CI, run `npm audit signatures`.
|
|
120
144
|
|
|
121
145
|
## Development
|
|
122
146
|
|
package/dist/index.js
CHANGED
|
@@ -1652,7 +1652,7 @@ var harnesses = [
|
|
|
1652
1652
|
];
|
|
1653
1653
|
|
|
1654
1654
|
// ../clinical/src/engine.ts
|
|
1655
|
-
var VERSION = true ? "0.3.
|
|
1655
|
+
var VERSION = true ? "0.3.2" : "0.0.0-dev";
|
|
1656
1656
|
var TRIAGE = { critical: "resuscitation", warning: "therapy", info: "preventive" };
|
|
1657
1657
|
var ORDER = ["resuscitation", "therapy", "preventive"];
|
|
1658
1658
|
var human = (k) => k.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase());
|
|
@@ -1759,7 +1759,6 @@ async function treat(rxId, opts) {
|
|
|
1759
1759
|
}
|
|
1760
1760
|
|
|
1761
1761
|
// ../clinical/src/ai.ts
|
|
1762
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
1763
1762
|
var OLLAMA = process.env.OLLAMA_HOST ?? "http://127.0.0.1:11434";
|
|
1764
1763
|
var MAX_CHARS = 12e4;
|
|
1765
1764
|
var SYSTEM = `You are a senior reviewer of AI coding-agent configuration (CLAUDE.md, AGENTS.md, Cursor rules, skills).
|
|
@@ -1804,15 +1803,24 @@ async function askAi(provider, prompt) {
|
|
|
1804
1803
|
return (await r2.json()).message?.content ?? "";
|
|
1805
1804
|
}
|
|
1806
1805
|
if (provider === "anthropic") {
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1806
|
+
const r2 = await fetch(`${process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com"}/v1/messages`, {
|
|
1807
|
+
method: "POST",
|
|
1808
|
+
headers: {
|
|
1809
|
+
"content-type": "application/json",
|
|
1810
|
+
"x-api-key": process.env.ANTHROPIC_API_KEY ?? "",
|
|
1811
|
+
"anthropic-version": "2023-06-01"
|
|
1812
|
+
},
|
|
1813
|
+
body: JSON.stringify({
|
|
1814
|
+
model: process.env.CTXMEDIC_AI_MODEL ?? "claude-opus-5-5",
|
|
1815
|
+
max_tokens: 16e3,
|
|
1816
|
+
system: SYSTEM,
|
|
1817
|
+
messages: [{ role: "user", content: prompt }]
|
|
1818
|
+
})
|
|
1813
1819
|
});
|
|
1820
|
+
if (!r2.ok) throw new Error(`Anthropic: HTTP ${r2.status}`);
|
|
1821
|
+
const res = await r2.json();
|
|
1814
1822
|
if (res.stop_reason === "refusal") return "The model declined to review this configuration.";
|
|
1815
|
-
return res.content.flatMap((b) => b.type === "text" ? [b.text] : []).join("\n");
|
|
1823
|
+
return (res.content ?? []).flatMap((b) => b.type === "text" && b.text ? [b.text] : []).join("\n");
|
|
1816
1824
|
}
|
|
1817
1825
|
const r = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
1818
1826
|
method: "POST",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ctxmedic",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "The context medic for your AI coding setup: checkup, treat, savings for Claude Code, Cursor, Windsurf, Codex CLI, OpenCode, Cline and Copilot.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"node": ">=20"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@anthropic-ai/sdk": "^1.11.0",
|
|
53
52
|
"@clack/prompts": "^0.9.1",
|
|
54
53
|
"@hono/node-server": "^2.1.6",
|
|
55
54
|
"commander": "^12.1.0",
|