memoir-cli 3.7.1 → 3.8.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.
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  npx memoir-cli
16
16
  ```
17
17
 
18
- One command. No install, no config, no API keys. Your AI now has persistent memory across sessions, tools, and machines. Works with Claude Code, Cursor, Windsurf, Gemini CLI, GitHub Copilot, and 8 more tools.
18
+ One command. No install, no config, no API keys. Your AI now has persistent memory across sessions, tools, and machines. Works with Claude Code, Cursor, Windsurf, Gemini CLI, GitHub Copilot, and 6 more tools.
19
19
 
20
20
  ---
21
21
 
@@ -44,7 +44,7 @@ npx memoir-cli
44
44
 
45
45
  That's it. memoir detects your AI tools, configures MCP, and activates memory. No global install needed.
46
46
 
47
- Your AI gets 7 memory tools:
47
+ Your AI gets 14 memory tools:
48
48
 
49
49
  | MCP Tool | What it does |
50
50
  |----------|-------------|
@@ -55,6 +55,13 @@ Your AI gets 7 memory tools:
55
55
  | `memoir_consolidate` | Analyze memories for duplicates, staleness, and bloat |
56
56
  | `memoir_status` | See which AI tools are detected |
57
57
  | `memoir_profiles` | Switch between work/personal |
58
+ | `memoir_set_goal` | Set the current session goal (pinned into CLAUDE.md) |
59
+ | `memoir_add_next` | Add a next action to the current session |
60
+ | `memoir_complete_next` | Mark a next action as done |
61
+ | `memoir_note` | Record a decision with its rationale |
62
+ | `memoir_ask` | Capture an open question for later |
63
+ | `memoir_session` | Show goals, next actions, decisions, and recent sessions |
64
+ | `memoir_why` | Look up why a past decision was made |
58
65
 
59
66
  ## Why memoir
60
67
 
@@ -62,7 +69,7 @@ Your AI forgets everything between sessions. You re-explain your codebase, your
62
69
 
63
70
  memoir fixes this by giving your AI a shared memory layer that works across **every tool you use**. Tell Claude something once. Cursor knows it too. Sync AI memory between tools, back it up to the cloud, restore it on any machine. And when your memories pile up, `memoir consolidate` cleans house — finds duplicates, flags stale context, and optionally uses AI to merge and prune.
64
71
 
65
- **13 tools supported:** Claude Code, Cursor, Windsurf, Gemini CLI, GitHub Copilot, OpenAI Codex, ChatGPT, Aider, Zed, Cline, Continue.dev, Augment, Trae.
72
+ **11 tools supported:** Claude Code, Cursor, Windsurf, Gemini CLI, GitHub Copilot, OpenAI Codex, ChatGPT, Aider, Zed, Cline, Continue.dev.
66
73
 
67
74
  ## Sync across machines
68
75
 
package/bin/memoir.js CHANGED
@@ -112,6 +112,7 @@ program
112
112
  .description('Back up your AI memory to the cloud')
113
113
  .option('--only <tools>', 'Only sync specific tools (comma-separated)')
114
114
  .option('-p, --profile <name>', 'Use a specific profile')
115
+ .option('--redact', 'Strip detected secrets from synced files before they are backed up')
115
116
  .action(async (options) => {
116
117
  try {
117
118
  await pushCommand(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memoir-cli",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "mcpName": "io.github.camgitt/memoir",
5
5
  "description": "MCP server that gives Claude, Cursor, and Gemini long-term memory across sessions. Your AI remembers your codebase, decisions, and preferences — across tools and machines.",
6
6
  "main": "src/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "https://github.com/camgitt/memoir.git"
23
+ "url": "git+https://github.com/camgitt/memoir.git"
24
24
  },
25
25
  "homepage": "https://memoir.sh",
26
26
  "bugs": {
@@ -8,15 +8,7 @@ import os from 'os';
8
8
  import { execSync } from 'child_process';
9
9
  import { getConfig } from '../config.js';
10
10
  import { adapters } from '../adapters/index.js';
11
-
12
- const SECRET_PATTERNS = [
13
- { pattern: /sk-[a-zA-Z0-9]{20,}/, label: 'OpenAI/Stripe secret key' },
14
- { pattern: /key-[a-zA-Z0-9]{20,}/, label: 'API key' },
15
- { pattern: /ghp_[a-zA-Z0-9]{36,}/, label: 'GitHub personal access token' },
16
- { pattern: /gho_[a-zA-Z0-9]{36,}/, label: 'GitHub OAuth token' },
17
- { pattern: /AKIA[0-9A-Z]{16}/, label: 'AWS access key' },
18
- { pattern: /Bearer\s+[a-zA-Z0-9._\-]{20,}/, label: 'Bearer token' },
19
- ];
11
+ import { scanForSecrets as scanTextForSecrets } from '../security/scanner.js';
20
12
 
21
13
  const SENSITIVE_FILENAMES = ['.env', 'credentials', 'token.json'];
22
14
 
@@ -61,11 +53,9 @@ async function scanForSecrets(files) {
61
53
  // Skip files larger than 1MB
62
54
  if (stat.size > 1024 * 1024) continue;
63
55
  const content = await fs.readFile(filePath, 'utf-8');
64
- for (const { pattern, label } of SECRET_PATTERNS) {
65
- if (pattern.test(content)) {
66
- warnings.push({ file: filePath, reason: label });
67
- break;
68
- }
56
+ const { found } = scanTextForSecrets(content);
57
+ if (found.length > 0) {
58
+ warnings.push({ file: filePath, reason: found[0].label });
69
59
  }
70
60
  } catch {
71
61
  // Skip unreadable files
@@ -19,6 +19,52 @@ import { paths as sessionPaths, readSession, addNote, recordSessionEnd } from '.
19
19
  import { renderSession } from '../session/render.js';
20
20
  import { injectInto, detectAvailableTargets } from '../session/inject.js';
21
21
 
22
+ // Recursively scan every staged file (the REAL tool memory/config files about
23
+ // to be uploaded — CLAUDE.md, .cursorrules, settings.json, project configs,
24
+ // etc.) for secrets. When `redact` is true, rewrite each offending file in
25
+ // place so the cleaned version is what gets uploaded (and encrypted, if on).
26
+ // Returns { findings, scanned } where findings is a flat list of detections
27
+ // keyed by file. Best-effort: unreadable/binary files are skipped.
28
+ export async function scanStagedFiles(dir, { redact = false } = {}) {
29
+ const findings = [];
30
+ let scanned = 0;
31
+
32
+ const walk = async (d) => {
33
+ let entries;
34
+ try {
35
+ entries = await fs.readdir(d, { withFileTypes: true });
36
+ } catch { return; }
37
+ for (const entry of entries) {
38
+ const fullPath = path.join(d, entry.name);
39
+ if (entry.isDirectory()) {
40
+ await walk(fullPath);
41
+ continue;
42
+ }
43
+ try {
44
+ const stat = await fs.stat(fullPath);
45
+ // Skip files larger than 1MB — same threshold as doctor's scan
46
+ if (stat.size > 1024 * 1024) continue;
47
+ const content = await fs.readFile(fullPath, 'utf-8');
48
+ scanned++;
49
+ const { found, clean } = scanForSecrets(content);
50
+ if (found.length > 0) {
51
+ for (const f of found) {
52
+ findings.push({ file: fullPath, label: f.label, redacted: f.redacted });
53
+ }
54
+ if (redact && clean !== content) {
55
+ await fs.writeFile(fullPath, clean);
56
+ }
57
+ }
58
+ } catch {
59
+ // Skip unreadable / non-text files
60
+ }
61
+ }
62
+ };
63
+
64
+ await walk(dir);
65
+ return { findings, scanned };
66
+ }
67
+
22
68
  export async function pushCommand(options = {}) {
23
69
  let config = await getConfig(options.profile);
24
70
 
@@ -205,6 +251,47 @@ export async function pushCommand(options = {}) {
205
251
  }
206
252
  }
207
253
 
254
+ // Scan the REAL files being synced (the staged tool memory/config files,
255
+ // not just the handoff blob) for secrets before they leave the machine.
256
+ // • --redact → strip secrets in place, then upload (sanitized)
257
+ // • otherwise → WARN and continue
258
+ // • background autopush → stay silent and continue
259
+ // We deliberately do NOT hard-block. This is a zero-knowledge encrypted
260
+ // backup of the user's OWN files; silently refusing to back up — which the
261
+ // detached `autopush` Stop-hook path (stdio:'ignore', MEMOIR_AUTOPUSH=1, no
262
+ // TTY) would hit on any false-positive match — is a worse failure than
263
+ // backing up. A future `--strict` flag could fail-closed for the
264
+ // encrypt-off / shared-destination case. Wrapped so a scanner error can
265
+ // never break the push.
266
+ const background = process.env.MEMOIR_AUTOPUSH === '1';
267
+ try {
268
+ const { findings } = await scanStagedFiles(stagingDir, { redact: options.redact === true });
269
+ if (findings.length > 0) {
270
+ if (options.redact === true) {
271
+ spinner.stop();
272
+ console.log(chalk.yellow(`\n 🔒 Redacted ${findings.length} secret(s) from synced files before upload:`));
273
+ for (const f of findings.slice(0, 5)) {
274
+ console.log(chalk.gray(` ${path.basename(f.file)}: ${f.label} (${f.redacted})`));
275
+ }
276
+ if (findings.length > 5) console.log(chalk.gray(` ...and ${findings.length - 5} more`));
277
+ spinner.start();
278
+ } else if (!background) {
279
+ // Warn (interactive or piped) but never block — the backup proceeds.
280
+ spinner.stop();
281
+ console.log(chalk.yellow(`\n ⚠️ ${findings.length} potential secret(s) in synced files (backed up as-is):`));
282
+ for (const f of findings.slice(0, 5)) {
283
+ console.log(chalk.gray(` ${path.basename(f.file)}: ${f.label} (${f.redacted})`));
284
+ }
285
+ if (findings.length > 5) console.log(chalk.gray(` ...and ${findings.length - 5} more`));
286
+ console.log(chalk.gray(' Re-run with ') + chalk.cyan('--redact') + chalk.gray(' to strip them from the backup.'));
287
+ spinner.start();
288
+ }
289
+ // background autopush: silent, continue — never block the auto-backup
290
+ }
291
+ } catch {
292
+ // Secret scan is best-effort — never let it break the push.
293
+ }
294
+
208
295
  // Encrypt if enabled (or ask on first push if not configured)
209
296
  let uploadDir = stagingDir;
210
297
  let encrypted = false;