@cruxy/cli 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/dist/agent/loop.js +3 -0
  2. package/dist/agent/session.js +2 -1
  3. package/dist/theme/tokens.js +3 -0
  4. package/dist/usage/collect.js +41 -2
  5. package/dist/usage/index.js +1 -1
  6. package/dist/usage/summary.js +19 -0
  7. package/dist/usage/types.js +9 -0
  8. package/package.json +1 -1
  9. package/dist/agent/budget.d.ts +0 -52
  10. package/dist/agent/index.d.ts +0 -3
  11. package/dist/agent/loop.d.ts +0 -159
  12. package/dist/agent/prompts.d.ts +0 -69
  13. package/dist/agent/session.d.ts +0 -212
  14. package/dist/approval/classify.d.ts +0 -18
  15. package/dist/approval/index.d.ts +0 -6
  16. package/dist/approval/mutex.d.ts +0 -45
  17. package/dist/approval/policy.d.ts +0 -43
  18. package/dist/approval/prompt.d.ts +0 -48
  19. package/dist/approval/service.d.ts +0 -36
  20. package/dist/approval/types.d.ts +0 -82
  21. package/dist/brand/index.d.ts +0 -1
  22. package/dist/brand/voice.d.ts +0 -94
  23. package/dist/checkpoint/capture.d.ts +0 -17
  24. package/dist/checkpoint/gate-hook.d.ts +0 -28
  25. package/dist/checkpoint/gate.d.ts +0 -71
  26. package/dist/checkpoint/git-store.d.ts +0 -61
  27. package/dist/checkpoint/index.d.ts +0 -10
  28. package/dist/checkpoint/restore.d.ts +0 -23
  29. package/dist/checkpoint/service.d.ts +0 -89
  30. package/dist/checkpoint/set-rollback.d.ts +0 -51
  31. package/dist/checkpoint/set.d.ts +0 -44
  32. package/dist/checkpoint/shadow-store.d.ts +0 -23
  33. package/dist/checkpoint/types.d.ts +0 -164
  34. package/dist/cli/commands/checkpoint.d.ts +0 -7
  35. package/dist/cli/commands/config.d.ts +0 -2
  36. package/dist/cli/commands/hooks.d.ts +0 -8
  37. package/dist/cli/commands/index.d.ts +0 -7
  38. package/dist/cli/commands/init.d.ts +0 -7
  39. package/dist/cli/commands/login.d.ts +0 -8
  40. package/dist/cli/commands/mcp.d.ts +0 -9
  41. package/dist/cli/commands/memory.d.ts +0 -8
  42. package/dist/cli/commands/pr.d.ts +0 -8
  43. package/dist/cli/commands/rollback.d.ts +0 -18
  44. package/dist/cli/commands/run.d.ts +0 -2
  45. package/dist/cli/commands/skills.d.ts +0 -8
  46. package/dist/cli/commands/test.d.ts +0 -9
  47. package/dist/cli/commands/usage.d.ts +0 -9
  48. package/dist/cli/onboard.d.ts +0 -25
  49. package/dist/cli/program.d.ts +0 -2
  50. package/dist/cli/repl.d.ts +0 -27
  51. package/dist/cli/session-factory.d.ts +0 -42
  52. package/dist/cli/stream-print.d.ts +0 -14
  53. package/dist/components/autocomplete.d.ts +0 -32
  54. package/dist/components/frame.d.ts +0 -28
  55. package/dist/components/fuzzy.d.ts +0 -61
  56. package/dist/components/index.d.ts +0 -6
  57. package/dist/components/input.d.ts +0 -78
  58. package/dist/components/keys.d.ts +0 -48
  59. package/dist/components/select.d.ts +0 -28
  60. package/dist/config/credentials.d.ts +0 -18
  61. package/dist/config/index.d.ts +0 -5
  62. package/dist/config/manager.d.ts +0 -39
  63. package/dist/config/owner-only.d.ts +0 -19
  64. package/dist/config/paths.d.ts +0 -9
  65. package/dist/config/project.d.ts +0 -10
  66. package/dist/config/schema.d.ts +0 -2143
  67. package/dist/constants.d.ts +0 -65
  68. package/dist/errors/boundary.d.ts +0 -43
  69. package/dist/errors/constructors.d.ts +0 -411
  70. package/dist/errors/format.d.ts +0 -31
  71. package/dist/errors/index.d.ts +0 -4
  72. package/dist/errors/types.d.ts +0 -270
  73. package/dist/hooks/config.d.ts +0 -21
  74. package/dist/hooks/index.d.ts +0 -7
  75. package/dist/hooks/router.d.ts +0 -58
  76. package/dist/hooks/runner.d.ts +0 -88
  77. package/dist/hooks/service.d.ts +0 -38
  78. package/dist/hooks/slash.d.ts +0 -48
  79. package/dist/hooks/trust.d.ts +0 -46
  80. package/dist/hooks/types.d.ts +0 -147
  81. package/dist/index.d.ts +0 -2
  82. package/dist/indexing/chunker.d.ts +0 -28
  83. package/dist/indexing/embedder.d.ts +0 -98
  84. package/dist/indexing/index.d.ts +0 -9
  85. package/dist/indexing/indexer.d.ts +0 -45
  86. package/dist/indexing/retriever.d.ts +0 -61
  87. package/dist/indexing/service.d.ts +0 -49
  88. package/dist/indexing/store.d.ts +0 -103
  89. package/dist/indexing/types.d.ts +0 -78
  90. package/dist/indexing/util.d.ts +0 -34
  91. package/dist/indexing/walker.d.ts +0 -53
  92. package/dist/jobs/approval-queue.d.ts +0 -85
  93. package/dist/jobs/dispatch-tool.d.ts +0 -34
  94. package/dist/jobs/index.d.ts +0 -6
  95. package/dist/jobs/log-buffer.d.ts +0 -31
  96. package/dist/jobs/log-renderer.d.ts +0 -32
  97. package/dist/jobs/manager.d.ts +0 -139
  98. package/dist/jobs/types.d.ts +0 -81
  99. package/dist/lsp/client.d.ts +0 -25
  100. package/dist/lsp/index.d.ts +0 -8
  101. package/dist/lsp/pool.d.ts +0 -48
  102. package/dist/lsp/registry.d.ts +0 -38
  103. package/dist/lsp/server.d.ts +0 -48
  104. package/dist/lsp/service.d.ts +0 -44
  105. package/dist/lsp/tools/common.d.ts +0 -50
  106. package/dist/lsp/tools/find-definition.d.ts +0 -23
  107. package/dist/lsp/tools/find-references.d.ts +0 -23
  108. package/dist/lsp/tools/get-diagnostics.d.ts +0 -17
  109. package/dist/lsp/tools/hover.d.ts +0 -23
  110. package/dist/lsp/tools/index.d.ts +0 -4
  111. package/dist/lsp/transport.d.ts +0 -39
  112. package/dist/lsp/types.d.ts +0 -107
  113. package/dist/mcp/adapter.d.ts +0 -44
  114. package/dist/mcp/bounds.d.ts +0 -35
  115. package/dist/mcp/client.d.ts +0 -19
  116. package/dist/mcp/demarcate.d.ts +0 -12
  117. package/dist/mcp/http-transport.d.ts +0 -89
  118. package/dist/mcp/index.d.ts +0 -12
  119. package/dist/mcp/service.d.ts +0 -71
  120. package/dist/mcp/sibling-banner.d.ts +0 -25
  121. package/dist/mcp/transport.d.ts +0 -30
  122. package/dist/mcp/trust-gate.d.ts +0 -59
  123. package/dist/mcp/trust.d.ts +0 -62
  124. package/dist/mcp/types.d.ts +0 -62
  125. package/dist/mcp/url-guard.d.ts +0 -48
  126. package/dist/memory/index.d.ts +0 -7
  127. package/dist/memory/recall.d.ts +0 -56
  128. package/dist/memory/remember-tool.d.ts +0 -28
  129. package/dist/memory/secrets.d.ts +0 -29
  130. package/dist/memory/service.d.ts +0 -92
  131. package/dist/memory/store.d.ts +0 -32
  132. package/dist/memory/trust.d.ts +0 -52
  133. package/dist/memory/types.d.ts +0 -101
  134. package/dist/net/ip-guard.d.ts +0 -55
  135. package/dist/onboarding/detect.d.ts +0 -26
  136. package/dist/onboarding/flow.d.ts +0 -28
  137. package/dist/onboarding/index.d.ts +0 -5
  138. package/dist/onboarding/io.d.ts +0 -9
  139. package/dist/onboarding/steps.d.ts +0 -17
  140. package/dist/onboarding/types.d.ts +0 -81
  141. package/dist/plan/approve.d.ts +0 -16
  142. package/dist/plan/execute.d.ts +0 -28
  143. package/dist/plan/index.d.ts +0 -7
  144. package/dist/plan/policy.d.ts +0 -26
  145. package/dist/plan/render.d.ts +0 -5
  146. package/dist/plan/service.d.ts +0 -58
  147. package/dist/plan/submit-plan.d.ts +0 -33
  148. package/dist/plan/types.d.ts +0 -60
  149. package/dist/render/capabilities.d.ts +0 -31
  150. package/dist/render/diff.d.ts +0 -18
  151. package/dist/render/highlight.d.ts +0 -47
  152. package/dist/render/index.d.ts +0 -22
  153. package/dist/render/layout.d.ts +0 -59
  154. package/dist/render/motion.d.ts +0 -76
  155. package/dist/render/plain-renderer.d.ts +0 -39
  156. package/dist/render/resize.d.ts +0 -36
  157. package/dist/render/screen-reader-renderer.d.ts +0 -45
  158. package/dist/render/state.d.ts +0 -49
  159. package/dist/render/tty-renderer.d.ts +0 -106
  160. package/dist/render/types.d.ts +0 -201
  161. package/dist/routing/index.d.ts +0 -2
  162. package/dist/routing/resolve.d.ts +0 -17
  163. package/dist/routing/router.d.ts +0 -47
  164. package/dist/routing/types.d.ts +0 -42
  165. package/dist/sandbox/detect.d.ts +0 -22
  166. package/dist/sandbox/docker-runtime.d.ts +0 -32
  167. package/dist/sandbox/index.d.ts +0 -7
  168. package/dist/sandbox/policy.d.ts +0 -26
  169. package/dist/sandbox/service.d.ts +0 -64
  170. package/dist/sandbox/types.d.ts +0 -123
  171. package/dist/skills/index.d.ts +0 -4
  172. package/dist/skills/loader.d.ts +0 -43
  173. package/dist/skills/parser.d.ts +0 -31
  174. package/dist/skills/service.d.ts +0 -41
  175. package/dist/skills/types.d.ts +0 -94
  176. package/dist/subagent/index.d.ts +0 -5
  177. package/dist/subagent/orchestrator.d.ts +0 -169
  178. package/dist/subagent/registry-scope.d.ts +0 -41
  179. package/dist/subagent/semaphore.d.ts +0 -56
  180. package/dist/subagent/spawn-tool.d.ts +0 -86
  181. package/dist/subagent/types.d.ts +0 -65
  182. package/dist/testing/detect.d.ts +0 -3
  183. package/dist/testing/index.d.ts +0 -5
  184. package/dist/testing/parse.d.ts +0 -33
  185. package/dist/testing/run-tests-tool.d.ts +0 -64
  186. package/dist/testing/runner.d.ts +0 -26
  187. package/dist/testing/sandbox-runner.d.ts +0 -16
  188. package/dist/testing/types.d.ts +0 -66
  189. package/dist/theme/index.d.ts +0 -2
  190. package/dist/theme/resolve.d.ts +0 -43
  191. package/dist/theme/tokens.d.ts +0 -119
  192. package/dist/tools/create-pull-request.d.ts +0 -27
  193. package/dist/tools/file/apply-patch.d.ts +0 -94
  194. package/dist/tools/file/edit-file.d.ts +0 -12
  195. package/dist/tools/file/glob.d.ts +0 -17
  196. package/dist/tools/file/grep-files.d.ts +0 -43
  197. package/dist/tools/file/index.d.ts +0 -7
  198. package/dist/tools/file/match.d.ts +0 -43
  199. package/dist/tools/file/paths.d.ts +0 -160
  200. package/dist/tools/file/read-file.d.ts +0 -8
  201. package/dist/tools/file/write-file.d.ts +0 -10
  202. package/dist/tools/git-status.d.ts +0 -15
  203. package/dist/tools/index.d.ts +0 -9
  204. package/dist/tools/list-files.d.ts +0 -13
  205. package/dist/tools/list-skills.d.ts +0 -9
  206. package/dist/tools/load-skill.d.ts +0 -21
  207. package/dist/tools/registry.d.ts +0 -23
  208. package/dist/tools/search-codebase.d.ts +0 -35
  209. package/dist/tools/shell/exec.d.ts +0 -53
  210. package/dist/tools/shell/index.d.ts +0 -1
  211. package/dist/tools/shell/resolve-shell.d.ts +0 -81
  212. package/dist/tools/shell/run-command.d.ts +0 -14
  213. package/dist/tools/types.d.ts +0 -257
  214. package/dist/usage/collect.d.ts +0 -40
  215. package/dist/usage/cost.d.ts +0 -19
  216. package/dist/usage/index.d.ts +0 -15
  217. package/dist/usage/store.d.ts +0 -37
  218. package/dist/usage/summary.d.ts +0 -32
  219. package/dist/usage/types.d.ts +0 -220
  220. package/dist/utils/child-tree.d.ts +0 -33
  221. package/dist/utils/git.d.ts +0 -17
  222. package/dist/utils/logger.d.ts +0 -18
  223. package/dist/utils/process-tree.d.ts +0 -16
  224. package/dist/vcs/auth.d.ts +0 -22
  225. package/dist/vcs/generate.d.ts +0 -74
  226. package/dist/vcs/git.d.ts +0 -60
  227. package/dist/vcs/github.d.ts +0 -50
  228. package/dist/vcs/guidance.d.ts +0 -20
  229. package/dist/vcs/index.d.ts +0 -7
  230. package/dist/vcs/service.d.ts +0 -61
  231. package/dist/vcs/types.d.ts +0 -73
  232. package/dist/web/demarcate.d.ts +0 -13
  233. package/dist/web/fetch.d.ts +0 -11
  234. package/dist/web/index.d.ts +0 -7
  235. package/dist/web/provider.d.ts +0 -29
  236. package/dist/web/search.d.ts +0 -17
  237. package/dist/web/ssrf.d.ts +0 -41
  238. package/dist/web/tools.d.ts +0 -20
  239. package/dist/web/types.d.ts +0 -64
  240. package/dist/workspace/add-root.d.ts +0 -27
  241. package/dist/workspace/index.d.ts +0 -6
  242. package/dist/workspace/resolve.d.ts +0 -54
  243. package/dist/workspace/select.d.ts +0 -41
  244. package/dist/workspace/types.d.ts +0 -30
  245. package/dist/workspace/workspace.d.ts +0 -61
@@ -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;
@@ -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;
@@ -1,2 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function buildProgram(): Command;
@@ -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>>;
@@ -1,6 +0,0 @@
1
- export * from "./keys.js";
2
- export * from "./input.js";
3
- export * from "./frame.js";
4
- export * from "./select.js";
5
- export * from "./fuzzy.js";
6
- export * from "./autocomplete.js";
@@ -1,78 +0,0 @@
1
- import type { RenderCapabilities } from "../render/index.js";
2
- import { type Key } from "./keys.js";
3
- /**
4
- * The one raw-mode input reader (U.7). Every interactive component — and the
5
- * refactored approval/onboarding key readers — reads keys through this seam;
6
- * nothing else in the CLI touches `setRawMode`. The lifecycle is strict:
7
- * `begin()` → `read()` loop → `restore()` in a `finally`, so the terminal is
8
- * never left in raw mode on any exit path (selection, cancel, throw).
9
- */
10
- /** The minimal stdin surface the reader needs. Injectable for tests. */
11
- export interface RawInput {
12
- isTTY?: boolean;
13
- setRawMode?(mode: boolean): unknown;
14
- resume(): unknown;
15
- pause(): unknown;
16
- on(event: "data" | "end", listener: (chunk: Buffer) => void): unknown;
17
- removeListener(event: "data" | "end", listener: (chunk: Buffer) => void): unknown;
18
- }
19
- /** Raw-mode key source with an explicit begin/read/restore lifecycle. */
20
- export interface KeyReader {
21
- /** Enter raw mode and start decoding. Safe to call once per interaction. */
22
- begin(): void;
23
- /**
24
- * The next decoded key. After stream end (or `restore()`), resolves
25
- * `{kind:"eof"}` forever — a component's read loop can never hang or reject.
26
- */
27
- read(): Promise<Key>;
28
- /** Leave raw mode, detach, pause. Idempotent; call in `finally`, always. */
29
- restore(): void;
30
- }
31
- /** Build the real reader over `stdin` (or an injected fake in tests). */
32
- export declare function createKeyReader(stdin?: RawInput): KeyReader;
33
- /**
34
- * Read exactly one key with the full begin/restore lifecycle — the shared
35
- * backend for the approval prompt's single-key read and the onboarding
36
- * `readKey`. Resolves the printable character, `"\n"` for enter, and `""` for
37
- * anything that means "no answer" (Ctrl-C, EOF, escape, arrows) — preserving
38
- * the callers' default-deny mapping.
39
- */
40
- export declare function readSingleKey(stdin?: RawInput): Promise<string>;
41
- /**
42
- * Every component resolves to a selection or a clean, typed cancellation
43
- * (Ctrl-C / EOF / escape). Cancellation is data for the caller to interpret —
44
- * never a thrown error, never a partial value.
45
- */
46
- export type InteractiveResult<T> = {
47
- kind: "selected";
48
- value: T;
49
- } | {
50
- kind: "cancelled";
51
- };
52
- /**
53
- * What a component needs from the environment, bundled so tests can script
54
- * all of it. `caps` is the existing U.2 capability detection — components
55
- * never re-probe NO_COLOR / width / TTY themselves.
56
- */
57
- export interface ComponentIO {
58
- caps: RenderCapabilities;
59
- /**
60
- * The whole interactive contract in one flag: stdin is a TTY *and* the
61
- * output supports cursor control (`TERM=dumb` fails this). When false, no
62
- * frame is drawn and no key is read — ever.
63
- */
64
- interactive: boolean;
65
- /** Transient frame bytes. Defaults to stderr so stdout stays pipe-clean. */
66
- write(text: string): void;
67
- keys: KeyReader;
68
- }
69
- /** The real environment: frames to stderr, keys from stdin, caps from stderr. */
70
- export declare function defaultComponentIO(): ComponentIO;
71
- /**
72
- * The shared non-TTY gate, run before any frame byte or key read:
73
- * - interactive → proceed;
74
- * - not interactive + a default was supplied → resolve to it immediately;
75
- * - otherwise → throw `CRUXY_E_INTERACTIVE_REQUIRED` (usage, exit 2).
76
- * Never blocks on a pipe, never silently picks an option.
77
- */
78
- export declare function resolveNonInteractive<T>(io: ComponentIO, what: string, defaultValue: T | undefined, alternatives?: string[]): InteractiveResult<T> | null;
@@ -1,48 +0,0 @@
1
- /**
2
- * Byte → key decoding for the interactive components (U.7). Pure data
3
- * transformation — no terminal, no state — so every mapping row is directly
4
- * unit-testable. The stateful raw-mode plumbing lives in `input.ts`.
5
- */
6
- /** One decoded keypress. The full vocabulary the U.7 components consume. */
7
- export type Key =
8
- /** A printable character (UTF-8; may be multi-byte, never a control char). */
9
- {
10
- kind: "char";
11
- char: string;
12
- } | {
13
- kind: "enter";
14
- } | {
15
- kind: "backspace";
16
- } | {
17
- kind: "tab";
18
- } | {
19
- kind: "escape";
20
- } | {
21
- kind: "up";
22
- } | {
23
- kind: "down";
24
- } | {
25
- kind: "left";
26
- } | {
27
- kind: "right";
28
- }
29
- /** Ctrl-C in raw mode (no SIGINT is delivered) — components must cancel. */
30
- | {
31
- kind: "ctrl-c";
32
- }
33
- /** Ctrl-D or stream end — components must cancel. */
34
- | {
35
- kind: "eof";
36
- };
37
- /**
38
- * Decode one raw-mode chunk into keys. A paste or fast typing delivers many
39
- * keys per chunk; all are returned in order.
40
- *
41
- * Escape handling is deliberately simple: `ESC [ A..D` decodes to an arrow,
42
- * any other CSI sequence (`ESC [ …final`) is swallowed whole (unmapped keys
43
- * must not leak garbage chars into a query), and a lone ESC decodes to
44
- * `escape`. Terminals send arrow sequences atomically in practice; a sequence
45
- * split across chunks degrades to `escape` + literal chars, which is safe
46
- * (escape cancels).
47
- */
48
- export declare function decodeKeys(chunk: Buffer | string): Key[];
@@ -1,28 +0,0 @@
1
- import { type ComponentIO, type InteractiveResult } from "./input.js";
2
- /**
3
- * SelectList (U.7): arrow-key pick from a short list of options. Single-select
4
- * only — multi-select is a deliberate seam for a later build (the result type
5
- * and key loop extend without breaking callers).
6
- */
7
- export interface SelectOptions<T> {
8
- /** Label an item renders under. Defaults to `String(item)`. */
9
- toLabel?: (item: T) => string;
10
- /** Header row above the options. */
11
- title?: string;
12
- /** Index highlighted first (so Enter-once picks a sensible default). */
13
- initialIndex?: number;
14
- /** Non-TTY fallback: resolve to this instead of failing loud. */
15
- defaultValue?: T;
16
- /** `--flag` alternatives listed in the non-TTY error. */
17
- nonInteractiveHint?: string[];
18
- /** Visible rows before the list scrolls (default 10). */
19
- maxVisible?: number;
20
- }
21
- /**
22
- * Pick one item: ↑/↓ move (wrapping past either end), Enter selects the
23
- * highlighted item, Esc / Ctrl-C / EOF cancel. Renders a transient frame via
24
- * the shared U.7 frame (width-truncated rows, no soft-wrap) and erases it
25
- * completely before resolving. Empty `items` resolves cancelled — there is
26
- * nothing to select.
27
- */
28
- export declare function selectList<T>(items: readonly T[], opts?: SelectOptions<T>, io?: ComponentIO): Promise<InteractiveResult<T>>;
@@ -1,18 +0,0 @@
1
- /** `~/.cruxy/credentials.json` */
2
- export declare function credentialsPath(): string;
3
- /** The stored key for `provider`, or `undefined`. Never throws. */
4
- export declare function readCredential(provider: string, file?: string): string | undefined;
5
- /**
6
- * The stored MCP bearer token for credential name `ref`, or `undefined` (C.27c).
7
- * Reads ONLY this owner-only store — never the environment, never any config file
8
- * — so a project config that merely NAMES a credential can never widen where the
9
- * secret is sourced from. Never throws.
10
- */
11
- export declare function readMcpCredential(ref: string, file?: string): string | undefined;
12
- /** Persist MCP bearer token for credential name `ref`. Same owner-only guarantee. */
13
- export declare function writeMcpCredential(ref: string, token: string, file?: string): void;
14
- /**
15
- * Persist `key` for `provider`, merging into any existing store. Written
16
- * owner-only (see {@link writeInto}); refuses loudly if that can't be enforced.
17
- */
18
- export declare function writeCredential(provider: string, key: string, file?: string): void;
@@ -1,5 +0,0 @@
1
- export * from "./schema.js";
2
- export * from "./paths.js";
3
- export * from "./manager.js";
4
- export * from "./project.js";
5
- export * from "./credentials.js";
@@ -1,39 +0,0 @@
1
- import { type CruxyConfig } from "./schema.js";
2
- export interface LoadOptions {
3
- /** Explicit config file, bypassing project discovery. */
4
- configPath?: string;
5
- /** Start dir for project-config discovery (defaults to cwd). */
6
- cwd?: string;
7
- }
8
- export interface LoadedConfig {
9
- config: CruxyConfig;
10
- sources: {
11
- global: string | null;
12
- project: string | null;
13
- explicit: string | null;
14
- };
15
- }
16
- /**
17
- * Resolution order (later wins):
18
- * schema defaults -> global file -> project file (or explicit) -> env vars
19
- */
20
- export declare function loadConfig(opts?: LoadOptions): LoadedConfig;
21
- /** Resolve a dot-path (e.g. "model.temperature") against a config object. */
22
- export declare function getPath(obj: unknown, path: string): unknown;
23
- /**
24
- * Set a dot-path on the given config file (creating it if needed), validating
25
- * the full merged result before writing. Returns the written file path.
26
- */
27
- export declare function setValue(path: string, rawValue: string, file: string): string;
28
- /** Write a default config to `file` if it does not already exist. */
29
- export declare function initConfig(file: string): {
30
- path: string;
31
- created: boolean;
32
- };
33
- /**
34
- * Provider API key, resolved **env → credentials store → undefined**. The
35
- * environment always wins (CI / one-off overrides); the credentials store
36
- * (`~/.cruxy/credentials.json`, written by onboarding / `cruxy login`) is the
37
- * persistent fallback. The key is never read from `config.json`.
38
- */
39
- export declare function resolveApiKey(provider: string): string | undefined;
@@ -1,19 +0,0 @@
1
- /**
2
- * Make `path` owner-only, or throw. On Windows the ACL is verified after the
3
- * edit (both the `icacls` exit code AND a read-back), so a returned call is a
4
- * genuine guarantee, never a best-effort attempt.
5
- *
6
- * @throws if owner-only permissions cannot be established (non-zero `icacls`,
7
- * an unresolvable SID, a filesystem without ACLs/modes, …).
8
- */
9
- export declare function enforceOwnerOnly(path: string, opts?: {
10
- directory?: boolean;
11
- }): void;
12
- /**
13
- * Whether `path` is currently owner-only. POSIX: no group/other bits. Windows:
14
- * best-effort — the ACL names no broad principal (Everyone / Authenticated
15
- * Users / Users). Used both to verify {@link enforceOwnerOnly} and to warn on a
16
- * pre-existing store with loose permissions. Returns `true` when it genuinely
17
- * cannot tell (a missing tool), so a warning path never cries wolf.
18
- */
19
- export declare function isOwnerOnly(path: string): boolean;
@@ -1,9 +0,0 @@
1
- /** ~/.cruxy */
2
- export declare function globalDir(): string;
3
- /** ~/.cruxy/config.json */
4
- export declare function globalConfigPath(): string;
5
- /**
6
- * Walk up from `startDir` looking for a project config file. Returns the first
7
- * match, or null if none is found before the filesystem root.
8
- */
9
- export declare function findProjectConfig(startDir?: string): string | null;
@@ -1,10 +0,0 @@
1
- /**
2
- * Load project instructions from `cwd`: the first of CRUXY.md, then AGENTS.md
3
- * that exists is read and returned. A missing (or unreadable) file is not an
4
- * error — it simply yields `null`. Oversized files are truncated to `MAX_BYTES`
5
- * with a trailing notice so they can't blow up the system prompt.
6
- *
7
- * Only `cwd` is consulted (no parent-directory walk) — instructions are scoped
8
- * to the project you launched cruxy in.
9
- */
10
- export declare function loadProjectInstructions(cwd: string): string | null;