From 0d631cca2651fef12e3995eb7cd51ec2b8152ea4 Mon Sep 17 00:00:00 2001 From: Gen TANG Date: Mon, 3 Aug 2026 13:58:54 +0800 Subject: [PATCH 1/4] update readme --- README-cn.md | 61 +++++++++++ README.md | 279 +++++++-------------------------------------------- 2 files changed, 97 insertions(+), 243 deletions(-) create mode 100644 README-cn.md diff --git a/README-cn.md b/README-cn.md new file mode 100644 index 0000000..72f2c70 --- /dev/null +++ b/README-cn.md @@ -0,0 +1,61 @@ +# Yada + +**Yet Another DeepSeek Agent** 是一个为 DeepSeek V4 构建的小型、可审计 +Coding Agent Harness。给它一个任务和一个 Git 仓库,Yada 会检查代码、应用经过 +校验的 Patch、运行验证,并记录完整执行轨迹。 + +[English README](README.md) + +> 只想使用 Yada?直接阅读下面的**快速开始**。想贡献代码?请从 +> [CONTRIBUTING.md](CONTRIBUTING.md) 和[开发者文档](docs/dev/architecture.md) +> 开始。 + +Yada 目前处于 Alpha 阶段。仓库已经测试本地 Agent 闭环,但尚未宣称任何对比 +评测结果。 + +## 运行条件 + +- Python 3.11+ +- Git +- [uv](https://docs.astral.sh/uv/)(推荐) +- DeepSeek API Key + +## 快速开始 + +```bash +git clone https://github.com/GenTang/Yada.git +cd Yada +uv sync --locked --dev + +export DEEPSEEK_API_KEY="sk-..." + +uv run yada "修复 parser 的边界问题,并运行相关测试" \ + --workspace /path/to/repository +``` + +Yada 默认会在运行仓库命令前请求确认。只有在可信、一次性的隔离环境中才应使用 +`--yes`: + +```bash +uv run yada --task-file issue.md --workspace /workspace --yes +``` + +## 运行时会发生什么 + +Yada 会打印每轮 DeepSeek 调用和工具执行,最后报告任务是否通过验证门槛。默认 +Trace 保存在目标仓库的 `.yada/runs/` 目录下。 + +仓库测试可以执行任意代码。Yada 提供 Guardrail,但不是完整的操作系统沙箱; +处理陌生项目时请使用一次性 VM 或容器。 + +## 更多文档 + +- [配置](docs/configuration.md):其他安装方式、API Key、模型参数、命令策略和 + Trace Level。 +- [CLI 参考](docs/cli-reference.md):`yada`、`yada eval` 和 `yada-trace`。 +- [贡献指南](CONTRIBUTING.md):开发环境、验证命令和基于 Rebase 的 PR 流程。 +- [架构](docs/dev/architecture.md):Agent 循环、工具、Patch 事务、评测边界与 + 安全不变量。 +- [调试](docs/dev/debugging.md):测试、Trace 检查与可复现 Issue。 + +Yada 使用 [MIT License](LICENSE)。 diff --git a/README.md b/README.md index f1cfc3a..8f5802e 100644 --- a/README.md +++ b/README.md @@ -1,271 +1,64 @@ # Yada -**Yet Another DeepSeek Agent** — a small, auditable coding-agent harness built -specifically for DeepSeek V4. +**Yet Another DeepSeek Agent** is a small, auditable coding-agent harness built +for DeepSeek V4. Give it a task and a Git repository; Yada inspects the code, +applies a checked patch, runs verification, and records a trace of the run. -[中文说明](README.zh-CN.md) +[中文说明](README-cn.md) -Yada is deliberately narrow: one agent loop, separate planning and execution -boundaries, one append-only conversation, five tools, version-checked patches, -and a verification gate. The runtime has no third-party Python dependencies. -Development checks use Ruff and pytest. +> Just want to use Yada? Follow **Quick start** below. Want to contribute? +> Start with [CONTRIBUTING.md](CONTRIBUTING.md) and the +> [developer docs](docs/dev/architecture.md). -> Alpha status: the offline agent loop is tested, but no comparative benchmark -> result is claimed yet. +Yada is currently alpha software. The local agent loop is tested, but the +project does not claim a comparative benchmark result yet. -## Generic evaluation +## Requirements -Yada includes a benchmark-neutral evaluation layer. `EvalRunner` composes any -`BenchmarkAdapter` with any `AgentAdapter`; the initial adapters cover local -JSON manifests, SWE-bench, native Yada, and arbitrary external commands. - -The repository includes one portable SWE-bench Verified development case. Its -first run fetches the exact pytest commit and creates a locked Python 3.9 task -environment; later runs reuse those caches while keeping each agent workspace -fresh: - -```bash -uv run yada eval \ - --case benchmarks/swebench_verified/pytest-10051 \ - --agent yada \ - --yes -``` - -This produces a real local verdict from one FAIL_TO_PASS and 15 PASS_TO_PASS -tests, but it is not an official Docker score. The checkout lives under -`.yada/cache/evals/`; the task recipe and its own `uv.lock` are committed. - -For SWE-bench, Yada produces the patch and official `predictions.jsonl` while -delegating the verdict to the Docker-based `swebench.harness.run_evaluation`. -See [docs/evaluation.md](docs/evaluation.md) for manifests, external-agent -templates, Docker prerequisites, and fair-comparison constraints. - -## Why this exists - -General-purpose harnesses can run DeepSeek, but they are not necessarily shaped -around DeepSeek's tool-use and context behavior. Yada is a compact research -vehicle for testing model-native harness ideas with reproducible trajectories -and ablations. - -The current hypotheses are: - -1. A tiny, stable tool schema reduces tool-call failures. -2. SHA-bound unified diffs prevent stale and ambiguous edits. -3. Structured, bounded command observations improve recovery after test failures. -4. An append-only conversation preserves DeepSeek prefix-cache opportunities. +- Python 3.11+ +- Git +- [uv](https://docs.astral.sh/uv/) (recommended) +- A DeepSeek API key ## Quick start -Requirements: Python 3.11+, Git, and a DeepSeek API key. - -The recommended workflow uses [uv](https://docs.astral.sh/uv/): - ```bash +git clone https://github.com/GenTang/Yada.git cd Yada uv sync --locked --dev -export DEEPSEEK_API_KEY="sk-..." - -uv run yada "Fix the failing parser edge case and run the relevant tests" \ - --workspace /path/to/repository -``` - -The package also works with standard library tooling and pip: -```bash -cd Yada -python3 -m venv .venv -.venv/bin/python -m pip install -e . export DEEPSEEK_API_KEY="sk-..." -yada "Fix the failing parser edge case and run the relevant tests" \ +uv run yada "Fix the failing parser edge case and run the relevant tests" \ --workspace /path/to/repository ``` -Yada asks before every repository command by default. For autonomous execution -inside a disposable sandbox: - -```bash -yada "Fix the issue described in issue.md" \ - --workspace /workspace \ - --yes -``` - -You can also pass a task file: - -```bash -yada --task-file issue.md --workspace . -``` - -The default model is `deepseek-v4-pro`, thinking is enabled, and reasoning -effort is `max`. These can be changed with `--model`, `--no-thinking`, and -`--reasoning-effort`. - -## Docker - -The container limits filesystem exposure to the mounted repository. It is not a -network sandbox. +Yada asks before running repository commands. Use `--yes` only inside a trusted, +disposable environment: ```bash -docker build -t yada . -docker run --rm -it \ - -e DEEPSEEK_API_KEY \ - -v "/path/to/repository:/workspace" \ - yada "Fix the failing test" --workspace /workspace --yes +uv run yada --task-file issue.md --workspace /workspace --yes ``` -## The loop - -```text -stable prompt + tool schema - ↓ -DeepSeek tool call - ↓ -validate → approve → execute - ↓ -bounded structured observation - ↓ -append and repeat - ↓ -finish only after post-patch verification -``` - -Tools: - -- `search_code`: ripgrep-backed repository search, with a Python fallback. -- `read_file`: bounded numbered reads plus SHA-256. -- `apply_patch`: Git-style unified diffs checked against every file hash. -- `run_command`: argv-only command execution with an allowlist and approval gate. -- `finish`: rejected until a test or build succeeds after the latest patch. - -DeepSeek thinking-mode `reasoning_content` is retained in memory and passed back -after tool calls, as required by the API. The default `--trace-level summary` -records compact context metrics. `--trace-level debug` additionally records the -complete sanitized provider payload and reasoning text for every model turn. -Summary traces replace reasoning with its length and hash. Both levels redact -common API keys, authorization values, tokens, passwords, and secrets. Debug -traces contain sensitive model context and must be handled accordingly. - -Capture a replayable debug trace during an evaluation: - -```bash -uv run yada eval \ - --case benchmarks/swebench_verified/pytest-10051 \ - --agent yada \ - --yes \ - --trace-level debug -``` - -Inspect a completed or interrupted run without manually scanning JSONL: - -```bash -uv run yada-trace \ - .yada/runs/fix-parser-edge-case__2026-08-02_20-26.jsonl -uv run yada-trace \ - eval-results/pytest-dev__pytest-10051__2026-08-02_20-26.artifacts/yada-trace.jsonl \ - --step 8 -uv run yada-trace eval-results/__.artifacts/yada-trace.jsonl \ - --verbose -uv run yada-trace TRACE.jsonl --events -``` - -The default report groups each model request, response, planning decision, and -ordered tool executions into one agent step. Every summary includes physical -JSONL line references so the source evidence is immediately reachable with tools -such as `sed`. `--step` and `--verbose` expand sanitized model messages, tool -arguments, patches, stdout, and stderr inside grouped steps; `--events` retains a -line-prefixed flat timeline. The source JSONL remains the durable, -streaming-friendly record. Debug traces can contain source code and test output -even after secret redaction, so handle them as sensitive artifacts. See -[docs/tracing.md](docs/tracing.md) for the event reference, field-presence -semantics, lifecycle, and `jq` recipes. - -Default trace and evaluation paths use the system-local time at minute -precision. If a name already exists, Yada appends `(1)`, `(2)`, and so on before -the file or artifacts suffix, keeping the result JSON and artifacts directory on -the same number. - -## Safety model - -Yada provides guardrails, not a complete OS sandbox: - -- File tools reject workspace escapes, symlink escapes, `.git`, and `.yada`. -- Patches reject binary, rename, copy, mode, and symlink changes. -- Commands use argv arrays rather than a shell string. -- Shell `-c` and mutating Git subcommands are rejected. -- Secret-looking environment variables, including the DeepSeek key, are removed - from child command environments. -- Command execution asks for confirmation unless `--yes` is used. - -Repository tests are arbitrary code. Run unfamiliar repositories in a disposable -VM or a stronger sandbox. The included Dockerfile reduces filesystem exposure, -but repository code can still access the container network. - -## Development checks - -The test suite includes a fully offline fake-model run through read → patch → -test → finish, plus stale hash, path escape, secret environment, and verification -gate tests. Ruff provides the repository's lint and formatting gates. - -```bash -uv sync --locked --dev -uv run --frozen ruff check . -uv run --frozen ruff format --check . -uv run --frozen pytest tests/ -v -``` - -CI runs the same checks on Python 3.11 and 3.12. Without uv, install the runtime -project with `python3 -m pip install -e .`, install `pytest` and `ruff` separately, -then run the equivalent commands. These tools remain development dependencies and -do not increase Yada's runtime dependency footprint. - -## Project layout - -Yada uses a `src/` layout and keeps orchestration separate from execution: - -```text -src/yada/ -├── agents/ # thin loop, side-effect-free planner, and tool executor -├── models/ # model protocol and DeepSeek API adapter -├── environments/ # workspace boundary and command approval -├── tools/ # one module per tool plus the small dispatcher -├── traces/ # JSONL writer plus a human-readable diagnostic report -├── evals/ # generic runner plus benchmark and agent adapters -├── run/ # CLI entry point -└── utils/ # bounded-output helpers -benchmarks/ # portable recipes; generated checkouts stay in .yada/cache -tests/ -├── agents/ -├── evals/ -├── models/ -├── tools/ -├── traces/ -└── utils/ -``` - -`Planner` owns conversation policy and validates the next action without I/O. -`Executor` owns argument parsing, workspace side effects, and correlated tool -events. `Agent` only coordinates the two. This is a deliberately small seam—not -a second model call—but it prevents the main loop from accumulating every future -planning and execution policy. - -The package boundaries follow the useful parts of mini-SWE-agent's structure, -while Yada retains its own multi-tool protocol, SHA-bound patches, command -policy, and verification gate. +## What happens next -## Design lineage +Yada prints each DeepSeek turn and tool execution, then reports whether the task +passed its verification gate. Traces are written under the target repository's +`.yada/runs/` directory by default. -Yada learns from the simplicity of -[mini-SWE-agent](https://github.com/SWE-agent/mini-swe-agent), the reproducible -trajectory discipline of [SWE-agent](https://github.com/SWE-agent/SWE-agent), -and DeepSeek's official [thinking-mode](https://api-docs.deepseek.com/guides/thinking_mode) -and [tool-call](https://api-docs.deepseek.com/guides/tool_calls) contracts. The -implementation is original and intentionally smaller than those systems. +Repository tests can execute arbitrary code. Yada provides guardrails, not a +complete OS sandbox; use a disposable VM or container for unfamiliar projects. -See [docs/architecture.md](docs/architecture.md) for the detailed contracts and -planned ablations, and [docs/tracing.md](docs/tracing.md) for the trace schema. +## Learn more -## Current non-goals +- [Configuration](docs/configuration.md): installation alternatives, API key, + model settings, command policy, and trace levels. +- [CLI reference](docs/cli-reference.md): `yada`, `yada eval`, and `yada-trace`. +- [Contributing](CONTRIBUTING.md): development setup, validation, and the rebase + pull-request workflow. +- [Architecture](docs/dev/architecture.md): agent loop, tools, patch transaction, + evaluation boundaries, and safety invariants. +- [Debugging](docs/dev/debugging.md): tests, trace inspection, and reproducible + issue reports. -No TUI, IDE plugin, MCP, skills, subagents, web search, long-term memory, model -routing, automatic commits, or benchmark leaderboard. Those features should be -earned by evaluation evidence. +Yada is licensed under the [MIT License](LICENSE). From 06d6b1048a82b3b97baa7c6601e6d9770f53f812 Mon Sep 17 00:00:00 2001 From: Gen TANG Date: Mon, 3 Aug 2026 13:59:29 +0800 Subject: [PATCH 2/4] add doc for dev --- docs/cli-reference.md | 233 +++++++++++++++++++++++++++++++++++ docs/configuration.md | 143 ++++++++++++++++++++++ docs/dev/architecture.md | 213 ++++++++++++++++++++++++++++++++ docs/dev/debugging.md | 253 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 842 insertions(+) create mode 100644 docs/cli-reference.md create mode 100644 docs/configuration.md create mode 100644 docs/dev/architecture.md create mode 100644 docs/dev/debugging.md diff --git a/docs/cli-reference.md b/docs/cli-reference.md new file mode 100644 index 0000000..cd6f6c1 --- /dev/null +++ b/docs/cli-reference.md @@ -0,0 +1,233 @@ +# CLI reference + +Yada installs two entry points: + +- `yada`: run the coding agent or an evaluation; +- `yada-trace`: inspect a JSONL execution trace. + +Examples below use `uv run`. After editable pip installation, omit `uv run`. +Run `uv run yada --help`, `uv run yada eval --help`, or +`uv run yada-trace --help` for the parser-generated reference. + +## `yada` + +```text +yada TASK [OPTIONS] +yada --task-file FILE [OPTIONS] +``` + +Provide exactly one task source. The workspace defaults to the current directory. + +```bash +uv run yada "Fix the parser boundary case and run its tests" \ + --workspace /path/to/repository + +uv run yada --task-file issue.md --workspace /path/to/repository +``` + +### Options + +| Option | Meaning | Default | +| --- | --- | --- | +| `TASK` | Natural-language coding task. | — | +| `--task-file PATH` | Read the task from a UTF-8 file. | — | +| `--workspace PATH` | Target Git workspace. | Current directory | +| `--model NAME` | DeepSeek model name. | `DEEPSEEK_MODEL` or `deepseek-v4-pro` | +| `--base-url URL` | DeepSeek-compatible API base URL. | `DEEPSEEK_BASE_URL` or `https://api.deepseek.com` | +| `--reasoning-effort high\|max` | Thinking effort. | `max` | +| `--thinking` / `--no-thinking` | Enable or disable thinking. | Enabled | +| `--max-steps N` | Maximum model turns. | `30` | +| `--max-output-tokens N` | Maximum tokens requested per completion. | `16384` | +| `--api-timeout SECONDS` | Timeout for one model request. | `300` | +| `--command-timeout SECONDS` | Default repository-command timeout. | `120` | +| `--command-policy ask\|allow\|deny` | Repository-command approval policy. | `ask` | +| `--yes` | Alias for command policy `allow`. | Off | +| `--trace PATH` | Exact JSONL trace path. | `.yada/runs/__