true-mem 1.0.3 → 1.0.9

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 (42) hide show
  1. package/README.md +21 -0
  2. package/dist/adapters/opencode/index.d.ts.map +1 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +83 -57
  5. package/dist/memory/patterns.d.ts +11 -0
  6. package/dist/memory/patterns.d.ts.map +1 -1
  7. package/dist/utils/toast.d.ts +6 -0
  8. package/dist/utils/toast.d.ts.map +1 -0
  9. package/dist/utils/version.d.ts +6 -0
  10. package/dist/utils/version.d.ts.map +1 -0
  11. package/package.json +2 -1
  12. package/dist/adapters/opencode/index.js +0 -676
  13. package/dist/adapters/opencode/index.js.map +0 -1
  14. package/dist/adapters/opencode/injection.js +0 -93
  15. package/dist/adapters/opencode/injection.js.map +0 -1
  16. package/dist/config.js +0 -61
  17. package/dist/config.js.map +0 -1
  18. package/dist/extraction/queue.js +0 -75
  19. package/dist/extraction/queue.js.map +0 -1
  20. package/dist/index.js.map +0 -1
  21. package/dist/logger.js +0 -30
  22. package/dist/logger.js.map +0 -1
  23. package/dist/memory/classifier.js +0 -363
  24. package/dist/memory/classifier.js.map +0 -1
  25. package/dist/memory/embeddings.js +0 -98
  26. package/dist/memory/embeddings.js.map +0 -1
  27. package/dist/memory/negative-patterns.js +0 -71
  28. package/dist/memory/negative-patterns.js.map +0 -1
  29. package/dist/memory/patterns.js +0 -623
  30. package/dist/memory/patterns.js.map +0 -1
  31. package/dist/memory/reconsolidate.js +0 -96
  32. package/dist/memory/reconsolidate.js.map +0 -1
  33. package/dist/memory/role-patterns.js +0 -188
  34. package/dist/memory/role-patterns.js.map +0 -1
  35. package/dist/shutdown.js +0 -120
  36. package/dist/shutdown.js.map +0 -1
  37. package/dist/storage/database.js +0 -590
  38. package/dist/storage/database.js.map +0 -1
  39. package/dist/storage/sqlite-adapter.js +0 -99
  40. package/dist/storage/sqlite-adapter.js.map +0 -1
  41. package/dist/types.js +0 -63
  42. package/dist/types.js.map +0 -1
package/README.md CHANGED
@@ -139,6 +139,27 @@ Use phrases like "Remember this:" or "Remember that ..." to force storage:
139
139
  "Remember that I prefer to use TypeScript in my projects"
140
140
  ```
141
141
 
142
+ **Scope Behavior**:
143
+
144
+ By default, explicit intent memories are stored at **project scope** (only visible in the current project). To make them **global** (available in all projects), include a global scope keyword anywhere in your phrase:
145
+
146
+ | Language | Global Scope Keywords |
147
+ |----------|---------------------|
148
+ | **English** | "always", "everywhere", "for all projects", "in every project", "globally" |
149
+ | **Italian** | "sempre", "ovunque", "per tutti i progetti", "in ogni progetto", "globalmente" |
150
+ | **Spanish** | "siempre", "en todas partes", "para todos los proyectos" |
151
+ | **French** | "toujours", "partout", "pour tous les projets" |
152
+ | **German** | "immer", "überall", "für alle projekte" |
153
+ | **Portuguese** | "sempre", "em todos os projetos" |
154
+
155
+ **Examples**:
156
+
157
+ | Memory | Scope | Phrase |
158
+ |---------|---------|---------|
159
+ | **Project** | `project_scope = current_project` | "Remember that we use REST for the API" |
160
+ | **Global** | `project_scope = null` | "Remember to _always_ run tests before committing" |
161
+ | **Global** | `project_scope = null` | "Remember that I _always_ use Typescript _in every project_" |
162
+
142
163
  ---
143
164
 
144
165
  ## Architecture
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/opencode/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAwB,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAA4D,MAAM,gBAAgB,CAAC;AA4F/G;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,WAAW,EAChB,eAAe,GAAE,OAAO,CAAC,cAAc,CAAM,GAC5C,OAAO,CAAC,KAAK,CAAC,CAwKhB;AAylBD,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/opencode/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAwB,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAA4D,MAAM,gBAAgB,CAAC;AA4F/G;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,WAAW,EAChB,eAAe,GAAE,OAAO,CAAC,cAAc,CAAM,GAC5C,OAAO,CAAC,KAAK,CAAC,CAwKhB;AAwlBD,eAAe,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,qBAAqB,CAAC;AAkBzD,QAAA,MAAM,UAAU,EAAE,MAgGjB,CAAC;AAEF,eAAe,UAAU,CAAC;AAG1B,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,qBAAqB,CAAC;AAmBzD,QAAA,MAAM,UAAU,EAAE,MAqGjB,CAAC;AAEF,eAAe,UAAU,CAAC;AAG1B,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1363,7 +1363,11 @@ function matchAllPatterns(text) {
1363
1363
  }
1364
1364
  return signals;
1365
1365
  }
1366
- var EXPLICIT_REMEMBER, EMPHASIS_CUE, CORRECTION, PREFERENCE, DECISION, CONSTRAINT, BUG_FIX, LEARNING, ALL_PATTERNS;
1366
+ function hasGlobalScopeKeyword(text) {
1367
+ const lowerText = text.toLowerCase();
1368
+ return GLOBAL_SCOPE_KEYWORDS.latin.some((keyword) => lowerText.includes(keyword.toLowerCase()));
1369
+ }
1370
+ var EXPLICIT_REMEMBER, EMPHASIS_CUE, CORRECTION, PREFERENCE, DECISION, CONSTRAINT, BUG_FIX, LEARNING, ALL_PATTERNS, GLOBAL_SCOPE_KEYWORDS;
1367
1371
  var init_patterns = __esm(() => {
1368
1372
  EXPLICIT_REMEMBER = {
1369
1373
  signalType: "explicit_remember",
@@ -2266,6 +2270,56 @@ var init_patterns = __esm(() => {
2266
2270
  BUG_FIX,
2267
2271
  LEARNING
2268
2272
  ];
2273
+ GLOBAL_SCOPE_KEYWORDS = {
2274
+ latin: [
2275
+ "always",
2276
+ "everywhere",
2277
+ "for all projects",
2278
+ "in every project",
2279
+ "globally",
2280
+ "in all my projects",
2281
+ "across all projects",
2282
+ "in all projects",
2283
+ "sempre",
2284
+ "ovunque",
2285
+ "per tutti i progetti",
2286
+ "in ogni progetto",
2287
+ "globalmente",
2288
+ "in tutti i miei progetti",
2289
+ "in tutti i progetti",
2290
+ "per ogni progetto",
2291
+ "siempre",
2292
+ "en todas partes",
2293
+ "para todos los proyectos",
2294
+ "en todos los proyectos",
2295
+ "en todos mis proyectos",
2296
+ "toujours",
2297
+ "partout",
2298
+ "pour tous les projets",
2299
+ "dans tous les projets",
2300
+ "dans tous mes projets",
2301
+ "immer",
2302
+ "uberall",
2303
+ "fur alle projekte",
2304
+ "in allen projekten",
2305
+ "in allen meinen projekten",
2306
+ "sempre",
2307
+ "em todos os projetos",
2308
+ "para todos os projetos",
2309
+ "em todos os meus projetos",
2310
+ "altijd",
2311
+ "overal",
2312
+ "voor alle projecten",
2313
+ "in al mijn projecten",
2314
+ "her zaman",
2315
+ "her yerde",
2316
+ "tum projelerde",
2317
+ "zawsze",
2318
+ "wszedzie",
2319
+ "dla wszystkich projektow",
2320
+ "we wszystkich moich projektach"
2321
+ ]
2322
+ };
2269
2323
  });
2270
2324
 
2271
2325
  // src/extraction/queue.ts
@@ -2697,7 +2751,8 @@ async function processSessionIdle(state, sessionId) {
2697
2751
  if (result.store) {
2698
2752
  const userLevelClassifications = ["constraint", "preference", "learning", "procedural"];
2699
2753
  const isExplicitIntent = confidence >= 0.85;
2700
- const isUserLevel = userLevelClassifications.includes(classification) || isExplicitIntent;
2754
+ const hasGlobalKeyword = hasGlobalScopeKeyword(isolatedContent);
2755
+ const isUserLevel = userLevelClassifications.includes(classification) || isExplicitIntent && hasGlobalKeyword;
2701
2756
  const scope = isUserLevel ? null : state.worktree;
2702
2757
  const autoPromoteClassifications = ["bugfix", "learning", "decision"];
2703
2758
  const shouldPromoteToLtm = isExplicitIntent || autoPromoteClassifications.includes(classification);
@@ -2952,61 +3007,29 @@ var init_opencode = __esm(() => {
2952
3007
 
2953
3008
  // src/index.ts
2954
3009
  init_logger();
2955
- // package.json
2956
- var package_default = {
2957
- name: "true-mem",
2958
- version: "1.0.3",
2959
- description: "Persistent memory plugin for OpenCode with cognitive psychology-based memory management",
2960
- main: "dist/index.js",
2961
- types: "dist/index.d.ts",
2962
- type: "module",
2963
- exports: {
2964
- ".": {
2965
- types: "./dist/index.d.ts",
2966
- import: "./dist/index.js"
2967
- }
2968
- },
2969
- scripts: {
2970
- build: "bun build src/index.ts --outdir dist --target bun --format esm && tsc --emitDeclarationOnly",
2971
- dev: "bun build src/index.ts --outdir dist --target bun --format esm --watch",
2972
- typecheck: "tsc --noEmit"
2973
- },
2974
- keywords: [
2975
- "opencode",
2976
- "ai",
2977
- "memory",
2978
- "plugin",
2979
- "persistent",
2980
- "cognitive",
2981
- "coding-assistant"
2982
- ],
2983
- author: "rizal72",
2984
- license: "MIT",
2985
- repository: {
2986
- type: "git",
2987
- url: "git+https://github.com/rizal72/true-mem.git"
2988
- },
2989
- bugs: {
2990
- url: "https://github.com/rizal72/true-mem/issues"
2991
- },
2992
- homepage: "https://github.com/rizal72/true-mem#readme",
2993
- files: [
2994
- "dist/",
2995
- "README.md",
2996
- "LICENSE"
2997
- ],
2998
- dependencies: {
2999
- "@opencode-ai/plugin": "^1.2.6",
3000
- "@opencode-ai/sdk": "^1.2.6",
3001
- uuid: "^13.0.0"
3002
- },
3003
- devDependencies: {
3004
- "@types/node": "^25.0.0",
3005
- "@types/uuid": "^10.0.0",
3006
- "bun-types": "^1.3.0",
3007
- typescript: "^5.9.3"
3010
+
3011
+ // src/utils/version.ts
3012
+ import fs from "fs";
3013
+ import path from "path";
3014
+ var __dirname = "/home/runner/work/true-mem/true-mem/src/utils";
3015
+ function getVersion() {
3016
+ try {
3017
+ const distDir = __dirname;
3018
+ const pkgPath = path.join(distDir, "..", "package.json");
3019
+ const content = fs.readFileSync(pkgPath, "utf-8");
3020
+ const pkg = JSON.parse(content);
3021
+ return pkg.version ?? "unknown";
3022
+ } catch {
3023
+ return "unknown";
3008
3024
  }
3009
- };
3025
+ }
3026
+
3027
+ // src/utils/toast.ts
3028
+ function showToast(ctx, title, message, variant = "info", duration = 3000) {
3029
+ ctx.client.tui.showToast({
3030
+ body: { title, message, variant, duration }
3031
+ }).catch(() => {});
3032
+ }
3010
3033
 
3011
3034
  // src/index.ts
3012
3035
  var state = {
@@ -3016,7 +3039,6 @@ var state = {
3016
3039
  realHooks: null
3017
3040
  };
3018
3041
  var TrueMemory = async (ctx) => {
3019
- console.log(`True-Mem v${package_default.version}: Plugin loading...`);
3020
3042
  state.ctx = ctx;
3021
3043
  state.initPromise = (async () => {
3022
3044
  log("Phase 1: Initializing plugin (lightweight)...");
@@ -3038,6 +3060,10 @@ var TrueMemory = async (ctx) => {
3038
3060
  log("True-Mem: Plugin registered (immediate init mode)");
3039
3061
  return {
3040
3062
  event: async ({ event }) => {
3063
+ if (event.type === "session.created" && state.ctx) {
3064
+ const version = getVersion();
3065
+ showToast(state.ctx, `True-Mem v${version}`, "Persistent memory plugin active.", "info");
3066
+ }
3041
3067
  const silentEvents = new Set(["message.part.delta", "message.part.updated", "session.diff"]);
3042
3068
  if (silentEvents.has(event.type))
3043
3069
  return;
@@ -103,6 +103,17 @@ export declare function matchAllPatterns(text: string): ImportanceSignal[];
103
103
  * Returns the best-matching MemoryClassification.
104
104
  */
105
105
  export declare function classifyByPatterns(text: string): string | null;
106
+ /**
107
+ * Global scope keywords - indicate memory should apply to all projects
108
+ * Must appear ANYWHERE in the text (not just after "ricordati")
109
+ */
110
+ export declare const GLOBAL_SCOPE_KEYWORDS: {
111
+ latin: string[];
112
+ };
113
+ /**
114
+ * Check if text contains global scope keywords
115
+ */
116
+ export declare function hasGlobalScopeKeyword(text: string): boolean;
106
117
  /**
107
118
  * Get all classification types supported by patterns
108
119
  */
@@ -1 +1 @@
1
- {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../src/memory/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAM1E,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,oBAAoB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,eA0C/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,eA8C1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,eA+CxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,eA8CxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,eAuCtB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,eAwCxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,eA0CrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,eAgDtB,CA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U,EAAE,eAwCxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,eA0CrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,eAgDtB,CAAC;AAMF,eAAO,MAAM,YAAY,EAAE,eAAe,EASzC,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;CAyFnC,CAAC;AAqCF;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI,CA2B7F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAWjE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6B9D;AAMD;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;CA6BjC,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK3D;AAMD;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,EAAE,CAEtD"}
@@ -0,0 +1,6 @@
1
+ import type { PluginInput } from '@opencode-ai/plugin';
2
+ /**
3
+ * Show a toast notification in the OpenCode TUI.
4
+ */
5
+ export declare function showToast(ctx: PluginInput, title: string, message: string, variant?: 'info' | 'success' | 'error', duration?: number): void;
6
+ //# sourceMappingURL=toast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../src/utils/toast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAM,GAAG,SAAS,GAAG,OAAgB,EAC9C,QAAQ,SAAO,GACd,IAAI,CAMN"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Read version from package.json at RUNTIME.
3
+ * This ensures the version is always current, even after npm version bump.
4
+ */
5
+ export declare function getVersion(): string;
6
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/utils/version.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAWnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "true-mem",
3
- "version": "1.0.3",
3
+ "version": "1.0.9",
4
4
  "description": "Persistent memory plugin for OpenCode with cognitive psychology-based memory management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  }
13
13
  },
14
14
  "scripts": {
15
+ "preversion": "bun run build",
15
16
  "build": "bun build src/index.ts --outdir dist --target bun --format esm && tsc --emitDeclarationOnly",
16
17
  "dev": "bun build src/index.ts --outdir dist --target bun --format esm --watch",
17
18
  "typecheck": "tsc --noEmit"