polydeukes 0.5.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 (79) hide show
  1. package/README.ko.md +54 -74
  2. package/README.md +55 -86
  3. package/dist/baseline.d.ts +82 -0
  4. package/dist/baseline.js +166 -0
  5. package/dist/bin.d.ts +1 -1
  6. package/dist/bin.js +26 -6
  7. package/dist/claude-code-hook.d.ts +7 -5
  8. package/dist/claude-code-hook.js +69 -17
  9. package/dist/claude-code.d.ts +6 -0
  10. package/dist/claude-code.js +6 -0
  11. package/dist/covenant-check.d.ts +10 -17
  12. package/dist/covenant-check.js +44 -12
  13. package/dist/covenant-module.d.ts +2 -2
  14. package/dist/covenant-module.js +9 -1
  15. package/dist/docs/README.ko.md +60 -0
  16. package/dist/docs/README.md +64 -0
  17. package/dist/docs/catalog.json +464 -0
  18. package/dist/docs/concepts/judgment.ko.md +113 -0
  19. package/dist/docs/concepts/judgment.md +113 -0
  20. package/dist/docs/how-to/configure-project.ko.md +99 -0
  21. package/dist/docs/how-to/configure-project.md +95 -0
  22. package/dist/docs/how-to/connect-surfaces.ko.md +115 -0
  23. package/dist/docs/how-to/connect-surfaces.md +118 -0
  24. package/dist/docs/how-to/write-disciplines.ko.md +124 -0
  25. package/dist/docs/how-to/write-disciplines.md +125 -0
  26. package/dist/docs/index.json +2046 -0
  27. package/dist/docs/reference/cli/covenant-check.ko.md +101 -0
  28. package/dist/docs/reference/cli/covenant-check.md +98 -0
  29. package/dist/docs/reference/cli/docs.ko.md +97 -0
  30. package/dist/docs/reference/cli/docs.md +95 -0
  31. package/dist/docs/reference/cli/explain.ko.md +79 -0
  32. package/dist/docs/reference/cli/explain.md +84 -0
  33. package/dist/docs/reference/cli/init.ko.md +119 -0
  34. package/dist/docs/reference/cli/init.md +131 -0
  35. package/dist/docs/reference/configuration/index.ko.md +448 -0
  36. package/dist/docs/reference/configuration/index.md +474 -0
  37. package/dist/docs/reference/packages/adapter-claude-code.ko.md +83 -0
  38. package/dist/docs/reference/{adapter-claude-code.md → packages/adapter-claude-code.md} +16 -10
  39. package/dist/docs/reference/packages/adapter-git.ko.md +101 -0
  40. package/dist/docs/reference/{adapter-git.md → packages/adapter-git.md} +25 -15
  41. package/dist/docs/reference/packages/core.ko.md +128 -0
  42. package/dist/docs/reference/{core.md → packages/core.md} +32 -13
  43. package/dist/docs/reference/packages/covenant.ko.md +115 -0
  44. package/dist/docs/reference/{covenant.md → packages/covenant.md} +41 -26
  45. package/dist/docs/reference/packages/polydeukes.ko.md +134 -0
  46. package/dist/docs/reference/packages/polydeukes.md +139 -0
  47. package/dist/docs/troubleshooting.ko.md +142 -0
  48. package/dist/docs/troubleshooting.md +97 -122
  49. package/dist/docs/tutorials/first-judgment.ko.md +82 -0
  50. package/dist/docs/tutorials/first-judgment.md +81 -0
  51. package/dist/docs-catalog.d.ts +25 -0
  52. package/dist/docs-catalog.js +450 -0
  53. package/dist/docs-library.d.ts +23 -0
  54. package/dist/docs-library.js +347 -0
  55. package/dist/docs-markdown.d.ts +32 -0
  56. package/dist/docs-markdown.js +150 -0
  57. package/dist/docs-query.d.ts +11 -40
  58. package/dist/docs-query.js +28 -122
  59. package/dist/docs-types.d.ts +105 -0
  60. package/dist/docs-types.js +2 -0
  61. package/dist/explain.d.ts +3 -5
  62. package/dist/explain.js +48 -47
  63. package/dist/index.d.ts +2 -3
  64. package/dist/index.js +1 -2
  65. package/dist/init-claude-code.d.ts +5 -3
  66. package/dist/init-claude-code.js +226 -63
  67. package/dist/init-grok.d.ts +51 -0
  68. package/dist/init-grok.js +242 -0
  69. package/dist/load-config.d.ts +5 -1
  70. package/dist/load-config.js +2 -1
  71. package/dist/pre-state-reader.d.ts +22 -0
  72. package/dist/pre-state-reader.js +32 -0
  73. package/dist/scaffold-project.js +48 -8
  74. package/dist/schema/polydeukes.schema.json +38 -91
  75. package/package.json +7 -7
  76. package/dist/docs/configuration.md +0 -103
  77. package/dist/docs/installation.md +0 -212
  78. package/dist/docs/reference/configuration.md +0 -338
  79. package/dist/docs/reference/polydeukes.md +0 -287
@@ -0,0 +1,113 @@
1
+ # How a judgment works
2
+
3
+ **English** · [한국어](./judgment.ko.md)
4
+
5
+ Polydeukes checks a declared practice against evidence a connected surface supplies. It does not
6
+ infer that a practice was followed merely because an agent says so. A passing result is bounded
7
+ by the files, calls, and history actually observed.
8
+
9
+ <a id="terms"></a>
10
+ ## Covenant, discipline, and surface
11
+
12
+ A **covenant** is a shared promise about the work. A **discipline** is one practice registered
13
+ in the project's configuration. The **judge** evaluates evidence; a **verdict** records the result.
14
+
15
+ A **surface** determines when evidence is gathered:
16
+
17
+ - The session surface observes a supported host's tool call before it runs.
18
+ - The commit surface observes staged changes, working-tree changes, or a revision range.
19
+
20
+ Installing the package is not the same as connecting a surface. Instructions an agent reads are
21
+ not automatic interception of its tools. Use a supported integration and verify an actual call.
22
+ See [connect the surfaces](../how-to/connect-surfaces.md).
23
+
24
+ <a id="declarations"></a>
25
+ ## Declarations and their limits
26
+
27
+ A judged discipline has an `id` and a `declare` block. Its scope selects observations; its sources
28
+ provide evidence; extraction steps transform that evidence; relations identify elements that
29
+ break the promise. `why` explains the practice but is not executable logic.
30
+
31
+ The fixed sources are `target.path`, `pre`, `post`, `state`, `changes`, `command`, and `actor`.
32
+ Additional bindings can read a named file, a sidecar channel, or session history. A declaration
33
+ can only use sources the surface supplies. The same declaration can therefore be judged on one
34
+ surface and skipped, or not match its scope, on another.
35
+
36
+ `state` pairs before and after values on a modification. It is not persistent state across runs,
37
+ an assertion that a workflow advanced, or proof that a command succeeded. The `unchanged`
38
+ relation consumes a paired extraction; other relations consume single extractions. Additions
39
+ and deletions do not carry that modification pair. Missing evidence follows the declaration's
40
+ `supply` policy, not a fabricated empty file.
41
+
42
+ A `draft: true` entry records a practice that has not been promoted into a declaration. It does
43
+ not judge or emit a telemetry row. Do not use a draft merely because a valid declaration needs
44
+ more testing. Conversely, do not invent a step or mechanism when the grammar lacks the evidence
45
+ or comparison you need. [Write disciplines](../how-to/write-disciplines.md) demonstrates a
46
+ working locale key comparison and a genuinely unsupported promise.
47
+
48
+ <a id="relations"></a>
49
+ ## Seven relations
50
+
51
+ Relations return a list of elements for which the comparison fails. An empty list means the
52
+ relation holds; it is not the same as the `empty` relation's requirement.
53
+
54
+ | Relation | Requirement |
55
+ |---|---|
56
+ | `empty` | The extraction contains no items. |
57
+ | `nonEmpty` | The extraction contains at least one item. |
58
+ | `equal` | Both extracted collections agree. |
59
+ | `subset` | Every item on the left is present on the right. |
60
+ | `implies` | The left-hand key requirements have corresponding keys on the right. |
61
+ | `ordered` | The extracted sequence satisfies the declared ordering. |
62
+ | `unchanged` | Values at shared keys agree before and after a modification. |
63
+
64
+ Keys and values have different roles. Keys identify items for keyed comparisons and combination;
65
+ values are compared structurally. A comparison of translation keys does not compare translated
66
+ text. Extraction decides which distinction a relation can see.
67
+
68
+ <a id="mechanisms"></a>
69
+ ## Eighteen mechanism names
70
+
71
+ A mechanism names the purpose and allowed shape of a declaration, not a new comparison operator.
72
+ The compiler derives the evidence axes and relations from the syntax and checks that they fit
73
+ the chosen mechanism.
74
+
75
+ `pairing`, `companion`, `monotonic-order`, `fingerprint-sync`, `producer-owned`,
76
+ `self-absolution-ban`, `actor-scope`, `precedent`, `phase-order`, `turn-locality`, `stated-ground`,
77
+ `controlled-vocabulary`, `naming`, `added-only`, `one-way-marker`, `delegated-scope`,
78
+ `scoped-valve`, and `forbidden-command` are the closed catalog.
79
+
80
+ `delegated-scope` is **reserved**, not a usable declaration in this release. `scoped-valve`
81
+ requires its own witness block; `naming` scopes on `target.path`; `forbidden-command` scopes on
82
+ `command`. See the [configuration reference](../reference/configuration/index.md#disciplines)
83
+ for syntax and extraction steps.
84
+
85
+ <a id="verdicts"></a>
86
+ ## Interpret the result, not just the exit code
87
+
88
+ | Record | Meaning |
89
+ |---|---|
90
+ | `passed` | The observed input was judged and upheld the covenant. |
91
+ | `blocked` | The observed input broke the covenant and was refused. |
92
+ | `witnessed` | A blocking judgment was allowed through its witness valve. |
93
+ | `advised` | A violation was recorded without stopping the operation. |
94
+ | `skipped` | The absence of a judgment was recorded. It is not a pass. |
95
+ | `unattributed` | Baseline comparison found protected movement without an explaining judgment. |
96
+
97
+ The final record is a comparison finding, not a judge's verdict. Telemetry uses the same event
98
+ column to record it. An `advised` or `skipped` observation may exit 0; that does not establish
99
+ that the practice was followed. An empty observation set establishes nothing about other files.
100
+
101
+ <a id="enforcement-and-witness"></a>
102
+ ## Enforcement and witness
103
+
104
+ Discipline entries default to `advise`. Promote an entry with `enforce: block` only after checking
105
+ both its violating and valid cases. The commit surface's level and an entry's level compose:
106
+ **the lenient side wins**. Setting only the surface to `block` does not promote every entry.
107
+ Protection of the judging chain is separate from ordinary discipline entries.
108
+
109
+ The witness valve is consulted after a blocking judgment, never instead of judgment. Session
110
+ and commit witnesses have different delivery mechanisms and evidence. A commit prompt cannot
111
+ approve a pending session call. See [witness and
112
+ recovery](../how-to/connect-surfaces.md#witness-and-recovery)
113
+ and [troubleshooting](../troubleshooting.md).
@@ -0,0 +1,99 @@
1
+ # 프로젝트 설정하기
2
+
3
+ [English](./configure-project.md) · **한국어**
4
+
5
+ 프로젝트 루트에 설정 파일 하나를 두고, 제품 소스의 범위와 검증 명령을 정합니다.
6
+ 위반이 생겼을 때 작업을 계속할지 차단할지도 선택합니다. 아직 설치하지 않았다면
7
+ [첫 판정 따라 하기](../tutorials/first-judgment.ko.md)부터 시작하세요.
8
+
9
+ <a id="find-the-config"></a>
10
+ ## 설정 파일 찾기
11
+
12
+ Polydeukes는 프로젝트 루트 바로 아래에서 `polydeukes.config.yaml`, `polydeukes.config.yml`,
13
+ `polydeukes.config.json` 중 하나를 읽습니다. 상위 디렉터리까지 찾아 올라가지는 않습니다.
14
+
15
+ - 파일이 없으면 설정이 필요한 명령은 실패합니다. 기본값으로 대신 실행하지 않습니다.
16
+ - 파일이 여러 개면 필요한 내용을 합친 뒤 하나만 남깁니다.
17
+ - 발견한 설정 파일은 자동으로 `protectedPaths`에 포함됩니다. 설정 자체를 바꾸는 작업도
18
+ 보호 대상입니다.
19
+
20
+ `pdks docs`는 프로젝트 설정 없이 사용할 수 있습니다. 필드별 제약은
21
+ [설정 참조](../reference/configuration/index.ko.md)에서 확인하세요.
22
+
23
+ <a id="add-ide-support"></a>
24
+ ## 편집기에서 스키마로 검사하기
25
+
26
+ YAML 파일에는 다음 줄을 넣어 설치된 스키마를 편집기에서 사용합니다.
27
+
28
+ ```yaml
29
+ # yaml-language-server: $schema=node_modules/polydeukes/dist/schema/polydeukes.schema.json
30
+ ```
31
+
32
+ 이 경로는 설정 파일을 기준으로 한 상대 경로이지 모듈 이름이 아닙니다. 설정 파일이 모노레포
33
+ 하위 패키지에 있고 의존성은 워크스페이스 루트에 설치된 경우, 올라가는 층수를 직접 셉니다.
34
+
35
+ ```yaml
36
+ # yaml-language-server: $schema=../../node_modules/polydeukes/dist/schema/polydeukes.schema.json
37
+ ```
38
+
39
+ `pdks init claude-code`는 생성한 설정 파일을 기준으로 기본 경로의 스키마를 찾을 수 있을 때만
40
+ 스키마 줄을 넣습니다. 이 줄이 없다면 스키마 위치에 맞춰 상대 경로를 직접 추가하세요.
41
+ `$schema` 경로를 찾지 못하면 편집기에 오류가 표시되지 않은 채 스키마 검증이 중단될 수 있습니다.
42
+
43
+ 우산이 아니라 `@polydeukes/core`를 직접 설치했다면 그 사본을 가리킵니다.
44
+
45
+ ```yaml
46
+ # yaml-language-server: $schema=node_modules/@polydeukes/core/schema/polydeukes.schema.json
47
+ ```
48
+
49
+ 편집기가 정적으로 읽는 파일 경로입니다. 런타임에 스키마를 읽는 코드는 exports 서브패스
50
+ `@polydeukes/core/schema.json`을 씁니다. JSON 설정에는 `$schema` 속성을 쓸 수 있습니다.
51
+ 로더는 이 속성을 허용하되 실제 사용할 설정에서는 제외합니다.
52
+
53
+ <a id="fill-the-language-block"></a>
54
+ ## 언어 블록 채우기
55
+
56
+ `languages`에는 항목이 하나 이상 있어야 합니다. 각 항목에 제품 소스의 경로와 검증 명령을
57
+ 적습니다.
58
+
59
+ ```yaml
60
+ languages:
61
+ typescript:
62
+ productionGlob: 'src/**'
63
+ testCmd: 'pnpm test'
64
+ ```
65
+
66
+ 언어 이름은 프로젝트에서 정하는 키입니다. 설치기가 만든 임시 값을 실제 경로와 명령으로
67
+ 바꾸세요. 블록을 지우거나 비워 두면 유효하지 않은 설정이 됩니다. 이 설정을 읽는 것만으로
68
+ 검증 명령이 실행되지는 않습니다.
69
+
70
+ <a id="choose-advise-or-block"></a>
71
+ ## 권고와 차단 중 선택하기
72
+
73
+ | 설정 | 위반 시 동작 |
74
+ |---|---|
75
+ | `adapters.git.enforce: advise` | 권고를 기록하고 커밋을 계속합니다. 증인 입력은 요청하지 않습니다. |
76
+ | `adapters.git.enforce: block` | 차단 판정을 받은 작업을 거부합니다. 스테이징 검사에서는 TTY로 증인 입력을 받을 수 있습니다. |
77
+
78
+ 일반 규율(discipline) 항목에도 자체 강제 수준이 있으며 기본값은 `advise`입니다.
79
+ **두 수준 중 더 관대한 쪽을 따릅니다.** 어댑터만 `block`으로 설정해도 일반 항목이 자동으로
80
+ 차단 수준으로 바뀌지는 않습니다. 설정된 경로의 보호는 이 항목별 기본값과 별개입니다.
81
+ 조립 단계에서 오류가 나면 어느 수준에서든 종료 코드 2를 반환합니다.
82
+
83
+ 최상위 `protectedPaths`는 두 표면에 모두 적용합니다. `adapters.git.protectedPaths`에는
84
+ 커밋할 때만 보호할 경로를 추가합니다. 세션 중에는 편집을 허용하되 커밋할 때 보호하려는
85
+ 파일에 사용하세요. [표면 연결과 증인](./connect-surfaces.ko.md#witness-and-recovery)에서
86
+ 자세히 설명합니다.
87
+
88
+ <a id="confirm-the-project"></a>
89
+ ## 설정 확인하기
90
+
91
+ - `pdks explain`은 설정을 읽고 등록된 항목을 보여 줍니다. 변경을 판정하지는 않습니다.
92
+ - `pdks covenant check --worktree`는 HEAD와 디스크를 비교합니다. 아직 Git에 등록하지 않은
93
+ 파일도 무시 대상이 아니면 포함합니다.
94
+ - `pdks covenant check`는 스테이징한 변경을 관측합니다. 차단 결과가 나고 TTY를 사용할 수
95
+ 있을 때 증인 입력을 요청할 수 있습니다. 어댑터가 `block`이라는 이유만으로 묻지는 않습니다.
96
+
97
+ 종료 코드와 함께 stderr와 텔레메트리도 확인하세요. 권고나 일부 미판정도 종료 코드 0을
98
+ 반환합니다. 조립에 실패했다면 규율을 시험하기 전에 오류가 지목한 설정이나 빠진 패키지부터
99
+ 확인하세요.
@@ -0,0 +1,95 @@
1
+ # Configure the project
2
+
3
+ **English** · [한국어](./configure-project.ko.md)
4
+
5
+ Keep one configuration file at the project root, define the production files and verification
6
+ command, and choose how violations should affect work. Start with the
7
+ [first-judgment tutorial](../tutorials/first-judgment.md) if the package is not installed yet.
8
+
9
+ <a id="find-the-config"></a>
10
+ ## Find the config file
11
+
12
+ Polydeukes reads exactly one of `polydeukes.config.yaml`, `polydeukes.config.yml`, or
13
+ `polydeukes.config.json` directly under the project root. It does not search parent directories.
14
+
15
+ - With no file, commands that need configuration fail rather than silently use defaults.
16
+ - With several files, merge the intended content and keep only one.
17
+ - The discovered file automatically joins `protectedPaths`, so changing the configuration itself
18
+ is subject to protection.
19
+
20
+ `pdks docs` does not need project configuration. Consult the
21
+ [configuration reference](../reference/configuration/index.md) for exact field constraints.
22
+
23
+ <a id="add-ide-support"></a>
24
+ ## Add IDE support
25
+
26
+ For YAML, add this line so the editor can use the installed schema:
27
+
28
+ ```yaml
29
+ # yaml-language-server: $schema=node_modules/polydeukes/dist/schema/polydeukes.schema.json
30
+ ```
31
+
32
+ The path is relative to the configuration file, not a module specifier. When the config sits in a
33
+ monorepo sub-package whose dependencies installed at the workspace root, count the levels up:
34
+
35
+ ```yaml
36
+ # yaml-language-server: $schema=../../node_modules/polydeukes/dist/schema/polydeukes.schema.json
37
+ ```
38
+
39
+ `pdks init claude-code` adds the schema line only when the default path resolves relative to the
40
+ generated config. If the line is absent, add a relative path to the installed schema yourself.
41
+ An unresolvable `$schema` can disable editor validation without displaying an error.
42
+
43
+ If you installed `@polydeukes/core` directly rather than the umbrella, name its copy:
44
+
45
+ ```yaml
46
+ # yaml-language-server: $schema=node_modules/@polydeukes/core/schema/polydeukes.schema.json
47
+ ```
48
+
49
+ That is a file path an editor reads statically. Code that reads the schema at runtime uses the
50
+ exports subpath `@polydeukes/core/schema.json` instead. JSON configurations can use a `$schema`
51
+ property; the loader accepts it but leaves it out of the resolved configuration.
52
+
53
+ <a id="fill-the-language-block"></a>
54
+ ## Fill the language block
55
+
56
+ `languages` must contain at least one entry. Each entry specifies production paths and a
57
+ verification command:
58
+
59
+ ```yaml
60
+ languages:
61
+ typescript:
62
+ productionGlob: 'src/**'
63
+ testCmd: 'pnpm test'
64
+ ```
65
+
66
+ Language names are project-defined keys. Replace the installer's placeholder with meaningful
67
+ paths and a command; deleting the block or leaving it empty makes the configuration invalid.
68
+ Loading this setting does not itself run the command.
69
+
70
+ <a id="choose-advise-or-block"></a>
71
+ ## Choose advise or block
72
+
73
+ | Setting | Effect on a violation |
74
+ |---|---|
75
+ | `adapters.git.enforce: advise` | Record advice and let the commit continue, without a witness prompt. |
76
+ | `adapters.git.enforce: block` | Refuse a blocking judgment; the staged path can offer a TTY witness prompt. |
77
+
78
+ An ordinary discipline also has its own level, defaulting to `advise`. **The lenient level wins.**
79
+ Setting only the adapter to `block` does not promote an ordinary entry. Protection of configured
80
+ paths is separate from that per-entry default. Assembly errors still exit 2 at either level.
81
+
82
+ Top-level `protectedPaths` applies to both surfaces. `adapters.git.protectedPaths` adds commit-only
83
+ paths. Use the latter for files that may be edited in a session but need protection when committed.
84
+ See [surface connection and witnesses](./connect-surfaces.md#witness-and-recovery).
85
+
86
+ <a id="confirm-the-project"></a>
87
+ ## Confirm the project
88
+
89
+ - `pdks explain` loads the configuration and shows registrations without judging a change.
90
+ - `pdks covenant check --worktree` compares HEAD with disk, including untracked, non-ignored files.
91
+ - `pdks covenant check` observes staged changes. A blocking result can prompt only when a TTY is
92
+ available; the command does not prompt merely because the adapter is set to `block`.
93
+
94
+ Check stderr and telemetry as well as the exit code. Advice and some skipped observations exit 0.
95
+ If assembly fails, diagnose the named configuration or missing package before testing a discipline.
@@ -0,0 +1,115 @@
1
+ # 표면 연결하기
2
+
3
+ [English](../how-to/connect-surfaces.md) · **한국어**
4
+
5
+ > 작업에 맞는 표면을 고릅니다. Claude Code와 Grok는 세션 표면을 배선하고, git은 커밋 표면을 배선합니다.
6
+
7
+ 두 표면은 같은 설정 어휘를 쓰지만 판정 시점이 다릅니다. AI 파트너가 편집할 때는 세션 표면을,
8
+ 변경을 이력으로 기록하기 전에는 커밋 표면을 사용합니다.
9
+
10
+ <a id="claude-code"></a>
11
+ ## Claude Code 세션 표면
12
+
13
+ Claude Code에서 AI 파트너와 함께 개발할 때 씁니다.
14
+
15
+ 1. 패키지를 프로젝트 의존성으로 설치합니다. `pnpm add -D polydeukes`. 일회성 `npx` 실행만으로는
16
+ 부족합니다. 두 표면 모두 프로젝트에 설치된 패키지에서 판정기를 불러옵니다.
17
+ 2. 프로젝트를 배선합니다. `pnpm exec pdks init claude-code`.
18
+ 3. 생성된 훅, 병합된 설정, 초기 설정 파일, 문서 안내와 `discipline-draft` 스킬을 확인합니다.
19
+ 4. 훅이 바뀌면 프로젝트를 다시 엽니다. 생성된 훅은 패키지에 판정을 위임하므로 패키지를
20
+ 갱신할 때 훅 파일까지 다시 쓸 필요는 없습니다.
21
+
22
+ 설치기는 `.claude/settings.json`을 덮어쓰지 않고 병합합니다. 기존 훅과 권한은 보존합니다.
23
+ `.claude/rules/polydeukes.md`에는 웹 검색 대신 설치된 `pdks docs`를 조회하도록 안내하고,
24
+ `.claude/skills/discipline-draft/SKILL.md`에는 문제를 선언이나 초안으로 등록하는 절차를
25
+ 제공합니다.
26
+
27
+ <a id="grok"></a>
28
+ ## Grok 세션 표면
29
+
30
+ Grok에서 개발할 때 씁니다.
31
+
32
+ 1. 패키지를 프로젝트 의존성으로 설치합니다. `pnpm add -D polydeukes`.
33
+ 2. 프로젝트를 배선합니다. `pnpm exec pdks init grok`.
34
+ 3. 설치가 끝나면 Hooks 탭을 다시 불러오거나 새 세션을 엽니다.
35
+
36
+ Grok 프로젝트에는 `.grok/hooks/` 아래에 훅 JSON 파일이 생깁니다. Claude 훅이 이미 있으면
37
+ Grok의 `command`도 그 파일을 가리킵니다. `.claude/settings.json`도 있다면 같은 `command`를
38
+ 등록한 Claude 항목에 맞춰 Grok의 `matcher`를 설정합니다. 두 값이 모두 같아야 Grok가 중복 등록을
39
+ 하나로 처리해 판정기를 두 번 실행하지 않기 때문입니다.
40
+ 새 등록의 제한 시간은 60초입니다. Grok 호스트의 기본값은 5초이며, 훅 실행이 시간 초과로
41
+ 끝나면 해당 호출을 차단하지 않습니다(fail-open).
42
+
43
+ Grok는 세션 증인 밸브에 필요한 Claude 형식의 인간 메시지를 공급하지 않습니다. 대화 기록은
44
+ Claude JSONL이 아니라 ACP `updates.jsonl`입니다.
45
+ 의도한 편집이 차단되면 자신의 터미널에서 수행하세요. 커밋 표면의 증인 프롬프트는 해당
46
+ 커밋에만 적용되며, 차단된 Grok 도구 호출을 허용하지는 않습니다.
47
+
48
+ <a id="commit-surface"></a>
49
+ ## 커밋 표면
50
+
51
+ 스테이징한 변경을 이력으로 기록하기 전에 Git에서 판정하려면 이 표면을 사용합니다.
52
+
53
+ 1. 프로젝트 루트에 `polydeukes.config.yaml`을 만듭니다.
54
+ 2. pre-commit 훅을 추가합니다.
55
+ 3. 필요할 때는 `pnpm exec pdks covenant check`를 직접 돌려 같은 판정을 봅니다.
56
+
57
+ lefthook 예시는 다음과 같습니다.
58
+
59
+ ```yaml
60
+ pre-commit:
61
+ commands:
62
+ covenant:
63
+ priority: 1
64
+ interactive: true
65
+ run: ./node_modules/.bin/pdks covenant check
66
+ ```
67
+
68
+ husky 예시는 다음과 같습니다.
69
+
70
+ ```sh
71
+ # .husky/pre-commit
72
+ ./node_modules/.bin/pdks covenant check
73
+ ```
74
+
75
+ 일반 git 훅으로 연결해도 됩니다.
76
+
77
+ ```sh
78
+ #!/bin/sh
79
+ ./node_modules/.bin/pdks covenant check
80
+ ```
81
+
82
+ 일반 훅은 `.git/hooks/pre-commit`으로 저장한 뒤 `chmod +x .git/hooks/pre-commit`으로
83
+ 실행 권한을 줍니다. 기존 훅이 있다면 덮어쓰지 말고 호출을 추가하세요. lefthook은 패키지
84
+ 관리자로 설치하고 YAML을 저장한 뒤 훅 설치 명령을 실행합니다. husky는 git이 찾을 수 있도록
85
+ husky 설치기로 `.husky/pre-commit`을 저장하세요.
86
+
87
+ `adapters.git.enforce: advise`이면 위반을 `advised`로 기록하고 stderr에 알린 뒤 커밋을
88
+ 허용합니다. `block`이면 보호 경로 위반과 `enforce: block`으로 지정한 항목의 위반을
89
+ 차단할 수 있습니다. 일반 항목의 기본값은 여전히 `advise`이며 표면 설정이 이를 승격하지
90
+ 않습니다. 증인이 설정돼 있고 터미널에 연결된 경우, 스테이징 검사에서 `/dev/tty` 프롬프트를
91
+ 제공합니다. `--worktree`와 `--range`는 프롬프트 없이 보고합니다. 조립 실패는 어느 강제
92
+ 수준에서도 종료 코드 2를 반환합니다.
93
+
94
+ <a id="witness-and-recovery"></a>
95
+ ## 증인과 회복
96
+
97
+ 증인 토큰은 두 표면에서 같은 뜻이지만 전달 방식은 다릅니다.
98
+
99
+ - 세션 표면에서는 대화 메시지 첫 줄에 토큰만 단독으로 넣습니다.
100
+ - 커밋 표면에서는 TTY 프롬프트에 전체 토큰을 입력합니다.
101
+
102
+ 밸브는 판정 결과가 차단일 때 확인합니다. 의도한 편집 전에 토큰을 입력해도 되며, 먼저
103
+ 실패하는 요청을 보낼 필요는 없습니다. 정상 판정은 바꾸지 않고, 현재 Grok 대화 기록
104
+ 형식에서는 세션 밸브를 사용할 수 없습니다.
105
+
106
+ Grok가 훅을 아직 읽지 못했다면 Hooks 탭을 다시 불러오거나 새 세션을 여세요. 판정기를 적재할 수 없다면 패키지를 다시 설치하거나 워크스페이스를 다시 빌드한 뒤
107
+ 시도하세요.
108
+
109
+ <a id="what-to-check"></a>
110
+ ## 배선한 뒤 확인할 것
111
+
112
+ - `pdks explain`은 각 표면이 어떤 등록을 조립했는지 보여 줍니다.
113
+ - `.polydeukes/roi.log`는 표면이 남긴 행을 기록합니다.
114
+ - `pdks covenant check --worktree`는 작업 뒤에 쓰기 좋은 즉시 확인 명령입니다.
115
+ - `pdks covenant check --range <base>..<head>`는 PR 전에 쓰기 좋은 형태입니다.
@@ -0,0 +1,118 @@
1
+ # Connect the surfaces
2
+
3
+ **English** · [한국어](../how-to/connect-surfaces.ko.md)
4
+
5
+ > Pick the surface that matches the job. Claude Code and Grok wire the session surface; git wires
6
+ the commit surface.
7
+
8
+ The two surfaces share the same config vocabulary, but they answer different moments. Use the
9
+ session surface when an AI partner is making edits, and use the commit surface when history is about
10
+ to be written.
11
+
12
+ <a id="claude-code"></a>
13
+ ## Claude Code session surface
14
+
15
+ Use this when the project is developed alongside an AI partner in Claude Code.
16
+
17
+ 1. Install the package as a project dependency: `pnpm add -D polydeukes`. A one-off `npx` run is
18
+ not enough — both surfaces load the judge from the project's own installed package.
19
+ 2. Wire the project: `pnpm exec pdks init claude-code`.
20
+ 3. Keep the generated hook file, settings merge, starter config, discovery rule, and
21
+ discipline-draft skill.
22
+ 4. Reopen the project when the hook changes. The generated hook is a delegator, so upgrading the
23
+ package upgrades the judge without rewriting the hook file.
24
+
25
+ The installer writes `.claude/settings.json` only by merging. Existing hooks and permissions stay in
26
+ place. It also writes `.claude/rules/polydeukes.md`, which tells the agent to use `pdks docs`
27
+ instead of searching the web, and `.claude/skills/discipline-draft/SKILL.md`, which turns a
28
+ described problem into either a judged entry or a draft entry.
29
+
30
+ <a id="grok"></a>
31
+ ## Grok session surface
32
+
33
+ Use this when the project is developed in Grok.
34
+
35
+ 1. Install the package as a project dependency: `pnpm add -D polydeukes`.
36
+ 2. Wire the project: `pnpm exec pdks init grok`.
37
+ 3. Reload the Hooks tab or open a new session after the installer finishes.
38
+
39
+ A Grok tree gets its own hook JSON under `.grok/hooks/`. When a Claude hook already exists, the Grok
40
+ command points at that file so the host does not spawn two judges. If the tree also has
41
+ `.claude/settings.json`, the Grok matcher follows the Claude registration that names the same
42
+ command, because Grok collapses the two registrations only when command and matcher match.
43
+ Generated registrations use a timeout of 60 seconds. The Grok host default is 5 seconds, and a
44
+ timed-out hook fails open.
45
+
46
+ Grok does not supply the Claude-format human message needed by the session witness valve. The
47
+ session log is ACP `updates.jsonl`, not Claude's JSONL.
48
+ For an intentional blocked edit, use your own terminal. A commit-surface prompt witnesses only
49
+ that commit; it cannot authorize a blocked Grok tool call.
50
+
51
+ <a id="commit-surface"></a>
52
+ ## Commit surface
53
+
54
+ Use this when you want git to judge staged changes before they become history.
55
+
56
+ 1. Create `polydeukes.config.yaml` at the project root.
57
+ 2. Add the pre-commit hook.
58
+ 3. Run `pnpm exec pdks covenant check` when you want the same judgment on demand.
59
+
60
+ A minimal lefthook entry looks like this:
61
+
62
+ ```yaml
63
+ pre-commit:
64
+ commands:
65
+ covenant:
66
+ priority: 1
67
+ interactive: true
68
+ run: ./node_modules/.bin/pdks covenant check
69
+ ```
70
+
71
+ A husky hook looks like this:
72
+
73
+ ```sh
74
+ # .husky/pre-commit
75
+ ./node_modules/.bin/pdks covenant check
76
+ ```
77
+
78
+ A plain git hook works too:
79
+
80
+ ```sh
81
+ #!/bin/sh
82
+ ./node_modules/.bin/pdks covenant check
83
+ ```
84
+
85
+ If you use the plain hook, save it as `.git/hooks/pre-commit` and make it executable with
86
+ `chmod +x .git/hooks/pre-commit`. Integrate with an existing hook instead of overwriting it.
87
+ For lefthook, install it with your package manager and run its hook installer after saving the YAML.
88
+ For husky, save `.husky/pre-commit` through husky's own installer so git can find it.
89
+
90
+ `adapters.git.enforce: advise` records violations as `advised`, writes diagnostics to stderr,
91
+ and lets the commit continue. With `block`, protected-path violations and entries explicitly set
92
+ to `enforce: block` can stop the commit. An ordinary entry still defaults to `advise`; the surface
93
+ does not promote it. When configured and attached to a terminal, the staged path offers a witness
94
+ prompt on `/dev/tty`. `--worktree` and `--range` report without prompting. Assembly errors remain
95
+ exit 2 at either level.
96
+
97
+ <a id="witness-and-recovery"></a>
98
+ ## Witness and recovery
99
+
100
+ The witness token is the same idea on both surfaces, but the delivery is different.
101
+
102
+ - On the session surface, type the token on its own first line in a conversation message.
103
+ - On the commit surface, type the full token into the TTY prompt.
104
+
105
+ The valve is consulted after the judgment returns a block. You can supply the token before an
106
+ intentional edit; a previous failed attempt is not required. It does not change a passing verdict
107
+ and the session valve does not work with Grok's current transcript format.
108
+
109
+ If the hook was not picked up in Grok, reload the Hooks tab or start a new session. If the judge
110
+ cannot be loaded, reinstall the package or rebuild the workspace and try again.
111
+
112
+ <a id="what-to-check"></a>
113
+ ## What to check after wiring
114
+
115
+ - `pdks explain` shows which registrations each surface assembled.
116
+ - `.polydeukes/roi.log` records the rows that the surfaces wrote.
117
+ - `pdks covenant check --worktree` is a good on-demand check after a task.
118
+ - `pdks covenant check --range <base>..<head>` is the shape to use before a PR.
@@ -0,0 +1,124 @@
1
+ # 규율 작성하기
2
+
3
+ [English](../how-to/write-disciplines.md) · **한국어**
4
+
5
+ 규율(discipline)은 확인하고 싶은 개발 관행을 선언한 항목입니다. 관측할 파일이나 세션의
6
+ 증거를 고르고, 추출 과정과 관계를 적은 다음 위반과 정상 사례를 각각 실행합니다.
7
+ 관측 결과를 보고 차단이 필요하다고 판단하기 전까지는 기본 강제 수준인 `advise`를 유지합니다.
8
+
9
+ <a id="locale-key-pairing"></a>
10
+ ## 번역 키 짝 맞춤
11
+
12
+ 두 JSON 번역 파일의 키 집합을 비교합니다. 중첩된 키도 비교 대상입니다.
13
+ 아래 전체 YAML을 **예제 프로젝트**의 `polydeukes.config.yaml`로 저장합니다. 기존 프로젝트의
14
+ 설정을 덮어쓰지 마세요. 기존 설정에 추가할 때는 규율 항목만 복사합니다.
15
+ 설치 절차는 [첫 판정 튜토리얼](../tutorials/first-judgment.ko.md)에 있습니다.
16
+
17
+ ```yaml
18
+ languages:
19
+ json:
20
+ productionGlob: 'locales/**/*.json'
21
+ testCmd: 'pnpm test'
22
+ telemetry:
23
+ logPath: '.polydeukes/roi.log'
24
+ disciplines:
25
+ - id: 'locale-key-parity'
26
+ why: 'the ko and en locales must carry the same keys'
27
+ declare:
28
+ mechanism: 'pairing'
29
+ sources:
30
+ ko: { file: 'locales/ko.json' }
31
+ en: { file: 'locales/en.json' }
32
+ supply: { ko: 'error', en: 'error' }
33
+ scope: { source: 'target.path', include: ['^locales/(ko|en)\.json$'] }
34
+ extract:
35
+ koKeys:
36
+ - { op: 'source', of: 'ko' }
37
+ - { op: 'json' }
38
+ - { op: 'flattenKeys' }
39
+ enKeys:
40
+ - { op: 'source', of: 'en' }
41
+ - { op: 'json' }
42
+ - { op: 'flattenKeys' }
43
+ relate:
44
+ - id: 'parity'
45
+ relation: { op: 'equal', of: ['koKeys', 'enKeys'] }
46
+ messageBySide:
47
+ left: '{key} is in ko only'
48
+ right: '{key} is in en only'
49
+ ```
50
+
51
+ `flattenKeys`는 번역 값이 아니라 키를 추출합니다. `equal`은 양방향으로 비교하고,
52
+ `messageBySide`는 어느 파일에 짝이 없는 키가 있는지 알려 줍니다. 기본 강제 수준은
53
+ `advise`입니다. 소스 파일 둘 다 존재하고 올바른 JSON이어야 합니다. 커밋 표면은 선택한
54
+ 관측 범위에서 파일을 읽고, 세션 편집에서는 바뀌는 파일의 편집 후 내용을 사용합니다.
55
+
56
+ 예제 프로젝트 루트에서 키가 같은 파일을 만들고 git 추적 대상으로 등록합니다.
57
+ 아래 커밋에는 평소 사용하는 git 작성자 설정이 필요합니다. 이 커밋이 작업 트리 비교의
58
+ 기준이 됩니다.
59
+
60
+ ```sh
61
+ mkdir -p locales
62
+ printf '{"home":"Home"}\n' > locales/en.json
63
+ printf '{"home":"홈"}\n' > locales/ko.json
64
+ git add locales/en.json locales/ko.json
65
+ git commit -m 'docs: prepare locale example'
66
+ printf '{"home":"Home","settings":"Settings"}\n' > locales/en.json
67
+ pnpm exec pdks covenant check --worktree
68
+ ```
69
+
70
+ `locale-key-parity`의 `advised` 진단에 영어에만 있는 `settings` 키가 나와야 합니다.
71
+ 권고이므로 명령은 종료 코드 0으로 끝납니다. 한국어 파일에 빠진 키를 추가하고 같은 검사를 반복합니다.
72
+
73
+ ```sh
74
+ printf '{"home":"홈","settings":"설정"}\n' > locales/ko.json
75
+ pnpm exec pdks covenant check --worktree
76
+ ```
77
+
78
+ 이제 키 비교 진단이 없어야 합니다. 번역 값은 서로 다르지만 키는 같습니다.
79
+ 확인이 끝나면 두 예제 파일을 커밋한 기준 상태로 되돌립니다.
80
+
81
+ ```sh
82
+ git restore -- locales/en.json locales/ko.json
83
+ ```
84
+
85
+ `--worktree`는 git이 추적하지 않더라도 무시 대상이 아닌 파일을 추가된 파일로 포함합니다.
86
+ 이 예제는 수정 사례를 검사하고 쉽게 원상 복구하기 위해 기준 상태를 커밋합니다.
87
+ 소스 파일이 존재한다는 이유만으로 선언이 실행되지는 않습니다. 관측된 변경 중 하나
88
+ 이상이 해당 선언의 적용 범위와 일치해야 합니다.
89
+
90
+ <a id="when-to-draft"></a>
91
+ ## 선언 대신 초안으로 남길 때
92
+
93
+ 필요한 약속이지만 현재 문법으로 표현할 수 없다면 `draft`로 등록합니다.
94
+
95
+ ```yaml
96
+ languages:
97
+ json:
98
+ productionGlob: 'locales/**/*.json'
99
+ testCmd: 'pnpm test'
100
+ disciplines:
101
+ - id: 'benchmark-supports-performance-claim'
102
+ why: 'a performance claim must be supported by a fresh benchmark run during judgment.'
103
+ draft: true
104
+ ```
105
+
106
+ `draft: true`인 항목은 판정 결과나 텔레메트리 행을 남기지 않습니다. 설정에는 등록돼
107
+ 있으므로 `pdks explain`에서 확인할 수 있습니다.
108
+
109
+ <a id="proof-runs"></a>
110
+ ## 한 번은 실제로 판정해 보기
111
+
112
+ 설정을 저장한 뒤에는 필요한 증거를 공급할 수 있는 판정 경로로 위반과 정상 사례를 모두
113
+ 검사합니다. `pdks covenant check --worktree`는 현재 작업 트리의 변경을 판정하고,
114
+ `pdks explain`은 선언과 초안의 등록 상태를 보여 줍니다. 위 번역 예제처럼 한쪽 파일만
115
+ 바꾼 경우와 양쪽 키를 맞춘 경우를 비교하세요.
116
+
117
+ 판정 결과가 나타나지 않으면 먼저 관측 조건을 확인합니다. 무시 대상이 아닌 관측 파일인지,
118
+ 선택한 비교에서 실제로 바뀌었는지, 적용 범위가 맞는지, 해당 표면이 증거를 공급할 수 있는지
119
+ 차례로 살펴봅니다. `pdks explain`과 로그에서 `config-fault`, `no-observation`,
120
+ `supply-pass`도 확인합니다. 진단이 없다는 사실만으로 선언이 작동한다고 판단하지 마세요.
121
+
122
+ 위 초안은 키 비교와 다른 요구입니다. 현재 엔진은 판정 도중 새 벤치마크를 실행하지 않습니다.
123
+ 이미 공급된 증거를 비교하는 것과 판정 도중 새 벤치마크를 실행하는 것은 다른 요구입니다.
124
+ [선언과 관측 한계](../concepts/judgment.ko.md#declarations)를 참고하세요.