mdkg 0.0.1 → 0.0.2
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 +20 -6
- package/dist/cli.js +667 -11
- package/dist/commands/checkpoint.js +133 -0
- package/dist/commands/format.js +297 -0
- package/dist/commands/guide.js +22 -0
- package/dist/commands/index.js +17 -0
- package/dist/commands/init.js +111 -0
- package/dist/commands/list.js +52 -0
- package/dist/commands/new.js +279 -0
- package/dist/commands/next.js +75 -0
- package/dist/commands/node_card.js +17 -0
- package/dist/commands/pack.js +105 -0
- package/dist/commands/search.js +70 -0
- package/dist/commands/show.js +95 -0
- package/dist/commands/validate.js +229 -0
- package/dist/commands/workspace.js +101 -0
- package/dist/core/config.js +162 -0
- package/dist/core/migrate.js +30 -0
- package/dist/core/paths.js +14 -0
- package/dist/graph/edges.js +64 -0
- package/dist/graph/frontmatter.js +132 -0
- package/dist/graph/index_cache.js +50 -0
- package/dist/graph/indexer.js +144 -0
- package/dist/graph/node.js +225 -0
- package/dist/graph/staleness.js +31 -0
- package/dist/graph/template_schema.js +86 -0
- package/dist/graph/validate_graph.js +115 -0
- package/dist/graph/workspace_files.js +64 -0
- package/dist/init/AGENTS.md +43 -0
- package/dist/init/CLAUDE.md +37 -0
- package/dist/init/config.json +67 -0
- package/dist/init/core/core.md +12 -0
- package/dist/init/core/guide.md +99 -0
- package/dist/init/core/rule-1-mdkg-conventions.md +232 -0
- package/dist/init/core/rule-2-context-pack-rules.md +186 -0
- package/dist/init/core/rule-3-cli-contract.md +177 -0
- package/dist/init/core/rule-4-repo-safety-and-ignores.md +97 -0
- package/dist/init/core/rule-5-release-and-versioning.md +82 -0
- package/dist/init/core/rule-6-templates-and-schemas.md +186 -0
- package/dist/init/templates/default/bug.md +54 -0
- package/dist/init/templates/default/chk.md +55 -0
- package/dist/init/templates/default/dec.md +38 -0
- package/dist/init/templates/default/edd.md +50 -0
- package/dist/init/templates/default/epic.md +46 -0
- package/dist/init/templates/default/feat.md +35 -0
- package/dist/init/templates/default/prd.md +59 -0
- package/dist/init/templates/default/prop.md +45 -0
- package/dist/init/templates/default/rule.md +33 -0
- package/dist/init/templates/default/task.md +53 -0
- package/dist/init/templates/default/test.md +49 -0
- package/dist/pack/export_json.js +38 -0
- package/dist/pack/export_md.js +93 -0
- package/dist/pack/export_toon.js +7 -0
- package/dist/pack/export_xml.js +73 -0
- package/dist/pack/order.js +162 -0
- package/dist/pack/pack.js +181 -0
- package/dist/pack/types.js +2 -0
- package/dist/pack/verbose_core.js +23 -0
- package/dist/templates/loader.js +82 -0
- package/dist/util/argparse.js +154 -0
- package/dist/util/date.js +9 -0
- package/dist/util/errors.js +12 -0
- package/dist/util/filter.js +26 -0
- package/dist/util/output.js +50 -0
- package/dist/util/qid.js +54 -0
- package/dist/util/sort.js +40 -0
- package/package.json +18 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: rule-2
|
|
3
|
+
type: rule
|
|
4
|
+
title: mdkg context pack rules (selection, ordering, verbose, checkpoints)
|
|
5
|
+
tags: [agents, mdkg, pack, spec]
|
|
6
|
+
owners: []
|
|
7
|
+
links: []
|
|
8
|
+
artifacts: []
|
|
9
|
+
relates: []
|
|
10
|
+
refs: []
|
|
11
|
+
aliases: []
|
|
12
|
+
created: 2026-01-06
|
|
13
|
+
updated: 2026-01-14
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# mdkg context pack rules
|
|
17
|
+
|
|
18
|
+
A **context pack** is a deterministic export that bundles the root node plus relevant linked nodes, ordered for agent execution and constraint compliance.
|
|
19
|
+
|
|
20
|
+
Packs are the core feature that turns a Markdown graph into a repeatable “what to read before you code” artifact.
|
|
21
|
+
|
|
22
|
+
## Goals
|
|
23
|
+
|
|
24
|
+
- Deterministic: same repo state + same command → same pack ordering and contents.
|
|
25
|
+
- Relevant: include the minimum set needed to execute the work well.
|
|
26
|
+
- Safe: enforce limits to prevent runaway packs.
|
|
27
|
+
- Flexible: export to Markdown / JSON / TOON / XML.
|
|
28
|
+
|
|
29
|
+
## Command (conceptual)
|
|
30
|
+
|
|
31
|
+
`mdkg pack <id-or-qid> [--depth N] [--verbose] [--edges ...] [--ws <alias>] [--format md|json|toon|xml] [--out <path>]`
|
|
32
|
+
|
|
33
|
+
Notes:
|
|
34
|
+
- CLI normalizes to lowercase before processing.
|
|
35
|
+
- Packs are generated using the global index (auto-reindexed if stale).
|
|
36
|
+
|
|
37
|
+
## Node selection
|
|
38
|
+
|
|
39
|
+
### Root node
|
|
40
|
+
The root node is always included.
|
|
41
|
+
|
|
42
|
+
### Default depth
|
|
43
|
+
Default traversal depth is `2` unless overridden.
|
|
44
|
+
|
|
45
|
+
### Default edges
|
|
46
|
+
By default, traversal includes:
|
|
47
|
+
- `parent`
|
|
48
|
+
- `epic`
|
|
49
|
+
- `relates`
|
|
50
|
+
|
|
51
|
+
Non-edge references and metadata fields like `refs`, `links`, and `artifacts` are searchable and included in pack exports, but they are NOT traversed by default unless their corresponding graph edge keys are selected.
|
|
52
|
+
|
|
53
|
+
Optional edges (include only when requested via `--edges`):
|
|
54
|
+
- `blocked_by`
|
|
55
|
+
- `blocks`
|
|
56
|
+
- `prev`
|
|
57
|
+
- `next`
|
|
58
|
+
|
|
59
|
+
`--edges` adds to the default edge set; duplicates are ignored.
|
|
60
|
+
|
|
61
|
+
### Traversal method
|
|
62
|
+
- BFS traversal from the root to the specified depth.
|
|
63
|
+
- Nodes are de-duplicated by `qid` (qualified ID) in global mode.
|
|
64
|
+
|
|
65
|
+
## Ordering rules
|
|
66
|
+
|
|
67
|
+
Ordering is designed to maximize agent usefulness and rule compliance.
|
|
68
|
+
|
|
69
|
+
### Task-root ordering (recommended default)
|
|
70
|
+
|
|
71
|
+
1) Root `task-*` / `bug-*`
|
|
72
|
+
2) Immediate context:
|
|
73
|
+
- `parent` (if present)
|
|
74
|
+
- `epic` (if present)
|
|
75
|
+
- related `chk-*` (checkpoint summaries) when present
|
|
76
|
+
- blockers/blocked-by nodes when they are immediate (depth=1) and included via `--edges`
|
|
77
|
+
3) Architecture and constraints:
|
|
78
|
+
- `edd-*`
|
|
79
|
+
- `dec-*`
|
|
80
|
+
- `rule-*`
|
|
81
|
+
4) Product requirements:
|
|
82
|
+
- `prd-*`
|
|
83
|
+
5) Supporting docs:
|
|
84
|
+
- `prop-*` (and any future supporting types)
|
|
85
|
+
6) Work graph neighbors (if included):
|
|
86
|
+
- blockers, blocks, prev/next chain, related tasks/bugs
|
|
87
|
+
|
|
88
|
+
### Non-task root ordering (fallback)
|
|
89
|
+
|
|
90
|
+
If the root is not a `task-*` or `bug-*`, the root is still first. Remaining nodes are ordered by type priority:
|
|
91
|
+
|
|
92
|
+
1) `edd-*`
|
|
93
|
+
2) `dec-*`
|
|
94
|
+
3) `rule-*`
|
|
95
|
+
4) `prd-*`
|
|
96
|
+
5) `prop-*`
|
|
97
|
+
6) `epic-*`
|
|
98
|
+
7) `feat-*`
|
|
99
|
+
8) `task-*`
|
|
100
|
+
9) `bug-*`
|
|
101
|
+
10) `chk-*`
|
|
102
|
+
|
|
103
|
+
### Tie-breakers (stable determinism)
|
|
104
|
+
|
|
105
|
+
Within each group:
|
|
106
|
+
1) type priority (as listed above)
|
|
107
|
+
2) numeric ID ascending (use the trailing number in `<prefix>-<number>` when present; otherwise treat as infinity)
|
|
108
|
+
3) title lexicographic (final tie-break)
|
|
109
|
+
|
|
110
|
+
## Verbose mode (`--verbose`)
|
|
111
|
+
|
|
112
|
+
Verbose mode is intended for “fresh agent sessions” and MUST add baseline rules even if not directly linked.
|
|
113
|
+
|
|
114
|
+
When `--verbose` is enabled:
|
|
115
|
+
- include IDs listed in `.mdkg/core/core.md` (one per line)
|
|
116
|
+
- pinned core inclusion MUST obey pack limits
|
|
117
|
+
- IDs are resolved as `id` or `qid`; ambiguous matches should warn and be skipped unless a qualified ID is provided
|
|
118
|
+
|
|
119
|
+
If a pinned core ID does not exist, pack generation should warn but continue.
|
|
120
|
+
|
|
121
|
+
## Checkpoints (compression nodes)
|
|
122
|
+
|
|
123
|
+
Checkpoints (`chk-*`) are phase summaries that reduce context sprawl.
|
|
124
|
+
|
|
125
|
+
### Recommended checkpoint frontmatter fields
|
|
126
|
+
- `scope: [id, id, ...]` (IDs covered by the checkpoint)
|
|
127
|
+
|
|
128
|
+
### Pack behavior with checkpoints
|
|
129
|
+
- If the root node relates to a checkpoint, include the checkpoint early (immediate context).
|
|
130
|
+
- Optional future behavior (not required for v1): `--prefer-checkpoints`
|
|
131
|
+
- when enabled, if many “done” nodes are in scope and a checkpoint covers them, include the checkpoint instead of the underlying nodes (while still including core constraints like rules/decisions as needed).
|
|
132
|
+
|
|
133
|
+
## Limits
|
|
134
|
+
|
|
135
|
+
Default limits (configurable):
|
|
136
|
+
- `max_nodes: 25`
|
|
137
|
+
- `max_bytes: 2,000,000` for Markdown output
|
|
138
|
+
|
|
139
|
+
When a limit is hit:
|
|
140
|
+
- the root node MUST remain included
|
|
141
|
+
- higher-priority types (`edd/dec/rule/prd`) should be favored over low-priority neighbors
|
|
142
|
+
- pack metadata must record that truncation occurred
|
|
143
|
+
- `max_bytes` is enforced for Markdown output; other formats ignore byte limits in v1
|
|
144
|
+
|
|
145
|
+
## Export formats
|
|
146
|
+
|
|
147
|
+
### Markdown (`--format md`)
|
|
148
|
+
Markdown packs MUST include:
|
|
149
|
+
- a pack header with metadata (root, depth, verbose, node count, truncation flags)
|
|
150
|
+
- an ordered “included nodes” list
|
|
151
|
+
- each node content separated by a stable divider
|
|
152
|
+
- node headers should include: `qid`, `type`, `title`, `status` (if any), `priority` (if any), `path`, and the searchable frontmatter lists `links` and `artifacts`
|
|
153
|
+
|
|
154
|
+
Node bodies should exclude the full raw frontmatter by default to reduce noise, but the header MUST surface key searchable fields (at minimum: `links` and `artifacts`, plus `refs` when present). A future flag like `--include-frontmatter` may include the full raw frontmatter.
|
|
155
|
+
|
|
156
|
+
### JSON (`--format json`)
|
|
157
|
+
JSON packs MUST include:
|
|
158
|
+
- `meta` (root, generation timestamp, depth, verbose, truncation info)
|
|
159
|
+
- `nodes` array in the same order as Markdown packs
|
|
160
|
+
- each node includes:
|
|
161
|
+
- `qid`, `id`, `workspace`, `type`, `title`, `status`, `priority` (if any), `path`
|
|
162
|
+
- `frontmatter` (parsed restricted subset, including `links`, `artifacts`, `refs`, and `aliases` when present)
|
|
163
|
+
- `body` (content excluding frontmatter)
|
|
164
|
+
|
|
165
|
+
### TOON (`--format toon`)
|
|
166
|
+
TOON packs SHOULD mirror JSON semantics:
|
|
167
|
+
- meta
|
|
168
|
+
- ordered nodes
|
|
169
|
+
- node fields as above
|
|
170
|
+
|
|
171
|
+
Exact TOON encoding is defined by the project’s TOON spec adoption.
|
|
172
|
+
|
|
173
|
+
### XML (`--format xml`)
|
|
174
|
+
XML packs SHOULD mirror JSON semantics:
|
|
175
|
+
- `<pack>` root element with `<meta>` and `<nodes>`
|
|
176
|
+
- `<nodes>` contains ordered `<node>` elements
|
|
177
|
+
- node fields align with JSON exporter
|
|
178
|
+
- list fields are represented as repeated child elements
|
|
179
|
+
- body content must be safely encoded
|
|
180
|
+
|
|
181
|
+
## Determinism requirements
|
|
182
|
+
|
|
183
|
+
Given the same repo state and command flags:
|
|
184
|
+
- included node set must be identical
|
|
185
|
+
- ordering must be identical
|
|
186
|
+
- only timestamps in metadata may differ between runs
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: rule-3
|
|
3
|
+
type: rule
|
|
4
|
+
title: mdkg cli contract (root-only, commands, flags, exit codes)
|
|
5
|
+
tags: [cli, contract, mdkg, spec]
|
|
6
|
+
owners: []
|
|
7
|
+
links: []
|
|
8
|
+
artifacts: []
|
|
9
|
+
relates: []
|
|
10
|
+
refs: []
|
|
11
|
+
aliases: []
|
|
12
|
+
created: 2026-01-06
|
|
13
|
+
updated: 2026-01-22
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# mdkg CLI contract
|
|
17
|
+
|
|
18
|
+
This rule defines the **stable CLI behavior** for mdkg v1. The CLI is designed for humans and AI coding agents to use deterministically.
|
|
19
|
+
|
|
20
|
+
## Root-only requirement
|
|
21
|
+
|
|
22
|
+
mdkg commands are intended to run at the **repo root**.
|
|
23
|
+
|
|
24
|
+
- The repo root is the current working directory containing `./.mdkg/config.json`.
|
|
25
|
+
- mdkg MUST NOT walk upward to find config by default.
|
|
26
|
+
- If config is not found in the current directory:
|
|
27
|
+
- mdkg MUST exit non-zero and print a helpful error.
|
|
28
|
+
- Users may pass `--root <path>` to run from elsewhere.
|
|
29
|
+
|
|
30
|
+
### `--root`
|
|
31
|
+
`--root <path>` sets the root directory explicitly.
|
|
32
|
+
|
|
33
|
+
- `<path>` may be the repo root or a path that contains `.mdkg/config.json`.
|
|
34
|
+
- When `--root` is set, mdkg behaves as if it was invoked from that root.
|
|
35
|
+
|
|
36
|
+
## Case normalization
|
|
37
|
+
|
|
38
|
+
- The CLI MUST accept any case for user inputs (types, IDs, flags values).
|
|
39
|
+
- Before processing, mdkg MUST normalize:
|
|
40
|
+
- IDs to lowercase
|
|
41
|
+
- types to lowercase
|
|
42
|
+
- status to lowercase
|
|
43
|
+
- workspace aliases to lowercase
|
|
44
|
+
- template set names to lowercase
|
|
45
|
+
|
|
46
|
+
## Cache / auto reindex (default)
|
|
47
|
+
|
|
48
|
+
- Cache is enabled by default.
|
|
49
|
+
- Commands that rely on the graph MUST:
|
|
50
|
+
1) load `.mdkg/config.json`
|
|
51
|
+
2) check if the global index is stale
|
|
52
|
+
3) auto-reindex if stale (unless `--no-reindex` or config disables)
|
|
53
|
+
4) proceed using the global index
|
|
54
|
+
|
|
55
|
+
### Flags
|
|
56
|
+
- `--no-cache` (optional): bypass reading the cache (debug only)
|
|
57
|
+
- `--no-reindex` (optional): do not auto rebuild when stale (CI/debug)
|
|
58
|
+
|
|
59
|
+
In v1, `--no-cache` and `--no-reindex` are intended as escape hatches, not the normal workflow.
|
|
60
|
+
|
|
61
|
+
## Workspace behavior
|
|
62
|
+
|
|
63
|
+
Workspaces are registered in `.mdkg/config.json`.
|
|
64
|
+
|
|
65
|
+
- Default behavior is **global** across all registered workspaces.
|
|
66
|
+
- Many commands SHOULD support:
|
|
67
|
+
- `--ws <alias>` to filter results to a workspace
|
|
68
|
+
- `--ws all` to force global behavior (optional; may be default)
|
|
69
|
+
|
|
70
|
+
Qualified IDs may be used as input:
|
|
71
|
+
- `<ws>:<id>` (example: `e2e:task-12`)
|
|
72
|
+
|
|
73
|
+
If a user provides an unqualified ID and it is ambiguous globally:
|
|
74
|
+
- mdkg MUST error and suggest qualified IDs.
|
|
75
|
+
|
|
76
|
+
## Exit codes (v1)
|
|
77
|
+
|
|
78
|
+
- `0` success
|
|
79
|
+
- `1` general error / invalid usage
|
|
80
|
+
- `2` validation error (frontmatter/schema/graph integrity)
|
|
81
|
+
- `3` not found (node/workspace/template not found)
|
|
82
|
+
- `4` index error (index build failure)
|
|
83
|
+
|
|
84
|
+
## Output conventions
|
|
85
|
+
|
|
86
|
+
- Human-readable output to stdout.
|
|
87
|
+
- Errors to stderr.
|
|
88
|
+
- Commands should be script-friendly:
|
|
89
|
+
- concise outputs for single items
|
|
90
|
+
- predictable formatting
|
|
91
|
+
- optional `--json` output later (not required for v1)
|
|
92
|
+
- when printing node summaries (e.g., `show`/list results), outputs SHOULD surface key searchable frontmatter fields such as `links` and `artifacts`
|
|
93
|
+
|
|
94
|
+
## Command set (v1 target)
|
|
95
|
+
|
|
96
|
+
### Initialization
|
|
97
|
+
- `mdkg init`
|
|
98
|
+
- creates `.mdkg/` directory structure at root
|
|
99
|
+
- creates `.mdkg/config.json` if missing
|
|
100
|
+
- creates core docs and templates if missing
|
|
101
|
+
- does NOT overwrite existing docs unless `--force`
|
|
102
|
+
- optional agent files:
|
|
103
|
+
- `--agents` creates `AGENTS.md`
|
|
104
|
+
- `--claude` creates `CLAUDE.md`
|
|
105
|
+
- `--llm` creates both
|
|
106
|
+
|
|
107
|
+
### Guide
|
|
108
|
+
- `mdkg guide`
|
|
109
|
+
- prints `.mdkg/core/guide.md` to stdout
|
|
110
|
+
|
|
111
|
+
### Workspace management (registered, no discovery)
|
|
112
|
+
- `mdkg workspace ls`
|
|
113
|
+
- `mdkg workspace add <alias> <path>`
|
|
114
|
+
- `mdkg workspace rm <alias>`
|
|
115
|
+
|
|
116
|
+
### Indexing
|
|
117
|
+
- `mdkg index`
|
|
118
|
+
- rebuild global cache `.mdkg/index/global.json`
|
|
119
|
+
- strict by default (fails on invalid frontmatter)
|
|
120
|
+
- optional `--tolerant` to skip invalid nodes (escape hatch)
|
|
121
|
+
|
|
122
|
+
### Create nodes
|
|
123
|
+
- `mdkg new <type> "<title>" [flags]`
|
|
124
|
+
- uses global templates (root-only) via token substitution
|
|
125
|
+
- writes into the appropriate workspace-local `.mdkg/<area>/` folder
|
|
126
|
+
- updates index if necessary
|
|
127
|
+
|
|
128
|
+
Common flags:
|
|
129
|
+
- `--ws <alias>` (default `root`)
|
|
130
|
+
- `--status <status>` (work items)
|
|
131
|
+
- `--priority <0..9>` (work items)
|
|
132
|
+
- `--epic <id>`
|
|
133
|
+
- `--parent <id>`
|
|
134
|
+
- `--relates <id,id,...>`
|
|
135
|
+
- `--blocked-by <id,id,...>`
|
|
136
|
+
- `--blocks <id,id,...>`
|
|
137
|
+
- `--prev <id>`
|
|
138
|
+
- `--next <id>`
|
|
139
|
+
- `--links <ref,ref,...>`
|
|
140
|
+
- `--artifacts <ref,ref,...>`
|
|
141
|
+
- `--refs <id,id,...>`
|
|
142
|
+
- `--aliases <text,text,...>`
|
|
143
|
+
- `--template <set>` (default from config)
|
|
144
|
+
|
|
145
|
+
### Read/search
|
|
146
|
+
- `mdkg show <id-or-qid>`
|
|
147
|
+
- `mdkg search "<query>" [--type <type>] [--status <status>] [--ws <alias>]`
|
|
148
|
+
- search SHOULD match on IDs, titles, tags, path tokens, and searchable frontmatter lists (`links`, `artifacts`, `refs`, `aliases`)
|
|
149
|
+
- `mdkg list [--type <type>] [--status <status>] [--ws <alias>] [--epic <id>] [--blocked] [--priority <n>]`
|
|
150
|
+
|
|
151
|
+
### Graph views
|
|
152
|
+
- `mdkg tree <epic-id-or-qid> [--ws <alias>]`
|
|
153
|
+
- `mdkg neighbors <id-or-qid> --depth <n> [--edges <...>]`
|
|
154
|
+
|
|
155
|
+
### Packs (core feature)
|
|
156
|
+
- `mdkg pack <id-or-qid> [--depth <n>] [--verbose] [--edges <keys>] [--format md|json|toon|xml] [--out <path>] [--ws <alias>]`
|
|
157
|
+
- `--edges` adds to the default edge set
|
|
158
|
+
- `--out` writes to a file (create parent dirs; overwrite if exists)
|
|
159
|
+
- if `--out` is omitted, write to `.mdkg/pack/pack_<kind>_<id>_<timestamp>.<ext>`
|
|
160
|
+
- short flags supported: `-o`, `-f`, `-v`, `-d`, `-e`, `-w`, `-r`
|
|
161
|
+
|
|
162
|
+
### Next priority
|
|
163
|
+
- `mdkg next [<id-or-qid>] [--ws <alias>]`
|
|
164
|
+
- If `<id>` provided: follow `next` if present; otherwise fall back to priority-based selection.
|
|
165
|
+
- If no `<id>` provided: use priority-based selection (and optionally an epic filter in future).
|
|
166
|
+
|
|
167
|
+
### Checkpoints
|
|
168
|
+
- `mdkg checkpoint new "<title>" [--ws <alias>] [--relates <id,...>] [--scope <id,...>]`
|
|
169
|
+
- creates a `chk-*` node from template
|
|
170
|
+
- designed as a phase summary / compression node
|
|
171
|
+
|
|
172
|
+
### Validation and formatting
|
|
173
|
+
- `mdkg validate`
|
|
174
|
+
- strict frontmatter + graph integrity checks (exit code 2 on failure)
|
|
175
|
+
- `mdkg format`
|
|
176
|
+
- normalize frontmatter formatting and casing
|
|
177
|
+
- avoid destructive body edits
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: rule-4
|
|
3
|
+
type: rule
|
|
4
|
+
title: mdkg repo safety (ignore rules, publish safety, deployment safety)
|
|
5
|
+
tags: [mdkg, publishing, safety]
|
|
6
|
+
owners: []
|
|
7
|
+
links: []
|
|
8
|
+
artifacts: []
|
|
9
|
+
relates: []
|
|
10
|
+
refs: []
|
|
11
|
+
aliases: []
|
|
12
|
+
created: 2026-01-06
|
|
13
|
+
updated: 2026-01-14
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Repo safety and ignores
|
|
17
|
+
|
|
18
|
+
mdkg content may contain sensitive notes and internal project planning. This rule defines how to prevent `.mdkg/` content from leaking into build artifacts, containers, and npm packages.
|
|
19
|
+
|
|
20
|
+
## Safety goals
|
|
21
|
+
|
|
22
|
+
- `.mdkg/` must not be shipped to production deployments.
|
|
23
|
+
- `.mdkg/` must not be published to npm.
|
|
24
|
+
- `.mdkg/index/` must never be committed.
|
|
25
|
+
|
|
26
|
+
## Git ignore requirements
|
|
27
|
+
|
|
28
|
+
The repo MUST ignore at minimum:
|
|
29
|
+
|
|
30
|
+
- `node_modules/`
|
|
31
|
+
- `dist/`
|
|
32
|
+
- `.mdkg/index/`
|
|
33
|
+
- `.mdkg/pack/`
|
|
34
|
+
|
|
35
|
+
Recommended `.gitignore` entries:
|
|
36
|
+
- `.mdkg/index/`
|
|
37
|
+
- `.mdkg/index/**`
|
|
38
|
+
- `.mdkg/pack/`
|
|
39
|
+
|
|
40
|
+
## npm publish safety (required)
|
|
41
|
+
|
|
42
|
+
The npm package MUST publish only the compiled CLI output and essential docs.
|
|
43
|
+
|
|
44
|
+
Required approach:
|
|
45
|
+
- Use `package.json` `"files"` whitelist to ship only:
|
|
46
|
+
- `dist/`
|
|
47
|
+
- `README.md`
|
|
48
|
+
- `LICENSE`
|
|
49
|
+
|
|
50
|
+
This approach is preferred over blacklists.
|
|
51
|
+
|
|
52
|
+
Additional belt-and-suspenders:
|
|
53
|
+
- Add `.npmignore` that excludes `.mdkg/` and other repo internals, even if `"files"` exists.
|
|
54
|
+
|
|
55
|
+
## Container and deployment safety (recommended)
|
|
56
|
+
|
|
57
|
+
If the repo is containerized:
|
|
58
|
+
- `.dockerignore` SHOULD exclude:
|
|
59
|
+
- `.mdkg/`
|
|
60
|
+
- `.mdkg/index/`
|
|
61
|
+
- `node_modules/`
|
|
62
|
+
- `dist/` (if built in container)
|
|
63
|
+
- any other local artifacts
|
|
64
|
+
|
|
65
|
+
For application builds:
|
|
66
|
+
- Build tooling SHOULD exclude `.mdkg/` (e.g., tsconfig excludes, bundlers exclude dot-folders).
|
|
67
|
+
|
|
68
|
+
## mdkg init behavior
|
|
69
|
+
|
|
70
|
+
`mdkg init` MAY offer optional flags to append ignore entries:
|
|
71
|
+
|
|
72
|
+
- `--update-gitignore`
|
|
73
|
+
- `--update-npmignore`
|
|
74
|
+
- `--update-dockerignore`
|
|
75
|
+
|
|
76
|
+
In v1, mdkg should default to **not** editing user files without an explicit flag.
|
|
77
|
+
|
|
78
|
+
## Index safety
|
|
79
|
+
|
|
80
|
+
- `.mdkg/index/` is generated.
|
|
81
|
+
- Index files may contain extracted metadata and could expose sensitive strings.
|
|
82
|
+
- Index files MUST be ignored from git.
|
|
83
|
+
- Index rebuild should be deterministic and safe to regenerate at any time.
|
|
84
|
+
|
|
85
|
+
## Workspace safety
|
|
86
|
+
|
|
87
|
+
Workspace-local `.mdkg/` directories (near code) should follow the same rules:
|
|
88
|
+
- the content is source-of-truth docs (tracked)
|
|
89
|
+
- the workspace-local index folder (if present) should be ignored
|
|
90
|
+
- templates remain global (root) in v1
|
|
91
|
+
|
|
92
|
+
## Summary checklist
|
|
93
|
+
|
|
94
|
+
- ✅ `.mdkg/index/` ignored
|
|
95
|
+
- ✅ npm publishes only `dist/`, `README.md`, `LICENSE`
|
|
96
|
+
- ✅ optional `.npmignore` excludes `.mdkg/`
|
|
97
|
+
- ✅ `.dockerignore` excludes `.mdkg/` when applicable
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: rule-5
|
|
3
|
+
type: rule
|
|
4
|
+
title: mdkg release and versioning (semver, publish checklist)
|
|
5
|
+
tags: [mdkg, npm, release, semver]
|
|
6
|
+
owners: []
|
|
7
|
+
links: []
|
|
8
|
+
artifacts: []
|
|
9
|
+
relates: []
|
|
10
|
+
refs: []
|
|
11
|
+
aliases: []
|
|
12
|
+
created: 2026-01-06
|
|
13
|
+
updated: 2026-01-14
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Release and versioning
|
|
17
|
+
|
|
18
|
+
mdkg follows SemVer for CLI stability and long-term compatibility.
|
|
19
|
+
|
|
20
|
+
## SemVer policy
|
|
21
|
+
|
|
22
|
+
- MAJOR: breaking CLI contract changes (flags/outputs removed or changed)
|
|
23
|
+
- MINOR: new commands/features that are backwards compatible
|
|
24
|
+
- PATCH: bug fixes and internal refactors with no contract changes
|
|
25
|
+
|
|
26
|
+
Configuration and schema versioning:
|
|
27
|
+
- `.mdkg/config.json` contains a `schema_version`.
|
|
28
|
+
- mdkg MUST support migrating older schemas to the current schema in a deterministic way.
|
|
29
|
+
- Backwards compatibility matters more for config and docs than for internal index formats.
|
|
30
|
+
|
|
31
|
+
## Release artifacts
|
|
32
|
+
|
|
33
|
+
The npm package MUST include:
|
|
34
|
+
- `dist/` compiled output
|
|
35
|
+
- `README.md`
|
|
36
|
+
- `LICENSE`
|
|
37
|
+
|
|
38
|
+
It MUST NOT include:
|
|
39
|
+
- `.mdkg/` docs
|
|
40
|
+
- `.mdkg/index/`
|
|
41
|
+
- source code (optional; can be included later, but not required)
|
|
42
|
+
|
|
43
|
+
## Release checklist (v1)
|
|
44
|
+
|
|
45
|
+
1) Ensure clean working tree
|
|
46
|
+
- no uncommitted changes
|
|
47
|
+
- all `.mdkg/index/` ignored
|
|
48
|
+
|
|
49
|
+
2) Rebuild and validate
|
|
50
|
+
- run `mdkg index`
|
|
51
|
+
- run `mdkg validate`
|
|
52
|
+
- run a pack smoke test (example):
|
|
53
|
+
- `mdkg pack task-1 --verbose --out /tmp/mdkg-pack.md`
|
|
54
|
+
|
|
55
|
+
3) Update version
|
|
56
|
+
- bump `package.json` version (semver)
|
|
57
|
+
|
|
58
|
+
4) Update changelog (recommended)
|
|
59
|
+
- add a short entry describing changes
|
|
60
|
+
|
|
61
|
+
5) Build
|
|
62
|
+
- run `npm run build` (or equivalent)
|
|
63
|
+
- confirm `dist/cli.js` exists and is executable as a node script
|
|
64
|
+
|
|
65
|
+
6) Confirm publish whitelist
|
|
66
|
+
- verify `package.json` `"files"` includes only expected files
|
|
67
|
+
- optionally run `npm pack` and inspect tarball contents
|
|
68
|
+
|
|
69
|
+
7) Publish
|
|
70
|
+
- `npm publish`
|
|
71
|
+
|
|
72
|
+
8) Tag and push
|
|
73
|
+
- create git tag matching version (example `v0.1.0`)
|
|
74
|
+
- push commits and tags
|
|
75
|
+
|
|
76
|
+
## Release notes guidance
|
|
77
|
+
|
|
78
|
+
Release notes should call out:
|
|
79
|
+
- new commands / flags
|
|
80
|
+
- changes to pack behavior
|
|
81
|
+
- changes to config schema (and how migration behaves)
|
|
82
|
+
- new node types or template changes
|