refactor: implement three-layer agent architecture (agents / prompts / skills)
Layer 1 — src/agents/ (thin agent definitions, no prompt text)
registry.ts — AgentConfig, registerAgent(), getAgent(), AGENTS proxy, pick()
orchestrator.ts, coder.ts, pm.ts, marketing.ts — one file each, just metadata + tool picks
index.ts — barrel: imports prompts then agents (correct registration order)
Layer 2 — src/prompts/ (prompt text separated from agent logic)
loader.ts — registerPrompt(), resolvePrompt() with {{variable}} substitution
orchestrator.ts, coder.ts, pm.ts, marketing.ts — prompt templates as registered strings
orchestrator.ts now uses resolvePrompt('orchestrator', { knowledge }) instead of
inline SYSTEM_PROMPT const; {{knowledge}} variable injects project memory cleanly.
agent-runner.ts uses resolvePrompt(config.promptId) per agent turn.
Layer 3 — src/tools/skills.ts (new skills capability)
list_skills(repo) — lists .skills/<name>/SKILL.md directories from a Gitea repo
get_skill(repo, name) — reads and returns the markdown body of a skill file
Orchestrator and all agents now have get_skill in their tool sets.
Orchestrator also has list_skills and references skills in its prompt.
Also fixed:
- server.ts now passes history + knowledge_context from request body to orchestratorChat()
(these were being sent by the frontend but silently dropped)
- server.ts imports PROTECTED_GITEA_REPOS from tools/security.ts (no more duplicate)
- Deleted src/agents.ts (replaced by src/agents/ directory)
Made-with: Cursor
This commit is contained in:
1
dist/tools/index.d.ts
vendored
1
dist/tools/index.d.ts
vendored
@@ -5,6 +5,7 @@ import './gitea';
|
||||
import './coolify';
|
||||
import './agent';
|
||||
import './memory';
|
||||
import './skills';
|
||||
export { ALL_TOOLS, executeTool, ToolDefinition } from './registry';
|
||||
export { ToolContext, MemoryUpdate } from './context';
|
||||
export { PROTECTED_GITEA_REPOS, PROTECTED_COOLIFY_PROJECT, PROTECTED_COOLIFY_APPS, assertGiteaWritable, assertCoolifyDeployable } from './security';
|
||||
|
||||
1
dist/tools/index.js
vendored
1
dist/tools/index.js
vendored
@@ -10,6 +10,7 @@ require("./gitea");
|
||||
require("./coolify");
|
||||
require("./agent");
|
||||
require("./memory");
|
||||
require("./skills");
|
||||
// Re-export the public API — identical surface to the old tools.ts
|
||||
var registry_1 = require("./registry");
|
||||
Object.defineProperty(exports, "ALL_TOOLS", { enumerable: true, get: function () { return registry_1.ALL_TOOLS; } });
|
||||
|
||||
1
dist/tools/skills.d.ts
vendored
Normal file
1
dist/tools/skills.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
60
dist/tools/skills.js
vendored
Normal file
60
dist/tools/skills.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const registry_1 = require("./registry");
|
||||
const SKILL_FILE = 'SKILL.md';
|
||||
const SKILLS_DIR = '.skills';
|
||||
async function giteaGetContents(repo, path, ctx) {
|
||||
const res = await fetch(`${ctx.gitea.apiUrl}/api/v1/repos/${repo}/contents/${path}`, {
|
||||
headers: { 'Authorization': `token ${ctx.gitea.apiToken}` }
|
||||
});
|
||||
if (!res.ok)
|
||||
return null;
|
||||
return res.json();
|
||||
}
|
||||
(0, registry_1.registerTool)({
|
||||
name: 'list_skills',
|
||||
description: `List available skills for a project repo. Skills are stored in .skills/<name>/SKILL.md and provide reusable instructions the agent should follow (e.g. deploy process, test commands, code conventions).`,
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
repo: { type: 'string', description: 'Repo in "owner/name" format' }
|
||||
},
|
||||
required: ['repo']
|
||||
},
|
||||
async handler(args, ctx) {
|
||||
const repo = String(args.repo);
|
||||
const contents = await giteaGetContents(repo, SKILLS_DIR, ctx);
|
||||
if (!contents || !Array.isArray(contents)) {
|
||||
return { skills: [], message: `No .skills/ directory found in ${repo}` };
|
||||
}
|
||||
const skills = contents
|
||||
.filter((entry) => entry.type === 'dir')
|
||||
.map((entry) => ({ name: entry.name, path: entry.path }));
|
||||
return { repo, skills };
|
||||
}
|
||||
});
|
||||
(0, registry_1.registerTool)({
|
||||
name: 'get_skill',
|
||||
description: `Read the full content of a specific skill from a project repo. Call list_skills first to see what's available. Use this before spawning agents so they have the relevant project-specific instructions.`,
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
repo: { type: 'string', description: 'Repo in "owner/name" format' },
|
||||
skill_name: { type: 'string', description: 'Skill name (directory name inside .skills/)' }
|
||||
},
|
||||
required: ['repo', 'skill_name']
|
||||
},
|
||||
async handler(args, ctx) {
|
||||
const repo = String(args.repo);
|
||||
const skillName = String(args.skill_name);
|
||||
const filePath = `${SKILLS_DIR}/${skillName}/${SKILL_FILE}`;
|
||||
const file = await giteaGetContents(repo, filePath, ctx);
|
||||
if (!file || !file.content) {
|
||||
return { error: `Skill "${skillName}" not found in ${repo}. Try list_skills to see available skills.` };
|
||||
}
|
||||
const content = Buffer.from(file.content, 'base64').toString('utf8');
|
||||
// Strip YAML frontmatter if present, return just the markdown body
|
||||
const body = content.replace(/^---[\s\S]*?---\s*/m, '').trim();
|
||||
return { repo, skill: skillName, content: body };
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user