claude-db 0.8.1 → 0.8.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.3
4
+
5
+ ### Fixed
6
+
7
+ - **No transcripts were found for a project whose path contained an underscore,
8
+ a space or any non-ASCII character.**
9
+ ([#13](https://github.com/Avijit07x/claude-db/issues/13))
10
+ The transcript directory name was built by replacing only `/` and `.` with
11
+ `-`, but Claude Code replaces every non-alphanumeric character. A project at
12
+ `/home/f/work/epiclin_2` was looked up under `-home-f-work-epiclin_2` while
13
+ its transcripts sat in `-home-f-work-epiclin-2`, so `flush`, `adoption` and
14
+ `setup` all reported nothing to ingest. The name is now derived the same way
15
+ Claude Code writes it — one dash per non-alphanumeric character — which also
16
+ covers paths with spaces, `@`, `~` or accented characters.
17
+
18
+ ## 0.8.2
19
+
20
+ ### Fixed
21
+
22
+ - **Hooks failed on Windows with MODULE_NOT_FOUND.** Hook commands were written
23
+ with backslash paths, but Claude Code runs them through bash whenever Git Bash
24
+ is present, and there a backslash is an escape character: an unquoted
25
+ `C:\Users\...\hooks\session-end.js` collapses to
26
+ `C:UsersAppData...hookssession-end.js`, which Node then resolves against the
27
+ project directory. Every hook failed. Paths are now written with forward
28
+ slashes, which Node accepts on Windows and bash leaves alone. The MCP server
29
+ was never affected, because its path is passed as an argument rather than
30
+ inside a command string. Reported and fixed by @bspangler21 (#10, #12).
31
+
32
+ - **`status` claimed claude-db was not installed on Windows**, and session start
33
+ never found the MCP server there. Both compared a path built with the
34
+ platform separator against a file that stores it differently — with forward
35
+ slashes now, and JSON-escaped backslashes before that — so the comparison
36
+ could not match. Path comparisons are now separator-insensitive.
37
+
38
+ - **The temporary-install guard did not work on Windows.** It split the install
39
+ path on forward slashes to look for `_npx`, so on a backslash path it found
40
+ nothing and let an install proceed from a directory that npx would delete.
41
+
3
42
  ## 0.8.1
4
43
 
5
44
  ### Fixed
@@ -112,13 +112,15 @@ function isSyntheticPrompt(text) {
112
112
  text.startsWith('[Request interrupted') ||
113
113
  text.startsWith('<local-command'));
114
114
  }
115
+ function projectSlug(project) {
116
+ return project.replace(/[^a-zA-Z0-9]/g, '-');
117
+ }
115
118
  export function transcriptPathFor(project, sessionId) {
116
- const slug = project.replace(/[/.]/g, '-');
117
- return join(homedir(), '.claude', 'projects', slug, `${sessionId}.jsonl`);
119
+ return join(homedir(), '.claude', 'projects', projectSlug(project), `${sessionId}.jsonl`);
118
120
  }
119
121
  export function transcriptsFor(project) {
120
122
  const root = join(homedir(), '.claude', 'projects');
121
- const slug = project.replace(/[/.]/g, '-');
123
+ const slug = projectSlug(project);
122
124
  let candidates;
123
125
  try {
124
126
  candidates = readdirSync(root).filter((name) => name === slug || name.startsWith(`${slug}-`));
@@ -8,6 +8,7 @@ import { createContext } from '../../context.js';
8
8
  import { join, resolve } from 'node:path';
9
9
  import { readFileSync, statSync } from 'node:fs';
10
10
  import { resolveProject } from '../../util/project.js';
11
+ import { mentionsPath } from '../../util/paths.js';
11
12
  import { transcriptsFor } from '../../capture/index.js';
12
13
  export async function cmdInstall(scope) {
13
14
  const project = resolveProject(undefined);
@@ -158,7 +159,7 @@ function isInstalled(settingsPath) {
158
159
  }
159
160
  function fileMentions(path, needle) {
160
161
  try {
161
- return readFileSync(path, 'utf8').includes(needle);
162
+ return mentionsPath(readFileSync(path, 'utf8'), needle);
162
163
  }
163
164
  catch {
164
165
  return false;
@@ -4,6 +4,7 @@ import { execFileSync } from 'node:child_process';
4
4
  import { readJson, readText, writeAtomic, writeJson } from './files.js';
5
5
  import { removeInstructions, writeInstructions } from './instructions.js';
6
6
  import { rmSync } from 'node:fs';
7
+ import { toPosix } from '../util/paths.js';
7
8
  function writeSkill(distDir, scope, project) {
8
9
  const source = resolve(distDir, '..', 'skills', 'cdb-scan', 'SKILL.md');
9
10
  const body = readText(source);
@@ -22,7 +23,7 @@ const HOOKS = [
22
23
  ];
23
24
  export function assertStableLocation(distDir) {
24
25
  const ephemeral = ['_npx', '_cacache'];
25
- const segments = distDir.split('/');
26
+ const segments = toPosix(distDir).split('/');
26
27
  if (!ephemeral.some((name) => segments.includes(name)))
27
28
  return;
28
29
  throw new Error(`Refusing to install from a temporary location:\n ${distDir}\n\n` +
@@ -125,9 +126,9 @@ export function uninstall(distDir, scope, project) {
125
126
  return path;
126
127
  }
127
128
  function hookCommand(distDir, file) {
128
- return `node ${resolve(distDir, 'hooks', file)}`;
129
+ return `node ${toPosix(resolve(distDir, 'hooks', file))}`;
129
130
  }
130
131
  function isOurHook(command) {
131
- const path = command.replace(/\\/g, '/');
132
+ const path = toPosix(command);
132
133
  return HOOKS.some(([, file]) => path.endsWith(`/hooks/${file}`));
133
134
  }
@@ -7,6 +7,7 @@ import { createContext } from '../context.js';
7
7
  import { openWork } from '../capture/index.js';
8
8
  import { emitContext, readPayload, runHook } from './payload.js';
9
9
  import { resolveProject } from '../util/project.js';
10
+ import { mentionsPath } from '../util/paths.js';
10
11
  import { toShortId } from '../util/shortid.js';
11
12
  import { refreshInstalled } from '../cli/refresh.js';
12
13
  import { updateNotice } from '../update.js';
@@ -36,7 +37,7 @@ function refreshInstalledQuietly(project) {
36
37
  function mcpRegistered(project) {
37
38
  return [join(project, '.mcp.json'), join(homedir(), '.claude.json')].some((path) => {
38
39
  try {
39
- return readFileSync(path, 'utf8').includes(SERVER);
40
+ return mentionsPath(readFileSync(path, 'utf8'), SERVER);
40
41
  }
41
42
  catch {
42
43
  return false;
@@ -0,0 +1,2 @@
1
+ export declare function toPosix(path: string): string;
2
+ export declare function mentionsPath(text: string, needle: string): boolean;
@@ -0,0 +1,7 @@
1
+ export function toPosix(path) {
2
+ return path.replace(/\\/g, '/');
3
+ }
4
+ export function mentionsPath(text, needle) {
5
+ const flatten = (value) => toPosix(value).replace(/\/+/g, '/');
6
+ return flatten(text).includes(flatten(needle));
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-db",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Persistent memory for Claude Code. Captures why decisions were made, not just which files changed. Bring your own database: SQLite, MongoDB or Postgres. No cloud, no subscription.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",