agent-lyra 0.6.3 → 0.6.5
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 +150 -350
- package/package.json +1 -1
- package/src/coding/export.js +10 -7
- package/src/coding/setup.js +4 -4
- package/src/init.js +4 -9
- package/src/resource-files.js +18 -0
- package/src/studio/export.js +1 -0
- package/src/studio/project.js +10 -11
- package/src/studio/pull-agent.js +3 -3
package/README.md
CHANGED
|
@@ -1,435 +1,235 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Build apps from your saved Lyra agents, run agents with your own OpenAI key, and inspect saved runs from your IDE. The Node.js package includes a command-line tool and typed JavaScript APIs for composing workflows.
|
|
4
|
-
|
|
5
|
-
[AgentLyra homepage](https://agentlyra.in/) · [CLI reference](https://agentlyra.in/#sdk-commands) · [Cloud console](https://console.agentlyra.in/)
|
|
6
|
-
|
|
7
|
-
## Choose an SDK mode
|
|
8
|
-
|
|
9
|
-
| Mode | Where work runs | What you need |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| **Work locally** | In your own Node.js process. Use `agent-lyra/standalone` for local workflows and retrieval, or run your own local workflows. | No AgentLyra account or key. Model-backed CLI runs use your own OpenAI key. |
|
|
12
|
-
| **Connect to Cloud** | On a compatible hosted backend. `agent-lyra/gated` calls the backend's `/agents/<vertical>/invoke` endpoint. | A Lyra API key for that backend and its base URL. For AgentLyra Cloud, use an AgentLyra API key with hosted agent access and the base URL https://api.agentlyra.in/api/sdk/v1. Cloud SDK calls also require an OpenAI key in Models settings. |
|
|
13
|
-
|
|
14
|
-
The App Builder below uses an AgentLyra API key with hosted agent access to run saved agents in AgentLyra Cloud. Standalone workflows remain available through the SDK and CLI.
|
|
15
|
-
|
|
16
|
-
## Install
|
|
17
|
-
|
|
18
|
-
Requires **Node.js 22.13 or newer**. From your project directory:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install agent-lyra
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Use `pnpm add agent-lyra` if your project uses pnpm. Run the CLI with `npx agent-lyra` after installation.
|
|
25
|
-
|
|
26
|
-
## Cloud access
|
|
27
|
-
|
|
28
|
-
### Switch workspace mode from your IDE
|
|
29
|
-
|
|
30
|
-
From the project folder, run one of these commands:
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
npx.cmd agent-lyra connect-cloud
|
|
34
|
-
npx.cmd agent-lyra work-locally
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
The first connection to Cloud prompts for an AgentLyra API key if none is available. Paste the key at the hidden prompt. The CLI saves a prompted key under `~/.agent-lyra/` for reuse by your OS account. Later switches reuse it. Run `npx.cmd agent-lyra connect-cloud --replace-key` to replace it. Working locally pauses Studio Cloud pulls and runs. Switching preserves your canvas and local agents. When connected to Cloud, you can use local and Cloud agents. If Studio is already open, click **Reload agents** to refresh the mode shown in its header.
|
|
1
|
+
<img src="https://agentlyra.in/images/logo.png" width="80" height="80" alt="AgentLyra constellation mark">
|
|
38
2
|
|
|
3
|
+
# AgentLyra SDK
|
|
39
4
|
|
|
40
|
-
|
|
5
|
+
**Build agent workflows, design apps, and set up coding assistants from your project.**
|
|
41
6
|
|
|
42
|
-
|
|
7
|
+
[Get started](#get-started) · [SDK](#sdk-library) · [Coding setup](#coding-setup) · [Studio](#lyra-studio) · [App Builder](#lyra-app-builder) · [Memory](#project-memory-and-skill-proposals) · [Cloud](#agentlyra-cloud-and-marketplace)
|
|
43
8
|
|
|
44
|
-
|
|
9
|
+
[Website](https://agentlyra.in/) · [Cloud console](https://console.agentlyra.in/) · [GitHub](https://github.com/agentlyra-labs/agent-lyra-sdk) · [npm](https://www.npmjs.com/package/agent-lyra) · [PyPI](https://pypi.org/project/agent-lyra/)
|
|
45
10
|
|
|
46
|
-
|
|
11
|
+
## Choose your starting point
|
|
47
12
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"runnable": true,
|
|
54
|
-
"steps": [
|
|
55
|
-
{"agentId": "local:writer", "task": "Draft a note.", "output": "draft"},
|
|
56
|
-
{"agentId": "local:reviewer", "task": "Review the draft.", "input": "draft"}
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
```
|
|
13
|
+
| | What you get |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| **GitHub source edition** | MIT-licensed JavaScript workflow and retrieval primitives, local execution and run history, evidence-based memory, manifest validation, and [technology skill guides](https://github.com/agentlyra-labs/agent-lyra-sdk/tree/main/src/coding/skills). |
|
|
16
|
+
| **SDK from npm or PyPI** | Coding stack detection, agent and skill generation, assistant exports, Studio, App Builder, and optional Cloud access. The Python package also provides native Python workflow and memory APIs. |
|
|
17
|
+
| **AgentLyra Cloud** | A signed-in workspace for hosted agents, syncing selected project resources, and browsing the Marketplace. |
|
|
60
18
|
|
|
61
|
-
|
|
19
|
+
## Get started
|
|
62
20
|
|
|
63
|
-
|
|
21
|
+
**JavaScript · Node.js 22.13 or newer**
|
|
64
22
|
|
|
65
23
|
```sh
|
|
66
|
-
|
|
67
|
-
npx
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### Sync a personal team
|
|
72
|
-
|
|
73
|
-
Use an **AgentLyra API key** with Cloud resource sync permission. Push local agents first, then save a definition such as this one in `.lyra/teams/research.json`:
|
|
74
|
-
|
|
75
|
-
```json
|
|
76
|
-
{"id":"research","name":"Research","description":"Draft and review research notes.","agentIds":["local:writer"]}
|
|
24
|
+
npm install agent-lyra
|
|
25
|
+
npx agent-lyra --help
|
|
26
|
+
npx agent-lyra setup coding --detect --preview
|
|
77
27
|
```
|
|
78
28
|
|
|
79
|
-
|
|
29
|
+
**Python · Python 3.9 or newer**
|
|
80
30
|
|
|
81
31
|
```sh
|
|
82
|
-
|
|
83
|
-
|
|
32
|
+
python -m pip install agent-lyra
|
|
33
|
+
python -m lyra --help
|
|
34
|
+
python -m lyra setup coding --detect --preview
|
|
84
35
|
```
|
|
85
36
|
|
|
37
|
+
Coding setup, Studio, App Builder, Cloud commands, and skill proposals require Node.js 22.13 or newer. Native Python workflows and local Memory commands run with Python alone.
|
|
86
38
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Use an **AgentLyra API key** with Cloud resource sync permission. Save a text definition such as this one in `.lyra/skills/notes.json`:
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
{"id":"notes","name":"Meeting notes","description":"Turn notes into a short recap.","body":"Summarize decisions and list next steps."}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
In Studio, use **Push to Cloud** on the skill card to create a private skill in your Cloud skill registry. Use **Pull skill edits** to bring back changes from Cloud. If both copies changed, sync stops for review. The skill's name, description, and text instructions can sync. Configure tool access and agent assignments separately. Executable Python skills stay in their local runtime.
|
|
39
|
+
**GitHub source edition · Node.js 22.13 or newer**
|
|
96
40
|
|
|
97
41
|
```sh
|
|
98
|
-
|
|
99
|
-
|
|
42
|
+
git clone https://github.com/agentlyra-labs/agent-lyra-sdk.git
|
|
43
|
+
cd agent-lyra-sdk
|
|
44
|
+
node bin/agent-lyra.js --help
|
|
100
45
|
```
|
|
101
46
|
|
|
47
|
+
Run project commands from your own project folder using the absolute path to the cloned CLI. Use the npm or PyPI install below to try Studio, App Builder, coding setup, or Cloud commands.
|
|
102
48
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Standalone agents run in your project. Cloud agents run in AgentLyra Cloud. Studio can use both in one canvas. You can keep your existing `.lyra` files and `manifest.json`. Rerunning `init` or changing the manifest mode is unnecessary.
|
|
106
|
-
|
|
107
|
-
1. Open [AgentLyra Console → API Keys](https://console.agentlyra.in/mcp-servers). Select **Generate AgentLyra API key** and copy the key beginning with `lyra_sdk_`.
|
|
108
|
-
2. In VS Code, open a **PowerShell** terminal in your project. Run the line below, paste the key at the masked prompt, and press Enter. The key is available to this terminal and the programs it starts.
|
|
49
|
+
**Command prefixes used below**
|
|
109
50
|
|
|
110
|
-
|
|
111
|
-
$env:LYRA_API_KEY = Read-Host "Paste your AgentLyra API key" -MaskInput
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
3. Start Studio from that same terminal. If it is already running, stop it first with **Ctrl+C** so it picks up the key.
|
|
115
|
-
|
|
116
|
-
```sh
|
|
117
|
-
npx agent-lyra studio
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
4. Open the URL Studio prints and click **Pull from Cloud**. You can also pull from the terminal with `npx agent-lyra studio pull`. The pull adds agent references, workflows, team metadata, and skill references under `.lyra/` and preserves existing files.
|
|
121
|
-
5. In the Inspector, choose the Cloud agent for an **Agent card**, or add it to a **Run button** sequence. Existing bindings keep using their current agents until you change them. To execute a Cloud agent, also configure your OpenAI key in **Console → Models**. The AgentLyra API key authorizes the pull and Cloud requests.
|
|
122
|
-
|
|
123
|
-
For exported apps with Cloud agents, set `LYRA_API_KEY` in the terminal that starts the exported app. Keep keys out of manifests and Git. If Studio asks for the AgentLyra API key after you set it, check that you launched Studio in the same terminal. If Cloud execution asks for a provider key, check **Console → Models**.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
## Build an app from your Lyra agents
|
|
127
|
-
|
|
128
|
-
Create two enabled text agents in AgentLyra Console. In [API key settings](https://console.agentlyra.in/mcp-servers), choose **Generate AgentLyra API key** and set it as `LYRA_API_KEY` in your terminal environment. Add your own OpenAI key in Console → Models. Keep both keys out of source control.
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
npx agent-lyra app init
|
|
132
|
-
npx agent-lyra app validate manifest.json
|
|
133
|
-
npx agent-lyra app preview manifest.json
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Choose the agents in the order they should run. The CLI creates one `manifest.json` in your project. Open the URL printed by the preview and enter some text. The first agent runs on that input, then the second receives the input and first result. The browser shows both outputs. This version runs each saved agent's instructions as text-only; connected tools and skills are outside this workflow.
|
|
137
|
-
|
|
138
|
-
Stop the preview or open a new terminal, then export into a new folder:
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
npx agent-lyra app export manifest.json ./my-app
|
|
142
|
-
cd my-app
|
|
143
|
-
npm start
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
The export contains editable HTML, a Node.js server, the runtime, and the app manifest. Keep `LYRA_API_KEY` in the server environment. The exported server binds to loopback and the two agents continue to run in Cloud.
|
|
147
|
-
|
|
148
|
-
## Choose the workflow you need
|
|
149
|
-
|
|
150
|
-
| I want to… | Start here |
|
|
51
|
+
| Edition | Prefix |
|
|
151
52
|
| --- | --- |
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
| Run a model-backed agent from my terminal | [Run an agent](#run-an-agent) |
|
|
156
|
-
| Inspect saved runs inside my IDE | [Connect your IDE](#connect-your-ide) |
|
|
157
|
-
| Share or import an app | [Use the Marketplace](#use-the-marketplace) |
|
|
53
|
+
| JavaScript | `npx agent-lyra` |
|
|
54
|
+
| Python | `python -m lyra` |
|
|
55
|
+
| GitHub source | `node /absolute/path/to/agent-lyra-sdk/bin/agent-lyra.js` |
|
|
158
56
|
|
|
159
|
-
|
|
57
|
+
Values in angle brackets are placeholders. Use `--help` to check arguments for the command you’re running. On Windows PowerShell, use `npm.cmd` and `npx.cmd` if PowerShell blocks the script shims.
|
|
160
58
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Copy the run ID printed by the first command into the second. The CLI saves run events locally in `.lyra/state/runs.sqlite`. To run a writer followed by a reviewer, use `team run draft-review` with the same model and prompt flags.
|
|
169
|
-
|
|
170
|
-
### Connect your IDE
|
|
171
|
-
|
|
172
|
-
Configure a stdio MCP server with the installed `agent-lyra` executable, using its absolute path if your IDE requires one. Set the arguments to:
|
|
59
|
+
| Command | Availability | Purpose |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| `--help` | All editions | Show the CLI entry points |
|
|
62
|
+
| `init [--mode standalone] [--dir <folder>]` | All editions | Initialize a local workspace |
|
|
63
|
+
| `init --domains <ids> [--stack <names> or --detect]` | npm, Python | Select domains and optionally configure a coding stack. The registry wizard also supports hosted setup |
|
|
173
64
|
|
|
174
|
-
|
|
175
|
-
["mcp", "serve", "--dir", "ABSOLUTE_PROJECT_PATH"]
|
|
176
|
-
```
|
|
65
|
+
The registry wizard supports `--mode`, `--domains`, `--stack`, `--detect`, `--dir`, `--force`, `--api-key`, and `--api-base-url`. For account credentials, prefer the hidden prompt in `connect-cloud`.
|
|
177
66
|
|
|
178
|
-
|
|
67
|
+
## SDK library
|
|
179
68
|
|
|
180
|
-
|
|
69
|
+
Use the SDK directly in your own code to compose workflows, run agents, and work with retrieval. Choose the runtime and provider that fit your app.
|
|
181
70
|
|
|
182
|
-
|
|
71
|
+
**JavaScript**
|
|
183
72
|
|
|
184
|
-
|
|
73
|
+
```js
|
|
74
|
+
import { standalone } from 'agent-lyra';
|
|
185
75
|
|
|
186
|
-
|
|
187
|
-
|
|
76
|
+
const workflow = standalone.createLinearWorkflow(() => 'Draft ready');
|
|
77
|
+
console.log(await standalone.runWorkflow(workflow));
|
|
188
78
|
```
|
|
189
79
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Studio reads standalone Markdown agents from `.lyra/agents/`. Each needs an `id`, a `name`, and a `## System Prompt` section. To run a local agent, set `OPENAI_API_KEY` and choose a model in the Run now drawer. Override the model list with a comma-separated `LYRA_STUDIO_MODELS` environment variable if needed.
|
|
193
|
-
|
|
194
|
-
Follow [Add Cloud access](#cloud-access) to import Cloud resources. Studio runs compatible sequential text workflows. Canvas workflows and teams appear as references.
|
|
195
|
-
|
|
196
|
-
Add an **Agent card** to let users run one agent directly from the app. Choose the agent in the Inspector and optionally bind an input and an output. Use a **Run button** for a sequence of agents or workflows.
|
|
197
|
-
|
|
198
|
-
Save the canvas in Studio and export it with `npx agent-lyra app export manifest.json ./my-app`. Open the new folder and run `npm start` to launch the app locally. The export keeps the component layout and Run button bindings. It includes the prompts of referenced local agents and the IDs of referenced Cloud agents. Supply your API keys through environment variables when starting the app.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
### Run a Python skill from the canvas
|
|
202
|
-
|
|
203
|
-
Install the Python SDK in your environment. Create `.lyra/agents/draft.py`:
|
|
80
|
+
**Python**
|
|
204
81
|
|
|
205
82
|
```python
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
def draft(text):
|
|
209
|
-
return f"Draft: {text}"
|
|
210
|
-
|
|
211
|
-
agent = Agent("draft", [Skill("draft-note", draft)])
|
|
212
|
-
```
|
|
83
|
+
import asyncio
|
|
84
|
+
from lyra.standalone import create_linear_workflow, run_workflow
|
|
213
85
|
|
|
214
|
-
|
|
86
|
+
async def draft(context):
|
|
87
|
+
return "Draft ready"
|
|
215
88
|
|
|
216
|
-
|
|
217
|
-
{"id":"draft","name":"Draft a note","runtime":"python","file":"draft.py","skill":"draft-note"}
|
|
89
|
+
print(asyncio.run(run_workflow(create_linear_workflow(draft))))
|
|
218
90
|
```
|
|
219
91
|
|
|
220
|
-
|
|
92
|
+
From the GitHub source edition, import the JavaScript primitives from `./src/standalone/index.js`. That edition also includes the [v1 manifest contract](https://github.com/agentlyra-labs/agent-lyra-sdk/blob/main/src/app-builder/manifest-contract.js).
|
|
221
93
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
Run commands from the folder you want to associate with the database:
|
|
229
|
-
|
|
230
|
-
```sh
|
|
231
|
-
npx agent-lyra memory init
|
|
232
|
-
npx agent-lyra memory record lesson.json
|
|
233
|
-
npx agent-lyra memory search "nullable GraphQL"
|
|
234
|
-
npx agent-lyra memory list
|
|
235
|
-
npx agent-lyra memory stats
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
Example `lesson.json`:
|
|
239
|
-
|
|
240
|
-
```json
|
|
241
|
-
{
|
|
242
|
-
"type": "corrective",
|
|
243
|
-
"title": "Handle nullable API fields",
|
|
244
|
-
"learning": "Show the fallback when the response field is null.",
|
|
245
|
-
"evidence": ["test:nullable-response"]
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
Evidence IDs are references. Recording an ID does not verify the lesson. Copy the ID returned by `record` into `memory inspect <id>`, `memory archive <id>`, or `memory forget <id> --yes`. Archive keeps the record for inspection and excludes it from search. Forget removes the content from normal store access and retains a deletion marker with the ID, revision, and deletion time.
|
|
250
|
-
|
|
251
|
-
Set `LYRA_MEMORY=off` in the launching process to disable local memory. Store only information appropriate for your machine. The database is plain SQLite and the memory folder has its own Git ignore file. Use OS account protections or disk encryption as appropriate. Close all memory clients before copying the database for a backup or before restoring it to another project. WAL files and older backups may retain deleted content.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
Use `openMemoryStore(projectPath)` from `agent-lyra/memory` for programmatic access. Close the store after use.
|
|
255
|
-
|
|
256
|
-
### Verify a coding correction
|
|
257
|
-
|
|
258
|
-
Run your test, review whether it supports the correction, and record the test reference in the memory's `evidence` list. Save a receipt like this as `evidence.json`:
|
|
259
|
-
|
|
260
|
-
```json
|
|
261
|
-
{
|
|
262
|
-
"adapter": "coding",
|
|
263
|
-
"evidenceId": "test:nullable-response",
|
|
264
|
-
"test": "nullable-response",
|
|
265
|
-
"result": "passed",
|
|
266
|
-
"reviewed": true,
|
|
267
|
-
"context": "graphql-client@1"
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
```sh
|
|
272
|
-
npx agent-lyra memory verify MEMORY_ID evidence.json
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
This command checks the receipt and recorded evidence reference. The developer supplies the test result and attests to the review. The command does not run the test or independently prove the correction.
|
|
276
|
-
|
|
277
|
-
For model-backed local runs, set `LYRA_MEMORY_CONTEXT` to the same compatibility tag in the terminal that launches the Node CLI or Studio. Use a new tag when relevant dependencies or assumptions change. The runner includes a few relevant verified memories as historical context and keeps the current request intact. Starting without a tag leaves retrieval off. Native Python callers can use `MemoryStore.retrieve(query, context)` explicitly. Python skills, Cloud agents, and exported apps do not automatically retrieve project memory.
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
### Practice exercise adapter
|
|
281
|
-
|
|
282
|
-
The experimental `practice` adapter supports self-contained training exercises. Record a procedural or corrective lesson with an `exercise:` evidence ID, then verify it with a reviewed passing receipt. For example:
|
|
283
|
-
|
|
284
|
-
```json
|
|
285
|
-
{"adapter":"practice","evidenceId":"exercise:async-sequence","exercise":"async-sequence","result":"passed","reviewed":true,"context":"async-practice@1"}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Set `LYRA_MEMORY_ADAPTER=practice` and `LYRA_MEMORY_CONTEXT=async-practice@1` for a model-backed local run. The default adapter is `coding`. Retrieval filters by both adapter and compatibility context. Skill proposal consolidation currently uses coding corrections.
|
|
94
|
+
| Command | Availability | Purpose |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| `agent run --model <model> --prompt <text>` | Source, npm | Run the local assistant with an OpenAI model |
|
|
97
|
+
| `team run draft-review --model <model> --prompt <text>` | Source, npm | Run the built-in drafting and review sequence |
|
|
98
|
+
| `run status <run-id>` | Source, npm | Read the latest saved run event |
|
|
99
|
+
| `mcp serve --dir <absolute-project-directory>` | Source, npm | Expose `get_saved_run` over read-only stdio MCP |
|
|
289
100
|
|
|
290
|
-
|
|
101
|
+
Model-backed runs require `OPENAI_API_KEY`. The provider receives the prompt and any retrieved project memory included with it. AgentLyra records local run history in SQLite. The MCP tool can read saved run output by UUID.
|
|
291
102
|
|
|
292
|
-
|
|
103
|
+
## Coding setup
|
|
293
104
|
|
|
294
|
-
|
|
105
|
+
Generate editable agents and skills in `.lyra/` for the technology you use. Choose packs manually or let Lyra detect your stack from local project files. Review the preview before applying it. Existing files are preserved.
|
|
295
106
|
|
|
296
107
|
```sh
|
|
297
|
-
npx agent-lyra
|
|
298
|
-
npx agent-lyra
|
|
299
|
-
npx agent-lyra
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
Review the draft Markdown and run a separate regression test. Save a receipt such as this one as `regression.json`:
|
|
303
|
-
|
|
304
|
-
```json
|
|
305
|
-
{"evidenceId":"test:skill-regression","context":"graphql-client@1","result":"passed","reviewed":true}
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
```sh
|
|
309
|
-
npx agent-lyra skills approve PROPOSAL_ID regression.json
|
|
108
|
+
npx agent-lyra setup coding --detect --preview
|
|
109
|
+
npx agent-lyra setup coding --stack playwright-cucumber --yes
|
|
110
|
+
npx agent-lyra setup coding export --to claude,codex,copilot --preview
|
|
310
111
|
```
|
|
311
112
|
|
|
312
|
-
|
|
113
|
+
| Command | Purpose |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `setup coding` | Choose technologies interactively |
|
|
116
|
+
| `setup coding --stack <names>` | Choose packs or presets such as `mern`, `python-fastapi`, and `playwright-cucumber` |
|
|
117
|
+
| `setup coding --detect` | Review detected technologies and the files that support each recommendation |
|
|
118
|
+
| `setup coding --stack <names> --catalog-version <number> --preview` | Preview a published Cloud catalog version. Without this option, setup uses the bundled catalog offline |
|
|
119
|
+
| `setup coding export --to claude,codex,copilot --preview` | Preview assistant-specific instructions. Replace `--preview` with `--yes` to write the files |
|
|
313
120
|
|
|
314
|
-
|
|
121
|
+
These commands are available in npm and Python. Both setup commands accept `--dir <folder>`. After setup, you can run `node .lyra/scripts/detect-stack.mjs` for a read-only JSON report. The GitHub source edition includes the guide files for reading and reuse.
|
|
315
122
|
|
|
316
|
-
|
|
123
|
+
## Lyra Studio
|
|
317
124
|
|
|
318
|
-
|
|
319
|
-
npx agent-lyra connect-cloud
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
If you previously saved a key, add `--replace-key` to enter the new one. Existing dedicated Memory keys still work through `LYRA_MEMORY_KEY`, which takes priority for Memory sync.
|
|
323
|
-
|
|
324
|
-
From the same terminal, preview a verified record and then explicitly confirm the upload:
|
|
125
|
+
Studio is a **local browser canvas** that you launch from your IDE terminal. Add a text input, agent card or run button, and an output. Use the Inspector to bind inputs and outputs, then run an agent or workflow from the canvas.
|
|
325
126
|
|
|
326
127
|
```sh
|
|
327
|
-
npx agent-lyra
|
|
328
|
-
npx agent-lyra memory cloud push MEMORY_ID --yes
|
|
128
|
+
npx agent-lyra studio
|
|
329
129
|
```
|
|
330
130
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
In a second project or machine, use the same Cloud account and run:
|
|
131
|
+
Run `python -m lyra studio` from a Python project. Start from the project root so Studio can find your `.lyra` agents, workflows, and skills. See [Cloud sync](#agentlyra-cloud-and-marketplace) for importing or pushing selected resources.
|
|
334
132
|
|
|
335
|
-
|
|
336
|
-
npx agent-lyra memory cloud list
|
|
337
|
-
npx agent-lyra memory cloud pull MEMORY_ID
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
Imported records start as candidates and require local review before an agent can retrieve them. If the two copies changed, sync stops. Review both before changing either one. To propagate a deletion, run `memory forget MEMORY_ID --yes` locally. Preview and push that ID again to remove its Cloud content. In the other project, pull the ID to apply the deletion when its local copy has no conflicting changes.
|
|
133
|
+
## Lyra App Builder
|
|
341
134
|
|
|
342
|
-
|
|
135
|
+
App Builder turns an **app manifest** into a browser preview or editable application source. Use `app init` to start with saved Cloud agents, then validate, preview, and export.
|
|
343
136
|
|
|
137
|
+
| Command | Purpose |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `app init [manifest.json]` | Create a manifest using saved Cloud agents. Connect to Cloud first |
|
|
140
|
+
| `app validate <manifest.json>` | Check the manifest |
|
|
141
|
+
| `app preview <manifest.json>` | Open a local browser preview. Set `LYRA_PREVIEW_PORT` if you need a different port |
|
|
142
|
+
| `app export <manifest.json> <new-directory>` | Export editable source to a new directory |
|
|
344
143
|
|
|
345
|
-
|
|
144
|
+
These commands are available in npm and Python. To import an app or preview a public listing, see [Marketplace](#marketplace).
|
|
346
145
|
|
|
347
|
-
|
|
146
|
+
## Project Memory and Skill Proposals
|
|
348
147
|
|
|
349
|
-
|
|
148
|
+
Project Memory uses SQLite on your machine. Record a lesson, verify it against evidence, and retrieve it for later runs. The runtimes provide SQLite, so there is no separate database server to install.
|
|
350
149
|
|
|
351
|
-
|
|
352
|
-
| --- | --- |
|
|
353
|
-
| `init [options]` | Scaffold a `.lyra` workspace and starter agents. Options include `--mode`, `--domains`, `--api-key`, `--api-base-url`, `--dir`, and `--force`. |
|
|
354
|
-
| `--help` | Show the init command and its options. The help alias does the same. Add `--help` to a specific command for its syntax. |
|
|
150
|
+
### Local memory
|
|
355
151
|
|
|
356
|
-
|
|
152
|
+
Local memory commands work in Source, npm, and Python. `consolidate` uses the shared Node CLI from Python.
|
|
357
153
|
|
|
358
|
-
| Command |
|
|
154
|
+
| Command | Purpose |
|
|
359
155
|
| --- | --- |
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
363
|
-
| `
|
|
364
|
-
| `
|
|
365
|
-
| `
|
|
366
|
-
| `
|
|
367
|
-
| `
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
| Command | What it does |
|
|
372
|
-
| --- | --- |
|
|
373
|
-
| `agent run --model <model> --prompt <text>` | Run a local agent with an OpenAI model. Requires `OPENAI_API_KEY`. |
|
|
374
|
-
| `team run draft-review --model <model> --prompt <text>` | Run the built-in writer and reviewer team. Requires `OPENAI_API_KEY`. |
|
|
375
|
-
| `run status <run-id>` | Read the latest event for a run from local SQLite history. |
|
|
376
|
-
| `mcp serve --dir <absolute-project-directory>` | Expose saved runs to an IDE over read-only stdio MCP. |
|
|
377
|
-
|
|
378
|
-
## Use the library from JavaScript
|
|
156
|
+
| `memory --help` | List memory commands |
|
|
157
|
+
| `memory init` | Initialize the SQLite memory store |
|
|
158
|
+
| `memory record <json-file>` | Record a candidate lesson |
|
|
159
|
+
| `memory list` | List project memories |
|
|
160
|
+
| `memory search <query>` | Search project memory |
|
|
161
|
+
| `memory inspect <id>` | Read a record and its evidence references |
|
|
162
|
+
| `memory verify <id> <evidence.json>` | Verify a candidate against reviewed evidence |
|
|
163
|
+
| `memory archive <id>` | Archive a memory |
|
|
164
|
+
| `memory consolidate <context>` | Find recurring lessons for a context |
|
|
165
|
+
| `memory stats` | Show store counts and search mode |
|
|
166
|
+
| `memory forget <id> --yes` | Permanently remove a local record |
|
|
379
167
|
|
|
380
|
-
|
|
381
|
-
import { createLinearWorkflow, runWorkflow } from "agent-lyra/standalone";
|
|
168
|
+
See [memory types](https://github.com/agentlyra-labs/agent-lyra-sdk/blob/main/src/memory/index.d.ts) and [evidence validation](https://github.com/agentlyra-labs/agent-lyra-sdk/blob/main/src/memory/validation.js). Store evidence references and reusable lessons. Keep secrets and sensitive data in appropriate stores. Use `LYRA_MEMORY_CONTEXT=off` to disable historical retrieval for model-backed runs.
|
|
382
169
|
|
|
383
|
-
|
|
384
|
-
async () => "collect",
|
|
385
|
-
async (context) => `${context.step_1}:analyze`,
|
|
386
|
-
);
|
|
170
|
+
### Skill proposals
|
|
387
171
|
|
|
388
|
-
|
|
389
|
-
```
|
|
172
|
+
These commands work in Source, npm, and Python. Approving a proposal requires independent regression evidence.
|
|
390
173
|
|
|
391
|
-
|
|
174
|
+
| Command | Purpose |
|
|
175
|
+
| --- | --- |
|
|
176
|
+
| `skills --help` | List skill proposal commands |
|
|
177
|
+
| `skills evolve <context> <memory-id>` | Draft an improvement from verified memory |
|
|
178
|
+
| `skills proposals` | List proposals |
|
|
179
|
+
| `skills proposal <id>` | Inspect a proposal and its sources |
|
|
180
|
+
| `skills approve <id> <regression.json>` | Approve a proposal with evidence |
|
|
181
|
+
| `skills reject <id>` | Reject a pending proposal |
|
|
182
|
+
| `skills withdraw <id>` | Withdraw an approval |
|
|
392
183
|
|
|
393
|
-
##
|
|
184
|
+
## AgentLyra Cloud and Marketplace
|
|
394
185
|
|
|
395
|
-
|
|
186
|
+
[Open the AgentLyra console](https://console.agentlyra.in/) to run hosted agents, manage a workspace, and view synced records. Create one AgentLyra API key under [API Keys](https://console.agentlyra.in/mcp-servers). Enable the permissions you need for hosted runs, resource sync, and verified memory sync.
|
|
396
187
|
|
|
397
|
-
|
|
188
|
+
| Command | Purpose |
|
|
189
|
+
| --- | --- |
|
|
190
|
+
| `connect-cloud [--replace-key]` | Connect once from the IDE. Use `--replace-key` to enter a new key |
|
|
191
|
+
| `work-locally` | Pause Cloud actions while keeping project files |
|
|
398
192
|
|
|
399
|
-
|
|
193
|
+
These commands are available in npm and Python. The compatibility names `gated` and `standalone` still work for switching modes. Provider credentials are configured separately where a hosted run requires them.
|
|
400
194
|
|
|
401
|
-
|
|
195
|
+
### Sync project resources
|
|
402
196
|
|
|
403
|
-
|
|
404
|
-
npx agent-lyra setup coding --stack mern,typescript,playwright --preview
|
|
405
|
-
npx agent-lyra setup coding --stack playwright-cucumber --yes
|
|
406
|
-
```
|
|
197
|
+
These commands work in the npm and Python distributions with a key that has Cloud resource sync permission.
|
|
407
198
|
|
|
408
|
-
|
|
199
|
+
| Command | Purpose |
|
|
200
|
+
| --- | --- |
|
|
201
|
+
| `studio pull` | Pull the workspace catalog from Cloud |
|
|
202
|
+
| `studio push <agent-id>` | Push a local agent to Cloud |
|
|
203
|
+
| `studio pull-agent <agent-id>` | Pull changes to a linked agent |
|
|
204
|
+
| `studio push-workflow <workflow-id>` | Push a local workflow |
|
|
205
|
+
| `studio pull-workflow <workflow-id>` | Pull changes to a linked workflow |
|
|
206
|
+
| `studio push-team <team-id>` | Push a local team |
|
|
207
|
+
| `studio pull-team <team-id>` | Pull changes to a linked team |
|
|
208
|
+
| `studio push-skill <skill-id>` | Push a local text skill |
|
|
209
|
+
| `studio pull-skill <skill-id>` | Pull changes to a linked text skill |
|
|
409
210
|
|
|
410
|
-
|
|
211
|
+
### Sync verified memories
|
|
411
212
|
|
|
412
|
-
|
|
413
|
-
npx agent-lyra setup coding --detect --preview
|
|
414
|
-
```
|
|
213
|
+
Cloud memory commands work in the npm and Python distributions. They require an AgentLyra API key with Memory sync permission.
|
|
415
214
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
215
|
+
| Command | Purpose |
|
|
216
|
+
| --- | --- |
|
|
217
|
+
| `memory cloud list [cursor]` | List your synced records |
|
|
218
|
+
| `memory cloud preview <id>` | Review what would be sent |
|
|
219
|
+
| `memory cloud push <id> --yes` | Upload the reviewed record |
|
|
220
|
+
| `memory cloud pull <id>` | Import a Cloud copy for local review |
|
|
419
221
|
|
|
420
|
-
|
|
421
|
-
npx agent-lyra setup coding export --to claude,codex,copilot --preview
|
|
422
|
-
npx agent-lyra setup coding export --to claude,codex,copilot --yes
|
|
423
|
-
```
|
|
222
|
+
A verified record stays local until you choose to upload it. Preview the payload before confirming a push. The Cloud copy is private to your account.
|
|
424
223
|
|
|
425
|
-
|
|
224
|
+
### Marketplace
|
|
426
225
|
|
|
427
|
-
|
|
226
|
+
Browse [published apps](https://agentlyra.in/marketplace/apps). Sign in to import or submit an app.
|
|
428
227
|
|
|
429
|
-
|
|
228
|
+
| Command | Purpose |
|
|
229
|
+
| --- | --- |
|
|
230
|
+
| `app use <listing-id> [new-manifest.json]` | Import a published app manifest. Requires `LYRA_SESSION_TOKEN` |
|
|
231
|
+
| `app publish <manifest.json> --dry-run` | Preview the listing payload. Submit the listing through Cloud |
|
|
430
232
|
|
|
431
|
-
|
|
432
|
-
npx agent-lyra setup coding --detect --catalog-version 3 --preview
|
|
433
|
-
```
|
|
233
|
+
## License
|
|
434
234
|
|
|
435
|
-
|
|
235
|
+
The public source edition is available under the [MIT License](https://github.com/agentlyra-labs/agent-lyra-sdk/blob/main/LICENSE). For questions and reproducible bugs, use [GitHub Issues](https://github.com/agentlyra-labs/agent-lyra-sdk/issues). Report security issues privately and keep credentials out of issue reports.
|
package/package.json
CHANGED
package/src/coding/export.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { lstat, readFile, readdir } from "node:fs/promises";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
2
|
+
import { join, resolve, basename, dirname } from "node:path";
|
|
3
|
+
import { resourceFiles } from "../resource-files.js";
|
|
3
4
|
import { createInterface } from "node:readline/promises";
|
|
4
5
|
import { parseArgs } from "node:util";
|
|
5
6
|
import { readLocalAgent } from "../studio/project.js";
|
|
@@ -44,9 +45,9 @@ async function sources(root, output) {
|
|
|
44
45
|
const agents = new Map();
|
|
45
46
|
const skills = new Map();
|
|
46
47
|
const agentDir = join(root, ".lyra", "agents");
|
|
47
|
-
for (const
|
|
48
|
-
|
|
49
|
-
const source = await text(join(agentDir,
|
|
48
|
+
for (const name of await resourceFiles(agentDir, ".md")) {
|
|
49
|
+
const entry = { name };
|
|
50
|
+
const source = await text(join(agentDir, name));
|
|
50
51
|
const item = readLocalAgent(source);
|
|
51
52
|
if (!item || item.source !== "local" || !safeName.test(item.id.slice(6))) {
|
|
52
53
|
output.write("Skip unsupported agent " + JSON.stringify(entry.name) + "\n");
|
|
@@ -57,9 +58,11 @@ async function sources(root, output) {
|
|
|
57
58
|
agents.set(id, item);
|
|
58
59
|
}
|
|
59
60
|
const skillDir = join(root, ".lyra", "skills");
|
|
60
|
-
for (const
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
61
|
+
for (const relative of await resourceFiles(skillDir, "SKILL.md")) {
|
|
62
|
+
if (basename(relative) !== "SKILL.md") continue;
|
|
63
|
+
const entry = { name: basename(dirname(relative)) };
|
|
64
|
+
if (!safeName.test(entry.name)) continue;
|
|
65
|
+
const source = await text(join(skillDir, relative));
|
|
63
66
|
const front = /^---\n([\s\S]*?)\n---\n/.exec(source);
|
|
64
67
|
const name = front && scalar(front[1], "name");
|
|
65
68
|
const description = front && scalar(front[1], "description");
|
package/src/coding/setup.js
CHANGED
|
@@ -32,7 +32,7 @@ function plan(selection, scope, { version, technologies, presets, skills }) {
|
|
|
32
32
|
const files = new Map();
|
|
33
33
|
for (const id of ids) {
|
|
34
34
|
const [, name, title, instructions] = technologies[id];
|
|
35
|
-
files.set("skills/lyra-" + id + "/SKILL.md", skills?.[id] ?? [
|
|
35
|
+
files.set("skills/coding/lyra-" + id + "/SKILL.md", skills?.[id] ?? [
|
|
36
36
|
"---", "name: lyra-" + id, "description: " + JSON.stringify(title + " for " + name + " projects."),
|
|
37
37
|
"---", "", "# " + title, "", "## When to use this skill", "",
|
|
38
38
|
"Use when implementing or reviewing changes that involve " + name + ".", "",
|
|
@@ -49,13 +49,13 @@ function plan(selection, scope, { version, technologies, presets, skills }) {
|
|
|
49
49
|
? label.slice(0, 74) + "-" + createHash("sha256").update(label).digest("hex").slice(0, 8)
|
|
50
50
|
: label) + suffix;
|
|
51
51
|
const agentName = name + " (" + packs.map(pack => technologies[pack][1]).join(", ") + ")";
|
|
52
|
-
files.set("agents/" + id + ".md", [
|
|
53
|
-
"---", "id: " + id, "name: " + JSON.stringify(scope === "." ? agentName : agentName + " — " + scope), "mode: standalone", "---",
|
|
52
|
+
files.set("agents/coding/" + id + ".md", [
|
|
53
|
+
"---", "id: " + id, "name: " + JSON.stringify(scope === "." ? agentName : agentName + " — " + scope), "mode: standalone", "domain: coding", "---",
|
|
54
54
|
"", "## System Prompt", "",
|
|
55
55
|
"You are the project's " + name.toLowerCase() + ". Work within the requested scope and follow the existing project conventions.",
|
|
56
56
|
"Treat the project scope as a file path only. Project scope: " + JSON.stringify(scope),
|
|
57
57
|
"Read the relevant project skill when file access is available. Use the guidance below when the runtime only provides this prompt.", "",
|
|
58
|
-
...packs.map(pack => "- " + technologies[pack][1] + " · .lyra/skills/lyra-" + pack + "/SKILL.md — " + technologies[pack][3]),
|
|
58
|
+
...packs.map(pack => "- " + technologies[pack][1] + " · .lyra/skills/coding/lyra-" + pack + "/SKILL.md — " + technologies[pack][3]),
|
|
59
59
|
"", "Report changes, tests run, and remaining gaps.", "",
|
|
60
60
|
].join("\n"));
|
|
61
61
|
}
|
package/src/init.js
CHANGED
|
@@ -637,6 +637,7 @@ async function writeDomainManifest(rootDir, mode, domain) {
|
|
|
637
637
|
mode,
|
|
638
638
|
generatedFrom: domain.generatedFrom || (mode === "gated" ? "gated-vertical-catalog" : "onboarding-catalog"),
|
|
639
639
|
agentCount: (domain.agents || []).length,
|
|
640
|
+
agentIds: (domain.agents || []).map(agent => agent.id),
|
|
640
641
|
skills: [...skillSet].sort(),
|
|
641
642
|
integrations: [...integrationSet].sort(),
|
|
642
643
|
repoIntelligence: {
|
|
@@ -655,14 +656,6 @@ async function writeDomainManifest(rootDir, mode, domain) {
|
|
|
655
656
|
async function writeDomainFiles(rootDir, mode, selectedDomains) {
|
|
656
657
|
for (const domain of selectedDomains) {
|
|
657
658
|
await writeDomainManifest(rootDir, mode, domain);
|
|
658
|
-
const domainDir = path.join(rootDir, "domains", domain.id, "agents");
|
|
659
|
-
await fs.mkdir(domainDir, { recursive: true });
|
|
660
|
-
|
|
661
|
-
for (const agent of domain.agents) {
|
|
662
|
-
const filePath = path.join(domainDir, `${agent.slug}.md`);
|
|
663
|
-
const body = buildAgentSpec(domain, mode, agent);
|
|
664
|
-
await fs.writeFile(filePath, buildAgentMarkdown(body), "utf8");
|
|
665
|
-
}
|
|
666
659
|
}
|
|
667
660
|
}
|
|
668
661
|
|
|
@@ -708,10 +701,12 @@ async function writeTopLevelManifest(rootDir, mode, selectedDomains) {
|
|
|
708
701
|
}));
|
|
709
702
|
|
|
710
703
|
for (const domain of selectedDomains) {
|
|
704
|
+
const domainDir = path.join(agentsDir, domain.id);
|
|
705
|
+
await fs.mkdir(domainDir, { recursive: true });
|
|
711
706
|
for (const agent of domain.agents || []) {
|
|
712
707
|
const spec = buildAgentSpec(domain, mode, agent);
|
|
713
708
|
const fileName = `${spec.slug}.md`;
|
|
714
|
-
await fs.writeFile(path.join(
|
|
709
|
+
await fs.writeFile(path.join(domainDir, fileName), buildAgentMarkdown(spec), "utf8");
|
|
715
710
|
}
|
|
716
711
|
}
|
|
717
712
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { lstat, readdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
export async function resourceFiles(directory, extension, prefix = "") {
|
|
5
|
+
const stat = await lstat(directory).catch(error => {
|
|
6
|
+
if (error.code === "ENOENT") return null;
|
|
7
|
+
throw error;
|
|
8
|
+
});
|
|
9
|
+
if (!stat?.isDirectory()) return [];
|
|
10
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
11
|
+
const result = [];
|
|
12
|
+
for (const entry of entries.sort((a,b) => a.name.localeCompare(b.name))) {
|
|
13
|
+
const name = join(prefix, entry.name);
|
|
14
|
+
if (entry.isDirectory()) result.push(...await resourceFiles(join(directory, entry.name), extension, name));
|
|
15
|
+
else if (entry.isFile() && entry.name.endsWith(extension)) result.push(name);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
package/src/studio/export.js
CHANGED
|
@@ -4,6 +4,7 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { readCatalog, resolveSequence, validateLayout } from "./project.js";
|
|
5
5
|
|
|
6
6
|
const runtime = [
|
|
7
|
+
"resource-files.js",
|
|
7
8
|
"studio/server.js", "studio/memory-actions.js", "studio/memory-panel.js", "studio/project.js", "studio/sync.js", "studio/index.html",
|
|
8
9
|
"studio/browser.js", "studio/studio.css", "studio/agent-ui.js", "studio/agent-ui.css", "app-builder/saved-app.js",
|
|
9
10
|
"memory/index.js", "memory/validation.js", "memory/proposals.js", "memory/sync.js", "memory/lifecycle.js", "memory/contract.json",
|
package/src/studio/project.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { lstat, mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { join, dirname, basename } from "node:path";
|
|
4
|
+
import { resourceFiles } from "../resource-files.js";
|
|
4
5
|
import { createSavedAgentClient } from "../app-builder/saved-app.js";
|
|
5
6
|
import { createOpenAIProvider, openStore } from "../runtime/local-cli.js";
|
|
6
7
|
import { readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
@@ -46,14 +47,14 @@ export function readLocalAgent(source) {
|
|
|
46
47
|
export async function readCatalog(root) {
|
|
47
48
|
const directory = join(root, ".lyra", "agents");
|
|
48
49
|
const agents = new Map();
|
|
49
|
-
for (const name of await
|
|
50
|
+
for (const name of await resourceFiles(directory, ".md")) {
|
|
50
51
|
const parsed = readLocalAgent(await readFile(join(directory, name), "utf8"));
|
|
51
52
|
if (parsed && !agents.has(parsed.id)) agents.set(parsed.id, parsed);
|
|
52
53
|
}
|
|
53
54
|
async function records(kind) {
|
|
54
55
|
const folder = join(root, ".lyra", kind);
|
|
55
56
|
const rows = [];
|
|
56
|
-
for (const name of await
|
|
57
|
+
for (const name of await resourceFiles(folder, ".json")) {
|
|
57
58
|
try {
|
|
58
59
|
const item = JSON.parse(await readFile(join(folder, name), "utf8"));
|
|
59
60
|
if (safeId.test(item.id) && typeof item.name === "string") rows.push(item);
|
|
@@ -63,7 +64,7 @@ export async function readCatalog(root) {
|
|
|
63
64
|
}
|
|
64
65
|
return rows;
|
|
65
66
|
}
|
|
66
|
-
for (const name of await
|
|
67
|
+
for (const name of await resourceFiles(directory, ".json")) {
|
|
67
68
|
let item;
|
|
68
69
|
try {
|
|
69
70
|
item = JSON.parse((await readFile(join(directory, name), "utf8")).replace(/^\uFEFF/, ""));
|
|
@@ -79,13 +80,11 @@ export async function readCatalog(root) {
|
|
|
79
80
|
}
|
|
80
81
|
const skills = await records("skills");
|
|
81
82
|
const skillRoot = join(root, ".lyra", "skills");
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!folder.isDirectory() || !safeId.test(folder.name)) continue;
|
|
88
|
-
const metadata = join(skillRoot, folder.name, "SKILL.md");
|
|
83
|
+
for (const relative of await resourceFiles(skillRoot, "SKILL.md")) {
|
|
84
|
+
if (basename(relative) !== "SKILL.md") continue;
|
|
85
|
+
const folder = { name: basename(dirname(relative)) };
|
|
86
|
+
if (!safeId.test(folder.name)) continue;
|
|
87
|
+
const metadata = join(skillRoot, relative);
|
|
89
88
|
const stat = await lstat(metadata).catch(error => {
|
|
90
89
|
if (error.code === "ENOENT") return null;
|
|
91
90
|
throw error;
|
package/src/studio/pull-agent.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { lstat, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { resourceFiles } from "../resource-files.js";
|
|
4
5
|
import { readLocalAgent } from "./project.js";
|
|
5
6
|
import { readMode, readSdkKey, requireCloudMode } from "./session.js";
|
|
6
7
|
|
|
@@ -22,9 +23,8 @@ export async function pullAgentEdits(root, id, { request = fetch, key } = {}) {
|
|
|
22
23
|
if (!digest.test(link?.linkId ?? "") || !digest.test(link?.revision ?? "")) throw new Error("Invalid Cloud link.");
|
|
23
24
|
|
|
24
25
|
const matches = [];
|
|
25
|
-
for (const
|
|
26
|
-
|
|
27
|
-
const path = join(folder, entry.name);
|
|
26
|
+
for (const name of await resourceFiles(folder, ".md")) {
|
|
27
|
+
const path = join(folder, name);
|
|
28
28
|
const content = await readFile(path, "utf8");
|
|
29
29
|
const parsed = readLocalAgent(content);
|
|
30
30
|
if (parsed?.id === id) matches.push({ path, content, parsed });
|