Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

docs: add English agent guidelines and Midscene verification workflow (#31)

Leyange051c088acd6
diff --git a/.gitignore b/.gitignore
index bb54a46..08f6fb3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -99,3 +99,8 @@ settings.json
*.bak
*.orig
*.rej
+
+# Local promotional drafts and desktop automation output
+/.tmp/
+/midscene_run/
+/tests/midscene/node_modules/
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..d9f8097
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,157 @@
+# Agent Development Guidelines
+
+These instructions apply to the entire Doubao Say repository. Before starting,
+read this file, [CONTRIBUTING.md](CONTRIBUTING.md), and
+[tests/README.md](tests/README.md).
+
+## Collaboration and scope
+
+- This is an English-by-default project. Write agent instructions, development
+ documentation, code comments, and new primary UI copy in English. Keep explicitly
+ localized documents and translations in their target languages. Follow the
+ user's requested language when communicating.
+- Before editing, confirm the branch, worktree, existing uncommitted changes,
+ and the source path of any running instance. When the user requests a separate
+ worktree, implement and verify there; do not accidentally test another checkout.
+- Preserve other tasks' changes and untracked files. Do not stash, revert, delete,
+ or restart another task's instance without authorization.
+- Stay within the task's scope and existing module boundaries. Keep rendering,
+ network requests, and business state separate.
+- Do not import release commands, private resources, or machine-specific paths
+ from the neighboring LifeOS Pro repository.
+
+## Project boundaries
+
+- This Linux voice-input application uses Python 3.11+, GTK4/PyGObject, and Cairo.
+ Recognition uses a Doubao web account or the optional official Volcengine Seed
+ ASR backend. Do not add recognition engines without an explicit requirement.
+- Update GTK only on the main thread; dispatch background results through GLib.
+ Use existing audio callbacks and keep gesture timing independently testable.
+- Overlays must not steal focus. Input-delivery changes must account for target
+ windows, shortcut release timing, focus changes, and original-text recovery,
+ avoiding duplicate delivery or input into the wrong window.
+- English is the default UI language. Provide Chinese translations alongside new
+ English strings. Check both languages, long text, truncation, state transitions,
+ and reduced-motion behavior when changing animations.
+- Do not expose real transcripts, cookies, tokens, API keys, or device/account
+ identifiers in logs, reports, or screenshots. Use synthetic text, fake
+ credentials, and isolated configuration for verification.
+- Preserve provenance and licensing when modifying inherited code under
+ `src/doubao_input/doubao/`; update NOTICE when appropriate.
+
+## Bug reproduction and verification
+
+1. **Reproduce first.** Record the trigger, steps, expected and actual results,
+ environment, language, commit, and worktree. Confirm the running source and
+ capture evidence before editing.
+2. **Identify and fix the cause.** Explain the cause and affected behavior. Keep
+ the fix focused and add regression coverage for automatable behavior defects.
+ Where practical, demonstrate failure before the fix and success afterward.
+3. **Repeat the scenario.** Use the same inputs, steps, and environment. Check
+ related transitions such as cancellation, timeout, fallback, repeated actions,
+ and cleanup after closing.
+4. **Preserve each round.** Keep separate before/after screenshots and results for
+ every verification round. Do not overwrite earlier failures. Verify UI and
+ runtime changes in the real application.
+5. **State the outcome precisely.** Distinguish code changes, automated test
+ success, real-environment verification, and release. Compilation, mock
+ assertions, and historical screenshots do not establish current acceptance.
+
+### Screenshots and evidence
+
+- Every UI bug requires before/after captures. Keep window size, scale, theme,
+ language, sample data, and interaction stage comparable, with enough context
+ to judge the defect.
+- Capture key frames for animation or transient issues; add a short recording
+ when needed. Supplement screenshots with sanitized logs or reproducible
+ assertions for focus, clipboard, delivered text, audio, and background behavior.
+- For nonvisual defects, explain why screenshots do not apply and retain failing
+ and passing test or log evidence. Explicitly report missing baseline captures,
+ unavailable environments, or unsuccessful reproduction. Never fabricate evidence.
+- Label minimal visual previews as previews; they do not prove the real voice-input
+ pipeline works.
+- Store evidence in the ignored directory
+ `artifacts/verification/<task>/<round>/`. Suggested files are `before.png`,
+ `after.png`, `test.log`, and `verification.md`; suffix different languages or
+ scenarios as needed.
+- In `verification.md`, record the date, source path, commit and local changes,
+ actual launch command, environment, reproduction steps, before/after results,
+ test commands and exit codes, evidence paths, and unverified scope.
+- Open and inspect captures before delivery: confirm the right target, visible
+ differences, and absence of private data. Include clickable absolute paths to
+ before/after images in the final handoff.
+- Keep a reviewable verification summary in the PR. Ignored local artifacts are
+ not uploaded with commits; provide sanitized attachments when sharing evidence
+ rather than relying on inaccessible local paths.
+
+## Tests and desktop instances
+
+- Run affected tests first, then `make check` before delivering code changes.
+ Follow CONTRIBUTING.md for coverage and release checks. Repeated automated runs
+ do not replace missing real-environment acceptance.
+- Unit tests must use fake credentials and must not access live recognition,
+ record audio, send keyboard events, or change desktop configuration. Put opt-in
+ device checks under `tests/manual/` and reusable Midscene flows under `tests/e2e/`.
+- Confirm instance ownership, configuration isolation, and recording state before
+ desktop tests. Do not interrupt dictation. Follow CONTRIBUTING.md for instance
+ conflicts in fresh-login/onboarding tests that share the production application ID.
+- Bound desktop scripts with a process-level timeout and register cleanup before
+ assertions. For example:
+
+ ```sh
+ GTK_A11Y=none PYTHONPATH=src timeout --signal=TERM --kill-after=5s 35s \
+ dbus-run-session -- .venv/bin/python tests/manual/refactor_smoke.py
+ ```
+
+- Use `tests/manual/safety.py` to bound event processing. Never use an unbounded
+ GTK event-draining loop. A timeout is a failure; after PASS, confirm process exit
+ and resource cleanup.
+- Verify Wayland and X11 focus, positioning, and paste behavior separately; state
+ when only one was tested. Fake audio and minimal GTK checks do not establish
+ real microphone or complete ASR acceptance.
+
+### Midscene E2E
+
+- Read [tests/e2e/README.md](tests/e2e/README.md) for setup and distribution-specific
+ coverage. The maintained suite uses `@midscene/test` and `@midscene/computer`,
+ with YAML scenarios under `tests/e2e/cases/` and setup in
+ `tests/e2e/midscene.config.ts`.
+- Extend the relevant scenario for user-visible flow regressions. Use visible
+ interactions and image assertions for UI conclusions; setup commands alone do
+ not prove that the interface works. Keep deterministic logic in unit tests.
+- Run the Ubuntu suite on the isolated Xvfb desktop with its synthetic GTK fixture.
+ The Omarchy suites use the disposable VM through VNC; follow the existing
+ workflow instead of changing the user's real desktop shell.
+- `make check` does not run Midscene E2E. On a prepared Linux host, install the
+ locked Node dependencies and run from `tests/e2e/`:
+
+ ```sh
+ npm ci --include=optional --ignore-scripts
+ npm run typecheck
+ MIDSCENE_COMPUTER_HEADLESS_LINUX=true timeout --signal=TERM --kill-after=10s 50m \
+ npm test -- --project ubuntu
+ ```
+
+- The onboarding suite contains multiple cases. Run the polishing overlay suite
+ separately with `timeout --signal=TERM --kill-after=10s 10m npm test -- --project ubuntu-polishing`
+ using the same headless environment. See the test guide for coverage boundaries.
+- Configure the required `MIDSCENE_MODEL_*` environment variables securely, as
+ documented in the test guide and CI workflow. Never commit or print model keys.
+ Missing credentials or dependencies mean E2E was not run, not that it passed.
+- Inspect `tests/e2e/midscene_run/report/` after the run. Preserve the HTML replay,
+ assertion results, relevant before/after frames, and logs with the verification
+ record; do not overwrite earlier rounds. For CI, record the run URL and tested
+ commit and retrieve the relevant artifacts before they expire.
+- Current onboarding fixtures use synthetic sign-in and endpoint checks. Their
+ success does not prove live login, microphone capture, recognition, or input
+ delivery. Report exactly which flows and desktop environments were verified.
+
+## Documentation and release
+
+- Keep this file and primary development documentation entirely in English.
+ Update README.md and README.zh-CN.md when user-visible behavior changes; update
+ CONTRIBUTING.md and tests/README.md when development workflows change.
+- Use focused conventional commits and stage only files owned by the current task.
+- Before release, follow CONTRIBUTING.md, SECURITY.md, and packaging/INSTALL.md.
+ Do not publish, push release tags, or change repository visibility without
+ authorization. Preserve LICENSE and NOTICE.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f27393c..254d841 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -5,6 +5,24 @@ optional official Volcengine Seed ASR backend. Do not add further recognition
engines, embed credentials or depend on personal Hyprland configuration.
There is no published repository/release for this revision yet.
+## Agent workflow and bug evidence
+
+Read [AGENTS.md](AGENTS.md) before making changes. For every bug verification
+round, reproduce the problem before editing, retain before/after screenshots,
+and repeat the same scenario after the fix. Use real application captures for
+UI changes; supplement screenshots with assertions or sanitized logs for focus,
+paste, audio, and background behavior. Record missing evidence or unavailable
+runtime checks explicitly; previews do not establish end-to-end acceptance.
+For bugs without a UI, record why screenshots do not apply and retain failing
+and passing test or log evidence instead.
+
+Store each round under `artifacts/verification/<task>/<round>/`, including a
+`verification.md` with the source revision, local changes, environment, steps,
+commands, exit codes, results, and evidence paths. Inspect the captures and link
+before/after images in the handoff. These local artifacts are ignored by Git;
+include a durable verification summary and sanitized attachments when sharing
+an issue or PR. See AGENTS.md for the complete workflow.
+
## Development
Use Python 3.11+ with system GTK4/PyGObject/Cairo. Release CI builds separate
@@ -26,6 +44,11 @@ layout is documented in `tests/README.md`. Stop recording before any lifecycle
test. Stop the normal app/plugin before fresh-login/onboarding tests; they share
the production application ID to prevent duplicate overlays.
+Midscene desktop E2E is a separate suite and is not included in `make check`.
+See [the test guide](tests/README.md#midscene-desktop-e2e) for prerequisites,
+commands, synthetic-fixture limitations, and HTML replay evidence. Extend the
+relevant scenario when fixing a covered user-visible flow.
+
## Change boundaries
- Audio callbacks run off-thread. Marshal GTK updates onto the GLib main loop.
diff --git a/README.md b/README.md
index 188d611..b127d15 100644
--- a/README.md
+++ b/README.md
@@ -331,6 +331,11 @@ full lifecycle and recovery instructions.
## Development and local packaging
+Development and AI-agent work follow [AGENTS.md](AGENTS.md) and
+[CONTRIBUTING.md](CONTRIBUTING.md). Bug fixes require reproducible verification
+and before/after screenshots for each UI verification round, with test or log
+evidence for behavior that screenshots cannot prove. Report any unverified scope.
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for `make check`,
[security reporting](SECURITY.md), and
[changes](CHANGELOG.md). The legacy Debian scripts are not the release path for
diff --git a/README.zh-CN.md b/README.zh-CN.md
index b464564..427fc66 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -257,6 +257,10 @@ cd "${XDG_CONFIG_HOME:-$HOME/.config}/omarchy/plugins/md.lifeos.doubao-say"
## 开发与本地打包
+开发与 AI Agent 协作遵循 [AGENTS.md](AGENTS.md) 和
+[贡献指南](CONTRIBUTING.md)。Bug 修复需可复现验证,每轮界面验证保存修复前后截图;
+截图无法证明的行为需补充测试或日志证据,并明确尚未验证的范围。
+
贡献流程和统一检查命令 `make check` 见[贡献指南](CONTRIBUTING.md),
另见[安全报告流程](SECURITY.md)和[变更记录](CHANGELOG.md)。
旧 Debian 打包脚本不属于本次候选版的发布路径,尚未完成新版安装验收。
diff --git a/tests/README.md b/tests/README.md
index 48738f0..71b5043 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -11,3 +11,65 @@
`make test-unit` and `make test-contracts` run the two local automated layers.
`make test` runs both. See `CONTRIBUTING.md` before running anything under
`manual/`.
+
+Bug reproduction and visual acceptance follow [AGENTS.md](../AGENTS.md).
+For each verification round, keep before/after captures and a verification record
+under `artifacts/verification/<task>/<round>/` (ignored by Git). Supplement visual
+evidence with behavior assertions; document missing evidence and checks that were
+not run. See [CONTRIBUTING.md](../CONTRIBUTING.md) for bounded desktop execution.
+
+## Midscene desktop E2E
+
+The maintained Midscene suite lives in [`e2e/`](e2e/README.md), using
+`@midscene/test` and `@midscene/computer`. Declarative scenarios live in
+`e2e/cases/`; `e2e/midscene.config.ts` owns desktop setup and teardown.
+`make test` and `make check` do not execute this separate Node-based suite.
+
+- **Ubuntu:** runs the real GTK onboarding UI with a synthetic fixture on an
+ isolated Xvfb desktop. Sign-in and endpoint responses are simulated. The
+ separate `ubuntu-polishing` project covers the native polishing overlay.
+- **Omarchy:** runs onboarding and shell visual checks through VNC in a disposable
+ Omarchy/Hyprland VM. Follow the existing VM workflow and setup guide; do not run
+ shell-changing scenarios against your personal desktop.
+
+For local Ubuntu execution, first prepare the system dependencies listed in the
+[Ubuntu workflow](../.github/workflows/midscene-ubuntu-22.04.yml), including the
+GTK/Python libraries, Xvfb, and Fluxbox. The fixture uses `/usr/bin/python3`, so
+installing Python dependencies only in a virtual environment is insufficient.
+Use the Node version specified by that workflow. Configure
+`MIDSCENE_MODEL_API_KEY`, `MIDSCENE_MODEL_NAME`, `MIDSCENE_MODEL_BASE_URL`, and
+`MIDSCENE_MODEL_FAMILY` in a secure local environment; CI uses Actions Secrets.
+Never put credential values into commands saved in reports or committed files.
+
+From the repository root:
+
+```sh
+cd tests/e2e
+npm ci --include=optional --ignore-scripts
+npm run typecheck
+MIDSCENE_COMPUTER_HEADLESS_LINUX=true timeout --signal=TERM --kill-after=10s 50m \
+ npm test -- --project ubuntu
+```
+
+Run the polishing overlay scenario separately (same prerequisites):
+
+```sh
+MIDSCENE_COMPUTER_HEADLESS_LINUX=true timeout --signal=TERM --kill-after=10s 10m \
+ npm test -- --project ubuntu-polishing
+```
+
+The onboarding suite contains multiple cases; the 50-minute outer limit allows
+for its per-case timeouts. A timeout is a failed run. Confirm test processes and their desktop resources
+have exited. Missing prerequisites or credentials must be reported as not run.
+
+Inspect the HTML replay under `tests/e2e/midscene_run/report/`, including visual
+assertions and screenshots. Preserve each run's report and relevant before/after
+frames under its verification directory, alongside the command, exit code, source
+revision, and remaining limitations. For CI verification, record the run URL and
+commit and download the artifacts before expiry. A historical green run is not
+verification of the current change.
+
+Add or update the relevant YAML scenario when fixing a user-visible flow covered
+by E2E. Use image assertions to establish visible results and deterministic tests
+for underlying logic. Synthetic onboarding does not verify real credentials,
+microphone capture, ASR, or text delivery; those require separate acceptance.