claude-db 0.12.4 → 0.14.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/CHANGELOG.md +93 -0
- package/dist/capture/cursors.d.ts +6 -0
- package/dist/capture/cursors.js +80 -0
- package/dist/capture/flush.d.ts +1 -3
- package/dist/capture/flush.js +35 -96
- package/dist/capture/index.d.ts +3 -3
- package/dist/capture/index.js +3 -3
- package/dist/capture/progress.js +4 -2
- package/dist/capture/reingest.d.ts +1 -0
- package/dist/capture/reingest.js +4 -1
- package/dist/capture/scrub.d.ts +1 -0
- package/dist/capture/scrub.js +4 -1
- package/dist/capture/transcript.d.ts +1 -1
- package/dist/capture/transcript.js +6 -6
- package/dist/capture/vectors.js +2 -1
- package/dist/catchup/gather.js +1 -1
- package/dist/cli/commands/catchup.js +2 -1
- package/dist/cli/commands/daemon.d.ts +1 -0
- package/dist/cli/commands/daemon.js +29 -0
- package/dist/cli/commands/distill.js +2 -1
- package/dist/cli/commands/graph.js +11 -11
- package/dist/cli/commands/insight.js +10 -1
- package/dist/cli/commands/maintain.js +3 -1
- package/dist/cli/commands/memory.js +2 -1
- package/dist/cli/commands/setup.js +1 -2
- package/dist/cli/commands/sync.js +4 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/install.js +1 -2
- package/dist/cli/instructions.d.ts +1 -3
- package/dist/cli/instructions.js +5 -40
- package/dist/cli/refresh.js +2 -6
- package/dist/cli/usage.js +1 -0
- package/dist/config/load.js +2 -1
- package/dist/config/schema.d.ts +4 -2
- package/dist/config/schema.js +6 -2
- package/dist/context.d.ts +1 -0
- package/dist/context.js +30 -6
- package/dist/daemon/client.d.ts +14 -0
- package/dist/daemon/client.js +106 -0
- package/dist/daemon/paths.d.ts +18 -0
- package/dist/daemon/paths.js +19 -0
- package/dist/daemon/pid.d.ts +3 -0
- package/dist/daemon/pid.js +20 -0
- package/dist/daemon/server.d.ts +2 -0
- package/dist/daemon/server.js +227 -0
- package/dist/embed/local.js +4 -1
- package/dist/facts/budget.d.ts +1 -0
- package/dist/facts/budget.js +4 -0
- package/dist/facts/claude-memory.js +3 -3
- package/dist/facts/distill.js +2 -2
- package/dist/facts/known.js +1 -1
- package/dist/facts/last-chat.d.ts +1 -1
- package/dist/facts/last-chat.js +5 -4
- package/dist/facts/model.d.ts +1 -1
- package/dist/facts/model.js +31 -16
- package/dist/facts/start-render.d.ts +13 -0
- package/dist/facts/start-render.js +43 -0
- package/dist/facts/start.d.ts +3 -6
- package/dist/facts/start.js +33 -47
- package/dist/graph/grammars.js +2 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/index.js +1 -1
- package/dist/graph/query/index.d.ts +1 -0
- package/dist/graph/query/index.js +1 -0
- package/dist/graph/query/refresh.js +5 -1
- package/dist/graph/query/stale.js +19 -2
- package/dist/graph/query/usages.d.ts +12 -0
- package/dist/graph/query/usages.js +37 -0
- package/dist/graph/scan/cache.d.ts +1 -0
- package/dist/graph/scan/cache.js +3 -2
- package/dist/graph/scan/files.js +2 -2
- package/dist/graph/scan/persist.js +12 -16
- package/dist/hooks/compact.d.ts +3 -1
- package/dist/hooks/compact.js +4 -3
- package/dist/hooks/detached.js +2 -0
- package/dist/hooks/graph-presence.d.ts +3 -0
- package/dist/hooks/graph-presence.js +42 -0
- package/dist/hooks/grep-symbols.d.ts +3 -1
- package/dist/hooks/grep-symbols.js +41 -2
- package/dist/hooks/handlers/prefer-usages.d.ts +2 -0
- package/dist/hooks/handlers/prefer-usages.js +118 -0
- package/dist/hooks/handlers/session-end.d.ts +2 -0
- package/dist/hooks/handlers/session-end.js +60 -0
- package/dist/hooks/handlers/session-start.d.ts +2 -0
- package/dist/hooks/handlers/session-start.js +83 -0
- package/dist/hooks/handlers/turn-end.d.ts +2 -0
- package/dist/hooks/handlers/turn-end.js +31 -0
- package/dist/hooks/handlers/user-prompt.d.ts +2 -0
- package/dist/hooks/handlers/user-prompt.js +55 -0
- package/dist/hooks/local.d.ts +2 -0
- package/dist/hooks/local.js +22 -0
- package/dist/hooks/payload.d.ts +9 -4
- package/dist/hooks/payload.js +30 -20
- package/dist/hooks/pick-deliver.js +2 -1
- package/dist/hooks/prefer-usages.js +2 -118
- package/dist/hooks/prompt-recall.d.ts +4 -2
- package/dist/hooks/prompt-recall.js +10 -10
- package/dist/hooks/route.d.ts +2 -0
- package/dist/hooks/route.js +33 -0
- package/dist/hooks/run.d.ts +13 -0
- package/dist/hooks/run.js +12 -0
- package/dist/hooks/save-turn.d.ts +2 -0
- package/dist/hooks/save-turn.js +11 -0
- package/dist/hooks/session-end.js +2 -63
- package/dist/hooks/session-start.js +2 -90
- package/dist/hooks/turn-end.js +2 -25
- package/dist/hooks/turn-save.js +10 -15
- package/dist/hooks/user-prompt.js +2 -58
- package/dist/mcp/tools/ids.d.ts +3 -0
- package/dist/mcp/tools/ids.js +6 -0
- package/dist/mcp/tools/memory.js +2 -1
- package/dist/mcp/tools/observations.js +3 -2
- package/dist/mcp/tools/search.js +4 -9
- package/dist/mcp/tools/usages.js +18 -44
- package/dist/pick/worker.js +1 -2
- package/dist/search/service.d.ts +6 -0
- package/dist/search/service.js +27 -11
- package/dist/store/adapter.d.ts +7 -5
- package/dist/store/mongo/index.d.ts +3 -6
- package/dist/store/mongo/index.js +5 -0
- package/dist/store/mongo/observations.js +13 -1
- package/dist/store/postgres/driver.d.ts +10 -3
- package/dist/store/postgres/driver.js +12 -0
- package/dist/store/postgres/filters.d.ts +1 -0
- package/dist/store/postgres/filters.js +3 -0
- package/dist/store/postgres/graph.d.ts +3 -5
- package/dist/store/postgres/graph.js +59 -52
- package/dist/store/postgres/index.d.ts +3 -6
- package/dist/store/postgres/index.js +8 -5
- package/dist/store/postgres/insert.js +98 -50
- package/dist/store/postgres/meta.d.ts +1 -0
- package/dist/store/postgres/meta.js +4 -0
- package/dist/store/postgres/observations.js +3 -3
- package/dist/store/project-resolver.d.ts +4 -0
- package/dist/store/project-resolver.js +34 -23
- package/dist/store/scoped-store.js +4 -2
- package/dist/store/sqlite/filters.d.ts +1 -0
- package/dist/store/sqlite/filters.js +6 -2
- package/dist/store/sqlite/graph.d.ts +3 -5
- package/dist/store/sqlite/graph.js +45 -35
- package/dist/store/sqlite/index.d.ts +3 -6
- package/dist/store/sqlite/index.js +3 -0
- package/dist/store/sqlite/observations.js +12 -9
- package/dist/util/claude-binary.js +5 -4
- package/dist/util/claude-cli.js +2 -1
- package/dist/util/claude-dir.d.ts +2 -0
- package/dist/util/claude-dir.js +8 -0
- package/dist/util/env.d.ts +2 -0
- package/dist/util/env.js +6 -0
- package/dist/util/job-lock.d.ts +1 -0
- package/dist/util/job-lock.js +50 -10
- package/dist/util/shortid.d.ts +3 -0
- package/dist/util/shortid.js +11 -0
- package/docs/how-it-works.md +5 -10
- package/docs/setup-guide.md +6 -1
- package/package.json +7 -6
- package/dist/hooks/start-legacy.d.ts +0 -6
- package/dist/hooks/start-legacy.js +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,98 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **A contract test runs the same checks on all three stores.** `npm test` runs it on SQLite, and CI on Postgres
|
|
8
|
+
and MongoDB.
|
|
9
|
+
- **`npm run bench:inject -- <project> --compare-rank` compares four search rankings** on your own chats, judged
|
|
10
|
+
by Haiku or by a labels file (`--labels`).
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Install no longer writes to `CLAUDE.md`.** The MCP server's own instructions already tell Claude when to
|
|
15
|
+
search memory. A block an older version wrote into `CLAUDE.local.md` or `~/.claude/CLAUDE.md` is removed at the
|
|
16
|
+
next chat start, and your own text is kept.
|
|
17
|
+
- **A grep for a code symbol runs as usual.** The graph's answer is added next to it, only for a symbol lookup
|
|
18
|
+
inside the repository. `CLAUDE_DB_USAGES_HOOK=deny` brings back the old blocking.
|
|
19
|
+
- **The start of a chat shows each thing once.** One block replaces the three that could repeat a chat's
|
|
20
|
+
summary, its turns and its open work, and the next prompt's pick skips what the start already showed. The scan
|
|
21
|
+
hint and update notice are shown to you, not to Claude.
|
|
22
|
+
- **Shorter `find_usages` and `search` descriptions.**
|
|
23
|
+
- **`sync` says what it copies:** rows the other side is missing, and status changes. Edits and deletes do not
|
|
24
|
+
travel.
|
|
25
|
+
- **Saving a chat writes only what changed.** A save compares its rows with the stored ones, so a chat with
|
|
26
|
+
nothing new writes nothing. The per-chat lock and `.written` files are gone, and old ones are cleared.
|
|
27
|
+
- **`npm test` builds first.**
|
|
28
|
+
- **The `capture.tools` and `inject.sessions` settings are removed.** A config that still has them loads.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- **`forget` refuses an empty, wildcard or too-short id.** One could delete memory in every project.
|
|
33
|
+
- **`claude-db merge <subfolder>` no longer deletes the project it merges into.**
|
|
34
|
+
- **Saving a turn no longer closes open work in other clones of the same repository.**
|
|
35
|
+
- **`get_observations` and `timeline` refuse ids that are not observation ids.** An empty id read every row.
|
|
36
|
+
- **`find_usages` takes its root from the project and uses `path` only as a filter**, so a path in another
|
|
37
|
+
repository no longer replaces this project's graph. `claude-db scan --path` does the same.
|
|
38
|
+
- **The code graph is read again after an upgrade**, and a deleted file no longer keeps it stale.
|
|
39
|
+
- **`find_usages` no longer lists false callers** on SQLite and Postgres for names that differ in case or
|
|
40
|
+
contain `_`.
|
|
41
|
+
- **A chat summary is no longer lost when a save stops halfway.**
|
|
42
|
+
- **With `CLAUDE_CONFIG_DIR` set, chats are found and their read positions are kept.**
|
|
43
|
+
- **Haiku calls no longer receive the start block or start a graph scan.**
|
|
44
|
+
- **A replaced row is no longer marked done on SQLite.**
|
|
45
|
+
- **MongoDB search reads `-word` and quotes as plain words.**
|
|
46
|
+
- **Postgres notices pgvector installed after its first run.**
|
|
47
|
+
- **Two rows with one id in one save keep the last one on every backend.**
|
|
48
|
+
- **An id prefix is matched literally on SQLite and Postgres.** `%` used to match every row.
|
|
49
|
+
- **The pick at a prompt always has Claude's previous reply.** A save already running for the chat could make
|
|
50
|
+
it skip.
|
|
51
|
+
- **With the daemon on, each hook uses its own environment.** `CLAUDE_CONFIG_DIR` and the `claude` binary for
|
|
52
|
+
Haiku calls came from the shell that started the daemon.
|
|
53
|
+
- **A stuck daemon no longer holds up a hook.** One that does not answer within 2 s is replaced, and the hook
|
|
54
|
+
does its own work. A hook used to wait up to 50 s.
|
|
55
|
+
- **A failed load of the embedding model is tried again after a minute**, instead of staying off for the life of
|
|
56
|
+
the process.
|
|
57
|
+
- **Facts about you follow a changed git email within a minute.**
|
|
58
|
+
|
|
59
|
+
## 0.13.0
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
- **An optional daemon keeps one process warm for the hooks.** Each hook starts node, opens a database
|
|
64
|
+
connection and loads the embedding model before it does any work. `claude-db daemon on` keeps one process
|
|
65
|
+
that the hooks hand their work to, so they skip that cost, and `claude-db daemon off` turns it off. It stops
|
|
66
|
+
after `daemon.idleMinutes` (15) with nothing to do and starts again with the next hook. It is off by default.
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
|
|
70
|
+
- **Hooks send fewer queries to a remote database.** A folder's project scope is read once per process, a batch
|
|
71
|
+
of memories is saved in one statement on Postgres, the session row is written once per prompt, and the prompt
|
|
72
|
+
is embedded while the keyword search runs.
|
|
73
|
+
- **A grep in a repository with no code graph no longer asks the database.** The hook remembers for ten minutes
|
|
74
|
+
that the project has no graph.
|
|
75
|
+
- **A chat's read position is kept when it ends**, so a resumed chat no longer saves its earlier turns again.
|
|
76
|
+
Read positions of chats that are gone are cleared once a day.
|
|
77
|
+
- **Session end no longer starts distill when the day's budget is used up or paused.**
|
|
78
|
+
- **`find_usages` and background graph refreshes no longer read every file when nothing changed since the
|
|
79
|
+
scan.**
|
|
80
|
+
|
|
81
|
+
### Fixed
|
|
82
|
+
|
|
83
|
+
- **A dropped connection to a remote Postgres no longer stops memory.** An idle connection closed by the server,
|
|
84
|
+
as Neon does, could end the MCP server for the rest of the chat.
|
|
85
|
+
- **One slow load of the embedding model no longer turns vectors off for good.** The model is used as soon as it
|
|
86
|
+
loads, and all calls in a process share one wait of `embeddings.timeoutMs`.
|
|
87
|
+
- **Only one save of a chat runs at a time.** Two hooks that saved the same chat at once embedded and wrote the
|
|
88
|
+
same turns twice.
|
|
89
|
+
- **A background job never runs twice at once.** A stale lock is taken over by one process only, and long jobs
|
|
90
|
+
keep their lock fresh.
|
|
91
|
+
- **Code graph changes are saved in one transaction**, so a reader never sees a changed file with no symbols.
|
|
92
|
+
- **Closed work stays closed when its row is saved again.**
|
|
93
|
+
|
|
94
|
+
By @alok-debnath (#38, #39, #41).
|
|
95
|
+
|
|
3
96
|
## 0.12.4
|
|
4
97
|
|
|
5
98
|
### Fixed
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function readCursor(sessionId: string): number;
|
|
2
|
+
export declare function writeCursor(sessionId: string, offset: number): void;
|
|
3
|
+
export declare function resetCursor(sessionId: string): void;
|
|
4
|
+
export declare function clearCursor(sessionId: string): void;
|
|
5
|
+
export declare function sweepCursorsDaily(now?: number): number;
|
|
6
|
+
export declare function sweepCursors(): number;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { CONFIG_DIR } from '../config/index.js';
|
|
4
|
+
import { sessionIdsOnDisk } from './transcript.js';
|
|
5
|
+
const SWEEP_EVERY_MS = 24 * 60 * 60 * 1000;
|
|
6
|
+
const LEGACY_FILE = /\.(written|lock|lock\.break)$/;
|
|
7
|
+
function cursorName(sessionId) {
|
|
8
|
+
return `${sessionId.replace(/[^\w-]/g, '_')}.offset`;
|
|
9
|
+
}
|
|
10
|
+
function cursorPath(sessionId) {
|
|
11
|
+
return join(CONFIG_DIR, 'cursors', cursorName(sessionId));
|
|
12
|
+
}
|
|
13
|
+
export function readCursor(sessionId) {
|
|
14
|
+
try {
|
|
15
|
+
const value = Number.parseInt(readFileSync(cursorPath(sessionId), 'utf8'), 10);
|
|
16
|
+
return Number.isFinite(value) && value >= 0 ? value : 0;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function writeCursor(sessionId, offset) {
|
|
23
|
+
const path = cursorPath(sessionId);
|
|
24
|
+
try {
|
|
25
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
26
|
+
writeFileSync(path, String(offset), 'utf8');
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
}
|
|
30
|
+
export function resetCursor(sessionId) {
|
|
31
|
+
writeCursor(sessionId, 0);
|
|
32
|
+
}
|
|
33
|
+
export function clearCursor(sessionId) {
|
|
34
|
+
rmSync(cursorPath(sessionId), { force: true });
|
|
35
|
+
rmSync(cursorPath(sessionId).replace(/\.offset$/, '.shown'), { force: true });
|
|
36
|
+
}
|
|
37
|
+
export function sweepCursorsDaily(now = Date.now()) {
|
|
38
|
+
const marker = join(CONFIG_DIR, 'cursors', '.swept');
|
|
39
|
+
let lastSweep = 0;
|
|
40
|
+
try {
|
|
41
|
+
lastSweep = Number(readFileSync(marker, 'utf8')) || 0;
|
|
42
|
+
}
|
|
43
|
+
catch { }
|
|
44
|
+
if (now - lastSweep < SWEEP_EVERY_MS)
|
|
45
|
+
return 0;
|
|
46
|
+
try {
|
|
47
|
+
mkdirSync(dirname(marker), { recursive: true });
|
|
48
|
+
writeFileSync(marker, String(now), 'utf8');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
return sweepCursors();
|
|
54
|
+
}
|
|
55
|
+
export function sweepCursors() {
|
|
56
|
+
const dir = join(CONFIG_DIR, 'cursors');
|
|
57
|
+
let files;
|
|
58
|
+
try {
|
|
59
|
+
files = readdirSync(dir);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
const legacy = files.filter((file) => LEGACY_FILE.test(file));
|
|
65
|
+
for (const file of legacy)
|
|
66
|
+
rmSync(join(dir, file), { force: true });
|
|
67
|
+
const onDisk = sessionIdsOnDisk();
|
|
68
|
+
if (onDisk === null)
|
|
69
|
+
return legacy.length;
|
|
70
|
+
const live = new Set(onDisk.map((id) => id.replace(/[^\w-]/g, '_')));
|
|
71
|
+
let removed = legacy.length;
|
|
72
|
+
for (const file of files) {
|
|
73
|
+
const match = /^(.+)\.(offset|shown)$/.exec(file);
|
|
74
|
+
if (!match?.[1] || live.has(match[1]))
|
|
75
|
+
continue;
|
|
76
|
+
rmSync(join(dir, file), { force: true });
|
|
77
|
+
removed += 1;
|
|
78
|
+
}
|
|
79
|
+
return removed;
|
|
80
|
+
}
|
package/dist/capture/flush.d.ts
CHANGED
|
@@ -8,6 +8,4 @@ export interface FlushResult {
|
|
|
8
8
|
export declare function flushSession(ctx: RecallContext, sessionId: string, project: string, transcriptPath?: string, rebuild?: boolean, finalReply?: string): Promise<FlushResult>;
|
|
9
9
|
export declare function embedObservations(ctx: RecallContext, observations: Observation[]): Promise<void>;
|
|
10
10
|
export declare function summarize(observations: Observation[], previous?: string): string;
|
|
11
|
-
export
|
|
12
|
-
export declare function clearCursor(sessionId: string): void;
|
|
13
|
-
export declare function sweepCursors(): number;
|
|
11
|
+
export { clearCursor, resetCursor, sweepCursors, sweepCursorsDaily } from './cursors.js';
|
package/dist/capture/flush.js
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
import { CONFIG_DIR } from '../config/index.js';
|
|
5
|
-
import { readTranscript, sessionIdsOnDisk, transcriptPathFor } from './transcript.js';
|
|
1
|
+
import { readTranscript, transcriptPathFor } from './transcript.js';
|
|
6
2
|
import { observationsFromTurns } from './turn-extractor.js';
|
|
7
3
|
import { closeLandedWork } from './progress.js';
|
|
8
4
|
import { noteMissingVectors } from './vectors.js';
|
|
5
|
+
import { readCursor, writeCursor } from './cursors.js';
|
|
6
|
+
const LOOKUP_CHUNK = 500;
|
|
9
7
|
export async function flushSession(ctx, sessionId, project, transcriptPath, rebuild = false, finalReply = '') {
|
|
10
8
|
const path = transcriptPath ?? transcriptPathFor(project, sessionId);
|
|
11
|
-
const
|
|
12
|
-
const read = readTranscript(path, cursor);
|
|
13
|
-
const { nextOffset } = read;
|
|
9
|
+
const read = readTranscript(path, readCursor(sessionId));
|
|
14
10
|
const turns = withFinalReply(read.turns, finalReply);
|
|
15
11
|
const lastReply = turns.at(-1)?.reasoning ?? '';
|
|
16
|
-
if (turns.length === 0) {
|
|
17
|
-
await closeLandedWork(ctx.store, project);
|
|
18
|
-
writeCursor(sessionId, nextOffset);
|
|
19
|
-
return { observations: 0, summary: null, lastReply };
|
|
20
|
-
}
|
|
21
12
|
const observations = observationsFromTurns(turns, sessionId, project, ctx.config);
|
|
22
|
-
|
|
13
|
+
const stored = rebuild
|
|
14
|
+
? new Map()
|
|
15
|
+
: await storedRows(ctx.store, observations);
|
|
16
|
+
const changed = observations.filter((obs) => !sameRow(obs, stored.get(obs.id)));
|
|
17
|
+
if (changed.length === 0) {
|
|
23
18
|
await closeLandedWork(ctx.store, project);
|
|
24
|
-
writeCursor(sessionId, nextOffset);
|
|
19
|
+
writeCursor(sessionId, read.nextOffset);
|
|
25
20
|
return { observations: 0, summary: null, lastReply };
|
|
26
21
|
}
|
|
27
|
-
const written = rebuild ? new Map() : readWritten(sessionId);
|
|
28
|
-
const prints = new Map(observations.map((obs) => [obs.id, printOf(obs)]));
|
|
29
|
-
const fresh = observations.filter((obs) => written.get(obs.id) !== prints.get(obs.id));
|
|
30
|
-
await embedObservations(ctx, fresh);
|
|
31
|
-
await ctx.store.insertObservations(fresh);
|
|
32
|
-
writeWritten(sessionId, prints);
|
|
33
|
-
await closeLandedWork(ctx.store, project);
|
|
34
22
|
const previous = rebuild ? null : await ctx.store.getSession(sessionId);
|
|
35
23
|
const summary = summarize(observations, previous?.summary);
|
|
36
24
|
await ctx.store.upsertSession({
|
|
@@ -39,9 +27,32 @@ export async function flushSession(ctx, sessionId, project, transcriptPath, rebu
|
|
|
39
27
|
startedAt: observations[0]?.createdAt ?? Date.now(),
|
|
40
28
|
summary,
|
|
41
29
|
});
|
|
42
|
-
|
|
30
|
+
await embedObservations(ctx, changed);
|
|
31
|
+
await ctx.store.insertObservations(changed);
|
|
32
|
+
await closeLandedWork(ctx.store, project);
|
|
33
|
+
writeCursor(sessionId, read.nextOffset);
|
|
43
34
|
return { observations: observations.length, summary, lastReply };
|
|
44
35
|
}
|
|
36
|
+
async function storedRows(store, observations) {
|
|
37
|
+
const ids = observations.map((obs) => obs.id);
|
|
38
|
+
const found = new Map();
|
|
39
|
+
for (let start = 0; start < ids.length; start += LOOKUP_CHUNK) {
|
|
40
|
+
for (const row of await store.getObservations(ids.slice(start, start + LOOKUP_CHUNK))) {
|
|
41
|
+
found.set(row.id, row);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return found;
|
|
45
|
+
}
|
|
46
|
+
const sameList = (a, b) => a.length === b.length && a.every((item, index) => item === b[index]);
|
|
47
|
+
function sameRow(fresh, stored) {
|
|
48
|
+
return (stored !== undefined &&
|
|
49
|
+
fresh.kind === stored.kind &&
|
|
50
|
+
fresh.title === stored.title &&
|
|
51
|
+
fresh.body === stored.body &&
|
|
52
|
+
fresh.createdAt === stored.createdAt &&
|
|
53
|
+
sameList(fresh.files, stored.files) &&
|
|
54
|
+
sameList(fresh.tags, stored.tags));
|
|
55
|
+
}
|
|
45
56
|
export async function embedObservations(ctx, observations) {
|
|
46
57
|
if (observations.length === 0)
|
|
47
58
|
return;
|
|
@@ -99,76 +110,4 @@ export function summarize(observations, previous) {
|
|
|
99
110
|
}
|
|
100
111
|
return kept.join(' | ');
|
|
101
112
|
}
|
|
102
|
-
|
|
103
|
-
return `${sessionId.replace(/[^\w-]/g, '_')}.offset`;
|
|
104
|
-
}
|
|
105
|
-
function cursorPath(sessionId) {
|
|
106
|
-
return join(CONFIG_DIR, 'cursors', cursorName(sessionId));
|
|
107
|
-
}
|
|
108
|
-
const writtenPath = (sessionId) => cursorPath(sessionId).replace(/\.offset$/, '.written');
|
|
109
|
-
const printOf = (obs) => createHash('sha256').update(JSON.stringify(obs)).digest('base64url');
|
|
110
|
-
function readWritten(sessionId) {
|
|
111
|
-
try {
|
|
112
|
-
const parsed = JSON.parse(readFileSync(writtenPath(sessionId), 'utf8'));
|
|
113
|
-
if (!parsed || typeof parsed !== 'object')
|
|
114
|
-
return new Map();
|
|
115
|
-
return new Map(Object.entries(parsed).filter((entry) => typeof entry[1] === 'string'));
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
return new Map();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function writeWritten(sessionId, prints) {
|
|
122
|
-
const path = writtenPath(sessionId);
|
|
123
|
-
try {
|
|
124
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
125
|
-
writeFileSync(path, JSON.stringify(Object.fromEntries(prints)), 'utf8');
|
|
126
|
-
}
|
|
127
|
-
catch { }
|
|
128
|
-
}
|
|
129
|
-
function readCursor(sessionId) {
|
|
130
|
-
try {
|
|
131
|
-
const value = Number.parseInt(readFileSync(cursorPath(sessionId), 'utf8'), 10);
|
|
132
|
-
return Number.isFinite(value) && value >= 0 ? value : 0;
|
|
133
|
-
}
|
|
134
|
-
catch {
|
|
135
|
-
return 0;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function writeCursor(sessionId, offset) {
|
|
139
|
-
const path = cursorPath(sessionId);
|
|
140
|
-
try {
|
|
141
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
142
|
-
writeFileSync(path, String(offset), 'utf8');
|
|
143
|
-
}
|
|
144
|
-
catch { }
|
|
145
|
-
}
|
|
146
|
-
export function resetCursor(sessionId) {
|
|
147
|
-
writeCursor(sessionId, 0);
|
|
148
|
-
rmSync(writtenPath(sessionId), { force: true });
|
|
149
|
-
}
|
|
150
|
-
export function clearCursor(sessionId) {
|
|
151
|
-
rmSync(cursorPath(sessionId), { force: true });
|
|
152
|
-
rmSync(cursorPath(sessionId).replace(/\.offset$/, '.shown'), { force: true });
|
|
153
|
-
rmSync(writtenPath(sessionId), { force: true });
|
|
154
|
-
}
|
|
155
|
-
export function sweepCursors() {
|
|
156
|
-
const dir = join(CONFIG_DIR, 'cursors');
|
|
157
|
-
let files;
|
|
158
|
-
try {
|
|
159
|
-
files = readdirSync(dir);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
return 0;
|
|
163
|
-
}
|
|
164
|
-
const live = new Set(sessionIdsOnDisk().map((id) => id.replace(/[^\w-]/g, '_')));
|
|
165
|
-
let removed = 0;
|
|
166
|
-
for (const file of files) {
|
|
167
|
-
const match = /^(.+)\.(offset|shown|written)$/.exec(file);
|
|
168
|
-
if (!match?.[1] || live.has(match[1]))
|
|
169
|
-
continue;
|
|
170
|
-
rmSync(join(dir, file), { force: true });
|
|
171
|
-
removed += 1;
|
|
172
|
-
}
|
|
173
|
-
return removed;
|
|
174
|
-
}
|
|
113
|
+
export { clearCursor, resetCursor, sweepCursors, sweepCursorsDaily } from './cursors.js';
|
package/dist/capture/index.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ export type { Turn, TranscriptRead } from './transcript.js';
|
|
|
7
7
|
export { observationsFromGit } from './git.js';
|
|
8
8
|
export { observationsFromTurns } from './turn-extractor.js';
|
|
9
9
|
export { redact } from './redact.js';
|
|
10
|
-
export { claimScrub, finishScrub, releaseScrub, scrubSecrets } from './scrub.js';
|
|
11
|
-
export { flushSession, resetCursor, clearCursor, sweepCursors, summarize, embedObservations, } from './flush.js';
|
|
10
|
+
export { claimScrub, finishScrub, keepScrub, releaseScrub, scrubSecrets } from './scrub.js';
|
|
11
|
+
export { flushSession, resetCursor, clearCursor, sweepCursors, sweepCursorsDaily, summarize, embedObservations, } from './flush.js';
|
|
12
12
|
export type { FlushResult } from './flush.js';
|
|
13
13
|
export { claimReembed, finishReembed, releaseReembed, startReembed, vectorsMissing, } from './vectors.js';
|
|
14
14
|
export { closeLandedWork, openWork } from './progress.js';
|
|
15
|
-
export { REINGEST_VERSION, claimReingest, finishReingest, reingestDone, reingestProject, rememberedTranscripts, reingestSession, releaseReingest, } from './reingest.js';
|
|
15
|
+
export { REINGEST_VERSION, claimReingest, finishReingest, keepReingest, reingestDone, reingestProject, rememberedTranscripts, reingestSession, releaseReingest, } from './reingest.js';
|
|
16
16
|
export type { ProjectReingest, SessionReingest } from './reingest.js';
|
|
17
17
|
export { aiSummary, buildSummaryPrompt, validateSummary } from './summarize.js';
|
package/dist/capture/index.js
CHANGED
|
@@ -5,9 +5,9 @@ export { readTranscript, sessionIdsOnDisk, transcriptPathFor, transcriptsFor, }
|
|
|
5
5
|
export { observationsFromGit } from './git.js';
|
|
6
6
|
export { observationsFromTurns } from './turn-extractor.js';
|
|
7
7
|
export { redact } from './redact.js';
|
|
8
|
-
export { claimScrub, finishScrub, releaseScrub, scrubSecrets } from './scrub.js';
|
|
9
|
-
export { flushSession, resetCursor, clearCursor, sweepCursors, summarize, embedObservations, } from './flush.js';
|
|
8
|
+
export { claimScrub, finishScrub, keepScrub, releaseScrub, scrubSecrets } from './scrub.js';
|
|
9
|
+
export { flushSession, resetCursor, clearCursor, sweepCursors, sweepCursorsDaily, summarize, embedObservations, } from './flush.js';
|
|
10
10
|
export { claimReembed, finishReembed, releaseReembed, startReembed, vectorsMissing, } from './vectors.js';
|
|
11
11
|
export { closeLandedWork, openWork } from './progress.js';
|
|
12
|
-
export { REINGEST_VERSION, claimReingest, finishReingest, reingestDone, reingestProject, rememberedTranscripts, reingestSession, releaseReingest, } from './reingest.js';
|
|
12
|
+
export { REINGEST_VERSION, claimReingest, finishReingest, keepReingest, reingestDone, reingestProject, rememberedTranscripts, reingestSession, releaseReingest, } from './reingest.js';
|
|
13
13
|
export { aiSummary, buildSummaryPrompt, validateSummary } from './summarize.js';
|
package/dist/capture/progress.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { join, sep } from 'node:path';
|
|
3
3
|
const MAX_BUFFER = 16 * 1024 * 1024;
|
|
4
4
|
const OPEN_LIMIT = 500;
|
|
5
5
|
function uncommittedFiles(project) {
|
|
@@ -29,6 +29,7 @@ function uncommittedFiles(project) {
|
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
const isInside = (file, folder) => file.startsWith(folder + sep);
|
|
32
33
|
export async function closeLandedWork(store, project) {
|
|
33
34
|
const dirty = uncommittedFiles(project);
|
|
34
35
|
if (!dirty)
|
|
@@ -48,7 +49,8 @@ export async function closeLandedWork(store, project) {
|
|
|
48
49
|
if (batch.length === 0)
|
|
49
50
|
break;
|
|
50
51
|
for (const obs of batch) {
|
|
51
|
-
|
|
52
|
+
const mine = obs.files.every((file) => isInside(file, project));
|
|
53
|
+
if (mine && obs.files.every((file) => !dirty.has(file)))
|
|
52
54
|
landed.push(obs.id);
|
|
53
55
|
}
|
|
54
56
|
const last = batch[batch.length - 1];
|
|
@@ -15,5 +15,6 @@ export declare function rememberedTranscripts(ctx: RecallContext, project: strin
|
|
|
15
15
|
export declare function reingestProject(ctx: RecallContext, project: string, paths?: string[], onSession?: (result: SessionReingest) => void): Promise<ProjectReingest>;
|
|
16
16
|
export declare function reingestDone(project: string): boolean;
|
|
17
17
|
export declare function claimReingest(project: string, now?: number): boolean;
|
|
18
|
+
export declare function keepReingest(project: string): void;
|
|
18
19
|
export declare function finishReingest(project: string): void;
|
|
19
20
|
export declare function releaseReingest(project: string): void;
|
package/dist/capture/reingest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename } from 'node:path';
|
|
2
|
-
import { claimJob, finishJob, jobMark, releaseJob } from '../util/job-lock.js';
|
|
2
|
+
import { claimJob, finishJob, jobMark, keepJob, releaseJob } from '../util/job-lock.js';
|
|
3
3
|
import { flushSession, resetCursor } from './flush.js';
|
|
4
4
|
import { readTranscript, transcriptsFor } from './transcript.js';
|
|
5
5
|
import { observationsFromTurns } from './turn-extractor.js';
|
|
@@ -48,6 +48,9 @@ export function claimReingest(project, now = Date.now()) {
|
|
|
48
48
|
return false;
|
|
49
49
|
return claimJob(JOB, project, now);
|
|
50
50
|
}
|
|
51
|
+
export function keepReingest(project) {
|
|
52
|
+
keepJob(JOB, project);
|
|
53
|
+
}
|
|
51
54
|
export function finishReingest(project) {
|
|
52
55
|
finishJob(JOB, project, REINGEST_VERSION);
|
|
53
56
|
}
|
package/dist/capture/scrub.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export interface ScrubResult {
|
|
|
7
7
|
export declare function scrubSecrets(ctx: RecallContext, now?: number): Promise<ScrubResult>;
|
|
8
8
|
export declare function scrubDone(database: string): boolean;
|
|
9
9
|
export declare function claimScrub(database: string, now?: number): boolean;
|
|
10
|
+
export declare function keepScrub(database: string): void;
|
|
10
11
|
export declare function finishScrub(database: string): void;
|
|
11
12
|
export declare function releaseScrub(database: string): void;
|
package/dist/capture/scrub.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { eachObservation } from '../store/each.js';
|
|
2
|
-
import { claimJob, finishJob, jobMark, releaseJob } from '../util/job-lock.js';
|
|
2
|
+
import { claimJob, finishJob, jobMark, keepJob, releaseJob } from '../util/job-lock.js';
|
|
3
3
|
import { embedObservations } from './flush.js';
|
|
4
4
|
import { redact } from './redact.js';
|
|
5
5
|
export const REDACT_VERSION = 1;
|
|
@@ -40,6 +40,9 @@ export function scrubDone(database) {
|
|
|
40
40
|
export function claimScrub(database, now = Date.now()) {
|
|
41
41
|
return !scrubDone(database) && claimJob(JOB, database, now);
|
|
42
42
|
}
|
|
43
|
+
export function keepScrub(database) {
|
|
44
|
+
keepJob(JOB, database);
|
|
45
|
+
}
|
|
43
46
|
export function finishScrub(database) {
|
|
44
47
|
finishJob(JOB, database, REDACT_VERSION);
|
|
45
48
|
}
|
|
@@ -15,4 +15,4 @@ export declare function readTranscript(path: string, fromOffset?: number): Trans
|
|
|
15
15
|
export declare function isSyntheticPrompt(text: string): boolean;
|
|
16
16
|
export declare function transcriptPathFor(project: string, sessionId: string): string;
|
|
17
17
|
export declare function transcriptsFor(project: string): string[];
|
|
18
|
-
export declare function sessionIdsOnDisk(): string[];
|
|
18
|
+
export declare function sessionIdsOnDisk(): string[] | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { closeSync, fstatSync, openSync, readdirSync, readSync } from 'node:fs';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
2
|
import { join } from 'node:path';
|
|
4
3
|
import { isRelayedMessage } from '../util/prompt.js';
|
|
4
|
+
import { claudeProjectsDir } from '../util/claude-dir.js';
|
|
5
5
|
import { resolveProject } from '../util/project.js';
|
|
6
6
|
export function readTranscript(path, fromOffset = 0) {
|
|
7
7
|
let fd;
|
|
@@ -132,10 +132,10 @@ function projectSlug(project) {
|
|
|
132
132
|
return project.replace(/[^a-zA-Z0-9]/g, '-');
|
|
133
133
|
}
|
|
134
134
|
export function transcriptPathFor(project, sessionId) {
|
|
135
|
-
return join(
|
|
135
|
+
return join(claudeProjectsDir(), projectSlug(project), `${sessionId}.jsonl`);
|
|
136
136
|
}
|
|
137
137
|
export function transcriptsFor(project) {
|
|
138
|
-
const root =
|
|
138
|
+
const root = claudeProjectsDir();
|
|
139
139
|
const slug = projectSlug(project);
|
|
140
140
|
let candidates;
|
|
141
141
|
try {
|
|
@@ -163,14 +163,14 @@ export function transcriptsFor(project) {
|
|
|
163
163
|
return transcripts.sort();
|
|
164
164
|
}
|
|
165
165
|
export function sessionIdsOnDisk() {
|
|
166
|
-
const root =
|
|
166
|
+
const root = claudeProjectsDir();
|
|
167
167
|
const ids = [];
|
|
168
168
|
let dirs;
|
|
169
169
|
try {
|
|
170
170
|
dirs = readdirSync(root);
|
|
171
171
|
}
|
|
172
|
-
catch {
|
|
173
|
-
return ids;
|
|
172
|
+
catch (error) {
|
|
173
|
+
return error.code === 'ENOENT' ? ids : null;
|
|
174
174
|
}
|
|
175
175
|
for (const dir of dirs) {
|
|
176
176
|
try {
|
package/dist/capture/vectors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { CONFIG_DIR } from '../config/index.js';
|
|
4
|
-
import { claimJob, finishJob, jobMark, releaseJob } from '../util/job-lock.js';
|
|
4
|
+
import { claimJob, finishJob, jobMark, keepJob, releaseJob } from '../util/job-lock.js';
|
|
5
5
|
import { scopeToken } from '../util/scope.js';
|
|
6
6
|
const JOB = 'reembed';
|
|
7
7
|
const FLAGS = 'vectors-missing';
|
|
@@ -29,6 +29,7 @@ export function claimReembed(project, now = Date.now()) {
|
|
|
29
29
|
}
|
|
30
30
|
export function startReembed(project) {
|
|
31
31
|
rmSync(flagPath(project), { force: true });
|
|
32
|
+
keepJob(JOB, project);
|
|
32
33
|
}
|
|
33
34
|
export function finishReembed(project, now = Date.now()) {
|
|
34
35
|
finishJob(JOB, project, now);
|
package/dist/catchup/gather.js
CHANGED
|
@@ -43,7 +43,7 @@ export async function gatherCatchup(ctx, project, current, now = Date.now()) {
|
|
|
43
43
|
unfinished: unfinished.map((entry) => ({ at: entry.askedAt, request: entry.request })),
|
|
44
44
|
chats: chats.map((chat) => ({
|
|
45
45
|
at: chat.at,
|
|
46
|
-
summary: chat.summary,
|
|
46
|
+
summary: chat.summary.join('; ') || null,
|
|
47
47
|
work: chat.turns.map(turnLine),
|
|
48
48
|
})),
|
|
49
49
|
todos,
|
|
@@ -2,11 +2,12 @@ import { gatherCatchup } from '../../catchup/gather.js';
|
|
|
2
2
|
import { renderCatchup } from '../../catchup/render.js';
|
|
3
3
|
import { createContext } from '../../context.js';
|
|
4
4
|
import { resolveProject } from '../../util/project.js';
|
|
5
|
+
import { hookEnv } from '../../util/env.js';
|
|
5
6
|
export async function cmdCatchup() {
|
|
6
7
|
const project = resolveProject(undefined);
|
|
7
8
|
const ctx = await createContext();
|
|
8
9
|
try {
|
|
9
|
-
const current =
|
|
10
|
+
const current = hookEnv()['CLAUDE_CODE_SESSION_ID'] || undefined;
|
|
10
11
|
console.log(renderCatchup(await gatherCatchup(ctx, project, current)));
|
|
11
12
|
}
|
|
12
13
|
finally {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cmdDaemon(argv: (string | undefined)[]): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { setConfigValue } from '../../config/index.js';
|
|
2
|
+
import { askDaemon, startDaemon } from '../../daemon/client.js';
|
|
3
|
+
import { buildId } from '../../daemon/paths.js';
|
|
4
|
+
const STOP = '__stop';
|
|
5
|
+
async function running() {
|
|
6
|
+
const asked = await askDaemon({ build: buildId(), hook: '__ping', raw: '', env: {} }, 1000);
|
|
7
|
+
return asked.kind === 'done';
|
|
8
|
+
}
|
|
9
|
+
export async function cmdDaemon(argv) {
|
|
10
|
+
const [action] = argv;
|
|
11
|
+
switch (action) {
|
|
12
|
+
case 'on':
|
|
13
|
+
case 'off':
|
|
14
|
+
setConfigValue('daemon', 'enabled', action === 'on');
|
|
15
|
+
if (action === 'off')
|
|
16
|
+
await askDaemon({ build: buildId(), hook: STOP, raw: '', env: {} }, 2000);
|
|
17
|
+
console.log(`daemon: ${action}`);
|
|
18
|
+
return;
|
|
19
|
+
case 'start':
|
|
20
|
+
console.log(startDaemon() ? 'daemon: starting' : 'daemon: already starting');
|
|
21
|
+
return;
|
|
22
|
+
case 'stop':
|
|
23
|
+
await askDaemon({ build: buildId(), hook: STOP, raw: '', env: {} }, 2000);
|
|
24
|
+
console.log('daemon: stopped');
|
|
25
|
+
return;
|
|
26
|
+
default:
|
|
27
|
+
console.log(`daemon: ${(await running()) ? 'running' : 'not running'}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -6,7 +6,7 @@ import { importClaudeMemory } from '../../facts/claude-memory.js';
|
|
|
6
6
|
import { FACTS_JOB, backfill, distillSession, factCounts, pendingSessions, } from '../../facts/distill.js';
|
|
7
7
|
import { runHeadlessResult } from '../../util/claude-cli.js';
|
|
8
8
|
import { describePause } from '../../util/daily-budget.js';
|
|
9
|
-
import { finishJob, releaseJob } from '../../util/job-lock.js';
|
|
9
|
+
import { finishJob, keepJob, releaseJob } from '../../util/job-lock.js';
|
|
10
10
|
import { resolveProject } from '../../util/project.js';
|
|
11
11
|
export async function cmdDistill(argv) {
|
|
12
12
|
const [first] = argv;
|
|
@@ -37,6 +37,7 @@ export async function cmdDistill(argv) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
async function runBackfill(project) {
|
|
40
|
+
keepJob(FACTS_JOB, project);
|
|
40
41
|
try {
|
|
41
42
|
const ctx = await createContext();
|
|
42
43
|
try {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createContext } from '../../context.js';
|
|
2
2
|
import { findUsages, formatUsages, repoRootFor } from '../../usages/index.js';
|
|
3
|
-
import { NO_GRAPH, NO_GRAPH_FOR_PATH,
|
|
3
|
+
import { NO_GRAPH, NO_GRAPH_FOR_PATH, hasGraph, languageNames, refreshGraph, saveScan, scanRepository, suggestFor, usagesAnswer, } from '../../graph/index.js';
|
|
4
4
|
import { PLATFORM } from '../../graph/grammars.js';
|
|
5
5
|
import { GRAPH_JOB } from '../../graph/scan/job.js';
|
|
6
|
-
import { releaseJob } from '../../util/job-lock.js';
|
|
6
|
+
import { keepJob, releaseJob } from '../../util/job-lock.js';
|
|
7
7
|
import { resolveProject } from '../../util/project.js';
|
|
8
8
|
import { valueOf, withoutFlags } from '../args.js';
|
|
9
9
|
function printScan(root, scan, elapsedMs) {
|
|
@@ -44,13 +44,13 @@ async function runRefresh(root, project) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
export async function cmdScan(argv) {
|
|
47
|
-
const
|
|
48
|
-
const root = repoRootFor(
|
|
49
|
-
const project = resolveProject(undefined);
|
|
47
|
+
const project = resolveProject(valueOf(argv, '--path'));
|
|
48
|
+
const root = repoRootFor(project);
|
|
50
49
|
if (!argv.includes('--background')) {
|
|
51
50
|
await runScan(root, project, argv.includes('--force'));
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
53
|
+
keepJob(GRAPH_JOB, project);
|
|
54
54
|
try {
|
|
55
55
|
await runRefresh(root, project);
|
|
56
56
|
}
|
|
@@ -112,16 +112,16 @@ async function graphAnswer(store, input) {
|
|
|
112
112
|
fail(NO_GRAPH_FOR_PATH);
|
|
113
113
|
return `${NO_GRAPH}\n${await textAnswer(store, input)}`;
|
|
114
114
|
}
|
|
115
|
-
const root = repoRootFor(input.path ?? process.cwd());
|
|
116
115
|
const mode = input.mode === 'text' ? 'usages' : input.mode;
|
|
117
|
-
|
|
116
|
+
return usagesAnswer({
|
|
118
117
|
store,
|
|
119
|
-
root,
|
|
120
118
|
project,
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
mode,
|
|
120
|
+
symbol,
|
|
121
|
+
target,
|
|
122
|
+
limit: input.limit,
|
|
123
|
+
path: input.path,
|
|
123
124
|
});
|
|
124
|
-
return formatGraph(answer, root);
|
|
125
125
|
}
|
|
126
126
|
export async function cmdUsages(argv) {
|
|
127
127
|
const input = usagesInput(argv);
|