agent-lyra 0.7.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +301 -276
- package/bin/agent-lyra.js +51 -51
- package/bin/lyra-oss-preview.js +16 -16
- package/package.json +60 -60
- package/src/app-builder/export.js +109 -109
- package/src/app-builder/gateway.js +62 -62
- package/src/app-builder/init.js +115 -72
- package/src/app-builder/manifest-contract.js +46 -46
- package/src/app-builder/native-adapter.js +29 -29
- package/src/app-builder/preview.js +35 -31
- package/src/app-builder/publish.js +14 -14
- package/src/app-builder/saved-app.js +70 -70
- package/src/app-builder/saved-preview-browser.js +33 -33
- package/src/app-builder/saved-preview.html +24 -24
- package/src/app-builder/saved-preview.js +61 -61
- package/src/app-builder/support-manifest.js +50 -50
- package/src/app-builder/support-template/manifest.json +55 -55
- package/src/app-builder/support-template/support-preview.html +56 -56
- package/src/app-builder/support-template/support-preview.js +37 -37
- package/src/app-builder/support-template/support-preview.mjs +67 -67
- package/src/app-builder/support-template/support-workflow.mjs +36 -36
- package/src/app-builder/use.js +37 -37
- package/src/app-builder/validate.js +31 -21
- package/src/app-builder/value-schema.js +37 -37
- package/src/catalog.js +147 -147
- package/src/coding/catalog.js +56 -56
- package/src/coding/cloud-catalog.js +64 -64
- package/src/coding/detect-stack.mjs +110 -110
- package/src/coding/export.js +133 -133
- package/src/coding/setup.js +175 -175
- package/src/coding/skills/lyra-android/SKILL.md +37 -37
- package/src/coding/skills/lyra-angular/SKILL.md +37 -37
- package/src/coding/skills/lyra-cucumber/SKILL.md +37 -37
- package/src/coding/skills/lyra-dbt/SKILL.md +37 -37
- package/src/coding/skills/lyra-django/SKILL.md +37 -37
- package/src/coding/skills/lyra-docker/SKILL.md +37 -37
- package/src/coding/skills/lyra-dotnet/SKILL.md +37 -37
- package/src/coding/skills/lyra-express/SKILL.md +37 -37
- package/src/coding/skills/lyra-fastapi/SKILL.md +37 -37
- package/src/coding/skills/lyra-flutter/SKILL.md +37 -37
- package/src/coding/skills/lyra-github-actions/SKILL.md +37 -37
- package/src/coding/skills/lyra-gitlab-ci/SKILL.md +37 -37
- package/src/coding/skills/lyra-go/SKILL.md +37 -37
- package/src/coding/skills/lyra-ios/SKILL.md +37 -37
- package/src/coding/skills/lyra-kubernetes/SKILL.md +37 -37
- package/src/coding/skills/lyra-mongodb/SKILL.md +37 -37
- package/src/coding/skills/lyra-mysql/SKILL.md +37 -37
- package/src/coding/skills/lyra-nextjs/SKILL.md +37 -37
- package/src/coding/skills/lyra-node/SKILL.md +37 -37
- package/src/coding/skills/lyra-playwright/SKILL.md +37 -37
- package/src/coding/skills/lyra-postgresql/SKILL.md +37 -37
- package/src/coding/skills/lyra-python/SKILL.md +37 -37
- package/src/coding/skills/lyra-react/SKILL.md +37 -37
- package/src/coding/skills/lyra-react-native/SKILL.md +37 -37
- package/src/coding/skills/lyra-redis/SKILL.md +37 -37
- package/src/coding/skills/lyra-rust/SKILL.md +37 -37
- package/src/coding/skills/lyra-spark/SKILL.md +37 -37
- package/src/coding/skills/lyra-spring-boot/SKILL.md +37 -37
- package/src/coding/skills/lyra-svelte/SKILL.md +37 -37
- package/src/coding/skills/lyra-terraform/SKILL.md +37 -37
- package/src/coding/skills/lyra-typescript/SKILL.md +37 -37
- package/src/coding/skills/lyra-vue/SKILL.md +37 -37
- package/src/framework/agent.js +181 -173
- package/src/framework/mda.js +65 -0
- package/src/framework/run.py +111 -111
- package/src/gated/hostedAgents.js +56 -56
- package/src/gated/index.d.ts +25 -25
- package/src/gated/index.js +5 -5
- package/src/index.d.ts +2 -2
- package/src/index.js +2 -2
- package/src/init.js +960 -960
- package/src/intelligence/graphsnip-provider.d.ts +5 -5
- package/src/intelligence/graphsnip-provider.js +57 -57
- package/src/intelligence/lifecycle.js +25 -0
- package/src/memory/LICENSE +21 -21
- package/src/memory/README.md +5 -5
- package/src/memory/UPSTREAM.json +24 -14
- package/src/memory/bridge-cli.js +16 -16
- package/src/memory/bridge.js +18 -18
- package/src/memory/cli.js +21 -21
- package/src/memory/cloud-sync-actions.js +61 -61
- package/src/memory/contract.json +45 -45
- package/src/memory/index.d.ts +50 -49
- package/src/memory/index.js +7 -7
- package/src/memory/lifecycle.js +29 -29
- package/src/memory/local-cli.js +34 -34
- package/src/memory/local-store.js +209 -209
- package/src/memory/package.json +33 -33
- package/src/memory/proposals.js +90 -90
- package/src/memory/skills-cli.js +26 -26
- package/src/memory/standalone.d.ts +50 -50
- package/src/memory/standalone.js +1 -1
- package/src/memory/sync.js +89 -89
- package/src/memory/validation.js +25 -25
- package/src/onboardingAgents.js +532 -532
- package/src/promptTemplates.js +178 -178
- package/src/resource-files.js +18 -18
- package/src/runtime/contracts.d.ts +47 -47
- package/src/runtime/local-cli.js +161 -160
- package/src/runtime/mcp-stdio.js +111 -111
- package/src/runtime/orchestration.js +59 -59
- package/src/runtime/run-agent.js +54 -53
- package/src/standalone/index.d.ts +45 -45
- package/src/standalone/index.js +13 -13
- package/src/standalone/init.js +12 -12
- package/src/standalone/orchestration.js +6 -6
- package/src/standalone/rag.js +113 -113
- package/src/studio/agent-ui.css +43 -43
- package/src/studio/agent-ui.js +32 -32
- package/src/studio/browser.js +542 -345
- package/src/studio/export.js +83 -85
- package/src/studio/index.html +74 -37
- package/src/studio/memory-actions.js +37 -37
- package/src/studio/memory-panel.js +200 -200
- package/src/studio/project.js +308 -240
- package/src/studio/pull-agent.js +72 -72
- package/src/studio/push.js +54 -54
- package/src/studio/python-agent.js +47 -47
- package/src/studio/python-agent.py +25 -25
- package/src/studio/server.js +164 -150
- package/src/studio/session.js +83 -83
- package/src/studio/studio.css +257 -10
- package/src/studio/sync.js +42 -42
- package/src/studio/workflow-editor.js +240 -0
- package/src/studio/workflow-sync.js +229 -157
package/src/coding/setup.js
CHANGED
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { detectStack } from "./detect-stack.mjs";
|
|
3
|
-
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
-
import { join, resolve } from "node:path";
|
|
5
|
-
import { createInterface } from "node:readline/promises";
|
|
6
|
-
import { parseArgs } from "node:util";
|
|
7
|
-
import { areas, presets, technologies } from "./catalog.js";
|
|
8
|
-
import { getBundledCatalog, fetchCodingCatalog } from "./cloud-catalog.js";
|
|
9
|
-
const areaLabels = { frontend: "Frontend", backend: "Backend and APIs", database: "Databases", devops: "DevOps", qa: "QA and test automation", mobile: "Mobile", data: "Data engineering" };
|
|
10
|
-
|
|
11
|
-
function showChoices(output, { presets, technologies }) {
|
|
12
|
-
output.write("Presets: " + Object.keys(presets).join(", ") + "\n");
|
|
13
|
-
for (const [area, label] of Object.entries(areaLabels)) {
|
|
14
|
-
output.write(label + ": " + Object.entries(technologies).filter(([, pack]) => pack[0] === area)
|
|
15
|
-
.map(([id, [, name]]) => name + " (" + id + ")").join(", ") + "\n");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function selectCodingStack(rl, output, catalog = { presets, technologies }) {
|
|
20
|
-
showChoices(output, catalog);
|
|
21
|
-
return (await rl.question("Choose presets or technologies (comma separated, Enter to skip): ")).trim();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function plan(selection, scope, { version, technologies, presets, skills }) {
|
|
25
|
-
const chosen = selection.toLowerCase().split(",").map(part => part.trim()).filter(Boolean);
|
|
26
|
-
if (!chosen.length) throw new Error("Choose at least one preset or technology.");
|
|
27
|
-
const ids = [...new Set(chosen.flatMap(id => {
|
|
28
|
-
if (Object.hasOwn(presets, id)) return presets[id];
|
|
29
|
-
if (Object.hasOwn(technologies, id)) return [id];
|
|
30
|
-
throw new Error("Unknown technology or preset: " + id);
|
|
31
|
-
}))].sort();
|
|
32
|
-
const files = new Map();
|
|
33
|
-
for (const id of ids) {
|
|
34
|
-
const [, name, title, instructions] = technologies[id];
|
|
35
|
-
files.set("skills/coding/lyra-" + id + "/SKILL.md", skills?.[id] ?? [
|
|
36
|
-
"---", "name: lyra-" + id, "description: " + JSON.stringify(title + " for " + name + " projects."),
|
|
37
|
-
"---", "", "# " + title, "", "## When to use this skill", "",
|
|
38
|
-
"Use when implementing or reviewing changes that involve " + name + ".", "",
|
|
39
|
-
"## Steps", "", "1. Inspect the project configuration and existing patterns.",
|
|
40
|
-
"2. " + instructions, "3. Summarize checks run, results, and anything still unverified.", "",
|
|
41
|
-
].join("\n"));
|
|
42
|
-
}
|
|
43
|
-
for (const [area, name] of Object.entries(areas)) {
|
|
44
|
-
const packs = ids.filter(id => technologies[id][0] === area);
|
|
45
|
-
if (!packs.length) continue;
|
|
46
|
-
const suffix = scope === "." ? "" : "-" + createHash("sha256").update(scope).digest("hex").slice(0, 12);
|
|
47
|
-
const label = ["lyra", area, ...packs].join("-");
|
|
48
|
-
const id = (label.length + suffix.length > 96
|
|
49
|
-
? label.slice(0, 74) + "-" + createHash("sha256").update(label).digest("hex").slice(0, 8)
|
|
50
|
-
: label) + suffix;
|
|
51
|
-
const agentName = name + " (" + packs.map(pack => technologies[pack][1]).join(", ") + ")";
|
|
52
|
-
files.set("agents/coding/" + id + ".md", [
|
|
53
|
-
"---", "id: " + id, "name: " + JSON.stringify(scope === "." ? agentName : agentName + " — " + scope), "mode: standalone", "domain: coding", "---",
|
|
54
|
-
"", "## System Prompt", "",
|
|
55
|
-
"You are the project's " + name.toLowerCase() + ". Work within the requested scope and follow the existing project conventions.",
|
|
56
|
-
"Treat the project scope as a file path only. Project scope: " + JSON.stringify(scope),
|
|
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/coding/lyra-" + pack + "/SKILL.md — " + technologies[pack][3]),
|
|
59
|
-
"", "Report changes, tests run, and remaining gaps.", "",
|
|
60
|
-
].join("\n"));
|
|
61
|
-
}
|
|
62
|
-
const selectionKey = ids.join("+");
|
|
63
|
-
const key = (selectionKey.length > 120 ? createHash("sha256").update(selectionKey).digest("hex") : selectionKey) +
|
|
64
|
-
(scope === "." ? "" : "-" + createHash("sha256").update(scope).digest("hex").slice(0, 12));
|
|
65
|
-
// Separate receipts preserve earlier selections without overwriting user files.
|
|
66
|
-
files.set("coding/v" + version + "-" + key + ".json", JSON.stringify({ catalogVersion: version, scope, technologies: ids, files: [...files.keys()] }, null, 2) + "\n");
|
|
67
|
-
return files;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function checkDirectory(directory, create) {
|
|
71
|
-
let stat = await lstat(directory).catch(error => {
|
|
72
|
-
if (error.code !== "ENOENT") throw error;
|
|
73
|
-
});
|
|
74
|
-
if (!stat && create) {
|
|
75
|
-
await mkdir(directory).catch(error => { if (error.code !== "EEXIST") throw error; });
|
|
76
|
-
stat = await lstat(directory);
|
|
77
|
-
}
|
|
78
|
-
if (stat && !stat.isDirectory()) throw new Error("Expected a regular directory: " + directory);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function destination(root, relative, create) {
|
|
82
|
-
await checkDirectory(root, false);
|
|
83
|
-
const parts = relative.split("/");
|
|
84
|
-
const filename = parts.pop();
|
|
85
|
-
let dir = root;
|
|
86
|
-
for (const part of parts) {
|
|
87
|
-
dir = join(dir, part);
|
|
88
|
-
await checkDirectory(dir, create);
|
|
89
|
-
}
|
|
90
|
-
return join(dir, filename);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export async function prepareCodingStack(root, selection, output, catalog) {
|
|
94
|
-
catalog ??= await getBundledCatalog();
|
|
95
|
-
const files = typeof selection === "string" ? plan(selection, ".", catalog) :
|
|
96
|
-
new Map(selection.flatMap(project => [...plan(project.ids.join(","), project.scope, catalog)]));
|
|
97
|
-
files.set("scripts/detect-stack.mjs", await readFile(new URL("./detect-stack.mjs", import.meta.url), "utf8"));
|
|
98
|
-
return prepareProjectFiles(root, new Map([...files].map(([name, content]) => [".lyra/" + name, content])), output);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export async function prepareProjectFiles(root, files, output) {
|
|
102
|
-
for (const [relative, content] of files) {
|
|
103
|
-
const path = await destination(root, relative, false);
|
|
104
|
-
const stat = await lstat(path).catch(error => {
|
|
105
|
-
if (error.code !== "ENOENT") throw error;
|
|
106
|
-
});
|
|
107
|
-
const unchanged = stat?.isFile() && (await readFile(path, "utf8")).replace(/\r\n/g, "\n") === content;
|
|
108
|
-
output.write((!stat ? "Create" : unchanged ? "Already installed" : "Keep existing") + " " + relative + "\n");
|
|
109
|
-
}
|
|
110
|
-
return async () => {
|
|
111
|
-
for (const [relative, content] of files) {
|
|
112
|
-
const path = await destination(root, relative, true);
|
|
113
|
-
await writeFile(path, content, { flag: "wx" }).catch(error => {
|
|
114
|
-
if (error.code !== "EEXIST" && error.code !== "EISDIR") throw error;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export async function recommendCodingStacks(root, output, { technologies: available } = { technologies }) {
|
|
121
|
-
const detected = await detectStack(root);
|
|
122
|
-
if (detected.truncated) output.write("Scan limit reached. Some folders were skipped.\n");
|
|
123
|
-
const selected = [];
|
|
124
|
-
for (const { scope, technologies: hits } of detected.projects) {
|
|
125
|
-
const supported = hits.filter(({ id }) => Object.hasOwn(available, id));
|
|
126
|
-
output.write("Project " + JSON.stringify(scope) + "\n");
|
|
127
|
-
for (const { id, evidence } of hits) {
|
|
128
|
-
output.write(" " + id + (Object.hasOwn(available, id) ? "" : " (no pack)") +
|
|
129
|
-
" · " + evidence.map(file => JSON.stringify(file)).join(", ") + "\n");
|
|
130
|
-
}
|
|
131
|
-
if (supported.length) selected.push({ scope, ids: supported.map(hit => hit.id) });
|
|
132
|
-
}
|
|
133
|
-
if (!selected.length) output.write("No supported stack detected. Choose your technologies manually.\n");
|
|
134
|
-
return selected;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export async function runCodingSetup(args, { input = process.stdin, output = process.stdout, root = process.cwd() } = {}) {
|
|
138
|
-
const { values } = parseArgs({ args, options: {
|
|
139
|
-
"catalog-version": { type: "string" }, detect: { type: "boolean" }, stack: { type: "string" }, dir: { type: "string" }, preview: { type: "boolean" },
|
|
140
|
-
yes: { type: "boolean", short: "y" }, help: { type: "boolean", short: "h" },
|
|
141
|
-
} });
|
|
142
|
-
if (values.help) {
|
|
143
|
-
output.write("Usage: agent-lyra setup coding [--stack <names> | --detect] [--catalog-version <number>] [--preview | --yes] [--dir <folder>]\n");
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (values.detect && values.stack) throw new Error("Choose --detect or --stack.");
|
|
147
|
-
if (!input.isTTY && ((!values.stack && !values.detect) || (!values.preview && !values.yes))) {
|
|
148
|
-
throw new Error("Provide --stack or --detect with --preview or --yes when running without an interactive terminal.");
|
|
149
|
-
}
|
|
150
|
-
const rl = input.isTTY ? createInterface({ input, output }) : null;
|
|
151
|
-
try {
|
|
152
|
-
const target = resolve(root, values.dir ?? ".");
|
|
153
|
-
const catalog = values["catalog-version"] ? await fetchCodingCatalog(values["catalog-version"]) : await getBundledCatalog();
|
|
154
|
-
output.write("Coding catalog " + catalog.version + (values["catalog-version"] ? " (Cloud)" : " (bundled)") + "\n");
|
|
155
|
-
const useDetection = values.detect || (!values.stack && /^y(?:es)?$/i.test((await rl.question("Detect technologies from this project? [y/N] ")).trim()));
|
|
156
|
-
let selected = values.stack;
|
|
157
|
-
if (useDetection) {
|
|
158
|
-
selected = await recommendCodingStacks(target, output, catalog);
|
|
159
|
-
if (!selected.length) {
|
|
160
|
-
selected = undefined;
|
|
161
|
-
} else if (rl && !values.yes && !values.preview) {
|
|
162
|
-
const answer = (await rl.question("Use these recommendations? [Y/n] ")).trim();
|
|
163
|
-
if (/^n(?:o)?$/i.test(answer)) selected = undefined;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (selected === undefined && rl && !values.preview) selected = await selectCodingStack(rl, output, catalog);
|
|
167
|
-
if (!selected) return;
|
|
168
|
-
const apply = await prepareCodingStack(target, selected, output, catalog);
|
|
169
|
-
if (values.preview || (!values.yes && !/^y(?:es)?$/i.test((await rl.question("Create these files? [y/N] ")).trim()))) return;
|
|
170
|
-
await apply();
|
|
171
|
-
output.write("Coding setup complete. Edit your agent and skill guidance in .lyra.\n");
|
|
172
|
-
} finally {
|
|
173
|
-
rl?.close();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { detectStack } from "./detect-stack.mjs";
|
|
3
|
+
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { createInterface } from "node:readline/promises";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
import { areas, presets, technologies } from "./catalog.js";
|
|
8
|
+
import { getBundledCatalog, fetchCodingCatalog } from "./cloud-catalog.js";
|
|
9
|
+
const areaLabels = { frontend: "Frontend", backend: "Backend and APIs", database: "Databases", devops: "DevOps", qa: "QA and test automation", mobile: "Mobile", data: "Data engineering" };
|
|
10
|
+
|
|
11
|
+
function showChoices(output, { presets, technologies }) {
|
|
12
|
+
output.write("Presets: " + Object.keys(presets).join(", ") + "\n");
|
|
13
|
+
for (const [area, label] of Object.entries(areaLabels)) {
|
|
14
|
+
output.write(label + ": " + Object.entries(technologies).filter(([, pack]) => pack[0] === area)
|
|
15
|
+
.map(([id, [, name]]) => name + " (" + id + ")").join(", ") + "\n");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function selectCodingStack(rl, output, catalog = { presets, technologies }) {
|
|
20
|
+
showChoices(output, catalog);
|
|
21
|
+
return (await rl.question("Choose presets or technologies (comma separated, Enter to skip): ")).trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function plan(selection, scope, { version, technologies, presets, skills }) {
|
|
25
|
+
const chosen = selection.toLowerCase().split(",").map(part => part.trim()).filter(Boolean);
|
|
26
|
+
if (!chosen.length) throw new Error("Choose at least one preset or technology.");
|
|
27
|
+
const ids = [...new Set(chosen.flatMap(id => {
|
|
28
|
+
if (Object.hasOwn(presets, id)) return presets[id];
|
|
29
|
+
if (Object.hasOwn(technologies, id)) return [id];
|
|
30
|
+
throw new Error("Unknown technology or preset: " + id);
|
|
31
|
+
}))].sort();
|
|
32
|
+
const files = new Map();
|
|
33
|
+
for (const id of ids) {
|
|
34
|
+
const [, name, title, instructions] = technologies[id];
|
|
35
|
+
files.set("skills/coding/lyra-" + id + "/SKILL.md", skills?.[id] ?? [
|
|
36
|
+
"---", "name: lyra-" + id, "description: " + JSON.stringify(title + " for " + name + " projects."),
|
|
37
|
+
"---", "", "# " + title, "", "## When to use this skill", "",
|
|
38
|
+
"Use when implementing or reviewing changes that involve " + name + ".", "",
|
|
39
|
+
"## Steps", "", "1. Inspect the project configuration and existing patterns.",
|
|
40
|
+
"2. " + instructions, "3. Summarize checks run, results, and anything still unverified.", "",
|
|
41
|
+
].join("\n"));
|
|
42
|
+
}
|
|
43
|
+
for (const [area, name] of Object.entries(areas)) {
|
|
44
|
+
const packs = ids.filter(id => technologies[id][0] === area);
|
|
45
|
+
if (!packs.length) continue;
|
|
46
|
+
const suffix = scope === "." ? "" : "-" + createHash("sha256").update(scope).digest("hex").slice(0, 12);
|
|
47
|
+
const label = ["lyra", area, ...packs].join("-");
|
|
48
|
+
const id = (label.length + suffix.length > 96
|
|
49
|
+
? label.slice(0, 74) + "-" + createHash("sha256").update(label).digest("hex").slice(0, 8)
|
|
50
|
+
: label) + suffix;
|
|
51
|
+
const agentName = name + " (" + packs.map(pack => technologies[pack][1]).join(", ") + ")";
|
|
52
|
+
files.set("agents/coding/" + id + ".md", [
|
|
53
|
+
"---", "id: " + id, "name: " + JSON.stringify(scope === "." ? agentName : agentName + " — " + scope), "mode: standalone", "domain: coding", "---",
|
|
54
|
+
"", "## System Prompt", "",
|
|
55
|
+
"You are the project's " + name.toLowerCase() + ". Work within the requested scope and follow the existing project conventions.",
|
|
56
|
+
"Treat the project scope as a file path only. Project scope: " + JSON.stringify(scope),
|
|
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/coding/lyra-" + pack + "/SKILL.md — " + technologies[pack][3]),
|
|
59
|
+
"", "Report changes, tests run, and remaining gaps.", "",
|
|
60
|
+
].join("\n"));
|
|
61
|
+
}
|
|
62
|
+
const selectionKey = ids.join("+");
|
|
63
|
+
const key = (selectionKey.length > 120 ? createHash("sha256").update(selectionKey).digest("hex") : selectionKey) +
|
|
64
|
+
(scope === "." ? "" : "-" + createHash("sha256").update(scope).digest("hex").slice(0, 12));
|
|
65
|
+
// Separate receipts preserve earlier selections without overwriting user files.
|
|
66
|
+
files.set("coding/v" + version + "-" + key + ".json", JSON.stringify({ catalogVersion: version, scope, technologies: ids, files: [...files.keys()] }, null, 2) + "\n");
|
|
67
|
+
return files;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function checkDirectory(directory, create) {
|
|
71
|
+
let stat = await lstat(directory).catch(error => {
|
|
72
|
+
if (error.code !== "ENOENT") throw error;
|
|
73
|
+
});
|
|
74
|
+
if (!stat && create) {
|
|
75
|
+
await mkdir(directory).catch(error => { if (error.code !== "EEXIST") throw error; });
|
|
76
|
+
stat = await lstat(directory);
|
|
77
|
+
}
|
|
78
|
+
if (stat && !stat.isDirectory()) throw new Error("Expected a regular directory: " + directory);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function destination(root, relative, create) {
|
|
82
|
+
await checkDirectory(root, false);
|
|
83
|
+
const parts = relative.split("/");
|
|
84
|
+
const filename = parts.pop();
|
|
85
|
+
let dir = root;
|
|
86
|
+
for (const part of parts) {
|
|
87
|
+
dir = join(dir, part);
|
|
88
|
+
await checkDirectory(dir, create);
|
|
89
|
+
}
|
|
90
|
+
return join(dir, filename);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function prepareCodingStack(root, selection, output, catalog) {
|
|
94
|
+
catalog ??= await getBundledCatalog();
|
|
95
|
+
const files = typeof selection === "string" ? plan(selection, ".", catalog) :
|
|
96
|
+
new Map(selection.flatMap(project => [...plan(project.ids.join(","), project.scope, catalog)]));
|
|
97
|
+
files.set("scripts/detect-stack.mjs", await readFile(new URL("./detect-stack.mjs", import.meta.url), "utf8"));
|
|
98
|
+
return prepareProjectFiles(root, new Map([...files].map(([name, content]) => [".lyra/" + name, content])), output);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function prepareProjectFiles(root, files, output) {
|
|
102
|
+
for (const [relative, content] of files) {
|
|
103
|
+
const path = await destination(root, relative, false);
|
|
104
|
+
const stat = await lstat(path).catch(error => {
|
|
105
|
+
if (error.code !== "ENOENT") throw error;
|
|
106
|
+
});
|
|
107
|
+
const unchanged = stat?.isFile() && (await readFile(path, "utf8")).replace(/\r\n/g, "\n") === content;
|
|
108
|
+
output.write((!stat ? "Create" : unchanged ? "Already installed" : "Keep existing") + " " + relative + "\n");
|
|
109
|
+
}
|
|
110
|
+
return async () => {
|
|
111
|
+
for (const [relative, content] of files) {
|
|
112
|
+
const path = await destination(root, relative, true);
|
|
113
|
+
await writeFile(path, content, { flag: "wx" }).catch(error => {
|
|
114
|
+
if (error.code !== "EEXIST" && error.code !== "EISDIR") throw error;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function recommendCodingStacks(root, output, { technologies: available } = { technologies }) {
|
|
121
|
+
const detected = await detectStack(root);
|
|
122
|
+
if (detected.truncated) output.write("Scan limit reached. Some folders were skipped.\n");
|
|
123
|
+
const selected = [];
|
|
124
|
+
for (const { scope, technologies: hits } of detected.projects) {
|
|
125
|
+
const supported = hits.filter(({ id }) => Object.hasOwn(available, id));
|
|
126
|
+
output.write("Project " + JSON.stringify(scope) + "\n");
|
|
127
|
+
for (const { id, evidence } of hits) {
|
|
128
|
+
output.write(" " + id + (Object.hasOwn(available, id) ? "" : " (no pack)") +
|
|
129
|
+
" · " + evidence.map(file => JSON.stringify(file)).join(", ") + "\n");
|
|
130
|
+
}
|
|
131
|
+
if (supported.length) selected.push({ scope, ids: supported.map(hit => hit.id) });
|
|
132
|
+
}
|
|
133
|
+
if (!selected.length) output.write("No supported stack detected. Choose your technologies manually.\n");
|
|
134
|
+
return selected;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export async function runCodingSetup(args, { input = process.stdin, output = process.stdout, root = process.cwd() } = {}) {
|
|
138
|
+
const { values } = parseArgs({ args, options: {
|
|
139
|
+
"catalog-version": { type: "string" }, detect: { type: "boolean" }, stack: { type: "string" }, dir: { type: "string" }, preview: { type: "boolean" },
|
|
140
|
+
yes: { type: "boolean", short: "y" }, help: { type: "boolean", short: "h" },
|
|
141
|
+
} });
|
|
142
|
+
if (values.help) {
|
|
143
|
+
output.write("Usage: agent-lyra setup coding [--stack <names> | --detect] [--catalog-version <number>] [--preview | --yes] [--dir <folder>]\n");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (values.detect && values.stack) throw new Error("Choose --detect or --stack.");
|
|
147
|
+
if (!input.isTTY && ((!values.stack && !values.detect) || (!values.preview && !values.yes))) {
|
|
148
|
+
throw new Error("Provide --stack or --detect with --preview or --yes when running without an interactive terminal.");
|
|
149
|
+
}
|
|
150
|
+
const rl = input.isTTY ? createInterface({ input, output }) : null;
|
|
151
|
+
try {
|
|
152
|
+
const target = resolve(root, values.dir ?? ".");
|
|
153
|
+
const catalog = values["catalog-version"] ? await fetchCodingCatalog(values["catalog-version"]) : await getBundledCatalog();
|
|
154
|
+
output.write("Coding catalog " + catalog.version + (values["catalog-version"] ? " (Cloud)" : " (bundled)") + "\n");
|
|
155
|
+
const useDetection = values.detect || (!values.stack && /^y(?:es)?$/i.test((await rl.question("Detect technologies from this project? [y/N] ")).trim()));
|
|
156
|
+
let selected = values.stack;
|
|
157
|
+
if (useDetection) {
|
|
158
|
+
selected = await recommendCodingStacks(target, output, catalog);
|
|
159
|
+
if (!selected.length) {
|
|
160
|
+
selected = undefined;
|
|
161
|
+
} else if (rl && !values.yes && !values.preview) {
|
|
162
|
+
const answer = (await rl.question("Use these recommendations? [Y/n] ")).trim();
|
|
163
|
+
if (/^n(?:o)?$/i.test(answer)) selected = undefined;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (selected === undefined && rl && !values.preview) selected = await selectCodingStack(rl, output, catalog);
|
|
167
|
+
if (!selected) return;
|
|
168
|
+
const apply = await prepareCodingStack(target, selected, output, catalog);
|
|
169
|
+
if (values.preview || (!values.yes && !/^y(?:es)?$/i.test((await rl.question("Create these files? [y/N] ")).trim()))) return;
|
|
170
|
+
await apply();
|
|
171
|
+
output.write("Coding setup complete. Edit your agent and skill guidance in .lyra.\n");
|
|
172
|
+
} finally {
|
|
173
|
+
rl?.close();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: lyra-android
|
|
3
|
-
description: "Implement Android behavior across lifecycle, persistence, permissions, and device variations."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Android
|
|
7
|
-
|
|
8
|
-
## Inspect the project
|
|
9
|
-
|
|
10
|
-
Check target and minimum SDK levels, Kotlin or Java, Compose or Views, Gradle modules, and build variants.
|
|
11
|
-
|
|
12
|
-
## Implementation practices
|
|
13
|
-
|
|
14
|
-
- Use project architecture for UI state and data ownership. Cover lifecycle recreation and distinguish ephemeral UI state from persisted application data.
|
|
15
|
-
- Keep database, network, and expensive work off the main thread. Scope coroutines or equivalent work to the owner and handle cancellation correctly.
|
|
16
|
-
- Use supported permission flows and preserve a usable denied state. Validate intent and deep-link data, and restrict exported components.
|
|
17
|
-
|
|
18
|
-
## Guardrails and trade-offs
|
|
19
|
-
|
|
20
|
-
- Use platform-approved storage for sensitive data, and avoid secrets in APK resources or diagnostics.
|
|
21
|
-
- Design for accessibility, localization, and device configuration changes. Measure UI responsiveness and battery-sensitive work before tuning.
|
|
22
|
-
|
|
23
|
-
## Decisions to check
|
|
24
|
-
|
|
25
|
-
Review configuration changes, saved-state behavior, and background work constraints. Use WorkManager or the project's supported scheduling mechanism for deferrable work when it fits the requirement. Verify locale and text-scale behavior for changed UI.
|
|
26
|
-
|
|
27
|
-
## Review scenario
|
|
28
|
-
|
|
29
|
-
For a screen dependent on permissions, verify initial denial, returning from settings, and activity recreation without duplicate requests.
|
|
30
|
-
|
|
31
|
-
## Verification
|
|
32
|
-
|
|
33
|
-
Run Gradle checks and appropriate local and instrumented tests. Verify affected API levels, build variants, and accessibility behavior.
|
|
34
|
-
|
|
35
|
-
## Reference
|
|
36
|
-
|
|
37
|
-
- [Android documentation](https://developer.android.com/topic/architecture)
|
|
1
|
+
---
|
|
2
|
+
name: lyra-android
|
|
3
|
+
description: "Implement Android behavior across lifecycle, persistence, permissions, and device variations."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Android
|
|
7
|
+
|
|
8
|
+
## Inspect the project
|
|
9
|
+
|
|
10
|
+
Check target and minimum SDK levels, Kotlin or Java, Compose or Views, Gradle modules, and build variants.
|
|
11
|
+
|
|
12
|
+
## Implementation practices
|
|
13
|
+
|
|
14
|
+
- Use project architecture for UI state and data ownership. Cover lifecycle recreation and distinguish ephemeral UI state from persisted application data.
|
|
15
|
+
- Keep database, network, and expensive work off the main thread. Scope coroutines or equivalent work to the owner and handle cancellation correctly.
|
|
16
|
+
- Use supported permission flows and preserve a usable denied state. Validate intent and deep-link data, and restrict exported components.
|
|
17
|
+
|
|
18
|
+
## Guardrails and trade-offs
|
|
19
|
+
|
|
20
|
+
- Use platform-approved storage for sensitive data, and avoid secrets in APK resources or diagnostics.
|
|
21
|
+
- Design for accessibility, localization, and device configuration changes. Measure UI responsiveness and battery-sensitive work before tuning.
|
|
22
|
+
|
|
23
|
+
## Decisions to check
|
|
24
|
+
|
|
25
|
+
Review configuration changes, saved-state behavior, and background work constraints. Use WorkManager or the project's supported scheduling mechanism for deferrable work when it fits the requirement. Verify locale and text-scale behavior for changed UI.
|
|
26
|
+
|
|
27
|
+
## Review scenario
|
|
28
|
+
|
|
29
|
+
For a screen dependent on permissions, verify initial denial, returning from settings, and activity recreation without duplicate requests.
|
|
30
|
+
|
|
31
|
+
## Verification
|
|
32
|
+
|
|
33
|
+
Run Gradle checks and appropriate local and instrumented tests. Verify affected API levels, build variants, and accessibility behavior.
|
|
34
|
+
|
|
35
|
+
## Reference
|
|
36
|
+
|
|
37
|
+
- [Android documentation](https://developer.android.com/topic/architecture)
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: lyra-angular
|
|
3
|
-
description: "Implement Angular components, services, forms, and routing within project conventions."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Angular
|
|
7
|
-
|
|
8
|
-
## Inspect the project
|
|
9
|
-
|
|
10
|
-
Check the installed Angular version, standalone versus NgModule conventions, RxJS and signals usage, and the configured compiler and test runner.
|
|
11
|
-
|
|
12
|
-
## Implementation practices
|
|
13
|
-
|
|
14
|
-
- Keep components focused on presentation and composition. Move shared business rules into the existing service layer, and scope providers to the intended lifetime.
|
|
15
|
-
- Use the project's form model and surface validation accessibly. Keep template bindings predictable and track list identity explicitly.
|
|
16
|
-
- Use supported subscription cleanup and cancel stale requests as needed. Treat route guards as UI navigation controls and enforce permission checks at the API.
|
|
17
|
-
|
|
18
|
-
## Guardrails and trade-offs
|
|
19
|
-
|
|
20
|
-
- Keep Angular's template sanitization in place. Review any bypass with the existing trust policy, and keep untrusted content out of trusted HTML and resource URLs.
|
|
21
|
-
- Prefer current project patterns over adopting new Angular primitives within an unrelated change. Measure change detection and bundle effects before performance refactors.
|
|
22
|
-
|
|
23
|
-
## Decisions to check
|
|
24
|
-
|
|
25
|
-
Use the official upgrade guidance for version-specific migrations. Keep subscriptions, signals, and forms aligned with the existing design instead of mixing state models inside one view. Exercise server authorization separately from guarded routes.
|
|
26
|
-
|
|
27
|
-
## Review scenario
|
|
28
|
-
|
|
29
|
-
For an edit form, verify validation errors, pending submit state, server errors, and navigation away during a request.
|
|
30
|
-
|
|
31
|
-
## Verification
|
|
32
|
-
|
|
33
|
-
Run compiler checks, the relevant component or service tests, and a production build when routes or dependency boundaries change.
|
|
34
|
-
|
|
35
|
-
## Reference
|
|
36
|
-
|
|
37
|
-
- [Angular documentation](https://angular.dev/style-guide)
|
|
1
|
+
---
|
|
2
|
+
name: lyra-angular
|
|
3
|
+
description: "Implement Angular components, services, forms, and routing within project conventions."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Angular
|
|
7
|
+
|
|
8
|
+
## Inspect the project
|
|
9
|
+
|
|
10
|
+
Check the installed Angular version, standalone versus NgModule conventions, RxJS and signals usage, and the configured compiler and test runner.
|
|
11
|
+
|
|
12
|
+
## Implementation practices
|
|
13
|
+
|
|
14
|
+
- Keep components focused on presentation and composition. Move shared business rules into the existing service layer, and scope providers to the intended lifetime.
|
|
15
|
+
- Use the project's form model and surface validation accessibly. Keep template bindings predictable and track list identity explicitly.
|
|
16
|
+
- Use supported subscription cleanup and cancel stale requests as needed. Treat route guards as UI navigation controls and enforce permission checks at the API.
|
|
17
|
+
|
|
18
|
+
## Guardrails and trade-offs
|
|
19
|
+
|
|
20
|
+
- Keep Angular's template sanitization in place. Review any bypass with the existing trust policy, and keep untrusted content out of trusted HTML and resource URLs.
|
|
21
|
+
- Prefer current project patterns over adopting new Angular primitives within an unrelated change. Measure change detection and bundle effects before performance refactors.
|
|
22
|
+
|
|
23
|
+
## Decisions to check
|
|
24
|
+
|
|
25
|
+
Use the official upgrade guidance for version-specific migrations. Keep subscriptions, signals, and forms aligned with the existing design instead of mixing state models inside one view. Exercise server authorization separately from guarded routes.
|
|
26
|
+
|
|
27
|
+
## Review scenario
|
|
28
|
+
|
|
29
|
+
For an edit form, verify validation errors, pending submit state, server errors, and navigation away during a request.
|
|
30
|
+
|
|
31
|
+
## Verification
|
|
32
|
+
|
|
33
|
+
Run compiler checks, the relevant component or service tests, and a production build when routes or dependency boundaries change.
|
|
34
|
+
|
|
35
|
+
## Reference
|
|
36
|
+
|
|
37
|
+
- [Angular documentation](https://angular.dev/style-guide)
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: lyra-cucumber
|
|
3
|
-
description: "Write and maintain executable Gherkin acceptance scenarios and Cucumber step definitions."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Cucumber
|
|
7
|
-
|
|
8
|
-
## Inspect the project
|
|
9
|
-
|
|
10
|
-
Identify the Cucumber implementation, feature paths, step language, runner, and tags. Clarify the business rule and observable result before choosing acceptance examples.
|
|
11
|
-
|
|
12
|
-
## Implementation practices
|
|
13
|
-
|
|
14
|
-
- Use Given for relevant state, When for the action, and Then for an observable outcome. Keep scenarios concise and use domain language in place of UI click sequences.
|
|
15
|
-
- Use Scenario Outline for meaningful input variations. Keep Background short and limit it to context shared by every scenario in its scope.
|
|
16
|
-
- Use typed or parameterized expressions for reusable steps. Keep implementation in helper code, and avoid broad step patterns that collide or hide missing behavior.
|
|
17
|
-
|
|
18
|
-
## Guardrails and trade-offs
|
|
19
|
-
|
|
20
|
-
- Create state per scenario using the runner's context or world. Ensure hooks give predictable cleanup under parallel execution and keep real credentials and account data out of fixtures and reports.
|
|
21
|
-
- Tag suites by execution intent and make skipped or quarantined cases visible. Prefer acceptance assertions over inspecting incidental internal state.
|
|
22
|
-
|
|
23
|
-
## Decisions to check
|
|
24
|
-
|
|
25
|
-
Choose acceptance-test boundaries by the business risk. Use a browser for a user-facing contract and a service adapter for rules that can be verified directly. Keep feature files readable by domain experts and share state only within the current scenario.
|
|
26
|
-
|
|
27
|
-
## Review scenario
|
|
28
|
-
|
|
29
|
-
For a checkout rule, describe eligibility and the resulting user-visible price. Cover boundary amounts in an outline and keep browser navigation inside the steps.
|
|
30
|
-
|
|
31
|
-
## Verification
|
|
32
|
-
|
|
33
|
-
Run the affected scenarios, check undefined and ambiguous steps, and confirm the feature works independently and under the repository's parallel runner.
|
|
34
|
-
|
|
35
|
-
## Reference
|
|
36
|
-
|
|
37
|
-
- [Cucumber documentation](https://cucumber.io/docs/bdd/better-gherkin/)
|
|
1
|
+
---
|
|
2
|
+
name: lyra-cucumber
|
|
3
|
+
description: "Write and maintain executable Gherkin acceptance scenarios and Cucumber step definitions."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cucumber
|
|
7
|
+
|
|
8
|
+
## Inspect the project
|
|
9
|
+
|
|
10
|
+
Identify the Cucumber implementation, feature paths, step language, runner, and tags. Clarify the business rule and observable result before choosing acceptance examples.
|
|
11
|
+
|
|
12
|
+
## Implementation practices
|
|
13
|
+
|
|
14
|
+
- Use Given for relevant state, When for the action, and Then for an observable outcome. Keep scenarios concise and use domain language in place of UI click sequences.
|
|
15
|
+
- Use Scenario Outline for meaningful input variations. Keep Background short and limit it to context shared by every scenario in its scope.
|
|
16
|
+
- Use typed or parameterized expressions for reusable steps. Keep implementation in helper code, and avoid broad step patterns that collide or hide missing behavior.
|
|
17
|
+
|
|
18
|
+
## Guardrails and trade-offs
|
|
19
|
+
|
|
20
|
+
- Create state per scenario using the runner's context or world. Ensure hooks give predictable cleanup under parallel execution and keep real credentials and account data out of fixtures and reports.
|
|
21
|
+
- Tag suites by execution intent and make skipped or quarantined cases visible. Prefer acceptance assertions over inspecting incidental internal state.
|
|
22
|
+
|
|
23
|
+
## Decisions to check
|
|
24
|
+
|
|
25
|
+
Choose acceptance-test boundaries by the business risk. Use a browser for a user-facing contract and a service adapter for rules that can be verified directly. Keep feature files readable by domain experts and share state only within the current scenario.
|
|
26
|
+
|
|
27
|
+
## Review scenario
|
|
28
|
+
|
|
29
|
+
For a checkout rule, describe eligibility and the resulting user-visible price. Cover boundary amounts in an outline and keep browser navigation inside the steps.
|
|
30
|
+
|
|
31
|
+
## Verification
|
|
32
|
+
|
|
33
|
+
Run the affected scenarios, check undefined and ambiguous steps, and confirm the feature works independently and under the repository's parallel runner.
|
|
34
|
+
|
|
35
|
+
## Reference
|
|
36
|
+
|
|
37
|
+
- [Cucumber documentation](https://cucumber.io/docs/bdd/better-gherkin/)
|