@tachu/extensions 1.0.0-beta.1 → 1.0.0-rc.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 (243) hide show
  1. package/CHANGELOG.md +48 -65
  2. package/README.md +83 -708
  3. package/README_ZH.md +82 -696
  4. package/dist/backends/file.d.ts +6 -6
  5. package/dist/backends/file.d.ts.map +1 -1
  6. package/dist/backends/file.js +27 -11
  7. package/dist/backends/file.js.map +1 -1
  8. package/dist/backends/terminal.d.ts +6 -6
  9. package/dist/backends/terminal.d.ts.map +1 -1
  10. package/dist/backends/terminal.js +31 -7
  11. package/dist/backends/terminal.js.map +1 -1
  12. package/dist/backends/web.d.ts +6 -6
  13. package/dist/backends/web.d.ts.map +1 -1
  14. package/dist/backends/web.js +10 -8
  15. package/dist/backends/web.js.map +1 -1
  16. package/dist/common/net.d.ts +8 -0
  17. package/dist/common/net.d.ts.map +1 -1
  18. package/dist/common/net.js +39 -24
  19. package/dist/common/net.js.map +1 -1
  20. package/dist/common/path.d.ts +38 -5
  21. package/dist/common/path.d.ts.map +1 -1
  22. package/dist/common/path.js +55 -13
  23. package/dist/common/path.js.map +1 -1
  24. package/dist/common/process.js.map +1 -1
  25. package/dist/index.d.ts +7 -3
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +7 -3
  28. package/dist/index.js.map +1 -1
  29. package/dist/mcp/sse-adapter.d.ts +45 -33
  30. package/dist/mcp/sse-adapter.d.ts.map +1 -1
  31. package/dist/mcp/sse-adapter.js +59 -34
  32. package/dist/mcp/sse-adapter.js.map +1 -1
  33. package/dist/mcp/stdio-adapter.d.ts +45 -33
  34. package/dist/mcp/stdio-adapter.d.ts.map +1 -1
  35. package/dist/mcp/stdio-adapter.js +59 -34
  36. package/dist/mcp/stdio-adapter.js.map +1 -1
  37. package/dist/memory/fs-memory-system.d.ts +288 -0
  38. package/dist/memory/fs-memory-system.d.ts.map +1 -0
  39. package/dist/memory/fs-memory-system.js +482 -0
  40. package/dist/memory/fs-memory-system.js.map +1 -0
  41. package/dist/memory/index.d.ts +5 -0
  42. package/dist/memory/index.d.ts.map +1 -0
  43. package/dist/memory/index.js +5 -0
  44. package/dist/memory/index.js.map +1 -0
  45. package/dist/memory/projection-outbox.d.ts +69 -0
  46. package/dist/memory/projection-outbox.d.ts.map +1 -0
  47. package/dist/memory/projection-outbox.js +187 -0
  48. package/dist/memory/projection-outbox.js.map +1 -0
  49. package/dist/memory/projection-projector.d.ts +16 -0
  50. package/dist/memory/projection-projector.d.ts.map +1 -0
  51. package/dist/memory/projection-projector.js +56 -0
  52. package/dist/memory/projection-projector.js.map +1 -0
  53. package/dist/memory/projection-worker.d.ts +28 -0
  54. package/dist/memory/projection-worker.d.ts.map +1 -0
  55. package/dist/memory/projection-worker.js +84 -0
  56. package/dist/memory/projection-worker.js.map +1 -0
  57. package/dist/observability/jsonl-emitter.d.ts +25 -25
  58. package/dist/observability/jsonl-emitter.d.ts.map +1 -1
  59. package/dist/observability/jsonl-emitter.js +25 -25
  60. package/dist/observability/jsonl-emitter.js.map +1 -1
  61. package/dist/observability/otel-emitter.d.ts +23 -23
  62. package/dist/observability/otel-emitter.d.ts.map +1 -1
  63. package/dist/observability/otel-emitter.js +39 -30
  64. package/dist/observability/otel-emitter.js.map +1 -1
  65. package/dist/providers/anthropic.d.ts +51 -32
  66. package/dist/providers/anthropic.d.ts.map +1 -1
  67. package/dist/providers/anthropic.js +293 -58
  68. package/dist/providers/anthropic.js.map +1 -1
  69. package/dist/providers/gemini.d.ts +115 -0
  70. package/dist/providers/gemini.d.ts.map +1 -0
  71. package/dist/providers/gemini.js +901 -0
  72. package/dist/providers/gemini.js.map +1 -0
  73. package/dist/providers/index.d.ts +2 -0
  74. package/dist/providers/index.d.ts.map +1 -1
  75. package/dist/providers/index.js +2 -0
  76. package/dist/providers/index.js.map +1 -1
  77. package/dist/providers/mock.d.ts +67 -24
  78. package/dist/providers/mock.d.ts.map +1 -1
  79. package/dist/providers/mock.js +122 -41
  80. package/dist/providers/mock.js.map +1 -1
  81. package/dist/providers/openai.d.ts +70 -35
  82. package/dist/providers/openai.d.ts.map +1 -1
  83. package/dist/providers/openai.js +330 -50
  84. package/dist/providers/openai.js.map +1 -1
  85. package/dist/providers/qwen.d.ts +146 -0
  86. package/dist/providers/qwen.d.ts.map +1 -0
  87. package/dist/providers/qwen.js +672 -0
  88. package/dist/providers/qwen.js.map +1 -0
  89. package/dist/safety/default-gate.d.ts +112 -0
  90. package/dist/safety/default-gate.d.ts.map +1 -0
  91. package/dist/safety/default-gate.js +188 -0
  92. package/dist/safety/default-gate.js.map +1 -0
  93. package/dist/safety/index.d.ts +2 -0
  94. package/dist/safety/index.d.ts.map +1 -0
  95. package/dist/safety/index.js +2 -0
  96. package/dist/safety/index.js.map +1 -0
  97. package/dist/tools/_shared/web-client.d.ts +18 -0
  98. package/dist/tools/_shared/web-client.d.ts.map +1 -0
  99. package/dist/tools/_shared/web-client.js +46 -0
  100. package/dist/tools/_shared/web-client.js.map +1 -0
  101. package/dist/tools/apply-patch/executor.d.ts.map +1 -1
  102. package/dist/tools/apply-patch/executor.js +54 -4
  103. package/dist/tools/apply-patch/executor.js.map +1 -1
  104. package/dist/tools/edit-file/executor.d.ts +32 -0
  105. package/dist/tools/edit-file/executor.d.ts.map +1 -0
  106. package/dist/tools/edit-file/executor.js +84 -0
  107. package/dist/tools/edit-file/executor.js.map +1 -0
  108. package/dist/tools/fetch-url/descriptor.md +6 -0
  109. package/dist/tools/fetch-url/executor.d.ts +8 -0
  110. package/dist/tools/fetch-url/executor.d.ts.map +1 -1
  111. package/dist/tools/fetch-url/executor.js +83 -2
  112. package/dist/tools/fetch-url/executor.js.map +1 -1
  113. package/dist/tools/git-blame/executor.d.ts +24 -0
  114. package/dist/tools/git-blame/executor.d.ts.map +1 -0
  115. package/dist/tools/git-blame/executor.js +76 -0
  116. package/dist/tools/git-blame/executor.js.map +1 -0
  117. package/dist/tools/git-branch/executor.d.ts +22 -0
  118. package/dist/tools/git-branch/executor.d.ts.map +1 -0
  119. package/dist/tools/git-branch/executor.js +81 -0
  120. package/dist/tools/git-branch/executor.js.map +1 -0
  121. package/dist/tools/git-diff/executor.d.ts +37 -0
  122. package/dist/tools/git-diff/executor.d.ts.map +1 -0
  123. package/dist/tools/git-diff/executor.js +156 -0
  124. package/dist/tools/git-diff/executor.js.map +1 -0
  125. package/dist/tools/git-log/executor.d.ts +31 -0
  126. package/dist/tools/git-log/executor.d.ts.map +1 -0
  127. package/dist/tools/git-log/executor.js +65 -0
  128. package/dist/tools/git-log/executor.js.map +1 -0
  129. package/dist/tools/git-show/executor.d.ts +22 -0
  130. package/dist/tools/git-show/executor.d.ts.map +1 -0
  131. package/dist/tools/git-show/executor.js +74 -0
  132. package/dist/tools/git-show/executor.js.map +1 -0
  133. package/dist/tools/git-status/executor.d.ts +25 -0
  134. package/dist/tools/git-status/executor.d.ts.map +1 -0
  135. package/dist/tools/git-status/executor.js +120 -0
  136. package/dist/tools/git-status/executor.js.map +1 -0
  137. package/dist/tools/glob/executor.d.ts +18 -0
  138. package/dist/tools/glob/executor.d.ts.map +1 -0
  139. package/dist/tools/glob/executor.js +47 -0
  140. package/dist/tools/glob/executor.js.map +1 -0
  141. package/dist/tools/index.d.ts +1 -1
  142. package/dist/tools/index.d.ts.map +1 -1
  143. package/dist/tools/index.js +459 -4
  144. package/dist/tools/index.js.map +1 -1
  145. package/dist/tools/list-dir/executor.d.ts.map +1 -1
  146. package/dist/tools/list-dir/executor.js +5 -3
  147. package/dist/tools/list-dir/executor.js.map +1 -1
  148. package/dist/tools/multi-edit/executor.d.ts +29 -0
  149. package/dist/tools/multi-edit/executor.d.ts.map +1 -0
  150. package/dist/tools/multi-edit/executor.js +37 -0
  151. package/dist/tools/multi-edit/executor.js.map +1 -0
  152. package/dist/tools/read-file/executor.d.ts +5 -0
  153. package/dist/tools/read-file/executor.d.ts.map +1 -1
  154. package/dist/tools/read-file/executor.js +49 -5
  155. package/dist/tools/read-file/executor.js.map +1 -1
  156. package/dist/tools/run-shell/executor.d.ts +12 -1
  157. package/dist/tools/run-shell/executor.d.ts.map +1 -1
  158. package/dist/tools/run-shell/executor.js +105 -9
  159. package/dist/tools/run-shell/executor.js.map +1 -1
  160. package/dist/tools/run-tests/executor.d.ts +28 -0
  161. package/dist/tools/run-tests/executor.d.ts.map +1 -0
  162. package/dist/tools/run-tests/executor.js +161 -0
  163. package/dist/tools/run-tests/executor.js.map +1 -0
  164. package/dist/tools/run-typecheck/executor.d.ts +25 -0
  165. package/dist/tools/run-typecheck/executor.d.ts.map +1 -0
  166. package/dist/tools/run-typecheck/executor.js +83 -0
  167. package/dist/tools/run-typecheck/executor.js.map +1 -0
  168. package/dist/tools/search-code/executor.d.ts.map +1 -1
  169. package/dist/tools/search-code/executor.js +60 -30
  170. package/dist/tools/search-code/executor.js.map +1 -1
  171. package/dist/tools/shared.d.ts +26 -0
  172. package/dist/tools/shared.d.ts.map +1 -1
  173. package/dist/tools/shared.js +15 -0
  174. package/dist/tools/shared.js.map +1 -1
  175. package/dist/tools/todo-read/executor.d.ts +20 -0
  176. package/dist/tools/todo-read/executor.d.ts.map +1 -0
  177. package/dist/tools/todo-read/executor.js +26 -0
  178. package/dist/tools/todo-read/executor.js.map +1 -0
  179. package/dist/tools/todo-write/executor.d.ts +21 -0
  180. package/dist/tools/todo-write/executor.d.ts.map +1 -0
  181. package/dist/tools/todo-write/executor.js +38 -0
  182. package/dist/tools/todo-write/executor.js.map +1 -0
  183. package/dist/tools/web-fetch/descriptor.md +198 -0
  184. package/dist/tools/web-fetch/errors.d.ts +32 -0
  185. package/dist/tools/web-fetch/errors.d.ts.map +1 -0
  186. package/dist/tools/web-fetch/errors.js +91 -0
  187. package/dist/tools/web-fetch/errors.js.map +1 -0
  188. package/dist/tools/web-fetch/executor.d.ts +10 -0
  189. package/dist/tools/web-fetch/executor.d.ts.map +1 -0
  190. package/dist/tools/web-fetch/executor.js +191 -0
  191. package/dist/tools/web-fetch/executor.js.map +1 -0
  192. package/dist/tools/web-fetch/index.d.ts +4 -0
  193. package/dist/tools/web-fetch/index.d.ts.map +1 -0
  194. package/dist/tools/web-fetch/index.js +3 -0
  195. package/dist/tools/web-fetch/index.js.map +1 -0
  196. package/dist/tools/web-fetch/types.d.ts +157 -0
  197. package/dist/tools/web-fetch/types.d.ts.map +1 -0
  198. package/dist/tools/web-fetch/types.js +7 -0
  199. package/dist/tools/web-fetch/types.js.map +1 -0
  200. package/dist/tools/web-search/descriptor.md +89 -0
  201. package/dist/tools/web-search/errors.d.ts +33 -0
  202. package/dist/tools/web-search/errors.d.ts.map +1 -0
  203. package/dist/tools/web-search/errors.js +45 -0
  204. package/dist/tools/web-search/errors.js.map +1 -0
  205. package/dist/tools/web-search/executor.d.ts +10 -0
  206. package/dist/tools/web-search/executor.d.ts.map +1 -0
  207. package/dist/tools/web-search/executor.js +185 -0
  208. package/dist/tools/web-search/executor.js.map +1 -0
  209. package/dist/tools/web-search/index.d.ts +4 -0
  210. package/dist/tools/web-search/index.d.ts.map +1 -0
  211. package/dist/tools/web-search/index.js +3 -0
  212. package/dist/tools/web-search/index.js.map +1 -0
  213. package/dist/tools/web-search/types.d.ts +86 -0
  214. package/dist/tools/web-search/types.d.ts.map +1 -0
  215. package/dist/tools/web-search/types.js +7 -0
  216. package/dist/tools/web-search/types.js.map +1 -0
  217. package/dist/tools/write-file/executor.js +3 -3
  218. package/dist/tools/write-file/executor.js.map +1 -1
  219. package/dist/transformers/document-to-text.d.ts +11 -11
  220. package/dist/transformers/document-to-text.d.ts.map +1 -1
  221. package/dist/transformers/document-to-text.js +11 -11
  222. package/dist/transformers/document-to-text.js.map +1 -1
  223. package/dist/transformers/image-to-text.d.ts +15 -15
  224. package/dist/transformers/image-to-text.d.ts.map +1 -1
  225. package/dist/transformers/image-to-text.js +22 -21
  226. package/dist/transformers/image-to-text.js.map +1 -1
  227. package/dist/vector/index.d.ts +4 -2
  228. package/dist/vector/index.d.ts.map +1 -1
  229. package/dist/vector/index.js +2 -2
  230. package/dist/vector/index.js.map +1 -1
  231. package/dist/vector/local-fs-index.d.ts +59 -0
  232. package/dist/vector/local-fs-index.d.ts.map +1 -0
  233. package/dist/vector/local-fs-index.js +216 -0
  234. package/dist/vector/local-fs-index.js.map +1 -0
  235. package/dist/vector/qdrant.d.ts +11 -52
  236. package/dist/vector/qdrant.d.ts.map +1 -1
  237. package/dist/vector/qdrant.js +39 -105
  238. package/dist/vector/qdrant.js.map +1 -1
  239. package/package.json +27 -6
  240. package/dist/vector/local-fs.d.ts +0 -76
  241. package/dist/vector/local-fs.d.ts.map +0 -1
  242. package/dist/vector/local-fs.js +0 -153
  243. package/dist/vector/local-fs.js.map +0 -1
package/README.md CHANGED
@@ -1,37 +1,79 @@
1
1
  # Tachu
2
2
 
3
- **Production-grade agentic engine — the Harness that turns any LLM into a reliable, observable, production-ready Agent.**
3
+ **An agentic engine under active development — the *Harness* that aims to turn any LLM into a reliable, observable Agent.**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@tachu/core?label=%40tachu%2Fcore)](https://www.npmjs.com/package/@tachu/core)
6
+ [![status: rc](https://img.shields.io/badge/status-rc-blue)](#project-status)
6
7
  [![license: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](#license)
7
8
  [![bun](https://img.shields.io/badge/runtime-bun-orange)](https://bun.sh)
8
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org)
9
10
 
11
+ > **Project Status — Release Candidate.** The 9-phase pipeline, registry, prompt assembler, CLI, OpenAI / Anthropic / Qwen / Gemini adapters, MCP adapters, vector stores and observability emitters are wired up and tested. Phase 3 (Intent Analysis) is a real LLM call, Phase 5 routes complex tool-capable requests to the built-in `tool-use` loop, and Phase 8 runs deterministic validation rules with optional semantic judge. Runtime provider fallback and semantic judge production hardening remain post-rc work. Install via the `@rc` dist-tag.
12
+
10
13
  ---
11
14
 
12
15
  ## What is Tachu?
13
16
 
14
- Tachu is a **production-grade agentic engine** — not a toy demo, not a thin wrapper. It is the *Harness* in the equation **Agent = Model + Harness**: it provides the structural skeleton (protocol, lifecycle, safety, memory, orchestration) so that any LLM becomes a reliable, observable, production-capable Agent.
17
+ Tachu aims to be an **agentic engine you can build a real product on** — not a toy demo, not a thin wrapper. It is the *Harness* in the equation **Agent = Model + Harness**: it provides the structural skeleton (protocol, lifecycle, safety, memory, orchestration) so that any LLM becomes a reliable, observable Agent.
15
18
 
16
- The engine is intentionally **domain-agnostic**: it knows nothing about your business logic, your users, or your domain vocabulary. Instead, it defines a small set of core abstractions (Rules, Skills, Tools, Agents) through which your business fills in all the intelligence. Tachu handles the hard parts — 9-phase execution pipeline, dual-plane semantic matching, context window management, token-precise prompt assembly, structured retry/fallback, cancellation propagation, and end-to-end observability.
19
+ The engine is intentionally **domain-agnostic**: it knows nothing about your business logic, your users, or your domain vocabulary. Instead, it defines a small set of core abstractions (Rules, Skills, Tools, Agents) through which your business fills in all the intelligence. Tachu is designed to handle the hard parts — 9-phase execution pipeline, dual-plane semantic matching, context window management, token-precise prompt assembly, structured retry/fallback, cancellation propagation, and end-to-end observability.
17
20
 
18
- Tachu ships as a Bun-native TypeScript monorepo with three packages: the zero-dependency engine core (`@tachu/core`), a production-quality official extensions library (`@tachu/extensions`), and a fully-featured CLI program (`@tachu/cli`) that doubles as the reference implementation.
21
+ Tachu ships as a Bun-native TypeScript monorepo with three published packages the zero-dependency engine core (`@tachu/core`), an official extensions library (`@tachu/extensions`), and a fully-featured CLI program (`@tachu/cli`) that doubles as the reference implementation — plus `@tachu/host-defaults` for shared CLI/embedded host wiring, and an optional private sidecar package (`@tachu/web-fetch-server`) for remote browser-backed web tools.
22
+
23
+ ---
24
+
25
+ ## Project Status
26
+
27
+ **Current release:** `1.0.0-rc.0` on the `rc` dist-tag.
28
+
29
+ **Version terminology:** The product line is **Tachu v1**. Release candidates are stabilization builds for `1.0.0`, not a separate framework generation. HTTP paths like `/v1/extract` are API versions only. See [detailed-design § version glossary](docs/detailed-design.md#版本与发布术语必读).
30
+
31
+ This is the **first release candidate**. The table below is a readability index only; runtime behavior, defaults, and edge cases are authoritative in the cited source files and tests.
32
+
33
+ | Capability | Status | Notes |
34
+ |-----------|--------|-------|
35
+ | 9-phase pipeline skeleton (types, orchestrator, state machine, hooks) | ✅ Implemented | `packages/core/src/engine` |
36
+ | Descriptor Registry (Rules / Skills / Tools / Agents) | ✅ Implemented | Markdown + YAML frontmatter loader, semantic indexing, startup validation |
37
+ | Prompt assembler (tiktoken, KV-cache-friendly ordering) | ✅ Implemented | `packages/core/src/prompt` |
38
+ | Task scheduler, DAG validator, turn/task retry bookkeeping | ✅ Implemented | `packages/core/src/engine/scheduler.ts`; **runtime provider fallback on LLM errors is not wired** (see [Providers guide](./docs/guides/providers-and-integrations.md)) |
39
+ | Session / Memory / Runtime-state / Safety / Model-router / Provider / Observability / Hooks modules | ✅ Implemented | `packages/core/src/modules` |
40
+ | OpenAI / Anthropic / Qwen / Mock Provider adapters | ✅ Implemented | CLI auto-wires via `@tachu/host-defaults`; streaming, function calling, tool schemas |
41
+ | Gemini Provider adapter | ✅ Implemented (manual wiring) | `GeminiProviderAdapter` in `@tachu/extensions` with unit tests; **not** registered by default CLI / `buildProviderAdapter` — inject via `createEngine(..., { providers: [new GeminiProviderAdapter(...)] })` (see [Providers guide](./docs/guides/providers-and-integrations.md)) |
42
+ | `apiKey` / `baseURL` / `organization` / `timeoutMs` configuration (env var / `tachu.config.ts` / CLI flags) | ✅ Implemented | Azure OpenAI / LiteLLM / OpenRouter / self-hosted gateways supported |
43
+ | 22 built-in tools + Terminal / File / Web backends | ✅ Implemented | `packages/extensions/src/tools/index.ts` |
44
+ | MCP stdio + SSE adapters | ✅ Implemented | `packages/extensions/src/mcp` |
45
+ | `LocalFsVectorIndexAdapter` (file-backed) + `QdrantVectorIndexAdapter` (REST) | ✅ Implemented | |
46
+ | OTel / JSONL emitters | ✅ Implemented | |
47
+ | `tachu init` / `tachu run` / `tachu chat` CLI surface, streaming renderer, session persistence, Ctrl+C semantics | ✅ Implemented | |
48
+ | **CLI terminal Markdown rendering** | ✅ **Implemented** | `marked` + `marked-terminal` + `cli-highlight` stack. Applied to the final assistant reply in `tachu chat` / `tachu run --output text` when stdout is a TTY; automatically disables under `NO_COLOR` / non-TTY / `--no-color`. Explicit control via `--markdown` / `--no-markdown` on `tachu run`. Dedicated `renderMarkdownToAnsi` wrapper (`packages/cli/src/renderer/markdown.ts`) with 12 unit tests in `markdown.test.ts`. |
49
+ | **Phase 3 — Intent Analysis (LLM call, pure classification)** | ✅ **Implemented** | Pure classification only (`IntentResult`); final user reply is Phase 7 `direct-answer`. **Implementation:** `packages/core/src/engine/phases/intent.ts` (`INTENT_SYSTEM_PROMPT_BASE`, fast paths, JSON parse, heuristic fallback); tests: `intent.test.ts`. Hosts may **`config.intent.systemPromptBase`** to replace the base wholesale; optional extra few-shots: `config.intent.fewShotExamples` (Agent Context / explicit selections still appended by core). |
50
+ | **Phase 5 — Task Planning (planning router)** | ✅ **Implemented** | Enforces `plans[0].tasks.length >= 1`. Rules: (1) `simple` intent → single `direct-answer` sub-flow task; (2) `complex` + visible tools → single `tool-use` sub-flow task; (3) `complex` + no visible tool → single `direct-answer` sub-flow task with `warn: true`; (4) defensive post-guard catches upstream regressions that leave `tasks` empty. Multi-step behavior lives inside `tool-use`; optional plan preview / human review may still evolve, but there is no separate default LLM pre-planner on the main path. |
51
+ | **`direct-answer` built-in Sub-flow (Phase 7)** | ✅ **Implemented** | `packages/core/src/engine/subflows/direct-answer.ts`. Resolves `capabilityMapping.intent` (fallback to `fast-cheap`), composes system + ≤10 memory-history entries + user prompt, calls `ProviderAdapter.chat()` with a 60 s per-call timeout merged with the phase abort signal. System prompt mandates **natural-language Markdown**, forbids JSON wrappers / `"已识别请求:…"` templates / 4-space indented code blocks, and supports a `warn: true` flag for honest tool-missing disclaimers. Emits `llm_call_start` / `llm_call_end` observability events under `phase: "direct-answer"`. Non-overridable: `DescriptorRegistry` registers `direct-answer` as a reserved name and rejects business registration / unregistration with `RegistryError.reservedName`. |
52
+ | **Phase 8 — Result Validation Outcome** | 🟡 **Partially wired** | `ValidationOutcome` union + `ValidationRuleRegistry` with **5 deterministic rules** via `buildDefaultValidationRuleRegistry()` (`packages/core/src/engine/phases/validation/index.ts`). Optional `ProviderSemanticJudgeAdapter` / `BudgetedSemanticJudgeAdapter`. Engine consumes `retry` (turn loop via `decideTurnRetry`), `degrade` / `handoff` (exit to Output). Gaps: no standalone `ExecutionPolicy` type; runtime provider fallback is not implemented and semantic judge is not production-complete. |
53
+ | **Phase 9 — Output Assembly** | ✅ **Implemented** | Content selector: `taskResults['task-direct-answer']` → `{intent, taskResults}` structured JSON (tool-chain success path; semantic polish still depends on real Phase 8) → honest-fallback plain-language message with recognized intent + internal diagnosis + *"rephrase as simple"* suggestion (validation failed). Internal state JSON is never leaked to end users. Covered by `output.test.ts`. |
54
+ | Real-world smoke tests against OpenAI / Anthropic / Azure | 🟡 **Manually verified; opt-in automated** | Mock unit tests cover adapters in CI. Maintainers have **hand-run** real LLM paths (custom gateways included). An **opt-in** scripted e2e exists — set `TACHU_REAL_E2E=1` plus `TACHU_E2E_API_KEY` / `TACHU_E2E_API_BASE` / `TACHU_E2E_PROVIDER` (see [Contributing](./CONTRIBUTING.md)) — but default CI does not publish signed recordings. |
55
+ | Production hardening (SLO, error budgets, failure injection, signed provenance) | 🔴 Not yet | Target for `1.0.0` (Tachu v1). |
56
+
57
+ Legend: ✅ implemented and tested · 🟡 stub / placeholder present, real implementation in progress · 🔴 not yet started.
19
58
 
20
59
  ---
21
60
 
22
61
  ## Key Features
23
62
 
24
- - **9-Phase Execution Pipeline** — session management → safety → intent analysis → pre-check → planning → DAG validation → execution → result validation → output normalization; each phase is a typed, hookable stage
63
+ - **9-Phase Execution Pipeline** — session management → safety → intent analysis (pure classification) → pre-check → planning router → DAG validation → execution → result validation outcome → output normalization; each phase is a typed, hookable stage, and every request — simple or complex — flows through all nine phases with uniform Rules / Hooks / Observability / budget accounting
64
+ - **Task Planning + Tool-use Loop** — Phase 5 does not precompute a ranked multi-step plan. It routes `simple` requests to `direct-answer`, routes `complex + visible tools` into the built-in `tool-use` Agentic Loop, and lets that loop perform iterative LLM tool selection → gated tool execution → tool-result feedback → final answer.
65
+ - **`direct-answer` built-in Sub-flow** — answers to simple requests (and to complex requests with no matching tool) are produced by a first-class engine-internal Sub-flow running in Phase 7, not baked into the intent prompt.
25
66
  - **Dual-Plane Matching** — semantic discovery (vector similarity) + deterministic execution gate (scopes, whitelist, approval) for every Rule, Skill, Tool, and Agent
26
67
  - **Four Core Abstractions** — declare Rules, Skills, Tools, and Agents as Markdown + YAML frontmatter descriptors; the engine resolves, activates, and orchestrates them automatically
27
- - **Dual Provider Support** — production-grade OpenAI and Anthropic adapters; configurable fallback order for zero-downtime provider switching
68
+ - **OpenAI & Anthropic Adapters** — streaming, function calling, configurable `baseURL` / `organization` / `timeoutMs`; works with Azure OpenAI, LiteLLM, OpenRouter, or any self-hosted gateway
28
69
  - **MCP Integration** — connect any MCP server (stdio or SSE) via `McpToolAdapter`; MCP tools become first-class engine Tools
29
70
  - **Token-Precise Prompt Assembly** — tiktoken-based exact token counting; KV-cache-friendly prompt layout; automatic context compression (Head-Middle-Tail strategy)
30
71
  - **Structured Memory** — session context window with configurable limits; archive-before-summarize guarantee; vector recall for long-term memory
31
72
  - **OpenTelemetry Observability** — every phase entry/exit, LLM call, tool call, retry, and fallback emits a structured `EngineEvent`; OTel and JSONL emitters included
32
- - **Production-Grade CLI** — `tachu chat` / `tachu run` / `tachu init` with full parameter sets, streaming render, session persistence, and Ctrl+C cancellation
73
+ - **Interactive CLI** — `tachu chat` / `tachu run` / `tachu init` with full parameter sets, streaming render, session persistence, and Ctrl+C cancellation
74
+ - **Terminal Markdown rendering** — final assistant replies are rendered via `marked` + `marked-terminal` + `cli-highlight`; headings, bold / italic, lists, block quotes, links, tables and fenced code blocks (with syntax highlighting) are all supported. Automatically disabled under `NO_COLOR` / non-TTY / `--no-color`; explicitly controllable with `--markdown` / `--no-markdown` on `tachu run`.
33
75
  - **Fail-Closed Safety Baseline** — loop protection, budget circuit-breaker, and basic input validation are hardwired into the engine and cannot be disabled
34
- - **Qdrant & LocalFs Vector Stores** — plug in Qdrant for production-grade vector storage or use the built-in in-memory store for development
76
+ - **Qdrant & LocalFs Vector Stores** — plug in Qdrant for multi-process deployments or use the file-backed store for local/single-process setups
35
77
 
36
78
  ---
37
79
 
@@ -52,119 +94,17 @@ Tachu is built around three convictions:
52
94
 
53
95
  ## Core Abstractions
54
96
 
55
- Tachu's four core abstractions are **co-equal and orthogonal** each independently registered, independently activated, and composable across all engine phases.
56
-
57
- | Abstraction | Nature | Activation Gate | Effect |
58
- |-------------|--------|-----------------|--------|
59
- | **Rules** | Constraints & guidance | Semantic discovery → direct activation | Injected into LLM System Prompt at each scoped phase |
60
- | **Skills** | Knowledge & instructions | Semantic discovery → direct activation | Injected into LLM context when activated |
61
- | **Tools** | Atomic executable operations | Semantic discovery → **mandatory gate** (scopes → whitelist → approval) | Executed with full side-effect tracking |
62
- | **Agents** | Natural-language-driven execution units | Semantic discovery → activatable | Recursively use engine capabilities; all Tool calls pass through the Tool gate |
63
-
64
- All four share a **common descriptor schema** (Markdown + YAML frontmatter):
97
+ Rules, Skills, Tools, and Agents are Markdown + YAML descriptors. Semantic discovery proposes candidates; deterministic gates authorize execution (especially Tools).
65
98
 
66
- ```yaml
67
- name: unique-name # required, unique within type
68
- description: ... # natural language (used for semantic discovery)
69
- tags: [tag1, tag2] # for filtering and classification
70
- trigger: { type: always } # activation condition
71
- requires:
72
- - { kind: tool, name: read-file } # explicit dependency references
73
- ```
74
-
75
- ### Dual-Plane Matching Model
76
-
77
- Every core abstraction is activated through a two-phase process:
78
-
79
- ```mermaid
80
- graph LR
81
- Input[Context Input] --> Discovery[Semantic Discovery Plane]
82
- Discovery --> Index[(Vector Index)]
83
- Index --> Candidates[Candidate Set]
84
- Candidates --> Gate[Deterministic Execution Gate]
85
- Gate -- scopes / whitelist / approval --> Execution[Execution Plane]
86
- ```
87
-
88
- - **Semantic discovery plane**: `description` is vectorized on registration; at runtime, the current context is matched against the index to produce a candidate set
89
- - **Deterministic execution gate**: final activation requires passing a deterministic gate (explicit references, whitelist checks, permission scopes, approval checks)
90
-
91
- Rules and Skills pass through the gate freely (no side effects). Tools always pass through the full gate. Agents activate freely but all Tool calls they trigger still pass through the Tool gate.
99
+ Details: [Overview · abstractions](./docs/overview-design.md#三四大核心抽象) · [Dual-plane matching](./docs/overview-design.md#共享特性).
92
100
 
93
101
  ---
94
102
 
95
- ## Architecture Overview
96
-
97
- ### Three-Layer Structure
98
-
99
- Tachu is published as three layers:
100
-
101
- ```mermaid
102
- graph TD
103
- subgraph "Business Layer"
104
- A[Business Rules / Domain Tools / Custom Adapters / Domain Skills / Agents / Plan Templates]
105
- end
106
- subgraph "Extensions Library — @tachu/extensions"
107
- B[OpenAI & Anthropic Adapters / 7 Common Tools / Terminal+File+Web Backends / Qdrant+LocalFs VectorStore / MCP Adapter / OTel+JSONL Emitters / 4 Common Rules]
108
- end
109
- subgraph "Engine Core — @tachu/core"
110
- C[Protocol Definitions / 9-Phase Pipeline / Lifecycle Hooks / Session / Memory / Safety / Model Router / Runtime State]
111
- end
112
- A --> B
113
- B --> C
114
- ```
103
+ ## Architecture (summary)
115
104
 
116
- | Layer | Package | Responsibility |
117
- |-------|---------|----------------|
118
- | Engine Core | `@tachu/core` | Protocol interfaces, 9-phase pipeline skeleton, 8 core modules, Registry, Prompt assembler, VectorStore interface + built-in light implementation |
119
- | Extensions Library | `@tachu/extensions` | Official concrete implementations: Provider adapters, Tools, Backends, VectorStore adapters, OTel/JSONL emitters, common Rules |
120
- | Business / CLI | `@tachu/cli` or your code | Assembles core + extensions into a working Agent; provides domain Rules/Skills/Tools/Agents |
121
-
122
- ### 9-Phase Execution Pipeline
123
-
124
- Every request processed by the engine flows through exactly 9 phases:
125
-
126
- ```mermaid
127
- graph TD
128
- Start([Business Request]) --> S1[Phase 1: Session Management]
129
- S1 --> S2[Phase 2: Minimum Safety Check]
130
- S2 --> S3[Phase 3: Intent Analysis — LLM]
131
- S3 -- simple --> S9[Phase 9: Output Normalization]
132
- S3 -- complex --> S4[Phase 4: Pre-Check]
133
- S4 --> S5[Phase 5: Task Planning]
134
- S5 -- Plan mode --> PlanLoop{Plan Review Loop}
135
- S5 -- Template match --> S6
136
- S5 -- Dynamic split --> S6[Phase 6: DAG Validation]
137
- PlanLoop -- confirmed --> S6
138
- S6 --> S7[Phase 7: Sub-task Execution]
139
- S7 --> S8[Phase 8: Result Validation — LLM]
140
- S8 -- pass --> S9
141
- S8 -- fail --> Retry{Retry / Re-plan}
142
- Retry -- within limits --> S5
143
- Retry -- exhausted --> S9
144
- S9 --> End([Output])
145
-
146
- style S2 fill:#ffeaa7,stroke:#fdcb6e
147
- style S7 fill:#dfe6e9,stroke:#b2bec3
148
- ```
105
+ Requests flow through a **9-phase pipeline**. Complex tool work enters the built-in `tool-use` loop in Phase 7.
149
106
 
150
- | # | Phase | LLM Call | Key Output |
151
- |---|-------|----------|------------|
152
- | 1 | Session Management | No | Session context loaded |
153
- | 2 | Minimum Safety Check | No | Pass / reject |
154
- | 3 | Intent Analysis | **Yes** | `IntentResult` (simple/complex, context relevance) |
155
- | 4 | Pre-Check | No | Resource availability, deep safety validation |
156
- | 5 | Task Planning | **Yes** | `PlanningResult` (ranked plans + DAG) |
157
- | 6 | DAG Validation | No | Cycle detection, node integrity (deterministic) |
158
- | 7 | Sub-task Execution | Per sub-task | `TaskResult[]` (parallel where possible) |
159
- | 8 | Result Validation | **Yes** | `ValidationResult` (pass / execution_issue / planning_issue) |
160
- | 9 | Output Normalization | No | `EngineOutput` (typed, with steps, metadata, artifacts) |
161
-
162
- **Key pipeline properties:**
163
-
164
- - **Full-path safety gating** — Phase 2 runs on every request, including fast-path simple responses
165
- - **Context guard** — Phase 3 decides whether session history is relevant; irrelevant history is not forwarded
166
- - **Three-strikes limit** — Task-level retries are bounded at 3 (configurable); system-level retries at 2
167
- - **Last-message-wins** — A new request on the same session cancels the current execution via `AbortController`
107
+ Details: [Pipeline phases](./docs/architecture/pipeline-phases.md) · [Overview design](./docs/overview-design.md).
168
108
 
169
109
  ---
170
110
 
@@ -172,21 +112,23 @@ graph TD
172
112
 
173
113
  Tachu requires [Bun](https://bun.sh) as the runtime.
174
114
 
115
+ > **Install via the `@rc` dist-tag** (or an exact version) until Tachu reaches stable.
116
+
175
117
  ```bash
176
118
  # Install the engine core
177
- bun add @tachu/core
119
+ bun add @tachu/core@rc
178
120
 
179
121
  # Install the extensions library (providers, tools, backends, vector stores)
180
- bun add @tachu/extensions
122
+ bun add @tachu/extensions@rc
181
123
 
182
124
  # Install and use the CLI globally
183
- bun add -g @tachu/cli
125
+ bun add -g @tachu/cli@rc
184
126
  ```
185
127
 
186
128
  After global installation, verify with:
187
129
 
188
130
  ```bash
189
- tachu --version
131
+ tachu --version # expect 1.0.0-rc.0 or newer
190
132
  ```
191
133
 
192
134
  ---
@@ -212,608 +154,41 @@ tachu chat
212
154
  tachu chat --resume
213
155
  ```
214
156
 
215
- ### Programmatic (TypeScript)
216
-
217
- ```typescript
218
- import { Engine } from '@tachu/core';
219
- import { OpenAIProviderAdapter } from '@tachu/extensions/providers';
220
- import { FileBackend, TerminalBackend } from '@tachu/extensions/backends';
221
- import type { EngineConfig, InputEnvelope, ExecutionContext } from '@tachu/core';
222
-
223
- const config: EngineConfig = {
224
- retry: { taskMaxRetries: 3, systemMaxRetries: 2 },
225
- planning: { planCount: 1, enableValidation: true },
226
- agent: { maxNestingDepth: 1 },
227
- context: { maxTokens: 8000, compressionThreshold: 0.8 },
228
- execution: { defaultTimeout: 120_000 },
229
- models: {
230
- capabilityMapping: {
231
- 'high-reasoning': 'gpt-4o',
232
- 'fast-cheap': 'gpt-4o-mini',
233
- },
234
- providerFallbackOrder: ['openai'],
235
- },
236
- safety: { maxInputSize: 1_000_000, maxRecursionDepth: 10 },
237
- hooks: { writeHookTimeout: 5000, failureBehavior: 'continue' },
238
- storage: {},
239
- };
240
-
241
- const engine = new Engine(config);
242
-
243
- // Register a provider
244
- engine.useProvider(new OpenAIProviderAdapter({ apiKey: process.env.OPENAI_API_KEY! }));
245
-
246
- // Stream results
247
- const input: InputEnvelope = {
248
- content: 'Write a TypeScript function that debounces async operations',
249
- metadata: { modality: 'text' },
250
- };
251
-
252
- const context: ExecutionContext = {
253
- requestId: crypto.randomUUID(),
254
- sessionId: 'session-001',
255
- traceId: crypto.randomUUID(),
256
- principal: { userId: 'user-001' },
257
- budget: { maxTokens: 20_000, maxDurationMs: 60_000 },
258
- scopes: ['read', 'write'],
259
- };
260
-
261
- for await (const chunk of engine.runStream(input, context)) {
262
- if (chunk.type === 'delta') process.stdout.write(chunk.content);
263
- if (chunk.type === 'done') console.log('\n\nCompleted:', chunk.output.status);
264
- }
265
- ```
266
-
267
- ---
268
-
269
- ## Package Layout
270
-
271
- ### Package Summary
272
-
273
- | Package | Description | Key Exports |
274
- |---------|-------------|-------------|
275
- | `@tachu/core` | Zero-dependency engine core | `Engine`, `Registry`, `PromptAssembler`, all interfaces and types |
276
- | `@tachu/extensions` | Official implementations | `OpenAIProviderAdapter`, `AnthropicProviderAdapter`, `McpToolAdapter`, `QdrantVectorStore`, `OtelEmitter`, backends, tools, rules |
277
- | `@tachu/cli` | Production CLI program | `tachu chat`, `tachu run`, `tachu init` |
278
-
279
- ### Dependency Relationship
280
-
281
- ```mermaid
282
- graph LR
283
- cli["@tachu/cli"]
284
- extensions["@tachu/extensions"]
285
- core["@tachu/core"]
286
-
287
- cli --> extensions
288
- cli --> core
289
- extensions --> core
290
-
291
- style core fill:#74b9ff,stroke:#0984e3
292
- style extensions fill:#a29bfe,stroke:#6c5ce7
293
- style cli fill:#fd79a8,stroke:#e84393
294
- ```
295
-
296
- ### Core Package Internal Structure
297
-
298
- ```
299
- @tachu/core / src/
300
- ├── types/ # All TypeScript interfaces: descriptors, context, I/O, config
301
- ├── engine/ # Engine entry class, phase handlers, orchestrator, scheduler
302
- ├── registry/ # Registry: register/lookup/startup validation for all 4 abstractions
303
- ├── modules/ # 8 core modules (session, memory, runtime-state, model-router,
304
- │ # provider, safety, observability, hooks)
305
- ├── prompt/ # PromptAssembler: token budgeting, KV-cache-friendly ordering
306
- └── vector/ # VectorStore interface + built-in lightweight implementation
307
- ```
308
-
309
- ---
310
-
311
- ## Providers & Integrations
312
-
313
- ### LLM Providers
314
-
315
- | Provider | Package | Streaming | Function Calling | Notes |
316
- |----------|---------|-----------|-----------------|-------|
317
- | OpenAI | `@tachu/extensions/providers` | ✅ | ✅ | GPT-4o, GPT-4o-mini, and all listable models |
318
- | Anthropic | `@tachu/extensions/providers` | ✅ | ✅ | Claude 3.5 Sonnet and all listable models |
319
- | Mock | `@tachu/extensions/providers` | ✅ | ✅ | For testing; configurable responses |
320
-
321
- Provider fallback is configured via `models.providerFallbackOrder`. When a system-level error occurs (timeout, API error), the engine automatically switches to the next provider in the list without re-planning.
322
-
323
- ### MCP (Model Context Protocol)
324
-
325
- ```typescript
326
- import { McpToolAdapter } from '@tachu/extensions/mcp';
327
-
328
- const adapter = new McpToolAdapter();
329
-
330
- // Connect via stdio (local process)
331
- await adapter.connect('stdio://path/to/mcp-server');
332
-
333
- // Connect via SSE (remote server)
334
- await adapter.connect('http://localhost:3000/sse');
335
-
336
- // MCP tools are automatically registered in the engine Registry
337
- const tools = await adapter.listTools(); // returns ToolDescriptor[]
338
- engine.registry.registerAll(tools);
339
- ```
340
-
341
- The `McpToolAdapter` handles MCP session lifecycle, capability negotiation, and propagates engine cancellation signals to the MCP server.
342
-
343
- ### Vector Stores
344
-
345
- | Adapter | Package | Use Case |
346
- |---------|---------|----------|
347
- | `InMemoryVectorStore` | `@tachu/core` | Development / testing; built-in, zero dependencies |
348
- | `LocalFsVectorStore` | `@tachu/extensions/vector` | Single-process production; file-backed persistence |
349
- | `QdrantVectorStore` | `@tachu/extensions/vector` | Multi-process production; full Qdrant REST API support |
350
-
351
- ```typescript
352
- import { QdrantVectorStore } from '@tachu/extensions/vector';
353
-
354
- const vectorStore = new QdrantVectorStore({
355
- url: 'http://localhost:6333',
356
- collectionName: 'tachu-descriptors',
357
- });
358
-
359
- engine.useVectorStore(vectorStore);
360
- ```
361
-
362
- ### Observability Emitters
363
-
364
- | Emitter | Package | Output |
365
- |---------|---------|--------|
366
- | `OtelEmitter` | `@tachu/extensions/emitters` | OpenTelemetry spans via `@opentelemetry/api` |
367
- | `JsonlEmitter` | `@tachu/extensions/emitters` | Append-only JSONL file |
368
- | `ConsoleEmitter` | `@tachu/extensions/emitters` | Structured console output (development) |
369
-
370
- ### Execution Backends
371
-
372
- | Backend | Package | Description |
373
- |---------|---------|-------------|
374
- | `TerminalBackend` | `@tachu/extensions/backends` | Shell command execution in a sandboxed terminal |
375
- | `FileBackend` | `@tachu/extensions/backends` | File system read/write operations |
376
- | `WebBackend` | `@tachu/extensions/backends` | HTTP requests to external APIs / web resources |
377
-
378
- ---
379
-
380
- ## Design Principles
381
-
382
- Tachu is built on seven core engineering principles drawn from its architecture:
383
-
384
- 1. **Dual-Plane Matching** — All four core abstractions are discovered semantically (vector similarity) but activated deterministically (scopes, whitelist, approval). Semantic discovery is advisory; execution gates are authoritative.
385
-
386
- 2. **Full-Path Safety Gating** — The minimum safety check (Phase 2) runs on *every* request path, including the fast path for simple questions. Safety is never traded for performance.
387
-
388
- 3. **Three-Strikes Retry Limit** — Both the task-level retry loop and the system-level retry loop are strictly bounded. Unlimited retry is not allowed. When limits are exhausted, the engine outputs step-level completion status rather than a generic failure.
389
-
390
- 4. **KV-Cache-Friendly Prompt Assembly** — The System Prompt is assembled in a stable order (hard rules → soft preferences → skills → tool definitions) so that the prefix remains unchanged across turns, maximizing KV cache reuse and reducing LLM cost.
391
-
392
- 5. **Last-Message-Wins Cancellation** — When a new message arrives in the same session, the current execution is cancelled via `AbortController` and the new input is processed in the existing context. This guarantees coherent context while avoiding stale work.
393
-
394
- 6. **Engine Agnostic of Business Permissions** — The engine only evaluates coarse-grained `scopes` from the execution context at the Tool gate. Fine-grained business authorization is the responsibility of Tool implementations or dedicated authorization Tools.
395
-
396
- 7. **Fail-Closed Safety Baseline** — Loop protection, budget circuit-breaking, and basic input validation are hardwired into the engine core and *cannot* be disabled by configuration. Even with a completely empty business configuration, the engine does not run unconstrained.
397
-
398
- ---
399
-
400
- ## Configuration
401
-
402
- The engine is configured via a `tachu.config.ts` file at the project root (generated by `tachu init`):
403
-
404
- ```typescript
405
- import type { EngineConfig } from '@tachu/core';
406
-
407
- const config: EngineConfig = {
408
- // Descriptor registry
409
- registry: {
410
- descriptorRoot: '.tachu', // root directory for Rules/Skills/Tools/Agents
411
- },
412
-
413
- // Runtime behaviour
414
- runtime: {
415
- planMode: false, // enable Plan mode by default
416
- maxConcurrency: 4, // max parallel sub-tasks
417
- },
418
-
419
- // Context window & memory
420
- memory: {
421
- maxTokens: 8000, // context window token limit
422
- compressionThreshold: 0.8, // trigger compression at 80% capacity
423
- archivePath: '.tachu/archive.jsonl',
424
- vectorIndexLimit: 10000, // max entries in the built-in vector index
425
- },
426
-
427
- // Budget constraints
428
- budget: {
429
- maxTokens: 50000, // total token budget per execution
430
- maxToolCalls: 50, // max tool calls per execution
431
- maxWallTimeMs: 300000, // 5 minutes wall-time limit
432
- },
433
-
434
- // Safety baseline (hardwired minimum; add business policies via hooks)
435
- safety: {
436
- maxInputSize: 1_000_000, // bytes
437
- maxRecursionDepth: 10,
438
- enablePromptInjectionCheck: true,
439
- },
440
-
441
- // Model routing
442
- models: {
443
- capabilityMapping: {
444
- 'high-reasoning': { provider: 'openai', model: 'gpt-4o' },
445
- 'fast-cheap': { provider: 'openai', model: 'gpt-4o-mini' },
446
- 'vision': { provider: 'openai', model: 'gpt-4o' },
447
- },
448
- providerFallbackOrder: ['openai', 'anthropic'],
449
- },
450
-
451
- // Observability
452
- observability: {
453
- emitter: 'jsonl',
454
- jsonlPath: '.tachu/events.jsonl',
455
- },
456
- };
457
-
458
- export default config;
459
- ```
460
-
461
- All fields have sensible defaults. `tachu init` generates this file pre-filled for your chosen provider.
462
-
463
- ---
464
-
465
- ## CLI Reference
466
-
467
- ### `tachu init`
468
157
 
469
- Initialize a new Tachu project workspace.
470
-
471
- ```
472
- tachu init [options]
473
-
474
- Options:
475
- --template <name> Scaffold template: minimal | full (default: minimal)
476
- --force Overwrite existing files without prompting
477
- --path <dir> Target directory (default: CWD)
478
- --provider <name> Default provider: openai | anthropic | mock (default: mock)
479
- --no-examples Skip generating example rule/tool descriptors
480
- -h, --help Show help
481
- ```
482
-
483
- Generates `.tachu/` directory skeleton + `tachu.config.ts` + `.gitignore` entries.
158
+ Programmatic embedding: see [Configuration](./docs/guides/configuration.md) and `@tachu/host-defaults`.
484
159
 
485
160
  ---
486
161
 
487
- ### `tachu run <prompt>`
488
-
489
- Execute a single prompt and stream the result to stdout.
490
-
491
- ```
492
- tachu run <prompt> [options]
493
-
494
- Arguments:
495
- <prompt> The prompt text (or pipe via stdin)
496
-
497
- Options:
498
- --session <id> Use a specific session ID
499
- --resume Resume the most recent session
500
- --model <name> Override the high-reasoning model
501
- --provider <name> Override the default provider
502
- --input <file> Read prompt from a file
503
- --json Parse prompt as JSON (structured input)
504
- --output <fmt> Output format: text | json | markdown (default: text)
505
- --no-validation Skip Phase 8 result validation
506
- --plan-mode Enable Plan mode (pause after Phase 5 for approval)
507
- --verbose, -v Verbose output (phase transitions, LLM call details)
508
- --no-color Disable ANSI color output (also respects NO_COLOR env var)
509
- --timeout <ms> Wall-time limit (overrides budget.maxWallTimeMs)
510
- -h, --help Show help
511
- ```
512
-
513
- ---
514
-
515
- ### `tachu chat`
516
-
517
- Start an interactive multi-turn chat session.
518
-
519
- ```
520
- tachu chat [options]
521
-
522
- Options:
523
- --session <id> Use a specific session ID
524
- --resume Resume the most recent session
525
- --history List all sessions and exit (no interactive prompt)
526
- --export <file> Export a session to Markdown and exit
527
- --model <name> Override the high-reasoning model
528
- --provider <name> Override the default provider
529
- --plan-mode Enable Plan mode
530
- --verbose, -v Verbose output
531
- --no-color Disable color output
532
- -h, --help Show help
533
- ```
534
-
535
- **Built-in interactive commands** (prefix with `/`):
536
-
537
- | Command | Description |
538
- |---------|-------------|
539
- | `/exit` | Save session and quit |
540
- | `/reset` | Clear the current session's memory |
541
- | `/new` | Start a new session |
542
- | `/list` | List all saved sessions |
543
- | `/load <id>` | Switch to a specific session |
544
- | `/save` | Manually persist the current session |
545
- | `/export <path>` | Export session to a Markdown file |
546
- | `/history` | Show this session's message history |
547
- | `/stats` | Show token usage, tool calls, and remaining budget |
548
- | `/help` | Show all commands |
549
-
550
- **Ctrl+C behaviour:**
551
- - First press: cancel the current LLM/Tool call (return to prompt, session intact)
552
- - Second press within 1 second: save session and exit gracefully
553
- - Third press: force exit
554
-
555
- ---
556
-
557
- ## Extension Guide
558
-
559
- Tachu is extended by creating Markdown descriptor files in the `.tachu/` directory. No code changes are required for Rules, Skills, and Tools — only Agents need executable functions registered separately.
560
-
561
- ### Custom Rule
562
-
563
- ```markdown
564
- <!-- .tachu/rules/no-external-calls.md -->
565
- ---
566
- name: no-external-calls
567
- description: Prevent the agent from making external network calls without explicit approval
568
- type: rule
569
- scope: [execution]
570
- tags: [security, network]
571
- ---
572
-
573
- Do not make HTTP requests, DNS lookups, or any other external network calls unless
574
- the tool being invoked has `requiresApproval: true` and the user has confirmed.
575
- ```
576
-
577
- ### Custom Skill
578
-
579
- ```markdown
580
- <!-- .tachu/skills/git-workflow/SKILL.md -->
581
- ---
582
- name: git-workflow
583
- description: Git branching, commit, and PR workflow knowledge for this repository
584
- tags: [development, git]
585
- requires:
586
- - { kind: tool, name: run-command }
587
- ---
588
-
589
- ## Git Workflow
590
-
591
- This repository follows trunk-based development with short-lived feature branches.
592
-
593
- ### Branch Naming
594
- - Feature: `feat/<ticket>-<short-desc>`
595
- - Fix: `fix/<ticket>-<short-desc>`
596
-
597
- ### Commit Convention
598
- Use Conventional Commits: `type(scope): subject`
599
- ...
600
- ```
601
-
602
- ### Custom Tool
603
-
604
- ```markdown
605
- <!-- .tachu/tools/query-db.md -->
606
- ---
607
- name: query-db
608
- description: Execute a read-only SQL query against the application database
609
- sideEffect: readonly
610
- idempotent: true
611
- requiresApproval: false
612
- timeout: 10000
613
- inputSchema:
614
- type: object
615
- properties:
616
- sql: { type: string, description: "SQL SELECT statement" }
617
- limit: { type: number, description: "Max rows to return", default: 100 }
618
- required: [sql]
619
- execute: queryDatabase
620
- ---
621
-
622
- Executes a parameterized read-only SQL query. Results are returned as a JSON array.
623
- ```
624
-
625
- Register the execution function in your `engine-factory.ts`:
626
-
627
- ```typescript
628
- engine.registry.registerExecutor('queryDatabase', async (input, ctx) => {
629
- const { sql, limit = 100 } = input as { sql: string; limit?: number };
630
- return db.query(sql).limit(limit).execute();
631
- });
632
- ```
633
-
634
- ### Custom Agent
635
-
636
- ```markdown
637
- <!-- .tachu/agents/code-reviewer.md -->
638
- ---
639
- name: code-reviewer
640
- description: Reviews pull request diffs and produces structured code review feedback
641
- sideEffect: readonly
642
- idempotent: true
643
- requiresApproval: false
644
- timeout: 180000
645
- maxDepth: 1
646
- availableTools: [read-file, search-code, run-command]
647
- ---
648
-
649
- You are a careful code reviewer. When given a diff or a set of files:
650
- 1. Understand the intent of the change
651
- 2. Review for correctness, clarity, security, and performance
652
- 3. Produce a structured review with severity levels: critical / major / minor / nit
653
- ```
654
-
655
- ---
656
-
657
- ## Observability & Safety
658
-
659
- ### OpenTelemetry Integration
660
-
661
- Every engine event maps to an OTel span, enabling full distributed tracing:
662
-
663
- ```typescript
664
- import { OtelEmitter } from '@tachu/extensions/emitters';
665
- import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
666
- import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
667
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
668
-
669
- const provider = new NodeTracerProvider();
670
- provider.addSpanProcessor(
671
- new SimpleSpanProcessor(new OTLPTraceExporter({ url: 'http://localhost:4318/v1/traces' }))
672
- );
673
- provider.register();
674
-
675
- const engine = new Engine({
676
- ...config,
677
- // The OtelEmitter consumes EngineEvents and creates OTel spans
678
- });
679
- engine.useEmitter(new OtelEmitter());
680
- ```
681
-
682
- **Events emitted for every request:**
683
-
684
- | Event Type | When |
685
- |-----------|------|
686
- | `phase_enter` / `phase_exit` | Every pipeline phase |
687
- | `llm_call_start` / `llm_call_end` | Every LLM invocation |
688
- | `tool_call_start` / `tool_call_end` | Every Tool execution |
689
- | `retry` | Task-level or system-level retry triggered |
690
- | `provider_fallback` | Provider downgrade initiated |
691
- | `budget_warning` | Budget at 80% of limit |
692
- | `budget_exhausted` | Budget circuit-breaker activated |
693
- | `error` | Any `EngineError` subclass |
694
-
695
- ### Safety Module
696
-
697
- The Safety module operates in two independent layers:
698
-
699
- **Engine baseline (non-disableable):**
700
- - Input size enforcement (`maxInputSize` bytes)
701
- - Recursion depth limit (`maxRecursionDepth`)
702
- - Budget circuit-breaker (terminates immediately when token/time budget is exhausted)
703
-
704
- **Business-injectable policies** (via hooks or configuration):
705
- - Prompt injection detection (`enablePromptInjectionCheck: true`)
706
- - Sensitive operation interception (register via `engine.registerSafetyPolicy()`)
707
- - Output content compliance checks
708
-
709
- ```typescript
710
- // Register a custom safety policy
711
- engine.registerSafetyPolicy(async (input, ctx) => {
712
- if (containsPersonalData(input.content)) {
713
- return { passed: false, violations: [{ type: 'pii', message: 'PII detected in input' }] };
714
- }
715
- return { passed: true, violations: [] };
716
- });
717
- ```
718
-
719
- ---
720
-
721
- ## Roadmap
722
-
723
- ### v1.0.0 — Delivered
724
-
725
- - [x] `@tachu/core`: Engine, 9-phase pipeline, 8 modules, Registry, PromptAssembler, InMemoryVectorStore, full error taxonomy
726
- - [x] `@tachu/extensions`: OpenAI + Anthropic providers, 7 tools, Terminal/File/Web backends, LocalFs + Qdrant VectorStore, MCP stdio+SSE adapters, OTel+JSONL emitters, 4 common rules
727
- - [x] `@tachu/cli`: `tachu init` / `tachu run` / `tachu chat` with full parameter sets, session persistence, streaming renderer
728
- - [x] Test suite (≥80% line coverage) and performance benchmarks
729
- - [x] English and Chinese READMEs
730
-
731
- ### v1.x — Planned
732
-
733
- - Additional VectorStore adapters (Pinecone, pgvector)
734
- - Additional Provider adapters (Google Gemini, Mistral)
735
- - Additional MCP tool integrations
736
- - More built-in compression strategies
737
- - Structured Plan template library
738
-
739
- ### v2 — Vision
162
+ ## Documentation
740
163
 
741
- - Multi-agent collaboration (agent-to-agent communication protocol)
742
- - Persistent long-term memory across deployment restarts
743
- - Fine-grained budget allocation per sub-task
164
+ | Document | Description |
165
+ |----------|-------------|
166
+ | [Overview Design](./docs/overview-design.md) | Vision, layers, abstractions, pipeline concepts |
167
+ | [Detailed Design](./docs/detailed-design.md) | Types, modules, configuration schema |
168
+ | [Technical Design](./docs/technical-design.md) | Engineering structure and implementation guide |
169
+ | [Pipeline phases](./docs/architecture/pipeline-phases.md) | 9-phase pipeline and tool-use loop |
170
+ | [Package layout](./docs/architecture/package-layout.md) | Monorepo packages and dependencies |
171
+ | [Design principles](./docs/architecture/design-principles.md) | Core engineering principles |
172
+ | [CLI reference](./docs/guides/cli.md) | All commands and flags |
173
+ | [Configuration](./docs/guides/configuration.md) | `tachu.config.ts` / `EngineConfig` |
174
+ | [Providers & integrations](./docs/guides/providers-and-integrations.md) | LLM, MCP, vector stores |
175
+ | [Extension guide](./docs/guides/extension-guide.md) | Rules, Skills, Tools, Agents |
176
+ | [Observability & safety](./docs/guides/observability-and-safety.md) | OTel, events, safety |
177
+ | [CONTEXT.md](./CONTEXT.md) | Product vocabulary |
178
+ | [CONTRIBUTING.md](./CONTRIBUTING.md) | Development workflow |
179
+ | [Web Fetch Server](./packages/web-fetch-server/README.md) | Optional browser sidecar |
744
180
 
745
181
  ---
746
182
 
747
- ## Contributing
748
-
749
- ### Requirements
750
-
751
- - [Bun](https://bun.sh) >= 1.1.0
752
- - TypeScript 5.x (provided via dev dependencies)
183
+ ## Web Fetch Server (optional)
753
184
 
754
- ### Development Workflow
185
+ For browser-backed `web-fetch` / `web-search`, run the private sidecar — see [packages/web-fetch-server/README.md](./packages/web-fetch-server/README.md).
755
186
 
756
187
  ```bash
757
- # Clone and install
758
- git clone https://github.com/dangaogit/tachu
759
- cd tachu
760
- bun install
761
-
762
- # Run all tests
763
- bun test
764
-
765
- # Type check
766
- bun run typecheck
767
-
768
- # Build all packages
769
- bun run build
770
-
771
- # Run a specific package's tests
772
- bun test --filter packages/core
188
+ bun run dev:server:install-browser
189
+ bun run dev:server
773
190
  ```
774
191
 
775
- ### Project Conventions
776
-
777
- - File names: `kebab-case`
778
- - Classes and types: `PascalCase`
779
- - Functions and variables: `camelCase`
780
- - Constants: `SCREAMING_SNAKE_CASE`
781
- - All public APIs must have TSDoc comments (`@param`, `@returns`, `@throws`, `@example`)
782
- - Test files co-located with source: `*.test.ts`
783
- - Integration tests under `__tests__/`
784
-
785
- Pull requests require:
786
- - All tests passing (`bun test`)
787
- - Zero TypeScript errors (`bun run typecheck`)
788
- - Coverage thresholds met (≥80% line, ≥70% branch)
789
- - TSDoc on any new public API
790
-
791
- See `CONTRIBUTING.md` for full guidelines.
792
-
793
- ---
794
-
795
- ## Benchmarks
796
-
797
- Performance baselines are established in `packages/core/benchmarks/` and run with `bun test`:
798
-
799
- | Benchmark | Metric | Baseline |
800
- |-----------|--------|----------|
801
- | `scheduler.bench.ts` — 100 parallel tasks | Scheduling throughput | *Populated by verifier phase* |
802
- | `vector-store.bench.ts` — 10,000 entries, topK=10 | Search QPS | *Populated by verifier phase* |
803
- | `prompt-assembler.bench.ts` — 4K token window assembly | Assembly latency (p99) | *Populated by verifier phase* |
804
-
805
- Benchmarks serve as regression baselines; there are no minimum performance requirements for v1.
806
-
807
- ---
808
-
809
- ## Documentation
810
-
811
- | Document | Description |
812
- |----------|-------------|
813
- | [Architecture Design](./docs/adr/architecture-design.md) | Vision, three-layer structure, four core abstractions, 9-phase pipeline design |
814
- | [Detailed Design](./docs/adr/detailed-design.md) | TypeScript interfaces, module specs, configuration schema |
815
- | [Technical Design](./docs/adr/technical-design.md) | Technology choices, engineering structure, implementation guide |
816
-
817
192
  ---
818
193
 
819
194
  ## License