@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 +21 -0
- package/README.md +109 -62
- package/dist/chunk-6GL2IYUE.js +2020 -0
- package/dist/cli.js +385 -0
- package/dist/index.d.ts +4532 -0
- package/dist/index.js +94 -0
- package/dist/server-NXAKSD5Z.js +862 -0
- package/package.json +19 -9
- package/src/cli/commands.test.ts +0 -105
- package/src/cli/commands.ts +0 -341
- package/src/cli/index.ts +0 -189
- package/src/cli/sessions.ts +0 -40
- package/src/graph/graph.ts +0 -67
- package/src/index/db.test.ts +0 -91
- package/src/index/db.ts +0 -196
- package/src/index.ts +0 -14
- package/src/kb-bridge/kb-bridge.test.ts +0 -44
- package/src/kb-bridge/kb-bridge.ts +0 -63
- package/src/migrate/gdoc.test.ts +0 -28
- package/src/migrate/gdoc.ts +0 -68
- package/src/schema/entities.test.ts +0 -60
- package/src/schema/entities.ts +0 -233
- package/src/schema/frontmatter.ts +0 -44
- package/src/schema/index.ts +0 -2
- package/src/store/store.test.ts +0 -64
- package/src/store/store.ts +0 -231
- package/src/types.ts +0 -18
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
12
|
+
## Install
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
##
|
|
24
|
+
## The store (your data)
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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`
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
50
|
-
*resolvable* once that article records a decision
|
|
51
|
-
|
|
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
|
-
|
|
69
|
+
kp <command> [--root <store>]
|
|
59
70
|
|
|
60
|
-
reindex
|
|
61
|
-
list [--type T] [--status S]
|
|
71
|
+
reindex rebuild the .index/planning.db projection
|
|
72
|
+
list [--type T] [--status S] [--project P]
|
|
62
73
|
daily [--date today] [--carry-over]
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
set-status <id> <status>
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
119
|
+
## Host integrations
|
|
77
120
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- **
|
|
86
|
-
|
|
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
|
|
134
|
+
npm test # vitest — schema, store, kb-bridge, migrate, index, graph, cli, serve
|
|
92
135
|
```
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|