@creator-notes/cnotes 0.112.0 → 0.113.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.
@@ -35,6 +35,7 @@ import { attachRubricsToResults, loadRubricMap, rubricsForTypes, } from "./lib/r
35
35
  import { lintNarratedVerbMentions, lintPlainTextDisplayIds, lintPlainTextDisplayIdsBatch, hasGenericMention, fetchRelationshipTypeOptions, } from "./lib/mention-lint.js";
36
36
  import { DECISION_CARD_RULE } from "./lib/decision-citation.js";
37
37
  import { parseReviewRef } from "./lib/review-helpers.js";
38
+ import { runQuery } from "./commands/query.js";
38
39
  // ---------------------------------------------------------------------------
39
40
  // Environment
40
41
  // ---------------------------------------------------------------------------
@@ -155,6 +156,37 @@ server.tool("cnotes_notes_list", "List notes in the workspace. Returns metadata
155
156
  format: includeContent ? "markdown" : undefined,
156
157
  limit: String(limit ?? 20),
157
158
  })));
159
+ server.tool("cnotes_query", "Ask a workspace-wide question over every note's metadata (title, type, tags, canvases, who made it, judged answers; never a body) and get the answer in milliseconds from a local copy of the workspace that syncs on each call. Filters AND across fields and OR within one. Use it to count, group or list notes across the whole workspace; use cnotes_notes_get for a note's content.", {
160
+ text: z.string().optional().describe("Words that must all appear in the title or display id"),
161
+ types: z.array(z.string()).optional().describe("Note types, e.g. ['Decision','Insight']"),
162
+ canvases: z.array(z.string()).optional().describe("Canvases by CANVAS-<n> display id or name"),
163
+ tags: z.array(z.string()).optional(),
164
+ madeBy: z.array(z.enum(["human", "agent", "api", "import"])).optional().describe("How the notes were made"),
165
+ by: z.string().optional().describe("A member whose name contains this"),
166
+ groupBy: z
167
+ .string()
168
+ .optional()
169
+ .describe("type (default), canvas, tag, month, person, made-by, none, or '<Type>:<dimension>' for a judged dimension"),
170
+ limit: z.number().int().min(1).max(2000).optional().describe("Rows to return (default 100)"),
171
+ sql: z.string().optional().describe("One read-only SELECT against the copy instead of a filter; 'tables' lists the tables"),
172
+ rebuild: z.boolean().optional().describe("Drop the local copy and copy the workspace again"),
173
+ }, async ({ text, types, canvases, tags, madeBy, by, groupBy, limit, sql, rebuild }) => withErrorHandling(async () => {
174
+ const answer = await runQuery(api, workspaceId, text ? [text] : [], {
175
+ type: types?.join(","),
176
+ canvas: canvases?.join(","),
177
+ tag: tags?.join(","),
178
+ madeBy: madeBy?.join(","),
179
+ by,
180
+ groupBy,
181
+ limit: limit === undefined ? undefined : String(limit),
182
+ sql,
183
+ rebuild,
184
+ });
185
+ if (answer.kind === "notes")
186
+ return answer.json;
187
+ const { kind: _kind, ...rest } = answer;
188
+ return rest;
189
+ }));
158
190
  server.tool("cnotes_notes_get", "Get one or more notes by display ID (e.g. MEETING-12, PRD-3). Always returns an array, in input order, in a single round-trip. Pass one ID for one note, or many IDs to batch-fetch — never call this tool multiple times in parallel for different IDs. Set expand=true to also return the notes they link to (outgoing relationship rows and inline [[rel::ID]] / [[ID]] mentions) as { notes, linked, truncated, cap, omitted, notice }.", {
159
191
  ids: z
160
192
  .array(z.string())
package/dist/program.js CHANGED
@@ -15,6 +15,7 @@ import { registerRelationshipsCommands } from "./commands/relationships.js";
15
15
  import { registerDepsCommands } from "./commands/deps.js";
16
16
  import { registerGoalsCommands } from "./commands/goals.js";
17
17
  import { registerSearchCommands } from "./commands/search.js";
18
+ import { registerQueryCommands } from "./commands/query.js";
18
19
  import { registerTimelineCommands } from "./commands/timeline.js";
19
20
  import { registerReviewCommands } from "./commands/review.js";
20
21
  import { registerSharedCommands } from "./commands/shared.js";
@@ -119,6 +120,7 @@ Env vars:
119
120
  registerDepsCommands(program);
120
121
  registerGoalsCommands(program);
121
122
  registerSearchCommands(program);
123
+ registerQueryCommands(program);
122
124
  registerTimelineCommands(program);
123
125
  registerReviewCommands(program);
124
126
  registerSharedCommands(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.112.0",
3
+ "version": "0.113.0",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,9 +24,10 @@
24
24
  "release:binaries": "node scripts/build-binaries.mjs --publish",
25
25
  "dev": "tsc --watch",
26
26
  "start": "node dist/cn.js",
27
- "test": "npm run build && node --experimental-transform-types --test \"src/**/*.test.ts\"",
27
+ "test": "npm run build && node scripts/sync-local-db.mjs --check && node --experimental-transform-types --test \"src/**/*.test.ts\"",
28
28
  "version": "node scripts/sync-plugin-version.mjs",
29
- "prepublishOnly": "npm run build"
29
+ "prepublishOnly": "npm run build",
30
+ "sync:local-db": "node scripts/sync-local-db.mjs"
30
31
  },
31
32
  "keywords": [
32
33
  "cli",
@@ -4,6 +4,7 @@ Focus plans, files and images, setup, theme, config, and sending feedback to the
4
4
 
5
5
  ## Contents
6
6
 
7
+ - [Query the workspace (`cnotes query`)](#query-the-workspace-cnotes-query)
7
8
  - [Focus plans (`cnotes focus`)](#focus-plans-cnotes-focus)
8
9
  - [Files (`cnotes files` / `cnotes f`)](#files-cnotes-files--cnotes-f)
9
10
  - [Init & MCP (`cnotes init` / `cnotes mcp`)](#init--mcp-cnotes-init--cnotes-mcp)
@@ -12,6 +13,27 @@ Focus plans, files and images, setup, theme, config, and sending feedback to the
12
13
  - [Feedback (`cnotes feedback`)](#feedback-cnotes-feedback)
13
14
  - [Closing the loop: submit feedback when you hit friction](#closing-the-loop-submit-feedback-when-you-hit-friction)
14
15
 
16
+ ## Query the workspace (`cnotes query`)
17
+
18
+ Workspace-wide questions over every note's metadata, answered from a local
19
+ SQLite copy in milliseconds instead of paged `notes list` reads. The first
20
+ call copies the workspace (a few seconds); later calls sync only what
21
+ changed. Never a note body: read those with `cnotes notes get`.
22
+
23
+ ```bash
24
+ cnotes query pricing --type Decision,Insight # words in the title; AND across fields
25
+ cnotes query --canvas CANVAS-12 --group-by tag # notes on one canvas, by tag
26
+ cnotes query --made-by agent --group-by month --json
27
+ cnotes query --group-by Risk:status # a judged dimension; `unjudged` is a group
28
+ cnotes query --sql "SELECT type, COUNT(*) AS n FROM notes GROUP BY type ORDER BY n DESC"
29
+ cnotes query --sql tables # the tables and their columns
30
+ ```
31
+
32
+ `--json` returns `{ total, groups, rows, sync, ms }`; rows carry `displayId`,
33
+ `title`, `type`, `updatedAt` and the group they fell in. `--sql` runs ONE
34
+ read-only SELECT (a write is refused). `--rebuild` drops the copy and copies
35
+ again. Needs Node.js 22.13 or newer.
36
+
15
37
  ## Focus plans (`cnotes focus`)
16
38
 
17
39
  Protected flow-state blocks, private to the user. The Focus calendar overlays