@edryslabs/edrys-dev 0.1.2 → 0.3.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/README.md +175 -42
- package/dist/chat.js +353 -28
- package/dist/index.js +29 -5
- package/dist/init.js +108 -0
- package/dist/mcp.js +319 -38
- package/dist/modules.js +14 -3
- package/dist/origin.js +55 -3
- package/dist/server.js +28 -14
- package/dist/sync.js +9 -3
- package/dist/watch.js +18 -0
- package/package.json +2 -2
- package/views/panel.js +119 -11
package/README.md
CHANGED
|
@@ -1,85 +1,218 @@
|
|
|
1
1
|
# edrys-dev
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build and try out an [edrys-Lite](https://github.com/edrys-labs/edrys-Lite) lab on your own computer before you share it with your students.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npm install -g @edryslabs/edrys-dev
|
|
7
|
-
edrys-dev lab.yml --open
|
|
8
|
-
```
|
|
5
|
+
You write your lab in a file (`lab.yml`), `edrys-dev` opens it as a class in your browser, and every time you save the file the class updates in all open tabs. No account and no deploy needed while you work.
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
## Quick start
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
You need [Node.js](https://nodejs.org) 20 or newer.
|
|
10
|
+
|
|
11
|
+
1. Make a folder for your lab and create a file `lab.yml` in it:
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
name: My first lab
|
|
15
|
+
meta:
|
|
16
|
+
description: Trying out edrys-dev.
|
|
17
|
+
modules:
|
|
18
|
+
- url: https://edrys-labs.github.io/module-markdown-it/index.html
|
|
19
|
+
config:
|
|
20
|
+
content: |
|
|
21
|
+
# Welcome
|
|
22
|
+
|
|
23
|
+
Edit lab.yml, save it, and watch this text change.
|
|
24
|
+
width: full
|
|
25
|
+
height: tall
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Start edrys-dev in that folder:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx @edryslabs/edrys-dev lab.yml --open
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Your browser opens the class. In the terminal you see two addresses:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
edrys-dev: /home/you/my-lab/lab.yml
|
|
38
|
+
http://localhost:3210/?dev
|
|
39
|
+
class open, share link:
|
|
40
|
+
http://localhost:3210/?/classroom/…
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
3. Change something in `lab.yml` and save. The class updates on its own.
|
|
18
44
|
|
|
19
|
-
|
|
20
|
-
- To try the lab as a student or station, open the share link in another browser or a private window. Each browser has its own identity, so it joins as a student, not as the owner.
|
|
21
|
-
- The class connects the way it will for your students: with the lab's own `communicationConfig`, or else edrys-Lite's default transport. With `--local` it syncs over edrys-dev's own port instead, which works offline; the share link then carries the setting (`#comm=…`).
|
|
22
|
-
- The lab file is the source of truth. Changes made in the class's Settings dialog are overwritten on the next save of the file.
|
|
45
|
+
If you use edrys-dev often, install it once with `npm install -g @edryslabs/edrys-dev` and then start it with just `edrys-dev lab.yml --open`.
|
|
23
46
|
|
|
24
|
-
|
|
47
|
+
Stop it with `Ctrl+C`.
|
|
25
48
|
|
|
26
|
-
##
|
|
49
|
+
## Working on a lab
|
|
27
50
|
|
|
28
|
-
|
|
51
|
+
- **The `/?dev` tab is yours.** It is the teacher's view of the class. Keep it open: it is the tab that picks up your changes to `lab.yml`.
|
|
52
|
+
- **Try the lab as a student or station.** Open the share link in a *different* browser or a private window. In the same browser you would be the teacher again.
|
|
53
|
+
- **The file wins.** Anything you change in the class's Settings dialog is replaced the next time you save `lab.yml`. Make your changes in the file.
|
|
54
|
+
- **Restarting is safe.** The same `lab.yml` reopens the same class, so share links you opened before keep working.
|
|
55
|
+
- **Mistakes are reported.** If the class cannot take your lab (for example a YAML typo), the terminal prints `lab error: …`. Fix the file and save again.
|
|
56
|
+
- **Offline?** Start with `--local`. The class then connects through edrys-dev itself instead of the internet.
|
|
57
|
+
|
|
58
|
+
Which modules exist and how to configure them is described in the [edrys-Lite documentation](https://github.com/edrys-labs/edrys-Lite) and the [edrys skills](https://github.com/edrys-labs/skills).
|
|
59
|
+
|
|
60
|
+
### When the lab is done
|
|
61
|
+
|
|
62
|
+
Publish `lab.yml` the way you normally would, for example in a GitHub repository with a deploy link to https://edrys-labs.github.io. Nothing from edrys-dev ends up in the file.
|
|
63
|
+
|
|
64
|
+
## Writing your own modules
|
|
65
|
+
|
|
66
|
+
If you are also writing a module, put it into a `modules/` folder next to the lab, one subfolder per module:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
my-lab/
|
|
70
|
+
├── lab.yml
|
|
71
|
+
└── modules/
|
|
72
|
+
└── my-module/
|
|
73
|
+
└── index.html
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
edrys-dev serves this folder on the next port (3211 by default). Use that address in `lab.yml`:
|
|
29
77
|
|
|
30
78
|
```yaml
|
|
31
79
|
modules:
|
|
32
80
|
- url: http://localhost:3211/my-module/index.html
|
|
33
81
|
```
|
|
34
82
|
|
|
35
|
-
|
|
83
|
+
When you save a file in `modules/my-module/`, only that module reloads in the class. Errors from your module's page are collected so an AI agent can see them (see below).
|
|
84
|
+
|
|
85
|
+
These addresses only work on your computer. Publish the module (for example on GitHub Pages) and put its real address into `lab.yml` before you share the lab.
|
|
86
|
+
|
|
87
|
+
## With an AI agent
|
|
88
|
+
|
|
89
|
+
edrys-dev can work together with an AI coding agent such as Claude Code or GitHub Copilot. The agent edits `lab.yml` for you, sees whether the class accepts it, and can look into the class: rooms, users, modules and their messages.
|
|
36
90
|
|
|
37
|
-
|
|
91
|
+
### Setup
|
|
38
92
|
|
|
39
|
-
|
|
93
|
+
The quick way, for a new lab:
|
|
40
94
|
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
"mcpServers": {
|
|
44
|
-
"edrys": { "command": "npx", "args": ["-y", "@edryslabs/edrys-dev", "--mcp", "lab.yml"] }
|
|
45
|
-
}
|
|
46
|
-
}
|
|
95
|
+
```bash
|
|
96
|
+
npx @edryslabs/edrys-dev init my-lab
|
|
47
97
|
```
|
|
48
98
|
|
|
49
|
-
|
|
99
|
+
This makes the folder `my-lab` with a starter `lab.yml`, the agent configuration for Claude Code (`.mcp.json`) and VS Code Copilot (`.vscode/mcp.json`), instructions for the agent (`AGENTS.md`, `CLAUDE.md`), Claude Code settings that let the agent use edrys-dev and edit `lab.yml` and `modules/` without asking each time (`.claude/settings.json`), and a `.gitignore`. In a folder that already has some of these files, it keeps them. If the edrys skills (step 2 below) are not installed yet, it offers to install them for you. Then open the folder in your agent and write "start".
|
|
50
100
|
|
|
51
|
-
|
|
101
|
+
By hand:
|
|
52
102
|
|
|
53
|
-
|
|
103
|
+
1. Create a file `.mcp.json` in your lab folder:
|
|
54
104
|
|
|
55
|
-
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"mcpServers": {
|
|
108
|
+
"edrys": { "command": "npx", "args": ["-y", "@edryslabs/edrys-dev", "--mcp", "lab.yml"] }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
56
112
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
113
|
+
If you installed edrys-dev globally, `"command": "edrys-dev", "args": ["--mcp", "lab.yml"]` starts faster.
|
|
114
|
+
|
|
115
|
+
2. Install the edrys skills, so the agent knows how labs and modules are written:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx skills add edrys-labs/skills
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
3. Start your agent in the lab folder. **The agent starts edrys-dev itself**; don't start it by hand as well. If the folder has no `lab.yml` yet, edrys-dev creates a starter lab there. Ask the agent for the class address if your browser doesn't open it.
|
|
122
|
+
|
|
123
|
+
### Talking to the agent from the class
|
|
124
|
+
|
|
125
|
+
The class tab has a chat button (🤖, bottom right). What you write there goes straight to the agent. Only you see this chat; it is not the class chat. The agent can answer with text and also with buttons or checkboxes for you to pick from.
|
|
126
|
+
|
|
127
|
+
When the class cannot take your lab file, for example after a typing mistake, a red note in the chat says so in plain words, with edrys-Lite's message under "Details". It goes away once the file loads again.
|
|
128
|
+
|
|
129
|
+
Under your message you see "Waiting for the agent…" until the agent picks it up, then "Thinking…". If nothing happens for 30 seconds, the agent may not be listening. Your message is kept and answered once it is.
|
|
130
|
+
|
|
131
|
+
Some agents don't notice new messages on their own while they are idle. In that case start the `chat` prompt of the edrys server once (in VS Code Copilot: type `/edrys.chat`, or `/mcp.edrys.chat` in older versions), and the agent keeps waiting for your messages.
|
|
132
|
+
|
|
133
|
+
Chats are saved in `.edrys-dev/chats/` next to the lab, so a restarted agent can pick up where you left off. The menu at the top of the chat starts a new chat or reopens an old one. Add `.edrys-dev/` to your `.gitignore`.
|
|
134
|
+
|
|
135
|
+
For safety, the chat only accepts messages from the class page on your own computer. Other websites or people on your network cannot write to your agent, as long as you keep `--host` at its default.
|
|
136
|
+
|
|
137
|
+
### What the agent can do
|
|
138
|
+
|
|
139
|
+
| Tool | |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `get_state` | the lab file, class address, share link, rooms, users and modules |
|
|
142
|
+
| `goto` | move your class tab to a room, or open a student or station tab |
|
|
143
|
+
| `chat`, `read_chat` | write to you in the class chat, read your messages |
|
|
144
|
+
| `read_messages` | messages between modules, and errors from your own modules |
|
|
145
|
+
| `read_module_state` | what the modules share in a room |
|
|
146
|
+
| `run_in_module` | run JavaScript inside one of your own modules, only when you ask for it |
|
|
147
|
+
| `wait_for_event` | wait for the next thing that happens in the class |
|
|
60
148
|
|
|
61
149
|
## Options
|
|
62
150
|
|
|
151
|
+
```
|
|
152
|
+
edrys-dev [lab.yml] [options]
|
|
153
|
+
```
|
|
154
|
+
|
|
63
155
|
| Option | Default | |
|
|
64
156
|
|---|---|---|
|
|
65
|
-
| `[lab.yml]`, `-i, --input <file>` | `./lab.yml` | lab file, YAML or JSON |
|
|
66
|
-
| `-
|
|
67
|
-
|
|
|
68
|
-
| `--local` | off |
|
|
69
|
-
| `-m, --modules <dir>` | `./modules
|
|
70
|
-
|
|
|
71
|
-
| `--mcp` | off |
|
|
157
|
+
| `[lab.yml]`, `-i, --input <file>` | `./lab.yml` | the lab file, YAML or JSON |
|
|
158
|
+
| `-o, --open` | off | open the class in the browser |
|
|
159
|
+
| `-p, --port <port>` | `3210` | if it is taken, the next free port is used |
|
|
160
|
+
| `--local` | off | connect the class through edrys-dev instead of the internet; works offline |
|
|
161
|
+
| `-m, --modules <dir>` | `./modules`, if it exists | folder with your own modules |
|
|
162
|
+
| `--host <host>` | `127.0.0.1` | `0.0.0.0` lets others on your network open the class (and, with `--mcp`, write to your agent) |
|
|
163
|
+
| `--mcp` | off | for AI agents; set it in `.mcp.json`, see above |
|
|
164
|
+
| `-h, --help` | | show help |
|
|
165
|
+
|
|
166
|
+
## Troubleshooting
|
|
167
|
+
|
|
168
|
+
- **`no lab file at …`**: edrys-dev looks for `lab.yml` in the current folder. Start it in your lab folder or give the path: `edrys-dev path/to/lab.yml`.
|
|
169
|
+
- **The share link opens me as the teacher.** Open it in another browser or a private window.
|
|
170
|
+
- **My changes in Settings are gone.** They are replaced by `lab.yml` on every save. Put them into the file.
|
|
171
|
+
- **The class doesn't connect / no internet.** Try `--local`.
|
|
172
|
+
- **A different port than 3210.** Another program uses it; edrys-dev took the next free one. The terminal shows the address.
|
|
173
|
+
- **The agent doesn't answer in the chat.** Check that your agent is running in the lab folder with `.mcp.json`, and if it does not wake up on its own, start the `chat` prompt (see above).
|
|
72
174
|
|
|
73
175
|
## Development
|
|
74
176
|
|
|
177
|
+
To work on edrys-dev itself:
|
|
178
|
+
|
|
75
179
|
```bash
|
|
76
180
|
npm install
|
|
77
181
|
npm run build # tsc → dist/
|
|
78
182
|
npm test # builds, then runs test/*.test.js
|
|
79
183
|
```
|
|
80
184
|
|
|
185
|
+
How the parts talk to each other:
|
|
186
|
+
|
|
187
|
+
```mermaid
|
|
188
|
+
flowchart LR
|
|
189
|
+
lab[lab.yml] -- watch --> srv
|
|
190
|
+
mods[modules/] -- watch --> msrv["module server :3211<br/>(module pages + error script)"]
|
|
191
|
+
subgraph srv ["edrys-dev :3210"]
|
|
192
|
+
direction TB
|
|
193
|
+
static["edrys-Lite dist + panel.js"]
|
|
194
|
+
api["/edrys-dev/lab · events · reload · bridge · module-error"]
|
|
195
|
+
end
|
|
196
|
+
srv -- "reload-lab, reload-module (SSE events)" --> tab["class tab /?dev"]
|
|
197
|
+
tab -- "GET lab, republish signed" --> room((class))
|
|
198
|
+
tab -- "state, messages, replies (POST bridge)" --> srv
|
|
199
|
+
msrv -- module frames --> tab
|
|
200
|
+
msrv -. "errors (POST module-error)" .-> srv
|
|
201
|
+
srv -- "reload (SSE)" --> peers
|
|
202
|
+
room -- "default transport, or --local on :3210" --> peers[student / station tabs]
|
|
203
|
+
agent[AI agent] <-- "MCP over stdio (--mcp)" --> srv
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- `index.ts` reads the options and starts the server, and with `--mcp` the MCP server (`mcp.ts`).
|
|
207
|
+
- `server.ts` serves edrys-Lite, watches the lab (`watch.ts`) and talks to the class tab: events go out over SSE, the tab's reports come back over `POST /edrys-dev/bridge`.
|
|
208
|
+
- In the class tab, edrys-Lite's own `DevBridge` (`src/ts/DevBridge.ts` in edrys-Lite, active with `?dev`) loads and republishes the lab and reports the class. edrys-dev adds `views/panel.js` to the page: the agent chat (`chat.ts` on the server), and in student and station tabs the reload on module changes.
|
|
209
|
+
- `modules.ts` serves local modules on the next port and adds the error reporter to their pages.
|
|
210
|
+
- `sync.ts` is the Yjs sync for `--local`, on edrys-dev's own port.
|
|
211
|
+
|
|
81
212
|
edrys-Lite comes from npm as [`@edryslabs/edrys-lite`](https://www.npmjs.com/package/@edryslabs/edrys-lite), pinned to one version: its `dist/` is what edrys-dev serves. To try changes to edrys-Lite, build it (`npm run build` there) and link the checkout with `npm install ../edrys-Lite`; pin the published version again afterwards. The same goes for [`@edryslabs/websocket-server`](https://www.npmjs.com/package/@edryslabs/websocket-server), an optional dependency that only `--local` uses.
|
|
82
213
|
|
|
214
|
+
Issues and pull requests: https://github.com/edrys-labs/edrys-devserver
|
|
215
|
+
|
|
83
216
|
## License
|
|
84
217
|
|
|
85
218
|
[MIT](LICENSE). The MCP server and the agent chat follow [LiaScript DevServer](https://github.com/LiaScript/LiaScript-DevServer) (MIT).
|