@evo-dev/core 0.0.1-alpha.2 → 0.0.1-alpha.20

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.
Files changed (79) hide show
  1. package/assets/skills/coding/knowledge-distillation/SKILL.md +5 -3
  2. package/assets/team/agents/code-reviewer.md +48 -0
  3. package/assets/team/agents/docs-maintainer.md +51 -0
  4. package/assets/team/agents/implementation-engineer.md +51 -0
  5. package/assets/team/agents/product-scope-analyst.md +58 -0
  6. package/assets/team/agents/release-engineer.md +55 -0
  7. package/assets/team/agents/security-boundary-reviewer.md +50 -0
  8. package/assets/team/agents/solution-architect.md +51 -0
  9. package/assets/team/agents/verification-engineer.md +51 -0
  10. package/assets/team/team.md +102 -0
  11. package/dist/assets/index.js +5 -5
  12. package/dist/config/index.js +793 -241
  13. package/dist/index.js +20840 -12908
  14. package/dist/plugins/index.js +13 -13
  15. package/package.json +1 -1
  16. package/src/agents/index.ts +1 -265
  17. package/src/code-agent-traces/index.ts +11 -12
  18. package/src/config/index.ts +2 -0
  19. package/src/config/settings.ts +116 -7
  20. package/src/config/store.ts +1 -1
  21. package/src/daemon/index.ts +1 -41
  22. package/src/evolution/candidates/index.ts +730 -0
  23. package/src/evolution/control/index.ts +20 -0
  24. package/src/evolution/evidence/analysis.ts +533 -0
  25. package/src/evolution/evidence/index.ts +3 -0
  26. package/src/evolution/evidence/session-memory/analysis.ts +287 -0
  27. package/src/evolution/evidence/session-memory/constants.ts +9 -0
  28. package/src/evolution/evidence/session-memory/index.ts +9 -0
  29. package/src/evolution/evidence/session-memory/paths.ts +29 -0
  30. package/src/evolution/evidence/session-memory/policy.ts +39 -0
  31. package/src/evolution/evidence/session-memory/retention.ts +643 -0
  32. package/src/evolution/evidence/session-memory/segment.ts +216 -0
  33. package/src/evolution/evidence/session-memory/semantic-packet.ts +408 -0
  34. package/src/evolution/evidence/session-memory/sensitivity.ts +335 -0
  35. package/src/evolution/evidence/session-memory/state-machine.ts +249 -0
  36. package/src/evolution/evidence/session-memory/storage.ts +744 -0
  37. package/src/evolution/evidence/session-memory/types.ts +296 -0
  38. package/src/evolution/evidence/session-memory/updater.ts +199 -0
  39. package/src/evolution/formatters.ts +169 -0
  40. package/src/evolution/imports/apply.ts +435 -0
  41. package/src/evolution/imports/diff.ts +472 -0
  42. package/src/evolution/imports/index.ts +7 -0
  43. package/src/evolution/imports/materialize.ts +640 -0
  44. package/src/evolution/imports/paths.ts +129 -0
  45. package/src/evolution/imports/stage.ts +414 -0
  46. package/src/evolution/imports/storage.ts +952 -0
  47. package/src/evolution/imports/types.ts +226 -0
  48. package/src/evolution/index.ts +19 -2827
  49. package/src/evolution/knowledge/change-store.ts +558 -0
  50. package/src/evolution/knowledge/changes.ts +459 -0
  51. package/src/evolution/knowledge/freshness.ts +69 -0
  52. package/src/{knowledge → evolution/knowledge}/index.ts +1532 -206
  53. package/src/evolution/knowledge/review.ts +446 -0
  54. package/src/evolution/knowledge/support.ts +135 -0
  55. package/src/evolution/paths.ts +44 -0
  56. package/src/evolution/processor/distillation.ts +518 -0
  57. package/src/evolution/processor/index.ts +3 -0
  58. package/src/evolution/processor/process.ts +594 -0
  59. package/src/{learning → evolution/review}/index.ts +10 -14
  60. package/src/evolution/schema.ts +639 -0
  61. package/src/evolution/shared.ts +1053 -0
  62. package/src/evolution/triggers/classification.ts +102 -0
  63. package/src/evolution/triggers/index.ts +295 -0
  64. package/src/hooks/index.ts +281 -197
  65. package/src/index.ts +15 -4
  66. package/src/projects/index.ts +934 -0
  67. package/src/runtime-logs/index.ts +100 -13
  68. package/src/team/index.ts +582 -3
  69. package/src/utils/errors.ts +13 -0
  70. package/src/utils/fs.ts +40 -0
  71. package/src/utils/hash.ts +9 -0
  72. package/src/utils/ids.ts +12 -0
  73. package/src/utils/index.ts +7 -0
  74. package/src/utils/parsing.ts +11 -0
  75. package/src/utils/text.ts +18 -0
  76. package/src/utils/time.ts +5 -0
  77. package/src/workflow/index.ts +3 -21
  78. package/src/project/index.ts +0 -507
  79. package/src/task/index.ts +0 -840
@@ -1,7 +1,8 @@
1
- import { createHash } from "node:crypto";
1
+ import { lstatSync, readFileSync, realpathSync } from "node:fs";
2
2
  import { appendFile, mkdir } from "node:fs/promises";
3
- import { dirname, isAbsolute, join, relative } from "node:path";
3
+ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
4
4
  import { resolveEvoDevPaths } from "../config/paths.ts";
5
+ import { normalizeTimestamp, sha256Short } from "../utils/index.ts";
5
6
 
6
7
  export type EvoDevLogPhase = "started" | "completed" | "failed";
7
8
  export type EvoDevDebugLogLevel = "verbose" | "debug" | "info" | "warn" | "error";
@@ -109,6 +110,15 @@ export interface TraceLogTeamContext {
109
110
  projectKey: string;
110
111
  }
111
112
 
113
+ export interface ProjectLogIdentity {
114
+ projectKey: string;
115
+ workspaceKey: string;
116
+ projectRoot: string;
117
+ workspaceRoot: string;
118
+ gitCommonDir: string | null;
119
+ linkedWorktree: boolean;
120
+ }
121
+
112
122
  export interface CliLogInput {
113
123
  phase: EvoDevLogPhase;
114
124
  argv: string[];
@@ -538,6 +548,39 @@ export function resolveTraceTeamContext(input: {
538
548
  }
539
549
 
540
550
  export function resolveProjectLogKey(homeDir: string, repoRoot: string): string {
551
+ return resolveProjectLogIdentity(homeDir, repoRoot).projectKey;
552
+ }
553
+
554
+ export function resolveProjectLogIdentity(homeDir: string, repoRoot: string): ProjectLogIdentity {
555
+ const identityHomeDir = realpathDirectoryOrFallback(homeDir);
556
+ const workspaceRoot = realpathDirectoryOrFallback(repoRoot);
557
+ const workspaceKey = resolvePathProjectLogKey(identityHomeDir, workspaceRoot);
558
+ const gitCommonDir = resolveGitCommonDir(workspaceRoot);
559
+ if (gitCommonDir === null) {
560
+ return {
561
+ projectKey: workspaceKey,
562
+ workspaceKey,
563
+ projectRoot: workspaceRoot,
564
+ workspaceRoot,
565
+ gitCommonDir: null,
566
+ linkedWorktree: false,
567
+ };
568
+ }
569
+
570
+ const commonDirOwnsWorktree = basename(gitCommonDir) === ".git";
571
+ const projectIdentityPath = commonDirOwnsWorktree ? dirname(gitCommonDir) : gitCommonDir;
572
+ const projectRoot = commonDirOwnsWorktree ? projectIdentityPath : workspaceRoot;
573
+ return {
574
+ projectKey: resolvePathProjectLogKey(identityHomeDir, projectIdentityPath),
575
+ workspaceKey,
576
+ projectRoot,
577
+ workspaceRoot,
578
+ gitCommonDir,
579
+ linkedWorktree: workspaceKey !== resolvePathProjectLogKey(identityHomeDir, projectIdentityPath),
580
+ };
581
+ }
582
+
583
+ export function resolvePathProjectLogKey(homeDir: string, repoRoot: string): string {
541
584
  const trimmedHome = stripTrailingSlash(homeDir);
542
585
  const trimmedRepo = stripTrailingSlash(repoRoot);
543
586
  const relativePath = relative(trimmedHome, trimmedRepo);
@@ -554,12 +597,64 @@ export function resolveProjectLogKey(homeDir: string, repoRoot: string): string
554
597
  return sanitizePersistentIdentifier(projectKey, "project");
555
598
  }
556
599
 
600
+ function realpathDirectoryOrFallback(path: string): string {
601
+ try {
602
+ return realpathSync(path);
603
+ } catch {
604
+ if (!isAbsolute(path)) return stripTrailingSlash(path);
605
+ const missingSegments: string[] = [];
606
+ let current = stripTrailingSlash(path);
607
+ for (;;) {
608
+ const parent = dirname(current);
609
+ if (parent === current) return stripTrailingSlash(path);
610
+ missingSegments.unshift(basename(current));
611
+ current = parent;
612
+ try {
613
+ return join(realpathSync(current), ...missingSegments);
614
+ } catch {
615
+ // Continue toward the nearest existing ancestor so deleted worktrees
616
+ // retain the same path identity across symlinked filesystem prefixes.
617
+ }
618
+ }
619
+ }
620
+ }
621
+
622
+ function resolveGitCommonDir(workspaceRoot: string): string | null {
623
+ const markerPath = join(workspaceRoot, ".git");
624
+ let gitDir: string;
625
+ try {
626
+ const marker = lstatSync(markerPath);
627
+ if (marker.isDirectory()) {
628
+ gitDir = realpathSync(markerPath);
629
+ } else if (marker.isFile()) {
630
+ const value = readFileSync(markerPath, "utf8").trim();
631
+ const match = value.match(/^gitdir:\s*(.+)$/u);
632
+ if (match?.[1] === undefined || match[1].includes("\0")) return null;
633
+ gitDir = realpathSync(isAbsolute(match[1]) ? match[1] : resolve(workspaceRoot, match[1]));
634
+ } else {
635
+ return null;
636
+ }
637
+ } catch {
638
+ return null;
639
+ }
640
+
641
+ try {
642
+ const commonDirValue = readFileSync(join(gitDir, "commondir"), "utf8").trim();
643
+ if (commonDirValue === "" || commonDirValue.includes("\0")) return gitDir;
644
+ return realpathSync(
645
+ isAbsolute(commonDirValue) ? commonDirValue : resolve(gitDir, commonDirValue),
646
+ );
647
+ } catch {
648
+ return gitDir;
649
+ }
650
+ }
651
+
557
652
  export function resolveTraceSessionKey(payload: unknown): string {
558
653
  const record = isRecord(payload) ? payload : {};
559
654
  const sessionId = optionalString(record.session_id ?? record.sessionId);
560
655
  const cwd = optionalString(record.cwd);
561
656
  const source = sessionId ?? cwd ?? "local";
562
- return `session-${createHash("sha256").update(source).digest("hex").slice(0, 16)}`;
657
+ return `session-${sha256Short(source)}`;
563
658
  }
564
659
 
565
660
  function sanitizeTraceLogEntryForAppend(entry: TraceLogEntryV1): TraceLogEntryV1 {
@@ -644,12 +739,6 @@ async function appendJsonLine(path: string, value: unknown): Promise<void> {
644
739
  await appendFile(path, `${JSON.stringify(value)}\n`, "utf8");
645
740
  }
646
741
 
647
- function normalizeTimestamp(value?: Date | string): string {
648
- if (value instanceof Date) return value.toISOString();
649
- if (typeof value === "string" && value.trim() !== "") return new Date(value).toISOString();
650
- return new Date().toISOString();
651
- }
652
-
653
742
  function formatLocalDateKey(timestamp: string): string {
654
743
  const date = new Date(timestamp);
655
744
  const year = date.getFullYear();
@@ -727,8 +816,7 @@ function createExecutionEventId(input: {
727
816
  summary: string;
728
817
  metadata: Record<string, EvoDevExecutionEventMetadataValue>;
729
818
  }): string {
730
- const hash = createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 16);
731
- return `exec-${hash}`;
819
+ return `exec-${sha256Short(JSON.stringify(input))}`;
732
820
  }
733
821
 
734
822
  function sanitizeDebugValue(value: unknown, depth = 0): unknown {
@@ -775,8 +863,7 @@ function sanitizePersistentIdentifier(value: string, prefix: string): string {
775
863
  if (!SENSITIVE_EVENT_TEXT_PATTERN.test(value) && !SENSITIVE_EVENT_TEXT_PATTERN.test(pathSafe)) {
776
864
  return pathSafe;
777
865
  }
778
- const hash = createHash("sha256").update(value).digest("hex").slice(0, 16);
779
- return `${prefix}-${hash}`;
866
+ return `${prefix}-${sha256Short(value)}`;
780
867
  }
781
868
 
782
869
  function stripTrailingSlash(path: string): string {