promptmic 0.1.1 → 0.1.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.
@@ -50,6 +50,36 @@ function resolveDirectExecutable(command, envPath, platform = process.platform,
50
50
  }
51
51
  return null;
52
52
  }
53
+ function readShebang(filePath) {
54
+ try {
55
+ const contents = fs.readFileSync(filePath, 'utf8');
56
+ const firstLine = contents.split(/\r?\n/, 1)[0];
57
+ return firstLine.startsWith('#!') ? firstLine : null;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ }
63
+ function resolveDirectSpawnTarget(command, args, env, platform) {
64
+ const executable = resolveDirectExecutable(command, env.PATH, platform, env.PATHEXT) ?? command;
65
+ try {
66
+ const realPath = fs.realpathSync(executable);
67
+ const shebang = readShebang(realPath)?.toLowerCase() ?? '';
68
+ if (shebang.includes('node')) {
69
+ return {
70
+ file: process.execPath,
71
+ args: [realPath, ...args],
72
+ };
73
+ }
74
+ }
75
+ catch {
76
+ // Fall back to the resolved executable path when realpath/read fails.
77
+ }
78
+ return {
79
+ file: executable,
80
+ args,
81
+ };
82
+ }
53
83
  export function expandTilde(value) {
54
84
  return value.startsWith('~/') ? path.join(HOME_DIR, value.slice(2)) : value;
55
85
  }
@@ -109,11 +139,11 @@ export function createPtySpawner(options = {}) {
109
139
  ...baseEnv,
110
140
  ...command.envOverrides,
111
141
  };
112
- const file = command.executionMode === 'direct'
113
- ? resolveDirectExecutable(command.file, env.PATH, platform, env.PATHEXT) ?? command.file
114
- : command.file;
142
+ const spawnTarget = command.executionMode === 'direct'
143
+ ? resolveDirectSpawnTarget(command.file, command.args, env, platform)
144
+ : { file: command.file, args: command.args };
115
145
  try {
116
- return spawn(file, command.args, {
146
+ return spawn(spawnTarget.file, spawnTarget.args, {
117
147
  name: 'xterm-256color',
118
148
  cols: 120,
119
149
  rows: 30,
@@ -126,4 +156,4 @@ export function createPtySpawner(options = {}) {
126
156
  }
127
157
  };
128
158
  }
129
- export { resolveDirectExecutable };
159
+ export { resolveDirectExecutable, resolveDirectSpawnTarget };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptmic",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Voice-first local UI for terminal-based AI coding assistants.",
5
5
  "license": "MIT",
6
6
  "keywords": [