@best-agent/cli 0.0.2-beta.8 → 0.0.3-beta.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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -181
  3. package/dist/launcher.js +32 -0
  4. package/package.json +15 -27
  5. package/dist/best-agent-native-bridge.d.ts +0 -389
  6. package/dist/best-agent-native-bridge.js +0 -4645
  7. package/dist/cli-storage.d.ts +0 -5
  8. package/dist/cli-storage.js +0 -7
  9. package/dist/dimsdk/ask-user.d.ts +0 -21
  10. package/dist/dimsdk/ask-user.js +0 -131
  11. package/dist/dimsdk/cli/version.d.ts +0 -6
  12. package/dist/dimsdk/cli/version.js +0 -36
  13. package/dist/dimsdk/compat/archships/dim-agent/runtime-host.d.ts +0 -49
  14. package/dist/dimsdk/compat/archships/dim-agent/runtime-host.js +0 -215
  15. package/dist/dimsdk/compat/runtime-host.d.ts +0 -2
  16. package/dist/dimsdk/compat/runtime-host.js +0 -2
  17. package/dist/dimsdk/core/debug-log.d.ts +0 -8
  18. package/dist/dimsdk/core/debug-log.js +0 -100
  19. package/dist/dimsdk/core/env.d.ts +0 -26
  20. package/dist/dimsdk/core/env.js +0 -130
  21. package/dist/dimsdk/core/markdown/sanitize.d.ts +0 -2
  22. package/dist/dimsdk/core/markdown/sanitize.js +0 -43
  23. package/dist/dimsdk/core/markdown/wrap.d.ts +0 -9
  24. package/dist/dimsdk/core/markdown/wrap.js +0 -139
  25. package/dist/dimsdk/core/markdown.d.ts +0 -18
  26. package/dist/dimsdk/core/markdown.js +0 -62
  27. package/dist/dimsdk/core/model.d.ts +0 -273
  28. package/dist/dimsdk/core/model.js +0 -16
  29. package/dist/dimsdk/core/observability/perf-log.d.ts +0 -18
  30. package/dist/dimsdk/core/observability/perf-log.js +0 -236
  31. package/dist/dimsdk/core/store/agent-event-mappers.d.ts +0 -26
  32. package/dist/dimsdk/core/store/agent-event-mappers.js +0 -109
  33. package/dist/dimsdk/core/store/message-mutations.d.ts +0 -105
  34. package/dist/dimsdk/core/store/message-mutations.js +0 -1528
  35. package/dist/dimsdk/core/store/semantic-readers.d.ts +0 -2
  36. package/dist/dimsdk/core/store/semantic-readers.js +0 -4
  37. package/dist/dimsdk/core/store/transcript-projector.d.ts +0 -164
  38. package/dist/dimsdk/core/store/transcript-projector.js +0 -580
  39. package/dist/dimsdk/core/tool-metadata.d.ts +0 -12
  40. package/dist/dimsdk/core/tool-metadata.js +0 -70
  41. package/dist/dimsdk/core/transcript-part-id.d.ts +0 -6
  42. package/dist/dimsdk/core/transcript-part-id.js +0 -22
  43. package/dist/dimsdk/i18n/index.d.ts +0 -18
  44. package/dist/dimsdk/i18n/index.js +0 -141
  45. package/dist/dimsdk/i18n/locales/en.d.ts +0 -988
  46. package/dist/dimsdk/i18n/locales/en.js +0 -987
  47. package/dist/dimsdk/i18n/locales/index.d.ts +0 -1976
  48. package/dist/dimsdk/i18n/locales/index.js +0 -8
  49. package/dist/dimsdk/i18n/locales/zh-CN.d.ts +0 -988
  50. package/dist/dimsdk/i18n/locales/zh-CN.js +0 -987
  51. package/dist/dimsdk/i18n/types.d.ts +0 -13
  52. package/dist/dimsdk/i18n/types.js +0 -2
  53. package/dist/dimsdk/shared/value-normalizers.d.ts +0 -7
  54. package/dist/dimsdk/shared/value-normalizers.js +0 -48
  55. package/dist/dimsdk-tui.bundle-size.json +0 -169
  56. package/dist/dimsdk-tui.bundle.js +0 -330756
  57. package/dist/goatchain-adapter.d.ts +0 -41
  58. package/dist/goatchain-adapter.js +0 -499
  59. package/dist/index.d.ts +0 -3
  60. package/dist/index.js +0 -1405
  61. package/dist/native-runtime-bridge.d.ts +0 -387
  62. package/dist/native-runtime-bridge.js +0 -4624
  63. package/dist/provider-config-env.d.ts +0 -7
  64. package/dist/provider-config-env.js +0 -286
  65. package/dist/provider-model-limit-index.generated.d.ts +0 -3
  66. package/dist/provider-model-limit-index.generated.js +0 -7818
  67. package/dist/provider-model-limits.d.ts +0 -8
  68. package/dist/provider-model-limits.js +0 -43
  69. package/dist/runtime.d.ts +0 -47
  70. package/dist/runtime.js +0 -516
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Simon He
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,198 +1,61 @@
1
1
  # @best-agent/cli
2
2
 
3
- Terminal entrypoint for `best-agent`.
3
+ v3 的本地 Application composition 与终端入口。
4
4
 
5
- ## Commands
5
+ ## 安装与发布
6
6
 
7
- - `best-agent server`
8
- - `best-agent serve`
9
- - `best-agent daemon`
10
- - `best-agent acp`
11
- - `best-agent run`
12
- - `best-agent chat`
7
+ - `npm install -g @best-agent/cli@beta`:根包按 `os`/`cpu`/`libc` 安装一个 SEA 平台包;
8
+ - `pnpm pack:tui`:构建、打包并安装 smoke-test 当前平台的根包和平台包;
9
+ - `pnpm release:cli --artifact-root .tmp/sea --tag beta --dry-run`:验证六个平台产物;去掉 `--dry-run` 后依次发布六个平台包和根包。
13
10
 
14
- ## Features
11
+ 发布包不含普通 CLI JavaScript、声明文件或 source map。根包只含平台选择 launcher;Harness、CLI 和 TUI 位于 minified/mangled Node SEA code cache 中。
15
12
 
16
- - loads `.env` from `--cwd` or the current working directory
17
- - starts `app-server` or `acp-server`
18
- - starts a REST + SSE server over the shared runtime
19
- - starts a long-lived local daemon over a native socket or named pipe
20
- - runs direct one-shot prompts through the daemon-backed app-server path with foreground approval prompts; `run` and non-TTY `chat` daemons exit after 10 seconds idle unless `BEST_AGENT_DAEMON_IDLE_EXIT_MS` is set
21
- - runs TTY chat through the goatagent `DimSdk` TUI backed by the `best-agent` runtime
22
- - runs the non-TTY interactive chat loop through `sdk-ts -> daemon client -> local daemon -> runtime`
23
- - exposes project-memory, plan mode, diagnostics, compaction, research, fork/resume, and thread lifecycle commands
13
+ ## 当前命令
24
14
 
25
- ## Key Flags
15
+ - `best-agent run ... <prompt>`:创建一个 frozen Plan、一个 Session 和一个 Run;
16
+ - `best-agent chat ...`:创建一个 frozen Plan 和一个 Session,普通输入开始新 Run,`/stop` 请求停止当前
17
+ Run,`/quit` 关闭本地 Application 资源;terminal assistant text 中的 `[[approval:<prompt>]]` 仅创建
18
+ Application 等待态,`/approve yes|no` 会提交同 Session 的**新 Run**。
19
+ - `best-agent subagent ... <task>`:使用 Application-owned coordinator 启动独立 child Agent/Session/Run;`--json` 输出 terminal snapshot 摘要。
20
+ - `best-agent workflow --workflow <steps.json> ...`:按 `{"steps":[{"prompt":"... {{previous}}"}]}` 顺序运行,每步均是前一步 terminal 后的新 Run。
26
21
 
27
- - `--cwd <path>`
28
- - `--storage-root <path>`
29
- - `--extensions-root <path>`
30
- - `--agent <name>`
31
- - `--plan`
32
- - `--resume <threadId>`
33
- - `--latest`
34
- - `--provider <openai|anthropic|google>`
35
- - `--model <id>`
36
- - `--base-url <url>`
37
- - `--compatibility <auto|native|compatible>`
38
- - `--approval-timeout-ms <ms>`
39
- - `--guardian-enabled <true|false>`
40
- - `--guardian-model <id>`
41
- - `--guardian-threshold <0-100>`
42
- - `--guardian-timeout-ms <ms>`
22
+ `server`、`daemon`、`serve`、`acp` 尚未完成 v3 product composition,会明确失败;CLI 不调用旧
23
+ Server、SDK、Engine 或 native bridge。
43
24
 
44
- ## Examples
25
+ ## Composition 输入
45
26
 
46
- Start the server:
47
-
48
- ```bash
49
- best-agent server --cwd /path/to/repo
50
- ```
51
-
52
- Start the local daemon:
53
-
54
- ```bash
55
- best-agent daemon --cwd /path/to/repo
56
- ```
57
-
58
- Start the HTTP+SSE server:
59
-
60
- ```bash
61
- best-agent serve --host 127.0.0.1 --port 3000 --cwd /path/to/repo
62
- ```
63
-
64
- HTTP auth:
65
-
66
- - loopback hosts (`127.0.0.1`, `::1`, `localhost`) keep the existing no-auth default
67
- - non-loopback hosts require `BEST_AGENT_HTTP_TOKEN`
68
- - when `BEST_AGENT_HTTP_TOKEN` is set, JSON routes require `Authorization: Bearer <token>`
69
- - SSE also accepts `?access_token=<token>`
70
-
71
- Run a single prompt:
72
-
73
- ```bash
74
- best-agent run --agent verify 'tool:read-file {"path":"package.json"}'
75
- ```
76
-
77
- Start chat with a provider:
78
-
79
- ```bash
80
- OPENAI_API_KEY=your_key \
81
- OPENAI_MODEL=gpt-5-mini \
82
- best-agent chat --cwd /path/to/repo
83
- ```
84
-
85
- Start the migrated local CLI from the repo root:
86
-
87
- ```bash
88
- pnpm chat -- --cwd /path/to/repo
89
- ```
90
-
91
- Start a planning session:
92
-
93
- ```bash
94
- best-agent chat --plan
95
- ```
96
-
97
- Run the TTY smoke check:
98
-
99
- ```bash
100
- pnpm smoke:cli-tui
27
+ ```text
28
+ --provider <openai|anthropic|google>
29
+ --model <id>
30
+ --base-url <http(s)-url>
31
+ --compatibility <native|compatible>
32
+ --system-prompt <text>
33
+ --instruction-file <absolute-path> # 可重复,顺序显式
34
+ --skill coding
35
+ --workspace <absolute-path>
36
+ --memory-dir <absolute-path> # Application-owned bounded JSON memory store
37
+ --compact-dir <absolute-path> # Rolling compact 与两槽 Session epoch artifact
38
+ --compact-debug-dir <absolute-path> # Metadata-only compact rotation evidence (no raw transcript)
39
+ --workspace-grant <read|write|exec> # 可重复
40
+ --exec-alias <alias>=<absolute-executable> # 可重复
101
41
  ```
102
42
 
103
- ## Web Search Configuration
104
-
105
- `web-search` is exposed by capability, not just by the presence of one vendor key.
106
-
107
- - if the active provider supports native web search, no external search key is required
108
- - if the active provider does not support native web search, the CLI can build an external search adapter from the persisted DimSdk tool settings
109
- - if neither capability exists, the runtime hides `web-search` from model-visible tools for that turn
110
-
111
- The CLI persists external search settings in:
112
-
113
- - `DIMCODE_HOME/tools.json` when `DIMCODE_HOME` is set
114
- - otherwise `~/.dimcode/tools.json`
115
-
116
- Relevant fields:
117
-
118
- ```json
119
- {
120
- "version": 1,
121
- "updatedAt": 0,
122
- "settings": {
123
- "websearch": {
124
- "apiKey": "serper-key",
125
- "apiEndpoint": "https://google.serper.dev/search?format=json",
126
- "numResults": 10
127
- }
128
- }
129
- }
130
- ```
131
-
132
- You can provide the key in either of these ways:
133
-
134
- - before starting chat, by writing the `tools.json` values above
135
- - during an existing chat, by updating the same search settings through the DimSdk settings flow
136
-
137
- Dynamic updates apply on the next turn:
138
-
139
- - if the conversation is already open and the user adds the missing search key, the next user message re-evaluates capability
140
- - a new thread is not required just to pick up the new key
141
- - endpoint and result-count changes follow the same next-turn behavior in the current CLI implementation
142
-
143
- For the deeper runtime contract, see `/Users/Simon/Github/best-agent/docs/architecture/web-search-capability-and-configuration.md`.
144
-
145
- ## Chat Commands
146
-
147
- - `/threads`, `/resume`, `/new`
148
- - `/archive`, `/unarchive`, `/delete`
149
- - `/memory show|set|add|edit|clear`
150
- - `/agent`, `/agents`
151
- - `/plan on|off|status|show|todos|approve|reject|export`
152
- - `/tools`, `/skills`, `/use-skill`, `/drop-skill`
153
- - `/diagnostics`, `/compact`
154
- - `/research`, `/evidence`, `/handoff`
155
- - `/fork`, `/forks`
156
-
157
- `/memory show` displays both user-authored manual memory and auto-extracted workspace memory. `/memory edit`, `/memory set`, and `/memory add` edit manual memory only. `/memory clear` clears both manual and auto memory.
158
-
159
- ## Does Not Own
160
-
161
- - protocol definitions
162
- - runtime policy
163
- - tool implementations
164
-
165
- The CLI stays intentionally thin. Runtime behavior belongs in `packages/engine`.
166
-
167
- ## Migration Notes
168
-
169
- - `best-agent run` now goes through `sdk-ts -> daemon client -> local daemon -> runtime` and no longer creates an in-process runtime for one-shot execution.
170
- - `best-agent serve` now exposes the same runtime through a thin HTTP+SSE surface for local integrations and e2e coverage.
171
- - `best-agent chat` now loads a bundled `DimSdk` runtime from `dist/dimsdk-tui.bundle.js`.
172
- - The bundle resolves `@simon_he/vue-tui` from the installed package in `node_modules`, so `best-agent chat` keeps the real goatagent shell and swaps only the runtime/backend bridge.
173
- - Provider/model changes now sync back into the `best-agent` runtime and persist through `cli-state.json`.
174
- - Session rename and `metadata.ui` persistence now round-trip through runtime/server/sdk/CLI bridge and survive restart.
175
- - Existing non-TTY CLI e2e remains the baseline acceptance path, `apps/cli/test/native-stream-runner.test.ts` covers the runtime bridge, the DimSdk tests live in `apps/cli/test`, and `pnpm smoke:cli-tui` is the manual TTY acceptance path.
176
-
177
- ## Known Gaps
178
-
179
- - The bundled TUI still depends on external package compatibility, but [package.json](/Users/Simon/Github/best-agent/package.json) no longer hardcodes a machine-specific `link:` path for `@simon_he/vue-tui`.
180
- - We now cover provider persistence, session metadata hydration, and session list view-model compatibility in `apps/cli/test`, but we have not yet ported the heaviest full-terminal DimSdk interaction tests such as transcript rendering order, tool call expansion/collapse, and approval overlays.
181
-
182
- ## Follow-up Plan
183
-
184
- ### 1. Keep External TUI Dependency Pinned
43
+ 开启 `--compact-debug-dir` 后,每次 manual/预算触发的 Session rotation 会写一个不含原文的 bounded JSON 记录,包含 source/epoch ref、SHA-256、
44
+ 字节数、group 选择/省略 ordinal、budget 与 cache usage。按记录中的 ref 可在 `<compact-dir>/compact/`(未指定时为 storage root 下的
45
+ `compact/compact/`)检查 rolling source 与 frozen epoch artifact;该模式不会额外复制原始 terminal Transcript。
185
46
 
186
- - Keep `@simon_he/vue-tui` pinned to the exact published version used by the bundle.
187
- - If the package API changes, update the bundle and test suite together instead of relinking a sibling repo path.
47
+ argv、environment、文件和 backend 配置在 C0 只是 candidate;CLI 在 C1 验证并构造 private
48
+ provider/sandbox,在 C2 显式选择 contributions 与 policy,Composer 在 C3 freeze Plan,CLI 在 C4
49
+ 创建 immutable Session admission。运行后只有 AgentKernel 可以写 Harness-local facts。
188
50
 
189
- Acceptance:
190
- - `pnpm build` and `pnpm chat -- --cwd ...` work on a clean machine without a sibling `goatagent` checkout.
51
+ Workspace grant 只能来自显式 CLI composition。Skill、prompt、Tool input、model output 和 sandbox 都不能
52
+ 增加 grant;sandbox 只可进一步收窄 Kernel 已授权的 exact Tool call。
191
53
 
192
- ### 2. Port Heavier DimSdk Terminal Tests
54
+ ## 不拥有
193
55
 
194
- - Continue with bridge-compatible tests that exercise transcript ordering, tool call rendering, and approval overlays.
195
- - Prefer real shell tests when they are stable; otherwise keep the current compatibility-layer tests that directly target DimSdk persistence and view-model logic.
56
+ - Kernel transition、Runtime facts 或 current-Run next-action authority;
57
+ - Provider、Tool 或 sandbox 返回值的外部事实;
58
+ - retry、resume、suspended Run、recovery 或 compact lifecycle;
59
+ - Server、SDK、Channel 或外部资源恢复。
196
60
 
197
- Acceptance:
198
- - The acceptance baseline remains: `pnpm test` and `pnpm smoke:cli-tui` both green.
61
+ 最终状态只来自 direct `ApplicationHost.snapshot`;event 仅用于 bounded preview/early read。
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { createRequire } from "node:module";
4
+
5
+ const targets = [{"id":"darwin-arm64","platform":"darwin","arch":"arm64","binary":"best-agent","packageName":"@best-agent/cli-darwin-arm64"},{"id":"darwin-x64","platform":"darwin","arch":"x64","binary":"best-agent","packageName":"@best-agent/cli-darwin-x64"},{"id":"linux-arm64-gnu","platform":"linux","arch":"arm64","libc":"glibc","binary":"best-agent","packageName":"@best-agent/cli-linux-arm64-gnu"},{"id":"linux-x64-gnu","platform":"linux","arch":"x64","libc":"glibc","binary":"best-agent","packageName":"@best-agent/cli-linux-x64-gnu"},{"id":"win32-arm64","platform":"win32","arch":"arm64","binary":"best-agent.exe","packageName":"@best-agent/cli-win32-arm64"},{"id":"win32-x64","platform":"win32","arch":"x64","binary":"best-agent.exe","packageName":"@best-agent/cli-win32-x64"}];
6
+ const target = targets.find((candidate) => candidate.platform === process.platform && candidate.arch === process.arch);
7
+ if (!target || (target.libc === "glibc" && !process.report?.getReport().header.glibcVersionRuntime)) {
8
+ process.stderr.write(`best-agent: unsupported platform ${process.platform}-${process.arch}.\n`);
9
+ process.exit(1);
10
+ }
11
+
12
+ let executable;
13
+ try {
14
+ executable = createRequire(import.meta.url).resolve(`${target.packageName}/bin/${target.binary}`);
15
+ } catch {
16
+ process.stderr.write(`best-agent: missing optional platform package ${target.packageName}; reinstall @best-agent/cli.\n`);
17
+ process.exit(1);
18
+ }
19
+
20
+ const result = spawnSync(executable, process.argv.slice(2), {
21
+ env: process.env,
22
+ stdio: "inherit",
23
+ windowsHide: false,
24
+ });
25
+ if (result.error) {
26
+ process.stderr.write(`best-agent: ${result.error.message}\n`);
27
+ process.exit(1);
28
+ }
29
+ if (result.signal) {
30
+ process.kill(process.pid, result.signal);
31
+ }
32
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,37 +1,25 @@
1
1
  {
2
2
  "name": "@best-agent/cli",
3
- "version": "0.0.2-beta.8",
3
+ "version": "0.0.3-beta.1",
4
+ "description": "best-agent v3 CLI and TUI",
5
+ "type": "module",
4
6
  "bin": {
5
- "best-agent": "./dist/index.js"
7
+ "best-agent": "./dist/launcher.js"
6
8
  },
7
9
  "files": [
10
+ "dist/launcher.js",
8
11
  "README.md",
9
- "dist/**/*.d.ts",
10
- "dist/**/*.js",
11
- "dist/dimsdk-tui.bundle-size.json",
12
- "!dist/**/*.map",
13
- "!dist/**/*.tsbuildinfo",
14
- "!dist/dimsdk-tui.bundle.metafile.json"
12
+ "LICENSE"
15
13
  ],
16
- "type": "module",
17
- "imports": {
18
- "#cli/*": "./src/dimsdk/*"
19
- },
20
- "publishConfig": {
21
- "access": "public"
22
- },
23
- "dependencies": {
24
- "dotenv": "^17.4.2",
25
- "node-notifier": "^10.0.1",
26
- "@best-agent/engine": "0.0.2-beta.8",
27
- "@best-agent/foundation": "0.0.2-beta.8",
28
- "@best-agent/extensions": "0.0.2-beta.8",
29
- "@best-agent/protocol": "0.0.2-beta.8",
30
- "@best-agent/sdk-ts": "0.0.2-beta.8",
31
- "@best-agent/server": "0.0.2-beta.8"
14
+ "engines": {
15
+ "node": ">=24.15.0"
32
16
  },
33
- "scripts": {
34
- "dev:server": "node ./dist/index.js server",
35
- "release": "pnpm -w build && bumpp -r --no-commit --no-tag --no-push --no-verify && pnpm publish --access public --no-git-checks"
17
+ "optionalDependencies": {
18
+ "@best-agent/cli-darwin-arm64": "0.0.3-beta.1",
19
+ "@best-agent/cli-darwin-x64": "0.0.3-beta.1",
20
+ "@best-agent/cli-linux-arm64-gnu": "0.0.3-beta.1",
21
+ "@best-agent/cli-linux-x64-gnu": "0.0.3-beta.1",
22
+ "@best-agent/cli-win32-arm64": "0.0.3-beta.1",
23
+ "@best-agent/cli-win32-x64": "0.0.3-beta.1"
36
24
  }
37
25
  }