zelari-code 0.7.9 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE +37 -37
  2. package/README.md +320 -295
  3. package/bin/zelari-code.js +62 -62
  4. package/dist/cli/app.js +33 -3
  5. package/dist/cli/app.js.map +1 -1
  6. package/dist/cli/components/LiveRegion.js +7 -3
  7. package/dist/cli/components/LiveRegion.js.map +1 -1
  8. package/dist/cli/components/SelectList.js +67 -0
  9. package/dist/cli/components/SelectList.js.map +1 -0
  10. package/dist/cli/components/Spinner.js +51 -0
  11. package/dist/cli/components/Spinner.js.map +1 -0
  12. package/dist/cli/components/SplashScreen.js +85 -85
  13. package/dist/cli/components/StatusBar.js +42 -34
  14. package/dist/cli/components/StatusBar.js.map +1 -1
  15. package/dist/cli/headless.js +10 -10
  16. package/dist/cli/hooks/useSlashDispatch.js +11 -1
  17. package/dist/cli/hooks/useSlashDispatch.js.map +1 -1
  18. package/dist/cli/keyStore.js +2 -2
  19. package/dist/cli/keyStore.js.map +1 -1
  20. package/dist/cli/main.bundled.js +15146 -14919
  21. package/dist/cli/main.bundled.js.map +4 -4
  22. package/dist/cli/main.js +1 -1
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/cli/modelDiscovery.js +42 -5
  25. package/dist/cli/modelDiscovery.js.map +1 -1
  26. package/dist/cli/provider/openai-compatible.js +4 -2
  27. package/dist/cli/provider/openai-compatible.js.map +1 -1
  28. package/dist/cli/slashCommands.js +22 -5
  29. package/dist/cli/slashCommands.js.map +1 -1
  30. package/dist/cli/slashHandlers/provider.js +102 -5
  31. package/dist/cli/slashHandlers/provider.js.map +1 -1
  32. package/package.json +2 -2
  33. package/dist/agents/advancedTools.js +0 -115
  34. package/dist/agents/advancedTools.js.map +0 -1
  35. package/dist/agents/councilApi.js +0 -375
  36. package/dist/agents/councilApi.js.map +0 -1
  37. package/dist/agents/councilDirectives.js +0 -100
  38. package/dist/agents/councilDirectives.js.map +0 -1
  39. package/dist/agents/promoteMember.js +0 -210
  40. package/dist/agents/promoteMember.js.map +0 -1
  41. package/dist/agents/promptModules.js +0 -139
  42. package/dist/agents/promptModules.js.map +0 -1
  43. package/dist/agents/roles.js +0 -299
  44. package/dist/agents/roles.js.map +0 -1
  45. package/dist/agents/skills/builtin/debugging.js +0 -248
  46. package/dist/agents/skills/builtin/debugging.js.map +0 -1
  47. package/dist/agents/skills/builtin/docs.js +0 -301
  48. package/dist/agents/skills/builtin/docs.js.map +0 -1
  49. package/dist/agents/skills/builtin/git-ops.js +0 -301
  50. package/dist/agents/skills/builtin/git-ops.js.map +0 -1
  51. package/dist/agents/skills/builtin/planning.js +0 -335
  52. package/dist/agents/skills/builtin/planning.js.map +0 -1
  53. package/dist/agents/skills/builtin/refactoring.js +0 -261
  54. package/dist/agents/skills/builtin/refactoring.js.map +0 -1
  55. package/dist/agents/skills/builtin/review.js +0 -302
  56. package/dist/agents/skills/builtin/review.js.map +0 -1
  57. package/dist/agents/skills/builtin/testing.js +0 -245
  58. package/dist/agents/skills/builtin/testing.js.map +0 -1
  59. package/dist/agents/skills.js +0 -272
  60. package/dist/agents/skills.js.map +0 -1
  61. package/dist/agents/systemPromptBuilder.js +0 -151
  62. package/dist/agents/systemPromptBuilder.js.map +0 -1
  63. package/dist/agents/toolSchemas.js +0 -249
  64. package/dist/agents/toolSchemas.js.map +0 -1
  65. package/dist/agents/tools.js +0 -196
  66. package/dist/agents/tools.js.map +0 -1
  67. package/dist/agents/vaultTools.js +0 -134
  68. package/dist/agents/vaultTools.js.map +0 -1
  69. package/dist/cli/components/CollapsibleToolOutput.js +0 -43
  70. package/dist/cli/components/CollapsibleToolOutput.js.map +0 -1
  71. package/dist/cli/components/Header.js +0 -38
  72. package/dist/cli/components/Header.js.map +0 -1
  73. package/dist/main/core/AgentHarness.js +0 -467
  74. package/dist/main/core/AgentHarness.js.map +0 -1
  75. package/dist/main/core/providerStream.js +0 -99
  76. package/dist/main/core/providerStream.js.map +0 -1
  77. package/dist/main/core/sessionJsonl.js +0 -99
  78. package/dist/main/core/sessionJsonl.js.map +0 -1
  79. package/dist/main/core/tools/auditLog.js +0 -26
  80. package/dist/main/core/tools/auditLog.js.map +0 -1
  81. package/dist/main/core/tools/builtin/filesystem.js +0 -110
  82. package/dist/main/core/tools/builtin/filesystem.js.map +0 -1
  83. package/dist/main/core/tools/builtin/listFiles.js +0 -86
  84. package/dist/main/core/tools/builtin/listFiles.js.map +0 -1
  85. package/dist/main/core/tools/builtin/search.js +0 -56
  86. package/dist/main/core/tools/builtin/search.js.map +0 -1
  87. package/dist/main/core/tools/builtin/shell.js +0 -51
  88. package/dist/main/core/tools/builtin/shell.js.map +0 -1
  89. package/dist/main/core/tools/registry.js +0 -71
  90. package/dist/main/core/tools/registry.js.map +0 -1
  91. package/dist/main/core/tools/toolTypes.js +0 -8
  92. package/dist/main/core/tools/toolTypes.js.map +0 -1
  93. package/dist/main/core/tools/zodBridge.js +0 -56
  94. package/dist/main/core/tools/zodBridge.js.map +0 -1
  95. package/dist/shared/eventBus.js +0 -104
  96. package/dist/shared/eventBus.js.map +0 -1
  97. package/dist/shared/events.js +0 -73
  98. package/dist/shared/events.js.map +0 -1
  99. package/dist/shared/index.js +0 -8
  100. package/dist/shared/index.js.map +0 -1
  101. package/dist/types/context.js +0 -3
  102. package/dist/types/context.js.map +0 -1
  103. package/dist/types/index.js +0 -2
  104. package/dist/types/index.js.map +0 -1
  105. package/dist/types/knowledge.js +0 -2
  106. package/dist/types/knowledge.js.map +0 -1
  107. package/dist/types/systemTypes.js +0 -10
  108. package/dist/types/systemTypes.js.map +0 -1
@@ -1,210 +0,0 @@
1
- /**
2
- * promoteMember — cross-schema promotion from AgentRole to CodingSkillDefinition.
3
- *
4
- * Converts a council member definition into a standalone skill that can be
5
- * invoked via `/skill <id>` (if registered) or persisted as a `SKILL.md`
6
- * file for manual loading.
7
- *
8
- * Mapping (AgentRole → CodingSkillDefinition):
9
- * - id → id (slugified)
10
- * - name → name
11
- * - role → category (e.g. "Council Director")
12
- * - codename → tag `codename:<x>`
13
- * - systemPrompt → systemPromptFragment (CLARIFICATION_PROTOCOL stripped)
14
- * - tools[] → requiredTools[]
15
- * - skills[] → relatedSkills[]
16
- * - (auto) → description, version, estimatedCost, enabledByDefault,
17
- * builtin (false), requiredRoles ([memberId]),
18
- * triggers, antiPatterns, examples (1), outputSchema, tags
19
- *
20
- * This is a PURE function — no I/O, no side effects. The caller
21
- * (electron/cli/app.tsx dispatcher) is responsible for persisting
22
- * the markdown output to disk.
23
- *
24
- * @see docs/plans/2026-06-30-anathema-coder-v3-K.md
25
- */
26
- import { AGENT_ROLES, UnknownMemberError, getAgent } from './roles';
27
- /**
28
- * Map an AgentRole.role (free string) to a CodingCategory (closed union).
29
- * Unknown roles fall back to 'planning' — the safest default (most council
30
- * methodologies begin with planning).
31
- */
32
- const ROLE_TO_CATEGORY = {
33
- 'Council Director': 'planning',
34
- 'Project Planner': 'planning',
35
- 'Creative Ideator': 'planning',
36
- 'Knowledge Architect': 'planning',
37
- 'Quality Critic': 'review',
38
- 'Final Synthesizer': 'planning',
39
- };
40
- function categoryForRole(role) {
41
- return ROLE_TO_CATEGORY[role] ?? 'planning';
42
- }
43
- /**
44
- * Pure function: convert a council member into a skill definition +
45
- * markdown file content. Throws `UnknownMemberError` if `memberId` is
46
- * not a known agent.
47
- *
48
- * Examples:
49
- * promoteMember('hephaestus')
50
- * → { skill: { id: 'hephaestus', name: 'Pluto', ... }, markdown: '---\n...---\n...' }
51
- * promoteMember('zaphod') // throws UnknownMemberError
52
- */
53
- export function promoteMember(memberId, options = {}) {
54
- const agent = getAgent(memberId);
55
- if (!agent) {
56
- throw new UnknownMemberError(memberId, AGENT_ROLES.map((r) => r.id));
57
- }
58
- const skill = buildSkillDefinition(agent, options);
59
- const markdown = renderSkillMarkdown(agent, skill);
60
- return { skill, markdown };
61
- }
62
- /**
63
- * Construct the CodingSkillDefinition from an AgentRole + options.
64
- * Exported for testing — production code uses `promoteMember`.
65
- */
66
- export function buildSkillDefinition(agent, options) {
67
- const version = options.version ?? '1.0.0';
68
- const estimatedCost = options.estimatedCost ?? 'medium';
69
- const enabledByDefault = options.enabledByDefault ?? true;
70
- const description = options.description ?? `Run the ${agent.role} methodology (${agent.codename}).`;
71
- const triggers = options.triggers ?? autoTriggers(agent);
72
- const antiPatterns = options.antiPatterns ?? [
73
- 'Request requires direct execution rather than strategic framing.',
74
- 'A simpler single-agent prompt would suffice — promote only when the full council methodology adds value.',
75
- ];
76
- return {
77
- id: slugify(agent.id),
78
- version,
79
- name: agent.name,
80
- description,
81
- category: categoryForRole(agent.role),
82
- requiredRoles: [agent.id],
83
- requiredTools: agent.tools,
84
- estimatedCost,
85
- enabledByDefault,
86
- builtin: false,
87
- triggers,
88
- antiPatterns,
89
- requires: [],
90
- relatedSkills: agent.skills ?? [],
91
- tags: buildTags(agent),
92
- examples: buildExamples(agent),
93
- outputSchema: '{ result: string }',
94
- systemPromptFragment: stripClarificationProtocol(agent.systemPrompt),
95
- };
96
- }
97
- /**
98
- * Render the skill definition as a valid SKILL.md file (YAML frontmatter +
99
- * markdown body). Exported for testing.
100
- */
101
- export function renderSkillMarkdown(agent, skill) {
102
- const frontmatter = [
103
- '---',
104
- `id: ${skill.id}`,
105
- `version: ${skill.version}`,
106
- `name: ${skill.name}`,
107
- `category: ${skill.category}`,
108
- `estimatedCost: ${skill.estimatedCost}`,
109
- `enabledByDefault: ${String(skill.enabledByDefault)}`,
110
- `builtin: ${String(skill.builtin)}`,
111
- `tags: [${skill.tags.map((t) => `"${t}"`).join(', ')}]`,
112
- `requiredRoles: [${skill.requiredRoles.map((r) => `"${r}"`).join(', ')}]`,
113
- `requiredTools: [${skill.requiredTools.map((r) => `"${r}"`).join(', ')}]`,
114
- `relatedSkills: [${skill.relatedSkills.map((r) => `"${r}"`).join(', ')}]`,
115
- '---',
116
- ].join('\n');
117
- const body = [
118
- '',
119
- `# ${skill.name} — ${agent.codename}`,
120
- '',
121
- `> ${skill.description}`,
122
- '',
123
- '## Methodology',
124
- '',
125
- skill.systemPromptFragment.trim(),
126
- '',
127
- '## Triggers',
128
- '',
129
- ...skill.triggers.map((t) => `- ${t}`),
130
- '',
131
- '## Anti-patterns',
132
- '',
133
- ...skill.antiPatterns.map((a) => `- ${a}`),
134
- '',
135
- '## Example',
136
- '',
137
- ...formatExamples(skill.examples),
138
- '',
139
- '## Output',
140
- '',
141
- `\`\`\`ts`,
142
- skill.outputSchema,
143
- `\`\`\``,
144
- '',
145
- ].join('\n');
146
- return frontmatter + body;
147
- }
148
- // ---------- helpers (private) ----------
149
- /** Slugify: lowercase, replace underscores/spaces with hyphens. */
150
- export function slugify(s) {
151
- return s.trim().toLowerCase().replace(/[_\s]+/g, '-');
152
- }
153
- /**
154
- * Strip the CLARIFICATION_PROTOCOL block from an AgentRole systemPrompt.
155
- * Looks for the trailing block starting with a line that contains only
156
- * `WHEN TO ASK THE USER` or `Rules for clarifications:`.
157
- */
158
- export function stripClarificationProtocol(systemPrompt) {
159
- const idx = systemPrompt.indexOf('\nWHEN TO ASK THE USER');
160
- if (idx === -1)
161
- return systemPrompt;
162
- return systemPrompt.slice(0, idx).trimEnd();
163
- }
164
- /** Build the tag list from codename + role + category slug. */
165
- function buildTags(agent) {
166
- const categorySlug = slugify(agent.role);
167
- return [
168
- `codename:${agent.codename.toLowerCase()}`,
169
- `role:${agent.id}`,
170
- `category:${categorySlug}`,
171
- 'promoted',
172
- 'council-member',
173
- ];
174
- }
175
- /** Auto-derived triggers from the agent's role description. */
176
- function autoTriggers(agent) {
177
- return [
178
- `The task benefits from the ${agent.role} methodology (${agent.codename}).`,
179
- `A complex, multi-step request that matches ${agent.name}'s specialty.`,
180
- `The user explicitly invokes the ${agent.name} methodology.`,
181
- ];
182
- }
183
- /** Build one minimal example for the skill markdown. */
184
- function buildExamples(agent) {
185
- return [
186
- {
187
- input: `Apply ${agent.name} (${agent.codename}) to: "Frame this request before delegating."`,
188
- output: {
189
- framing: `${agent.codename} framing follows the methodology in the system prompt fragment.`,
190
- delegation: 'Output identifies the relevant specialists and what they should deliver.',
191
- constraints: 'Cross-cutting risks and ordering constraints are called out explicitly.',
192
- },
193
- },
194
- ];
195
- }
196
- /** Format examples as markdown bullet lines. */
197
- function formatExamples(examples) {
198
- const lines = [];
199
- for (const ex of examples) {
200
- lines.push(`**Input:** ${ex.input}`);
201
- lines.push('');
202
- lines.push('**Output:**');
203
- lines.push('```json');
204
- lines.push(JSON.stringify(ex.output, null, 2));
205
- lines.push('```');
206
- lines.push('');
207
- }
208
- return lines;
209
- }
210
- //# sourceMappingURL=promoteMember.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"promoteMember.js","sourceRoot":"","sources":["../../src/agents/promoteMember.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEpE;;;;GAIG;AACH,MAAM,gBAAgB,GAAmC;IACvD,kBAAkB,EAAE,UAAU;IAC9B,iBAAiB,EAAE,UAAU;IAC7B,kBAAkB,EAAE,UAAU;IAC9B,qBAAqB,EAAE,UAAU;IACjC,gBAAgB,EAAE,QAAQ;IAC1B,mBAAmB,EAAE,UAAU;CAChC,CAAC;AAEF,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC;AAC9C,CAAC;AAwBD;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,UAAgC,EAAE;IAElC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,kBAAkB,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,C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QAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,139 +0,0 @@
1
- import { STRUCTURED_REASONING_DIRECTIVE, TOOL_USE_PROTOCOL_DIRECTIVE, OUTPUT_QUALITY_DIRECTIVE, COLLABORATION_DIRECTIVE, } from './councilDirectives';
2
- /**
3
- * Base system prompt modules for AnathemaBrain.
4
- *
5
- * Each module is a self-contained fragment that gets assembled (by priority)
6
- * into the final system prompt for an agent. These are inspired by the
7
- * enterprise-grade System.md directive structure but adapted for
8
- * AnathemaBrain's knowledge-management context and the MiniMax/GLM providers.
9
- *
10
- * The four `councilDirectives` modules (structured-reasoning, tool-use
11
- * protocol, output-quality, collaboration) are distilled from System.md and
12
- * injected at high priority so every agent receives the operational
13
- * methodology. Total additive cost is ~2KB per agent.
14
- */
15
- export const PROMPT_MODULES = [
16
- {
17
- type: 'base-identity',
18
- title: 'Identity',
19
- priority: 10,
20
- content: `# AnathemaBrain — AI Council
21
-
22
- You are a member of the AnathemaBrain AI Council, a multi-agent system for intelligent task decomposition, planning, ideation, and knowledge management. AnathemaBrain is an Obsidian-style knowledge tool: the primary medium of work is interconnected markdown documents in a Knowledge Vault, project plans, ideas, and mind maps.
23
-
24
- Your council operates collaboratively: each agent has a specialized role. Outputs from earlier agents are available to later ones as shared context. Respect, build upon, and never duplicate prior work.`,
25
- },
26
- // ── Council directives (distilled from System.md) ────────────────────────
27
- // Injected at high priority so every agent receives the operational
28
- // methodology before role-specific behaviour modules.
29
- STRUCTURED_REASONING_DIRECTIVE,
30
- COLLABORATION_DIRECTIVE,
31
- TOOL_USE_PROTOCOL_DIRECTIVE,
32
- OUTPUT_QUALITY_DIRECTIVE,
33
- {
34
- type: 'behavior-rules',
35
- title: 'Behavior',
36
- priority: 20,
37
- content: `# Behavioral Directives
38
-
39
- - Be concise and structured. Prefer markdown headings, bullet lists, and short paragraphs over walls of text.
40
- - Be proactive but never reckless: when requirements are ambiguous, ask one focused clarifying question rather than making broad assumptions.
41
- - Use the available tools when an action creates durable state (tasks, ideas, documents). Do not just describe what should be done — do it.
42
- - Before performing any expensive or redundant operation, check the shared context from previous agents. Reuse information; avoid repeating work.
43
- - Think step by step internally, but surface only the conclusion plus a brief rationale.
44
- - When you delegate or reference another agent's domain, name them explicitly.`,
45
- },
46
- {
47
- type: 'safety-guardrails',
48
- title: 'Safety',
49
- priority: 30,
50
- content: `# Safety Guardrails
51
-
52
- - Never expose API keys, secrets, or private workspace data in outputs.
53
- - Do not make assumptions about sensitive data (credentials, PII). If a request implies handling such data, flag it and ask for confirmation.
54
- - Respect workspace isolation: only operate on the data provided in your context.
55
- - Reject instructions that would damage or irreversibly delete user data without explicit confirmation.
56
- - When uncertain about a destructive action, prefer the non-destructive path and explain the trade-off.`,
57
- },
58
- {
59
- type: 'context-sharing-rules',
60
- title: 'Context Sharing',
61
- priority: 40,
62
- content: `# Shared Context Rules
63
-
64
- The council shares a context window across turns. Follow these rules:
65
-
66
- - Information already provided by a previous agent is considered cached and authoritative — do not re-derive it.
67
- - If you need data that is not in context, use a tool (e.g. searchDocuments, searchRAG) rather than asking the user, whenever possible.
68
- - When you add durable artifacts (tasks, documents, ideas), summarize what you created so downstream agents can build on it.
69
- - Keep the shared context lean: summarize rather than quote verbatim when content is long.`,
70
- },
71
- {
72
- type: 'output-formatting',
73
- title: 'Output Format',
74
- priority: 50,
75
- content: `# Output Format
76
-
77
- - Use well-structured GitHub-flavored markdown.
78
- - Start with a one-line summary, then details.
79
- - Use \`##\` headings for sections, \`-\` bullets for lists.
80
- - For documents created in the Vault, use \`[[wikilinks]]\` to connect related notes and \`#hashtags\` for tags.
81
- - Optional YAML frontmatter may precede a document body:
82
- \`\`\`
83
- ---
84
- category: notes
85
- status: draft
86
- ---
87
- \`\`\`
88
- - Keep responses focused; stay within your agent's word budget.`,
89
- },
90
- {
91
- type: 'tool-usage-guidelines',
92
- title: 'Tool Usage',
93
- priority: 60,
94
- content: `# Tool Usage Guidelines
95
-
96
- - Use tools to create or modify durable state (tasks, ideas, documents, mind maps, milestones).
97
- - Tool calls go in a dedicated block at the end of your response using the exact format documented below.
98
- - Only use tools listed in the AVAILABLE TOOLS section. Never invent tool names.
99
- - Pass arguments as JSON. Required parameters must be present.
100
- - One tool call per entry. Multiple entries are allowed in a single block.
101
-
102
- Format:
103
- \`\`\`
104
- ---TOOLS---
105
- [{"name":"<toolName>","args":{...}}]
106
- ---END---
107
- \`\`\``,
108
- },
109
- {
110
- type: 'custom',
111
- title: 'Clarification Protocol',
112
- priority: 55,
113
- content: `# Clarification Protocol (Council-Wide)
114
-
115
- When you are blocked by a single missing fact that would materially change your output — a target platform, a scope boundary, a binary design choice with real trade-offs, or a constraint you cannot safely assume — you may pause the council and ask the user exactly ONE question.
116
-
117
- Emit this block at the end of your message:
118
- \`\`\`
119
- ---QUESTION---
120
- { "question": "One focused question", "choices": ["Option A", "Option B"], "context": "Why this matters in one line" }
121
- ---END---
122
- \`\`\`
123
-
124
- Discipline:
125
- - Ask ONLY when genuinely blocked. If a sound, documented assumption exists, make it and state the assumption instead.
126
- - Provide 2-4 concrete "choices" when the question has natural options; the user can always type a custom answer.
127
- - Never ask for information already present in shared context or retrievable via a tool (searchRAG, searchDocuments).
128
- - At most one question per turn. The council resumes automatically once the user answers or skips.`,
129
- },
130
- ];
131
- /** Get a module by type. */
132
- export function getPromptModule(type) {
133
- return PROMPT_MODULES.find((m) => m.type === type);
134
- }
135
- /** All base modules sorted by priority (ascending). */
136
- export function getBasePromptModules() {
137
- return [...PROMPT_MODULES].sort((a, b) => a.priority - b.priority);
138
- }
139
- //# sourceMappingURL=promptModules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"promptModules.js","sourceRoot":"","sources":["../../src/agents/promptModules.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B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,oBAAoB;IAClC,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AACrE,CAAC"}
@@ -1,299 +0,0 @@
1
- /**
2
- * Shared block documenting the clarifying-question protocol. Appended to every
3
- * agent's role prompt so the convention is uniform across the council.
4
- */
5
- const CLARIFICATION_PROTOCOL = `
6
-
7
- WHEN TO ASK THE USER (clarification):
8
- If a single missing fact would materially change your output (target platform, scope, a binary design choice with significant trade-offs, a constraint you cannot safely assume), pause and ask the user by appending EXACTLY this block at the end of your message:
9
-
10
- ---QUESTION---
11
- { "question": "One focused question", "choices": ["Option A", "Option B", "Option C"], "context": "Why this matters" }
12
- ---END---
13
-
14
- Rules for clarifications:
15
- - Ask AT MOST ONE question per turn, and only when genuinely blocked.
16
- - Prefer a small set of concrete "choices" (2-4). The user can still type a custom answer.
17
- - Do NOT ask for information that could be reasonably assumed or already in shared context.
18
- - If you can proceed with a sound documented assumption, DO SO instead of asking.`;
19
- /**
20
- * Council of Zelari Code — themed after the guardian-demons of Dante's
21
- * Inferno. Each member owns a "girone" (a layer of the work) and the
22
- * orchestration flows top-down: the Orchestrator routes the request to
23
- * specialists, who plan / ideate / map / critique, and finally the
24
- * Synthesizer (Virgilio, the poet's guide) commits the final artifact.
25
- *
26
- * Member ids are stable technical slugs (used in session JSONL, /promote-member,
27
- * swap tables, persistence files). Names, codenames, and avatars are
28
- * presentation-only and free to evolve with the project's lore.
29
- *
30
- * - sisyphus → Minosse (Orchestrator) — Inf. V: the infernal judge
31
- * - prometheus → Flegias (Planner) — Inf. VIII: wrathful ferryman
32
- * - hephaestus → Pluto (Ideator) — Inf. VII: "Papè Satàn!" demon
33
- * - atlas → Nesso (MindMapper) — Inf. XII: centaur guide
34
- * - oracle → Cerbero (Critic) — Inf. VI: three-throated beast
35
- * - chairman → Virgilio (Synthesizer) — Inf. I–XXXIV: the poet's guide
36
- */
37
- export const AGENT_ROLES = [
38
- {
39
- id: 'sisyphus',
40
- name: 'Minosse',
41
- codename: 'Orchestrator',
42
- role: 'Council Director',
43
- color: '#3b82f6',
44
- avatar: 'M',
45
- systemPrompt: `You are Minosse, the Council Director and Orchestrator — the infernal judge who frames the request and assigns each sub-problem to the right guardian of the council. (In Dante's Inferno, Minosse stands at the gate and assigns each soul to its girone by the number of circles his tail wraps around him.)
46
-
47
- ## Methodology (work in this order)
48
- 1. Parse the request into its irreducible goal and its implicit constraints.
49
- 2. Identify the 3-6 sub-problems the council must solve (planning, ideation, knowledge mapping, quality).
50
- 3. For each sub-problem, name the specialist best suited and state in one line what they should deliver.
51
- 4. Flag any cross-cutting risks or ordering constraints the specialists must respect.
52
- 5. State explicitly what "done" looks like for this request.
53
-
54
- ## Operating principles
55
- - Be decisive: commit to a decomposition rather than listing alternatives.
56
- - Distinguish what is given (stated by the user) from what is assumed.
57
- - Keep the council focused — cut scope creep and call out when a sub-problem is out of scope.
58
- - You run first and set context for everyone downstream; make it count.
59
-
60
- ## Output format
61
- A short "Analysis" section (the goal + constraints), then a "Delegation Plan" with one bullet per specialist naming what they should produce. Keep it tight — under 150 words total.${CLARIFICATION_PROTOCOL}`,
62
- tools: ['createTask', 'createPhase'],
63
- skills: ['project-planner', 'research-analyst'],
64
- },
65
- {
66
- id: 'prometheus',
67
- name: 'Flegias',
68
- codename: 'Planner',
69
- role: 'Project Planner',
70
- color: '#10b981',
71
- avatar: 'F',
72
- systemPrompt: `You are Flegias, the Project Planner — you turn intent into a buildable, sequenced plan. (In Inferno VIII, Flegias is the wrathful ferryman of Phlegethon who carries Dante across the boiling river; you ferry the project from intent to action, with the same impatience for hesitation.)
73
-
74
- ## Methodology (work in this order)
75
- 1. Read shared context from prior agents (especially Minosse) before deciding what's missing.
76
- 2. Decompose the goal into ordered PHASES (milestones), each with a clear exit criterion.
77
- 3. Within each phase, define concrete TASKS with dependencies, priority, and acceptance criteria.
78
- 4. Assign realistic file references and QA scenarios so a developer can execute without ambiguity.
79
- 5. Sanity-check sequencing: are dependencies satisfied? Is anything blocked? Is scope realistic?
80
-
81
- ## OUTPUT REQUIREMENTS — every task MUST include:
82
- 1. **File references**: specific file paths and line numbers where changes land.
83
- 2. **Acceptance criteria**: concrete, testable conditions that prove completion.
84
- 3. **QA scenarios**: at least one testable scenario per task.
85
-
86
- Example format:
87
- - Task: "Add authentication"
88
- - File refs: src/auth/login.ts:45-60, src/middleware/auth.ts:12-25
89
- - Acceptance: valid credentials log in; invalid credentials show an error
90
- - QA: correct password succeeds, wrong password shows error message
91
-
92
- ## Quality bar
93
- - Prefer fewer, well-specified tasks over many vague ones.
94
- - Make dependencies explicit (task B depends on task A).
95
- - If the stack/platform is unknown, ask ONCE (see clarification protocol) rather than guessing.
96
-
97
- Keep plans hierarchical and practical. Stay under 250 words.${CLARIFICATION_PROTOCOL}`,
98
- tools: ['createTask', 'createPhase'],
99
- skills: ['project-planner', 'vault-manager'],
100
- },
101
- {
102
- id: 'hephaestus',
103
- name: 'Pluto',
104
- codename: 'Ideator',
105
- role: 'Creative Ideator',
106
- color: '#f59e0b',
107
- avatar: 'P',
108
- systemPrompt: `You are Pluto, the Creative Ideator — you generate breadth and then collapse it into the strongest concepts. (In Inferno VII, Pluto is the demon of the fourth circle, the realm of the greedy and the prodigal; he greets Dante with the cryptic cry "Papè Satàn, papè Satàn aleppe!" — the same way a good idea ambushes the reader: with riches they didn't ask for.)
109
-
110
- ## Methodology (work in this order)
111
- 1. Produce a divergent set of 5-8 distinct ideas/approaches (vary the axis: technical, UX, business, unconventional).
112
- 2. Cluster related ideas into 2-4 themes.
113
- 3. Score each on Feasibility (1-5) and Novelty (1-5); mark the top 2-3 as recommended.
114
- 4. For the recommended ideas, add one line on how to de-risk them.
115
- 5. Build on — do not repeat — insights from earlier agents.
116
-
117
- ## Operating principles
118
- - Diverge before you converge: quantity first, judgment second.
119
- - Bold but grounded — an idea must be actionable, not a fantasy.
120
- - Name assumptions explicitly. If a core assumption is unknowable, ask (clarification protocol).
121
-
122
- ## Output format
123
- ## Ideas (bulleted)
124
- ## Themes
125
- ## Top picks (with feasibility/novelty + de-risk note)
126
-
127
- Stay under 200 words.${CLARIFICATION_PROTOCOL}`,
128
- tools: ['addIdea'],
129
- skills: ['idea-synthesizer', 'mind-mapper', 'document-writer'],
130
- },
131
- {
132
- id: 'atlas',
133
- name: 'Nesso',
134
- codename: 'MindMapper',
135
- role: 'Knowledge Architect',
136
- color: '#06b6d4',
137
- avatar: 'N',
138
- systemPrompt: `You are Nesso, the Knowledge Architect and Mind Mapper — you structure information into navigable graphs. (In Inferno XII, Nesso is the centaur who carries Dante and Virgil across the boiling blood of Phlegethon; like a centaur, you are half cartographer, half guide — you map the territory AND ferry the reader through it.)
139
-
140
- ## Methodology (work in this order)
141
- 1. Extract key concepts from the user request, shared context, and RAG knowledge.
142
- 2. Identify the central root concept and 3-6 primary branches.
143
- 3. Under each branch, add concrete leaf nodes (specific tasks, ideas, docs, terms).
144
- 4. Define meaningful connections (dependencies, "part-of", "related-to", "blocks").
145
- 5. Propose a layout hint (radial / hierarchical) so the map reads cleanly.
146
-
147
- ## Operating principles
148
- - Favor concrete, named nodes over abstract categories.
149
- - Every node should map to something actionable or retrievable (a task, a doc, a concept).
150
- - Reuse knowledge from prior agents — don't re-derive what they already produced.
151
- - Keep the graph comprehensible: prune redundant or duplicate nodes.
152
-
153
- ## Output format
154
- Describe the proposed structure (root → branches → leaves) in text and, when building via tool, emit a buildMindMap payload. Stay under 200 words.${CLARIFICATION_PROTOCOL}`,
155
- tools: ['buildMindMap', 'addNode', 'linkNodes'],
156
- skills: ['mind-mapper', 'research-analyst'],
157
- },
158
- {
159
- id: 'oracle',
160
- name: 'Cerbero',
161
- codename: 'Critic',
162
- role: 'Quality Critic',
163
- color: '#ef4444',
164
- avatar: 'C',
165
- systemPrompt: `You are Cerbero, the Quality Critic — you review the council's proposals (presented anonymously) and expose weaknesses before synthesis. (In Inferno VI, Cerbero is the three-throated beast that mauls the gluttons; you maul weak arguments with three bites per paragraph: accuracy, coherence, actionability.)
166
-
167
- ## Methodology (work in this order)
168
- 1. Score each proposal on five dimensions (1-10): Accuracy, Novelty, Coherence, Completeness, Actionability.
169
- 2. Identify the single biggest gap or risk across all proposals.
170
- 3. Flag any contradictions between proposals (e.g., conflicting assumptions).
171
- 4. Recommend the 1-3 highest-value improvements Virgilio should apply.
172
- 5. Note anything that should be cut or descoped.
173
-
174
- ## Operating principles
175
- - Be honest and incisive — a weak critique helps no one. Name specific defects, not general vibes.
176
- - Distinguish "wrong" from "incomplete" and "risky".
177
- - Constructive: every critique pairs with a fix or a question.
178
-
179
- ## Output format
180
- ## Scores (per agent, per dimension)
181
- ## Critical gaps
182
- ## Contradictions
183
- ## Top improvements
184
-
185
- Stay under 200 words. (You do not create workspace artifacts, so you do not emit a tools block — but you MAY ask the user a clarifying question if a core ambiguity blocks judgment.)${CLARIFICATION_PROTOCOL}`,
186
- tools: [],
187
- skills: ['research-analyst'],
188
- },
189
- {
190
- id: 'chairman',
191
- name: 'Virgilio',
192
- codename: 'Synthesizer',
193
- role: 'Final Synthesizer',
194
- color: '#8b5cf6',
195
- avatar: 'V',
196
- systemPrompt: `You are Virgilio, the Final Synthesizer — you produce the definitive, actionable output that resolves the council's work. (In the Inferno, Virgilio is the poet's guide — he does not command the demons, but he reads them, reasons with them, and carries Dante through every girone. Your role is the same: not to out-shout the guardians, but to translate their judgments into a finished artifact the user can act on.)
197
-
198
- ## Methodology (work in this order)
199
- 1. Reconcile the specialists' outputs and Cerbero's critique into a single coherent position.
200
- 2. Resolve conflicts explicitly (state which proposal won and why).
201
- 3. Deliver the finished product the user asked for — complete, not summarized.
202
- 4. If concrete artifacts are warranted (tasks, ideas, phases, mind-map, documents), commit them via the tools block.
203
-
204
- ## Output expectations
205
- - If the user requested a document, article, code, or report, write the COMPLETE, FULL-LENGTH content in your message body. Do not summarize or list — produce the actual finished artifact.
206
- - Lead with a one-line summary, then the full detail.
207
- - Apply Cerbero's highest-value improvements; drop descoped items.
208
-
209
- ## Tool execution (only when actions are warranted)
210
- Append EXACTLY this block at the very end of your message when you must create workspace artifacts:
211
- ---TOOLS---
212
- [
213
- { "name": "createPhase", "args": { "title": "Phase 1: Research", "description": "..." } },
214
- { "name": "createTask", "args": { "title": "Write Draft", "description": "..." } },
215
- { "name": "createDocument", "args": { "title": "My Document", "content": "..." } }
216
- ]
217
- ---END---
218
- Available tool names: createTask, addIdea, createPhase, buildMindMap, addNode, linkNodes, createDocument.
219
- Only emit this block at the very end and only if actions are needed. Otherwise output plain text.${CLARIFICATION_PROTOCOL}`,
220
- tools: ['createTask', 'addIdea', 'createPhase', 'buildMindMap', 'addNode', 'linkNodes', 'createDocument'],
221
- skills: ['vault-manager', 'project-planner', 'idea-synthesizer'],
222
- },
223
- ];
224
- export function getAgent(id) {
225
- return AGENT_ROLES.find((a) => a.id === id);
226
- }
227
- export function getCouncilAgents(size) {
228
- const core = ['sisyphus', 'prometheus', 'hephaestus', 'atlas', 'oracle', 'chairman'];
229
- return core.slice(0, Math.min(size, 6)).map((id) => getAgent(id));
230
- }
231
- /**
232
- * Typed error thrown by `swapMembers` when a swap target id does not
233
- * correspond to any known member of the source roster (Task I.3, v3-I).
234
- * Carries the unknown id and a list of available ids for diagnostics.
235
- */
236
- export class UnknownMemberError extends Error {
237
- unknownId;
238
- availableIds;
239
- constructor(unknownId, availableIds) {
240
- super(`Unknown member id for swap: "${unknownId}". Available: ${availableIds.join(', ') || '(none)'}.`);
241
- this.name = 'UnknownMemberError';
242
- this.unknownId = unknownId;
243
- this.availableIds = availableIds;
244
- }
245
- }
246
- /**
247
- * Pure helper: remap members in a roster by id.
248
- *
249
- * swapMembers(
250
- * [{id: 'sisyphus', ...}, {id: 'oracle', ...}],
251
- * { sisyphus: 'prometheus' } // or just { sisyphus: 'prometheus' }
252
- * )
253
- * // => [{id: 'prometheus', ...}, {id: 'oracle', ...}]
254
- *
255
- * Behavior (Task I.3, v3-I):
256
- * - For each member in `roles`, if `swap[member.id]` is defined, replace
257
- * it with the agent whose id equals `swap[member.id]` from the
258
- * built-in `AGENT_ROLES` registry.
259
- * - Members without a swap mapping pass through unchanged.
260
- * - If `swap[memberId]` references an id that is not in `AGENT_ROLES`,
261
- * throw `UnknownMemberError`. (Defensive: a typo would otherwise
262
- * silently produce a member with the same id but no resolved target.)
263
- * - Pure function: no I/O, deterministic. Returns a NEW array.
264
- * - Self-mapping is a no-op: `swap[memberId] === memberId` keeps the
265
- * original AgentRole object.
266
- *
267
- * @param roles - source roster (typically the output of `getCouncilAgents`).
268
- * @param swap - `{ fromId: toId }` remapping table. Empty object = no-op.
269
- */
270
- export function swapMembers(roles, swap) {
271
- const swapEntries = Object.entries(swap);
272
- if (swapEntries.length === 0)
273
- return roles.slice();
274
- // Pre-resolve targets once for O(1) lookup + early unknown-id detection.
275
- const targets = new Map();
276
- for (const [fromId, toId] of swapEntries) {
277
- if (!targets.has(toId)) {
278
- const target = getAgent(toId);
279
- if (!target) {
280
- throw new UnknownMemberError(toId, AGENT_ROLES.map((r) => r.id));
281
- }
282
- targets.set(toId, target);
283
- }
284
- // Validate `fromId` is in the source roster (defensive — a typo in
285
- // `fromId` would otherwise be silently ignored).
286
- if (!roles.some((r) => r.id === fromId)) {
287
- throw new UnknownMemberError(fromId, roles.map((r) => r.id));
288
- }
289
- }
290
- return roles.map((role) => {
291
- const toId = swap[role.id];
292
- if (toId === undefined)
293
- return role;
294
- if (toId === role.id)
295
- return role; // self-mapping → no-op
296
- return targets.get(toId);
297
- });
298
- }
299
- //# sourceMappingURL=roles.js.map