polydeukes 0.6.0 → 0.6.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 (55) hide show
  1. package/README.ko.md +54 -80
  2. package/README.md +55 -94
  3. package/dist/bin.js +8 -5
  4. package/dist/docs/README.ko.md +60 -0
  5. package/dist/docs/README.md +64 -0
  6. package/dist/docs/catalog.json +464 -0
  7. package/dist/docs/concepts/judgment.ko.md +113 -0
  8. package/dist/docs/concepts/judgment.md +113 -0
  9. package/dist/docs/how-to/configure-project.ko.md +99 -0
  10. package/dist/docs/how-to/configure-project.md +95 -0
  11. package/dist/docs/how-to/connect-surfaces.ko.md +115 -0
  12. package/dist/docs/how-to/connect-surfaces.md +118 -0
  13. package/dist/docs/how-to/write-disciplines.ko.md +124 -0
  14. package/dist/docs/how-to/write-disciplines.md +125 -0
  15. package/dist/docs/index.json +2046 -0
  16. package/dist/docs/reference/cli/covenant-check.ko.md +101 -0
  17. package/dist/docs/reference/cli/covenant-check.md +98 -0
  18. package/dist/docs/reference/cli/docs.ko.md +97 -0
  19. package/dist/docs/reference/cli/docs.md +95 -0
  20. package/dist/docs/reference/cli/explain.ko.md +79 -0
  21. package/dist/docs/reference/cli/explain.md +84 -0
  22. package/dist/docs/reference/cli/init.ko.md +119 -0
  23. package/dist/docs/reference/cli/init.md +131 -0
  24. package/dist/docs/reference/configuration/index.ko.md +448 -0
  25. package/dist/docs/reference/{configuration.md → configuration/index.md} +48 -30
  26. package/dist/docs/reference/packages/adapter-claude-code.ko.md +83 -0
  27. package/dist/docs/reference/{adapter-claude-code.md → packages/adapter-claude-code.md} +10 -6
  28. package/dist/docs/reference/packages/adapter-git.ko.md +101 -0
  29. package/dist/docs/reference/{adapter-git.md → packages/adapter-git.md} +20 -12
  30. package/dist/docs/reference/packages/core.ko.md +128 -0
  31. package/dist/docs/reference/{core.md → packages/core.md} +21 -8
  32. package/dist/docs/reference/packages/covenant.ko.md +115 -0
  33. package/dist/docs/reference/{covenant.md → packages/covenant.md} +18 -11
  34. package/dist/docs/reference/packages/polydeukes.ko.md +134 -0
  35. package/dist/docs/reference/packages/polydeukes.md +139 -0
  36. package/dist/docs/troubleshooting.ko.md +142 -0
  37. package/dist/docs/troubleshooting.md +98 -150
  38. package/dist/docs/tutorials/first-judgment.ko.md +82 -0
  39. package/dist/docs/tutorials/first-judgment.md +81 -0
  40. package/dist/docs-catalog.d.ts +25 -0
  41. package/dist/docs-catalog.js +450 -0
  42. package/dist/docs-library.d.ts +23 -0
  43. package/dist/docs-library.js +347 -0
  44. package/dist/docs-markdown.d.ts +32 -0
  45. package/dist/docs-markdown.js +150 -0
  46. package/dist/docs-query.d.ts +11 -40
  47. package/dist/docs-query.js +28 -122
  48. package/dist/docs-types.d.ts +105 -0
  49. package/dist/docs-types.js +2 -0
  50. package/dist/init-claude-code.d.ts +1 -1
  51. package/dist/init-claude-code.js +159 -42
  52. package/package.json +5 -5
  53. package/dist/docs/configuration.md +0 -103
  54. package/dist/docs/installation.md +0 -241
  55. package/dist/docs/reference/polydeukes.md +0 -315
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydeukes",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "A development discipline framework for building alongside an AI coding partner — deterministic covenants, a verifiable work ledger, local memory, and adversarial verification. Alpha.",
5
5
  "keywords": [
6
6
  "harness",
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "yaml": "2.9.0",
57
- "@polydeukes/adapter-git": "^0.6.0",
58
- "@polydeukes/covenant": "^0.6.0",
59
- "@polydeukes/core": "^0.6.0",
60
- "@polydeukes/adapter-claude-code": "^0.6.0"
57
+ "@polydeukes/adapter-claude-code": "^0.6.1",
58
+ "@polydeukes/core": "^0.6.1",
59
+ "@polydeukes/covenant": "^0.6.1",
60
+ "@polydeukes/adapter-git": "^0.6.1"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "^24.0.0",
@@ -1,103 +0,0 @@
1
- # Configuring Polydeukes
2
-
3
- **English** · [한국어](./configuration.ko.md)
4
-
5
- > Alpha. This guide covers the config surface as shipped today (schema v2, loader, and
6
- > the declaration grammar). Fields and steps will grow; what is
7
- > written here is tested and enforced now.
8
-
9
- `polydeukes.config.yaml` is the one file where a project declares its disciplines — the
10
- promises the human and the AI partner both agree to be bound by. It is **data, not code**:
11
- nothing in it can compute, so nothing in it can lie. The core validates it, the covenant
12
- package enforces it, and every judgment it causes is measured.
13
-
14
- This is the guide layer: the file itself, how discovery fails, the IDE wiring, and what
15
- enforcement looks like. Every key, with its full rules and pitfalls, lives in
16
- [the configuration reference](./reference/configuration.md).
17
-
18
- ## The file
19
-
20
- Put exactly one of these at the project root:
21
-
22
- | Filename | Note |
23
- |---|---|
24
- | `polydeukes.config.yaml` | canonical |
25
- | `polydeukes.config.yml` | accepted variant |
26
- | `polydeukes.config.json` | accepted variant (read by the same parser — YAML is a JSON superset) |
27
-
28
- Discovery is deliberately strict, and every failure refuses loudly instead of guessing:
29
-
30
- - **No config found** → error naming all three candidate filenames. A missing config never
31
- silently loads defaults — silent defaults would mean silently unprotected.
32
- - **More than one found** → error naming the collisions. Ambiguity never picks a winner.
33
- - **Parse error, or a custom YAML tag** → error naming the file. Custom tags are rejected
34
- even though the parser cannot execute them — config data stays uncomputable by contract.
35
- - **Schema violation** → error naming the key and the file. Unknown keys are rejected
36
- wherever the core owns the vocabulary — the top level, and the fixed keys inside a
37
- discipline entry — so `protectedPath:` for `protectedPaths:`, or `adaptors:` for
38
- `adapters:`, is caught here. Two maps stay open, because their keys are your values
39
- rather than the core's: language names under `languages`, and adapter names under
40
- `adapters`. A misspelt adapter name is accepted and its block simply goes unread, which
41
- leaves that adapter on its defaults — check the name against the adapter's own reference.
42
- Inside a namespace the vocabulary belongs to that adapter: the core passes contents
43
- through verbatim, and the adapter's own validator rejects what it does not recognise,
44
- naming the full field path (see
45
- [the `adapters` reference](./reference/configuration.md#adapters)).
46
-
47
- ## IDE support
48
-
49
- The JSON Schema gives autocompletion and validation in editors. It ships inside the
50
- `polydeukes` package, so the line names a path into your own `node_modules`:
51
-
52
- ```yaml
53
- # yaml-language-server: $schema=node_modules/polydeukes/dist/schema/polydeukes.schema.json
54
- ```
55
-
56
- For a JSON config, use the standard top-level key instead. The loader accepts it and drops
57
- it from the resolved config:
58
-
59
- ```json
60
- { "$schema": "node_modules/polydeukes/dist/schema/polydeukes.schema.json" }
61
- ```
62
-
63
- **The path is resolved against the directory your config sits in**, not against a project
64
- root the editor infers. The spelling above is right when the two are the same place. When
65
- they are not — a config in a monorepo sub-package whose dependencies installed at the
66
- workspace root — count the levels up yourself:
67
-
68
- ```yaml
69
- # yaml-language-server: $schema=../../node_modules/polydeukes/dist/schema/polydeukes.schema.json
70
- ```
71
-
72
- `pdks init claude-code` writes the line only when the schema is where the plain spelling
73
- names it. If the generated config has no such line, that is the case above, and the prefix
74
- is yours to add — an unresolvable path costs you validation without reporting anything.
75
-
76
- If you installed `@polydeukes/core` directly rather than the umbrella, name its own copy:
77
-
78
- ```yaml
79
- # yaml-language-server: $schema=node_modules/@polydeukes/core/schema/polydeukes.schema.json
80
- ```
81
-
82
- Every value here is a **file path**, not a module specifier: `$schema` is a static string an
83
- editor reads, so no module resolver runs on it. Code that reads the schema at runtime uses
84
- the package subpath `polydeukes/schema.json` instead.
85
-
86
- ## What enforcement looks like
87
-
88
- A `disciplines:` entry lands at **advise** by default: a break is recorded as `advised`
89
- with the discipline's `id` in the telemetry record, the break message with its `why` goes
90
- to stderr, and the call proceeds (exit 0) — the judgment measures instead of stopping.
91
- Writing `enforce: block` on an entry is the promotion: that entry then **blocks (exit 2)**
92
- before the call runs. The sanctioned valve on a block is the witness — a human supplying
93
- the pass condition on a judgment that actually blocked, recorded as `witnessed` — never
94
- silent.
95
-
96
- What blocks without being asked is the judging chain's own protection, a finite list: the
97
- `protectedPaths` entries (tool-axis and shell-axis mutations, and mentions without a
98
- read-only head), the session transcript, and the assembly itself — a missing, ambiguous, or
99
- invalid config, an unbuilt judge, an unparseable payload, or a routing that could not
100
- answer. At either level the system fails closed on these, because a dead gate that waves
101
- things through is the cheapest bypass of all. On the commit surface `adapters.git.enforce: advise` relaxes
102
- the protected-path verdicts to `advised` as well — it is the observer's setting — while an
103
- assembly that cannot judge still fails closed.
@@ -1,241 +0,0 @@
1
- # Installing Polydeukes
2
-
3
- **English** · [한국어](./installation.ko.md)
4
-
5
- > Alpha. This guide covers the install paths that ship today, and everything here is the
6
- > measured behaviour of the published packages.
7
-
8
- This is the getting-started layer: from an empty project to a first judged call.
9
-
10
- One devDependency, one command per surface. The umbrella package `polydeukes` is the only
11
- thing you install — it carries the core, the judge, and the adapters as its own
12
- dependencies, and `pdks` is its CLI (an alias of `polydeukes`).
13
-
14
- **Two surfaces ship, for two different situations — pick the one that matches how the
15
- project is developed.** A project built alongside an AI partner in Claude Code wires the
16
- **session surface**: a PreToolUse hook that judges every editing tool call and shell
17
- command as it is declared. A project you develop yourself wires the **commit surface**: a
18
- pre-commit hook that judges the staged diff, so the discipline you declared for yourself
19
- is applied at the moment work becomes history. They enforce the same config vocabulary,
20
- but they answer different situations — there is no general reason to wire both in one
21
- project.
22
-
23
- ## Prerequisites
24
-
25
- - **Node.js ≥ 24** — the engines floor of every published package.
26
- - **A package manager** — pnpm and npm both work; examples below use pnpm.
27
- - **Claude Code** — only for the session surface. The commit surface needs no AI tool at
28
- all: just git and a way to run a pre-commit hook.
29
-
30
- ## Install
31
-
32
- ```sh
33
- pnpm add -D polydeukes
34
- ```
35
-
36
- (or `npm install --save-dev polydeukes`.)
37
-
38
- This must be a real project dependency, not a one-off `npx` run — both surfaces load the
39
- judge from your project's own installed package.
40
-
41
- ## The session surface — developing with an AI partner
42
-
43
- From the project root:
44
-
45
- ```sh
46
- pnpm exec pdks init claude-code # Claude Code
47
- pnpm exec pdks init grok # Grok
48
- ```
49
-
50
- The command installs into the directory it is invoked from, and it proves the `polydeukes`
51
- package resolves there **before writing anything** — if it does not (say, the install step
52
- was skipped), it prints the install command and exits 2 with zero files written, never a
53
- half-wired tree.
54
-
55
- Nothing existing is overwritten. What exists is reported and kept — the hook, the config,
56
- and the discipline files are left alone, the settings file is merged, and `.gitignore` is
57
- only ever appended to — so re-running is always safe. One command-field exception: if
58
- `.grok/hooks/covenant-pretooluse.json` still names the grok delegator and a Claude
59
- delegator is on disk, the JSON `command` is rewritten to that Claude file so the host
60
- does not spawn two judges. Grok collapses two registrations only when `command` AND
61
- `matcher` are identical, so every grok entry naming that Claude file also takes the matcher
62
- of the `.claude/settings.json` entry that registers the same command — on a fresh write and
63
- on every re-run; `timeout` stays. A command you pointed elsewhere is left as it was.
64
-
65
- `pdks init claude-code` writes six artifacts:
66
-
67
- | Artifact | What it is |
68
- |---|---|
69
- | `.claude/hooks/covenant-pretooluse.mjs` | The hook — a thin delegator that loads the judge from the installed package. Upgrading the package upgrades the judge; this file never changes. |
70
- | `.claude/settings.json` | The PreToolUse registration for editing tools and shell calls. **Merged, never replaced** — your other hooks and permissions stay. |
71
- | `polydeukes.config.yaml` | The starter protection policy: a placeholder `languages` block, a minimum `protectedPaths` list, and the witness block. The comments in the file explain why each entry is there. |
72
- | `.claude/rules/polydeukes.md` | A scoped discipline file telling your AI partner that `pdks docs` exists and which topic answers what. It carries `paths` frontmatter, so it loads when a Polydeukes path is in play rather than sitting in every session's context. |
73
- | `.claude/skills/discipline-draft/SKILL.md` | The classification procedure. Describe a recurring problem to your AI partner and it lands as a config entry — judged at advise when a current family can express it, a `draft: true` entry otherwise — and the same file tells the agent to consult `advised` rows in the telemetry log at task boundaries. |
74
- | `.gitignore` | An appended ignore rule for `.polydeukes/`, with its comment line — telemetry is local observation data and never belongs in history. |
75
-
76
- `pdks init grok` shares the scaffold (config and the ignore line) and writes Grok's own
77
- registration. A Grok-only tree has four artifacts, and no `.claude/` directory:
78
-
79
- | Artifact | What it is |
80
- |---|---|
81
- | `.grok/hooks/covenant-pretooluse.mjs` | The hook — the same delegator text, only when no Claude delegator is already on disk. |
82
- | `.grok/hooks/covenant-pretooluse.json` | The PreToolUse matcher, `timeout` 60 (the host default is 5 seconds, and a timed-out hook fails open), and the command that names one delegator file. In a tree that also has `.claude/settings.json`, the matcher is copied from the settings entry with the same command — Grok reads that file too, and collapses the two registrations into one spawn only when `command` and `matcher` match exactly. That copy leans on Grok's tool-name aliases, so if you later remove `.claude/settings.json`, delete this JSON and run `pdks init grok` again to get the Grok-native matcher back. |
83
- | `polydeukes.config.yaml` | The same starter policy as above. |
84
- | `.gitignore` | The same appended ignore line. |
85
-
86
- If `.claude/hooks/covenant-pretooluse.mjs` already exists, the JSON command points at that
87
- file instead of planting a second one. A later `pdks init grok` or `pdks init claude-code`
88
- retargets an installer-generated grok-mjs command the same way.
89
-
90
- An already-open Grok session keeps the hook snapshot from start. Reload from the Hooks tab
91
- (`r`) or start a new session. The witness valve does not open on Grok — the session log is
92
- ACP `updates.jsonl`, not Claude's JSONL. A block is recovered from another terminal or the
93
- commit-surface TTY.
94
-
95
- ## First edit — `languages`
96
-
97
- The generated config ships a placeholder language profile, because the installer cannot
98
- know your stack:
99
-
100
- ```yaml
101
- languages:
102
- placeholder:
103
- productionGlob: 'src/**'
104
- testCmd: 'echo "set a verification command for {scope}"'
105
- ```
106
-
107
- Rename the key to your language, point `productionGlob` at your production sources, and put
108
- your real verification command in `testCmd`. (On the commit-surface path you write this
109
- block yourself as part of the config below.) The placeholder is valid as generated and no
110
- judgment path reads these values yet, so it cannot produce a wrong verdict while it waits —
111
- but `languages` is the schema's one required block, so *removing* it (or emptying it) makes
112
- the config invalid, and an invalid config blocks every call. Edit it, don't delete it.
113
-
114
- ## The commit surface — developing by yourself
115
-
116
- This path is for applying your own discipline to your own commits — no AI tool involved.
117
- It has no installer today; the wiring is two small manual steps.
118
-
119
- **First, the config.** Create `polydeukes.config.yaml` at the project root (there is no
120
- generator on this path — the file is yours from the first line):
121
-
122
- ```yaml
123
- languages:
124
- typescript:
125
- productionGlob: 'src/**'
126
- testCmd: 'pnpm test'
127
-
128
- # Judged at commit time: a staged change to these paths stops the commit
129
- # until you answer the witness prompt in person.
130
- protectedPaths:
131
- - 'db/migrations'
132
-
133
- witness:
134
- token: 'pdks witness'
135
- ttlMinutes: 10
136
- ```
137
-
138
- Add `.polydeukes/` to your `.gitignore` too — telemetry is local observation data.
139
-
140
- **Then, the hook.** One command judges what is currently staged and exits 2 on a broken
141
- covenant:
142
-
143
- ```sh
144
- pnpm exec pdks covenant check
145
- ```
146
-
147
- Register it as a pre-commit hook. With **lefthook**:
148
-
149
- ```yaml
150
- # lefthook.yml
151
- pre-commit:
152
- commands:
153
- covenant:
154
- priority: 1
155
- interactive: true # keep the witness prompt visible — see below
156
- run: ./node_modules/.bin/pdks covenant check
157
- ```
158
-
159
- With **husky**:
160
-
161
- ```sh
162
- # .husky/pre-commit
163
- ./node_modules/.bin/pdks covenant check
164
- ```
165
-
166
- With plain **`.git/hooks`** (make it executable):
167
-
168
- ```sh
169
- #!/bin/sh
170
- # .git/hooks/pre-commit
171
- ./node_modules/.bin/pdks covenant check
172
- ```
173
-
174
- Three things to know about this surface:
175
-
176
- - **The valve is a TTY prompt.** At the default `block` level, a commit that stages a
177
- protected change stops at a prompt only a human at a terminal can answer. Configure your
178
- hook runner so it does not swallow that prompt (lefthook needs `interactive: true`).
179
- - **Declarations judge here.** A staged diff carries file changes and nothing else, so
180
- protection lists and every `declare` entry over the change judge in full. A declaration
181
- scoped on `command` has no command line to read in a staged diff and observes nothing on
182
- this surface, and a declaration that reads the session (`precedent` and the other history
183
- mechanisms) is recorded as `skipped` — declare those where an AI partner's session exists
184
- to be judged.
185
- - **The commit surface has its own additive scope.** Paths that are fine to edit freely
186
- but whose promotion into history deserves a judged checkpoint go under the adapter
187
- namespace, judged on top of the shared list:
188
-
189
- ```yaml
190
- adapters:
191
- git:
192
- protectedPaths:
193
- - 'src/policy'
194
- ```
195
-
196
- ## The witness valve
197
-
198
- Both surfaces carry the same valve, spelled for their situation. It sits **after** the
199
- verdict — only a judgment that actually blocked can be witnessed open — and every allowance
200
- is recorded as `witnessed`, never silent.
201
-
202
- ```yaml
203
- witness:
204
- token: 'pdks witness'
205
- ttlMinutes: 10
206
- ```
207
-
208
- - **Session surface:** a human types the token so it stands alone on the first line of a
209
- conversation message; the window holds for `ttlMinutes`, then blocking resumes. An agent
210
- cannot open the valve for itself — only human-authored messages count.
211
- - **Commit surface:** the blocked commit shows a TTY prompt, and typing the full token
212
- there opens that one commit.
213
-
214
- Change the token and window as you like — the token is not a secret; the defence is
215
- provenance, not confidentiality. **Keep the block**: on the session surface the generated
216
- protection list covers `.claude/hooks` and `.grok/hooks`, so without a valve the first
217
- blocked call would freeze the project until a human edits the config from their own
218
- terminal.
219
-
220
- ## Prove the gate is live
221
-
222
- Prove it once on the surface you wired, then read the telemetry.
223
-
224
- - **Session surface:** ask your agent to append a line to
225
- `.claude/hooks/covenant-pretooluse.mjs` (a protected path). The call must come back
226
- blocked.
227
- - **Commit surface:** stage an edit to a path on your protection list and run
228
- `git commit`. It must stop at the witness prompt (answer it, or abort with Ctrl-C).
229
-
230
- ```sh
231
- cat .polydeukes/roi.log
232
- ```
233
-
234
- Every judgment appends exactly one record — `passed`, `blocked`, `witnessed`, `advised`, or
235
- `skipped` — so the block you just caused is the last line. A gate you have watched block
236
- once is a gate you know is wired.
237
-
238
- From here: [the configuration guide](./configuration.md) for the file and its wiring,
239
- [the configuration reference](./reference/configuration.md) for every field and for
240
- writing your own disciplines, and [troubleshooting](./troubleshooting.md) when something
241
- blocks and you don't know why.