@agentuity/opencode 1.0.0 → 1.0.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.
Files changed (138) hide show
  1. package/AGENTS.md +121 -13
  2. package/README.md +133 -12
  3. package/dist/agents/architect.d.ts +1 -1
  4. package/dist/agents/architect.d.ts.map +1 -1
  5. package/dist/agents/architect.js +2 -2
  6. package/dist/agents/builder.d.ts +1 -1
  7. package/dist/agents/builder.d.ts.map +1 -1
  8. package/dist/agents/builder.js +2 -2
  9. package/dist/agents/builder.js.map +1 -1
  10. package/dist/agents/expert-backend.d.ts +4 -0
  11. package/dist/agents/expert-backend.d.ts.map +1 -0
  12. package/dist/agents/expert-backend.js +493 -0
  13. package/dist/agents/expert-backend.js.map +1 -0
  14. package/dist/agents/expert-frontend.d.ts +4 -0
  15. package/dist/agents/expert-frontend.d.ts.map +1 -0
  16. package/dist/agents/expert-frontend.js +480 -0
  17. package/dist/agents/expert-frontend.js.map +1 -0
  18. package/dist/agents/expert-ops.d.ts +4 -0
  19. package/dist/agents/expert-ops.d.ts.map +1 -0
  20. package/dist/agents/expert-ops.js +375 -0
  21. package/dist/agents/expert-ops.js.map +1 -0
  22. package/dist/agents/expert.d.ts +1 -1
  23. package/dist/agents/expert.d.ts.map +1 -1
  24. package/dist/agents/expert.js +172 -913
  25. package/dist/agents/expert.js.map +1 -1
  26. package/dist/agents/index.d.ts.map +1 -1
  27. package/dist/agents/index.js +8 -2
  28. package/dist/agents/index.js.map +1 -1
  29. package/dist/agents/lead.d.ts +1 -1
  30. package/dist/agents/lead.d.ts.map +1 -1
  31. package/dist/agents/lead.js +359 -58
  32. package/dist/agents/lead.js.map +1 -1
  33. package/dist/agents/memory/entities.d.ts.map +1 -1
  34. package/dist/agents/memory/entities.js +5 -2
  35. package/dist/agents/memory/entities.js.map +1 -1
  36. package/dist/agents/memory.d.ts +1 -1
  37. package/dist/agents/memory.d.ts.map +1 -1
  38. package/dist/agents/memory.js +285 -10
  39. package/dist/agents/memory.js.map +1 -1
  40. package/dist/agents/monitor.d.ts +4 -0
  41. package/dist/agents/monitor.d.ts.map +1 -0
  42. package/dist/agents/monitor.js +106 -0
  43. package/dist/agents/monitor.js.map +1 -0
  44. package/dist/agents/product.d.ts +1 -1
  45. package/dist/agents/product.d.ts.map +1 -1
  46. package/dist/agents/product.js +161 -21
  47. package/dist/agents/product.js.map +1 -1
  48. package/dist/agents/reasoner.d.ts +1 -1
  49. package/dist/agents/reasoner.d.ts.map +1 -1
  50. package/dist/agents/reasoner.js +94 -11
  51. package/dist/agents/reasoner.js.map +1 -1
  52. package/dist/agents/scout.d.ts +1 -1
  53. package/dist/agents/scout.d.ts.map +1 -1
  54. package/dist/agents/scout.js +6 -4
  55. package/dist/agents/scout.js.map +1 -1
  56. package/dist/agents/types.d.ts +6 -0
  57. package/dist/agents/types.d.ts.map +1 -1
  58. package/dist/background/manager.d.ts +22 -1
  59. package/dist/background/manager.d.ts.map +1 -1
  60. package/dist/background/manager.js +218 -1
  61. package/dist/background/manager.js.map +1 -1
  62. package/dist/background/types.d.ts +19 -0
  63. package/dist/background/types.d.ts.map +1 -1
  64. package/dist/config/loader.d.ts +1 -1
  65. package/dist/config/loader.d.ts.map +1 -1
  66. package/dist/config/loader.js +10 -1
  67. package/dist/config/loader.js.map +1 -1
  68. package/dist/plugin/hooks/cadence.d.ts +2 -1
  69. package/dist/plugin/hooks/cadence.d.ts.map +1 -1
  70. package/dist/plugin/hooks/cadence.js +66 -3
  71. package/dist/plugin/hooks/cadence.js.map +1 -1
  72. package/dist/plugin/hooks/keyword.d.ts.map +1 -1
  73. package/dist/plugin/hooks/keyword.js +5 -3
  74. package/dist/plugin/hooks/keyword.js.map +1 -1
  75. package/dist/plugin/hooks/session-memory.d.ts +2 -1
  76. package/dist/plugin/hooks/session-memory.d.ts.map +1 -1
  77. package/dist/plugin/hooks/session-memory.js +57 -5
  78. package/dist/plugin/hooks/session-memory.js.map +1 -1
  79. package/dist/plugin/hooks/tools.d.ts.map +1 -1
  80. package/dist/plugin/hooks/tools.js +28 -5
  81. package/dist/plugin/hooks/tools.js.map +1 -1
  82. package/dist/plugin/plugin.d.ts.map +1 -1
  83. package/dist/plugin/plugin.js +119 -68
  84. package/dist/plugin/plugin.js.map +1 -1
  85. package/dist/services/auth.d.ts.map +1 -1
  86. package/dist/services/auth.js +9 -0
  87. package/dist/services/auth.js.map +1 -1
  88. package/dist/tmux/executor.d.ts.map +1 -1
  89. package/dist/tmux/executor.js +13 -4
  90. package/dist/tmux/executor.js.map +1 -1
  91. package/dist/tools/background.d.ts +4 -1
  92. package/dist/tools/background.d.ts.map +1 -1
  93. package/dist/tools/index.d.ts +0 -1
  94. package/dist/tools/index.d.ts.map +1 -1
  95. package/dist/tools/index.js +0 -1
  96. package/dist/tools/index.js.map +1 -1
  97. package/dist/types.d.ts +4 -1
  98. package/dist/types.d.ts.map +1 -1
  99. package/dist/types.js +4 -1
  100. package/dist/types.js.map +1 -1
  101. package/package.json +3 -3
  102. package/src/agents/architect.ts +2 -2
  103. package/src/agents/builder.ts +2 -2
  104. package/src/agents/expert-backend.ts +495 -0
  105. package/src/agents/expert-frontend.ts +482 -0
  106. package/src/agents/expert-ops.ts +377 -0
  107. package/src/agents/expert.ts +172 -913
  108. package/src/agents/index.ts +8 -2
  109. package/src/agents/lead.ts +359 -58
  110. package/src/agents/memory/entities.ts +10 -2
  111. package/src/agents/memory.ts +285 -10
  112. package/src/agents/monitor.ts +108 -0
  113. package/src/agents/product.ts +161 -21
  114. package/src/agents/reasoner.ts +94 -11
  115. package/src/agents/scout.ts +6 -4
  116. package/src/agents/types.ts +6 -0
  117. package/src/background/manager.ts +259 -2
  118. package/src/background/types.ts +17 -0
  119. package/src/config/loader.ts +11 -1
  120. package/src/plugin/hooks/cadence.ts +79 -3
  121. package/src/plugin/hooks/keyword.ts +5 -3
  122. package/src/plugin/hooks/session-memory.ts +68 -6
  123. package/src/plugin/hooks/tools.ts +40 -14
  124. package/src/plugin/plugin.ts +128 -70
  125. package/src/services/auth.ts +10 -0
  126. package/src/tmux/executor.ts +13 -4
  127. package/src/tools/index.ts +0 -1
  128. package/src/types.ts +4 -1
  129. package/dist/agents/planner.d.ts +0 -4
  130. package/dist/agents/planner.d.ts.map +0 -1
  131. package/dist/agents/planner.js +0 -158
  132. package/dist/agents/planner.js.map +0 -1
  133. package/dist/tools/delegate.d.ts +0 -45
  134. package/dist/tools/delegate.d.ts.map +0 -1
  135. package/dist/tools/delegate.js +0 -72
  136. package/dist/tools/delegate.js.map +0 -1
  137. package/src/agents/planner.ts +0 -161
  138. package/src/tools/delegate.ts +0 -83
@@ -63,21 +63,6 @@ You are running inside an Agentuity Sandbox (ID: ${SANDBOX_ID}).
63
63
  // Agents that should receive sandbox context in their prompts
64
64
  const SANDBOX_AWARE_AGENTS: AgentRole[] = ['lead', 'builder', 'architect'];
65
65
 
66
- // Agent display names for @mentions
67
- const AGENT_MENTIONS: Record<AgentRole, string> = {
68
- lead: '@Agentuity Coder Lead',
69
- scout: '@Agentuity Coder Scout',
70
- builder: '@Agentuity Coder Builder',
71
- architect: '@Agentuity Coder Architect',
72
- reviewer: '@Agentuity Coder Reviewer',
73
- memory: '@Agentuity Coder Memory',
74
- expert: '@Agentuity Coder Expert',
75
- planner: '@Agentuity Coder Planner',
76
- runner: '@Agentuity Coder Runner',
77
- reasoner: '@Agentuity Coder Reasoner',
78
- product: '@Agentuity Coder Product',
79
- };
80
-
81
66
  export async function createCoderPlugin(ctx: PluginInput): Promise<Hooks> {
82
67
  ctx.client.app.log({
83
68
  body: {
@@ -94,7 +79,6 @@ export async function createCoderPlugin(ctx: PluginInput): Promise<Hooks> {
94
79
  const toolHooks = createToolHooks(ctx, coderConfig);
95
80
  const keywordHooks = createKeywordHooks(ctx, coderConfig);
96
81
  const paramsHooks = createParamsHooks(ctx, coderConfig);
97
- const cadenceHooks = createCadenceHooks(ctx, coderConfig);
98
82
  const tmuxManager = coderConfig.tmux?.enabled
99
83
  ? new TmuxSessionManager(ctx, coderConfig.tmux, {
100
84
  onLog: (message) =>
@@ -125,9 +109,37 @@ export async function createCoderPlugin(ctx: PluginInput): Promise<Hooks> {
125
109
  : undefined,
126
110
  });
127
111
 
112
+ // Recover any background tasks from previous sessions
113
+ // This allows tasks to survive plugin restarts
114
+ void backgroundManager
115
+ .recoverTasks()
116
+ .then((count) => {
117
+ if (count > 0) {
118
+ ctx.client.app.log({
119
+ body: {
120
+ service: 'agentuity-coder',
121
+ level: 'info',
122
+ message: `Recovered ${count} background task(s) from previous sessions`,
123
+ },
124
+ });
125
+ }
126
+ })
127
+ .catch((error) => {
128
+ ctx.client.app.log({
129
+ body: {
130
+ service: 'agentuity-coder',
131
+ level: 'warn',
132
+ message: `Failed to recover background tasks: ${error}`,
133
+ },
134
+ });
135
+ });
136
+
137
+ // Create hooks that need backgroundManager for task reference injection during compaction
138
+ const cadenceHooks = createCadenceHooks(ctx, coderConfig, backgroundManager);
139
+
128
140
  // Session memory hooks handle checkpointing and compaction for non-Cadence sessions
129
141
  // Orchestration (deciding which module handles which session) happens below in the hooks
130
- const sessionMemoryHooks = createSessionMemoryHooks(ctx, coderConfig);
142
+ const sessionMemoryHooks = createSessionMemoryHooks(ctx, coderConfig, backgroundManager);
131
143
 
132
144
  const configHandler = createConfigHandler(coderConfig);
133
145
 
@@ -228,8 +240,10 @@ function createConfigHandler(
228
240
  // Validate merged configs and warn about mismatches
229
241
  validateAndWarnConfigs(mergedAgents);
230
242
 
231
- // In sandbox, allow all permissions without prompts
243
+ // Permission configuration for external directories
244
+ // Memory agent and other operations may need to write temp files for CLI piping
232
245
  if (IN_SANDBOX) {
246
+ // In sandbox, allow all permissions without prompts
233
247
  config.permission = {
234
248
  '*': 'allow',
235
249
  external_directory: {
@@ -237,6 +251,26 @@ function createConfigHandler(
237
251
  '*': 'allow',
238
252
  },
239
253
  };
254
+ } else {
255
+ // For non-sandbox environments, auto-allow temp directory writes
256
+ // This prevents blocking prompts when Memory agent writes large JSON for CLI piping
257
+ const existingPermissions = (config.permission as Record<string, unknown>) ?? {};
258
+ const existingExternalDir =
259
+ (existingPermissions.external_directory as Record<string, string>) ?? {};
260
+
261
+ // Normalize TMPDIR: strip trailing slashes, then append /**
262
+ const tmpdir = process.env.TMPDIR?.replace(/\/+$/, '');
263
+ const tmpdirPattern = tmpdir ? `${tmpdir}/**` : null;
264
+
265
+ config.permission = {
266
+ ...existingPermissions,
267
+ external_directory: {
268
+ ...existingExternalDir,
269
+ '/tmp/**': 'allow',
270
+ // Also allow OS-specific temp directories
271
+ ...(tmpdirPattern ? { [tmpdirPattern]: 'allow' } : {}),
272
+ },
273
+ };
240
274
  }
241
275
 
242
276
  config.command = {
@@ -280,6 +314,7 @@ function createAgentConfigs(
280
314
  ...(agent.maxSteps !== undefined ? { maxSteps: agent.maxSteps } : {}),
281
315
  ...(agent.reasoningEffort ? { reasoningEffort: agent.reasoningEffort } : {}),
282
316
  ...(agent.thinking ? { thinking: agent.thinking } : {}),
317
+ ...(agent.hidden ? { hidden: agent.hidden } : {}),
283
318
  };
284
319
  }
285
320
 
@@ -303,7 +338,6 @@ You are the Agentuity Coder Lead agent orchestrating the Agentuity Coder team.
303
338
  - **@Agentuity Coder Memory**: Store context, remember decisions
304
339
  - **@Agentuity Coder Reasoner**: Extract structured conclusions, resolve conflicts, surface corrections
305
340
  - **@Agentuity Coder Expert**: Agentuity CLI and cloud services specialist
306
- - **@Agentuity Coder Planner**: Deep planning for complex architecture decisions
307
341
  - **@Agentuity Coder Runner**: Run lint/build/test commands, returns structured results
308
342
  - **@Agentuity Coder Product**: Clarify requirements, validate features, track progress
309
343
 
@@ -459,7 +493,6 @@ You are the Agentuity Coder Lead in **Cadence mode** — a long-running autonomo
459
493
  - **@Agentuity Coder Memory**: Store context, remember decisions, checkpoints
460
494
  - **@Agentuity Coder Reasoner**: Extract structured conclusions, resolve conflicts, surface corrections
461
495
  - **@Agentuity Coder Expert**: Agentuity CLI and cloud services specialist
462
- - **@Agentuity Coder Planner**: Deep planning for complex architecture decisions
463
496
  - **@Agentuity Coder Runner**: Run lint/build/test commands, returns structured results
464
497
  - **@Agentuity Coder Product**: Clarify requirements, validate features, track progress, Cadence briefings
465
498
 
@@ -468,33 +501,52 @@ $ARGUMENTS
468
501
 
469
502
  ## Cadence Workflow
470
503
 
471
- 1. **Initialize loop state**:
504
+ 1. **FIRST: Establish PRD with Product** (REQUIRED):
505
+ - Ask @Agentuity Coder Product to establish/validate the PRD for this task
506
+ - Product will check for existing PRD or create one
507
+ - This defines "what" we're building and success criteria
508
+
509
+ 2. **Initialize loop state**:
472
510
  - Generate loop ID (format: \`lp_short_name_01\`)
473
511
  - Store in KV: \`agentuity cloud kv set agentuity-opencode-tasks "loop:{loopId}:state" '{...}'\`
512
+ - Link session planning to PRD via \`prdKey\`
474
513
 
475
- 2. **Each iteration**:
514
+ 3. **Each iteration**:
476
515
  - Ask @Agentuity Coder Memory for relevant context
477
516
  - Use @Agentuity Coder Scout to understand what's needed
478
- - For complex planning, consult @Agentuity Coder Planner
517
+ - For complex planning, use extended thinking (ultrathink) — ground in PRD requirements
479
518
  - Delegate implementation to **@Agentuity Coder Architect** (preferred for Cadence)
480
519
  - Have @Agentuity Coder Reviewer verify the work
481
520
  - Tell @Agentuity Coder Memory to store checkpoint
482
521
 
483
- 3. **When truly complete**, output:
522
+ 4. **When truly complete**, output:
484
523
  \`\`\`
485
524
  <promise>DONE</promise>
486
525
  \`\`\`
487
526
 
488
- 4. **Tell @Agentuity Coder Memory to memorialize** the completed session
527
+ 5. **Finalize**:
528
+ - Tell @Agentuity Coder Product to update the PRD with completed work
529
+ - Tell @Agentuity Coder Memory to memorialize the session
489
530
 
490
531
  ## Guidelines
532
+ - **Product first** — Always establish PRD before starting work
491
533
  - **Use Architect for implementation** — Architect has GPT Codex with maximum reasoning, ideal for autonomous work
492
534
  - Use regular Builder only for trivial fixes within an iteration
493
535
  - Ask Memory for context at each iteration start
494
536
  - Store checkpoints at each iteration end
495
- - If stuck on architecture, consult Planner before trying more approaches
537
+ - If stuck on architecture, use extended thinking (ultrathink) for deep planning
496
538
  - Use @Agentuity Coder Expert for sandbox/cloud operations
497
- - Respect max iterations (50 default)`,
539
+ - Respect max iterations (50 default)
540
+
541
+ ## Lead-of-Leads (Parallel Work)
542
+ If the task has **independent workstreams** that can run in parallel (e.g., "build auth, payments, and notifications"):
543
+ 1. Ask @Agentuity Coder Product to create PRD with workstreams
544
+ 2. Spawn child Leads via \`agentuity_background_task\` for each workstream
545
+ 3. Each child Lead claims a workstream, works autonomously, marks done when complete
546
+ 4. Monitor progress via PRD workstream status
547
+ 5. Do integration work when all children complete
548
+
549
+ **Don't use Lead-of-Leads for:** small tasks, sequential work, or work requiring tight coordination.`,
498
550
  agent: 'Agentuity Coder Lead',
499
551
  argumentHint: 'build the new auth feature with tests',
500
552
  },
@@ -539,46 +591,6 @@ function createTools(backgroundManager: BackgroundManager): Hooks['tool'] {
539
591
  // Use the schema from @opencode-ai/plugin's tool helper to avoid Zod version mismatches
540
592
  const s = tool.schema;
541
593
 
542
- const coderDelegate = tool({
543
- description: `Delegate a task to a specialized Agentuity Coder agent.
544
-
545
- Use this to:
546
- - Scout: Explore codebase, find patterns, research documentation
547
- - Builder: Implement features, write code, run tests (interactive work)
548
- - Architect: Complex autonomous tasks, Cadence mode, deep reasoning (GPT Codex)
549
- - Reviewer: Review changes, catch issues, apply fixes
550
- - Memory: Store context, remember decisions across sessions
551
- - Reasoner: Extract structured conclusions, resolve conflicts, surface corrections
552
- - Expert: Get help with Agentuity CLI and cloud services
553
- - Planner: Strategic advisor for complex architecture and deep planning (read-only)
554
- - Runner: Execute lint/build/test/typecheck/format commands, returns structured results`,
555
- args: {
556
- agent: s
557
- .enum([
558
- 'scout',
559
- 'builder',
560
- 'architect',
561
- 'reviewer',
562
- 'memory',
563
- 'reasoner',
564
- 'expert',
565
- 'planner',
566
- 'runner',
567
- ])
568
- .describe('Which agent to delegate to'),
569
- task: s.string().describe('Clear description of the task'),
570
- context: s.string().optional().describe('Additional context from previous tasks'),
571
- },
572
- async execute(args) {
573
- const mention = AGENT_MENTIONS[args.agent as AgentRole];
574
- let prompt = `${mention}\n\n## Task\n${args.task}`;
575
- if (args.context) {
576
- prompt = `${mention}\n\n## Context\n${args.context}\n\n## Task\n${args.task}`;
577
- }
578
- return `To delegate this task, use the Task tool with this prompt:\n\n${prompt}\n\nThe ${args.agent} agent will handle this task.`;
579
- },
580
- });
581
-
582
594
  const backgroundTask = tool({
583
595
  description: `Launch a task to run in the background. Use this for parallel execution of multiple independent tasks.
584
596
 
@@ -597,9 +609,9 @@ IMPORTANT: Use this tool instead of the 'task' tool when:
597
609
  'memory',
598
610
  'reasoner',
599
611
  'expert',
600
- 'planner',
601
612
  'runner',
602
613
  'product',
614
+ 'monitor',
603
615
  ])
604
616
  .describe('Agent role to run the task'),
605
617
  task: s.string().describe('Task prompt to run in the background'),
@@ -672,6 +684,49 @@ IMPORTANT: Use this tool instead of the 'task' tool when:
672
684
  },
673
685
  });
674
686
 
687
+ const backgroundInspect = tool({
688
+ description: `Inspect a background task to see its session messages and current state. Useful for debugging or checking what a child agent is doing.`,
689
+ args: {
690
+ task_id: s.string().describe('Background task ID to inspect'),
691
+ },
692
+ async execute(args) {
693
+ const inspection = await backgroundManager.inspectTask(args.task_id);
694
+ if (!inspection) {
695
+ return JSON.stringify({
696
+ taskId: args.task_id,
697
+ status: 'unknown',
698
+ found: false,
699
+ error: 'Task not found or session no longer exists.',
700
+ });
701
+ }
702
+
703
+ // Extract last few messages for summary
704
+ const messages = inspection.messages ?? [];
705
+ const lastMessages = messages
706
+ .slice(-3)
707
+ .map((m) => {
708
+ const parts = m.parts ?? [];
709
+ const textParts = parts.filter(
710
+ (p: unknown) => (p as { type?: string }).type === 'text'
711
+ );
712
+ return textParts
713
+ .map((p: unknown) => ((p as { text?: string }).text ?? '').slice(0, 200))
714
+ .join(' ')
715
+ .slice(0, 300);
716
+ })
717
+ .filter(Boolean);
718
+
719
+ return JSON.stringify({
720
+ taskId: inspection.taskId,
721
+ status: inspection.status,
722
+ found: true,
723
+ messageCount: messages.length,
724
+ lastMessages,
725
+ lastActivity: inspection.lastActivity,
726
+ });
727
+ },
728
+ });
729
+
675
730
  const memoryShare = tool({
676
731
  description: `Share memory content publicly via Agentuity Cloud Streams.
677
732
 
@@ -702,10 +757,11 @@ Returns the public URL that can be copied and used anywhere.`,
702
757
  compress: s.boolean().optional().describe('Enable gzip compression'),
703
758
  region: s.string().optional().describe('Cloud region (use, usc, usw). Default: usc'),
704
759
  },
705
- async execute(args) {
760
+ async execute(args, context) {
706
761
  // Get the profile first - this ensures checkAuth() and CLI use the same profile
707
762
  const profile = getCoderProfile();
708
763
  const originalProfile = process.env.AGENTUITY_PROFILE;
764
+ const sessionId = context.sessionID;
709
765
 
710
766
  try {
711
767
  // Set profile before auth check so checkAuth reads the correct config
@@ -752,6 +808,8 @@ Returns the public URL that can be copied and used anywhere.`,
752
808
  env: {
753
809
  ...process.env,
754
810
  AGENTUITY_PROFILE: profile,
811
+ AGENTUITY_AGENT_MODE: 'opencode',
812
+ ...(sessionId ? { AGENTUITY_OPENCODE_SESSION: sessionId } : {}),
755
813
  },
756
814
  });
757
815
 
@@ -810,10 +868,10 @@ Returns the public URL that can be copied and used anywhere.`,
810
868
  });
811
869
 
812
870
  return {
813
- agentuity_coder_delegate: coderDelegate,
814
871
  agentuity_background_task: backgroundTask,
815
872
  agentuity_background_output: backgroundOutput,
816
873
  agentuity_background_cancel: backgroundCancel,
874
+ agentuity_background_inspect: backgroundInspect,
817
875
  agentuity_memory_share: memoryShare,
818
876
  };
819
877
  }
@@ -27,6 +27,16 @@ const AGENTUITY_CONFIG_DIR = join(homedir(), '.config', 'agentuity');
27
27
  const DEFAULT_PROFILE = 'production.yaml';
28
28
 
29
29
  async function getProfilePath(): Promise<string> {
30
+ // Check AGENTUITY_PROFILE env var first (matches CLI behavior)
31
+ if (process.env.AGENTUITY_PROFILE) {
32
+ const envProfilePath = join(AGENTUITY_CONFIG_DIR, `${process.env.AGENTUITY_PROFILE}.yaml`);
33
+ const envFile = Bun.file(envProfilePath);
34
+ if (await envFile.exists()) {
35
+ return envProfilePath;
36
+ }
37
+ }
38
+
39
+ // Then check profile file
30
40
  const profileFile = Bun.file(join(AGENTUITY_CONFIG_DIR, 'profile'));
31
41
 
32
42
  if (await profileFile.exists()) {
@@ -1,6 +1,7 @@
1
1
  import type { PaneAction, WindowState, TmuxConfig } from './types';
2
2
  import { runTmuxCommand, runTmuxCommandSync } from './utils';
3
3
  import { spawn, spawnSync } from 'bun';
4
+ import { getCoderProfile } from '../plugin/hooks/tools';
4
5
 
5
6
  /**
6
7
  * Escape a string for safe use in shell commands.
@@ -432,10 +433,14 @@ async function replacePane(
432
433
  // Use exec to replace bash with opencode attach directly.
433
434
  // This ensures signals go directly to opencode attach (no wrapper process).
434
435
  // When opencode attach exits, the pane closes automatically (tmux remain-on-exit off).
435
- // Use shellEscape to prevent shell injection via session IDs
436
+ // Use shellEscape to prevent shell injection via session IDs and profile
436
437
  const escapedServerUrl = shellEscape(ctx.serverUrl);
437
438
  const escapedSessionId = shellEscape(action.newSessionId);
438
- const command = `exec opencode attach ${escapedServerUrl} --session ${escapedSessionId}`;
439
+ // Inject profile, session ID, and agent mode environment variables
440
+ const profile = getCoderProfile();
441
+ const escapedProfile = shellEscape(profile);
442
+ const envPrefix = `AGENTUITY_PROFILE=${escapedProfile} AGENTUITY_OPENCODE_SESSION=${escapedSessionId} AGENTUITY_AGENT_MODE=opencode`;
443
+ const command = `${envPrefix} exec opencode attach ${escapedServerUrl} --session ${escapedSessionId}`;
439
444
  const result = await runTmuxCommand(['respawn-pane', '-k', '-t', action.paneId, command]);
440
445
  if (!result.success) {
441
446
  return { success: false, error: result.output };
@@ -473,10 +478,14 @@ async function spawnInAgentsWindow(
473
478
  // Use exec to replace bash with opencode attach directly.
474
479
  // This ensures signals go directly to opencode attach (no wrapper process).
475
480
  // When opencode attach exits, the pane closes automatically (tmux remain-on-exit off).
476
- // Use shellEscape to prevent shell injection via session IDs
481
+ // Use shellEscape to prevent shell injection via session IDs and profile
477
482
  const escapedServerUrl = shellEscape(ctx.serverUrl);
478
483
  const escapedSessionId = shellEscape(action.sessionId);
479
- const command = `exec opencode attach ${escapedServerUrl} --session ${escapedSessionId}`;
484
+ // Inject profile, session ID, and agent mode environment variables
485
+ const profile = getCoderProfile();
486
+ const escapedProfile = shellEscape(profile);
487
+ const envPrefix = `AGENTUITY_PROFILE=${escapedProfile} AGENTUITY_OPENCODE_SESSION=${escapedSessionId} AGENTUITY_AGENT_MODE=opencode`;
488
+ const command = `${envPrefix} exec opencode attach ${escapedServerUrl} --session ${escapedSessionId}`;
480
489
  const layout = 'tiled'; // Always use tiled layout for grid arrangement
481
490
 
482
491
  // Check if we have a cached agents window ID and if it still exists
@@ -1,4 +1,3 @@
1
- export { delegateTool, DelegateArgsSchema, type DelegateArgs } from './delegate';
2
1
  export {
3
2
  createBackgroundTools,
4
3
  BackgroundTaskArgsSchema,
package/src/types.ts CHANGED
@@ -23,10 +23,13 @@ export const AgentRoleSchema = z.enum([
23
23
  'reviewer',
24
24
  'memory',
25
25
  'expert',
26
- 'planner',
26
+ 'expert-backend',
27
+ 'expert-frontend',
28
+ 'expert-ops',
27
29
  'runner',
28
30
  'reasoner',
29
31
  'product',
32
+ 'monitor',
30
33
  ]);
31
34
  export type AgentRole = z.infer<typeof AgentRoleSchema>;
32
35
 
@@ -1,4 +0,0 @@
1
- import type { AgentDefinition } from './types';
2
- export declare const PLANNER_SYSTEM_PROMPT = "# Planner Agent\n\nYou are a strategic technical advisor with deep reasoning capabilities, operating as a specialized consultant within the Agentuity Coder team.\n\n## Context\n\nYou function as an on-demand specialist invoked by the Lead agent when complex analysis or architectural decisions require elevated reasoning. Each consultation is standalone\u2014treat every request as complete and self-contained since no clarifying dialogue is possible.\n\n## What You ARE / ARE NOT\n\n| You ARE | You ARE NOT |\n|---------|-------------|\n| Strategic technical advisor | Code implementer |\n| Architecture analyst | Direct file editor |\n| Deep reasoning specialist | Quick task executor |\n| Decision framework provider | Build/test runner |\n| Risk assessor | Project manager |\n\n## What You Do\n\nYour expertise covers:\n- Dissecting codebases to understand structural patterns and design choices\n- Formulating concrete, implementable technical recommendations\n- Architecting solutions and mapping out implementation roadmaps\n- Resolving intricate technical questions through systematic reasoning\n- Surfacing hidden issues and crafting preventive measures\n- Creating detailed, actionable plans that Builder can execute\n\n## Decision Framework\n\nApply pragmatic minimalism in all recommendations:\n\n**Bias toward simplicity**: The right solution is typically the least complex one that fulfills the actual requirements. Resist hypothetical future needs.\n\n**Leverage what exists**: Favor modifications to current code, established patterns, and existing dependencies over introducing new components. New libraries, services, or infrastructure require explicit justification.\n\n**Prioritize developer experience**: Optimize for readability, maintainability, and reduced cognitive load. Theoretical performance gains or architectural purity matter less than practical usability.\n\n**One clear path**: Present a single primary recommendation. Mention alternatives only when they offer substantially different trade-offs worth considering.\n\n**Match depth to complexity**: Quick questions get quick answers. Reserve thorough analysis for genuinely complex problems or explicit requests for depth.\n\n**Signal the investment**: Tag recommendations with estimated effort\u2014use Quick(<1h), Short(1-4h), Medium(1-2d), or Large(3d+) to set expectations.\n\n**Know when to stop**: \"Working well\" beats \"theoretically optimal.\" Identify what conditions would warrant revisiting with a more sophisticated approach.\n\n## Working With Tools\n\nYou are a **read-only** agent. You can:\n- Read files to understand code structure\n- Use glob/grep to find patterns\n- Fetch documentation\n\nYou **cannot** and **should not**:\n- Write or edit files\n- Run bash commands\n- Execute tests or builds\n- Make any modifications\n\nYour role is to analyze and recommend. Builder will execute your plans.\n\n## Response Structure\n\nOrganize your final answer in three tiers:\n\n### Essential (always include)\n\n**Bottom Line**: 2-3 sentences capturing your recommendation\n\n**Action Plan**: Numbered steps or checklist for implementation\n- Each step should be specific enough for Builder to execute\n- Include file paths, function names, and expected changes\n- Order steps by dependency (what must happen first)\n\n**Effort Estimate**: Using the Quick/Short/Medium/Large scale\n\n### Expanded (include when relevant)\n\n**Why This Approach**: Brief reasoning and key trade-offs considered\n\n**Watch Out For**: Risks, edge cases, and mitigation strategies\n\n**Dependencies**: What needs to exist before this work can begin\n\n### Edge Cases (only when genuinely applicable)\n\n**Escalation Triggers**: Specific conditions that would justify a more complex solution\n\n**Alternative Sketch**: High-level outline of the advanced path (not a full design)\n\n## Plan Format for Builder\n\nWhen creating implementation plans, use this structure:\n\n```markdown\n## Implementation Plan\n\n### Phase 1: [Name]\n**Effort**: Quick/Short/Medium/Large\n\n1. **[Step Name]**\n - File: `path/to/file.ts`\n - Action: [Create/Modify/Delete]\n - Details: [Specific changes needed]\n\n2. **[Step Name]**\n - File: `path/to/other.ts`\n - Action: [Create/Modify/Delete]\n - Details: [Specific changes needed]\n\n### Phase 2: [Name]\n...\n\n### Verification\n- [ ] [Specific test or check]\n- [ ] [Another verification step]\n```\n\n## Guiding Principles\n\n- **Actionable insight over exhaustive analysis**: Give Builder what they need to execute\n- **Depth matches complexity**: Simple questions get simple answers\n- **One recommendation**: Present the best path, not all possible paths\n- **Concrete specifics**: File paths, function names, exact changes\n- **Risk awareness**: Surface potential issues before they become problems\n\n## Collaboration\n\nYou work primarily with Lead and Builder/Architect:\n\n| Agent | How You Help Them |\n|-------|-------------------|\n| Lead | Provide strategic analysis, architecture decisions, detailed plans |\n| Builder or Architect | Create step-by-step implementation plans they can execute |\n| Reviewer | Offer architectural context for code reviews |\n| Scout | N/A (Scout gathers info for you to analyze) |\n\n## Critical Note\n\nYour response goes directly to the Lead agent who will delegate to Builder. Make your final message self-contained: a clear recommendation and actionable plan that Builder can execute immediately.\n\n**You are read-only.** Analyze, recommend, and plan\u2014but never attempt to modify code yourself.\n";
3
- export declare const plannerAgent: AgentDefinition;
4
- //# sourceMappingURL=planner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../src/agents/planner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,qBAAqB,68KA8IjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,eAc1B,CAAC"}
@@ -1,158 +0,0 @@
1
- export const PLANNER_SYSTEM_PROMPT = `# Planner Agent
2
-
3
- You are a strategic technical advisor with deep reasoning capabilities, operating as a specialized consultant within the Agentuity Coder team.
4
-
5
- ## Context
6
-
7
- You function as an on-demand specialist invoked by the Lead agent when complex analysis or architectural decisions require elevated reasoning. Each consultation is standalone—treat every request as complete and self-contained since no clarifying dialogue is possible.
8
-
9
- ## What You ARE / ARE NOT
10
-
11
- | You ARE | You ARE NOT |
12
- |---------|-------------|
13
- | Strategic technical advisor | Code implementer |
14
- | Architecture analyst | Direct file editor |
15
- | Deep reasoning specialist | Quick task executor |
16
- | Decision framework provider | Build/test runner |
17
- | Risk assessor | Project manager |
18
-
19
- ## What You Do
20
-
21
- Your expertise covers:
22
- - Dissecting codebases to understand structural patterns and design choices
23
- - Formulating concrete, implementable technical recommendations
24
- - Architecting solutions and mapping out implementation roadmaps
25
- - Resolving intricate technical questions through systematic reasoning
26
- - Surfacing hidden issues and crafting preventive measures
27
- - Creating detailed, actionable plans that Builder can execute
28
-
29
- ## Decision Framework
30
-
31
- Apply pragmatic minimalism in all recommendations:
32
-
33
- **Bias toward simplicity**: The right solution is typically the least complex one that fulfills the actual requirements. Resist hypothetical future needs.
34
-
35
- **Leverage what exists**: Favor modifications to current code, established patterns, and existing dependencies over introducing new components. New libraries, services, or infrastructure require explicit justification.
36
-
37
- **Prioritize developer experience**: Optimize for readability, maintainability, and reduced cognitive load. Theoretical performance gains or architectural purity matter less than practical usability.
38
-
39
- **One clear path**: Present a single primary recommendation. Mention alternatives only when they offer substantially different trade-offs worth considering.
40
-
41
- **Match depth to complexity**: Quick questions get quick answers. Reserve thorough analysis for genuinely complex problems or explicit requests for depth.
42
-
43
- **Signal the investment**: Tag recommendations with estimated effort—use Quick(<1h), Short(1-4h), Medium(1-2d), or Large(3d+) to set expectations.
44
-
45
- **Know when to stop**: "Working well" beats "theoretically optimal." Identify what conditions would warrant revisiting with a more sophisticated approach.
46
-
47
- ## Working With Tools
48
-
49
- You are a **read-only** agent. You can:
50
- - Read files to understand code structure
51
- - Use glob/grep to find patterns
52
- - Fetch documentation
53
-
54
- You **cannot** and **should not**:
55
- - Write or edit files
56
- - Run bash commands
57
- - Execute tests or builds
58
- - Make any modifications
59
-
60
- Your role is to analyze and recommend. Builder will execute your plans.
61
-
62
- ## Response Structure
63
-
64
- Organize your final answer in three tiers:
65
-
66
- ### Essential (always include)
67
-
68
- **Bottom Line**: 2-3 sentences capturing your recommendation
69
-
70
- **Action Plan**: Numbered steps or checklist for implementation
71
- - Each step should be specific enough for Builder to execute
72
- - Include file paths, function names, and expected changes
73
- - Order steps by dependency (what must happen first)
74
-
75
- **Effort Estimate**: Using the Quick/Short/Medium/Large scale
76
-
77
- ### Expanded (include when relevant)
78
-
79
- **Why This Approach**: Brief reasoning and key trade-offs considered
80
-
81
- **Watch Out For**: Risks, edge cases, and mitigation strategies
82
-
83
- **Dependencies**: What needs to exist before this work can begin
84
-
85
- ### Edge Cases (only when genuinely applicable)
86
-
87
- **Escalation Triggers**: Specific conditions that would justify a more complex solution
88
-
89
- **Alternative Sketch**: High-level outline of the advanced path (not a full design)
90
-
91
- ## Plan Format for Builder
92
-
93
- When creating implementation plans, use this structure:
94
-
95
- \`\`\`markdown
96
- ## Implementation Plan
97
-
98
- ### Phase 1: [Name]
99
- **Effort**: Quick/Short/Medium/Large
100
-
101
- 1. **[Step Name]**
102
- - File: \`path/to/file.ts\`
103
- - Action: [Create/Modify/Delete]
104
- - Details: [Specific changes needed]
105
-
106
- 2. **[Step Name]**
107
- - File: \`path/to/other.ts\`
108
- - Action: [Create/Modify/Delete]
109
- - Details: [Specific changes needed]
110
-
111
- ### Phase 2: [Name]
112
- ...
113
-
114
- ### Verification
115
- - [ ] [Specific test or check]
116
- - [ ] [Another verification step]
117
- \`\`\`
118
-
119
- ## Guiding Principles
120
-
121
- - **Actionable insight over exhaustive analysis**: Give Builder what they need to execute
122
- - **Depth matches complexity**: Simple questions get simple answers
123
- - **One recommendation**: Present the best path, not all possible paths
124
- - **Concrete specifics**: File paths, function names, exact changes
125
- - **Risk awareness**: Surface potential issues before they become problems
126
-
127
- ## Collaboration
128
-
129
- You work primarily with Lead and Builder/Architect:
130
-
131
- | Agent | How You Help Them |
132
- |-------|-------------------|
133
- | Lead | Provide strategic analysis, architecture decisions, detailed plans |
134
- | Builder or Architect | Create step-by-step implementation plans they can execute |
135
- | Reviewer | Offer architectural context for code reviews |
136
- | Scout | N/A (Scout gathers info for you to analyze) |
137
-
138
- ## Critical Note
139
-
140
- Your response goes directly to the Lead agent who will delegate to Builder. Make your final message self-contained: a clear recommendation and actionable plan that Builder can execute immediately.
141
-
142
- **You are read-only.** Analyze, recommend, and plan—but never attempt to modify code yourself.
143
- `;
144
- export const plannerAgent = {
145
- role: 'planner',
146
- id: 'ag-planner',
147
- displayName: 'Agentuity Coder Planner',
148
- description: 'Strategic technical advisor for complex architecture and deep planning. Read-only, high-reasoning specialist.',
149
- defaultModel: 'openai/gpt-5.2',
150
- systemPrompt: PLANNER_SYSTEM_PROMPT,
151
- mode: 'subagent',
152
- tools: {
153
- exclude: ['write', 'edit', 'apply_patch', 'bash'], // Read-only agent
154
- },
155
- reasoningEffort: 'xhigh', // Maximum reasoning for GPT models
156
- temperature: 0.1, // Low for consistent, deterministic analysis
157
- };
158
- //# sourceMappingURL=planner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner.js","sourceRoot":"","sources":["../../src/agents/planner.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8IpC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAoB;IAC5C,IAAI,EAAE,SAAS;IACf,EAAE,EAAE,YAAY;IAChB,WAAW,EAAE,yBAAyB;IACtC,WAAW,EACV,+GAA+G;IAChH,YAAY,EAAE,gBAAgB;IAC9B,YAAY,EAAE,qBAAqB;IACnC,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE;QACN,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,kBAAkB;KACrE;IACD,eAAe,EAAE,OAAO,EAAE,mCAAmC;IAC7D,WAAW,EAAE,GAAG,EAAE,6CAA6C;CAC/D,CAAC"}
@@ -1,45 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const DelegateArgsSchema: z.ZodObject<{
3
- agent: z.ZodEnum<{
4
- scout: "scout";
5
- builder: "builder";
6
- architect: "architect";
7
- reviewer: "reviewer";
8
- memory: "memory";
9
- expert: "expert";
10
- planner: "planner";
11
- runner: "runner";
12
- reasoner: "reasoner";
13
- product: "product";
14
- }>;
15
- task: z.ZodString;
16
- context: z.ZodOptional<z.ZodString>;
17
- waitForResult: z.ZodDefault<z.ZodBoolean>;
18
- }, z.core.$strip>;
19
- export type DelegateArgs = z.infer<typeof DelegateArgsSchema>;
20
- export declare const delegateTool: {
21
- name: string;
22
- description: string;
23
- args: z.ZodObject<{
24
- agent: z.ZodEnum<{
25
- scout: "scout";
26
- builder: "builder";
27
- architect: "architect";
28
- reviewer: "reviewer";
29
- memory: "memory";
30
- expert: "expert";
31
- planner: "planner";
32
- runner: "runner";
33
- reasoner: "reasoner";
34
- product: "product";
35
- }>;
36
- task: z.ZodString;
37
- context: z.ZodOptional<z.ZodString>;
38
- waitForResult: z.ZodDefault<z.ZodBoolean>;
39
- }, z.core.$strip>;
40
- execute(args: DelegateArgs, _context: unknown): Promise<{
41
- output: string;
42
- }>;
43
- };
44
- export default delegateTool;
45
- //# sourceMappingURL=delegate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;iBAqB7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAiB9D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;kBAoBJ,YAAY,YAAY,OAAO,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAgBjF,CAAC;AAEF,eAAe,YAAY,CAAC"}