sensemaking 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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +132 -0
  3. package/bin/cli.js +5 -0
  4. package/dist/cjs/cli.d.cts +1 -0
  5. package/dist/cjs/cli.d.ts +1 -0
  6. package/dist/cjs/cli.js +422 -0
  7. package/dist/cjs/cli.js.map +1 -0
  8. package/dist/cjs/config.d.cts +18 -0
  9. package/dist/cjs/config.d.ts +18 -0
  10. package/dist/cjs/config.js +147 -0
  11. package/dist/cjs/config.js.map +1 -0
  12. package/dist/cjs/db.d.cts +20 -0
  13. package/dist/cjs/db.d.ts +20 -0
  14. package/dist/cjs/db.js +326 -0
  15. package/dist/cjs/db.js.map +1 -0
  16. package/dist/cjs/errors.d.cts +5 -0
  17. package/dist/cjs/errors.d.ts +5 -0
  18. package/dist/cjs/errors.js +134 -0
  19. package/dist/cjs/errors.js.map +1 -0
  20. package/dist/cjs/index.d.cts +12 -0
  21. package/dist/cjs/index.d.ts +12 -0
  22. package/dist/cjs/index.js +76 -0
  23. package/dist/cjs/index.js.map +1 -0
  24. package/dist/cjs/output.d.cts +2 -0
  25. package/dist/cjs/output.d.ts +2 -0
  26. package/dist/cjs/output.js +90 -0
  27. package/dist/cjs/output.js.map +1 -0
  28. package/dist/cjs/package.json +1 -0
  29. package/dist/cjs/scan.d.cts +18 -0
  30. package/dist/cjs/scan.d.ts +18 -0
  31. package/dist/cjs/scan.js +113 -0
  32. package/dist/cjs/scan.js.map +1 -0
  33. package/dist/cjs/watch.d.cts +19 -0
  34. package/dist/cjs/watch.d.ts +19 -0
  35. package/dist/cjs/watch.js +237 -0
  36. package/dist/cjs/watch.js.map +1 -0
  37. package/dist/esm/cli.d.ts +1 -0
  38. package/dist/esm/cli.js +171 -0
  39. package/dist/esm/cli.js.map +1 -0
  40. package/dist/esm/config.d.ts +18 -0
  41. package/dist/esm/config.js +78 -0
  42. package/dist/esm/config.js.map +1 -0
  43. package/dist/esm/db.d.ts +20 -0
  44. package/dist/esm/db.js +176 -0
  45. package/dist/esm/db.js.map +1 -0
  46. package/dist/esm/errors.d.ts +5 -0
  47. package/dist/esm/errors.js +10 -0
  48. package/dist/esm/errors.js.map +1 -0
  49. package/dist/esm/index.d.ts +12 -0
  50. package/dist/esm/index.js +9 -0
  51. package/dist/esm/index.js.map +1 -0
  52. package/dist/esm/output.d.ts +2 -0
  53. package/dist/esm/output.js +25 -0
  54. package/dist/esm/output.js.map +1 -0
  55. package/dist/esm/package.json +1 -0
  56. package/dist/esm/scan.d.ts +18 -0
  57. package/dist/esm/scan.js +69 -0
  58. package/dist/esm/scan.js.map +1 -0
  59. package/dist/esm/watch.d.ts +19 -0
  60. package/dist/esm/watch.js +93 -0
  61. package/dist/esm/watch.js.map +1 -0
  62. package/package.json +63 -0
  63. package/schema.json +38 -0
  64. package/skills/sense/SKILL.md +95 -0
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: sense
3
+ description: Query a markdown tree's YAML frontmatter with SQL via the sense CLI. Use when the user wants to query, filter, count, or report on a folder of markdown notes by their frontmatter fields, when a directory has a sense.config.json, when asked what named queries exist, or when asked to add a new query to one.
4
+ ---
5
+
6
+ # sense
7
+
8
+ `sense` runs SQL over the frontmatter of a tree of markdown files. Each file is a row in a
9
+ `docs` table (one column per frontmatter key); the file's own content is never queried, only its
10
+ frontmatter. A running app is **never** required — files on disk are the only source of truth.
11
+
12
+ ## Before anything else
13
+
14
+ Confirm `sense` is installed (`sense --list` or `which sense`; if missing, `npm install -g sense`)
15
+ and that a config exists. Discovery walks **up** from cwd looking for `sense.config.json`, same as
16
+ git looks for `.git` — you don't need to `cd` to the project root, and `--config <path>` bypasses
17
+ discovery entirely. If no config exists yet in the tree you're being asked to query, run
18
+ `sense init` at its root to write a starter config, then tailor the queries.
19
+
20
+ ## See what's queryable
21
+
22
+ ```
23
+ sense --list
24
+ ```
25
+
26
+ Prints the named queries defined in `sense.config.json`, sorted. Read that file directly if you
27
+ need to see the SQL, not just the names.
28
+
29
+ ## Run a query
30
+
31
+ ```
32
+ sense <name> [params...] --format json
33
+ ```
34
+
35
+ **Prefer `--format json` when consuming output as an agent** — it's structured and avoids parsing
36
+ a padded text table. `--format table` (the default) is for humans at a terminal.
37
+
38
+ Named queries may contain `?` placeholders; positional arguments after the name bind to them in
39
+ order. The parameter count is checked strictly — passing the wrong number of arguments is a usage
40
+ error (exit 2), never a silent empty result.
41
+
42
+ ```
43
+ sense by-tag urgent --format json
44
+ ```
45
+
46
+ ## One-off questions: `query`, not config edits
47
+
48
+ For an ad-hoc question, run SQL directly — do NOT add a temporary query to
49
+ `sense.config.json` and remove it afterward:
50
+
51
+ ```
52
+ sense query "SELECT path FROM docs WHERE has(phase, 'screen') AND NOT has(phase, 'explore')" --format json
53
+ sense query "SELECT path FROM docs WHERE has(tags, ?)" urgent --format json
54
+ ```
55
+
56
+ Save a query into `sense.config.json` only when it's meant to be reused as a named view.
57
+
58
+ ## `has()` semantics
59
+
60
+ The one custom SQL function, for frontmatter fields that are arrays or free text:
61
+
62
+ | field type | `has(field, value)` means |
63
+ |--------------------------|---------------------------------|
64
+ | JSON array (e.g. `tags`) | array membership |
65
+ | string | substring match |
66
+ | NULL (key absent) | always false |
67
+
68
+ ## Adding a named query
69
+
70
+ Edit `sense.config.json` directly — it's plain JSON, not something sense itself writes:
71
+
72
+ ```json
73
+ {
74
+ "scan": { "include": ["**/*.md"] },
75
+ "queries": {
76
+ "my-query": "SELECT path, title FROM docs WHERE has(tags, ?) ORDER BY path"
77
+ }
78
+ }
79
+ ```
80
+ `scan.include` globs and query results are both relative to the config file's own directory,
81
+ regardless of your cwd. Reserved columns (don't use as frontmatter key names): `path`, `_mtime`,
82
+ `_size`.
83
+
84
+ ## Exit codes
85
+
86
+ `0` success · `1` a real error (bad config, SQL error — the SQLite message is printed verbatim) ·
87
+ `2` usage error (missing query name, unknown query name, wrong parameter count).
88
+
89
+ ## When results look stale
90
+
91
+ `sense rebuild` deletes the local `.sense/` cache and re-crawls every file from scratch. Every
92
+ query already reconciles the cache against the filesystem on open, so this is rarely needed — use
93
+ it if you doubt the cache rather than trying to debug it. `sense status` shows the doc count, db
94
+ path, and whether a background `sense watch` process is running (it's an optional pre-warmer, not
95
+ a correctness requirement).