docs(i18n): proofread active Chinese documentation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write
|
||||
# pnpm run verify-translation-pairing --write docs/user/develop/basic/config.md
|
||||
config.md: 26d2d48ebede74194fbf306aa97d214bdb99b722
|
||||
config.zh.md: 9ed389b16779f25c633d0c8772f8658197ba4322
|
||||
config.zh.md: 1ca727b56b661df315026902d48fbcaf507fe08b
|
||||
@@ -75,7 +75,7 @@ Schema 在插件加载时执行校验。如果配置不合法,插件会加载
|
||||
|
||||
### 无硬编码可调参数
|
||||
|
||||
Harness 的约定:**任何两个部署可能想要不同值的东西,都应该是配置字段**。
|
||||
Harness 的约定:**凡是不同部署可能需要采用不同值的参数,都必须定义为配置字段**。
|
||||
|
||||
```ts
|
||||
// Wrong: hardcoded timeout.
|
||||
@@ -110,7 +110,7 @@ export function apply(ctx: Context, config: ModelConfig) {
|
||||
|
||||
## 配合 HMR
|
||||
|
||||
配置变更会触发插件热替换:修改 `cordis.yml` 中某个插件的 `config`,框架会卸载旧实例、加载新实例。由于注册都是效果(自动清理),这个过程是安全的。
|
||||
配置变更会触发插件热替换:修改 `cordis.yml` 中某个插件的 `config` 后,框架会卸载旧实例并加载新实例。由于注册都属于 effect 并会自动清理,替换后不会保留旧实例的注册。
|
||||
|
||||
## 下一步
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write
|
||||
# pnpm run verify-translation-pairing --write docs/user/develop/basic/index.md
|
||||
index.md: 5a9f8dfb8f2d87dfbd2ba30b4d09d002ae9b635c
|
||||
index.zh.md: 08aca87cbc02d1b0dfbe6fe2d92b3f6e87075097
|
||||
index.zh.md: 6f8926aeac5dcf667e4d311505ef7b2a321659c2
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[English](index.md) | 中文
|
||||
|
||||
本文带你编写一个最小的 Harness 插件并加载到 Agent 中。
|
||||
本文带你编写一个最小的 Harness 插件并加载到 agent(智能体)中。
|
||||
|
||||
## 插件是什么
|
||||
|
||||
@@ -18,7 +18,7 @@ export function apply(ctx: Context) {
|
||||
}
|
||||
```
|
||||
|
||||
就这么简单。
|
||||
这就是完整结构。
|
||||
|
||||
## 创建插件文件
|
||||
|
||||
@@ -48,7 +48,7 @@ export function apply(ctx: Context) {
|
||||
|
||||
## 自动清理
|
||||
|
||||
通过 `ctx` 注册的任何东西——事件监听、tool、定时器——在插件卸载时都会被自动清理。你不需要手动 removeListener 或 clearInterval。
|
||||
通过 `ctx` 注册的任何东西——事件监听、工具、定时器——在插件卸载时都会被自动清理。你不需要手动 removeListener 或 clearInterval。
|
||||
|
||||
如果你有需要手动清理的资源(比如一个网络连接),用 `ctx.effect()` 告诉框架怎么清理:
|
||||
|
||||
@@ -118,11 +118,11 @@ export default class MyService extends Service {
|
||||
}
|
||||
```
|
||||
|
||||
大多数情况下,函数形式足够了。类形式用于需要对外提供服务的插件(见 [服务与依赖](../framework/service.md))。
|
||||
大多数情况下,函数形式足够了。当插件需要向其他插件提供服务时,可使用类形式(见 [服务与依赖](../framework/service.md))。
|
||||
|
||||
## 完整示例
|
||||
|
||||
最小化的工具插件会在 `ctx.tools` 上注册其定义:
|
||||
最小的工具插件会在 `ctx.tools` 上注册其定义:
|
||||
|
||||
```ts
|
||||
import type { Context } from 'cordis'
|
||||
@@ -151,5 +151,5 @@ export function apply(ctx: Context) {
|
||||
|
||||
## 下一步
|
||||
|
||||
- [开发一个 Tool](./tool.md) — 详细了解 tool 定义 DSL
|
||||
- [开发一个工具](./tool.md) — 详细了解工具定义 DSL
|
||||
- [插件配置](./config.md) — 让插件接受用户配置
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write
|
||||
# pnpm run verify-translation-pairing --write docs/user/develop/basic/tool.md
|
||||
tool.md: 0d7cbc3f0b86f88fb67aeff6aa61181dff2912ee
|
||||
tool.zh.md: 30cc871d7b417bdf7f33025b22e3f0965e2b8805
|
||||
tool.zh.md: 37362c510a07fcc32e9eee2b578d82907788e471
|
||||
@@ -1,8 +1,8 @@
|
||||
# 开发一个 Tool
|
||||
# 开发一个工具
|
||||
|
||||
[English](tool.md) | 中文
|
||||
|
||||
Tool 是模型可以调用的能力。本文介绍如何用 `defineTool` 编写一个 tool。
|
||||
工具是模型可以调用的能力。本文介绍如何用 `defineTool` 编写一个工具。
|
||||
|
||||
## 最小示例
|
||||
|
||||
@@ -156,9 +156,9 @@ async execute(args) {
|
||||
|
||||
你不需要在 `execute` 里手动校验参数类型。
|
||||
|
||||
## 展示层 (Presentation)
|
||||
## 展示层(Presentation)
|
||||
|
||||
Tool 可以定义与传输方式无关的展示方法,供终端和 Web 客户端使用:
|
||||
工具可以定义与传输方式无关的展示方法,供终端和 Web 客户端使用:
|
||||
|
||||
```ts ignore-check
|
||||
defineTool({
|
||||
@@ -187,7 +187,7 @@ defineTool({
|
||||
|
||||
## 注册与卸载
|
||||
|
||||
`ctx.tools.register()` 返回值就是 disposer。但由于你在 `ctx` 上调用,框架已经自动追踪了这个注册——插件卸载时会自动移除 tool。你不需要手动调用 disposer。
|
||||
`ctx.tools.register()` 返回值就是 disposer。但由于你在 `ctx` 上调用,框架已经自动追踪了这个注册——插件卸载时会自动移除工具。你不需要手动调用 disposer。
|
||||
|
||||
```ts ignore-check
|
||||
// This is sufficient:
|
||||
@@ -196,9 +196,9 @@ ctx.tools.register(defineTool({ /* ... */ }))
|
||||
// No saved disposer or extra cleanup registration is needed.
|
||||
```
|
||||
|
||||
## 完整实战示例
|
||||
## 完整示例
|
||||
|
||||
一个文件计数 tool:
|
||||
一个文件计数工具:
|
||||
|
||||
```ts
|
||||
import type { Context } from 'cordis'
|
||||
@@ -241,5 +241,5 @@ export function apply(ctx: Context) {
|
||||
|
||||
## 下一步
|
||||
|
||||
- [插件配置](./config.md) — 让你的 tool 可配置
|
||||
- [能力三件套](../practice/) — 了解 seam/impl/consumer 模式
|
||||
- [插件配置](./config.md) — 让你的工具可配置
|
||||
- [能力分层](../practice/) — 了解接口/实现/消费方模式
|
||||
Reference in New Issue
Block a user