@bamptee/aia-code 2.0.3 → 2.0.6

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.3",
3
+ "version": "2.0.6",
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,10 +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
- const child = spawn(command, args, {
14
- stdio: ['pipe', 'pipe', 'pipe'],
25
+
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}`);
36
+
37
+ const child = spawn('sh', ['-c', spawnCommand], {
38
+ stdio: ['ignore', 'pipe', 'pipe'],
15
39
  env: { ...cleanEnv, FORCE_COLOR: '0' },
16
40
  });
17
41
 
@@ -19,6 +43,12 @@ export function runCli(command, args, { stdin: stdinData, verbose = false, apply
19
43
  let stderr = '';
20
44
  let settled = false;
21
45
 
46
+ function cleanup() {
47
+ if (tmpFile) {
48
+ try { unlinkSync(tmpFile); } catch {}
49
+ }
50
+ }
51
+
22
52
  function resetTimer() {
23
53
  clearTimeout(timer);
24
54
  timer = setTimeout(() => {
@@ -31,6 +61,7 @@ export function runCli(command, args, { stdin: stdinData, verbose = false, apply
31
61
  if (settled) return;
32
62
  settled = true;
33
63
  clearTimeout(timer);
64
+ cleanup();
34
65
  if (err) reject(err);
35
66
  else resolve(result);
36
67
  }
@@ -71,10 +102,5 @@ export function runCli(command, args, { stdin: stdinData, verbose = false, apply
71
102
  finish(null, chunks.join(''));
72
103
  }
73
104
  });
74
-
75
- if (stdinData) {
76
- child.stdin.write(stdinData);
77
- child.stdin.end();
78
- }
79
105
  });
80
106
  }