sensemaking 0.7.1 → 0.8.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 (201) hide show
  1. package/README.md +61 -41
  2. package/dist/cjs/cli/check.js +386 -0
  3. package/dist/cjs/cli/check.js.map +1 -0
  4. package/dist/cjs/{commands → cli}/find.js +3 -4
  5. package/dist/cjs/cli/find.js.map +1 -0
  6. package/dist/cjs/cli/index.js.map +1 -0
  7. package/dist/cjs/{commands → cli}/init.js +3 -0
  8. package/dist/cjs/cli/init.js.map +1 -0
  9. package/dist/cjs/{commands → cli}/map.js +2 -2
  10. package/dist/cjs/cli/map.js.map +1 -0
  11. package/dist/cjs/{commands → cli}/named.d.cts +1 -1
  12. package/dist/cjs/{commands → cli}/named.d.ts +1 -1
  13. package/dist/cjs/cli/named.js +209 -0
  14. package/dist/cjs/cli/named.js.map +1 -0
  15. package/dist/cjs/{commands → cli}/peek.js +2 -2
  16. package/dist/cjs/cli/peek.js.map +1 -0
  17. package/dist/cjs/cli/query.js.map +1 -0
  18. package/dist/cjs/cli/rebuild.js.map +1 -0
  19. package/dist/cjs/{commands → cli}/shared.d.cts +1 -0
  20. package/dist/{esm/commands → cjs/cli}/shared.d.ts +1 -0
  21. package/dist/cjs/{commands → cli}/shared.js +9 -0
  22. package/dist/cjs/cli/shared.js.map +1 -0
  23. package/dist/cjs/{commands → cli}/status.js +7 -1
  24. package/dist/cjs/cli/status.js.map +1 -0
  25. package/dist/cjs/cli/watch.js.map +1 -0
  26. package/dist/cjs/cli.js +23 -18
  27. package/dist/cjs/cli.js.map +1 -1
  28. package/dist/{esm/verbs.d.ts → cjs/commands.d.cts} +5 -4
  29. package/dist/cjs/{verbs.d.cts → commands.d.ts} +5 -4
  30. package/dist/cjs/{verbs.js → commands.js} +246 -21
  31. package/dist/cjs/commands.js.map +1 -0
  32. package/dist/cjs/config.d.cts +7 -1
  33. package/dist/cjs/config.d.ts +7 -1
  34. package/dist/cjs/config.js +75 -24
  35. package/dist/cjs/config.js.map +1 -1
  36. package/dist/cjs/db.d.cts +1 -1
  37. package/dist/cjs/db.d.ts +1 -1
  38. package/dist/cjs/db.js +88 -17
  39. package/dist/cjs/db.js.map +1 -1
  40. package/dist/cjs/errors.d.cts +1 -1
  41. package/dist/cjs/errors.d.ts +1 -1
  42. package/dist/cjs/errors.js.map +1 -1
  43. package/dist/cjs/features/embed.js +7 -1
  44. package/dist/cjs/features/embed.js.map +1 -1
  45. package/dist/cjs/features/links.js +201 -24
  46. package/dist/cjs/features/links.js.map +1 -1
  47. package/dist/cjs/features/rank.js +8 -1
  48. package/dist/cjs/features/rank.js.map +1 -1
  49. package/dist/cjs/features/types.d.cts +10 -3
  50. package/dist/cjs/features/types.d.ts +10 -3
  51. package/dist/cjs/index.d.cts +3 -3
  52. package/dist/cjs/index.d.ts +3 -3
  53. package/dist/cjs/index.js +4 -4
  54. package/dist/cjs/index.js.map +1 -1
  55. package/dist/cjs/output.d.cts +1 -0
  56. package/dist/cjs/output.d.ts +1 -0
  57. package/dist/cjs/output.js +2 -1
  58. package/dist/cjs/output.js.map +1 -1
  59. package/dist/cjs/progress.d.cts +5 -0
  60. package/dist/cjs/progress.d.ts +5 -0
  61. package/dist/cjs/progress.js +54 -0
  62. package/dist/cjs/progress.js.map +1 -0
  63. package/dist/cjs/scan.d.cts +1 -0
  64. package/dist/cjs/scan.d.ts +1 -0
  65. package/dist/cjs/scan.js +3 -2
  66. package/dist/cjs/scan.js.map +1 -1
  67. package/dist/esm/{commands → cli}/check.js +43 -3
  68. package/dist/esm/cli/check.js.map +1 -0
  69. package/dist/esm/{commands → cli}/find.js +3 -4
  70. package/dist/esm/cli/find.js.map +1 -0
  71. package/dist/esm/cli/index.js.map +1 -0
  72. package/dist/esm/{commands → cli}/init.js +3 -0
  73. package/dist/esm/cli/init.js.map +1 -0
  74. package/dist/esm/{commands → cli}/map.js +1 -1
  75. package/dist/esm/cli/map.js.map +1 -0
  76. package/dist/esm/{commands → cli}/named.d.ts +1 -1
  77. package/dist/esm/cli/named.js +33 -0
  78. package/dist/esm/cli/named.js.map +1 -0
  79. package/dist/esm/{commands → cli}/peek.js +1 -1
  80. package/dist/esm/cli/peek.js.map +1 -0
  81. package/dist/esm/cli/query.js.map +1 -0
  82. package/dist/esm/cli/rebuild.js.map +1 -0
  83. package/dist/{cjs/commands → esm/cli}/shared.d.ts +1 -0
  84. package/dist/esm/{commands → cli}/shared.js +9 -0
  85. package/dist/esm/cli/shared.js.map +1 -0
  86. package/dist/esm/{commands → cli}/status.js +7 -1
  87. package/dist/esm/cli/status.js.map +1 -0
  88. package/dist/esm/cli/types.js.map +1 -0
  89. package/dist/esm/cli/watch.js.map +1 -0
  90. package/dist/esm/cli.js +9 -7
  91. package/dist/esm/cli.js.map +1 -1
  92. package/dist/{cjs/verbs.d.ts → esm/commands.d.ts} +5 -4
  93. package/dist/esm/{verbs.js → commands.js} +165 -21
  94. package/dist/esm/commands.js.map +1 -0
  95. package/dist/esm/config.d.ts +7 -1
  96. package/dist/esm/config.js +38 -4
  97. package/dist/esm/config.js.map +1 -1
  98. package/dist/esm/db.d.ts +1 -1
  99. package/dist/esm/db.js +78 -16
  100. package/dist/esm/db.js.map +1 -1
  101. package/dist/esm/errors.d.ts +1 -1
  102. package/dist/esm/errors.js.map +1 -1
  103. package/dist/esm/features/embed.js +6 -0
  104. package/dist/esm/features/embed.js.map +1 -1
  105. package/dist/esm/features/links.js +130 -20
  106. package/dist/esm/features/links.js.map +1 -1
  107. package/dist/esm/features/rank.js +8 -1
  108. package/dist/esm/features/rank.js.map +1 -1
  109. package/dist/esm/features/types.d.ts +10 -3
  110. package/dist/esm/features/types.js.map +1 -1
  111. package/dist/esm/index.d.ts +3 -3
  112. package/dist/esm/index.js +1 -1
  113. package/dist/esm/index.js.map +1 -1
  114. package/dist/esm/output.d.ts +1 -0
  115. package/dist/esm/output.js +2 -1
  116. package/dist/esm/output.js.map +1 -1
  117. package/dist/esm/progress.d.ts +5 -0
  118. package/dist/esm/progress.js +44 -0
  119. package/dist/esm/progress.js.map +1 -0
  120. package/dist/esm/scan.d.ts +1 -0
  121. package/dist/esm/scan.js +5 -2
  122. package/dist/esm/scan.js.map +1 -1
  123. package/package.json +6 -2
  124. package/schema.json +19 -4
  125. package/skills/sense/EXAMPLES.md +9 -7
  126. package/skills/sense/SKILL.md +43 -27
  127. package/skills/sense-setup/SKILL.md +16 -2
  128. package/dist/cjs/commands/check.js +0 -143
  129. package/dist/cjs/commands/check.js.map +0 -1
  130. package/dist/cjs/commands/find.js.map +0 -1
  131. package/dist/cjs/commands/index.js.map +0 -1
  132. package/dist/cjs/commands/init.js.map +0 -1
  133. package/dist/cjs/commands/map.js.map +0 -1
  134. package/dist/cjs/commands/named.js +0 -23
  135. package/dist/cjs/commands/named.js.map +0 -1
  136. package/dist/cjs/commands/peek.js.map +0 -1
  137. package/dist/cjs/commands/query.js.map +0 -1
  138. package/dist/cjs/commands/rebuild.js.map +0 -1
  139. package/dist/cjs/commands/shared.js.map +0 -1
  140. package/dist/cjs/commands/status.js.map +0 -1
  141. package/dist/cjs/commands/watch.js.map +0 -1
  142. package/dist/cjs/verbs.js.map +0 -1
  143. package/dist/esm/commands/check.js.map +0 -1
  144. package/dist/esm/commands/find.js.map +0 -1
  145. package/dist/esm/commands/index.js.map +0 -1
  146. package/dist/esm/commands/init.js.map +0 -1
  147. package/dist/esm/commands/map.js.map +0 -1
  148. package/dist/esm/commands/named.js +0 -12
  149. package/dist/esm/commands/named.js.map +0 -1
  150. package/dist/esm/commands/peek.js.map +0 -1
  151. package/dist/esm/commands/query.js.map +0 -1
  152. package/dist/esm/commands/rebuild.js.map +0 -1
  153. package/dist/esm/commands/shared.js.map +0 -1
  154. package/dist/esm/commands/status.js.map +0 -1
  155. package/dist/esm/commands/types.js.map +0 -1
  156. package/dist/esm/commands/watch.js.map +0 -1
  157. package/dist/esm/verbs.js.map +0 -1
  158. /package/dist/cjs/{commands → cli}/check.d.cts +0 -0
  159. /package/dist/cjs/{commands → cli}/check.d.ts +0 -0
  160. /package/dist/cjs/{commands → cli}/find.d.cts +0 -0
  161. /package/dist/cjs/{commands → cli}/find.d.ts +0 -0
  162. /package/dist/cjs/{commands → cli}/index.d.cts +0 -0
  163. /package/dist/cjs/{commands → cli}/index.d.ts +0 -0
  164. /package/dist/cjs/{commands → cli}/index.js +0 -0
  165. /package/dist/cjs/{commands → cli}/init.d.cts +0 -0
  166. /package/dist/cjs/{commands → cli}/init.d.ts +0 -0
  167. /package/dist/cjs/{commands → cli}/map.d.cts +0 -0
  168. /package/dist/cjs/{commands → cli}/map.d.ts +0 -0
  169. /package/dist/cjs/{commands → cli}/peek.d.cts +0 -0
  170. /package/dist/cjs/{commands → cli}/peek.d.ts +0 -0
  171. /package/dist/cjs/{commands → cli}/query.d.cts +0 -0
  172. /package/dist/cjs/{commands → cli}/query.d.ts +0 -0
  173. /package/dist/cjs/{commands → cli}/query.js +0 -0
  174. /package/dist/cjs/{commands → cli}/rebuild.d.cts +0 -0
  175. /package/dist/cjs/{commands → cli}/rebuild.d.ts +0 -0
  176. /package/dist/cjs/{commands → cli}/rebuild.js +0 -0
  177. /package/dist/cjs/{commands → cli}/status.d.cts +0 -0
  178. /package/dist/cjs/{commands → cli}/status.d.ts +0 -0
  179. /package/dist/cjs/{commands → cli}/types.d.cts +0 -0
  180. /package/dist/cjs/{commands → cli}/types.d.ts +0 -0
  181. /package/dist/cjs/{commands → cli}/types.js +0 -0
  182. /package/dist/cjs/{commands → cli}/types.js.map +0 -0
  183. /package/dist/cjs/{commands → cli}/watch.d.cts +0 -0
  184. /package/dist/cjs/{commands → cli}/watch.d.ts +0 -0
  185. /package/dist/cjs/{commands → cli}/watch.js +0 -0
  186. /package/dist/esm/{commands → cli}/check.d.ts +0 -0
  187. /package/dist/esm/{commands → cli}/find.d.ts +0 -0
  188. /package/dist/esm/{commands → cli}/index.d.ts +0 -0
  189. /package/dist/esm/{commands → cli}/index.js +0 -0
  190. /package/dist/esm/{commands → cli}/init.d.ts +0 -0
  191. /package/dist/esm/{commands → cli}/map.d.ts +0 -0
  192. /package/dist/esm/{commands → cli}/peek.d.ts +0 -0
  193. /package/dist/esm/{commands → cli}/query.d.ts +0 -0
  194. /package/dist/esm/{commands → cli}/query.js +0 -0
  195. /package/dist/esm/{commands → cli}/rebuild.d.ts +0 -0
  196. /package/dist/esm/{commands → cli}/rebuild.js +0 -0
  197. /package/dist/esm/{commands → cli}/status.d.ts +0 -0
  198. /package/dist/esm/{commands → cli}/types.d.ts +0 -0
  199. /package/dist/esm/{commands → cli}/types.js +0 -0
  200. /package/dist/esm/{commands → cli}/watch.d.ts +0 -0
  201. /package/dist/esm/{commands → cli}/watch.js +0 -0
package/README.md CHANGED
@@ -29,7 +29,7 @@ sense query "SELECT path FROM frontmatter WHERE has(tags, ?)" urgent
29
29
 
30
30
  ## Model
31
31
 
32
- Every file becomes rows in four tables:
32
+ Every file becomes rows in these tables, plus whatever an enabled feature adds of its own:
33
33
 
34
34
  | table | holds | for |
35
35
  |---|---|---|
@@ -43,8 +43,9 @@ afterward through the filesystem, scoped to the line ranges `peek` returns. This
43
43
  [just-in-time context pattern](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents):
44
44
  the agent holds lightweight identifiers and loads payloads only when needed.
45
45
 
46
- Measured costs: a `find` row is ~20–40 tokens, a `peek` is ~17% of reading the file, and the
47
- section it points at is a direct `Read` range.
46
+ Output size is a contract, measured per release ([BENCHMARKING.md](BENCHMARKING.md)): `map` is
47
+ fixed-size, a `find` row is tens of tokens, and a `peek` stays flat however large the note is —
48
+ so what it saves over reading grows with the file, and a small note is cheaper read whole.
48
49
 
49
50
  ```sql
50
51
  -- filter and search compose in one query
@@ -54,22 +55,29 @@ WHERE f.status = 'active' AND content MATCH 'revenue'
54
55
  ORDER BY bm25(content, 10.0, 5.0, 1.0) LIMIT 10
55
56
  ```
56
57
 
57
- ## Verbs
58
+ ## Commands
58
59
 
59
- | verb | does |
60
+ | command | does |
60
61
  |---|---|
61
62
  | `map` | doc count, frontmatter field coverage, top hubs by link rank, recent changes |
62
63
  | `find "<terms>" [--where "<sql>"] [--k n] [--semantic]` | BM25 + link-graph expansion, fused; `via` marks each row `match`, `link`, or `match+link` |
63
- | `peek <path>` | frontmatter + heading outline (`[L143-162, ~380t]`) + links both ways, capped at 20 per list |
64
- | `query "<sql>" [params...]` | ad-hoc SQL over all four tables; `?` binds positional args |
64
+ | `peek <path>` | frontmatter + heading outline (`[L143-162, ~380t]`) + links both ways first 20 per list, each with its total; the `links` table has the rest |
65
+ | `query "<sql>" [params...]` | ad-hoc SQL over all the tables; `?` binds positional args |
66
+ | `<name> [params...]` | run a query saved in the config; `--list` names them |
67
+ | `init` | write a starter `sense.config.json` |
68
+ | `status` | index location, doc count, feature state, watcher heartbeat |
69
+ | `check` | prepare and run the saved queries, so a broken one fails here instead of mid-task |
70
+ | `rebuild` | delete the cache and re-crawl |
71
+ | `watch` | keep the index warm in the background (optional; see [WATCH.md](WATCH.md)) |
65
72
 
66
73
  `find` seeds a personalized-PageRank walk with the BM25 matches, so a note that never contains
67
74
  the terms but is linked from ones that do still surfaces. Terms pass verbatim to FTS5 `MATCH`
68
- (bare words AND-join; operators are yours to write). `--where` takes a frontmatter condition
69
- against alias `f`. On trees with the `embed` feature, `--semantic` additionally expands by
70
- meaning — explicit per query, never silent; rows it adds are labeled `via: vector` and carry a
71
- `lines` column pointing at the best-matching section.
72
- `--format json` on any verb returns structured output.
75
+ (bare words AND-join; operators are yours to write). `--where` takes any SQL condition against
76
+ frontmatter alias `f`. On trees with the `embed` feature, `--semantic` additionally expands by
77
+ meaning — explicit per query, never silent; rows it adds are labeled `via: vector` and carry
78
+ `similarity` (cosine against the best-matching chunk). A `lines` column points at the section
79
+ that earned a row — a direct read range. `--format json` on any command returns structured
80
+ output; `--version` and `--help` do what they say.
73
81
 
74
82
  ## Config
75
83
 
@@ -82,46 +90,55 @@ meaning — explicit per query, never silent; rows it adds are labeled `via: vec
82
90
  "version": 2,
83
91
  "scan": { "include": ["**/*.md"] },
84
92
  "features": { "links": true, "sections": true, "rank": true },
93
+ "defaults": { "find": { "where": "f.type != 'generated'" } },
85
94
  "queries": {
86
- "by-tag": "SELECT path, title FROM frontmatter WHERE has(tags, ?) ORDER BY path"
87
- }
95
+ "dead-links": "SELECT src, target FROM links WHERE dst IS NULL",
96
+ "by-tag": "SELECT path, title FROM frontmatter WHERE has(tags, ?) ORDER BY path",
97
+ "hot": { "find": "pricing OR billing", "k": 20 }
98
+ },
99
+ "checks": { "dead-links": "empty" }
88
100
  }
89
101
  ```
90
102
 
91
- Features toggle independently; disabling one degrades its verb instead of failing it (`find`
103
+ A query entry is a SQL string, or a saved `find` with its settings baked in `sense hot`
104
+ then needs no flags. `defaults.find.where` scopes `find` tree-wide (an explicit `--where`
105
+ replaces it, so `--where "1=1"` always reaches everything). `checks` turns a saved query
106
+ into an assertion: `sense check` fails when a query marked `empty` returns rows. Every key
107
+ is documented in [schema.json](schema.json), which editors read for autocomplete.
108
+
109
+ Features toggle independently; disabling one degrades its command instead of failing it (`find`
92
110
  goes BM25-only without `links`, `map` drops hubs without `rank`, `peek` drops the outline
93
111
  without `sections`). Toggling rebuilds the cache. Older config versions auto-migrate on load,
94
112
  noted on stderr.
95
113
 
96
- `embed` is the one opt-in feature (absent = off; most trees don't need vectors): `"embed": true`
97
- uses the built-in static model (downloaded to `~/.cache/sensemaking` on first use, never in the
98
- package), or `{ "model", "type": "static"|"api", "url", "key" }` points at any Model2Vec model,
114
+ `embed` is opt-in the only feature off by default, since most trees don't need vectors.
115
+ `"embed": true` uses the built-in static model (downloaded to `~/.cache/sensemaking` on first
116
+ use, never in the package), or `{ "model", "type": "static"|"api", "url", "key" }` points at any Model2Vec model,
99
117
  local path, or OpenAI-compatible endpoint (Ollama, LM Studio, hosted). With it on, vectors stay
100
118
  fresh at reconcile and `find --semantic` uses them; default `find` results are unchanged.
101
119
 
102
- ## Reference
103
-
104
- - `has(field, value)` the one custom SQL function: array membership on JSON-array fields,
105
- substring on strings (so `has(f.status, 'active')` also matches `inactive`), false on missing
106
- keys. Exact matches: `=` for scalars, `EXISTS (SELECT 1 FROM json_each(f.tags) WHERE value = ?)`
107
- for array members.
108
- - Reserved frontmatter keys (dropped with a warning): `path`, `_mtime`, `_size`, `_rank`,
109
- `content`, `links`, `sections`.
110
- - FTS5 syntax in `MATCH`: `a OR b`, `"phrase"`, `pref*`, `NEAR(a b, 5)`, `summary: term`.
111
- Stemmed; markdown is stripped at index time. `bm25(content, 10.0, 5.0, 1.0)` weights title
112
- over summary over body.
113
- - A one-line `summary:` in frontmatter is both a selectable column and a weighted search field.
114
- - Exit codes: `0` ok, `1` error (SQLite message verbatim), `2` usage.
115
- - Frontmatter parsing is lenient: syntax errors (an alias starting with `@`, say) are per-file
116
- warnings and the values are still indexed.
120
+ `has(field, value)` is the one custom SQL function: array membership on JSON-array fields,
121
+ substring on strings, false on missing keys. Frontmatter parsing is lenient — syntax errors are
122
+ per-file warnings and the values are still indexed, so one bad note never costs you the crawl.
117
123
 
118
124
  ## Scale
119
125
 
120
126
  Every query starts with a freshness check against the cache in `.sense/`; only changed files are
121
- re-parsed. Measured per release in [BENCHMARKING.md](BENCHMARKING.md) at 6,566 notes: full
122
- crawl ~5 s, warm query ~100 ms, one-file change ~200 ms. `sense watch` (optional) moves
123
- re-parsing into the background see [WATCH.md](WATCH.md). `sense rebuild` deletes the cache and
124
- re-crawls.
127
+ re-parsed. What to expect as a tree grows:
128
+
129
+ - **Work is linear in note count** crawl, reconcile, and the freshness check every invocation
130
+ pays. That check is the floor cost of a query and the first thing to watch on a large tree.
131
+ - **Output is flat.** `map`, `peek`, and a `find` row cost the same on a small tree as a large
132
+ one: context cost is bounded by what you ask for, not by how much there is.
133
+ - **Bulk changes are paid by whoever queries next.** `sense watch` moves that re-parse into the
134
+ background ([WATCH.md](WATCH.md)) — it changes latency, never answers, since every query
135
+ reconciles for itself. `sense rebuild` starts the cache over.
136
+
137
+ These are release gates rather than hopes: every release regenerates the numbers on pinned
138
+ corpora spanning a 4x range in note count plus a stress tree that packs the worst measured
139
+ shapes into one place — a megabyte-scale note, heading-dense outlines, dense link graphs,
140
+ hundreds of frontmatter fields. A row that grows faster than linearly, or a token count
141
+ that grows at all, blocks the release. Current figures: [BENCHMARKING.md](BENCHMARKING.md).
125
142
 
126
143
  ## For AI agents
127
144
 
@@ -129,14 +146,15 @@ re-crawls.
129
146
  npx skills add kmalakoff/sensemaking # -g for global, -a claude-code to target
130
147
  ```
131
148
 
132
- The skill teaches the descent: `map` to orient, `find` to locate, `peek` before reading,
133
- `Read` line ranges instead of files.
149
+ Two skills: `sense` for querying a tree — what each command is for, FTS5 syntax, reading the
150
+ `via`/`score`/`similarity` columns, worked examples and `sense-setup` for making one, where
151
+ features, frontmatter conventions, and note size are decisions with consequences either way.
134
152
 
135
153
  ## Prior art
136
154
 
137
155
  - [Effective context engineering for AI agents](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)
138
156
  (Anthropic): agents should hold lightweight identifiers — file paths, links — and load payloads
139
- just in time, because context is a finite resource. The four verbs implement that pattern as a CLI.
157
+ just in time, because context is a finite resource. The commands implement that pattern as a CLI.
140
158
  - [llm-wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) (Karpathy): an
141
159
  agent-maintained wiki navigated by an `index.md` and links, which he notes needs real search
142
160
  infrastructure past a few hundred pages. `sense map` derives that index from the notes instead of
@@ -154,7 +172,9 @@ The skill teaches the descent: `map` to orient, `find` to locate, `peek` before
154
172
 
155
173
  Dependencies: [yaml](https://github.com/eemeli/yaml),
156
174
  [remove-markdown](https://github.com/zuchka/remove-markdown),
157
- [fast-glob](https://github.com/mrmlnc/fast-glob), and Node's built-in SQLite. No native builds.
175
+ [fast-glob](https://github.com/mrmlnc/fast-glob),
176
+ [@huggingface/tokenizers](https://github.com/huggingface/tokenizers.js) (pure JS), and Node's
177
+ built-in SQLite. No native builds.
158
178
 
159
179
  ## License
160
180
 
@@ -0,0 +1,386 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ var _commandsts = require("../commands.js");
12
+ var _configts = require("../config.js");
13
+ var _dbts = require("../db.js");
14
+ var _outputts = require("../output.js");
15
+ var _sharedts = require("./shared.js");
16
+ function _array_like_to_array(arr, len) {
17
+ if (len == null || len > arr.length) len = arr.length;
18
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
19
+ return arr2;
20
+ }
21
+ function _array_with_holes(arr) {
22
+ if (Array.isArray(arr)) return arr;
23
+ }
24
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
25
+ try {
26
+ var info = gen[key](arg);
27
+ var value = info.value;
28
+ } catch (error) {
29
+ reject(error);
30
+ return;
31
+ }
32
+ if (info.done) {
33
+ resolve(value);
34
+ } else {
35
+ Promise.resolve(value).then(_next, _throw);
36
+ }
37
+ }
38
+ function _async_to_generator(fn) {
39
+ return function() {
40
+ var self = this, args = arguments;
41
+ return new Promise(function(resolve, reject) {
42
+ var gen = fn.apply(self, args);
43
+ function _next(value) {
44
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
45
+ }
46
+ function _throw(err) {
47
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
48
+ }
49
+ _next(undefined);
50
+ });
51
+ };
52
+ }
53
+ function _iterable_to_array_limit(arr, i) {
54
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
55
+ if (_i == null) return;
56
+ var _arr = [];
57
+ var _n = true;
58
+ var _d = false;
59
+ var _s, _e;
60
+ try {
61
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
62
+ _arr.push(_s.value);
63
+ if (i && _arr.length === i) break;
64
+ }
65
+ } catch (err) {
66
+ _d = true;
67
+ _e = err;
68
+ } finally{
69
+ try {
70
+ if (!_n && _i["return"] != null) _i["return"]();
71
+ } finally{
72
+ if (_d) throw _e;
73
+ }
74
+ }
75
+ return _arr;
76
+ }
77
+ function _non_iterable_rest() {
78
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
79
+ }
80
+ function _sliced_to_array(arr, i) {
81
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
82
+ }
83
+ function _unsupported_iterable_to_array(o, minLen) {
84
+ if (!o) return;
85
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
86
+ var n = Object.prototype.toString.call(o).slice(8, -1);
87
+ if (n === "Object" && o.constructor) n = o.constructor.name;
88
+ if (n === "Map" || n === "Set") return Array.from(n);
89
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
90
+ }
91
+ function _ts_generator(thisArg, body) {
92
+ var f, y, t, _ = {
93
+ label: 0,
94
+ sent: function() {
95
+ if (t[0] & 1) throw t[1];
96
+ return t[1];
97
+ },
98
+ trys: [],
99
+ ops: []
100
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
101
+ return d(g, "next", {
102
+ value: verb(0)
103
+ }), d(g, "throw", {
104
+ value: verb(1)
105
+ }), d(g, "return", {
106
+ value: verb(2)
107
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
108
+ value: function() {
109
+ return this;
110
+ }
111
+ }), g;
112
+ function verb(n) {
113
+ return function(v) {
114
+ return step([
115
+ n,
116
+ v
117
+ ]);
118
+ };
119
+ }
120
+ function step(op) {
121
+ if (f) throw new TypeError("Generator is already executing.");
122
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
123
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
124
+ if (y = 0, t) op = [
125
+ op[0] & 2,
126
+ t.value
127
+ ];
128
+ switch(op[0]){
129
+ case 0:
130
+ case 1:
131
+ t = op;
132
+ break;
133
+ case 4:
134
+ _.label++;
135
+ return {
136
+ value: op[1],
137
+ done: false
138
+ };
139
+ case 5:
140
+ _.label++;
141
+ y = op[1];
142
+ op = [
143
+ 0
144
+ ];
145
+ continue;
146
+ case 7:
147
+ op = _.ops.pop();
148
+ _.trys.pop();
149
+ continue;
150
+ default:
151
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
+ _ = 0;
153
+ continue;
154
+ }
155
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
156
+ _.label = op[1];
157
+ break;
158
+ }
159
+ if (op[0] === 6 && _.label < t[1]) {
160
+ _.label = t[1];
161
+ t = op;
162
+ break;
163
+ }
164
+ if (t && _.label < t[2]) {
165
+ _.label = t[2];
166
+ _.ops.push(op);
167
+ break;
168
+ }
169
+ if (t[2]) _.ops.pop();
170
+ _.trys.pop();
171
+ continue;
172
+ }
173
+ op = body.call(thisArg, _);
174
+ } catch (e) {
175
+ op = [
176
+ 6,
177
+ e
178
+ ];
179
+ y = 0;
180
+ } finally{
181
+ f = t = 0;
182
+ }
183
+ if (op[0] & 5) throw op[1];
184
+ return {
185
+ value: op[0] ? op[1] : void 0,
186
+ done: true
187
+ };
188
+ }
189
+ }
190
+ // A saved query that returns zero rows looks identical to a true empty result, so a broken
191
+ // one can sit unnoticed -- one field report had `WHERE flag = 'true'` against a numeric
192
+ // column reading as "nothing tagged yet" for hours. Preparing each query catches syntax and
193
+ // unknown-column errors without executing it; queries that take no parameters are also run
194
+ // for a row count. Parameterised queries are validated but not counted: inventing arguments
195
+ // would report a count for a query nobody ran. Saved finds run lexically with k=1 -- that
196
+ // validates the `where` fragment and the FTS5 terms against the real schema, the same
197
+ // breakage class prepare() catches for SQL strings -- but never semantically (a --semantic
198
+ // pass costs model time and, on api trees, network); `semantic: true` is only checked for
199
+ // a features.embed to run against.
200
+ var check = function check(ctx) {
201
+ return _async_to_generator(function() {
202
+ var _cfg_queries, cfg, _open, db, warnings, rows, failed, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, entry, _sql_match, _cfg_checks, count, err, sql, params, expectEmpty, statement, count1, err1;
203
+ return _ts_generator(this, function(_state) {
204
+ switch(_state.label){
205
+ case 0:
206
+ cfg = ctx.resolveConfig();
207
+ _open = (0, _dbts.open)(cfg), db = _open.db, warnings = _open.warnings;
208
+ (0, _sharedts.printWarnings)(warnings);
209
+ rows = [];
210
+ failed = 0;
211
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
212
+ _state.label = 1;
213
+ case 1:
214
+ _state.trys.push([
215
+ 1,
216
+ 10,
217
+ 11,
218
+ 12
219
+ ]);
220
+ _iterator = Object.entries((_cfg_queries = cfg.queries) !== null && _cfg_queries !== void 0 ? _cfg_queries : {})[Symbol.iterator]();
221
+ _state.label = 2;
222
+ case 2:
223
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
224
+ 3,
225
+ 9
226
+ ];
227
+ _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], entry = _step_value[1];
228
+ if (!(typeof entry !== 'string')) return [
229
+ 3,
230
+ 7
231
+ ];
232
+ if (entry.semantic && !(0, _configts.featureEnabled)(cfg, 'embed')) {
233
+ failed++;
234
+ rows.push({
235
+ query: name,
236
+ params: '—',
237
+ rows: '—',
238
+ status: 'FAILED: semantic requested but features.embed is off'
239
+ });
240
+ return [
241
+ 3,
242
+ 8
243
+ ];
244
+ }
245
+ _state.label = 3;
246
+ case 3:
247
+ _state.trys.push([
248
+ 3,
249
+ 5,
250
+ ,
251
+ 6
252
+ ]);
253
+ return [
254
+ 4,
255
+ (0, _commandsts.find)(db, cfg, entry.find, {
256
+ k: 1,
257
+ where: entry.where
258
+ })
259
+ ];
260
+ case 4:
261
+ count = _state.sent().length;
262
+ rows.push({
263
+ query: name,
264
+ params: '—',
265
+ rows: '—',
266
+ status: count === 0 ? 'ok, but matches 0 notes (lexical probe)' : entry.semantic ? 'ok (lexical probe; semantic not run)' : 'ok (probe run with k=1)'
267
+ });
268
+ return [
269
+ 3,
270
+ 6
271
+ ];
272
+ case 5:
273
+ err = _state.sent();
274
+ failed++;
275
+ rows.push({
276
+ query: name,
277
+ params: '—',
278
+ rows: '—',
279
+ status: "FAILED: ".concat(err.message)
280
+ });
281
+ return [
282
+ 3,
283
+ 6
284
+ ];
285
+ case 6:
286
+ return [
287
+ 3,
288
+ 8
289
+ ];
290
+ case 7:
291
+ sql = entry;
292
+ params = ((_sql_match = sql.match(/\?/g)) !== null && _sql_match !== void 0 ? _sql_match : []).length;
293
+ expectEmpty = ((_cfg_checks = cfg.checks) === null || _cfg_checks === void 0 ? void 0 : _cfg_checks[name]) === 'empty';
294
+ try {
295
+ statement = db.prepare(sql);
296
+ if (params > 0) {
297
+ rows.push({
298
+ query: name,
299
+ params: params,
300
+ rows: '—',
301
+ status: 'ok (not run: needs parameters)'
302
+ });
303
+ return [
304
+ 3,
305
+ 8
306
+ ];
307
+ }
308
+ count1 = statement.all().length;
309
+ if (expectEmpty) {
310
+ // An invariant query: rows are violations, so 0 is the pass, anything else fails.
311
+ if (count1 > 0) failed++;
312
+ rows.push({
313
+ query: name,
314
+ params: params,
315
+ rows: count1,
316
+ status: count1 === 0 ? 'ok (empty, as asserted)' : "FAILED: expected empty, returned ".concat(count1, " row(s)")
317
+ });
318
+ } else {
319
+ rows.push({
320
+ query: name,
321
+ params: params,
322
+ rows: count1,
323
+ status: count1 === 0 ? 'ok, but returns 0 rows' : 'ok'
324
+ });
325
+ }
326
+ } catch (err) {
327
+ failed++;
328
+ rows.push({
329
+ query: name,
330
+ params: params,
331
+ rows: '—',
332
+ status: "FAILED: ".concat(err.message)
333
+ });
334
+ }
335
+ _state.label = 8;
336
+ case 8:
337
+ _iteratorNormalCompletion = true;
338
+ return [
339
+ 3,
340
+ 2
341
+ ];
342
+ case 9:
343
+ return [
344
+ 3,
345
+ 12
346
+ ];
347
+ case 10:
348
+ err1 = _state.sent();
349
+ _didIteratorError = true;
350
+ _iteratorError = err1;
351
+ return [
352
+ 3,
353
+ 12
354
+ ];
355
+ case 11:
356
+ try {
357
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
358
+ _iterator.return();
359
+ }
360
+ } finally{
361
+ if (_didIteratorError) {
362
+ throw _iteratorError;
363
+ }
364
+ }
365
+ return [
366
+ 7
367
+ ];
368
+ case 12:
369
+ db.close();
370
+ if (rows.length === 0) {
371
+ console.log('no saved queries in config');
372
+ return [
373
+ 2
374
+ ];
375
+ }
376
+ (0, _outputts.printRows)(rows, ctx.format);
377
+ if (failed > 0) process.exit(1);
378
+ return [
379
+ 2
380
+ ];
381
+ }
382
+ });
383
+ })();
384
+ };
385
+ var _default = check;
386
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/check.ts"],"sourcesContent":["import { find } from '../commands.ts';\nimport { featureEnabled } from '../config.ts';\nimport { open } from '../db.ts';\nimport type { Row } from '../output.ts';\nimport { printRows } from '../output.ts';\nimport { printWarnings } from './shared.ts';\nimport type { Command } from './types.ts';\n\n// A saved query that returns zero rows looks identical to a true empty result, so a broken\n// one can sit unnoticed -- one field report had `WHERE flag = 'true'` against a numeric\n// column reading as \"nothing tagged yet\" for hours. Preparing each query catches syntax and\n// unknown-column errors without executing it; queries that take no parameters are also run\n// for a row count. Parameterised queries are validated but not counted: inventing arguments\n// would report a count for a query nobody ran. Saved finds run lexically with k=1 -- that\n// validates the `where` fragment and the FTS5 terms against the real schema, the same\n// breakage class prepare() catches for SQL strings -- but never semantically (a --semantic\n// pass costs model time and, on api trees, network); `semantic: true` is only checked for\n// a features.embed to run against.\nconst check: Command = async (ctx) => {\n const cfg = ctx.resolveConfig();\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n\n const rows: Row[] = [];\n let failed = 0;\n for (const [name, entry] of Object.entries(cfg.queries ?? {})) {\n if (typeof entry !== 'string') {\n if (entry.semantic && !featureEnabled(cfg, 'embed')) {\n failed++;\n rows.push({ query: name, params: '—', rows: '—', status: 'FAILED: semantic requested but features.embed is off' });\n continue;\n }\n try {\n const count = (await find(db, cfg, entry.find, { k: 1, where: entry.where })).length;\n rows.push({ query: name, params: '—', rows: '—', status: count === 0 ? 'ok, but matches 0 notes (lexical probe)' : entry.semantic ? 'ok (lexical probe; semantic not run)' : 'ok (probe run with k=1)' });\n } catch (err) {\n failed++;\n rows.push({ query: name, params: '—', rows: '—', status: `FAILED: ${(err as Error).message}` });\n }\n continue;\n }\n const sql = entry;\n const params = (sql.match(/\\?/g) ?? []).length;\n const expectEmpty = cfg.checks?.[name] === 'empty';\n try {\n const statement = db.prepare(sql);\n if (params > 0) {\n rows.push({ query: name, params, rows: '—', status: 'ok (not run: needs parameters)' });\n continue;\n }\n const count = (statement.all() as unknown[]).length;\n if (expectEmpty) {\n // An invariant query: rows are violations, so 0 is the pass, anything else fails.\n if (count > 0) failed++;\n rows.push({ query: name, params, rows: count, status: count === 0 ? 'ok (empty, as asserted)' : `FAILED: expected empty, returned ${count} row(s)` });\n } else {\n rows.push({ query: name, params, rows: count, status: count === 0 ? 'ok, but returns 0 rows' : 'ok' });\n }\n } catch (err) {\n failed++;\n rows.push({ query: name, params, rows: '—', status: `FAILED: ${(err as Error).message}` });\n }\n }\n\n db.close();\n if (rows.length === 0) {\n console.log('no saved queries in config');\n return;\n }\n printRows(rows, ctx.format);\n if (failed > 0) process.exit(1);\n};\nexport default check;\n"],"names":["check","ctx","cfg","open","db","warnings","rows","failed","name","entry","sql","count","err","params","expectEmpty","statement","resolveConfig","printWarnings","Object","entries","queries","semantic","featureEnabled","push","query","status","find","k","where","length","message","match","checks","prepare","all","close","console","log","printRows","format","process","exit"],"mappings":"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"}
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
+ var _commandsts = require("../commands.js");
11
12
  var _outputts = require("../output.js");
12
- var _verbsts = require("../verbs.js");
13
13
  var _sharedts = require("./shared.js");
14
14
  function _array_like_to_array(arr, len) {
15
15
  if (len == null || len > arr.length) len = arr.length;
@@ -193,8 +193,7 @@ var findCmd = function findCmd(ctx) {
193
193
  case 0:
194
194
  _ctx_rest = _sliced_to_array(ctx.rest, 1), terms = _ctx_rest[0];
195
195
  if (!terms) ctx.usageError("usage: ".concat(ctx.name, ' find "<terms>" [--where "<sql>"] [--k n] [--semantic]'));
196
- k = ctx.values.k === undefined ? undefined : Number.parseInt(ctx.values.k, 10);
197
- if (ctx.values.k !== undefined && !Number.isInteger(k)) ctx.usageError('--k expects an integer, got "'.concat(ctx.values.k, '"'));
196
+ k = (0, _sharedts.parseK)(ctx);
198
197
  return [
199
198
  4,
200
199
  (0, _sharedts.withDb)(ctx, function(db, cfg) {
@@ -204,7 +203,7 @@ var findCmd = function findCmd(ctx) {
204
203
  case 0:
205
204
  return [
206
205
  4,
207
- (0, _verbsts.find)(db, cfg, terms, {
206
+ (0, _commandsts.find)(db, cfg, terms, {
208
207
  k: k,
209
208
  where: ctx.values.where,
210
209
  semantic: ctx.values.semantic
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/find.ts"],"sourcesContent":["import { find } from '../commands.ts';\nimport { printRows } from '../output.ts';\nimport { parseK, withDb } from './shared.ts';\nimport type { Command } from './types.ts';\n\nconst findCmd: Command = async (ctx) => {\n const [terms] = ctx.rest;\n if (!terms) ctx.usageError(`usage: ${ctx.name} find \"<terms>\" [--where \"<sql>\"] [--k n] [--semantic]`);\n const k = parseK(ctx);\n await withDb(ctx, async (db, cfg) => printRows(await find(db, cfg, terms, { k, where: ctx.values.where, semantic: ctx.values.semantic }), ctx.format));\n};\nexport default findCmd;\n"],"names":["findCmd","ctx","terms","k","rest","usageError","name","parseK","withDb","db","cfg","find","where","values","semantic","printRows","format"],"mappings":";;;;+BAWA;;;eAAA;;;0BAXqB;wBACK;wBACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG/B,IAAMA,UAAmB,iBAAOC;;YACdA,WAATC,OAEDC;;;;oBAFUF,6BAAAA,IAAIG,IAAI,MAAjBF,QAASD;oBAChB,IAAI,CAACC,OAAOD,IAAII,UAAU,CAAC,AAAC,UAAkB,OAATJ,IAAIK,IAAI,EAAC;oBACxCH,IAAII,IAAAA,gBAAM,EAACN;oBACjB;;wBAAMO,IAAAA,gBAAM,EAACP,KAAK,SAAOQ,IAAIC;;;;;4CAAkB;;gDAAMC,IAAAA,gBAAI,EAACF,IAAIC,KAAKR,OAAO;oDAAEC,GAAAA;oDAAGS,OAAOX,IAAIY,MAAM,CAACD,KAAK;oDAAEE,UAAUb,IAAIY,MAAM,CAACC,QAAQ;gDAAC;;;;;gDAAjGC,mBAAS;oDAAC;oDAA2Fd,IAAIe,MAAM;;;;;;;;;oBAApJ;;;;;;IACF;;IACA,WAAehB"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/index.ts"],"sourcesContent":["import type { Command } from './types.ts';\n\n// Lazy registry: a command's imports load only when it runs, so a heavy dependency in one\n// command never taxes the others (or --version/--help). These names are reserved: a named\n// query in config can never shadow them.\nexport const COMMANDS: Record<string, () => Promise<{ default: Command }>> = {\n init: () => import('./init.ts'),\n watch: () => import('./watch.ts'),\n status: () => import('./status.ts'),\n check: () => import('./check.ts'),\n rebuild: () => import('./rebuild.ts'),\n query: () => import('./query.ts'),\n find: () => import('./find.ts'),\n map: () => import('./map.ts'),\n peek: () => import('./peek.ts'),\n};\n\nexport type { Command, Ctx } from './types.ts';\n"],"names":["COMMANDS","init","watch","status","check","rebuild","query","find","map","peek"],"mappings":";;;;+BAKaA;;;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAN,IAAMA,WAAgE;IAC3EC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;IACnBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,QAAQ,SAARA;eAAc;2DAAA,QAAO;;;IACrBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,SAAS,SAATA;eAAe;2DAAA,QAAO;;;IACtBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;IACnBC,KAAK,SAALA;eAAW;2DAAA,QAAO;;;IAClBC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;AACrB"}
@@ -13,6 +13,9 @@ var init = function init(ctx) {
13
13
  var configPath = (0, _configts.initConfig)(process.cwd());
14
14
  console.log("created ".concat(configPath));
15
15
  console.log("query away: ".concat(ctx.name, ' query "SELECT path FROM frontmatter LIMIT 10"'));
16
+ // The decisions a new tree faces -- features, frontmatter conventions, note size -- are not
17
+ // in this output; name both places that hold them, since an agent may have neither.
18
+ console.log('features and tree design: the sense-setup skill, or schema.json');
16
19
  };
17
20
  var _default = init;
18
21
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/init.ts"],"sourcesContent":["import { initConfig } from '../config.ts';\nimport type { Command } from './types.ts';\n\nconst init: Command = (ctx) => {\n const configPath = initConfig(process.cwd());\n console.log(`created ${configPath}`);\n console.log(`query away: ${ctx.name} query \"SELECT path FROM frontmatter LIMIT 10\"`);\n // The decisions a new tree faces -- features, frontmatter conventions, note size -- are not\n // in this output; name both places that hold them, since an agent may have neither.\n console.log('features and tree design: the sense-setup skill, or schema.json');\n};\nexport default init;\n"],"names":["init","ctx","configPath","initConfig","process","cwd","console","log","name"],"mappings":";;;;+BAWA;;;eAAA;;;wBAX2B;AAG3B,IAAMA,OAAgB,cAACC;IACrB,IAAMC,aAAaC,IAAAA,oBAAU,EAACC,QAAQC,GAAG;IACzCC,QAAQC,GAAG,CAAC,AAAC,WAAqB,OAAXL;IACvBI,QAAQC,GAAG,CAAC,AAAC,eAAuB,OAATN,IAAIO,IAAI,EAAC;IACpC,4FAA4F;IAC5F,oFAAoF;IACpFF,QAAQC,GAAG,CAAC;AACd;IACA,WAAeP"}
@@ -8,12 +8,12 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
+ var _commandsts = require("../commands.js");
11
12
  var _outputts = require("../output.js");
12
- var _verbsts = require("../verbs.js");
13
13
  var _sharedts = require("./shared.js");
14
14
  var map = function map(ctx) {
15
15
  return (0, _sharedts.withDb)(ctx, function(db, cfg) {
16
- var result = (0, _verbsts.mapTree)(db, cfg);
16
+ var result = (0, _commandsts.mapTree)(db, cfg);
17
17
  console.log(ctx.format === 'json' ? JSON.stringify(result, null, 2) : (0, _outputts.renderMap)(result));
18
18
  });
19
19
  };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/map.ts"],"sourcesContent":["import { mapTree } from '../commands.ts';\nimport { renderMap } from '../output.ts';\nimport { withDb } from './shared.ts';\nimport type { Command } from './types.ts';\n\nconst map: Command = (ctx) =>\n withDb(ctx, (db, cfg) => {\n const result = mapTree(db, cfg);\n console.log(ctx.format === 'json' ? JSON.stringify(result, null, 2) : renderMap(result));\n });\nexport default map;\n"],"names":["map","ctx","withDb","db","cfg","result","mapTree","console","log","format","JSON","stringify","renderMap"],"mappings":";;;;+BAUA;;;eAAA;;;0BAVwB;wBACE;wBACH;AAGvB,IAAMA,MAAe,aAACC;WACpBC,IAAAA,gBAAM,EAACD,KAAK,SAACE,IAAIC;QACf,IAAMC,SAASC,IAAAA,mBAAO,EAACH,IAAIC;QAC3BG,QAAQC,GAAG,CAACP,IAAIQ,MAAM,KAAK,SAASC,KAAKC,SAAS,CAACN,QAAQ,MAAM,KAAKO,IAAAA,mBAAS,EAACP;IAClF;;IACF,WAAeL"}
@@ -1,2 +1,2 @@
1
1
  import type { Ctx } from './types.js';
2
- export default function named(ctx: Ctx, queryName: string, params: string[]): void;
2
+ export default function named(ctx: Ctx, queryName: string, params: string[]): Promise<void>;