polydeukes 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +11 -4
- package/README.md +21 -5
- package/dist/baseline.d.ts +82 -0
- package/dist/baseline.js +166 -0
- package/dist/bin.d.ts +5 -6
- package/dist/bin.js +92 -38
- package/dist/claude-code-hook.d.ts +40 -17
- package/dist/claude-code-hook.js +187 -175
- package/dist/claude-code.d.ts +6 -0
- package/dist/claude-code.js +6 -0
- package/dist/covenant-check.d.ts +50 -36
- package/dist/covenant-check.js +167 -193
- package/dist/covenant-module.d.ts +25 -0
- package/dist/covenant-module.js +42 -0
- package/dist/docs/configuration.md +17 -9
- package/dist/docs/installation.md +42 -12
- package/dist/docs/reference/adapter-claude-code.md +6 -4
- package/dist/docs/reference/adapter-git.md +23 -10
- package/dist/docs/reference/configuration.md +265 -103
- package/dist/docs/reference/core.md +15 -7
- package/dist/docs/reference/covenant.md +32 -24
- package/dist/docs/reference/polydeukes.md +132 -32
- package/dist/docs/troubleshooting.md +37 -8
- package/dist/docs-query.d.ts +10 -10
- package/dist/docs-query.js +12 -12
- package/dist/explain.d.ts +25 -0
- package/dist/explain.js +153 -0
- package/dist/index.d.ts +11 -16
- package/dist/index.js +10 -15
- package/dist/init-claude-code.d.ts +31 -18
- package/dist/init-claude-code.js +254 -40
- package/dist/init-grok.d.ts +51 -0
- package/dist/init-grok.js +242 -0
- package/dist/load-config.d.ts +17 -15
- package/dist/load-config.js +13 -12
- package/dist/pre-state-reader.d.ts +22 -0
- package/dist/pre-state-reader.js +32 -0
- package/dist/scaffold-project.d.ts +23 -14
- package/dist/scaffold-project.js +97 -32
- package/dist/schema/polydeukes.schema.json +54 -81
- package/package.json +7 -7
package/dist/explain.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pdks explain` — render both surfaces' assembled registration sets without judging.
|
|
3
|
+
*
|
|
4
|
+
* This module calls the composition roots' OWN assembly functions and renders what they
|
|
5
|
+
* return, so it reports the table the judgment uses rather than a second opinion about it.
|
|
6
|
+
*
|
|
7
|
+
* It never dispatches, never writes telemetry or a baseline, and never opens a transcript
|
|
8
|
+
* file — the session assembly receives core's `noopTranscript`, which answers queries with
|
|
9
|
+
* nothing and reads no disk. Every failure throws: an answer that cannot be given is never
|
|
10
|
+
* given halfway.
|
|
11
|
+
*/
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import { resolveGitAdapterSettings } from '@polydeukes/adapter-git';
|
|
14
|
+
import { AXIS_NAMES, deriveShape, noopTranscript, RELATION_NAMES } from '@polydeukes/core';
|
|
15
|
+
import { assembleSessionRegistrations } from './claude-code-hook.js';
|
|
16
|
+
import { assembleCommitRegistrations } from './covenant-check.js';
|
|
17
|
+
import { loadCovenantModule, resolveCovenantDist } from './covenant-module.js';
|
|
18
|
+
import { loadConfig } from './load-config.js';
|
|
19
|
+
/** The three meta-covenant labels: registrations that protect the judging chain itself. */
|
|
20
|
+
const META_LABELS = new Set(['self-mod', 'shell-mod', 'transcript-mod']);
|
|
21
|
+
/**
|
|
22
|
+
* The description of a declaration entry: its catalogue coordinate (the mechanism, the axes
|
|
23
|
+
* its sources derive, and the relations its entries decide), then what it routes on, how
|
|
24
|
+
* large its two regex lists are, how many sources it names and how many of those carry
|
|
25
|
+
* each non-file kind, whether it carries a valve, and whether the author left a `why`. An
|
|
26
|
+
* absent scope block admits every world.
|
|
27
|
+
*
|
|
28
|
+
* The axes are derived, never read off the declaration: `loadConfig` has already run the
|
|
29
|
+
* declaration through the validator, so the shape here is the one the catalogue admitted.
|
|
30
|
+
*/
|
|
31
|
+
function declareDescription(entry, enforce) {
|
|
32
|
+
const declare = entry.declare;
|
|
33
|
+
const shape = deriveShape(declare);
|
|
34
|
+
const axes = AXIS_NAMES.filter((axis) => shape.axes.has(axis)).join(',');
|
|
35
|
+
const relations = RELATION_NAMES.filter((relation) => shape.relations.has(relation)).join(',');
|
|
36
|
+
const relate = declare.relate.map((relateEntry) => relateEntry.id).join(', ');
|
|
37
|
+
const scope = declare.scope === undefined ? 'scope every world' : `scope ${declare.scope.source}`;
|
|
38
|
+
const include = declare.scope?.include?.length ?? 0;
|
|
39
|
+
const exclude = declare.scope?.exclude?.length ?? 0;
|
|
40
|
+
const bindings = Object.values(declare.sources ?? {});
|
|
41
|
+
// A file binding is the unmarked kind, so only the two the surface has to supply are
|
|
42
|
+
// counted out; a kind nothing binds is left off rather than printed as a zero.
|
|
43
|
+
const kinds = ['sidecar', 'transcript']
|
|
44
|
+
.map((kind) => ({ kind, count: bindings.filter((binding) => kind in binding).length }))
|
|
45
|
+
.filter(({ count }) => count > 0)
|
|
46
|
+
.map(({ kind, count }) => `${kind} ${count}`);
|
|
47
|
+
const counted = kinds.length === 0 ? '' : ` (${kinds.join(', ')})`;
|
|
48
|
+
const sources = `sources ${bindings.length}${counted}`;
|
|
49
|
+
const valve = declare.witness === undefined ? '—' : '✓';
|
|
50
|
+
const why = entry.why === undefined ? '—' : '✓';
|
|
51
|
+
return (`${declare.mechanism} · ${axes} · ${relations} ${relate} · ${scope} · ` +
|
|
52
|
+
`include ${include} · exclude ${exclude} · ${sources} · valve ${valve} · why ${why}${enforce}`);
|
|
53
|
+
}
|
|
54
|
+
/** One rendered line: the kind column, the label column, then the description. */
|
|
55
|
+
function row(kind, label, width, description) {
|
|
56
|
+
return ` ${kind.padEnd(8)} ${label.padEnd(width)} ${description}`;
|
|
57
|
+
}
|
|
58
|
+
/** The description of a meta-covenant registration — how much surface it covers. */
|
|
59
|
+
function metaDescription(registration, surface) {
|
|
60
|
+
if (registration.label === 'transcript-mod') {
|
|
61
|
+
return 'content predicate · conditional: transcript_path';
|
|
62
|
+
}
|
|
63
|
+
return `paths ${registration.protectedPaths.length} (${surface})`;
|
|
64
|
+
}
|
|
65
|
+
/** Render one surface: its header, its tallies, and one line per registration. */
|
|
66
|
+
function renderSurface(spec) {
|
|
67
|
+
const lines = [];
|
|
68
|
+
const width = Math.max(...spec.registrations.map((registration) => registration.label.length), ...spec.drafts.map((draft) => draft.id.length));
|
|
69
|
+
let declare = 0;
|
|
70
|
+
let skip = 0;
|
|
71
|
+
let meta = 0;
|
|
72
|
+
for (const registration of spec.registrations) {
|
|
73
|
+
if (META_LABELS.has(registration.label)) {
|
|
74
|
+
meta += 1;
|
|
75
|
+
const scope = registration.label === 'self-mod' ? spec.selfModScope : 'common';
|
|
76
|
+
lines.push(row('meta', registration.label, width, metaDescription(registration, scope)));
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (registration.skip !== undefined) {
|
|
80
|
+
skip += 1;
|
|
81
|
+
lines.push(row('skip', registration.label, width, registration.skip.reason));
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
// Every non-meta body registration is one config entry's declaration; a label the config
|
|
85
|
+
// does not carry is an assembly the renderer was never told about.
|
|
86
|
+
const entry = spec.disciplines.find((candidate) => candidate.id === registration.label);
|
|
87
|
+
if (entry === undefined) {
|
|
88
|
+
throw new Error(`explain: registration '${registration.label}' matches no config entry`);
|
|
89
|
+
}
|
|
90
|
+
// The DECLARED level is rendered, never the effective one: an omission stays unmarked
|
|
91
|
+
// so the default and an author's explicit choice of it never read alike, and the
|
|
92
|
+
// surface header states what the omission resolves to.
|
|
93
|
+
const level = entry.enforce === undefined ? '' : ` · enforce: ${entry.enforce}`;
|
|
94
|
+
declare += 1;
|
|
95
|
+
lines.push(row('declare', registration.label, width, declareDescription(entry, level)));
|
|
96
|
+
}
|
|
97
|
+
for (const draft of spec.drafts) {
|
|
98
|
+
lines.push(row('draft', draft.id, width, 'unpromoted — no judgment'));
|
|
99
|
+
}
|
|
100
|
+
const tally = ` registrations ${meta + declare + skip} · ` +
|
|
101
|
+
`declare ${declare} · skip ${skip} · meta ${meta} · draft ${spec.drafts.length}`;
|
|
102
|
+
return [spec.header, tally, ...lines].join('\n');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Read the config at `repoRoot`, assemble both surfaces, and render them.
|
|
106
|
+
*
|
|
107
|
+
* The session assembly is given a transcript path, so its `transcript-mod` registration
|
|
108
|
+
* exists here exactly as it does under a normal hook payload — the path is never read,
|
|
109
|
+
* because the injected transcript is the no-op one.
|
|
110
|
+
*/
|
|
111
|
+
export async function explain(spec) {
|
|
112
|
+
const { config, configPath } = loadConfig({ rootDir: spec.repoRoot });
|
|
113
|
+
// Resolved and imported exactly as the two runners do, so what this renders is the table
|
|
114
|
+
// that would judge: a dist those runners would refuse cannot be rendered as if it worked.
|
|
115
|
+
// The load names the missing module and the recovery command.
|
|
116
|
+
const covenant = await loadCovenantModule(resolveCovenantDist());
|
|
117
|
+
const disciplines = config.disciplines ?? [];
|
|
118
|
+
const drafts = config.drafts ?? [];
|
|
119
|
+
const session = assembleSessionRegistrations({
|
|
120
|
+
config,
|
|
121
|
+
rootDir: spec.repoRoot,
|
|
122
|
+
covenant,
|
|
123
|
+
transcriptPath: join(spec.repoRoot, 'transcript.jsonl'),
|
|
124
|
+
transcript: noopTranscript,
|
|
125
|
+
});
|
|
126
|
+
const commit = assembleCommitRegistrations({
|
|
127
|
+
config,
|
|
128
|
+
rootDir: spec.repoRoot,
|
|
129
|
+
covenant,
|
|
130
|
+
});
|
|
131
|
+
const gitSettings = resolveGitAdapterSettings({ namespace: config.adapters?.git });
|
|
132
|
+
const text = [
|
|
133
|
+
`pdks explain — ${configPath}`,
|
|
134
|
+
'',
|
|
135
|
+
renderSurface({
|
|
136
|
+
header: 'surface: session (claude-code hook) · disciplines: advise unless enforce: block · meta: block',
|
|
137
|
+
registrations: session,
|
|
138
|
+
drafts,
|
|
139
|
+
disciplines,
|
|
140
|
+
selfModScope: 'common; includes the config file itself',
|
|
141
|
+
}),
|
|
142
|
+
'',
|
|
143
|
+
renderSurface({
|
|
144
|
+
header: `surface: commit (git pre-commit) · enforce: ${gitSettings.enforce} · disciplines: advise unless enforce: block`,
|
|
145
|
+
registrations: commit,
|
|
146
|
+
drafts,
|
|
147
|
+
disciplines,
|
|
148
|
+
selfModScope: 'common ∪ adapters.git; deduped, includes the config file itself',
|
|
149
|
+
}),
|
|
150
|
+
'',
|
|
151
|
+
].join('\n');
|
|
152
|
+
return { text };
|
|
153
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,25 +3,20 @@
|
|
|
3
3
|
* coding partner.
|
|
4
4
|
*
|
|
5
5
|
* Pre-alpha. This package reserves the unscoped `polydeukes` name and is the umbrella /
|
|
6
|
-
* `pdks` CLI entry point. It owns the config discovery loader
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* `pdks` CLI entry point. It owns the config discovery loader and both surfaces'
|
|
7
|
+
* composition roots — `runCovenantCheck` for the commit surface and `runClaudeCodeHook`
|
|
8
|
+
* for the session one — because assembly needs an adapter and the covenant package at
|
|
9
|
+
* once, which no sibling is allowed to depend on. The covenant, ledger, memory, and verify
|
|
10
|
+
* modules live in their own `@polydeukes/*` packages.
|
|
11
11
|
*
|
|
12
12
|
* This file is a barrel and nothing more. ESM re-exports are eager, so anything defined
|
|
13
|
-
* here would be instantiated by every consumer of any other export
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* here would be instantiated by every consumer of any other export. Keep definitions in
|
|
14
|
+
* their own modules and let importers reach them directly. A session call enters through
|
|
15
|
+
* the published `./claude-code` subpath instead, which keeps the commit surface and its git
|
|
16
|
+
* adapter off that load path.
|
|
16
17
|
*
|
|
17
|
-
* The mirror of that coupling is closed as of DIST-02. `exports` publishes `./claude-code`
|
|
18
|
-
* alongside `"."`, and both delegators — this repository's and the one `pdks init
|
|
19
|
-
* claude-code` generates — enter through it, so a session call no longer instantiates
|
|
20
|
-
* `covenant-check.js` or `@polydeukes/adapter-git`. The window DIST-01 §3-d declared (a
|
|
21
|
-
* workspace missing only that dist failing closed with no telemetry row) is gone with it.
|
|
22
18
|
* See https://github.com/huskyhoochu/polydeukes
|
|
23
19
|
*/
|
|
24
20
|
export type { ResolvedConfig } from '@polydeukes/core';
|
|
25
|
-
export { type
|
|
26
|
-
export { type
|
|
27
|
-
export { type LoadedConfig, loadConfig } from './load-config.js';
|
|
21
|
+
export { type CheckDomain, type CovenantCheckOutcome, type CovenantCheckSpec, runCovenantCheck, } from './covenant-check.ts';
|
|
22
|
+
export { type LoadConfigSpec, type LoadedConfig, loadConfig } from './load-config.ts';
|
package/dist/index.js
CHANGED
|
@@ -3,24 +3,19 @@
|
|
|
3
3
|
* coding partner.
|
|
4
4
|
*
|
|
5
5
|
* Pre-alpha. This package reserves the unscoped `polydeukes` name and is the umbrella /
|
|
6
|
-
* `pdks` CLI entry point. It owns the config discovery loader
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* `pdks` CLI entry point. It owns the config discovery loader and both surfaces'
|
|
7
|
+
* composition roots — `runCovenantCheck` for the commit surface and `runClaudeCodeHook`
|
|
8
|
+
* for the session one — because assembly needs an adapter and the covenant package at
|
|
9
|
+
* once, which no sibling is allowed to depend on. The covenant, ledger, memory, and verify
|
|
10
|
+
* modules live in their own `@polydeukes/*` packages.
|
|
11
11
|
*
|
|
12
12
|
* This file is a barrel and nothing more. ESM re-exports are eager, so anything defined
|
|
13
|
-
* here would be instantiated by every consumer of any other export
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* here would be instantiated by every consumer of any other export. Keep definitions in
|
|
14
|
+
* their own modules and let importers reach them directly. A session call enters through
|
|
15
|
+
* the published `./claude-code` subpath instead, which keeps the commit surface and its git
|
|
16
|
+
* adapter off that load path.
|
|
16
17
|
*
|
|
17
|
-
* The mirror of that coupling is closed as of DIST-02. `exports` publishes `./claude-code`
|
|
18
|
-
* alongside `"."`, and both delegators — this repository's and the one `pdks init
|
|
19
|
-
* claude-code` generates — enter through it, so a session call no longer instantiates
|
|
20
|
-
* `covenant-check.js` or `@polydeukes/adapter-git`. The window DIST-01 §3-d declared (a
|
|
21
|
-
* workspace missing only that dist failing closed with no telemetry row) is gone with it.
|
|
22
18
|
* See https://github.com/huskyhoochu/polydeukes
|
|
23
19
|
*/
|
|
24
|
-
export {
|
|
25
|
-
export { runCovenantCheck } from './covenant-check.js';
|
|
20
|
+
export { runCovenantCheck, } from './covenant-check.js';
|
|
26
21
|
export { loadConfig } from './load-config.js';
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `initClaudeCode` — the session-surface installer
|
|
2
|
+
* `initClaudeCode` — the session-surface installer.
|
|
3
3
|
*
|
|
4
4
|
* One command wires a project into the session surface: prove the package resolves, run the
|
|
5
5
|
* shared project-side scaffold ({@link scaffoldProject}), then add what this distribution
|
|
6
|
-
* path owns — the delegator hook file, its `.claude/settings.json` registration,
|
|
7
|
-
* discipline file that tells an agent the docs query exists
|
|
6
|
+
* path owns — the delegator hook file, its `.claude/settings.json` registration, the
|
|
7
|
+
* discipline file that tells an agent the docs query exists, and the classification skill
|
|
8
|
+
* that turns a described problem into a config entry.
|
|
8
9
|
*
|
|
9
|
-
* Preflight comes first and nothing is written before it clears
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Preflight comes first and nothing is written before it clears. A generated hook whose
|
|
11
|
+
* import can never resolve blocks every call through its own fail-closed catch, and a tree
|
|
12
|
+
* that also has no config and no valve to open cannot be edited back into shape from inside
|
|
13
|
+
* the session.
|
|
13
14
|
*
|
|
14
|
-
* Nothing existing is overwritten
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Nothing existing is overwritten. The settings file in particular is merged, never
|
|
16
|
+
* replaced: a consumer's other PreToolUse registrations and permissions are live
|
|
17
|
+
* configuration, and replacing them would disarm every other tool they wired. A grok JSON
|
|
18
|
+
* whose command still names the grok mjs is rewritten to this hook's command so the two
|
|
19
|
+
* installers do not leave two spawn strings.
|
|
17
20
|
*/
|
|
18
|
-
import { type ScaffoldReport } from './scaffold-project.
|
|
19
|
-
/**
|
|
21
|
+
import { type ScaffoldReport } from './scaffold-project.ts';
|
|
22
|
+
/**
|
|
23
|
+
* The generated classification skill — the procedure that turns a described problem into a
|
|
24
|
+
* registered entry. A classification procedure an agent never learns about is one that never
|
|
25
|
+
* runs, so it ships as an artifact of the install rather than as prose in a README.
|
|
26
|
+
*
|
|
27
|
+
* Its advise-consumption section is the delivery path for advised rows: the session surface
|
|
28
|
+
* lets an advised call through with exit 0, and the reason never reaches the model at call
|
|
29
|
+
* time — reading the telemetry log at task boundaries is the only way it arrives.
|
|
30
|
+
*/
|
|
31
|
+
export declare const GENERATED_SKILL = "---\nname: discipline-draft\ndescription: Turn a described discipline problem into a registered entry in polydeukes.config \u2014 a judged entry when the current families can express it, a draft entry otherwise. Use when the user describes a recurring problem they want promised away (\"I keep...\", \"stop X from happening\", \"we should never...\", \"how do I enforce Y\").\n---\n\n# discipline-draft \u2014 from a problem description to a registered discipline\n\nThis project is judged by Polydeukes. A discipline starts as prose and climbs a ladder \u2014\n`draft` (registered, read, never judged) \u2192 `advise` (judged, recorded, never stops a call) \u2192\n`block` (stops the call; the user's explicit choice, never the default). This skill walks a\nproblem description down to the right first rung and registers it.\n\n## Procedure\n\n### 1. Restate the problem as a promise\n\nRewrite the description as one sentence of the form \"X must not happen\" or \"when A happens,\nB must also happen\". If the sentence needs \"unless\" more than once, split it into two\npromises and classify each separately.\n\n### 2. Classify the shape\n\nAsk these questions in order; the first yes decides.\n\n| # | Question | Entry key |\n| --- | --- | --- |\n| 1 | Is the promise about content newly ADDED to a file (a pattern that must not appear in new lines)? | `declare` (mechanism `added-only`) |\n| 2 | Is it about a whole path that must not be modified or deleted (creating it once stays allowed)? | `declare` (mechanism `self-absolution-ban`) |\n| 3 | Is it about the shell command line itself, regardless of files? | `declare` (mechanism `forbidden-command`, reading the `command` source) |\n| 4 | Does it require that something else was already done earlier in the session (a tool call that must precede this one)? | `declare` (mechanism `precedent`, reading a `transcript` source) |\n| 5 | None of the above | `draft: true` (step 4b) |\n\nAn `added-only` declaration forgives existing occurrences \u2014 only what the edit adds breaks\nthe promise. That is usually what you want: a discipline adopted today should not indict\nyesterday's code.\n\nOne path-shaped promise takes no `disciplines:` entry at all: a path nobody may touch\nbelongs in the top-level `protectedPaths:` list \u2014 its own config block, never an entry key.\n\n### 3. Check the observation boundary\n\nTwo kinds of promise cannot be judged here, whatever their shape:\n\n- **Destruction outside the repository** \u2014 judgment observes the project root only. Register\n nothing; use the agent's own permission deny policy for commands like `rm -rf ~`.\n- **Writes by child processes** \u2014 a test runner or script writing files is invisible to the\n session surface, which judges declared tool calls only. Say so to the user; the commit\n surface will still see the result as a staged diff.\n\n### 4a. Expressible now \u2014 register a judged entry\n\nAdd the entry to the `disciplines:` array in `polydeukes.config.yaml`. Advise is the default\nlanding \u2014 a break is recorded as `advised` and the call goes on \u2014 and the `enforce: advise`\nline below only spells that default out. NEVER write `enforce: block` from this skill:\npromotion to block is the user's own choice, made after the advise measurements have been\nread.\n\nThe examples below are whole documents, so `languages:` \u2014 the schema's one required block \u2014\nappears alongside the entry; in a config that already has one, copy the entry only.\n\n```yaml\nlanguages:\n placeholder:\n productionGlob: 'src/**'\n testCmd: 'echo \"set a verification command for {scope}\"'\ndisciplines:\n - id: 'no-focused-tests'\n why: 'a committed .only silently shrinks the suite to one test'\n declare:\n mechanism: 'added-only'\n scope: { source: 'target.path', include: ['^src/'] }\n supply: { pre: 'empty', post: 'empty' }\n extract:\n before:\n - { op: 'source', of: 'pre' }\n - { op: 'lines' }\n - { op: 'keyByPattern', re: '(\\.only\\()' }\n after:\n - { op: 'source', of: 'post' }\n - { op: 'lines' }\n - { op: 'keyByPattern', re: '(\\.only\\()' }\n added:\n - { op: 'onlyIn', of: 'after', notIn: 'before' }\n relate:\n - id: 'nothing-added'\n relation: { op: 'empty', of: 'added' }\n message: 'adds {key}: {value}'\n enforce: advise\n```\n\nA command-line ban reads the fixed source `command` and scopes on it \u2014 the scope is part of\nthe mechanism's shape, so a `forbidden-command` entry without it is refused at load time:\n\n```yaml\nlanguages:\n placeholder:\n productionGlob: 'src/**'\n testCmd: 'echo \"set a verification command for {scope}\"'\ndisciplines:\n - id: 'no-force-push'\n why: 'a force push rewrites history nobody reviewed'\n declare:\n mechanism: 'forbidden-command'\n scope: { source: 'command' }\n extract:\n hits:\n - { op: 'source', of: 'command' }\n - { op: 'lines' }\n - { op: 'matches', re: 'git push\\\\b.*--force(?![\\\\w-])' }\n relate:\n - { id: 'no-force', relation: { op: 'empty', of: 'hits' }, message: '{value}' }\n enforce: advise\n```\n\n**Write the regex yourself \u2014 the user states the promise, you author the pattern.** The\npattern is the part users find hardest, so never hand the prose back and ask for one. Three\nauthoring traps, each measured on a live config:\n\n- **A pattern answers a syntactic question only.** \"Is this string a forbidden word\" is\n syntax; \"is this a new dependency version\" is meaning, and a regex leaks both ways on a\n semantic question. When the question is semantic, narrow the declaration's own `scope`\n block to the files where any match IS a break, or accept \"editing this file at all\" as\n the trigger.\n- **`^` means what the preceding step left.** After a `lines` step a declaration's\n pattern sees one line at a time, so `^` anchors to that line; over an unsplit source it\n anchors to the whole text and matches the first line only. A ban over the command line\n puts `lines` before its `matches` for exactly that reason.\n- **Author both directions.** Before registering, write down one string the pattern must\n match and one nearby string it must not (`only(` vs `only_helper(`, a flag vs its\n substring). A pattern checked in only the breaking direction over-fires in review-proof\n ways.\n\n### 4b. Not expressible yet \u2014 register a draft\n\nA draft is prose with a handle: `id`, `why`, and the literal marker `draft: true` \u2014 no other\nkeys. It produces no judgment and no telemetry; `pdks explain` lists it as unpromoted.\nRecord the SHAPE of the promise inside `why`, so the promotion destination is already\nwritten down when a later engine can express it. Name the shape in these terms:\n\n| Shape | The promise reads like |\n| --- | --- |\n| pairing | every element of set A has a counterpart in set B (translation keys, i18n) |\n| companion | if X appears in a unit, Y must appear with it |\n| ordered | a sequence must keep its order (migration journals, version ladders) |\n| fingerprint | a derived artifact must match the hash/stamp of its source |\n| producer-owned | only a designated generator may write this artifact |\n| self-absolution | the party being judged must not write its own verdict field |\n| actor-scope | the same action is fine for one actor and a break for another |\n| phase-order | several precedents, in a fixed order |\n| turn-locality | the evidence must be in the same turn or time window |\n| stated-ground | the reason must be written down before the action |\n| controlled-vocabulary | only an enumerated set of words/values is allowed |\n| naming-convention | names must match a pattern per kind |\n| irreversible-marker | once present, a marker may never be removed |\n| delegation-scope | a delegated task may touch only its granted scope |\n| scope-valve | a defined exception valve, judged rather than ad hoc |\n| claim-verification | the claim must be re-run/measured, not trusted |\n\n```yaml\nlanguages:\n placeholder:\n productionGlob: 'src/**'\n testCmd: 'echo \"set a verification command for {scope}\"'\ndisciplines:\n - id: 'locale-files-move-together'\n why: 'pairing \u2014 en.json and ko.json must change in the same commit; one side alone is a break'\n draft: true\n```\n\n### 5. Prove it fires, then close\n\nRun `pdks explain` and confirm the new entry is listed (a judged entry with its mechanism\nand surfaces; a draft as unpromoted).\n\nFor a judged entry, registration is not the finish \u2014 a pattern that never fires protects\nnothing while looking installed. Fire it once for real, with the proof run the declaration's\nown mechanism can actually reach:\n\n| Mechanism | Break it once | The entry's id shows up in |\n| --- | --- | --- |\n| a file-reading one (`added-only`, `naming`, \u2026) | one scratch edit matching the must-match direction | `pdks covenant check --worktree` output \u2014 the exit stays 0 at advise, the id is the proof |\n| `forbidden-command` | run one harmless command matching the pattern | the telemetry log tail \u2014 at advise the call proceeds and its row records the id |\n| `precedent` | one in-scope edit made without the required precedent | the telemetry log tail \u2014 a declaration reading the session judges on the session surface only (the commit surface has none, so its `supply` policy records it `skipped`) |\n\nThen undo the scratch break, repeat the same run, and confirm silence on the\nmust-NOT-match direction. Close by telling the user which rung the entry landed on and\nthat `enforce: block` is theirs to add later if the advise record earns it.\n\n## Reading the advise record\n\nAn `advised` row means a promise was broken and the call went through anyway. Rows land in\nthe telemetry log at the path configured by `telemetry.logPath` (default\n`.polydeukes/roi.log`). The hook's stderr note is not shown to you, so consult the log at\ntask boundaries: before committing, or after a batch of edits, read the tail and act on any\n`advised` row \u2014 fix the break, or tell the user why it should stand. An advisory nobody\nreads measures nothing.\n";
|
|
32
|
+
/** `initClaudeCode` input — the target tree and the preflight seam. */
|
|
20
33
|
export type InitClaudeCodeSpec = {
|
|
21
34
|
/** Project root to install into — every write below is relative to it. */
|
|
22
35
|
projectRoot: string;
|
|
23
36
|
/**
|
|
24
|
-
*
|
|
37
|
+
* Preflight seam: throws when the package cannot be resolved from the given root.
|
|
25
38
|
* ABSENT uses the real resolution, anchored at that root and nowhere else — anchoring it
|
|
26
39
|
* at the installer's own module would answer for the installer's install graph rather
|
|
27
40
|
* than the target project's, which is precisely the case that must fail.
|
|
@@ -29,11 +42,11 @@ export type InitClaudeCodeSpec = {
|
|
|
29
42
|
resolvePolydeukes?: (projectRoot: string) => void;
|
|
30
43
|
};
|
|
31
44
|
/**
|
|
32
|
-
* Install the session surface into `spec.projectRoot
|
|
33
|
-
*
|
|
45
|
+
* Install the session surface into `spec.projectRoot`, skipping whatever is already there
|
|
46
|
+
* and reporting both halves per artifact.
|
|
34
47
|
*
|
|
35
|
-
* Throws before any write when the package cannot be resolved from that root
|
|
36
|
-
*
|
|
37
|
-
*
|
|
48
|
+
* Throws before any write when the package cannot be resolved from that root or when two
|
|
49
|
+
* config spellings already coexist there — both leave zero files. Translating a throw into
|
|
50
|
+
* exit 2 with the install command is the bin's job.
|
|
38
51
|
*/
|
|
39
52
|
export declare function initClaudeCode(spec: InitClaudeCodeSpec): ScaffoldReport;
|