@botconnector/bccli 0.4.0 → 0.4.1

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 (162) hide show
  1. package/README.en.md +13 -2
  2. package/README.md +13 -2
  3. package/dist/abort.d.ts +5 -0
  4. package/dist/{acp-ATIL4JOZ.js → acp-3PHBAI64.js} +2 -2
  5. package/dist/acp.d.ts +27 -0
  6. package/dist/agent.d.ts +143 -0
  7. package/dist/agents.d.ts +4 -0
  8. package/dist/{args-J5ONVGIF.js → args-W6BNKY7K.js} +3 -3
  9. package/dist/args.d.ts +51 -0
  10. package/dist/budget.d.ts +23 -0
  11. package/dist/checkpoints.d.ts +34 -0
  12. package/dist/{chunk-L7QI6JN2.js → chunk-24JN75FZ.js} +6 -6
  13. package/dist/{chunk-XBO5GACQ.js → chunk-75BECX4F.js} +3 -3
  14. package/dist/{chunk-QDQU6VY2.js → chunk-BC7UXFE4.js} +10 -1
  15. package/dist/{chunk-M7CALSP3.js → chunk-BGXNR74O.js} +1 -1
  16. package/dist/{chunk-6M5X2KZE.js → chunk-BKGFA2PT.js} +1 -1
  17. package/dist/{chunk-BNA74HPN.js → chunk-BXQQCUAC.js} +4 -4
  18. package/dist/{chunk-LACUWBWS.js → chunk-FLQPE4S5.js} +21 -9
  19. package/dist/{chunk-JL5ZCSP2.js → chunk-GN4W3T6E.js} +3 -3
  20. package/dist/{chunk-SPRNLS7K.js → chunk-JHPGOAXU.js} +1 -1
  21. package/dist/{chunk-7F3IWBPQ.js → chunk-MFHCQQEN.js} +18 -8
  22. package/dist/{chunk-O7M3TGIW.js → chunk-MHIYLXJC.js} +35 -0
  23. package/dist/{chunk-TVALKHFB.js → chunk-PZRKU4UM.js} +10 -10
  24. package/dist/{chunk-TLPFQIS2.js → chunk-R5RE46CW.js} +2 -2
  25. package/dist/{chunk-BQ2IGPBR.js → chunk-WI22M2ID.js} +1 -1
  26. package/dist/{chunk-PUN4HMAG.js → chunk-WNACAUDK.js} +9 -3
  27. package/dist/{chunk-KEMYIGCP.js → chunk-XV7ZVL4J.js} +2 -2
  28. package/dist/cli.d.ts +1 -0
  29. package/dist/cli.js +34 -35
  30. package/dist/clipboardImage.d.ts +17 -0
  31. package/dist/commands.d.ts +16 -0
  32. package/dist/completion.d.ts +14 -0
  33. package/dist/{config-COPNMMV6.js → config-DIDLDONU.js} +2 -2
  34. package/dist/{config-RZ5JONMX.js → config-IU76CPK2.js} +7 -3
  35. package/dist/config.d.ts +97 -0
  36. package/dist/context.d.ts +13 -0
  37. package/dist/contextWindow.d.ts +3 -0
  38. package/dist/diff.d.ts +7 -0
  39. package/dist/exit.d.ts +9 -0
  40. package/dist/extensions.d.ts +34 -0
  41. package/dist/{ghBotCli-IBCZIWT5.js → ghBotCli-E3VPHNZY.js} +12 -12
  42. package/dist/ghBotCli.d.ts +9 -0
  43. package/dist/ghBotDispatch.d.ts +68 -0
  44. package/dist/ghBotRunner.d.ts +82 -0
  45. package/dist/ghBotServe.d.ts +21 -0
  46. package/dist/ghBotWebhook.d.ts +45 -0
  47. package/dist/hooks.d.ts +27 -0
  48. package/dist/i18n/id.d.ts +1 -0
  49. package/dist/i18n.d.ts +16 -0
  50. package/dist/{integrationCli-P75R2VSC.js → integrationCli-Q2YPDTPG.js} +1 -1
  51. package/dist/integrationCli.d.ts +9 -0
  52. package/dist/keybinds.d.ts +22 -0
  53. package/dist/{login-SYIQP46J.js → login-FP3BB44A.js} +3 -3
  54. package/dist/login.d.ts +19 -0
  55. package/dist/lsp.d.ts +47 -0
  56. package/dist/mcp/catalog.d.ts +14 -0
  57. package/dist/mcp/config.d.ts +36 -0
  58. package/dist/mcp/manager.d.ts +34 -0
  59. package/dist/mcp/oauth.d.ts +82 -0
  60. package/dist/{mcpCli-QUV5SD64.js → mcpCli-SNBDUWJN.js} +5 -5
  61. package/dist/mcpCli.d.ts +3 -0
  62. package/dist/mcpServer/serve.d.ts +8 -0
  63. package/dist/mcpServer/server.d.ts +19 -0
  64. package/dist/models.d.ts +13 -0
  65. package/dist/{modelsCli-TRRB5LX4.js → modelsCli-CZ2HNGKR.js} +4 -4
  66. package/dist/modelsCli.d.ts +15 -0
  67. package/dist/npmRunner.d.ts +21 -0
  68. package/dist/oauthLogin.d.ts +47 -0
  69. package/dist/permissions.d.ts +30 -0
  70. package/dist/pluginSpec.d.ts +25 -0
  71. package/dist/plugins.d.ts +45 -0
  72. package/dist/{pluginsCli-GNW4TPVV.js → pluginsCli-LPIUUDWB.js} +1 -1
  73. package/dist/pluginsCli.d.ts +16 -0
  74. package/dist/prCli.d.ts +33 -0
  75. package/dist/presets.d.ts +8 -0
  76. package/dist/print.d.ts +14 -0
  77. package/dist/provider.d.ts +140 -0
  78. package/dist/{providerCli-FAOZHOKW.js → providerCli-NMUFXAAS.js} +5 -5
  79. package/dist/providerCli.d.ts +17 -0
  80. package/dist/providers.d.ts +6 -0
  81. package/dist/reasoning.d.ts +12 -0
  82. package/dist/repomap.d.ts +10 -0
  83. package/dist/sdk.d.ts +57 -0
  84. package/dist/sdk.js +99 -18
  85. package/dist/{serve-6QLBJUYW.js → serve-KWOECK5W.js} +1 -1
  86. package/dist/{serve-JG7RLIUD.js → serve-X2ZV4S5U.js} +20 -14
  87. package/dist/serve.d.ts +37 -0
  88. package/dist/serveHeartbeat.d.ts +14 -0
  89. package/dist/serveProtocol.d.ts +47 -0
  90. package/dist/{session-KBAQ4BZ5.js → session-GKEXDJKZ.js} +2 -2
  91. package/dist/session.d.ts +30 -0
  92. package/dist/setup-OV3NWQN5.js +24 -0
  93. package/dist/setup.d.ts +74 -0
  94. package/dist/slash/copy.d.ts +1 -0
  95. package/dist/slash/diff.d.ts +1 -0
  96. package/dist/slash/doctor.d.ts +18 -0
  97. package/dist/slash/export.d.ts +2 -0
  98. package/dist/slash/info.d.ts +45 -0
  99. package/dist/slash/memory.d.ts +10 -0
  100. package/dist/statsCli.d.ts +62 -0
  101. package/dist/textToolCalls.d.ts +6 -0
  102. package/dist/thinking.d.ts +17 -0
  103. package/dist/tokenBudget.d.ts +22 -0
  104. package/dist/tools/bash.d.ts +52 -0
  105. package/dist/tools/diagnostics.d.ts +5 -0
  106. package/dist/tools/edit.d.ts +7 -0
  107. package/dist/tools/fetch.d.ts +41 -0
  108. package/dist/tools/glob.d.ts +5 -0
  109. package/dist/tools/globSafety.d.ts +7 -0
  110. package/dist/tools/grep.d.ts +13 -0
  111. package/dist/tools/ignore.d.ts +2 -0
  112. package/dist/tools/index.d.ts +12 -0
  113. package/dist/tools/memory.d.ts +13 -0
  114. package/dist/tools/paths.d.ts +2 -0
  115. package/dist/tools/plan.d.ts +10 -0
  116. package/dist/tools/read.d.ts +16 -0
  117. package/dist/tools/repomap.d.ts +2 -0
  118. package/dist/tools/sandbox.d.ts +12 -0
  119. package/dist/tools/shell.d.ts +18 -0
  120. package/dist/tools/skill.d.ts +3 -0
  121. package/dist/tools/task.d.ts +28 -0
  122. package/dist/tools/todo.d.ts +13 -0
  123. package/dist/tools/types.d.ts +52 -0
  124. package/dist/tools/websearch.d.ts +9 -0
  125. package/dist/tools/write.d.ts +5 -0
  126. package/dist/{transferCli-TK2GSVRK.js → transferCli-YUFPI6AH.js} +3 -3
  127. package/dist/transferCli.d.ts +23 -0
  128. package/dist/ui/App.d.ts +7 -0
  129. package/dist/ui/DiffView.d.ts +3 -0
  130. package/dist/ui/EditableText.d.ts +7 -0
  131. package/dist/ui/LinePrompt.d.ts +6 -0
  132. package/dist/ui/ListPicker.d.ts +11 -0
  133. package/dist/ui/Markdown.d.ts +8 -0
  134. package/dist/ui/McpMenu.d.ts +11 -0
  135. package/dist/ui/ModelPicker.d.ts +6 -0
  136. package/dist/ui/PermissionPrompt.d.ts +5 -0
  137. package/dist/ui/PlanApproval.d.ts +5 -0
  138. package/dist/ui/PromptInput.d.ts +18 -0
  139. package/dist/ui/ProviderMenu.d.ts +10 -0
  140. package/dist/ui/Spinner.d.ts +4 -0
  141. package/dist/ui/StatusBar.d.ts +9 -0
  142. package/dist/ui/TodoList.d.ts +4 -0
  143. package/dist/ui/ToolBlock.d.ts +14 -0
  144. package/dist/ui/complete.d.ts +1 -0
  145. package/dist/ui/focusReport.d.ts +1 -0
  146. package/dist/ui/index.d.ts +7 -0
  147. package/dist/ui/lineEdit.d.ts +42 -0
  148. package/dist/ui/replay.d.ts +4 -0
  149. package/dist/ui/table.d.ts +20 -0
  150. package/dist/ui/theme.d.ts +5 -0
  151. package/dist/ui/thinkingMouse.d.ts +33 -0
  152. package/dist/ui/transcript.d.ts +55 -0
  153. package/dist/ui/vim.d.ts +26 -0
  154. package/dist/{ui-B3CJ6TGE.js → ui-IVIFNUCC.js} +13 -11
  155. package/dist/{update-K5IQ2MYR.js → update-TZ2G6KQ3.js} +1 -1
  156. package/dist/update.d.ts +30 -0
  157. package/dist/verify.d.ts +16 -0
  158. package/dist/version.d.ts +1 -0
  159. package/dist/webBudget.d.ts +25 -0
  160. package/dist/worktree.d.ts +12 -0
  161. package/package.json +26 -13
  162. package/dist/setup-FJAWDWV4.js +0 -24
package/README.en.md CHANGED
@@ -19,6 +19,9 @@ edits files, and runs commands — with your permission.
19
19
  # one-line install (macOS / Linux / WSL2) — provisions a portable Node if needed, no sudo
20
20
  curl -fsSL https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.sh | bash
21
21
 
22
+ # Windows (PowerShell 5.1+) — needs Node.js 22+ already installed
23
+ irm https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.ps1 | iex
24
+
22
25
  # or manual, if you already have Node.js 22+
23
26
  npm i -g @botconnector/bccli # latest stable, requires Node.js 22+
24
27
  npm i -g @botconnector/bccli@next # …or the next prerelease
@@ -53,13 +56,18 @@ In-session commands (type `/` for suggestions, ↑↓ to select, Enter to run):
53
56
  | `/session` | info about this session |
54
57
  | `/status` | version, model, permission mode, MCP, context |
55
58
  | `/permissions` | view/revoke permissions |
59
+ | `/pr` | review a pull request (`/pr <n\|url\|branch>`) |
60
+ | `/worktree` | list git worktrees; create one with `bccli -w <name>` |
56
61
  | `/undo` | undo the last file-edit turn |
62
+ | `/redo` | re-apply the file edits that /undo just reverted |
63
+ | `/rewind` | step back turns: conversation + file edits (`/rewind 2`) |
57
64
  | `/diff` | git diff of the project |
58
65
  | `/copy` | copy the last answer |
59
66
  | `/export` | save the conversation to markdown |
60
67
  | `/memory` | project instructions (/memory <text>, /memory global <text>) |
61
68
  | `/init` | create/update AGENTS.md for this project |
62
69
  | `/agents` | list subagents |
70
+ | `/tasks` | list background tasks |
63
71
  | `/skills` | list skills and custom commands |
64
72
  | `/doctor` | check installation health |
65
73
  | `/login` | store the active provider's API key |
@@ -125,6 +133,8 @@ the `reasoning` preference is read only from the user config `~/.bccli/config.js
125
133
  cloned repo — permissions (`permissionMode`, `allow`) and existing providers are configured only
126
134
  from `~/.bccli/config.json`, so a cloned repo cannot grant itself full permissions or steal API keys.
127
135
 
136
+ Every key of `~/.bccli/config.json` with its values and scope: [`docs/config.md`](docs/config.md).
137
+
128
138
  ## External agent integrations
129
139
 
130
140
  BCCLI can set up BotConnector as a provider for other agents:
@@ -221,16 +231,17 @@ Tasks with ≥ 3 steps show a checklist above the input box. In plan mode (Shift
221
231
  the agent only reads and then proposes a plan; `[a]` approves with automatic edits,
222
232
  `[y]` approves asking at each step, `[n]` asks for revisions.
223
233
 
224
- Project instructions are read from `AGENTS.md` and `BCCLI.md`.
234
+ Project instructions are read from `AGENTS.md`, `CLAUDE.md`, and `BCCLI.md`.
225
235
 
226
236
  ## Development
227
237
 
228
238
  ```bash
229
239
  npm install
230
240
  npm test && npm run typecheck && npm run lint && npm run build
241
+ npm run coverage # coverage gate (also enforced on Linux CI)
231
242
  ```
232
243
 
233
- CI (`ci.yml`) runs the same on Linux, macOS, and Windows.
244
+ CI (`ci.yml`) runs the same on Linux, macOS, and Windows, plus the coverage gate on Linux.
234
245
  Releases: bump `version` in `package.json`, then push a `v<version>` tag — `release.yml`
235
246
  runs tests, a smoke test against BotConnector Cloud, and `npm publish --provenance`.
236
247
 
package/README.md CHANGED
@@ -19,6 +19,9 @@ dan menjalankan perintah — dengan izin kamu.
19
19
  # install satu baris (macOS / Linux / WSL2) — pasang Node portable bila perlu, tanpa sudo
20
20
  curl -fsSL https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.sh | bash
21
21
 
22
+ # Windows (PowerShell 5.1+) — butuh Node.js 22+ terpasang lebih dulu
23
+ irm https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.ps1 | iex
24
+
22
25
  # atau manual, bila Node.js 22+ sudah terpasang
23
26
  npm i -g @botconnector/bccli # rilis stabil terbaru, butuh Node.js 22+
24
27
  npm i -g @botconnector/bccli@next # …atau pra-rilis berikutnya
@@ -53,13 +56,18 @@ Perintah di dalam sesi (ketik `/` untuk saran, ↑↓ pilih, Enter jalankan):
53
56
  | `/session` | info sesi ini |
54
57
  | `/status` | versi, model, mode izin, MCP, konteks |
55
58
  | `/permissions` | lihat/cabut izin |
59
+ | `/pr` | review pull request (`/pr <n\|url\|branch>`) |
60
+ | `/worktree` | daftar git worktree; buat dengan `bccli -w <nama>` |
56
61
  | `/undo` | batalkan edit file giliran terakhir |
62
+ | `/redo` | terapkan ulang edit file yang baru dibatalkan `/undo` |
63
+ | `/rewind` | mundur beberapa giliran: percakapan + edit file (`/rewind 2`) |
57
64
  | `/diff` | git diff project |
58
65
  | `/copy` | salin jawaban terakhir |
59
66
  | `/export` | simpan percakapan ke markdown |
60
67
  | `/memory` | instruksi project (/memory <teks>, /memory global <teks>) |
61
68
  | `/init` | buat/perbarui AGENTS.md untuk project ini |
62
69
  | `/agents` | daftar subagent |
70
+ | `/tasks` | daftar tugas latar belakang |
63
71
  | `/skills` | daftar skill dan perintah custom |
64
72
  | `/doctor` | cek kesehatan instalasi |
65
73
  | `/login` | simpan API key provider aktif |
@@ -124,6 +132,8 @@ preference `reasoning` hanya dibaca dari config user `~/.bccli/config.json`, buk
124
132
  izin (`permissionMode`, `allow`) dan provider yang sudah ada hanya diatur dari `~/.bccli/config.json`,
125
133
  supaya repo yang kamu clone tidak bisa memberi dirinya izin penuh atau mencuri API key.
126
134
 
135
+ Daftar lengkap kunci `~/.bccli/config.json` beserta nilai dan cakupannya: [`docs/config.md`](docs/config.md).
136
+
127
137
  ## Integrasi agent eksternal
128
138
 
129
139
  BCCLI dapat memasang BotConnector sebagai provider untuk agent lain:
@@ -218,16 +228,17 @@ Tugas ≥ 3 langkah menampilkan checklist di atas kotak input. Di mode plan (Shi
218
228
  agent hanya membaca lalu mengajukan rencana; `[a]` setujui dengan edit otomatis,
219
229
  `[y]` setujui dengan tanya tiap langkah, `[n]` minta perbaikan.
220
230
 
221
- Instruksi project dibaca dari `AGENTS.md` dan `BCCLI.md`.
231
+ Instruksi project dibaca dari `AGENTS.md`, `CLAUDE.md`, dan `BCCLI.md`.
222
232
 
223
233
  ## Pengembangan
224
234
 
225
235
  ```bash
226
236
  npm install
227
237
  npm test && npm run typecheck && npm run lint && npm run build
238
+ npm run coverage # gerbang coverage (juga dijalankan di CI Linux)
228
239
  ```
229
240
 
230
- CI (`ci.yml`) menjalankan hal yang sama di Linux, macOS, dan Windows.
241
+ CI (`ci.yml`) menjalankan hal yang sama di Linux, macOS, dan Windows, plus gerbang coverage di Linux.
231
242
  Rilis: naikkan `version` di `package.json`, lalu push tag `v<version>` — `release.yml`
232
243
  menjalankan test, smoke test ke BotConnector Cloud, dan `npm publish --provenance`.
233
244
 
@@ -0,0 +1,5 @@
1
+ export declare const ABORTED: unique symbol;
2
+ /** Resolves with the promise's value, or with ABORTED as soon as the signal fires. */
3
+ export declare function raceAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T | typeof ABORTED>;
4
+ /** Collects an async iterable, giving up (and telling the iterator to stop) as soon as the signal fires. */
5
+ export declare function collectUntilAbort<T>(iterable: AsyncIterable<T>, signal: AbortSignal | undefined, onItem: (item: T) => void): Promise<boolean>;
@@ -161,8 +161,8 @@ function runtimeAgent(cwd, allowAll = false) {
161
161
  return {
162
162
  async run(text, onChunk, signal, io) {
163
163
  if (!rt) {
164
- const { parseCliArgs } = await import("./args-J5ONVGIF.js");
165
- const { createRuntime } = await import("./setup-FJAWDWV4.js");
164
+ const { parseCliArgs } = await import("./args-W6BNKY7K.js");
165
+ const { createRuntime } = await import("./setup-OV3NWQN5.js");
166
166
  rt = createRuntime({ cwd, args: { ...parseCliArgs([]), allowAll } });
167
167
  }
168
168
  if (io && !allowAll) rt.agent.askPermission = (req) => io.askPermission(req);
package/dist/acp.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { PermissionAnswer, PermissionAsk } from './agent';
2
+ export declare const ACP_PROTOCOL_VERSION = 1;
3
+ /** What the agent reports to the editor besides text: tool calls, and permission questions the editor answers. */
4
+ export interface AcpIo {
5
+ toolStart(id: string, tool: string, target: string): void;
6
+ toolEnd(id: string, output: string, isError: boolean): void;
7
+ askPermission(req: PermissionAsk): Promise<PermissionAnswer>;
8
+ }
9
+ /** The minimum an ACP client needs: run one prompt, stream text chunks, allow cancellation. */
10
+ export interface AcpAgent {
11
+ run(text: string, onChunk: (text: string) => void, signal: AbortSignal, io?: AcpIo): Promise<void>;
12
+ }
13
+ /**
14
+ * Agent Client Protocol over newline-delimited JSON-RPC (the transport editors like Zed use).
15
+ * Implements the subset: initialize, session/new, session/prompt (streaming session/update
16
+ * notifications: text chunks and tool calls), session/request_permission, session/cancel;
17
+ * anything else with an id gets -32601.
18
+ */
19
+ export declare function runAcp(input: NodeJS.ReadableStream, output: NodeJS.WritableStream, opts: {
20
+ cwd: string;
21
+ newAgent: (cwd: string) => AcpAgent;
22
+ }): Promise<void>;
23
+ /**
24
+ * Production agent: one bccli runtime per ACP session. Permission questions go to the editor
25
+ * (session/request_permission); `allowAll` skips them and runs everything unasked.
26
+ */
27
+ export declare function runtimeAgent(cwd: string, allowAll?: boolean): AcpAgent;
@@ -0,0 +1,143 @@
1
+ import type { PermissionRequest, Permissions } from './permissions';
2
+ import { type ChatMessage, type Provider, type Usage } from './provider';
3
+ import type { ReasoningLevel } from './reasoning';
4
+ import { type HookEvent, type HooksConfig } from './hooks';
5
+ import type { Tool } from './tools/types';
6
+ import { type UsageCap } from './budget';
7
+ export type AgentEvent = {
8
+ type: 'text';
9
+ delta: string;
10
+ } | {
11
+ type: 'thinking';
12
+ delta: string;
13
+ } | {
14
+ type: 'textReplace';
15
+ text: string;
16
+ } | {
17
+ type: 'toolStart';
18
+ id: string;
19
+ tool: string;
20
+ target: string;
21
+ } | {
22
+ type: 'toolEnd';
23
+ id: string;
24
+ tool: string;
25
+ output: string;
26
+ display?: string;
27
+ isError: boolean;
28
+ } | {
29
+ type: 'usage';
30
+ inputTokens: number;
31
+ outputTokens: number;
32
+ cachedInputTokens?: number;
33
+ cacheWriteTokens?: number;
34
+ } | {
35
+ type: 'compacted';
36
+ } | {
37
+ type: 'stepLimit';
38
+ maxSteps: number;
39
+ } | {
40
+ type: 'budgetExceeded';
41
+ kind: 'tokens' | 'usd';
42
+ used: number;
43
+ limit: number;
44
+ } | {
45
+ type: 'aborted';
46
+ } | {
47
+ type: 'error';
48
+ message: string;
49
+ } | {
50
+ type: 'done';
51
+ } | {
52
+ type: 'subagent';
53
+ parentId: string;
54
+ agent: string;
55
+ event: AgentEvent;
56
+ };
57
+ export type PermissionAnswer = 'yes' | 'session' | 'all' | 'no';
58
+ export type PermissionAsk = PermissionRequest & {
59
+ preview?: string;
60
+ sessionRules?: string[];
61
+ agent?: string;
62
+ };
63
+ export type AskPermission = (req: PermissionAsk) => Promise<PermissionAnswer>;
64
+ export interface AgentOptions {
65
+ provider: Provider;
66
+ tools: Tool[];
67
+ permissions: Permissions;
68
+ systemPrompt: string;
69
+ cwd: string;
70
+ history?: ChatMessage[];
71
+ maxSteps?: number | null;
72
+ contextWindow?: number;
73
+ onMessage?: (message: ChatMessage) => void;
74
+ onReset?: () => void;
75
+ /** Per-turn token usage delta (provider-reported or estimated); the session persists it for stats. */
76
+ onUsage?: (usage: Usage) => void;
77
+ /** Marks the start of a user turn (undo boundary). */
78
+ onTurnStart?: () => void;
79
+ checkpoint?: (absPath: string) => Promise<void>;
80
+ /** Subagent name, shown on its permission prompts. */
81
+ label?: string;
82
+ reasoning?: ReasoningLevel;
83
+ /** Tool/session hooks (global config only). */
84
+ hooks?: HooksConfig;
85
+ /** In-process plugin observers fired alongside the shell hooks (global config plugins). */
86
+ pluginEmit?: (event: HookEvent, payload?: {
87
+ tool?: string;
88
+ input?: unknown;
89
+ output?: string;
90
+ }) => Promise<void>;
91
+ /** Base environment handed to hook processes (defaults to the process env at spawn). */
92
+ env?: NodeJS.ProcessEnv;
93
+ /** Per-session token/USD budget (global config usageCap); blocks model calls once exceeded. */
94
+ usageCap?: UsageCap;
95
+ /** Model ref used to match usageCap.prices keys. */
96
+ budgetModel?: string;
97
+ }
98
+ export declare class Agent {
99
+ private readonly opts;
100
+ provider: Provider;
101
+ permissions: Permissions;
102
+ messages: ChatMessage[];
103
+ totalUsage: Usage;
104
+ lastInputTokens: number;
105
+ onEvent: (event: AgentEvent) => void;
106
+ reasoning: ReasoningLevel;
107
+ askPermission: AskPermission;
108
+ tools: Tool[];
109
+ private definitions;
110
+ private turnTools;
111
+ private turnDefinitions;
112
+ private readonly readFiles;
113
+ private readonly webBudget;
114
+ private readonly maxSteps?;
115
+ private contextWindow;
116
+ private systemPrompt;
117
+ constructor(opts: AgentOptions);
118
+ setSystemPrompt(text: string): void;
119
+ setContextWindow(window: number): void;
120
+ setTools(tools: Tool[]): void;
121
+ private isParallelSafe;
122
+ private push;
123
+ /** Swaps in another conversation (resume, new session) without writing to the session log. */
124
+ load(messages: ChatMessage[]): void;
125
+ clear(): void;
126
+ compact(signal: AbortSignal): Promise<void>;
127
+ /**
128
+ * Events of one tool execution. A cancelled turn gives up on a tool that does not stop, and whatever that tool
129
+ * reports later must not reach the screen or a newer turn, so this is per execution and not per call id (ids repeat).
130
+ */
131
+ private report;
132
+ run(text: string, signal: AbortSignal): Promise<void>;
133
+ /** Current cap status; undefined means the budget is not exhausted. */
134
+ private overBudget;
135
+ /** Every tool call needs an answer in the history, or the next request to the model is rejected. */
136
+ private cancelCalls;
137
+ /**
138
+ * Every tool call must resolve with text: a rejected one would leave the assistant tool_calls
139
+ * without answers, and the next request to the model would be rejected until a restart.
140
+ */
141
+ private runTool;
142
+ private executeTool;
143
+ }
@@ -0,0 +1,4 @@
1
+ import type { AgentDef } from './extensions';
2
+ export declare const EXPLORE_PROMPT = "You are a read-only research agent working for another agent. Search and read the codebase to answer the request. You cannot edit files or run commands. Reply with a concise report: the answer, the relevant file paths with line numbers, and nothing else.";
3
+ export declare const GENERAL_PROMPT = "You are an agent handling a delegated task for another agent. Complete the task end to end with the tools you have, verify the result, and reply with a short report of what you did and what you found.";
4
+ export declare const BUILTIN_AGENTS: AgentDef[];
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  helpText,
4
4
  parseCliArgs
5
- } from "./chunk-KEMYIGCP.js";
6
- import "./chunk-O7M3TGIW.js";
5
+ } from "./chunk-XV7ZVL4J.js";
6
+ import "./chunk-MHIYLXJC.js";
7
7
  import "./chunk-BLOYFIAD.js";
8
- import "./chunk-LACUWBWS.js";
8
+ import "./chunk-FLQPE4S5.js";
9
9
  import "./chunk-UZWJQF67.js";
10
10
  export {
11
11
  helpText,
package/dist/args.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { type PermissionMode } from './config';
2
+ import { type ReasoningLevel } from './reasoning';
3
+ import { type Lang } from './i18n';
4
+ export interface CliArgs {
5
+ command: 'run' | 'login' | 'models' | 'update' | 'acp' | 'serve' | 'plugins' | 'gh-bot' | 'provider' | 'mcp' | 'connect' | 'disconnect' | 'integrations' | 'completion' | 'stats' | 'export' | 'import' | 'pr';
6
+ subArgs: string[];
7
+ url?: string;
8
+ name?: string;
9
+ keyEnv?: string;
10
+ values: string[];
11
+ prompt?: string;
12
+ print: boolean;
13
+ model?: string;
14
+ reasoning?: ReasoningLevel;
15
+ lang?: Lang;
16
+ continue: boolean;
17
+ resume: boolean;
18
+ allowAll: boolean;
19
+ allowedTools: string[];
20
+ worktree?: string;
21
+ outputFormat?: 'text' | 'json' | 'stream-json';
22
+ permissionMode?: PermissionMode;
23
+ help: boolean;
24
+ version: boolean;
25
+ loginProvider?: string;
26
+ /** `bccli login` — pakai prompt API key lama, bukan OAuth. */
27
+ key: boolean;
28
+ /** `bccli login` — hapus credential tersimpan (hanya openrouter via OAuth path). */
29
+ logout: boolean;
30
+ /** `bccli serve` listener port (0 = ephemeral). */
31
+ port?: number;
32
+ /** `bccli serve` bind address — loopback only. */
33
+ host?: string;
34
+ /** `bccli serve` bearer token override. */
35
+ token?: string;
36
+ /** Base URL override for `bccli mcp serve`. */
37
+ baseUrl?: string;
38
+ /** `bccli stats` — only count sessions from the last N days (default 7). */
39
+ days?: number;
40
+ /** `bccli stats` - cap the tool-usage list to the top N tools. */
41
+ tools?: number;
42
+ /** `bccli stats [--models [N|all]]` - show per-model token usage (top N or all). */
43
+ models?: string;
44
+ /** `bccli stats --project <slug>` - filter rows; empty string = current project. */
45
+ project?: string;
46
+ /** `bccli pr` — explicit owner/name repo when cwd is not a git checkout of the PR. */
47
+ repo?: string;
48
+ }
49
+ /** Help text in the current language (call it after the language is set). */
50
+ export declare const helpText: () => string;
51
+ export declare function parseCliArgs(argv: string[]): CliArgs;
@@ -0,0 +1,23 @@
1
+ export interface UsageCap {
2
+ /** Total tokens (input + output) per session. */
3
+ tokens?: number;
4
+ /** Total USD per session; requires `prices`. */
5
+ usd?: number;
6
+ /** USD per 1M tokens, keyed by a substring of the model ref (first match wins). */
7
+ prices?: Record<string, {
8
+ input: number;
9
+ output: number;
10
+ }>;
11
+ }
12
+ export declare function priceFor(cap: UsageCap, model: string): {
13
+ input: number;
14
+ output: number;
15
+ } | undefined;
16
+ export declare function budgetStatus(usage: {
17
+ inputTokens: number;
18
+ outputTokens: number;
19
+ }, cap: UsageCap | undefined, model: string): {
20
+ kind: 'tokens' | 'usd';
21
+ used: number;
22
+ limit: number;
23
+ } | undefined;
@@ -0,0 +1,34 @@
1
+ interface UndoResult {
2
+ restored: string[];
3
+ deleted: string[];
4
+ skipped: string[];
5
+ failed: string[];
6
+ }
7
+ export declare class CheckpointStore {
8
+ private readonly history;
9
+ private current;
10
+ private pendingRedo;
11
+ beginTurn(): void;
12
+ /** Call before writing a file; only the first snapshot per file per turn is kept. */
13
+ snapshot(path: string): Promise<void>;
14
+ turns(): number;
15
+ /** Total entries including empty ones; used to align file snapshots with conversation turns. */
16
+ entries(): number;
17
+ undo(): Promise<UndoResult | undefined>;
18
+ /**
19
+ * Revert every snapshot taken at or after the `keep`-th entry, newest first, so the files
20
+ * end in the state from before the turn that created entry `keep`. Used by /rewind, which
21
+ * pairs conversation turns with the entry count recorded when each turn started.
22
+ */
23
+ undoTo(keep: number): Promise<UndoResult | undefined>;
24
+ /**
25
+ * Re-apply the file state captured right before the last undo/undoTo.
26
+ * Only file edits are redone, never conversation history. Invalidated by
27
+ * any new snapshot turn or clear(), so redo can't resurrect stale content.
28
+ */
29
+ redo(): Promise<UndoResult | undefined>;
30
+ /** Records the on-disk state of a turn's paths so redo() can put it back. */
31
+ private captureFor;
32
+ clear(): void;
33
+ }
34
+ export {};
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- ConfigError
4
- } from "./chunk-LACUWBWS.js";
3
+ ConfigError,
4
+ writeFileAtomic
5
+ } from "./chunk-FLQPE4S5.js";
5
6
  import {
6
7
  t
7
8
  } from "./chunk-UZWJQF67.js";
8
9
 
9
10
  // src/mcp/config.ts
10
11
  import { createHash } from "crypto";
11
- import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
12
+ import { existsSync, mkdirSync, readFileSync } from "fs";
12
13
  import { dirname, join, resolve } from "path";
13
14
  var ENV_REF = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
14
15
  function expandEnvVars(config, env) {
@@ -41,9 +42,8 @@ function readJson(path, fallback) {
41
42
  }
42
43
  function writePrivate(path, data) {
43
44
  mkdirSync(dirname(path), { recursive: true });
44
- writeFileSync(path, `${JSON.stringify(data, null, 2)}
45
- `, { mode: 384 });
46
- chmodSync(path, 384);
45
+ writeFileAtomic(path, `${JSON.stringify(data, null, 2)}
46
+ `, 384);
47
47
  }
48
48
  function readMcpFile(path) {
49
49
  return readJson(path, {}).mcpServers ?? {};
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  hasKey,
4
4
  providerName
5
- } from "./chunk-SPRNLS7K.js";
5
+ } from "./chunk-JHPGOAXU.js";
6
6
  import {
7
7
  createProvider
8
- } from "./chunk-PUN4HMAG.js";
8
+ } from "./chunk-WNACAUDK.js";
9
9
  import {
10
10
  PRESETS,
11
11
  readCredentials
12
- } from "./chunk-LACUWBWS.js";
12
+ } from "./chunk-FLQPE4S5.js";
13
13
  import {
14
14
  t
15
15
  } from "./chunk-UZWJQF67.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  contentText
4
- } from "./chunk-PUN4HMAG.js";
4
+ } from "./chunk-WNACAUDK.js";
5
5
 
6
6
  // src/session.ts
7
7
  import { randomBytes } from "crypto";
@@ -79,6 +79,15 @@ var Session = class _Session {
79
79
  }
80
80
  return repairTail(messages);
81
81
  }
82
+ /** Model of the most recent turn that recorded usage — serve attach continues a session with its own model. */
83
+ lastModel() {
84
+ const records = this.records();
85
+ for (let i = records.length - 1; i >= 0; i--) {
86
+ const record = records[i];
87
+ if (record.t === "usage" && record.model) return record.model;
88
+ }
89
+ return void 0;
90
+ }
82
91
  /**
83
92
  * What the user sees on resume: the whole conversation. Compaction only shrinks what the model is sent, so
84
93
  * its reset does not hide the older turns here. A real reset (/clear, rewind) still starts over, the
@@ -404,7 +404,7 @@ var BUILTIN_AGENTS = [
404
404
  // src/context.ts
405
405
  import { existsSync as existsSync3, readFileSync } from "fs";
406
406
  import { dirname, join } from "path";
407
- var FILES = ["AGENTS.md", "BCCLI.md"];
407
+ var FILES = ["AGENTS.md", "CLAUDE.md", "BCCLI.md"];
408
408
  function readIf(path) {
409
409
  try {
410
410
  return existsSync3(path) ? readFileSync(path, "utf8").trim() : void 0;
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.4.0" : "0.0.0-dev";
4
+ var VERSION = true ? "0.4.1" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  defaultOpen
4
- } from "./chunk-7F3IWBPQ.js";
4
+ } from "./chunk-MFHCQQEN.js";
5
5
  import {
6
6
  removeCredential,
7
7
  saveCredential
8
- } from "./chunk-LACUWBWS.js";
8
+ } from "./chunk-FLQPE4S5.js";
9
9
  import {
10
10
  t
11
11
  } from "./chunk-UZWJQF67.js";
@@ -91,8 +91,8 @@ function defaultLoginDeps() {
91
91
  fetch: globalThis.fetch,
92
92
  // Wiring NYATA jalur lama: persis runLogin lama (provider add + prompt key).
93
93
  legacyAdd: async (providerId, targetCwd) => {
94
- const { runProviderCommand } = await import("./providerCli-FAOZHOKW.js");
95
- const { parseCliArgs: parse } = await import("./args-J5ONVGIF.js");
94
+ const { runProviderCommand } = await import("./providerCli-NMUFXAAS.js");
95
+ const { parseCliArgs: parse } = await import("./args-W6BNKY7K.js");
96
96
  return runProviderCommand(parse(["provider", "add", providerId]), {
97
97
  env: process.env,
98
98
  cwd: targetCwd,
@@ -274,11 +274,12 @@ function readGlobalPlugins(env = process.env) {
274
274
  }
275
275
  return value;
276
276
  }
277
- function writeFileAtomic(path, data) {
277
+ function writeFileAtomic(path, data, mode) {
278
278
  const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
279
279
  try {
280
- writeFileSync(tmp, data);
280
+ writeFileSync(tmp, data, mode === void 0 ? void 0 : { mode });
281
281
  renameSync(tmp, path);
282
+ if (mode !== void 0) chmodSync(path, mode);
282
283
  } catch (error) {
283
284
  try {
284
285
  rmSync(tmp, { force: true });
@@ -287,6 +288,18 @@ function writeFileAtomic(path, data) {
287
288
  throw error;
288
289
  }
289
290
  }
291
+ function quarantineCorruptFile(path, error) {
292
+ const stamp = Date.now();
293
+ let dest = `${path}.corrupt-${stamp}`;
294
+ for (let n = 1; existsSync(dest); n++) dest = `${path}.corrupt-${stamp}-${n}`;
295
+ try {
296
+ renameSync(path, dest);
297
+ } catch {
298
+ return void 0;
299
+ }
300
+ console.error(`${path} is not valid JSON (${error.message}); moved it to ${dest} instead of overwriting it.`);
301
+ return dest;
302
+ }
290
303
  function updateGlobalConfig(env, mutate) {
291
304
  const path = globalConfigPath(env);
292
305
  let cfg = {};
@@ -303,16 +316,15 @@ function readCredentials(env = process.env) {
303
316
  if (!existsSync(path)) return {};
304
317
  try {
305
318
  return JSON.parse(readFileSync(path, "utf8"));
306
- } catch {
319
+ } catch (error) {
320
+ quarantineCorruptFile(path, error);
307
321
  return {};
308
322
  }
309
323
  }
310
324
  function saveCredential(providerId, key, env = process.env) {
311
325
  const home = bccliHome(env);
312
326
  mkdirSync(home, { recursive: true });
313
- const path = join(home, "credentials");
314
- writeFileSync(path, JSON.stringify({ ...readCredentials(env), [providerId]: key }, null, 2), { mode: 384 });
315
- chmodSync(path, 384);
327
+ writeFileAtomic(join(home, "credentials"), JSON.stringify({ ...readCredentials(env), [providerId]: key }, null, 2), 384);
316
328
  }
317
329
  function resolveModel(config, modelRef, env = process.env) {
318
330
  const slash = modelRef.indexOf("/");
@@ -334,9 +346,7 @@ function removeCredential(providerId, env = process.env) {
334
346
  const creds = readCredentials(env);
335
347
  if (!(providerId in creds)) return false;
336
348
  delete creds[providerId];
337
- const path = join(bccliHome(env), "credentials");
338
- writeFileSync(path, JSON.stringify(creds, null, 2), { mode: 384 });
339
- chmodSync(path, 384);
349
+ writeFileAtomic(join(bccliHome(env), "credentials"), JSON.stringify(creds, null, 2), 384);
340
350
  return true;
341
351
  }
342
352
 
@@ -353,6 +363,8 @@ export {
353
363
  loadConfig,
354
364
  globalConfigPath,
355
365
  readGlobalPlugins,
366
+ writeFileAtomic,
367
+ quarantineCorruptFile,
356
368
  updateGlobalConfig,
357
369
  readCredentials,
358
370
  saveCredential,
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  listAllModels
4
- } from "./chunk-XBO5GACQ.js";
4
+ } from "./chunk-75BECX4F.js";
5
5
  import {
6
6
  hasKey,
7
7
  providerName,
8
8
  removeGlobalProvider,
9
9
  writeGlobalConfig
10
- } from "./chunk-SPRNLS7K.js";
10
+ } from "./chunk-JHPGOAXU.js";
11
11
  import {
12
12
  PRESETS,
13
13
  loadConfig,
14
14
  saveCredential
15
- } from "./chunk-LACUWBWS.js";
15
+ } from "./chunk-FLQPE4S5.js";
16
16
  import {
17
17
  t
18
18
  } from "./chunk-UZWJQF67.js";
@@ -5,7 +5,7 @@ import {
5
5
  readCredentials,
6
6
  readJsonConfig,
7
7
  removeCredential
8
- } from "./chunk-LACUWBWS.js";
8
+ } from "./chunk-FLQPE4S5.js";
9
9
 
10
10
  // src/providers.ts
11
11
  import { mkdirSync, writeFileSync } from "fs";