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:
@@ -8,16 +8,9 @@ import { createJob, getJob, listJobs, updateJob } from './job-store';
|
||||
import { runAgent } from './agent-runner';
|
||||
import { AGENTS } from './agents';
|
||||
import { ToolContext } from './tools';
|
||||
import { PROTECTED_GITEA_REPOS } from './tools/security';
|
||||
import { orchestratorChat, listSessions, clearSession } from './orchestrator';
|
||||
|
||||
// Protected Vibn platform repos — agents cannot clone or work in these workspaces
|
||||
const PROTECTED_GITEA_REPOS = new Set([
|
||||
'mark/vibn-frontend',
|
||||
'mark/theia-code-os',
|
||||
'mark/vibn-agent-runner',
|
||||
'mark/vibn-api',
|
||||
'mark/master-ai',
|
||||
]);
|
||||
import { LLMMessage } from './llm';
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
@@ -186,14 +179,28 @@ app.get('/api/jobs/:id', (req: Request, res: Response) => {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
app.post('/orchestrator/chat', async (req: Request, res: Response) => {
|
||||
const { message, session_id } = req.body as { message?: string; session_id?: string };
|
||||
const {
|
||||
message,
|
||||
session_id,
|
||||
history,
|
||||
knowledge_context
|
||||
} = req.body as {
|
||||
message?: string;
|
||||
session_id?: string;
|
||||
history?: LLMMessage[];
|
||||
knowledge_context?: string;
|
||||
};
|
||||
|
||||
if (!message) { res.status(400).json({ error: '"message" is required' }); return; }
|
||||
|
||||
const sessionId = session_id || `session_${Date.now()}`;
|
||||
const ctx = buildContext();
|
||||
|
||||
try {
|
||||
const result = await orchestratorChat(sessionId, message, ctx);
|
||||
const result = await orchestratorChat(sessionId, message, ctx, {
|
||||
preloadedHistory: history,
|
||||
knowledgeContext: knowledge_context
|
||||
});
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err instanceof Error ? err.message : String(err) });
|
||||
|
||||
Reference in New Issue
Block a user