Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ jobs:
# Electron fetches its binary on first use; do it here, not inside the first test.
- run: node node_modules/electron/install.js
- run: npm run build
# Visual baselines depend on the macOS version's CJK system fonts, so they are compared on
# the machine that captured them (tests/visual/README.md), not on CI runners.
# UI layout scenarios can also be run locally with test:visual; screenshots stay local.
- run: npx playwright test --project=e2e
- if: always()
uses: actions/upload-artifact@v4
Expand Down
6 changes: 4 additions & 2 deletions AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ This file provides guidance to AI agents when working with code in this reposito

## What this project is

Easy Agent is a **terminal-native agentic coding CLI** published as the `eagent` npm package. It installs the `eagent` command and the `easy-agent` long alias.
Easy Agent is a **general-purpose, open-source Agent Harness** published as the `eagent` npm package. It provides the execution loop, model connections, tools, context, permissions, sessions and extension mechanisms used through the CLI, Headless mode, SDK, RPC/ACP and desktop client. The CLI installs the `eagent` command and the `easy-agent` long alias; coding is a use case of the default Agent.

Claude Code informed the early architecture. Current work follows Easy Agent's own requirements, public contracts and tests. Reference implementations are optional research material, not a requirement to reproduce their behavior. Describe implemented capabilities separately from roadmap work.

- Runtime: Node 22+, ESM, strict TS, target ES2022, JSX `react-jsx`
- TUI: React 19 + Ink 7 (no web framework)
Expand All @@ -28,7 +30,7 @@ Workspace registries and resource lifecycles belong to a runtime (`src/state/run
Tests are smoke/characterization scripts listed in `scripts/verify-production.ts`; the release workflow runs the Stage 36 verification before publishing.

- **Offline tests:** `npm test` runs the `core`, `extensions`, and `ui` groups (the same set as `verify:production`, without typecheck/lint/build). `npm test -- --list` prints them.
- **Desktop tests:** in `apps/desktop/`, `npm test` runs unit and e2e tests. Visual comparisons run separately with `npm run test:visual`, after generating local baselines from `web-ui` using `visual:baseline`. Baseline images, actual screenshots, diff images, and test reports are local artifacts and must not be committed. See `apps/desktop/tests/visual/README.md`.
- **Desktop tests:** in `apps/desktop/`, `npm test` runs unit and e2e tests. `npm run test:visual` separately checks twelve UI scenarios in the actual client, including control states, themes and layout bounds; it requires no prototype or baseline images. `CAPTURE_UI=1 npm run test:visual` also captures local screenshots. Images and reports must not be committed. See `apps/desktop/tests/visual/README.md`.
- **Lint / format:** Biome, configured in `biome.jsonc`. `npm run lint` (errors and warnings fail) and `npm run format:check` are both part of `verify:production`; run `npm run format` before committing. Rules switched off in `biome.jsonc` carry a reason; keep it that way. The formatter collapses repeated spaces in JSX text, so write aligned text as a string expression: `<Text>{" ↳ "}{label}</Text>`.
- **Typecheck:** `npm run typecheck` → `tsc --noEmit`
- **Frontend boundaries:** `npm run check:frontend-boundaries` (part of `verify:production`) rejects runtime imports of session internals (QueryEngine, agentic loop, session storage, `state/` stores, plan files, thinking, mailbox, permissions, Bash tool) from `src/ui/` and `src/entrypoint/`; use the SDK instead.
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Easy Agent

A terminal coding agent that reads your code, edits files, and runs commands under permission rules you control.
An open-source Agent Harness for configuring and running agents through a CLI, SDK, RPC/ACP, and desktop client.

![Easy Agent banner](https://raw.githubusercontent.com/ConardLi/easy-agent/main/public/img/banner.jpeg)

Easy Agent (`eagent`) runs in your terminal next to your repository. Describe a task and it plans the work, reads and changes files, runs tests or shell commands, and reports back. Every action that can change your machine goes through permission rules, workspace trust, and an optional OS-level sandbox. It works with Anthropic, OpenAI-compatible, Gemini, and local models.
Easy Agent (`eagent`) brings model connections, the execution loop, tools, context, permissions, sessions, and extensions into one runtime. Configure an Agent for your task and use the same core through the terminal, scripts, the session SDK, editor protocols, or the desktop client. The default Agent can explore code, edit files, and run commands under permission rules, workspace trust, and an optional OS-level sandbox. It works with Anthropic, OpenAI-compatible, Gemini, and local models.

The code is written to be read as well as run. Model communication, the agentic loop, tools, permissions, context management, and each extension system live in separate layers. The documents linked below explain how the security-relevant parts behave and why, and the [learning path](./docs/learning-path.md) walks through the layers in order with code snapshots, which helps if you want to build or customize an agent of your own.

> 中文文档:[README.zh-CN.md](./README.zh-CN.md)

## What you can use it for

- Embed Agent sessions in your own application through the SDK or RPC, and configure the tools, prompts, context sources, and extensions each Agent uses.
- Find your way around an unfamiliar codebase: ask where something is handled, how a flow works, or what a change would touch.
- Make multi-file changes, review the diff, and undo them with `/rewind` if they are wrong.
- Run builds and tests, read the failures, and iterate on a fix.
Expand Down
5 changes: 3 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Easy Agent

在终端里干活的 Coding Agent:读代码、改文件、跑命令,每一步都在你定的权限规则里。
通用的开源 Agent Harness:通过 CLI、SDK、RPC/ACP 和桌面客户端配置与运行 Agent。

![Easy Agent banner](https://raw.githubusercontent.com/ConardLi/easy-agent/main/public/img/banner.jpeg)

Easy Agent(命令 `eagent`)就在你的仓库旁边运行。把任务说给它,它会先想好怎么做,再读文件、改代码、跑测试或 Shell 命令,最后把结果告诉你。凡是会改动机器的操作,都要先过权限规则和工作区信任检查,需要的话还可以放进系统级沙箱里跑。模型方面支持 Anthropic、OpenAI 兼容接口、Gemini 和本地模型。
Easy Agent(命令 `eagent`)把模型接入、执行循环、工具、上下文、权限、会话和扩展机制组织在同一个运行时中。按任务配置 Agent,再通过终端、脚本、SDK、编辑器协议或桌面客户端使用同一套核心能力。默认 Agent 可以阅读代码、修改文件和运行命令,操作受权限规则、工作区信任和可选系统级沙箱约束。模型方面支持 Anthropic、OpenAI 兼容接口、Gemini 和本地模型。

代码除了能跑,也照着让人读懂来写。模型通信、Agentic Loop、工具、权限、上下文管理和各套扩展机制分层放置。下文链接的文档讲清了安全相关部分怎么工作、为什么这样设计;[学习路线](./docs/learning-path.zh-CN.md)按顺序把各层串起来,附带代码快照,适合想自己造一个 Agent、或者在它基础上做定制的工程师。

> English documentation: [README.md](./README.md)

## 能用它做什么

- 通过 SDK 或 RPC 把 Agent 会话嵌入自己的应用,配置每个 Agent 使用的工具、提示词、上下文来源和扩展。
- 熟悉一个陌生的代码库:问它某段逻辑在哪儿处理、一个流程怎么走、改一处会牵连哪些地方。
- 跨多个文件改代码,看完 diff 再决定留不留,改错了用 `/rewind` 撤回。
- 跑构建和测试,读报错,一轮轮修到通过。
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ out/
release/
test-results/
playwright-report/
# Visual references are generated and used locally.
# Keep any locally retained reference images out of version control.
tests/visual/baseline/
3 changes: 1 addition & 2 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"format:check": "biome format .",
"test": "playwright test --project=unit --project=e2e",
"test:e2e": "playwright test --project=e2e",
"test:visual": "playwright test --project=visual",
"visual:baseline": "playwright test --project=baseline"
"test:visual": "playwright test --project=visual"
},
"devDependencies": {
"@biomejs/biome": "2.5.14",
Expand Down
10 changes: 1 addition & 9 deletions apps/desktop/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import { defineConfig } from "@playwright/test";

export default defineConfig({
// Every Electron test starts its own app; running them one at a time keeps screenshots stable.
// Every Electron test starts its own app; run them one at a time.
workers: 1,
retries: process.env.CI ? 1 : 0,
reporter: [["list"]],
snapshotPathTemplate: "tests/visual/baseline/{arg}{ext}",
// Baselines come from the style reference only, never from the client itself.
updateSnapshots: "none",
expect: {
toHaveScreenshot: { threshold: 0.05, maxDiffPixels: 0, animations: "disabled" },
},
projects: [
{ name: "unit", testDir: "tests/unit" },
{ name: "e2e", testDir: "tests/e2e" },
{ name: "visual", testDir: "tests/visual", testMatch: /\.spec\.ts$/ },
// Captures the baseline from the style reference; see tests/visual/README.md.
{ name: "baseline", testDir: "tests/visual", testMatch: /\.capture\.ts$/ },
],
});
120 changes: 36 additions & 84 deletions apps/desktop/tests/visual/README.md
Original file line number Diff line number Diff line change
@@ -1,98 +1,50 @@
# Visual comparison with the style reference
# Client UI checks

The style reference (`web-ui/`, kept outside this repository) decides how the client looks. Each scenario in `scenarios.ts` is a state of the reference, opened with URL parameters, and the preferences that put the client in the same state. `baseline/<name>.png` is the reference's screenshot of that state.
The Electron client is the maintained interface. UI work and validation happen
in this application; there is no separate prototype server or reference-image
generator.

All baseline images are local files ignored by Git. Commit the test code and
scenario definitions, but do not commit baseline images, actual screenshots,
diff images, or test reports. A fresh checkout has no baselines.
`npm test` runs unit and e2e tests. `npm run test:visual` runs the twelve UI
scenarios in `scenarios.ts` against the built client. It checks visible content,
control states, themes, sidebar visibility and whether the primary view fits
the window without horizontal page overflow. It does not compare pixels or
require baseline images.

`npm test` runs unit and e2e tests without requiring images. Visual comparison is
an explicit local check: generate baselines from the reference first, then run
`npm run test:visual`. A missing baseline produces setup instructions before
launching the app; it is never generated from the client or silently skipped.
## Running

`npm run test:visual` starts the built client for every scenario and compares its window with the baseline. Native traffic lights and the OS user name differ for reasons other than styling, so elements marked `data-visual-mask` are painted over on both sides.
Build the Agent in the repository root with `npm run build`, then in
`apps/desktop/`:

## Capturing the baseline

The baseline only ever comes from the reference (`updateSnapshots` is `none`), so a client change cannot make its own screenshot the new standard.

1. Start the reference: `npm run dev` in `web-ui/` (port 5180).
2. In `apps/desktop/`: `WEB_UI_URL=http://localhost:5180 npm run visual:baseline`.

The reference is rendered in the same Electron build as the client, at a 1280×800 viewport and a device scale factor of 1, so fonts and compositing match. Chinese text falls back to the system's CJK font, whose glyphs change between macOS versions, so a baseline only holds on the machine (or macOS version) that captured it. CI runs the e2e tests only; run `npm run test:visual` locally before a pull request that touches the interface, and capture the baseline again after a macOS upgrade.

## When the design changes

Change the reference first, capture the baseline again, then change the client until `npm run test:visual` passes. New states the client needs get a reference state (a URL parameter) and a scenario before the client implements them.

## Resource library navigation (#119)

The reference's `src/components/app/Sidebar.tsx` now labels the resource
library `资源库`, replacing `自定义`. The first-run baselines were captured
again from that reference on macOS 15.7.3 with Electron 44.4.5, at 1280×800
and device scale factor 1.

Only the three screenshots with a visible sidebar changed: each has 399
different RGB pixels, all inside the navigation label at `(43, 150)` to
`(82, 163)` (exclusive end coordinates). The hidden-sidebar baseline is
unchanged. Screenshot thresholds, masks, and scenarios are unchanged, and
all four local visual comparisons pass.

These four scenarios cover the first-run shell. Resource library pages and
Agent assignment are exercised by `tests/e2e/customize.spec.ts`; their saved
screenshots support manual inspection but are not pixel comparison baselines.

## Request detail and comparison (#120)

Four more scenarios cover the context panel and request comparison, each in
dark and light themes. The reference states are `?requestView=context` and
`?requestView=compare` (with `&theme=dark|light`). Their presentation lives in
`web-ui/src/components/requests/`, using the same modal shell and panel width
as the client. The original four first-run baselines are unchanged.

`requestFixtures.ts` contains frozen, SDK-typed `session/context` and request
diff responses. The reference reads these fixtures; `shell.spec.ts` opens a
real workspace in the client and replays only those two RPC responses at the
test IPC boundary. No replay or mock mode ships in the application. The
fixtures stabilize request IDs, sizes, token counts and diff text so the
pixel test measures presentation. `requestSteps.ts` performs the same visible
interactions on both sides, clears hover and lets macOS scrollbars fade.
```sh
npm run build
npm run test:visual
```

The context capture covers the panel viewport with the skill source expanded;
the comparison capture covers the dialog content with the identity difference
expanded. No new masks or tolerance changes are used. The four new baselines
were captured on macOS 15.7.3 / Electron 44.4.5 at the existing 1280×800, 1×
viewport. To capture only these states:
For local screenshot inspection:

```sh
WEB_UI_URL=http://127.0.0.1:5180 npm run visual:baseline -- --grep request-
CAPTURE_UI=1 npm run test:visual
```

`tests/e2e/requestContext.spec.ts` separately exercises actual Agent requests:
component provenance and provider counts, cache activity, navigation to the
session's Agent, removal of a disabled skill on the next request, two-Agent
comparison without provider calls, identical requests, input invalidation,
failed reads with retry, and late comparison responses. Its screenshots show
the complete application with real RPC data. Pixel replay does not replace
these behavioral tests or claim coverage of every expanded component.
Images go to Playwright's ignored test output directory, or the directory passed
with `--output`. Screenshots, reports and any privately maintained comparison
images must not be committed. This suite never turns current client screenshots
into expected results.

## Recovering a session with an unavailable model
## Coverage

Four scenarios cover model selection and the empty model list in both themes.
The reference URLs are `?resumeModel=available&theme=light|dark` and
`?resumeModel=empty&theme=light|dark`. The client opens an actual historical
transcript in an isolated home, with a missing model profile; the screenshots
cover the recovery form, following the request comparison's component capture.
The shared modal shell and footer are inspected in the e2e screenshot and
exercised by the behavior tests. Capturing the form keeps the translucent
dialog border and the unrelated page behind it out of the component comparison.
The existing baselines, masks and thresholds are unchanged.
- Four first-run states: dark, light, ember accent and hidden sidebar.
- Context details and request comparison in both themes.
- Session model recovery with available and empty model lists in both themes.

`tests/e2e/sessionRecovery.spec.ts` also verifies explicit selection, preserved
messages, restart after recovery, cancellation, starting a fresh conversation,
and returning from model settings. Recovery does not call the model provider.
Tests start real Electron windows. Workspaces, configuration and transcripts are
isolated in temporary directories, and Agent requests use the local fixture
provider. `requestFixtures.ts` supplies deterministic responses at the test IPC
boundary for context and comparison presentation; no preview mode or fake data
is added to production code.

```sh
WEB_UI_URL=http://localhost:5180 npm run visual:baseline -- --grep resume-model
```
`tests/e2e/requestContext.spec.ts` covers actual request provenance, configuration
changes and comparison errors. `tests/e2e/sessionRecovery.spec.ts` covers resume,
restart, cancellation, settings round trips and stale profile selections.
These behavioral checks complement the UI scenarios. They do not replace live
provider validation when connection behavior changes.
43 changes: 0 additions & 43 deletions apps/desktop/tests/visual/baseline.capture.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/desktop/tests/visual/reference-window.cjs

This file was deleted.

Loading
Loading