@delfini/drift-engine 0.1.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.md +172 -0
- package/dist/diff-filter.d.ts +33 -0
- package/dist/diff-filter.d.ts.map +1 -0
- package/dist/diff-filter.js +579 -0
- package/dist/doc-scope.d.ts +119 -0
- package/dist/doc-scope.d.ts.map +1 -0
- package/dist/doc-scope.js +260 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/prompt-budget.d.ts +2 -0
- package/dist/prompt-budget.d.ts.map +1 -0
- package/dist/prompt-budget.js +16 -0
- package/dist/prompt-builder.d.ts +21 -0
- package/dist/prompt-builder.d.ts.map +1 -0
- package/dist/prompt-builder.js +267 -0
- package/dist/reconcile.d.ts +17 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/reconcile.js +290 -0
- package/dist/relevance.d.ts +73 -0
- package/dist/relevance.d.ts.map +1 -0
- package/dist/relevance.js +266 -0
- package/dist/schema.d.ts +293 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +50 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/package.json +39 -0
- package/src/prompt.md +360 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ContradictionSchema: z.ZodObject<{
|
|
3
|
+
targetDocPath: z.ZodString;
|
|
4
|
+
targetSection: z.ZodString;
|
|
5
|
+
targetLineStart: z.ZodNumber;
|
|
6
|
+
targetLineEnd: z.ZodNumber;
|
|
7
|
+
whatChanged: z.ZodString;
|
|
8
|
+
whatContradicts: z.ZodString;
|
|
9
|
+
proposedReplacement: z.ZodNullable<z.ZodString>;
|
|
10
|
+
severity: z.ZodEnum<["High", "Medium", "Low"]>;
|
|
11
|
+
confidence: z.ZodNumber;
|
|
12
|
+
quotedDocText: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
targetDocPath: string;
|
|
15
|
+
targetSection: string;
|
|
16
|
+
targetLineStart: number;
|
|
17
|
+
targetLineEnd: number;
|
|
18
|
+
whatChanged: string;
|
|
19
|
+
whatContradicts: string;
|
|
20
|
+
proposedReplacement: string | null;
|
|
21
|
+
severity: "High" | "Medium" | "Low";
|
|
22
|
+
confidence: number;
|
|
23
|
+
quotedDocText: string;
|
|
24
|
+
}, {
|
|
25
|
+
targetDocPath: string;
|
|
26
|
+
targetSection: string;
|
|
27
|
+
targetLineStart: number;
|
|
28
|
+
targetLineEnd: number;
|
|
29
|
+
whatChanged: string;
|
|
30
|
+
whatContradicts: string;
|
|
31
|
+
proposedReplacement: string | null;
|
|
32
|
+
severity: "High" | "Medium" | "Low";
|
|
33
|
+
confidence: number;
|
|
34
|
+
quotedDocText: string;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const AdditionSchema: z.ZodObject<{
|
|
37
|
+
targetDocPath: z.ZodString;
|
|
38
|
+
anchorSection: z.ZodString;
|
|
39
|
+
insertionMode: z.ZodEnum<["before", "after"]>;
|
|
40
|
+
proposedContent: z.ZodString;
|
|
41
|
+
severity: z.ZodEnum<["High", "Medium", "Low"]>;
|
|
42
|
+
confidence: z.ZodNumber;
|
|
43
|
+
whatChanged: z.ZodString;
|
|
44
|
+
rationaleForAddition: z.ZodString;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
targetDocPath: string;
|
|
47
|
+
whatChanged: string;
|
|
48
|
+
severity: "High" | "Medium" | "Low";
|
|
49
|
+
confidence: number;
|
|
50
|
+
anchorSection: string;
|
|
51
|
+
insertionMode: "before" | "after";
|
|
52
|
+
proposedContent: string;
|
|
53
|
+
rationaleForAddition: string;
|
|
54
|
+
}, {
|
|
55
|
+
targetDocPath: string;
|
|
56
|
+
whatChanged: string;
|
|
57
|
+
severity: "High" | "Medium" | "Low";
|
|
58
|
+
confidence: number;
|
|
59
|
+
anchorSection: string;
|
|
60
|
+
insertionMode: "before" | "after";
|
|
61
|
+
proposedContent: string;
|
|
62
|
+
rationaleForAddition: string;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const AnalysisResultSchema: z.ZodObject<{
|
|
65
|
+
contradictions: z.ZodArray<z.ZodObject<{
|
|
66
|
+
targetDocPath: z.ZodString;
|
|
67
|
+
targetSection: z.ZodString;
|
|
68
|
+
targetLineStart: z.ZodNumber;
|
|
69
|
+
targetLineEnd: z.ZodNumber;
|
|
70
|
+
whatChanged: z.ZodString;
|
|
71
|
+
whatContradicts: z.ZodString;
|
|
72
|
+
proposedReplacement: z.ZodNullable<z.ZodString>;
|
|
73
|
+
severity: z.ZodEnum<["High", "Medium", "Low"]>;
|
|
74
|
+
confidence: z.ZodNumber;
|
|
75
|
+
quotedDocText: z.ZodString;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
targetDocPath: string;
|
|
78
|
+
targetSection: string;
|
|
79
|
+
targetLineStart: number;
|
|
80
|
+
targetLineEnd: number;
|
|
81
|
+
whatChanged: string;
|
|
82
|
+
whatContradicts: string;
|
|
83
|
+
proposedReplacement: string | null;
|
|
84
|
+
severity: "High" | "Medium" | "Low";
|
|
85
|
+
confidence: number;
|
|
86
|
+
quotedDocText: string;
|
|
87
|
+
}, {
|
|
88
|
+
targetDocPath: string;
|
|
89
|
+
targetSection: string;
|
|
90
|
+
targetLineStart: number;
|
|
91
|
+
targetLineEnd: number;
|
|
92
|
+
whatChanged: string;
|
|
93
|
+
whatContradicts: string;
|
|
94
|
+
proposedReplacement: string | null;
|
|
95
|
+
severity: "High" | "Medium" | "Low";
|
|
96
|
+
confidence: number;
|
|
97
|
+
quotedDocText: string;
|
|
98
|
+
}>, "many">;
|
|
99
|
+
additions: z.ZodArray<z.ZodObject<{
|
|
100
|
+
targetDocPath: z.ZodString;
|
|
101
|
+
anchorSection: z.ZodString;
|
|
102
|
+
insertionMode: z.ZodEnum<["before", "after"]>;
|
|
103
|
+
proposedContent: z.ZodString;
|
|
104
|
+
severity: z.ZodEnum<["High", "Medium", "Low"]>;
|
|
105
|
+
confidence: z.ZodNumber;
|
|
106
|
+
whatChanged: z.ZodString;
|
|
107
|
+
rationaleForAddition: z.ZodString;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
targetDocPath: string;
|
|
110
|
+
whatChanged: string;
|
|
111
|
+
severity: "High" | "Medium" | "Low";
|
|
112
|
+
confidence: number;
|
|
113
|
+
anchorSection: string;
|
|
114
|
+
insertionMode: "before" | "after";
|
|
115
|
+
proposedContent: string;
|
|
116
|
+
rationaleForAddition: string;
|
|
117
|
+
}, {
|
|
118
|
+
targetDocPath: string;
|
|
119
|
+
whatChanged: string;
|
|
120
|
+
severity: "High" | "Medium" | "Low";
|
|
121
|
+
confidence: number;
|
|
122
|
+
anchorSection: string;
|
|
123
|
+
insertionMode: "before" | "after";
|
|
124
|
+
proposedContent: string;
|
|
125
|
+
rationaleForAddition: string;
|
|
126
|
+
}>, "many">;
|
|
127
|
+
rawConfidence: z.ZodNumber;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
contradictions: {
|
|
130
|
+
targetDocPath: string;
|
|
131
|
+
targetSection: string;
|
|
132
|
+
targetLineStart: number;
|
|
133
|
+
targetLineEnd: number;
|
|
134
|
+
whatChanged: string;
|
|
135
|
+
whatContradicts: string;
|
|
136
|
+
proposedReplacement: string | null;
|
|
137
|
+
severity: "High" | "Medium" | "Low";
|
|
138
|
+
confidence: number;
|
|
139
|
+
quotedDocText: string;
|
|
140
|
+
}[];
|
|
141
|
+
additions: {
|
|
142
|
+
targetDocPath: string;
|
|
143
|
+
whatChanged: string;
|
|
144
|
+
severity: "High" | "Medium" | "Low";
|
|
145
|
+
confidence: number;
|
|
146
|
+
anchorSection: string;
|
|
147
|
+
insertionMode: "before" | "after";
|
|
148
|
+
proposedContent: string;
|
|
149
|
+
rationaleForAddition: string;
|
|
150
|
+
}[];
|
|
151
|
+
rawConfidence: number;
|
|
152
|
+
}, {
|
|
153
|
+
contradictions: {
|
|
154
|
+
targetDocPath: string;
|
|
155
|
+
targetSection: string;
|
|
156
|
+
targetLineStart: number;
|
|
157
|
+
targetLineEnd: number;
|
|
158
|
+
whatChanged: string;
|
|
159
|
+
whatContradicts: string;
|
|
160
|
+
proposedReplacement: string | null;
|
|
161
|
+
severity: "High" | "Medium" | "Low";
|
|
162
|
+
confidence: number;
|
|
163
|
+
quotedDocText: string;
|
|
164
|
+
}[];
|
|
165
|
+
additions: {
|
|
166
|
+
targetDocPath: string;
|
|
167
|
+
whatChanged: string;
|
|
168
|
+
severity: "High" | "Medium" | "Low";
|
|
169
|
+
confidence: number;
|
|
170
|
+
anchorSection: string;
|
|
171
|
+
insertionMode: "before" | "after";
|
|
172
|
+
proposedContent: string;
|
|
173
|
+
rationaleForAddition: string;
|
|
174
|
+
}[];
|
|
175
|
+
rawConfidence: number;
|
|
176
|
+
}>;
|
|
177
|
+
export declare const analysisSchema: z.ZodObject<{
|
|
178
|
+
contradictions: z.ZodArray<z.ZodObject<{
|
|
179
|
+
targetDocPath: z.ZodString;
|
|
180
|
+
targetSection: z.ZodString;
|
|
181
|
+
targetLineStart: z.ZodNumber;
|
|
182
|
+
targetLineEnd: z.ZodNumber;
|
|
183
|
+
whatChanged: z.ZodString;
|
|
184
|
+
whatContradicts: z.ZodString;
|
|
185
|
+
proposedReplacement: z.ZodNullable<z.ZodString>;
|
|
186
|
+
severity: z.ZodEnum<["High", "Medium", "Low"]>;
|
|
187
|
+
confidence: z.ZodNumber;
|
|
188
|
+
quotedDocText: z.ZodString;
|
|
189
|
+
}, "strip", z.ZodTypeAny, {
|
|
190
|
+
targetDocPath: string;
|
|
191
|
+
targetSection: string;
|
|
192
|
+
targetLineStart: number;
|
|
193
|
+
targetLineEnd: number;
|
|
194
|
+
whatChanged: string;
|
|
195
|
+
whatContradicts: string;
|
|
196
|
+
proposedReplacement: string | null;
|
|
197
|
+
severity: "High" | "Medium" | "Low";
|
|
198
|
+
confidence: number;
|
|
199
|
+
quotedDocText: string;
|
|
200
|
+
}, {
|
|
201
|
+
targetDocPath: string;
|
|
202
|
+
targetSection: string;
|
|
203
|
+
targetLineStart: number;
|
|
204
|
+
targetLineEnd: number;
|
|
205
|
+
whatChanged: string;
|
|
206
|
+
whatContradicts: string;
|
|
207
|
+
proposedReplacement: string | null;
|
|
208
|
+
severity: "High" | "Medium" | "Low";
|
|
209
|
+
confidence: number;
|
|
210
|
+
quotedDocText: string;
|
|
211
|
+
}>, "many">;
|
|
212
|
+
additions: z.ZodArray<z.ZodObject<{
|
|
213
|
+
targetDocPath: z.ZodString;
|
|
214
|
+
anchorSection: z.ZodString;
|
|
215
|
+
insertionMode: z.ZodEnum<["before", "after"]>;
|
|
216
|
+
proposedContent: z.ZodString;
|
|
217
|
+
severity: z.ZodEnum<["High", "Medium", "Low"]>;
|
|
218
|
+
confidence: z.ZodNumber;
|
|
219
|
+
whatChanged: z.ZodString;
|
|
220
|
+
rationaleForAddition: z.ZodString;
|
|
221
|
+
}, "strip", z.ZodTypeAny, {
|
|
222
|
+
targetDocPath: string;
|
|
223
|
+
whatChanged: string;
|
|
224
|
+
severity: "High" | "Medium" | "Low";
|
|
225
|
+
confidence: number;
|
|
226
|
+
anchorSection: string;
|
|
227
|
+
insertionMode: "before" | "after";
|
|
228
|
+
proposedContent: string;
|
|
229
|
+
rationaleForAddition: string;
|
|
230
|
+
}, {
|
|
231
|
+
targetDocPath: string;
|
|
232
|
+
whatChanged: string;
|
|
233
|
+
severity: "High" | "Medium" | "Low";
|
|
234
|
+
confidence: number;
|
|
235
|
+
anchorSection: string;
|
|
236
|
+
insertionMode: "before" | "after";
|
|
237
|
+
proposedContent: string;
|
|
238
|
+
rationaleForAddition: string;
|
|
239
|
+
}>, "many">;
|
|
240
|
+
rawConfidence: z.ZodNumber;
|
|
241
|
+
}, "strip", z.ZodTypeAny, {
|
|
242
|
+
contradictions: {
|
|
243
|
+
targetDocPath: string;
|
|
244
|
+
targetSection: string;
|
|
245
|
+
targetLineStart: number;
|
|
246
|
+
targetLineEnd: number;
|
|
247
|
+
whatChanged: string;
|
|
248
|
+
whatContradicts: string;
|
|
249
|
+
proposedReplacement: string | null;
|
|
250
|
+
severity: "High" | "Medium" | "Low";
|
|
251
|
+
confidence: number;
|
|
252
|
+
quotedDocText: string;
|
|
253
|
+
}[];
|
|
254
|
+
additions: {
|
|
255
|
+
targetDocPath: string;
|
|
256
|
+
whatChanged: string;
|
|
257
|
+
severity: "High" | "Medium" | "Low";
|
|
258
|
+
confidence: number;
|
|
259
|
+
anchorSection: string;
|
|
260
|
+
insertionMode: "before" | "after";
|
|
261
|
+
proposedContent: string;
|
|
262
|
+
rationaleForAddition: string;
|
|
263
|
+
}[];
|
|
264
|
+
rawConfidence: number;
|
|
265
|
+
}, {
|
|
266
|
+
contradictions: {
|
|
267
|
+
targetDocPath: string;
|
|
268
|
+
targetSection: string;
|
|
269
|
+
targetLineStart: number;
|
|
270
|
+
targetLineEnd: number;
|
|
271
|
+
whatChanged: string;
|
|
272
|
+
whatContradicts: string;
|
|
273
|
+
proposedReplacement: string | null;
|
|
274
|
+
severity: "High" | "Medium" | "Low";
|
|
275
|
+
confidence: number;
|
|
276
|
+
quotedDocText: string;
|
|
277
|
+
}[];
|
|
278
|
+
additions: {
|
|
279
|
+
targetDocPath: string;
|
|
280
|
+
whatChanged: string;
|
|
281
|
+
severity: "High" | "Medium" | "Low";
|
|
282
|
+
confidence: number;
|
|
283
|
+
anchorSection: string;
|
|
284
|
+
insertionMode: "before" | "after";
|
|
285
|
+
proposedContent: string;
|
|
286
|
+
rationaleForAddition: string;
|
|
287
|
+
}[];
|
|
288
|
+
rawConfidence: number;
|
|
289
|
+
}>;
|
|
290
|
+
export type ContradictionShape = z.infer<typeof ContradictionSchema>;
|
|
291
|
+
export type AdditionShape = z.infer<typeof AdditionSchema>;
|
|
292
|
+
export type AnalysisResultShape = z.infer<typeof AnalysisResultSchema>;
|
|
293
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB9B,CAAA;AAQF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;EASzB,CAAA;AASF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI/B,CAAA;AAKF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAuB,CAAA;AAElD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AACpE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAC1D,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ContradictionSchema = z.object({
|
|
3
|
+
targetDocPath: z.string().min(1),
|
|
4
|
+
targetSection: z.string().min(1),
|
|
5
|
+
targetLineStart: z.number().int().positive(),
|
|
6
|
+
targetLineEnd: z.number().int().positive(),
|
|
7
|
+
whatChanged: z.string().min(1),
|
|
8
|
+
whatContradicts: z.string().min(1),
|
|
9
|
+
proposedReplacement: z.string().nullable(),
|
|
10
|
+
severity: z.enum(['High', 'Medium', 'Low']),
|
|
11
|
+
confidence: z.number().int().min(1).max(5),
|
|
12
|
+
// Story 3.9b — verbatim doc-side excerpt the LLM cites as contradicted by
|
|
13
|
+
// the code change. Used by the orchestrator's reconciler to locate the cited
|
|
14
|
+
// text in the doc body and overwrite `targetLineStart` / `targetLineEnd`
|
|
15
|
+
// with the actual line range. Min length 1 — empty quotes are rejected so
|
|
16
|
+
// the LLM can't bypass grounding by emitting an empty string.
|
|
17
|
+
quotedDocText: z.string().min(1),
|
|
18
|
+
});
|
|
19
|
+
// Story 4.25 / 4.26 — additive finding LLM output shape. The diff introduces
|
|
20
|
+
// a foundational new concept that no doc section covers but that the doc
|
|
21
|
+
// would naturally describe. The LLM cites an anchor SECTION HEADING (not a
|
|
22
|
+
// quoted line) plus an insertion mode + the verbatim new content to splice.
|
|
23
|
+
// The orchestrator's reconciler locates the anchor section's line in the doc
|
|
24
|
+
// body before the finding leaves the orchestrator.
|
|
25
|
+
export const AdditionSchema = z.object({
|
|
26
|
+
targetDocPath: z.string().min(1),
|
|
27
|
+
anchorSection: z.string().min(1),
|
|
28
|
+
insertionMode: z.enum(['before', 'after']),
|
|
29
|
+
proposedContent: z.string().min(1),
|
|
30
|
+
severity: z.enum(['High', 'Medium', 'Low']),
|
|
31
|
+
confidence: z.number().int().min(1).max(5),
|
|
32
|
+
whatChanged: z.string().min(1),
|
|
33
|
+
rationaleForAddition: z.string().min(1),
|
|
34
|
+
});
|
|
35
|
+
// Story 4.26 — `additions` is REQUIRED (not `.optional().default([])`).
|
|
36
|
+
// Mirrors `contradictions`' shape so the LLM is forced to emit an explicit
|
|
37
|
+
// `[]` when no additive findings apply. The Story 4.25 shape used
|
|
38
|
+
// `.optional().default([])` which the Zod→JSON-Schema conversion under
|
|
39
|
+
// `withStructuredOutput` surfaces as a non-required field to the LLM — a
|
|
40
|
+
// likely contributor to additive under-emission spotted in the 4.25 code
|
|
41
|
+
// review.
|
|
42
|
+
export const AnalysisResultSchema = z.object({
|
|
43
|
+
contradictions: z.array(ContradictionSchema),
|
|
44
|
+
additions: z.array(AdditionSchema),
|
|
45
|
+
rawConfidence: z.number().min(0).max(1),
|
|
46
|
+
});
|
|
47
|
+
// Public-API alias (architecture.md L1055–L1070). `AnalysisResultSchema` is
|
|
48
|
+
// the historical internal name; `analysisSchema` is the camelCase public
|
|
49
|
+
// surface re-exported from the barrel.
|
|
50
|
+
export const analysisSchema = AnalysisResultSchema;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export type Severity = 'High' | 'Medium' | 'Low';
|
|
2
|
+
export interface DocFile {
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
frontMatterLineCount: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PRMetadata {
|
|
8
|
+
owner: string;
|
|
9
|
+
repo: string;
|
|
10
|
+
prNumber: number;
|
|
11
|
+
headSha: string;
|
|
12
|
+
baseSha: string;
|
|
13
|
+
title: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AnalysisInput {
|
|
16
|
+
diff: string;
|
|
17
|
+
docs: DocFile[];
|
|
18
|
+
prMetadata: PRMetadata;
|
|
19
|
+
}
|
|
20
|
+
export interface Contradiction {
|
|
21
|
+
targetDocPath: string;
|
|
22
|
+
targetSection: string;
|
|
23
|
+
targetLineStart: number;
|
|
24
|
+
targetLineEnd: number;
|
|
25
|
+
whatChanged: string;
|
|
26
|
+
whatContradicts: string;
|
|
27
|
+
proposedReplacement: string | null;
|
|
28
|
+
severity: Severity;
|
|
29
|
+
confidence: number;
|
|
30
|
+
quotedDocText: string;
|
|
31
|
+
}
|
|
32
|
+
export interface Addition {
|
|
33
|
+
targetDocPath: string;
|
|
34
|
+
anchorSection: string;
|
|
35
|
+
anchorLine: number;
|
|
36
|
+
insertionMode: 'before' | 'after';
|
|
37
|
+
proposedContent: string;
|
|
38
|
+
severity: Severity;
|
|
39
|
+
confidence: number;
|
|
40
|
+
whatChanged: string;
|
|
41
|
+
rationaleForAddition: string;
|
|
42
|
+
}
|
|
43
|
+
export interface AnalysisResult {
|
|
44
|
+
contradictions: Contradiction[];
|
|
45
|
+
additions: Addition[];
|
|
46
|
+
rawConfidence: number;
|
|
47
|
+
narrativeOnlyContradictions?: Contradiction[];
|
|
48
|
+
}
|
|
49
|
+
export interface BuildPromptOptions {
|
|
50
|
+
/**
|
|
51
|
+
* When set to a positive integer, docs whose relevance score is below
|
|
52
|
+
* this threshold are dropped from the prompt before rendering. Score is
|
|
53
|
+
* computed by `selectRelevantDocs` (file-path overlap + identifier
|
|
54
|
+
* overlap + heading overlap + doc-path-in-diff). When undefined or 0,
|
|
55
|
+
* every doc in `input.docs` is included verbatim.
|
|
56
|
+
*/
|
|
57
|
+
relevanceThreshold?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Story P3.7.3 / FR152 — ranked-fill prompt budget. When set to a positive
|
|
60
|
+
* finite integer AND `relevanceThreshold` is also positive, retained doc
|
|
61
|
+
* sections are ranked most-relevant-first and included only while the
|
|
62
|
+
* running token total stays at-or-below this budget. Sections that don't
|
|
63
|
+
* fit are surfaced as `droppedSections` from `buildPromptWithDrops`.
|
|
64
|
+
*
|
|
65
|
+
* Default (undefined / <= 0 / non-finite) → no budget cap; every retained
|
|
66
|
+
* section is rendered (P3.7.1 retrieval-on path is unchanged). When
|
|
67
|
+
* `relevanceThreshold` is undefined / <= 0 / non-finite this option is
|
|
68
|
+
* IGNORED — there are no scored candidates to rank.
|
|
69
|
+
*
|
|
70
|
+
* Budget unit: estimated tokens via `estimatePromptTokens` (Math.ceil(len/3.5)).
|
|
71
|
+
*/
|
|
72
|
+
promptTokenBudget?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface ClarifyingQuestion {
|
|
75
|
+
whatChanged: string;
|
|
76
|
+
naturalHomeDoc: string;
|
|
77
|
+
naturalHomeSection: string;
|
|
78
|
+
question: string;
|
|
79
|
+
proposedReplacement: string | null;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;AAEhD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IAMf,oBAAoB,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,EAAE,QAAQ,CAAA;IAElB,UAAU,EAAE,MAAM,CAAA;IAOlB,aAAa,EAAE,MAAM,CAAA;CACtB;AAOD,MAAM,WAAW,QAAQ;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IAIrB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAA;IACjC,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,oBAAoB,EAAE,MAAM,CAAA;CAC7B;AAeD,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,aAAa,EAAE,CAAA;IAC/B,SAAS,EAAE,QAAQ,EAAE,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,2BAA2B,CAAC,EAAE,aAAa,EAAE,CAAA;CAC9C;AAQD,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAQD,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Pure-logic types for the drift-detection algorithm. No I/O, no wire shapes,
|
|
2
|
+
// no platform-specific schema fields. The wire-shape types used by the Action
|
|
3
|
+
// to talk to the hosted platform (Intake*, Config*, ReviewStatus, etc.) live
|
|
4
|
+
// in `apps/action/src/ports/intake-types.ts` — those carry snake_case field
|
|
5
|
+
// names load-bearing for the FR88d/FR88g contract and have no business here.
|
|
6
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@delfini/drift-engine",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"description": "Pure-logic drift analysis core shared by @delfini/action and @delfini/cli. No I/O, no LLM client, no credentials, no fetch. Runtime deps: zod + picomatch (both pure CPU). Public API: buildPrompt, validateAndReconcile, estimatePromptTokens, analysisSchema, and the doc-scope algebra (normalizeDocScope, validateDocScopeEntry, classifyEntry, isFileInDocScope).",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./prompt.md": "./src/prompt.md"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"src/prompt.md",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"picomatch": "^4.0.0",
|
|
25
|
+
"zod": "^3.24.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.10.2",
|
|
29
|
+
"@types/picomatch": "^4.0.0",
|
|
30
|
+
"typescript": "^5.7.2",
|
|
31
|
+
"vitest": "^3.0.5"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -b",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"lint": "eslint src",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
}
|
|
39
|
+
}
|