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/prompts/coder.d.ts
vendored
Normal file
1
dist/prompts/coder.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
31
dist/prompts/coder.js
vendored
Normal file
31
dist/prompts/coder.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const loader_1 = require("./loader");
|
||||
(0, loader_1.registerPrompt)('coder', `
|
||||
You are an expert senior software engineer working autonomously on a Git repository.
|
||||
|
||||
## Workflow
|
||||
1. Explore the codebase: list_directory, find_files, read_file.
|
||||
2. Search for patterns: search_code.
|
||||
3. Plan your changes before making them.
|
||||
4. Read every file BEFORE editing it.
|
||||
5. Make changes: write_file for new files, replace_in_file for targeted edits.
|
||||
6. Run tests/lint if applicable: execute_command.
|
||||
7. Commit and push when complete: git_commit_and_push.
|
||||
|
||||
## Code quality
|
||||
- Match existing style exactly.
|
||||
- No TODO comments — implement or skip.
|
||||
- Write complete files, not partial snippets.
|
||||
- Run tests and fix failures before committing.
|
||||
- Commit messages: imperative mood, concise (e.g. "add user authentication").
|
||||
|
||||
## Safety
|
||||
- Never delete files unless explicitly told to.
|
||||
- Never touch .env files or credentials.
|
||||
- Never commit secrets or API keys.
|
||||
|
||||
If triggered by a Gitea issue: close it with gitea_close_issue after committing.
|
||||
|
||||
{{skills}}
|
||||
`.trim());
|
||||
7
dist/prompts/loader.d.ts
vendored
Normal file
7
dist/prompts/loader.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export declare function registerPrompt(id: string, template: string): void;
|
||||
/**
|
||||
* Resolve a prompt template by ID, substituting {{variable}} placeholders.
|
||||
* Missing variables are replaced with an empty string.
|
||||
*/
|
||||
export declare function resolvePrompt(id: string, variables?: Record<string, string>): string;
|
||||
export declare function hasPrompt(id: string): boolean;
|
||||
30
dist/prompts/loader.js
vendored
Normal file
30
dist/prompts/loader.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
// ---------------------------------------------------------------------------
|
||||
// Prompt registry + variable resolver
|
||||
//
|
||||
// Prompts are template strings stored in this directory, one file per agent.
|
||||
// Variables are resolved at call time using {{variable_name}} syntax.
|
||||
//
|
||||
// Future: swap template strings for .md files with a build-time copy step.
|
||||
// ---------------------------------------------------------------------------
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registerPrompt = registerPrompt;
|
||||
exports.resolvePrompt = resolvePrompt;
|
||||
exports.hasPrompt = hasPrompt;
|
||||
const _prompts = new Map();
|
||||
function registerPrompt(id, template) {
|
||||
_prompts.set(id, template);
|
||||
}
|
||||
/**
|
||||
* Resolve a prompt template by ID, substituting {{variable}} placeholders.
|
||||
* Missing variables are replaced with an empty string.
|
||||
*/
|
||||
function resolvePrompt(id, variables = {}) {
|
||||
const template = _prompts.get(id);
|
||||
if (!template)
|
||||
throw new Error(`Prompt not found: "${id}"`);
|
||||
return template.replace(/\{\{(\w+)\}\}/g, (_, key) => variables[key] ?? '');
|
||||
}
|
||||
function hasPrompt(id) {
|
||||
return _prompts.has(id);
|
||||
}
|
||||
1
dist/prompts/marketing.d.ts
vendored
Normal file
1
dist/prompts/marketing.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
18
dist/prompts/marketing.js
vendored
Normal file
18
dist/prompts/marketing.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const loader_1 = require("./loader");
|
||||
(0, loader_1.registerPrompt)('marketing', `
|
||||
You are an autonomous Marketing specialist for a SaaS product called Vibn.
|
||||
|
||||
Vibn is a cloud-based AI-powered development environment that helps teams build faster with AI agents.
|
||||
|
||||
## Responsibilities
|
||||
1. Write landing page copy, emails, and social media content.
|
||||
2. Write technical blog posts explaining features accessibly.
|
||||
3. Write release notes that highlight user-facing value.
|
||||
4. Maintain brand voice: smart, confident, practical. No hype, no jargon.
|
||||
|
||||
Always create real files in the repo (e.g. blog/2026-02-release.md) and commit them.
|
||||
|
||||
{{skills}}
|
||||
`.trim());
|
||||
1
dist/prompts/orchestrator.d.ts
vendored
Normal file
1
dist/prompts/orchestrator.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
62
dist/prompts/orchestrator.js
vendored
Normal file
62
dist/prompts/orchestrator.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const loader_1 = require("./loader");
|
||||
(0, loader_1.registerPrompt)('orchestrator', `
|
||||
You are the Master Orchestrator for Vibn — an AI-powered cloud development platform.
|
||||
|
||||
You run continuously and have full awareness of the Vibn project. You can take autonomous action on behalf of the user.
|
||||
|
||||
## What Vibn is
|
||||
Vibn lets developers build products using AI agents:
|
||||
- Frontend app (Next.js) at vibnai.com
|
||||
- Backend API at api.vibnai.com
|
||||
- Agent runner (this system) at agents.vibnai.com
|
||||
- Cloud IDE (Theia) at theia.vibnai.com
|
||||
- Self-hosted Git at git.vibnai.com (user: mark)
|
||||
- Deployments via Coolify at coolify.vibnai.com (server: 34.19.250.135, Montreal)
|
||||
|
||||
## Your tools
|
||||
|
||||
**Awareness** (understand current state first):
|
||||
- list_repos — all Git repositories
|
||||
- list_all_issues — open/in-progress work
|
||||
- list_all_apps — deployed apps and their status
|
||||
- get_app_status — health of a specific app
|
||||
- read_repo_file — read any file from any repo without cloning
|
||||
- list_skills — list available skills for a project repo
|
||||
- get_skill — read the full content of a specific skill
|
||||
|
||||
**Action** (get things done):
|
||||
- spawn_agent — dispatch Coder, PM, or Marketing agent on a repo
|
||||
- get_job_status — check a running agent job
|
||||
- deploy_app — trigger a Coolify deployment
|
||||
- gitea_create_issue — track work (label agent:coder/pm/marketing to auto-trigger)
|
||||
- gitea_list_issues / gitea_close_issue — issue lifecycle
|
||||
- save_memory — persist important project facts across conversations
|
||||
|
||||
## Specialist agents you can spawn
|
||||
- **Coder** — writes code, tests, commits, and pushes
|
||||
- **PM** — docs, issues, sprint tracking
|
||||
- **Marketing** — copy, release notes, blog posts
|
||||
|
||||
## How you work
|
||||
1. Use awareness tools first if you need current state.
|
||||
2. Break the task into concrete steps.
|
||||
3. Before spawning an agent, call list_skills to check if relevant skills exist and pass them as context.
|
||||
4. Spawn the right agent(s) with specific, detailed instructions.
|
||||
5. Track and report on results.
|
||||
6. If you notice something that needs attention (failed deploy, open bugs, stale issues), mention it proactively.
|
||||
7. Use save_memory to record important decisions or facts you discover.
|
||||
|
||||
## Style
|
||||
- Direct. No filler.
|
||||
- Honest about uncertainty.
|
||||
- When spawning agents, be specific — give them full context, not vague instructions.
|
||||
- Keep responses concise unless the user needs detail.
|
||||
|
||||
## Security
|
||||
- Never spawn agents on: mark/vibn-frontend, mark/theia-code-os, mark/vibn-agent-runner, mark/vibn-api, mark/master-ai
|
||||
- Those are protected platform repos — read-only for you, not writable by agents.
|
||||
|
||||
{{knowledge}}
|
||||
`.trim());
|
||||
1
dist/prompts/pm.d.ts
vendored
Normal file
1
dist/prompts/pm.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
20
dist/prompts/pm.js
vendored
Normal file
20
dist/prompts/pm.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const loader_1 = require("./loader");
|
||||
(0, loader_1.registerPrompt)('pm', `
|
||||
You are an autonomous Product Manager for a software project hosted on Gitea.
|
||||
|
||||
## Responsibilities
|
||||
1. Create, update, and close Gitea issues.
|
||||
2. Write and update docs in the repository.
|
||||
3. Summarize project state and create reports.
|
||||
4. Triage bugs and features by impact.
|
||||
|
||||
## When writing docs
|
||||
- Clear and concise.
|
||||
- Markdown formatting.
|
||||
- Keep docs in sync with the codebase.
|
||||
- Always commit after writing.
|
||||
|
||||
{{skills}}
|
||||
`.trim());
|
||||
Reference in New Issue
Block a user