mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-30 00:47:36 +00:00
* fix(proactive): simplify round files and restore failed summaries * fix(proactive): validate document-relative Markdown links * feat(proactive_agent): implement v2 daily record workflow with single-file decision - Add ProactiveAgentStepV2 class to support single daily note decision and reminder - Introduce RoundOutputs for v2 round file tracking, and keep RoundArtifacts for v1 summary backup - Refactor AgentOutbox to support both v1 standalone reminder files and v2 daily reminder records - Add proactive_record utilities to parse and validate v2 daily record frontmatter and metadata - Enhance proactive_agent to prepare, read, and manage artifacts for both v1 and v2 flows - Add configuration profile proactive_v2 to enable new workflow with backward compatibility - Update proactive.yaml and reactive proactive_agent_step configuration comment for easy switching - Provide extensive schema validation for v2 reminders ensuring priority and message consistency - Document v2 workflow and usage in English and Chinese runtime docs - Add unit tests for v2 step verifying single file output and proper decision handling * refactor(agent/runtime): replace ReminderRef with string keys and simplify reminder handling - Remove ReminderRef model and switch to using workspace-relative string keys for reminders - Simplify AgentOutbox to read, write, and manage reminders keyed by strings - Change file locking and version checking to protect concurrent edits on daily record files - Replace legacy and v2 reminder file handling with unified ReminderFiles storage - Adjust ChatNotifications to operate with the new key scheme and update pending/read sets - Refactor RoundOutputs to RoundRecord for safer round record tracking and rollback - Remove unused ProactiveRunResult and related references from imports and exports - Update InboxWakeRequest, AgentReminder, and related models for consistent ID and path validation - Adjust proactive agent runtime and local runtime to check reminder versions before commit - Correct language and docs to describe reminders as daily records instead of separate files - Clean up roles of inbox and outbox for reminder ownership, delivery, and acknowledgments * fix(proactive): serialize round commits and align desktop reminders * refactor(proactive): unify task triggers in Proactive Runtime * fix(proactive): bound reminder payloads and simplify receipts * refactor(studio): share workbench and simplify proactive delivery * fix(studio): update and centralize build dependencies * fix(proactive): guard draft repair and verify Studio deployments * chore(docs): update source-map-js * feat(release): support publishing selected artifacts from a tag * chore(studio): remove the public playground * refactor: simplify reminders and release workflows * fix: preserve proactive records and align release provenance * test(proactive): remove brittle prompt and preset assertions * fix(proactive): register reminders after input acknowledgement * feat(notebook): list projects across todos and ideas * feat(studio): connect mobile apps to configurable ReMe services * fix(proactive): reserve registered reminder paths * fix(studio): request Android local network access * fix(proactive): reserve reminder paths referenced by receipts
223 lines
13 KiB
Markdown
223 lines
13 KiB
Markdown
# AGENTS.md
|
|
|
|
This file guides coding agents working in the ReMe repository. Keep changes small, testable, and consistent with the
|
|
contracts expressed by the current code.
|
|
|
|
## Project Principles
|
|
|
|
ReMe is a local-first, file-native memory system for agents.
|
|
|
|
- User-owned workspace files are the durable source of truth.
|
|
- Indexes, catalogs, graphs, caches, and generated metadata must remain rebuildable.
|
|
- Prefer transparent formats and predictable behavior over hidden state.
|
|
- Preserve user control over workspace paths, configuration, and service boundaries.
|
|
- Keep concepts focused on project intent; let code and schemas describe implementation.
|
|
|
|
When convenience conflicts with these principles, favor data ownership, recoverability, and explicit behavior.
|
|
|
|
## Sources of Truth
|
|
|
|
Use this order when documentation and implementation disagree:
|
|
|
|
1. Current code and public Pydantic schemas.
|
|
2. Tests that describe supported behavior.
|
|
3. CLI behavior and the built-in configuration.
|
|
4. README files and other development documentation.
|
|
|
|
Do not duplicate large implementation descriptions in documentation. Express the stable contract and link to the
|
|
relevant module where useful. When behavior changes intentionally, update the implementation, schemas, tests, defaults,
|
|
and concise documentation together.
|
|
|
|
## Repository Map
|
|
|
|
- `reme/reme.py`: CLI entry point; dispatches `start`, `find_reme`, and client calls.
|
|
- `reme/core/application.py`: application assembly, dependency ordering, job execution, and lifecycle.
|
|
- `reme/config/config_parser.py`: YAML/JSON loading, environment expansion, dot-notation parsing, and deep config
|
|
merging.
|
|
- `reme/config/default.yaml`: default service, jobs, steps, and components. Other files in
|
|
`reme/config/` are named configuration variants.
|
|
- `reme/schema/application_config.py`: typed application, component, and job configuration.
|
|
- `reme/schema/`: request, response, streaming, memory, graph, and file contracts.
|
|
- `reme/core/context.py`: application-wide wiring and request-scoped data, response, streaming, and stop events.
|
|
- `reme/components/base.py`: component lifecycle, dependency binding, and workspace helpers.
|
|
- `reme/core/registry.py`: the frozen built-in registry template and application-local registry factory.
|
|
- `reme/components/job/`: base, stream, background, and cron job implementations.
|
|
- `reme/components/service/`: local CLI, HTTP, and MCP service backends.
|
|
- `reme/components/proactive_runtime/`: task inputs, schedules, execution coordination, and reminders.
|
|
- `reme/steps/proactive/`: task execution, Remy conversation and reminders, management tools, and observation collectors.
|
|
- `reme/components/`: agent wrappers, model adapters, stores, catalogs, graphs, indexes, clients, tokenizers, and
|
|
outbound proxies.
|
|
- `reme/steps/`: registered job steps grouped by common, file I/O, index, evolve, cookbook, and transfer
|
|
concerns.
|
|
- `reme/utils/`: shared logging, async, process, and token helpers, with `files/` for filesystem primitives,
|
|
`documents/` for document parsing and links, and `file_sandbox/` for platform-specific sandboxed execution.
|
|
- `tests/unit/`: primary fast, isolated validation suite.
|
|
- `tests/integration/`: service/model tests that may need credentials or external processes.
|
|
- `reme_studio/`: npm workspace for `desktop/`, `web/`, `mobile/`, the shared React `workbench/`, and `client/`.
|
|
The Android and iOS native projects live under `mobile/`. The ReMe release publishes the desktop installers and
|
|
Studio static packages under the version in `reme/_version.py`.
|
|
- `plugins/`: installable ReMe extensions, including Auto Fin and LME/BEAM plugins.
|
|
- `integrations/`: adapters that connect ReMe to external agent hosts, including the independent, self-contained DSH
|
|
and OpenClaw TypeScript plugins plus the Claude Code and Hermes Agent integrations.
|
|
- `skills/`: standalone skills; `reme_memory` calls ReMe, while other skills may use separate tools or direct-file
|
|
conventions.
|
|
- `benchmark/` and `cookbook/`: runnable evaluations and example workflows.
|
|
- `docs/`: README-linked supporting pages and figures.
|
|
- `github-pages/`: VitePress build shell, generated-content assembly, documentation checks, and GitHub Pages output. The
|
|
canonical theme and guides remain under `docs/`; `.generated/` and `dist/` are disposable.
|
|
|
|
## Development Setup
|
|
|
|
ReMe requires Python 3.11 or newer. Install the editable development environment with:
|
|
|
|
```bash
|
|
pip install -e reme_studio/web/python -e ".[dev,core]"
|
|
```
|
|
|
|
Before changing behavior, inspect the adjacent implementation, schema, built-in config, and focused tests. Follow
|
|
existing async and typing patterns unless the task explicitly requires a new contract.
|
|
|
|
## Configuration and CLI Contracts
|
|
|
|
- CLI syntax is `reme ACTION key=value ...`; leading `-` or `--` on arguments is accepted.
|
|
- Nested overrides use dot notation. Values support null, booleans, numbers, JSON collections, and quoted JSON strings;
|
|
leading-zero numeric-looking values, `nan`, and `inf` remain strings.
|
|
- `config=<name-or-path>` loads a discovered config name or a `.yaml`, `.yml`, or `.json` file. With no explicit config
|
|
path, `default` is loaded when available.
|
|
- Config files expand `${VAR}` and `${VAR:-default}` recursively. An undefined variable without a default is an error.
|
|
- CLI/config overrides are deep-merged over the loaded file. Do not silently change this merge behavior or stable
|
|
configuration keys.
|
|
- `ApplicationConfig` normalizes `workspace_dir` to an expanded absolute path. `session_dir`
|
|
must remain workspace-relative; standard transcripts live under `{session_dir}/dialog`.
|
|
- `reme start` runs the configured service. `reme start job=<name> ...` switches to the one-shot CLI service and runs
|
|
the job through the normal application lifecycle.
|
|
- Other actions use a client selected from the running service configuration when discoverable, otherwise from local
|
|
config. Client-selection arguments must not leak into the job payload.
|
|
|
|
## Registration and Application Lifecycle
|
|
|
|
Component and Step discovery is import-driven:
|
|
|
|
- Implementations declare a non-`BASE` `component_type` and register with `@R.register("backend")`
|
|
or `R.register(Class, "backend")`.
|
|
- Component packages must be imported through `reme/components/__init__.py`.
|
|
- Step packages/modules must be reachable through their package `__init__.py` chain and ultimately
|
|
`reme/steps/__init__.py`.
|
|
- Adding an implementation without its registration import leaves it undiscoverable at runtime. Treat implementation,
|
|
registration, import side effect, defaults, and tests as one change.
|
|
|
|
`Application` validates config through `ApplicationContext`, creates workspace directories, instantiates the service,
|
|
configured components, and jobs, and then manages lifecycle as follows:
|
|
|
|
- Components start in topological dependency order. Missing required dependencies and cycles fail explicitly; optional
|
|
dependencies may resolve to `None`.
|
|
- Jobs start after components in this order: base jobs, stream jobs, background jobs, then cron jobs.
|
|
- Shutdown closes everything in reverse start order and then shuts down the optional thread pool.
|
|
- If startup fails, already-started resources are closed.
|
|
- `BaseComponent.start()` and `close()` are lock-protected and idempotent. Dependencies created by a standalone
|
|
`default_factory` are owned and closed by the parent component.
|
|
|
|
Keep async clients, tasks, executors, and services under this lifecycle. Do not introduce an untracked long-lived
|
|
resource.
|
|
|
|
## Jobs, Steps, and State
|
|
|
|
`BaseJob` resolves configured Step classes during job startup and constructs fresh Step instances for every invocation.
|
|
Job-level kwargs are merged into each `RuntimeContext`, with call-time kwargs taking precedence. Sequential Steps in one
|
|
invocation share the same `RuntimeContext` and `Response`.
|
|
|
|
Treat Step instances as invocation-scoped:
|
|
|
|
- Constructor fields and `self.kwargs` hold Step configuration and resolved dependencies. They may be cached or adjusted
|
|
during that one invocation, but must not be relied on across Job calls.
|
|
- `self.context.data` holds request inputs and intermediate values shared by sequential Steps.
|
|
- `self.context.response.answer`, `success`, and `metadata` are request-scoped output. Because the same response travels
|
|
through the Step chain, later Steps may consume metadata produced earlier, but it is not application-lifetime or
|
|
durable storage.
|
|
- `self.app_context.metadata` holds in-memory state shared across Job/Step invocations for the life of one
|
|
`Application`, such as counters, tool-context state, session maps, or locks.
|
|
- Workspace files or a dedicated Component/store hold durable state that must survive restart.
|
|
|
|
Use narrow, namespaced keys in `app_context.metadata` and protect shared mutable values against concurrent access. The
|
|
search/draft helpers intentionally mirror tool-context state into
|
|
`self.kwargs` only when no `ApplicationContext` exists for standalone use and unit tests; do not generalize that
|
|
compatibility fallback into persistent runtime state. If shared state becomes a stable service contract or needs
|
|
dedicated lifecycle, locking, or persistence, promote it to a typed context field or Component.
|
|
|
|
Additional Step contracts:
|
|
|
|
- `Ref` dependencies resolve in this order: Step kwargs, current `RuntimeContext`, then the named application component.
|
|
The value is cached only on the current Step instance and cleared before each call.
|
|
- `input_mapping` and `output_mapping` copy keys within `RuntimeContext.data`; missing sources are ignored.
|
|
- Dispatched Steps receive the current `RuntimeContext`, so their data and response are shared.
|
|
- Base jobs convert uncaught Step errors into `Response(success=False)`; stream jobs emit an error chunk and always a
|
|
terminal `DONE`; background jobs let errors reach their supervisor.
|
|
- Background jobs are never service-exposed. MCP also skips stream jobs. Respect `enable_serve`
|
|
and any configured service job allowlist.
|
|
|
|
## Workspace and File Safety
|
|
|
|
- Application startup creates the workspace plus configured metadata, session, memory-session, resource, daily, and
|
|
digest directories.
|
|
- File-operation paths are resolved against the workspace and must stay inside it. Home-relative paths are unsupported,
|
|
traversal escapes are rejected, and `_allowed_paths` restrictions fail closed when invalid.
|
|
- Preserve per-path locking, encoding detection, byte limits, truncation behavior, and optimistic
|
|
`expected_mtime` checks when modifying file operations.
|
|
- Do not bypass the existing file steps or stores in a way that weakens workspace containment.
|
|
- Never write test state into the repository's `.reme/`; use `tmp_path` or another isolated workspace.
|
|
- Do not delete or rewrite user memory to repair an index or make a test pass. Rebuild derived state from source files
|
|
instead.
|
|
|
|
## Validation
|
|
|
|
Use the narrowest useful check while iterating, then broaden it according to risk.
|
|
|
|
Focused test:
|
|
|
|
```bash
|
|
pytest tests/unit/path/to/test_file.py -v
|
|
```
|
|
|
|
Main unit suite:
|
|
|
|
```bash
|
|
pytest tests/unit -v --tb=long -s --log-cli-level=WARNING
|
|
```
|
|
|
|
Repository formatting and lint checks:
|
|
|
|
```bash
|
|
pre-commit run --all-files
|
|
```
|
|
|
|
Black and Flake8 use a 120-character line limit and Python 3.11 formatting; Pylint is also run by pre-commit. If
|
|
`reme_studio/` changes, use its Node 22.13+ scripts and run the proportionate checks from that directory, such as
|
|
`npm run format:check`, `npm run typecheck`, or `npm test`.
|
|
|
|
Integration tests may contact real model providers, services, or agent subprocesses and can require credentials. Do not
|
|
run credentialed or externally mutating tests automatically; run them only when the task requires them and the necessary
|
|
environment has been supplied or authorized. Mock network, model, and subprocess boundaries in unit tests.
|
|
|
|
If documentation or the documentation theme changes, run `npm test` and `npm run build` from `github-pages/`. The Job
|
|
reference is generated from `reme/config/default.yaml`; do not edit generated pages directly.
|
|
|
|
## Change Guardrails
|
|
|
|
- Preserve unrelated user changes in a dirty working tree.
|
|
- Make the smallest coherent change and avoid unrelated cleanup or broad refactors.
|
|
- Documentation should recommend two-stage service usage: start `reme start config=<name-or-path>` in one terminal,
|
|
then call `reme <job-name>` from another. Keep `reme start job=...` in explicitly labeled one-shot CLI sections;
|
|
service-private jobs must retain their documented local execution path.
|
|
- Do not edit generated output when the source can be changed instead. The publish workflow builds
|
|
`reme_studio/web/dist-static` and stages it under `reme_studio/web/python/src/reme_studio/static`; change `reme_studio/` source for
|
|
frontend work.
|
|
- Do not silently change CLI flags, configuration keys, workspace layouts, serialized schemas, endpoint shapes,
|
|
streaming termination, or service interfaces. Preserve compatibility where practical and document intentional
|
|
migrations.
|
|
- Do not introduce dependencies without a concrete repository-level need.
|
|
- Do not commit `.env` files, credentials, runtime memory, logs, indexes, caches, benchmark outputs, or generated
|
|
Studio distributions.
|
|
- State which validations passed and which relevant checks were not run in the final handoff.
|
|
|
|
If a requirement is ambiguous, infer intent from nearby code, schemas, defaults, and tests. Ask the user only when the
|
|
remaining choice would materially alter a public contract, user data, or an external system.
|