agent-lyra 0.6.4 → 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/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/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 });
|