@gajae-code/coding-agent 0.18.1 → 0.18.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/types/cli/stats-cli.d.ts +0 -5
  3. package/dist/types/config/autorouting-tier-map.d.ts +29 -2
  4. package/dist/types/config/model-registry.d.ts +16 -1
  5. package/dist/types/exa/mcp-client.d.ts +1 -5
  6. package/dist/types/exec/bash-shell-guardian.d.ts +26 -0
  7. package/dist/types/hashline/parser.d.ts +28 -5
  8. package/dist/types/modes/acp/acp-agent.d.ts +6 -1
  9. package/dist/types/sdk/broker/lifecycle.d.ts +6 -1
  10. package/dist/types/sdk/broker/recovery-backoff.d.ts +62 -0
  11. package/dist/types/sdk/broker/runtime.d.ts +20 -0
  12. package/dist/types/sdk/broker/startup-budget.d.ts +5 -1
  13. package/dist/types/sdk/bus/index.d.ts +1 -0
  14. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
  15. package/dist/types/sdk/host/session-runtime.d.ts +7 -0
  16. package/dist/types/sdk/prompt-watchdog.d.ts +1 -1
  17. package/dist/types/tools/bash.d.ts +1 -0
  18. package/package.json +7 -7
  19. package/src/cli/stats-cli.ts +4 -36
  20. package/src/cli-main.ts +4 -8
  21. package/src/cli.ts +4 -8
  22. package/src/commands/commit.ts +2 -2
  23. package/src/commands/sdk.ts +1 -2
  24. package/src/config/autorouting-tier-map.ts +20 -2
  25. package/src/config/model-preset-registry.ts +17 -2
  26. package/src/config/model-profile-activation.ts +3 -1
  27. package/src/config/model-profiles.ts +11 -3
  28. package/src/config/model-registry.ts +45 -17
  29. package/src/exa/mcp-client.ts +41 -8
  30. package/src/exec/bash-shell-guardian.ts +184 -34
  31. package/src/hashline/execute.ts +51 -3
  32. package/src/hashline/parser.ts +63 -16
  33. package/src/internal-urls/docs-index.generated.ts +22 -22
  34. package/src/modes/acp/acp-agent.ts +39 -4
  35. package/src/modes/controllers/ssh-command-controller.ts +3 -1
  36. package/src/sdk/broker/lifecycle.ts +408 -218
  37. package/src/sdk/broker/recovery-backoff.ts +135 -0
  38. package/src/sdk/broker/runtime.ts +83 -0
  39. package/src/sdk/broker/startup-budget.ts +6 -1
  40. package/src/sdk/bus/chat-daemon-control.ts +2 -2
  41. package/src/sdk/bus/index.ts +305 -19
  42. package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
  43. package/src/sdk/host/session-runtime.ts +99 -3
  44. package/src/sdk/prompt-watchdog.ts +17 -4
  45. package/src/session/agent-session.ts +14 -2
  46. package/src/session/internal/managed-session-storage.ts +23 -0
  47. package/src/tools/bash.ts +39 -0
  48. package/dist/types/cli/grep-cli.d.ts +0 -17
  49. package/dist/types/cli/shell-cli.d.ts +0 -8
  50. package/dist/types/commands/grep.d.ts +0 -42
  51. package/dist/types/commands/shell.d.ts +0 -21
  52. package/src/cli/grep-cli.ts +0 -160
  53. package/src/cli/shell-cli.ts +0 -176
  54. package/src/commands/grep.ts +0 -48
  55. package/src/commands/shell.ts +0 -29
@@ -1,176 +0,0 @@
1
- /**
2
- * Shell CLI command handlers.
3
- *
4
- * Handles `gjc shell` subcommand for testing the native brush-core shell.
5
- */
6
- import * as path from "node:path";
7
- import { createInterface } from "node:readline/promises";
8
- import { Shell } from "@gajae-code/natives";
9
- import { APP_NAME, getProjectDir } from "@gajae-code/utils";
10
- import chalk from "chalk";
11
- import { Settings } from "../config/settings";
12
- import { buildMinimizerOptions } from "../exec/bash-executor";
13
- import { getOrCreateSnapshot } from "../utils/shell-snapshot";
14
-
15
- export interface ShellCommandArgs {
16
- cwd?: string;
17
- timeoutMs?: number;
18
- noSnapshot?: boolean;
19
- }
20
-
21
- export function parseShellArgs(args: string[]): ShellCommandArgs | undefined {
22
- if (args.length === 0 || args[0] !== "shell") {
23
- return undefined;
24
- }
25
-
26
- const result: ShellCommandArgs = {};
27
-
28
- for (let i = 1; i < args.length; i++) {
29
- const arg = args[i];
30
- if (arg === "--cwd" || arg === "-C") {
31
- result.cwd = args[++i];
32
- } else if (arg === "--timeout" || arg === "-t") {
33
- const parsed = Number.parseInt(args[++i], 10);
34
- if (Number.isFinite(parsed)) {
35
- result.timeoutMs = parsed;
36
- }
37
- } else if (arg === "--no-snapshot") {
38
- result.noSnapshot = true;
39
- }
40
- }
41
-
42
- return result;
43
- }
44
-
45
- export async function runShellCommand(cmd: ShellCommandArgs): Promise<void> {
46
- if (!process.stdin.isTTY) {
47
- process.stderr.write("Error: shell console requires an interactive TTY.\n");
48
- process.exit(1);
49
- }
50
-
51
- const cwd = cmd.cwd ? path.resolve(cmd.cwd) : getProjectDir();
52
- const settings = await Settings.init({ cwd });
53
- const { shell, env: shellEnv } = settings.getShellConfig();
54
- const snapshotPath = cmd.noSnapshot || !shell.includes("bash") ? null : await getOrCreateSnapshot(shell, shellEnv);
55
- const minimizer = buildMinimizerOptions(settings.getGroup("shellMinimizer"));
56
- const shellSession = new Shell({ sessionEnv: shellEnv, snapshotPath: snapshotPath ?? undefined, minimizer });
57
-
58
- let active = false;
59
- let lastChar: string | null = null;
60
-
61
- const rl = createInterface({ input: process.stdin, output: process.stdout, terminal: true });
62
- const prompt = chalk.cyan(`${APP_NAME} shell> `);
63
-
64
- const printHelp = () => {
65
- process.stdout.write(
66
- `${chalk.bold("Shell Console Commands")}
67
-
68
- ` +
69
- `${chalk.bold("Special Commands:")}
70
- .help Show this help
71
- .exit, exit Exit the console
72
-
73
- ` +
74
- `${chalk.bold("Options:")}
75
- --cwd, -C <path> Set working directory for commands
76
- --timeout, -t <ms> Timeout per command in milliseconds
77
- --no-snapshot Skip sourcing snapshot from user shell
78
-
79
- ` +
80
- `${chalk.bold("Notes:")}
81
- Runs in a persistent brush-core shell session.
82
- Variables and functions defined in one command persist for the next.
83
-
84
- `,
85
- );
86
- };
87
-
88
- const interruptHandler = () => {
89
- if (active) {
90
- void shellSession.abort();
91
- return;
92
- }
93
- rl.close();
94
- process.exit(0);
95
- };
96
-
97
- process.on("SIGINT", interruptHandler);
98
- process.stdout.write(chalk.dim("Type .help for commands.\n"));
99
-
100
- try {
101
- while (true) {
102
- const line = (await rl.question(prompt)).trim();
103
- if (!line) {
104
- continue;
105
- }
106
- if (line === ".help") {
107
- printHelp();
108
- continue;
109
- }
110
- if (line === ".exit" || line === "exit" || line === "quit") {
111
- break;
112
- }
113
-
114
- active = true;
115
- lastChar = null;
116
- try {
117
- const result = await shellSession.run(
118
- {
119
- command: line,
120
- cwd,
121
- timeoutMs: cmd.timeoutMs,
122
- },
123
- (err, chunk) => {
124
- if (err) {
125
- process.stderr.write(`${err.message}\n`);
126
- return;
127
- }
128
- if (chunk.length > 0) {
129
- lastChar = chunk[chunk.length - 1] ?? null;
130
- }
131
- process.stdout.write(chunk);
132
- },
133
- );
134
-
135
- if (lastChar && lastChar !== "\n") {
136
- process.stdout.write("\n");
137
- }
138
-
139
- if (result.timedOut) {
140
- process.stderr.write(chalk.yellow("Command timed out.\n"));
141
- } else if (result.cancelled) {
142
- process.stderr.write(chalk.yellow("Command cancelled.\n"));
143
- } else if (result.exitCode !== 0 && result.exitCode !== undefined) {
144
- process.stderr.write(chalk.yellow(`Exit code: ${result.exitCode}\n`));
145
- }
146
- } catch (err) {
147
- const message = err instanceof Error ? err.message : String(err);
148
- process.stderr.write(chalk.red(`Error: ${message}\n`));
149
- } finally {
150
- active = false;
151
- }
152
- }
153
- } finally {
154
- process.off("SIGINT", interruptHandler);
155
- rl.close();
156
- }
157
- }
158
-
159
- export function printShellHelp(): void {
160
- process.stdout.write(`${chalk.bold(`${APP_NAME} shell`)} - Interactive shell console for testing
161
-
162
- ${chalk.bold("Usage:")}
163
- ${APP_NAME} shell [options]
164
-
165
- ${chalk.bold("Options:")}
166
- --cwd, -C <path> Set working directory for commands
167
- --timeout, -t <ms> Timeout per command in milliseconds
168
- --no-snapshot Skip sourcing snapshot from user shell
169
- -h, --help Show this help
170
-
171
- ${chalk.bold("Examples:")}
172
- ${APP_NAME} shell
173
- ${APP_NAME} shell --cwd ./tmp
174
- ${APP_NAME} shell --timeout 2000
175
- `);
176
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * Test grep tool.
3
- */
4
- import { GrepOutputMode } from "@gajae-code/natives";
5
- import { Args, Command, Flags } from "@gajae-code/utils/cli";
6
- import { type GrepCommandArgs, runGrepCommand } from "../cli/grep-cli";
7
- import { initTheme } from "../modes/theme/theme";
8
-
9
- export default class Grep extends Command {
10
- static description = "Test grep tool";
11
-
12
- static args = {
13
- pattern: Args.string({ description: "Regex pattern to search for", required: false }),
14
- path: Args.string({ description: "Directory or file to search", required: false }),
15
- };
16
-
17
- static flags = {
18
- glob: Flags.string({ char: "g", description: "Filter files by glob pattern" }),
19
- limit: Flags.integer({ char: "l", description: "Max matches", default: 20 }),
20
- context: Flags.integer({ char: "C", description: "Context lines", default: 2 }),
21
- files: Flags.boolean({ char: "f", description: "Output file names only" }),
22
- count: Flags.boolean({ char: "c", description: "Output match counts per file" }),
23
- "no-gitignore": Flags.boolean({ description: "Include files excluded by .gitignore" }),
24
- };
25
-
26
- async run(): Promise<void> {
27
- const { args, flags } = await this.parse(Grep);
28
-
29
- const mode: GrepCommandArgs["mode"] = flags.count
30
- ? GrepOutputMode.Count
31
- : flags.files
32
- ? GrepOutputMode.FilesWithMatches
33
- : GrepOutputMode.Content;
34
-
35
- const cmd: GrepCommandArgs = {
36
- pattern: args.pattern ?? "",
37
- path: args.path ?? ".",
38
- glob: flags.glob,
39
- limit: flags.limit,
40
- context: flags.context,
41
- mode,
42
- gitignore: !flags["no-gitignore"],
43
- };
44
-
45
- await initTheme();
46
- await runGrepCommand(cmd);
47
- }
48
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Interactive shell console.
3
- */
4
- import { Command, Flags } from "@gajae-code/utils/cli";
5
- import { runShellCommand, type ShellCommandArgs } from "../cli/shell-cli";
6
- import { initTheme } from "../modes/theme/theme";
7
-
8
- export default class Shell extends Command {
9
- static description = "Interactive shell console";
10
-
11
- static flags = {
12
- cwd: Flags.string({ char: "C", description: "Set working directory for commands" }),
13
- timeout: Flags.integer({ char: "t", description: "Timeout per command in milliseconds" }),
14
- "no-snapshot": Flags.boolean({ description: "Skip sourcing snapshot from user shell" }),
15
- };
16
-
17
- async run(): Promise<void> {
18
- const { flags } = await this.parse(Shell);
19
-
20
- const cmd: ShellCommandArgs = {
21
- cwd: flags.cwd,
22
- timeoutMs: flags.timeout,
23
- noSnapshot: flags["no-snapshot"],
24
- };
25
-
26
- await initTheme();
27
- await runShellCommand(cmd);
28
- }
29
- }