@unpolarize/knowledge-planning 0.1.0 → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 unpolarize
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,92 +1,139 @@
1
1
  # @unpolarize/knowledge-planning
2
2
 
3
- A durable, git-backed, **life-wide** planning system software, career, finances, family,
4
- research over a markdown SSOT. Combines Nimbalyst (plans/tracker/session-kanban) and Vibe
5
- Kanban (card agent execution) patterns, wired to the `~/docs` knowledge base (`blocked_by`
6
- edges) and the portable `~/.sessions` corpus (`planning_refs`).
3
+ **KP** — a durable, git-backed planning CLI and library over a **markdown SSOT**. It makes
4
+ the work that ideas and agent sessions advance first-class: every task, idea, plan, and thought
5
+ is a markdown file with typed frontmatter, addressable by a stable id, queryable, and linkable to
6
+ coding sessions.
7
7
 
8
- Implements the design in `~/docs/knowledge/tech/agents/knowledge-planning-design.md`.
8
+ - **Life-wide, not just software** — model any set of domains (work, life, whatever you define).
9
+ - **Plain files, in git** — the store is a directory of markdown; nothing is locked in a database.
10
+ - **CLI + library + optional web UI** — script it, embed it, or serve a localhost dashboard.
9
11
 
10
- ## Why
12
+ ## Install
11
13
 
12
- Planning was scattered across a Google Doc, `notes.md`, and `tasks.md`, with no durable,
13
- queryable, session-linked home for ideas/plans/daily work. This makes the *work that agent
14
- sessions advance* first-class, in git, addressable by stable id.
14
+ ```bash
15
+ npm i -g @unpolarize/knowledge-planning # global CLI: `kp` / `knowledge-planning`
16
+ # or, no install:
17
+ npx @unpolarize/knowledge-planning --help
18
+ # or as a library:
19
+ npm i @unpolarize/knowledge-planning
20
+ ```
21
+
22
+ Requires **Node ≥ 22** (uses the built-in `node:sqlite` for the read index — no native modules).
15
23
 
16
- ## Data / code split
24
+ ## The store (your data)
17
25
 
18
- This repo is **tool source only**. The planning **data** (the SSOT) lives in the knowledge base
19
- at **`~/docs/planning`**, and execution **sessions** live in **`~/.sessions`** (separate git repos).
20
- The CLI defaults its store root to `~/docs/planning` (override with `--root` / `$KP_ROOT`).
26
+ The **data** lives wherever you point KP it is separate from this package. Set the store root
27
+ with `--root <dir>` or `$KP_ROOT` (default: `~/.knowledge-planning`). A store is just:
21
28
 
22
29
  ```
23
- ~/projects/unpolarize/knowledge-planning ← THIS repo (code)
24
- src/
25
- schema/ # Zod entities + frontmatter parse/serialize
26
- store/ # markdown read/write, edges
27
- index/ # node:sqlite projection (objects, edges, fts, blocked-by, daily board)
28
- graph/ # GraphData for the CSV webview
29
- kb-bridge/ # resolve KnowledgeRef → ~/docs; decision detection
30
- migrate/ # Google Doc / notes.md bullets seed objects
31
- cli/ # the `kp` command
32
- scripts/seed.ts # reproducible dogfood seed (writes to ~/docs/planning)
33
-
34
- ~/docs/planning ← the DATA store (SSOT, in the KB)
35
- config.json # domains, kb_root (~/docs), sessions_root (~/.sessions)
36
- domains/ catalog/ projects/ ideas/ plans/ tasks/ daily/ reflections/ insights/
37
- edges.jsonl # explicit edges (append-only; rebuildable from frontmatter)
38
- .index/planning.db # node:sqlite projection (gitignored, rebuilt by `kp reindex`)
30
+ <store>/
31
+ config.json # domains, kb_root, sessions_root, optional project rules
32
+ ideas/ plans/ tasks/ thoughts/ projects/ domains/ daily/ reflections/ insights/
33
+ edges.jsonl # explicit typed edges (append-only; rebuildable from frontmatter)
34
+ .index/planning.db # node:sqlite projection (gitignored; rebuilt by `kp reindex`)
35
+ ```
36
+
37
+ `config.json` (all optional; sensible defaults):
38
+
39
+ ```jsonc
40
+ {
41
+ "domains": ["work", "life"],
42
+ "kb_root": "/path/to/knowledge-base", // where blocked_by / cites refs resolve
43
+ "sessions_root": "/path/to/session-store", // git session corpus for planning_refs
44
+ "project_rules": [ // optional: derive-projects id/text rules
45
+ { "project": "projects/my-app", "patterns": ["my-app", "\\bMYAPP\\b"] }
46
+ ],
47
+ "project_id_rules": [{ "pattern": "^tasks/myapp-", "project": "projects/my-app" }]
48
+ }
39
49
  ```
40
50
 
51
+ Keep your store in its own git repo to get durable, cross-machine history for free.
52
+
41
53
  ## Entities
42
54
 
43
- `Domain` · `Project` (wraps projects-catalog + KB folder) · `CatalogEntry` (non-repo pursuit) ·
44
- `Idea` (capture→refine→accepted→…) · `Plan` (speckit dev / goal+steps life) · `Task` (kanban
45
- lanes) · `DailyPlan` · `Reflection` (human) · `Insight` (AI). Edges via frontmatter
55
+ `Domain` · `Project` · `CatalogEntry` · `Idea` (capture→refine→accepted→…) · `Plan`
56
+ (dev goal+steps / life goal) · `Task` (kanban lanes) · `Thought` (captured prose, convertible to
57
+ ideas/tasks) · `DailyPlan` · `Reflection` · `Insight`. Typed edges live in frontmatter
46
58
  (`blocked_by`, `depends_on`, `cites`, `related`, `promoted_to`, `linked_sessions`) unioned with
47
- `edges.jsonl`.
59
+ `edges.jsonl`. All schemas are Zod-validated and `.passthrough()`, so unknown keys survive a
60
+ round-trip.
48
61
 
49
- **Knowledge blocks work:** a `blocked_by` edge points at a `~/docs` article and is only
50
- *resolvable* once that article records a decision (`decision:` frontmatter or a `## Decision`
51
- section) — so the blocker tracks a real artifact instead of rotting.
62
+ **Knowledge can block work:** a `blocked_by` edge points at a knowledge-base article and is only
63
+ *resolvable* once that article records a decision so a blocker tracks a real artifact instead of
64
+ rotting.
52
65
 
53
66
  ## CLI
54
67
 
55
- No build step — Node ≥22 runs the TypeScript directly; `node:sqlite` needs no native module.
56
-
57
68
  ```bash
58
- node src/cli/index.ts <command> # or: npm run kp -- <command>
69
+ kp <command> [--root <store>]
59
70
 
60
- reindex # rebuild .index/planning.db
61
- list [--type T] [--status S] # list objects
71
+ reindex rebuild the .index/planning.db projection
72
+ list [--type T] [--status S] [--project P]
62
73
  daily [--date today] [--carry-over]
63
- blocked # objects blocked_by unresolved knowledge
64
- graph [--json] # nodes/edges
65
- capture "<text>" [--domain D] # quick-capture an idea
66
- promote <ideaId> [--to planId] # idea → plan (+lineage)
67
- link-session <objectId> <uuid> # bidirectional: linked_sessions session planning_refs
68
- insight <file> --source S # ingest digest bullets → Insight
69
- set-status <id> <status> # board lane / accept
70
- export [--date today] # one-shot JSON snapshot (consumed by the CSV planning mode)
71
- doctor # config, counts, fts, blocked, warnings
74
+ board alias for daily
75
+ blocked objects blocked_by unresolved knowledge
76
+ graph [--json] nodes/edges
77
+ capture "<text>" [--domain D] quick-capture an idea
78
+ create "<title>" [--type task|idea|plan|thought] [--status S --domain D --priority p0-p3 --due DATE]
79
+ promote <ideaId> [--to planId] idea plan (+ lineage)
80
+ set-status <id> <status> [--note "…"] change status; --note appends a Resolution section
81
+ set-due <id> <date|-> set/clear due date
82
+ set-priority <id> <p0-p3|-> set/clear priority
83
+ set-project <id> <project|-> assign/clear project
84
+ recategorize <id> [--to-type T --domain D --lane L]
85
+ link-session <id> <uuid> bidirectional: linked_sessions ↔ session planning_refs
86
+ ingest-gdoc <file> [--domain D --max N] NEW bullets → tasks/ideas (provenance-stamped)
87
+ ingest-thoughts <file> [--all --max N] NEW prose paragraphs → thoughts
88
+ derive-projects [--dry-run --force] label objects by config project rules
89
+ calendar [--from D] [--to D]
90
+ lookback [<date>|today] what happened that day (sessions + touched items)
91
+ serve [--port 4622] localhost web dashboard (board / calendar / topics / day)
92
+ export [--date today] one-shot JSON snapshot (for host integrations)
93
+ show <id> rich JSON detail (body + resolved refs + children)
94
+ doctor config, counts, index, blocked, warnings
95
+ ```
96
+
97
+ No build step is needed to run from a checkout (`node src/cli/index.ts <cmd>`); the published
98
+ package ships compiled JS.
99
+
100
+ ## Library
101
+
102
+ ```ts
103
+ import { Store, PlanningIndex, buildGraph, commands } from '@unpolarize/knowledge-planning';
104
+
105
+ const store = new Store(process.env.KP_ROOT!); // a store directory
106
+ const idx = new PlanningIndex(store);
107
+ console.log(commands.cmdExport(store, idx, store.config(), commands.today()));
72
108
  ```
73
109
 
74
- `KP_ROOT` (or `--root`) overrides the store root (defaults to this package root).
110
+ Exports the store reader/writer, the Zod entity schemas, the SQLite index/projection, the graph
111
+ builder, the markdown-ingest helpers, and the `commands` namespace (every CLI operation).
112
+
113
+ ## Web dashboard
114
+
115
+ `kp serve` starts a zero-dependency localhost dashboard (board with drag-and-drop, calendar,
116
+ topics, day lookback) over the same store. It binds `127.0.0.1` only — it is unauthenticated and
117
+ meant for local use.
75
118
 
76
- ## Integrations
119
+ ## Host integrations
77
120
 
78
- - **`~/docs` agent skills:** `/planning-daily`, `/planning-capture`, `/planning-refine`,
79
- `/planning-promote`, `/planning-link-session`, `/planning-blocked-by`, `/planning-insight`,
80
- `/planning-reflect` (in `~/docs/.claude/commands/`).
81
- - **Sessions:** `code-sessions` `SessionSchema` carries `planning_refs[]` + `phase`; `kp
82
- link-session` writes both sides.
83
- - **Code Sessions VS Code:** a **Planning** activity-bar container (Today / Inbox / Projects
84
- trees, kanban board + graph webviews, status bar) reads this store via `kp export`.
85
- - **Daily workflow:** the Google Doc stays the mobile capture surface; planning *ingests* from
86
- `raw/google-docs/personal-todo-notes.md` + `notes.md` rather than replacing it.
121
+ `kp export` emits a single JSON snapshot that a host UI can render; `kp show <id>` returns rich
122
+ per-object detail. This is how editor extensions and other front-ends consume KP without importing
123
+ its internals — they shell out to the CLI (or import the library) and read JSON.
124
+
125
+ ## How to consume it (summary)
126
+
127
+ - **CLI**: `npx @unpolarize/knowledge-planning` or a global install the `kp` binary.
128
+ - **Library**: `import from '@unpolarize/knowledge-planning'` (typed; ships `.d.ts`).
129
+ - **JSON bridge**: `kp export` / `kp show` for any front-end (the decoupled, version-independent path).
87
130
 
88
131
  ## Tests
89
132
 
90
133
  ```bash
91
- npm test # vitest — schema, store, kb-bridge, migrate, index, graph, cli (29 tests)
134
+ npm test # vitest — schema, store, kb-bridge, migrate, index, graph, cli, serve
92
135
  ```
136
+
137
+ ## License
138
+
139
+ MIT