total-recall-brain 3.1.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 (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/bin/antigravity.mjs +212 -0
  4. package/bin/init.mjs +36 -0
  5. package/bin/oci-sniper.sh +69 -0
  6. package/bin/total-recall.mjs +229 -0
  7. package/docs/ARCHITECTURE.md +251 -0
  8. package/docs/IDE_INTEGRATION.md +112 -0
  9. package/package.json +71 -0
  10. package/scaffold/.agent/skills/total-recall/SKILL.md +195 -0
  11. package/scaffold/.agent/skills/total-recall/evals/evals.json +20 -0
  12. package/scaffold/.agent/skills/total-recall/memory-vault/concepts/cli-help-reference.md +145 -0
  13. package/scaffold/.agent/skills/total-recall/memory-vault/invariants/operating-instructions.md +75 -0
  14. package/scaffold/.agent/skills/total-recall/memory-vault/preferences/always-websearch-gap.md +16 -0
  15. package/scaffold/.agent/skills/total-recall/memory-vault/preferences/topic-research-sop.md +17 -0
  16. package/scaffold/.agent/skills/total-recall/references/api-reference.md +187 -0
  17. package/scaffold/.agent/skills/total-recall/references/architecture-reference.md +81 -0
  18. package/scaffold/.agent/skills/total-recall/references/cli-reference.md +103 -0
  19. package/scaffold/.agent/skills/total-recall/references/ssss-reference.md +88 -0
  20. package/scaffold/.agent/skills/total-recall/references/troubleshooting.md +68 -0
  21. package/scaffold/.agent/skills/total-recall/scripts/sync-repo.mjs +83 -0
  22. package/scaffold/.agent/skills/total-recall/skills/cli-agents/SKILL.md +122 -0
  23. package/scaffold/.agent/skills/total-recall/skills/cli-agents/agents.yml +27 -0
  24. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/antigravity.txt +20 -0
  25. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/claude.txt +58 -0
  26. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/codex.txt +81 -0
  27. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/gemini.txt +44 -0
  28. package/scaffold/.agent/skills/total-recall/skills/research/SKILL.md +337 -0
  29. package/scaffold/.agent/skills/total-recall/skills/skill/SKILL.md +281 -0
  30. package/scaffold/.agent/skills/total-recall/skills/skill/assets/skill-template/SKILL.md +20 -0
  31. package/scaffold/.agent/skills/total-recall/skills/skill/evals/evals.json +20 -0
  32. package/scaffold/.agent/skills/total-recall/skills/skill/hooks/on-skill-add.sh +14 -0
  33. package/scaffold/.agent/skills/total-recall/skills/skill/hooks/on-skill-delete.sh +14 -0
  34. package/scaffold/.agent/skills/total-recall/skills/skill/learnings/.gitkeep +0 -0
  35. package/scaffold/.agent/skills/total-recall/skills/skill/references/.gitkeep +0 -0
  36. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/.gitkeep +0 -0
  37. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/create-skill.sh +65 -0
  38. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/enforce-skill-optimization.mjs +135 -0
  39. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/find-skills.mjs +124 -0
  40. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/scan-skill.mjs +207 -0
  41. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/skill-watcher.mjs +64 -0
  42. package/scaffold/.agent/skills/total-recall/skills/skill/subagents/audit-all-skills.md +62 -0
  43. package/scaffold/.agent/skills/total-recall/skills/ssss/SKILL.md +27 -0
  44. package/scaffold/.agent/skills/total-recall/skills/ssss/evals/evals.json +17 -0
  45. package/scaffold/.agent/skills/total-recall/skills/ssss/references/ssss-spec.md +117 -0
  46. package/scaffold/.agent/skills/total-recall/skills/ssss/scripts/validate-schema.mjs +54 -0
  47. package/scaffold/.agent/skills/total-recall/skills/ssss/subagents/audit-ssss-node.md +9 -0
  48. package/scaffold/.agent/skills/total-recall/subagents/total-recall-diagnostician.md +13 -0
  49. package/src/cli/agent-dir.mjs +105 -0
  50. package/src/cli/backup.mjs +313 -0
  51. package/src/cli/brain.mjs +224 -0
  52. package/src/cli/chat.mjs +74 -0
  53. package/src/cli/config.mjs +247 -0
  54. package/src/cli/connect.mjs +872 -0
  55. package/src/cli/daemon.mjs +228 -0
  56. package/src/cli/deploy-ui.mjs +1793 -0
  57. package/src/cli/deploy.mjs +1726 -0
  58. package/src/cli/doctor.mjs +254 -0
  59. package/src/cli/dream.mjs +80 -0
  60. package/src/cli/forget.mjs +92 -0
  61. package/src/cli/friction.mjs +21 -0
  62. package/src/cli/generate-pat.mjs +65 -0
  63. package/src/cli/hash-password.mjs +22 -0
  64. package/src/cli/help.mjs +153 -0
  65. package/src/cli/import-rules.mjs +102 -0
  66. package/src/cli/ingest/index.mjs +318 -0
  67. package/src/cli/ingest/parsers/chrome-bookmarks.mjs +238 -0
  68. package/src/cli/ingest/parsers/google-keep.mjs +147 -0
  69. package/src/cli/ingest/parsers/search-history.mjs +142 -0
  70. package/src/cli/ingest/parsers/youtube-history.mjs +181 -0
  71. package/src/cli/ingest/utils/dedup.mjs +69 -0
  72. package/src/cli/ingest/utils/takeout-walker.mjs +101 -0
  73. package/src/cli/ingest.mjs +102 -0
  74. package/src/cli/init.mjs +736 -0
  75. package/src/cli/integration-dispatcher.mjs +128 -0
  76. package/src/cli/lint.mjs +166 -0
  77. package/src/cli/map.mjs +194 -0
  78. package/src/cli/migrate.mjs +87 -0
  79. package/src/cli/rebuild.mjs +88 -0
  80. package/src/cli/recall.mjs +219 -0
  81. package/src/cli/relay.mjs +518 -0
  82. package/src/cli/remember.mjs +306 -0
  83. package/src/cli/research.mjs +381 -0
  84. package/src/cli/reset-password.mjs +75 -0
  85. package/src/cli/restore.mjs +135 -0
  86. package/src/cli/setup.mjs +616 -0
  87. package/src/cli/share.mjs +180 -0
  88. package/src/cli/skill.mjs +313 -0
  89. package/src/cli/snapshot.mjs +108 -0
  90. package/src/cli/start.mjs +63 -0
  91. package/src/cli/status.mjs +296 -0
  92. package/src/cli/sync.mjs +383 -0
  93. package/src/cli/uninstall.mjs +613 -0
  94. package/src/cli/upgrade.mjs +141 -0
  95. package/src/cli/wizard.html +3682 -0
  96. package/src/core/blackboard.mjs +54 -0
  97. package/src/core/clarity-rewriter.mjs +770 -0
  98. package/src/core/conclusion-writer.mjs +259 -0
  99. package/src/core/config.mjs +277 -0
  100. package/src/core/conflict-detector.mjs +536 -0
  101. package/src/core/crypto.mjs +107 -0
  102. package/src/core/daemon-control.mjs +158 -0
  103. package/src/core/daemon-loop.mjs +364 -0
  104. package/src/core/dream.mjs +347 -0
  105. package/src/core/drift-detector.mjs +143 -0
  106. package/src/core/embeddings.mjs +632 -0
  107. package/src/core/emergency-alerts.mjs +137 -0
  108. package/src/core/evolution.mjs +107 -0
  109. package/src/core/fact-seeker.mjs +1602 -0
  110. package/src/core/friction.mjs +95 -0
  111. package/src/core/import-rules.mjs +308 -0
  112. package/src/core/inference-engine.mjs +367 -0
  113. package/src/core/logger.mjs +75 -0
  114. package/src/core/memory-layers.mjs +96 -0
  115. package/src/core/migrate.mjs +116 -0
  116. package/src/core/notifications.mjs +77 -0
  117. package/src/core/operation-validator.mjs +272 -0
  118. package/src/core/optimizer.mjs +330 -0
  119. package/src/core/pattern_detector.mjs +113 -0
  120. package/src/core/post-mortem.mjs +413 -0
  121. package/src/core/protect-instructions.mjs +148 -0
  122. package/src/core/quick-capture.mjs +145 -0
  123. package/src/core/research-queue.mjs +431 -0
  124. package/src/core/research.mjs +461 -0
  125. package/src/core/runtime.mjs +515 -0
  126. package/src/core/sandbox.mjs +163 -0
  127. package/src/core/scheduler.mjs +569 -0
  128. package/src/core/schema.mjs +333 -0
  129. package/src/core/search.mjs +219 -0
  130. package/src/core/semantic-index.mjs +276 -0
  131. package/src/core/session-watcher.mjs +850 -0
  132. package/src/core/snapshot.mjs +133 -0
  133. package/src/core/source-adapters.mjs +1038 -0
  134. package/src/core/steering.mjs +137 -0
  135. package/src/core/surface.mjs +444 -0
  136. package/src/core/task_runner.mjs +125 -0
  137. package/src/core/tts.mjs +142 -0
  138. package/src/core/usage-tracker.mjs +349 -0
  139. package/src/core/vault-cache.mjs +76 -0
  140. package/src/core/vault.mjs +273 -0
  141. package/src/core/watchdog.mjs +236 -0
  142. package/src/server/api.mjs +944 -0
  143. package/src/server/auth.mjs +410 -0
  144. package/src/server/index.mjs +868 -0
  145. package/src/server/keys.mjs +181 -0
  146. package/src/server/rest.mjs +1652 -0
  147. package/src/server/route-manifest.json +77 -0
  148. package/src/server/routes/_shared.mjs +93 -0
  149. package/src/server/routes/keys.mjs +55 -0
  150. package/src/server/routes/memory.mjs +249 -0
  151. package/src/server/routes/sessions.mjs +336 -0
  152. package/src/server/routes/share.mjs +138 -0
  153. package/src/server/tools.mjs +618 -0
  154. package/templates/Caddyfile +37 -0
  155. package/templates/com.totalrecall.backup.plist +42 -0
  156. package/templates/com.totalrecall.daemon.plist +40 -0
  157. package/templates/com.totalrecall.duckdns.plist +23 -0
  158. package/templates/com.totalrecall.server.plist +46 -0
  159. package/templates/default-config/budget.yml +6 -0
  160. package/templates/default-config/runtime.yml +11 -0
  161. package/templates/default-config/security.yml +53 -0
  162. package/templates/default-config/voice.yml +34 -0
  163. package/templates/obsidian-queries/conflicts.md +26 -0
  164. package/templates/obsidian-queries/daily.md +17 -0
  165. package/templates/obsidian-queries/index.md +38 -0
  166. package/templates/obsidian-queries/skills.md +14 -0
  167. package/templates/onboarding-interview.md +72 -0
  168. package/templates/skill_engineering.md +40 -0
  169. package/templates/total-recall-daemon.service +21 -0
  170. package/templates/total-recall-server.service +20 -0
@@ -0,0 +1,219 @@
1
+ import { resolveAgentDir, resolveBrainDir, parseLayerFlag, getBothBrains } from './agent-dir.mjs';
2
+ import { semanticSearch } from '../core/search.mjs';
3
+ import path from 'node:path';
4
+
5
+ function printHelp() {
6
+ console.log(`
7
+ total-recall recall — Semantic search across rules, facts, and session history
8
+
9
+ Usage: total-recall recall "<query>" [options]
10
+ Alias: total-recall search "<query>" [options]
11
+
12
+ Options:
13
+ --top-k, -k <number> Number of results to return (default: 5, max: 20)
14
+ --no-sessions, -ns Exclude session chunk results, search vault only
15
+ --format, -f <type> Output format: 'text' (default) or 'json'
16
+ --category, -cat <name> Filter results by SSSS category
17
+ --tags, -t <list> Filter results by comma-separated tags
18
+ --modality, -m <type> Filter results by modality
19
+ --importance, -i <1-5> Filter results by minimum numerical importance
20
+ --priority, -p <level> Filter results by priority level
21
+
22
+ Examples:
23
+ npx total-recall recall "Never run tsc directly"
24
+ npx total-recall recall "Express server port" --top-k 3
25
+ npx total-recall recall "Chromium sandbox bypass" --no-sessions
26
+ npx total-recall recall "tsc" --category invariants --modality must
27
+ npx total-recall recall "port" --tags config,port --importance 4
28
+ npx total-recall recall "ORM choice" --project # Search project brain only
29
+ npx total-recall recall "coding style" --global # Search global brain only
30
+ `);
31
+ }
32
+
33
+ export default async function recall(args) {
34
+ // Parse layer flag first
35
+ const { layer, remainingArgs } = parseLayerFlag(args);
36
+ const query = remainingArgs[0];
37
+
38
+ if (!query || query === '--help' || query === '-h') {
39
+ printHelp();
40
+ return;
41
+ }
42
+
43
+ // Parse options
44
+ let top_k = 5;
45
+ let includeSessions = true;
46
+ let format = 'text';
47
+ let category = null;
48
+ let tags = null;
49
+ let modality = null;
50
+ let importance = null;
51
+ let priority = null;
52
+
53
+ for (let i = 1; i < remainingArgs.length; i++) {
54
+ const arg = remainingArgs[i];
55
+ if (arg === '--top-k' || arg === '-k') {
56
+ const val = parseInt(remainingArgs[i + 1], 10);
57
+ if (!isNaN(val)) {
58
+ top_k = val;
59
+ i++;
60
+ }
61
+ } else if (arg === '--no-sessions' || arg === '-ns') {
62
+ includeSessions = false;
63
+ } else if (arg === '--format' || arg === '-f') {
64
+ const val = remainingArgs[i + 1];
65
+ if (val === 'text' || val === 'json') {
66
+ format = val;
67
+ i++;
68
+ }
69
+ } else if (arg === '--category' || arg === '-cat') {
70
+ const val = remainingArgs[i + 1];
71
+ if (val) {
72
+ category = val.trim();
73
+ i++;
74
+ }
75
+ } else if (arg === '--tags' || arg === '-t') {
76
+ const val = remainingArgs[i + 1];
77
+ if (val) {
78
+ tags = val.split(',').map(t => t.trim());
79
+ i++;
80
+ }
81
+ } else if (arg === '--modality' || arg === '-m') {
82
+ const val = remainingArgs[i + 1];
83
+ if (val) {
84
+ modality = val.toLowerCase();
85
+ i++;
86
+ }
87
+ } else if (arg === '--importance' || arg === '-i') {
88
+ const val = remainingArgs[i + 1];
89
+ if (val) {
90
+ const num = parseInt(val, 10);
91
+ if (!isNaN(num)) importance = num;
92
+ i++;
93
+ }
94
+ } else if (arg === '--priority' || arg === '-p') {
95
+ const val = remainingArgs[i + 1];
96
+ if (val) {
97
+ priority = val.toLowerCase();
98
+ i++;
99
+ }
100
+ }
101
+ }
102
+
103
+ // Determine which brains to search
104
+ const brains = getBothBrains();
105
+ const searchTargets = [];
106
+
107
+ if (layer === 'global' || layer === 'auto') {
108
+ if (brains.global) {
109
+ searchTargets.push({ label: 'global', brainDir: brains.global.brainDir });
110
+ }
111
+ }
112
+ if (layer === 'project' || layer === 'auto') {
113
+ if (brains.project) {
114
+ searchTargets.push({ label: 'project', brainDir: brains.project.brainDir });
115
+ }
116
+ }
117
+
118
+ if (searchTargets.length === 0) {
119
+ console.error('No brain found. Run `npx total-recall init` to create one.');
120
+ process.exit(1);
121
+ }
122
+
123
+ try {
124
+ // Search all target brains and merge results
125
+ let allResults = [];
126
+
127
+ for (const target of searchTargets) {
128
+ const vaultDir = path.join(target.brainDir, 'memory-vault');
129
+ const derivedDir = path.join(target.brainDir, 'memory-derived');
130
+
131
+ try {
132
+ const results = await semanticSearch(query, {
133
+ vaultDir,
134
+ derivedDir,
135
+ top_k,
136
+ includeSessions: includeSessions && target.label !== 'global', // sessions only in project/local
137
+ category,
138
+ tags,
139
+ modality,
140
+ importance,
141
+ priority
142
+ });
143
+ // Tag each result with its layer
144
+ for (const r of results) {
145
+ r._layer = target.label;
146
+ }
147
+ allResults = allResults.concat(results);
148
+ } catch {
149
+ // Skip brains that can't be searched (no embeddings, etc.)
150
+ }
151
+ }
152
+
153
+ // Sort by score descending, limit to top_k
154
+ allResults.sort((a, b) => (b.score || 0) - (a.score || 0));
155
+ allResults = allResults.slice(0, top_k);
156
+
157
+ if (format === 'json') {
158
+ console.log(JSON.stringify(allResults, null, 2));
159
+ return;
160
+ }
161
+
162
+ if (allResults.length === 0) {
163
+ console.log('\n 🔍 No matching memory nodes found.');
164
+ return;
165
+ }
166
+ if (allResults.degradedTextSearch) {
167
+ console.log('\n ⚠️ WARNING: Embedding API unreachable or unconfigured. Cos-similarity vector search is disabled.');
168
+ console.log(' Running basic text keyword search instead. Configure GOOGLE_API_KEY or OPENAI_API_KEY.');
169
+ }
170
+ const layerSuffix = searchTargets.length > 1 ? ' (merged)' : ` (${searchTargets[0].label})`;
171
+ console.log(`\n 🔍 Semantic search results for "${query}"${layerSuffix}:\n`);
172
+ for (let i = 0; i < allResults.length; i++) {
173
+ const match = allResults[i];
174
+ const rank = i + 1;
175
+ const score = Math.round(match.score * 100) + '%';
176
+ const layerTag = searchTargets.length > 1 ? ` [${match._layer}]` : '';
177
+
178
+ if (match.type === 'vault') {
179
+ const modalityTag = match.modality ? ` [${match.modality.toUpperCase()}]` : '';
180
+ const priorityTag = match.priority && match.priority !== 'normal' ? ` [${match.priority.toUpperCase()}]` : '';
181
+ const importanceVal = parseInt(match.importance, 10) || 3;
182
+ const stars = '⭐'.repeat(Math.max(1, Math.min(5, importanceVal))) + '☆'.repeat(Math.max(0, 5 - importanceVal));
183
+ const confVal = match.confidence !== undefined ? ` (conf: ${Math.round(match.confidence * 100)}%)` : '';
184
+
185
+ console.log(` [${rank}] Vault Match (${score})${layerTag} - Category: ${match.category}${modalityTag}${priorityTag}`);
186
+ console.log(` Title: ${match.title}`);
187
+ console.log(` Slug: ${match.slug}`);
188
+ console.log(` Importance: ${stars}${confVal}`);
189
+ if (match.tags && match.tags.length > 0) {
190
+ console.log(` Tags: ${match.tags.join(', ')}`);
191
+ }
192
+ if (match.related && match.related.length > 0) {
193
+ console.log(` Related: ${match.related.join(', ')}`);
194
+ }
195
+ if (match.body) {
196
+ console.log(` Body:`);
197
+ const bodyLines = match.body.trim().split('\n');
198
+ for (const line of bodyLines) {
199
+ console.log(` │ ${line}`);
200
+ }
201
+ }
202
+ } else if (match.type === 'session') {
203
+ const sessionId = match.session_id ? String(match.session_id).slice(0, 12) + '...' : 'unknown';
204
+ console.log(` [${rank}] Session Match (${score})${layerTag} - Session ID: ${sessionId}`);
205
+ if (match.snippet) {
206
+ console.log(` Snippet: "${match.snippet.trim().replace(/\n/g, ' ')}"`);
207
+ }
208
+ console.log(` Chunk: ${match.chunk} / ${match.total_chunks}`);
209
+ } else {
210
+ console.log(` [${rank}] Match (${score})${layerTag} - Type: ${match.type}`);
211
+ console.log(` Slug: ${match.slug || 'unknown'}`);
212
+ }
213
+ console.log('');
214
+ }
215
+ } catch (err) {
216
+ console.error(`Error executing recall: ${err.message}`);
217
+ process.exit(1);
218
+ }
219
+ }