noggin-cli 0.1.3 → 0.4.3

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.
package/README.md CHANGED
@@ -1,389 +1,53 @@
1
1
  # noggin
2
2
 
3
- A small, single-user working-memory tree for in-flight work — your
4
- second brain for the stuff you can't fit in your head.
3
+ A working-memory tree for in-flight work — your second brain for
4
+ the stuff you can't fit in your head.
5
5
 
6
- Lives in `~/.noggin.yaml` by default. Override per call with `--file
7
- <path>`, or set `$NOGGIN_FILE` to point every invocation at a
8
- different file. (The VS Code extension sets `NOGGIN_FILE` in its
9
- terminals so the CLI follows whichever noggin you have open.) Driven
10
- by [`noggin.mjs`](noggin.mjs) next to this file. The YAML file is the source
11
- of truth; the CLI is the only sanctioned way to read or write it.
12
-
13
- For the agent-facing behavioral instructions, see [SKILL.md](SKILL.md).
14
- This document is the human reference: what noggin is, what the
15
- commands do, how the file is shaped.
16
-
17
- ## Mental model
18
-
19
- Items form a tree. There is at most one **active** item; the path
6
+ Items form a tree. There's at most one **active** item; the path
20
7
  from a root to the active item is your current spine. Other open
21
- items are paused work you started but stepped away from. Done
22
- items stay in the tree under their parent so you can see what got
23
- finished. Use `edit --open` if it turns out something was not
24
- really finished.
25
-
26
- An item and a "todo" are the same thing at different lifecycle stages:
27
-
28
- - **push** = create a child of active and immediately become it
29
- ("I'm going to do this now").
30
- - **add** = create a child of active without becoming it (a deferred
31
- task; same shape, just never activated).
32
-
33
- You can later `goto` an added child to make it active, or just `done`
34
- it without ever activating.
35
-
36
- ### What an item carries
37
-
38
- Just the things that are about an item *being an item* in the tree:
39
-
40
- - a **title** (one line)
41
- - a **done** flag and a `createdAt` timestamp
42
- - append-only timestamped **notes** — anything you want to remember,
43
- including a system-generated `closed` note appended whenever the item
44
- transitions from open to done (the note's timestamp records when)
45
-
46
- There is **no fixed schema** for things like "why," "where," "what's
47
- next," tags, or resolution. If it matters, drop a `note`. The CLI
48
- stays focused on tree shape and lifecycle; everything else is content
49
- the user (or an agent) writes in note text.
50
-
51
- ## Identifiers and paths
52
-
53
- - **key** — an opaque, stable internal identifier (e.g.
54
- `i-20260616-184644-f04bf5`). Used in the YAML file for parent links
55
- and the active pointer. Hidden from human output; included in JSON
56
- output when you want to inspect it.
57
- - **position** — a computed 1-based index among siblings. Shown in
58
- brackets in human output, e.g. `[2]`.
59
- - **path** — how you refer to items on the command line.
60
-
61
- ### Path syntax
62
-
63
- The leading `/` is the unambiguous marker that separates the two
64
- families of paths.
65
-
66
- **Absolute** paths start with `/` and walk from a root. This is the
67
- canonical form used everywhere the API or human output reports a
68
- path (`activePath`, `ItemView.path`, `parentPath`, error messages).
69
-
70
- ```
71
- "/1/2/3"
72
- │ │ │
73
- │ │ └── third child of "/1/2"
74
- │ └──── second child of root "/1"
75
- └────── first root item
76
- ```
77
-
78
- **Relative** paths are everything else, resolved against the active
79
- item (file-system style):
80
-
81
- | Token | Meaning |
82
- |---|---|
83
- | `.` | active item |
84
- | `..` | parent of active |
85
- | `-` | previous sibling of active |
86
- | `+` | next sibling of active |
87
- | `./X/Y` | descendant of active |
88
- | `../X` | sibling of active (child X of parent) |
89
- | `-/X/Y` | descendant under the previous sibling |
90
- | `+/X/Y` | descendant under the next sibling |
91
- | `../../X` | walk up two and then down |
92
- | `X` / `X/Y` | bare positions are short for `./X` / `./X/Y` |
8
+ items are paused. Done items stay in the tree under their parent
9
+ so you can see what got finished. Lives in `~/.noggin.yaml` by
10
+ default; the YAML file is the source of truth.
93
11
 
94
- Relative paths require an active item. If none is set, pass an
95
- absolute path instead (e.g. `noggin show /1` rather than `noggin
96
- show 1`).
97
-
98
- Paths are coordinates into the current tree order — they are
99
- intended for immediate interactive use, not long-term bookmarks.
100
- Stable identity lives in `key` and `parentKey`.
101
-
102
- ## Command reference
103
-
104
- Every command takes:
105
-
106
- - `--file <path>` — override the file resolution (highest priority).
107
- - `--json` — emit structured JSON instead of the human tree view.
108
- - `--with-json` — human output followed by JSON.
109
-
110
- The file is resolved in this order:
111
-
112
- 1. `--file <path>`
113
- 2. `$NOGGIN_FILE` environment variable
114
- 3. `~/.noggin.yaml`
115
-
116
- Use `noggin where` at any time to print which file would be used and
117
- why.
118
-
119
- Commands that change or inspect a target also take `--goto [path]`.
120
- With no path, `--goto` activates the command's target; with a path,
121
- the path resolves from the command target (not from the previously
122
- active item).
123
-
124
- Common flags can appear before or after the verb.
125
-
126
- | Verb | Effect |
127
- |---|---|
128
- | `push <title>` | Create a child of active and make it active. |
129
- | `add <title> [--before\|--after\|--into <path>] [--goto [path]]` | Create a child of active by default. `--before <path>` / `--after <path>` insert as a sibling of the anchor; `--into <path>` makes it the last child of the anchor. Active does **not** change unless `--goto` is present. |
130
- | `move [<path>] (--before\|--after\|--into <path>) [--goto [path]]` | Relocate an item. Default target is the active item. Exactly one of `--before` / `--after` / `--into` is required. Active is preserved by key, so the computed path may change but `📍` stays on the same item. Cycles (anchor in the moved subtree) are rejected. |
131
- | `goto <path>` | Make the item at `<path>` active. |
132
- | `done [<path>] [--force\|--close-all]` | Mark an item done, then make the target's parent active. Idempotent (no error if already done). Refuses if open descendants exist unless `--close-all` first closes them or `--force` closes just the target anyway. Root items leave no active item after completion. |
133
- | `pop [--force\|--close-all]` | Shorthand for `done` on the active item (no path). Honors `--force` and `--close-all` the same way. |
134
- | `edit [<path>] [--done\|--open] [--title T] [--force\|--close-all] [--goto [path]]` | Idempotent mutation of a single item's lifecycle state and/or title. Pass at least one of `--done` / `--open` / `--title`. Active is unchanged unless `--goto` is passed. When closing (`--done`), the same open-descendant rules apply as `done`: `--force` closes anyway, `--close-all` closes descendants first. Replaces the older `set-state` and `retitle` verbs. |
135
- | `show [<path>] [--no-children\|--with-descendants] [--with-siblings] [--with-all] [--with-notes] [--goto [path]]` | Current-position view: ancestor spine, sibling peers, current-item details, and first-level children. Default target is active. `--no-children` omits children. `--with-siblings` also includes the full sibling row at every ancestor depth (sibling subtrees stay collapsed). `--with-descendants` expands the target's subtree recursively. `--with-all` = `--with-siblings --with-descendants`. `--with-notes` appends note bodies. `--no-children` and `--with-descendants` are mutually exclusive. |
136
- | `note [<path>] <text…> [--goto [path]]` | Append a timestamped note. |
137
- | `delete <path> [--recursive]` | Remove an item. Refuses if the item has descendants unless `--recursive` is passed, in which case the whole subtree is deleted. If the active item is inside the deleted subtree, active falls back to the deleted item's parent (or becomes empty if it was a root). |
138
- | `where` | Print which noggin file would be used and why (flag / env / default). |
139
- | `help` | Print full help. |
140
-
141
- ### Tree output
142
-
143
- Each row is `<absolute-path> <state> title <notes>`, with three
144
- optional indicator slots:
145
-
146
- - `📍` (between path and title) — this is the active item
147
- - `✅` (between path and title) — done
148
- - `✏️` (trailing) — has notes
149
-
150
- Every row leads with the item's absolute path (`/1/3` etc.) so each
151
- row self-describes — ancestors on the spine still read clearly even
152
- though their siblings are trimmed from the view.
153
-
154
- `show` keeps note bodies collapsed by default; pass `--with-notes` to
155
- append them after the tree.
156
-
157
- ### JSON output
158
-
159
- `--json` and `--with-json` emit a stable envelope shared with the VS Code
160
- extension's language-model tools, so a single consumer can target both
161
- surfaces.
162
-
163
- ```jsonc
164
- // success
165
- {
166
- "status": "ok",
167
- "schemaVersion": 2, // JSON_SCHEMA_VERSION — bump on breaking changes
168
- "verb": "push", // command that produced this payload
169
- "file": "/…/.noggin.yaml", // resolved noggin file
170
- "data": { … } // verb-specific (CurrentTreeView, DeleteResult, …)
171
- }
172
-
173
- // error (written to stderr; exit code matches error.exitCode)
174
- {
175
- "status": "error",
176
- "schemaVersion": 2,
177
- "verb": "push",
178
- "file": "/…/.noggin.yaml",
179
- "error": { "code": "title-required", "message": "…", "exitCode": 2 }
180
- }
181
- ```
12
+ ---
182
13
 
183
- Inside `data`, a small whitelist of fields whose value matches their
184
- declared default is **omitted** to keep payloads focused. A consumer
185
- that doesn't see one of these fields should treat it as the default:
14
+ ## 📖 Full docs
186
15
 
187
- | Field | Omitted when |
188
- |---|---|
189
- | `parentKey` | `null` (item is a root) |
190
- | `done` | `false` (item is still open) |
191
- | `notes` | `[]` (no notes) |
192
- | `activePath` | `null` (no active item) |
193
- | `activeKey` | `null` (no active item) |
194
- | `descendantCount` | `0` (in `DeleteResult`) |
195
- | `view` | `null` (delete left the tree empty) |
196
- | `exists` | `false` (in `where` output) |
197
- | `env` | `null` (in `where` output, no `$NOGGIN_FILE` set) |
16
+ This README is intentionally short. Everything else lives on the
17
+ **[noggin docs site](https://dornstein.github.io/noggin/)**:
198
18
 
199
- Everything else is always present, including the envelope itself
200
- (`status`, `schemaVersion`, `verb`, `file`, `data` / `error`).
19
+ - **[Install](https://dornstein.github.io/noggin/install/)** VS Code extension, agent plugin (Codex / Claude Code / GitHub Copilot CLI), bare CLI
20
+ - **[CLI reference](https://dornstein.github.io/noggin/cli/)** every verb, every flag, generated from the binary
21
+ - **[Verb demo](https://dornstein.github.io/noggin/demo/)** — side-by-side human vs JSON output, real CLI runs
22
+ - **[MCP server](https://dornstein.github.io/noggin/mcp/)** — tools the agent sees over stdio
23
+ - **[Document schema](https://dornstein.github.io/noggin/schema/)** — the `NogginDocument` shape and invariants
24
+ - **[Response envelope](https://dornstein.github.io/noggin/envelope/)** — JSON wrapper around every CLI / MCP / LM-tool response
25
+ - **[Playground](https://dornstein.github.io/noggin/playground/)** — try noggin in your browser, no install
201
26
 
202
- `ViewNode.children` is special: it's already a tri-state encoded by
203
- presence (see `CurrentTreeView` below). Pruning doesn't touch it.
27
+ Agent-facing instructions live in [SKILL.md](SKILL.md). The TypeScript
28
+ declarations for the in-process API are in [noggin-api.d.mts](noggin-api.d.mts).
204
29
 
205
- #### `CurrentTreeView`
30
+ ## Quick start
206
31
 
207
- Returned in `data` by every mutating verb and by `show`. Carries
208
- everything the human "current tree" view shows, so JSON consumers can
209
- reconstruct the same picture without re-reading the file.
32
+ ```bash
33
+ # Install the CLI (and the MCP server bin) globally
34
+ npm install -g noggin-cli
210
35
 
211
- ```jsonc
212
- {
213
- "activePath": "/1/2/3", // path of the active item, or null
214
- "activeKey": "i-…", // opaque key of the active item, or null
215
- "targetKey": "i-…", // opaque key of the item the verb acted on
216
- "items": [ // top of the rendered tree (see below)
217
- { …ItemView…, "children"?: [ ViewNode, … ] },
218
-
219
- ]
220
- }
36
+ # Or run ad-hoc via npx
37
+ npx -y noggin-cli noggin push "ship v1"
38
+ npx -y noggin-cli noggin show
221
39
  ```
222
40
 
223
- The view is a **recursive tree**. Each node (`ViewNode`) is an
224
- `ItemView` (the usual `key, parentKey, path, position, title, done,
225
- createdAt, notes` fields) plus an *optional* `children` slot:
41
+ The package ships two bins:
226
42
 
227
- | `children` | Meaning |
228
- |---|---|
229
- | present (array, possibly `[]`) | this view renders this node's child level; the array is the rendered children |
230
- | **absent** | leaf of this view — the store may have a subtree here, but this view doesn't render it |
43
+ - `noggin` the working-memory tree CLI
44
+ - `noggin-mcp` — a stdio MCP server exposing the same verbs to
45
+ agent hosts (Codex, Claude Code, GitHub Copilot CLI, VS Code MCP)
231
46
 
232
- The recursion walks the direct ancestor chain from a root down to the
233
- target. Sibling-of-ancestor items are **trimmed** — each intermediate
234
- ancestor's `children` is a single-element array. The target's parent's
235
- `children` is the full **peer row** (siblings + target itself, in
236
- tree order). The target itself carries its first-level kids in
237
- `children` (or omits the field entirely with `--no-children`).
238
-
239
- Peers and grandkids (the children listed under the target) are
240
- **leaves of the view**: no `children` field. To explore their
241
- subtrees, call `show` on them.
242
-
243
- `items` is either:
244
- - a one-element array containing the target's root ancestor, when the
245
- target is below the root level; or
246
- - the target's full peer row (the actual store roots, in tree order),
247
- when the target itself is a root.
248
-
249
- To find the target node, walk the tree and match on `targetKey`.
250
-
251
- Active is reported separately as both `activePath` and `activeKey`
252
- because the active item may not appear in this view at all (e.g.
253
- `add --into <other-branch>` returns a view of the new item, but
254
- active is unchanged on a different branch). A consumer that wants
255
- to show "📍 you're at `X`" needs the path explicitly.
256
-
257
- An `ItemView` is `{ key, parentKey, path, position, title, done,
258
- createdAt, notes }`. Notes are `{ timestamp, text }` objects.
259
-
260
- #### `DeleteResult`
261
-
262
- Returned in `data` by `delete`. Always carries the deletion record;
263
- `view` is `null` only when the tree is left with no active item.
264
-
265
- ```jsonc
266
- {
267
- "deleted": { "key": "i-…", "path": "/1/2/3", "title": "…" },
268
- "descendantCount": 2,
269
- "view": { … CurrentTreeView … } | null
270
- }
271
- ```
272
-
273
- #### `where`
274
-
275
- Returns the `FileResolution` shape: `{ file, source, exists,
276
- defaultFile, env }` with all fields always present.
277
-
278
- ## File schema (v1)
279
-
280
- The CLI reads and writes a single YAML file. Writes are atomic: the
281
- CLI writes to `<file>.tmp-<pid>-<ts>` and renames over the real path,
282
- so a partial write never corrupts the user's file.
283
-
284
- ### Top-level shape
285
-
286
- ```yaml
287
- schemaVersion: 1
288
- active: <key> | null # the item currently being worked on
289
- items: [] # flat array; tree is implied via parentKey
290
- ```
291
-
292
- - `schemaVersion` is required and must equal `1`. Any other value
293
- causes the CLI to refuse to read the file.
294
- - `active` is the opaque `key` of the active item, or `null` when
295
- nothing is active. The active item's path is computed at runtime
296
- by walking parents.
297
- - `items` is a flat list. Tree structure comes from `parentKey`
298
- pointers. Sibling order is array order, and display positions are
299
- computed from that order.
300
-
301
- ### Item shape
302
-
303
- ```yaml
304
- - key: i-20260616-184644-f04bf5 # opaque, immortal
305
- parentKey: null # null = root item
306
- title: marketplace import path
307
- done: false # true once finished; reversible via `edit --open`
308
- createdAt: 2026-06-16T18:46:44.071Z
309
- notes:
310
- - timestamp: 2026-06-16T18:46:45.625Z
311
- text: found the storage abstraction in tableStorageService
312
- - timestamp: 2026-06-16T18:46:46.200Z
313
- text: |
314
- Resumption note
315
-
316
- Where I am
317
- - branch users/davidorn/marketplace-import
318
- ...
319
- - timestamp: 2026-06-16T18:50:11.300Z
320
- text: closed # system-generated when the item is closed
321
- ```
322
-
323
- ### Field semantics
324
-
325
- | Field | Purpose |
326
- |---|---|
327
- | `key` | Opaque, never reused. Format `i-YYYYMMDD-HHMMSS-<hex>` (display only — don't parse). Hidden from human output; included in JSON. |
328
- | `parentKey` | Opaque key of the parent item, or `null` for roots. Multiple roots are allowed. |
329
- | `title` | One-line human label. |
330
- | `done` | `false` while the work is live, `true` once finished. Reversible via `edit --open`. |
331
- | `createdAt` | ISO-8601 timestamp when the item was created. |
332
- | `notes` | Append-only list of `{ timestamp, text }` objects. Each user note is added by `noggin note`. A single system-generated note with text `closed` is appended whenever the item transitions from open to done (via `done`, `pop`, `edit --done`, or the extension UI). Reopening with `edit --open` does not add or remove notes — the historical close stays in the log. |
333
-
334
- ### Invariants
335
-
336
- The CLI validates these on every save:
337
-
338
- 1. Every item has a unique `key`.
339
- 2. Every non-null `parentKey` references an existing item.
340
- 3. `active`, if non-null, references an existing item. An active
341
- item may have `done: true` after explicit `edit --done`; use
342
- `edit --open` to revert, or `goto ..` to leave it.
343
- 4. Done items (`done: true`) remain in the tree (they are not
344
- deleted) and can be reverted via `edit --open`.
345
- 5. A done item may have open descendants only when it was closed
346
- with `--force`. The standard close paths (`done`, `pop`, `edit
347
- --done` without flags, or with `--close-all`) preserve the
348
- stronger invariant "done items have no open descendants".
349
-
350
- ## Resumption notes
351
-
352
- Resumption notes are for **cold-start rehydration** — what an LLM (or
353
- you, two days later) needs to resume work without reading the whole
354
- session. They are just notes; the schema does not enforce structure.
355
-
356
- A useful shape:
357
-
358
- ```
359
- Where I am
360
- - branch / file / cursor
361
- - last action
362
-
363
- What I believe
364
- - the model of the system that this work assumes
365
- - constraints and invariants
366
-
367
- Ruled out
368
- - approaches considered and rejected (and why)
369
-
370
- Decisions in flight
371
- - questions that aren't settled yet
372
-
373
- Resume by
374
- - the literal first thing to do on return
375
- ```
376
-
377
- Append it as a normal note:
378
-
379
- ```powershell
380
- node noggin.mjs note "Resumption note`n`nWhere I am`n - ...`nResume by`n - ..."
381
- ```
47
+ For MCP wire-up examples and host-specific config paths, see the
48
+ [MCP page](https://dornstein.github.io/noggin/mcp/) and the
49
+ [plugin distribution README](https://github.com/dornstein/noggin/blob/main/plugin/README.md).
382
50
 
383
- ## Constraints
51
+ ## License
384
52
 
385
- - Single-user, single-machine. No collaboration, no network, no
386
- remote sync.
387
- - The CLI is intentionally tiny: stdlib + `js-yaml`. Bundleable into
388
- the Agency plugin if needed (vendor `js-yaml` next to `noggin.mjs` at
389
- bundle time).
53
+ [MIT](LICENSE).
package/SKILL.md CHANGED
@@ -79,6 +79,7 @@ stable IDs. Don't store them.
79
79
  | "Add a note about X" | `note <text>` (active) or `note <path> <text>` |
80
80
  | "Rename this" | `edit [<path>] --title <new title>` |
81
81
  | "Drop this" / "never mind, delete it" | `delete <path>` (add `--recursive` if it has children) |
82
+ | "Migrate my noggin into this repo" / "copy the home noggin into this folder" | `copy <from> <to>` (whole-noggin, append-only; preserves notes and timestamps) |
82
83
 
83
84
  Default to `push` for active side-quests, `add` for everything that
84
85
  can wait. The cost of `add` is near zero — capture stray "we should
@@ -115,15 +116,22 @@ also…" remarks rather than letting them evaporate.
115
116
  `#nogginPop`, `#nogginNote`, `#nogginEdit`,
116
117
  `#nogginMove`, `#nogginDelete`) over shelling out to `noggin.mjs`. The tools always
117
118
  target the noggin the user has open in the editor. If you do shell
118
- out, the CLI honors the `NOGGIN_FILE` env var, which the extension
119
+ out, the CLI honors the `NOGGIN` env var, which the extension
119
120
  sets in every terminal — so `node noggin.mjs ...` in a VS Code
120
121
  terminal still hits the right file. Use `noggin where` if you need
121
122
  to confirm which file the CLI would touch.
122
- 11. **Outside VS Code (Copilot CLI, Claude Code, Codex), prefer the MCP
123
+ 11. **Outside VS Code (GitHub Copilot CLI, Claude Code, Codex), prefer the MCP
123
124
  tools** (`noggin_show`, `noggin_push`, etc.) when the host has the
124
125
  noggin MCP server wired up — they return the same JSON envelope as
125
126
  the CLI with no spawn cost. Fall back to `noggin.mjs` only when no
126
127
  tool surface is available.
128
+ 12. **The MCP server is multi-noggin: every tool call requires a `noggin`
129
+ parameter** — a canonical location string like `~/.noggin.yaml`,
130
+ `./.noggin.yaml`, or `file:///abs/path.yaml`. There is no
131
+ server-wide default. Pass the location the user is working with;
132
+ if you don't know it, ask. Use `noggin_where` to confirm a noggin
133
+ is reachable, or `noggin_factories` to discover what location forms
134
+ the server accepts.
127
135
 
128
136
  ## Resumption note template
129
137