@nxuss/lemma 1.34.0 β†’ 1.36.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.
Files changed (75) hide show
  1. package/README.md +37 -0
  2. package/bin/brain-ingest.js +28 -0
  3. package/bin/checkpoint.js +6 -0
  4. package/dashboard/dist/assets/index-D6nem4OA.js +461 -0
  5. package/dashboard/dist/assets/index-DNz43ews.css +1 -0
  6. package/dashboard/dist/index.html +2 -2
  7. package/dist/cjs/cli/hostHooks.d.ts +3 -1
  8. package/dist/cjs/cli/hostHooks.d.ts.map +1 -1
  9. package/dist/cjs/cli/hostHooks.js +31 -13
  10. package/dist/cjs/cli/hostHooks.js.map +1 -1
  11. package/dist/cjs/mcp/index.js +2 -0
  12. package/dist/cjs/mcp/index.js.map +1 -1
  13. package/dist/cjs/mcp/staleBuild.d.ts +19 -0
  14. package/dist/cjs/mcp/staleBuild.d.ts.map +1 -1
  15. package/dist/cjs/mcp/staleBuild.js +73 -0
  16. package/dist/cjs/mcp/staleBuild.js.map +1 -1
  17. package/dist/cjs/mcp/tools/memory.d.ts.map +1 -1
  18. package/dist/cjs/mcp/tools/memory.js +84 -13
  19. package/dist/cjs/mcp/tools/memory.js.map +1 -1
  20. package/dist/cjs/subconscious/ExternalRefs.d.ts +47 -0
  21. package/dist/cjs/subconscious/ExternalRefs.d.ts.map +1 -0
  22. package/dist/cjs/subconscious/ExternalRefs.js +131 -0
  23. package/dist/cjs/subconscious/ExternalRefs.js.map +1 -0
  24. package/dist/cjs/subconscious/HostRecall.d.ts +22 -0
  25. package/dist/cjs/subconscious/HostRecall.d.ts.map +1 -1
  26. package/dist/cjs/subconscious/HostRecall.js +96 -0
  27. package/dist/cjs/subconscious/HostRecall.js.map +1 -1
  28. package/dist/cjs/subconscious/TheBrainV2.d.ts +16 -0
  29. package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
  30. package/dist/cjs/subconscious/TheBrainV2.js +17 -0
  31. package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
  32. package/dist/cjs/utils/StoreDraft.d.ts +26 -0
  33. package/dist/cjs/utils/StoreDraft.d.ts.map +1 -0
  34. package/dist/cjs/utils/StoreDraft.js +81 -0
  35. package/dist/cjs/utils/StoreDraft.js.map +1 -0
  36. package/dist/cjs/utils/ageLabel.d.ts +3 -0
  37. package/dist/cjs/utils/ageLabel.d.ts.map +1 -0
  38. package/dist/cjs/utils/ageLabel.js +17 -0
  39. package/dist/cjs/utils/ageLabel.js.map +1 -0
  40. package/dist/esm/cli/hostHooks.d.ts +3 -1
  41. package/dist/esm/cli/hostHooks.d.ts.map +1 -1
  42. package/dist/esm/cli/hostHooks.js +30 -12
  43. package/dist/esm/cli/hostHooks.js.map +1 -1
  44. package/dist/esm/mcp/index.js +2 -0
  45. package/dist/esm/mcp/index.js.map +1 -1
  46. package/dist/esm/mcp/staleBuild.d.ts +19 -0
  47. package/dist/esm/mcp/staleBuild.d.ts.map +1 -1
  48. package/dist/esm/mcp/staleBuild.js +70 -0
  49. package/dist/esm/mcp/staleBuild.js.map +1 -1
  50. package/dist/esm/mcp/tools/memory.d.ts.map +1 -1
  51. package/dist/esm/mcp/tools/memory.js +84 -13
  52. package/dist/esm/mcp/tools/memory.js.map +1 -1
  53. package/dist/esm/subconscious/ExternalRefs.d.ts +47 -0
  54. package/dist/esm/subconscious/ExternalRefs.d.ts.map +1 -0
  55. package/dist/esm/subconscious/ExternalRefs.js +124 -0
  56. package/dist/esm/subconscious/ExternalRefs.js.map +1 -0
  57. package/dist/esm/subconscious/HostRecall.d.ts +22 -0
  58. package/dist/esm/subconscious/HostRecall.d.ts.map +1 -1
  59. package/dist/esm/subconscious/HostRecall.js +93 -0
  60. package/dist/esm/subconscious/HostRecall.js.map +1 -1
  61. package/dist/esm/subconscious/TheBrainV2.d.ts +16 -0
  62. package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
  63. package/dist/esm/subconscious/TheBrainV2.js +17 -0
  64. package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
  65. package/dist/esm/utils/StoreDraft.d.ts +26 -0
  66. package/dist/esm/utils/StoreDraft.d.ts.map +1 -0
  67. package/dist/esm/utils/StoreDraft.js +74 -0
  68. package/dist/esm/utils/StoreDraft.js.map +1 -0
  69. package/dist/esm/utils/ageLabel.d.ts +3 -0
  70. package/dist/esm/utils/ageLabel.d.ts.map +1 -0
  71. package/dist/esm/utils/ageLabel.js +14 -0
  72. package/dist/esm/utils/ageLabel.js.map +1 -0
  73. package/package.json +1 -1
  74. package/dashboard/dist/assets/index-Yt1H2B7F.css +0 -1
  75. package/dashboard/dist/assets/index-euG1IvQ7.js +0 -481
package/README.md CHANGED
@@ -35,6 +35,17 @@ lemma start # gateway + dashboard on http://localhost:8081
35
35
  >
36
36
  > **πŸ†• v1.22.0 β€” Lemma auto-activates in every LLM client.** `npm i -g @nxuss/lemma` registers the skill in your **user** catalog (auto-loads in every `muse` session, any project) and `lemma init` wires each project for Muse, Claude Code, Cursor, Codex, Windsurf, Kiro and OpenCode. Health check: `lemma doctor`.
37
37
  >
38
+ > **πŸ†• v1.35.0 β€” recall *before* the answer, and memories that notice when the world moved.** A
39
+ > status question ("what's still pending?") touches no file, so no post-tool hook ever fired for it
40
+ > and an agent answered from stale notes. `lemma init` now also installs a `UserPromptSubmit` hook
41
+ > that names the memories bearing on the prompt (with age and freshness) and reminds the agent to
42
+ > verify live git/CI state for status questions. `store_memory` takes `refs` β€” a commit, or an MR /
43
+ > issue with the state it asserts β€” and `verify_memory` checks them (`git`, `gh`, `glab`; anything it
44
+ > cannot read is `unverified`, never `fresh`). Also: `search_memory` shows each hit's age and lists
45
+ > below-floor near-misses as orientation only, `get_memory` stops saying "tracks nothing" for
46
+ > claim-tracked entries, `lemma-checkpoint` leaves a store draft the next prompt surfaces once, and a
47
+ > stale MCP build is reported by the prompt hook. Re-run `lemma init` after updating.
48
+ >
38
49
  > **πŸ†• v1.34.0 β€” Dashboard fixes.** The header shows the real running version (from `/health`), the debugger's pause/resume now works against the proxy, the Vite dev proxy points at the right port, and `npm run build` rebuilds the dashboard so the published UI is never stale.
39
50
  >
40
51
  > **πŸ†• v1.33.0 β€” C# (.NET) support, honestly labeled.** New per-project language detection
@@ -172,6 +183,14 @@ lemma start # gateway + dashboard on http://localhost:8081
172
183
  are recovered from the command; OpenCode gets a plugin, since it has no hook protocol.
173
184
  Windsurf/Devin post-hooks can't inject context, and Kiro's hooks spend tokens by design, so
174
185
  neither is wired.
186
+ - **Recall before the agent answers, and memories that know when the world moved** β€” a
187
+ `UserPromptSubmit` hook (`lemma-brain-ingest --prompt-submit`, Claude Code) points at the
188
+ memories a prompt substantially covers and, for status-style questions, says to verify live state
189
+ first: file-hash freshness can't see an MR merge. `store_memory` / `update_memory` accept
190
+ `refs` (`{kind:'commit',sha}`, or `{kind:'mr'|'issue',provider,id,state}`), and `verify_memory`
191
+ checks them with `git` / `gh` / `glab` β€” stale when they moved, `unverified` (never `fresh`) when
192
+ they can't be read. The session-end checkpoint leaves a one-shot reminder to store what was
193
+ verified.
175
194
  - **A team Brain, shared through git** β€” `brain_team push` writes this project's fresh, tracked
176
195
  memories to `.lemma-brain/memories/<id>.json`: one sorted-key JSON file per memory, so two people
177
196
  sharing at once never conflict, every shared memory goes through code review, and deleting one is
@@ -294,6 +313,7 @@ lemma_toolbox { "action": "call", "tool": "terraform_drift", "args": {} }
294
313
  | `lemma activate <key>` | Activate a Pro license. |
295
314
  | `lemma-checkpoint [projectRoot]` | Derive a session checkpoint from repo state (branch, changed files, commits) with no assistant call. |
296
315
  | `lemma-brain-ingest [projectRoot] [--changelog] [--team-pull]` | Feed The Brain from git commits and `CHANGELOG.md`, incrementally; `--team-pull` imports the repo's `.lemma-brain/`. |
316
+ | `lemma-brain-ingest --prompt-submit` | Read a Claude Code `UserPromptSubmit` payload on stdin and reply with the memories that bear on the prompt (id, age, freshness) plus, for a "what is pending" question, a reminder to verify live git/CI state β€” or nothing. Also surfaces the last session's store draft and a stale MCP build, once each. |
297
317
  | `lemma-brain-ingest --hook-result [--host=claude\|codex\|cursor\|opencode]` | Read a host post-tool payload on stdin: capture red β†’ green fixes from the agent's own shell, and reply with a Brain note (memory ids, failed attempts, known fixes) in that host's format β€” or nothing. |
298
318
 
299
319
  Wire the standalone bins into hooks so memory doesn't depend on the assistant remembering to call a tool:
@@ -311,6 +331,23 @@ Wire the standalone bins into hooks so memory doesn't depend on the assistant re
311
331
  "hooks": [{ "type": "command", "command": "lemma-brain-ingest --hook-result" }] }] } }
312
332
  ```
313
333
 
334
+ ```jsonc
335
+ // …and the same file gets the recall-before-answer hook (no matcher: it fires on every prompt)
336
+ { "hooks": { "UserPromptSubmit": [{ "hooks": [{ "type": "command",
337
+ "command": "lemma-brain-ingest --prompt-submit" }] }] } }
338
+ ```
339
+
340
+ Attach external state when you store something whose truth depends on it, so `verify_memory` can
341
+ tell when it goes stale:
342
+
343
+ ```jsonc
344
+ // store_memory arguments (excerpt)
345
+ { "refs": [
346
+ { "kind": "commit", "sha": "2c8a8cb" }, // holds while an ancestor of HEAD
347
+ { "kind": "mr", "provider": "gitlab", "id": "1061", "state": "merged" } // stale once its state differs
348
+ ] }
349
+ ```
350
+
314
351
  Codex (`~/.codex/hooks.json`, `--host=codex`), Cursor (`~/.cursor/hooks.json`, `postToolUse` +
315
352
  `postToolUseFailure`, `--host=cursor`) and OpenCode (a plugin in `~/.config/opencode/plugins/`) are
316
353
  wired the same way by `lemma init` when their config directory exists. Existing hooks are kept;
@@ -15,6 +15,7 @@
15
15
  *
16
16
  * Usage: lemma-brain-ingest [projectRoot] [--max N] [--changelog] [--no-commits] [--team-pull]
17
17
  * lemma-brain-ingest --hook-result [--host=claude|codex|cursor|opencode] < payload.json
18
+ * lemma-brain-ingest --prompt-submit < payload.json
18
19
  *
19
20
  * --team-pull Import the repo's shared memories from .lemma-brain/ (post-merge/post-checkout).
20
21
  * --hook-result Read a host PostToolUse hook payload on stdin (Claude Code shape) and:
@@ -29,6 +30,13 @@
29
30
  * `lemma init` wires it for each host it finds, e.g. .claude/settings.local.json:
30
31
  * "hooks": { "PostToolUse": [{ "matcher": "Bash|Read|Edit|MultiEdit|Write|NotebookEdit",
31
32
  * "hooks": [{ "type": "command", "command": "lemma-brain-ingest --hook-result" }] }] }
33
+ * --prompt-submit Read a Claude Code UserPromptSubmit payload on stdin and answer with the
34
+ * Brain's memories that bear on the prompt (ids, age, freshness) plus, for a
35
+ * "what is pending" style question, a reminder to verify live state with
36
+ * git/gh/glab. This is the recall point that exists before the agent answers: a
37
+ * status question touches no file, so no PostToolUse hook ever fires for it.
38
+ * Silent when nothing matches. Wired by `lemma init` in
39
+ * .claude/settings.local.json under hooks.UserPromptSubmit.
32
40
  */
33
41
 
34
42
  const path = require('path');
@@ -72,8 +80,28 @@ function hookResult(args) {
72
80
  if (out) process.stdout.write(out);
73
81
  }
74
82
 
83
+ function promptSubmit() {
84
+ const dist = path.join(__dirname, '..', 'dist', 'cjs');
85
+ let recallForPrompt, formatHostOutput;
86
+ try {
87
+ ({ recallForPrompt } = require(path.join(dist, 'subconscious', 'HostRecall.js')));
88
+ ({ formatHostOutput } = require(path.join(dist, 'subconscious', 'HostAdapters.js')));
89
+ } catch {
90
+ return; // no build β€” a hook must stay silent and harmless
91
+ }
92
+ let payload;
93
+ try {
94
+ payload = JSON.parse(readStdin());
95
+ } catch {
96
+ return;
97
+ }
98
+ const out = formatHostOutput('claude', recallForPrompt(payload, payload && payload.cwd, undefined, { mcpEntry: path.join(dist, 'mcp', 'index.js') }), 'UserPromptSubmit');
99
+ if (out) process.stdout.write(out);
100
+ }
101
+
75
102
  function main() {
76
103
  const args = process.argv.slice(2);
104
+ if (args.includes('--prompt-submit')) return promptSubmit();
77
105
  if (args.includes('--hook-result')) return hookResult(args);
78
106
  const maxIndex = args.indexOf('--max');
79
107
  const maxCommits = maxIndex >= 0 ? parseInt(args[maxIndex + 1], 10) : undefined;
package/bin/checkpoint.js CHANGED
@@ -35,6 +35,12 @@ function main() {
35
35
  console.error('[lemma-checkpoint] Not a git repository β€” nothing to capture.');
36
36
  return;
37
37
  }
38
+ // Leave a draft for the next session's first prompt: a SessionEnd hook can't speak to the
39
+ // model, and what was verified this session is exactly what a later status question needs.
40
+ try {
41
+ const { writeStoreDraft } = require(path.join(__dirname, '..', 'dist', 'cjs', 'utils', 'StoreDraft.js'));
42
+ writeStoreDraft(projectRoot);
43
+ } catch { /* the draft is a courtesy */ }
38
44
  console.error(
39
45
  `[lemma-checkpoint] Saved: ${result.filesModified.length} file(s) changed β†’ ${path.join(projectRoot, '.lemma/session')}`
40
46
  );