@adhdev/daemon-core 0.8.11 → 0.8.12

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/session-host-core",
3
- "version": "0.8.11",
3
+ "version": "0.8.12",
4
4
  "description": "ADHDev local session host core — session registry, protocol, buffers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.8.11",
3
+ "version": "0.8.12",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -195,6 +195,20 @@ function sanitizeTerminalText(str: string): string {
195
195
  return stripTerminalNoise(stripAnsi(str));
196
196
  }
197
197
 
198
+ function applyPreferredTerminalColorEnv(env: Record<string, string>): void {
199
+ if (env.NO_COLOR) return;
200
+
201
+ if (!env.TERM || env.TERM === 'xterm-color') {
202
+ env.TERM = 'xterm-256color';
203
+ }
204
+ if (!env.COLORTERM) env.COLORTERM = 'truecolor';
205
+
206
+ if (process.platform === 'win32') {
207
+ if (!env.FORCE_COLOR) env.FORCE_COLOR = '1';
208
+ if (!env.CLICOLOR) env.CLICOLOR = '1';
209
+ }
210
+ }
211
+
198
212
  function buildCliSpawnEnv(baseEnv: NodeJS.ProcessEnv, overrides?: Record<string, string>): Record<string, string> {
199
213
  const env: Record<string, string> = {};
200
214
  const source = { ...baseEnv, ...(overrides || {}) } as NodeJS.ProcessEnv;
@@ -207,8 +221,6 @@ function buildCliSpawnEnv(baseEnv: NodeJS.ProcessEnv, overrides?: Record<string,
207
221
  for (const key of Object.keys(env)) {
208
222
  if (
209
223
  key === 'INIT_CWD'
210
- || key === 'NO_COLOR'
211
- || key === 'FORCE_COLOR'
212
224
  || key === 'npm_command'
213
225
  || key === 'npm_execpath'
214
226
  || key === 'npm_node_execpath'
@@ -224,6 +236,7 @@ function buildCliSpawnEnv(baseEnv: NodeJS.ProcessEnv, overrides?: Record<string,
224
236
  }
225
237
  }
226
238
 
239
+ applyPreferredTerminalColorEnv(env);
227
240
  return env;
228
241
  }
229
242
 
@@ -92,7 +92,7 @@ export class NodePtyTransportFactory implements PtyTransportFactory {
92
92
  spawn(command: string, args: string[], options: PtySpawnOptions): PtyRuntimeTransport {
93
93
  if (!pty) throw new Error('node-pty is not installed');
94
94
  const handle = pty.spawn(command, args, {
95
- name: os.platform() === 'win32' ? 'xterm-color' : 'xterm-256color',
95
+ name: 'xterm-256color',
96
96
  cols: options.cols,
97
97
  rows: options.rows,
98
98
  cwd: options.cwd,
@@ -202,17 +202,54 @@ export async function handleDiscoverAgents(h: CommandHelpers, args: any): Promis
202
202
 
203
203
  // ─── File commands ─────────────────────────────
204
204
 
205
+ function normalizeWindowsRequestedPath(requestedPath: string): string {
206
+ const trimmed = requestedPath.trim();
207
+ if (!trimmed) return '.';
208
+
209
+ const slashDriveMatch = trimmed.match(/^[/\\]([A-Za-z])(?:[/\\](.*))?$/);
210
+ if (slashDriveMatch) {
211
+ const drive = slashDriveMatch[1].toUpperCase();
212
+ const rest = (slashDriveMatch[2] || '').replace(/[/\\]+/g, '\\');
213
+ return rest ? `${drive}:\\${rest}` : `${drive}:\\`;
214
+ }
215
+
216
+ if (/^[A-Za-z]:$/.test(trimmed)) {
217
+ return `${trimmed[0].toUpperCase()}:\\`;
218
+ }
219
+
220
+ if (/^[A-Za-z]:[^/\\].*$/.test(trimmed)) {
221
+ return `${trimmed[0].toUpperCase()}:\\${trimmed.slice(2).replace(/[/\\]+/g, '\\')}`;
222
+ }
223
+
224
+ if (/^[A-Za-z]:[/\\]/.test(trimmed)) {
225
+ return `${trimmed[0].toUpperCase()}:${trimmed.slice(2)}`;
226
+ }
227
+
228
+ return trimmed;
229
+ }
230
+
205
231
  function resolveSafePath(requestedPath: string): string {
232
+ const rawPath = typeof requestedPath === 'string' ? requestedPath.trim() : '';
233
+ const inputPath = rawPath || '.';
206
234
  const home = os.homedir();
207
- let resolved: string;
208
- if (requestedPath.startsWith('~')) {
209
- resolved = path.join(home, requestedPath.slice(1));
210
- } else if (path.isAbsolute(requestedPath)) {
211
- resolved = requestedPath;
212
- } else {
213
- resolved = path.resolve(requestedPath);
235
+
236
+ if (inputPath.startsWith('~')) {
237
+ return path.resolve(path.join(home, inputPath.slice(1)));
214
238
  }
215
- return resolved;
239
+
240
+ if (process.platform === 'win32') {
241
+ const normalized = normalizeWindowsRequestedPath(inputPath);
242
+ if (path.win32.isAbsolute(normalized)) {
243
+ return path.win32.normalize(normalized);
244
+ }
245
+ return path.win32.resolve(normalized);
246
+ }
247
+
248
+ if (path.isAbsolute(inputPath)) {
249
+ return path.normalize(inputPath);
250
+ }
251
+
252
+ return path.resolve(inputPath);
216
253
  }
217
254
 
218
255
  function listDirectoryEntriesSafe(dirPath: string): Array<{ name: string; type: 'directory' | 'file'; size?: number }> {