@kodrunhq/opencode-autopilot 1.16.0 → 1.18.0

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 (61) hide show
  1. package/assets/commands/oc-doctor.md +17 -0
  2. package/bin/configure-tui.ts +1 -1
  3. package/bin/inspect.ts +2 -2
  4. package/package.json +1 -1
  5. package/src/config/index.ts +29 -0
  6. package/src/config/migrations.ts +196 -0
  7. package/src/config/v7.ts +45 -0
  8. package/src/config.ts +108 -24
  9. package/src/health/checks.ts +165 -0
  10. package/src/health/runner.ts +8 -2
  11. package/src/health/types.ts +1 -1
  12. package/src/index.ts +25 -2
  13. package/src/kernel/transaction.ts +48 -0
  14. package/src/kernel/types.ts +1 -2
  15. package/src/logging/domains.ts +39 -0
  16. package/src/logging/forensic-writer.ts +177 -0
  17. package/src/logging/index.ts +4 -0
  18. package/src/logging/logger.ts +44 -0
  19. package/src/logging/performance.ts +59 -0
  20. package/src/logging/rotation.ts +261 -0
  21. package/src/logging/types.ts +33 -0
  22. package/src/memory/capture-utils.ts +149 -0
  23. package/src/memory/capture.ts +16 -197
  24. package/src/memory/decay.ts +11 -2
  25. package/src/memory/injector.ts +4 -1
  26. package/src/memory/lessons.ts +85 -0
  27. package/src/memory/observations.ts +177 -0
  28. package/src/memory/preferences.ts +718 -0
  29. package/src/memory/projects.ts +83 -0
  30. package/src/memory/repository.ts +46 -1001
  31. package/src/memory/retrieval.ts +5 -1
  32. package/src/observability/context-display.ts +8 -0
  33. package/src/observability/event-handlers.ts +44 -6
  34. package/src/observability/forensic-log.ts +10 -2
  35. package/src/observability/forensic-schemas.ts +9 -1
  36. package/src/observability/log-reader.ts +20 -1
  37. package/src/orchestrator/error-context.ts +24 -0
  38. package/src/orchestrator/handlers/build-utils.ts +118 -0
  39. package/src/orchestrator/handlers/build.ts +13 -148
  40. package/src/orchestrator/handlers/retrospective.ts +0 -1
  41. package/src/orchestrator/lesson-memory.ts +7 -2
  42. package/src/orchestrator/orchestration-logger.ts +46 -31
  43. package/src/orchestrator/progress.ts +63 -0
  44. package/src/review/memory.ts +11 -3
  45. package/src/review/parse-findings.ts +116 -0
  46. package/src/review/pipeline.ts +3 -107
  47. package/src/review/selection.ts +38 -4
  48. package/src/scoring/time-provider.ts +23 -0
  49. package/src/tools/configure.ts +1 -1
  50. package/src/tools/doctor.ts +2 -2
  51. package/src/tools/logs.ts +32 -6
  52. package/src/tools/orchestrate.ts +11 -9
  53. package/src/tools/replay.ts +42 -0
  54. package/src/tools/review.ts +8 -2
  55. package/src/tools/summary.ts +43 -0
  56. package/src/types/background.ts +51 -0
  57. package/src/types/mcp.ts +27 -0
  58. package/src/types/recovery.ts +39 -0
  59. package/src/types/routing.ts +39 -0
  60. package/src/utils/random.ts +33 -0
  61. package/src/ux/session-summary.ts +56 -0
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Project repository operations.
3
+ *
4
+ * Handles project upsert and path resolution.
5
+ * Extracted from repository.ts for better module organization.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { Database } from "bun:sqlite";
11
+ import { getMemoryDb } from "./database";
12
+ import { projectSchema } from "./schemas";
13
+ import type { Project } from "./types";
14
+
15
+ /** Resolve optional db parameter to singleton fallback. */
16
+ function resolveDb(db?: Database): Database {
17
+ return db ?? getMemoryDb();
18
+ }
19
+
20
+ /** Map a snake_case DB row to camelCase Project. */
21
+ function rowToProject(row: Record<string, unknown>): Project {
22
+ return {
23
+ id: row.id as string,
24
+ path: row.path as string,
25
+ name: row.name as string,
26
+ firstSeenAt: ((row.first_seen_at as string) ?? (row.last_updated as string)) as string,
27
+ lastUpdated: row.last_updated as string,
28
+ };
29
+ }
30
+
31
+ /**
32
+ * Create or replace a project record.
33
+ */
34
+ export function upsertProject(project: Project, db?: Database): void {
35
+ const validated = projectSchema.parse(project);
36
+ const d = resolveDb(db);
37
+ const firstSeenAt = validated.firstSeenAt ?? validated.lastUpdated;
38
+ d.run(
39
+ `INSERT INTO projects (id, path, name, first_seen_at, last_updated)
40
+ VALUES (?, ?, ?, ?, ?)
41
+ ON CONFLICT(id) DO UPDATE SET
42
+ path = excluded.path,
43
+ name = excluded.name,
44
+ first_seen_at = COALESCE(projects.first_seen_at, excluded.first_seen_at),
45
+ last_updated = excluded.last_updated`,
46
+ [validated.id, validated.path, validated.name, firstSeenAt, validated.lastUpdated],
47
+ );
48
+ d.run("UPDATE project_paths SET is_current = 0, last_updated = ? WHERE project_id = ?", [
49
+ validated.lastUpdated,
50
+ validated.id,
51
+ ]);
52
+ d.run(
53
+ `INSERT INTO project_paths (project_id, path, first_seen_at, last_updated, is_current)
54
+ VALUES (?, ?, ?, ?, 1)
55
+ ON CONFLICT(project_id, path) DO UPDATE SET
56
+ last_updated = excluded.last_updated,
57
+ is_current = 1`,
58
+ [validated.id, validated.path, firstSeenAt, validated.lastUpdated],
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Get a project by its filesystem path. Returns null if not found.
64
+ */
65
+ export function getProjectByPath(path: string, db?: Database): Project | null {
66
+ const d = resolveDb(db);
67
+ const row = d
68
+ .query(
69
+ `SELECT p.*
70
+ FROM projects p
71
+ WHERE p.path = ?
72
+ UNION ALL
73
+ SELECT p.*
74
+ FROM project_paths pp
75
+ JOIN projects p ON p.id = pp.project_id
76
+ WHERE pp.path = ?
77
+ AND NOT EXISTS (SELECT 1 FROM projects p2 WHERE p2.path = ?)
78
+ ORDER BY last_updated DESC
79
+ LIMIT 1`,
80
+ )
81
+ .get(path, path, path) as Record<string, unknown> | null;
82
+ return row ? rowToProject(row) : null;
83
+ }