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:
34
dist/agents/registry.js
vendored
Normal file
34
dist/agents/registry.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AGENTS = void 0;
|
||||
exports.registerAgent = registerAgent;
|
||||
exports.getAgent = getAgent;
|
||||
exports.allAgents = allAgents;
|
||||
exports.pick = pick;
|
||||
const tools_1 = require("../tools");
|
||||
const _registry = new Map();
|
||||
function registerAgent(config) {
|
||||
_registry.set(config.name, config);
|
||||
}
|
||||
function getAgent(name) {
|
||||
return _registry.get(name);
|
||||
}
|
||||
function allAgents() {
|
||||
return [..._registry.values()];
|
||||
}
|
||||
/**
|
||||
* Backwards-compatible AGENTS object — populated as agents register.
|
||||
* server.ts uses AGENTS[name] and Object.values(AGENTS).
|
||||
*/
|
||||
exports.AGENTS = new Proxy({}, {
|
||||
get(_target, prop) { return _registry.get(prop); },
|
||||
ownKeys() { return [..._registry.keys()]; },
|
||||
getOwnPropertyDescriptor(_target, prop) {
|
||||
const v = _registry.get(prop);
|
||||
return v ? { configurable: true, enumerable: true, value: v } : undefined;
|
||||
}
|
||||
});
|
||||
/** Pick tools from ALL_TOOLS by name. */
|
||||
function pick(names) {
|
||||
return tools_1.ALL_TOOLS.filter(t => names.includes(t.name));
|
||||
}
|
||||
Reference in New Issue
Block a user