specmodule 0.1.0__tar.gz → 0.1.2__tar.gz
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.
- specmodule-0.1.2/PKG-INFO +150 -0
- specmodule-0.1.2/README.md +122 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/llm/__init__.py +2 -0
- specmodule-0.1.2/llm/mock.py +26 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/__init__.py +10 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/checkpoint.py +1 -6
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/cli.py +151 -245
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/entry.py +57 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/module.py +33 -22
- specmodule-0.1.2/module_harness/query.py +506 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/scaffold.py +9 -9
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/store.py +9 -6
- {specmodule-0.1.0 → specmodule-0.1.2}/pyproject.toml +1 -1
- specmodule-0.1.2/specmodule.egg-info/PKG-INFO +150 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/specmodule.egg-info/SOURCES.txt +1 -0
- specmodule-0.1.0/PKG-INFO +0 -321
- specmodule-0.1.0/README.md +0 -293
- specmodule-0.1.0/module_harness/query.py +0 -216
- specmodule-0.1.0/specmodule.egg-info/PKG-INFO +0 -321
- {specmodule-0.1.0 → specmodule-0.1.2}/LICENSE +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/llm/client.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/llm/config.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/align.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/builtins.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/command.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/config.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/consistency.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/events.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/feed.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/graph_builder.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/harness.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/loader.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/outputfmt.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/prompt.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/registry.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/spec.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/status.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/submodule.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/templates/builtin/codereview.json +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/templates/builtin/docwrite.json +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/templates/builtin/summarize.json +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/templates/builtin/translate.json +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/module_harness/translator.py +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/setup.cfg +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/specmodule.egg-info/dependency_links.txt +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/specmodule.egg-info/entry_points.txt +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/specmodule.egg-info/requires.txt +0 -0
- {specmodule-0.1.0 → specmodule-0.1.2}/specmodule.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: specmodule
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: 可审计、可调试、可完全掌控的 LLM 使用框架(tickflow + llm + module_harness)
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: llm,workflow,petri-net,agent
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: tickflow-py>=0.1.0
|
|
19
|
+
Provides-Extra: anthropic
|
|
20
|
+
Requires-Dist: anthropic; extra == "anthropic"
|
|
21
|
+
Provides-Extra: openai
|
|
22
|
+
Requires-Dist: openai; extra == "openai"
|
|
23
|
+
Provides-Extra: validate
|
|
24
|
+
Requires-Dist: jsonschema; extra == "validate"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# SpecModule
|
|
30
|
+
|
|
31
|
+
可审计、可调试、可完全掌控的 LLM 使用框架。
|
|
32
|
+
|
|
33
|
+
将 LLM 调用拆分为可组合的 Petri 网节点,每个节点是最小执行单元——翻译、审查、shell 命令、Python 函数。节点通过有向边连接(支持 AND/OR 汇合、循环),引擎以同步步进执行,所有状态集中记录。**每 tick 落盘轻量快照**,快照、暂停、精确回退(tick 号)都是低开销的。
|
|
34
|
+
|
|
35
|
+
## 架构
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
SpecModule/
|
|
39
|
+
├── tickflow # Petri 网工作流引擎(外部 pip 依赖 tickflow-py,import 名 tickflow)
|
|
40
|
+
├── llm/ # LLM 客户端(Anthropic + OpenAI 兼容)
|
|
41
|
+
│ ├── client.py
|
|
42
|
+
│ └── config.py # LLMConfig.from_env():配置回退链(env > 项目根 > store)
|
|
43
|
+
├── module_harness/ # Module 上层抽象
|
|
44
|
+
│ ├── module.py # Module 编排器(run/resume/snapshot/rollback)
|
|
45
|
+
│ ├── registry.py # HarnessRegistry(harness / script / command 注册)
|
|
46
|
+
│ ├── harness.py # Harness 类(LLM 调用节点,三层 prompt)
|
|
47
|
+
│ ├── command.py # Command 节点(shell 子进程)
|
|
48
|
+
│ ├── prompt.py # 三层 prompt 渲染
|
|
49
|
+
│ ├── outputfmt.py # 输出格式校验 + 自动提取
|
|
50
|
+
│ ├── spec.py # Spec, Tasklist, TasklistTemplate 数据模型
|
|
51
|
+
│ ├── translator.py # spec → tasklist 翻译 + 校验 + 模板加载
|
|
52
|
+
│ ├── graph_builder.py # tasklist → tickflow Graph
|
|
53
|
+
│ ├── consistency.py # spec + tasklist 一致性审核
|
|
54
|
+
│ ├── align.py # 对齐检查 harness
|
|
55
|
+
│ ├── checkpoint.py # 运行输入存档 + resume 兼容性校验
|
|
56
|
+
│ ├── status.py # 跨进程运行状态查询
|
|
57
|
+
│ ├── submodule.py # 类式 module 定义 + 打包发布
|
|
58
|
+
│ ├── loader.py # module 加载 + 依赖校验
|
|
59
|
+
│ ├── builtins.py # 内置 harness 集
|
|
60
|
+
│ ├── events.py # EventBus + 类型化事件
|
|
61
|
+
│ ├── entry.py # ModuleEntry 入口合约 + 目录发现
|
|
62
|
+
│ ├── scaffold.py # init 脚手架生成(单文件 + --as-dir 目录形态)
|
|
63
|
+
│ ├── store.py # store 共享层(家目录/搜索路径/枚举/安装管理)
|
|
64
|
+
│ ├── feed.py # 零依赖运行 feed(http.server,CLI feed 命令)
|
|
65
|
+
│ ├── query.py # 共享查询层(时间线/检查点,CLI/MCP/Web 复用)
|
|
66
|
+
│ ├── cli.py # specmodule CLI(18 子命令,argparse 零依赖)
|
|
67
|
+
│ ├── templates/ # 内置任务模板
|
|
68
|
+
│ └── tests/ # pytest 测试套件(含真实 LLM smoke)
|
|
69
|
+
├── examples/ # 嵌入式最小 demo(embed_minimal)+ 教程案例(tutorial)
|
|
70
|
+
└── docs/ # 用户文档(guides/references/concepts)+ 内部文档(dev/)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 安装依赖
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 库:pip 安装(pyproject.toml + console script `specmodule`)
|
|
77
|
+
pip install specmodule
|
|
78
|
+
|
|
79
|
+
# 开发(本仓库):源码 + 测试依赖
|
|
80
|
+
pip install -r requirements.txt
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
| 包 | 用途 | 必需 |
|
|
84
|
+
|----|------|------|
|
|
85
|
+
| **`specmodule`** | 库本体(PyPI 名;`pyproject.toml` 打包:`llm` + `module_harness` + CLI `specmodule`) | ✅ 必需 |
|
|
86
|
+
| **`tickflow-py`** | Petri 网工作流引擎。⚠️ PyPI 包名为 `tickflow-py`,**import 名仍为 `tickflow`**(`import tickflow`,不是 `import tickflow_py`)。上游仓库:https://github.com/MountLynx/tickflow- | ✅ 必需 |
|
|
87
|
+
| `anthropic` | Claude 后端(`provider=anthropic` 时) | 按 provider 选装 |
|
|
88
|
+
| `openai` | OpenAI 及兼容后端(`provider=openai` / `openai-compatible` 时) | 按 provider 选装 |
|
|
89
|
+
| `jsonschema` | `json_schema` 输出格式校验(未安装则跳过 schema 校验,仅保证是 JSON) | 推荐 |
|
|
90
|
+
| `pytest` | 测试套件(`python -m pytest module_harness/tests/ -q`) | 仅开发 |
|
|
91
|
+
|
|
92
|
+
## 快速开始
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install specmodule
|
|
96
|
+
specmodule setup # 一次性配置 provider/model/key(写 store 级配置)
|
|
97
|
+
specmodule install <模块 pack 目录或 git URL> # 获取模块(见 store-walkthrough)
|
|
98
|
+
specmodule run --module <名> --spec '{"text": "……"}' --mock # --mock 免 key 冒烟
|
|
99
|
+
specmodule review --run-id <名> # 审阅 tick 时间线
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
写第一个模块(入口声明 → harness/script 注册 → tasklist → 发布)见 [**从零到第一个模块(教程)**](docs/guides/tutorial-first-module.md);store 使用闭环见 [**store-walkthrough**](docs/guides/store-walkthrough.md);配置见 [**config-guide**](docs/guides/config-guide.md)。
|
|
103
|
+
|
|
104
|
+
## 文档导航
|
|
105
|
+
|
|
106
|
+
| 你是 | 入口 |
|
|
107
|
+
|------|------|
|
|
108
|
+
| 用 module(CLI 用户) | [store-walkthrough](docs/guides/store-walkthrough.md) → [cli-usage 参考](docs/references/cli-usage.md) |
|
|
109
|
+
| 写 module(开发者) | [教程:从零到第一个模块](docs/guides/tutorial-first-module.md) → [tasklist 执行语义](docs/references/tickflow-integration.md) → [语法参考](docs/references/spec-harness-syntax.md) |
|
|
110
|
+
| 理解框架(概念) | [concepts/SpecModule.md](docs/concepts/SpecModule.md) |
|
|
111
|
+
| 嵌入宿主项目 | [embedding.md](docs/guides/embedding.md)(demo:`examples/embed_minimal/`) |
|
|
112
|
+
| 完整索引 | [docs/README.md](docs/README.md) |
|
|
113
|
+
|
|
114
|
+
## 核心概念
|
|
115
|
+
|
|
116
|
+
### 三种节点类型
|
|
117
|
+
|
|
118
|
+
| 类型 | 用途 | 注册方式 |
|
|
119
|
+
|------|------|----------|
|
|
120
|
+
| **harness** | LLM 调用 — 三层 prompt、输出校验、流式 token | `reg.harness("name", config)` |
|
|
121
|
+
| **script** | 纯 Python 函数 — 处理、计算、IO | `@reg.script("name")` |
|
|
122
|
+
| **command** | Shell 命令 — 一行字符串即节点 | `reg.command("name", CommandConfig(...))` |
|
|
123
|
+
|
|
124
|
+
### spec 与 tasklist
|
|
125
|
+
|
|
126
|
+
- **spec** — 结构化键值对,描述"想要什么"。无预定义 schema,字段由模板设计者定义。
|
|
127
|
+
- **tasklist** — `{Tasks: {A: {...}, B: {...}}, Flow: "A --> B"}`。描述"如何做",每个 Task 映射为一个 tickflow 节点。
|
|
128
|
+
- **两种输入**:① 只传 spec(通过模板翻译为 tasklist)② 传 spec + tasklist(一致性审核后直入 graph builder)。选择依据与模板通道见 [concepts](docs/concepts/SpecModule.md)。
|
|
129
|
+
|
|
130
|
+
### 快照与回滚
|
|
131
|
+
|
|
132
|
+
每 tick 轻量快照(persist=True 时逐 tick 落盘),任意 tick 可精确回退(`resume(tick)` / `rollback`);手动检查点 `checkpoint("label")` 永久保留;进程内 `snapshot()` / `restore()` 支持任意分支。持久化约定与敏感数据注意见 [concepts](docs/concepts/SpecModule.md)。
|
|
133
|
+
|
|
134
|
+
### submodule — 类式 module + 打包发布
|
|
135
|
+
|
|
136
|
+
`SubModule` 类式声明(含 `spec_schema` 输入契约)→ `pack()` 导出可发布清单(module.json + harnesses/ + scripts/ + commands/)→ `ModuleLoader` 加载(`requires` 依赖校验)。`mode = "fast"` 零落盘运行。
|
|
137
|
+
|
|
138
|
+
## 当前状态
|
|
139
|
+
|
|
140
|
+
**库核心框架能力已完成**(18 项);**库自身主线已完成**(2026-08-22):打包接线、module-user-store 全系列(store 家目录 / 配置回退链 / 统一枚举 run / CLI 管理面)、独立线(嵌入式验证 demo + stdlib 可视化 feed);0.1.1(2026-08-23)init 脚手架修复 + git 来源安装完善。待做:M2 实践线、收口 API 稳定化、生态项目(TUI/MCP/Web)。完整进度与路线图见 [docs/dev/progress/module-roadmap.md](docs/dev/progress/module-roadmap.md)(内部文档)。
|
|
141
|
+
|
|
142
|
+
## 开发原则
|
|
143
|
+
|
|
144
|
+
- **tickflow 零修改(有条件的)** — tickflow 是外部依赖(PyPI 包 `tickflow-py`,import 名 `tickflow`,上游仓库 https://github.com/MountLynx/tickflow-),仓库内无 tickflow 代码。修改前先判断:改动是否有普适性、是否真正有助于优化 tickflow 本身?**没有 → 不碰**(模块层功能一律通过 `Registry` 子类扩展);**有 → 在上游改**,发布新版 `tickflow-py` 并升级安装版本
|
|
145
|
+
- **两级用户定位** — 框架服务两类用户:**开发者用户**(写 module 并发布)与**使用者用户**(只写 spec/tasklist)。边界不硬——开发者也是使用者,使用者也能按需修改。本质是两个使用场景(**开发场景** vs **使用场景**)
|
|
146
|
+
- **完全掌控** — 无隐式行为,promptmode 选错直接 KeyError,框架不兜底
|
|
147
|
+
|
|
148
|
+
## 许可证
|
|
149
|
+
|
|
150
|
+
MIT
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# SpecModule
|
|
2
|
+
|
|
3
|
+
可审计、可调试、可完全掌控的 LLM 使用框架。
|
|
4
|
+
|
|
5
|
+
将 LLM 调用拆分为可组合的 Petri 网节点,每个节点是最小执行单元——翻译、审查、shell 命令、Python 函数。节点通过有向边连接(支持 AND/OR 汇合、循环),引擎以同步步进执行,所有状态集中记录。**每 tick 落盘轻量快照**,快照、暂停、精确回退(tick 号)都是低开销的。
|
|
6
|
+
|
|
7
|
+
## 架构
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
SpecModule/
|
|
11
|
+
├── tickflow # Petri 网工作流引擎(外部 pip 依赖 tickflow-py,import 名 tickflow)
|
|
12
|
+
├── llm/ # LLM 客户端(Anthropic + OpenAI 兼容)
|
|
13
|
+
│ ├── client.py
|
|
14
|
+
│ └── config.py # LLMConfig.from_env():配置回退链(env > 项目根 > store)
|
|
15
|
+
├── module_harness/ # Module 上层抽象
|
|
16
|
+
│ ├── module.py # Module 编排器(run/resume/snapshot/rollback)
|
|
17
|
+
│ ├── registry.py # HarnessRegistry(harness / script / command 注册)
|
|
18
|
+
│ ├── harness.py # Harness 类(LLM 调用节点,三层 prompt)
|
|
19
|
+
│ ├── command.py # Command 节点(shell 子进程)
|
|
20
|
+
│ ├── prompt.py # 三层 prompt 渲染
|
|
21
|
+
│ ├── outputfmt.py # 输出格式校验 + 自动提取
|
|
22
|
+
│ ├── spec.py # Spec, Tasklist, TasklistTemplate 数据模型
|
|
23
|
+
│ ├── translator.py # spec → tasklist 翻译 + 校验 + 模板加载
|
|
24
|
+
│ ├── graph_builder.py # tasklist → tickflow Graph
|
|
25
|
+
│ ├── consistency.py # spec + tasklist 一致性审核
|
|
26
|
+
│ ├── align.py # 对齐检查 harness
|
|
27
|
+
│ ├── checkpoint.py # 运行输入存档 + resume 兼容性校验
|
|
28
|
+
│ ├── status.py # 跨进程运行状态查询
|
|
29
|
+
│ ├── submodule.py # 类式 module 定义 + 打包发布
|
|
30
|
+
│ ├── loader.py # module 加载 + 依赖校验
|
|
31
|
+
│ ├── builtins.py # 内置 harness 集
|
|
32
|
+
│ ├── events.py # EventBus + 类型化事件
|
|
33
|
+
│ ├── entry.py # ModuleEntry 入口合约 + 目录发现
|
|
34
|
+
│ ├── scaffold.py # init 脚手架生成(单文件 + --as-dir 目录形态)
|
|
35
|
+
│ ├── store.py # store 共享层(家目录/搜索路径/枚举/安装管理)
|
|
36
|
+
│ ├── feed.py # 零依赖运行 feed(http.server,CLI feed 命令)
|
|
37
|
+
│ ├── query.py # 共享查询层(时间线/检查点,CLI/MCP/Web 复用)
|
|
38
|
+
│ ├── cli.py # specmodule CLI(18 子命令,argparse 零依赖)
|
|
39
|
+
│ ├── templates/ # 内置任务模板
|
|
40
|
+
│ └── tests/ # pytest 测试套件(含真实 LLM smoke)
|
|
41
|
+
├── examples/ # 嵌入式最小 demo(embed_minimal)+ 教程案例(tutorial)
|
|
42
|
+
└── docs/ # 用户文档(guides/references/concepts)+ 内部文档(dev/)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 安装依赖
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# 库:pip 安装(pyproject.toml + console script `specmodule`)
|
|
49
|
+
pip install specmodule
|
|
50
|
+
|
|
51
|
+
# 开发(本仓库):源码 + 测试依赖
|
|
52
|
+
pip install -r requirements.txt
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
| 包 | 用途 | 必需 |
|
|
56
|
+
|----|------|------|
|
|
57
|
+
| **`specmodule`** | 库本体(PyPI 名;`pyproject.toml` 打包:`llm` + `module_harness` + CLI `specmodule`) | ✅ 必需 |
|
|
58
|
+
| **`tickflow-py`** | Petri 网工作流引擎。⚠️ PyPI 包名为 `tickflow-py`,**import 名仍为 `tickflow`**(`import tickflow`,不是 `import tickflow_py`)。上游仓库:https://github.com/MountLynx/tickflow- | ✅ 必需 |
|
|
59
|
+
| `anthropic` | Claude 后端(`provider=anthropic` 时) | 按 provider 选装 |
|
|
60
|
+
| `openai` | OpenAI 及兼容后端(`provider=openai` / `openai-compatible` 时) | 按 provider 选装 |
|
|
61
|
+
| `jsonschema` | `json_schema` 输出格式校验(未安装则跳过 schema 校验,仅保证是 JSON) | 推荐 |
|
|
62
|
+
| `pytest` | 测试套件(`python -m pytest module_harness/tests/ -q`) | 仅开发 |
|
|
63
|
+
|
|
64
|
+
## 快速开始
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install specmodule
|
|
68
|
+
specmodule setup # 一次性配置 provider/model/key(写 store 级配置)
|
|
69
|
+
specmodule install <模块 pack 目录或 git URL> # 获取模块(见 store-walkthrough)
|
|
70
|
+
specmodule run --module <名> --spec '{"text": "……"}' --mock # --mock 免 key 冒烟
|
|
71
|
+
specmodule review --run-id <名> # 审阅 tick 时间线
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
写第一个模块(入口声明 → harness/script 注册 → tasklist → 发布)见 [**从零到第一个模块(教程)**](docs/guides/tutorial-first-module.md);store 使用闭环见 [**store-walkthrough**](docs/guides/store-walkthrough.md);配置见 [**config-guide**](docs/guides/config-guide.md)。
|
|
75
|
+
|
|
76
|
+
## 文档导航
|
|
77
|
+
|
|
78
|
+
| 你是 | 入口 |
|
|
79
|
+
|------|------|
|
|
80
|
+
| 用 module(CLI 用户) | [store-walkthrough](docs/guides/store-walkthrough.md) → [cli-usage 参考](docs/references/cli-usage.md) |
|
|
81
|
+
| 写 module(开发者) | [教程:从零到第一个模块](docs/guides/tutorial-first-module.md) → [tasklist 执行语义](docs/references/tickflow-integration.md) → [语法参考](docs/references/spec-harness-syntax.md) |
|
|
82
|
+
| 理解框架(概念) | [concepts/SpecModule.md](docs/concepts/SpecModule.md) |
|
|
83
|
+
| 嵌入宿主项目 | [embedding.md](docs/guides/embedding.md)(demo:`examples/embed_minimal/`) |
|
|
84
|
+
| 完整索引 | [docs/README.md](docs/README.md) |
|
|
85
|
+
|
|
86
|
+
## 核心概念
|
|
87
|
+
|
|
88
|
+
### 三种节点类型
|
|
89
|
+
|
|
90
|
+
| 类型 | 用途 | 注册方式 |
|
|
91
|
+
|------|------|----------|
|
|
92
|
+
| **harness** | LLM 调用 — 三层 prompt、输出校验、流式 token | `reg.harness("name", config)` |
|
|
93
|
+
| **script** | 纯 Python 函数 — 处理、计算、IO | `@reg.script("name")` |
|
|
94
|
+
| **command** | Shell 命令 — 一行字符串即节点 | `reg.command("name", CommandConfig(...))` |
|
|
95
|
+
|
|
96
|
+
### spec 与 tasklist
|
|
97
|
+
|
|
98
|
+
- **spec** — 结构化键值对,描述"想要什么"。无预定义 schema,字段由模板设计者定义。
|
|
99
|
+
- **tasklist** — `{Tasks: {A: {...}, B: {...}}, Flow: "A --> B"}`。描述"如何做",每个 Task 映射为一个 tickflow 节点。
|
|
100
|
+
- **两种输入**:① 只传 spec(通过模板翻译为 tasklist)② 传 spec + tasklist(一致性审核后直入 graph builder)。选择依据与模板通道见 [concepts](docs/concepts/SpecModule.md)。
|
|
101
|
+
|
|
102
|
+
### 快照与回滚
|
|
103
|
+
|
|
104
|
+
每 tick 轻量快照(persist=True 时逐 tick 落盘),任意 tick 可精确回退(`resume(tick)` / `rollback`);手动检查点 `checkpoint("label")` 永久保留;进程内 `snapshot()` / `restore()` 支持任意分支。持久化约定与敏感数据注意见 [concepts](docs/concepts/SpecModule.md)。
|
|
105
|
+
|
|
106
|
+
### submodule — 类式 module + 打包发布
|
|
107
|
+
|
|
108
|
+
`SubModule` 类式声明(含 `spec_schema` 输入契约)→ `pack()` 导出可发布清单(module.json + harnesses/ + scripts/ + commands/)→ `ModuleLoader` 加载(`requires` 依赖校验)。`mode = "fast"` 零落盘运行。
|
|
109
|
+
|
|
110
|
+
## 当前状态
|
|
111
|
+
|
|
112
|
+
**库核心框架能力已完成**(18 项);**库自身主线已完成**(2026-08-22):打包接线、module-user-store 全系列(store 家目录 / 配置回退链 / 统一枚举 run / CLI 管理面)、独立线(嵌入式验证 demo + stdlib 可视化 feed);0.1.1(2026-08-23)init 脚手架修复 + git 来源安装完善。待做:M2 实践线、收口 API 稳定化、生态项目(TUI/MCP/Web)。完整进度与路线图见 [docs/dev/progress/module-roadmap.md](docs/dev/progress/module-roadmap.md)(内部文档)。
|
|
113
|
+
|
|
114
|
+
## 开发原则
|
|
115
|
+
|
|
116
|
+
- **tickflow 零修改(有条件的)** — tickflow 是外部依赖(PyPI 包 `tickflow-py`,import 名 `tickflow`,上游仓库 https://github.com/MountLynx/tickflow-),仓库内无 tickflow 代码。修改前先判断:改动是否有普适性、是否真正有助于优化 tickflow 本身?**没有 → 不碰**(模块层功能一律通过 `Registry` 子类扩展);**有 → 在上游改**,发布新版 `tickflow-py` 并升级安装版本
|
|
117
|
+
- **两级用户定位** — 框架服务两类用户:**开发者用户**(写 module 并发布)与**使用者用户**(只写 spec/tasklist)。边界不硬——开发者也是使用者,使用者也能按需修改。本质是两个使用场景(**开发场景** vs **使用场景**)
|
|
118
|
+
- **完全掌控** — 无隐式行为,promptmode 选错直接 KeyError,框架不兜底
|
|
119
|
+
|
|
120
|
+
## 许可证
|
|
121
|
+
|
|
122
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Mock LLM 客户端:--mock / 测试用假客户端(免 key 免网络)。"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from .client import LLMResponse
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MockLLMClient:
|
|
12
|
+
"""通用假客户端:output_format=json_object 时返回宽松合法 JSON。
|
|
13
|
+
|
|
14
|
+
翻译通道(script 翻译器)不经 LLM,天然可用;json_object 输出可通过
|
|
15
|
+
OutputValidator;text 输出为占位文本。
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
async def complete(self, **kwargs: Any) -> LLMResponse:
|
|
19
|
+
fmt = kwargs.get("output_format") or {}
|
|
20
|
+
if fmt.get("type") == "json_object":
|
|
21
|
+
content = json.dumps(
|
|
22
|
+
{"result": "mock output", "summary": "mock", "issues": []}
|
|
23
|
+
)
|
|
24
|
+
else:
|
|
25
|
+
content = "mock output"
|
|
26
|
+
return LLMResponse(content=content)
|
|
@@ -52,14 +52,19 @@ from .entry import ModuleEntry, discover_modules
|
|
|
52
52
|
from .query import (
|
|
53
53
|
CheckpointEntry,
|
|
54
54
|
CheckpointList,
|
|
55
|
+
QueryValueResult,
|
|
55
56
|
ReviewEntry,
|
|
56
57
|
ReviewTimeline,
|
|
57
58
|
build_checkpoints,
|
|
58
59
|
build_timeline,
|
|
59
60
|
checkpoints_to_dict,
|
|
61
|
+
create_checkpoint,
|
|
60
62
|
filter_failed,
|
|
61
63
|
filter_node,
|
|
62
64
|
filter_tick,
|
|
65
|
+
load_snapshot_summary,
|
|
66
|
+
query_value,
|
|
67
|
+
run_db_path,
|
|
63
68
|
timeline_to_dict,
|
|
64
69
|
)
|
|
65
70
|
from .checkpoint import (
|
|
@@ -169,16 +174,21 @@ __all__ = [
|
|
|
169
174
|
# 共享查询层(roadmap Phase 0:CLI/MCP/Web 复用)
|
|
170
175
|
"ReviewEntry",
|
|
171
176
|
"ReviewTimeline",
|
|
177
|
+
"QueryValueResult",
|
|
178
|
+
"query_value",
|
|
172
179
|
"build_timeline",
|
|
173
180
|
"filter_failed",
|
|
174
181
|
"filter_node",
|
|
175
182
|
"filter_tick",
|
|
176
183
|
"timeline_to_dict",
|
|
184
|
+
"run_db_path",
|
|
177
185
|
# 共享查询层(回退点列表:resume/rollback 目标清单)
|
|
178
186
|
"CheckpointEntry",
|
|
179
187
|
"CheckpointList",
|
|
180
188
|
"build_checkpoints",
|
|
181
189
|
"checkpoints_to_dict",
|
|
190
|
+
"create_checkpoint",
|
|
191
|
+
"load_snapshot_summary",
|
|
182
192
|
# store 共享层(module-user-store:家目录/枚举/安装管理)
|
|
183
193
|
"store_home",
|
|
184
194
|
"search_paths",
|
|
@@ -27,18 +27,13 @@ from typing import Any
|
|
|
27
27
|
from tickflow import Graph
|
|
28
28
|
|
|
29
29
|
from .graph_builder import _is_constant_ref
|
|
30
|
+
from .query import run_db_path as _run_db_path # 路径规则单一来源(query.run_db_path)
|
|
30
31
|
from .spec import TaskDefinition, Tasklist
|
|
31
32
|
from .translator import prepare_flow
|
|
32
33
|
|
|
33
34
|
log = logging.getLogger(__name__)
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
def _run_db_path(module_id: str, base_dir: Path | None = None) -> Path:
|
|
37
|
-
"""``<base_dir>/.specmodule/runs/<module_id>/run.sqlite``(与 Module._persist_dir 对齐)。"""
|
|
38
|
-
base = base_dir if base_dir is not None else Path.cwd()
|
|
39
|
-
return base / ".specmodule" / "runs" / module_id / "run.sqlite"
|
|
40
|
-
|
|
41
|
-
|
|
42
37
|
def tasklist_to_dict(tl: Tasklist) -> dict[str, Any]:
|
|
43
38
|
"""Tasklist → JSON 可序列化 dict(``Tasklist.to_dict`` 薄封装,导出兼容)。"""
|
|
44
39
|
return tl.to_dict()
|