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
17 changes: 14 additions & 3 deletions .github/actions/reflect/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
description: >-
Provider id to activate (for example openai, anthropic, gemini, ollama, or
any configured OpenAI-/Anthropic-compatible endpoint). Optional when the
repository already carries a .zero/config.json with an active provider.
repository already carries a .reflect/settings.json with an active provider.
required: false
default: ""
api-key:
Expand Down Expand Up @@ -215,8 +215,10 @@ runs:
fi
export "${REFLECT_INPUT_API_KEY_ENV}=${REFLECT_INPUT_API_KEY}"
fi
# Select the provider through the CLI; Reflect reads the active provider
# from Relay's provider.json, not from an environment variable.
if [ -n "${REFLECT_INPUT_PROVIDER}" ]; then
export REFLECT_PROVIDER="${REFLECT_INPUT_PROVIDER}"
reflect config provider "${REFLECT_INPUT_PROVIDER}"
fi

args=(exec)
Expand All @@ -226,7 +228,16 @@ runs:
exit 2
fi
if [ -n "${REFLECT_INPUT_PROMPT_FILE}" ]; then
args+=(--file "${REFLECT_INPUT_PROMPT_FILE}")
if [ ! -f "${REFLECT_INPUT_PROMPT_FILE}" ]; then
echo "::error::prompt-file not found: ${REFLECT_INPUT_PROMPT_FILE}" >&2
exit 2
fi
prompt="$(cat "${REFLECT_INPUT_PROMPT_FILE}")"
if [ -z "${prompt}" ]; then
echo "::error::prompt-file is empty: ${REFLECT_INPUT_PROMPT_FILE}" >&2
exit 2
fi
args+=("${prompt}")
elif [ -n "${REFLECT_INPUT_PROMPT}" ]; then
args+=("${REFLECT_INPUT_PROMPT}")
else
Expand Down
170 changes: 120 additions & 50 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Extending reflect — how to write AGENTS.md files, custom specialists, skills, hooks, MCP servers, and plugins.
description: Extending reflect — how to write AGENTS.md files, custom agents, skills, hooks, MCP servers, and plugins.
globs: "*.go, *.js, *.md, *.json, *.toml, *.yaml, *.yml"
alwaysApply: false
---
Expand Down Expand Up @@ -50,28 +50,27 @@ Tips:

### Personal guidelines, across every project

For preferences that follow *you*, not a specific repo (tone, tooling habits, workflow), drop a `ZERO.md` in your user config directory: `~/.reflect/ZERO.md` on Linux/macOS, `%AppData%\reflect\ZERO.md` on Windows — the same directory as config files and your personal specialists. Same format and 8 KiB cap as the project files above, and the same case-insensitive basename match.
For preferences that follow *you*, not a specific repo (tone, tooling habits, workflow), drop a `ZERO.md` in your user config directory: `~/.reflect/ZERO.md` on Linux/macOS, `%AppData%\reflect\ZERO.md` on Windows — the same directory as config files and your personal agents. Same format and 8 KiB cap as the project files above, and the same case-insensitive basename match.

This file is injected as its own `## User guidelines` section, before the project's `AGENTS.md`/`ZERO.md`, and is labeled as personal preference in the prompt: project guidelines are the later, more specific instruction and take precedence over it when the two conflict.

## 2. Custom specialists
## 2. Custom agents (personas)

Specialists are reflect's sub-agents. Three scopes, in priority order:
Custom agents are Reflect's user-defined sub-agent personas. They live in one
place only — Reflect user state:

| Scope | Path | Shared? |
| --- | --- | --- |
| Built-in | compiled into reflect | yes |
| User | `~/.reflect/specialists/*.md` | no — your machine only |
| Project | `./.zero/specialists/*.md` | yes — the repo team |

Project overrides user overrides built-in when names collide.
```text
~/.reflect/agents/*.md
```

A specialist is a markdown manifest with frontmatter and a system prompt:
There is no project scope and no built-in/user/project override chain. A persona
is a markdown file with frontmatter and a system prompt:

```markdown
---
name: api-reviewer
description: Reviews API changes for breaking-change risk and missing tests.
tools: read-only,plan
model: inherit
---

You review API changes. For every changed hunk in `internal/api/` or any file
Expand All @@ -86,45 +85,46 @@ that ends in `_api.go`:
Reply with one JSON object per finding: `{"file", "line", "severity", "message", "fix"}`.
```

Frontmatter supports `name`, `description`, and `model` (`inherit` uses the
session model). There is no `tools` field. Use the persona with
`reflect exec --agent api-reviewer` or the agent picker in the TUI.

CLI management:

```bash
reflect specialist list
reflect specialist show api-reviewer
reflect specialist create api-reviewer \
--project \
--description "Reviews API changes" \
--tools read-only,plan \
--prompt "$(cat api-reviewer.md)"
reflect specialist edit api-reviewer --project
reflect specialist delete api-reviewer --project
reflect specialist path # prints the resolved specialists directory
reflect agent list
reflect agent show api-reviewer
reflect agent create api-reviewer --description "Reviews API changes"
reflect agent remove api-reviewer
```

## 3. Skills

reflect ships **no bundled skills** by default. Skills are markdown instruction
files that extend agent capabilities, sourced from the separate
`GrayCodeAI/graycode-skills` repo and installed on demand:
files that extend agent capabilities, installed from any public GitHub
repository on demand:

```bash
reflect skills search <query> # find skills in graycode-skills
reflect skills install <owner/repo> [skill-name] # install after user approval
reflect skills install <owner/repo> [skill-name] # install all or one skill
reflect skills list # list installed skills
reflect skills remove <name>
reflect skills info <name> # details for an installed skill
```

Installed skills live in user or project scope:
- User-scoped: `~/.reflect/skills/`
- Project-scoped: `./.zero/skills/` or `./skills/`
- Project-scoped: Reflect's project state directory under `skills/`

A skill manifest:
`reflect skills search` and `reflect skills trending` read a community index;
there is no published index at this time, so treat those subcommands as
unavailable and install directly from a repository you trust.

A `SKILL.md` manifest:

```markdown
---
description: How to review Go code for security issues
globs: "*.go"
alwaysApply: true
name: go-security-review
description: Reviews Go code for SQL injection, unsafe error handling, hardcoded secrets, and input-validation gaps.
---

When reviewing Go code for security:
Expand All @@ -137,47 +137,117 @@ When reviewing Go code for security:

## 4. Hooks

Hooks allow custom commands to run at specific lifecycle points:
- `beforeReview` — runs before code review starts
- `afterReview` — runs after code review completes
- `sessionStart` — runs at session initialization
- `sessionEnd` — runs at session teardown
Hooks run a command when a Reflect lifecycle event fires. They are file-based
only — there is no `reflect hook` CLI. Create one Markdown file per hook under
`.reflect/hooks/`:

```bash
reflect hook add beforeReview --command "lint-check"
reflect hook remove beforeReview
reflect hook list
```markdown
---
name: format-go
event: PostToolUse
pattern: "*.go"
command: ./scripts/gofmt-changed.sh
timeout: 30
async: true
---

Optional notes; Reflect reads the YAML frontmatter.
```

Frontmatter fields: `name` (defaults to the file name), `event` (required),
`command` (required), `pattern` (glob matched against a payload `path`),
`timeout` (seconds, default 30), and `async`. The command is executed directly,
not through a shell, so use a script for pipes or `&&`.

Canonical events include `session_start`, `user_prompt_submit`, `pre_tool`,
`post_tool`, `post_tool_failure`, `pre_compact`/`post_compact`, `file_changed`,
`permission_ask`/`permission_result`, `subagent_start`/`subagent_stop`,
`task_started`, `session_heartbeat`, `stop`/`stop_failure`, `failure`,
`interrupt`, `notification`, and `test_result`. Vendor spellings such as
`PreToolUse` are normalized to the same events.

Hooks load from `.reflect/hooks/`, `.agents/hooks/`, and `.claude/hooks/`
(project, trust required), plus Reflect's user state and config `hooks/`
directories. Show what loaded with `/hooks` in the TUI. See
[docs/user-guide/10-hooks.md](docs/user-guide/10-hooks.md).

## 5. MCP integration

MCP (Model Context Protocol) servers can expose tools to reflect:
MCP servers are configured as an array in `settings.json` (global
`~/.reflect/settings.json`, project `.reflect/settings.json`):

```json
{
"mcp_servers": [
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
"type": "stdio"
},
{
"name": "linear",
"type": "http",
"url": "https://mcp.linear.app/mcp",
"headers": { "Authorization": "Bearer <token>" }
}
]
}
```

Fields are `name`, `command`, `args`, `type` (`stdio`, `sse`, `http`,
`websocket`), `url`, `headers`, and `client_id`. There is no `enabled` or `env`
field; stdio servers inherit Reflect's environment. Project servers load only
after the folder is trusted. Tools are exposed as `mcp__<server>__<tool>`.

The `reflect mcp` command only covers Reflect acting as an MCP server for
another client:

```bash
reflect mcp add --name server --url http://localhost:8080
reflect mcp remove server
reflect mcp list
reflect mcp serve # run Reflect as an MCP server over stdio
reflect mcp config # print the client configuration block
```

See [docs/mcp-servers.md](docs/mcp-servers.md).

## 6. Plugins

Plugins extend reflect with custom tools and capabilities:
Plugins bundle tools, hooks, skills, and MCP servers into one installable unit.
The command is `reflect plugin` (singular):

```bash
reflect plugin add --name my-plugin --path ./my-plugin
reflect plugin remove my-plugin
reflect plugin list
reflect plugin install owner/repo
reflect plugin install /path/to/local/plugin
reflect plugin inspect my-plugin
reflect plugin activate my-plugin
reflect plugin deactivate my-plugin
reflect plugin reload my-plugin
reflect plugin status
reflect plugin logs my-plugin
reflect plugin uninstall my-plugin
reflect plugin create my-plugin
reflect plugin marketplace list
```

A plugin is a directory with a `plugin.json` manifest plus optional `skills/`,
`hooks/`, and `mcp.json` components. User plugins live in `~/.reflect/plugins/`;
project plugins live in `.reflect/plugins/` and require folder trust. See
[docs/user-guide/09-plugins.md](docs/user-guide/09-plugins.md).

## 7. Verification

reflect includes a self-verification system to validate local changes before contributing:
reflect includes local self-verification that runs without a model:

```bash
reflect verify
reflect verify --fix
```

It checks the tamper-evident security event log hash chain, validates the
managed governance policy when one is installed, and runs any project
test/verify commands discovered in the workspace. It exits non-zero on the
first failure. There is no `--fix` flag.

## Development

```bash
Expand Down
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,17 @@ Each sub-agent runs in its own git worktree with full autonomy.

### Community Skills

Discover and install modular instruction packages for specialized workflows:
Install modular instruction packages for specialized workflows:

```bash
reflect skills search api # Search community registry
reflect skills install go-review # Install from GitHub
reflect skills audit # Security scan installed skills
reflect skills install owner/repo # install from a public GitHub repository
reflect skills list # list installed skills
reflect skills audit # security scan installed skills
```

`reflect skills search` and `reflect skills trending` depend on a community
index that is not published yet, so they currently return no results.

### Plan, Build, Review

The CLI uses its original full-width chat layout, with the input fixed at the
Expand Down Expand Up @@ -494,22 +497,19 @@ reflect/
├── docs/ # Architecture, security, integration docs
└── testdata/ # Test fixtures

Ecosystem sibling repos (independent Git repos in the `graycode-eco` parent
folder):
Sibling repository (a separate Git repo, checked out alongside this one only for
coordinated development):
├── relay/ # LLM provider runtime
```

### Ecosystem

reflect is the main CLI/product and integrates these GrayCodeAI repositories in
three runtime layers plus optional tooling/platform services:
reflect is the end-user product. It has one runtime dependency:

- **relay** — the LLM provider runtime, consumed through its stable engine facade.

- **Primary product:** **reflect** is the only end-user product surface in this ecosystem.
- **Provider engine mounted by Reflect:** **relay** is the LLM provider runtime, consumed through its stable engine facade.
- **API consumers/extensions:** **graycode-skills** provides Reflect skills
installed on demand (`reflect skills install`).
- **Tooling/platform:** **graycode-platform** contains the optional web/BFF/Reflect
Cloud plane and is outside the Reflect Go runtime graph.
An optional hosted control plane (GrayCode Cloud) is operated separately from
this repository and is not required to build, test, or run reflect.

Reflect builds and tests independently against the published Relay version in
`go.mod`. Setup and CI require only this repository.
Expand All @@ -520,8 +520,8 @@ to create a gitignored `go.local.mod` with an explicit local replacement, then r
Verify the normal published dependency graph separately with `make ci`.

Cross-repo contracts now live in `internal/contracts` (vendored from the
removed `github.com/GrayCodeAI/eagle` module) so support repos do not depend
on Reflect internals. External consumers should vendor the needed DTOs from `internal/contracts`
removed `github.com/GrayCodeAI/eagle` module) so external consumers do not depend
on Reflect internals. They should vendor the needed DTOs from `internal/contracts`
until a published contracts module exists.

Current contract packages (`internal/contracts/`):
Expand All @@ -541,21 +541,8 @@ Reflect does not create or modify parent workspaces.
|---|---|---|
| **reflect** | This repo | AI coding agent |
| **relay** | [GrayCodeAI/relay](https://github.com/GrayCodeAI/relay) | LLM provider runtime |
| **graycode-skills** | [GrayCodeAI/graycode-skills](https://github.com/GrayCodeAI/graycode-skills) | Community skill registry |
| **graycode-platform** | [GrayCodeAI/graycode-platform](https://github.com/GrayCodeAI/graycode-platform) | Web, BFF, and Reflect Cloud |

The canonical inventory of sibling repositories is
[`GrayCodeAI/graycode-eco/ecosystem.yaml`](https://github.com/GrayCodeAI/graycode-eco/blob/main/ecosystem.yaml),
not the `ecosystem.yaml` in this repo, which is deprecated and incomplete. The
inventory moved because a product must not own the registry of its siblings: it
lived here, `reflect` was renamed from `hawk` without signalling the other nine
repositories, and the list silently omitted `beam`. See
[graycode-eco/adr/0001](https://github.com/GrayCodeAI/graycode-eco/blob/main/adr/README.md).

`scripts/ecosystem-manifest.sh` reads the roof's file and falls back to the
deprecated local copy only when the roof is not checked out alongside.

`relay` is the only Go module dependency in the entire ecosystem; it is consumed
`relay` is the only Go module dependency in the project; it is consumed
through its stable engine facade.

For the consolidated repo map and the current-vs-proposed architecture diagrams, see [docs/architecture/reflect-current-vs-proposed.md](docs/architecture/reflect-current-vs-proposed.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/COMPETITIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ External star counts below are approximate web-search snapshots (2026-09-08), no

1. **Traction.** reflect has no star-moat. Leaders won via day-1 provider-agnostic + one-liner install + Web/Desktop alongside TUI. reflect ships the verified install script and `go install` today (`README.md` Install) — keep, don't add Desktop.
2. **Language/distro.** Go+MIT+zero-CGO (`Makefile:54`, `go.mod:3`) matches `gh/fzf/lazygit` enterprise-safe profile. Avoid GPL/EUPL patterns (kitty/eza). Rust wave wins on published benchmarks — reflect has `make bench` but publishes none (Gap-04).
3. **Providers.** reflect routes only via `relay/engine` facade (`docs/SECURITY-DEVELOPER.md:51-56`; facade declared in `GrayCodeAI/graycode-eco/ecosystem.yaml`); custom OpenAI-compat supported (`internal/config/settings.go:50`). Count messaging ("28 first-class" per README) trails OpenCode 75+ / Hermes 300+ — fix by exposing catalog count dynamically, not by forking providers into CLI (ownership lives in router per AGENTS.md).
3. **Providers.** reflect routes only via the `relay/engine` facade (`docs/SECURITY-DEVELOPER.md:51-56`; see [`AGENTS.md`](../AGENTS.md)); custom OpenAI-compat is supported (`internal/config/settings.go:50`). The catalog currently ships 29 first-class providers, behind OpenCode's 75+ / Hermes's 300+ — fix by exposing the catalog count dynamically, not by forking providers into the CLI (ownership lives in relay per AGENTS.md).
4. **TUI/UX.** Bubble Tea v2 + vim keys + `/autonomy` + `/spec` + watch `AI!`/`AI?` + visual diff is competitive. Missing vs field: hosted share-link (ours is local `reflect://` deeplink), multi-session grid (we have `mission` worktrees + daemon — unsurfaced like herdr/cmux). Gap-02.
5. **Execution safety.** Host execution keeps onboarding simple, but requires strong permission, path, approval, and audit controls. Keep those controls explicit and testable; do not add a hidden execution backend.
6. **Memory/context.** AST repomap + Harrier graph + compaction segments + relevance-prune + conversation-arc + 80% tool-result clearing exceeds most. Missing: Hermes-style auto-skill learning loop (we have curator archive + harness — surface it).
Expand Down
9 changes: 8 additions & 1 deletion docs/ECOSYSTEM-ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# GrayCode Ecosystem Roadmap (2026)

**Status:** Active · **Last updated:** 2026-09-09
> **HISTORICAL (2026-09-09 snapshot).** This roadmap describes the workspace as
> it stood before the 1.0 releases, including repositories and engine modules
> that were never published. The current products are **Reflect** and
> **Relay**, with **GrayCode Cloud** as the optional hosted control plane. For
> current behavior see [`AGENTS.md`](../AGENTS.md), [`docs/architecture.md`](./architecture.md),
> and the repository `VERSION` files.

**Status:** Historical · **Last updated:** 2026-09-09
**Scope:** the 4 in-workspace repos — `reflect`, `relay`,
`graycode-skills`, `graycode-platform` — plus the 5 external engine repos they
depend on.
Expand Down
Loading
Loading