loreli 0.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +710 -97
- package/bin/loreli.js +89 -0
- package/package.json +77 -14
- package/packages/README.md +101 -0
- package/packages/action/README.md +98 -0
- package/packages/action/prompts/action.md +172 -0
- package/packages/action/src/index.js +684 -0
- package/packages/agent/README.md +606 -0
- package/packages/agent/src/backends/claude.js +387 -0
- package/packages/agent/src/backends/codex.js +351 -0
- package/packages/agent/src/backends/cursor.js +371 -0
- package/packages/agent/src/backends/index.js +486 -0
- package/packages/agent/src/base.js +138 -0
- package/packages/agent/src/cli.js +275 -0
- package/packages/agent/src/discover.js +396 -0
- package/packages/agent/src/factory.js +124 -0
- package/packages/agent/src/index.js +12 -0
- package/packages/agent/src/models.js +159 -0
- package/packages/agent/src/output.js +62 -0
- package/packages/agent/src/session.js +162 -0
- package/packages/agent/src/trace.js +186 -0
- package/packages/classify/README.md +136 -0
- package/packages/classify/prompts/blocker.md +12 -0
- package/packages/classify/prompts/feedback.md +14 -0
- package/packages/classify/prompts/pane-state.md +20 -0
- package/packages/classify/src/index.js +81 -0
- package/packages/config/README.md +898 -0
- package/packages/config/src/defaults.js +145 -0
- package/packages/config/src/index.js +223 -0
- package/packages/config/src/schema.js +291 -0
- package/packages/config/src/validate.js +160 -0
- package/packages/context/README.md +165 -0
- package/packages/context/src/index.js +198 -0
- package/packages/hub/README.md +338 -0
- package/packages/hub/src/base.js +154 -0
- package/packages/hub/src/github.js +1597 -0
- package/packages/hub/src/index.js +79 -0
- package/packages/hub/src/labels.js +48 -0
- package/packages/identity/README.md +288 -0
- package/packages/identity/src/index.js +620 -0
- package/packages/identity/src/themes/avatar.js +217 -0
- package/packages/identity/src/themes/digimon.js +217 -0
- package/packages/identity/src/themes/dragonball.js +217 -0
- package/packages/identity/src/themes/lotr.js +217 -0
- package/packages/identity/src/themes/marvel.js +217 -0
- package/packages/identity/src/themes/pokemon.js +217 -0
- package/packages/identity/src/themes/starwars.js +217 -0
- package/packages/identity/src/themes/transformers.js +217 -0
- package/packages/identity/src/themes/zelda.js +217 -0
- package/packages/knowledge/README.md +217 -0
- package/packages/knowledge/src/index.js +243 -0
- package/packages/log/README.md +93 -0
- package/packages/log/src/index.js +252 -0
- package/packages/marker/README.md +200 -0
- package/packages/marker/src/index.js +184 -0
- package/packages/mcp/README.md +323 -0
- package/packages/mcp/instructions.md +126 -0
- package/packages/mcp/scaffolding/.agents/skills/loreli-context/SKILL.md +89 -0
- package/packages/mcp/scaffolding/ISSUE_TEMPLATE/config.yml +2 -0
- package/packages/mcp/scaffolding/ISSUE_TEMPLATE/loreli.yml +83 -0
- package/packages/mcp/scaffolding/loreli.yml +491 -0
- package/packages/mcp/scaffolding/mcp-configs/.codex/config.toml +4 -0
- package/packages/mcp/scaffolding/mcp-configs/.cursor/mcp.json +14 -0
- package/packages/mcp/scaffolding/mcp-configs/.mcp.json +14 -0
- package/packages/mcp/scaffolding/pull-request.md +23 -0
- package/packages/mcp/src/index.js +600 -0
- package/packages/mcp/src/tools/agent-context.js +44 -0
- package/packages/mcp/src/tools/agents.js +450 -0
- package/packages/mcp/src/tools/context.js +200 -0
- package/packages/mcp/src/tools/github.js +1163 -0
- package/packages/mcp/src/tools/hitl.js +162 -0
- package/packages/mcp/src/tools/index.js +18 -0
- package/packages/mcp/src/tools/refactor.js +227 -0
- package/packages/mcp/src/tools/repo.js +44 -0
- package/packages/mcp/src/tools/start.js +904 -0
- package/packages/mcp/src/tools/status.js +149 -0
- package/packages/mcp/src/tools/work.js +134 -0
- package/packages/orchestrator/README.md +192 -0
- package/packages/orchestrator/src/index.js +1492 -0
- package/packages/planner/README.md +251 -0
- package/packages/planner/prompts/plan-reviewer.md +109 -0
- package/packages/planner/prompts/planner.md +191 -0
- package/packages/planner/prompts/tiebreaker-reviewer.md +71 -0
- package/packages/planner/src/index.js +1381 -0
- package/packages/review/README.md +129 -0
- package/packages/review/prompts/reviewer.md +158 -0
- package/packages/review/src/index.js +1403 -0
- package/packages/risk/README.md +178 -0
- package/packages/risk/prompts/risk.md +272 -0
- package/packages/risk/src/index.js +439 -0
- package/packages/session/README.md +165 -0
- package/packages/session/src/index.js +215 -0
- package/packages/test-utils/README.md +96 -0
- package/packages/test-utils/src/index.js +354 -0
- package/packages/tmux/README.md +261 -0
- package/packages/tmux/src/index.js +501 -0
- package/packages/workflow/README.md +317 -0
- package/packages/workflow/prompts/preamble.md +14 -0
- package/packages/workflow/src/index.js +660 -0
- package/packages/workflow/src/proof-of-life.js +74 -0
- package/packages/workspace/README.md +143 -0
- package/packages/workspace/src/index.js +1127 -0
- package/index.js +0 -8
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# loreli/mcp
|
|
2
|
+
|
|
3
|
+
MCP server for agentic team orchestration via GitHub. Exposes orchestration tools, manages agent lifecycle, and provides a CLI entry point.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
Run this command to start the MCP server over stdio when you want to connect a client directly; the process should stay running and wait for MCP messages.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
loreli mcp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Before using the CLI tool commands below, configure an MCP server entry named `loreli` in your client or global config (for example `~/.cursor/mcp.json`, `~/.claude/.mcp.json`, or `~/.codex/config.toml`). This matters because the CLI resolves tool invocations through that server entry, and without it the commands will fail. When configured correctly, you should see the tool list printed and each command should execute successfully.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
loreli tools list
|
|
17
|
+
loreli tools start --repo owner/repo
|
|
18
|
+
# or rely on repo fallback from loreli.yml / LORELI_REPO
|
|
19
|
+
loreli tools start
|
|
20
|
+
loreli tools team_status
|
|
21
|
+
loreli tools agents --action check
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
All MCP tools are automatically available as CLI commands through `@mcp-layer/cli` once the `loreli` MCP server entry is configured. Run `loreli --help` for the full list.
|
|
25
|
+
|
|
26
|
+
## API Reference
|
|
27
|
+
|
|
28
|
+
### `Loreli` Class
|
|
29
|
+
|
|
30
|
+
The main server class following the uprising start pattern.
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { Loreli } from 'loreli/mcp';
|
|
34
|
+
|
|
35
|
+
const loreli = new Loreli();
|
|
36
|
+
await loreli.start(); // connects stdio transport
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### `loreli.loadInstructions()` -> string
|
|
40
|
+
|
|
41
|
+
Loads the `instructions.md` file that is returned to MCP clients via the protocol's `instructions` field. This gives connected agents context about how Loreli works, its workflow, and review expectations.
|
|
42
|
+
|
|
43
|
+
#### `loreli.tools(tools)`
|
|
44
|
+
|
|
45
|
+
Register tool definitions. Each tool is `{ title, description, schema, exec }`.
|
|
46
|
+
|
|
47
|
+
#### `loreli.prompts(prompts)` / `loreli.resources(resources)`
|
|
48
|
+
|
|
49
|
+
Register prompt and resource definitions.
|
|
50
|
+
|
|
51
|
+
#### `loreli.start(transport?)` -> McpServer
|
|
52
|
+
|
|
53
|
+
Start the server. Defaults to stdio transport.
|
|
54
|
+
|
|
55
|
+
## MCP Tools
|
|
56
|
+
|
|
57
|
+
All tools are visible at all times. No progressive disclosure — every tool is available from the first connection.
|
|
58
|
+
|
|
59
|
+
### Start & Environment
|
|
60
|
+
|
|
61
|
+
| Tool | Description |
|
|
62
|
+
|------|-------------|
|
|
63
|
+
| `start` | Initialize orchestration for a target GitHub repo. Accepts `--repo`, or falls back to configured `repo` from `loreli.yml` / `LORELI_REPO`. Validates access, discovers/scaffolds templates, creates project board. Idempotent — safe to re-run. |
|
|
64
|
+
| `environment` | Report detected environment: tmux, backends, providers, review strategy. |
|
|
65
|
+
|
|
66
|
+
### Team Management
|
|
67
|
+
|
|
68
|
+
| Tool | Description |
|
|
69
|
+
|------|-------------|
|
|
70
|
+
| `add_agent` | Add an agent. Params: `provider` (`openai`, `anthropic`, `cursor-openai`, `cursor-anthropic`), `role` (`planner`, `action`, `reviewer`), `model`, `theme`. |
|
|
71
|
+
| `agents` | Query agent team state. Actions: `list` (show all agents with state, identity, role, and terminal output; optional `lines` param, default 40), `check` (liveness check for one or all agents). |
|
|
72
|
+
| `start_planning` | Activate planner agents to analyze the repo and create draft work items. Accepts an `objective` to guide the planner. Uses explicit `repo` argument when provided, otherwise falls back to configured `repo`. |
|
|
73
|
+
| `start_work` | Begin action/review cycle. Action agents claim issues, do work, create PRs. Review agents are auto-assigned via yin/yang pairing. Uses explicit `repo` argument when provided, otherwise falls back to configured `repo`. |
|
|
74
|
+
| `team_status` | Dashboard: issues, PRs, agent states with terminal snapshots (last 20 lines), review loops, PRs awaiting human review, and GitHub API rate limits. Uses explicit `repo` argument when provided, otherwise falls back to configured `repo`. |
|
|
75
|
+
|
|
76
|
+
### Agent Tools (Agent-Only)
|
|
77
|
+
|
|
78
|
+
| Tool | Description |
|
|
79
|
+
|------|-------------|
|
|
80
|
+
| `plan` | Plan lifecycle management. Actions: `create` (new discussion), `revise` (update after feedback), `verdict` (approve/reject as reviewer), `escalate` (flag process or architecture concerns). |
|
|
81
|
+
| `pr` | Pull request lifecycle. Actions: `create` (open PR from branch), `review` (submit adversarial review). |
|
|
82
|
+
| `comment` | Post a comment on the agent's current work item. Set `claim: true` to claim an issue, `abandon: true` to abandon. |
|
|
83
|
+
| `read` | Read any issue, PR, or discussion by number. |
|
|
84
|
+
| `refactor` | Flag a bug, code smell, or tech debt discovered during implementation. Action agents only. Creates a deduplicated Loreli discussion labeled `loreli:refactor` that enters the standard review/promote pipeline. |
|
|
85
|
+
| `context` | Resolve code context. Actions: `blame`, `history`, `search`, `patterns`. |
|
|
86
|
+
| `environment` | Report detected environment: tmux, backends, providers, review strategy. |
|
|
87
|
+
|
|
88
|
+
#### `refactor` Tool
|
|
89
|
+
|
|
90
|
+
Enables [opportunistic refactoring](https://martinfowler.com/bliki/OpportunisticRefactoring.html) — action agents report improvements they discover without leaving their assigned scope.
|
|
91
|
+
|
|
92
|
+
**Parameters:**
|
|
93
|
+
|
|
94
|
+
| Parameter | Type | Required | Description |
|
|
95
|
+
|-----------|------|----------|-------------|
|
|
96
|
+
| `kind` | `string` | yes | Category: `bug`, `refactor`, `smell`, or `debt` |
|
|
97
|
+
| `title` | `string` | yes | Concise improvement title |
|
|
98
|
+
| `description` | `string` | yes | Problem statement with stable identifiers (function names, class names, error messages) |
|
|
99
|
+
| `files` | `string[]` | no | Affected file paths, optionally with line range hints |
|
|
100
|
+
| `impact` | `string` | no | `low`, `medium` (default), or `high` |
|
|
101
|
+
|
|
102
|
+
**File path format:**
|
|
103
|
+
|
|
104
|
+
File entries accept plain paths or paths with GitHub-style line range hints:
|
|
105
|
+
|
|
106
|
+
- `src/hub.js` — plain path
|
|
107
|
+
- `packages/hub/src/github.js#R40-R50` — path with line range hint (lines 40–50)
|
|
108
|
+
|
|
109
|
+
Line ranges are advisory hints; they may drift between commits. Always include stable identifiers (function names, error patterns) in the `description`.
|
|
110
|
+
|
|
111
|
+
**Dedup behavior:**
|
|
112
|
+
|
|
113
|
+
Before creating a discussion, the tool searches existing issues and `loreli:refactor`-labeled discussions by normalized title. If a match is found, it returns an "Already tracked" reference instead of creating a duplicate. Dedup is best-effort — parallel reports can race.
|
|
114
|
+
|
|
115
|
+
**Pipeline integration:**
|
|
116
|
+
|
|
117
|
+
Created discussions enter the existing planner review/revise/promote pipeline. When promoted to issues, the `loreli:refactor` label is carried to the new issue for tracking.
|
|
118
|
+
|
|
119
|
+
### Human In The Loop (HITL)
|
|
120
|
+
|
|
121
|
+
| Tool | Description |
|
|
122
|
+
|------|-------------|
|
|
123
|
+
| `hitl` | Hand off a PR to human reviewers (Human In The Loop). Requests review, assigns users, posts summary comment tagging reviewers. Kills agents to conserve resources. Uses explicit `repo` argument when provided, otherwise falls back to configured `repo`. |
|
|
124
|
+
| `watch` | Check an HITL PR for new human feedback. Filters out agent comments. Returns comments posted after the HITL timestamp. Uses explicit `repo` argument when provided, otherwise falls back to configured `repo`. |
|
|
125
|
+
|
|
126
|
+
### Agent Lifecycle
|
|
127
|
+
|
|
128
|
+
| Tool | Description |
|
|
129
|
+
|------|-------------|
|
|
130
|
+
| `stop` | Stop an agent by name. Actions: `shutdown` (graceful, agent finishes current work then exits; escalates to kill after timeout), `kill` (immediate forced termination of tmux pane). |
|
|
131
|
+
|
|
132
|
+
## Start Repair
|
|
133
|
+
|
|
134
|
+
Start is an idempotent repair operation. Every invocation discovers which required files exist and scaffolds any that are missing. Safe to re-run.
|
|
135
|
+
|
|
136
|
+
```mermaid
|
|
137
|
+
flowchart TD
|
|
138
|
+
Discover["discover templates via hub.read"] --> Check{"Missing files?"}
|
|
139
|
+
Check -->|yes| Scaffold["scaffold via hub.write"]
|
|
140
|
+
Check -->|no| Load
|
|
141
|
+
Scaffold --> Load["config.load via hub"]
|
|
142
|
+
Load --> Merge["config.merge(args)"]
|
|
143
|
+
Merge --> Session["storage.init(session, config)"]
|
|
144
|
+
Session --> Report["Report: found + scaffolded"]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Required Files
|
|
148
|
+
|
|
149
|
+
| File | Scaffold Source | Discover Key |
|
|
150
|
+
|------|----------------|--------------|
|
|
151
|
+
| `.github/pull_request_template.md` | `scaffolding/pull-request.md` | `pr` |
|
|
152
|
+
| `.github/ISSUE_TEMPLATE/` | `scaffolding/ISSUE_TEMPLATE/` | `issue` |
|
|
153
|
+
| `loreli.yml` | `scaffolding/loreli.yml` | `config` |
|
|
154
|
+
|
|
155
|
+
## Scaffolding Templates
|
|
156
|
+
|
|
157
|
+
Default templates for empty repos, read from `scaffolding/`:
|
|
158
|
+
|
|
159
|
+
- `pull-request.md` — PR template with Summary, Changes, Testing, Issue Reference, Sign-off
|
|
160
|
+
- `ISSUE_TEMPLATE/loreli.yml` — Structured issue form mirroring the planner output format: Objective, Acceptance Criteria, Testing Strategy, Scope Boundaries, Dependencies, Estimated Complexity. Auto-applies the `loreli` label so issues enter the dispatch pipeline immediately.
|
|
161
|
+
- `ISSUE_TEMPLATE/config.yml` — Issue template configuration (blank issues disabled to ensure all issues use the structured template and receive the `loreli` label)
|
|
162
|
+
- `loreli.yml` — Default config with all keys documented via inline comments
|
|
163
|
+
|
|
164
|
+
Issue templates use the [new YAML-based issue form workflow](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository) instead of the deprecated single-file Markdown format. The template guides authors toward writing agent-actionable prompts with mandatory acceptance criteria and testing strategy, matching the same structure the planner produces.
|
|
165
|
+
|
|
166
|
+
## Orchestrator
|
|
167
|
+
|
|
168
|
+
The `Orchestrator` class manages the full lifecycle:
|
|
169
|
+
|
|
170
|
+
1. **Plan** — Planner creates drafts on project board, reviewer challenges
|
|
171
|
+
2. **Promote** — Approved drafts become real issues
|
|
172
|
+
3. **Action** — Agents claim issues, create PRs
|
|
173
|
+
4. **Review** — Cross-provider adversarial review
|
|
174
|
+
5. **HITL** (optional) — Hand off to human reviewers, kill agents
|
|
175
|
+
6. **Merge** — Dual sign-off triggers merge (auto), or human merges (HITL)
|
|
176
|
+
|
|
177
|
+
### Orchestrator Lifecycle
|
|
178
|
+
|
|
179
|
+
```mermaid
|
|
180
|
+
stateDiagram-v2
|
|
181
|
+
[*] --> Init: start
|
|
182
|
+
Init --> Planning: start_planning(objective)
|
|
183
|
+
Planning --> Promoting: drafts approved
|
|
184
|
+
Promoting --> Working: start_work
|
|
185
|
+
Working --> Reviewing: PR opened
|
|
186
|
+
Reviewing --> Working: feedback
|
|
187
|
+
Reviewing --> Gating: dual sign-off
|
|
188
|
+
Gating --> Merged: auto-merge
|
|
189
|
+
Gating --> AwaitingHuman: HITL
|
|
190
|
+
AwaitingHuman --> Merged: human merges
|
|
191
|
+
AwaitingHuman --> Rework: human comments
|
|
192
|
+
Rework --> Reviewing: fresh agent
|
|
193
|
+
Merged --> [*]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Stall Detection (Escalation Tiers)
|
|
197
|
+
|
|
198
|
+
The orchestrator monitors agents for inactivity with three escalation tiers:
|
|
199
|
+
|
|
200
|
+
| Tier | Trigger | Action |
|
|
201
|
+
|------|---------|--------|
|
|
202
|
+
| **Nudge** | 1x `timeouts.stall` | Send a message to the agent asking for status |
|
|
203
|
+
| **Warning** | 2x `timeouts.stall` | Post a visible GitHub comment on the agent's claimed issue |
|
|
204
|
+
| **Reassign** | 3x `timeouts.stall` | Kill the agent, release all claimed issues, emit event |
|
|
205
|
+
|
|
206
|
+
When an agent is killed via stall detection (tier 3), its claimed issues are released so `start_work` can re-assign them to a fresh agent.
|
|
207
|
+
|
|
208
|
+
### Issue Reassignment
|
|
209
|
+
|
|
210
|
+
When an agent is killed (`stop` action: `kill`) or shut down (`stop` action: `shutdown`), any GitHub issues claimed by that agent are automatically released. This prevents dead agents from blocking work:
|
|
211
|
+
|
|
212
|
+
1. Scan open issues for the agent's claim comments
|
|
213
|
+
2. Post a release comment on each claimed issue
|
|
214
|
+
3. Remove agent-specific labels
|
|
215
|
+
4. Issue becomes available for re-claim by `start_work`
|
|
216
|
+
|
|
217
|
+
### Structured Shutdown Protocol
|
|
218
|
+
|
|
219
|
+
Agent shutdown follows a 3-phase protocol:
|
|
220
|
+
|
|
221
|
+
1. **Request** — Send a structured shutdown message with a unique `requestId` and optional reason
|
|
222
|
+
2. **Poll** — Wait for the agent to acknowledge (exits or transitions to dormant)
|
|
223
|
+
3. **Cleanup** — Force stop, release claimed issues, remove from registry
|
|
224
|
+
|
|
225
|
+
The `requestId` prevents confusion between concurrent shutdown requests. If the agent doesn't acknowledge within the timeout, it is force-stopped.
|
|
226
|
+
|
|
227
|
+
### Plan Review
|
|
228
|
+
|
|
229
|
+
When `start_planning` dispatches to planner agents, a reviewer agent (if available) is automatically assigned to adversarially review the resulting drafts. This leverages the yin/yang pairing to get cross-provider plan review before drafts are promoted to issues.
|
|
230
|
+
|
|
231
|
+
### Human In The Loop (HITL)
|
|
232
|
+
|
|
233
|
+
```mermaid
|
|
234
|
+
sequenceDiagram
|
|
235
|
+
participant Action as ActionAgent
|
|
236
|
+
participant Reviewer as ReviewAgent
|
|
237
|
+
participant GH as GitHub PR
|
|
238
|
+
participant Orch as Orchestrator
|
|
239
|
+
participant Human as Human Reviewer
|
|
240
|
+
|
|
241
|
+
Action->>GH: Opens PR
|
|
242
|
+
Reviewer->>GH: Reviews PR
|
|
243
|
+
Action->>GH: Addresses feedback
|
|
244
|
+
Reviewer->>GH: Approves
|
|
245
|
+
Action->>GH: Signs off
|
|
246
|
+
Orch->>Orch: config.get merge.hitl
|
|
247
|
+
alt hitl = false
|
|
248
|
+
Orch->>GH: Merge PR
|
|
249
|
+
else hitl = true
|
|
250
|
+
Orch->>GH: Request review + assign reviewers
|
|
251
|
+
Orch->>GH: Post summary comment @tagging reviewers
|
|
252
|
+
Orch->>Orch: Kill both agents
|
|
253
|
+
Note over GH: awaiting_hitl
|
|
254
|
+
Human->>GH: Merge OR comment
|
|
255
|
+
alt human merges
|
|
256
|
+
Note over GH: Done
|
|
257
|
+
else human comments
|
|
258
|
+
Orch->>Orch: Spawn fresh agent
|
|
259
|
+
Action->>GH: Address feedback + push
|
|
260
|
+
Orch->>GH: Re-request + re-assign
|
|
261
|
+
Orch->>Orch: Kill agent
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
HITL is activated when `loreli.yml` has a non-empty `reviewers` list or `merge.hitl` is set to `true`.
|
|
267
|
+
|
|
268
|
+
## CLI
|
|
269
|
+
|
|
270
|
+
The CLI is powered by `@mcp-layer/cli`, which automatically exposes all MCP tools as CLI commands.
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Start the MCP server (required when used as MCP server)
|
|
274
|
+
loreli mcp
|
|
275
|
+
|
|
276
|
+
# All tools are available as subcommands
|
|
277
|
+
loreli tools list
|
|
278
|
+
loreli tools start --repo owner/repo
|
|
279
|
+
loreli tools add_agent --provider anthropic --role action
|
|
280
|
+
loreli tools team_status
|
|
281
|
+
loreli tools agents --action check --name optimus-0
|
|
282
|
+
|
|
283
|
+
# Default (no args) shows help
|
|
284
|
+
loreli
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Input Validation
|
|
288
|
+
|
|
289
|
+
All tool handlers validate inputs before any side effects using `check.*` from `loreli/config`:
|
|
290
|
+
|
|
291
|
+
| Validator | Rule |
|
|
292
|
+
|-----------|------|
|
|
293
|
+
| `check.repo(str)` | Must match `owner/name` format |
|
|
294
|
+
| `check.name(str)` | Alphanumeric + hyphens/underscores, max 64 chars |
|
|
295
|
+
| `check.role(str)` | Must be `planner`, `action`, or `reviewer` |
|
|
296
|
+
| `check.theme(str)` | Must be one of the supported themes (`transformers`, `pokemon`, `marvel`, `digimon`, `starwars`, `lotr`, `dragonball`, `avatar`, `zelda`) |
|
|
297
|
+
| `check.provider(str)` | Must be `openai`, `anthropic`, `cursor-openai`, or `cursor-anthropic` |
|
|
298
|
+
| `check.positive(n, label)` | Must be a finite positive number |
|
|
299
|
+
|
|
300
|
+
Invalid inputs throw immediately with descriptive error messages before any GitHub API calls or state mutations.
|
|
301
|
+
|
|
302
|
+
## Dynamic Tool Descriptions
|
|
303
|
+
|
|
304
|
+
After start discovers available backends, the `add_agent` tool description is dynamically updated to list available backends, model aliases, and providers. MCP clients receive a `tools/list_changed` notification so they can refresh the tool list.
|
|
305
|
+
|
|
306
|
+
## Client Detection
|
|
307
|
+
|
|
308
|
+
The server identifies the connected MCP client via the standard `initialize` handshake. The `clientInfo` field (name, version) from the handshake is used to build a lightweight `Identity` for stamping tool-originated content. This replaces the previous sampling-based probe which was fragile and optional.
|
|
309
|
+
|
|
310
|
+
## Error Handling
|
|
311
|
+
|
|
312
|
+
| Scenario | Behavior |
|
|
313
|
+
|----------|----------|
|
|
314
|
+
| Spawn fails | All steps rolled back in reverse order, identity released, error propagated |
|
|
315
|
+
| Agent stalls | Tier 1: nudge, Tier 2: GitHub comment, Tier 3: kill and reassign |
|
|
316
|
+
| Shutdown timeout | Force stop after timeout, issues released |
|
|
317
|
+
| Agent killed | Issues reassigned, identity released, labels cleaned |
|
|
318
|
+
| Invalid tool input | Descriptive error thrown before any side effects |
|
|
319
|
+
| No backends found | Clear error with installation guidance |
|
|
320
|
+
| Hub unavailable | Tool returns error with guidance |
|
|
321
|
+
| No planner agents | `start_planning` returns error |
|
|
322
|
+
| No unclaimed issues | `start_work` returns "no unclaimed issues" message |
|
|
323
|
+
| tmux missing | `loreli mcp` exits with install instructions |
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
You are connected to **Loreli**, an agentic team orchestration server that coordinates AI agents using GitHub as the collaboration layer.
|
|
2
|
+
|
|
3
|
+
<overview>
|
|
4
|
+
|
|
5
|
+
Loreli manages teams of AI agents that work on GitHub repositories. Issues are tasks, pull requests are deliverables, discussions are plans, comments are communication, and reviews are quality gates.
|
|
6
|
+
|
|
7
|
+
### Workflow
|
|
8
|
+
|
|
9
|
+
1. **Start**: Point Loreli at a target GitHub repository. It validates access, discovers existing files, and scaffolds any missing ones (PR template, issue template, `loreli.yml`). This is idempotent — safe to re-run.
|
|
10
|
+
2. **Plan**: Planner agents create plan discussions in the Loreli category using the `plan` tool. A polar-opposite reviewer challenges the plan using the `plan` tool (action: `verdict`).
|
|
11
|
+
3. **Action**: Action agents claim approved issues (first-comment-wins), create branches, implement work, and open PRs using the `pr` tool.
|
|
12
|
+
4. **Review**: Cross-provider reviewers assess PRs adversarially using the `pr` tool (action: `review`). Feedback is addressed in iteration loops.
|
|
13
|
+
5. **Human In The Loop (HITL)** (optional): If `loreli.yml` has `reviewers` configured, PRs are handed off to human reviewers after agent approval. Agents are shut down while awaiting human decision.
|
|
14
|
+
6. **Merge**: Dual sign-off triggers merge (auto), or human merges manually (HITL). Agents go dormant or claim new work.
|
|
15
|
+
|
|
16
|
+
### Configuration
|
|
17
|
+
|
|
18
|
+
Each target repository can have a `loreli.yml` in its root to configure orchestration behavior — theme, merge method, human reviewers, timeouts, and more. If the file doesn't exist, start scaffolds a default one. Start params override `loreli.yml` values.
|
|
19
|
+
|
|
20
|
+
### Agent Identity
|
|
21
|
+
|
|
22
|
+
Agents are assigned themed identities (Transformers, Pokemon, Marvel, Digimon) with yin/yang provider pairing. OpenAI agents get one faction, Anthropic agents get the opposing faction. This creates adversarial quality checks.
|
|
23
|
+
|
|
24
|
+
### Backends
|
|
25
|
+
|
|
26
|
+
Loreli supports multiple backends: Claude (interactive, Anthropic), Cursor Agent (interactive, multi-provider), Codex (interactive, OpenAI). The `environment` tool shows which backends are available. When adding agents, use `provider: "anthropic"` for Claude, `provider: "openai"` for Codex, or `provider: "multi"` for Cursor Agent (which can run models from any provider).
|
|
27
|
+
|
|
28
|
+
</overview>
|
|
29
|
+
|
|
30
|
+
<protocols>
|
|
31
|
+
|
|
32
|
+
### Claim Protocol
|
|
33
|
+
|
|
34
|
+
Issues are claimed via first-comment-wins. When an agent wants to work on an issue, it posts a claim comment using the `comment` tool. The first claim comment's author is the assigned agent.
|
|
35
|
+
|
|
36
|
+
### Review Expectations
|
|
37
|
+
|
|
38
|
+
- Address all review feedback before requesting re-review.
|
|
39
|
+
- Both the action agent and review agent must sign off for merge.
|
|
40
|
+
- Escalate scope concerns using the `plan` tool (action: `escalate`).
|
|
41
|
+
|
|
42
|
+
### Human In The Loop (HITL)
|
|
43
|
+
|
|
44
|
+
When configured, after both agents sign off:
|
|
45
|
+
|
|
46
|
+
1. Loreli requests review from the configured human reviewers.
|
|
47
|
+
2. Agents are shut down to conserve resources.
|
|
48
|
+
3. If the human merges, the workflow is complete.
|
|
49
|
+
4. If the human posts comments, Loreli spawns a fresh agent to address the feedback and re-requests review.
|
|
50
|
+
|
|
51
|
+
### Communication
|
|
52
|
+
|
|
53
|
+
All communication happens through GitHub: issue comments, PR comments, discussion comments, and reviews. There are no private channels — everything is visible and auditable.
|
|
54
|
+
|
|
55
|
+
</protocols>
|
|
56
|
+
|
|
57
|
+
<tool_contract>
|
|
58
|
+
|
|
59
|
+
## Agent Tool Contract
|
|
60
|
+
|
|
61
|
+
When you are a spawned agent (planner, action, or reviewer), use the Loreli MCP tools for all GitHub operations. Your identity, repository, and current work item are resolved automatically from your session.
|
|
62
|
+
|
|
63
|
+
### Available Agent Tools
|
|
64
|
+
|
|
65
|
+
| Tool | Actions | Used By |
|
|
66
|
+
|------|---------|---------|
|
|
67
|
+
| **plan** | `create`, `revise`, `verdict`, `escalate` | Planner creates/revises; Reviewer renders verdict; Any role escalates |
|
|
68
|
+
| **pr** | `create`, `review` | Action creates PRs; Reviewer submits reviews |
|
|
69
|
+
| **comment** | (none) | Any role posts comments on their current work item |
|
|
70
|
+
| **read** | (none) | Any role reads issues, PRs, or discussions by number |
|
|
71
|
+
| **refactor** | (none) | Action flags bugs, smells, debt for planning |
|
|
72
|
+
| **context** | `blame`, `history`, `search`, `patterns` | Any role looks up code context, decision history, and feedback patterns |
|
|
73
|
+
| **environment** | (none) | Any role checks available backends |
|
|
74
|
+
|
|
75
|
+
### Context Resolution
|
|
76
|
+
|
|
77
|
+
Your session automatically provides:
|
|
78
|
+
- **Repository**: The target repo you are assigned to.
|
|
79
|
+
- **Identity**: Your themed identity with stamp and labels.
|
|
80
|
+
- **Role**: Your role (planner, action, reviewer).
|
|
81
|
+
- **Task**: Your current work item (discussion number, issue number, or PR number).
|
|
82
|
+
|
|
83
|
+
You do not need to provide these values — the tools resolve them from your session.
|
|
84
|
+
|
|
85
|
+
### Role Enforcement
|
|
86
|
+
|
|
87
|
+
Tools enforce role boundaries server-side:
|
|
88
|
+
|
|
89
|
+
| Action | Allowed Role | Blocked Roles |
|
|
90
|
+
|--------|-------------|---------------|
|
|
91
|
+
| `plan/create`, `plan/revise` | planner | action, reviewer |
|
|
92
|
+
| `plan/verdict` | reviewer | planner, action |
|
|
93
|
+
| `pr/create` | action | planner, reviewer |
|
|
94
|
+
| `pr/review` | reviewer | planner, action |
|
|
95
|
+
| `refactor` | action | planner, reviewer |
|
|
96
|
+
| `plan/escalate`, `comment` | any | — |
|
|
97
|
+
| `context/*`, `read`, `environment` | any | — |
|
|
98
|
+
|
|
99
|
+
An action agent cannot approve its own PR. A planner cannot approve its own plan. The antagonist (opposing-provider reviewer) is always mandatory and auto-enlisted when missing.
|
|
100
|
+
|
|
101
|
+
### Context Tool
|
|
102
|
+
|
|
103
|
+
The `context` tool resolves code context — tracing lines to the PRs, issues, and discussions that shaped them. Use it to understand why code exists before changing it.
|
|
104
|
+
|
|
105
|
+
| Action | What it does |
|
|
106
|
+
|--------|-------------|
|
|
107
|
+
| `blame` | Trace a file+line to the commit, author, and associated PRs |
|
|
108
|
+
| `history` | View the commit history for a file with linked PR references |
|
|
109
|
+
| `search` | Search issues and PRs by keyword to find past decisions |
|
|
110
|
+
| `patterns` | View recurring review feedback patterns across PRs and plan discussions |
|
|
111
|
+
|
|
112
|
+
Also available via CLI: `loreli tools context --action blame --file <path> --line <N>`
|
|
113
|
+
|
|
114
|
+
</tool_contract>
|
|
115
|
+
|
|
116
|
+
<rules>
|
|
117
|
+
|
|
118
|
+
1. **Never bypass the tools**: All GitHub interactions must go through Loreli MCP tools. Direct `gh` CLI, REST, or GraphQL calls bypass stamping and label enforcement.
|
|
119
|
+
2. **Never manage labels manually**: Labels are applied automatically by the tools. Do not add, remove, or modify `loreli:*` labels yourself.
|
|
120
|
+
3. **Stay within scope**: If you discover work outside your current assignment, use the `plan` tool (action: `escalate`) to flag it.
|
|
121
|
+
4. **Respect your role**: Only use actions permitted for your role. Attempting unauthorized actions wastes tokens and time.
|
|
122
|
+
5. **Honor repository policy files**: If `AGENTS.md` exists in the repository root, treat it as authoritative repository policy input.
|
|
123
|
+
6. **Follow role prompt quality gates**: Testing and style-quality requirements are enforced in role-specific prompts and review flows; do not bypass them.
|
|
124
|
+
7. **Flag improvements opportunistically**: When you encounter bugs, code smells, or tech debt during your work, use the `refactor` tool immediately. Do not fix out-of-scope issues yourself — flag them and continue your task. The dedup gate prevents duplicate reports. Use `plan` (action: `escalate`) for process or architecture concerns, not code-level findings.
|
|
125
|
+
|
|
126
|
+
</rules>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: loreli-context
|
|
3
|
+
description: Use when modifying unfamiliar code, investigating patterns, or reviewing PRs — resolves code to its full decision chain via git blame, PR history, issue tracking, and discussion threads
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Loreli Context
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Loreli maintains a complete decision chain for every line of code: commits link to PRs, PRs link to issues, and issues link to planning discussions. This skill teaches you how to query that chain.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Understand why code exists before changing it.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- Before modifying code you did not write
|
|
17
|
+
- When encountering a pattern or convention you do not understand
|
|
18
|
+
- When reviewing PRs with unclear rationale
|
|
19
|
+
- Before making architectural decisions (check what has been tried before)
|
|
20
|
+
- When debugging to understand historical context of a module
|
|
21
|
+
|
|
22
|
+
## CLI Commands
|
|
23
|
+
|
|
24
|
+
All commands are run in the terminal via the loreli CLI:
|
|
25
|
+
|
|
26
|
+
### Blame — "Why was this line written?"
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
loreli tools context --action blame --file <path> --line <N>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Traces a specific line to the commit that created it, the PR that landed it, the issue it addressed, and the discussion where it was planned. Includes agent traces if available.
|
|
33
|
+
|
|
34
|
+
### History — "What decisions shaped this file?"
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
loreli tools context --action history --file <path> --limit <N>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Returns recent commits touching a file with their associated PRs. Default limit is 10. Use this to understand the evolution of a module before making changes.
|
|
41
|
+
|
|
42
|
+
### Search — "What do we know about X?"
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
loreli tools context --action search --query "<keywords>"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Searches across issues, PRs, and discussions for matching content. Use this to find prior discussions about a concept, pattern, or decision.
|
|
49
|
+
|
|
50
|
+
### Patterns — "What recurring review themes exist?"
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
loreli tools context --action patterns --category <category>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Shows recurring feedback patterns across PR reviews and plan discussion verdicts. Categories: naming, architecture, testing, documentation, performance, security. Each pattern lists its source refs as `PR #N` or `Discussion #N` so you can trace feedback origin. Check this before submitting PRs to avoid known issues.
|
|
57
|
+
|
|
58
|
+
## Documentation Requirements
|
|
59
|
+
|
|
60
|
+
When working on code, maintain these documentation standards:
|
|
61
|
+
|
|
62
|
+
### Architectural Changes
|
|
63
|
+
|
|
64
|
+
If you add new packages, modules, or change data flow:
|
|
65
|
+
|
|
66
|
+
- Create or update architecture diagrams in `docs/`
|
|
67
|
+
- Explain the decision and alternatives considered
|
|
68
|
+
- Link back to the discussion/issue where the change was planned
|
|
69
|
+
|
|
70
|
+
### Error Handling
|
|
71
|
+
|
|
72
|
+
If you add new error handling:
|
|
73
|
+
|
|
74
|
+
- Document each error with resolution steps
|
|
75
|
+
- Steps must be followable by anyone regardless of skill level
|
|
76
|
+
- Include the error message, cause, and fix
|
|
77
|
+
|
|
78
|
+
### API Documentation
|
|
79
|
+
|
|
80
|
+
If you add exported functions, endpoints, or tool definitions:
|
|
81
|
+
|
|
82
|
+
- Document parameters, return shapes, and error behavior
|
|
83
|
+
- Update the package README
|
|
84
|
+
|
|
85
|
+
## Lore Maintenance
|
|
86
|
+
|
|
87
|
+
- When decisions change, update the relevant docs
|
|
88
|
+
- Link docs to the discussion/issue where the decision was made
|
|
89
|
+
- Use `loreli tools context --action search` to find existing docs before creating new ones
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Loreli Work Item
|
|
2
|
+
description: Structured work item for Loreli agent orchestration. Issues created with this template are automatically labeled for agent dispatch.
|
|
3
|
+
title: "[Loreli]: "
|
|
4
|
+
labels: ["loreli"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
This template produces issues that Loreli agents can act on directly.
|
|
10
|
+
Write each section as if briefing an engineer who has never seen this
|
|
11
|
+
codebase — specific, testable, and unambiguous.
|
|
12
|
+
|
|
13
|
+
- type: textarea
|
|
14
|
+
id: objective
|
|
15
|
+
attributes:
|
|
16
|
+
label: Objective
|
|
17
|
+
description: What needs to be done, in one sentence. Be precise — this becomes the agent's mission.
|
|
18
|
+
placeholder: "Add exponential backoff retry logic to the GitHub API client for transient failures."
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
21
|
+
|
|
22
|
+
- type: textarea
|
|
23
|
+
id: acceptance
|
|
24
|
+
attributes:
|
|
25
|
+
label: Acceptance Criteria
|
|
26
|
+
description: >
|
|
27
|
+
Specific, testable conditions that define "done". Each criterion must be
|
|
28
|
+
independently verifiable by someone who did not write the code. Aim for
|
|
29
|
+
3+ criteria — vague items like "works correctly" will be rejected.
|
|
30
|
+
placeholder: |
|
|
31
|
+
- [ ] Retries on 429 and 5xx status codes, up to 3 attempts.
|
|
32
|
+
- [ ] Uses exponential backoff: 1s, 2s, 4s base delays with jitter.
|
|
33
|
+
- [ ] Non-retryable errors (4xx except 429) propagate immediately.
|
|
34
|
+
- [ ] Retry attempts are logged with attempt number and delay.
|
|
35
|
+
validations:
|
|
36
|
+
required: true
|
|
37
|
+
|
|
38
|
+
- type: textarea
|
|
39
|
+
id: testing
|
|
40
|
+
attributes:
|
|
41
|
+
label: Testing Strategy
|
|
42
|
+
description: >
|
|
43
|
+
Concrete test scenarios to write before implementation (TDD). Name
|
|
44
|
+
specific inputs, expected behaviors, and edge cases. Agents write
|
|
45
|
+
tests first — this section tells them what to test.
|
|
46
|
+
placeholder: |
|
|
47
|
+
- Test that 429 responses trigger retry with correct backoff timing.
|
|
48
|
+
- Test that 500/502/503 trigger retry.
|
|
49
|
+
- Test that 400/401/404 propagate immediately without retry.
|
|
50
|
+
- Test that max retries is respected and final error surfaces.
|
|
51
|
+
- Test jitter produces non-deterministic delays within expected bounds.
|
|
52
|
+
validations:
|
|
53
|
+
required: true
|
|
54
|
+
|
|
55
|
+
- type: textarea
|
|
56
|
+
id: scope
|
|
57
|
+
attributes:
|
|
58
|
+
label: Scope Boundaries
|
|
59
|
+
description: What is explicitly NOT included in this work. Helps agents avoid scope creep.
|
|
60
|
+
placeholder: "Does NOT include circuit breaker patterns, request queuing, or rate limit header parsing."
|
|
61
|
+
validations:
|
|
62
|
+
required: false
|
|
63
|
+
|
|
64
|
+
- type: textarea
|
|
65
|
+
id: dependencies
|
|
66
|
+
attributes:
|
|
67
|
+
label: Dependencies
|
|
68
|
+
description: Other issues, PRs, or external work this depends on. Link them if possible.
|
|
69
|
+
placeholder: "Depends on #42 (API client refactor)."
|
|
70
|
+
validations:
|
|
71
|
+
required: false
|
|
72
|
+
|
|
73
|
+
- type: dropdown
|
|
74
|
+
id: complexity
|
|
75
|
+
attributes:
|
|
76
|
+
label: Estimated Complexity
|
|
77
|
+
description: Rough sizing to help the orchestrator allocate the right agent tier.
|
|
78
|
+
options:
|
|
79
|
+
- Low
|
|
80
|
+
- Medium
|
|
81
|
+
- High
|
|
82
|
+
validations:
|
|
83
|
+
required: true
|