@cruxy/cli 1.0.3 → 1.0.5
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/package.json +2 -2
- package/dist/agent/budget.d.ts +0 -52
- package/dist/agent/index.d.ts +0 -3
- package/dist/agent/loop.d.ts +0 -159
- package/dist/agent/prompts.d.ts +0 -69
- package/dist/agent/session.d.ts +0 -212
- package/dist/approval/classify.d.ts +0 -18
- package/dist/approval/index.d.ts +0 -6
- package/dist/approval/mutex.d.ts +0 -45
- package/dist/approval/policy.d.ts +0 -43
- package/dist/approval/prompt.d.ts +0 -48
- package/dist/approval/service.d.ts +0 -36
- package/dist/approval/types.d.ts +0 -82
- package/dist/brand/index.d.ts +0 -1
- package/dist/brand/voice.d.ts +0 -94
- package/dist/checkpoint/capture.d.ts +0 -17
- package/dist/checkpoint/gate-hook.d.ts +0 -28
- package/dist/checkpoint/gate.d.ts +0 -71
- package/dist/checkpoint/git-store.d.ts +0 -61
- package/dist/checkpoint/index.d.ts +0 -10
- package/dist/checkpoint/restore.d.ts +0 -23
- package/dist/checkpoint/service.d.ts +0 -89
- package/dist/checkpoint/set-rollback.d.ts +0 -51
- package/dist/checkpoint/set.d.ts +0 -44
- package/dist/checkpoint/shadow-store.d.ts +0 -23
- package/dist/checkpoint/types.d.ts +0 -164
- package/dist/cli/commands/checkpoint.d.ts +0 -7
- package/dist/cli/commands/config.d.ts +0 -2
- package/dist/cli/commands/hooks.d.ts +0 -8
- package/dist/cli/commands/index.d.ts +0 -7
- package/dist/cli/commands/init.d.ts +0 -7
- package/dist/cli/commands/login.d.ts +0 -8
- package/dist/cli/commands/mcp.d.ts +0 -9
- package/dist/cli/commands/memory.d.ts +0 -8
- package/dist/cli/commands/pr.d.ts +0 -8
- package/dist/cli/commands/rollback.d.ts +0 -18
- package/dist/cli/commands/run.d.ts +0 -2
- package/dist/cli/commands/skills.d.ts +0 -8
- package/dist/cli/commands/test.d.ts +0 -9
- package/dist/cli/commands/usage.d.ts +0 -9
- package/dist/cli/onboard.d.ts +0 -25
- package/dist/cli/program.d.ts +0 -2
- package/dist/cli/repl.d.ts +0 -27
- package/dist/cli/session-factory.d.ts +0 -42
- package/dist/cli/stream-print.d.ts +0 -14
- package/dist/components/autocomplete.d.ts +0 -32
- package/dist/components/frame.d.ts +0 -28
- package/dist/components/fuzzy.d.ts +0 -61
- package/dist/components/index.d.ts +0 -6
- package/dist/components/input.d.ts +0 -78
- package/dist/components/keys.d.ts +0 -48
- package/dist/components/select.d.ts +0 -28
- package/dist/config/credentials.d.ts +0 -18
- package/dist/config/index.d.ts +0 -5
- package/dist/config/manager.d.ts +0 -39
- package/dist/config/owner-only.d.ts +0 -19
- package/dist/config/paths.d.ts +0 -9
- package/dist/config/project.d.ts +0 -10
- package/dist/config/schema.d.ts +0 -2143
- package/dist/constants.d.ts +0 -65
- package/dist/errors/boundary.d.ts +0 -43
- package/dist/errors/constructors.d.ts +0 -411
- package/dist/errors/format.d.ts +0 -31
- package/dist/errors/index.d.ts +0 -4
- package/dist/errors/types.d.ts +0 -270
- package/dist/hooks/config.d.ts +0 -21
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/router.d.ts +0 -58
- package/dist/hooks/runner.d.ts +0 -88
- package/dist/hooks/service.d.ts +0 -38
- package/dist/hooks/slash.d.ts +0 -48
- package/dist/hooks/trust.d.ts +0 -46
- package/dist/hooks/types.d.ts +0 -147
- package/dist/index.d.ts +0 -2
- package/dist/indexing/chunker.d.ts +0 -28
- package/dist/indexing/embedder.d.ts +0 -98
- package/dist/indexing/index.d.ts +0 -9
- package/dist/indexing/indexer.d.ts +0 -45
- package/dist/indexing/retriever.d.ts +0 -61
- package/dist/indexing/service.d.ts +0 -49
- package/dist/indexing/store.d.ts +0 -103
- package/dist/indexing/types.d.ts +0 -78
- package/dist/indexing/util.d.ts +0 -34
- package/dist/indexing/walker.d.ts +0 -53
- package/dist/jobs/approval-queue.d.ts +0 -85
- package/dist/jobs/dispatch-tool.d.ts +0 -34
- package/dist/jobs/index.d.ts +0 -6
- package/dist/jobs/log-buffer.d.ts +0 -31
- package/dist/jobs/log-renderer.d.ts +0 -32
- package/dist/jobs/manager.d.ts +0 -139
- package/dist/jobs/types.d.ts +0 -81
- package/dist/lsp/client.d.ts +0 -25
- package/dist/lsp/index.d.ts +0 -8
- package/dist/lsp/pool.d.ts +0 -48
- package/dist/lsp/registry.d.ts +0 -38
- package/dist/lsp/server.d.ts +0 -48
- package/dist/lsp/service.d.ts +0 -44
- package/dist/lsp/tools/common.d.ts +0 -50
- package/dist/lsp/tools/find-definition.d.ts +0 -23
- package/dist/lsp/tools/find-references.d.ts +0 -23
- package/dist/lsp/tools/get-diagnostics.d.ts +0 -17
- package/dist/lsp/tools/hover.d.ts +0 -23
- package/dist/lsp/tools/index.d.ts +0 -4
- package/dist/lsp/transport.d.ts +0 -39
- package/dist/lsp/types.d.ts +0 -107
- package/dist/mcp/adapter.d.ts +0 -44
- package/dist/mcp/bounds.d.ts +0 -35
- package/dist/mcp/client.d.ts +0 -19
- package/dist/mcp/demarcate.d.ts +0 -12
- package/dist/mcp/http-transport.d.ts +0 -89
- package/dist/mcp/index.d.ts +0 -12
- package/dist/mcp/service.d.ts +0 -71
- package/dist/mcp/sibling-banner.d.ts +0 -25
- package/dist/mcp/transport.d.ts +0 -30
- package/dist/mcp/trust-gate.d.ts +0 -59
- package/dist/mcp/trust.d.ts +0 -62
- package/dist/mcp/types.d.ts +0 -62
- package/dist/mcp/url-guard.d.ts +0 -48
- package/dist/memory/index.d.ts +0 -7
- package/dist/memory/recall.d.ts +0 -56
- package/dist/memory/remember-tool.d.ts +0 -28
- package/dist/memory/secrets.d.ts +0 -29
- package/dist/memory/service.d.ts +0 -92
- package/dist/memory/store.d.ts +0 -32
- package/dist/memory/trust.d.ts +0 -52
- package/dist/memory/types.d.ts +0 -101
- package/dist/net/ip-guard.d.ts +0 -55
- package/dist/onboarding/detect.d.ts +0 -26
- package/dist/onboarding/flow.d.ts +0 -28
- package/dist/onboarding/index.d.ts +0 -5
- package/dist/onboarding/io.d.ts +0 -9
- package/dist/onboarding/steps.d.ts +0 -17
- package/dist/onboarding/types.d.ts +0 -81
- package/dist/plan/approve.d.ts +0 -16
- package/dist/plan/execute.d.ts +0 -28
- package/dist/plan/index.d.ts +0 -7
- package/dist/plan/policy.d.ts +0 -26
- package/dist/plan/render.d.ts +0 -5
- package/dist/plan/service.d.ts +0 -58
- package/dist/plan/submit-plan.d.ts +0 -33
- package/dist/plan/types.d.ts +0 -60
- package/dist/render/capabilities.d.ts +0 -31
- package/dist/render/diff.d.ts +0 -18
- package/dist/render/highlight.d.ts +0 -47
- package/dist/render/index.d.ts +0 -22
- package/dist/render/layout.d.ts +0 -59
- package/dist/render/motion.d.ts +0 -76
- package/dist/render/plain-renderer.d.ts +0 -39
- package/dist/render/resize.d.ts +0 -36
- package/dist/render/screen-reader-renderer.d.ts +0 -45
- package/dist/render/state.d.ts +0 -49
- package/dist/render/tty-renderer.d.ts +0 -106
- package/dist/render/types.d.ts +0 -201
- package/dist/routing/index.d.ts +0 -2
- package/dist/routing/resolve.d.ts +0 -17
- package/dist/routing/router.d.ts +0 -47
- package/dist/routing/types.d.ts +0 -42
- package/dist/sandbox/detect.d.ts +0 -22
- package/dist/sandbox/docker-runtime.d.ts +0 -32
- package/dist/sandbox/index.d.ts +0 -7
- package/dist/sandbox/policy.d.ts +0 -26
- package/dist/sandbox/service.d.ts +0 -64
- package/dist/sandbox/types.d.ts +0 -123
- package/dist/skills/index.d.ts +0 -4
- package/dist/skills/loader.d.ts +0 -43
- package/dist/skills/parser.d.ts +0 -31
- package/dist/skills/service.d.ts +0 -41
- package/dist/skills/types.d.ts +0 -94
- package/dist/subagent/index.d.ts +0 -5
- package/dist/subagent/orchestrator.d.ts +0 -169
- package/dist/subagent/registry-scope.d.ts +0 -41
- package/dist/subagent/semaphore.d.ts +0 -56
- package/dist/subagent/spawn-tool.d.ts +0 -86
- package/dist/subagent/types.d.ts +0 -65
- package/dist/testing/detect.d.ts +0 -3
- package/dist/testing/index.d.ts +0 -5
- package/dist/testing/parse.d.ts +0 -33
- package/dist/testing/run-tests-tool.d.ts +0 -64
- package/dist/testing/runner.d.ts +0 -26
- package/dist/testing/sandbox-runner.d.ts +0 -16
- package/dist/testing/types.d.ts +0 -66
- package/dist/theme/index.d.ts +0 -2
- package/dist/theme/resolve.d.ts +0 -43
- package/dist/theme/tokens.d.ts +0 -125
- package/dist/tools/create-pull-request.d.ts +0 -27
- package/dist/tools/file/apply-patch.d.ts +0 -94
- package/dist/tools/file/edit-file.d.ts +0 -12
- package/dist/tools/file/glob.d.ts +0 -17
- package/dist/tools/file/grep-files.d.ts +0 -43
- package/dist/tools/file/index.d.ts +0 -7
- package/dist/tools/file/match.d.ts +0 -43
- package/dist/tools/file/paths.d.ts +0 -160
- package/dist/tools/file/read-file.d.ts +0 -8
- package/dist/tools/file/write-file.d.ts +0 -10
- package/dist/tools/git-status.d.ts +0 -15
- package/dist/tools/index.d.ts +0 -9
- package/dist/tools/list-files.d.ts +0 -13
- package/dist/tools/list-skills.d.ts +0 -9
- package/dist/tools/load-skill.d.ts +0 -21
- package/dist/tools/registry.d.ts +0 -23
- package/dist/tools/search-codebase.d.ts +0 -35
- package/dist/tools/shell/exec.d.ts +0 -53
- package/dist/tools/shell/index.d.ts +0 -1
- package/dist/tools/shell/resolve-shell.d.ts +0 -81
- package/dist/tools/shell/run-command.d.ts +0 -14
- package/dist/tools/types.d.ts +0 -257
- package/dist/usage/collect.d.ts +0 -53
- package/dist/usage/cost.d.ts +0 -19
- package/dist/usage/index.d.ts +0 -15
- package/dist/usage/store.d.ts +0 -37
- package/dist/usage/summary.d.ts +0 -32
- package/dist/usage/types.d.ts +0 -283
- package/dist/utils/child-tree.d.ts +0 -33
- package/dist/utils/git.d.ts +0 -17
- package/dist/utils/logger.d.ts +0 -18
- package/dist/utils/process-tree.d.ts +0 -16
- package/dist/vcs/auth.d.ts +0 -22
- package/dist/vcs/generate.d.ts +0 -74
- package/dist/vcs/git.d.ts +0 -60
- package/dist/vcs/github.d.ts +0 -50
- package/dist/vcs/guidance.d.ts +0 -20
- package/dist/vcs/index.d.ts +0 -7
- package/dist/vcs/service.d.ts +0 -61
- package/dist/vcs/types.d.ts +0 -73
- package/dist/web/demarcate.d.ts +0 -13
- package/dist/web/fetch.d.ts +0 -11
- package/dist/web/index.d.ts +0 -7
- package/dist/web/provider.d.ts +0 -29
- package/dist/web/search.d.ts +0 -17
- package/dist/web/ssrf.d.ts +0 -41
- package/dist/web/tools.d.ts +0 -20
- package/dist/web/types.d.ts +0 -64
- package/dist/workspace/add-root.d.ts +0 -27
- package/dist/workspace/index.d.ts +0 -6
- package/dist/workspace/resolve.d.ts +0 -54
- package/dist/workspace/select.d.ts +0 -41
- package/dist/workspace/types.d.ts +0 -30
- package/dist/workspace/workspace.d.ts +0 -61
package/dist/hooks/types.d.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Types for hooks + custom slash commands (C.19). Everything here is **data**:
|
|
4
|
-
* hook and command definitions are validated (fail-loud, malformed excluded) and
|
|
5
|
-
* NEVER eval'd — a hook's `command` string only ever reaches execution through
|
|
6
|
-
* the shared U.3-gated + C.16-sandboxed shell path (see `runner.ts`), exactly
|
|
7
|
-
* like an agent-run command.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* The core hook lifecycle events. Deliberately a small, closed set for this
|
|
11
|
-
* build; the enum is the extension point for future events (out of scope).
|
|
12
|
-
* - `before-run` / `after-run` — around a whole user turn (the agent loop).
|
|
13
|
-
* - `before-tool` / `after-tool` — around each tool call.
|
|
14
|
-
* - `on-file-change` — after a file-mutating tool (write/edit/patch) succeeds.
|
|
15
|
-
*/
|
|
16
|
-
export declare const HOOK_EVENTS: readonly ["before-run", "after-run", "before-tool", "after-tool", "on-file-change"];
|
|
17
|
-
export type HookEvent = (typeof HOOK_EVENTS)[number];
|
|
18
|
-
/** `before-*` events default to blocking (fail-closed pre-checks); everything
|
|
19
|
-
* that fires *after* an action defaults to advisory. Overridable per hook. */
|
|
20
|
-
export declare function defaultBlocking(event: HookEvent): boolean;
|
|
21
|
-
/** Where a hook / command was discovered. `project` is the supply-chain-risky
|
|
22
|
-
* source (another author); `user` is your own `~/.cruxy`. */
|
|
23
|
-
export type HookSource = "project" | "user";
|
|
24
|
-
/** Precedence: a project definition overrides a user one of the same name. */
|
|
25
|
-
export declare const HOOK_SOURCE_PRECEDENCE: readonly HookSource[];
|
|
26
|
-
/** Strict schema for one hook definition in a `hooks.json`. Unknown keys are a
|
|
27
|
-
* loud error (`.strict()`); `blocking` is optional (resolved from the event). */
|
|
28
|
-
export declare const HookSpecSchema: z.ZodObject<{
|
|
29
|
-
name: z.ZodString;
|
|
30
|
-
event: z.ZodEnum<["before-run", "after-run", "before-tool", "after-tool", "on-file-change"]>;
|
|
31
|
-
command: z.ZodString;
|
|
32
|
-
blocking: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
-
}, "strict", z.ZodTypeAny, {
|
|
34
|
-
name: string;
|
|
35
|
-
command: string;
|
|
36
|
-
event: "before-run" | "after-run" | "before-tool" | "after-tool" | "on-file-change";
|
|
37
|
-
blocking?: boolean | undefined;
|
|
38
|
-
}, {
|
|
39
|
-
name: string;
|
|
40
|
-
command: string;
|
|
41
|
-
event: "before-run" | "after-run" | "before-tool" | "after-tool" | "on-file-change";
|
|
42
|
-
blocking?: boolean | undefined;
|
|
43
|
-
}>;
|
|
44
|
-
export type HookSpec = z.infer<typeof HookSpecSchema>;
|
|
45
|
-
/** The whole `hooks.json` file shape. */
|
|
46
|
-
export declare const HooksFileSchema: z.ZodObject<{
|
|
47
|
-
hooks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
48
|
-
name: z.ZodString;
|
|
49
|
-
event: z.ZodEnum<["before-run", "after-run", "before-tool", "after-tool", "on-file-change"]>;
|
|
50
|
-
command: z.ZodString;
|
|
51
|
-
blocking: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
-
}, "strict", z.ZodTypeAny, {
|
|
53
|
-
name: string;
|
|
54
|
-
command: string;
|
|
55
|
-
event: "before-run" | "after-run" | "before-tool" | "after-tool" | "on-file-change";
|
|
56
|
-
blocking?: boolean | undefined;
|
|
57
|
-
}, {
|
|
58
|
-
name: string;
|
|
59
|
-
command: string;
|
|
60
|
-
event: "before-run" | "after-run" | "before-tool" | "after-tool" | "on-file-change";
|
|
61
|
-
blocking?: boolean | undefined;
|
|
62
|
-
}>, "many">>;
|
|
63
|
-
}, "strict", z.ZodTypeAny, {
|
|
64
|
-
hooks: {
|
|
65
|
-
name: string;
|
|
66
|
-
command: string;
|
|
67
|
-
event: "before-run" | "after-run" | "before-tool" | "after-tool" | "on-file-change";
|
|
68
|
-
blocking?: boolean | undefined;
|
|
69
|
-
}[];
|
|
70
|
-
}, {
|
|
71
|
-
hooks?: {
|
|
72
|
-
name: string;
|
|
73
|
-
command: string;
|
|
74
|
-
event: "before-run" | "after-run" | "before-tool" | "after-tool" | "on-file-change";
|
|
75
|
-
blocking?: boolean | undefined;
|
|
76
|
-
}[] | undefined;
|
|
77
|
-
}>;
|
|
78
|
-
/** A validated hook, tagged with its source and with `blocking` resolved. */
|
|
79
|
-
export interface HookDefinition {
|
|
80
|
-
name: string;
|
|
81
|
-
event: HookEvent;
|
|
82
|
-
command: string;
|
|
83
|
-
/** Resolved (event default applied) — the value the runner acts on. */
|
|
84
|
-
blocking: boolean;
|
|
85
|
-
source: HookSource;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* A custom slash command. `prompt` (the safe default) expands a text template
|
|
89
|
-
* fed to the agent; `shell` binds a command that runs through the SAME gate +
|
|
90
|
-
* sandbox as everything else. Never arbitrary code by default.
|
|
91
|
-
*/
|
|
92
|
-
export type SlashKind = "prompt" | "shell";
|
|
93
|
-
/** Strict frontmatter for a `commands/<name>.md`. The command NAME comes from
|
|
94
|
-
* the filename; the markdown BODY is the prompt template (kind `prompt`). */
|
|
95
|
-
export declare const SlashFrontmatterSchema: z.ZodObject<{
|
|
96
|
-
kind: z.ZodDefault<z.ZodEnum<["prompt", "shell"]>>;
|
|
97
|
-
description: z.ZodString;
|
|
98
|
-
/** Required (and only meaningful) when `kind: "shell"`. */
|
|
99
|
-
command: z.ZodOptional<z.ZodString>;
|
|
100
|
-
}, "strict", z.ZodTypeAny, {
|
|
101
|
-
kind: "shell" | "prompt";
|
|
102
|
-
description: string;
|
|
103
|
-
command?: string | undefined;
|
|
104
|
-
}, {
|
|
105
|
-
description: string;
|
|
106
|
-
kind?: "shell" | "prompt" | undefined;
|
|
107
|
-
command?: string | undefined;
|
|
108
|
-
}>;
|
|
109
|
-
export type SlashFrontmatter = z.infer<typeof SlashFrontmatterSchema>;
|
|
110
|
-
/** A validated custom slash command, tagged with source. */
|
|
111
|
-
export interface SlashCommandSpec {
|
|
112
|
-
name: string;
|
|
113
|
-
kind: SlashKind;
|
|
114
|
-
description: string;
|
|
115
|
-
/** Prompt template (kind `prompt`); `{{args}}` is substituted at expansion. */
|
|
116
|
-
template?: string;
|
|
117
|
-
/** Shell command (kind `shell`) — gated + sandboxed when run. */
|
|
118
|
-
command?: string;
|
|
119
|
-
source: HookSource;
|
|
120
|
-
}
|
|
121
|
-
/** A malformed hook / command, excluded from the catalog and surfaced loudly
|
|
122
|
-
* (never eval'd, never silently dropped). */
|
|
123
|
-
export interface HookConfigError {
|
|
124
|
-
source: HookSource;
|
|
125
|
-
/** Absolute path of the offending file. */
|
|
126
|
-
file: string;
|
|
127
|
-
/** The would-be name (filename / spec name), for display. */
|
|
128
|
-
name: string;
|
|
129
|
-
message: string;
|
|
130
|
-
}
|
|
131
|
-
/** The resolved hook catalog: valid definitions (deduped by precedence) + the
|
|
132
|
-
* malformed ones that were excluded. */
|
|
133
|
-
export interface HookCatalog {
|
|
134
|
-
hooks: HookDefinition[];
|
|
135
|
-
commands: SlashCommandSpec[];
|
|
136
|
-
errors: HookConfigError[];
|
|
137
|
-
}
|
|
138
|
-
/** One repo's recorded trust decision (persisted in `~/.cruxy/trust.json`). The
|
|
139
|
-
* `fingerprint` binds trust to the exact hook commands seen at trust time. */
|
|
140
|
-
export interface HookTrust {
|
|
141
|
-
/** Absolute project root. */
|
|
142
|
-
root: string;
|
|
143
|
-
/** sha256 of the canonicalized project hook specs (see `trust.ts`). */
|
|
144
|
-
fingerprint: string;
|
|
145
|
-
/** ISO timestamp the decision was recorded. */
|
|
146
|
-
at: string;
|
|
147
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Chunk } from "./types.js";
|
|
2
|
-
/** Knobs for {@link chunkFile}. */
|
|
3
|
-
export interface ChunkOptions {
|
|
4
|
-
/** Target window size, in lines. */
|
|
5
|
-
windowLines: number;
|
|
6
|
-
/** Lines shared between consecutive windows (clamped to < windowLines). */
|
|
7
|
-
overlapLines: number;
|
|
8
|
-
/**
|
|
9
|
-
* How far (in lines) the window end may slide to land on a blank-line
|
|
10
|
-
* boundary. Keeps chunks aligned to natural gaps without drifting too far
|
|
11
|
-
* from the target size.
|
|
12
|
-
*/
|
|
13
|
-
snapSlack?: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Split a file's text into overlapping line windows.
|
|
17
|
-
*
|
|
18
|
-
* Windows are `windowLines` long and advance by `windowLines - overlapLines`, so
|
|
19
|
-
* consecutive chunks share `overlapLines` lines (context that would otherwise be
|
|
20
|
-
* severed at a hard cut). Where possible the window end is nudged — within
|
|
21
|
-
* `snapSlack` lines — to fall right after a blank line, so chunks break at
|
|
22
|
-
* natural boundaries (between functions, paragraphs, etc.).
|
|
23
|
-
*
|
|
24
|
-
* Line numbers are 1-based and inclusive. A whitespace-only (or empty) file
|
|
25
|
-
* yields no chunks. A file shorter than one window yields exactly one chunk.
|
|
26
|
-
* Coverage is gap-free: every source line belongs to at least one chunk.
|
|
27
|
-
*/
|
|
28
|
-
export declare function chunkFile(path: string, text: string, opts: ChunkOptions): Chunk[];
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output dimensionality of bge-small-en-v1.5, and the default size of the
|
|
3
|
-
* hashing embedder's feature space, so the two backends are interchangeable in
|
|
4
|
-
* the store schema.
|
|
5
|
-
*/
|
|
6
|
-
export declare const DEFAULT_DIM = 384;
|
|
7
|
-
/**
|
|
8
|
-
* Turns text into vectors. Two implementations ship: {@link FastEmbedEmbedder}
|
|
9
|
-
* (local ONNX, semantic) and {@link HashingEmbedder} (dependency-free,
|
|
10
|
-
* deterministic, lexical). The store records `id`; if it changes, the index is
|
|
11
|
-
* re-embedded from scratch (see `indexer.ts`).
|
|
12
|
-
*/
|
|
13
|
-
export interface Embedder {
|
|
14
|
-
/** Stable identity of this embedder + model. Persisted with the index. */
|
|
15
|
-
readonly id: string;
|
|
16
|
-
/** Embedding dimensionality. */
|
|
17
|
-
readonly dim: number;
|
|
18
|
-
/**
|
|
19
|
-
* Embed document/passage texts. Returns one L2-normalized vector per input,
|
|
20
|
-
* in the same order. An empty input yields an empty array.
|
|
21
|
-
*/
|
|
22
|
-
embed(texts: string[]): Promise<Float32Array[]>;
|
|
23
|
-
/**
|
|
24
|
-
* Embed a search query. May use a different representation than {@link embed}
|
|
25
|
-
* (e.g. bge prepends a retrieval instruction to queries).
|
|
26
|
-
*/
|
|
27
|
-
embedQuery(text: string): Promise<Float32Array>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Split text into lowercase lexical tokens, breaking identifiers on camelCase
|
|
31
|
-
* and snake/kebab boundaries so `getUserById` contributes `get`/`user`/`by`/`id`.
|
|
32
|
-
*/
|
|
33
|
-
export declare function tokenize(text: string): string[];
|
|
34
|
-
export interface HashingEmbedderOptions {
|
|
35
|
-
dim?: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A deterministic, dependency-free embedder: signed feature hashing
|
|
39
|
-
* (bag-of-words) over code-aware tokens, L2-normalized. It captures lexical
|
|
40
|
-
* overlap rather than true semantics, but it is offline, instant, and stable —
|
|
41
|
-
* which makes it the right default for tests and a sane fallback when the native
|
|
42
|
-
* embedding model is unavailable.
|
|
43
|
-
*/
|
|
44
|
-
export declare class HashingEmbedder implements Embedder {
|
|
45
|
-
readonly id: string;
|
|
46
|
-
readonly dim: number;
|
|
47
|
-
constructor(opts?: HashingEmbedderOptions);
|
|
48
|
-
embed(texts: string[]): Promise<Float32Array[]>;
|
|
49
|
-
embedQuery(text: string): Promise<Float32Array>;
|
|
50
|
-
private embedOne;
|
|
51
|
-
}
|
|
52
|
-
export interface FastEmbedEmbedderOptions {
|
|
53
|
-
/** Where the ONNX model is downloaded/cached. Defaults to fastembed's own dir. */
|
|
54
|
-
cacheDir?: string;
|
|
55
|
-
/** Max model input length, in tokens. */
|
|
56
|
-
maxLength?: number;
|
|
57
|
-
/** Texts per inference batch. */
|
|
58
|
-
batchSize?: number;
|
|
59
|
-
/** Print the model download progress on first run. */
|
|
60
|
-
showDownloadProgress?: boolean;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Local semantic embeddings via fastembed (ONNX), model bge-small-en-v1.5
|
|
64
|
-
* (384-dim). The native dependency is imported lazily on first use, so merely
|
|
65
|
-
* registering the `search_codebase` tool stays cheap and the heavy ONNX runtime
|
|
66
|
-
* only loads when an index is actually built or queried.
|
|
67
|
-
*
|
|
68
|
-
* Embedding is CPU-bound and single-threaded inside ONNX, so throughput is
|
|
69
|
-
* bounded by `batchSize` (fed sequentially through fastembed's batching
|
|
70
|
-
* generator) rather than by JS-level concurrency.
|
|
71
|
-
*/
|
|
72
|
-
export declare class FastEmbedEmbedder implements Embedder {
|
|
73
|
-
readonly id = "fastembed:bge-small-en-v1.5";
|
|
74
|
-
readonly dim = 384;
|
|
75
|
-
private readonly opts;
|
|
76
|
-
private model;
|
|
77
|
-
constructor(opts?: FastEmbedEmbedderOptions);
|
|
78
|
-
private getModel;
|
|
79
|
-
embed(texts: string[]): Promise<Float32Array[]>;
|
|
80
|
-
embedQuery(text: string): Promise<Float32Array>;
|
|
81
|
-
}
|
|
82
|
-
export interface CreateEmbedderOptions {
|
|
83
|
-
/** Cache dir for the fastembed model. */
|
|
84
|
-
cacheDir?: string;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Build the **production** embedder: fastembed / bge-small-en-v1.5.
|
|
88
|
-
*
|
|
89
|
-
* The native dependency is loaded eagerly here so a missing or broken install
|
|
90
|
-
* fails *now*, loudly, with an actionable message — rather than silently
|
|
91
|
-
* degrading search quality at query time. There is deliberately **no** fallback
|
|
92
|
-
* to {@link HashingEmbedder}: that backend is reachable only by explicit
|
|
93
|
-
* injection in tests (see `getIndexService`'s `deps.embedder`), never selected
|
|
94
|
-
* automatically by this factory or by config.
|
|
95
|
-
*
|
|
96
|
-
* @throws if the fastembed native module cannot be loaded.
|
|
97
|
-
*/
|
|
98
|
-
export declare function createEmbedder(opts?: CreateEmbedderOptions): Promise<Embedder>;
|
package/dist/indexing/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./types.js";
|
|
2
|
-
export * from "./util.js";
|
|
3
|
-
export * from "./chunker.js";
|
|
4
|
-
export * from "./embedder.js";
|
|
5
|
-
export * from "./store.js";
|
|
6
|
-
export * from "./walker.js";
|
|
7
|
-
export * from "./indexer.js";
|
|
8
|
-
export * from "./retriever.js";
|
|
9
|
-
export * from "./service.js";
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type ChunkOptions } from "./chunker.js";
|
|
2
|
-
import type { Embedder } from "./embedder.js";
|
|
3
|
-
import type { VectorStore } from "./store.js";
|
|
4
|
-
import type { IndexStats } from "./types.js";
|
|
5
|
-
/** Minimal logger surface the indexer reports progress to. */
|
|
6
|
-
interface IndexerLogger {
|
|
7
|
-
debug(message: string): void;
|
|
8
|
-
info(message: string): void;
|
|
9
|
-
}
|
|
10
|
-
export interface IndexerOptions {
|
|
11
|
-
/** Absolute project root to index. */
|
|
12
|
-
root: string;
|
|
13
|
-
/** Where embeddings are stored. */
|
|
14
|
-
store: VectorStore;
|
|
15
|
-
/** How text is turned into vectors. */
|
|
16
|
-
embedder: Embedder;
|
|
17
|
-
/** Hard per-file size cap, in bytes. */
|
|
18
|
-
maxFileBytes: number;
|
|
19
|
-
/** Chunking parameters. */
|
|
20
|
-
chunk: ChunkOptions;
|
|
21
|
-
/** Concurrency for reading/hashing files. */
|
|
22
|
-
readConcurrency?: number;
|
|
23
|
-
/** Files chunked + embedded + upserted per batch (bounds peak memory). */
|
|
24
|
-
fileBatchSize?: number;
|
|
25
|
-
/** Optional progress logger. */
|
|
26
|
-
logger?: IndexerLogger;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Orchestrates the index: walk → hash → (skip unchanged | chunk → embed →
|
|
30
|
-
* upsert) → purge removed.
|
|
31
|
-
*
|
|
32
|
-
* Incrementality is content-hash based: a file is re-embedded only when its
|
|
33
|
-
* bytes change; unchanged files are skipped; files that disappeared (deleted or
|
|
34
|
-
* newly ignored) are purged. Changing the embedder (a new model or dimension)
|
|
35
|
-
* invalidates the whole index — its signature is stored, and a mismatch forces a
|
|
36
|
-
* full re-embed so vectors never mix across models.
|
|
37
|
-
*/
|
|
38
|
-
export declare class Indexer {
|
|
39
|
-
private readonly opts;
|
|
40
|
-
constructor(opts: IndexerOptions);
|
|
41
|
-
index(runOpts?: {
|
|
42
|
-
force?: boolean;
|
|
43
|
-
}): Promise<IndexStats>;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Embedder } from "./embedder.js";
|
|
2
|
-
import type { VectorStore } from "./store.js";
|
|
3
|
-
import type { SearchHit } from "./types.js";
|
|
4
|
-
/** Inputs to {@link searchCodebase}. */
|
|
5
|
-
export interface SearchOptions {
|
|
6
|
-
query: string;
|
|
7
|
-
/** Number of hits to return; falls back to `defaultK`. Clamped to [1, 50]. */
|
|
8
|
-
k?: number;
|
|
9
|
-
/** Optional glob restricting results by path, e.g. `src/**\/*.ts`. */
|
|
10
|
-
pathGlob?: string;
|
|
11
|
-
/**
|
|
12
|
-
* The declared name of the root being searched (C.26). Stamped onto every
|
|
13
|
-
* returned hit so a fanned multi-root search can attribute each hit to its
|
|
14
|
-
* source root. Required: this retriever runs against exactly one root's store,
|
|
15
|
-
* so the caller that selected that store names it here — no hit is unattributed.
|
|
16
|
-
*/
|
|
17
|
-
root: string;
|
|
18
|
-
/**
|
|
19
|
-
* Per-call override of the snippet token budget (C.26). A fanned multi-root
|
|
20
|
-
* search passes `Infinity` so each root returns its top-k by score *unbudgeted*,
|
|
21
|
-
* then applies the real budget ONCE over the merged set ({@link mergeRankedHits},
|
|
22
|
-
* ⚖︎JC-I) — a true global budget, not the budget applied N× (once per root).
|
|
23
|
-
* Omitted by single-root callers, who keep the config budget (byte-identical).
|
|
24
|
-
*/
|
|
25
|
-
tokenBudget?: number;
|
|
26
|
-
}
|
|
27
|
-
/** Collaborators + budget knobs for the retriever. */
|
|
28
|
-
export interface RetrieverDeps {
|
|
29
|
-
store: VectorStore;
|
|
30
|
-
embedder: Embedder;
|
|
31
|
-
/** `k` used when the caller omits it. */
|
|
32
|
-
defaultK: number;
|
|
33
|
-
/** Approximate combined-snippet token budget (chars/4 heuristic). */
|
|
34
|
-
tokenBudget: number;
|
|
35
|
-
/** Maximum lines kept in any single snippet. */
|
|
36
|
-
maxSnippetLines: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Embed the query, run a cosine top-k over the index, and return ranked hits.
|
|
40
|
-
*
|
|
41
|
-
* Results are token-budgeted: snippets are trimmed to `maxSnippetLines`, then
|
|
42
|
-
* hits are appended only while the combined snippet estimate stays under
|
|
43
|
-
* `tokenBudget` — except the top hit, which is always included so a single large
|
|
44
|
-
* match is never dropped. This keeps tool output from flooding the agent's
|
|
45
|
-
* context window.
|
|
46
|
-
*/
|
|
47
|
-
export declare function searchCodebase(deps: RetrieverDeps, opts: SearchOptions): Promise<SearchHit[]>;
|
|
48
|
-
/**
|
|
49
|
-
* Merge per-root hit lists into one globally-ranked, budgeted, k-capped list —
|
|
50
|
-
* the cross-root half of a fanned {@link searchCodebase}. The cap and the token
|
|
51
|
-
* budget are applied **after** the merge (⚖︎JC-I), so `k` is a global top-k across
|
|
52
|
-
* all roots (a strong hit in root B is never crowded out by weaker hits in root A
|
|
53
|
-
* that a per-root cap happened to keep), and the combined snippet budget is
|
|
54
|
-
* honored once for the whole result — not N× as it would be if each root budgeted
|
|
55
|
-
* independently. Hits already carry their `root`, so the merge never loses
|
|
56
|
-
* attribution. Mirrors the single-root budget rule: always keep the top hit.
|
|
57
|
-
*/
|
|
58
|
-
export declare function mergeRankedHits(perRoot: readonly (readonly SearchHit[])[], opts: {
|
|
59
|
-
k: number;
|
|
60
|
-
tokenBudget: number;
|
|
61
|
-
}): SearchHit[];
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { CruxyConfig } from "../config/index.js";
|
|
2
|
-
import { type Embedder } from "./embedder.js";
|
|
3
|
-
import { type SearchOptions } from "./retriever.js";
|
|
4
|
-
import type { IndexStats, IndexStatus, SearchHit } from "./types.js";
|
|
5
|
-
/** Logger surface the service reports through. */
|
|
6
|
-
interface ServiceLogger {
|
|
7
|
-
debug(message: string): void;
|
|
8
|
-
info(message: string): void;
|
|
9
|
-
warn(message: string): void;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A ready-to-use index for one project root: it owns the store, embedder, and
|
|
13
|
-
* indexer, exposes `search`/`index`/`status`, and refreshes itself lazily on the
|
|
14
|
-
* first search. Build one with {@link getIndexService}, which caches per cwd so
|
|
15
|
-
* the heavy backends are constructed at most once per process.
|
|
16
|
-
*/
|
|
17
|
-
export interface IndexService {
|
|
18
|
-
/** Search the index, refreshing it first if it hasn't been this process. */
|
|
19
|
-
search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
20
|
-
/** Build/refresh the index (incremental unless `force`). */
|
|
21
|
-
index(runOpts?: {
|
|
22
|
-
force?: boolean;
|
|
23
|
-
}): Promise<IndexStats>;
|
|
24
|
-
/** Read-only snapshot for `cruxy index --status` (does not modify the index). */
|
|
25
|
-
status(): IndexStatus;
|
|
26
|
-
/** Release backend resources. */
|
|
27
|
-
close(): void;
|
|
28
|
-
}
|
|
29
|
-
/** Absolute path of the SQLite index for a project root. */
|
|
30
|
-
export declare function indexDbPath(cwd: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* Explicit dependency overrides. The sole supported override is `embedder`: it
|
|
33
|
-
* is the *only* way to substitute a non-production embedder (e.g.
|
|
34
|
-
* `HashingEmbedder`) and exists for tests. Production callers (the
|
|
35
|
-
* `search_codebase` tool, `cruxy index`) never pass it, so they always go
|
|
36
|
-
* through {@link createEmbedder} — fastembed or a loud failure.
|
|
37
|
-
*/
|
|
38
|
-
export interface IndexServiceDeps {
|
|
39
|
-
embedder?: Embedder;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get (or build) the {@link IndexService} for a project root, cached per
|
|
43
|
-
* resolved cwd so the embedder + store are created at most once per process.
|
|
44
|
-
* `deps` is for explicit test injection only (see {@link IndexServiceDeps}).
|
|
45
|
-
*/
|
|
46
|
-
export declare function getIndexService(cwd: string, config: CruxyConfig, logger: ServiceLogger, deps?: IndexServiceDeps): Promise<IndexService>;
|
|
47
|
-
/** Drop all cached services (closing them). For tests and process teardown. */
|
|
48
|
-
export declare function resetIndexServices(): Promise<void>;
|
|
49
|
-
export {};
|
package/dist/indexing/store.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type DatabaseNs from "better-sqlite3";
|
|
2
|
-
import type { EmbeddedChunk, ScoredRecord } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Vector storage for the codebase index. The {@link VectorStore} interface hides
|
|
5
|
-
* the backend so the brute-force cosine search here can be swapped for an ANN
|
|
6
|
-
* index later without touching the indexer, retriever, or tool. Two backends
|
|
7
|
-
* ship: {@link SqliteVectorStore} (persistent, the default) and
|
|
8
|
-
* {@link InMemoryVectorStore} (ephemeral, for tests).
|
|
9
|
-
*
|
|
10
|
-
* Vectors are stored L2-normalized, so cosine similarity reduces to a dot
|
|
11
|
-
* product (see {@link dot}).
|
|
12
|
-
*/
|
|
13
|
-
/** Embedder identity + dimensionality the index was built with. */
|
|
14
|
-
export interface VectorStoreMeta {
|
|
15
|
-
embedderId: string;
|
|
16
|
-
dim: number;
|
|
17
|
-
}
|
|
18
|
-
export interface VectorStore {
|
|
19
|
-
/** Embedder identity + dim recorded for this index, or null if never set. */
|
|
20
|
-
getMeta(): VectorStoreMeta | null;
|
|
21
|
-
/** Record the embedder identity + dim. Called when the index is (re)initialized. */
|
|
22
|
-
setMeta(meta: VectorStoreMeta): void;
|
|
23
|
-
/** Map of indexed file path → content hash, for incremental decisions. */
|
|
24
|
-
getFileHashes(): Map<string, string>;
|
|
25
|
-
/** Replace every chunk for `path` with `chunks` and record its hash. Atomic. */
|
|
26
|
-
upsertFile(path: string, hash: string, chunks: EmbeddedChunk[]): void;
|
|
27
|
-
/** Remove a file and all of its chunks. */
|
|
28
|
-
deleteByPath(path: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* Brute-force cosine top-k over stored vectors, optionally restricted to paths
|
|
31
|
-
* for which `pathFilter` returns true. Results are sorted by score, descending.
|
|
32
|
-
*/
|
|
33
|
-
search(query: Float32Array, k: number, pathFilter?: (path: string) => boolean): ScoredRecord[];
|
|
34
|
-
/** Number of indexed files. */
|
|
35
|
-
countFiles(): number;
|
|
36
|
-
/** Number of stored chunks. */
|
|
37
|
-
countChunks(): number;
|
|
38
|
-
/** Release any held resources (e.g. the SQLite handle). Idempotent. */
|
|
39
|
-
close(): void;
|
|
40
|
-
}
|
|
41
|
-
/** Dot product over the overlapping prefix of two vectors. */
|
|
42
|
-
export declare function dot(a: Float32Array, b: Float32Array): number;
|
|
43
|
-
/** Cosine similarity in [-1, 1]. Returns 0 if either vector is all-zero. */
|
|
44
|
-
export declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
45
|
-
/** Serialize a vector to a little-endian Float32 BLOB (an owning copy). */
|
|
46
|
-
export declare function vectorToBlob(v: Float32Array): Buffer;
|
|
47
|
-
/** Deserialize a little-endian Float32 BLOB back into a vector. */
|
|
48
|
-
export declare function blobToVector(buf: Buffer): Float32Array;
|
|
49
|
-
/** Indices of the `k` largest scores, sorted descending. */
|
|
50
|
-
export declare function topKIndices(scores: ArrayLike<number>, k: number): number[];
|
|
51
|
-
/**
|
|
52
|
-
* A non-persistent {@link VectorStore} backed by plain JS maps. Used by the test
|
|
53
|
-
* suite and as the `auto` fallback when the SQLite native dependency is
|
|
54
|
-
* unavailable. Holds everything in memory; rebuilt on each process.
|
|
55
|
-
*/
|
|
56
|
-
export declare class InMemoryVectorStore implements VectorStore {
|
|
57
|
-
private meta;
|
|
58
|
-
private readonly fileHashes;
|
|
59
|
-
private readonly chunksByPath;
|
|
60
|
-
getMeta(): VectorStoreMeta | null;
|
|
61
|
-
setMeta(meta: VectorStoreMeta): void;
|
|
62
|
-
getFileHashes(): Map<string, string>;
|
|
63
|
-
upsertFile(path: string, hash: string, chunks: EmbeddedChunk[]): void;
|
|
64
|
-
deleteByPath(path: string): void;
|
|
65
|
-
countFiles(): number;
|
|
66
|
-
countChunks(): number;
|
|
67
|
-
search(query: Float32Array, k: number, pathFilter?: (path: string) => boolean): ScoredRecord[];
|
|
68
|
-
close(): void;
|
|
69
|
-
}
|
|
70
|
-
type DB = DatabaseNs.Database;
|
|
71
|
-
/**
|
|
72
|
-
* Persistent {@link VectorStore} backed by better-sqlite3 at `.cruxy/index.db`.
|
|
73
|
-
* Vectors are stored as Float32 BLOBs; search lazily loads them into one
|
|
74
|
-
* contiguous matrix (cached until the next write) so warm queries are a tight
|
|
75
|
-
* dot-product scan rather than per-row deserialization.
|
|
76
|
-
*
|
|
77
|
-
* Construct via {@link createSqliteVectorStore}, which loads the native module.
|
|
78
|
-
*/
|
|
79
|
-
export declare class SqliteVectorStore implements VectorStore {
|
|
80
|
-
private readonly db;
|
|
81
|
-
private cache;
|
|
82
|
-
private closed;
|
|
83
|
-
constructor(db: DB);
|
|
84
|
-
getMeta(): VectorStoreMeta | null;
|
|
85
|
-
setMeta(meta: VectorStoreMeta): void;
|
|
86
|
-
getFileHashes(): Map<string, string>;
|
|
87
|
-
upsertFile(path: string, hash: string, chunks: EmbeddedChunk[]): void;
|
|
88
|
-
deleteByPath(path: string): void;
|
|
89
|
-
countFiles(): number;
|
|
90
|
-
countChunks(): number;
|
|
91
|
-
search(query: Float32Array, k: number, pathFilter?: (path: string) => boolean): ScoredRecord[];
|
|
92
|
-
close(): void;
|
|
93
|
-
private ensureCache;
|
|
94
|
-
private getMetaValue;
|
|
95
|
-
private setMetaValue;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Open (or create) a {@link SqliteVectorStore} at `dbPath`. The native module is
|
|
99
|
-
* imported lazily here, so nothing loads it until an index is actually used.
|
|
100
|
-
* The parent directory must already exist.
|
|
101
|
-
*/
|
|
102
|
-
export declare function createSqliteVectorStore(dbPath: string): Promise<SqliteVectorStore>;
|
|
103
|
-
export {};
|
package/dist/indexing/types.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types for the codebase index (C.17). Kept in one place so the walker,
|
|
3
|
-
* chunker, embedder, store, indexer, and retriever can depend on the same
|
|
4
|
-
* vocabulary without import cycles — mirroring `src/tools/types.ts`.
|
|
5
|
-
*/
|
|
6
|
-
/** A contiguous slice of a source file: the unit that gets embedded and stored. */
|
|
7
|
-
export interface Chunk {
|
|
8
|
-
/** Project-relative POSIX path of the source file. */
|
|
9
|
-
path: string;
|
|
10
|
-
/** 1-based line where the chunk begins (inclusive). */
|
|
11
|
-
startLine: number;
|
|
12
|
-
/** 1-based line where the chunk ends (inclusive). */
|
|
13
|
-
endLine: number;
|
|
14
|
-
/** The chunk's raw text (the joined source lines). */
|
|
15
|
-
text: string;
|
|
16
|
-
}
|
|
17
|
-
/** A chunk paired with its embedding, ready to persist. */
|
|
18
|
-
export interface EmbeddedChunk {
|
|
19
|
-
chunk: Chunk;
|
|
20
|
-
/** L2-normalized embedding; length equals the embedder's `dim`. */
|
|
21
|
-
vector: Float32Array;
|
|
22
|
-
}
|
|
23
|
-
/** A stored chunk scored against a query, as returned by `VectorStore.search`. */
|
|
24
|
-
export interface ScoredRecord {
|
|
25
|
-
path: string;
|
|
26
|
-
startLine: number;
|
|
27
|
-
endLine: number;
|
|
28
|
-
text: string;
|
|
29
|
-
/** Cosine similarity in [-1, 1]; higher is more relevant. */
|
|
30
|
-
score: number;
|
|
31
|
-
}
|
|
32
|
-
/** One ranked search result handed back to the agent. */
|
|
33
|
-
export interface SearchHit {
|
|
34
|
-
/**
|
|
35
|
-
* The declared name of the root this hit was indexed from (C.26). Required —
|
|
36
|
-
* so a hit can never be un-attributed — and stamped at construction from the
|
|
37
|
-
* same root whose store produced it, which is what lets a fanned multi-root
|
|
38
|
-
* search label each hit with its true source (the honesty pin).
|
|
39
|
-
*/
|
|
40
|
-
root: string;
|
|
41
|
-
path: string;
|
|
42
|
-
startLine: number;
|
|
43
|
-
endLine: number;
|
|
44
|
-
/** Cosine similarity in [-1, 1], rounded for display. */
|
|
45
|
-
score: number;
|
|
46
|
-
/** The (possibly trimmed) source snippet for the chunk. */
|
|
47
|
-
snippet: string;
|
|
48
|
-
}
|
|
49
|
-
/** Outcome of an indexing run, surfaced by `cruxy index`. */
|
|
50
|
-
export interface IndexStats {
|
|
51
|
-
/** Candidate text files remaining after the walk's ignore/size/binary filters. */
|
|
52
|
-
filesSeen: number;
|
|
53
|
-
/** Files added or re-embedded this run (content changed, new, or forced). */
|
|
54
|
-
filesIndexed: number;
|
|
55
|
-
/** Files skipped because their content hash was unchanged. */
|
|
56
|
-
filesSkipped: number;
|
|
57
|
-
/** Files removed from the index (deleted on disk or newly ignored). */
|
|
58
|
-
filesPurged: number;
|
|
59
|
-
/** Chunks embedded this run. */
|
|
60
|
-
chunksIndexed: number;
|
|
61
|
-
/** Wall-clock duration in milliseconds. */
|
|
62
|
-
durationMs: number;
|
|
63
|
-
}
|
|
64
|
-
/** Snapshot of the on-disk index for `cruxy index --status`. */
|
|
65
|
-
export interface IndexStatus {
|
|
66
|
-
/** Whether a populated index already exists. */
|
|
67
|
-
exists: boolean;
|
|
68
|
-
/** Embedder identity the index was built with (e.g. `fastembed:bge-small-en-v1.5`). */
|
|
69
|
-
embedderId: string | null;
|
|
70
|
-
/** Embedding dimensionality recorded in the index. */
|
|
71
|
-
dim: number | null;
|
|
72
|
-
/** Number of indexed files. */
|
|
73
|
-
files: number;
|
|
74
|
-
/** Number of stored chunks. */
|
|
75
|
-
chunks: number;
|
|
76
|
-
/** Absolute path of the index store, or null for an in-memory store. */
|
|
77
|
-
storePath: string | null;
|
|
78
|
-
}
|
package/dist/indexing/util.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Small shared helpers for the index pipeline: content hashing, vector
|
|
3
|
-
* normalization, a bounded-concurrency map, a token estimate, and glob→RegExp
|
|
4
|
-
* compilation (reused by both the `pathGlob` search filter and the gitignore
|
|
5
|
-
* matcher in `walker.ts`).
|
|
6
|
-
*/
|
|
7
|
-
/** Stable content hash of a file's bytes — sha256, hex. Drives incremental indexing. */
|
|
8
|
-
export declare function contentHash(data: Buffer | string): string;
|
|
9
|
-
/**
|
|
10
|
-
* L2-normalize `v` in place and return it. A zero vector is left untouched (its
|
|
11
|
-
* norm is 0). Normalizing at embed time lets the store treat cosine similarity
|
|
12
|
-
* as a plain dot product.
|
|
13
|
-
*/
|
|
14
|
-
export declare function l2normalize(v: Float32Array): Float32Array;
|
|
15
|
-
/**
|
|
16
|
-
* Approximate token count via the chars/4 heuristic used elsewhere in the CLI
|
|
17
|
-
* (see `agent/session.ts`). Good enough to budget snippet sizes.
|
|
18
|
-
*/
|
|
19
|
-
export declare function estimateTokens(text: string): number;
|
|
20
|
-
/**
|
|
21
|
-
* Run `fn` over `items` with at most `limit` calls in flight, preserving input
|
|
22
|
-
* order in the result. Used to bound filesystem/CPU concurrency during indexing.
|
|
23
|
-
*/
|
|
24
|
-
export declare function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
25
|
-
/**
|
|
26
|
-
* Convert a glob into the *body* of a RegExp (no anchors), supporting `*`
|
|
27
|
-
* (within a path segment), `**` (across segments, including zero), and `?`
|
|
28
|
-
* (a single non-separator char). Backslashes are normalized to `/` first.
|
|
29
|
-
*/
|
|
30
|
-
export declare function globToRegexBody(glob: string): string;
|
|
31
|
-
/** Compile a glob into a RegExp anchored to a full POSIX path. */
|
|
32
|
-
export declare function globToRegExp(glob: string): RegExp;
|
|
33
|
-
/** Sniff the head of a buffer for a NUL byte — the cheap "is this binary?" test. */
|
|
34
|
-
export declare function isBinary(buf: Buffer, sniffBytes?: number): boolean;
|