@twinklerg/coden 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,19 @@
4
4
 
5
5
  CodeN(Code NJU)是一个用 TypeScript 独立实现的极简编程智能体。它直接使用模型原生 Tool Calling,在本地读取、修改文件和执行命令;不依赖 Agent 框架或服务端代码执行。
6
6
 
7
- ## 要求与安装
7
+ ## 安装与使用
8
+
9
+ ### 从 npm 安装(发布后的 CLI)
10
+
11
+ ```bash
12
+ bun add -g @twinklerg/coden # 或 npm install -g @twinklerg/coden
13
+ coden --version # 0.1.2
14
+ coden --help
15
+ ```
16
+
17
+ 发布产物是构建后的单文件 Node CLI(`dist/index.js`,已 minify),运行时只需 Node,不需要 Bun。
18
+
19
+ ### 从源码运行(开发)
8
20
 
9
21
  - [Bun](https://bun.sh/) 1.1+
10
22
  - [Just](https://github.com/casey/just)
@@ -16,22 +28,23 @@ just check
16
28
 
17
29
  源码仅使用标准 Web/Node.js API;Bun 负责依赖、脚本和 TypeScript 插件运行。
18
30
 
19
- ## 使用
31
+ ### 使用示例
20
32
 
21
33
  ```bash
22
34
  export CODEN_OPENAI_API_KEY=...
23
- bun run src/cli/index.ts "修复当前项目的测试失败"
24
- bun run src/cli/index.ts -p --auto "实现功能并运行测试"
35
+ coden "修复当前项目的测试失败"
36
+ coden -p --auto "实现功能并运行测试"
25
37
 
26
38
  export CODEN_ANTHROPIC_API_KEY=...
27
- bun run src/cli/index.ts --provider anthropic --model claude-sonnet-4-20250514
39
+ coden --provider anthropic --model claude-sonnet-4-20250514
28
40
 
29
- bun run src/cli/index.ts --resume <session-id>
41
+ coden --resume <session-id> # 恢复指定会话
42
+ coden --resume # 列出当前工作区的会话
30
43
  ```
31
44
 
32
- 也可执行 `just run -- --help`。无 prompt 时进入 REPL,支持 `/help`、`/session`、`/compact`、`/reload`、`/new` 和 `/quit`。
45
+ prompt 时进入 REPL,支持 `/help`、`/session`、`/sessions`、`/compact`、`/reload`、`/new` 和 `/quit`。启动横幅会显示当前版本与 16 位 workspace hash。
33
46
 
34
- 核心选项:`--provider`、`--model`、`--resume`、`--auto`、`--verbose`、`--max-steps` 和可重复的 `--plugin`。
47
+ 核心选项:`--provider`、`--model`、`-p/--print`、`--resume [session-id]`、`--auto`、`--verbose`、`--max-steps`、可重复的 `--plugin` `--version`。
35
48
 
36
49
  ## 配置
37
50
 
@@ -152,7 +165,7 @@ coden plugin remove @scope/coden-plugin-example
152
165
  单工具默认导出一个兼容 `ToolDefinition` 的对象:
153
166
 
154
167
  ```ts
155
- import type { ToolDefinition } from "coden/plugin";
168
+ import type { ToolDefinition } from "@twinklerg/coden/plugin";
156
169
 
157
170
  const tool: ToolDefinition = {
158
171
  name: "example_echo",
@@ -176,7 +189,7 @@ export default tool;
176
189
  多工具默认导出 `CodeNPlugin`,其中 `name` 必须等于 npm 包名:
177
190
 
178
191
  ```ts
179
- import type { CodeNPlugin, ToolDefinition } from "coden/plugin";
192
+ import type { CodeNPlugin, ToolDefinition } from "@twinklerg/coden/plugin";
180
193
 
181
194
  const readTool: ToolDefinition = {
182
195
  name: "example_read",
@@ -207,14 +220,19 @@ const plugin: CodeNPlugin = {
207
220
  export default plugin;
208
221
  ```
209
222
 
210
- 插件可以把 `coden` 放入 `devDependencies` 以获得 `coden/plugin` 类型;构建产物中的类型导入会被移除,运行时不应加载另一份 CodeN。
223
+ `@twinklerg/coden/plugin` 是 CodeN 提供给插件作者的公共契约子路径。插件把 `@twinklerg/coden` 放入 `devDependencies` 以在构建时获得类型;`import type` 会在构建时被移除,运行时不加载另一份 CodeN。`ToolContext.signal` 使用 `AbortSignal`,请确保 tsconfig 提供一个定义它的 lib(如 `@types/node` DOM)。
224
+
225
+ 插件契约以 `src/plugin/index.ts` 为唯一来源;构建时自动生成 `dist/plugin/index.d.ts` 和仅包含公开常量的最小 JavaScript 入口,不发布 `src`。CodeN 的 npm 包只暴露 `/plugin` 这一条子路径,主入口 `"."` 未公开,`import "@twinklerg/coden"` 会被拒绝——它定位为 CLI,不作为程序化导入库。
211
226
 
212
227
  ## 开发与测试
213
228
 
214
229
  ```bash
215
- just fmt # Biome format
216
- just test # offline Vitest
217
- just check # Biome lint + strict tsc + complete offline tests
230
+ just fmt # Biome format
231
+ just test # offline Vitest
232
+ just check # Biome lint + strict tsc + complete offline tests
233
+ just build # build the CLI and generate the public plugin contract in dist/
234
+ just publish-dry-run # verify exactly what npm would publish (no upload)
235
+ just publish # lint + typecheck + test, then publish to npm (--access public)
218
236
  ```
219
237
 
220
238
  离线集成测试用 `ScriptedProvider` 覆盖工具循环、拒绝、重试和恢复。真实 API 冒烟测试(`test/live.test.ts`)默认跳过,仅在显式设置后运行: