@jeffober/thatch 0.1.48 → 0.2.1

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 (50) hide show
  1. package/README.md +43 -4
  2. package/artifacts/skills/thatch-fact-extractor.md +1 -1
  3. package/artifacts/skills/thatch-memory-verify.md +2 -2
  4. package/bin/thatch +31 -16
  5. package/docs/dev/README.md +39 -13
  6. package/docs/dev/features/behavior-engine.md +3 -2
  7. package/docs/dev/features/cicd.md +1 -1
  8. package/docs/dev/features/compaction-recovery.md +1 -1
  9. package/docs/dev/features/cross-session-chat.md +12 -3
  10. package/docs/dev/features/extraction.md +10 -2
  11. package/docs/dev/features/hygiene.md +3 -1
  12. package/docs/dev/features/memory-store.md +1 -1
  13. package/docs/dev/features/multi-host.md +4 -2
  14. package/docs/dev/features/notifications.md +121 -4
  15. package/docs/dev/features/nudge-pipeline.md +16 -2
  16. package/docs/dev/features/opencode-plugin.md +133 -0
  17. package/docs/dev/features/qa-system.md +43 -0
  18. package/docs/dev/features/repo-identity.md +1 -1
  19. package/docs/dev/features/session-lifecycle.md +6 -3
  20. package/docs/dev/features/watchers.md +12 -5
  21. package/docs/dev/gotchas.md +94 -4
  22. package/docs/dev/mcp-parity.md +4 -3
  23. package/docs/dev/setup-and-hooks.md +7 -2
  24. package/docs/plans/llm-alerts.md +287 -0
  25. package/docs/plans/prediction-consolidation.md +3 -3
  26. package/docs/user/README.md +8 -4
  27. package/docs/user/memory.md +1 -1
  28. package/docs/user/notifications.md +63 -4
  29. package/docs/user/setup.md +4 -0
  30. package/docs/user/watchers.md +15 -7
  31. package/package.json +3 -1
  32. package/src/alerts.ts +360 -0
  33. package/src/capabilities.ts +174 -0
  34. package/src/chat.ts +80 -5
  35. package/src/commands.ts +44 -5
  36. package/src/config.ts +32 -1
  37. package/src/db.ts +157 -12
  38. package/src/embeddings.ts +43 -0
  39. package/src/extraction.ts +210 -0
  40. package/src/index.ts +77 -1339
  41. package/src/opencode/v1.ts +54 -0
  42. package/src/opencode/v2.ts +605 -0
  43. package/src/os-args.ts +99 -0
  44. package/src/prompts.ts +181 -31
  45. package/src/runtime.ts +2004 -0
  46. package/src/seed-behaviors.ts +1 -1
  47. package/src/session-db.ts +32 -0
  48. package/src/tool-defs.ts +340 -46
  49. package/src/tools.ts +16 -35
  50. package/src/watchers.ts +109 -14
@@ -30,7 +30,7 @@ interface DefaultBehavior {
30
30
  * (2) a user-codified behavior that happens to match a seed situation
31
31
  * would be found and silently deleted.
32
32
  *
33
- * Called by both the opencode plugin (src/index.ts) and the MCP server
33
+ * Called by both the opencode plugin (src/runtime.ts) and the MCP server
34
34
  * (src/mcp.ts) at startup, after DB and model initialization.
35
35
  */
36
36
  const DEFAULT_BEHAVIORS: DefaultBehavior[] = [
package/src/session-db.ts CHANGED
@@ -54,6 +54,38 @@ export function resolveOpencodeDbPath(): string | null {
54
54
  return existsSync(path) ? path : null;
55
55
  }
56
56
 
57
+ /**
58
+ * Resolves the session `opencode -c` continues: the most recently updated
59
+ * top-level session in the directory, read straight from the session
60
+ * database - the same pick the TUI makes from client.session.list(), which
61
+ * the v2 plugin context cannot call (its session domain has no list) and
62
+ * which would arrive too late for the runtime's synchronous rehydration
63
+ * partition regardless. Null when the db is unavailable or no top-level
64
+ * session exists in the directory.
65
+ */
66
+ export function mostRecentTopLevelSessionId(directory: string): string | null {
67
+ const dbPath = resolveOpencodeDbPath();
68
+ if (!dbPath) return null;
69
+ let db: Database;
70
+ try {
71
+ db = new Database(dbPath, { readonly: true });
72
+ } catch {
73
+ return null;
74
+ }
75
+ try {
76
+ const row = db
77
+ .query(
78
+ "SELECT id FROM session WHERE directory = ? AND (parent_id IS NULL OR parent_id = '') ORDER BY time_updated DESC LIMIT 1",
79
+ )
80
+ .get(directory) as { id: string } | undefined;
81
+ return row?.id ?? null;
82
+ } catch {
83
+ return null;
84
+ } finally {
85
+ db.close();
86
+ }
87
+ }
88
+
57
89
  export interface SessionRow {
58
90
  id: string;
59
91
  title: string;