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
179 changes: 179 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Installing Trader's Agent: instructions for AI agents

**If you are an AI agent and your user gave you this repository's link to install, follow this file.**
It is written for you: every command is exact, and each step says what success looks like. A human can
read it too. The README holds the same facts, written for people.

Trader's Agent is a chart-first trading desk:
- a local console on `127.0.0.1` (a Vela chart, the LuxAlgo Library, a paper broker);
- a `traders-chart` MCP server with 56 tools, so you can drive that chart;
- a skill that teaches you to use those tools;
- in Hermes Desktop, a sidebar pane that shows the chart beside the chat.

## Rules

1. **Tell your user what you are about to do, in one short message, before you run anything.** For
example: "I'll clone it to ~/tradersagent-plugin and run its installer. That sets up a Python
environment, installs the console as a login service, and registers the chart tools with me. No
sudo; about a minute." Then proceed unless they object.
2. **Never use `sudo`**, and never edit system files. Everything installs into the user's home folder.
3. **Run only the commands below.** Do not add optional extras (`--with-edge`, `--with-prop`,
`--with-backtest`) unless the user asks for them. They are large and need Node 20+.
4. **If a step fails, stop.** Show the user the exact error and the matching row under
[If something fails](#if-something-fails). Do not improvise workarounds.
5. **Keep the clone where you put it.** The console service runs from that folder, so never clone into a
temporary directory.

## 1. Check the machine

```bash
uname -s # Linux or Darwin (macOS). Windows: stop, it is not supported.
git --version # required
command -v uv || python3 --version # uv, OR a Python 3.11+ (one of the two is enough)
curl --version | head -1 # required
```

Then work out which agent host you are running in:

| Signal | You are in | Go to |
|---|---|---|
| `$HERMES_HOME` is set, or `~/.hermes` exists, or `hermes` is on PATH | Hermes Agent / Hermes Desktop | step 3A |
| `dsh` is on PATH, or your user says DeepSeek Harness | DeepSeek Harness | step 3B |
| neither | another agent | step 3C |

## 2. Get the code

```bash
if [ -d ~/tradersagent-plugin/.git ]; then
git -C ~/tradersagent-plugin pull --ff-only
else
git clone --depth 1 https://github.com/godzillacode0000/tradersagent-plugin ~/tradersagent-plugin
fi
cd ~/tradersagent-plugin
```

## 3A. Hermes Agent / Hermes Desktop

```bash
./install.sh --all
```

This one command:
1. finds or builds a Python with the `mcp` client (uses `uv` when present);
2. installs the plugin and the desk skill into `$HERMES_HOME` (default `~/.hermes`);
3. installs the console as a login service on port 8787;
4. registers the `traders-chart` MCP server with Hermes;
5. waits until the console answers.

It is safe to run again: it updates in place.

**Success:** it ends with `Done in Ns. The console is answering on http://127.0.0.1:8787.`

Two lines you may also see:
- **`register-mcp.sh: no 'hermes' on PATH — run this once in a terminal where it is:`** followed by a
`hermes mcp add traders-chart ...` command. If you can run `hermes`, run that exact command.
Otherwise give it to your user to paste.
- **`note: no systemd user session here — starting the console detached`** means the console is
running now but will not start again after a reboot. Tell your user.

Then go to step 4.

## 3B. DeepSeek Harness (dsh)

dsh gets a desk of its own: a separate console on port 8788, with its own chart, paper account and
token. It is never linked to a Hermes desk on the same machine.

First find the JSON file where this dsh lists its MCP servers. Check dsh's docs or config folder. If
you cannot find it, ask your user. Do not guess.

```bash
./adapters/dsh/install-dsh.sh --mcp-file /path/to/dsh/mcp.json # skill + MCP entry (other servers kept, backup made)
./adapters/dsh/install-dsh.sh --service # dsh's own console, starts at login
```

If you could not find the MCP file, run `./adapters/dsh/install-dsh.sh` with no flags. It prints the
JSON entry, which your user can paste into dsh's config themselves.

**Success:** `install-dsh.sh` prints `dsh gets a desk of its own ('dsh' on port 8788)`, and `--service`
prints `ok console running ... on port 8788`.

Then go to step 4.

## 3C. Another MCP-capable agent

There is no ready adapter for your host, and this path is untested. Tell your user so. If they want to
try anyway, use the dsh adapter: it writes a standard stdio MCP entry and runs an isolated desk.

```bash
./adapters/dsh/install-dsh.sh --skills-dir /your/skills/folder # prints a standard {"mcpServers": {...}} entry
./adapters/dsh/install-dsh.sh --service # the console it points at, on port 8788
```

Add the printed entry to your MCP configuration.

## 4. Verify

| Host | Command | Must end with |
|---|---|---|
| Hermes | `./install.sh --doctor` | no `FAIL` lines |
| dsh, or another agent | `./adapters/dsh/install-dsh.sh --doctor` | `all checks passed` |

Lines starting with `--` are optional parts that are not installed. They are not failures.

Then check that the console answers:

```bash
curl -fsS http://127.0.0.1:8787/api/health # Hermes desk
curl -fsS http://127.0.0.1:8788/api/health # dsh desk
```

The `instance` field must say `default` for the Hermes desk and `dsh` for the dsh desk.

## 5. Tell your user what is left

You cannot click inside their app, so finish with these steps for them.

**Hermes Desktop:**
1. Press Cmd/Ctrl+K and choose "Reload desktop plugins".
2. Click "Trader's Agent" in the left sidebar. The chart opens beside the chat.
3. If the row is missing: Settings → Plugins → "Trader's Agent" → on.
4. Start a new agent session so it gets the chart tools, then ask: "what is on my chart?"

**DeepSeek Harness:**
1. Restart dsh, or reload its MCP servers and skills.
2. Open http://127.0.0.1:8788/ in a browser to watch the chart.
3. Ask: "what is on my chart?"

## If something fails

| You see | Do this |
|---|---|
| `no python with the 'mcp' client found` | `./bin/setup-python.sh`, then repeat your step 3 command |
| `no uv and no python 3.11+ on PATH` | ask your user to install `uv` (https://docs.astral.sh/uv/) or Python 3.12, then retry |
| `cannot listen on 127.0.0.1:8787` / port in use | another program uses the port. Run `./install.sh --doctor` and show your user the result. Do not kill processes you did not start |
| `console not answering` after install | read the last 30 lines of the log the installer printed (`console.log`, or `journalctl --user -u traders-agent.service -n 30`) and show them |
| `the console on ... is the 'default' desk, not 'dsh'` | dsh's port is taken by the Hermes desk. Run `./adapters/dsh/install-dsh.sh --service` |
| the chart pane says the console is not running | `./console/service-linux.sh status` (Linux) or `./console/service-macos.sh status` (macOS) |
| anything else | stop, and show your user the full error |

## Update and uninstall

```bash
cd ~/tradersagent-plugin && git pull --ff-only && ./install.sh --all # Hermes: update in place
./install.sh --uninstall # Hermes: remove plugin and skill (prints what else to undo)
./adapters/dsh/install-dsh.sh --uninstall --mcp-file /path/to/dsh/mcp.json # dsh: remove skill, entry and dsh's service
```

The user's paper account and settings are left in `~/.local/state/traders-agent/` on purpose.
Uninstalling never deletes them.

## Working on this repository instead?

If you were asked to change this code rather than install it, this file is not your guide. Start with
[`docs/HANDOFF.md`](docs/HANDOFF.md). Run the tests with:

```bash
python3 -m unittest discover -s console/backend/tests
```

Then run the checks in `.github/workflows/ci.yml` before you push.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,43 @@ All notable changes to this project are documented here. Format: [Keep a Changel

## [Unreleased]

### Added

- **`AGENTS.md`: give an agent the repo link and it installs the plugin** (30 Oct). A file written for AI agents
and signposted at the top of the README ("If you are an AI agent ..."). It covers:
- telling the user what will happen, before running anything;
- checking the machine and working out the host (Hermes, DeepSeek Harness, other);
- the exact install commands for each host, and the line that means success;
- the two warnings an install can print (no `hermes` on PATH, no systemd) and what to do about each;
- verifying with the doctor and `/api/health`;
- what to tell the user at the end, since an agent cannot click inside their app;
- a troubleshooting table that quotes the real error lines;
- update and uninstall.

Its rules: no sudo, no optional extras unless asked, stop on failure. `test_agents_guide.py` fails if a flag it
runs or a message it waits for stops existing in the scripts. A fresh-home dry run of the guide took 7 s to a
console answering on 8787 (Hermes) and 8788 (dsh, doctor: all checks passed).

### Changed

- **The DeepSeek Harness gets a desk of its own** (30 Oct). The operator: a desk opened in dsh "should stay in
DeepSeek Harness only — not linked or connected" to the Hermes one.
- **Before:** the dsh adapter pointed its MCP server at the Hermes console on 8787. Both agents shared one chart,
one paper account, one write token and one set of studies, and dsh's in-app study chat ran through the Hermes CLI.
- **Now:** `TRADERS_AGENT_INSTANCE=NAME` (`console/backend/instance.py`) gives a console its own token, paper
account, chart and study files under `~/.local/state/traders-agent/instances/NAME/`. It also gets its own Edge
Stats workspace and engine on the console's port + 2, and no Hermes chat unless `HERMES_CLI` is set.
- A named desk runs on its own port, and the browser keeps per origin, so saved scripts, layout and theme are
separate too.
- `install-dsh.sh` defaults to desk `dsh` on 8788. New options: `--console` runs that desk, and `--service`
installs it as its own service (`traders-agent-dsh.service` / `com.traders-agent.console.dsh`). `--doctor`
fails if the console on dsh's port is another desk. `--shared` is the explicit way back to one desk.
- Unset, nothing changes for Hermes.
- Market data stays shared on purpose.
- Pinned by `test_instances.py`, which runs two real consoles side by side: different tokens, a token refused
across desks, a chart command that never reaches the other chart, and the chat refused on the dsh desk. Also
pinned by adapter and service tests.

- **The replay strip is a glass capsule** (30 Oct), the operator's pick of two designs. One frosted
pill, about 430 px: the scrubber is its top edge (white playhead, the range's first and last bar fade
in on hover), Play is the one bright control and turns into Pause, back-to-start and next-bar flank
Expand All @@ -20,6 +55,11 @@ All notable changes to this project are documented here. Format: [Keep a Changel

### Fixed

- **`./install.sh --doctor` failed a working install.** The install started the console with the Python that has
the `mcp` client, but the doctor checked the first Python 3.11+ on PATH, a 3.14 without it, and said FAIL. It
now prefers an interpreter with `mcp`, the same order as the service and `bin/setup-python.sh`. Found by
following `AGENTS.md` on a fresh home.

- **The chart sprang back to its right edge after a drag, in replay and out** (30 Oct). Two faults in
`nudgeChart()` (app.js): its repaint dispatched a window `resize`, and the resize handler called
`nudgeChart()` again — an endless loop, measured at 140 view resets in 10 idle seconds; and each
Expand Down
63 changes: 52 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

</div>

> [!IMPORTANT]
> **If you are an AI agent asked to install this for your user, follow [`AGENTS.md`](AGENTS.md).** It covers
> Hermes, DeepSeek Harness and other agents: exact commands, what success looks like, how to verify, and what to
> tell your user at the end.

A sidebar entry that docks a full trading console **beside your conversation**: **Vela**-rendered
candlesticks and the **LuxAlgo Library** (800+ concepts and indicators, served live by LuxAlgo's own
MCP server) in one local web app — your chat session is left exactly where it was.
Expand Down Expand Up @@ -53,6 +58,9 @@ MCP server) in one local web app — your chat session is left exactly where it

## Install

**Let your agent do it:** give Hermes (or DeepSeek Harness) this repository's link and ask it to install it. It
reads [`AGENTS.md`](AGENTS.md) and runs the steps below, then tells you the two clicks left in the app.

**One command** (Linux and macOS; about a minute with [uv](https://docs.astral.sh/uv/), a few without it):

```bash
Expand Down Expand Up @@ -414,22 +422,54 @@ is still not a headless renderer: with no view attached, commands fail fast and

### Using it from the DeepSeek Harness (dsh)

The chart pane is Hermes-only, but the desk is not: the same MCP server (56 tools) and the same skill work from dsh,
and the agent drives the console's chart exactly as it does from Hermes. Open `http://127.0.0.1:8787/` in a browser tab
to watch it.
The chart pane is Hermes-only, but the desk is not: the same MCP server (56 tools) and the same skill work from dsh.
**dsh gets a desk of its own.** It runs a second console on `127.0.0.1:8788` (`TRADERS_AGENT_INSTANCE=dsh`, see
`console/backend/instance.py`). Nothing the dsh agent does reaches the Hermes desk on 8787, and nothing Hermes does
reaches dsh's desk.

```bash
./console/start.sh # the console must be running
./adapters/dsh/install-dsh.sh --mcp-file PATH # PATH: the JSON file where your dsh lists MCP servers
./adapters/dsh/install-dsh.sh --doctor # skill, launcher, a real MCP handshake, the console
./adapters/dsh/install-dsh.sh --console # run dsh's console (or --service: start it at login)
./adapters/dsh/install-dsh.sh --doctor # skill, launcher, a real MCP handshake, and that 8788 is dsh's desk
```

It copies the skill to `~/.agents/skills/trader-desk` (`--skills-dir` or `DSH_SKILLS_DIR` to change it) and writes a
stdio entry into the file you name (it runs `console/mcp/server.py` with `PY`, the repo's `.venv` or a python that has the `mcp` client, same order as `bin/register-mcp.sh`; else `uvx fastmcp run`; `--venv` forces a private venv),
keeping your other servers and a `.bak-traders` copy. Without `--mcp-file` it prints the entry for you to paste.
`PORT=9000` points the entry at a console on another port. It reads nothing from dsh itself and writes nowhere else, so
check your dsh's own docs for the config path. Not verified against a real dsh install yet: the handshake is tested with
the MCP client, and dsh's skill and config locations are as reported by third-party dsh plugins.
Open `http://127.0.0.1:8788/` in a browser tab to watch the dsh agent drive its chart.

| | Hermes desk | dsh desk |
|---|---|---|
| console | `127.0.0.1:8787` | `127.0.0.1:8788` |
| chart and agent commands | its own | its own |
| write token | its own | its own |
| paper account | its own | its own |
| studies | its own | its own |
| saved scripts, layout, theme | its own | its own |
| Edge Stats engine and workspace | `8789` | `8790` |
| in-app study chat | the Hermes CLI | off (the dsh agent talks through its MCP tools) |
| service | `traders-agent.service` / `com.traders-agent.console` | `traders-agent-dsh.service` / `com.traders-agent.console.dsh` |
| state | `~/.local/state/traders-agent/` | `~/.local/state/traders-agent/instances/dsh/` |
| market data | shared | shared |

Market data is shared on purpose: the tick store, candle caches, downloaded data, thumbnails and the prop-firm
simulator describe the market, not a desk.

The doctor fails if the console on dsh's port turns out to be another desk. `--shared` is the explicit way back to one
desk: the entry points at the Hermes console on 8787, the same chart and paper account.

The installer copies the skill to `~/.agents/skills/trader-desk` (`--skills-dir` or `DSH_SKILLS_DIR` to change it). It
writes a stdio entry into the file you name. That entry runs `console/mcp/server.py` with the first of these that
works:
1. `PY`, the repo's `.venv`, or a python that has the `mcp` client (the same order as `bin/register-mcp.sh`);
2. `uvx fastmcp run`.

`--venv` forces a private venv instead. Your other servers are kept, and a `.bak-traders` copy is saved. Without
`--mcp-file` the installer prints the entry for you to paste.

`PORT=9000` moves dsh's console to another port. `--uninstall` removes the skill and dsh's service. It never touches
the Hermes console and keeps dsh's desk state.

The installer reads nothing from dsh itself and writes nowhere else, so check your dsh's own docs for the config path.
This is not verified against a real dsh install yet. The handshake is tested with the MCP client, and the two desks
are tested side by side as real consoles. dsh's skill and config locations are as reported by third-party dsh plugins.

## Screenshots

Expand Down Expand Up @@ -486,6 +526,7 @@ bin/ register-mcp.sh (the MCP registration on its own) · is-enabl
| `TRADER_CONSOLE_TOKEN_FILE` | `~/.local/state/traders-agent/console.token` | the POST token the console mints and the MCP server and CLI read |
| `TRADERS_AGENT_WORKDIR` | `~/Projects/luxalgo-web` if it exists, else `console/agents` | the folder the in-app study bridge runs the agent CLI in (never taken from a request) |
| `TRADERS_AGENT_ALLOW_LAN` | unset | with `--host 0.0.0.0`, let peers that reach the console **from their own address** receive the POST token; without it they get a read-only console. It does **not** govern a caller arriving through a local reverse proxy — see the row below |
| `TRADERS_AGENT_INSTANCE` | unset | runs a separate desk: its own token, paper account, chart and study files under `~/.local/state/traders-agent/instances/NAME/`, its own Edge Stats engine (the console's port + 2), and no Hermes study chat unless `HERMES_CLI` is set. Unset is the Hermes desk. The dsh adapter uses `dsh` |
| `TRADERS_AGENT_ALLOWED_HOSTS` | unset | comma-separated extra `Host` names this console answers to, for a local reverse proxy that forwards the public name (`tailscale serve` does). **Every name you add here is a full-trust door:** the proxy terminates on this machine, so the caller arrives on loopback, is handed the POST token and can write — approve paper orders, drive the chart, run Pine — with `ALLOW_LAN` unset. Only add names that resolve to this machine inside an access-controlled network, and read it as “everyone on that tailnet is me”. Any other name is still refused |
| `TRADER_PAPER_FILE` | `~/.local/state/traders-agent/paper.json` | the paper account (use another path for a second test console) |
| `LUXALGO_AGENTS_DIR` | `console/agents` | runtime state: chart bridge files, study threads, shots |
Expand Down
Loading
Loading