peaks-loop 4.0.21 → 4.0.24

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 (57) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/dist/cli/commands/_register.js +2 -1
  3. package/dist/cli/commands/best-practice-scan-command.d.ts +36 -0
  4. package/dist/cli/commands/best-practice-scan-command.js +118 -0
  5. package/dist/cli/commands/request-commands.js +21 -9
  6. package/dist/services/best-practice/language-detector.d.ts +7 -0
  7. package/dist/services/best-practice/language-detector.js +96 -0
  8. package/dist/services/best-practice/output-formatter.d.ts +41 -0
  9. package/dist/services/best-practice/output-formatter.js +116 -0
  10. package/dist/services/best-practice/scan-orchestrator.d.ts +39 -0
  11. package/dist/services/best-practice/scan-orchestrator.js +85 -0
  12. package/dist/services/context/collector.d.ts +5 -12
  13. package/dist/services/context/context-builder.d.ts +12 -20
  14. package/dist/services/context/context-builder.js +1 -1
  15. package/dist/services/context/context-schema.d.ts +51 -364
  16. package/dist/services/context/context-schema.js +3 -3
  17. package/dist/services/crystallization/crystallization-service.d.ts +2 -12
  18. package/dist/services/crystallization/crystallization-service.js +3 -9
  19. package/dist/services/crystallization/crystallization-types.d.ts +45 -153
  20. package/dist/services/crystallization/crystallization-types.js +17 -11
  21. package/dist/services/crystallization/evidence-brief-builder.d.ts +12 -112
  22. package/dist/services/evolution/evolution-types.d.ts +83 -497
  23. package/dist/services/evolution/evolution-types.js +6 -10
  24. package/dist/services/fixture/fixture-sanitize-service.d.ts +10 -36
  25. package/dist/services/fixture/fixture-sanitize-service.js +1 -1
  26. package/dist/services/job/job-progress-store.d.ts +1 -17
  27. package/dist/services/job/job-progress-store.js +2 -2
  28. package/dist/services/job/job-types.d.ts +63 -370
  29. package/dist/services/job/job-types.js +46 -11
  30. package/dist/services/loop/loop-bee-relation-types.d.ts +20 -32
  31. package/dist/services/loop/loop-bee-relation-types.js +2 -2
  32. package/dist/services/loop/loop-release-types.d.ts +31 -110
  33. package/dist/services/migrate-skill-name/schema.d.ts +3 -19
  34. package/dist/services/migrate-skill-name/schema.js +4 -4
  35. package/dist/services/observability/observability-service.d.ts +21 -19
  36. package/dist/services/observability/observability-service.js +1 -1
  37. package/dist/services/prd/best-practice-auto-trigger.d.ts +61 -0
  38. package/dist/services/prd/best-practice-auto-trigger.js +126 -0
  39. package/dist/services/rd/types.d.ts +25 -194
  40. package/dist/services/sediment/json-schema.d.ts +39 -224
  41. package/dist/services/sediment/json-schema.js +2 -2
  42. package/dist/services/session/binding-store.d.ts +5 -47
  43. package/dist/services/session/binding-store.js +1 -1
  44. package/dist/services/share/bundle-types.d.ts +12 -180
  45. package/dist/services/share/bundle-types.js +15 -9
  46. package/dist/services/share/run-state-contract.d.ts +8 -25
  47. package/dist/services/skill/skill-search-service.d.ts +26 -46
  48. package/dist/services/skill/skill-search-service.js +2 -2
  49. package/dist/services/skills/hooks-settings-service.d.ts +9 -0
  50. package/dist/services/skills/hooks-settings-service.js +31 -1
  51. package/dist/services/skills/skill-presence-service.d.ts +24 -0
  52. package/dist/services/skills/skill-presence-service.js +33 -0
  53. package/package.json +8 -8
  54. package/schemas/context.schema.json +17 -8
  55. package/skills/bee/peaks-prd/SKILL.md +17 -0
  56. package/skills/peaks-code/SKILL.md +28 -1
  57. package/skills/peaks-code/references/skill-presence-and-title.md +3 -3
@@ -0,0 +1,85 @@
1
+ const DEFAULT_CONTEXT7_TIMEOUT_MS = 30_000;
2
+ const DEFAULT_CONTEXT7_DELAY_MS = 100;
3
+ const DEFAULT_WEBSEARCH_DELAY_MS = 200;
4
+ const defaultContext7Lookup = async (intent, language) => {
5
+ // TODO: real MCP integration — call `@upstash/context7-mcp`'s
6
+ // resolve-library-id + query-docs and translate errors into the
7
+ // shared `{ ok, results }` envelope.
8
+ await new Promise((resolveFn) => setTimeout(resolveFn, DEFAULT_CONTEXT7_DELAY_MS));
9
+ return {
10
+ ok: true,
11
+ results: [
12
+ {
13
+ title: `Context7 ${language} doc for "${intent}"`,
14
+ url: `https://context7.com/${language}/${encodeURIComponent(intent)}`,
15
+ snippet: `best practice for ${intent} in ${language} (context7 stub)`
16
+ }
17
+ ]
18
+ };
19
+ };
20
+ const defaultWebSearchLookup = async (intent, language) => {
21
+ // TODO: real web search wiring — use Context7 WebSearch tool or
22
+ // WebFetch + ranking; current stub returns a synthetic fragment.
23
+ await new Promise((resolveFn) => setTimeout(resolveFn, DEFAULT_WEBSEARCH_DELAY_MS));
24
+ return {
25
+ ok: true,
26
+ results: [
27
+ {
28
+ title: `WebSearch ${language} case for "${intent}"`,
29
+ url: `https://example.com/search?q=${encodeURIComponent(intent)}&lang=${language}`,
30
+ snippet: `implementation example for ${intent} in ${language} (websearch stub)`
31
+ }
32
+ ]
33
+ };
34
+ };
35
+ export async function scanBestPractice(opts) {
36
+ const timeoutMs = opts.context7TimeoutMs ?? DEFAULT_CONTEXT7_TIMEOUT_MS;
37
+ const startedAt = Date.now();
38
+ opts.io.stdout(`[scan-orchestrator] querying context7 for "${opts.intent}" (${opts.language})`);
39
+ let context7Outcome = null;
40
+ let context7Error = null;
41
+ try {
42
+ const ctxPromise = defaultContext7Lookup(opts.intent, opts.language);
43
+ const ctxTimer = new Promise((_, reject) => {
44
+ setTimeout(() => reject(new Error(`context7 timeout after ${timeoutMs}ms`)), timeoutMs).unref();
45
+ });
46
+ context7Outcome = await Promise.race([ctxPromise, ctxTimer]);
47
+ }
48
+ catch (err) {
49
+ context7Error = err instanceof Error ? err.message : String(err);
50
+ opts.io.stderr(`[scan-orchestrator] context7 failed: ${context7Error}`);
51
+ }
52
+ if (context7Outcome !== null && context7Outcome.ok && context7Outcome.results.length > 0) {
53
+ return {
54
+ results: context7Outcome.results,
55
+ fragments: context7Outcome.results,
56
+ source: 'context7',
57
+ elapsedMs: Date.now() - startedAt
58
+ };
59
+ }
60
+ opts.io.stdout(`[scan-orchestrator] falling back to websearch for "${opts.intent}" (${opts.language})`);
61
+ let webOutcome = null;
62
+ let webError = null;
63
+ try {
64
+ webOutcome = await defaultWebSearchLookup(opts.intent, opts.language);
65
+ }
66
+ catch (err) {
67
+ webError = err instanceof Error ? err.message : String(err);
68
+ opts.io.stderr(`[scan-orchestrator] websearch failed: ${webError}`);
69
+ }
70
+ if (webOutcome !== null && webOutcome.ok && webOutcome.results.length > 0) {
71
+ return {
72
+ results: webOutcome.results,
73
+ fragments: webOutcome.results,
74
+ source: 'websearch',
75
+ elapsedMs: Date.now() - startedAt
76
+ };
77
+ }
78
+ opts.io.stderr('[scan-orchestrator] both sources empty; returning empty fallback');
79
+ return {
80
+ results: [],
81
+ fragments: [],
82
+ source: 'fallback',
83
+ elapsedMs: Date.now() - startedAt
84
+ };
85
+ }
@@ -3,19 +3,12 @@ import type { CollectorOutput } from './types.js';
3
3
  declare const CollectInputSchema: z.ZodObject<{
4
4
  goal: z.ZodString;
5
5
  project: z.ZodString;
6
- depsMode: z.ZodEnum<["locked", "latest"]>;
6
+ depsMode: z.ZodEnum<{
7
+ latest: "latest";
8
+ locked: "locked";
9
+ }>;
7
10
  out: z.ZodOptional<z.ZodString>;
8
- }, "strip", z.ZodTypeAny, {
9
- project: string;
10
- goal: string;
11
- depsMode: "latest" | "locked";
12
- out?: string | undefined;
13
- }, {
14
- project: string;
15
- goal: string;
16
- depsMode: "latest" | "locked";
17
- out?: string | undefined;
18
- }>;
11
+ }, z.core.$strip>;
19
12
  export type CollectInput = z.infer<typeof CollectInputSchema>;
20
13
  export declare function collectContext(rawInput: unknown): Promise<{
21
14
  readonly goal: string;
@@ -3,28 +3,20 @@ import type { ContextJson } from './types.js';
3
3
  declare const BuildInputSchema: z.ZodObject<{
4
4
  goal: z.ZodString;
5
5
  project: z.ZodString;
6
- audience: z.ZodEnum<["peaks-rd", "peaks-qa", "peaks-mut", "all"]>;
7
- depsMode: z.ZodEnum<["locked", "latest"]>;
6
+ audience: z.ZodEnum<{
7
+ all: "all";
8
+ "peaks-rd": "peaks-rd";
9
+ "peaks-qa": "peaks-qa";
10
+ "peaks-mut": "peaks-mut";
11
+ }>;
12
+ depsMode: z.ZodEnum<{
13
+ latest: "latest";
14
+ locked: "locked";
15
+ }>;
8
16
  docBudgetTokens: z.ZodDefault<z.ZodNumber>;
9
17
  out: z.ZodString;
10
- fetcher: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
11
- }, "strip", z.ZodTypeAny, {
12
- project: string;
13
- goal: string;
14
- audience: "all" | "peaks-rd" | "peaks-qa" | "peaks-mut";
15
- depsMode: "latest" | "locked";
16
- out: string;
17
- docBudgetTokens: number;
18
- fetcher: (...args: unknown[]) => unknown;
19
- }, {
20
- project: string;
21
- goal: string;
22
- audience: "all" | "peaks-rd" | "peaks-qa" | "peaks-mut";
23
- depsMode: "latest" | "locked";
24
- out: string;
25
- fetcher: (...args: unknown[]) => unknown;
26
- docBudgetTokens?: number | undefined;
27
- }>;
18
+ fetcher: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
19
+ }, z.core.$strip>;
28
20
  export type BuildInput = z.infer<typeof BuildInputSchema>;
29
21
  export declare function buildContext(rawInput: unknown): Promise<ContextJson>;
30
22
  export {};
@@ -19,7 +19,7 @@ const BuildInputSchema = z.object({
19
19
  project: z.string().min(1),
20
20
  audience: z.enum(['peaks-rd', 'peaks-qa', 'peaks-mut', 'all']),
21
21
  depsMode: z.enum(['locked', 'latest']),
22
- docBudgetTokens: z.number().int().positive().default(8000),
22
+ docBudgetTokens: z.number().int().gt(0).default(8000),
23
23
  out: z.string().min(1),
24
24
  fetcher: z.function(),
25
25
  });
@@ -11,114 +11,44 @@ export declare const ContextJsonSchema: z.ZodObject<{
11
11
  collector: z.ZodObject<{
12
12
  files: z.ZodArray<z.ZodObject<{
13
13
  path: z.ZodString;
14
- kind: z.ZodEnum<["source", "test", "config", "doc"]>;
14
+ kind: z.ZodEnum<{
15
+ doc: "doc";
16
+ source: "source";
17
+ config: "config";
18
+ test: "test";
19
+ }>;
15
20
  lines: z.ZodNumber;
16
21
  hash: z.ZodString;
17
- }, "strip", z.ZodTypeAny, {
18
- path: string;
19
- lines: number;
20
- kind: "doc" | "source" | "config" | "test";
21
- hash: string;
22
- }, {
23
- path: string;
24
- lines: number;
25
- kind: "doc" | "source" | "config" | "test";
26
- hash: string;
27
- }>, "many">;
22
+ }, z.core.$strip>>;
28
23
  gitStatus: z.ZodObject<{
29
24
  branch: z.ZodString;
30
25
  lastCommit: z.ZodString;
31
26
  dirty: z.ZodBoolean;
32
- }, "strip", z.ZodTypeAny, {
33
- dirty: boolean;
34
- branch: string;
35
- lastCommit: string;
36
- }, {
37
- dirty: boolean;
38
- branch: string;
39
- lastCommit: string;
40
- }>;
27
+ }, z.core.$strip>;
41
28
  memoryEntries: z.ZodArray<z.ZodObject<{
42
29
  path: z.ZodString;
43
30
  title: z.ZodString;
44
31
  relevanceScore: z.ZodNumber;
45
32
  excerptHash: z.ZodString;
46
- }, "strip", z.ZodTypeAny, {
47
- path: string;
48
- title: string;
49
- relevanceScore: number;
50
- excerptHash: string;
51
- }, {
52
- path: string;
53
- title: string;
54
- relevanceScore: number;
55
- excerptHash: string;
56
- }>, "many">;
33
+ }, z.core.$strip>>;
57
34
  deps: z.ZodRecord<z.ZodString, z.ZodObject<{
58
35
  version: z.ZodString;
59
- source: z.ZodEnum<["package.json", "pnpm-lock.yaml", "yarn.lock"]>;
36
+ source: z.ZodEnum<{
37
+ "package.json": "package.json";
38
+ "pnpm-lock.yaml": "pnpm-lock.yaml";
39
+ "yarn.lock": "yarn.lock";
40
+ }>;
60
41
  resolved: z.ZodString;
61
- }, "strip", z.ZodTypeAny, {
62
- version: string;
63
- source: "package.json" | "pnpm-lock.yaml" | "yarn.lock";
64
- resolved: string;
65
- }, {
66
- version: string;
67
- source: "package.json" | "pnpm-lock.yaml" | "yarn.lock";
68
- resolved: string;
69
- }>>;
70
- }, "strip", z.ZodTypeAny, {
71
- files: {
72
- path: string;
73
- lines: number;
74
- kind: "doc" | "source" | "config" | "test";
75
- hash: string;
76
- }[];
77
- deps: Record<string, {
78
- version: string;
79
- source: "package.json" | "pnpm-lock.yaml" | "yarn.lock";
80
- resolved: string;
81
- }>;
82
- gitStatus: {
83
- dirty: boolean;
84
- branch: string;
85
- lastCommit: string;
86
- };
87
- memoryEntries: {
88
- path: string;
89
- title: string;
90
- relevanceScore: number;
91
- excerptHash: string;
92
- }[];
93
- }, {
94
- files: {
95
- path: string;
96
- lines: number;
97
- kind: "doc" | "source" | "config" | "test";
98
- hash: string;
99
- }[];
100
- deps: Record<string, {
101
- version: string;
102
- source: "package.json" | "pnpm-lock.yaml" | "yarn.lock";
103
- resolved: string;
104
- }>;
105
- gitStatus: {
106
- dirty: boolean;
107
- branch: string;
108
- lastCommit: string;
109
- };
110
- memoryEntries: {
111
- path: string;
112
- title: string;
113
- relevanceScore: number;
114
- excerptHash: string;
115
- }[];
116
- }>;
42
+ }, z.core.$strip>>;
43
+ }, z.core.$strip>;
117
44
  docRetriever: z.ZodObject<{
118
45
  fetchedDocs: z.ZodArray<z.ZodObject<{
119
46
  dep: z.ZodString;
120
47
  version: z.ZodString;
121
- source: z.ZodEnum<["local-cache", "remote-fetch"]>;
48
+ source: z.ZodEnum<{
49
+ "local-cache": "local-cache";
50
+ "remote-fetch": "remote-fetch";
51
+ }>;
122
52
  url: z.ZodOptional<z.ZodString>;
123
53
  fetchedAt: z.ZodString;
124
54
  contentHash: z.ZodString;
@@ -126,290 +56,47 @@ export declare const ContextJsonSchema: z.ZodObject<{
126
56
  title: z.ZodString;
127
57
  tokenEstimate: z.ZodNumber;
128
58
  excerpt: z.ZodString;
129
- }, "strip", z.ZodTypeAny, {
130
- title: string;
131
- tokenEstimate: number;
132
- excerpt: string;
133
- }, {
134
- title: string;
135
- tokenEstimate: number;
136
- excerpt: string;
137
- }>, "many">;
59
+ }, z.core.$strip>>;
138
60
  stale: z.ZodBoolean;
139
- }, "strip", z.ZodTypeAny, {
140
- version: string;
141
- stale: boolean;
142
- source: "local-cache" | "remote-fetch";
143
- dep: string;
144
- fetchedAt: string;
145
- contentHash: string;
146
- sections: {
147
- title: string;
148
- tokenEstimate: number;
149
- excerpt: string;
150
- }[];
151
- url?: string | undefined;
152
- }, {
153
- version: string;
154
- stale: boolean;
155
- source: "local-cache" | "remote-fetch";
156
- dep: string;
157
- fetchedAt: string;
158
- contentHash: string;
159
- sections: {
160
- title: string;
161
- tokenEstimate: number;
162
- excerpt: string;
163
- }[];
164
- url?: string | undefined;
165
- }>, "many">;
61
+ }, z.core.$strip>>;
166
62
  skipped: z.ZodArray<z.ZodObject<{
167
63
  dep: z.ZodString;
168
- reason: z.ZodEnum<["unconfigured", "network_error", "version_unknown"]>;
169
- }, "strip", z.ZodTypeAny, {
170
- reason: "unconfigured" | "network_error" | "version_unknown";
171
- dep: string;
172
- }, {
173
- reason: "unconfigured" | "network_error" | "version_unknown";
174
- dep: string;
175
- }>, "many">;
176
- }, "strip", z.ZodTypeAny, {
177
- skipped: {
178
- reason: "unconfigured" | "network_error" | "version_unknown";
179
- dep: string;
180
- }[];
181
- fetchedDocs: {
182
- version: string;
183
- stale: boolean;
184
- source: "local-cache" | "remote-fetch";
185
- dep: string;
186
- fetchedAt: string;
187
- contentHash: string;
188
- sections: {
189
- title: string;
190
- tokenEstimate: number;
191
- excerpt: string;
192
- }[];
193
- url?: string | undefined;
194
- }[];
195
- }, {
196
- skipped: {
197
- reason: "unconfigured" | "network_error" | "version_unknown";
198
- dep: string;
199
- }[];
200
- fetchedDocs: {
201
- version: string;
202
- stale: boolean;
203
- source: "local-cache" | "remote-fetch";
204
- dep: string;
205
- fetchedAt: string;
206
- contentHash: string;
207
- sections: {
208
- title: string;
209
- tokenEstimate: number;
210
- excerpt: string;
211
- }[];
212
- url?: string | undefined;
213
- }[];
214
- }>;
64
+ reason: z.ZodEnum<{
65
+ unconfigured: "unconfigured";
66
+ network_error: "network_error";
67
+ version_unknown: "version_unknown";
68
+ }>;
69
+ }, z.core.$strip>>;
70
+ }, z.core.$strip>;
215
71
  tokenizer: z.ZodObject<{
216
72
  metadata: z.ZodArray<z.ZodObject<{
217
73
  id: z.ZodString;
218
- kind: z.ZodEnum<["doc", "code", "memory", "git"]>;
74
+ kind: z.ZodEnum<{
75
+ git: "git";
76
+ code: "code";
77
+ doc: "doc";
78
+ memory: "memory";
79
+ }>;
219
80
  version: z.ZodOptional<z.ZodString>;
220
- blastRadius: z.ZodArray<z.ZodString, "many">;
81
+ blastRadius: z.ZodArray<z.ZodString>;
221
82
  conflictScore: z.ZodNumber;
222
83
  timeDecayScore: z.ZodNumber;
223
- tags: z.ZodArray<z.ZodString, "many">;
224
- }, "strip", z.ZodTypeAny, {
225
- id: string;
226
- kind: "git" | "code" | "doc" | "memory";
227
- tags: string[];
228
- blastRadius: string[];
229
- conflictScore: number;
230
- timeDecayScore: number;
231
- version?: string | undefined;
232
- }, {
233
- id: string;
234
- kind: "git" | "code" | "doc" | "memory";
235
- tags: string[];
236
- blastRadius: string[];
237
- conflictScore: number;
238
- timeDecayScore: number;
239
- version?: string | undefined;
240
- }>, "many">;
241
- }, "strip", z.ZodTypeAny, {
242
- metadata: {
243
- id: string;
244
- kind: "git" | "code" | "doc" | "memory";
245
- tags: string[];
246
- blastRadius: string[];
247
- conflictScore: number;
248
- timeDecayScore: number;
249
- version?: string | undefined;
250
- }[];
251
- }, {
252
- metadata: {
253
- id: string;
254
- kind: "git" | "code" | "doc" | "memory";
255
- tags: string[];
256
- blastRadius: string[];
257
- conflictScore: number;
258
- timeDecayScore: number;
259
- version?: string | undefined;
260
- }[];
261
- }>;
84
+ tags: z.ZodArray<z.ZodString>;
85
+ }, z.core.$strip>>;
86
+ }, z.core.$strip>;
262
87
  renderer: z.ZodObject<{
263
- audience: z.ZodEnum<["peaks-rd", "peaks-qa", "peaks-mut", "all"]>;
88
+ audience: z.ZodEnum<{
89
+ all: "all";
90
+ "peaks-rd": "peaks-rd";
91
+ "peaks-qa": "peaks-qa";
92
+ "peaks-mut": "peaks-mut";
93
+ }>;
264
94
  renderedAt: z.ZodString;
265
95
  sizeBytes: z.ZodNumber;
266
96
  truncated: z.ZodBoolean;
267
- truncatedReason: z.ZodOptional<z.ZodEnum<["doc_budget_exceeded", "section_count_exceeded"]>>;
268
- }, "strip", z.ZodTypeAny, {
269
- sizeBytes: number;
270
- truncated: boolean;
271
- audience: "all" | "peaks-rd" | "peaks-qa" | "peaks-mut";
272
- renderedAt: string;
273
- truncatedReason?: "doc_budget_exceeded" | "section_count_exceeded" | undefined;
274
- }, {
275
- sizeBytes: number;
276
- truncated: boolean;
277
- audience: "all" | "peaks-rd" | "peaks-qa" | "peaks-mut";
278
- renderedAt: string;
279
- truncatedReason?: "doc_budget_exceeded" | "section_count_exceeded" | undefined;
280
- }>;
281
- }, "strip", z.ZodTypeAny, {
282
- version: "1.0";
283
- goal: string;
284
- sha256: string;
285
- generatedAt: string;
286
- collector: {
287
- files: {
288
- path: string;
289
- lines: number;
290
- kind: "doc" | "source" | "config" | "test";
291
- hash: string;
292
- }[];
293
- deps: Record<string, {
294
- version: string;
295
- source: "package.json" | "pnpm-lock.yaml" | "yarn.lock";
296
- resolved: string;
297
- }>;
298
- gitStatus: {
299
- dirty: boolean;
300
- branch: string;
301
- lastCommit: string;
302
- };
303
- memoryEntries: {
304
- path: string;
305
- title: string;
306
- relevanceScore: number;
307
- excerptHash: string;
308
- }[];
309
- };
310
- docRetriever: {
311
- skipped: {
312
- reason: "unconfigured" | "network_error" | "version_unknown";
313
- dep: string;
314
- }[];
315
- fetchedDocs: {
316
- version: string;
317
- stale: boolean;
318
- source: "local-cache" | "remote-fetch";
319
- dep: string;
320
- fetchedAt: string;
321
- contentHash: string;
322
- sections: {
323
- title: string;
324
- tokenEstimate: number;
325
- excerpt: string;
326
- }[];
327
- url?: string | undefined;
328
- }[];
329
- };
330
- tokenizer: {
331
- metadata: {
332
- id: string;
333
- kind: "git" | "code" | "doc" | "memory";
334
- tags: string[];
335
- blastRadius: string[];
336
- conflictScore: number;
337
- timeDecayScore: number;
338
- version?: string | undefined;
339
- }[];
340
- };
341
- renderer: {
342
- sizeBytes: number;
343
- truncated: boolean;
344
- audience: "all" | "peaks-rd" | "peaks-qa" | "peaks-mut";
345
- renderedAt: string;
346
- truncatedReason?: "doc_budget_exceeded" | "section_count_exceeded" | undefined;
347
- };
348
- }, {
349
- version: "1.0";
350
- goal: string;
351
- sha256: string;
352
- generatedAt: string;
353
- collector: {
354
- files: {
355
- path: string;
356
- lines: number;
357
- kind: "doc" | "source" | "config" | "test";
358
- hash: string;
359
- }[];
360
- deps: Record<string, {
361
- version: string;
362
- source: "package.json" | "pnpm-lock.yaml" | "yarn.lock";
363
- resolved: string;
364
- }>;
365
- gitStatus: {
366
- dirty: boolean;
367
- branch: string;
368
- lastCommit: string;
369
- };
370
- memoryEntries: {
371
- path: string;
372
- title: string;
373
- relevanceScore: number;
374
- excerptHash: string;
375
- }[];
376
- };
377
- docRetriever: {
378
- skipped: {
379
- reason: "unconfigured" | "network_error" | "version_unknown";
380
- dep: string;
381
- }[];
382
- fetchedDocs: {
383
- version: string;
384
- stale: boolean;
385
- source: "local-cache" | "remote-fetch";
386
- dep: string;
387
- fetchedAt: string;
388
- contentHash: string;
389
- sections: {
390
- title: string;
391
- tokenEstimate: number;
392
- excerpt: string;
393
- }[];
394
- url?: string | undefined;
395
- }[];
396
- };
397
- tokenizer: {
398
- metadata: {
399
- id: string;
400
- kind: "git" | "code" | "doc" | "memory";
401
- tags: string[];
402
- blastRadius: string[];
403
- conflictScore: number;
404
- timeDecayScore: number;
405
- version?: string | undefined;
406
- }[];
407
- };
408
- renderer: {
409
- sizeBytes: number;
410
- truncated: boolean;
411
- audience: "all" | "peaks-rd" | "peaks-qa" | "peaks-mut";
412
- renderedAt: string;
413
- truncatedReason?: "doc_budget_exceeded" | "section_count_exceeded" | undefined;
414
- };
415
- }>;
97
+ truncatedReason: z.ZodOptional<z.ZodEnum<{
98
+ doc_budget_exceeded: "doc_budget_exceeded";
99
+ section_count_exceeded: "section_count_exceeded";
100
+ }>>;
101
+ }, z.core.$strip>;
102
+ }, z.core.$strip>;
@@ -12,7 +12,7 @@ export const ContextJsonSchema = z.object({
12
12
  files: z.array(z.object({
13
13
  path: z.string(),
14
14
  kind: z.enum(['source', 'test', 'config', 'doc']),
15
- lines: z.number().int().nonnegative(),
15
+ lines: z.number().int().gte(0),
16
16
  hash: z.string(),
17
17
  })),
18
18
  gitStatus: z.object({
@@ -42,7 +42,7 @@ export const ContextJsonSchema = z.object({
42
42
  contentHash: z.string(),
43
43
  sections: z.array(z.object({
44
44
  title: z.string(),
45
- tokenEstimate: z.number().int().nonnegative(),
45
+ tokenEstimate: z.number().int().gte(0),
46
46
  excerpt: z.string(),
47
47
  })),
48
48
  stale: z.boolean(),
@@ -66,7 +66,7 @@ export const ContextJsonSchema = z.object({
66
66
  renderer: z.object({
67
67
  audience: z.enum(['peaks-rd', 'peaks-qa', 'peaks-mut', 'all']),
68
68
  renderedAt: z.string().datetime(),
69
- sizeBytes: z.number().int().nonnegative(),
69
+ sizeBytes: z.number().int().gte(0),
70
70
  truncated: z.boolean(),
71
71
  truncatedReason: z.enum(['doc_budget_exceeded', 'section_count_exceeded']).optional(),
72
72
  }),
@@ -70,17 +70,7 @@ export declare const CrystallizationTaskStateSchema: z.ZodObject<{
70
70
  task_status: z.ZodLiteral<"completed">;
71
71
  gates_passed: z.ZodLiteral<true>;
72
72
  evidence_collected: z.ZodLiteral<true>;
73
- }, "strip", z.ZodTypeAny, {
74
- task_id: string;
75
- task_status: "completed";
76
- gates_passed: true;
77
- evidence_collected: true;
78
- }, {
79
- task_id: string;
80
- task_status: "completed";
81
- gates_passed: true;
82
- evidence_collected: true;
83
- }>;
73
+ }, z.core.$strip>;
84
74
  export type CrystallizationTaskState = z.infer<typeof CrystallizationTaskStateSchema>;
85
75
  export type CrystallizationIntegrityErrorCode = "CRYSTALLIZATION_PRE_RUN" | "CRYSTALLIZATION_INVALID_TASK_STATE" | "CRYSTALLIZATION_TX_FAILED" | "MISSING_BRIEF_SECTION";
86
76
  export declare class CrystallizationIntegrityError extends Error {
@@ -183,7 +173,6 @@ export declare class CrystallizationService {
183
173
  * (newest-first).
184
174
  */
185
175
  list(opts?: Parameters<typeof listCrystallizationEvents>[1]): {
186
- schema_version: "peaks.crystallization/1";
187
176
  trigger: "user_explicit" | "llm_suggested" | "success_default_prompt" | "similar_task_recurrence";
188
177
  evidence_brief: {
189
178
  what_happened: string;
@@ -197,6 +186,7 @@ export declare class CrystallizationService {
197
186
  user_decision_summary: string;
198
187
  lifecycle_status: "candidate" | "stable" | "retired";
199
188
  id: string;
189
+ schema_version: "peaks.crystallization/1";
200
190
  created_at: string;
201
191
  created_loop_release_id?: string | undefined;
202
192
  updated_loop_release_id?: string | undefined;