@oh-my-pi/subagents 1.3.375 → 1.3.376

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/package.json +1 -1
  2. package/tools/index.ts +23 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/subagents",
3
- "version": "1.3.375",
3
+ "version": "1.3.376",
4
4
  "description": "Task delegation system with specialized subagents (task, planner, explore, reviewer, browser)",
5
5
  "keywords": [
6
6
  "omp-plugin",
package/tools/index.ts CHANGED
@@ -27,6 +27,12 @@
27
27
  */
28
28
 
29
29
  import { spawn, spawnSync } from 'node:child_process'
30
+
31
+ /** pi command: 'pi.cmd' on Windows, 'pi' elsewhere */
32
+ const PI_CMD = process.platform === 'win32' ? 'pi.cmd' : 'pi'
33
+ /** Windows shell option for spawn/spawnSync when using PI_CMD */
34
+ const PI_SHELL_OPT = process.platform === 'win32'
35
+
30
36
  import * as crypto from 'node:crypto'
31
37
  import * as fs from 'node:fs'
32
38
  import * as os from 'node:os'
@@ -49,9 +55,10 @@ function getAvailableModels(): string[] {
49
55
  if (cachedModels !== null) return cachedModels
50
56
 
51
57
  try {
52
- const result = spawnSync('pi', ['--list-models'], {
58
+ const result = spawnSync(PI_CMD, ['--list-models'], {
53
59
  encoding: 'utf-8',
54
60
  timeout: 5000,
61
+ shell: PI_SHELL_OPT,
55
62
  })
56
63
 
57
64
  if (result.status !== 0 || !result.stdout) {
@@ -463,20 +470,6 @@ async function mapWithConcurrencyLimit<TIn, TOut>(
463
470
  return results
464
471
  }
465
472
 
466
- function writePromptToTempFile(agentName: string, prompt: string): { dir: string; filePath: string } {
467
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-task-agent-'))
468
- const safeName = agentName.replace(/[^\w.-]+/g, '_')
469
- const filePath = path.join(tmpDir, `prompt-${safeName}.md`)
470
- try {
471
- // mode: 0o600 restricts file permissions on Unix; ignored on Windows
472
- fs.writeFileSync(filePath, prompt, { encoding: 'utf-8', mode: 0o600 })
473
- } catch (err) {
474
- fs.rmSync(tmpDir, { recursive: true, force: true })
475
- throw err
476
- }
477
- return { dir: tmpDir, filePath }
478
- }
479
-
480
473
  interface RunAgentOptions {
481
474
  onProgress?: (progress: AgentProgress) => void
482
475
  index?: number
@@ -539,17 +532,22 @@ async function runSingleAgent(
539
532
  }
540
533
 
541
534
  let tmpPromptDir: string | null = null
542
- let tmpPromptPath: string | null = null
543
535
 
544
536
  try {
537
+ // Create temp dir for task file (avoids Windows shell escaping issues with long/complex CLI args)
538
+ tmpPromptDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-task-agent-'))
539
+
545
540
  if (agent.systemPrompt.trim()) {
546
- const tmp = writePromptToTempFile(agent.name, agent.systemPrompt)
547
- tmpPromptDir = tmp.dir
548
- tmpPromptPath = tmp.filePath
549
- args.push('--append-system-prompt', tmpPromptPath)
541
+ const systemFilePath = path.join(tmpPromptDir, `system-${agent.name.replace(/[^\w.-]+/g, '_')}.md`)
542
+ fs.writeFileSync(systemFilePath, agent.systemPrompt, { encoding: 'utf-8', mode: 0o600 })
543
+ args.push('--append-system-prompt', systemFilePath)
550
544
  }
551
545
 
552
- args.push(`Task: ${task}`)
546
+ // Write task to file and pass as @file to avoid shell escaping issues on Windows
547
+ const taskFilePath = path.join(tmpPromptDir, `task-${agent.name.replace(/[^\w.-]+/g, '_')}.md`)
548
+ fs.writeFileSync(taskFilePath, task, { encoding: 'utf-8', mode: 0o600 })
549
+ // Use forward slashes for the @file syntax (works on all platforms)
550
+ args.push(`@${taskFilePath.replace(/\\/g, '/')}`)
553
551
 
554
552
  // Emit initial "Initializing" state
555
553
  options?.onProgress?.({
@@ -571,9 +569,10 @@ async function runSingleAgent(
571
569
  })
572
570
 
573
571
  return await new Promise<SingleResult>(resolve => {
574
- const proc = spawn('pi', args, {
572
+ const proc = spawn(PI_CMD, args, {
575
573
  cwd,
576
574
  stdio: ['ignore', 'pipe', 'pipe'],
575
+ shell: PI_SHELL_OPT,
577
576
  })
578
577
 
579
578
  let toolCount = 0
@@ -782,16 +781,10 @@ async function runSingleAgent(
782
781
  })
783
782
  })
784
783
  } finally {
785
- if (tmpPromptPath) {
786
- try {
787
- fs.unlinkSync(tmpPromptPath)
788
- } catch {
789
- /* ignore */
790
- }
791
- }
784
+ // Clean up temp directory (contains system prompt and task files)
792
785
  if (tmpPromptDir) {
793
786
  try {
794
- fs.rmdirSync(tmpPromptDir)
787
+ fs.rmSync(tmpPromptDir, { recursive: true, force: true })
795
788
  } catch {
796
789
  /* ignore */
797
790
  }