@nazty_labs/common-ground 0.5.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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/SETUP.md +219 -0
  4. package/dist/access.d.ts +172 -0
  5. package/dist/access.js +175 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +198 -0
  8. package/dist/commands.d.ts +189 -0
  9. package/dist/commands.js +202 -0
  10. package/dist/discovery.d.ts +73 -0
  11. package/dist/discovery.js +417 -0
  12. package/dist/errors.d.ts +15 -0
  13. package/dist/errors.js +22 -0
  14. package/dist/export.d.ts +14 -0
  15. package/dist/export.js +86 -0
  16. package/dist/guidance.d.ts +11 -0
  17. package/dist/guidance.js +75 -0
  18. package/dist/hooks.d.ts +4 -0
  19. package/dist/hooks.js +141 -0
  20. package/dist/init.d.ts +304 -0
  21. package/dist/init.js +150 -0
  22. package/dist/maintenance.d.ts +126 -0
  23. package/dist/maintenance.js +23 -0
  24. package/dist/matching.d.ts +17 -0
  25. package/dist/matching.js +32 -0
  26. package/dist/model.d.ts +974 -0
  27. package/dist/model.js +21 -0
  28. package/dist/navigation.d.ts +164 -0
  29. package/dist/navigation.js +164 -0
  30. package/dist/operations.d.ts +10 -0
  31. package/dist/operations.js +130 -0
  32. package/dist/paging.d.ts +5 -0
  33. package/dist/paging.js +32 -0
  34. package/dist/retrieval.d.ts +146 -0
  35. package/dist/retrieval.js +150 -0
  36. package/dist/review-files.d.ts +3 -0
  37. package/dist/review-files.js +106 -0
  38. package/dist/review.d.ts +86 -0
  39. package/dist/review.js +124 -0
  40. package/dist/server.d.ts +8 -0
  41. package/dist/server.js +105 -0
  42. package/dist/source-search.d.ts +63 -0
  43. package/dist/source-search.js +245 -0
  44. package/dist/store.d.ts +452 -0
  45. package/dist/store.js +718 -0
  46. package/dist/version.d.ts +1 -0
  47. package/dist/version.js +2 -0
  48. package/dist/workflow.d.ts +450 -0
  49. package/dist/workflow.js +317 -0
  50. package/docs/architecture.md +65 -0
  51. package/docs/audit-0.4.0.md +42 -0
  52. package/docs/demo.md +42 -0
  53. package/docs/discovery.md +70 -0
  54. package/docs/knowledge-policy.md +51 -0
  55. package/docs/pillar-contract.md +98 -0
  56. package/docs/quiet-workflow.md +98 -0
  57. package/docs/releases.md +157 -0
  58. package/package.json +52 -0
  59. package/schemas/admission.schema.json +75 -0
  60. package/schemas/knowledge.schema.json +192 -0
  61. package/schemas/patch.schema.json +220 -0
  62. package/schemas/update.schema.json +218 -0
@@ -0,0 +1 @@
1
+ export declare const version: string;
@@ -0,0 +1,2 @@
1
+ import { readFileSync } from 'node:fs';
2
+ export const version = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
@@ -0,0 +1,450 @@
1
+ import { type FactChange } from './review.js';
2
+ import { z } from 'zod';
3
+ import { Store } from './store.js';
4
+ import { Fact, type RegistryRecord } from './model.js';
5
+ export declare const Patch: z.ZodObject<{
6
+ taskId: z.ZodOptional<z.ZodString>;
7
+ chapterId: z.ZodString;
8
+ factIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9
+ touchedPaths: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>, "many">;
10
+ tidyId: z.ZodOptional<z.ZodString>;
11
+ verification: z.ZodObject<{
12
+ sourceFiles: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>, "many">;
13
+ documentFiles: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>, "many">;
14
+ }, "strict", z.ZodTypeAny, {
15
+ sourceFiles: string[];
16
+ documentFiles: string[];
17
+ }, {
18
+ sourceFiles: string[];
19
+ documentFiles: string[];
20
+ }>;
21
+ reviews: z.ZodArray<z.ZodObject<{
22
+ chapterId: z.ZodString;
23
+ expectedRevision: z.ZodNumber;
24
+ reviewedAllFacts: z.ZodLiteral<true>;
25
+ } & {
26
+ replacements: z.ZodDefault<z.ZodArray<z.ZodObject<{
27
+ id: z.ZodString;
28
+ statement: z.ZodString;
29
+ evidence: z.ZodArray<z.ZodObject<{
30
+ path: z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>;
31
+ quote: z.ZodString;
32
+ }, "strict", z.ZodTypeAny, {
33
+ path: string;
34
+ quote: string;
35
+ }, {
36
+ path: string;
37
+ quote: string;
38
+ }>, "many">;
39
+ } & {
40
+ sourceScope: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>, "many">;
41
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
42
+ }, "strict", z.ZodTypeAny, {
43
+ id: string;
44
+ statement: string;
45
+ evidence: {
46
+ path: string;
47
+ quote: string;
48
+ }[];
49
+ sourceScope: string[];
50
+ dependsOn: string[];
51
+ }, {
52
+ id: string;
53
+ statement: string;
54
+ evidence: {
55
+ path: string;
56
+ quote: string;
57
+ }[];
58
+ sourceScope: string[];
59
+ dependsOn?: string[] | undefined;
60
+ }>, "many">>;
61
+ removeFactIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
62
+ reason: z.ZodString;
63
+ maintenance: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
+ factId: z.ZodString;
65
+ action: z.ZodEnum<["correct", "merge", "remove", "tighten"]>;
66
+ reason: z.ZodString;
67
+ replacement: z.ZodOptional<z.ZodString>;
68
+ }, "strict", z.ZodTypeAny, {
69
+ factId: string;
70
+ action: "correct" | "merge" | "remove" | "tighten";
71
+ reason: string;
72
+ replacement?: string | undefined;
73
+ }, {
74
+ factId: string;
75
+ action: "correct" | "merge" | "remove" | "tighten";
76
+ reason: string;
77
+ replacement?: string | undefined;
78
+ }>, "many">>;
79
+ }, "strict", z.ZodTypeAny, {
80
+ reason: string;
81
+ chapterId: string;
82
+ expectedRevision: number;
83
+ reviewedAllFacts: true;
84
+ replacements: {
85
+ id: string;
86
+ statement: string;
87
+ evidence: {
88
+ path: string;
89
+ quote: string;
90
+ }[];
91
+ sourceScope: string[];
92
+ dependsOn: string[];
93
+ }[];
94
+ removeFactIds: string[];
95
+ maintenance?: {
96
+ factId: string;
97
+ action: "correct" | "merge" | "remove" | "tighten";
98
+ reason: string;
99
+ replacement?: string | undefined;
100
+ }[] | undefined;
101
+ }, {
102
+ reason: string;
103
+ chapterId: string;
104
+ expectedRevision: number;
105
+ reviewedAllFacts: true;
106
+ maintenance?: {
107
+ factId: string;
108
+ action: "correct" | "merge" | "remove" | "tighten";
109
+ reason: string;
110
+ replacement?: string | undefined;
111
+ }[] | undefined;
112
+ replacements?: {
113
+ id: string;
114
+ statement: string;
115
+ evidence: {
116
+ path: string;
117
+ quote: string;
118
+ }[];
119
+ sourceScope: string[];
120
+ dependsOn?: string[] | undefined;
121
+ }[] | undefined;
122
+ removeFactIds?: string[] | undefined;
123
+ }>, "many">;
124
+ }, "strict", z.ZodTypeAny, {
125
+ chapterId: string;
126
+ touchedPaths: string[];
127
+ reviews: {
128
+ reason: string;
129
+ chapterId: string;
130
+ expectedRevision: number;
131
+ reviewedAllFacts: true;
132
+ replacements: {
133
+ id: string;
134
+ statement: string;
135
+ evidence: {
136
+ path: string;
137
+ quote: string;
138
+ }[];
139
+ sourceScope: string[];
140
+ dependsOn: string[];
141
+ }[];
142
+ removeFactIds: string[];
143
+ maintenance?: {
144
+ factId: string;
145
+ action: "correct" | "merge" | "remove" | "tighten";
146
+ reason: string;
147
+ replacement?: string | undefined;
148
+ }[] | undefined;
149
+ }[];
150
+ verification: {
151
+ sourceFiles: string[];
152
+ documentFiles: string[];
153
+ };
154
+ factIds?: string[] | undefined;
155
+ tidyId?: string | undefined;
156
+ taskId?: string | undefined;
157
+ }, {
158
+ chapterId: string;
159
+ touchedPaths: string[];
160
+ reviews: {
161
+ reason: string;
162
+ chapterId: string;
163
+ expectedRevision: number;
164
+ reviewedAllFacts: true;
165
+ maintenance?: {
166
+ factId: string;
167
+ action: "correct" | "merge" | "remove" | "tighten";
168
+ reason: string;
169
+ replacement?: string | undefined;
170
+ }[] | undefined;
171
+ replacements?: {
172
+ id: string;
173
+ statement: string;
174
+ evidence: {
175
+ path: string;
176
+ quote: string;
177
+ }[];
178
+ sourceScope: string[];
179
+ dependsOn?: string[] | undefined;
180
+ }[] | undefined;
181
+ removeFactIds?: string[] | undefined;
182
+ }[];
183
+ verification: {
184
+ sourceFiles: string[];
185
+ documentFiles: string[];
186
+ };
187
+ factIds?: string[] | undefined;
188
+ tidyId?: string | undefined;
189
+ taskId?: string | undefined;
190
+ }>;
191
+ export declare const Admission: z.ZodObject<{
192
+ reviews: z.ZodArray<z.ZodObject<{
193
+ chapterId: z.ZodString;
194
+ expectedRevision: z.ZodNumber;
195
+ reviewedAllFacts: z.ZodLiteral<true>;
196
+ }, "strict", z.ZodTypeAny, {
197
+ chapterId: string;
198
+ expectedRevision: number;
199
+ reviewedAllFacts: true;
200
+ }, {
201
+ chapterId: string;
202
+ expectedRevision: number;
203
+ reviewedAllFacts: true;
204
+ }>, "many">;
205
+ verification: z.ZodObject<{
206
+ sourceFiles: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>, "many">;
207
+ documentFiles: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>, "many">;
208
+ }, "strict", z.ZodTypeAny, {
209
+ sourceFiles: string[];
210
+ documentFiles: string[];
211
+ }, {
212
+ sourceFiles: string[];
213
+ documentFiles: string[];
214
+ }>;
215
+ }, "strict", z.ZodTypeAny, {
216
+ reviews: {
217
+ chapterId: string;
218
+ expectedRevision: number;
219
+ reviewedAllFacts: true;
220
+ }[];
221
+ verification: {
222
+ sourceFiles: string[];
223
+ documentFiles: string[];
224
+ };
225
+ }, {
226
+ reviews: {
227
+ chapterId: string;
228
+ expectedRevision: number;
229
+ reviewedAllFacts: true;
230
+ }[];
231
+ verification: {
232
+ sourceFiles: string[];
233
+ documentFiles: string[];
234
+ };
235
+ }>;
236
+ type Draft = {
237
+ chapterId: string;
238
+ fact: z.infer<typeof Fact>;
239
+ fingerprint: string;
240
+ };
241
+ type Task = {
242
+ phase: 'active' | 'awaiting-approval';
243
+ paths: string[];
244
+ cache: Record<string, string>;
245
+ changes: Record<string, string>;
246
+ changeDetails?: Record<string, FactChange>;
247
+ pending: string[];
248
+ drafts: Draft[];
249
+ };
250
+ /** Ignored, task-scoped bookkeeping. No prompt history or model calls; only changed fact records and task metadata. */
251
+ export declare class Workflow {
252
+ readonly store: Store;
253
+ constructor(store: Store);
254
+ name(id: string): string;
255
+ task(id: string): Promise<Task>;
256
+ save(id: string, task: Task): Promise<void>;
257
+ reuse(id: string | undefined, key: unknown, value: unknown, context: unknown, refresh?: boolean): Promise<unknown>;
258
+ start(paths?: string[], signal?: string): Promise<{
259
+ state: string;
260
+ next: string;
261
+ proposalPath?: undefined;
262
+ } | {
263
+ state: string;
264
+ proposalPath: string;
265
+ next: {
266
+ action: string;
267
+ approvalRequired: boolean;
268
+ command: string;
269
+ schema: string;
270
+ guide: string;
271
+ authorization: string;
272
+ };
273
+ } | {
274
+ routes: {
275
+ items: {
276
+ chapterId: string;
277
+ title: string;
278
+ }[];
279
+ total: number;
280
+ hasMore: boolean;
281
+ };
282
+ next: string;
283
+ setup?: {
284
+ state: string;
285
+ boundariesApproved: boolean;
286
+ emptyChapters: string[];
287
+ next: {
288
+ action: string;
289
+ approvalRequired: boolean;
290
+ schema: string;
291
+ };
292
+ } | undefined;
293
+ taskId: `${string}-${string}-${string}-${string}-${string}`;
294
+ state?: undefined;
295
+ proposalPath?: undefined;
296
+ }>;
297
+ assess(id: string, paths: string[], cursor?: string, limit?: number, refresh?: boolean): Promise<unknown>;
298
+ prepare(input: unknown): Promise<{
299
+ noop: true;
300
+ proposalId?: undefined;
301
+ changedChapters?: undefined;
302
+ reviewedChapters?: undefined;
303
+ } | {
304
+ noop: false;
305
+ proposalId: `${string}-${string}-${string}-${string}-${string}`;
306
+ changedChapters: string[];
307
+ reviewedChapters: string[];
308
+ }>;
309
+ draftFingerprint(registry: RegistryRecord, chapterId: string, fact: z.infer<typeof Fact>): Promise<string>;
310
+ propose(id: string, chapterId: string, values: unknown): Promise<{
311
+ queued: number;
312
+ total: number;
313
+ sharedKnowledgeChanged: boolean;
314
+ }>;
315
+ draftStates(task: Task, registry: RegistryRecord): Promise<{
316
+ kind: string;
317
+ factId: string;
318
+ statement: string;
319
+ evidencePaths: string[];
320
+ stale: boolean;
321
+ recommendation: string;
322
+ }[]>;
323
+ finish(id: string, cursor?: string, limit?: number): Promise<{
324
+ reviewPrompt?: string | undefined;
325
+ reviewFormat?: string | undefined;
326
+ items: ({
327
+ kind: string;
328
+ factId: string;
329
+ statement: string;
330
+ evidencePaths: string[];
331
+ stale: boolean;
332
+ recommendation: string;
333
+ } | {
334
+ kind: string;
335
+ proposalId: string;
336
+ } | {
337
+ reason: string;
338
+ changedSinceUpdate: boolean;
339
+ evidenceStatus: string;
340
+ recommendation: string;
341
+ approvalRequired: boolean;
342
+ evidenceDetails?: string | undefined;
343
+ change?: string | undefined;
344
+ fields?: {
345
+ [k: string]: {
346
+ before: {} | null;
347
+ after: {} | null;
348
+ };
349
+ } | undefined;
350
+ evidencePaths?: string[] | undefined;
351
+ statement?: string | undefined;
352
+ kind: string;
353
+ factId: string;
354
+ })[];
355
+ total: number;
356
+ nextCursor: string | null;
357
+ notification: string;
358
+ }>;
359
+ proposals(id: string, cursor?: string, limit?: number): Promise<{
360
+ items: {
361
+ chapterId: string;
362
+ fact: z.infer<typeof Fact>;
363
+ }[];
364
+ total: number;
365
+ nextCursor: string | null;
366
+ }>;
367
+ drop(id: string, keys: string[]): Promise<{
368
+ remaining: number;
369
+ sharedKnowledgeChanged: boolean;
370
+ }>;
371
+ admissionPlan(id: string): Promise<{
372
+ task: Task;
373
+ registry: {
374
+ schemaVersion: 2;
375
+ pillars: {
376
+ id: string;
377
+ title: string;
378
+ scope: string;
379
+ excludes: string;
380
+ chapters: {
381
+ id: string;
382
+ title: string;
383
+ scope: string;
384
+ excludes: string;
385
+ paths: string[];
386
+ revision: number;
387
+ facts: {
388
+ id: string;
389
+ statement: string;
390
+ evidence: {
391
+ path: string;
392
+ quote: string;
393
+ }[];
394
+ sourceScope: string[];
395
+ dependsOn: string[];
396
+ }[];
397
+ sources: Record<string, string>;
398
+ dependencyFingerprints: Record<string, string>;
399
+ }[];
400
+ }[];
401
+ };
402
+ candidate: {
403
+ schemaVersion: 2;
404
+ pillars: {
405
+ id: string;
406
+ title: string;
407
+ scope: string;
408
+ excludes: string;
409
+ chapters: {
410
+ id: string;
411
+ title: string;
412
+ scope: string;
413
+ excludes: string;
414
+ paths: string[];
415
+ revision: number;
416
+ facts: {
417
+ id: string;
418
+ statement: string;
419
+ evidence: {
420
+ path: string;
421
+ quote: string;
422
+ }[];
423
+ sourceScope: string[];
424
+ dependsOn: string[];
425
+ }[];
426
+ sources: Record<string, string>;
427
+ dependencyFingerprints: Record<string, string>;
428
+ }[];
429
+ }[];
430
+ };
431
+ keys: string[];
432
+ }>;
433
+ proposalReview(id: string, cursor?: string, limit?: number): Promise<{
434
+ items: ({
435
+ kind: string;
436
+ chapterId: string;
437
+ expectedRevision: number;
438
+ } | {
439
+ kind: string;
440
+ path: string;
441
+ })[];
442
+ total: number;
443
+ nextCursor: string | null;
444
+ }>;
445
+ accept(id: string, input: unknown): Promise<{
446
+ admitted: number;
447
+ changedChapters: string[];
448
+ }>;
449
+ }
450
+ export {};