@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/checkpoint/set.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { CheckpointSet, RollbackApplied, SetRollbackApplied } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Multi-root rollback sets (C.26). A run that mutates N repos produces one
|
|
4
|
-
* per-root checkpoint plus a {@link CheckpointSet} that ties them together, so
|
|
5
|
-
* `cruxy rollback` restores exactly the touched roots as one gated operation.
|
|
6
|
-
*
|
|
7
|
-
* Two guarantees live here:
|
|
8
|
-
* • **exactly the touched roots** — the applier iterates ONLY `set.members`, so
|
|
9
|
-
* an untouched root (absent from the set) is never opened;
|
|
10
|
-
* • **stop-and-report, never silent partial** (R3) — validate every member up
|
|
11
|
-
* front (missing/corrupt → `CHECKPOINT_SET_INCOMPLETE`), then apply
|
|
12
|
-
* sequentially and STOP on the first failure, throwing
|
|
13
|
-
* `CHECKPOINT_SET_PARTIAL` with the exact restored-vs-not split.
|
|
14
|
-
*/
|
|
15
|
-
/** `run-<utc-stamp>-<rand>` — sortable, collision-safe enough for a local CLI. */
|
|
16
|
-
export declare function newRunId(): string;
|
|
17
|
-
/** The set-manifest directory under the PRIMARY root (⚖︎#7). */
|
|
18
|
-
export declare function setDir(primaryRoot: string): string;
|
|
19
|
-
/** Persist a set manifest (atomic temp-then-rename), self-ignoring from git. */
|
|
20
|
-
export declare function writeSet(primaryRoot: string, set: CheckpointSet): Promise<void>;
|
|
21
|
-
/** Read a set manifest, or throw `CHECKPOINT_SET_INCOMPLETE` if missing/corrupt. */
|
|
22
|
-
export declare function readSet(primaryRoot: string, runId: string): Promise<CheckpointSet>;
|
|
23
|
-
/** List all set manifests under the primary root, newest first. */
|
|
24
|
-
export declare function listSets(primaryRoot: string): Promise<CheckpointSet[]>;
|
|
25
|
-
/**
|
|
26
|
-
* One root's rollback, pre-validated (its plan already computed): `restore`
|
|
27
|
-
* actually applies it. The orchestrator builds one per member.
|
|
28
|
-
*/
|
|
29
|
-
export interface MemberRollback {
|
|
30
|
-
rootName: string;
|
|
31
|
-
restore: () => Promise<RollbackApplied>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Apply an all-roots rollback: run each member's `restore` in order and STOP on
|
|
35
|
-
* the first failure (R3). On success, returns the restored-vs-per-root summary.
|
|
36
|
-
* On failure, throws `CHECKPOINT_SET_PARTIAL` naming the roots restored (before
|
|
37
|
-
* the failure) and those not restored (the failing one + all not-yet-attempted)
|
|
38
|
-
* — so a partial rollback can never be reported as success, and re-running (which
|
|
39
|
-
* recomputes each root from disk) safely finishes the job.
|
|
40
|
-
*
|
|
41
|
-
* The applier only ever touches roots present in `rollbacks`; an untouched root
|
|
42
|
-
* (never added to the set) is structurally impossible to open here.
|
|
43
|
-
*/
|
|
44
|
-
export declare function applySetRollback(runId: string, rollbacks: readonly MemberRollback[]): Promise<SetRollbackApplied>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { CaptureFile, CheckpointStore, FileEntry } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Shadow-copy checkpoint content store (C.32 fallback substrate): used outside
|
|
4
|
-
* a git repo, or when git plumbing fails mid-snapshot. File contents live in a
|
|
5
|
-
* content-addressed pool at `.cruxy/checkpoints/objects/<sha256>` — identical
|
|
6
|
-
* content across files or checkpoints is stored once, and pruning sweeps
|
|
7
|
-
* objects no longer referenced by any surviving manifest.
|
|
8
|
-
*
|
|
9
|
-
* Writes are temp-file-then-rename so a crash can never leave a torn object; a
|
|
10
|
-
* torn *read* is impossible because an object either exists complete or not at
|
|
11
|
-
* all, and a missing object fails loudly.
|
|
12
|
-
*/
|
|
13
|
-
export declare class ShadowCheckpointStore implements CheckpointStore {
|
|
14
|
-
readonly kind: "shadow";
|
|
15
|
-
private readonly objectsDir;
|
|
16
|
-
constructor(root: string);
|
|
17
|
-
hashContent(content: Buffer): string;
|
|
18
|
-
snapshot(files: CaptureFile[]): Promise<FileEntry[]>;
|
|
19
|
-
readContent(entry: FileEntry): Promise<Buffer>;
|
|
20
|
-
collect(referenced: ReadonlySet<string>): Promise<void>;
|
|
21
|
-
/** Content-addressed write: skip if present, else temp-then-rename (atomic). */
|
|
22
|
-
private writeObject;
|
|
23
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Working-tree checkpoints (C.32): a complete snapshot of everything the agent
|
|
3
|
-
* could touch, captured before a run's first mutation, so `cruxy rollback` can
|
|
4
|
-
* undo the entire run — creates, edits, deletes — in one gated operation.
|
|
5
|
-
*
|
|
6
|
-
* Two layers, deliberately separated:
|
|
7
|
-
* • {@link CheckpointStore} — the *content substrate* (where file bytes
|
|
8
|
-
* live), swappable like VectorStore: git-object-backed in a repo, a
|
|
9
|
-
* content-addressed shadow copy otherwise.
|
|
10
|
-
* • The manifest — uniform JSON under `.cruxy/checkpoints/`, owned by the
|
|
11
|
-
* service regardless of substrate, so list/prune/rollback never care which
|
|
12
|
-
* store wrote a checkpoint.
|
|
13
|
-
*
|
|
14
|
-
* Explicit boundary: checkpoints cover WORKING-TREE file state only. They can
|
|
15
|
-
* never undo git commits, pushes, or PRs made during a run (C.15) — that is
|
|
16
|
-
* stated in the rollback preview, not silently implied.
|
|
17
|
-
*/
|
|
18
|
-
/** A file selected for capture: project-relative POSIX path + where it is on disk. */
|
|
19
|
-
export interface CaptureFile {
|
|
20
|
-
path: string;
|
|
21
|
-
absPath: string;
|
|
22
|
-
}
|
|
23
|
-
/** Which content substrate a checkpoint was written with. */
|
|
24
|
-
export type CheckpointStoreKind = "git" | "shadow";
|
|
25
|
-
/**
|
|
26
|
-
* One captured file in a checkpoint manifest. `oid` is the content address in
|
|
27
|
-
* the store that wrote it: a git blob sha-1 for the git store, a sha-256 for
|
|
28
|
-
* the shadow store. `mode` preserves the executable bit across restore.
|
|
29
|
-
*/
|
|
30
|
-
export interface FileEntry {
|
|
31
|
-
path: string;
|
|
32
|
-
mode: "100644" | "100755";
|
|
33
|
-
oid: string;
|
|
34
|
-
}
|
|
35
|
-
/** A persisted checkpoint: identity, provenance, and the full pre-run manifest. */
|
|
36
|
-
export interface Checkpoint {
|
|
37
|
-
/** Stable id, e.g. `ck-20260703T141530-a4f2`. */
|
|
38
|
-
id: string;
|
|
39
|
-
/** ISO-8601 creation time. */
|
|
40
|
-
createdAt: string;
|
|
41
|
-
/** One line describing the run this checkpoint protects. */
|
|
42
|
-
runSummary: string;
|
|
43
|
-
store: CheckpointStoreKind;
|
|
44
|
-
/** Every file that existed (and was capturable) before the run's first mutation. */
|
|
45
|
-
files: FileEntry[];
|
|
46
|
-
/**
|
|
47
|
-
* Project-relative paths the tracked run mutated through file tools, recorded
|
|
48
|
-
* as the run proceeds. At rollback time, a difference on a path NOT in this
|
|
49
|
-
* list is an *external* change — surfaced loudly in the preview.
|
|
50
|
-
*/
|
|
51
|
-
touchedPaths: string[];
|
|
52
|
-
/**
|
|
53
|
-
* True when the run executed approved shell commands: a shell command can
|
|
54
|
-
* touch any path, so per-file attribution becomes impossible and the preview
|
|
55
|
-
* says so instead of guessing.
|
|
56
|
-
*/
|
|
57
|
-
hasShellMutations: boolean;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The content substrate seam. Implementations persist and retrieve file
|
|
61
|
-
* *contents* only — manifests are the service's job.
|
|
62
|
-
*
|
|
63
|
-
* THE invariant (git store): snapshot/read must never disturb user-visible git
|
|
64
|
-
* state — HEAD, the index, the stash, or any ref. The git store self-checks
|
|
65
|
-
* this at runtime and fails loudly on drift.
|
|
66
|
-
*/
|
|
67
|
-
export interface CheckpointStore {
|
|
68
|
-
readonly kind: CheckpointStoreKind;
|
|
69
|
-
/** Persist the current contents of `files`; returns the manifest entries. */
|
|
70
|
-
snapshot(files: CaptureFile[]): Promise<FileEntry[]>;
|
|
71
|
-
/** The content address `snapshot` would give this buffer (for diffing). */
|
|
72
|
-
hashContent(content: Buffer): string;
|
|
73
|
-
/** Read one captured file's bytes back. Throws CRUXY_E_CHECKPOINT_FAILED if gone. */
|
|
74
|
-
readContent(entry: FileEntry): Promise<Buffer>;
|
|
75
|
-
/**
|
|
76
|
-
* Best-effort GC after prune: drop stored content whose oid is no longer
|
|
77
|
-
* referenced by any surviving manifest. The git store is a no-op (dangling
|
|
78
|
-
* objects belong to git's own gc); the shadow store sweeps its object pool.
|
|
79
|
-
*/
|
|
80
|
-
collect(referenced: ReadonlySet<string>): Promise<void>;
|
|
81
|
-
}
|
|
82
|
-
/** What rollback will do to one path. */
|
|
83
|
-
export type RollbackAction =
|
|
84
|
-
/** The run deleted it — recreate from the checkpoint. */
|
|
85
|
-
"recreate"
|
|
86
|
-
/** The run edited it — revert content (and mode) to the checkpoint. */
|
|
87
|
-
| "revert"
|
|
88
|
-
/** The run created it — delete it. */
|
|
89
|
-
| "delete";
|
|
90
|
-
export interface RollbackEntry {
|
|
91
|
-
path: string;
|
|
92
|
-
action: RollbackAction;
|
|
93
|
-
/**
|
|
94
|
-
* True when this path changed since the checkpoint but the tracked run never
|
|
95
|
-
* touched it — concurrent user (or other-tool) work that rollback would
|
|
96
|
-
* clobber. Always surfaced in the preview; never overwritten silently.
|
|
97
|
-
*/
|
|
98
|
-
external: boolean;
|
|
99
|
-
/** Checkpoint-side content to restore (recreate/revert; absent for delete). */
|
|
100
|
-
entry?: FileEntry;
|
|
101
|
-
}
|
|
102
|
-
/** The computed diff between the current working tree and a checkpoint. */
|
|
103
|
-
export interface RollbackPlan {
|
|
104
|
-
checkpoint: Checkpoint;
|
|
105
|
-
/** Sorted by path; empty means the tree already matches the checkpoint. */
|
|
106
|
-
entries: RollbackEntry[];
|
|
107
|
-
/** The `external: true` paths, for the preview's warning block. */
|
|
108
|
-
externalPaths: string[];
|
|
109
|
-
/** Mirrors {@link Checkpoint.hasShellMutations}: attribution is unknowable. */
|
|
110
|
-
attributionUnknown: boolean;
|
|
111
|
-
}
|
|
112
|
-
/** Counts of what a successful rollback actually did. */
|
|
113
|
-
export interface RollbackApplied {
|
|
114
|
-
recreated: number;
|
|
115
|
-
reverted: number;
|
|
116
|
-
deleted: number;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* One touched root inside a {@link CheckpointSet}: the declared root's name (for
|
|
120
|
-
* attribution in the preview), its absolute path, and the id of the per-root
|
|
121
|
-
* checkpoint that protects it. There is exactly ONE member per root the run
|
|
122
|
-
* mutated — an untouched root has no member and is never opened at rollback.
|
|
123
|
-
*/
|
|
124
|
-
export interface CheckpointSetMember {
|
|
125
|
-
/** Declared workspace-root name (shown in the grouped preview). */
|
|
126
|
-
rootName: string;
|
|
127
|
-
/** Absolute path of the root (where its `.cruxy/checkpoints/` live). */
|
|
128
|
-
rootPath: string;
|
|
129
|
-
/** The checkpoint id within that root. */
|
|
130
|
-
checkpointId: string;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* A run's rollback unit across N repos (C.26). `cruxy rollback` restores **all
|
|
134
|
-
* members** of a set as one gated operation — exactly the roots the run touched,
|
|
135
|
-
* no more (untouched roots are absent) and no less (a touched root missing its
|
|
136
|
-
* member is a loud `CRUXY_E_CHECKPOINT_SET_INCOMPLETE`, never a silent partial).
|
|
137
|
-
*
|
|
138
|
-
* The set manifest lives under the PRIMARY root's `.cruxy/checkpoints/sets/`, so
|
|
139
|
-
* it travels with the workspace and survives `rm -rf ~/.cruxy`. The member
|
|
140
|
-
* checkpoints themselves live in each root, exactly as in the single-root case.
|
|
141
|
-
*/
|
|
142
|
-
export interface CheckpointSet {
|
|
143
|
-
/** Stable run id, e.g. `run-20260708T031500-a4f2`. */
|
|
144
|
-
runId: string;
|
|
145
|
-
/** ISO-8601 creation time (of the set, i.e. the run's first mutation). */
|
|
146
|
-
createdAt: string;
|
|
147
|
-
/** One line describing the run this set protects. */
|
|
148
|
-
runSummary: string;
|
|
149
|
-
/** One entry per TOUCHED root. */
|
|
150
|
-
members: CheckpointSetMember[];
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* The outcome of a successful all-roots rollback: which roots were restored and
|
|
154
|
-
* what each did. On a mid-apply failure this is NOT returned — a
|
|
155
|
-
* `CRUXY_E_CHECKPOINT_SET_PARTIAL` is thrown instead, carrying the restored-vs-not
|
|
156
|
-
* split (R3), so a partial can never read as success.
|
|
157
|
-
*/
|
|
158
|
-
export interface SetRollbackApplied {
|
|
159
|
-
runId: string;
|
|
160
|
-
/** Root names restored, in apply order. */
|
|
161
|
-
restored: string[];
|
|
162
|
-
/** Per-root counts, keyed by root name. */
|
|
163
|
-
perRoot: Record<string, RollbackApplied>;
|
|
164
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy checkpoint` (C.32) — inspect the working-tree snapshots that back
|
|
4
|
-
* `cruxy rollback`. Creation is automatic (before a run's first mutation);
|
|
5
|
-
* this command only lists.
|
|
6
|
-
*/
|
|
7
|
-
export declare function checkpointCommand(): Command;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy hooks` — inspect and trust hooks + custom slash commands (C.19).
|
|
4
|
-
* `list` shows the resolved catalog (including which project hooks are trusted
|
|
5
|
-
* and any malformed definitions); `trust <path>` records the explicit,
|
|
6
|
-
* reviewed decision to run a project's hooks, bound to their current fingerprint.
|
|
7
|
-
*/
|
|
8
|
-
export declare function hooksCommand(): Command;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy index` — build or refresh the local codebase search index that backs
|
|
4
|
-
* the `search_codebase` tool. `--status` reports the current state without
|
|
5
|
-
* modifying it; `--force` re-embeds every file regardless of content hashes.
|
|
6
|
-
*/
|
|
7
|
-
export declare function indexCommand(): Command;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy init` — set up a project (U.6): ensure a key (acquired only if missing),
|
|
4
|
-
* offer to scaffold a project `CRUXY.md`, and offer a first-win demo run. Like
|
|
5
|
-
* `login`, it's interactive-only.
|
|
6
|
-
*/
|
|
7
|
-
export declare function initCommand(): Command;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy login` — set or replace the API key on demand (U.6). Runs the key step
|
|
4
|
-
* of onboarding (always, even if a key already resolves — this is how you
|
|
5
|
-
* re-key / switch), validates it live, and persists it to the credentials store.
|
|
6
|
-
* Non-interactive invocations fail loud rather than hang.
|
|
7
|
-
*/
|
|
8
|
-
export declare function loginCommand(): Command;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy mcp` — inspect and control MCP server integration (C.27). `list` shows
|
|
4
|
-
* the configured servers and whether this repo's config is trusted; `trust`
|
|
5
|
-
* records the explicit decision to connect them, bound to the current config
|
|
6
|
-
* fingerprint. Trusting a server runs its code UNSANDBOXED with your privileges,
|
|
7
|
-
* so `trust` restates that plainly before recording.
|
|
8
|
-
*/
|
|
9
|
-
export declare function mcpCommand(): Command;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy memory` — inspect and control persistent memory (C.29). `list` shows
|
|
4
|
-
* user + project entries and whether project memory is trusted (recalled);
|
|
5
|
-
* `forget`/`clear` remove entries; `trust` records the explicit decision to
|
|
6
|
-
* recall a repo's project memory, bound to its current fingerprint.
|
|
7
|
-
*/
|
|
8
|
-
export declare function memoryCommand(): Command;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy pr` — turn the current changes into a pull request (C.15). Generates the
|
|
4
|
-
* branch name, conventional commit, and PR title/body from the diff with the
|
|
5
|
-
* model, then runs branch → commit → push → open-PR behind the one U.3 approval.
|
|
6
|
-
* The forge token comes from the environment / `gh`; it's never prompted or stored.
|
|
7
|
-
*/
|
|
8
|
-
export declare function prCommand(): Command;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy rollback [id]` (C.32/C.26) — restore the working tree to a run's
|
|
4
|
-
* checkpoint(s), undoing everything an agent run changed in one operation.
|
|
5
|
-
* Destructive by definition, so it is preview-first and gated through U.3 at the
|
|
6
|
-
* destructive tier, ungrantable; non-TTY is refused with a coded error before
|
|
7
|
-
* anything is computed. Out of scope, stated in the preview: commits, pushes, and
|
|
8
|
-
* PRs made during the run are not undone.
|
|
9
|
-
*
|
|
10
|
-
* Routing:
|
|
11
|
-
* • an explicit `<id>` that names a run/JOB set (C.28: a background job's id) →
|
|
12
|
-
* set-based rollback of exactly that run, restoring every root it touched;
|
|
13
|
-
* • an explicit `<id>` that is a checkpoint id → single-root rollback (escape
|
|
14
|
-
* hatch; also the recovery route if the primary root's set index was removed);
|
|
15
|
-
* • no id, a set manifest exists → set-based rollback of the latest run;
|
|
16
|
-
* • no id, no set manifest → JC-F fallback to legacy single-root, logged.
|
|
17
|
-
*/
|
|
18
|
-
export declare function rollbackCommand(): Command;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy skills` — list the skills available to the agent (the same catalog the
|
|
4
|
-
* `list_skills` tool sees). `--status` additionally shows the three source
|
|
5
|
-
* directories in precedence order and any validation errors (skills that were
|
|
6
|
-
* excluded for being malformed).
|
|
7
|
-
*/
|
|
8
|
-
export declare function skillsCommand(): Command;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy test` (C.13) — run the project's detected/configured test command
|
|
4
|
-
* once and print the structured result the agent would see. Directly
|
|
5
|
-
* user-invoked, so there is no approval gate (typing the command IS the
|
|
6
|
-
* consent — same as running the suite by hand); the process exit code mirrors
|
|
7
|
-
* the suite's pass/fail so scripts and CI can branch on it.
|
|
8
|
-
*/
|
|
9
|
-
export declare function testCommand(): Command;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* `cruxy usage` (C.22) — show LOCAL token usage and (when priced) cost, read
|
|
4
|
-
* back from `~/.cruxy/usage`. Read-only and local: it prints your own accounting
|
|
5
|
-
* and transmits nothing. Every figure is real — a request the provider never
|
|
6
|
-
* reported usage for is shown as unreported, never a fabricated number, and cost
|
|
7
|
-
* appears only for tiers you have priced.
|
|
8
|
-
*/
|
|
9
|
-
export declare function usageCommand(): Command;
|
package/dist/cli/onboard.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { CruxyConfig } from "../config/index.js";
|
|
2
|
-
import { type OnboardingResult } from "../onboarding/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* CLI-layer glue between the entry points and the onboarding module (U.6). Keeps
|
|
5
|
-
* `run`/`program`/`login`/`init` thin: they decide *when* to onboard; this builds
|
|
6
|
-
* the production wiring (live validation, credential persistence, first-win run).
|
|
7
|
-
*/
|
|
8
|
-
/** The env var that holds the key for a provider (for the fail-loud message). */
|
|
9
|
-
export declare function apiKeyEnvVar(provider: string): string;
|
|
10
|
-
/** Run one first-win task end-to-end against the just-saved key. */
|
|
11
|
-
export declare function runFirstWinTask(config: CruxyConfig, cwd: string, prompt: string): Promise<void>;
|
|
12
|
-
export interface MaybeOnboardOptions {
|
|
13
|
-
/** Whether stdin is a TTY (the gate). */
|
|
14
|
-
ttyInteractive: boolean;
|
|
15
|
-
/** Offer the first-win demo run (no real task queued). */
|
|
16
|
-
offerFirstWin: boolean;
|
|
17
|
-
cwd: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Run the guided first-run flow **iff** this is a first run; otherwise return
|
|
21
|
-
* `null` so the caller can fall back (fail loud, or show a banner). Never throws
|
|
22
|
-
* for an aborted setup — `result.completed` is `false` and the caller exits
|
|
23
|
-
* cleanly.
|
|
24
|
-
*/
|
|
25
|
-
export declare function maybeRunOnboarding(config: CruxyConfig, opts: MaybeOnboardOptions): Promise<OnboardingResult> | null;
|
package/dist/cli/program.d.ts
DELETED
package/dist/cli/repl.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Readable, Writable } from "node:stream";
|
|
2
|
-
import type { Session } from "../agent/index.js";
|
|
3
|
-
import type { CheckpointGate } from "../checkpoint/index.js";
|
|
4
|
-
import { type SlashCommandSpec } from "../hooks/index.js";
|
|
5
|
-
import { type StreamRenderer } from "../render/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* The REPL's slash commands — the autocomplete candidate set (U.7). Keep in
|
|
8
|
-
* sync with the dispatch below and the HELP text.
|
|
9
|
-
*/
|
|
10
|
-
export declare const REPL_COMMANDS: readonly ["/help", "/clear", "/compact", "/reload", "/plan", "/jobs", "/logs", "/cancel", "/exit", "/quit"];
|
|
11
|
-
/** The stdin/stdout pair the REPL reads from and prompts on. Injectable for tests. */
|
|
12
|
-
export interface ReplIO {
|
|
13
|
-
input: Readable;
|
|
14
|
-
output: Writable;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Drive an interactive multi-turn session: prompt, read a line, dispatch slash
|
|
18
|
-
* commands or run a turn, repeat. Assistant text and tool-call progress stream
|
|
19
|
-
* through the `renderer` from within `session.send`; this loop only owns input
|
|
20
|
-
* and control.
|
|
21
|
-
*
|
|
22
|
-
* `io` defaults to real stdin/stdout; tests inject a scripted stream pair. The
|
|
23
|
-
* renderer defaults to whatever `io.output` supports (a TTY gets the managed
|
|
24
|
-
* live region, anything else the plain append-only renderer); `cruxy run`
|
|
25
|
-
* passes its own so the approval prompt's status-suspend hook shares it.
|
|
26
|
-
*/
|
|
27
|
-
export declare function runInteractive(session: Session, io?: ReplIO, renderer?: StreamRenderer, checkpoints?: CheckpointGate, slashCommands?: readonly SlashCommandSpec[]): Promise<void>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { CruxyConfig } from "../config/index.js";
|
|
2
|
-
import { withCheckpointGate } from "../checkpoint/index.js";
|
|
3
|
-
import type { CheckpointGate } from "../checkpoint/index.js";
|
|
4
|
-
export { withCheckpointGate };
|
|
5
|
-
import type { SandboxService } from "../sandbox/index.js";
|
|
6
|
-
import type { StreamRenderer } from "../render/index.js";
|
|
7
|
-
import { ToolRegistry, type Tool } from "../tools/index.js";
|
|
8
|
-
import { Session, type LifecycleHookRunner } from "../agent/index.js";
|
|
9
|
-
import type { Workspace } from "../workspace/index.js";
|
|
10
|
-
/**
|
|
11
|
-
* Register every CONDITIONALLY-enabled runtime tool onto `registry`, in the fixed
|
|
12
|
-
* order the model sees them: `remember` (memory), the four LSP tools, the two web
|
|
13
|
-
* tools, the trusted MCP tools, then `spawn_subagent`. Factored out of
|
|
14
|
-
* {@link buildAgentSession} for ONE reason beyond tidiness: it makes the *complete
|
|
15
|
-
* runtime* tool set enumerable by a test (JC-B). The default registry only covers
|
|
16
|
-
* the 14 always-on tools; the allowlist test that pins "no tool can add a workspace
|
|
17
|
-
* root" is only sound if it runs against the SAME set the session ships — so the
|
|
18
|
-
* session factory and that test both build the surface through this one seam. A new
|
|
19
|
-
* conditionally-registered tool added here fails the allowlist test until it is
|
|
20
|
-
* consciously listed and audited.
|
|
21
|
-
*
|
|
22
|
-
* Each family is opt-in and inert when its feature flag is off, exactly as before —
|
|
23
|
-
* this function is a pure move of the inline registration, same guards, same order.
|
|
24
|
-
* `spawnTool` is passed in (already depth-bound) because it needs the orchestrator;
|
|
25
|
-
* it registers only when nesting is allowed (`subagent.maxDepth > 0`).
|
|
26
|
-
*/
|
|
27
|
-
export declare function registerRuntimeTools(registry: ToolRegistry, config: CruxyConfig, opts?: {
|
|
28
|
-
mcpTools?: Tool[];
|
|
29
|
-
spawnTool?: Tool;
|
|
30
|
-
spawnManyTool?: Tool;
|
|
31
|
-
jobTool?: Tool;
|
|
32
|
-
}): void;
|
|
33
|
-
/**
|
|
34
|
-
* Build a ready-to-run agent {@link Session} from a resolved key — the wiring
|
|
35
|
-
* shared by `cruxy run` and the onboarding first-win task (so they can't drift).
|
|
36
|
-
* The approval gate's interactivity tracks the TTY, exactly as in `run`.
|
|
37
|
-
*
|
|
38
|
-
* When `planMode` is on (C.31), it additionally wires a {@link PlanExecutionPolicy}
|
|
39
|
-
* over the shared U.3 allowlist and a `planRunner` so `session.send` proposes →
|
|
40
|
-
* approves → executes. Plan mode is fully opt-in; the default path is unchanged.
|
|
41
|
-
*/
|
|
42
|
-
export declare function buildAgentSession(config: CruxyConfig, apiKey: string, workspace: Workspace, ttyInteractive: boolean, planMode?: boolean, renderer?: StreamRenderer, checkpoints?: CheckpointGate, sandbox?: SandboxService, hooks?: LifecycleHookRunner, mcpTools?: Tool[]): Session;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wrap a raw write sink into a printer for streamed assistant text.
|
|
3
|
-
*
|
|
4
|
-
* Models routinely begin a turn with one or more leading newlines; written
|
|
5
|
-
* verbatim those land as blank lines between the prompt and the answer. The
|
|
6
|
-
* printer drops the leading newline run of a turn (until the first visible
|
|
7
|
-
* character) so output starts on a single fresh line, and otherwise forwards
|
|
8
|
-
* text untouched — internal blank lines (markdown paragraphs, code) are
|
|
9
|
-
* preserved. State is per printer, so create one per turn.
|
|
10
|
-
*
|
|
11
|
-
* All turn output — the deltas and the loop's single segment-terminating
|
|
12
|
-
* newline — flows through this one sink, so nothing races the stream on stdout.
|
|
13
|
-
*/
|
|
14
|
-
export declare function createStreamPrinter(write: (text: string) => void): (delta: string) => void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Autocomplete (U.7): pure completion over an injectable candidate list, plus
|
|
3
|
-
* the readline adapter the REPL uses for Tab-completion. Non-destructive by
|
|
4
|
-
* construction — this module transforms strings and returns suggestions; it
|
|
5
|
-
* has no access to the session, so completing can never execute anything.
|
|
6
|
-
* Enter (the existing REPL path) remains the only way to act.
|
|
7
|
-
*/
|
|
8
|
-
/** The outcome of one completion attempt. */
|
|
9
|
-
export interface Completion {
|
|
10
|
-
/** The (possibly extended) input line. Unchanged when nothing matches. */
|
|
11
|
-
line: string;
|
|
12
|
-
/** Every candidate the input currently prefixes (shown on ambiguity). */
|
|
13
|
-
suggestions: string[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Complete `line` against `candidates` (exact-prefix filter):
|
|
17
|
-
* - no match → line unchanged, no suggestions;
|
|
18
|
-
* - one match → completed fully to it;
|
|
19
|
-
* - several → extended to their longest common prefix, all listed.
|
|
20
|
-
* Pure data in, data out — deterministic and order-preserving.
|
|
21
|
-
*/
|
|
22
|
-
export declare function completeLine(line: string, candidates: readonly string[]): Completion;
|
|
23
|
-
/**
|
|
24
|
-
* A Node-readline `completer` over a live candidate source. Only the leading
|
|
25
|
-
* word of a line starting with `/` completes (slash commands); everything
|
|
26
|
-
* else — prompts to the model — is left alone, so Tab never mangles prose.
|
|
27
|
-
*
|
|
28
|
-
* readline's contract: return `[hits, prefixBeingReplaced]`; readline itself
|
|
29
|
-
* extends to the common prefix and lists hits on a second Tab. It rewrites
|
|
30
|
-
* only the edit buffer — submission stays on Enter.
|
|
31
|
-
*/
|
|
32
|
-
export declare function makeReplCompleter(candidates: () => readonly string[]): (line: string) => [string[], string];
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { stripAnsi } from "../render/layout.js";
|
|
2
|
-
import type { RenderCapabilities } from "../render/index.js";
|
|
3
|
-
/** The visible text of a possibly-styled row (re-exported from the U.12 home). */
|
|
4
|
-
export { stripAnsi };
|
|
5
|
-
/**
|
|
6
|
-
* The transient multi-line region interactive components draw into (U.7) —
|
|
7
|
-
* the multi-row analog of the TTY renderer's single managed status line, with
|
|
8
|
-
* the same discipline:
|
|
9
|
-
*
|
|
10
|
-
* - Only the frame is ever rewritten (erase + redraw in place) — committed
|
|
11
|
-
* output above it is never touched.
|
|
12
|
-
* - Every line is hard-truncated to the terminal width so a row can never
|
|
13
|
-
* soft-wrap; wrapped rows would break erasure and leave artifacts.
|
|
14
|
-
* - `clear()` removes the frame entirely — after a component resolves, the
|
|
15
|
-
* screen holds zero leftover bytes from the interaction.
|
|
16
|
-
* - On resize (U.12) the frame reflows its current rows in place at the new
|
|
17
|
-
* width; committed output above is untouched. `clear()` also unsubscribes.
|
|
18
|
-
*
|
|
19
|
-
* Requires cursor control (`caps.cursor`); components guard on that before
|
|
20
|
-
* constructing one.
|
|
21
|
-
*/
|
|
22
|
-
export interface Frame {
|
|
23
|
-
/** Repaint the frame with these rows (erases the previous paint first). */
|
|
24
|
-
render(lines: string[]): void;
|
|
25
|
-
/** Erase the frame completely and release the resize subscription. Idempotent. */
|
|
26
|
-
clear(): void;
|
|
27
|
-
}
|
|
28
|
-
export declare function createFrame(write: (text: string) => void, caps: RenderCapabilities): Frame;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { type Theme } from "../theme/index.js";
|
|
2
|
-
import { type ComponentIO, type InteractiveResult } from "./input.js";
|
|
3
|
-
/**
|
|
4
|
-
* Fuzzy finding (U.7): a deterministic, honest subsequence scorer (pure,
|
|
5
|
-
* headless-tested) plus the interactive type-to-filter component built on it.
|
|
6
|
-
* No fabricated relevance — a label either contains the query as a
|
|
7
|
-
* subsequence or it does not, and the score is three documented bonuses.
|
|
8
|
-
*/
|
|
9
|
-
/** A successful match: its rank score and the label indices that matched. */
|
|
10
|
-
export interface FuzzyMatch {
|
|
11
|
-
score: number;
|
|
12
|
-
/** Indices into the label of the matched characters (for highlighting). */
|
|
13
|
-
positions: number[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Case-insensitive greedy-leftmost subsequence match.
|
|
17
|
-
* - Empty query matches everything: score 0, no positions (nothing to
|
|
18
|
-
* highlight, nothing to fabricate).
|
|
19
|
-
* - Not a subsequence → `null`.
|
|
20
|
-
* - Score = Σ per matched char: {@link BASE} + {@link CONSECUTIVE} when the
|
|
21
|
-
* match continues a run + {@link BOUNDARY} when it starts a word.
|
|
22
|
-
* Deterministic by construction — same inputs, same output, no randomness,
|
|
23
|
-
* no length normalization (ties break in {@link rankItems}).
|
|
24
|
-
*/
|
|
25
|
-
export declare function fuzzyScore(query: string, label: string): FuzzyMatch | null;
|
|
26
|
-
/** An item that survived filtering, with everything the finder renders. */
|
|
27
|
-
export interface RankedItem<T> {
|
|
28
|
-
item: T;
|
|
29
|
-
label: string;
|
|
30
|
-
match: FuzzyMatch;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Filter + rank a list against a query. Ordering is fully stable and
|
|
34
|
-
* deterministic: score descending, then shorter label, then original index.
|
|
35
|
-
* An empty query returns every item in original order.
|
|
36
|
-
*/
|
|
37
|
-
export declare function rankItems<T>(items: readonly T[], toLabel: (item: T) => string, query: string): RankedItem<T>[];
|
|
38
|
-
/**
|
|
39
|
-
* Bold the matched characters of a label via the theme's accent role. With
|
|
40
|
-
* color off (NO_COLOR, pipe) the roles are identity — plain text, zero ANSI.
|
|
41
|
-
*/
|
|
42
|
-
export declare function highlightMatch(label: string, positions: readonly number[], theme: Theme): string;
|
|
43
|
-
export interface FuzzyFindOptions<T> {
|
|
44
|
-
/** Label an item filters/renders under. Required — items are opaque. */
|
|
45
|
-
toLabel: (item: T) => string;
|
|
46
|
-
/** Header above the query line (e.g. "pick a checkpoint"). */
|
|
47
|
-
title?: string;
|
|
48
|
-
/** Non-TTY fallback: resolve to this instead of failing loud. */
|
|
49
|
-
defaultValue?: T;
|
|
50
|
-
/** `--flag` alternatives listed in the non-TTY error. */
|
|
51
|
-
nonInteractiveHint?: string[];
|
|
52
|
-
/** Visible result rows before the list scrolls (default 10). */
|
|
53
|
-
maxVisible?: number;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Interactive fuzzy finder: type to filter, ↑/↓ to move through the ranked
|
|
57
|
-
* results, Enter to select the highlighted item (inert while there are no
|
|
58
|
-
* matches), Esc / Ctrl-C / EOF to cancel. The transient frame is fully erased
|
|
59
|
-
* before resolving — the screen keeps no trace of the interaction.
|
|
60
|
-
*/
|
|
61
|
-
export declare function fuzzyFind<T>(items: readonly T[], opts: FuzzyFindOptions<T>, io?: ComponentIO): Promise<InteractiveResult<T>>;
|