@unpolarize/code-sessions-schema 0.1.0 → 0.2.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/dist/index.d.ts +58 -10
- package/dist/index.js +18 -0
- package/package.json +13 -4
- package/src/schemas.ts +23 -0
package/dist/index.d.ts
CHANGED
|
@@ -211,6 +211,17 @@ declare const SessionSchema: z.ZodObject<{
|
|
|
211
211
|
}>>;
|
|
212
212
|
title: z.ZodOptional<z.ZodString>;
|
|
213
213
|
labels: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
214
|
+
/** lineage when this session was forked from another at a turn ("git for sessions") */
|
|
215
|
+
forked_from: z.ZodOptional<z.ZodObject<{
|
|
216
|
+
session_id: z.ZodString;
|
|
217
|
+
turn_index: z.ZodNumber;
|
|
218
|
+
}, "strict", z.ZodTypeAny, {
|
|
219
|
+
session_id: string;
|
|
220
|
+
turn_index: number;
|
|
221
|
+
}, {
|
|
222
|
+
session_id: string;
|
|
223
|
+
turn_index: number;
|
|
224
|
+
}>>;
|
|
214
225
|
native_ref: z.ZodObject<{
|
|
215
226
|
format: z.ZodString;
|
|
216
227
|
uuid: z.ZodString;
|
|
@@ -244,6 +255,10 @@ declare const SessionSchema: z.ZodObject<{
|
|
|
244
255
|
started_at?: string | undefined;
|
|
245
256
|
ended_at?: string | undefined;
|
|
246
257
|
title?: string | undefined;
|
|
258
|
+
forked_from?: {
|
|
259
|
+
session_id: string;
|
|
260
|
+
turn_index: number;
|
|
261
|
+
} | undefined;
|
|
247
262
|
}, {
|
|
248
263
|
schema: "session-store/session@1";
|
|
249
264
|
session_id: string;
|
|
@@ -267,7 +282,13 @@ declare const SessionSchema: z.ZodObject<{
|
|
|
267
282
|
} | undefined;
|
|
268
283
|
title?: string | undefined;
|
|
269
284
|
labels?: string[] | undefined;
|
|
285
|
+
forked_from?: {
|
|
286
|
+
session_id: string;
|
|
287
|
+
turn_index: number;
|
|
288
|
+
} | undefined;
|
|
270
289
|
}>;
|
|
290
|
+
/** What the session was about — the user's intent behind the prompt(s). */
|
|
291
|
+
declare const INTENTS: readonly ["feature", "bugfix", "refactor", "research", "docs", "ops", "review", "chore", "other"];
|
|
271
292
|
declare const SIGNAL_KINDS: readonly ["stuck-loop", "error-recovery", "high-cost-turn", "long-session", "affect-negative", "affect-positive", "tool-heavy", "other"];
|
|
272
293
|
declare const SignalSchema: z.ZodObject<{
|
|
273
294
|
kind: z.ZodEnum<["stuck-loop", "error-recovery", "high-cost-turn", "long-session", "affect-negative", "affect-positive", "tool-heavy", "other"]>;
|
|
@@ -275,12 +296,12 @@ declare const SignalSchema: z.ZodObject<{
|
|
|
275
296
|
turn_index: z.ZodOptional<z.ZodNumber>;
|
|
276
297
|
note: z.ZodOptional<z.ZodString>;
|
|
277
298
|
}, "strict", z.ZodTypeAny, {
|
|
278
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
299
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
279
300
|
severity: "info" | "warn" | "critical";
|
|
280
301
|
turn_index?: number | undefined;
|
|
281
302
|
note?: string | undefined;
|
|
282
303
|
}, {
|
|
283
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
304
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
284
305
|
turn_index?: number | undefined;
|
|
285
306
|
severity?: "info" | "warn" | "critical" | undefined;
|
|
286
307
|
note?: string | undefined;
|
|
@@ -293,19 +314,23 @@ declare const InsightsSchema: z.ZodObject<{
|
|
|
293
314
|
generated_at: z.ZodString;
|
|
294
315
|
provider: z.ZodString;
|
|
295
316
|
topic: z.ZodOptional<z.ZodString>;
|
|
317
|
+
/** what the session was about (feature/bugfix/research/…) */
|
|
318
|
+
intent: z.ZodOptional<z.ZodEnum<["feature", "bugfix", "refactor", "research", "docs", "ops", "review", "chore", "other"]>>;
|
|
296
319
|
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
320
|
+
/** project ids the session touched (derived from edited file paths) */
|
|
321
|
+
projects: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
297
322
|
signals: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
298
323
|
kind: z.ZodEnum<["stuck-loop", "error-recovery", "high-cost-turn", "long-session", "affect-negative", "affect-positive", "tool-heavy", "other"]>;
|
|
299
324
|
severity: z.ZodDefault<z.ZodEnum<["info", "warn", "critical"]>>;
|
|
300
325
|
turn_index: z.ZodOptional<z.ZodNumber>;
|
|
301
326
|
note: z.ZodOptional<z.ZodString>;
|
|
302
327
|
}, "strict", z.ZodTypeAny, {
|
|
303
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
328
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
304
329
|
severity: "info" | "warn" | "critical";
|
|
305
330
|
turn_index?: number | undefined;
|
|
306
331
|
note?: string | undefined;
|
|
307
332
|
}, {
|
|
308
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
333
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
309
334
|
turn_index?: number | undefined;
|
|
310
335
|
severity?: "info" | "warn" | "critical" | undefined;
|
|
311
336
|
note?: string | undefined;
|
|
@@ -318,13 +343,15 @@ declare const InsightsSchema: z.ZodObject<{
|
|
|
318
343
|
generated_at: string;
|
|
319
344
|
provider: string;
|
|
320
345
|
tags: string[];
|
|
346
|
+
projects: string[];
|
|
321
347
|
signals: {
|
|
322
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
348
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
323
349
|
severity: "info" | "warn" | "critical";
|
|
324
350
|
turn_index?: number | undefined;
|
|
325
351
|
note?: string | undefined;
|
|
326
352
|
}[];
|
|
327
353
|
topic?: string | undefined;
|
|
354
|
+
intent?: "feature" | "bugfix" | "refactor" | "research" | "docs" | "ops" | "review" | "chore" | "other" | undefined;
|
|
328
355
|
summary?: string | undefined;
|
|
329
356
|
}, {
|
|
330
357
|
schema: "session-store/insights@1";
|
|
@@ -333,9 +360,11 @@ declare const InsightsSchema: z.ZodObject<{
|
|
|
333
360
|
generated_at: string;
|
|
334
361
|
provider: string;
|
|
335
362
|
topic?: string | undefined;
|
|
363
|
+
intent?: "feature" | "bugfix" | "refactor" | "research" | "docs" | "ops" | "review" | "chore" | "other" | undefined;
|
|
336
364
|
tags?: string[] | undefined;
|
|
365
|
+
projects?: string[] | undefined;
|
|
337
366
|
signals?: {
|
|
338
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
367
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
339
368
|
turn_index?: number | undefined;
|
|
340
369
|
severity?: "info" | "warn" | "critical" | undefined;
|
|
341
370
|
note?: string | undefined;
|
|
@@ -353,6 +382,7 @@ type Insights = z.infer<typeof InsightsSchema>;
|
|
|
353
382
|
type AgentKind = (typeof AGENTS)[number];
|
|
354
383
|
type Role = (typeof ROLES)[number];
|
|
355
384
|
type SignalKind = (typeof SIGNAL_KINDS)[number];
|
|
385
|
+
type Intent = (typeof INTENTS)[number];
|
|
356
386
|
declare const SCHEMA_VERSIONS: {
|
|
357
387
|
readonly turn: "session-store/turn@1";
|
|
358
388
|
readonly session: "session-store/session@1";
|
|
@@ -470,6 +500,10 @@ declare const parseSession: (data: unknown) => {
|
|
|
470
500
|
started_at?: string | undefined;
|
|
471
501
|
ended_at?: string | undefined;
|
|
472
502
|
title?: string | undefined;
|
|
503
|
+
forked_from?: {
|
|
504
|
+
session_id: string;
|
|
505
|
+
turn_index: number;
|
|
506
|
+
} | undefined;
|
|
473
507
|
};
|
|
474
508
|
declare const parseInsights: (data: unknown) => {
|
|
475
509
|
schema: "session-store/insights@1";
|
|
@@ -478,13 +512,15 @@ declare const parseInsights: (data: unknown) => {
|
|
|
478
512
|
generated_at: string;
|
|
479
513
|
provider: string;
|
|
480
514
|
tags: string[];
|
|
515
|
+
projects: string[];
|
|
481
516
|
signals: {
|
|
482
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
517
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
483
518
|
severity: "info" | "warn" | "critical";
|
|
484
519
|
turn_index?: number | undefined;
|
|
485
520
|
note?: string | undefined;
|
|
486
521
|
}[];
|
|
487
522
|
topic?: string | undefined;
|
|
523
|
+
intent?: "feature" | "bugfix" | "refactor" | "research" | "docs" | "ops" | "review" | "chore" | "other" | undefined;
|
|
488
524
|
summary?: string | undefined;
|
|
489
525
|
};
|
|
490
526
|
/** Non-throwing validation. */
|
|
@@ -566,6 +602,10 @@ declare const safeParseSession: (data: unknown) => zod.SafeParseReturnType<{
|
|
|
566
602
|
} | undefined;
|
|
567
603
|
title?: string | undefined;
|
|
568
604
|
labels?: string[] | undefined;
|
|
605
|
+
forked_from?: {
|
|
606
|
+
session_id: string;
|
|
607
|
+
turn_index: number;
|
|
608
|
+
} | undefined;
|
|
569
609
|
}, {
|
|
570
610
|
schema: "session-store/session@1";
|
|
571
611
|
session_id: string;
|
|
@@ -589,6 +629,10 @@ declare const safeParseSession: (data: unknown) => zod.SafeParseReturnType<{
|
|
|
589
629
|
started_at?: string | undefined;
|
|
590
630
|
ended_at?: string | undefined;
|
|
591
631
|
title?: string | undefined;
|
|
632
|
+
forked_from?: {
|
|
633
|
+
session_id: string;
|
|
634
|
+
turn_index: number;
|
|
635
|
+
} | undefined;
|
|
592
636
|
}>;
|
|
593
637
|
declare const safeParseInsights: (data: unknown) => zod.SafeParseReturnType<{
|
|
594
638
|
schema: "session-store/insights@1";
|
|
@@ -597,9 +641,11 @@ declare const safeParseInsights: (data: unknown) => zod.SafeParseReturnType<{
|
|
|
597
641
|
generated_at: string;
|
|
598
642
|
provider: string;
|
|
599
643
|
topic?: string | undefined;
|
|
644
|
+
intent?: "feature" | "bugfix" | "refactor" | "research" | "docs" | "ops" | "review" | "chore" | "other" | undefined;
|
|
600
645
|
tags?: string[] | undefined;
|
|
646
|
+
projects?: string[] | undefined;
|
|
601
647
|
signals?: {
|
|
602
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
648
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
603
649
|
turn_index?: number | undefined;
|
|
604
650
|
severity?: "info" | "warn" | "critical" | undefined;
|
|
605
651
|
note?: string | undefined;
|
|
@@ -612,14 +658,16 @@ declare const safeParseInsights: (data: unknown) => zod.SafeParseReturnType<{
|
|
|
612
658
|
generated_at: string;
|
|
613
659
|
provider: string;
|
|
614
660
|
tags: string[];
|
|
661
|
+
projects: string[];
|
|
615
662
|
signals: {
|
|
616
|
-
kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy"
|
|
663
|
+
kind: "other" | "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy";
|
|
617
664
|
severity: "info" | "warn" | "critical";
|
|
618
665
|
turn_index?: number | undefined;
|
|
619
666
|
note?: string | undefined;
|
|
620
667
|
}[];
|
|
621
668
|
topic?: string | undefined;
|
|
669
|
+
intent?: "feature" | "bugfix" | "refactor" | "research" | "docs" | "ops" | "review" | "chore" | "other" | undefined;
|
|
622
670
|
summary?: string | undefined;
|
|
623
671
|
}>;
|
|
624
672
|
|
|
625
|
-
export { AGENTS, type AgentKind, type BuildTurnContext, type ClaudeSessionMeta, type Insights, InsightsSchema, NativeRefSchema, type NormalizedEvent, ROLES, type Role, SCHEMA_VERSIONS, SIGNAL_KINDS, type SessionEnvelope, SessionSchema, type Signal, type SignalKind, SignalSchema, type Telemetry, TelemetrySchema, type ToolCall, ToolCallSchema, type Totals, TotalsSchema, type Turn, TurnSchema, type Usage, UsageSchema, buildTurn, extractClaudeSessionMeta, insightsJsonSchema, normalizeClaudeEvent, normalizeClaudeLines, parseInsights, parseSession, parseTurn, safeParseInsights, safeParseSession, safeParseTurn, sessionJsonSchema, turnJsonSchema };
|
|
673
|
+
export { AGENTS, type AgentKind, type BuildTurnContext, type ClaudeSessionMeta, INTENTS, type Insights, InsightsSchema, type Intent, NativeRefSchema, type NormalizedEvent, ROLES, type Role, SCHEMA_VERSIONS, SIGNAL_KINDS, type SessionEnvelope, SessionSchema, type Signal, type SignalKind, SignalSchema, type Telemetry, TelemetrySchema, type ToolCall, ToolCallSchema, type Totals, TotalsSchema, type Turn, TurnSchema, type Usage, UsageSchema, buildTurn, extractClaudeSessionMeta, insightsJsonSchema, normalizeClaudeEvent, normalizeClaudeLines, parseInsights, parseSession, parseTurn, safeParseInsights, safeParseSession, safeParseTurn, sessionJsonSchema, turnJsonSchema };
|
package/dist/index.js
CHANGED
|
@@ -60,8 +60,21 @@ var SessionSchema = z.object({
|
|
|
60
60
|
totals: TotalsSchema.default({}),
|
|
61
61
|
title: z.string().optional(),
|
|
62
62
|
labels: z.array(z.string()).default([]),
|
|
63
|
+
/** lineage when this session was forked from another at a turn ("git for sessions") */
|
|
64
|
+
forked_from: z.object({ session_id: z.string(), turn_index: z.number().int().nonnegative() }).strict().optional(),
|
|
63
65
|
native_ref: NativeRefSchema
|
|
64
66
|
}).strict();
|
|
67
|
+
var INTENTS = [
|
|
68
|
+
"feature",
|
|
69
|
+
"bugfix",
|
|
70
|
+
"refactor",
|
|
71
|
+
"research",
|
|
72
|
+
"docs",
|
|
73
|
+
"ops",
|
|
74
|
+
"review",
|
|
75
|
+
"chore",
|
|
76
|
+
"other"
|
|
77
|
+
];
|
|
65
78
|
var SIGNAL_KINDS = [
|
|
66
79
|
"stuck-loop",
|
|
67
80
|
"error-recovery",
|
|
@@ -85,7 +98,11 @@ var InsightsSchema = z.object({
|
|
|
85
98
|
generated_at: z.string(),
|
|
86
99
|
provider: z.string(),
|
|
87
100
|
topic: z.string().optional(),
|
|
101
|
+
/** what the session was about (feature/bugfix/research/…) */
|
|
102
|
+
intent: z.enum(INTENTS).optional(),
|
|
88
103
|
tags: z.array(z.string()).default([]),
|
|
104
|
+
/** project ids the session touched (derived from edited file paths) */
|
|
105
|
+
projects: z.array(z.string()).default([]),
|
|
89
106
|
signals: z.array(SignalSchema).default([]),
|
|
90
107
|
summary: z.string().optional()
|
|
91
108
|
}).strict();
|
|
@@ -249,6 +266,7 @@ var safeParseSession = (data) => SessionSchema.safeParse(data);
|
|
|
249
266
|
var safeParseInsights = (data) => InsightsSchema.safeParse(data);
|
|
250
267
|
export {
|
|
251
268
|
AGENTS,
|
|
269
|
+
INTENTS,
|
|
252
270
|
InsightsSchema,
|
|
253
271
|
NativeRefSchema,
|
|
254
272
|
ROLES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpolarize/code-sessions-schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Canonical wire schema for cross-agent session records (turns, envelopes, insights)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,9 +13,18 @@
|
|
|
13
13
|
"default": "./src/index.ts"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/unpolarize/code-sessions.git",
|
|
26
|
+
"directory": "packages/schema"
|
|
27
|
+
},
|
|
19
28
|
"scripts": {
|
|
20
29
|
"build": "tsup src/index.ts --format esm --dts --clean --out-dir dist"
|
|
21
30
|
},
|
package/src/schemas.ts
CHANGED
|
@@ -90,10 +90,28 @@ export const SessionSchema = z
|
|
|
90
90
|
totals: TotalsSchema.default({}),
|
|
91
91
|
title: z.string().optional(),
|
|
92
92
|
labels: z.array(z.string()).default([]),
|
|
93
|
+
/** lineage when this session was forked from another at a turn ("git for sessions") */
|
|
94
|
+
forked_from: z
|
|
95
|
+
.object({ session_id: z.string(), turn_index: z.number().int().nonnegative() })
|
|
96
|
+
.strict()
|
|
97
|
+
.optional(),
|
|
93
98
|
native_ref: NativeRefSchema,
|
|
94
99
|
})
|
|
95
100
|
.strict();
|
|
96
101
|
|
|
102
|
+
/** What the session was about — the user's intent behind the prompt(s). */
|
|
103
|
+
export const INTENTS = [
|
|
104
|
+
'feature',
|
|
105
|
+
'bugfix',
|
|
106
|
+
'refactor',
|
|
107
|
+
'research',
|
|
108
|
+
'docs',
|
|
109
|
+
'ops',
|
|
110
|
+
'review',
|
|
111
|
+
'chore',
|
|
112
|
+
'other',
|
|
113
|
+
] as const;
|
|
114
|
+
|
|
97
115
|
export const SIGNAL_KINDS = [
|
|
98
116
|
'stuck-loop',
|
|
99
117
|
'error-recovery',
|
|
@@ -123,7 +141,11 @@ export const InsightsSchema = z
|
|
|
123
141
|
generated_at: z.string(),
|
|
124
142
|
provider: z.string(),
|
|
125
143
|
topic: z.string().optional(),
|
|
144
|
+
/** what the session was about (feature/bugfix/research/…) */
|
|
145
|
+
intent: z.enum(INTENTS).optional(),
|
|
126
146
|
tags: z.array(z.string()).default([]),
|
|
147
|
+
/** project ids the session touched (derived from edited file paths) */
|
|
148
|
+
projects: z.array(z.string()).default([]),
|
|
127
149
|
signals: z.array(SignalSchema).default([]),
|
|
128
150
|
summary: z.string().optional(),
|
|
129
151
|
})
|
|
@@ -140,6 +162,7 @@ export type Insights = z.infer<typeof InsightsSchema>;
|
|
|
140
162
|
export type AgentKind = (typeof AGENTS)[number];
|
|
141
163
|
export type Role = (typeof ROLES)[number];
|
|
142
164
|
export type SignalKind = (typeof SIGNAL_KINDS)[number];
|
|
165
|
+
export type Intent = (typeof INTENTS)[number];
|
|
143
166
|
|
|
144
167
|
export const SCHEMA_VERSIONS = {
|
|
145
168
|
turn: 'session-store/turn@1',
|