@adhdev/daemon-core 0.8.6 → 0.8.8

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.6",
3
+ "version": "0.8.8",
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.6",
3
+ "version": "0.8.8",
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",
@@ -357,6 +357,12 @@ function normalizeScreenSnapshot(text: string): string {
357
357
  .trim();
358
358
  }
359
359
 
360
+ function normalizeComparableMessageContent(text: string): string {
361
+ return String(text || '')
362
+ .replace(/\s+/g, ' ')
363
+ .trim();
364
+ }
365
+
360
366
  /**
361
367
  * Normalize provider.json for auto-implement approval detection.
362
368
  * Kept for backward compat with dev-server auto-impl pipeline only.
@@ -486,15 +492,60 @@ export class ProviderCliAdapter implements CliAdapter {
486
492
  }
487
493
 
488
494
  private normalizeParsedMessages(parsedMessages: any[]): CliChatMessage[] {
495
+ const referenceMessages = [...this.committedMessages];
496
+ const usedReferenceIndexes = new Set<number>();
497
+ const now = Date.now();
498
+
499
+ const findReferenceTimestamp = (role: 'user' | 'assistant', content: string, parsedIndex: number): number | undefined => {
500
+ const normalizedContent = normalizeComparableMessageContent(content);
501
+ if (!normalizedContent) return undefined;
502
+
503
+ const sameIndex = referenceMessages[parsedIndex];
504
+ if (
505
+ sameIndex
506
+ && !usedReferenceIndexes.has(parsedIndex)
507
+ && sameIndex.role === role
508
+ && normalizeComparableMessageContent(sameIndex.content) === normalizedContent
509
+ && typeof sameIndex.timestamp === 'number'
510
+ && Number.isFinite(sameIndex.timestamp)
511
+ ) {
512
+ usedReferenceIndexes.add(parsedIndex);
513
+ return sameIndex.timestamp;
514
+ }
515
+
516
+ for (let i = 0; i < referenceMessages.length; i++) {
517
+ if (usedReferenceIndexes.has(i)) continue;
518
+ const candidate = referenceMessages[i];
519
+ if (!candidate || candidate.role !== role) continue;
520
+ const candidateContent = normalizeComparableMessageContent(candidate.content);
521
+ if (!candidateContent) continue;
522
+ const exactMatch = candidateContent === normalizedContent;
523
+ const fuzzyMatch = candidateContent.includes(normalizedContent) || normalizedContent.includes(candidateContent);
524
+ if (!exactMatch && !fuzzyMatch) continue;
525
+ if (typeof candidate.timestamp === 'number' && Number.isFinite(candidate.timestamp)) {
526
+ usedReferenceIndexes.add(i);
527
+ return candidate.timestamp;
528
+ }
529
+ }
530
+
531
+ return undefined;
532
+ };
533
+
489
534
  return parsedMessages
490
535
  .filter((message) => message && (message.role === 'user' || message.role === 'assistant'))
491
- .map((message) => ({
492
- role: message.role,
493
- content: typeof message.content === 'string' ? message.content : String(message.content || ''),
494
- timestamp: typeof message.timestamp === 'number' && Number.isFinite(message.timestamp)
536
+ .map((message, index) => {
537
+ const role = message.role as 'user' | 'assistant';
538
+ const content = typeof message.content === 'string' ? message.content : String(message.content || '');
539
+ const parsedTimestamp = typeof message.timestamp === 'number' && Number.isFinite(message.timestamp)
495
540
  ? message.timestamp
496
- : Date.now(),
497
- }));
541
+ : undefined;
542
+ const referenceTimestamp = parsedTimestamp ?? findReferenceTimestamp(role, content, index);
543
+ return {
544
+ role,
545
+ content,
546
+ timestamp: referenceTimestamp ?? now,
547
+ };
548
+ });
498
549
  }
499
550
 
500
551
  private sliceFromOffset(text: string, start: number): string {
@@ -749,12 +800,17 @@ export class ProviderCliAdapter implements CliAdapter {
749
800
  || isScriptBinary(binaryPath)
750
801
  || !looksLikeMachOOrElf(binaryPath)
751
802
  );
752
- const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
803
+ // On Windows, .cmd/.bat shims cannot be spawned directly — must go through cmd.exe
804
+ const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
805
+ const useShell = isWin ? (!!spawnConfig.shell || isCmdShim) : useShellUnix;
753
806
 
754
807
  if (useShell) {
755
808
  if (!spawnConfig.shell && !isWin) {
756
809
  LOG.info('CLI', `[${this.cliType}] Using login shell (script shim or non-native binary)`);
757
810
  }
811
+ if (isCmdShim) {
812
+ LOG.info('CLI', `[${this.cliType}] Using cmd.exe shell for .cmd/.bat shim: ${binaryPath}`);
813
+ }
758
814
  shellCmd = isWin ? 'cmd.exe' : (process.env.SHELL || '/bin/zsh');
759
815
  if (isWin) {
760
816
  // On Windows, pass binaryPath and args as separate items so node-pty's