@shahmilsaari/memory-core 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +14 -39
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -887,17 +887,7 @@ Things that must never appear:
887
887
  ${avoids.map((a, i) => `${i + 1}. ${a}`).join("\n")}
888
888
 
889
889
  IMPORTANT: Respond with JSON: {"violations":[...]} or {"violations":[]}.
890
- Each violation must include ALL of these fields:
891
- - "rule": the rule that was broken (exact text)
892
- - "file": filename
893
- - "line": line number where the violation occurs (integer)
894
- - "code": the exact bad line of code (just that one line, no line number prefix)
895
- - "issue": plain English description of what is wrong
896
- - "suggestion": concrete fix \u2014 what to write instead
897
- - "reason": copy the WHY from the rule to explain why this matters
898
- - "severity": "error" for definite violations, "warning" for possible violations
899
-
900
- Example: {"violations":[{"rule":"Thin controllers","file":"user.ts","line":34,"code":"const hash = await bcrypt.hash(password, 10)","issue":"Password hashing inside controller","suggestion":"Move to UserService.hashPassword()","reason":"Business logic in controllers cannot be reused","severity":"error"}]}
890
+ Each violation: {"rule":"...","file":"...","line":N,"issue":"...","suggestion":"...","reason":"..."}.
901
891
  No text outside the JSON.`;
902
892
  try {
903
893
  const res = await fetch(`${ollamaUrl}/api/chat`, {
@@ -943,40 +933,25 @@ ${diffToSend}` }
943
933
  console.log(chalk2.green(` \u2713 ${rel}`) + chalk2.dim(" \u2014 no violations"));
944
934
  return;
945
935
  }
946
- const errors = violations.filter((v) => v.severity !== "warning").length;
947
- const warnings = violations.filter((v) => v.severity === "warning").length;
948
- const summary = [
949
- errors > 0 ? chalk2.red.bold(`${errors} error${errors > 1 ? "s" : ""}`) : "",
950
- warnings > 0 ? chalk2.yellow.bold(`${warnings} warning${warnings > 1 ? "s" : ""}`) : ""
951
- ].filter(Boolean).join(chalk2.dim(", "));
952
- console.log(`
953
- ${chalk2.red.bold("\u2717")} ${chalk2.bold(rel)} \u2014 ${summary}
954
- `);
936
+ console.log(
937
+ chalk2.red.bold(`
938
+ \u2717 ${violations.length} violation${violations.length > 1 ? "s" : ""} in ${rel}
939
+ `)
940
+ );
955
941
  violations.forEach((v, i) => {
956
- const isWarning = v.severity === "warning";
957
- const badge = isWarning ? chalk2.yellow.bold(" WARN ") : chalk2.red.bold(" ERR ");
958
- const loc = v.line ? chalk2.dim(`line ${v.line}`) : "";
959
- console.log(` ${badge} ${chalk2.bold(v.rule)} ${loc}`);
942
+ const loc = v.line ? `${v.file ?? rel}:${v.line}` : v.file ?? rel;
943
+ console.log(chalk2.bold(` [${i + 1}] ${loc}`));
944
+ console.log(chalk2.yellow(" Rule: ") + v.rule);
960
945
  const why = v.reason ?? reasonMap2.get(v.rule);
961
- if (why) {
962
- console.log(chalk2.dim(` Why: ${why}`));
963
- }
964
- console.log();
946
+ if (why) console.log(chalk2.dim(" Why: ") + chalk2.dim(why));
965
947
  if (v.line && existsSync5(filePath)) {
966
- printCodeContext(filePath, v.line);
967
- } else if (v.code) {
968
- console.log(chalk2.dim(" \u250C\u2500 code \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
969
- console.log(chalk2.red(` \u2502 \u25B6 ${v.code}`));
970
- console.log(chalk2.dim(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
948
+ printCodeContext(filePath, v.line, 1);
971
949
  }
972
- console.log();
973
- if (v.issue) console.log(chalk2.red(` Problem: `) + v.issue);
974
- if (v.suggestion) console.log(chalk2.green(` Fix: `) + chalk2.green(v.suggestion));
975
- console.log();
976
- console.log(chalk2.dim(" " + "\u2500".repeat(55)));
950
+ if (v.issue) console.log(chalk2.red(" Issue: ") + v.issue);
951
+ if (v.suggestion) console.log(chalk2.green(" Fix: ") + v.suggestion);
977
952
  console.log();
978
953
  });
979
- console.log(chalk2.dim(' Run: memory-core remember "<lesson>" to save this as a rule'));
954
+ console.log(chalk2.dim(' Fix violations or run: memory-core remember "<lesson>"'));
980
955
  console.log();
981
956
  } catch (err) {
982
957
  if (err.cause?.code === "ECONNREFUSED" || err.message?.includes("ECONNREFUSED")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shahmilsaari/memory-core",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Universal AI memory core — generate AI context files from architecture profiles with RAG support",
5
5
  "type": "module",
6
6
  "bin": {