@pcircle/memesh 4.8.0 → 4.8.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.
Files changed (81) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +7 -1
  4. package/README.de.md +1 -1
  5. package/README.md +1 -1
  6. package/README.zh-TW.md +1 -1
  7. package/dashboard/dist/index.html +9 -9
  8. package/dist/core/agent-message-inbox.d.ts +9 -0
  9. package/dist/core/agent-message-inbox.d.ts.map +1 -0
  10. package/dist/core/agent-message-inbox.js +26 -0
  11. package/dist/core/agent-message-inbox.js.map +1 -0
  12. package/dist/core/agent-router.d.ts.map +1 -1
  13. package/dist/core/agent-router.js +5 -5
  14. package/dist/core/agent-router.js.map +1 -1
  15. package/dist/core/briefing.d.ts.map +1 -1
  16. package/dist/core/briefing.js +5 -1
  17. package/dist/core/briefing.js.map +1 -1
  18. package/dist/core/config.d.ts +4 -1
  19. package/dist/core/config.d.ts.map +1 -1
  20. package/dist/core/config.js +12 -3
  21. package/dist/core/config.js.map +1 -1
  22. package/dist/core/doctor.d.ts.map +1 -1
  23. package/dist/core/doctor.js +5 -2
  24. package/dist/core/doctor.js.map +1 -1
  25. package/dist/core/dreamer.d.ts +2 -0
  26. package/dist/core/dreamer.d.ts.map +1 -1
  27. package/dist/core/dreamer.js +7 -1
  28. package/dist/core/dreamer.js.map +1 -1
  29. package/dist/core/lesson-engine.d.ts +2 -1
  30. package/dist/core/lesson-engine.d.ts.map +1 -1
  31. package/dist/core/lesson-engine.js +5 -2
  32. package/dist/core/lesson-engine.js.map +1 -1
  33. package/dist/core/lesson-slug.d.ts +2 -0
  34. package/dist/core/lesson-slug.d.ts.map +1 -0
  35. package/dist/core/lesson-slug.js +12 -0
  36. package/dist/core/lesson-slug.js.map +1 -0
  37. package/dist/core/llm-client.js +1 -1
  38. package/dist/core/llm-client.js.map +1 -1
  39. package/dist/core/llm-validator.d.ts +4 -1
  40. package/dist/core/llm-validator.d.ts.map +1 -1
  41. package/dist/core/llm-validator.js +59 -30
  42. package/dist/core/llm-validator.js.map +1 -1
  43. package/dist/core/operations.d.ts +9 -3
  44. package/dist/core/operations.d.ts.map +1 -1
  45. package/dist/core/operations.js +18 -14
  46. package/dist/core/operations.js.map +1 -1
  47. package/dist/core/paths.d.ts.map +1 -1
  48. package/dist/core/paths.js +2 -3
  49. package/dist/core/paths.js.map +1 -1
  50. package/dist/core/schema-export.js +2 -2
  51. package/dist/core/schema-export.js.map +1 -1
  52. package/dist/core/transcript-extractor.d.ts.map +1 -1
  53. package/dist/core/transcript-extractor.js +2 -2
  54. package/dist/core/transcript-extractor.js.map +1 -1
  55. package/dist/db.d.ts.map +1 -1
  56. package/dist/db.js +12 -0
  57. package/dist/db.js.map +1 -1
  58. package/dist/host-runtime/acp.d.ts.map +1 -1
  59. package/dist/host-runtime/acp.js +12 -4
  60. package/dist/host-runtime/acp.js.map +1 -1
  61. package/dist/skills-manifest.json +14 -9
  62. package/dist/storage/graph-repairs.d.ts +12 -0
  63. package/dist/storage/graph-repairs.d.ts.map +1 -0
  64. package/dist/storage/graph-repairs.js +194 -0
  65. package/dist/storage/graph-repairs.js.map +1 -0
  66. package/dist/transports/cli/cli.d.ts +5 -0
  67. package/dist/transports/cli/cli.d.ts.map +1 -1
  68. package/dist/transports/cli/cli.js +20 -9
  69. package/dist/transports/cli/cli.js.map +1 -1
  70. package/dist/transports/http/server.d.ts.map +1 -1
  71. package/dist/transports/http/server.js +117 -7
  72. package/dist/transports/http/server.js.map +1 -1
  73. package/dist/transports/mcp/handlers.d.ts +1 -1
  74. package/dist/transports/mcp/handlers.js +1 -1
  75. package/dist/transports/mcp/handlers.js.map +1 -1
  76. package/package.json +13 -3
  77. package/scripts/hooks/_generated/agent-message-inbox.js +33 -0
  78. package/scripts/hooks/_generated/core-paths.js +2 -3
  79. package/scripts/hooks/session-start.js +34 -7
  80. package/scripts/hooks/session-summary.js +40 -1
  81. package/skills/memesh/SKILL.md +17 -1
@@ -87,6 +87,30 @@ async function runAutoUpdateAtStop() {
87
87
  // Handles the current Claude Code transcript format where tool_use/tool_result
88
88
  // are nested inside assistant/user message entries, not top-level entries.
89
89
  // Defensive: never throws — malformed lines are silently skipped.
90
+ /**
91
+ * File paths a shell command writes in place. Recognises the shapes an
92
+ * agent actually uses to edit without Write/Edit: heredoc redirection
93
+ * (`> path <<'EOF'`, `cat > path`), `sed -i`, `tee`, and `pathlib.Path('x')
94
+ * .write_text(` / `fs.writeFileSync('x'` inside an inline script. Returns
95
+ * basenames' sources; the caller keeps basename() as the stored form.
96
+ */
97
+ function bashEditedPaths(cmd) {
98
+ if (typeof cmd !== 'string') return [];
99
+ const found = new Set();
100
+ const add = (m) => { if (m && m[1] && !m[1].startsWith('/dev/') && !m[1].startsWith('/tmp/')) found.add(m[1]); };
101
+ for (const re of [
102
+ /(?:^|[^<])>\s*"?([^\s"'>|&;]+)"?\s*<<\s*['"]?\w+['"]?/g, // > file <<'EOF'
103
+ /\bcat\s*>\s*"?([^\s"'>|&;]+)"?/g, // cat > file
104
+ /\btee\s+(?:-a\s+)?"?([^\s"'>|&;]+)"?/g, // tee file
105
+ /\bsed\s+-i(?:\s+'')?\s+(?:'[^']*'|"[^"]*")\s+"?([^\s"'>|&;]+)"?/g, // sed -i '...' file
106
+ /Path\(\s*['"]([^'"]+)['"]\s*\)\s*\.write_text\(/g, // pathlib write_text
107
+ /writeFileSync\(\s*['"]([^'"]+)['"]/g, // fs.writeFileSync
108
+ ]) {
109
+ let m; while ((m = re.exec(cmd)) !== null) add(m);
110
+ }
111
+ return [...found];
112
+ }
113
+
90
114
  function parseTranscript(transcriptPath) {
91
115
  const filesEdited = new Set();
92
116
  const bashCommands = [];
@@ -118,6 +142,15 @@ function parseTranscript(transcriptPath) {
118
142
  }
119
143
  if (block.name === 'Bash') {
120
144
  const cmd = block.input?.command ?? '';
145
+ // A session that edits through Bash — heredocs, sed -i, a
146
+ // short python script — never produces a Write/Edit block, so
147
+ // `filesEdited` stayed empty and the summary asserted "0 files
148
+ // edited" for a session that edited a dozen. The count also
149
+ // drives the re-capture guard below, so the same gap made the
150
+ // -summary entity re-append on every Stop (#240). Recognise the
151
+ // common in-place write shapes; anything not matched is simply
152
+ // uncounted, which is honest — it is not asserted as zero.
153
+ for (const fp of bashEditedPaths(cmd)) filesEdited.add(basename(fp));
121
154
  if (typeof cmd === 'string' && cmd.length > 10 && !cmd.startsWith('ls') && !cmd.startsWith('cd')) {
122
155
  // Redact BEFORE truncating. A bash command line is the single
123
156
  // most likely place a credential appears in a transcript
@@ -347,7 +380,13 @@ process.stdin.on('end', async () => {
347
380
  // A dedup bail is a SUCCESSFUL run — the loop executed and correctly
348
381
  // decided there was nothing to do — so it stamps the heartbeat like
349
382
  // the capture path below does. Only a throw leaves no stamp.
350
- const alreadyCaptured = db.prepare("SELECT id FROM entities WHERE name = ?").get(`session-${sessionId}-files`);
383
+ // Guard on ANY of this session's three entities, not only `-files`.
384
+ // A Bash-only session created no `-files` row, so the guard never
385
+ // tripped and `-summary` was re-appended on every Stop — measured: 56
386
+ // observations, 16 unique, three commands stored fourteen times each.
387
+ const alreadyCaptured = db.prepare(
388
+ "SELECT id FROM entities WHERE name IN (?, ?, ?) LIMIT 1",
389
+ ).get(`session-${sessionId}-files`, `session-${sessionId}-fixes`, `session-${sessionId}-summary`);
351
390
  if (alreadyCaptured) {
352
391
  recordHookRun(db, 'session-summary');
353
392
  return exit0();
@@ -23,6 +23,22 @@ Persistent memory for AI agents. The point is continuity: the next session start
23
23
 
24
24
  All examples below use CLI. MCP tools accept the same parameters as JSON objects.
25
25
 
26
+ ## All 11 MCP tools
27
+
28
+ | Tool | Purpose |
29
+ |---|---|
30
+ | `remember` | Store knowledge as an entity with observations, tags, and relations |
31
+ | `recall` | Search stored knowledge; empty query lists recent memories |
32
+ | `forget` | Archive an entity or remove one exact observation |
33
+ | `export` | Export memories as portable JSON |
34
+ | `import` | Import a JSON export with the required skip, append, or overwrite strategy |
35
+ | `learn` | Record a structured lesson with error, fix, root cause, and prevention |
36
+ | `task_state` | Read or update user-stated goal, next step, blocker, and finished work |
37
+ | `briefing` | Assemble the current project's work topology |
38
+ | `user_patterns` | Analyze work schedule, tool preferences, and focus areas |
39
+ | `improvement` | Propose an evidence-linked product improvement or read its status; only a human may accept or reject it |
40
+ | `message` | Contact another local agent (hand off, ask, report back) — send here first; the durable inbox is the record. Fetching does not acknowledge |
41
+
26
42
  ## The Loop
27
43
 
28
44
  Four moments. Everything else in this file is detail.
@@ -61,7 +77,7 @@ Use the routing and identity fields returned by `fetch`. A reply has this shape
61
77
  }
62
78
  ```
63
79
 
64
- An active compatible managed host can receive a native push, which removes polling for that live delivery. One-time provider enablement and a MeMesh-managed Codex app-server, Claude Channel, or Gemini ACP session may be required; ordinary unattached sessions are presence-only/inbound-unavailable. Adapter imports and a live router socket do not prove host registration or `host_accept`. Do not promise that a stopped, missing, or replaced session will wake up: it is not resumed or silently rerouted. Use the stable principal for logical routing, and an exact session/generation only when delivery must not move to a replacement connection. Local owns durable storage and host-native delivery; Cloud relay, A2A, SSE, discovery, or fetch is not host delivery.
80
+ An active compatible managed host can receive a native push, which removes polling for that live delivery. One-time provider enablement and a MeMesh-managed Codex app-server or Claude Channel may be required; ordinary unattached sessions are presence-only/inbound-unavailable. The bundled Gemini ACP adapter is experimental protocol-development code, not a release-gated native-wakeup provider. Adapter imports and a live router socket do not prove host registration or `host_accept`. Do not promise that a stopped, missing, or replaced session will wake up: it is not resumed or silently rerouted. Use the stable principal for logical routing, and an exact session/generation only when delivery must not move to a replacement connection. Local owns durable storage and host-native delivery; Cloud relay, A2A, SSE, discovery, or fetch is not host delivery.
65
81
 
66
82
  Durable audit does not mean unbounded silent growth. Owners can inspect it with `memesh message storage report --cutoff <ISO timestamp>`, preview bounded terminal-payload tombstones with `memesh message storage prune --cutoff <ISO timestamp>`, and explicitly add `--apply`. Never prune unresolved/offline-pending work. `MEMESH_AGENT_MESSAGE_STORAGE_QUOTA_BYTES` is an optional owner policy; there is no default quota or automatic pruning.
67
83