xibecode 1.0.2 → 1.0.6
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.
- package/dist/commands/chat.d.ts +0 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +10 -7
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +5 -3
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/diagnostics.js +1 -1
- package/dist/commands/diagnostics.js.map +1 -1
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/resume.js +1 -1
- package/dist/commands/resume.js.map +1 -1
- package/dist/commands/run-pr.d.ts.map +1 -1
- package/dist/commands/run-pr.js +13 -10
- package/dist/commands/run-pr.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +17 -14
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/commands/skills.js +3 -2
- package/dist/commands/skills.js.map +1 -1
- package/dist/components/AssistantMarkdown.js +1 -1
- package/dist/components/AssistantMarkdown.js.map +1 -1
- package/dist/index.js +2 -39
- package/dist/index.js.map +1 -1
- package/dist/ui/claude-style-chat.d.ts.map +1 -1
- package/dist/ui/claude-style-chat.js +15 -11
- package/dist/ui/claude-style-chat.js.map +1 -1
- package/dist/utils/built-in-skills-dir.d.ts +7 -0
- package/dist/utils/built-in-skills-dir.d.ts.map +1 -0
- package/dist/utils/built-in-skills-dir.js +11 -0
- package/dist/utils/built-in-skills-dir.js.map +1 -0
- package/dist/utils/config.d.ts +2 -119
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +3 -88
- package/dist/utils/config.js.map +1 -1
- package/package.json +11 -26
- package/dist/commands/punycode.d.ts +0 -5
- package/dist/commands/punycode.d.ts.map +0 -1
- package/dist/commands/punycode.js +0 -48
- package/dist/commands/punycode.js.map +0 -1
- package/dist/commands/tui.d.ts +0 -9
- package/dist/commands/tui.d.ts.map +0 -1
- package/dist/commands/tui.js +0 -83
- package/dist/commands/tui.js.map +0 -1
- package/dist/core/agent-tool-policies.d.ts +0 -5
- package/dist/core/agent-tool-policies.d.ts.map +0 -1
- package/dist/core/agent-tool-policies.js +0 -18
- package/dist/core/agent-tool-policies.js.map +0 -1
- package/dist/core/agent.d.ts +0 -181
- package/dist/core/agent.d.ts.map +0 -1
- package/dist/core/agent.js +0 -1777
- package/dist/core/agent.js.map +0 -1
- package/dist/core/background-agent.d.ts +0 -23
- package/dist/core/background-agent.d.ts.map +0 -1
- package/dist/core/background-agent.js +0 -175
- package/dist/core/background-agent.js.map +0 -1
- package/dist/core/code-graph.d.ts +0 -18
- package/dist/core/code-graph.d.ts.map +0 -1
- package/dist/core/code-graph.js +0 -105
- package/dist/core/code-graph.js.map +0 -1
- package/dist/core/conflict-solver.d.ts +0 -26
- package/dist/core/conflict-solver.d.ts.map +0 -1
- package/dist/core/conflict-solver.js +0 -108
- package/dist/core/conflict-solver.js.map +0 -1
- package/dist/core/context-compactor.d.ts +0 -10
- package/dist/core/context-compactor.d.ts.map +0 -1
- package/dist/core/context-compactor.js +0 -158
- package/dist/core/context-compactor.js.map +0 -1
- package/dist/core/context-pruner.d.ts +0 -19
- package/dist/core/context-pruner.d.ts.map +0 -1
- package/dist/core/context-pruner.js +0 -103
- package/dist/core/context-pruner.js.map +0 -1
- package/dist/core/context.d.ts +0 -82
- package/dist/core/context.d.ts.map +0 -1
- package/dist/core/context.js +0 -273
- package/dist/core/context.js.map +0 -1
- package/dist/core/conversation-recovery.d.ts +0 -9
- package/dist/core/conversation-recovery.d.ts.map +0 -1
- package/dist/core/conversation-recovery.js +0 -15
- package/dist/core/conversation-recovery.js.map +0 -1
- package/dist/core/debug-workflow.d.ts +0 -9
- package/dist/core/debug-workflow.d.ts.map +0 -1
- package/dist/core/debug-workflow.js +0 -19
- package/dist/core/debug-workflow.js.map +0 -1
- package/dist/core/docs-scraper.d.ts +0 -40
- package/dist/core/docs-scraper.d.ts.map +0 -1
- package/dist/core/docs-scraper.js +0 -386
- package/dist/core/docs-scraper.js.map +0 -1
- package/dist/core/editor.d.ts +0 -87
- package/dist/core/editor.d.ts.map +0 -1
- package/dist/core/editor.js +0 -377
- package/dist/core/editor.js.map +0 -1
- package/dist/core/export.d.ts +0 -11
- package/dist/core/export.d.ts.map +0 -1
- package/dist/core/export.js +0 -54
- package/dist/core/export.js.map +0 -1
- package/dist/core/history-manager.d.ts +0 -75
- package/dist/core/history-manager.d.ts.map +0 -1
- package/dist/core/history-manager.js +0 -146
- package/dist/core/history-manager.js.map +0 -1
- package/dist/core/marketplace-client.d.ts +0 -52
- package/dist/core/marketplace-client.d.ts.map +0 -1
- package/dist/core/marketplace-client.js +0 -71
- package/dist/core/marketplace-client.js.map +0 -1
- package/dist/core/mcp/mcp-config.d.ts +0 -10
- package/dist/core/mcp/mcp-config.d.ts.map +0 -1
- package/dist/core/mcp/mcp-config.js +0 -70
- package/dist/core/mcp/mcp-config.js.map +0 -1
- package/dist/core/mcp/mcp-policy.d.ts +0 -17
- package/dist/core/mcp/mcp-policy.d.ts.map +0 -1
- package/dist/core/mcp/mcp-policy.js +0 -56
- package/dist/core/mcp/mcp-policy.js.map +0 -1
- package/dist/core/mcp/oauth-flow.d.ts +0 -30
- package/dist/core/mcp/oauth-flow.d.ts.map +0 -1
- package/dist/core/mcp/oauth-flow.js +0 -230
- package/dist/core/mcp/oauth-flow.js.map +0 -1
- package/dist/core/mcp/oauth-store.d.ts +0 -13
- package/dist/core/mcp/oauth-store.d.ts.map +0 -1
- package/dist/core/mcp/oauth-store.js +0 -68
- package/dist/core/mcp/oauth-store.js.map +0 -1
- package/dist/core/mcp/resolve-mcp-servers.d.ts +0 -16
- package/dist/core/mcp/resolve-mcp-servers.d.ts.map +0 -1
- package/dist/core/mcp/resolve-mcp-servers.js +0 -83
- package/dist/core/mcp/resolve-mcp-servers.js.map +0 -1
- package/dist/core/mcp-client.d.ts +0 -99
- package/dist/core/mcp-client.d.ts.map +0 -1
- package/dist/core/mcp-client.js +0 -315
- package/dist/core/mcp-client.js.map +0 -1
- package/dist/core/memory-promotions.d.ts +0 -15
- package/dist/core/memory-promotions.d.ts.map +0 -1
- package/dist/core/memory-promotions.js +0 -38
- package/dist/core/memory-promotions.js.map +0 -1
- package/dist/core/memory.d.ts +0 -32
- package/dist/core/memory.d.ts.map +0 -1
- package/dist/core/memory.js +0 -121
- package/dist/core/memory.js.map +0 -1
- package/dist/core/modes.d.ts +0 -432
- package/dist/core/modes.d.ts.map +0 -1
- package/dist/core/modes.js +0 -1088
- package/dist/core/modes.js.map +0 -1
- package/dist/core/pattern-miner.d.ts +0 -43
- package/dist/core/pattern-miner.d.ts.map +0 -1
- package/dist/core/pattern-miner.js +0 -123
- package/dist/core/pattern-miner.js.map +0 -1
- package/dist/core/permission-store.d.ts +0 -15
- package/dist/core/permission-store.d.ts.map +0 -1
- package/dist/core/permission-store.js +0 -30
- package/dist/core/permission-store.js.map +0 -1
- package/dist/core/permissions.d.ts +0 -33
- package/dist/core/permissions.d.ts.map +0 -1
- package/dist/core/permissions.js +0 -141
- package/dist/core/permissions.js.map +0 -1
- package/dist/core/plan-artifacts.d.ts +0 -10
- package/dist/core/plan-artifacts.d.ts.map +0 -1
- package/dist/core/plan-artifacts.js +0 -60
- package/dist/core/plan-artifacts.js.map +0 -1
- package/dist/core/plan-session.d.ts +0 -25
- package/dist/core/plan-session.d.ts.map +0 -1
- package/dist/core/plan-session.js +0 -99
- package/dist/core/plan-session.js.map +0 -1
- package/dist/core/planMode.d.ts +0 -51
- package/dist/core/planMode.d.ts.map +0 -1
- package/dist/core/planMode.js +0 -245
- package/dist/core/planMode.js.map +0 -1
- package/dist/core/plugins.d.ts +0 -96
- package/dist/core/plugins.d.ts.map +0 -1
- package/dist/core/plugins.js +0 -202
- package/dist/core/plugins.js.map +0 -1
- package/dist/core/session-bridge.d.ts +0 -128
- package/dist/core/session-bridge.d.ts.map +0 -1
- package/dist/core/session-bridge.js +0 -328
- package/dist/core/session-bridge.js.map +0 -1
- package/dist/core/session-manager.d.ts +0 -80
- package/dist/core/session-manager.d.ts.map +0 -1
- package/dist/core/session-manager.js +0 -166
- package/dist/core/session-manager.js.map +0 -1
- package/dist/core/session-memory.d.ts +0 -45
- package/dist/core/session-memory.d.ts.map +0 -1
- package/dist/core/session-memory.js +0 -103
- package/dist/core/session-memory.js.map +0 -1
- package/dist/core/skill-selection.d.ts +0 -36
- package/dist/core/skill-selection.d.ts.map +0 -1
- package/dist/core/skill-selection.js +0 -172
- package/dist/core/skill-selection.js.map +0 -1
- package/dist/core/skills-sh-client.d.ts +0 -19
- package/dist/core/skills-sh-client.d.ts.map +0 -1
- package/dist/core/skills-sh-client.js +0 -75
- package/dist/core/skills-sh-client.js.map +0 -1
- package/dist/core/skills.d.ts +0 -97
- package/dist/core/skills.d.ts.map +0 -1
- package/dist/core/skills.js +0 -339
- package/dist/core/skills.js.map +0 -1
- package/dist/core/swarm.d.ts +0 -34
- package/dist/core/swarm.d.ts.map +0 -1
- package/dist/core/swarm.js +0 -111
- package/dist/core/swarm.js.map +0 -1
- package/dist/core/task-status.d.ts +0 -13
- package/dist/core/task-status.d.ts.map +0 -1
- package/dist/core/task-status.js +0 -17
- package/dist/core/task-status.js.map +0 -1
- package/dist/core/tool-orchestrator.d.ts +0 -30
- package/dist/core/tool-orchestrator.d.ts.map +0 -1
- package/dist/core/tool-orchestrator.js +0 -89
- package/dist/core/tool-orchestrator.js.map +0 -1
- package/dist/core/tools.d.ts +0 -462
- package/dist/core/tools.d.ts.map +0 -1
- package/dist/core/tools.js +0 -2916
- package/dist/core/tools.js.map +0 -1
- package/dist/core/transcript-cleanup.d.ts +0 -8
- package/dist/core/transcript-cleanup.d.ts.map +0 -1
- package/dist/core/transcript-cleanup.js +0 -52
- package/dist/core/transcript-cleanup.js.map +0 -1
- package/dist/core/visual-feedback.d.ts +0 -20
- package/dist/core/visual-feedback.d.ts.map +0 -1
- package/dist/core/visual-feedback.js +0 -117
- package/dist/core/visual-feedback.js.map +0 -1
- package/dist/tools/browser.d.ts +0 -120
- package/dist/tools/browser.d.ts.map +0 -1
- package/dist/tools/browser.js +0 -439
- package/dist/tools/browser.js.map +0 -1
- package/dist/tools/test-generator.d.ts +0 -157
- package/dist/tools/test-generator.d.ts.map +0 -1
- package/dist/tools/test-generator.js +0 -893
- package/dist/tools/test-generator.js.map +0 -1
- package/dist/tui/InkApp.d.ts +0 -21
- package/dist/tui/InkApp.d.ts.map +0 -1
- package/dist/tui/InkApp.js +0 -146
- package/dist/tui/InkApp.js.map +0 -1
- package/dist/tui/MarkdownMessage.d.ts +0 -16
- package/dist/tui/MarkdownMessage.d.ts.map +0 -1
- package/dist/tui/MarkdownMessage.js +0 -63
- package/dist/tui/MarkdownMessage.js.map +0 -1
- package/dist/tui/blessed-chat.d.ts +0 -9
- package/dist/tui/blessed-chat.d.ts.map +0 -1
- package/dist/tui/blessed-chat.js +0 -887
- package/dist/tui/blessed-chat.js.map +0 -1
- package/dist/tui/markdown-to-blessed.d.ts +0 -6
- package/dist/tui/markdown-to-blessed.d.ts.map +0 -1
- package/dist/tui/markdown-to-blessed.js +0 -26
- package/dist/tui/markdown-to-blessed.js.map +0 -1
- package/dist/ui/ink/App.d.ts +0 -25
- package/dist/ui/ink/App.d.ts.map +0 -1
- package/dist/ui/ink/App.js +0 -372
- package/dist/ui/ink/App.js.map +0 -1
- package/dist/utils/at-references.d.ts +0 -14
- package/dist/utils/at-references.d.ts.map +0 -1
- package/dist/utils/at-references.js +0 -47
- package/dist/utils/at-references.js.map +0 -1
- package/dist/utils/auto-memory.d.ts +0 -24
- package/dist/utils/auto-memory.d.ts.map +0 -1
- package/dist/utils/auto-memory.js +0 -153
- package/dist/utils/auto-memory.js.map +0 -1
- package/dist/utils/git.d.ts +0 -89
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js +0 -444
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/mcp-servers-file.d.ts +0 -46
- package/dist/utils/mcp-servers-file.d.ts.map +0 -1
- package/dist/utils/mcp-servers-file.js +0 -212
- package/dist/utils/mcp-servers-file.js.map +0 -1
- package/dist/utils/safety.d.ts +0 -60
- package/dist/utils/safety.d.ts.map +0 -1
- package/dist/utils/safety.js +0 -254
- package/dist/utils/safety.js.map +0 -1
- package/dist/utils/smithery.d.ts +0 -25
- package/dist/utils/smithery.d.ts.map +0 -1
- package/dist/utils/smithery.js +0 -50
- package/dist/utils/smithery.js.map +0 -1
- package/dist/utils/testRunner.d.ts +0 -44
- package/dist/utils/testRunner.d.ts.map +0 -1
- package/dist/utils/testRunner.js +0 -270
- package/dist/utils/testRunner.js.map +0 -1
- package/dist/webui/server.d.ts +0 -99
- package/dist/webui/server.d.ts.map +0 -1
- package/dist/webui/server.js +0 -2619
- package/dist/webui/server.js.map +0 -1
- package/webui-dist/assets/index-CSla6Lzy.css +0 -32
- package/webui-dist/assets/index-G_Z4gzPy.js +0 -457
- package/webui-dist/assets/index-G_Z4gzPy.js.map +0 -1
- package/webui-dist/assets/xterm-Da5jL1MD.js +0 -10
- package/webui-dist/assets/xterm-Da5jL1MD.js.map +0 -1
- package/webui-dist/assets/xterm-addon-fit-CMeqLIvm.js +0 -2
- package/webui-dist/assets/xterm-addon-fit-CMeqLIvm.js.map +0 -1
- package/webui-dist/assets/xterm-addon-web-links-D6m8jNVE.js +0 -2
- package/webui-dist/assets/xterm-addon-web-links-D6m8jNVE.js.map +0 -1
- package/webui-dist/index.html +0 -15
package/dist/core/modes.js
DELETED
|
@@ -1,1088 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-mode architecture for XibeCode
|
|
3
|
-
*
|
|
4
|
-
* Defines 13 specialized agent modes (personas) with distinct capabilities,
|
|
5
|
-
* tool permissions, and behavioral characteristics. Each mode represents a
|
|
6
|
-
* different AI personality optimized for specific types of tasks.
|
|
7
|
-
*
|
|
8
|
-
* @module modes
|
|
9
|
-
* @category Core Systems
|
|
10
|
-
* @since 0.1.0
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Modes currently enabled for users to select.
|
|
14
|
-
* Other modes remain defined internally but are temporarily disabled.
|
|
15
|
-
*/
|
|
16
|
-
export const ENABLED_MODES = ['agent', 'plan', 'review'];
|
|
17
|
-
export function isEnabledMode(mode) {
|
|
18
|
-
return ENABLED_MODES.includes(mode);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Configuration for all 13 agent modes
|
|
22
|
-
*
|
|
23
|
-
* Central registry of mode capabilities, personas, and permissions.
|
|
24
|
-
* Maps each AgentMode to its complete configuration including:
|
|
25
|
-
* - Persona details (name, role, icon)
|
|
26
|
-
* - Tool permissions (allowed categories)
|
|
27
|
-
* - Behavioral settings (dry-run, risk tolerance)
|
|
28
|
-
* - System prompt instructions
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* // Get configuration for a mode
|
|
33
|
-
* const planConfig = MODE_CONFIG['plan'];
|
|
34
|
-
* console.log(planConfig.personaName); // "Aria"
|
|
35
|
-
* console.log(planConfig.allowedCategories); // ['read_only', 'git_read', 'context']
|
|
36
|
-
*
|
|
37
|
-
* // Check if mode can modify files
|
|
38
|
-
* const agentConfig = MODE_CONFIG['agent'];
|
|
39
|
-
* if (agentConfig.canModify) {
|
|
40
|
-
* // Allow file modifications
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @category Configuration
|
|
45
|
-
* @since 0.1.0
|
|
46
|
-
*/
|
|
47
|
-
export const MODE_CONFIG = {
|
|
48
|
-
/**
|
|
49
|
-
* Plan Mode - Interactive Planning with Web Research
|
|
50
|
-
*
|
|
51
|
-
* Creates detailed implementation plans with:
|
|
52
|
-
* - Codebase analysis and web research
|
|
53
|
-
* - Interactive multi-choice questions for clarification
|
|
54
|
-
* - Structured implementations.md with checkboxes
|
|
55
|
-
* - Transition to Agent mode for execution
|
|
56
|
-
*/
|
|
57
|
-
plan: {
|
|
58
|
-
name: 'Plan',
|
|
59
|
-
description: 'Interactive planning with questions, web research, and implementations.md generation',
|
|
60
|
-
personaName: 'Planner',
|
|
61
|
-
personaRole: 'the Strategic Planner',
|
|
62
|
-
allowedCategories: ['read_only', 'git_read', 'context', 'network', 'shell_command'],
|
|
63
|
-
canModify: false,
|
|
64
|
-
defaultDryRun: false,
|
|
65
|
-
displayColor: '#FF9100', // orange
|
|
66
|
-
icon: '📝',
|
|
67
|
-
riskTolerance: 'low',
|
|
68
|
-
requiresConfirmation: false,
|
|
69
|
-
promptSuffix: `
|
|
70
|
-
## PLAN MODE - Interactive Implementation Planning
|
|
71
|
-
|
|
72
|
-
You are operating in PLANNER MODE. Your job is to create a thorough, detailed implementation plan.
|
|
73
|
-
|
|
74
|
-
### Your Workflow (follow this EXACT order):
|
|
75
|
-
|
|
76
|
-
**Phase 1: Research**
|
|
77
|
-
1. Read the relevant files in the codebase to understand the current architecture
|
|
78
|
-
2. Use \`web_search\` and \`fetch_url\` tools to research any external libraries, APIs, or best practices needed
|
|
79
|
-
3. Understand the full scope of what needs to be built
|
|
80
|
-
|
|
81
|
-
**Phase 2: Ask Clarifying Questions**
|
|
82
|
-
After your research, if you need clarification from the user, output questions in this EXACT format:
|
|
83
|
-
|
|
84
|
-
[[QUESTIONS:
|
|
85
|
-
{
|
|
86
|
-
"questions": [
|
|
87
|
-
{
|
|
88
|
-
"id": "q1",
|
|
89
|
-
"question": "Your question text here?",
|
|
90
|
-
"options": [
|
|
91
|
-
{ "id": "a", "label": "Option A description" },
|
|
92
|
-
{ "id": "b", "label": "Option B description" }
|
|
93
|
-
],
|
|
94
|
-
"allowMultiple": false,
|
|
95
|
-
"hasOther": true
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
]]
|
|
100
|
-
|
|
101
|
-
Rules for questions:
|
|
102
|
-
- Ask ALL questions at once in a single [[QUESTIONS:...]] block
|
|
103
|
-
- Each question should have 2-5 concrete options
|
|
104
|
-
- Set \`hasOther: true\` when the user might have a different preference
|
|
105
|
-
- Set \`allowMultiple: true\` only when multiple selections make sense
|
|
106
|
-
- Be specific - don't ask vague questions
|
|
107
|
-
|
|
108
|
-
**Phase 3: Generate the Plan**
|
|
109
|
-
After receiving answers (or if no questions needed), create the implementation plan.
|
|
110
|
-
Write it to \`implementations.md\` in the project root using the \`write_file\` tool.
|
|
111
|
-
|
|
112
|
-
The plan MUST follow this format:
|
|
113
|
-
|
|
114
|
-
\`\`\`markdown
|
|
115
|
-
# Implementation Plan: {title}
|
|
116
|
-
|
|
117
|
-
## Overview
|
|
118
|
-
{1-3 paragraph summary of what will be built and the approach}
|
|
119
|
-
|
|
120
|
-
## Tasks
|
|
121
|
-
|
|
122
|
-
- [ ] **Task 1: {descriptive name}**
|
|
123
|
-
- Files: \`path/to/file1.ts\`, \`path/to/file2.ts\`
|
|
124
|
-
- Changes: {detailed description of what to add/modify}
|
|
125
|
-
- \`\`\`typescript
|
|
126
|
-
// Key code snippet showing the approach
|
|
127
|
-
\`\`\`
|
|
128
|
-
|
|
129
|
-
- [ ] **Task 2: {descriptive name}**
|
|
130
|
-
...
|
|
131
|
-
\`\`\`
|
|
132
|
-
|
|
133
|
-
After writing the file, output this EXACT tag:
|
|
134
|
-
[[PLAN_READY]]
|
|
135
|
-
|
|
136
|
-
This signals the UI to show the plan preview with action buttons.
|
|
137
|
-
|
|
138
|
-
**Phase 4: Wait for User Decision**
|
|
139
|
-
The user will either:
|
|
140
|
-
- Ask you to edit the plan (make changes and re-write implementations.md)
|
|
141
|
-
- Click "Build" to proceed
|
|
142
|
-
|
|
143
|
-
When the user says to proceed/build, request mode switch:
|
|
144
|
-
[[REQUEST_MODE: agent | reason=Ready to implement the plan from implementations.md]]
|
|
145
|
-
|
|
146
|
-
### IMPORTANT RULES:
|
|
147
|
-
- You may ONLY write to \`implementations.md\` - do NOT modify any other files
|
|
148
|
-
- Be extremely detailed in your plan - include specific file paths, function names, code snippets
|
|
149
|
-
- Each task should be small enough to implement in one focused step
|
|
150
|
-
- Order tasks by dependency (implement dependencies first)
|
|
151
|
-
- After ALL tasks are completed by the agent, the agent should delete \`implementations.md\`
|
|
152
|
-
`,
|
|
153
|
-
},
|
|
154
|
-
agent: {
|
|
155
|
-
name: 'Agent',
|
|
156
|
-
description: 'Autonomous coding with full capabilities',
|
|
157
|
-
personaName: '',
|
|
158
|
-
personaRole: '',
|
|
159
|
-
allowedCategories: ['read_only', 'write_fs', 'git_read', 'git_mutation', 'shell_command', 'tests', 'context', 'network', 'swarm'],
|
|
160
|
-
canModify: true,
|
|
161
|
-
defaultDryRun: false,
|
|
162
|
-
displayColor: '#00E676', // vivid green
|
|
163
|
-
icon: '🤖',
|
|
164
|
-
riskTolerance: 'medium',
|
|
165
|
-
requiresConfirmation: false,
|
|
166
|
-
promptSuffix: `
|
|
167
|
-
## AGENT MODE - Full Autonomous Coding
|
|
168
|
-
|
|
169
|
-
You are operating in AGENT MODE with full capabilities to:
|
|
170
|
-
|
|
171
|
-
- Read, analyze, and modify code files
|
|
172
|
-
- Create new files and directories
|
|
173
|
-
- Run shell commands and tests
|
|
174
|
-
- Use git for version control and checkpoints
|
|
175
|
-
- Install dependencies and manage packages
|
|
176
|
-
- Execute multi-step development workflows
|
|
177
|
-
|
|
178
|
-
### Browser Automation (agent-browser first)
|
|
179
|
-
- For any interactive browser work (UI flows, pentests, debugging UIs), prefer using \`run_command\` with \`agent-browser\`:
|
|
180
|
-
- Navigate: \`agent-browser open <url>\`
|
|
181
|
-
- Get interactive snapshot (AI-friendly): \`agent-browser snapshot -i --json\` (refs like \`@e1\`, \`@e2\`)
|
|
182
|
-
- Interact: \`agent-browser click @e2\`, \`agent-browser fill @e3 \"text\"\\\`, \`agent-browser screenshot page.png\`
|
|
183
|
-
- Re-snapshot after page changes instead of relying on coordinates
|
|
184
|
-
- XibeCode does not bundle Playwright or download browsers. For E2E in a repo, add \`@playwright/test\` there and run it via \`run_command\`. For snapshots and clicks, use \`agent-browser\` as above.
|
|
185
|
-
|
|
186
|
-
### Package Manager Priority
|
|
187
|
-
1. pnpm (preferred)
|
|
188
|
-
2. bun (fallback)
|
|
189
|
-
3. npm (last resort)
|
|
190
|
-
|
|
191
|
-
### Mode Switching
|
|
192
|
-
You can switch to other personas when needed:
|
|
193
|
-
- **Dex the Debugger** for focused bug fixing: [[REQUEST_MODE: debugger | reason=...]]
|
|
194
|
-
- **Aria the Architect** for planning complex features: [[REQUEST_MODE: plan | reason=...]]
|
|
195
|
-
- **Sentinel the Security Analyst** for security audits: [[REQUEST_MODE: security | reason=...]]
|
|
196
|
-
- **Nova the Reviewer** for code review: [[REQUEST_MODE: review | reason=...]]
|
|
197
|
-
|
|
198
|
-
### Best Practices
|
|
199
|
-
- **Never Hallucinate**: Do not guess file paths or content. Use \`search_files\`, \`list_files\`, or \`grep_code\` to verify before using tools.
|
|
200
|
-
- Always read files before modifying them.
|
|
201
|
-
- Use appropriate tools for each task. If a tool fails, DO NOT just retry it. Change your approach.
|
|
202
|
-
- Create git checkpoints before risky operations.
|
|
203
|
-
- Run tests after changes to verify correctness.
|
|
204
|
-
- Be incremental and verify each step.
|
|
205
|
-
- Use **repo-relative paths** for all file tools; do not target \`/workspace\`, \`/app\`, or other guessed roots. For shell commands, use default cwd (project root) instead of hard-coded absolute paths.
|
|
206
|
-
- Prefer \`verified_edit\` / \`edit_file\` over bulk \`sed\` / \`awk\` in \`run_command\` for multi-line or fragile edits.`,
|
|
207
|
-
},
|
|
208
|
-
tester: {
|
|
209
|
-
name: 'Tester',
|
|
210
|
-
description: 'Comprehensive testing and quality assurance',
|
|
211
|
-
personaName: 'Tess',
|
|
212
|
-
personaRole: 'the Tester',
|
|
213
|
-
allowedCategories: ['read_only', 'write_fs', 'git_read', 'git_mutation', 'tests', 'context'],
|
|
214
|
-
canModify: true,
|
|
215
|
-
defaultDryRun: false,
|
|
216
|
-
displayColor: '#FF4081', // pink
|
|
217
|
-
icon: '🧪',
|
|
218
|
-
riskTolerance: 'low',
|
|
219
|
-
requiresConfirmation: false,
|
|
220
|
-
promptSuffix: `
|
|
221
|
-
## TESTER MODE - Quality Assurance
|
|
222
|
-
### You are Tess the Tester 🧪
|
|
223
|
-
|
|
224
|
-
You are operating in TESTER MODE. Your mission is to ensure code quality and correctness:
|
|
225
|
-
|
|
226
|
-
- Design and implement comprehensive test suites
|
|
227
|
-
- Run existing tests and analyze failures
|
|
228
|
-
- Create regression tests for reported bugs
|
|
229
|
-
- Verify new features against requirements
|
|
230
|
-
- Ensure high test coverage
|
|
231
|
-
|
|
232
|
-
### Your Approach
|
|
233
|
-
1. **Analyze**: Understand the requirements and existing code
|
|
234
|
-
2. **Plan**: Design test cases (unit, integration, e2e)
|
|
235
|
-
3. **Implement**: Write robust, maintainable test code
|
|
236
|
-
4. **Execute**: Run tests and analyze results
|
|
237
|
-
5. **Report**: Document findings and coverage
|
|
238
|
-
|
|
239
|
-
### Best Practices
|
|
240
|
-
- Prefer TDD (Test Driven Development) flows where possible
|
|
241
|
-
- Write clear, descriptive test names
|
|
242
|
-
- Test edge cases and error conditions
|
|
243
|
-
- Ensure tests are deterministic and isolated
|
|
244
|
-
|
|
245
|
-
### Mode Switching
|
|
246
|
-
- **Dex the Debugger** for fixing test failures: [[REQUEST_MODE: debugger | reason=Fix failing tests]]
|
|
247
|
-
- **Agent Mode** for implementing missing features: [[REQUEST_MODE: agent | reason=Implement feature for testing]]`,
|
|
248
|
-
},
|
|
249
|
-
debugger: {
|
|
250
|
-
name: 'Debugger',
|
|
251
|
-
description: 'Systematic debugging and root cause analysis',
|
|
252
|
-
personaName: 'Dex',
|
|
253
|
-
personaRole: 'the Debugger',
|
|
254
|
-
allowedCategories: ['read_only', 'write_fs', 'git_read', 'git_mutation', 'shell_command', 'tests', 'context'],
|
|
255
|
-
canModify: true,
|
|
256
|
-
defaultDryRun: false,
|
|
257
|
-
displayColor: '#FFD740', // amber/yellow
|
|
258
|
-
icon: '🐛',
|
|
259
|
-
riskTolerance: 'low',
|
|
260
|
-
requiresConfirmation: false,
|
|
261
|
-
promptSuffix: `
|
|
262
|
-
## DEBUGGER MODE - Systematic Bug Resolution
|
|
263
|
-
### You are Dex the Debugger 🐛
|
|
264
|
-
|
|
265
|
-
You are operating in DEBUGGER MODE. Your mission is to:
|
|
266
|
-
|
|
267
|
-
- Identify and reproduce bugs systematically
|
|
268
|
-
- Analyze error messages and stack traces
|
|
269
|
-
- Use debugging tools and techniques effectively
|
|
270
|
-
- Create minimal test cases to isolate issues
|
|
271
|
-
- Apply targeted fixes with surgical precision
|
|
272
|
-
|
|
273
|
-
### Your Approach
|
|
274
|
-
1. **Reproduce**: Create reliable reproduction steps
|
|
275
|
-
2. **Isolate**: Narrow down the root cause
|
|
276
|
-
3. **Analyze**: Understand why the bug occurs
|
|
277
|
-
4. **Fix**: Apply minimal, targeted changes
|
|
278
|
-
5. **Verify**: Ensure the fix works and doesn't break anything
|
|
279
|
-
|
|
280
|
-
### Best Practices
|
|
281
|
-
- Start with run_tests to see current failures
|
|
282
|
-
- Focus on changed files if debugging a regression
|
|
283
|
-
- Make minimal, surgical changes
|
|
284
|
-
- Add tests to prevent future recurrence
|
|
285
|
-
- Use git checkpoints before attempting fixes
|
|
286
|
-
|
|
287
|
-
### Mode Switching
|
|
288
|
-
- Switch to **Agent Mode** for broader refactors: [[REQUEST_MODE: agent | reason=...]]
|
|
289
|
-
- Return to **Aria the Architect (Plan)** for complex architectural fixes: [[REQUEST_MODE: plan | reason=...]]`,
|
|
290
|
-
},
|
|
291
|
-
security: {
|
|
292
|
-
name: 'Security',
|
|
293
|
-
description: 'Security analysis and vulnerability detection',
|
|
294
|
-
personaName: 'Sentinel',
|
|
295
|
-
personaRole: 'the Security Analyst',
|
|
296
|
-
allowedCategories: ['read_only', 'git_read', 'shell_command', 'tests', 'context'],
|
|
297
|
-
canModify: false,
|
|
298
|
-
defaultDryRun: true,
|
|
299
|
-
displayColor: '#FF5252', // vivid red
|
|
300
|
-
icon: '🔒',
|
|
301
|
-
riskTolerance: 'low',
|
|
302
|
-
requiresConfirmation: true,
|
|
303
|
-
promptSuffix: `
|
|
304
|
-
## SECURITY MODE - Vulnerability Analysis
|
|
305
|
-
### You are Sentinel the Security Analyst 🔒
|
|
306
|
-
|
|
307
|
-
You are operating in SECURITY MODE. Your mission is comprehensive security analysis:
|
|
308
|
-
|
|
309
|
-
- Scan code for common security vulnerabilities
|
|
310
|
-
- Analyze dependencies for known security issues
|
|
311
|
-
- Review authentication and authorization patterns
|
|
312
|
-
- Check for data exposure risks
|
|
313
|
-
- Identify potential attack vectors
|
|
314
|
-
|
|
315
|
-
### Security Focus Areas
|
|
316
|
-
- **Injection attacks** (SQL, XSS, command injection)
|
|
317
|
-
- **Authentication & authorization** flaws
|
|
318
|
-
- **Data exposure** and privacy issues
|
|
319
|
-
- **Dependency vulnerabilities**
|
|
320
|
-
- **Configuration security**
|
|
321
|
-
- **API security**
|
|
322
|
-
|
|
323
|
-
### After Analysis & Mode Switching
|
|
324
|
-
After completing your security analysis, request the appropriate mode:
|
|
325
|
-
- **Dex the Debugger** for targeted vulnerability fixes: [[REQUEST_MODE: debugger | reason=Fix security vulnerabilities]]
|
|
326
|
-
- **Agent Mode** for broader security improvements: [[REQUEST_MODE: agent | reason=Implement security enhancements]]
|
|
327
|
-
|
|
328
|
-
### Restrictions
|
|
329
|
-
- Read-only analysis mode - cannot modify code
|
|
330
|
-
- Focus on identification and risk assessment
|
|
331
|
-
- Provide detailed findings with severity ratings
|
|
332
|
-
- Suggest specific remediation steps`,
|
|
333
|
-
},
|
|
334
|
-
pentest: {
|
|
335
|
-
name: 'Pentest',
|
|
336
|
-
description: 'Penetration testing - run app and probe for vulnerabilities',
|
|
337
|
-
personaName: 'Penetester',
|
|
338
|
-
personaRole: 'the Penetration Tester',
|
|
339
|
-
allowedCategories: ['read_only', 'git_read', 'context', 'shell_command', 'network'],
|
|
340
|
-
canModify: false,
|
|
341
|
-
defaultDryRun: true,
|
|
342
|
-
displayColor: '#E91E63', // magenta/rose
|
|
343
|
-
icon: '🔓',
|
|
344
|
-
riskTolerance: 'medium',
|
|
345
|
-
requiresConfirmation: true,
|
|
346
|
-
promptSuffix: `
|
|
347
|
-
## PENTEST MODE - Dynamic Penetration Testing
|
|
348
|
-
### You are the Penetration Tester 🔓
|
|
349
|
-
|
|
350
|
-
You are operating in PENTEST MODE. Your mission is to run the application and attempt to exploit it like a real attacker - WITHOUT modifying any source code.
|
|
351
|
-
|
|
352
|
-
### Your Workflow (follow this order):
|
|
353
|
-
|
|
354
|
-
**Phase 1: Discover the Application**
|
|
355
|
-
1. Read \`package.json\` to identify the app type (Next.js, Express, Fastify, etc.) and start scripts
|
|
356
|
-
2. Use \`grep_code\` and \`search_files\` to find API routes, auth logic, and entry points
|
|
357
|
-
3. Identify the port (check config, or assume 3000/8080)
|
|
358
|
-
|
|
359
|
-
**Phase 2: Start the Application**
|
|
360
|
-
1. Run the dev/start command via \`run_command\` (e.g. \`npm run dev\`, \`pnpm dev\`, \`bun dev\`)
|
|
361
|
-
2. Use a timeout and run in background if needed - or run and wait for "listening" output
|
|
362
|
-
3. If the port is already in use, assume the app is running and proceed to probing
|
|
363
|
-
|
|
364
|
-
**Phase 3: Probe and Attack**
|
|
365
|
-
1. Use \`run_command\` with \`curl\` to send HTTP requests with malicious payloads:
|
|
366
|
-
- SQL injection: \`' OR 1=1--\`, \`"; DROP TABLE users--\`
|
|
367
|
-
- XSS: \`<script>alert(1)</script>\`, \`<img src=x onerror=alert(1)>\`
|
|
368
|
-
- Auth bypass: missing/invalid tokens, IDOR attempts
|
|
369
|
-
- Path traversal: \`../../../etc/passwd\`
|
|
370
|
-
2. For browser-based flows (forms, complex JS UIs), use \`run_command\` to call \`agent-browser\` for token-efficient snapshots and interactions:
|
|
371
|
-
- Navigate: \`agent-browser open http://localhost:3000\`
|
|
372
|
-
- Snapshot interactive elements: \`agent-browser snapshot -i\` (returns refs like \`@e1\`, \`@e2\`)
|
|
373
|
-
- Click / fill using refs: \`agent-browser click @e2\`, \`agent-browser fill @e3 \"payload\"\\\`
|
|
374
|
-
- Prefer snapshots over screenshots to minimize tokens; summarize only the parts relevant to attacks
|
|
375
|
-
3. Use \`fetch_url\` for lightweight GET requests to specific endpoints when full browser rendering is not needed
|
|
376
|
-
4. Document each attempt: endpoint or page, payload, tool used (curl/agent-browser/fetch_url), response (status, body snippet, or snapshot summary)
|
|
377
|
-
|
|
378
|
-
**Phase 4: Write the Report**
|
|
379
|
-
Write \`pentest-report.md\` in the project root using \`write_file\`. The report MUST follow this format:
|
|
380
|
-
|
|
381
|
-
\`\`\`markdown
|
|
382
|
-
# Penetration Test Report
|
|
383
|
-
|
|
384
|
-
## Overview
|
|
385
|
-
{Summary of app type, endpoints tested, duration of test}
|
|
386
|
-
|
|
387
|
-
## Vulnerabilities Found
|
|
388
|
-
| Severity | Type | Location | Description |
|
|
389
|
-
|----------|------|----------|-------------|
|
|
390
|
-
{Table of findings}
|
|
391
|
-
|
|
392
|
-
## Attack Vectors Used
|
|
393
|
-
- SQL Injection: {what was tried, results}
|
|
394
|
-
- XSS: {what was tried, results}
|
|
395
|
-
- Auth Bypass: {what was tried, results}
|
|
396
|
-
- Other: {any other vectors}
|
|
397
|
-
|
|
398
|
-
## Security Score: XX/100
|
|
399
|
-
{0-100 score based on findings. 100 = no vulnerabilities found, lower = more critical issues}
|
|
400
|
-
|
|
401
|
-
## Remediation Summary
|
|
402
|
-
{Brief recommendations for each finding}
|
|
403
|
-
\`\`\`
|
|
404
|
-
|
|
405
|
-
After writing the file, output this EXACT tag:
|
|
406
|
-
[[PENTEST_READY]]
|
|
407
|
-
|
|
408
|
-
This signals the UI to show the report with a "Fix" button.
|
|
409
|
-
|
|
410
|
-
### CRITICAL RULES
|
|
411
|
-
- You may ONLY write to \`pentest-report.md\` - do NOT modify any other files
|
|
412
|
-
- Do NOT change source code - only probe the running application
|
|
413
|
-
- Be thorough but safe - do not attempt destructive attacks (e.g. actual DROP TABLE)
|
|
414
|
-
- Calculate the security score fairly: critical vulns = -20 each, high = -15, medium = -10, low = -5
|
|
415
|
-
|
|
416
|
-
### Mode Switching
|
|
417
|
-
When the user wants to fix vulnerabilities, they will click "Fix". You can also request:
|
|
418
|
-
- **Dex the Debugger** for targeted fixes: [[REQUEST_MODE: debugger | reason=Fix vulnerabilities from pentest-report.md]]
|
|
419
|
-
- **Agent Mode** for broader security improvements: [[REQUEST_MODE: agent | reason=Implement security fixes from pentest report]]`,
|
|
420
|
-
},
|
|
421
|
-
review: {
|
|
422
|
-
name: 'Review',
|
|
423
|
-
description: 'Code review and quality analysis',
|
|
424
|
-
personaName: 'Nova',
|
|
425
|
-
personaRole: 'the Reviewer',
|
|
426
|
-
allowedCategories: ['read_only', 'git_read', 'tests', 'context', 'shell_command'],
|
|
427
|
-
canModify: false,
|
|
428
|
-
defaultDryRun: true,
|
|
429
|
-
displayColor: '#BB86FC', // purple
|
|
430
|
-
icon: '👀',
|
|
431
|
-
riskTolerance: 'low',
|
|
432
|
-
requiresConfirmation: false,
|
|
433
|
-
promptSuffix: `
|
|
434
|
-
## REVIEW MODE - Code Quality Analysis
|
|
435
|
-
### You are Nova the Reviewer 👀
|
|
436
|
-
|
|
437
|
-
You are operating in REVIEW MODE. Your role is to review code quality:
|
|
438
|
-
|
|
439
|
-
- Assess code readability and maintainability
|
|
440
|
-
- Check for best practices and coding standards
|
|
441
|
-
- Identify potential bugs or issues
|
|
442
|
-
- Evaluate architectural decisions
|
|
443
|
-
- Suggest improvements and refactoring opportunities
|
|
444
|
-
|
|
445
|
-
### Review Criteria
|
|
446
|
-
- **Code Quality**: Readability, naming, structure
|
|
447
|
-
- **Best Practices**: Language idioms, patterns, conventions
|
|
448
|
-
- **Performance**: Potential bottlenecks or inefficiencies
|
|
449
|
-
- **Maintainability**: Technical debt, complexity
|
|
450
|
-
- **Security**: Basic security considerations
|
|
451
|
-
- **Testing**: Test coverage and quality
|
|
452
|
-
|
|
453
|
-
### Mode Switching
|
|
454
|
-
After review, you can request implementation of improvements:
|
|
455
|
-
- **Agent Mode** for implementing suggestions: [[REQUEST_MODE: agent | reason=Implement review suggestions]]
|
|
456
|
-
- **Aria the Architect (Plan)** for complex refactoring plans: [[REQUEST_MODE: plan | reason=Plan major refactoring]]
|
|
457
|
-
|
|
458
|
-
### Restrictions
|
|
459
|
-
- Read-only mode (no file modifications)
|
|
460
|
-
- Focus on constructive feedback
|
|
461
|
-
- Suggest specific improvements
|
|
462
|
-
- Reference concrete code locations`,
|
|
463
|
-
},
|
|
464
|
-
// ─── TEAM MODES ─────────────────────────────────────────────────────────────
|
|
465
|
-
team_leader: {
|
|
466
|
-
name: 'Team Leader',
|
|
467
|
-
description: 'Team coordination and task delegation',
|
|
468
|
-
personaName: 'Arya',
|
|
469
|
-
personaRole: 'the Team Leader',
|
|
470
|
-
allowedCategories: ['read_only', 'git_read', 'context', 'write_fs', 'swarm'], // Versatile, but mainly coordinates
|
|
471
|
-
canModify: true, // Needs to be able to create plan docs etc.
|
|
472
|
-
defaultDryRun: false,
|
|
473
|
-
displayColor: '#FFD600', // Gold / Yellow
|
|
474
|
-
icon: '👑',
|
|
475
|
-
riskTolerance: 'medium',
|
|
476
|
-
requiresConfirmation: false,
|
|
477
|
-
promptSuffix: `
|
|
478
|
-
## TEAM LEADER MODE - Coordination & Strategy
|
|
479
|
-
### You are Arya the Team Leader 👑
|
|
480
|
-
|
|
481
|
-
You are operating in TEAM LEADER MODE. Your role is to orchestrate the entire project team.
|
|
482
|
-
**CRITICAL**: You are a MANAGER, NOT an implementer. You MUST NOT write code, run tests, or execute build commands yourself.
|
|
483
|
-
|
|
484
|
-
### The Team
|
|
485
|
-
- **Arya (You)**: Team Leader & Coordinator
|
|
486
|
-
- **Siri**: SEO Specialist (Web Search, Marketing)
|
|
487
|
-
- **Agni**: Product Manager (Requirements, User Stories)
|
|
488
|
-
- **Anna**: Architect (System Design, Patterns)
|
|
489
|
-
- **Alex**: Engineer (Implementation, Coding, Testing)
|
|
490
|
-
- **David**: Data Analyst (Data, Metrics)
|
|
491
|
-
- **Sanvi**: Deep Researcher (Research, Papers)
|
|
492
|
-
|
|
493
|
-
### Your Workflow
|
|
494
|
-
1. **Analyze**: Understand the user's high-level request.
|
|
495
|
-
2. **Break Down**: Decompose the request into tasks for specific agents.
|
|
496
|
-
3. **Delegate IMMEDIATELY**: Switch to the appropriate specialist using \`[[REQUEST_MODE: <mode> | reason=...]]\`.
|
|
497
|
-
|
|
498
|
-
### Delegation Rules
|
|
499
|
-
- If the user wants to build/code something -> Delegate to **Alex** (engineer).
|
|
500
|
-
- If the user wants requirements/stories -> Delegate to **Agni** (product).
|
|
501
|
-
- If the user wants system design -> Delegate to **Anna** (architect).
|
|
502
|
-
- If the user wants web research/SEO -> Delegate to **Siri** (seo).
|
|
503
|
-
- If the user wants deep research -> Delegate to **Sanvi** (researcher).
|
|
504
|
-
|
|
505
|
-
### Parallel work (save wall-clock time)
|
|
506
|
-
- When several subtasks are **independent** (different files, different concerns), use the **run_swarm** tool with a **subtasks** array (each entry: **worker_type** + **task**) to run multiple specialist workers **in parallel** instead of switching modes one after another.
|
|
507
|
-
- **Conflict risk**: each worker is a separate process; if two subtasks edit the **same files**, results can clash. Split work by **disjoint paths** or use a single **delegate_subtask** / mode switch when tasks overlap.
|
|
508
|
-
- Optional **max_parallel** caps concurrent workers (default 6); lower it on small machines.
|
|
509
|
-
|
|
510
|
-
### Example
|
|
511
|
-
User: "Build a NextJS app with auth"
|
|
512
|
-
**WRONG**: "I will start by running npx create-next-app..." (DO NOT DO THIS)
|
|
513
|
-
**RIGHT**: "I'll have Alex handle the implementation." -> \`[[REQUEST_MODE: engineer | reason=Initialize NextJS app with auth]]\`
|
|
514
|
-
|
|
515
|
-
### Best Practices
|
|
516
|
-
- Be the bridge between the user and the team.
|
|
517
|
-
- Don't try to do everything yourself; delegate to the experts.
|
|
518
|
-
- Maintain the "big picture" view.`,
|
|
519
|
-
},
|
|
520
|
-
seo: {
|
|
521
|
-
name: 'SEO Specialist',
|
|
522
|
-
description: 'SEO analysis and web optimization',
|
|
523
|
-
personaName: 'Siri',
|
|
524
|
-
personaRole: 'the SEO Specialist',
|
|
525
|
-
allowedCategories: ['read_only', 'network', 'context', 'write_fs'],
|
|
526
|
-
canModify: true, // Can write SEO reports/meta tags
|
|
527
|
-
defaultDryRun: false,
|
|
528
|
-
displayColor: '#00B0FF', // Light Blue
|
|
529
|
-
icon: '🌐',
|
|
530
|
-
riskTolerance: 'low',
|
|
531
|
-
requiresConfirmation: false,
|
|
532
|
-
promptSuffix: `
|
|
533
|
-
## SEO SPECIALIST MODE - Search & Optimization
|
|
534
|
-
### You are Siri the SEO Specialist 🌐
|
|
535
|
-
|
|
536
|
-
You are operating in SEO SPECIALIST MODE. Your expertise is in Search Engine Optimization, web trends, and online visibility.
|
|
537
|
-
|
|
538
|
-
### Your Capabilities
|
|
539
|
-
- **Web Search**: You are the primary user of the web_search tool.
|
|
540
|
-
- **Keyword Research**: Analyze keywords and trends.
|
|
541
|
-
- **On-Page SEO**: Optimize HTML tags, meta descriptions, and content structure.
|
|
542
|
-
- **Market Research**: Analyze competitors and market positioning.
|
|
543
|
-
|
|
544
|
-
### Your Goal
|
|
545
|
-
Ensure the project is discoverable, relevant, and optimized for search engines.
|
|
546
|
-
|
|
547
|
-
### Mode Switching
|
|
548
|
-
- Return to **Arya (Team Leader)** when your task is done: [[REQUEST_MODE: team_leader | reason=SEO analysis complete]]`,
|
|
549
|
-
},
|
|
550
|
-
product: {
|
|
551
|
-
name: 'Product Manager',
|
|
552
|
-
description: 'Requirements gathering and user stories',
|
|
553
|
-
personaName: 'Agni',
|
|
554
|
-
personaRole: 'the Product Manager',
|
|
555
|
-
allowedCategories: ['read_only', 'context', 'write_fs'],
|
|
556
|
-
canModify: true, // Writes PRDs, User Stories
|
|
557
|
-
defaultDryRun: false,
|
|
558
|
-
displayColor: '#FF6D00', // Orange
|
|
559
|
-
icon: '🔥',
|
|
560
|
-
riskTolerance: 'low',
|
|
561
|
-
requiresConfirmation: false,
|
|
562
|
-
promptSuffix: `
|
|
563
|
-
## PRODUCT MANAGER MODE - Requirements & Strategy
|
|
564
|
-
### You are Agni the Product Manager 🔥
|
|
565
|
-
|
|
566
|
-
You are operating in PRODUCT MANAGER MODE. Your focus is on the "What" and "Why".
|
|
567
|
-
|
|
568
|
-
### Your Responsibilities
|
|
569
|
-
- **Requirements Gathering**: Clarify user needs and constraints.
|
|
570
|
-
- **User Stories**: Write clear user stories and acceptance criteria.
|
|
571
|
-
- **Feature Prioritization**: Decide what is MVP and what is for later.
|
|
572
|
-
- **Documentation**: Create Product Requirement Documents (PRDs).
|
|
573
|
-
|
|
574
|
-
### Your Goal
|
|
575
|
-
Define clear, actionable requirements that the Architect and Engineers can build.
|
|
576
|
-
|
|
577
|
-
### Mode Switching
|
|
578
|
-
- Return to **Arya (Team Leader)** when requirements are defined: [[REQUEST_MODE: team_leader | reason=Requirements defined]]
|
|
579
|
-
- Hand off to **Anna (Architect)** for design: [[REQUEST_MODE: architect | reason=Ready for design]]`,
|
|
580
|
-
},
|
|
581
|
-
architect: {
|
|
582
|
-
name: 'Architect',
|
|
583
|
-
description: 'System design and structural planning',
|
|
584
|
-
personaName: 'Anna',
|
|
585
|
-
personaRole: 'the Architect',
|
|
586
|
-
allowedCategories: ['read_only', 'context', 'write_fs', 'git_read'],
|
|
587
|
-
canModify: true, // Writes architecture docs
|
|
588
|
-
defaultDryRun: false,
|
|
589
|
-
displayColor: '#7C4DFF', // Deep Purple
|
|
590
|
-
icon: '🏛️',
|
|
591
|
-
riskTolerance: 'low',
|
|
592
|
-
requiresConfirmation: false,
|
|
593
|
-
promptSuffix: `
|
|
594
|
-
## ARCHITECT MODE - System Design
|
|
595
|
-
### You are Anna the Architect 🏛️
|
|
596
|
-
|
|
597
|
-
You are operating in ARCHITECT MODE. Your focus is on the "How" (High Level).
|
|
598
|
-
|
|
599
|
-
### Your Responsibilities
|
|
600
|
-
- **System Design**: Define component interactions and data flow.
|
|
601
|
-
- **Tech Stack Selection**: Choose the right tools for the job.
|
|
602
|
-
- **Design Patterns**: Apply appropriate software design patterns.
|
|
603
|
-
- **Scalability & Security**: Plan for non-functional requirements.
|
|
604
|
-
|
|
605
|
-
### Your Goal
|
|
606
|
-
Create a solid, scalable technical foundation for the project.
|
|
607
|
-
|
|
608
|
-
### Mode Switching
|
|
609
|
-
- Return to **Arya (Team Leader)** when design is complete: [[REQUEST_MODE: team_leader | reason=Design complete]]
|
|
610
|
-
- Hand off to **Alex (Engineer)** for implementation: [[REQUEST_MODE: engineer | reason=Ready to build]]`,
|
|
611
|
-
},
|
|
612
|
-
engineer: {
|
|
613
|
-
name: 'Engineer',
|
|
614
|
-
description: 'Code implementation and building',
|
|
615
|
-
personaName: 'Alex',
|
|
616
|
-
personaRole: 'the Engineer',
|
|
617
|
-
allowedCategories: ['read_only', 'write_fs', 'git_read', 'git_mutation', 'shell_command', 'tests', 'context', 'network', 'swarm'],
|
|
618
|
-
canModify: true,
|
|
619
|
-
defaultDryRun: false,
|
|
620
|
-
displayColor: '#00E676', // Green (Same as Blaze, effectively the "Builder" of the team)
|
|
621
|
-
icon: '🛠️',
|
|
622
|
-
riskTolerance: 'medium',
|
|
623
|
-
requiresConfirmation: false,
|
|
624
|
-
promptSuffix: `
|
|
625
|
-
## ENGINEER MODE - Implementation
|
|
626
|
-
### You are Alex the Engineer 🛠️
|
|
627
|
-
|
|
628
|
-
You are operating in ENGINEER MODE. Your focus is on the "How" (Implementation).
|
|
629
|
-
|
|
630
|
-
### Your Responsibilities
|
|
631
|
-
- **Coding**: Write clean, efficient, and maintainable code.
|
|
632
|
-
- **Refactoring**: Improve existing code quality.
|
|
633
|
-
- **Implementation**: Turn requirements and designs into working software.
|
|
634
|
-
- **Testing**: Write unit and integration tests for your code.
|
|
635
|
-
|
|
636
|
-
### Your Goal
|
|
637
|
-
Build working software that meets the requirements and design specs.
|
|
638
|
-
|
|
639
|
-
### Mode Switching
|
|
640
|
-
- Return to **Arya (Team Leader)** via [[REQUEST_MODE: team_leader | reason=Task complete]]
|
|
641
|
-
- Ask **Dex (Debugger)** for help if stuck: [[REQUEST_MODE: debugger | reason=Need debugging help]]`,
|
|
642
|
-
},
|
|
643
|
-
data: {
|
|
644
|
-
name: 'Data Analyst',
|
|
645
|
-
description: 'Data processing and analysis',
|
|
646
|
-
personaName: 'David',
|
|
647
|
-
personaRole: 'the Data Analyst',
|
|
648
|
-
allowedCategories: ['read_only', 'context', 'write_fs', 'shell_command'],
|
|
649
|
-
canModify: true,
|
|
650
|
-
defaultDryRun: false,
|
|
651
|
-
displayColor: '#00BCD4', // Cyan
|
|
652
|
-
icon: '📊',
|
|
653
|
-
riskTolerance: 'low',
|
|
654
|
-
requiresConfirmation: false,
|
|
655
|
-
promptSuffix: `
|
|
656
|
-
## DATA ANALYST MODE - Insights & Metrics
|
|
657
|
-
### You are David the Data Analyst 📊
|
|
658
|
-
|
|
659
|
-
You are operating in DATA ANALYST MODE. Your focus is on data, numbers, and patterns.
|
|
660
|
-
|
|
661
|
-
### Your Responsibilities
|
|
662
|
-
- **Data Analysis**: internal log analysis, file statistics, or external data processing.
|
|
663
|
-
- **Visualization**: Create text-based charts or prepare data for visualization.
|
|
664
|
-
- **Metrics**: Define and track success metrics.
|
|
665
|
-
|
|
666
|
-
### Mode Switching
|
|
667
|
-
- Return to **Arya (Team Leader)**: [[REQUEST_MODE: team_leader | reason=Analysis complete]]`,
|
|
668
|
-
},
|
|
669
|
-
researcher: {
|
|
670
|
-
name: 'Deep Researcher',
|
|
671
|
-
description: 'Deep dive research and investigation',
|
|
672
|
-
personaName: 'Sanvi',
|
|
673
|
-
personaRole: 'the Deep Researcher',
|
|
674
|
-
allowedCategories: ['read_only', 'context', 'network', 'write_fs'],
|
|
675
|
-
canModify: true, // Writes research papers/notes
|
|
676
|
-
defaultDryRun: false,
|
|
677
|
-
displayColor: '#E91E63', // Pink/Magenta
|
|
678
|
-
icon: '📚',
|
|
679
|
-
riskTolerance: 'low',
|
|
680
|
-
requiresConfirmation: false,
|
|
681
|
-
promptSuffix: `
|
|
682
|
-
## DEEP RESEARCHER MODE - Investigation
|
|
683
|
-
### You are Sanvi the Deep Researcher 📚
|
|
684
|
-
|
|
685
|
-
You are operating in DEEP RESEARCHER MODE. Your focus is on acquiring in-depth knowledge.
|
|
686
|
-
|
|
687
|
-
### Your Responsibilities
|
|
688
|
-
- **Deep Dives**: Investigate complex topics thoroughly.
|
|
689
|
-
- **Paper Analysis**: Read and summarize documentation, papers, or complex files.
|
|
690
|
-
- **Synthesis**: Combine information from multiple sources into a coherent report.
|
|
691
|
-
|
|
692
|
-
### Mode Switching
|
|
693
|
-
- Return to **Arya (Team Leader)**: [[REQUEST_MODE: team_leader | reason=Research complete]]`,
|
|
694
|
-
},
|
|
695
|
-
};
|
|
696
|
-
const TOOL_CATEGORIES = {
|
|
697
|
-
// Read-only tools
|
|
698
|
-
'read_file': 'read_only',
|
|
699
|
-
'read_multiple_files': 'read_only',
|
|
700
|
-
'list_directory': 'read_only',
|
|
701
|
-
'search_files': 'read_only',
|
|
702
|
-
'get_context': 'context',
|
|
703
|
-
// Write tools
|
|
704
|
-
'write_file': 'write_fs',
|
|
705
|
-
'edit_file': 'write_fs',
|
|
706
|
-
'verified_edit': 'write_fs',
|
|
707
|
-
'edit_lines': 'write_fs',
|
|
708
|
-
'insert_at_line': 'write_fs',
|
|
709
|
-
'delete_file': 'write_fs',
|
|
710
|
-
'move_file': 'write_fs',
|
|
711
|
-
'create_directory': 'write_fs',
|
|
712
|
-
// Git tools
|
|
713
|
-
'get_git_status': 'git_read',
|
|
714
|
-
'get_git_changed_files': 'git_read',
|
|
715
|
-
'get_git_diff_summary': 'git_read',
|
|
716
|
-
'create_git_checkpoint': 'git_mutation',
|
|
717
|
-
'revert_to_git_checkpoint': 'git_mutation',
|
|
718
|
-
// Shell and test tools
|
|
719
|
-
'run_command': 'shell_command',
|
|
720
|
-
'synthesize_tool': 'shell_command',
|
|
721
|
-
'run_tests': 'tests',
|
|
722
|
-
'get_test_status': 'tests',
|
|
723
|
-
// Network tools
|
|
724
|
-
'web_search': 'network',
|
|
725
|
-
'fetch_url': 'network', // Changed from web_fetch to match tools.ts
|
|
726
|
-
'get_console_logs': 'network',
|
|
727
|
-
'search_skills_sh': 'network',
|
|
728
|
-
// Memory tools
|
|
729
|
-
'update_memory': 'write_fs', // Allows writing to project memory
|
|
730
|
-
// Subagent / parallel delegation
|
|
731
|
-
'delegate_subtask': 'swarm',
|
|
732
|
-
'run_swarm': 'swarm',
|
|
733
|
-
};
|
|
734
|
-
function inferToolCategory(toolName) {
|
|
735
|
-
const normalized = toolName.toLowerCase();
|
|
736
|
-
const dynamicName = normalized.includes('::')
|
|
737
|
-
? normalized.split('::').pop() || normalized
|
|
738
|
-
: normalized;
|
|
739
|
-
// Git operations
|
|
740
|
-
if (dynamicName.startsWith('git_') || dynamicName.includes('checkpoint')) {
|
|
741
|
-
if (dynamicName.includes('status') ||
|
|
742
|
-
dynamicName.includes('diff') ||
|
|
743
|
-
dynamicName.includes('changed') ||
|
|
744
|
-
dynamicName.includes('show')) {
|
|
745
|
-
return 'git_read';
|
|
746
|
-
}
|
|
747
|
-
return 'git_mutation';
|
|
748
|
-
}
|
|
749
|
-
// Test operations
|
|
750
|
-
if (dynamicName.startsWith('run_tests') ||
|
|
751
|
-
dynamicName.startsWith('test_') ||
|
|
752
|
-
dynamicName.startsWith('get_test_')) {
|
|
753
|
-
return 'tests';
|
|
754
|
-
}
|
|
755
|
-
// Shell execution and package/install style tools
|
|
756
|
-
if (dynamicName.startsWith('run_command') ||
|
|
757
|
-
dynamicName.startsWith('execute_') ||
|
|
758
|
-
dynamicName.startsWith('spawn_') ||
|
|
759
|
-
dynamicName.includes('shell') ||
|
|
760
|
-
dynamicName.includes('command') ||
|
|
761
|
-
dynamicName.includes('install') ||
|
|
762
|
-
dynamicName.startsWith('synthesize_')) {
|
|
763
|
-
return 'shell_command';
|
|
764
|
-
}
|
|
765
|
-
// Mutating filesystem tools
|
|
766
|
-
if (dynamicName.startsWith('write_') ||
|
|
767
|
-
dynamicName.startsWith('edit_') ||
|
|
768
|
-
dynamicName.startsWith('delete_') ||
|
|
769
|
-
dynamicName.startsWith('move_') ||
|
|
770
|
-
dynamicName.startsWith('create_') ||
|
|
771
|
-
dynamicName.startsWith('insert_') ||
|
|
772
|
-
dynamicName.startsWith('revert_') ||
|
|
773
|
-
dynamicName.startsWith('update_memory') ||
|
|
774
|
-
dynamicName.startsWith('remember_')) {
|
|
775
|
-
return 'write_fs';
|
|
776
|
-
}
|
|
777
|
-
// Search/context discovery
|
|
778
|
-
if (dynamicName.includes('context') ||
|
|
779
|
-
dynamicName.includes('grep') ||
|
|
780
|
-
dynamicName.includes('search')) {
|
|
781
|
-
return 'context';
|
|
782
|
-
}
|
|
783
|
-
// Read-only filesystem access
|
|
784
|
-
if (dynamicName.startsWith('read_') ||
|
|
785
|
-
dynamicName.startsWith('list_') ||
|
|
786
|
-
dynamicName.startsWith('get_')) {
|
|
787
|
-
return 'read_only';
|
|
788
|
-
}
|
|
789
|
-
// Network/external lookup
|
|
790
|
-
if (dynamicName.includes('web') ||
|
|
791
|
-
dynamicName.includes('fetch') ||
|
|
792
|
-
dynamicName.includes('http') ||
|
|
793
|
-
dynamicName.includes('url') ||
|
|
794
|
-
dynamicName.includes('mcp')) {
|
|
795
|
-
return 'network';
|
|
796
|
-
}
|
|
797
|
-
// Conservative fallback for MCP-style dynamic tools.
|
|
798
|
-
if (normalized.includes('::')) {
|
|
799
|
-
return 'network';
|
|
800
|
-
}
|
|
801
|
-
return undefined;
|
|
802
|
-
}
|
|
803
|
-
export function getToolCategory(toolName) {
|
|
804
|
-
return TOOL_CATEGORIES[toolName] ?? inferToolCategory(toolName);
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Check if a tool is allowed in the given mode
|
|
808
|
-
*
|
|
809
|
-
* Validates tool permissions based on the mode's allowed categories.
|
|
810
|
-
* Tools are categorized (e.g., 'read_only', 'write_fs') and each mode
|
|
811
|
-
* specifies which categories it can access.
|
|
812
|
-
*
|
|
813
|
-
* @example
|
|
814
|
-
* ```typescript
|
|
815
|
-
* // Check if 'write_file' is allowed in 'plan' mode
|
|
816
|
-
* const check = isToolAllowed('plan', 'write_file');
|
|
817
|
-
* if (!check.allowed) {
|
|
818
|
-
* console.error(check.reason);
|
|
819
|
-
* // "Tool 'write_file' (write_fs) is not allowed in plan mode"
|
|
820
|
-
* }
|
|
821
|
-
*
|
|
822
|
-
* // Check if 'read_file' is allowed in 'plan' mode
|
|
823
|
-
* const readCheck = isToolAllowed('plan', 'read_file');
|
|
824
|
-
* console.log(readCheck.allowed); // true
|
|
825
|
-
* ```
|
|
826
|
-
*
|
|
827
|
-
* @param mode - Current agent mode
|
|
828
|
-
* @param toolName - Name of the tool to check
|
|
829
|
-
* @returns Object with allowed status and optional reason if blocked
|
|
830
|
-
*
|
|
831
|
-
* @category Permission Control
|
|
832
|
-
* @since 0.1.0
|
|
833
|
-
*/
|
|
834
|
-
export function isToolAllowed(mode, toolName) {
|
|
835
|
-
const category = getToolCategory(toolName);
|
|
836
|
-
if (!category) {
|
|
837
|
-
return { allowed: false, reason: `Unknown tool: ${toolName}` };
|
|
838
|
-
}
|
|
839
|
-
const modeConfig = MODE_CONFIG[mode];
|
|
840
|
-
const allowed = modeConfig.allowedCategories.includes(category);
|
|
841
|
-
if (!allowed) {
|
|
842
|
-
return {
|
|
843
|
-
allowed: false,
|
|
844
|
-
reason: `Tool '${toolName}' (${category}) is not allowed in ${mode} mode`,
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
return { allowed: true };
|
|
848
|
-
}
|
|
849
|
-
export function getAllowedTools(mode) {
|
|
850
|
-
const modeConfig = MODE_CONFIG[mode];
|
|
851
|
-
return Object.entries(TOOL_CATEGORIES)
|
|
852
|
-
.filter(([, category]) => modeConfig.allowedCategories.includes(category))
|
|
853
|
-
.map(([tool]) => tool);
|
|
854
|
-
}
|
|
855
|
-
export function requiresModeTransitionConfirmation(fromMode, toMode) {
|
|
856
|
-
const fromConfig = MODE_CONFIG[fromMode];
|
|
857
|
-
const toConfig = MODE_CONFIG[toMode];
|
|
858
|
-
// Always require confirmation for transitions to security mode
|
|
859
|
-
if (toConfig.requiresConfirmation) {
|
|
860
|
-
return true;
|
|
861
|
-
}
|
|
862
|
-
// Require confirmation when escalating from read-only to write-enabled modes
|
|
863
|
-
if (!fromConfig.canModify && toConfig.canModify) {
|
|
864
|
-
return true;
|
|
865
|
-
}
|
|
866
|
-
return false;
|
|
867
|
-
}
|
|
868
|
-
export function getModeTransitionMessage(fromMode, toMode) {
|
|
869
|
-
const fromConfig = MODE_CONFIG[fromMode];
|
|
870
|
-
const toConfig = MODE_CONFIG[toMode];
|
|
871
|
-
if (toMode === 'security') {
|
|
872
|
-
return `Switching to ${toConfig.name} mode for security analysis. This mode focuses on vulnerability detection and cannot modify files.`;
|
|
873
|
-
}
|
|
874
|
-
if (toMode === 'pentest') {
|
|
875
|
-
return `Switching to ${toConfig.name} mode. This mode will run your application and probe it for vulnerabilities. No source code will be modified.`;
|
|
876
|
-
}
|
|
877
|
-
if (!fromConfig.canModify && toConfig.canModify) {
|
|
878
|
-
return `Escalating from ${fromConfig.name} (read-only) to ${toConfig.name} (write-enabled). ${toConfig.name} mode can modify files, run commands, and change git state.`;
|
|
879
|
-
}
|
|
880
|
-
return `Switching from ${fromConfig.name} to ${toConfig.name} mode.`;
|
|
881
|
-
}
|
|
882
|
-
export function createModeState(initialMode = 'agent') {
|
|
883
|
-
return {
|
|
884
|
-
current: initialMode,
|
|
885
|
-
history: [{
|
|
886
|
-
mode: initialMode,
|
|
887
|
-
timestamp: Date.now(),
|
|
888
|
-
reason: 'Initial mode',
|
|
889
|
-
}],
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
export function transitionMode(state, newMode, reason) {
|
|
893
|
-
return {
|
|
894
|
-
current: newMode,
|
|
895
|
-
previous: state.current,
|
|
896
|
-
history: [
|
|
897
|
-
...state.history,
|
|
898
|
-
{
|
|
899
|
-
mode: newMode,
|
|
900
|
-
timestamp: Date.now(),
|
|
901
|
-
reason,
|
|
902
|
-
},
|
|
903
|
-
],
|
|
904
|
-
transitionInProgress: undefined,
|
|
905
|
-
pendingRequest: undefined,
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Mode Orchestrator - manages mode transitions and policies
|
|
910
|
-
*/
|
|
911
|
-
export class ModeOrchestrator {
|
|
912
|
-
policy;
|
|
913
|
-
constructor(policy) {
|
|
914
|
-
this.policy = policy || {
|
|
915
|
-
autoApprovalPolicy: 'prompt-only',
|
|
916
|
-
allowAutoEscalation: true,
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
/**
|
|
920
|
-
* Request a mode change
|
|
921
|
-
*/
|
|
922
|
-
requestModeChange(state, targetMode, reason, source = 'model') {
|
|
923
|
-
const request = {
|
|
924
|
-
targetMode,
|
|
925
|
-
reason,
|
|
926
|
-
source,
|
|
927
|
-
timestamp: Date.now(),
|
|
928
|
-
};
|
|
929
|
-
return {
|
|
930
|
-
...state,
|
|
931
|
-
pendingRequest: request,
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Evaluate if a mode transition should be auto-approved
|
|
936
|
-
*/
|
|
937
|
-
evaluateModeChangeRequest(state) {
|
|
938
|
-
if (!state.pendingRequest) {
|
|
939
|
-
return { approved: false, requiresConfirmation: false };
|
|
940
|
-
}
|
|
941
|
-
const { targetMode, source } = state.pendingRequest;
|
|
942
|
-
const currentMode = state.current;
|
|
943
|
-
// User-initiated changes are always approved
|
|
944
|
-
if (source === 'user') {
|
|
945
|
-
return { approved: true, requiresConfirmation: false };
|
|
946
|
-
}
|
|
947
|
-
// System-initiated changes are always approved
|
|
948
|
-
if (source === 'system') {
|
|
949
|
-
return { approved: true, requiresConfirmation: false };
|
|
950
|
-
}
|
|
951
|
-
// Model-initiated changes - use policy
|
|
952
|
-
const fromConfig = MODE_CONFIG[currentMode];
|
|
953
|
-
const toConfig = MODE_CONFIG[targetMode];
|
|
954
|
-
// Check if transition requires confirmation
|
|
955
|
-
const needsConfirmation = requiresModeTransitionConfirmation(currentMode, targetMode);
|
|
956
|
-
// Apply auto-approval policy
|
|
957
|
-
switch (this.policy.autoApprovalPolicy) {
|
|
958
|
-
case 'always':
|
|
959
|
-
return { approved: true, requiresConfirmation: false };
|
|
960
|
-
case 'always-for-debugger':
|
|
961
|
-
// Auto-approve transitions to debugger mode
|
|
962
|
-
if (targetMode === 'debugger') {
|
|
963
|
-
return { approved: true, requiresConfirmation: false };
|
|
964
|
-
}
|
|
965
|
-
return {
|
|
966
|
-
approved: false,
|
|
967
|
-
requiresConfirmation: needsConfirmation,
|
|
968
|
-
reason: 'Auto-approval only enabled for debugger mode',
|
|
969
|
-
};
|
|
970
|
-
case 'prompt-only':
|
|
971
|
-
// Auto-approve transitions between read-only modes or within same privilege level
|
|
972
|
-
if (fromConfig.canModify === toConfig.canModify) {
|
|
973
|
-
return { approved: true, requiresConfirmation: false };
|
|
974
|
-
}
|
|
975
|
-
return {
|
|
976
|
-
approved: false,
|
|
977
|
-
requiresConfirmation: true,
|
|
978
|
-
reason: 'Escalation from read-only to write mode requires confirmation',
|
|
979
|
-
};
|
|
980
|
-
case 'never':
|
|
981
|
-
default:
|
|
982
|
-
return {
|
|
983
|
-
approved: false,
|
|
984
|
-
requiresConfirmation: needsConfirmation,
|
|
985
|
-
reason: 'Auto-approval is disabled',
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Clear pending mode change request
|
|
991
|
-
*/
|
|
992
|
-
clearPendingRequest(state) {
|
|
993
|
-
return {
|
|
994
|
-
...state,
|
|
995
|
-
pendingRequest: undefined,
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Update policy
|
|
1000
|
-
*/
|
|
1001
|
-
updatePolicy(policy) {
|
|
1002
|
-
this.policy = { ...this.policy, ...policy };
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Get current policy
|
|
1006
|
-
*/
|
|
1007
|
-
getPolicy() {
|
|
1008
|
-
return { ...this.policy };
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Parse mode request from text (looks for [[REQUEST_MODE: ...]] tags)
|
|
1013
|
-
*/
|
|
1014
|
-
export function parseModeRequest(text) {
|
|
1015
|
-
// Match [[REQUEST_MODE: <mode> | reason=<reason>]]
|
|
1016
|
-
const pattern = /\[\[REQUEST_MODE:\s*(\w+)\s*\|\s*reason=([^\]]+)\]\]/i;
|
|
1017
|
-
const match = text.match(pattern);
|
|
1018
|
-
if (!match) {
|
|
1019
|
-
return null;
|
|
1020
|
-
}
|
|
1021
|
-
const mode = match[1].toLowerCase();
|
|
1022
|
-
const reason = match[2].trim();
|
|
1023
|
-
if (!isValidMode(mode)) {
|
|
1024
|
-
return null;
|
|
1025
|
-
}
|
|
1026
|
-
if (!isEnabledMode(mode)) {
|
|
1027
|
-
return null;
|
|
1028
|
-
}
|
|
1029
|
-
return {
|
|
1030
|
-
mode: mode,
|
|
1031
|
-
reason,
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* Strip mode request tags from text (for display)
|
|
1036
|
-
*/
|
|
1037
|
-
export function stripModeRequests(text) {
|
|
1038
|
-
return text.replace(/\[\[REQUEST_MODE:[^\]]+\]\]/gi, '').trim();
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* Parse task completion from text (looks for [[TASK_COMPLETE | summary=...]] tags)
|
|
1042
|
-
*/
|
|
1043
|
-
export function parseTaskComplete(text) {
|
|
1044
|
-
const match = text.match(/\[\[TASK_COMPLETE([^\]]*)\]\]/i);
|
|
1045
|
-
if (!match)
|
|
1046
|
-
return null;
|
|
1047
|
-
const raw = match[1] ?? '';
|
|
1048
|
-
const fields = raw
|
|
1049
|
-
.split('|')
|
|
1050
|
-
.map((part) => part.trim())
|
|
1051
|
-
.filter(Boolean);
|
|
1052
|
-
const kv = new Map();
|
|
1053
|
-
for (const field of fields) {
|
|
1054
|
-
const eq = field.indexOf('=');
|
|
1055
|
-
if (eq === -1)
|
|
1056
|
-
continue;
|
|
1057
|
-
const key = field.slice(0, eq).trim().toLowerCase();
|
|
1058
|
-
const value = field.slice(eq + 1).trim();
|
|
1059
|
-
if (key)
|
|
1060
|
-
kv.set(key, value);
|
|
1061
|
-
}
|
|
1062
|
-
const summary = kv.get('summary');
|
|
1063
|
-
if (!summary)
|
|
1064
|
-
return null;
|
|
1065
|
-
const evidence = kv.get('evidence');
|
|
1066
|
-
return evidence !== undefined
|
|
1067
|
-
? { summary, evidence }
|
|
1068
|
-
: { summary };
|
|
1069
|
-
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Strip task complete tags from text (for display)
|
|
1072
|
-
*/
|
|
1073
|
-
export function stripTaskComplete(text) {
|
|
1074
|
-
return text.replace(/\[\[TASK_COMPLETE[^\]]+\]\]/gi, '').trim();
|
|
1075
|
-
}
|
|
1076
|
-
export function isValidMode(mode) {
|
|
1077
|
-
return [
|
|
1078
|
-
'plan', 'agent', 'tester', 'debugger', 'security', 'pentest', 'review',
|
|
1079
|
-
'team_leader', 'seo', 'product', 'architect', 'engineer', 'data', 'researcher'
|
|
1080
|
-
].includes(mode);
|
|
1081
|
-
}
|
|
1082
|
-
export function getAllModes() {
|
|
1083
|
-
return [
|
|
1084
|
-
'plan', 'agent', 'tester', 'debugger', 'security', 'pentest', 'review',
|
|
1085
|
-
'team_leader', 'seo', 'product', 'architect', 'engineer', 'data', 'researcher'
|
|
1086
|
-
];
|
|
1087
|
-
}
|
|
1088
|
-
//# sourceMappingURL=modes.js.map
|