mdkg 0.0.1

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/dist/cli.js +12 -0
  4. package/package.json +26 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nick Reames
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 ADDED
@@ -0,0 +1,210 @@
1
+ # mdkg — Markdown Knowledge Graph
2
+
3
+ mdkg is a **local-first CLI** that turns structured Markdown into a **searchable, linkable knowledge graph** for engineering work.
4
+
5
+ It’s designed for:
6
+ - humans who want lightweight project documentation + task tracking **in git**
7
+ - AI coding agents/LLMs that need **deterministic context bundles** for code generation
8
+
9
+ mdkg is intentionally boring and portable:
10
+ - **Node.js 18+**
11
+ - written in **TypeScript**
12
+ - **zero runtime dependencies** (no sqlite, no external indexers)
13
+ - works with npm / pnpm / bun
14
+
15
+ ---
16
+
17
+ ## Core idea
18
+
19
+ You store project knowledge as Markdown nodes with strict frontmatter (a small, stable schema). mdkg:
20
+
21
+ 1) indexes those nodes into a local JSON cache (`.mdkg/index/global.json`)
22
+ 2) provides fast search/list/show tools
23
+ 3) generates deterministic **context packs** for agents (Markdown/JSON/TOON exports)
24
+
25
+ Everything stays in your repo. No servers. No surprises.
26
+
27
+ ---
28
+
29
+ ## Repository structure
30
+
31
+ mdkg lives in a hidden directory at the repo root:
32
+
33
+ - `.mdkg/core/` — rules + “pinned” docs
34
+ - `.mdkg/design/` — decisions + architecture
35
+ - `.mdkg/work/` — epics/tasks/bugs/checkpoints
36
+ - `.mdkg/templates/` — document templates used by `mdkg new`
37
+ - `.mdkg/index/` — generated cache (gitignored)
38
+
39
+ mdkg is root-only: you run commands from the repository root and mdkg indexes all registered workspaces without “discovering” nested repos.
40
+
41
+ ---
42
+
43
+ ## Install
44
+
45
+ Pre-release note: this project is being actively developed and dogfooded.
46
+
47
+ Once published:
48
+ - `npm i -g mdkg`
49
+ - `pnpm add -g mdkg`
50
+ - `bun add -g mdkg`
51
+
52
+ ---
53
+
54
+ ## Quickstart
55
+
56
+ 1) Initialize mdkg in your repo:
57
+
58
+ ```bash
59
+ mdkg init
60
+ ```
61
+
62
+ This creates `.mdkg/` (rules, templates, work folders) and updates ignore rules so caches are not committed.
63
+
64
+ 2) Index your repo (cache is default behavior):
65
+
66
+ ```bash
67
+ mdkg index
68
+ ```
69
+
70
+ 3) Create a task from a template:
71
+
72
+ ```bash
73
+ mdkg new task "bootstrap cli" --status todo --priority 1 --tags cli,build
74
+ ```
75
+
76
+ 4) Search and list:
77
+
78
+ ```bash
79
+ mdkg search "pack"
80
+ mdkg list --type task --status todo
81
+ mdkg show task-1
82
+ ```
83
+
84
+ 5) Generate a deterministic context bundle for an agent:
85
+
86
+ ```bash
87
+ mdkg pack task-1 --format md --verbose
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Why this exists
93
+
94
+ LLMs are great at writing code, but they need **high-quality, structured context**.
95
+
96
+ mdkg makes that context:
97
+ - easy to author
98
+ - easy to query
99
+ - easy to hand to an agent
100
+ - reproducible across runs and contributors
101
+
102
+ This is also intended to be a compatible building block for “life git”-style productivity systems (which may later add richer databases like SQLite/Postgres). mdkg stays minimal and local.
103
+
104
+ ---
105
+
106
+ ## Concepts
107
+
108
+ ### Nodes
109
+
110
+ A node is a Markdown file with strict YAML-like frontmatter fenced by `---`.
111
+
112
+ Each node must include:
113
+ - `id` (unique)
114
+ - `type` (rule, prd, edd, dec, prop, epic, feat, task, bug, checkpoint)
115
+ - `title`
116
+ - `created` / `updated` (`YYYY-MM-DD`)
117
+
118
+ Work items also typically include:
119
+ - `status` (backlog, blocked, todo, progress, review, done)
120
+ - `priority` (0..9, where 0 is most urgent)
121
+
122
+ ### Graph links
123
+
124
+ mdkg treats these frontmatter fields as explicit graph structure:
125
+ - `epic`, `parent`
126
+ - `relates: [...]`
127
+ - `blocked_by: [...]`, `blocks: [...]`
128
+ - `prev`, `next` (chain navigation)
129
+
130
+ ### Searchable metadata
131
+
132
+ If you want something searchable, put it in frontmatter:
133
+ - `links: [ref, ref]` (URLs or any searchable reference string)
134
+ - `artifacts: [ref, ref]` (build outputs, PRs, commits, releases, tarballs, etc.)
135
+ - `refs: [id, id]` (non-edge references)
136
+ - `aliases: [text, text]`
137
+
138
+ ---
139
+
140
+ ## CLI commands (v1)
141
+
142
+ ### Project setup
143
+
144
+ - `mdkg init`
145
+ - create `.mdkg/` structure
146
+ - add ignore rules for caches
147
+
148
+ ### Indexing
149
+
150
+ - `mdkg index`
151
+ - builds `.mdkg/index/global.json`
152
+ - cache is the default; mdkg will reindex automatically if stale
153
+
154
+ ### Query
155
+
156
+ - `mdkg show <id-or-qid>`
157
+ - `mdkg list [--type <type>] [--status <status>] [--ws <alias>] [--epic <id>] [--priority <n>]`
158
+ - `mdkg search "<query>"`
159
+
160
+ ### Packs (agent context)
161
+
162
+ - `mdkg pack <id> [--format md|json|toon] [--verbose] [--depth <n>] [--edges <keys>]`
163
+
164
+ `--verbose` includes pinned core docs listed in `.mdkg/core/core.md`.
165
+
166
+ ### Workflow helpers
167
+
168
+ - `mdkg next [<id>] [--ws <alias>]`
169
+ - follows `next` chain if present; otherwise picks highest priority work item
170
+
171
+ - `mdkg checkpoint new "<title>"`
172
+ - creates a checkpoint node (a compression summary)
173
+
174
+ ### Quality gates
175
+
176
+ - `mdkg validate`
177
+ - strict frontmatter validation
178
+ - missing required fields, invalid enums, dangling edges, cycles, duplicates
179
+
180
+ - `mdkg format`
181
+ - conservative frontmatter normalizer (idempotent)
182
+
183
+ ---
184
+
185
+ ## Safety
186
+
187
+ mdkg is designed to avoid accidental leaks:
188
+ - cache files live under `.mdkg/index/` and must be gitignored
189
+ - publishing should use a strict `package.json.files` whitelist
190
+ - `.mdkg/` content should never ship to production builds
191
+
192
+ ---
193
+
194
+ ## Contributing
195
+
196
+ This repo dogfoods mdkg. The source of truth for behavior is:
197
+ - `.mdkg/core/rule-*.md`
198
+ - `.mdkg/core/guide.md`
199
+ - `.mdkg/core/rule-2-context-pack-rules.md`
200
+
201
+ Suggested workflow:
202
+ 1) create or update a task in `.mdkg/work/`
203
+ 2) run `mdkg validate`
204
+ 3) generate a pack for the task and use it as agent context
205
+
206
+ ---
207
+
208
+ ## License
209
+
210
+ MIT (recommended). Add a `LICENSE` file to confirm.
package/dist/cli.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+
3
+ const args = process.argv.slice(2);
4
+ if (args.includes("--help") || args.length === 0) {
5
+ console.log("mdkg - Markdown Knowledge Graph");
6
+ console.log("\nUsage:");
7
+ console.log(" mdkg <command> [options]");
8
+ process.exit(0);
9
+ }
10
+
11
+ console.error("Unknown command. Use --help for usage.");
12
+ process.exit(1);
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "mdkg",
3
+ "version": "0.0.1",
4
+ "description": "Markdown Knowledge Graph",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "mdkg": "dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist/",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+ssh://git@github.com/nickreames/mdkg.git"
20
+ },
21
+ "keywords": [
22
+ "markdown",
23
+ "knowledge-graph",
24
+ "cli"
25
+ ]
26
+ }