@goondocks/myco 0.1.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 (308) hide show
  1. package/.claude-plugin/marketplace.json +22 -0
  2. package/.claude-plugin/plugin.json +18 -0
  3. package/CONTRIBUTING.md +143 -0
  4. package/LICENSE +21 -0
  5. package/README.md +74 -0
  6. package/commands/init.md +231 -0
  7. package/commands/setup-llm.md +89 -0
  8. package/commands/status.md +112 -0
  9. package/dist/src/agents/adapter.d.ts +76 -0
  10. package/dist/src/agents/adapter.d.ts.map +1 -0
  11. package/dist/src/agents/adapter.js +124 -0
  12. package/dist/src/agents/adapter.js.map +1 -0
  13. package/dist/src/agents/claude-code.d.ts +3 -0
  14. package/dist/src/agents/claude-code.d.ts.map +1 -0
  15. package/dist/src/agents/claude-code.js +22 -0
  16. package/dist/src/agents/claude-code.js.map +1 -0
  17. package/dist/src/agents/cursor.d.ts +3 -0
  18. package/dist/src/agents/cursor.d.ts.map +1 -0
  19. package/dist/src/agents/cursor.js +154 -0
  20. package/dist/src/agents/cursor.js.map +1 -0
  21. package/dist/src/agents/index.d.ts +6 -0
  22. package/dist/src/agents/index.d.ts.map +1 -0
  23. package/dist/src/agents/index.js +5 -0
  24. package/dist/src/agents/index.js.map +1 -0
  25. package/dist/src/agents/registry.d.ts +34 -0
  26. package/dist/src/agents/registry.d.ts.map +1 -0
  27. package/dist/src/agents/registry.js +95 -0
  28. package/dist/src/agents/registry.js.map +1 -0
  29. package/dist/src/artifacts/candidates.d.ts +20 -0
  30. package/dist/src/artifacts/candidates.d.ts.map +1 -0
  31. package/dist/src/artifacts/candidates.js +84 -0
  32. package/dist/src/artifacts/candidates.js.map +1 -0
  33. package/dist/src/artifacts/slugify.d.ts +2 -0
  34. package/dist/src/artifacts/slugify.d.ts.map +1 -0
  35. package/dist/src/artifacts/slugify.js +22 -0
  36. package/dist/src/artifacts/slugify.js.map +1 -0
  37. package/dist/src/capture/artifact-watcher.d.ts +19 -0
  38. package/dist/src/capture/artifact-watcher.d.ts.map +1 -0
  39. package/dist/src/capture/artifact-watcher.js +37 -0
  40. package/dist/src/capture/artifact-watcher.js.map +1 -0
  41. package/dist/src/capture/buffer.d.ts +20 -0
  42. package/dist/src/capture/buffer.d.ts.map +1 -0
  43. package/dist/src/capture/buffer.js +55 -0
  44. package/dist/src/capture/buffer.js.map +1 -0
  45. package/dist/src/capture/plan-detector.d.ts +15 -0
  46. package/dist/src/capture/plan-detector.d.ts.map +1 -0
  47. package/dist/src/capture/plan-detector.js +34 -0
  48. package/dist/src/capture/plan-detector.js.map +1 -0
  49. package/dist/src/capture/processor.d.ts +2 -0
  50. package/dist/src/capture/processor.d.ts.map +1 -0
  51. package/dist/src/capture/processor.js +3 -0
  52. package/dist/src/capture/processor.js.map +1 -0
  53. package/dist/src/capture/prompts/classify.md +28 -0
  54. package/dist/src/capture/prompts/debugging.md +91 -0
  55. package/dist/src/capture/prompts/exploration.md +88 -0
  56. package/dist/src/capture/prompts/extraction.md +93 -0
  57. package/dist/src/capture/prompts/implementation.md +90 -0
  58. package/dist/src/capture/prompts/prompts/classify.md +28 -0
  59. package/dist/src/capture/prompts/prompts/debugging.md +91 -0
  60. package/dist/src/capture/prompts/prompts/exploration.md +88 -0
  61. package/dist/src/capture/prompts/prompts/extraction.md +93 -0
  62. package/dist/src/capture/prompts/prompts/implementation.md +90 -0
  63. package/dist/src/capture/prompts/prompts/schema.yaml +97 -0
  64. package/dist/src/capture/prompts/prompts/session-summary.md +65 -0
  65. package/dist/src/capture/prompts/prompts/session-title.md +46 -0
  66. package/dist/src/capture/prompts/schema.yaml +97 -0
  67. package/dist/src/capture/prompts/session-summary.md +65 -0
  68. package/dist/src/capture/prompts/session-title.md +46 -0
  69. package/dist/src/capture/prompts.d.ts +77 -0
  70. package/dist/src/capture/prompts.d.ts.map +1 -0
  71. package/dist/src/capture/prompts.js +255 -0
  72. package/dist/src/capture/prompts.js.map +1 -0
  73. package/dist/src/capture/transcript-miner.d.ts +31 -0
  74. package/dist/src/capture/transcript-miner.d.ts.map +1 -0
  75. package/dist/src/capture/transcript-miner.js +61 -0
  76. package/dist/src/capture/transcript-miner.js.map +1 -0
  77. package/dist/src/cli.d.ts +3 -0
  78. package/dist/src/cli.d.ts.map +1 -0
  79. package/dist/src/cli.js +584 -0
  80. package/dist/src/cli.js.map +1 -0
  81. package/dist/src/config/loader.d.ts +4 -0
  82. package/dist/src/config/loader.d.ts.map +1 -0
  83. package/dist/src/config/loader.js +32 -0
  84. package/dist/src/config/loader.js.map +1 -0
  85. package/dist/src/config/schema.d.ts +83 -0
  86. package/dist/src/config/schema.d.ts.map +1 -0
  87. package/dist/src/config/schema.js +55 -0
  88. package/dist/src/config/schema.js.map +1 -0
  89. package/dist/src/constants.d.ts +73 -0
  90. package/dist/src/constants.d.ts.map +1 -0
  91. package/dist/src/constants.js +86 -0
  92. package/dist/src/constants.js.map +1 -0
  93. package/dist/src/context/injector.d.ts +18 -0
  94. package/dist/src/context/injector.d.ts.map +1 -0
  95. package/dist/src/context/injector.js +71 -0
  96. package/dist/src/context/injector.js.map +1 -0
  97. package/dist/src/context/relevance.d.ts +13 -0
  98. package/dist/src/context/relevance.d.ts.map +1 -0
  99. package/dist/src/context/relevance.js +44 -0
  100. package/dist/src/context/relevance.js.map +1 -0
  101. package/dist/src/daemon/batch.d.ts +22 -0
  102. package/dist/src/daemon/batch.d.ts.map +1 -0
  103. package/dist/src/daemon/batch.js +38 -0
  104. package/dist/src/daemon/batch.js.map +1 -0
  105. package/dist/src/daemon/lifecycle.d.ts +27 -0
  106. package/dist/src/daemon/lifecycle.d.ts.map +1 -0
  107. package/dist/src/daemon/lifecycle.js +50 -0
  108. package/dist/src/daemon/lifecycle.js.map +1 -0
  109. package/dist/src/daemon/lineage.d.ts +42 -0
  110. package/dist/src/daemon/lineage.d.ts.map +1 -0
  111. package/dist/src/daemon/lineage.js +116 -0
  112. package/dist/src/daemon/lineage.js.map +1 -0
  113. package/dist/src/daemon/logger.d.ts +33 -0
  114. package/dist/src/daemon/logger.d.ts.map +1 -0
  115. package/dist/src/daemon/logger.js +88 -0
  116. package/dist/src/daemon/logger.js.map +1 -0
  117. package/dist/src/daemon/main.d.ts +2 -0
  118. package/dist/src/daemon/main.d.ts.map +1 -0
  119. package/dist/src/daemon/main.js +738 -0
  120. package/dist/src/daemon/main.js.map +1 -0
  121. package/dist/src/daemon/processor.d.ts +44 -0
  122. package/dist/src/daemon/processor.d.ts.map +1 -0
  123. package/dist/src/daemon/processor.js +142 -0
  124. package/dist/src/daemon/processor.js.map +1 -0
  125. package/dist/src/daemon/server.d.ts +24 -0
  126. package/dist/src/daemon/server.d.ts.map +1 -0
  127. package/dist/src/daemon/server.js +117 -0
  128. package/dist/src/daemon/server.js.map +1 -0
  129. package/dist/src/daemon/watcher.d.ts +29 -0
  130. package/dist/src/daemon/watcher.d.ts.map +1 -0
  131. package/dist/src/daemon/watcher.js +67 -0
  132. package/dist/src/daemon/watcher.js.map +1 -0
  133. package/dist/src/hooks/client.d.ts +20 -0
  134. package/dist/src/hooks/client.d.ts.map +1 -0
  135. package/dist/src/hooks/client.js +111 -0
  136. package/dist/src/hooks/client.js.map +1 -0
  137. package/dist/src/hooks/post-tool-use.d.ts +2 -0
  138. package/dist/src/hooks/post-tool-use.d.ts.map +1 -0
  139. package/dist/src/hooks/post-tool-use.js +40 -0
  140. package/dist/src/hooks/post-tool-use.js.map +1 -0
  141. package/dist/src/hooks/read-stdin.d.ts +2 -0
  142. package/dist/src/hooks/read-stdin.d.ts.map +1 -0
  143. package/dist/src/hooks/read-stdin.js +10 -0
  144. package/dist/src/hooks/read-stdin.js.map +1 -0
  145. package/dist/src/hooks/session-end.d.ts +2 -0
  146. package/dist/src/hooks/session-end.d.ts.map +1 -0
  147. package/dist/src/hooks/session-end.js +23 -0
  148. package/dist/src/hooks/session-end.js.map +1 -0
  149. package/dist/src/hooks/session-start.d.ts +2 -0
  150. package/dist/src/hooks/session-start.d.ts.map +1 -0
  151. package/dist/src/hooks/session-start.js +49 -0
  152. package/dist/src/hooks/session-start.js.map +1 -0
  153. package/dist/src/hooks/stop.d.ts +2 -0
  154. package/dist/src/hooks/stop.d.ts.map +1 -0
  155. package/dist/src/hooks/stop.js +34 -0
  156. package/dist/src/hooks/stop.js.map +1 -0
  157. package/dist/src/hooks/user-prompt-submit.d.ts +2 -0
  158. package/dist/src/hooks/user-prompt-submit.d.ts.map +1 -0
  159. package/dist/src/hooks/user-prompt-submit.js +46 -0
  160. package/dist/src/hooks/user-prompt-submit.js.map +1 -0
  161. package/dist/src/index/fts.d.ts +16 -0
  162. package/dist/src/index/fts.d.ts.map +1 -0
  163. package/dist/src/index/fts.js +53 -0
  164. package/dist/src/index/fts.js.map +1 -0
  165. package/dist/src/index/rebuild.d.ts +4 -0
  166. package/dist/src/index/rebuild.d.ts.map +1 -0
  167. package/dist/src/index/rebuild.js +40 -0
  168. package/dist/src/index/rebuild.js.map +1 -0
  169. package/dist/src/index/sqlite.d.ts +33 -0
  170. package/dist/src/index/sqlite.d.ts.map +1 -0
  171. package/dist/src/index/sqlite.js +99 -0
  172. package/dist/src/index/sqlite.js.map +1 -0
  173. package/dist/src/index/vectors.d.ts +24 -0
  174. package/dist/src/index/vectors.d.ts.map +1 -0
  175. package/dist/src/index/vectors.js +97 -0
  176. package/dist/src/index/vectors.js.map +1 -0
  177. package/dist/src/intelligence/anthropic.d.ts +17 -0
  178. package/dist/src/intelligence/anthropic.d.ts.map +1 -0
  179. package/dist/src/intelligence/anthropic.js +36 -0
  180. package/dist/src/intelligence/anthropic.js.map +1 -0
  181. package/dist/src/intelligence/embeddings.d.ts +3 -0
  182. package/dist/src/intelligence/embeddings.d.ts.map +1 -0
  183. package/dist/src/intelligence/embeddings.js +15 -0
  184. package/dist/src/intelligence/embeddings.js.map +1 -0
  185. package/dist/src/intelligence/haiku.d.ts +17 -0
  186. package/dist/src/intelligence/haiku.d.ts.map +1 -0
  187. package/dist/src/intelligence/haiku.js +35 -0
  188. package/dist/src/intelligence/haiku.js.map +1 -0
  189. package/dist/src/intelligence/llm.d.ts +33 -0
  190. package/dist/src/intelligence/llm.d.ts.map +1 -0
  191. package/dist/src/intelligence/llm.js +26 -0
  192. package/dist/src/intelligence/llm.js.map +1 -0
  193. package/dist/src/intelligence/lm-studio.d.ts +20 -0
  194. package/dist/src/intelligence/lm-studio.d.ts.map +1 -0
  195. package/dist/src/intelligence/lm-studio.js +59 -0
  196. package/dist/src/intelligence/lm-studio.js.map +1 -0
  197. package/dist/src/intelligence/ollama.d.ts +22 -0
  198. package/dist/src/intelligence/ollama.d.ts.map +1 -0
  199. package/dist/src/intelligence/ollama.js +64 -0
  200. package/dist/src/intelligence/ollama.js.map +1 -0
  201. package/dist/src/intelligence/response.d.ts +29 -0
  202. package/dist/src/intelligence/response.d.ts.map +1 -0
  203. package/dist/src/intelligence/response.js +71 -0
  204. package/dist/src/intelligence/response.js.map +1 -0
  205. package/dist/src/intelligence/service.d.ts +18 -0
  206. package/dist/src/intelligence/service.d.ts.map +1 -0
  207. package/dist/src/intelligence/service.js +66 -0
  208. package/dist/src/intelligence/service.js.map +1 -0
  209. package/dist/src/logs/format.d.ts +6 -0
  210. package/dist/src/logs/format.d.ts.map +1 -0
  211. package/dist/src/logs/format.js +46 -0
  212. package/dist/src/logs/format.js.map +1 -0
  213. package/dist/src/logs/reader.d.ts +28 -0
  214. package/dist/src/logs/reader.d.ts.map +1 -0
  215. package/dist/src/logs/reader.js +106 -0
  216. package/dist/src/logs/reader.js.map +1 -0
  217. package/dist/src/mcp/server.d.ts +16 -0
  218. package/dist/src/mcp/server.d.ts.map +1 -0
  219. package/dist/src/mcp/server.js +305 -0
  220. package/dist/src/mcp/server.js.map +1 -0
  221. package/dist/src/mcp/tools/consolidate.d.ts +15 -0
  222. package/dist/src/mcp/tools/consolidate.d.ts.map +1 -0
  223. package/dist/src/mcp/tools/consolidate.js +49 -0
  224. package/dist/src/mcp/tools/consolidate.js.map +1 -0
  225. package/dist/src/mcp/tools/graph.d.ts +30 -0
  226. package/dist/src/mcp/tools/graph.d.ts.map +1 -0
  227. package/dist/src/mcp/tools/graph.js +106 -0
  228. package/dist/src/mcp/tools/graph.js.map +1 -0
  229. package/dist/src/mcp/tools/logs.d.ts +3 -0
  230. package/dist/src/mcp/tools/logs.d.ts.map +1 -0
  231. package/dist/src/mcp/tools/logs.js +7 -0
  232. package/dist/src/mcp/tools/logs.js.map +1 -0
  233. package/dist/src/mcp/tools/plans.d.ts +23 -0
  234. package/dist/src/mcp/tools/plans.d.ts.map +1 -0
  235. package/dist/src/mcp/tools/plans.js +63 -0
  236. package/dist/src/mcp/tools/plans.js.map +1 -0
  237. package/dist/src/mcp/tools/recall.d.ts +30 -0
  238. package/dist/src/mcp/tools/recall.d.ts.map +1 -0
  239. package/dist/src/mcp/tools/recall.js +34 -0
  240. package/dist/src/mcp/tools/recall.js.map +1 -0
  241. package/dist/src/mcp/tools/remember.d.ts +15 -0
  242. package/dist/src/mcp/tools/remember.d.ts.map +1 -0
  243. package/dist/src/mcp/tools/remember.js +18 -0
  244. package/dist/src/mcp/tools/remember.js.map +1 -0
  245. package/dist/src/mcp/tools/search.d.ts +19 -0
  246. package/dist/src/mcp/tools/search.d.ts.map +1 -0
  247. package/dist/src/mcp/tools/search.js +59 -0
  248. package/dist/src/mcp/tools/search.js.map +1 -0
  249. package/dist/src/mcp/tools/sessions.d.ts +21 -0
  250. package/dist/src/mcp/tools/sessions.d.ts.map +1 -0
  251. package/dist/src/mcp/tools/sessions.js +36 -0
  252. package/dist/src/mcp/tools/sessions.js.map +1 -0
  253. package/dist/src/mcp/tools/supersede.d.ts +14 -0
  254. package/dist/src/mcp/tools/supersede.d.ts.map +1 -0
  255. package/dist/src/mcp/tools/supersede.js +30 -0
  256. package/dist/src/mcp/tools/supersede.js.map +1 -0
  257. package/dist/src/mcp/tools/team.d.ts +16 -0
  258. package/dist/src/mcp/tools/team.d.ts.map +1 -0
  259. package/dist/src/mcp/tools/team.js +32 -0
  260. package/dist/src/mcp/tools/team.js.map +1 -0
  261. package/dist/src/obsidian/formatter.d.ts +80 -0
  262. package/dist/src/obsidian/formatter.d.ts.map +1 -0
  263. package/dist/src/obsidian/formatter.js +227 -0
  264. package/dist/src/obsidian/formatter.js.map +1 -0
  265. package/dist/src/prompts/classification.md +42 -0
  266. package/dist/src/prompts/extraction.md +45 -0
  267. package/dist/src/prompts/index.d.ts +13 -0
  268. package/dist/src/prompts/index.d.ts.map +1 -0
  269. package/dist/src/prompts/index.js +75 -0
  270. package/dist/src/prompts/index.js.map +1 -0
  271. package/dist/src/prompts/session-similarity.md +24 -0
  272. package/dist/src/prompts/summary.md +9 -0
  273. package/dist/src/prompts/title.md +8 -0
  274. package/dist/src/vault/frontmatter.d.ts +6 -0
  275. package/dist/src/vault/frontmatter.d.ts.map +1 -0
  276. package/dist/src/vault/frontmatter.js +10 -0
  277. package/dist/src/vault/frontmatter.js.map +1 -0
  278. package/dist/src/vault/observations.d.ts +10 -0
  279. package/dist/src/vault/observations.d.ts.map +1 -0
  280. package/dist/src/vault/observations.js +33 -0
  281. package/dist/src/vault/observations.js.map +1 -0
  282. package/dist/src/vault/reader.d.ts +10 -0
  283. package/dist/src/vault/reader.d.ts.map +1 -0
  284. package/dist/src/vault/reader.js +48 -0
  285. package/dist/src/vault/reader.js.map +1 -0
  286. package/dist/src/vault/resolve.d.ts +18 -0
  287. package/dist/src/vault/resolve.d.ts.map +1 -0
  288. package/dist/src/vault/resolve.js +51 -0
  289. package/dist/src/vault/resolve.js.map +1 -0
  290. package/dist/src/vault/session-id.d.ts +16 -0
  291. package/dist/src/vault/session-id.d.ts.map +1 -0
  292. package/dist/src/vault/session-id.js +29 -0
  293. package/dist/src/vault/session-id.js.map +1 -0
  294. package/dist/src/vault/types.d.ts +88 -0
  295. package/dist/src/vault/types.d.ts.map +1 -0
  296. package/dist/src/vault/types.js +94 -0
  297. package/dist/src/vault/types.js.map +1 -0
  298. package/dist/src/vault/writer.d.ts +66 -0
  299. package/dist/src/vault/writer.d.ts.map +1 -0
  300. package/dist/src/vault/writer.js +217 -0
  301. package/dist/src/vault/writer.js.map +1 -0
  302. package/hooks/hooks.json +60 -0
  303. package/package.json +52 -0
  304. package/skills/myco/SKILL.md +206 -0
  305. package/skills/myco/references/wisdom.md +61 -0
  306. package/skills/rules/SKILL.md +185 -0
  307. package/skills/rules/references/rules-bad-example.md +106 -0
  308. package/skills/rules/references/rules-good-example.md +90 -0
@@ -0,0 +1,227 @@
1
+ import { sessionNoteId } from '../vault/session-id.js';
2
+ // Callout type mapping for observation types
3
+ const CALLOUT_MAP = {
4
+ gotcha: 'warning',
5
+ bug_fix: 'bug',
6
+ decision: 'info',
7
+ discovery: 'tip',
8
+ trade_off: 'question',
9
+ };
10
+ export function observationCalloutType(observationType) {
11
+ return CALLOUT_MAP[observationType] ?? 'note';
12
+ }
13
+ export function callout(type, title, content) {
14
+ const indented = content.split('\n').map((line) => `> ${line}`).join('\n');
15
+ return `> [!${type}] ${title}\n${indented}`;
16
+ }
17
+ export function inlineField(key, value) {
18
+ return `${key}:: ${value}`;
19
+ }
20
+ export function wikilink(target, display) {
21
+ return display ? `[[${target}|${display}]]` : `[[${target}]]`;
22
+ }
23
+ /**
24
+ * Normalize an observation_type to a tag-safe form.
25
+ * Frontmatter keeps underscores; tags use hyphens per Obsidian convention.
26
+ */
27
+ function tagNormalize(s) {
28
+ return s.replace(/_/g, '-');
29
+ }
30
+ /**
31
+ * Sanitize a user/LLM-provided tag for Obsidian compatibility.
32
+ * Obsidian tags cannot contain spaces — replace with slash (nested tag).
33
+ * Strips leading # if present.
34
+ */
35
+ function sanitizeTag(raw) {
36
+ const stripped = raw.startsWith('#') ? raw.slice(1) : raw;
37
+ return stripped.replace(/\s+/g, '/');
38
+ }
39
+ export function buildTags(type, subtype, extraTags = []) {
40
+ const tags = [`type/${type}`];
41
+ if (subtype) {
42
+ tags.push(`${type}/${tagNormalize(subtype)}`);
43
+ }
44
+ for (const tag of extraTags) {
45
+ const normalized = sanitizeTag(tag);
46
+ if (normalized && !tags.includes(normalized)) {
47
+ tags.push(normalized);
48
+ }
49
+ }
50
+ return tags;
51
+ }
52
+ export function footerTags(tags) {
53
+ return tags.map((t) => (t.startsWith('#') ? t : `#${t}`)).join(' ');
54
+ }
55
+ export function formatSessionBody(input) {
56
+ const sections = [];
57
+ sections.push(`# ${input.title}`);
58
+ if (input.narrative) {
59
+ sections.push(callout('abstract', 'Summary', input.narrative));
60
+ }
61
+ // Inline fields
62
+ const fields = [];
63
+ fields.push(inlineField('Session', wikilink(sessionNoteId(input.sessionId))));
64
+ if (input.user)
65
+ fields.push(inlineField('User', input.user));
66
+ if (input.started && input.ended) {
67
+ const duration = formatDuration(input.started, input.ended);
68
+ if (duration)
69
+ fields.push(inlineField('Duration', duration));
70
+ }
71
+ if (input.branch)
72
+ fields.push(inlineField('Branch', `\`${input.branch}\``));
73
+ sections.push(fields.join('\n'));
74
+ // Related memories
75
+ if (input.relatedMemories?.length) {
76
+ const links = input.relatedMemories.map((m) => `- ${wikilink(m.id, m.title)}`);
77
+ sections.push(`## Related Memories\n${links.join('\n')}`);
78
+ }
79
+ // Conversation turns — always rebuilt from the full transcript.
80
+ // The transcript is the source of truth for the complete conversation.
81
+ if (input.turns.length > 0) {
82
+ const turnLines = [];
83
+ for (let i = 0; i < input.turns.length; i++) {
84
+ const turn = input.turns[i];
85
+ const turnNum = i + 1;
86
+ turnLines.push(`### Turn ${turnNum}`);
87
+ if (turn.prompt || turn.images?.length) {
88
+ // Build prompt content: text + images + tool count
89
+ const parts = [];
90
+ if (turn.prompt)
91
+ parts.push(turn.prompt);
92
+ if (turn.images?.length) {
93
+ parts.push(turn.images.map((f) => `![[${f}]]`).join('\n'));
94
+ }
95
+ if (turn.toolCount > 0)
96
+ parts.push(`*${turn.toolCount} tool calls*`);
97
+ turnLines.push(callout('user', 'Prompt', parts.join('\n\n')));
98
+ }
99
+ else if (turn.toolCount > 0) {
100
+ turnLines.push(callout('user', 'Prompt', `*${turn.toolCount} tool calls*`));
101
+ }
102
+ if (turn.aiResponse) {
103
+ turnLines.push(callout('assistant', 'Response', turn.aiResponse));
104
+ }
105
+ }
106
+ sections.push(`## Conversation\n\n${turnLines.join('\n\n')}`);
107
+ }
108
+ // Footer tags
109
+ const allTags = buildTags('session', 'ended', [
110
+ ...(input.user ? [`user/${input.user}`] : []),
111
+ ...(input.tags ?? []),
112
+ ]);
113
+ sections.push(footerTags(allTags));
114
+ return sections.join('\n\n');
115
+ }
116
+ export function formatMemoryBody(input) {
117
+ const sections = [];
118
+ const calloutType = observationCalloutType(input.observationType);
119
+ const calloutTitle = capitalize(tagNormalize(input.observationType));
120
+ sections.push(`# ${input.title}`);
121
+ sections.push(callout(calloutType, calloutTitle, input.content));
122
+ // Inline fields
123
+ const fields = [];
124
+ if (input.sessionId) {
125
+ fields.push(inlineField('Session', wikilink(sessionNoteId(input.sessionId))));
126
+ }
127
+ fields.push(inlineField('Observation', input.observationType));
128
+ if (fields.length > 0)
129
+ sections.push(fields.join('\n'));
130
+ // Type-specific sub-sections
131
+ if (input.root_cause)
132
+ sections.push(`## Root Cause\n${input.root_cause}`);
133
+ if (input.fix)
134
+ sections.push(`## Fix\n${input.fix}`);
135
+ if (input.rationale)
136
+ sections.push(`## Rationale\n${input.rationale}`);
137
+ if (input.alternatives_rejected)
138
+ sections.push(`## Alternatives Rejected\n${input.alternatives_rejected}`);
139
+ if (input.gained)
140
+ sections.push(`## Gained\n${input.gained}`);
141
+ if (input.sacrificed)
142
+ sections.push(`## Sacrificed\n${input.sacrificed}`);
143
+ // Footer tags
144
+ const allTags = buildTags('memory', input.observationType, input.tags ?? []);
145
+ sections.push(footerTags(allTags));
146
+ return sections.join('\n\n');
147
+ }
148
+ export function formatPlanBody(input) {
149
+ const sections = [];
150
+ // Inline fields block
151
+ const fields = [];
152
+ fields.push(inlineField('Plan', wikilink(input.id)));
153
+ fields.push(inlineField('Status', input.status));
154
+ if (input.author)
155
+ fields.push(inlineField('Author', input.author));
156
+ if (input.created)
157
+ fields.push(inlineField('Created', input.created));
158
+ sections.push(fields.join('\n'));
159
+ // User-provided content body (don't restructure)
160
+ sections.push(input.content);
161
+ // Sessions section
162
+ if (input.sessions?.length) {
163
+ const links = input.sessions.map((s) => `- ${wikilink(sessionNoteId(s.id), s.title)}`);
164
+ sections.push(`## Sessions\n${links.join('\n')}`);
165
+ }
166
+ // Footer tags
167
+ const statusTag = tagNormalize(input.status);
168
+ const allTags = buildTags('plan', statusTag, input.tags ?? []);
169
+ sections.push(footerTags(allTags));
170
+ return sections.join('\n\n');
171
+ }
172
+ export function formatArtifactBody(input) {
173
+ const sections = [];
174
+ // Inline fields
175
+ const fields = [];
176
+ fields.push(inlineField('Artifact', wikilink(input.id)));
177
+ fields.push(inlineField('Source', `\`${input.source_path}\``));
178
+ fields.push(inlineField('Type', input.artifact_type));
179
+ fields.push(inlineField('Session', wikilink(sessionNoteId(input.sessionId))));
180
+ sections.push(fields.join('\n'));
181
+ // Body: full content from disk
182
+ sections.push(input.content);
183
+ // Footer tags
184
+ const allTags = buildTags('artifact', input.artifact_type, input.tags ?? []);
185
+ sections.push(footerTags(allTags));
186
+ return sections.join('\n\n');
187
+ }
188
+ export function formatTeamBody(input) {
189
+ const sections = [];
190
+ sections.push(`# ${input.user}`);
191
+ sections.push(callout('info', 'Team Member', input.role ?? 'Contributor'));
192
+ // Inline fields
193
+ const fields = [];
194
+ fields.push(inlineField('User', input.user));
195
+ if (input.role)
196
+ fields.push(inlineField('Role', input.role));
197
+ sections.push(fields.join('\n'));
198
+ // Recent sessions
199
+ if (input.recentSessions?.length) {
200
+ const links = input.recentSessions.map((s) => `- ${wikilink(sessionNoteId(s.id), s.title)}`);
201
+ sections.push(`## Recent Sessions\n${links.join('\n')}`);
202
+ }
203
+ // Footer tags
204
+ const allTags = buildTags('team', '', [`user/${input.user}`]);
205
+ sections.push(footerTags(allTags));
206
+ return sections.join('\n\n');
207
+ }
208
+ // --- Helpers ---
209
+ function capitalize(s) {
210
+ return s.charAt(0).toUpperCase() + s.slice(1);
211
+ }
212
+ function formatDuration(started, ended) {
213
+ const ms = new Date(ended).getTime() - new Date(started).getTime();
214
+ if (isNaN(ms) || ms < 0)
215
+ return '';
216
+ const totalMinutes = Math.floor(ms / 60000);
217
+ if (totalMinutes < 1)
218
+ return '<1m';
219
+ const hours = Math.floor(totalMinutes / 60);
220
+ const minutes = totalMinutes % 60;
221
+ if (hours === 0)
222
+ return `${minutes}m`;
223
+ if (minutes === 0)
224
+ return `${hours}h`;
225
+ return `${hours}h ${minutes}m`;
226
+ }
227
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/obsidian/formatter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,6CAA6C;AAC7C,MAAM,WAAW,GAA2B;IAC1C,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,UAAU;CACtB,CAAC;AAEF,MAAM,UAAU,sBAAsB,CAAC,eAAuB;IAC5D,OAAO,WAAW,CAAC,eAAe,CAAC,IAAI,MAAM,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,KAAa,EAAE,OAAe;IAClE,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E,OAAO,OAAO,IAAI,KAAK,KAAK,KAAK,QAAQ,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,KAAa;IACpD,OAAO,GAAG,GAAG,MAAM,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,U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AO,GAAG,CAAC;AACjC,CAAC"}
@@ -0,0 +1,42 @@
1
+ You are classifying files from coding session "{{sessionId}}" to determine which are substantive **project** artifacts worth preserving in a knowledge vault.
2
+
3
+ ## Candidate Files
4
+
5
+ {{fileList}}
6
+
7
+ ## Task
8
+
9
+ For each file that is a substantive project artifact (design doc, specification, implementation plan, RFC, or project documentation), classify it.
10
+
11
+ **DO NOT classify these — they are tooling, not project artifacts:**
12
+ - Agent/LLM instruction files (CLAUDE.md, AGENTS.md, GEMINI.md, rules files)
13
+ - Plugin components: slash commands, skills, hooks, plugin manifests
14
+ - Configuration files, dotfiles, settings
15
+ - Implementation code, test files, generated output
16
+ - Prompt templates used by the tool/plugin itself
17
+ - README, CONTRIBUTING, CHANGELOG, LICENSE files
18
+ - GitHub/CI templates: pull request templates, issue templates, workflow files
19
+ - Documentation that describes how to use the tool or repo (quickstart guides, lifecycle docs)
20
+
21
+ **DO classify these — they are project artifacts:**
22
+ - Design specifications and architecture documents
23
+ - Implementation plans and roadmaps
24
+ - RFCs and proposals
25
+ - Project documentation that captures decisions, context, or knowledge
26
+
27
+ Artifact types:
28
+ {{artifactTypes}}
29
+
30
+ Respond with valid JSON only, no markdown fences:
31
+ {
32
+ "artifacts": [
33
+ {
34
+ "source_path": "exact/path/from/above",
35
+ "artifact_type": "{{validTypes}}",
36
+ "title": "Human-readable title",
37
+ "tags": ["single_word_tags", "no spaces"]
38
+ }
39
+ ]
40
+ }
41
+
42
+ If none of the candidates are artifacts, respond with: {"artifacts": []}
@@ -0,0 +1,45 @@
1
+ You are analyzing a coding session buffer for session "{{sessionId}}".
2
+
3
+ ## Events ({{eventCount}} total)
4
+ {{toolSummary}}
5
+
6
+ ## Task
7
+ Analyze these events and produce a JSON response with exactly this structure:
8
+ {
9
+ "summary": "A concise narrative of what happened in this session (2-4 sentences).",
10
+ "observations": [
11
+ {
12
+ "type": "gotcha|bug_fix|decision|discovery|trade_off",
13
+ "title": "Short descriptive title",
14
+ "content": "Detailed explanation of the observation.",
15
+ "tags": ["relevant", "tags"]
16
+ }
17
+ ]
18
+ }
19
+
20
+ ## Type-Specific Fields
21
+ Include these additional fields when appropriate for the observation type:
22
+
23
+ - **bug_fix**: add "root_cause" (what caused the bug) and "fix" (what resolved it)
24
+ - **decision**: add "rationale" (why this choice) and "alternatives_rejected" (what was considered and why not)
25
+ - **trade_off**: add "gained" (what was achieved) and "sacrificed" (what was given up)
26
+
27
+ These fields are optional — only include them when the session provides clear evidence.
28
+
29
+ ## Observation Guidelines
30
+ Only include observations that meet ALL criteria:
31
+ - Valuable to a teammate encountering the same code/problem
32
+ - Not obvious from reading the code itself
33
+ - Not specific to this session's transient state
34
+
35
+ Types:
36
+ - "gotcha": A non-obvious problem, pitfall, or workaround
37
+ - "bug_fix": Root cause of a bug and what fixed it
38
+ - "decision": An architectural or technical choice, with rationale and rejected alternatives
39
+ - "discovery": A significant learning about the codebase, tooling, or domain
40
+ - "trade_off": What was sacrificed and why
41
+
42
+ Routine activity (file reads, searches, test runs, navigation) goes in the summary only.
43
+ Target 0-5 observations. Err on fewer, higher-quality observations.
44
+
45
+ Respond with valid JSON only, no markdown fences.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Prompt loader — reads .md templates from disk and interpolates variables.
3
+ * Prompts are markdown files in this directory, not TypeScript strings.
4
+ */
5
+ export declare function buildExtractionPrompt(sessionId: string, eventCount: number, toolSummary: string): string;
6
+ export declare function buildSummaryPrompt(sessionId: string, user: string, content: string): string;
7
+ export declare function buildTitlePrompt(summary: string, sessionId: string): string;
8
+ export declare function buildSimilarityPrompt(currentSummary: string, candidateSummary: string): string;
9
+ export declare function buildClassificationPrompt(sessionId: string, candidates: Array<{
10
+ path: string;
11
+ content: string;
12
+ }>): string;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+BH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAMR;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,MAAM,CAMR;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,MAAM,CAKR;AAUD,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAKR;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACnD,MAAM,CAcR"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Prompt loader — reads .md templates from disk and interpolates variables.
3
+ * Prompts are markdown files in this directory, not TypeScript strings.
4
+ */
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { ARTIFACT_TYPES } from '../vault/types.js';
9
+ import { CANDIDATE_CONTENT_PREVIEW } from '../constants.js';
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+ const promptCache = new Map();
12
+ function loadPrompt(name) {
13
+ let cached = promptCache.get(name);
14
+ if (!cached) {
15
+ cached = fs.readFileSync(path.join(__dirname, `${name}.md`), 'utf-8').trim();
16
+ promptCache.set(name, cached);
17
+ }
18
+ return cached;
19
+ }
20
+ function interpolate(template, vars) {
21
+ let result = template;
22
+ for (const [key, value] of Object.entries(vars)) {
23
+ result = result.replaceAll(`{{${key}}}`, value);
24
+ }
25
+ return result;
26
+ }
27
+ // --- Prompt builders ---
28
+ export function buildExtractionPrompt(sessionId, eventCount, toolSummary) {
29
+ return interpolate(loadPrompt('extraction'), {
30
+ sessionId,
31
+ eventCount: String(eventCount),
32
+ toolSummary,
33
+ });
34
+ }
35
+ export function buildSummaryPrompt(sessionId, user, content) {
36
+ return interpolate(loadPrompt('summary'), {
37
+ sessionId,
38
+ user,
39
+ content,
40
+ });
41
+ }
42
+ export function buildTitlePrompt(summary, sessionId) {
43
+ return interpolate(loadPrompt('title'), {
44
+ summary,
45
+ sessionId,
46
+ });
47
+ }
48
+ const ARTIFACT_TYPE_DESCRIPTIONS = [
49
+ '"spec" — Design specifications, architecture documents',
50
+ '"plan" — Implementation plans, roadmaps',
51
+ '"rfc" — Requests for comment, proposals',
52
+ '"doc" — Documentation, guides, READMEs',
53
+ '"other" — Other substantive documents',
54
+ ];
55
+ export function buildSimilarityPrompt(currentSummary, candidateSummary) {
56
+ return interpolate(loadPrompt('session-similarity'), {
57
+ currentSummary,
58
+ candidateSummary,
59
+ });
60
+ }
61
+ export function buildClassificationPrompt(sessionId, candidates) {
62
+ const fileList = candidates
63
+ .map((c) => {
64
+ const truncated = c.content.slice(0, CANDIDATE_CONTENT_PREVIEW);
65
+ return `### ${c.path}\n\`\`\`\n${truncated}\n\`\`\``;
66
+ })
67
+ .join('\n\n');
68
+ return interpolate(loadPrompt('classification'), {
69
+ sessionId,
70
+ fileList,
71
+ artifactTypes: ARTIFACT_TYPE_DESCRIPTIONS.map((d) => `- ${d}`).join('\n'),
72
+ validTypes: ARTIFACT_TYPES.join('|'),
73
+ });
74
+ }
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;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;QACJ,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,SAAiB;IAEjB,OAAO,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QACtC,OAAO;QACP,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAED,MAAM,0BAA0B,GAAG;IACjC,wDAAwD;IACxD,yCAAyC;IACzC,yCAAyC;IACzC,wCAAwC;IACxC,uCAAuC;CACxC,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,gBAAwB;IAExB,OAAO,WAAW,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;QACnD,cAAc;QACd,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,SAAiB,EACjB,UAAoD;IAEpD,MAAM,QAAQ,GAAG,UAAU;SACxB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC;QAChE,OAAO,OAAO,CAAC,CAAC,IAAI,aAAa,SAAS,UAAU,CAAC;IACvD,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO,WAAW,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QAC/C,SAAS;QACT,QAAQ;QACR,aAAa,EAAE,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACzE,UAAU,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC;KACrC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ Rate how related these two coding sessions are on a scale of 0.0 to 1.0.
2
+
3
+ ## Current Session
4
+ {{currentSummary}}
5
+
6
+ ## Candidate Parent Session
7
+ {{candidateSummary}}
8
+
9
+ ## Scoring Guidelines
10
+
11
+ 1. **Same feature/bug** (high weight): Both sessions working on the same feature, bug fix, or component? Same file names or modules?
12
+ 2. **Continuation pattern** (high weight): Does the current session continue work from the candidate? References decisions, plans, or outcomes?
13
+ 3. **Related work** (medium weight): Related but distinct features? Same area of the codebase?
14
+ 4. **Unrelated** (low score): Different features, different parts of the codebase.
15
+
16
+ ## Score Ranges
17
+
18
+ - 0.9-1.0: Direct continuation (picks up exactly where the other left off)
19
+ - 0.7-0.9: Same feature/bug (clearly related work)
20
+ - 0.5-0.7: Related work (same area, related features)
21
+ - 0.3-0.5: Loosely related (some overlap but different focus)
22
+ - 0.0-0.3: Unrelated (different work entirely)
23
+
24
+ Respond with ONLY a single number between 0.0 and 1.0.
@@ -0,0 +1,9 @@
1
+ You are summarizing a coding session for user "{{user}}" (session "{{sessionId}}").
2
+
3
+ ## Session Content
4
+ {{content}}
5
+
6
+ ## Task
7
+ Write a concise narrative summary of this session (3-6 sentences). Describe what was accomplished, key decisions made, and any problems encountered. Focus on outcomes rather than individual tool calls.
8
+
9
+ Respond with plain text only, no JSON or markdown fences.
@@ -0,0 +1,8 @@
1
+ Given this session summary, produce a short, descriptive title (5-10 words) suitable for a vault note heading.
2
+
3
+ Summary:
4
+ {{summary}}
5
+
6
+ Session ID: {{sessionId}}
7
+
8
+ Respond with the title text only, no quotes, no punctuation at the end.
@@ -0,0 +1,6 @@
1
+ import type { IndexedNote } from '../index/sqlite.js';
2
+ import type { PlanFrontmatter, SessionFrontmatter, MemoryFrontmatter } from './types.js';
3
+ export declare function planFm(note: IndexedNote): PlanFrontmatter;
4
+ export declare function sessionFm(note: IndexedNote): SessionFrontmatter;
5
+ export declare function memoryFm(note: IndexedNote): MemoryFrontmatter;
6
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../src/vault/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEzF,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAEzD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB,CAE/D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,iBAAiB,CAE7D"}
@@ -0,0 +1,10 @@
1
+ export function planFm(note) {
2
+ return note.frontmatter;
3
+ }
4
+ export function sessionFm(note) {
5
+ return note.frontmatter;
6
+ }
7
+ export function memoryFm(note) {
8
+ return note.frontmatter;
9
+ }
10
+ //# sourceMappingURL=frontmatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../src/vault/frontmatter.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,MAAM,CAAC,IAAiB;IACtC,OAAO,IAAI,CAAC,WAAyC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAiB;IACzC,OAAO,IAAI,CAAC,WAA4C,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAiB;IACxC,OAAO,IAAI,CAAC,WAA2C,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Observation } from '../daemon/processor.js';
2
+ import type { VaultWriter } from './writer.js';
3
+ import type { MycoIndex } from '../index/sqlite.js';
4
+ export interface WrittenNote {
5
+ id: string;
6
+ path: string;
7
+ observation: Observation;
8
+ }
9
+ export declare function writeObservationNotes(observations: Observation[], sessionId: string, writer: VaultWriter, index: MycoIndex, vaultDir: string): WrittenNote[];
10
+ //# sourceMappingURL=observations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observations.d.ts","sourceRoot":"","sources":["../../../src/vault/observations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,WAAW,EAAE,EAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,MAAM,GACf,WAAW,EAAE,CA8Bf"}
@@ -0,0 +1,33 @@
1
+ import { formatMemoryBody } from '../obsidian/formatter.js';
2
+ import { sessionNoteId } from './session-id.js';
3
+ import { indexNote } from '../index/rebuild.js';
4
+ export function writeObservationNotes(observations, sessionId, writer, index, vaultDir) {
5
+ const results = [];
6
+ for (const obs of observations) {
7
+ const obsId = `${obs.type}-${sessionId.slice(-6)}-${Date.now()}`;
8
+ const body = formatMemoryBody({
9
+ title: obs.title,
10
+ observationType: obs.type,
11
+ content: obs.content,
12
+ sessionId,
13
+ root_cause: obs.root_cause,
14
+ fix: obs.fix,
15
+ rationale: obs.rationale,
16
+ alternatives_rejected: obs.alternatives_rejected,
17
+ gained: obs.gained,
18
+ sacrificed: obs.sacrificed,
19
+ tags: obs.tags,
20
+ });
21
+ const relativePath = writer.writeMemory({
22
+ id: obsId,
23
+ observation_type: obs.type,
24
+ session: sessionNoteId(sessionId),
25
+ tags: obs.tags,
26
+ content: body,
27
+ });
28
+ indexNote(index, vaultDir, relativePath);
29
+ results.push({ id: obsId, path: relativePath, observation: obs });
30
+ }
31
+ return results;
32
+ }
33
+ //# sourceMappingURL=observations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observations.js","sourceRoot":"","sources":["../../../src/vault/observations.ts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,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type VaultNote } from './types.js';
2
+ export declare class VaultReader {
3
+ private vaultDir;
4
+ constructor(vaultDir: string);
5
+ readNote(relativePath: string): VaultNote;
6
+ listNotes(subdir: string): VaultNote[];
7
+ readAllNotes(): VaultNote[];
8
+ walkMarkdownFiles(dir: string): string[];
9
+ }
10
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/vault/reader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAIlE,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAEpC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS;IAQzC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE;IAWtC,YAAY,IAAI,SAAS,EAAE;IAI3B,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE;CAiBzC"}
@@ -0,0 +1,48 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import matter from 'gray-matter';
4
+ import { parseNoteFrontmatter } from './types.js';
5
+ const VAULT_SUBDIRS = ['sessions', 'plans', 'memories', 'artifacts', 'team'];
6
+ export class VaultReader {
7
+ vaultDir;
8
+ constructor(vaultDir) {
9
+ this.vaultDir = vaultDir;
10
+ }
11
+ readNote(relativePath) {
12
+ const fullPath = path.join(this.vaultDir, relativePath);
13
+ const raw = fs.readFileSync(fullPath, 'utf-8');
14
+ const { data, content } = matter(raw);
15
+ const frontmatter = parseNoteFrontmatter(data);
16
+ return { path: relativePath, frontmatter, content: content.trim() };
17
+ }
18
+ listNotes(subdir) {
19
+ const dirPath = path.join(this.vaultDir, subdir);
20
+ if (!fs.existsSync(dirPath))
21
+ return [];
22
+ const files = this.walkMarkdownFiles(dirPath);
23
+ return files.map((filePath) => {
24
+ const relativePath = path.relative(this.vaultDir, filePath);
25
+ return this.readNote(relativePath);
26
+ });
27
+ }
28
+ readAllNotes() {
29
+ return VAULT_SUBDIRS.flatMap((subdir) => this.listNotes(subdir));
30
+ }
31
+ walkMarkdownFiles(dir) {
32
+ if (!fs.existsSync(dir))
33
+ return [];
34
+ const results = [];
35
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
36
+ for (const entry of entries) {
37
+ const fullPath = path.join(dir, entry.name);
38
+ if (entry.isDirectory()) {
39
+ results.push(...this.walkMarkdownFiles(fullPath));
40
+ }
41
+ else if (entry.isFile() && entry.name.endsWith('.md')) {
42
+ results.push(fullPath);
43
+ }
44
+ }
45
+ return results;
46
+ }
47
+ }
48
+ //# sourceMappingURL=reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../src/vault/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAC;AAElE,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAE7E,MAAM,OAAO,WAAW;IACF;IAApB,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAExC,QAAQ,CAAC,YAAoB;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACxD,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,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