@justestif/pk 0.1.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/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@justestif/pk",
3
+ "version": "0.1.0",
4
+ "description": "Project knowledge — structured intake, search, and recall",
5
+ "bin": {
6
+ "pk": "dist/index.js"
7
+ },
8
+ "files": [
9
+ "dist/",
10
+ "skill/",
11
+ "README.md"
12
+ ],
13
+ "scripts": {
14
+ "build": "bun build src/index.ts --outfile dist/index.js --target bun && printf '#!/usr/bin/env bun\n' | cat - dist/index.js > dist/tmp.js && mv dist/tmp.js dist/index.js && chmod +x dist/index.js",
15
+ "check": "bun run typecheck && bun run lint && bun test",
16
+ "typecheck": "bunx tsc --noEmit",
17
+ "lint": "bunx eslint src/",
18
+ "test": "bun test",
19
+ "prepublishOnly": "bun run build"
20
+ },
21
+ "dependencies": {
22
+ "commander": "^14.0.0",
23
+ "markdownlint": "^0.40.0"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/justEstif/pk.git"
28
+ },
29
+ "devDependencies": {
30
+ "@types/bun": "latest",
31
+ "typescript": "latest",
32
+ "eslint": "^9.0.0",
33
+ "typescript-eslint": "^8.0.0"
34
+ }
35
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: pk
3
+ description: "Load when maintaining project knowledge, capturing decisions or questions, looking up what the project knows, organizing notes, running knowledge intake, or initializing a project knowledge base. Keywords: pk, project knowledge, decision log, note, source, question log, knowledge base, intake."
4
+ ---
5
+
6
+ # pk
7
+
8
+ Structured project knowledge — intake, search, recall, and audit over `knowledge/`.
9
+
10
+ ## Prerequisites
11
+
12
+ Verify before every operation:
13
+
14
+ ```bash
15
+ pk --version 2>/dev/null || npm install -g @justestif/pk
16
+ ```
17
+
18
+ ## First use in a project
19
+
20
+ ```bash
21
+ pk init
22
+ ```
23
+
24
+ Creates `knowledge/`, installs Claude Code hook at `.claude/hooks/pk-user-prompt-submit.ts`.
25
+ The hook injects open questions, recent decisions, and active notes into every prompt automatically.
26
+
27
+ ## Commands
28
+
29
+ ```bash
30
+ pk new <type> <title> [--tags tag1,tag2] # type: note|decision|question|source
31
+ pk search <query> [--context] [--limit 5]
32
+ pk synthesize [query] [--all] [--session-start]
33
+ pk index # rebuild FTS5 + markdown indexes
34
+ pk lint # validate structure — exit 1 on errors
35
+ pk instructions <command> # full behavioral guide per command
36
+ ```
37
+
38
+ Run all commands from the project root (where `knowledge/` lives).
39
+
40
+ ## Intake
41
+
42
+ **Search before creating** — always run `pk search` first.
43
+
44
+ - Substantial messy input → `source`. Extract `note`, `decision`, `question` only when durable beyond this session.
45
+ - Update existing when the match is obvious; otherwise create and link in body.
46
+ - Run `pk lint` before committing. Auto-commit coherent operations only when lint passes and no unrelated files are staged.
47
+
48
+ ## Asking
49
+
50
+ 1. `pk search <query> [--context]`
51
+ 2. Read top results directly
52
+ 3. Answer with citations to note paths/IDs
53
+ 4. If silent or ambiguous, offer to create a `question` note
54
+
55
+ ## NEVER
56
+
57
+ - **Skip `pk search` before creating** — duplicates erode trust in the knowledge base
58
+ - **Dump raw input into durable notes** — preserve in `source`, extract selectively
59
+ - **Silently merge related-but-different claims** — create and link instead
60
+ - **Auto-commit when lint fails or unrelated files are staged**
61
+
62
+ ## References
63
+
64
+ Load only when the task requires it:
65
+
66
+ - `references/knowledge-model.md` — types, folders, frontmatter schema, required sections
67
+ - `references/git-workflow.md` — commit policy, safety stops
68
+ - `references/source-principles.md` — documentation governance
@@ -0,0 +1,29 @@
1
+ ---
2
+ id: decision-{{date}}-{{slug}}
3
+ type: decision
4
+ title: {{title}}
5
+ created: {{date}}
6
+ updated: {{date}}
7
+ status: accepted
8
+ tags: [{{tags}}]
9
+ ---
10
+
11
+ ## Decision
12
+
13
+ What was decided.
14
+
15
+ ## Context
16
+
17
+ Why this decision came up.
18
+
19
+ ## Rationale
20
+
21
+ Why this option won.
22
+
23
+ ## Consequences
24
+
25
+ What this changes or constrains.
26
+
27
+ ## Related
28
+
29
+ Links to source, questions, notes, or superseded decisions.
@@ -0,0 +1,25 @@
1
+ ---
2
+ id: index-{{slug}}
3
+ type: index
4
+ title: {{title}}
5
+ created: {{date}}
6
+ updated: {{date}}
7
+ status: active
8
+ tags: [{{tags}}]
9
+ ---
10
+
11
+ ## Purpose
12
+
13
+ What this index helps navigate.
14
+
15
+ ## Key Links
16
+
17
+ Curated links.
18
+
19
+ ## Open Questions
20
+
21
+ Relevant unresolved questions.
22
+
23
+ ## Recent Changes
24
+
25
+ Notable updates.
@@ -0,0 +1,25 @@
1
+ ---
2
+ id: note-{{date}}-{{slug}}
3
+ type: note
4
+ title: {{title}}
5
+ created: {{date}}
6
+ updated: {{date}}
7
+ status: active
8
+ tags: [{{tags}}]
9
+ ---
10
+
11
+ ## Summary
12
+
13
+ One short paragraph.
14
+
15
+ ## Details
16
+
17
+ Durable project knowledge.
18
+
19
+ ## Evidence
20
+
21
+ Source links, files, quotes, or observations.
22
+
23
+ ## Related
24
+
25
+ Links to related notes, decisions, or questions.
@@ -0,0 +1,25 @@
1
+ ---
2
+ id: question-{{date}}-{{slug}}
3
+ type: question
4
+ title: {{title}}
5
+ created: {{date}}
6
+ updated: {{date}}
7
+ status: open
8
+ tags: [{{tags}}]
9
+ ---
10
+
11
+ ## Question
12
+
13
+ The unresolved question.
14
+
15
+ ## Why It Matters
16
+
17
+ What decision or work this blocks or informs.
18
+
19
+ ## Current Understanding
20
+
21
+ Known facts and candidate answers.
22
+
23
+ ## Resolution
24
+
25
+ Answer once resolved.
@@ -0,0 +1,21 @@
1
+ ---
2
+ id: source-{{date}}-{{slug}}
3
+ type: source
4
+ title: {{title}}
5
+ created: {{date}}
6
+ updated: {{date}}
7
+ status: unprocessed
8
+ tags: [{{tags}}]
9
+ ---
10
+
11
+ ## Source
12
+
13
+ Where this came from.
14
+
15
+ ## Raw Material
16
+
17
+ Original or lightly cleaned content.
18
+
19
+ ## Extracted Items
20
+
21
+ Links to notes, decisions, or questions created from this source.
@@ -0,0 +1,77 @@
1
+ # Git Workflow for Project Knowledge
2
+
3
+ Git is the audit, safety, and review layer for `knowledge/`.
4
+
5
+ ## Before Modifying Knowledge
6
+
7
+ Check repository state:
8
+
9
+ ```bash
10
+ git status --short
11
+ ```
12
+
13
+ Stop before editing if unrelated user changes would be mixed into the same commit. If changes are clearly knowledge-system work in scope, continue.
14
+
15
+ ## After Modifying Knowledge
16
+
17
+ Run mechanical maintenance:
18
+
19
+ ```bash
20
+ scripts/knowledge-index
21
+ scripts/knowledge-lint
22
+ ```
23
+
24
+ Review what changed:
25
+
26
+ ```bash
27
+ git diff -- knowledge scripts/knowledge-* assets/templates hk.pkl
28
+ ```
29
+
30
+ Summarize:
31
+
32
+ - files created
33
+ - files updated
34
+ - generated indexes
35
+ - lint result
36
+ - any ignored/deferred material
37
+
38
+ ## Auto-Commit Policy
39
+
40
+ Auto-commit coherent completed knowledge operations unless a safety stop applies.
41
+
42
+ Normal intake commits stage only:
43
+
44
+ ```bash
45
+ git add knowledge/
46
+ ```
47
+
48
+ Knowledge-system implementation commits may stage:
49
+
50
+ ```bash
51
+ git add knowledge/ scripts/knowledge-* assets/templates/ hk.pkl
52
+ ```
53
+
54
+ Use concise commit messages:
55
+
56
+ ```txt
57
+ knowledge: intake <topic>
58
+ knowledge: update <topic>
59
+ knowledge: answer <topic>
60
+ knowledge-system: update <topic>
61
+ ```
62
+
63
+ ## Safety Stops
64
+
65
+ Do not auto-commit when:
66
+
67
+ - unrelated project files are modified
68
+ - lint fails
69
+ - the edit deletes or rewrites existing knowledge ambiguously
70
+ - the working tree contains user changes outside the allowed commit boundary
71
+ - the user says not to commit
72
+
73
+ When stopped, report the exact reason and show the staged/unstaged state.
74
+
75
+ ## Hooks
76
+
77
+ If hk is used, run `knowledge-lint` on pre-commit only when `knowledge/**/*.md` changes. Avoid every-N-commit scheduling; it is arbitrary and less transparent than change-triggered checks.
@@ -0,0 +1,127 @@
1
+ # Project Knowledge Model
2
+
3
+ ## Scope
4
+
5
+ This system is project-specific. It is not a personal second brain, a full wiki platform, or a semantic memory database.
6
+
7
+ The canonical store is plain markdown under `knowledge/`. Beans/issues remain for trackable work; the knowledge base is for durable context and future answers.
8
+
9
+ ## Folder and Type Rules
10
+
11
+ | Type | Folder | Purpose | Status values |
12
+ | --- | --- | --- | --- |
13
+ | `source` | `knowledge/sources/` | Provenance and raw/lightly cleaned input | `unprocessed`, `processed`, `archived` |
14
+ | `note` | `knowledge/notes/` | Durable project knowledge | `active`, `superseded`, `archived` |
15
+ | `decision` | `knowledge/decisions/` | Chosen direction and rationale | `proposed`, `accepted`, `superseded` |
16
+ | `question` | `knowledge/questions/` | Unresolved or resolved uncertainty | `open`, `answered`, `obsolete` |
17
+ | `index` | `knowledge/indexes/` | Navigation/MOC pages | `active`, `archived` |
18
+
19
+ ## Frontmatter
20
+
21
+ Required fields only:
22
+
23
+ ```yaml
24
+ ---
25
+ id: note-YYYY-MM-DD-short-slug
26
+ type: note
27
+ title: Short title
28
+ created: YYYY-MM-DD
29
+ updated: YYYY-MM-DD
30
+ status: active
31
+ tags: [tag-one, tag-two]
32
+ ---
33
+ ```
34
+
35
+ Rules:
36
+
37
+ - `id` must be unique across `knowledge/**/*.md`.
38
+ - `type` must match both status set and folder.
39
+ - `tags` must be a flat list of lowercase slugs.
40
+ - Do not use nested YAML, multiline YAML, or relationship arrays.
41
+
42
+ ## Required Sections
43
+
44
+ ### source
45
+
46
+ - `## Source`
47
+ - `## Raw Material`
48
+ - `## Extracted Items`
49
+
50
+ ### note
51
+
52
+ - `## Summary`
53
+ - `## Details`
54
+ - `## Evidence`
55
+ - `## Related`
56
+
57
+ ### decision
58
+
59
+ - `## Decision`
60
+ - `## Context`
61
+ - `## Rationale`
62
+ - `## Consequences`
63
+ - `## Related`
64
+
65
+ ### question
66
+
67
+ - `## Question`
68
+ - `## Why It Matters`
69
+ - `## Current Understanding`
70
+ - `## Resolution`
71
+
72
+ ### index
73
+
74
+ - `## Purpose`
75
+ - `## Key Links`
76
+ - `## Open Questions`
77
+ - `## Recent Changes`
78
+
79
+ ## Intake Triage
80
+
81
+ Classify extracted material this way:
82
+
83
+ - Raw/provenance-heavy material → `source`
84
+ - Stable project fact/explanation/constraint → `note`
85
+ - Chosen path with rationale/consequences → `decision`
86
+ - Unknown that blocks or informs work → `question`
87
+ - Navigation over a topic/type/tag → `index`
88
+ - Action item/task → issue tracker, not a knowledge note
89
+ - Low-signal commentary → ignore or keep only in `source`
90
+
91
+ ## Update Policy
92
+
93
+ Search before creating durable notes.
94
+
95
+ - Exact or obvious same claim/topic → update existing note, preserving provenance.
96
+ - Related but not same → create a new note and link both in body sections.
97
+ - Contradictory or superseding claim → do not overwrite silently; explain the conflict and use status/linking.
98
+ - Unsure → create or update a `question` note.
99
+
100
+ ## Lint Policy
101
+
102
+ Hard failures:
103
+
104
+ - missing frontmatter
105
+ - missing required fields
106
+ - duplicate `id`
107
+ - invalid `type`
108
+ - invalid `status` for type
109
+ - file in wrong folder for `type`
110
+ - required sections missing
111
+ - broken internal markdown/wiki links
112
+
113
+ Warnings:
114
+
115
+ - empty `tags`
116
+ - length threshold exceeded
117
+ - `source` marked `processed` with no extracted items
118
+
119
+ Length warning thresholds:
120
+
121
+ - `question`: 80 lines
122
+ - `decision`: 120 lines
123
+ - `note`: 150 lines
124
+ - `index`: 200 lines
125
+ - `source`: 400 lines
126
+
127
+ Hard fail non-source notes over 400 lines.
@@ -0,0 +1,73 @@
1
+ # Governance Documentation Source Principles
2
+
3
+ Based on Frederick Vanbrabant's articles:
4
+
5
+ - Governance: Documentation as a Knowledge Network (2026-03-07)
6
+ - Governance: Documentation to support projects (2026-03-22)
7
+
8
+ ## Knowledge Network Principles
9
+
10
+ - Tools are usually not the problem; setup is. Confluence, Notion, Slite, SharePoint, etc. can work if the information architecture is deliberate.
11
+ - Knowledge graph beats folder dump: valuable knowledge is often in relationships between pages, not only in page content.
12
+ - MOCs (Maps of Content) are landing pages that both introduce a topic and route readers to deeper nodes.
13
+ - Atomic documentation means one concept per page. Use links/transclusion instead of repeating definitions.
14
+ - Folder structure remains useful as an adoption ramp for new users, but links should become the primary navigation once readers enter.
15
+ - Recommended top-level folders: Projects, Applications, Processes, Resources, Archive.
16
+ - Archive prevents broken links and preserves reuse value; use banners/status where tooling allows.
17
+ - Metadata worth adding: creation date, last-updated date, author, maybe status. Old information is not automatically bad.
18
+ - LLMs should support writing, not replace ownership. Atomic, linked notes reduce temptation to generate giant documents.
19
+
20
+ ## Project Documentation Principles
21
+
22
+ Documentation should grow organically from actual project communication and problems. If an issue happened once, documenting it prevents repeated confusion.
23
+
24
+ Four project areas:
25
+
26
+ 1. **Strategy** — Business Case, Kick-off Document.
27
+ 2. **Logs** — Open Questions Log, Decision Log, Constraint Log, Meeting Notes.
28
+ 3. **Blueprints** — TO-BE Diagram, AS-IS Diagram, Data Model, Phasing Diagrams.
29
+ 4. **Program Management** — Gantt chart / critical path.
30
+
31
+ ### Core Project Artifacts
32
+
33
+ Always consider these first:
34
+
35
+ - Business Case: the approved why; missing clarity causes drift.
36
+ - Decision & Question Logs: high-value historical nodes for future maintainers.
37
+ - TO-BE Diagram: quick shared reference for what changes.
38
+ - Gantt: centralizes timing, gates, dependencies, and impact.
39
+
40
+ ### Logs
41
+
42
+ Question Log fields: ID, descriptive name, dated history, priority, assignee, status. Link solved questions to the Decision Log.
43
+
44
+ Decision Log should capture: decision, context/question, chosen option, alternatives considered, why alternatives were rejected, constraints/trade-offs.
45
+
46
+ Constraint Log should capture budget, compliance, technical constraints, and other non-negotiables useful for onboarding.
47
+
48
+ Meeting notes can be AI-assisted because they are raw project evidence, not polished canonical docs.
49
+
50
+ ### Diagrams
51
+
52
+ Keep both editable raw formats and static exports. Add labels: author, date, status. For large projects, include AS-IS, TO-BE, and phase views. Data models help tool experts reason in systems of record and data flows.
53
+
54
+ ### Project Close
55
+
56
+ At close, project docs should not fade out. Run a retrospective and merge durable artifacts:
57
+
58
+ - Project target state becomes current state for the relevant application/process.
59
+ - Decisions/questions/constraints move or link into affected domain nodes.
60
+ - Diagrams move to application/process/resource areas.
61
+ - Remaining project material moves to Archive.
62
+
63
+ ## Evaluation Heuristics
64
+
65
+ Ask these when reviewing a documentation system:
66
+
67
+ - Can a newcomer find the right starting MOC in two clicks?
68
+ - Does each important concept have one canonical definition?
69
+ - Are decisions linked from the applications/processes they affect?
70
+ - Are open questions visible enough to manage project risk?
71
+ - Can readers move from high-level overview to technical specifics by following links?
72
+ - Would deleting a project folder break useful organisational memory?
73
+ - Is documentation scaled to risk, or copied from a framework checklist?