ctxmedic 0.9.0 → 0.10.0
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 +1 -0
- package/dist/index.js +51 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ npx ctxmedic checkup
|
|
|
53
53
|
| `ctxmedic savings` | FinOps only: spend, run rate, cache hit ratio, savings. |
|
|
54
54
|
| `ctxmedic consult [--ai]` | Interactive appointment: your priorities, budget and main tool shape the treatment plan. `--ai` asks local Ollama or your own Anthropic/OpenAI key for a second opinion. |
|
|
55
55
|
| `ctxmedic history` | Health Score over time. |
|
|
56
|
+
| `ctxmedic rules [path]` | Every rule with its effective level and the options `ctxmedic.config.json` changed. `--json`. |
|
|
56
57
|
| `ctxmedic ui` | Local Web UI on `127.0.0.1`: dashboard, diagnoses, FinOps, config graph. |
|
|
57
58
|
|
|
58
59
|
Common options: `--days 30`, `--no-finops`, `--no-global`.
|
package/dist/index.js
CHANGED
|
@@ -919,6 +919,33 @@ var ConfigError = class extends Error {
|
|
|
919
919
|
};
|
|
920
920
|
var levelOf = (e) => e === void 0 ? "on" : typeof e === "string" ? e : e[0];
|
|
921
921
|
var optionsOf = (e) => Array.isArray(e) && e[1] || {};
|
|
922
|
+
var RuleInfo = z5.object({
|
|
923
|
+
id: RuleId,
|
|
924
|
+
/** "config": reads config files; "session-logs": a FIN_* detector that reads session logs. */
|
|
925
|
+
source: z5.enum(["config", "session-logs"]),
|
|
926
|
+
level: RuleLevel,
|
|
927
|
+
type: z5.enum(["problem", "suggestion"]),
|
|
928
|
+
fixable: z5.boolean(),
|
|
929
|
+
description: z5.string(),
|
|
930
|
+
docs: z5.string(),
|
|
931
|
+
/** Effective options, defaults included. */
|
|
932
|
+
options: z5.record(z5.string(), z5.unknown()),
|
|
933
|
+
/** Options the config set to a value other than the default. */
|
|
934
|
+
changed: z5.record(z5.string(), z5.unknown())
|
|
935
|
+
});
|
|
936
|
+
function describeRules(config) {
|
|
937
|
+
const all = [
|
|
938
|
+
...rules.map((r) => [r.id, r.meta, "config"]),
|
|
939
|
+
...Object.entries(finopsMeta).map(([id, meta2]) => [id, meta2, "session-logs"])
|
|
940
|
+
];
|
|
941
|
+
return all.map(([id, meta2, source]) => {
|
|
942
|
+
const entry = config.rules[id];
|
|
943
|
+
const options = meta2.options?.parse(optionsOf(entry)) ?? {};
|
|
944
|
+
const defaults = meta2.options?.parse({}) ?? {};
|
|
945
|
+
const changed = Object.fromEntries(Object.entries(options).filter(([k, v]) => JSON.stringify(v) !== JSON.stringify(defaults[k])));
|
|
946
|
+
return RuleInfo.parse({ id, source, level: levelOf(entry), type: meta2.type, fixable: meta2.fixable, description: meta2.description, docs: meta2.docs, options, changed });
|
|
947
|
+
});
|
|
948
|
+
}
|
|
922
949
|
function loadConfig(root) {
|
|
923
950
|
const file2 = path9.join(root, CONFIG_FILE);
|
|
924
951
|
if (!fs6.existsSync(file2)) return CtxmedicConfig.parse({});
|
|
@@ -1522,6 +1549,8 @@ var en = {
|
|
|
1522
1549
|
},
|
|
1523
1550
|
cli: {
|
|
1524
1551
|
noBackups: "No backups in .ctxmedic/backups: nothing to restore.",
|
|
1552
|
+
rulesColumns: { rule: "Rule", level: "Level", type: "Type", fix: "Fix", changed: "Changed options" },
|
|
1553
|
+
rulesHint: (configFile) => `Levels and options come from ${configFile}. Docs: docs/rules/<RULE>.md`,
|
|
1525
1554
|
restoreHint: "Undo a fix: ctxmedic restore <backup> (or latest)",
|
|
1526
1555
|
restored: (id) => `Restored backup ${id}`,
|
|
1527
1556
|
noAutoFix: "No auto-fix: follow the prescription by hand.",
|
|
@@ -1697,7 +1726,7 @@ var harnesses = [
|
|
|
1697
1726
|
];
|
|
1698
1727
|
|
|
1699
1728
|
// ../clinical/src/engine.ts
|
|
1700
|
-
var VERSION = true ? "0.
|
|
1729
|
+
var VERSION = true ? "0.10.0" : "0.0.0-dev";
|
|
1701
1730
|
var TRIAGE = { critical: "resuscitation", warning: "therapy", info: "preventive" };
|
|
1702
1731
|
var ORDER = ["resuscitation", "therapy", "preventive"];
|
|
1703
1732
|
var human = (k) => k.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase());
|
|
@@ -2172,6 +2201,18 @@ function history(visits) {
|
|
|
2172
2201
|
if (!visits.length) return pc.dim("No visits yet. Run `ctxmedic checkup`.");
|
|
2173
2202
|
return visits.slice(-20).map((v) => `${v.at.slice(0, 16).replace("T", " ")} ${bar(v.healthScore)} ${String(v.healthScore).padStart(3)} \u{1F534}${v.counts.resuscitation} \u{1F7E1}${v.counts.therapy} \u{1F7E2}${v.counts.preventive} ${pc.dim(v.root)}${scanFlags(v)}`).join("\n");
|
|
2174
2203
|
}
|
|
2204
|
+
function rules2(list, lang, configFile) {
|
|
2205
|
+
const m = messages(lang).cli;
|
|
2206
|
+
const c = m.rulesColumns;
|
|
2207
|
+
const w = Math.max(c.rule.length, ...list.map((r) => r.id.length)) + 2;
|
|
2208
|
+
const row = (a2, b, d2, e, f) => `${a2.padEnd(w)}${b.padEnd(10)}${d2.padEnd(12)}${e.padEnd(5)}${f}`.trimEnd();
|
|
2209
|
+
const lines2 = list.map((r) => {
|
|
2210
|
+
const changed = Object.entries(r.changed).map(([k, v]) => `${k}=${JSON.stringify(v)}`).join(" ");
|
|
2211
|
+
const line = row(r.id, r.level, r.type, r.fixable ? "\u2714" : "", changed);
|
|
2212
|
+
return r.level === "off" ? pc.dim(line) : line;
|
|
2213
|
+
});
|
|
2214
|
+
return [pc.bold(row(c.rule, c.level, c.type, c.fix, c.changed)), ...lines2, "", pc.dim(m.rulesHint(configFile))].join("\n");
|
|
2215
|
+
}
|
|
2175
2216
|
|
|
2176
2217
|
// src/index.ts
|
|
2177
2218
|
var common = (cmd) => cmd.option("--lang <lang>", "interface language (only en for now)").option("--days <n>", "how many days of session logs to analyze", "30").option("--no-finops", "skip session-log (cost) analysis").option("--no-global", "skip global configs in the home directory");
|
|
@@ -2227,6 +2268,15 @@ ${m.restoreHint}`));
|
|
|
2227
2268
|
for (const line of r.restored) console.log(pc2.dim(` ${line}`));
|
|
2228
2269
|
console.log(`${r.dryRun ? pc2.yellow("dry-run") : pc2.green("\u2714")} ${m.restored(r.id)}: ${r.title}`);
|
|
2229
2270
|
});
|
|
2271
|
+
program.command("rules [path]").description("list rules with their effective level and options from ctxmedic.config.json").option("--lang <lang>", "interface language (only en for now)").option("--json", "print the rules as JSON").action((dir, o2) => {
|
|
2272
|
+
let list;
|
|
2273
|
+
try {
|
|
2274
|
+
list = describeRules(loadConfig(path16.resolve(dir ?? ".")));
|
|
2275
|
+
} catch (e) {
|
|
2276
|
+
fail(e);
|
|
2277
|
+
}
|
|
2278
|
+
console.log(o2.json ? JSON.stringify(list, null, 2) : rules2(list, resolveLang(o2.lang), CONFIG_FILE));
|
|
2279
|
+
});
|
|
2230
2280
|
common(program.command("savings [path]").description("FinOps: token spend, cache hit ratio and savings prescriptions")).option("--json", "print the FinOps report as JSON").action(async (dir, o2) => {
|
|
2231
2281
|
const c = ctx(dir, o2);
|
|
2232
2282
|
const ex = await examine(c.root, harnesses, { global: c.global }).catch(fail);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ctxmedic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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",
|