agent-lyra 0.6.1 → 0.6.3

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.
Files changed (108) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +435 -395
  3. package/bin/agent-lyra.js +49 -44
  4. package/bin/lyra-oss-preview.js +16 -0
  5. package/package.json +60 -60
  6. package/src/app-builder/export.js +109 -109
  7. package/src/app-builder/gateway.js +62 -62
  8. package/src/app-builder/init.js +52 -52
  9. package/src/app-builder/manifest-contract.js +46 -0
  10. package/src/app-builder/native-adapter.js +29 -29
  11. package/src/app-builder/preview.js +22 -22
  12. package/src/app-builder/publish.js +14 -14
  13. package/src/app-builder/saved-app.js +70 -70
  14. package/src/app-builder/saved-preview-browser.js +33 -33
  15. package/src/app-builder/saved-preview.html +24 -24
  16. package/src/app-builder/saved-preview.js +61 -61
  17. package/src/app-builder/support-manifest.js +50 -50
  18. package/src/app-builder/support-template/manifest.json +55 -55
  19. package/src/app-builder/support-template/support-preview.html +56 -56
  20. package/src/app-builder/support-template/support-preview.js +37 -37
  21. package/src/app-builder/support-template/support-preview.mjs +67 -67
  22. package/src/app-builder/support-template/support-workflow.mjs +36 -36
  23. package/src/app-builder/use.js +37 -37
  24. package/src/app-builder/validate.js +21 -64
  25. package/src/app-builder/value-schema.js +37 -37
  26. package/src/catalog.js +147 -147
  27. package/src/coding/catalog.js +56 -0
  28. package/src/coding/cloud-catalog.js +64 -0
  29. package/src/coding/detect-stack.mjs +110 -0
  30. package/src/coding/export.js +130 -0
  31. package/src/coding/setup.js +175 -0
  32. package/src/coding/skills/lyra-android/SKILL.md +37 -0
  33. package/src/coding/skills/lyra-angular/SKILL.md +37 -0
  34. package/src/coding/skills/lyra-cucumber/SKILL.md +37 -0
  35. package/src/coding/skills/lyra-dbt/SKILL.md +37 -0
  36. package/src/coding/skills/lyra-django/SKILL.md +37 -0
  37. package/src/coding/skills/lyra-docker/SKILL.md +37 -0
  38. package/src/coding/skills/lyra-dotnet/SKILL.md +37 -0
  39. package/src/coding/skills/lyra-express/SKILL.md +37 -0
  40. package/src/coding/skills/lyra-fastapi/SKILL.md +37 -0
  41. package/src/coding/skills/lyra-flutter/SKILL.md +37 -0
  42. package/src/coding/skills/lyra-github-actions/SKILL.md +37 -0
  43. package/src/coding/skills/lyra-gitlab-ci/SKILL.md +37 -0
  44. package/src/coding/skills/lyra-go/SKILL.md +37 -0
  45. package/src/coding/skills/lyra-ios/SKILL.md +37 -0
  46. package/src/coding/skills/lyra-kubernetes/SKILL.md +37 -0
  47. package/src/coding/skills/lyra-mongodb/SKILL.md +37 -0
  48. package/src/coding/skills/lyra-mysql/SKILL.md +37 -0
  49. package/src/coding/skills/lyra-nextjs/SKILL.md +37 -0
  50. package/src/coding/skills/lyra-node/SKILL.md +37 -0
  51. package/src/coding/skills/lyra-playwright/SKILL.md +37 -0
  52. package/src/coding/skills/lyra-postgresql/SKILL.md +37 -0
  53. package/src/coding/skills/lyra-python/SKILL.md +37 -0
  54. package/src/coding/skills/lyra-react/SKILL.md +37 -0
  55. package/src/coding/skills/lyra-react-native/SKILL.md +37 -0
  56. package/src/coding/skills/lyra-redis/SKILL.md +37 -0
  57. package/src/coding/skills/lyra-rust/SKILL.md +37 -0
  58. package/src/coding/skills/lyra-spark/SKILL.md +37 -0
  59. package/src/coding/skills/lyra-spring-boot/SKILL.md +37 -0
  60. package/src/coding/skills/lyra-svelte/SKILL.md +37 -0
  61. package/src/coding/skills/lyra-terraform/SKILL.md +37 -0
  62. package/src/coding/skills/lyra-typescript/SKILL.md +37 -0
  63. package/src/coding/skills/lyra-vue/SKILL.md +37 -0
  64. package/src/gated/hostedAgents.js +56 -56
  65. package/src/gated/index.d.ts +25 -25
  66. package/src/gated/index.js +5 -5
  67. package/src/index.d.ts +2 -2
  68. package/src/index.js +2 -2
  69. package/src/init.js +965 -937
  70. package/src/memory/cli.js +21 -49
  71. package/src/memory/contract.json +28 -28
  72. package/src/memory/index.d.ts +49 -49
  73. package/src/memory/index.js +259 -259
  74. package/src/memory/lifecycle.js +29 -29
  75. package/src/memory/local-cli.js +34 -0
  76. package/src/memory/proposals.js +84 -84
  77. package/src/memory/skills-cli.js +26 -26
  78. package/src/memory/sync.js +89 -85
  79. package/src/memory/validation.js +25 -25
  80. package/src/onboardingAgents.js +532 -532
  81. package/src/promptTemplates.js +178 -178
  82. package/src/runtime/contracts.d.ts +47 -47
  83. package/src/runtime/local-cli.js +160 -160
  84. package/src/runtime/mcp-stdio.js +111 -111
  85. package/src/runtime/orchestration.js +59 -59
  86. package/src/runtime/run-agent.js +43 -43
  87. package/src/standalone/index.d.ts +45 -45
  88. package/src/standalone/index.js +13 -13
  89. package/src/standalone/init.js +12 -0
  90. package/src/standalone/orchestration.js +6 -6
  91. package/src/standalone/rag.js +113 -113
  92. package/src/studio/agent-ui.css +43 -43
  93. package/src/studio/agent-ui.js +32 -32
  94. package/src/studio/browser.js +331 -331
  95. package/src/studio/export.js +80 -80
  96. package/src/studio/index.html +37 -37
  97. package/src/studio/memory-actions.js +37 -37
  98. package/src/studio/memory-panel.js +200 -200
  99. package/src/studio/project.js +216 -197
  100. package/src/studio/pull-agent.js +72 -72
  101. package/src/studio/push.js +54 -54
  102. package/src/studio/python-agent.js +47 -47
  103. package/src/studio/python-agent.py +25 -25
  104. package/src/studio/server.js +143 -143
  105. package/src/studio/session.js +83 -83
  106. package/src/studio/studio.css +10 -10
  107. package/src/studio/sync.js +42 -42
  108. package/src/studio/workflow-sync.js +157 -157
@@ -0,0 +1,130 @@
1
+ import { lstat, readFile, readdir } from "node:fs/promises";
2
+ import { join, resolve } from "node:path";
3
+ import { createInterface } from "node:readline/promises";
4
+ import { parseArgs } from "node:util";
5
+ import { readLocalAgent } from "../studio/project.js";
6
+ import { prepareProjectFiles } from "./setup.js";
7
+
8
+ const formats = {
9
+ claude: { marker: ".claude", skills: ".claude/skills", agents: ".claude/agents", extension: ".md" },
10
+ codex: { marker: ".codex", skills: ".agents/skills", agents: ".codex/agents", extension: ".toml" },
11
+ copilot: { marker: ".github", skills: ".github/skills", agents: ".github/agents", extension: ".agent.md" },
12
+ };
13
+ const safeName = /^[a-z0-9][a-z0-9-]{0,95}$/;
14
+ const missing = error => {
15
+ if (error.code !== "ENOENT") throw error;
16
+ return null;
17
+ };
18
+
19
+ async function entries(path) {
20
+ const stat = await lstat(path).catch(missing);
21
+ if (!stat) return [];
22
+ if (!stat.isDirectory()) throw new Error("Expected a regular project directory: " + path);
23
+ return readdir(path, { withFileTypes: true });
24
+ }
25
+
26
+ async function text(path) {
27
+ const stat = await lstat(path).catch(missing);
28
+ if (!stat?.isFile() || stat.size > 64_000) return "";
29
+ return (await readFile(path, "utf8")).replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
30
+ }
31
+
32
+ function scalar(header, key) {
33
+ const value = new RegExp("^" + key + ":[ \t]*(.+)$", "m").exec(header)?.[1]?.trim();
34
+ if (!value) return "";
35
+ if (!value.startsWith('"')) return value.replace(/^'|'$/g, "");
36
+ try {
37
+ const parsed = JSON.parse(value);
38
+ return typeof parsed === "string" ? parsed : "";
39
+ } catch { return ""; }
40
+ }
41
+
42
+ async function sources(root, output) {
43
+ await entries(join(root, ".lyra"));
44
+ const agents = new Map();
45
+ const skills = new Map();
46
+ const agentDir = join(root, ".lyra", "agents");
47
+ for (const entry of await entries(agentDir)) {
48
+ if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
49
+ const source = await text(join(agentDir, entry.name));
50
+ const item = readLocalAgent(source);
51
+ if (!item || item.source !== "local" || !safeName.test(item.id.slice(6))) {
52
+ output.write("Skip unsupported agent " + JSON.stringify(entry.name) + "\n");
53
+ continue;
54
+ }
55
+ const id = item.id.slice(6);
56
+ if (agents.has(id)) throw new Error("Duplicate Lyra agent ID: " + id);
57
+ agents.set(id, item);
58
+ }
59
+ const skillDir = join(root, ".lyra", "skills");
60
+ for (const entry of await entries(skillDir)) {
61
+ if (!entry.isDirectory() || !safeName.test(entry.name)) continue;
62
+ const source = await text(join(skillDir, entry.name, "SKILL.md"));
63
+ const front = /^---\n([\s\S]*?)\n---\n/.exec(source);
64
+ const name = front && scalar(front[1], "name");
65
+ const description = front && scalar(front[1], "description");
66
+ if (!name || name !== entry.name || !description) {
67
+ output.write("Skip skill without matching name and description " + JSON.stringify(entry.name) + "\n");
68
+ continue;
69
+ }
70
+ skills.set(name, ["---", "name: " + name, "description: " + JSON.stringify(description), "---", source.slice(front[0].length)].join("\n"));
71
+ }
72
+ return { agents, skills };
73
+ }
74
+
75
+ function renderAgent(target, id, agent) {
76
+ const description = "AgentLyra project profile for " + agent.name + ".";
77
+ if (target === "codex") {
78
+ const quoted = value => JSON.stringify(value).replace(/\u007f/g, "\\u007F");
79
+ return "name = " + quoted(id) + "\ndescription = " + quoted(description) +
80
+ "\ndeveloper_instructions = " + quoted(agent.prompt) + "\n";
81
+ }
82
+ return ["---", "name: " + id, "description: " + JSON.stringify(description), "---", "", agent.prompt, ""].join("\n");
83
+ }
84
+
85
+ export async function runCodingExport(args, { input = process.stdin, output = process.stdout, root = process.cwd() } = {}) {
86
+ const { values } = parseArgs({ args, options: {
87
+ to: { type: "string" }, dir: { type: "string" }, preview: { type: "boolean" },
88
+ yes: { type: "boolean", short: "y" }, help: { type: "boolean", short: "h" },
89
+ } });
90
+ if (values.help) {
91
+ output.write("Usage: agent-lyra setup coding export [--to claude,codex,copilot] [--preview | --yes] [--dir <folder>]\n");
92
+ return;
93
+ }
94
+ if (!input.isTTY && (!values.to || (!values.preview && !values.yes))) {
95
+ throw new Error("Provide --to with --preview or --yes when running without an interactive terminal.");
96
+ }
97
+ const project = resolve(root, values.dir ?? ".");
98
+ const rl = input.isTTY ? createInterface({ input, output }) : null;
99
+ try {
100
+ let choice = values.to;
101
+ if (!choice) {
102
+ const existing = new Set((await entries(project)).filter(item => item.isDirectory() || item.isFile()).map(item => item.name));
103
+ const hints = Object.entries(formats).filter(([id, { marker }]) => existing.has(marker) ||
104
+ (id === "codex" && existing.has(".agents")) || (id === "claude" && existing.has("CLAUDE.md")));
105
+ if (hints.length) output.write("Project files suggest: " + hints.map(([id]) => id).join(", ") + "\n");
106
+ choice = (await rl.question("Export to claude, codex, or copilot (comma separated, Enter to cancel): ")).trim();
107
+ if (!choice) return;
108
+ }
109
+ const targets = [...new Set(choice.split(",").map(name => name.trim().toLowerCase()))];
110
+ if (targets.some(target => !Object.hasOwn(formats, target))) throw new Error("Choose claude, codex, or copilot.");
111
+ const { agents, skills } = await sources(project, output);
112
+ const files = new Map();
113
+ for (const target of targets) {
114
+ const format = formats[target];
115
+ for (const [id, agent] of agents) files.set(format.agents + "/" + id + format.extension, renderAgent(target, id, agent));
116
+ for (const [name, skill] of skills) files.set(format.skills + "/" + name + "/SKILL.md", skill);
117
+ }
118
+ if (!files.size) {
119
+ output.write("No exportable Markdown agents or skills found in .lyra. Run setup coding first.\n");
120
+ return;
121
+ }
122
+ output.write("Export includes instructions only. Tool permissions, hooks, scripts, and other skill resources stay in their original project files.\n");
123
+ const apply = await prepareProjectFiles(project, files, output);
124
+ if (values.preview || (!values.yes && !/^y(?:es)?$/i.test((await rl.question("Write these exports? [y/N] ")).trim()))) return;
125
+ await apply();
126
+ output.write("Assistant export complete. Existing files were preserved.\n");
127
+ } finally {
128
+ rl?.close();
129
+ }
130
+ }
@@ -0,0 +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/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/" + id + ".md", [
53
+ "---", "id: " + id, "name: " + JSON.stringify(scope === "." ? agentName : agentName + " — " + scope), "mode: standalone", "---",
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/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
+ }
@@ -0,0 +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)
@@ -0,0 +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)
@@ -0,0 +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/)
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: lyra-dbt
3
+ description: "Implement dbt models, tests, documentation, and incremental changes safely."
4
+ ---
5
+
6
+ # dbt
7
+
8
+ ## Inspect the project
9
+
10
+ Check the dbt adapter and version, model selectors, environments, macro conventions, and target warehouse. Trace source lineage and grain.
11
+
12
+ ## Implementation practices
13
+
14
+ - Use ref and source for declared dependencies. Define each model's grain, key, and expected null behavior and document resulting columns where relevant.
15
+ - Choose materialization based on workload. For incremental models, account for late data, repeated inputs, schema changes, and backfill semantics.
16
+ - Add focused uniqueness, not-null, relationship, or domain tests based on model invariants. Check freshness when delay affects consumers.
17
+
18
+ ## Guardrails and trade-offs
19
+
20
+ - Use development schemas and synthetic or approved datasets. Review credential scope and avoid running broad backfills or full refreshes by default.
21
+ - Measure query cost and affected downstream models. Review compatibility for consumers and handle sensitive fields according to existing governance.
22
+
23
+ ## Decisions to check
24
+
25
+ Separate model unit behavior from warehouse-level data tests when the project's dbt version supports both. Review model contracts or exposures where downstream consumers depend on them. Estimate execution and warehouse cost before expanding selectors.
26
+
27
+ ## Review scenario
28
+
29
+ For an incremental model, verify an initial build, late-arriving data, duplicate input, and a rerun against the same data.
30
+
31
+ ## Verification
32
+
33
+ Compile and build the affected selector in a test target. Inspect test results, lineage, and representative row counts before rollout.
34
+
35
+ ## Reference
36
+
37
+ - [dbt documentation](https://docs.getdbt.com/docs/build/data-tests)
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: lyra-django
3
+ description: "Implement Django models, migrations, views, forms, and permissions."
4
+ ---
5
+
6
+ # Django
7
+
8
+ ## Inspect the project
9
+
10
+ Read the Django release, app structure, settings modules, middleware, and ORM usage. Trace the URL, view, form or serializer, and database writes.
11
+
12
+ ## Implementation practices
13
+
14
+ - Use Django's validation and built-in CSRF protections for browser mutations. Scope querysets by authorization and enforce object-level checks on reads and writes.
15
+ - Treat schema and data migrations as separate concerns where useful. Use historical models in migration code and keep changes compatible with the rollout order.
16
+ - Manage atomicity deliberately and schedule external effects only after a successful commit where appropriate. Avoid repeated ORM queries with measured joins or prefetching.
17
+
18
+ ## Guardrails and trade-offs
19
+
20
+ - Keep autoescaping active and use explicit validation for user-controlled file access. Redact sensitive data from logs and keep debug settings out of production.
21
+ - Preserve URL names, forms, permissions, status codes, and template context contracts that existing callers use.
22
+
23
+ ## Decisions to check
24
+
25
+ Review how queryset operations evaluate and where lazy relations can lead to repeated queries. Preserve intended authorization when adding custom model managers or bulk operations. Ensure permission tests cover authenticated users without access as well as anonymous users.
26
+
27
+ ## Review scenario
28
+
29
+ For an owner-only edit, verify owner access and another authenticated user's rejection. Include invalid form data and ensure no partial writes.
30
+
31
+ ## Verification
32
+
33
+ Run Django checks and targeted tests. Rehearse migrations and inspect query count or plans for performance-sensitive changes.
34
+
35
+ ## Reference
36
+
37
+ - [Django documentation](https://docs.djangoproject.com/en/stable/)
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: lyra-docker
3
+ description: "Build and review Docker images, container startup, and Compose configuration."
4
+ ---
5
+
6
+ # Docker
7
+
8
+ ## Inspect the project
9
+
10
+ Identify the target OS and architecture, supported runtime, build context, and deployment expectations. Read existing Dockerfiles and ignore rules.
11
+
12
+ ## Implementation practices
13
+
14
+ - Use a trusted base image and a reproducible dependency install. Separate build and runtime stages where helpful and ship only runtime files.
15
+ - Keep package caches and unrelated files out of the runtime image. Choose image versions or digests according to the project's update policy.
16
+ - Keep secrets out of build arguments, layers, and copied files. Use the build or runtime secret mechanism and run with the minimum required privileges.
17
+
18
+ ## Guardrails and trade-offs
19
+
20
+ - Ensure executable permissions, signal delivery, startup dependencies, and health behavior match the deployment. Persist required state through the approved storage mechanism.
21
+ - Measure image size and build timings when optimizing. Keep dependencies and cache boundaries aligned with the files that invalidate them.
22
+
23
+ ## Decisions to check
24
+
25
+ Check whether build args or context changes invalidate dependency layers. Review entrypoints for shell wrappers that swallow signals or exit codes. Validate the container when its root filesystem or build environment is more constrained than the local machine.
26
+
27
+ ## Review scenario
28
+
29
+ For an API container, confirm the process receives shutdown signals, stops accepting work, and drains outstanding requests within the orchestrator deadline.
30
+
31
+ ## Verification
32
+
33
+ Build and run the target image locally with synthetic configuration. Check health, startup failure, filesystem permissions, shutdown, and required architectures.
34
+
35
+ ## Reference
36
+
37
+ - [Docker documentation](https://docs.docker.com/build/building/best-practices/)
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: lyra-dotnet
3
+ description: "Implement .NET services and APIs with compatible hosting, dependency injection, and data access."
4
+ ---
5
+
6
+ # .NET
7
+
8
+ ## Inspect the project
9
+
10
+ Check the target framework, SDK pin, hosting model, test projects, nullable settings, and installed framework features.
11
+
12
+ ## Implementation practices
13
+
14
+ - Model configuration with typed options and validate important settings at startup. Respect transient, scoped, and singleton lifetimes, especially for DbContext.
15
+ - Propagate CancellationToken to supported operations. Keep server-side I/O asynchronous and bound resource use and retries.
16
+ - Validate payloads and centralize error mapping. Enforce resource authorization independently of endpoint authentication and keep sensitive data out of Problem Details.
17
+
18
+ ## Guardrails and trade-offs
19
+
20
+ - Use EF Core transactions and projections intentionally. Review migration ordering, parameterization, and data-loading cost before changing queries.
21
+ - Keep logging structured and redact credentials and private request data. Reuse application health and metrics conventions.
22
+
23
+ ## Decisions to check
24
+
25
+ Validate configuration in the effective hosted environment and use the project's forwarded-header policy behind proxies. Review middleware order when changing authentication, authorization, exception handling, or routing. Test behavior through the HTTP host when middleware forms part of the contract.
26
+
27
+ ## Review scenario
28
+
29
+ For a cancellation-sensitive endpoint, cancel a test request and verify downstream work observes cancellation and releases its resources.
30
+
31
+ ## Verification
32
+
33
+ Run dotnet build and the relevant tests through the project's solution or scripts. Verify integration tests against the actual hosting and data boundaries.
34
+
35
+ ## Reference
36
+
37
+ - [.NET documentation](https://learn.microsoft.com/en-us/aspnet/core/)
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: lyra-express
3
+ description: "Implement Express routes, middleware, validation, error handling, and service checks."
4
+ ---
5
+
6
+ # Express
7
+
8
+ ## Inspect the project
9
+
10
+ Identify the Express major version, router mount path, middleware order, body parser, proxy topology, and error response contract.
11
+
12
+ ## Implementation practices
13
+
14
+ - Authenticate early and authorize against the resource and tenant on the server. Validate params, query, headers, and body. Put bounds on payload sizes and pagination.
15
+ - Keep handlers thin by reusing service logic. Map known failures to stable status codes and return a consistent public response shape.
16
+ - Route asynchronous errors through the project's error middleware according to its Express version. Preserve a single response per request and handle aborted streaming requests.
17
+
18
+ ## Guardrails and trade-offs
19
+
20
+ - Configure trust proxy for the actual topology. Treat CORS as a browser control and enforce access checks independently. Protect cookie-authenticated mutations using the project's CSRF controls.
21
+ - Avoid exposing stack traces, secrets, raw request bodies, or internal database errors. Use request IDs and structured logs with safe fields.
22
+
23
+ ## Decisions to check
24
+
25
+ Keep the fallback 404 and terminal error middleware after route registration. Validate content type where needed and distinguish client input errors from upstream errors. Make write retries safe through an idempotency strategy where retries are expected.
26
+
27
+ ## Review scenario
28
+
29
+ For an update endpoint, verify that a valid user from a different tenant cannot mutate the resource and that invalid input fails before the store is called.
30
+
31
+ ## Verification
32
+
33
+ Run integration tests through the mounted router. Exercise valid, malformed, unauthenticated, forbidden, missing, conflict, and unexpected failure cases as relevant.
34
+
35
+ ## Reference
36
+
37
+ - [Express documentation](https://expressjs.com/en/advanced/best-practice-security.html)
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: lyra-fastapi
3
+ description: "Maintain FastAPI endpoints, Pydantic models, dependency wiring, and OpenAPI contracts."
4
+ ---
5
+
6
+ # FastAPI
7
+
8
+ ## Inspect the project
9
+
10
+ Inspect the FastAPI and Pydantic versions, router wiring, exception handlers, and lifespan configuration. Trace request data and permission dependencies.
11
+
12
+ ## Implementation practices
13
+
14
+ - Use request and response schemas to validate and shape the public contract. Distinguish optional from nullable fields and deliberately exclude private model fields.
15
+ - Authorize each resource using the current identity and tenant. Reuse existing dependency injection and return consistent error responses.
16
+ - Use async handlers with async clients. Handle blocking work through the team's established sync or worker path. Scope and release sessions and clients predictably.
17
+
18
+ ## Guardrails and trade-offs
19
+
20
+ - Set limits for uploads, pagination, and expensive queries. Keep raw exception text and credentials outside public responses and structured logs.
21
+ - Treat status codes, response shapes, and generated OpenAPI as compatibility surfaces. Review client generation or event consumers before changing them.
22
+
23
+ ## Decisions to check
24
+
25
+ Model pagination and error responses explicitly when clients depend on them. Use dependency overrides only in tests and reset overrides between cases. Use the project job mechanism for durable work that must survive restarts.
26
+
27
+ ## Review scenario
28
+
29
+ For a partial update, test omitted fields separately from fields explicitly set to null. Verify response serialization excludes internal fields.
30
+
31
+ ## Verification
32
+
33
+ Run API tests with the project test client and override dependencies at the test boundary. Verify authorization failures, validation errors, response shape, and lifespan cleanup.
34
+
35
+ ## Reference
36
+
37
+ - [FastAPI documentation](https://fastapi.tiangolo.com/)