Skip to content

Commit 756b616

Browse files
committed
✨ docs: update all docs to match nexa v1.1-v1.3.x source code
- index.md/en: remove python comparison boxes, add v1.1-v1.3.x feature overview - cli_reference.md/en: rewrite with actual CLI commands from src/cli.py - stdlib_reference.md/en: add 15 new namespaces (db/auth/kv/concurrent/template/pipe/defer/null_coalesce/string/match/struct/enum/trait) - reference.md/en: add all new syntax constructs (requires/ensures/invariant/type/job/server/db/auth/kv/struct/enum/trait/impl/pipe/defer/match/?/otherwise/??/#{}) - error_index.md/en: replace fictional error codes with actual types from source (ContractViolation/TypeViolation/TypeWarning/DatabaseError/AuthError/KVError/ConcurrencyError/TemplateError/PatternMatchError/ADTError/JobError/HTTPError) - part1_basic.md/en: add new declaration keywords section, update property table - part2_advanced.md/en: add |> pipe, ?? null coalesce, defer, pattern matching, ADT sections - part3_extensions.md/en: add DbC, gradual type system, error propagation sections - part4_ecosystem_and_stdlib.md/en: add 15 new namespace sections - part5_enterprise.md/en: complete rewrite with HTTP Server, Database, Auth, KV, Concurrency, Template, Jobs - quickstart.md/en: update version to v1.3.x, add CLI commands section - troubleshooting.md/en: add 6 new troubleshooting sections (Contract/Type, Database, Auth, Concurrency, HTTP Server, Job), expand error code table - examples.md/en: add 6 new examples (DbC, error propagation, pattern matching+ADT, HTTP+DB, concurrency, jobs)
1 parent 7c4e57a commit 756b616

26 files changed

Lines changed: 9622 additions & 4757 deletions

docs/cli_reference.en.md

Lines changed: 268 additions & 523 deletions
Large diffs are not rendered by default.

docs/cli_reference.md

Lines changed: 263 additions & 518 deletions
Large diffs are not rendered by default.

docs/error_index.en.md

Lines changed: 375 additions & 542 deletions
Large diffs are not rendered by default.

docs/error_index.md

Lines changed: 374 additions & 541 deletions
Large diffs are not rendered by default.

docs/examples.en.md

Lines changed: 462 additions & 0 deletions
Large diffs are not rendered by default.

docs/examples.md

Lines changed: 462 additions & 0 deletions
Large diffs are not rendered by default.

docs/index.en.md

Lines changed: 157 additions & 343 deletions
Large diffs are not rendered by default.

docs/index.md

Lines changed: 154 additions & 340 deletions
Large diffs are not rendered by default.

docs/part1_basic.en.md

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ agent FriendlyBot {
2929

3030
### Property Overview Table
3131

32-
| Property | Type | Required | Default | Description |
33-
|-----|------|-----|-------|------|
34-
| `role` | string | No | - | Agent's role description, as part of the system prompt |
35-
| `prompt` | string | **Yes** | - | Agent's core task instruction |
36-
| `model` | string | No | Default model | Specifies the LLM model to use |
37-
| `memory` | string | No | - | Memory mode: `persistent`, etc. |
38-
| `stream` | boolean | No | false | Whether to enable streaming output |
39-
| `cache` | boolean | No | false | Whether to enable intelligent caching |
40-
| `experience` | string | No | - | Long-term memory file path |
41-
| `fallback` | string/list | No | - | Backup model configuration |
42-
| `tools` | list | No | [] | Available tools list |
43-
| `max_tokens` | int | No | - | Maximum output token count |
44-
| `timeout` | int | No | 30 | Execution timeout (seconds) |
45-
| `retry` | int | No | 3 | Number of retry attempts on failure |
32+
| Property | Type | Required | Default | Version | Description |
33+
|-----|------|-----|-------|---------|------|
34+
| `role` | string | No | - | v0.5+ | Agent's role description, as part of the system prompt |
35+
| `prompt` | string | **Yes** | - | v0.5+ | Agent's core task instruction |
36+
| `model` | string | No | Default model | v0.5+ | Specifies the LLM model to use |
37+
| `memory` | string | No | - | v0.5+ | Memory mode: `persistent`, etc. |
38+
| `stream` | boolean | No | false | v0.5+ | Whether to enable streaming output |
39+
| `cache` | boolean | No | false | v0.5+ | Whether to enable intelligent caching |
40+
| `experience` | string | No | - | v0.5+ | Long-term memory file path |
41+
| `fallback` | string/list | No | - | v0.5+ | Backup model configuration |
42+
| `tools` | list | No | [] | v0.5+ | Available tools list |
43+
| `max_tokens` | int | No | - | v0.5+ | Maximum output token count |
44+
| `timeout` | int | No | 30 | v0.5+ | Execution timeout (seconds) |
45+
| `retry` | int | No | 3 | v0.5+ | Number of retry attempts on failure |
46+
| `requires` | clause | No | - | v1.2+ | Precondition contract clause |
47+
| `ensures` | clause | No | - | v1.2+ | Postcondition contract clause |
4648

4749
### Property Detailed Explanation
4850

@@ -772,16 +774,56 @@ agent Bot {
772774

773775
---
774776

777+
## 🆕 v1.3.x New Declaration Keywords Quick Reference
778+
779+
Nexa v1.3.x introduces multiple new declaration keywords that extend the language's expressiveness and enterprise capabilities. Here's a quick overview; for detailed usage, refer to the corresponding chapters.
780+
781+
### Data Modeling Keywords
782+
783+
| Keyword | Version | Description | Example |
784+
|---------|---------|-------------|---------|
785+
| `struct` | v1.3.x | Define struct | `struct Point { x: Int, y: Int }` |
786+
| `enum` | v1.3.x | Define enum | `enum Option[T] { Some(T), None }` |
787+
| `trait` | v1.3.x | Define trait | `trait Printable { fn format() -> String }` |
788+
| `impl` | v1.3.x | Implement trait | `impl Printable for Point { ... }` |
789+
| `type` | v1.0.2+ | Define semantic type | `type Email = string @ "valid email"` |
790+
791+
### Enterprise Declaration Keywords
792+
793+
| Keyword | Version | Description | Example |
794+
|---------|---------|-------------|---------|
795+
| `job` | v1.3.3 | Define background job | `job SendEmail { handler: ..., retry: 3 }` |
796+
| `server` | v1.3.4 | Define HTTP server | `server MyApp { route GET "/hello" { ... } }` |
797+
| `db` | v1.3.5 | Define database | `db main_db { type: sqlite, path: "data.db" }` |
798+
| `auth` | v1.3.6 | Define authentication | `auth my_auth { providers: ["google"] }` |
799+
| `kv` | v1.3.7 | Define KV store | `kv my_cache { path: ":memory:" }` |
800+
801+
### Contract Keywords
802+
803+
| Keyword | Version | Description | Example |
804+
|---------|---------|-------------|---------|
805+
| `requires` | v1.2.0 | Precondition | `requires: amount > 0` |
806+
| `ensures` | v1.2.0 | Postcondition | `ensures: result.success == true` |
807+
| `invariant` | v1.2.0 | Invariant | `invariant: state in ["idle", "running"]` |
808+
809+
!!! info "Deep Learning"
810+
- Data modeling keywords (struct/enum/trait/impl) detailed usage: [Advanced Features](part2_advanced.en.md)
811+
- Enterprise declaration keywords (job/server/db/auth/kv) detailed usage: [Enterprise Architecture Features](part5_enterprise.en.md)
812+
- Contract keywords (requires/ensures/invariant) detailed usage: [Syntax Extensions](part3_extensions.en.md)
813+
814+
---
815+
775816
## 📝 Chapter Summary
776817

777818
In this chapter, we learned:
778819

779820
1. **Agent Definition**: Using the `agent` keyword to define intelligent agents
780-
2. **Core Properties**: `role`, `prompt`, `model`, `memory`, `stream`, `cache`, etc.
821+
2. **Core Properties**: `role`, `prompt`, `model`, `memory`, `stream`, `cache`, `requires`, `ensures`, etc.
781822
3. **Flow Control**: Using `flow main` as program entry point
782823
4. **Tool Mounting**: Using the `uses` keyword to load standard library tools
783824
5. **Common Patterns**: Simple conversation, professional domain, tool-enhanced, high-availability patterns
784825
6. **Common Errors**: Model format, definition order, property spelling, etc.
826+
7. **v1.3.x New Keywords**: struct/enum/trait/impl/type/job/server/db/auth/kv/requires/ensures/invariant
785827

786828
But this only unleashes the large language model's single-agent task capability. Real business systems are filled with complex and lengthy collaborative interleaving: How to make a dozen agents with clear divisions of labor complete tasks in relay? How to achieve perfect consensus among agents with different opinions?
787829

@@ -791,6 +833,9 @@ Don't blink, this is exactly what the next chapter **Multi-Agent Scheduling and
791833

792834
## 🔗 Related Resources
793835

794-
- [Quickstart Tutorial](quickstart.md) - Master Nexa in 30 minutes
795-
- [Complete Example Collection](examples.md) - More practical code
796-
- [Troubleshooting Guide](troubleshooting.md) - Solve development issues
836+
- [Quickstart Tutorial](quickstart.en.md) - Master Nexa in 30 minutes
837+
- [Advanced Features](part2_advanced.en.md) - Pipe/Pattern Matching/ADT details
838+
- [Syntax Extensions](part3_extensions.en.md) - Contract/Type/Error Propagation
839+
- [Enterprise Architecture](part5_enterprise.en.md) - HTTP Server/Database/Auth
840+
- [Complete Example Collection](examples.en.md) - More practical code
841+
- [Troubleshooting Guide](troubleshooting.en.md) - Solve development issues

docs/part1_basic.md

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ agent FriendlyBot {
2929

3030
### 属性总览表
3131

32-
| 属性 | 类型 | 必填 | 默认值 | 说明 |
33-
|-----|------|-----|-------|------|
34-
| `role` | string || - | Agent 的角色描述,作为系统提示词的一部分 |
35-
| `prompt` | string | **** | - | Agent 的核心任务指令 |
36-
| `model` | string || 默认模型 | 指定使用的 LLM 模型 |
37-
| `memory` | string || - | 记忆模式:`persistent`(持久化)等 |
38-
| `stream` | boolean || false | 是否启用流式输出 |
39-
| `cache` | boolean || false | 是否启用智能缓存 |
40-
| `experience` | string || - | 长期记忆文件路径 |
41-
| `fallback` | string/list || - | 备用模型配置 |
42-
| `tools` | list || [] | 可用工具列表 |
43-
| `max_tokens` | int || - | 最大输出 token 数 |
44-
| `timeout` | int || 30 | 执行超时时间(秒) |
45-
| `retry` | int || 3 | 失败重试次数 |
32+
| 属性 | 类型 | 必填 | 默认值 | 版本 | 说明 |
33+
|-----|------|-----|-------|------|------|
34+
| `role` | string || - | v0.5+ | Agent 的角色描述,作为系统提示词的一部分 |
35+
| `prompt` | string | **** | - | v0.5+ | Agent 的核心任务指令 |
36+
| `model` | string || 默认模型 | v0.5+ | 指定使用的 LLM 模型 |
37+
| `memory` | string || - | v0.5+ | 记忆模式:`persistent`(持久化)等 |
38+
| `stream` | boolean || false | v0.5+ | 是否启用流式输出 |
39+
| `cache` | boolean || false | v0.5+ | 是否启用智能缓存 |
40+
| `experience` | string || - | v0.5+ | 长期记忆文件路径 |
41+
| `fallback` | string/list || - | v0.5+ | 备用模型配置 |
42+
| `tools` | list || [] | v0.5+ | 可用工具列表 |
43+
| `max_tokens` | int || - | v0.5+ | 最大输出 token 数 |
44+
| `timeout` | int || 30 | v0.5+ | 执行超时时间(秒) |
45+
| `retry` | int || 3 | v0.5+ | 失败重试次数 |
46+
| `requires` | clause || - | v1.2+ | 前置条件契约条款 |
47+
| `ensures` | clause || - | v1.2+ | 后置条件契约条款 |
4648

4749
### 属性详细说明
4850

@@ -760,16 +762,56 @@ agent Bot {
760762

761763
---
762764

765+
## 🆕 v1.3.x 新声明关键字速览
766+
767+
Nexa v1.3.x 引入了多个新的声明关键字,它们扩展了语言的表达力和企业级能力。以下是快速概览,详细用法请参考对应章节。
768+
769+
### 数据建模关键字
770+
771+
| 关键字 | 版本 | 说明 | 示例 |
772+
|-------|------|------|------|
773+
| `struct` | v1.3.x | 定义结构体 | `struct Point { x: Int, y: Int }` |
774+
| `enum` | v1.3.x | 定义枚举 | `enum Option[T] { Some(T), None }` |
775+
| `trait` | v1.3.x | 定义特质 | `trait Printable { fn format() -> String }` |
776+
| `impl` | v1.3.x | 实现特质 | `impl Printable for Point { ... }` |
777+
| `type` | v1.0.2+ | 定义语义类型 | `type Email = string @ "valid email"` |
778+
779+
### 企业级声明关键字
780+
781+
| 关键字 | 版本 | 说明 | 示例 |
782+
|-------|------|------|------|
783+
| `job` | v1.3.3 | 定义后台任务 | `job SendEmail { handler: ..., retry: 3 }` |
784+
| `server` | v1.3.4 | 定义 HTTP 服务 | `server MyApp { route GET "/hello" { ... } }` |
785+
| `db` | v1.3.5 | 定义数据库 | `db main_db { type: sqlite, path: "data.db" }` |
786+
| `auth` | v1.3.6 | 定义认证 | `auth my_auth { providers: ["google"] }` |
787+
| `kv` | v1.3.7 | 定义 KV 存储 | `kv my_cache { path: ":memory:" }` |
788+
789+
### 契约关键字
790+
791+
| 关键字 | 版本 | 说明 | 示例 |
792+
|-------|------|------|------|
793+
| `requires` | v1.2.0 | 前置条件 | `requires: amount > 0` |
794+
| `ensures` | v1.2.0 | 后置条件 | `ensures: result.success == true` |
795+
| `invariant` | v1.2.0 | 不变式 | `invariant: state in ["idle", "running"]` |
796+
797+
!!! info "深入学习"
798+
- 数据建模关键字(struct/enum/trait/impl)的详细用法请参考 [高级特性](part2_advanced.md)
799+
- 企业级声明关键字(job/server/db/auth/kv)的详细用法请参考 [企业级架构特性](part5_enterprise.md)
800+
- 契约关键字(requires/ensures/invariant)的详细用法请参考 [语法扩展](part3_extensions.md)
801+
802+
---
803+
763804
## 📝 本章小结
764805

765806
在这一章里,我们学习了:
766807

767808
1. **Agent 的定义**:使用 `agent` 关键字定义智能体
768-
2. **核心属性**`role`, `prompt`, `model`, `memory`, `stream`, `cache`
809+
2. **核心属性**`role`, `prompt`, `model`, `memory`, `stream`, `cache`, `requires`, `ensures`
769810
3. **流程控制**:使用 `flow main` 作为程序入口
770811
4. **工具挂载**:使用 `uses` 关键字加载标准库工具
771812
5. **常见模式**:简单对话、专业领域、工具增强、高可用等模式
772813
6. **常见错误**:模型格式、定义顺序、属性拼写等
814+
7. **v1.3.x 新关键字**:struct/enum/trait/impl/type/job/server/db/auth/kv/requires/ensures/invariant
773815

774816
但这仅仅发挥出大语言模型单打独斗(Single-Agent Task)的实力。真实的业务系统充满复杂冗长的协同交错:如何让十几个分工明确的代理接力完成任务?又该如何在各执一词的代理间达成完美共识?
775817

@@ -780,5 +822,8 @@ agent Bot {
780822
## 🔗 相关资源
781823

782824
- [快速入门教程](quickstart.md) - 30 分钟掌握 Nexa
825+
- [高级特性](part2_advanced.md) - 管道/模式匹配/ADT 详解
826+
- [语法扩展](part3_extensions.md) - 契约/类型/错误传播
827+
- [企业级架构](part5_enterprise.md) - HTTP Server/数据库/认证
783828
- [完整示例集合](examples.md) - 更多实战代码
784829
- [常见问题与排查](troubleshooting.md) - 解决开发问题

0 commit comments

Comments
 (0)