@bamptee/aia-code 2.0.4 → 2.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamptee/aia-code",
3
- "version": "2.0.4",
3
+ "version": "2.0.7",
4
4
  "description": "AI Architecture Assistant - orchestrate AI-assisted development workflows via CLI tools (Claude, Codex, Gemini)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,4 +1,8 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { writeFileSync, unlinkSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import path from 'node:path';
5
+ import { randomBytes } from 'node:crypto';
2
6
  import chalk from 'chalk';
3
7
 
4
8
  const DEFAULT_IDLE_TIMEOUT_MS = 180_000;
@@ -8,14 +12,30 @@ export function runCli(command, args, { stdin: stdinData, verbose = false, apply
8
12
  if (!idleTimeoutMs) {
9
13
  idleTimeoutMs = apply ? AGENT_IDLE_TIMEOUT_MS : DEFAULT_IDLE_TIMEOUT_MS;
10
14
  }
15
+
16
+ // Write prompt to a temp file to avoid stdin piping issues
17
+ let tmpFile;
18
+ if (stdinData) {
19
+ tmpFile = path.join(tmpdir(), `aia-prompt-${randomBytes(6).toString('hex')}.txt`);
20
+ writeFileSync(tmpFile, stdinData, 'utf-8');
21
+ }
22
+
11
23
  return new Promise((resolve, reject) => {
12
24
  const { CLAUDECODE, ...cleanEnv } = process.env;
13
25
 
14
- console.error(`[DEBUG] spawn: ${command} ${args.join(' ')}`);
15
- console.error(`[DEBUG] stdin length: ${stdinData ? stdinData.length : 0} chars`);
26
+ // Replace the `-` stdin marker with the temp file path via shell redirection
27
+ const finalArgs = tmpFile
28
+ ? args.filter(a => a !== '-')
29
+ : args;
30
+
31
+ const spawnCommand = tmpFile
32
+ ? `${command} ${finalArgs.map(a => `'${a}'`).join(' ')} < '${tmpFile}'`
33
+ : `${command} ${args.map(a => `'${a}'`).join(' ')}`;
34
+
35
+ console.error(`[DEBUG] ${spawnCommand}`);
16
36
 
17
- const child = spawn(command, args, {
18
- stdio: ['pipe', 'pipe', 'pipe'],
37
+ const child = spawn('sh', ['-c', spawnCommand], {
38
+ stdio: ['ignore', 'pipe', 'pipe'],
19
39
  env: { ...cleanEnv, FORCE_COLOR: '0' },
20
40
  });
21
41
 
@@ -23,6 +43,12 @@ export function runCli(command, args, { stdin: stdinData, verbose = false, apply
23
43
  let stderr = '';
24
44
  let settled = false;
25
45
 
46
+ function cleanup() {
47
+ if (tmpFile) {
48
+ try { unlinkSync(tmpFile); } catch {}
49
+ }
50
+ }
51
+
26
52
  function resetTimer() {
27
53
  clearTimeout(timer);
28
54
  timer = setTimeout(() => {
@@ -35,6 +61,7 @@ export function runCli(command, args, { stdin: stdinData, verbose = false, apply
35
61
  if (settled) return;
36
62
  settled = true;
37
63
  clearTimeout(timer);
64
+ cleanup();
38
65
  if (err) reject(err);
39
66
  else resolve(result);
40
67
  }
@@ -75,10 +102,5 @@ export function runCli(command, args, { stdin: stdinData, verbose = false, apply
75
102
  finish(null, chunks.join(''));
76
103
  }
77
104
  });
78
-
79
- if (stdinData) {
80
- child.stdin.write(stdinData);
81
- child.stdin.end();
82
- }
83
105
  });
84
106
  }