@panaversity/ksor 0.0.1 → 0.0.3

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 (51) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +24 -6
  3. package/dist/cli.mjs +345 -2
  4. package/docs/index.md +38 -6
  5. package/package.json +3 -1
  6. package/templates/LICENSE +23 -0
  7. package/templates/scaffold/.agents/skills/add-sources/SKILL.md +46 -0
  8. package/templates/scaffold/.agents/skills/format-checker/SKILL.md +46 -0
  9. package/templates/scaffold/.agents/skills/format-checker/check.mjs +991 -0
  10. package/templates/scaffold/.agents/skills/intake-interview/SKILL.md +61 -0
  11. package/templates/scaffold/.claude/skills/add-sources/SKILL.md +46 -0
  12. package/templates/scaffold/.claude/skills/format-checker/SKILL.md +46 -0
  13. package/templates/scaffold/.claude/skills/format-checker/check.mjs +991 -0
  14. package/templates/scaffold/.claude/skills/intake-interview/SKILL.md +61 -0
  15. package/templates/scaffold/.gemini/settings.json +5 -0
  16. package/templates/scaffold/.gitattributes +5 -0
  17. package/templates/scaffold/.github/workflows/validate.yml +23 -0
  18. package/templates/scaffold/AGENTS.md +133 -0
  19. package/templates/scaffold/CLAUDE.md +1 -0
  20. package/templates/scaffold/README.md +90 -0
  21. package/templates/scaffold/gitignore +16 -0
  22. package/templates/scaffold/instance.md +26 -0
  23. package/templates/scaffold/knowledge/example.md +23 -0
  24. package/templates/scaffold/package.json +15 -0
  25. package/templates/scaffold/pnpm-lock.yaml +4041 -0
  26. package/templates/scaffold/pnpm-workspace.yaml +19 -0
  27. package/templates/scaffold/system/site/app/(home)/layout.tsx +6 -0
  28. package/templates/scaffold/system/site/app/(home)/page.tsx +83 -0
  29. package/templates/scaffold/system/site/app/api/search/route.ts +11 -0
  30. package/templates/scaffold/system/site/app/docs/[[...slug]]/page.tsx +53 -0
  31. package/templates/scaffold/system/site/app/docs/layout.tsx +24 -0
  32. package/templates/scaffold/system/site/app/global.css +26 -0
  33. package/templates/scaffold/system/site/app/icon.png +0 -0
  34. package/templates/scaffold/system/site/app/layout.tsx +41 -0
  35. package/templates/scaffold/system/site/app/llms-full.txt/route.ts +10 -0
  36. package/templates/scaffold/system/site/app/llms.txt/route.ts +15 -0
  37. package/templates/scaffold/system/site/components/built-with.tsx +18 -0
  38. package/templates/scaffold/system/site/components/footer-mark.tsx +22 -0
  39. package/templates/scaffold/system/site/components/mdx.tsx +15 -0
  40. package/templates/scaffold/system/site/lib/audience.ts +178 -0
  41. package/templates/scaffold/system/site/lib/layout.shared.tsx +17 -0
  42. package/templates/scaffold/system/site/lib/shared.ts +60 -0
  43. package/templates/scaffold/system/site/lib/source.ts +119 -0
  44. package/templates/scaffold/system/site/lib/stage-knowledge.ts +301 -0
  45. package/templates/scaffold/system/site/next-env.d.ts +6 -0
  46. package/templates/scaffold/system/site/next.config.mjs +32 -0
  47. package/templates/scaffold/system/site/package.json +29 -0
  48. package/templates/scaffold/system/site/postcss.config.mjs +7 -0
  49. package/templates/scaffold/system/site/source.config.ts +41 -0
  50. package/templates/scaffold/system/site/tsconfig.json +35 -0
  51. package/templates/scaffold/vercel.json +8 -0
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: intake-interview
3
+ description: The first conversation with the owner of this Knowledge System of Record — six questions that define what it is authoritative for and who may read it, then write instance.md together. Use when the owner asks to set up, configure, or "get started with" this project, when instance.md still contains its scaffold placeholder text, or when the scope of the corpus is unclear.
4
+ metadata:
5
+ version: "1.2.0"
6
+ ---
7
+
8
+ # Intake interview
9
+
10
+ `instance.md` is the identity of this Knowledge System of Record, and its
11
+ prose will one day be the agent surface's system prompt. Do not draft it from
12
+ guesses — interview the owner, one question at a time, and write down what
13
+ they actually say.
14
+
15
+ ## The six questions
16
+
17
+ Ask these one at a time; follow up until each answer is concrete enough to
18
+ act on:
19
+
20
+ 1. **Authority** — "What should this record be the _final word_ on? Finish
21
+ the sentence: when someone here disagrees with this corpus, the corpus
22
+ wins about ___."
23
+ 2. **Boundary** — "What is explicitly _outside_ it — near-miss topics people
24
+ will ask about that this record should refuse rather than guess at?"
25
+ 3. **Audience** — "Who reads it — people, agents, both? In what situations,
26
+ making what decisions?"
27
+ 4. **Sources** — "Which existing materials are authoritative inputs (name
28
+ the actual documents, systems, people), and which are explicitly _not_
29
+ trusted?"
30
+ 5. **Strictness** — "When the record doesn't cover a question, how firmly
31
+ should it decline? ('Not in this corpus' is a correct answer here —
32
+ confirm the owner wants that behavior and where they want it softened.)"
33
+ 6. **Audiences** — "Does every reader of this record see every document? If
34
+ not, what are the audiences, from most public to most restricted?" A yes
35
+ is the common answer and the whole answer: write no `audiences:` key and
36
+ nothing about the project changes. A list means writing it into
37
+ `instance.md`'s frontmatter — ordered least- to most-restricted with
38
+ `public` first, plus `default_visibility:` naming the audience a document
39
+ takes when it says nothing (there is no safe guess, so the checker
40
+ requires it). Tell the owner what the key does and does not do:
41
+ documents carry `visibility:` and builds are made per audience, but
42
+ anyone who can clone the repository reads everything in it — if someone
43
+ must not read a document and can clone, that document belongs in a
44
+ different repository.
45
+
46
+ ## Then write
47
+
48
+ - Rewrite `instance.md`'s body from the answers: first the `# H1` — the
49
+ record's **display title**, the human name every page will lead with
50
+ ("Acme Operations Handbook", not the slug) — then the authority sentence,
51
+ boundary, audience, and strictness — plain prose, written for a reader
52
+ who must act on it. Leave the frontmatter keys alone, with one exception:
53
+ an audience model from question 6 is written there as `audiences:` (a
54
+ list) and `default_visibility:`, and `pnpm check` will hold the record to
55
+ it from that moment on.
56
+ - Restart `pnpm dev` afterwards so the site picks the new title up, and
57
+ show the owner their name on the page.
58
+ - Offer to capture the source list from question 4 as the first real
59
+ documents (the add-sources skill takes it from there).
60
+ - Read the result back to the owner and get an explicit yes before
61
+ finishing. Their words, tightened — never your invention.
@@ -0,0 +1,5 @@
1
+ {
2
+ "context": {
3
+ "fileName": ["AGENTS.md", "GEMINI.md"]
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ # Checkout bytes are provenance bytes: markdown is LF on every platform so
2
+ # the same commit hashes identically on Windows, macOS, and Linux.
3
+ * text=auto
4
+ *.md text eol=lf
5
+ instance.md text eol=lf
@@ -0,0 +1,23 @@
1
+ name: Validate knowledge
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ check:
13
+ name: Format checker
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17
+ with:
18
+ persist-credentials: false
19
+ - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
20
+ with:
21
+ node-version: "24"
22
+ # The checker is dependency-free Node — no install step needed.
23
+ - run: node .agents/skills/format-checker/check.mjs
@@ -0,0 +1,133 @@
1
+ # AGENTS.md
2
+
3
+ The working contract for this Knowledge System of Record. CLAUDE.md points
4
+ here; every coding agent reads this file first.
5
+
6
+ ## The two worlds
7
+
8
+ | Path | What it is |
9
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
10
+ | `knowledge/` | **the record** — governed markdown, the owner's world, the product |
11
+ | `system/` | **the system** — all code that serves the record |
12
+ | `instance.md` | what this SoR is authoritative for; its prose is the future agent surface's system prompt. Its `name:` is the machine identity (llms.txt, future citations) and its body `# H1` is the DISPLAY TITLE every page leads with — both read when the server or build STARTS, so restart `pnpm dev` after changing either (found live 2026-08-18) |
13
+
14
+ The record survives the system: `knowledge/` must stay readable and complete
15
+ even if `system/` is deleted. Dependency flows one way — the system reads the
16
+ record; the record never references the system.
17
+
18
+ `instance.md` carries a closed key set — `format`, `name`, `ksor`, `site`,
19
+ and the optional pair `audiences` + `default_visibility` (the record's reader
20
+ audiences, ordered least- to most-restricted with `public` first, and the one
21
+ a document takes when it names none — declared together or not at all) — and
22
+ everything that matters about it is the prose below that frontmatter;
23
+ `pnpm check` names any other key rather than ignoring it.
24
+
25
+ ## Critical rules
26
+
27
+ 1. **The site never contains authored content.** Knowledge goes in
28
+ `knowledge/`, always. Never create markdown, MDX, or content pages inside
29
+ `system/site` — the site _renders_ the record, it never _holds_ it.
30
+ 2. **`knowledge/` is CommonMark `.md` only.** No `.mdx`, no `meta.json`, no
31
+ framework files. A document must read cleanly in any markdown viewer.
32
+ 3. **Never edit generated files** — `system/site/.source/`, `.next/`, `out/`,
33
+ `system/site/.staged-knowledge/` (a build's per-audience copy of the
34
+ record — edit `knowledge/`, or the next build erases the change),
35
+ lockfiles by hand.
36
+
37
+ ## Commands (run at the repo root)
38
+
39
+ ```sh
40
+ pnpm install # once, after cloning or scaffolding
41
+ pnpm dev # the site, hot-reloading, at http://localhost:3000
42
+ pnpm build # static site into system/site/out/
43
+ pnpm check # the format checker — run before handing off any knowledge change
44
+ ```
45
+
46
+ ## Publishing
47
+
48
+ `pnpm build` emits a fully static site (`system/site/out/`) deployable to
49
+ any host — Vercel reads the shipped `vercel.json` (deploy from the repo
50
+ ROOT, never `system/site/`), and every other host just serves the folder.
51
+ `KSOR_BASE_PATH=/repo pnpm build` targets sub-path hosting. With
52
+ `audiences:` declared, plain `pnpm build` is always the public tier;
53
+ `KSOR_AUDIENCE=<audience> pnpm build` builds a wider tier that belongs
54
+ behind that audience's own access control, never on a public host.
55
+ Details in README → Deploying.
56
+
57
+ ## Writing knowledge
58
+
59
+ - One document per file under `knowledge/`; the path is the document's
60
+ identity and its URL — ascii lowercase, digits, hyphens; no spaces or
61
+ special characters; no two files differing only in case; never both
62
+ `foo.md` and `foo/index.md`. The `title:` carries the document's real
63
+ name in any language — the filename is the address, not the name.
64
+ - The frontmatter `title` IS the rendered page heading — never repeat it as
65
+ an `# h1` in the body, and quote any value containing a colon
66
+ (`title: "Note: quoting"`).
67
+ - Frontmatter: `title` and `status` (`draft | review | approved | superseded`)
68
+ are required. `owner` and `provenance` (a list naming real sources) are
69
+ strongly encouraged — they become required as this project climbs the
70
+ governance ladder. `description`, `visibility` (below), `order` (sidebar
71
+ position), `effective` (the date the document takes effect) and `superseded`
72
+ (a legacy marker — prefer `status`) are available. No other keys; never
73
+ `id:` or `name:` — the path is the identity.
74
+ - `visibility:` names the one audience a document belongs to — a single value
75
+ from `instance.md`'s `audiences:`, never a list, and orthogonal to `status:`
76
+ (an approved document can be restricted, and a draft is not hidden). Leave
77
+ it off and the document takes `default_visibility`. The key does nothing
78
+ until `instance.md` declares `audiences:`; once it does, `pnpm check`
79
+ refuses any link or `superseded_by:` pointing from a wider audience at a
80
+ narrower one — the leak no single build can catch, because the build that
81
+ publishes the link has already dropped its target.
82
+
83
+ **Publication, not authorship: anyone who can clone the repository reads
84
+ every document regardless of frontmatter; if someone must not read a
85
+ document and can clone, the answer is a second repository.**
86
+
87
+ - A replaced document is marked `status: superseded` with `superseded_by:`
88
+ pointing at its successor — superseded documents are never deleted.
89
+ - Images and assets live in `knowledge/` beside the document that uses them,
90
+ referenced by relative links. A relative link must never leave `knowledge/`.
91
+ - Copy load-bearing values (numbers, thresholds, dates) exactly from their
92
+ source, and name the source in `provenance`.
93
+
94
+ ### Structuring the record
95
+
96
+ - A folder per topic; its front page is `<folder>/index.md`, and the folder
97
+ takes the position that page declares.
98
+ - Sidebar position is the governed `order:` key: documents that declare it come
99
+ first, ascending; the rest follow in name order.
100
+ - One order drives the sidebar, `llms.txt`, and the home page's first-document
101
+ link — set it once and every surface agrees.
102
+ - Never `meta.json` or `sidebar_position`: the checker refuses framework files
103
+ in the record, which has to read the same without the site.
104
+
105
+ ## Skills
106
+
107
+ - `.agents/skills/intake-interview/` — first run: interview the owner and
108
+ write `instance.md` together.
109
+ - `.agents/skills/add-sources/` — turn source material (documents, pages,
110
+ notes) into governed knowledge.
111
+ - `.agents/skills/format-checker/` — the rules above, as a program;
112
+ `pnpm check` runs it and its errors explain how to fix themselves.
113
+
114
+ ## Customizing the site
115
+
116
+ You own `system/site/` outright — these are the seams, cheapest first:
117
+
118
+ - **Display title** — `instance.md`'s body `# H1` (the intake interview
119
+ writes it). Headline, navbar, and browser title follow on restart.
120
+ - **Accent color** — the one brand pair in `system/site/app/global.css`
121
+ (`--color-fd-primary`, light and dark); every accented element follows.
122
+ - **Logo and favicon** — replace `system/site/app/icon.png`; the tab icon
123
+ and the home-page mark are the same file.
124
+ - **Anything deeper** — edit the site like the Next.js app it is; the only
125
+ rule that survives customization is critical rule 1. The whole shell is
126
+ replaceable behind a five-clause contract (a themed Docusaurus shell with
127
+ a swap recipe lives in the ksor repository under `workbench/shells/`).
128
+
129
+ ## What this project owns
130
+
131
+ Everything. The scaffold was emitted by `ksor init` (version recorded in
132
+ `instance.md`) and belongs to this repository outright — change anything in
133
+ `system/` deliberately; the knowledge in `knowledge/` was always yours.
@@ -0,0 +1 @@
1
+ @AGENTS.md
@@ -0,0 +1,90 @@
1
+ # KSOR-STAMP-NAME
2
+
3
+ A **Knowledge System of Record**: the governed source of knowledge this
4
+ project's people and AI agents operate from.
5
+
6
+ Two worlds live here:
7
+
8
+ - **`knowledge/` — the record.** Plain governed markdown. Yours forever,
9
+ readable anywhere, portable without this repository's code.
10
+ - **`system/` — the system.** The site (and later, services) that serve the
11
+ record. Replaceable machinery.
12
+
13
+ ## Working here
14
+
15
+ ```sh
16
+ pnpm install
17
+ pnpm dev # browse the knowledge at http://localhost:3000
18
+ ```
19
+
20
+ No pnpm? Run `npm install -g pnpm` — or `corepack enable pnpm` on Node
21
+ versions that bundle corepack.
22
+
23
+ Then talk to your coding agent — `AGENTS.md` carries the working rules, and
24
+ the agent kit in `.agents/skills/` knows how to interview you
25
+ (`intake-interview`), convert your source material (`add-sources`), and keep
26
+ the record well-formed (`format-checker`, also `pnpm check`).
27
+
28
+ ## The files, explained
29
+
30
+ Nothing here is decoration, and the dotfiles are not ceremony — each one is a
31
+ different coding agent's way of finding the same working contract.
32
+
33
+ | Entry | What it is |
34
+ | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35
+ | `knowledge/` | **the record** — your governed markdown. The product; everything else serves it. |
36
+ | `system/` | the code that serves the record: the site today, more as you need it. |
37
+ | `instance.md` | what this record is authoritative for; its `name:` is the identity every surface publishes (read at server/build start — restart `pnpm dev` after renaming). When the agent surface ships, this prose becomes its system prompt. |
38
+ | `AGENTS.md` | the working contract every coding agent reads first — the rules for writing knowledge here. |
39
+ | `CLAUDE.md` | one line, pointing at `AGENTS.md`. Claude Code looks for this filename, not that one. |
40
+ | `.agents/skills/` | the agent kit: `intake-interview` (define the record with you), `add-sources` (turn source material into governed documents), `format-checker` (the rules, as a program). |
41
+ | `.claude/skills/` | byte-identical copies of the kit — Claude Code discovers skills only here. The checker enforces the mirror, so the two cannot drift. |
42
+ | `.gemini/settings.json` | points Gemini CLI at `AGENTS.md`; Gemini does not read that filename on its own. |
43
+ | `.github/workflows/validate.yml` | your CI: runs the same checker on every pull request and push to main. |
44
+ | `.gitattributes` | markdown is checked out byte-stable on every platform, so the same commit hashes the same everywhere. |
45
+ | `.gitignore` | keeps build output, `node_modules/`, and `.env*` out of the record's history. |
46
+ | `package.json` | the `pnpm dev` / `pnpm build` / `pnpm check` commands, and the pnpm version this project pins. |
47
+ | `pnpm-workspace.yaml` | where the workspace looks for code (`system/site`, plus reserved `system/gateways/*` and `system/packages/*`), and the supply-chain policy for installs. |
48
+ | `pnpm-lock.yaml` | the exact dependency versions — the reason two machines build the same site. |
49
+
50
+ `format-checker` deliberately contains a program, `check.mjs`, and not only
51
+ prose: rules that are only written down cannot refuse anything. `pnpm check`
52
+ runs it, and every failure it reports says what is wrong, why the rule exists,
53
+ and how to fix it.
54
+
55
+ Everything here is yours to change. The kit exists so that any coding agent can
56
+ operate this project without being taught it first.
57
+
58
+ ## Deploying
59
+
60
+ The built site is a folder of files — 2 MB of HTML, JS and CSS with zero
61
+ host-specific dependencies. `pnpm build` writes it to `system/site/out/`,
62
+ and anything that can serve files can serve it.
63
+
64
+ - **Vercel** — connect the repository (or run `vercel`); the shipped
65
+ `vercel.json` answers the setup interview: deploy from the repo root
66
+ (never pin `system/site` as the root directory — the record lives
67
+ outside it), build with `pnpm build`, serve `system/site/out/`. If the
68
+ build image's pnpm predates the `packageManager` pin, set the
69
+ `ENABLE_EXPERIMENTAL_COREPACK=1` build environment variable.
70
+ - **GitHub Pages, nginx, S3, anything static** — run `pnpm build` and
71
+ upload `system/site/out/`. Hosted under a sub-path (like
72
+ `user.github.io/repo`)? Build with `KSOR_BASE_PATH=/repo pnpm build`.
73
+ - **Verify any deploy** the same way: the home page, one document page,
74
+ and `/llms.txt` all load; nothing else is required.
75
+
76
+ If `instance.md` declares `audiences:`, what you deploy is a **tier**.
77
+ Plain `pnpm build` always builds the public tier — safe for any host.
78
+ `KSOR_AUDIENCE=<audience> pnpm build` builds a wider tier for that
79
+ audience's own deployment, and that build carries an
80
+ "— not for publication" label because it must never reach a public host:
81
+ put it behind access control you already trust (VPN, SSO proxy,
82
+ authenticated host). The tiers govern what a build contains; where each
83
+ build may be served is yours to enforce.
84
+
85
+ ## Ownership
86
+
87
+ Everything here is yours. The scaffold was generated by
88
+ [ksor](https://github.com/panaversity/ksor) (version in `instance.md`) and is
89
+ granted without attribution or licence obligations; your knowledge was never
90
+ anyone else's to license.
@@ -0,0 +1,16 @@
1
+ # scratch space for ksor verbs — everything transient lives under one roof
2
+ .ksor/
3
+
4
+ node_modules/
5
+ system/site/.next/
6
+ system/site/.source/
7
+ system/site/out/
8
+ # the per-audience copy of the record a build stages — a filtered derivative,
9
+ # never a second record; committing it would publish what a build excluded
10
+ system/site/.staged-knowledge/
11
+ *.tsbuildinfo
12
+
13
+ # secrets never enter the record — system/ is their future home (serve)
14
+ .env*
15
+
16
+ .DS_Store
@@ -0,0 +1,26 @@
1
+ ---
2
+ format: 1
3
+ name: KSOR-STAMP-NAME
4
+ ksor:
5
+ requires: ">=KSOR-STAMP-VERSION"
6
+ scaffolded: "KSOR-STAMP-VERSION"
7
+ ---
8
+
9
+ # Knowledge System of Record
10
+
11
+ The heading above is this record's **display title** — the human name every
12
+ page leads with. The intake interview replaces it with the real one
13
+ ("Acme Operations Handbook"); the machine identity stays `KSOR-STAMP-NAME`
14
+ in the frontmatter, and that is what agents and citations use.
15
+
16
+ This Knowledge System of Record is authoritative for — _fill this in; it is
17
+ the single most important sentence in the project._
18
+
19
+ Everything below this frontmatter is the identity of this instance: what the
20
+ corpus covers, who it serves, and how strictly it should decline questions it
21
+ does not cover. When the agent surface ships, this prose becomes its system
22
+ prompt — write it for a reader who must act on it.
23
+
24
+ Ask your coding agent to run the **intake interview** (it knows how — see
25
+ `.agents/skills/intake-interview/`), answer its questions, and let it write
26
+ this document with you.
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: Your first governed document
3
+ status: draft
4
+ order: 1
5
+ ---
6
+
7
+ This file exists so the record is never empty: browse it with `pnpm dev`,
8
+ then replace it with real knowledge.
9
+
10
+ A governed document is plain markdown with a small frontmatter header. This
11
+ one carries the two required keys — `title` and `status: draft`. As the
12
+ knowledge matures, documents gain `owner` and `provenance` (who stands behind
13
+ this, and which sources it came from), move to `status: approved`, and — when
14
+ replaced — are marked `superseded`, never deleted.
15
+
16
+ It also carries `order: 1`, which is how the record decides reading order: a
17
+ document that declares `order` sorts ahead of every document that does not, so
18
+ this one stays first in the sidebar, first in `llms.txt`, and the document the
19
+ home page opens.
20
+
21
+ Ask your coding agent to run the **intake interview** to define what this
22
+ Knowledge System of Record is authoritative for, then start adding documents
23
+ with the **add-sources** skill. `pnpm check` keeps every document honest.
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "KSOR-STAMP-NAME",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "pnpm -C system/site dev",
8
+ "build": "pnpm -C system/site build",
9
+ "check": "node .agents/skills/format-checker/check.mjs"
10
+ },
11
+ "engines": {
12
+ "node": ">=24"
13
+ },
14
+ "packageManager": "pnpm@11.22.0"
15
+ }