claude-db 0.10.2 → 0.11.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 (96) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +2 -1
  3. package/dist/catchup/gather.d.ts +17 -0
  4. package/dist/catchup/gather.js +39 -0
  5. package/dist/catchup/git-state.d.ts +7 -0
  6. package/dist/catchup/git-state.js +32 -0
  7. package/dist/catchup/render.d.ts +3 -0
  8. package/dist/catchup/render.js +41 -0
  9. package/dist/cli/backfill-output.d.ts +13 -0
  10. package/dist/cli/backfill-output.js +78 -0
  11. package/dist/cli/commands/catchup.d.ts +1 -0
  12. package/dist/cli/commands/catchup.js +14 -0
  13. package/dist/cli/commands/distill.js +13 -2
  14. package/dist/cli/commands/doctor.d.ts +2 -0
  15. package/dist/cli/commands/doctor.js +42 -3
  16. package/dist/cli/commands/insight.js +2 -1
  17. package/dist/cli/commands/setup.js +29 -9
  18. package/dist/cli/index.js +9 -0
  19. package/dist/cli/install.d.ts +6 -1
  20. package/dist/cli/install.js +8 -18
  21. package/dist/cli/paths.d.ts +1 -1
  22. package/dist/cli/paths.js +2 -2
  23. package/dist/cli/refresh.js +4 -12
  24. package/dist/cli/skills.d.ts +17 -0
  25. package/dist/cli/skills.js +65 -0
  26. package/dist/cli/usage.js +2 -0
  27. package/dist/config/schema.d.ts +3 -0
  28. package/dist/config/schema.js +8 -0
  29. package/dist/context.js +5 -2
  30. package/dist/facts/distill.d.ts +16 -1
  31. package/dist/facts/distill.js +20 -7
  32. package/dist/facts/handoff.d.ts +6 -0
  33. package/dist/facts/handoff.js +25 -0
  34. package/dist/facts/health.d.ts +3 -0
  35. package/dist/facts/health.js +10 -0
  36. package/dist/facts/model.d.ts +1 -0
  37. package/dist/facts/model.js +12 -0
  38. package/dist/facts/start.js +16 -5
  39. package/dist/hooks/payload.js +2 -0
  40. package/dist/store/adapter.d.ts +4 -2
  41. package/dist/store/adapter.js +1 -1
  42. package/dist/store/mongo/docs.d.ts +6 -0
  43. package/dist/store/mongo/filters.d.ts +2 -1
  44. package/dist/store/mongo/filters.js +9 -2
  45. package/dist/store/mongo/index.d.ts +5 -2
  46. package/dist/store/mongo/index.js +13 -2
  47. package/dist/store/mongo/observations.js +9 -5
  48. package/dist/store/mongo/project-links.d.ts +4 -0
  49. package/dist/store/mongo/project-links.js +13 -0
  50. package/dist/store/mongo/search.js +3 -0
  51. package/dist/store/mongo/sessions.d.ts +2 -2
  52. package/dist/store/mongo/sessions.js +5 -1
  53. package/dist/store/mongo/vectorSearch.js +3 -0
  54. package/dist/store/postgres/filters.d.ts +2 -1
  55. package/dist/store/postgres/filters.js +11 -4
  56. package/dist/store/postgres/index.d.ts +4 -2
  57. package/dist/store/postgres/index.js +7 -0
  58. package/dist/store/postgres/observations.js +15 -10
  59. package/dist/store/postgres/project-links.d.ts +3 -0
  60. package/dist/store/postgres/project-links.js +15 -0
  61. package/dist/store/postgres/schema.d.ts +2 -2
  62. package/dist/store/postgres/schema.js +9 -1
  63. package/dist/store/postgres/search.js +3 -0
  64. package/dist/store/postgres/sessions.d.ts +2 -2
  65. package/dist/store/postgres/sessions.js +9 -2
  66. package/dist/store/postgres/vectorSearch.js +3 -0
  67. package/dist/store/project-resolver.d.ts +16 -0
  68. package/dist/store/project-resolver.js +49 -0
  69. package/dist/store/project-scope.d.ts +5 -0
  70. package/dist/store/project-scope.js +16 -0
  71. package/dist/store/scoped-store.d.ts +3 -0
  72. package/dist/store/scoped-store.js +49 -0
  73. package/dist/store/sqlite/filters.d.ts +3 -2
  74. package/dist/store/sqlite/filters.js +23 -9
  75. package/dist/store/sqlite/index.d.ts +4 -2
  76. package/dist/store/sqlite/index.js +7 -0
  77. package/dist/store/sqlite/observations.js +13 -7
  78. package/dist/store/sqlite/project-links.d.ts +3 -0
  79. package/dist/store/sqlite/project-links.js +15 -0
  80. package/dist/store/sqlite/schema.sql +9 -0
  81. package/dist/store/sqlite/search.js +5 -0
  82. package/dist/store/sqlite/sessions.d.ts +2 -2
  83. package/dist/store/sqlite/sessions.js +8 -2
  84. package/dist/types.d.ts +4 -3
  85. package/dist/util/claude-binary.d.ts +23 -0
  86. package/dist/util/claude-binary.js +106 -0
  87. package/dist/util/claude-cli.d.ts +0 -1
  88. package/dist/util/claude-cli.js +2 -4
  89. package/dist/util/project-key.d.ts +7 -0
  90. package/dist/util/project-key.js +23 -0
  91. package/dist/util/remote-key.d.ts +3 -0
  92. package/dist/util/remote-key.js +50 -0
  93. package/docs/setup-guide.md +21 -13
  94. package/package.json +1 -1
  95. package/skills/catchup/SKILL.md +44 -0
  96. package/skills/handoff/SKILL.md +62 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Added
6
+
7
+ - **Projects are matched by git remote.** A repository with an `origin` remote is now one project wherever
8
+ it is cloned, so a laptop and a Mac share memory when they use the same Postgres or MongoDB database.
9
+ The `ssh` and `https` addresses of one repository match. Any token in the address is dropped and never
10
+ stored. A folder with no remote is matched by its path, as before. A fork has its own remote, so it is
11
+ its own project. The new setting `project.remote` picks another remote than `origin`. Memory saved before
12
+ this, under a folder path, is still found and is not moved. A second machine needs this version to share
13
+ notes by remote. A machine still on 0.10.x keeps working on the same database but does not see notes
14
+ saved by remote, so update every machine that shares a database. Each folder links itself to its remote
15
+ the first time you use 0.11.0 in it, and notes saved under that folder's path are found by other machines
16
+ from then on. Postgres moves to schema version 5 on first use and adds one table, `project_links`.
17
+ MongoDB gets the same collection.
18
+ - **`/catchup` and `/handoff` skills.** `/catchup` says where you stopped, in three groups: done, open and
19
+ next, from the last chat, the recorded to-dos, the last handoff and git. `/handoff` writes the same three
20
+ lines, saves them as the project's current handoff, and prints them. The next chat sees the handoff at the
21
+ start for 14 days. `claude-db catchup` prints the facts both skills use. If you already have a skill with
22
+ one of these names, claude-db keeps yours and says so.
23
+ - **`claude-db --version` and `-v`.**
24
+ - **`doctor` shows which `claude` it found and where from**, for example `from saved path`. With no
25
+ `claude` it says so and how to fix it. `doctor --deep` also makes one small real Haiku call. `doctor` lists
26
+ the installed skills.
27
+ - **`status` warns when chats have waited over a day** and no fact-making call was tried.
28
+
29
+ ### Changed
30
+
31
+ - **`distill --backfill` shows progress.** It says how many chats are waiting, shows a spinner on a terminal,
32
+ prints one line per finished chat, and ends with the reason if it stops. A pipe or a file gets plain lines.
33
+ - **A session start shows the newest handoff** with its done, open and next lines.
34
+ - **`status` and `projects` count notes saved by another clone** of the same repository as this project's.
35
+ A fact saved by two clones is shown once.
36
+
37
+ ### Fixed
38
+
39
+ - On macOS, a `claude` found by name only could be saved as the useless path `claude`. A bare name is now
40
+ left to the `PATH` search.
41
+
42
+ ## 0.10.3
43
+
44
+ ### Fixed
45
+
46
+ - **Picks and facts can now find Claude when `claude` is not on `PATH`.** Both call
47
+ Claude through its binary. Claude Code does not pass that path to its hooks, so
48
+ on a machine where `claude` is not on `PATH`, for example when Claude Code runs
49
+ inside an editor, every call failed with `claude was not found`, and the feature
50
+ paused. Each hook now looks up the Claude process that started it and saves
51
+ its path in `~/.claude-memory/claude-binary`. Background jobs and commands run
52
+ in a terminal use that path when `CLAUDE_CODE_EXECPATH` is not set. A saved path
53
+ that no longer exists, for example after an editor update, is replaced by the
54
+ next hook run. Linux and macOS only.
55
+
3
56
  ## 0.10.2
4
57
 
5
58
  ### Changed
package/README.md CHANGED
@@ -51,7 +51,8 @@ machine.
51
51
 
52
52
  A fresh install has no history yet. `claude-db scan` builds the code graph, and
53
53
  the `/cdb-scan` skill maps an existing codebase into memory, so search has
54
- something to find on day one. The [setup guide](./docs/setup-guide.md) covers
54
+ something to find on day one. `/catchup` answers "where did I stop?" and `/handoff` leaves a note for the
55
+ next chat. The [setup guide](./docs/setup-guide.md) covers
55
56
  the settings and habits that give the best results.
56
57
 
57
58
  ## Commands
@@ -0,0 +1,17 @@
1
+ import type { RecallContext } from '../context.js';
2
+ import type { GitState } from './git-state.js';
3
+ export interface CatchupData {
4
+ handoff: {
5
+ at: number;
6
+ lines: string[];
7
+ } | null;
8
+ lastChat: {
9
+ at: number;
10
+ summary: string;
11
+ work: string[];
12
+ } | null;
13
+ todos: string[];
14
+ uncommitted: string[];
15
+ git: GitState | null;
16
+ }
17
+ export declare function gatherCatchup(ctx: RecallContext, project: string, now?: number): Promise<CatchupData>;
@@ -0,0 +1,39 @@
1
+ import { openWork } from '../capture/progress.js';
2
+ import { FACT_SESSION, factType, onePerKey } from '../facts/model.js';
3
+ import { handoffBodyLines, newestHandoff } from '../facts/handoff.js';
4
+ import { readGitState } from './git-state.js';
5
+ const CHAT_TITLES = 6;
6
+ const TODOS = 5;
7
+ const UNCOMMITTED = 5;
8
+ const FACTS_SCANNED = 100;
9
+ export async function gatherCatchup(ctx, project, now = Date.now()) {
10
+ const handoff = await newestHandoff(ctx, project, now);
11
+ const [latest] = await ctx.store.recentSessions(project, 1);
12
+ const chatWork = latest
13
+ ? (await ctx.store.list({ project, sessionId: latest.id, newest: true, limit: CHAT_TITLES }))
14
+ .filter((obs) => obs.status !== 'replaced')
15
+ .map((obs) => obs.title)
16
+ : [];
17
+ const facts = await ctx.store.list({
18
+ project,
19
+ sessionId: FACT_SESSION,
20
+ newest: true,
21
+ limit: FACTS_SCANNED,
22
+ });
23
+ const todos = onePerKey(facts.filter((obs) => obs.status !== 'replaced'))
24
+ .filter((obs) => factType(obs) === 'todo')
25
+ .slice(0, TODOS)
26
+ .map((obs) => obs.title);
27
+ const uncommitted = (await openWork(ctx.store, project))
28
+ .slice(0, UNCOMMITTED)
29
+ .map((obs) => obs.title);
30
+ return {
31
+ handoff: handoff ? { at: handoff.createdAt, lines: handoffBodyLines(handoff) } : null,
32
+ lastChat: latest
33
+ ? { at: latest.startedAt, summary: latest.summary ?? '', work: chatWork }
34
+ : null,
35
+ todos,
36
+ uncommitted,
37
+ git: readGitState(project),
38
+ };
39
+ }
@@ -0,0 +1,7 @@
1
+ export interface GitState {
2
+ status: string[];
3
+ hiddenStatusLines: number;
4
+ commits: string[];
5
+ }
6
+ export type GitRunner = (args: string[]) => string;
7
+ export declare function readGitState(project: string, git?: GitRunner): GitState | null;
@@ -0,0 +1,32 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { redact } from '../capture/redact.js';
3
+ const GIT_TIMEOUT_MS = 5000;
4
+ const STATUS_LINES = 15;
5
+ const RECENT_COMMITS = 5;
6
+ function runGit(project) {
7
+ return (args) => execFileSync('git', ['-C', project, ...args], {
8
+ encoding: 'utf8',
9
+ stdio: ['ignore', 'pipe', 'ignore'],
10
+ timeout: GIT_TIMEOUT_MS,
11
+ });
12
+ }
13
+ function lines(text) {
14
+ return text
15
+ .split('\n')
16
+ .map((line) => line.trimEnd())
17
+ .filter((line) => line.length > 0);
18
+ }
19
+ export function readGitState(project, git = runGit(project)) {
20
+ try {
21
+ const status = lines(git(['status', '--short']));
22
+ const commits = lines(git(['log', `-n${RECENT_COMMITS}`, '--pretty=format:%h %s'])).map(redact);
23
+ return {
24
+ status: status.slice(0, STATUS_LINES),
25
+ hiddenStatusLines: Math.max(0, status.length - STATUS_LINES),
26
+ commits,
27
+ };
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ }
@@ -0,0 +1,3 @@
1
+ import type { CatchupData } from './gather.js';
2
+ export declare const NOTHING_RECORDED = "Nothing recorded for this project yet.";
3
+ export declare function renderCatchup(data: CatchupData, now?: number): string;
@@ -0,0 +1,41 @@
1
+ import { formatDay } from '../util/day.js';
2
+ export const NOTHING_RECORDED = 'Nothing recorded for this project yet.';
3
+ function section(heading, lines) {
4
+ return lines.length === 0 ? [] : [heading, ...lines, ''];
5
+ }
6
+ function bullets(items) {
7
+ return items.map((item) => ` - ${item}`);
8
+ }
9
+ function gitLines(data) {
10
+ const git = data.git;
11
+ if (!git)
12
+ return { status: [], commits: [] };
13
+ const hidden = git.hiddenStatusLines > 0 ? [` ...and ${git.hiddenStatusLines} more`] : [];
14
+ return {
15
+ status: [...git.status.map((line) => ` ${line}`), ...hidden],
16
+ commits: git.commits.map((line) => ` ${line}`),
17
+ };
18
+ }
19
+ function chatBlock(chat, now) {
20
+ if (!chat)
21
+ return [];
22
+ const heading = `Last chat (${formatDay(chat.at, now)}): ${chat.summary || 'no summary'}`;
23
+ return [heading, ...bullets(chat.work), ''];
24
+ }
25
+ function handoffBlock(handoff, now) {
26
+ if (!handoff)
27
+ return [];
28
+ return section(`Last handoff (${formatDay(handoff.at, now)}):`, handoff.lines.map((line) => ` ${line}`));
29
+ }
30
+ export function renderCatchup(data, now = Date.now()) {
31
+ const { status, commits } = gitLines(data);
32
+ const blocks = [
33
+ ...handoffBlock(data.handoff, now),
34
+ ...chatBlock(data.lastChat, now),
35
+ ...section('Still to do (from facts):', bullets(data.todos)),
36
+ ...section('Not committed yet (recorded work):', bullets(data.uncommitted)),
37
+ ...section('Git status:', status),
38
+ ...section('Recent commits:', commits),
39
+ ];
40
+ return blocks.length === 0 ? NOTHING_RECORDED : blocks.join('\n').trimEnd();
41
+ }
@@ -0,0 +1,13 @@
1
+ import type { BackfillResult, BackfillStep } from '../facts/distill.js';
2
+ import type { BudgetUsage } from '../util/daily-budget.js';
3
+ export interface BackfillPrinterOptions {
4
+ write: (text: string) => void;
5
+ tty: boolean;
6
+ every?: (tick: () => void, ms: number) => () => void;
7
+ }
8
+ export interface BackfillPrinter {
9
+ step: (step: BackfillStep) => void;
10
+ finish: (result: BackfillResult, usage: BudgetUsage, dailyLimit: number) => void;
11
+ }
12
+ export declare function stopLine(result: BackfillResult, usage: BudgetUsage, dailyLimit: number): string;
13
+ export declare function createBackfillPrinter(options: BackfillPrinterOptions): BackfillPrinter;
@@ -0,0 +1,78 @@
1
+ import { describePause } from '../util/daily-budget.js';
2
+ const FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
3
+ const FRAME_MS = 120;
4
+ const CLEAR_LINE = '\r\u001b[K';
5
+ function everyInterval(tick, ms) {
6
+ const timer = setInterval(tick, ms);
7
+ timer.unref();
8
+ return () => clearInterval(timer);
9
+ }
10
+ export function stopLine(result, usage, dailyLimit) {
11
+ const left = `${result.remaining} chat(s) still waiting`;
12
+ if (result.stopped === 'failed') {
13
+ const reason = usage.lastFailure?.reason ?? 'the call failed';
14
+ return `stopped : a Haiku call failed (${reason}), ${left}`;
15
+ }
16
+ const pause = describePause(usage);
17
+ const why = pause ? `paused ${pause}` : `the daily limit of ${dailyLimit} calls is used up`;
18
+ return `stopped : ${why}, ${left}`;
19
+ }
20
+ function factsMade(count) {
21
+ return `${count} ${count === 1 ? 'fact' : 'facts'} made`;
22
+ }
23
+ function headerLine(total) {
24
+ if (total === 0)
25
+ return 'nothing waiting: every recent chat is already turned into facts\n';
26
+ return `${total} chat(s) waiting. This can take a few minutes, each chat needs one or more Haiku calls.\n`;
27
+ }
28
+ function progressLine(step) {
29
+ return `${step.index} of ${step.total} chats, ${factsMade(step.facts)}\n`;
30
+ }
31
+ function closingLine(result, usage, dailyLimit) {
32
+ if (result.stopped !== 'done')
33
+ return `${stopLine(result, usage, dailyLimit)}\n`;
34
+ if (result.distilled === 0)
35
+ return '';
36
+ return `done : ${result.distilled} chat(s) turned into ${result.facts} fact(s)\n`;
37
+ }
38
+ export function createBackfillPrinter(options) {
39
+ const { write, tty, every = everyInterval } = options;
40
+ let stopSpinner = null;
41
+ const clearSpinner = () => {
42
+ if (!stopSpinner)
43
+ return;
44
+ stopSpinner();
45
+ stopSpinner = null;
46
+ write(CLEAR_LINE);
47
+ };
48
+ const startSpinner = (label) => {
49
+ let frame = 0;
50
+ const draw = () => {
51
+ write(`${CLEAR_LINE}${FRAMES[frame % FRAMES.length]} ${label}`);
52
+ frame += 1;
53
+ };
54
+ draw();
55
+ stopSpinner = every(draw, FRAME_MS);
56
+ };
57
+ return {
58
+ step(step) {
59
+ switch (step.kind) {
60
+ case 'begin':
61
+ write(headerLine(step.total));
62
+ return;
63
+ case 'start':
64
+ if (tty)
65
+ startSpinner(`chat ${step.index} of ${step.total}`);
66
+ return;
67
+ case 'done':
68
+ clearSpinner();
69
+ write(progressLine(step));
70
+ return;
71
+ }
72
+ },
73
+ finish(result, usage, dailyLimit) {
74
+ clearSpinner();
75
+ write(closingLine(result, usage, dailyLimit));
76
+ },
77
+ };
78
+ }
@@ -0,0 +1 @@
1
+ export declare function cmdCatchup(): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import { gatherCatchup } from '../../catchup/gather.js';
2
+ import { renderCatchup } from '../../catchup/render.js';
3
+ import { createContext } from '../../context.js';
4
+ import { resolveProject } from '../../util/project.js';
5
+ export async function cmdCatchup() {
6
+ const project = resolveProject(undefined);
7
+ const ctx = await createContext();
8
+ try {
9
+ console.log(renderCatchup(await gatherCatchup(ctx, project)));
10
+ }
11
+ finally {
12
+ await ctx.close();
13
+ }
14
+ }
@@ -1,8 +1,10 @@
1
1
  import { setConfigValue } from '../../config/index.js';
2
+ import { createBackfillPrinter } from '../backfill-output.js';
2
3
  import { createContext } from '../../context.js';
3
4
  import { distillUsage } from '../../facts/budget.js';
4
5
  import { importClaudeMemory } from '../../facts/claude-memory.js';
5
6
  import { FACTS_JOB, backfill, distillSession, factCounts, pendingSessions, } from '../../facts/distill.js';
7
+ import { runHeadlessResult } from '../../util/claude-cli.js';
6
8
  import { describePause } from '../../util/daily-budget.js';
7
9
  import { finishJob, releaseJob } from '../../util/job-lock.js';
8
10
  import { resolveProject } from '../../util/project.js';
@@ -39,8 +41,17 @@ async function runBackfill(project) {
39
41
  const ctx = await createContext();
40
42
  try {
41
43
  await importClaudeMemory(ctx, project);
42
- if (ctx.config.distill.enabled)
43
- await backfill(ctx, project);
44
+ if (ctx.config.distill.enabled) {
45
+ const printer = createBackfillPrinter({
46
+ write: (text) => process.stdout.write(text),
47
+ tty: process.stdout.isTTY === true,
48
+ });
49
+ const result = await backfill(ctx, project, runHeadlessResult, printer.step);
50
+ printer.finish(result, distillUsage(), ctx.config.distill.dailyLimit);
51
+ }
52
+ else {
53
+ console.log('distill : off, so no chats were turned into facts (claude-db distill on)');
54
+ }
44
55
  }
45
56
  finally {
46
57
  await ctx.close();
@@ -1 +1,3 @@
1
+ import type { ClaudeLocation } from '../../util/claude-binary.js';
1
2
  export declare function cmdDoctor(argv: (string | undefined)[]): Promise<void>;
3
+ export declare function describeClaude(location: ClaudeLocation | null): string;
@@ -8,6 +8,12 @@ import { ourHookFile } from '../install.js';
8
8
  import { settingsPathFor } from '../paths.js';
9
9
  import { existsSync, readFileSync } from 'node:fs';
10
10
  import { toShortId } from '../../util/shortid.js';
11
+ import { resolveClaude } from '../../util/claude-binary.js';
12
+ import { runHeadlessResult } from '../../util/claude-cli.js';
13
+ import { describeSkills } from '../skills.js';
14
+ const HAIKU_PROBE_PROMPT = 'Reply with the single word: ok';
15
+ const HAIKU_PROBE_TIMEOUT_MS = 60_000;
16
+ const REPLY_PREVIEW_CHARS = 40;
11
17
  export async function cmdDoctor(argv) {
12
18
  const base = loadConfig();
13
19
  const ctx = await createContext({
@@ -28,10 +34,43 @@ export async function cmdDoctor(argv) {
28
34
  console.log('hint : builtin embeddings are keyword-grade. For semantic vectors:');
29
35
  console.log(' npm i -g @xenova/transformers && claude-db reembed');
30
36
  }
31
- checkWiring(resolveProject(undefined));
32
- const healthy = argv.includes('--deep') ? await deepCheck(ctx) : true;
37
+ const project = resolveProject(undefined);
38
+ checkWiring(project);
39
+ console.log(describeSkills(project));
40
+ const claude = resolveClaude();
41
+ console.log(describeClaude(claude));
42
+ const deepOk = argv.includes('--deep') ? await runDeepChecks(ctx, claude) : true;
33
43
  await ctx.close();
34
- process.exit(reachable && healthy ? 0 : 1);
44
+ process.exit(reachable && deepOk ? 0 : 1);
45
+ }
46
+ async function runDeepChecks(ctx, claude) {
47
+ const storeOk = await deepCheck(ctx);
48
+ const haikuOk = await haikuCheck(ctx, claude);
49
+ return storeOk && haikuOk;
50
+ }
51
+ export function describeClaude(location) {
52
+ if (location)
53
+ return `claude : ${location.path} (from ${location.source})`;
54
+ return [
55
+ 'claude : NOT FOUND, so facts and picks cannot run',
56
+ ' fix: put claude on PATH, or set CLAUDE_CODE_EXECPATH to its full path',
57
+ ].join('\n');
58
+ }
59
+ async function haikuCheck(ctx, claude) {
60
+ const model = ctx.config.distill.model;
61
+ console.log(`\nhaiku check (one small ${model} call, not counted against the daily limits)`);
62
+ if (!claude) {
63
+ console.log(' FAIL call — claude was not found');
64
+ return false;
65
+ }
66
+ const result = await runHeadlessResult(HAIKU_PROBE_PROMPT, model, HAIKU_PROBE_TIMEOUT_MS);
67
+ if (!result.ok) {
68
+ console.log(` FAIL call — ${result.reason}`);
69
+ return false;
70
+ }
71
+ const reply = result.stdout.trim().slice(0, REPLY_PREVIEW_CHARS);
72
+ console.log(` ok call — ${reply || 'empty reply'}`);
73
+ return true;
35
74
  }
36
75
  function checkWiring(project) {
37
76
  const problems = [];
@@ -66,8 +66,9 @@ export async function cmdProjects() {
66
66
  return;
67
67
  }
68
68
  console.log(`database: ${redact(ctx.config.database)}\n`);
69
+ const names = await ctx.store.projectScope(here);
69
70
  for (const entry of projects) {
70
- const marker = entry.project === here ? '*' : ' ';
71
+ const marker = names.includes(entry.project) ? '*' : ' ';
71
72
  const date = new Date(entry.lastActive).toISOString().slice(0, 10);
72
73
  console.log(`${marker} ${String(entry.observations).padStart(5)} ${date} ${entry.project}`);
73
74
  }
@@ -3,15 +3,26 @@ import { closeLandedWork, openWork, redact } from '../../capture/index.js';
3
3
  import { CONFIG_PATH } from '../../config/index.js';
4
4
  import { DIST_DIR } from '../constants.js';
5
5
  import { assertStableLocation, install, uninstall } from '../install.js';
6
- import { instructionsPathFor, mcpPathFor, settingsPathFor, skillPathFor } from '../paths.js';
6
+ import { instructionsPathFor, mcpPathFor, settingsPathFor } from '../paths.js';
7
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
11
  import { mentionsPath } from '../../util/paths.js';
12
12
  import { transcriptsFor } from '../../capture/index.js';
13
- import { factCounts, pendingSessions } from '../../facts/distill.js';
13
+ import { factCounts, oldestPendingAt, pendingSessions } from '../../facts/distill.js';
14
+ import { distillUsage } from '../../facts/budget.js';
15
+ import { waitingWarning } from '../../facts/health.js';
14
16
  import { pickStatus } from './pick.js';
17
+ function printSkills(results) {
18
+ for (const { name, path, outcome } of results) {
19
+ if (outcome === 'written')
20
+ console.log(`Skill : ${path} (/${name})`);
21
+ if (outcome === 'kept-yours') {
22
+ console.log(`Skill : /${name} not installed, you already have your own at ${path}`);
23
+ }
24
+ }
25
+ }
15
26
  export async function cmdInstall(scope) {
16
27
  const project = resolveProject(undefined);
17
28
  try {
@@ -21,14 +32,14 @@ export async function cmdInstall(scope) {
21
32
  console.error(error instanceof Error ? error.message : String(error));
22
33
  process.exit(1);
23
34
  }
24
- const settingsPath = install(DIST_DIR, scope, project);
35
+ const { settingsPath, skills } = install(DIST_DIR, scope, project);
25
36
  const ctx = await createContext();
26
37
  const embedder = await ctx.embedder();
27
38
  await ctx.close();
28
39
  console.log(`Scope : ${scope === 'project' ? `this project only (${project})` : 'all projects on this machine'}`);
29
40
  console.log(`Settings : ${settingsPath}`);
30
41
  console.log(`Guidance : ${instructionsPathFor(scope, project)}`);
31
- console.log(`Skill : ${skillPathFor(scope, project)} (/cdb-scan)`);
42
+ printSkills(skills);
32
43
  console.log(`Config : ${CONFIG_PATH}`);
33
44
  console.log(`Database : ${redact(ctx.config.database)}`);
34
45
  if (embedder.id === 'builtin-hashing') {
@@ -92,16 +103,25 @@ export async function cmdStatus() {
92
103
  const mcpFile = [mcpPathFor('project', project), mcpPathFor('global', project)].find((candidate) => fileMentions(candidate, resolve(DIST_DIR, 'mcp', 'server.js')));
93
104
  console.log(`mcp : ${mcpFile ? `registered (${mcpFile})` : 'NOT REGISTERED'}`);
94
105
  console.log(`sessions : ${sessions.length} recorded for this project`);
95
- const saved = (await ctx.store.listProjects()).find((entry) => entry.project === project);
96
- const lastSaved = saved?.lastActive ?? 0;
106
+ const names = await ctx.store.projectScope(project);
107
+ const lastSaved = Math.max(0, ...(await ctx.store.listProjects())
108
+ .filter((entry) => names.includes(entry.project))
109
+ .map((entry) => entry.lastActive));
97
110
  const worked = workedAt(project);
98
111
  console.log(`worked : ${worked.last > 0 ? ago(worked.last) : 'never'}`);
99
112
  console.log(`recorded : ${lastSaved > 0 ? ago(lastSaved) : 'never'}`);
100
113
  const facts = await factCounts(ctx, project);
101
114
  console.log(`facts : ${facts.project} for this project, ${facts.you} about you`);
102
- console.log(ctx.config.distill.enabled
103
- ? `waiting : ${(await pendingSessions(ctx, project)).length} chat(s) not yet turned into facts`
104
- : 'distill : off, so chats are not turned into facts (claude-db distill on)');
115
+ if (ctx.config.distill.enabled) {
116
+ const waiting = (await pendingSessions(ctx, project)).length;
117
+ console.log(`waiting : ${waiting} chat(s) not yet turned into facts`);
118
+ const warning = waitingWarning(waiting, await oldestPendingAt(ctx, project), distillUsage());
119
+ if (warning)
120
+ console.log(warning);
121
+ }
122
+ else {
123
+ console.log('distill : off, so chats are not turned into facts (claude-db distill on)');
124
+ }
105
125
  console.log(pickStatus(ctx.config));
106
126
  await closeLandedWork(ctx.store, project);
107
127
  const open = await openWork(ctx.store, project);
package/dist/cli/index.js CHANGED
@@ -9,6 +9,7 @@ import { cmdForget, cmdRemember, cmdSearch } from './commands/memory.js';
9
9
  import { cmdExport, cmdImport, cmdPrune, cmdReembed } from './commands/transfer.js';
10
10
  import { cmdMerge, cmdProjects, cmdStats } from './commands/insight.js';
11
11
  import { cmdFlush, cmdRedact, cmdReset, cmdUpdate } from './commands/maintain.js';
12
+ import { cmdCatchup } from './commands/catchup.js';
12
13
  import { cmdDistill } from './commands/distill.js';
13
14
  import { cmdPick } from './commands/pick.js';
14
15
  import { cmdScan, cmdUsages } from './commands/graph.js';
@@ -16,6 +17,7 @@ import { cmdSeed } from './commands/seed.js';
16
17
  import { cmdAdoption } from './commands/adoption.js';
17
18
  import { cmdView } from './commands/view.js';
18
19
  import { silenceSqliteWarning } from '../util/warnings.js';
20
+ import { packageVersion } from '../update.js';
19
21
  silenceSqliteWarning();
20
22
  const [command, ...args] = process.argv.slice(2);
21
23
  try {
@@ -75,6 +77,9 @@ async function run() {
75
77
  case 'update':
76
78
  await cmdUpdate(args);
77
79
  break;
80
+ case 'catchup':
81
+ await cmdCatchup();
82
+ break;
78
83
  case 'distill':
79
84
  await cmdDistill(args);
80
85
  break;
@@ -108,6 +113,10 @@ async function run() {
108
113
  case 'sync':
109
114
  await cmdSync(args);
110
115
  break;
116
+ case '--version':
117
+ case '-v':
118
+ console.log(packageVersion());
119
+ break;
111
120
  default:
112
121
  usage();
113
122
  }
@@ -1,6 +1,11 @@
1
1
  import { Scope } from './paths.js';
2
+ import type { SkillInstallResult } from './skills.js';
2
3
  export declare function assertStableLocation(distDir: string): void;
3
4
  export declare function refreshHooks(distDir: string, path: string): boolean;
4
- export declare function install(distDir: string, scope: Scope, project: string): string;
5
+ export interface InstallResult {
6
+ settingsPath: string;
7
+ skills: SkillInstallResult[];
8
+ }
9
+ export declare function install(distDir: string, scope: Scope, project: string): InstallResult;
5
10
  export declare function uninstall(distDir: string, scope: Scope, project: string): string | null;
6
11
  export declare function ourHookFile(command: string): string | null;
@@ -1,20 +1,10 @@
1
- import { instructionsPathFor, mcpPathFor, settingsPathFor, skillPathFor } from './paths.js';
2
- import { dirname, resolve } from 'node:path';
1
+ import { instructionsPathFor, mcpPathFor, settingsPathFor } from './paths.js';
2
+ import { installSkills, removeSkills } from './skills.js';
3
+ import { resolve } from 'node:path';
3
4
  import { execFileSync } from 'node:child_process';
4
- import { readJson, readText, writeAtomic, writeJson } from './files.js';
5
+ import { readJson, writeJson } from './files.js';
5
6
  import { removeInstructions, writeInstructions } from './instructions.js';
6
- import { rmSync } from 'node:fs';
7
7
  import { toPosix } from '../util/paths.js';
8
- function writeSkill(distDir, scope, project) {
9
- const source = resolve(distDir, '..', 'skills', 'cdb-scan', 'SKILL.md');
10
- const body = readText(source);
11
- if (body.length > 0)
12
- writeAtomic(skillPathFor(scope, project), body);
13
- }
14
- function removeSkill(scope, project) {
15
- const path = skillPathFor(scope, project);
16
- rmSync(dirname(path), { recursive: true, force: true });
17
- }
18
8
  const HOOKS = [
19
9
  ['SessionStart', 'session-start.js'],
20
10
  ['UserPromptSubmit', 'user-prompt.js'],
@@ -85,16 +75,16 @@ export function install(distDir, scope, project) {
85
75
  writeJson(path, settings);
86
76
  const server = resolve(distDir, 'mcp', 'server.js');
87
77
  writeInstructions(instructionsPathFor(scope, project));
88
- writeSkill(distDir, scope, project);
78
+ const skills = installSkills(distDir, scope, project);
89
79
  if (scope === 'global' && registerViaCli(server))
90
- return path;
80
+ return { settingsPath: path, skills };
91
81
  const mcpPath = mcpPathFor(scope, project);
92
82
  const mcpConfig = readJson(mcpPath);
93
83
  const servers = (mcpConfig['mcpServers'] ?? {});
94
84
  servers['memory'] = { command: 'node', args: [server] };
95
85
  mcpConfig['mcpServers'] = servers;
96
86
  writeJson(mcpPath, mcpConfig);
97
- return path;
87
+ return { settingsPath: path, skills };
98
88
  }
99
89
  function claudeMcp(args) {
100
90
  try {
@@ -128,7 +118,7 @@ export function uninstall(distDir, scope, project) {
128
118
  delete settings['hooks'];
129
119
  writeJson(path, settings);
130
120
  removeInstructions(instructionsPathFor(scope, project));
131
- removeSkill(scope, project);
121
+ removeSkills(scope, project);
132
122
  if (scope === 'global' && claudeMcp(['mcp', 'remove', 'memory', '-s', 'user'])) {
133
123
  return path;
134
124
  }
@@ -1,5 +1,5 @@
1
1
  export type Scope = 'global' | 'project';
2
2
  export declare function settingsPathFor(scope: Scope, project: string): string;
3
3
  export declare function instructionsPathFor(scope: Scope, project: string): string;
4
- export declare function skillPathFor(scope: Scope, project: string): string;
4
+ export declare function skillPathFor(scope: Scope, project: string, name?: string): string;
5
5
  export declare function mcpPathFor(scope: Scope, project: string): string;
package/dist/cli/paths.js CHANGED
@@ -10,9 +10,9 @@ export function instructionsPathFor(scope, project) {
10
10
  ? join(project, 'CLAUDE.local.md')
11
11
  : join(homedir(), '.claude', 'CLAUDE.md');
12
12
  }
13
- export function skillPathFor(scope, project) {
13
+ export function skillPathFor(scope, project, name = 'cdb-scan') {
14
14
  const root = scope === 'project' ? join(project, '.claude') : join(homedir(), '.claude');
15
- return join(root, 'skills', 'cdb-scan', 'SKILL.md');
15
+ return join(root, 'skills', name, 'SKILL.md');
16
16
  }
17
17
  export function mcpPathFor(scope, project) {
18
18
  return scope === 'project' ? join(project, '.mcp.json') : join(homedir(), '.claude.json');