polydeukes 0.6.0 → 0.7.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 (117) hide show
  1. package/README.ko.md +30 -70
  2. package/README.md +31 -84
  3. package/dist/baseline.d.ts +37 -1
  4. package/dist/baseline.js +68 -1
  5. package/dist/bin.d.ts +3 -4
  6. package/dist/bin.js +79 -93
  7. package/dist/covenant/bash-line.d.ts +130 -0
  8. package/dist/covenant/bash-line.js +566 -0
  9. package/dist/covenant/declaration-engine.d.ts +108 -0
  10. package/dist/covenant/declaration-engine.js +415 -0
  11. package/dist/covenant/discipline.d.ts +103 -0
  12. package/dist/covenant/discipline.js +667 -0
  13. package/dist/covenant/dispatch.d.ts +153 -0
  14. package/dist/covenant/dispatch.js +237 -0
  15. package/dist/covenant/extract-steps.d.ts +122 -0
  16. package/dist/covenant/extract-steps.js +0 -0
  17. package/dist/covenant/mention.d.ts +117 -0
  18. package/dist/covenant/mention.js +209 -0
  19. package/dist/covenant/module.d.ts +25 -0
  20. package/dist/covenant/module.js +23 -0
  21. package/dist/covenant/mutation-rules.d.ts +40 -0
  22. package/dist/covenant/mutation-rules.js +146 -0
  23. package/dist/covenant/relations.d.ts +46 -0
  24. package/dist/covenant/relations.js +68 -0
  25. package/dist/covenant/run-covenant.d.ts +95 -0
  26. package/dist/covenant/run-covenant.js +164 -0
  27. package/dist/covenant/self-mod.d.ts +55 -0
  28. package/dist/covenant/self-mod.js +84 -0
  29. package/dist/covenant/shell-evidence.d.ts +38 -0
  30. package/dist/covenant/shell-evidence.js +247 -0
  31. package/dist/covenant/shell-mod.d.ts +84 -0
  32. package/dist/covenant/shell-mod.js +213 -0
  33. package/dist/covenant/supply.d.ts +54 -0
  34. package/dist/covenant/supply.js +50 -0
  35. package/dist/covenant/transcript-mod.d.ts +60 -0
  36. package/dist/covenant/transcript-mod.js +254 -0
  37. package/dist/covenant/ttl-witness.d.ts +47 -0
  38. package/dist/covenant/ttl-witness.js +80 -0
  39. package/dist/covenant-check.d.ts +72 -39
  40. package/dist/covenant-check.js +260 -121
  41. package/dist/diff-ir.d.ts +28 -0
  42. package/dist/diff-ir.js +310 -0
  43. package/dist/docs/README.ko.md +60 -0
  44. package/dist/docs/README.md +64 -0
  45. package/dist/docs/catalog.json +480 -0
  46. package/dist/docs/concepts/judgment.ko.md +113 -0
  47. package/dist/docs/concepts/judgment.md +113 -0
  48. package/dist/docs/how-to/configure-project.ko.md +99 -0
  49. package/dist/docs/how-to/configure-project.md +98 -0
  50. package/dist/docs/how-to/connect-surfaces.ko.md +120 -0
  51. package/dist/docs/how-to/connect-surfaces.md +121 -0
  52. package/dist/docs/how-to/write-disciplines.ko.md +179 -0
  53. package/dist/docs/how-to/write-disciplines.md +181 -0
  54. package/dist/docs/index.json +2280 -0
  55. package/dist/docs/reference/cli/covenant-check.ko.md +148 -0
  56. package/dist/docs/reference/cli/covenant-check.md +153 -0
  57. package/dist/docs/reference/cli/docs.ko.md +97 -0
  58. package/dist/docs/reference/cli/docs.md +95 -0
  59. package/dist/docs/reference/cli/explain.ko.md +84 -0
  60. package/dist/docs/reference/cli/explain.md +89 -0
  61. package/dist/docs/reference/cli/init.ko.md +119 -0
  62. package/dist/docs/reference/cli/init.md +119 -0
  63. package/dist/docs/reference/configuration/index.ko.md +553 -0
  64. package/dist/docs/reference/{configuration.md → configuration/index.md} +215 -90
  65. package/dist/docs/reference/packages/adapter-claude-code.ko.md +110 -0
  66. package/dist/docs/reference/{adapter-claude-code.md → packages/adapter-claude-code.md} +47 -19
  67. package/dist/docs/reference/packages/adapter-grok.ko.md +77 -0
  68. package/dist/docs/reference/packages/adapter-grok.md +79 -0
  69. package/dist/docs/reference/packages/core.ko.md +174 -0
  70. package/dist/docs/reference/{core.md → packages/core.md} +74 -12
  71. package/dist/docs/reference/packages/polydeukes.ko.md +195 -0
  72. package/dist/docs/reference/packages/polydeukes.md +204 -0
  73. package/dist/docs/reference/packages/sdk-ts.ko.md +161 -0
  74. package/dist/docs/reference/packages/sdk-ts.md +164 -0
  75. package/dist/docs/troubleshooting.ko.md +144 -0
  76. package/dist/docs/troubleshooting.md +103 -151
  77. package/dist/docs/tutorials/first-judgment.ko.md +82 -0
  78. package/dist/docs/tutorials/first-judgment.md +81 -0
  79. package/dist/docs-catalog.d.ts +25 -0
  80. package/dist/docs-catalog.js +450 -0
  81. package/dist/docs-library.d.ts +23 -0
  82. package/dist/docs-library.js +347 -0
  83. package/dist/docs-markdown.d.ts +32 -0
  84. package/dist/docs-markdown.js +150 -0
  85. package/dist/docs-query.d.ts +11 -40
  86. package/dist/docs-query.js +28 -122
  87. package/dist/docs-types.d.ts +105 -0
  88. package/dist/docs-types.js +2 -0
  89. package/dist/explain.d.ts +1 -1
  90. package/dist/explain.js +37 -22
  91. package/dist/load-config.d.ts +1 -1
  92. package/dist/load-config.js +1 -1
  93. package/dist/pre-state-reader.d.ts +1 -1
  94. package/dist/pre-state-reader.js +1 -1
  95. package/dist/scaffold-project.d.ts +2 -2
  96. package/dist/scaffold-project.js +9 -3
  97. package/dist/schema/polydeukes.schema.json +12 -0
  98. package/dist/worktree-reader.d.ts +19 -0
  99. package/dist/worktree-reader.js +30 -0
  100. package/package.json +3 -17
  101. package/dist/claude-code-hook.d.ts +0 -79
  102. package/dist/claude-code-hook.js +0 -372
  103. package/dist/claude-code.d.ts +0 -6
  104. package/dist/claude-code.js +0 -6
  105. package/dist/covenant-module.d.ts +0 -25
  106. package/dist/covenant-module.js +0 -42
  107. package/dist/docs/configuration.md +0 -103
  108. package/dist/docs/installation.md +0 -241
  109. package/dist/docs/reference/adapter-git.md +0 -100
  110. package/dist/docs/reference/covenant.md +0 -116
  111. package/dist/docs/reference/polydeukes.md +0 -315
  112. package/dist/index.d.ts +0 -22
  113. package/dist/index.js +0 -21
  114. package/dist/init-claude-code.d.ts +0 -52
  115. package/dist/init-claude-code.js +0 -469
  116. package/dist/init-grok.d.ts +0 -51
  117. package/dist/init-grok.js +0 -242
@@ -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 change-set 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 change-set 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`은 생성한 설정 파일을 기준으로 기본 경로의 스키마를 찾을 수 있을 때만 스키마 줄을
40
+ 넣습니다. `pdks-claude-code init`이 이 명령을 대신 실행합니다. 이 줄이 없다면 스키마 위치에 맞춰 상대 경로를 직접 추가하세요.
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
+ | 항목의 `enforce: advise`(또는 적지 않음) | 권고를 기록하고 호출을 진행합니다. 종료 코드 0입니다. |
76
+ | 항목의 `enforce: block` | 판정한 호출을 거부합니다. 종료 코드 2입니다. |
77
+
78
+ **적지 않으면 `advise`입니다.** 설정에는 표면 단위의 강제 수준 키가 없습니다. 강제 수준은
79
+ 각 항목이 가지며 적지 않은 항목을 승격하는 설정도 없습니다. 설정된 경로의 보호는 이 항목별
80
+ 기본값과 별개입니다. 세션 표면에서는 차단하고, 변경 집합 표면에서는 명령을 `--enforce block`으로
81
+ 실행하지 않는 한 `advised`로 기록합니다. 조립 단계에서 오류가 나면 종료 코드 2를
82
+ 반환합니다.
83
+
84
+ `protectedPaths`는 두 표면에 모두 적용하는 최상위 목록 하나입니다. 변경 집합 표면에서 판정기는
85
+ 종료 코드만 내므로, 커밋을 멈출지는 훅 배선이 정합니다.
86
+ [표면 연결과 증인](./connect-surfaces.ko.md#witness-and-recovery)에서 자세히 설명합니다.
87
+
88
+ <a id="confirm-the-project"></a>
89
+ ## 설정 확인하기
90
+
91
+ - `pdks explain`은 설정을 읽고 등록된 항목을 보여 줍니다. 변경을 판정하지는 않습니다.
92
+ - `git diff HEAD | pdks covenant check --diff`는 아직 커밋하지 않은 변경 전부를 판정합니다.
93
+ - `git diff --cached | pdks covenant check --diff`는 스테이징한 변경을 관측합니다. pre-commit
94
+ 훅이 쓰는 형태입니다. 이 명령은 사람에게 묻지 않고 종료 코드 0 또는 2만 내며, 커밋을
95
+ 멈출지는 훅 배선이 정합니다.
96
+
97
+ 종료 코드와 함께 stderr와 텔레메트리도 확인하세요. 권고나 일부 미판정도 종료 코드 0을
98
+ 반환합니다. 조립에 실패했다면 규율을 시험하기 전에 오류가 지목한 설정이나 빠진 패키지부터
99
+ 확인하세요.
@@ -0,0 +1,98 @@
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` — which `pdks-claude-code init` runs for you — adds the schema line only when the
40
+ default path resolves relative to the generated config. If the line is absent, add a relative path
41
+ to the installed schema yourself.
42
+ An unresolvable `$schema` can disable editor validation without displaying an error.
43
+
44
+ If you installed `@polydeukes/core` directly rather than the umbrella, name its copy:
45
+
46
+ ```yaml
47
+ # yaml-language-server: $schema=node_modules/@polydeukes/core/schema/polydeukes.schema.json
48
+ ```
49
+
50
+ That is a file path an editor reads statically. Code that reads the schema at runtime uses the
51
+ exports subpath `@polydeukes/core/schema.json` instead. JSON configurations can use a `$schema`
52
+ property; the loader accepts it but leaves it out of the resolved configuration.
53
+
54
+ <a id="fill-the-language-block"></a>
55
+ ## Fill the language block
56
+
57
+ `languages` must contain at least one entry. Each entry specifies production paths and a
58
+ verification command:
59
+
60
+ ```yaml
61
+ languages:
62
+ typescript:
63
+ productionGlob: 'src/**'
64
+ testCmd: 'pnpm test'
65
+ ```
66
+
67
+ Language names are project-defined keys. Replace the installer's placeholder with meaningful
68
+ paths and a command; deleting the block or leaving it empty makes the configuration invalid.
69
+ Loading this setting does not itself run the command.
70
+
71
+ <a id="choose-advise-or-block"></a>
72
+ ## Choose advise or block
73
+
74
+ | Setting | Effect on a violation |
75
+ |---|---|
76
+ | `enforce: advise` on an entry (or absent) | Record advice and let the call proceed, exit 0. |
77
+ | `enforce: block` on an entry | Refuse the judged call, exit 2. |
78
+
79
+ **Absent means `advise`.** There is no surface-level enforcement key in the config: each entry
80
+ carries its own level and nothing promotes an absent one. Protection of configured paths is
81
+ separate from that per-entry default — it blocks on the session surface, and on the change-set
82
+ surface it lands `advised` unless the command is run with `--enforce block`. Assembly errors
83
+ still exit 2.
84
+
85
+ `protectedPaths` is a single top-level list that applies to both surfaces. On the change-set
86
+ surface the judge only emits the exit code; whether the commit stops is your hook wiring.
87
+ See [surface connection and witnesses](./connect-surfaces.md#witness-and-recovery).
88
+
89
+ <a id="confirm-the-project"></a>
90
+ ## Confirm the project
91
+
92
+ - `pdks explain` loads the configuration and shows registrations without judging a change.
93
+ - `git diff HEAD | pdks covenant check --diff` judges everything not yet committed.
94
+ - `git diff --cached | pdks covenant check --diff` observes staged changes — the pre-commit shape.
95
+ The command never prompts; it exits 0 or 2 and your hook wiring decides the commit's fate.
96
+
97
+ Check stderr and telemetry as well as the exit code. Advice and some skipped observations exit 0.
98
+ If assembly fails, diagnose the named configuration or missing package before testing a discipline.
@@ -0,0 +1,120 @@
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
16
+ @polydeukes/adapter-claude-code`. 일회성 `npx` 실행만으로는 부족합니다. 두 표면 모두
17
+ 프로젝트에 설치된 패키지에서 판정기를 불러옵니다.
18
+ 2. 프로젝트 루트에서 배선합니다. `pnpm exec pdks-claude-code init`. 이 실행 파일은 어댑터가
19
+ 제공하며, 먼저 `pdks init`으로 초기 파일을 만든 뒤 Claude Code 등록 산출물을 씁니다.
20
+ 3. 생성된 훅, 병합된 설정, 초기 설정 파일, 문서 안내와 `discipline-draft` 스킬을 확인합니다.
21
+ 4. 훅이 바뀌면 프로젝트를 다시 엽니다. 생성된 훅은 패키지에 판정을 위임하므로 패키지를
22
+ 갱신할 때 훅 파일까지 다시 쓸 필요는 없습니다.
23
+
24
+ 설치기는 `.claude/settings.json`을 덮어쓰지 않고 병합합니다. 기존 훅과 권한은 보존합니다.
25
+ `.claude/rules/polydeukes.md`에는 웹 검색 대신 설치된 `pdks docs`를 조회하도록 안내하고,
26
+ `.claude/skills/discipline-draft/SKILL.md`에는 문제를 선언이나 초안으로 등록하는 절차를
27
+ 제공합니다.
28
+
29
+ <a id="grok"></a>
30
+ ## Grok 세션 표면
31
+
32
+ Grok에서 개발할 때 씁니다.
33
+
34
+ 1. 두 패키지를 프로젝트 의존성으로 설치합니다. `pnpm add -D polydeukes @polydeukes/adapter-grok`.
35
+ 2. 프로젝트 루트에서 배선합니다. `pnpm exec pdks-grok init`. 어댑터가 이 실행 파일을
36
+ 제공합니다. 먼저 `pdks init`으로 초기 파일을 만든 뒤 Grok 등록 산출물을 씁니다.
37
+ 3. 설치가 끝나면 Hooks 탭을 다시 불러오거나 새 세션을 엽니다.
38
+
39
+ Grok 프로젝트에는 `.grok/hooks/` 아래에 훅 JSON과 위임자가 생깁니다. 새 등록의 제한 시간은
40
+ 60초입니다. Grok 호스트의 기본값은 5초이며, 훅 실행이 시간 초과로 끝나면 해당 호출을
41
+ 차단하지 않습니다(fail-open). 두 세션 어댑터를 한 프로젝트에 함께 설치하면 호출마다
42
+ 판정기가 두 번 실행될 수 있습니다.
43
+
44
+ Grok는 세션 증인(witness) 밸브에 필요한 Claude 형식의 인간 메시지를 공급하지 않습니다. 대화
45
+ 기록은 Claude JSONL이 아니라 ACP `updates.jsonl`입니다.
46
+ 의도한 편집이 차단되면 자신의 터미널에서 수행하세요. 변경 집합 표면에는 증인 프롬프트가 없으므로
47
+ 차단된 Grok 도구 호출을 커밋 쪽에서 허용할 방법도 없습니다.
48
+
49
+ <a id="change-set-surface"></a>
50
+ ## 변경 집합 표면
51
+
52
+ 스테이징한 변경을 이력으로 기록하기 전에 Git에서 판정하려면 이 표면을 사용합니다.
53
+
54
+ 1. 프로젝트 루트에 `polydeukes.config.yaml`을 만듭니다.
55
+ 2. pre-commit 훅을 추가합니다.
56
+ 3. 필요할 때는 `git diff HEAD | pnpm exec pdks covenant check --diff`를 직접 돌려 같은
57
+ 판정을 봅니다.
58
+
59
+ lefthook 예시는 다음과 같습니다. `git diff`의 플래그는 판정기가 받는 것을 고정합니다. 색 코드
60
+ 없음, 외부 diff 드라이버 없음, textconv 변환 없음, 번역기가 벗기는 `a/`·`b/` 접두입니다. 사용자의
61
+ git 설정이 관측을 바꾸지 못합니다(CLI 레퍼런스 참고).
62
+
63
+ ```yaml
64
+ pre-commit:
65
+ commands:
66
+ covenant:
67
+ priority: 1
68
+ run: git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
69
+ ```
70
+
71
+ husky 예시는 다음과 같습니다.
72
+
73
+ ```sh
74
+ # .husky/pre-commit
75
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
76
+ ```
77
+
78
+ 일반 git 훅으로 연결해도 됩니다.
79
+
80
+ ```sh
81
+ #!/bin/sh
82
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
83
+ ```
84
+
85
+ 일반 훅은 `.git/hooks/pre-commit`으로 저장한 뒤 `chmod +x .git/hooks/pre-commit`으로
86
+ 실행 권한을 줍니다. 기존 훅이 있다면 덮어쓰지 말고 호출을 추가하세요. lefthook은 패키지
87
+ 관리자로 설치하고 YAML을 저장한 뒤 훅 설치 명령을 실행합니다. husky는 git이 찾을 수 있도록
88
+ husky 설치기로 `.husky/pre-commit`을 저장하세요.
89
+
90
+ 판정기는 종료 코드 0 또는 2만 내고 사람에게 묻지 않습니다. 기본값에서는 `protectedPaths`
91
+ 위반을 포함한 이 표면의 모든 위반이 stderr에 진단 한 줄을 남기고 행으로 기록되며 종료
92
+ 코드 0입니다. 스테이징된 관문 파일 변경은 이미 세션 표면에서 판정을 받았거나 사람이 직접
93
+ 한 것이고, 이 표면에는 사람이 답할 밸브가 없기 때문입니다. `protectedPaths` 위반이나
94
+ `enforce: block` 항목의 위반을 종료 코드 2로 받으려면 명령에 `--enforce block`을 붙입니다.
95
+ 커밋을 멈출지는 훅 배선이 정합니다. 위 예시는 종료 코드를 그대로 따릅니다. 조립 실패는
96
+ 언제나 종료 코드 2입니다.
97
+
98
+ <a id="witness-and-recovery"></a>
99
+ ## 증인과 회복
100
+
101
+ 증인 토큰은 두 표면에서 같은 뜻이지만 전달 방식은 다릅니다.
102
+
103
+ - 세션 표면에서는 대화 메시지 첫 줄에 토큰만 단독으로 넣습니다.
104
+ - 변경 집합 표면에는 프롬프트가 없습니다. 판정은 종료 코드로 전달되고, 그것으로 무엇을 할지는
105
+ 훅 배선이 정합니다.
106
+
107
+ 밸브는 판정 결과가 차단일 때 확인합니다. 의도한 편집 전에 토큰을 입력해도 되며, 먼저
108
+ 실패하는 요청을 보낼 필요는 없습니다. 정상 판정은 바꾸지 않고, 현재 Grok 대화 기록
109
+ 형식에서는 세션 밸브를 사용할 수 없습니다.
110
+
111
+ Grok가 훅을 아직 읽지 못했다면 Hooks 탭을 다시 불러오거나 새 세션을 여세요. 판정기를 적재할 수 없다면 패키지를 다시 설치하거나 워크스페이스를 다시 빌드한 뒤
112
+ 시도하세요.
113
+
114
+ <a id="what-to-check"></a>
115
+ ## 배선한 뒤 확인할 것
116
+
117
+ - `pdks explain`은 각 표면이 어떤 등록을 조립했는지 보여 줍니다.
118
+ - `.polydeukes/roi.log`는 표면이 남긴 행을 기록합니다.
119
+ - `git diff HEAD | pdks covenant check --diff`는 작업 뒤에 쓰기 좋은 즉시 확인 명령입니다.
120
+ - `git diff <base>..<head> | pdks covenant check --diff`는 PR 전에 쓰기 좋은 형태입니다.
@@ -0,0 +1,121 @@
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 change-set 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 change-set surface when history
10
+ is about 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 both packages as project dependencies: `pnpm add -D polydeukes
18
+ @polydeukes/adapter-claude-code`. A one-off `npx` run is not enough — both surfaces load the
19
+ judge from the project's own installed package.
20
+ 2. Wire the project from its root: `pnpm exec pdks-claude-code init`. The adapter ships this bin;
21
+ it runs `pdks init` for the scaffold, then writes the Claude Code registration artifacts.
22
+ 3. Keep the generated hook file, settings merge, starter config, discovery rule, and
23
+ discipline-draft skill.
24
+ 4. Reopen the project when the hook changes. The generated hook is a delegator, so upgrading the
25
+ package upgrades the judge without rewriting the hook file.
26
+
27
+ The installer writes `.claude/settings.json` only by merging. Existing hooks and permissions stay in
28
+ place. It also writes `.claude/rules/polydeukes.md`, which tells the agent to use `pdks docs`
29
+ instead of searching the web, and `.claude/skills/discipline-draft/SKILL.md`, which turns a
30
+ described problem into either a judged entry or a draft entry.
31
+
32
+ <a id="grok"></a>
33
+ ## Grok session surface
34
+
35
+ Use this when the project is developed in Grok.
36
+
37
+ 1. Install both packages as project dependencies: `pnpm add -D polydeukes @polydeukes/adapter-grok`.
38
+ 2. Wire the project from its root: `pnpm exec pdks-grok init`. The adapter ships this bin; it
39
+ runs `pdks init` for the scaffold, then writes the Grok registration artifacts.
40
+ 3. Reload the Hooks tab or open a new session after the installer finishes.
41
+
42
+ A Grok tree gets its own hook JSON and delegator under `.grok/hooks/`. Generated registrations
43
+ use a timeout of 60 seconds. The Grok host default is 5 seconds, and a timed-out hook fails
44
+ open. Installing both session adapters in one project can run the judge twice per call.
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. The change-set surface has no prompt, so
49
+ there is no way to authorize a blocked Grok tool call from that side either.
50
+
51
+ <a id="change-set-surface"></a>
52
+ ## Change-set 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 `git diff HEAD | pnpm exec pdks covenant check --diff` when you want the same judgment
59
+ on demand.
60
+
61
+ A minimal lefthook entry looks like this. The `git diff` flags pin what the judge receives:
62
+ no color codes, no external diff driver, no textconv rewrite, and the `a/`/`b/` prefixes the
63
+ translator strips — a user's git config cannot change the observation (see the CLI reference).
64
+
65
+ ```yaml
66
+ pre-commit:
67
+ commands:
68
+ covenant:
69
+ priority: 1
70
+ run: git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
71
+ ```
72
+
73
+ A husky hook looks like this:
74
+
75
+ ```sh
76
+ # .husky/pre-commit
77
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
78
+ ```
79
+
80
+ A plain git hook works too:
81
+
82
+ ```sh
83
+ #!/bin/sh
84
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
85
+ ```
86
+
87
+ If you use the plain hook, save it as `.git/hooks/pre-commit` and make it executable with
88
+ `chmod +x .git/hooks/pre-commit`. Integrate with an existing hook instead of overwriting it.
89
+ For lefthook, install it with your package manager and run its hook installer after saving the YAML.
90
+ For husky, save `.husky/pre-commit` through husky's own installer so git can find it.
91
+
92
+ The judge emits exit 0 or exit 2 and never prompts. By default every break on this surface — a
93
+ `protectedPaths` violation included — lands as a row with a diagnostic on stderr and exit 0: a
94
+ staged gate-file change has already passed the session surface or was made by a human, and
95
+ this surface has no valve a human could answer. Add `--enforce block` to the command when you
96
+ want a `protectedPaths` violation or an entry set to `enforce: block` to exit 2. Whether a commit
97
+ stops is your hook wiring: the entries above honour the exit code. Assembly errors always exit 2.
98
+
99
+ <a id="witness-and-recovery"></a>
100
+ ## Witness and recovery
101
+
102
+ The witness token is the same idea on both surfaces, but the delivery is different.
103
+
104
+ - On the session surface, type the token on its own first line in a conversation message.
105
+ - The change-set surface has no prompt. Its judgment reaches you as an exit code, and your hook
106
+ wiring decides what to do with it.
107
+
108
+ The valve is consulted after the judgment returns a block. You can supply the token before an
109
+ intentional edit; a previous failed attempt is not required. It does not change a passing verdict
110
+ and the session valve does not work with Grok's current transcript format.
111
+
112
+ If the hook was not picked up in Grok, reload the Hooks tab or start a new session. If the judge
113
+ cannot be loaded, reinstall the package or rebuild the workspace and try again.
114
+
115
+ <a id="what-to-check"></a>
116
+ ## What to check after wiring
117
+
118
+ - `pdks explain` shows which registrations each surface assembled.
119
+ - `.polydeukes/roi.log` records the rows that the surfaces wrote.
120
+ - `git diff HEAD | pdks covenant check --diff` is a good on-demand check after a task.
121
+ - `git diff <base>..<head> | pdks covenant check --diff` is the shape to use before a PR.