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:
18
dist/server.js
vendored
18
dist/server.js
vendored
@@ -45,15 +45,8 @@ const child_process_1 = require("child_process");
|
||||
const job_store_1 = require("./job-store");
|
||||
const agent_runner_1 = require("./agent-runner");
|
||||
const agents_1 = require("./agents");
|
||||
const security_1 = require("./tools/security");
|
||||
const orchestrator_1 = require("./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',
|
||||
]);
|
||||
const app = (0, express_1.default)();
|
||||
app.use((0, cors_1.default)());
|
||||
const startTime = new Date();
|
||||
@@ -71,7 +64,7 @@ function ensureWorkspace(repo) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
return dir;
|
||||
}
|
||||
if (PROTECTED_GITEA_REPOS.has(repo)) {
|
||||
if (security_1.PROTECTED_GITEA_REPOS.has(repo)) {
|
||||
throw new Error(`SECURITY: Repo "${repo}" is a protected Vibn platform repo. ` +
|
||||
`Agents cannot clone or work in this workspace.`);
|
||||
}
|
||||
@@ -196,7 +189,7 @@ app.get('/api/jobs/:id', (req, res) => {
|
||||
// Orchestrator — persistent chat with full project context
|
||||
// ---------------------------------------------------------------------------
|
||||
app.post('/orchestrator/chat', async (req, res) => {
|
||||
const { message, session_id } = req.body;
|
||||
const { message, session_id, history, knowledge_context } = req.body;
|
||||
if (!message) {
|
||||
res.status(400).json({ error: '"message" is required' });
|
||||
return;
|
||||
@@ -204,7 +197,10 @@ app.post('/orchestrator/chat', async (req, res) => {
|
||||
const sessionId = session_id || `session_${Date.now()}`;
|
||||
const ctx = buildContext();
|
||||
try {
|
||||
const result = await (0, orchestrator_1.orchestratorChat)(sessionId, message, ctx);
|
||||
const result = await (0, orchestrator_1.orchestratorChat)(sessionId, message, ctx, {
|
||||
preloadedHistory: history,
|
||||
knowledgeContext: knowledge_context
|
||||
});
|
||||
res.json(result);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user