opencode-task 0.1.3 → 0.1.5

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 (2) hide show
  1. package/dist/index.js +141 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12331,6 +12331,94 @@ function tool(input) {
12331
12331
  tool.schema = exports_external;
12332
12332
  // utils.ts
12333
12333
  import { appendFile } from "node:fs/promises";
12334
+ var AGENT_CONFIGS = {
12335
+ Explore: {
12336
+ description: "Fast agent specialized for exploring codebases. Use when you need to quickly find files by patterns, search code for keywords, or answer questions about the codebase.",
12337
+ prompt: "You are an exploration specialist. Search thoroughly using Glob, Grep, and Read. Report findings concisely. Do not modify any files.",
12338
+ tools: [
12339
+ "Glob",
12340
+ "Grep",
12341
+ "Read",
12342
+ "Bash",
12343
+ "LSP",
12344
+ "WebFetch",
12345
+ "WebSearch",
12346
+ "AskUserQuestion"
12347
+ ]
12348
+ },
12349
+ Plan: {
12350
+ description: "Software architect agent for designing implementation plans. Use when you need to plan implementation strategy. Returns step-by-step plans, identifies critical files, considers architectural trade-offs.",
12351
+ prompt: "You are a software architect. Analyze requirements, explore the codebase thoroughly, and design clear implementation plans with specific steps. Do not modify any files.",
12352
+ tools: [
12353
+ "Glob",
12354
+ "Grep",
12355
+ "Read",
12356
+ "Bash",
12357
+ "LSP",
12358
+ "WebFetch",
12359
+ "WebSearch",
12360
+ "AskUserQuestion"
12361
+ ]
12362
+ },
12363
+ "general-purpose": {
12364
+ description: "General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks. Use for heavy lifting when simpler agents are insufficient.",
12365
+ prompt: "You are a general-purpose assistant. Complete the assigned task thoroughly and report results.",
12366
+ tools: null
12367
+ },
12368
+ "claude-code-guide": {
12369
+ description: "Expert on Claude Code CLI features, hooks, slash commands, MCP servers, settings, IDE integrations. Also covers Claude Agent SDK and Claude API usage.",
12370
+ prompt: "You are a Claude Code expert. Answer questions about Claude Code features, Agent SDK, and API usage accurately. Search documentation and web resources as needed.",
12371
+ tools: ["Glob", "Grep", "Read", "WebFetch", "WebSearch"]
12372
+ },
12373
+ "web-search": {
12374
+ description: "Web researcher for external information not in the codebase. Use for: library docs, API references, error lookups, technology research, best practices. Do NOT use for codebase questions (use Explore) or Claude Code questions (use claude-code-guide).",
12375
+ prompt: `Research specialist. Find accurate information, cite sources, flag uncertainty.
12376
+
12377
+ TOOLS:
12378
+ - WebSearch: Broad queries, discover sources
12379
+ - WebFetch: Extract content from specific URLs
12380
+ - Read/Grep/Glob: Check local files for context before searching
12381
+ - Bash: Use curl, gh, or CLI tools for direct API access
12382
+ - AskUserQuestion: Clarify ambiguous requests BEFORE searching
12383
+
12384
+ PROCEDURE:
12385
+ 1. Parse request: factual lookup | how-to | comparison | troubleshooting
12386
+ 2. Search: Start specific, broaden if <3 relevant results
12387
+ 3. Verify: Single authoritative source for facts. Cross-reference for disputed topics.
12388
+ 4. Synthesize: Answer directly, then evidence.
12389
+
12390
+ FAILURE HANDLING:
12391
+ - Limit to 5 source pages unless requested otherwise
12392
+ - If page inaccessible (paywall/JS-only), note and try alternatives
12393
+ - After 3 failed query reformulations, report partial findings and unknowns
12394
+
12395
+ STOP CONDITIONS:
12396
+ - Factual: Official source found → done
12397
+ - How-to: Working solution with docs link → done
12398
+ - Troubleshooting: Root cause found OR 3 searches no progress → report gaps
12399
+
12400
+ QUALITY:
12401
+ - Reject sources >2yr old for fast-moving topics
12402
+ - Priority: official docs > GitHub issues > Stack Overflow > blogs
12403
+ - On conflict, report both positions with provenance
12404
+
12405
+ OUTPUT:
12406
+ [Direct answer or "Unable to determine"]
12407
+ [Evidence with inline [source](url) citations]
12408
+ [Confidence: HIGH (multiple authoritative) | MEDIUM (single authoritative) | LOW (conflicting/unofficial)]`,
12409
+ tools: [
12410
+ "WebSearch",
12411
+ "WebFetch",
12412
+ "Bash",
12413
+ "Grep",
12414
+ "Glob",
12415
+ "Read",
12416
+ "AskUserQuestion"
12417
+ ],
12418
+ model: "sonnet"
12419
+ }
12420
+ };
12421
+
12334
12422
  class Semaphore {
12335
12423
  maxConcurrent;
12336
12424
  permits;
@@ -12473,7 +12561,7 @@ class TaskRegistry {
12473
12561
  if (!this.accepting) {
12474
12562
  throw new Error("Registry is shutting down");
12475
12563
  }
12476
- const id = `task-${this.nextId++}`;
12564
+ const id = `task-${this.nextId++}-${crypto.randomUUID()}`;
12477
12565
  const cwd = options.cwd ?? process.cwd();
12478
12566
  const task = createTask(id, command, cwd, options.timeout, options.sessionID, options.metadata);
12479
12567
  this.tasks.set(id, task);
@@ -12770,6 +12858,58 @@ You will receive a notification when it completes.`,
12770
12858
  }
12771
12859
  return JSON.stringify(result);
12772
12860
  }
12861
+ }),
12862
+ AgentTask: tool({
12863
+ description: "Spawn a Claude agent to work on a subtask in the background. Available agents: Explore (codebase search), Plan (architecture design), general-purpose (complex multi-step tasks), claude-code-guide (Claude Code/SDK questions), web-search (research external information). You will receive a notification when complete.",
12864
+ args: {
12865
+ agent: tool.schema.enum([
12866
+ "Explore",
12867
+ "Plan",
12868
+ "general-purpose",
12869
+ "claude-code-guide",
12870
+ "web-search"
12871
+ ]).describe("Agent type to spawn"),
12872
+ prompt: tool.schema.string().describe("Task prompt for the agent"),
12873
+ cwd: tool.schema.string().optional().describe("Working directory"),
12874
+ timeout: tool.schema.number().optional().describe("Timeout in milliseconds")
12875
+ },
12876
+ async execute(args, context) {
12877
+ const agentType = args.agent;
12878
+ const config2 = AGENT_CONFIGS[agentType];
12879
+ const agentDef = {
12880
+ [agentType]: {
12881
+ description: config2.description,
12882
+ prompt: config2.prompt
12883
+ }
12884
+ };
12885
+ const cmdParts = [
12886
+ "claude",
12887
+ "--verbose",
12888
+ "--strict-mcp-config",
12889
+ "--mcp-config",
12890
+ '{"mcpServers":{}}',
12891
+ "--allow-dangerously-skip-permissions",
12892
+ "--agents",
12893
+ JSON.stringify(agentDef),
12894
+ "--agent",
12895
+ agentType
12896
+ ];
12897
+ if (config2.tools !== null) {
12898
+ cmdParts.push("--tools", config2.tools.join(","));
12899
+ }
12900
+ cmdParts.push("--output-format", "stream-json", "--print", "-p", args.prompt);
12901
+ const command = cmdParts.map((p) => p.includes(" ") || p.includes('"') ? `'${p}'` : p).join(" ");
12902
+ const id = await registry2.spawn(command, {
12903
+ cwd: args.cwd,
12904
+ timeout: args.timeout,
12905
+ sessionID: context.sessionID
12906
+ });
12907
+ return JSON.stringify({
12908
+ taskId: id,
12909
+ agent: agentType,
12910
+ message: `Agent ${agentType} spawned as ${id}. You will receive a notification when complete.`
12911
+ });
12912
+ }
12773
12913
  })
12774
12914
  }
12775
12915
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-task",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": ["dist"],