@polydeukes/core 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.
- package/README.ko.md +50 -32
- package/README.md +50 -32
- package/dist/algebra.d.ts +174 -0
- package/dist/algebra.js +438 -0
- package/dist/catalogue.d.ts +69 -0
- package/dist/catalogue.js +191 -0
- package/dist/config.d.ts +15 -42
- package/dist/config.js +26 -164
- package/dist/exit-codes.d.ts +3 -3
- package/dist/exit-codes.js +3 -3
- package/dist/index.d.ts +10 -94
- package/dist/index.js +4 -53
- package/dist/is-plain-object.d.ts +3 -0
- package/dist/is-plain-object.js +3 -0
- package/dist/protocol.d.ts +152 -0
- package/dist/protocol.js +121 -0
- package/dist/source-names.d.ts +10 -0
- package/dist/source-names.js +18 -0
- package/dist/telemetry.d.ts +32 -5
- package/dist/telemetry.js +59 -8
- package/dist/transcript.d.ts +2 -9
- package/dist/transcript.js +1 -6
- package/dist/validation.d.ts +24 -0
- package/dist/validation.js +44 -0
- package/package.json +3 -2
- package/schema/algebra-declaration.schema.json +402 -0
- package/schema/polydeukes.schema.json +38 -91
package/README.ko.md
CHANGED
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
# `@polydeukes/core`
|
|
2
|
+
|
|
3
|
+
[English](./README.md) · **한국어**
|
|
4
|
+
|
|
5
|
+
`core` 패키지는 공통 어휘를 정의합니다. 판정기와 어댑터가 함께 쓰는 약속(covenant)
|
|
6
|
+
프로토콜, 설정 검증, 텔레메트리 도우미, 공유 타입을 제공합니다.
|
|
7
|
+
|
|
8
|
+
<a id="overview"></a>
|
|
9
|
+
## 개요
|
|
10
|
+
|
|
11
|
+
공개 계약 심볼은 다음과 같습니다.
|
|
12
|
+
|
|
13
|
+
- `defineConfig`
|
|
14
|
+
- `parseInput`
|
|
15
|
+
- `verdictToExitCode`
|
|
16
|
+
- `normalizeProtectedPaths`
|
|
17
|
+
- `appendRecordFailOpen`
|
|
18
|
+
- `readRecords`
|
|
19
|
+
- `noopTranscript`
|
|
20
|
+
- `ResolvedConfig`
|
|
21
|
+
- `CovenantInput`
|
|
22
|
+
- `CovenantVerdict`
|
|
23
|
+
- `EXIT_UPHOLD`
|
|
24
|
+
- `EXIT_BREAK_NON_BLOCKING`
|
|
25
|
+
- `EXIT_BREAK_BLOCKING`
|
|
26
|
+
|
|
27
|
+
<a id="examples"></a>
|
|
28
|
+
## 예제
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { defineConfig, parseInput } from '@polydeukes/core';
|
|
32
|
+
|
|
33
|
+
const config = defineConfig({
|
|
34
|
+
languages: {
|
|
35
|
+
typescript: {
|
|
36
|
+
productionGlob: 'packages/*/src/**/*.ts',
|
|
37
|
+
testCmd: 'pnpm --filter {scope} test',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const payload = parseInput('{"toolCalls":[],"subagentSpawns":[],"userMessages":[]}');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
<a id="see-also"></a>
|
|
46
|
+
## 같이 보기
|
|
47
|
+
|
|
48
|
+
- [`@polydeukes/core` 패키지 레퍼런스](../../docs/reference/packages/core.ko.md)
|
|
49
|
+
- [`설정 레퍼런스`](../../docs/reference/configuration/index.ko.md)
|
|
50
|
+
- [`@polydeukes/covenant`](../../docs/reference/packages/covenant.ko.md)
|
package/README.md
CHANGED
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
# `@polydeukes/core`
|
|
2
|
+
|
|
3
|
+
**English** · [한국어](./README.ko.md)
|
|
4
|
+
|
|
5
|
+
The core package is the vocabulary layer. It exports the covenant protocol, config validation,
|
|
6
|
+
telemetry helpers, and shared types used by the judge and adapters.
|
|
7
|
+
|
|
8
|
+
<a id="overview"></a>
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Public contract symbols include:
|
|
12
|
+
|
|
13
|
+
- `defineConfig`
|
|
14
|
+
- `parseInput`
|
|
15
|
+
- `verdictToExitCode`
|
|
16
|
+
- `normalizeProtectedPaths`
|
|
17
|
+
- `appendRecordFailOpen`
|
|
18
|
+
- `readRecords`
|
|
19
|
+
- `noopTranscript`
|
|
20
|
+
- `ResolvedConfig`
|
|
21
|
+
- `CovenantInput`
|
|
22
|
+
- `CovenantVerdict`
|
|
23
|
+
- `EXIT_UPHOLD`
|
|
24
|
+
- `EXIT_BREAK_NON_BLOCKING`
|
|
25
|
+
- `EXIT_BREAK_BLOCKING`
|
|
26
|
+
|
|
27
|
+
<a id="examples"></a>
|
|
28
|
+
## Examples
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { defineConfig, parseInput } from '@polydeukes/core';
|
|
32
|
+
|
|
33
|
+
const config = defineConfig({
|
|
34
|
+
languages: {
|
|
35
|
+
typescript: {
|
|
36
|
+
productionGlob: 'packages/*/src/**/*.ts',
|
|
37
|
+
testCmd: 'pnpm --filter {scope} test',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const payload = parseInput('{"toolCalls":[],"subagentSpawns":[],"userMessages":[]}');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
<a id="see-also"></a>
|
|
46
|
+
## See also
|
|
47
|
+
|
|
48
|
+
- [`@polydeukes/core` package reference](../../docs/reference/packages/core.md)
|
|
49
|
+
- [`Configuration reference`](../../docs/reference/configuration/index.md)
|
|
50
|
+
- [`@polydeukes/covenant`](../../docs/reference/packages/covenant.md)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `algebra.ts` — the shape of one algebra declaration: five blocks, a closed relation
|
|
3
|
+
* position, a closed binary combinator position, and an open unary extraction vocabulary.
|
|
4
|
+
*
|
|
5
|
+
* The module knows no judgment. It runs no extraction and evaluates no relation; the
|
|
6
|
+
* kernel expansion laws quoted on each relation branch below are comments, never code.
|
|
7
|
+
*/
|
|
8
|
+
/** The relation position, closed. This tuple is the single source of the list. */
|
|
9
|
+
export declare const RELATION_NAMES: readonly ['empty', 'nonEmpty', 'equal', 'subset', 'implies', 'ordered', 'unchanged'];
|
|
10
|
+
/** One of the seven relation names — the closed vocabulary of the relation position. */
|
|
11
|
+
export type RelationName = (typeof RELATION_NAMES)[number];
|
|
12
|
+
/** The binary world-combining position, closed. Anything else is a unary step. */
|
|
13
|
+
export declare const BINARY_COMBINATOR_NAMES: readonly ['union', 'onlyIn', 'intersect'];
|
|
14
|
+
/**
|
|
15
|
+
* What a missing source does: refuse the declaration, let it pass unjudged, or read the
|
|
16
|
+
* absence as an empty item list and judge on.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SUPPLY_POLICIES: readonly ['error', 'pass', 'empty'];
|
|
19
|
+
/** The kind position of a `sources` entry, closed. Each entry carries exactly one of them. */
|
|
20
|
+
export declare const SOURCE_KINDS: readonly ['file', 'sidecar', 'transcript'];
|
|
21
|
+
/**
|
|
22
|
+
* `RelationDecl` — the relation position of one relate entry, one branch per name.
|
|
23
|
+
*
|
|
24
|
+
* Every name references extract names declared in the same declaration; `equal` is the
|
|
25
|
+
* only two-sided branch. The kernel expansion quoted on each branch is a comment — the
|
|
26
|
+
* engine owns the semantics, this module only the shape.
|
|
27
|
+
*/
|
|
28
|
+
export type RelationDecl =
|
|
29
|
+
/** `empty` — the extraction produced no element. The primitive. */
|
|
30
|
+
{
|
|
31
|
+
op: 'empty';
|
|
32
|
+
of: string;
|
|
33
|
+
}
|
|
34
|
+
/** `nonEmpty` — expands to ¬empty. */
|
|
35
|
+
| {
|
|
36
|
+
op: 'nonEmpty';
|
|
37
|
+
of: string;
|
|
38
|
+
}
|
|
39
|
+
/** `equal` — expands to subset in both directions; the only two-sided relation. */
|
|
40
|
+
| {
|
|
41
|
+
op: 'equal';
|
|
42
|
+
of: [string, string];
|
|
43
|
+
}
|
|
44
|
+
/** `subset` — `of` ⊆ `in`. The primitive. */
|
|
45
|
+
| {
|
|
46
|
+
op: 'subset';
|
|
47
|
+
of: string;
|
|
48
|
+
in: string;
|
|
49
|
+
}
|
|
50
|
+
/** `implies` — expands to a subset of the two key projections. */
|
|
51
|
+
| {
|
|
52
|
+
op: 'implies';
|
|
53
|
+
of: string;
|
|
54
|
+
requires: string;
|
|
55
|
+
}
|
|
56
|
+
/** `ordered` — adjacent pairs are monotone; `strict` forbids equal neighbours. */
|
|
57
|
+
| {
|
|
58
|
+
op: 'ordered';
|
|
59
|
+
of: string;
|
|
60
|
+
strict?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** `unchanged` — expands to equal over the keys the two states share. */
|
|
63
|
+
| {
|
|
64
|
+
op: 'unchanged';
|
|
65
|
+
of: string;
|
|
66
|
+
};
|
|
67
|
+
/** A binary world combinator — the closed step kind that joins two extractions. */
|
|
68
|
+
export type BinaryStep = {
|
|
69
|
+
op: 'union';
|
|
70
|
+
of: [string, string];
|
|
71
|
+
} | {
|
|
72
|
+
op: 'onlyIn';
|
|
73
|
+
of: string;
|
|
74
|
+
notIn: string;
|
|
75
|
+
} | {
|
|
76
|
+
op: 'intersect';
|
|
77
|
+
of: [string, string];
|
|
78
|
+
};
|
|
79
|
+
/** Open vocabulary — a name outside the three combinators; its arguments pass through. */
|
|
80
|
+
export type UnaryStep = {
|
|
81
|
+
op: string;
|
|
82
|
+
[arg: string]: unknown;
|
|
83
|
+
};
|
|
84
|
+
/** One pipeline step: an open unary step or a closed binary combinator. */
|
|
85
|
+
export type ExtractStep = UnaryStep | BinaryStep;
|
|
86
|
+
/** The `extract` block — named pipelines, each a non-empty step list. */
|
|
87
|
+
export type ExtractBlock = Record<string, ExtractStep[]>;
|
|
88
|
+
/** The `scope` block — which calls a declaration applies to, by constant regex over a source. */
|
|
89
|
+
export type ScopeBlock = {
|
|
90
|
+
source: string;
|
|
91
|
+
include?: string[];
|
|
92
|
+
exclude?: string[];
|
|
93
|
+
excludeIgnoreCase?: boolean;
|
|
94
|
+
};
|
|
95
|
+
/** One supply policy — the closed value position of a `supply` entry. */
|
|
96
|
+
export type SupplyPolicy = (typeof SUPPLY_POLICIES)[number];
|
|
97
|
+
/**
|
|
98
|
+
* The `supply` block — per source name, what its absence does: `error` refuses, `pass` skips,
|
|
99
|
+
* `empty` reads the absence as an empty item list and judges on.
|
|
100
|
+
*/
|
|
101
|
+
export type SupplyBlock = Record<string, SupplyPolicy>;
|
|
102
|
+
/**
|
|
103
|
+
* The `sources` block — per source name, what outside the target it stands for.
|
|
104
|
+
*
|
|
105
|
+
* A `file` path is repo-relative and the supply layer joins it onto the root, which is why an
|
|
106
|
+
* absolute path and a `..` segment are refused here rather than at read time. A `sidecar`
|
|
107
|
+
* binding names a channel the surface supplies and a `transcript` binding the session's
|
|
108
|
+
* conversation history; the location of either is the host's fact, not the declaration's, so
|
|
109
|
+
* the value is the marker `true` and never a path.
|
|
110
|
+
*/
|
|
111
|
+
export type SourcesBlock = Record<string, {
|
|
112
|
+
file: string;
|
|
113
|
+
} | {
|
|
114
|
+
sidecar: true;
|
|
115
|
+
} | {
|
|
116
|
+
transcript: true;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* `RelateEntry` — one (extract name, relation) pairing with its break text.
|
|
120
|
+
*
|
|
121
|
+
* Exactly one of `message` and `messageBySide`; the latter only on `equal`, the one relation
|
|
122
|
+
* with two sides.
|
|
123
|
+
*/
|
|
124
|
+
export type RelateEntry = {
|
|
125
|
+
id: string;
|
|
126
|
+
relation: RelationDecl;
|
|
127
|
+
} & ({
|
|
128
|
+
message: string;
|
|
129
|
+
} | {
|
|
130
|
+
messageBySide: {
|
|
131
|
+
left: string;
|
|
132
|
+
right: string;
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* `WitnessBlock` — the valve standing after the verdict: its own extract pipelines and relate
|
|
137
|
+
* entries in the same grammar. It sees the body's extract names; the body never sees its.
|
|
138
|
+
*/
|
|
139
|
+
export type WitnessBlock = {
|
|
140
|
+
extract?: ExtractBlock;
|
|
141
|
+
relate: RelateEntry[];
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* `AlgebraDeclaration` — one judgment written as data, `judge = relate ∘ extract`.
|
|
145
|
+
*
|
|
146
|
+
* Pure JSON shape validated by {@link validateAlgebraDeclaration}; `mechanism` names the
|
|
147
|
+
* catalogue entry whose shape the declaration must match.
|
|
148
|
+
*/
|
|
149
|
+
export type AlgebraDeclaration = {
|
|
150
|
+
discipline: string;
|
|
151
|
+
mechanism: string;
|
|
152
|
+
scope?: ScopeBlock;
|
|
153
|
+
sources?: SourcesBlock;
|
|
154
|
+
supply?: SupplyBlock;
|
|
155
|
+
extract: ExtractBlock;
|
|
156
|
+
relate: RelateEntry[];
|
|
157
|
+
witness?: WitnessBlock;
|
|
158
|
+
};
|
|
159
|
+
/** One element for which the relation does not hold. The engine fixes the rest of the shape. */
|
|
160
|
+
export type Witness = {
|
|
161
|
+
readonly value: unknown;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* An empty list means the relation holds. The order preserves the extraction's input
|
|
165
|
+
* order — the premise on which two surfaces reach the same verdict.
|
|
166
|
+
*/
|
|
167
|
+
export type Witnesses = readonly Witness[];
|
|
168
|
+
/**
|
|
169
|
+
* Validate one algebra declaration's shape, returning it unchanged.
|
|
170
|
+
*
|
|
171
|
+
* Every violation throws {@link ConfigValidationError} with a message starting at
|
|
172
|
+
* `location`, so a caller validating many declarations sees which one failed.
|
|
173
|
+
*/
|
|
174
|
+
export declare function validateAlgebraDeclaration(input: unknown, location?: string): AlgebraDeclaration;
|