zenox 1.4.1 → 1.4.2

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/index.js CHANGED
@@ -823,6 +823,41 @@ The system automatically reminds you if you go idle with incomplete tasks.
823
823
  - The session goes idle
824
824
  - There's been sufficient time since the last reminder
825
825
  `;
826
+ function getOrchestrationPrompt(agent) {
827
+ switch (agent) {
828
+ case "build":
829
+ return ORCHESTRATION_PROMPT;
830
+ case "plan":
831
+ return ORCHESTRATION_PROMPT;
832
+ default:
833
+ return;
834
+ }
835
+ }
836
+
837
+ // src/orchestration/session-agent-tracker.ts
838
+ var sessionAgentMap = new Map;
839
+ function setSessionAgent(sessionID, agent) {
840
+ if (agent) {
841
+ sessionAgentMap.set(sessionID, agent);
842
+ }
843
+ }
844
+ function getSessionAgent(sessionID) {
845
+ return sessionAgentMap.get(sessionID);
846
+ }
847
+ function clearSessionAgent(sessionID) {
848
+ if (sessionID) {
849
+ sessionAgentMap.delete(sessionID);
850
+ }
851
+ }
852
+ function getOrchestrationAgentType(agent) {
853
+ if (agent === "build")
854
+ return "build";
855
+ if (agent === "plan")
856
+ return "plan";
857
+ if (agent === undefined)
858
+ return;
859
+ return agent;
860
+ }
826
861
 
827
862
  // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
828
863
  var exports_external = {};
@@ -18314,6 +18349,7 @@ var ZenoxPlugin = async (ctx) => {
18314
18349
  ...codeIntelligenceTools
18315
18350
  },
18316
18351
  "chat.message": async (input, output) => {
18352
+ setSessionAgent(input.sessionID, input.agent);
18317
18353
  const message = output.message;
18318
18354
  if (firstMessageVariantGate.shouldOverride(input.sessionID)) {
18319
18355
  const variant = resolveAgentVariant(pluginConfig, input.agent);
@@ -18326,6 +18362,17 @@ var ZenoxPlugin = async (ctx) => {
18326
18362
  }
18327
18363
  await keywordDetectorHook["chat.message"]?.(input, output);
18328
18364
  },
18365
+ "experimental.chat.system.transform": async (input, output) => {
18366
+ const { sessionID } = input;
18367
+ if (!sessionID)
18368
+ return;
18369
+ const agent = getSessionAgent(sessionID);
18370
+ const agentType = getOrchestrationAgentType(agent);
18371
+ const prompt = getOrchestrationPrompt(agentType);
18372
+ if (prompt) {
18373
+ output.system.push(prompt);
18374
+ }
18375
+ },
18329
18376
  event: async (input) => {
18330
18377
  const { event } = input;
18331
18378
  await autoUpdateHook.event(input);
@@ -18341,6 +18388,7 @@ var ZenoxPlugin = async (ctx) => {
18341
18388
  const props = event.properties;
18342
18389
  const sessionID = props?.info?.id;
18343
18390
  firstMessageVariantGate.clear(sessionID);
18391
+ clearSessionAgent(sessionID);
18344
18392
  if (sessionID && sessionID === backgroundManager.getMainSession()) {
18345
18393
  backgroundManager.setMainSession(undefined);
18346
18394
  }
@@ -18392,14 +18440,6 @@ var ZenoxPlugin = async (ctx) => {
18392
18440
  if (!disabledAgents.has("ui-planner")) {
18393
18441
  config2.agent["ui-planner"] = applyModelOverride("ui-planner", uiPlannerAgent);
18394
18442
  }
18395
- if (config2.agent.build) {
18396
- const existingPrompt = config2.agent.build.prompt ?? "";
18397
- config2.agent.build.prompt = existingPrompt + ORCHESTRATION_PROMPT;
18398
- }
18399
- if (config2.agent.plan) {
18400
- const existingPrompt = config2.agent.plan.prompt ?? "";
18401
- config2.agent.plan.prompt = existingPrompt + ORCHESTRATION_PROMPT;
18402
- }
18403
18443
  const builtinMcps = createBuiltinMcps(disabledMcps);
18404
18444
  config2.mcp = {
18405
18445
  ...config2.mcp,
@@ -3,3 +3,4 @@
3
3
  * This teaches the primary agents how to delegate to specialized subagents using the Task tool.
4
4
  */
5
5
  export declare const ORCHESTRATION_PROMPT = "\n\n---\n\n## Sub-Agent Delegation\n\nYou have specialized subagents. Use the **Task tool** to delegate work proactively.\n\n### Available Agents\n\n| Agent | Use For | subagent_type |\n|-------|---------|---------------|\n| **Explorer** | Codebase grep - fast pattern matching, \"Where is X?\" | `explorer` |\n| **Librarian** | External grep - docs, GitHub, OSS examples | `librarian` |\n| **Oracle** | Strategic advisor - architecture, debugging, decisions | `oracle` |\n| **UI Planner** | Designer-developer - visual design, CSS, animations | `ui-planner` |\n\n### Quick Rule: Background vs Synchronous\n\n| Agent | Default Execution | Why |\n|-------|-------------------|-----|\n| Explorer | `background_task` | It's codebase grep - fire and continue |\n| Librarian | `background_task` | It's external grep - fire and continue |\n| Oracle | `Task` (sync) | Need strategic answer before proceeding |\n| UI Planner | `Task` (sync) | Implements changes, needs write access |\n\n**Mental Model**: Explorer & Librarian = **grep commands**. You don't wait for grep, you fire it and continue thinking.\n\n### When to Delegate (Fire Immediately)\n\n| Trigger | subagent_type | Why |\n|---------|---------------|-----|\n| \"Where is X?\", \"Find Y\", locate code | `explorer` | Fast codebase search |\n| External library, \"how does X library work?\" | `librarian` | Searches docs, GitHub, OSS |\n| 2+ modules involved, cross-cutting concerns | `explorer` | Multi-file pattern discovery |\n| Architecture decision, \"should I use X or Y?\" | `oracle` | Deep reasoning advisor |\n| Visual/styling, CSS, animations, UI/UX | `ui-planner` | Designer-developer hybrid |\n| After 2+ failed fix attempts | `oracle` | Debugging escalation |\n\n### How to Delegate\n\nUse the Task tool with these parameters:\n\n```\nTask(\n subagent_type: \"explorer\" | \"librarian\" | \"oracle\" | \"ui-planner\",\n description: \"Short 3-5 word task description\",\n prompt: \"Detailed instructions for the agent\"\n)\n```\n\n**Example delegations:**\n\n```\n// Find code in codebase\nTask(\n subagent_type: \"explorer\",\n description: \"Find auth middleware\",\n prompt: \"Find all authentication middleware implementations in this codebase. Return file paths and explain the auth flow.\"\n)\n\n// Research external library\nTask(\n subagent_type: \"librarian\",\n description: \"React Query caching docs\",\n prompt: \"How does React Query handle caching? Find official documentation and real-world examples with GitHub permalinks.\"\n)\n\n// Architecture decision\nTask(\n subagent_type: \"oracle\",\n description: \"Redux vs Zustand analysis\",\n prompt: \"Analyze trade-offs between Redux and Zustand for this project. Consider bundle size, learning curve, and our existing patterns.\"\n)\n\n// UI/Visual work\nTask(\n subagent_type: \"ui-planner\",\n description: \"Redesign dashboard cards\",\n prompt: \"Redesign the dashboard stat cards to be more visually appealing. Use modern aesthetics, subtle animations, and ensure responsive design.\"\n)\n```\n\n### Parallel Execution\n\nTo run multiple agents in parallel, call multiple Task tools in the **same response message**:\n\n```\n// CORRECT: Multiple Task calls in ONE message = parallel execution\nTask(subagent_type: \"explorer\", description: \"Find auth code\", prompt: \"...\")\nTask(subagent_type: \"librarian\", description: \"JWT best practices\", prompt: \"...\")\n// Both run simultaneously\n\n// WRONG: One Task per message = sequential (slow)\nMessage 1: Task(...) \u2192 wait for result\nMessage 2: Task(...) \u2192 wait for result\n```\n\n### Delegation Priority\n\n1. **Explorer FIRST** \u2014 Always locate code before modifying unfamiliar areas\n2. **Librarian** \u2014 When dealing with external libraries/APIs you don't fully understand\n3. **Oracle** \u2014 For complex decisions or after 2+ failed fix attempts\n4. **UI Planner** \u2014 For ANY visual/styling work (never edit CSS/UI yourself)\n\n### Critical Rules\n\n1. **Never touch frontend visual/styling code yourself** \u2014 Always delegate to `ui-planner`\n2. **Fire librarian proactively** when unfamiliar libraries are involved\n3. **Consult oracle BEFORE major architectural decisions**, not after\n4. **Verify delegated work** before marking task complete\n\n### When to Handle Directly (Don't Delegate)\n\n- Single file edits with known location\n- Questions answerable from code already in context\n- Trivial changes requiring no specialist knowledge\n- Tasks you can complete faster than explaining to an agent\n\n---\n\n## Background Tasks (Parallel Research)\n\nFor **independent research tasks** that benefit from parallelism, use background tasks instead of sequential Task calls.\n\n### When to Use Background Tasks\n\n| Scenario | Use Background Tasks |\n|----------|---------------------|\n| User wants \"comprehensive\" / \"thorough\" / \"deep\" exploration | YES - fire 3-4 agents in parallel |\n| Need BOTH codebase search AND external docs | YES - explore + librarian in parallel |\n| Exploring multiple modules/features simultaneously | YES - separate explore for each |\n| Result of Task A needed before Task B | NO - use sequential Task |\n| Single focused lookup | NO - just use Task directly |\n\n### How Background Tasks Work\n\n1. **Fire**: Launch multiple agents with `background_task` - they run in parallel\n2. **Continue**: Keep working while background agents search\n3. **Notify**: You'll be notified when ALL background tasks complete\n4. **Retrieve**: Use `background_output` to get each result\n\n### Usage\n\n```\n// Launch parallel research (all run simultaneously)\nbackground_task(agent=\"explorer\", description=\"Find auth code\", prompt=\"Search for authentication...\")\nbackground_task(agent=\"explorer\", description=\"Find db layer\", prompt=\"Search for database/ORM...\")\nbackground_task(agent=\"librarian\", description=\"Best practices\", prompt=\"Find framework best practices...\")\n\n// Continue working on other things while they run...\n\n// [NOTIFICATION: All background tasks complete!]\n\n// Retrieve results\nbackground_output(task_id=\"bg_abc123\")\nbackground_output(task_id=\"bg_def456\")\nbackground_output(task_id=\"bg_ghi789\")\n```\n\n### Background Tasks vs Task Tool\n\n| Aspect | Task Tool | Background Tasks |\n|--------|-----------|------------------|\n| Execution | Sequential (waits for result) | Parallel (fire-and-forget) |\n| Best for | Dependent tasks, immediate needs | Independent research, breadth |\n| Result | Inline, immediate | Retrieved later via background_output |\n\n### Key Insight\n\n- **Task** = Use when you need the result immediately before proceeding\n- **Background** = Use when researching multiple angles independently\n\n**Both tools coexist - choose based on whether tasks are dependent or independent.**\n\n### The Parallel Research Pattern\n\nFor complex tasks, fire research first, then continue working:\n\n```\n// 1. FIRE parallel research (don't wait!)\nbackground_task(agent=\"explorer\", description=\"Find existing patterns\", prompt=\"...\")\nbackground_task(agent=\"librarian\", description=\"Find best practices\", prompt=\"...\")\n\n// 2. CONTINUE productive work while they run:\n// - Plan your implementation approach\n// - Read files you already know about\n// - Identify edge cases and questions\n\n// 3. When notified \u2192 RETRIEVE and synthesize\nbackground_output(task_id=\"bg_xxx\")\nbackground_output(task_id=\"bg_yyy\")\n```\n\n**Anti-pattern**: Firing background tasks then doing nothing. Always continue productive work!\n\n---\n\n## Keyword Triggers (Power User)\n\nInclude these keywords in your prompt to unlock special modes:\n\n| Keyword | Effect |\n|---------|--------|\n| `ultrawork` or `ulw` | Maximum multi-agent coordination - aggressive parallel research |\n| `deep research` | Comprehensive exploration - fires 3-4 background agents |\n| `explore codebase` | Codebase mapping - multiple explorers in parallel |\n\n---\n\n## Session History Tools\n\nYou have tools to learn from past work sessions:\n\n| Tool | Use For |\n|------|---------|\n| `session_list` | List recent sessions to find relevant past work |\n| `session_search` | Search messages across sessions for how something was done |\n\n### When to Use Session Tools\n\n- **Before implementing unfamiliar features** \u2014 search if done before\n- **When user says \"like before\" or \"last time\"** \u2014 find that session\n- **When debugging** \u2014 check if similar issues were solved previously\n- **For context on ongoing projects** \u2014 understand recent work history\n\n### Example Usage\n\n```\n// Find how authentication was implemented before\nsession_search({ query: \"JWT authentication\" })\n\n// List recent sessions to understand project context\nsession_list({ limit: 5 })\n\n// Find past implementations of a feature\nsession_search({ query: \"rate limiting\" })\n```\n\n---\n\n## Code Intelligence Tools\n\nYou have tools to understand code structure via LSP:\n\n| Tool | Use For |\n|------|---------|\n| `find_symbols` | Search for functions, classes, variables by name |\n| `lsp_status` | Check which language servers are running |\n\n### When to Use Code Intelligence\n\n- **Before editing code** \u2014 find the symbol's definition location\n- **When refactoring** \u2014 search for related symbols\n- **To understand project structure** \u2014 search for key symbols like \"auth\", \"user\", \"api\"\n- **To verify LSP availability** \u2014 check if code intelligence is working\n\n### Example Usage\n\n```\n// Find all auth-related functions/classes\nfind_symbols({ query: \"auth\" })\n\n// Find a specific function\nfind_symbols({ query: \"handleLogin\" })\n\n// Check LSP server status\nlsp_status()\n```\n\n---\n\n## Todo Continuation\n\nThe system automatically reminds you if you go idle with incomplete tasks.\n\n**Best Practices:**\n- Keep your todo list updated with `TodoWrite`\n- Mark tasks complete immediately when finished\n- Use clear, actionable task descriptions\n- The system will prompt you to continue if tasks remain incomplete\n\n**Note:** You don't need to invoke the todo enforcer \u2014 it runs automatically when:\n- You have pending or in-progress todos\n- The session goes idle\n- There's been sufficient time since the last reminder\n";
6
+ export declare function getOrchestrationPrompt(agent: "build" | "plan" | string | undefined): string | undefined;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Session-Agent Tracker
3
+ *
4
+ * Tracks which agent is active for each session, allowing the system transform
5
+ * hook to inject agent-specific prompts.
6
+ *
7
+ * Flow:
8
+ * 1. chat.message hook fires with { sessionID, agent }
9
+ * 2. We store the mapping: sessionID -> agentName
10
+ * 3. experimental.chat.system.transform fires with { sessionID }
11
+ * 4. We look up the agent and inject the appropriate prompt
12
+ */
13
+ /**
14
+ * Record which agent is active for a session.
15
+ * Called from chat.message hook.
16
+ */
17
+ export declare function setSessionAgent(sessionID: string, agent: string | undefined): void;
18
+ /**
19
+ * Get the active agent for a session.
20
+ * Called from experimental.chat.system.transform hook.
21
+ */
22
+ export declare function getSessionAgent(sessionID: string): string | undefined;
23
+ /**
24
+ * Clear tracking for a session (on deletion).
25
+ */
26
+ export declare function clearSessionAgent(sessionID: string | undefined): void;
27
+ /**
28
+ * Check if an agent should receive orchestration injection.
29
+ * Only build and plan agents get the orchestration prompt.
30
+ */
31
+ export declare function shouldInjectOrchestration(agent: string | undefined): boolean;
32
+ /**
33
+ * Get the agent type for prompt selection.
34
+ * Returns "build", "plan", or string for other agents.
35
+ */
36
+ export declare function getOrchestrationAgentType(agent: string | undefined): "build" | "plan" | string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zenox",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "OpenCode plugin with specialized agents (explorer, librarian, oracle, ui-planner), background tasks for parallel execution, and smart orchestration",
5
5
  "author": "Ayush",
6
6
  "license": "MIT",