@popmelt.com/core 0.8.4 → 0.8.6

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/dist/server.d.mts CHANGED
@@ -1,3 +1,139 @@
1
+ type ImprintExplanationKind = 'intention' | 'principle' | 'pattern';
2
+ type ImprintExplanationState = 'emerging' | 'testing' | 'grounded' | 'challenged' | 'retired';
3
+ type ImprintScopeKind = 'project' | 'route' | 'component' | 'selector' | 'file';
4
+ type ImprintScope = {
5
+ kind: ImprintScopeKind;
6
+ values: string[];
7
+ };
8
+ type ImprintEvidence = {
9
+ id: string;
10
+ kind: 'observation' | 'application' | 'confirmation' | 'correction' | 'exception' | 'rejection';
11
+ stance: 'supports' | 'challenges' | 'excepts';
12
+ summary: string;
13
+ threadId: string;
14
+ jobId: string;
15
+ createdAt: string;
16
+ };
17
+ type ImprintExplanation = {
18
+ id: string;
19
+ kind: ImprintExplanationKind;
20
+ statement: string;
21
+ rationale: string;
22
+ scope: ImprintScope;
23
+ state: ImprintExplanationState;
24
+ createdAt: string;
25
+ updatedAt: string;
26
+ evidence: ImprintEvidence[];
27
+ supersededBy?: string;
28
+ };
29
+ type ImprintConcrete = {
30
+ id: string;
31
+ modelPath: string;
32
+ value: unknown;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ };
36
+ type ImprintRelationType = 'operationalizes' | 'refines' | 'supports' | 'contradicts' | 'excepts' | 'instantiates';
37
+ type ImprintRelation = {
38
+ id: string;
39
+ type: ImprintRelationType;
40
+ fromId: string;
41
+ toId: string;
42
+ rationale: string;
43
+ createdAt: string;
44
+ };
45
+ type ImprintGraph = {
46
+ version: 1;
47
+ projectId: string;
48
+ createdAt: string;
49
+ updatedAt: string;
50
+ head: {
51
+ sequence: number;
52
+ hash: string | null;
53
+ };
54
+ explanations: ImprintExplanation[];
55
+ concrete: ImprintConcrete[];
56
+ relations: ImprintRelation[];
57
+ };
58
+ type ImprintMutation = {
59
+ op: 'add_explanation';
60
+ explanation: ImprintExplanation;
61
+ } | {
62
+ op: 'replace_explanation';
63
+ explanation: ImprintExplanation;
64
+ } | {
65
+ op: 'remove_explanation';
66
+ explanationId: string;
67
+ } | {
68
+ op: 'add_concrete';
69
+ concrete: ImprintConcrete;
70
+ } | {
71
+ op: 'remove_concrete';
72
+ concreteId: string;
73
+ } | {
74
+ op: 'add_evidence';
75
+ explanationId: string;
76
+ evidence: ImprintEvidence;
77
+ } | {
78
+ op: 'revise_explanation';
79
+ explanationId: string;
80
+ patch: Partial<Pick<ImprintExplanation, 'statement' | 'rationale' | 'scope' | 'state' | 'supersededBy'>>;
81
+ updatedAt: string;
82
+ } | {
83
+ op: 'add_relation';
84
+ relation: ImprintRelation;
85
+ } | {
86
+ op: 'remove_relation';
87
+ relationId: string;
88
+ };
89
+ type ImprintTransaction = {
90
+ version: 1;
91
+ sequence: number;
92
+ transactionId: string;
93
+ projectId: string;
94
+ committedAt: string;
95
+ previousHash: string | null;
96
+ hash: string;
97
+ source: {
98
+ kind: 'automatic' | 'grounding' | 'correction' | 'undo';
99
+ threadId: string;
100
+ jobId: string;
101
+ };
102
+ summary: string;
103
+ mutations: ImprintMutation[];
104
+ inverseMutations: ImprintMutation[];
105
+ undoesTransactionId?: string;
106
+ };
107
+ type ImprintSummaryKind = 'added' | 'strengthened' | 'refined' | 'challenged' | 'exception' | 'consolidated';
108
+ type ImprintThreadSummary = {
109
+ transactionId: string;
110
+ coalescedTransactionIds?: string[];
111
+ additionalObservationCount?: number;
112
+ kind: ImprintSummaryKind;
113
+ title: string;
114
+ detail: string;
115
+ changes: Array<{
116
+ explanationId: string;
117
+ action: 'added' | 'revised' | 'supported' | 'challenged' | 'retired' | 'related';
118
+ statement: string;
119
+ state: ImprintExplanationState;
120
+ }>;
121
+ grounding?: {
122
+ explanationId: string;
123
+ question: string;
124
+ state: 'testing';
125
+ };
126
+ resolvedAction?: ImprintGroundingAction;
127
+ };
128
+ type ImprintGroundingAction = 'confirm' | 'reason_wrong' | 'narrow' | 'exception' | 'edit' | 'dont_learn' | 'undo';
129
+ type ImprintContext = {
130
+ explanations: Array<Pick<ImprintExplanation, 'id' | 'kind' | 'statement' | 'rationale' | 'scope' | 'state'> & {
131
+ concrete: Array<Pick<ImprintConcrete, 'id' | 'modelPath' | 'value'>>;
132
+ }>;
133
+ truncated: boolean;
134
+ pendingGroundingExplanationIds?: string[];
135
+ };
136
+
1
137
  type Provider = 'claude' | 'codex' | 'copilot';
2
138
 
3
139
  type PopmeltOptions = {
@@ -20,6 +156,137 @@ type PopmeltHandle = {
20
156
  close: () => Promise<void>;
21
157
  };
22
158
 
159
+ type ImprintLoadResult = {
160
+ graph: ImprintGraph;
161
+ transactions: ImprintTransaction[];
162
+ recoveredTransactions: number;
163
+ };
164
+ declare class ImprintStore {
165
+ private readonly projectRoot;
166
+ private readonly projectId;
167
+ private readonly imprintDir;
168
+ private readonly manifestPath;
169
+ private readonly graphPath;
170
+ private readonly journalDir;
171
+ private writeChain;
172
+ constructor(projectRoot: string, projectId: string);
173
+ private readManifest;
174
+ load(): Promise<ImprintLoadResult>;
175
+ commit(input: {
176
+ transactionId: string;
177
+ committedAt: string;
178
+ source: ImprintTransaction['source'];
179
+ summary: string;
180
+ mutations: ImprintMutation[];
181
+ undoesTransactionId?: string;
182
+ }): Promise<{
183
+ graph: ImprintGraph;
184
+ transaction: ImprintTransaction;
185
+ }>;
186
+ undo(transactionId: string, source: ImprintTransaction['source'], committedAt: string, undoTransactionId: string): Promise<{
187
+ graph: ImprintGraph;
188
+ transaction: ImprintTransaction;
189
+ }>;
190
+ recover(): Promise<ImprintLoadResult>;
191
+ }
192
+
193
+ type ProposedMutation = {
194
+ op: 'add';
195
+ clientId?: string;
196
+ kind: ImprintExplanationKind;
197
+ statement: string;
198
+ rationale: string;
199
+ scope?: ImprintScope;
200
+ } | {
201
+ op: 'revise';
202
+ explanationId: string;
203
+ statement?: string;
204
+ rationale?: string;
205
+ scope?: ImprintScope;
206
+ reopenGrounding?: boolean;
207
+ } | {
208
+ op: 'evidence';
209
+ explanationId: string;
210
+ stance: 'supports' | 'challenges' | 'excepts';
211
+ summary: string;
212
+ } | {
213
+ op: 'relation';
214
+ type: ImprintRelationType;
215
+ fromId: string;
216
+ toId: string;
217
+ rationale: string;
218
+ } | {
219
+ op: 'supersede';
220
+ explanationId: string;
221
+ replacementId: string;
222
+ reason: string;
223
+ } | {
224
+ op: 'bind_concrete';
225
+ explanationId: string;
226
+ modelPath: string;
227
+ rationale: string;
228
+ } | {
229
+ op: 'retire';
230
+ explanationId: string;
231
+ reason: string;
232
+ };
233
+ type ImprintNoopReason = 'application_only' | 'transient_state' | 'concrete_without_model_path' | 'duplicate' | 'insufficient_evidence' | 'task_specific_detail' | 'no_shared_understanding_change';
234
+ type ImprintMutationDraft = {
235
+ decision: 'mutate';
236
+ summary: {
237
+ kind: ImprintSummaryKind;
238
+ title: string;
239
+ detail: string;
240
+ };
241
+ appliedExplanationIds: string[];
242
+ mutations: ProposedMutation[];
243
+ grounding?: {
244
+ explanationId: string;
245
+ question: string;
246
+ };
247
+ };
248
+ type ImprintDraft = ImprintMutationDraft | {
249
+ decision: 'none';
250
+ reason: ImprintNoopReason;
251
+ };
252
+ type ImprintCaptureInput = {
253
+ threadId: string;
254
+ jobId: string;
255
+ occurredAt?: string;
256
+ concreteModel?: Record<string, unknown> | null;
257
+ pendingGroundingExplanationIds?: string[];
258
+ };
259
+ declare function parseImprintDraft(responseText: string): {
260
+ draft?: ImprintDraft;
261
+ visibleText: string;
262
+ error?: string;
263
+ };
264
+ declare function formatImprintPrompt(context: ImprintContext | undefined): string;
265
+ declare class ImprintService {
266
+ readonly store: ImprintStore;
267
+ private readonly noopCounts;
268
+ constructor(projectRoot: string, projectId: string);
269
+ recordNoop(reason: ImprintNoopReason): void;
270
+ diagnostics(): {
271
+ noopDecisions: Partial<Record<ImprintNoopReason, number>>;
272
+ };
273
+ contextualize(input: {
274
+ text?: string;
275
+ subjectHints?: string[];
276
+ maxExplanations?: number;
277
+ pendingGroundingExplanationIds?: string[];
278
+ }): Promise<ImprintContext | undefined>;
279
+ capture(draft: ImprintMutationDraft, input: ImprintCaptureInput): Promise<ImprintThreadSummary | undefined>;
280
+ applyGroundingAction(input: {
281
+ summary: ImprintThreadSummary;
282
+ action: ImprintGroundingAction;
283
+ value?: string;
284
+ threadId: string;
285
+ jobId: string;
286
+ occurredAt?: string;
287
+ }): Promise<void>;
288
+ }
289
+
23
290
  type StartPopmeltOptions = PopmeltOptions & {
24
291
  force?: boolean;
25
292
  detached?: boolean;
@@ -28,4 +295,4 @@ type StartPopmeltOptions = PopmeltOptions & {
28
295
  };
29
296
  declare function startPopmelt(options?: StartPopmeltOptions): Promise<PopmeltHandle>;
30
297
 
31
- export { type PopmeltHandle, type PopmeltOptions, type StartPopmeltOptions, startPopmelt };
298
+ export { type ImprintConcrete, type ImprintContext, type ImprintEvidence, type ImprintExplanation, type ImprintExplanationKind, type ImprintExplanationState, type ImprintGraph, type ImprintGroundingAction, type ImprintMutation, type ImprintRelation, type ImprintRelationType, type ImprintScope, ImprintService, ImprintStore, type ImprintThreadSummary, type ImprintTransaction, type PopmeltHandle, type PopmeltOptions, type StartPopmeltOptions, formatImprintPrompt, parseImprintDraft, startPopmelt };