@basou/core 0.17.0 → 0.18.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 +24 -0
- package/dist/index.js +59 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/event.schema.json +64 -0
- package/schemas/session-import.schema.json +64 -0
package/dist/index.d.ts
CHANGED
|
@@ -410,6 +410,17 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
|
|
|
410
410
|
rejected_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
411
411
|
linked_events: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<`evt_${string}`, string, z.core.$ZodTypeInternals<`evt_${string}`, string>>>>;
|
|
412
412
|
linked_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
413
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
414
|
+
schema_version: z.ZodLiteral<"0.1.0">;
|
|
415
|
+
id: z.ZodString & z.ZodType<`evt_${string}`, string, z.core.$ZodTypeInternals<`evt_${string}`, string>>;
|
|
416
|
+
session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
|
|
417
|
+
occurred_at: z.ZodString;
|
|
418
|
+
source: z.ZodString;
|
|
419
|
+
prev_hash: z.ZodOptional<z.ZodString>;
|
|
420
|
+
type: z.ZodLiteral<"decision_voided">;
|
|
421
|
+
decision_id: z.ZodString & z.ZodType<`decision_${string}`, string, z.core.$ZodTypeInternals<`decision_${string}`, string>>;
|
|
422
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
423
|
+
superseded_by: z.ZodOptional<z.ZodString & z.ZodType<`decision_${string}`, string, z.core.$ZodTypeInternals<`decision_${string}`, string>>>;
|
|
413
424
|
}, z.core.$strip>, z.ZodObject<{
|
|
414
425
|
schema_version: z.ZodLiteral<"0.1.0">;
|
|
415
426
|
id: z.ZodString & z.ZodType<`evt_${string}`, string, z.core.$ZodTypeInternals<`evt_${string}`, string>>;
|
|
@@ -1203,6 +1214,17 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1203
1214
|
rejected_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1204
1215
|
linked_events: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<`evt_${string}`, string, z.core.$ZodTypeInternals<`evt_${string}`, string>>>>;
|
|
1205
1216
|
linked_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1217
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1218
|
+
schema_version: z.ZodLiteral<"0.1.0">;
|
|
1219
|
+
id: z.ZodString & z.ZodType<`evt_${string}`, string, z.core.$ZodTypeInternals<`evt_${string}`, string>>;
|
|
1220
|
+
session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
|
|
1221
|
+
occurred_at: z.ZodString;
|
|
1222
|
+
source: z.ZodString;
|
|
1223
|
+
prev_hash: z.ZodOptional<z.ZodString>;
|
|
1224
|
+
type: z.ZodLiteral<"decision_voided">;
|
|
1225
|
+
decision_id: z.ZodString & z.ZodType<`decision_${string}`, string, z.core.$ZodTypeInternals<`decision_${string}`, string>>;
|
|
1226
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1227
|
+
superseded_by: z.ZodOptional<z.ZodString & z.ZodType<`decision_${string}`, string, z.core.$ZodTypeInternals<`decision_${string}`, string>>>;
|
|
1206
1228
|
}, z.core.$strip>, z.ZodObject<{
|
|
1207
1229
|
schema_version: z.ZodLiteral<"0.1.0">;
|
|
1208
1230
|
id: z.ZodString & z.ZodType<`evt_${string}`, string, z.core.$ZodTypeInternals<`evt_${string}`, string>>;
|
|
@@ -4671,6 +4693,8 @@ type ReportDecisionItem = {
|
|
|
4671
4693
|
id: string;
|
|
4672
4694
|
title: string;
|
|
4673
4695
|
occurredAt: string;
|
|
4696
|
+
/** True when a later `decision_voided` event retracted this decision. */
|
|
4697
|
+
voided?: boolean;
|
|
4674
4698
|
};
|
|
4675
4699
|
type ReportTaskItem = {
|
|
4676
4700
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -874,6 +874,12 @@ var DecisionRecordedEventSchema = BaseEventSchema.extend({
|
|
|
874
874
|
linked_events: z3.array(EventIdSchema).optional(),
|
|
875
875
|
linked_files: z3.array(z3.string().min(1).max(4096)).optional()
|
|
876
876
|
});
|
|
877
|
+
var DecisionVoidedEventSchema = BaseEventSchema.extend({
|
|
878
|
+
type: z3.literal("decision_voided"),
|
|
879
|
+
decision_id: DecisionIdSchema,
|
|
880
|
+
reason: z3.string().nullable().optional(),
|
|
881
|
+
superseded_by: DecisionIdSchema.optional()
|
|
882
|
+
});
|
|
877
883
|
var TaskCreatedEventSchema = BaseEventSchema.extend({
|
|
878
884
|
type: z3.literal("task_created"),
|
|
879
885
|
task_id: TaskIdSchema,
|
|
@@ -937,6 +943,7 @@ var EventSchema = z3.discriminatedUnion("type", [
|
|
|
937
943
|
GitSnapshotEventSchema,
|
|
938
944
|
FileChangedEventSchema,
|
|
939
945
|
DecisionRecordedEventSchema,
|
|
946
|
+
DecisionVoidedEventSchema,
|
|
940
947
|
TaskCreatedEventSchema,
|
|
941
948
|
TaskStatusChangedEventSchema,
|
|
942
949
|
TaskReconciledEventSchema,
|
|
@@ -1460,6 +1467,7 @@ async function renderDecisions(input) {
|
|
|
1460
1467
|
if (input.onWarning !== void 0) loadOpts.onWarning = input.onWarning;
|
|
1461
1468
|
const entries = await loadSessionEntries(input.paths, loadOpts);
|
|
1462
1469
|
const decisions = [];
|
|
1470
|
+
const voids = /* @__PURE__ */ new Map();
|
|
1463
1471
|
const knownEventIds = /* @__PURE__ */ new Set();
|
|
1464
1472
|
for (const entry of entries) {
|
|
1465
1473
|
const sessionDir = join6(input.paths.sessions, entry.sessionId);
|
|
@@ -1478,8 +1486,11 @@ async function renderDecisions(input) {
|
|
|
1478
1486
|
alternatives: ev.alternatives,
|
|
1479
1487
|
rejectedReason: ev.rejected_reason,
|
|
1480
1488
|
linkedEvents: ev.linked_events,
|
|
1481
|
-
linkedFiles: ev.linked_files
|
|
1489
|
+
linkedFiles: ev.linked_files,
|
|
1490
|
+
voided: void 0
|
|
1482
1491
|
});
|
|
1492
|
+
} else if (ev.type === "decision_voided") {
|
|
1493
|
+
voids.set(ev.decision_id, { reason: ev.reason, supersededBy: ev.superseded_by });
|
|
1483
1494
|
}
|
|
1484
1495
|
}
|
|
1485
1496
|
} catch {
|
|
@@ -1488,6 +1499,10 @@ async function renderDecisions(input) {
|
|
|
1488
1499
|
}
|
|
1489
1500
|
}
|
|
1490
1501
|
}
|
|
1502
|
+
for (const d of decisions) {
|
|
1503
|
+
const v = voids.get(d.decisionId);
|
|
1504
|
+
if (v !== void 0) d.voided = v;
|
|
1505
|
+
}
|
|
1491
1506
|
decisions.sort((a, b) => {
|
|
1492
1507
|
const c = Date.parse(a.occurredAt) - Date.parse(b.occurredAt);
|
|
1493
1508
|
return c !== 0 ? c : a.decisionId.localeCompare(b.decisionId);
|
|
@@ -1527,8 +1542,16 @@ async function formatDecisionsBody(args) {
|
|
|
1527
1542
|
return lines.join("\n");
|
|
1528
1543
|
}
|
|
1529
1544
|
for (const d of args.decisions) {
|
|
1530
|
-
|
|
1531
|
-
|
|
1545
|
+
if (d.voided !== void 0) {
|
|
1546
|
+
lines.push(`## ~~${d.decisionId}: ${d.title}~~ [VOIDED]`);
|
|
1547
|
+
lines.push("");
|
|
1548
|
+
const supersededBy = d.voided.supersededBy !== void 0 ? `, superseded by ${d.voided.supersededBy}` : "";
|
|
1549
|
+
const reason = typeof d.voided.reason === "string" && d.voided.reason.length > 0 ? `: ${d.voided.reason}` : "";
|
|
1550
|
+
lines.push(`- \u26A0 VOIDED${reason}${supersededBy}`);
|
|
1551
|
+
} else {
|
|
1552
|
+
lines.push(`## ${d.decisionId}: ${d.title}`);
|
|
1553
|
+
lines.push("");
|
|
1554
|
+
}
|
|
1532
1555
|
const occurredDate = d.occurredAt.slice(0, 10);
|
|
1533
1556
|
lines.push(`- \u6C7A\u5B9A\u65E5: ${occurredDate}`);
|
|
1534
1557
|
lines.push(`- session: ${shortDecisionSessionId(d.sessionId)}`);
|
|
@@ -3853,6 +3876,7 @@ async function renderHandoff(input) {
|
|
|
3853
3876
|
if (input.onWarning !== void 0) loadOpts.onWarning = input.onWarning;
|
|
3854
3877
|
const entries = await loadSessionEntries(input.paths, loadOpts);
|
|
3855
3878
|
const decisions = [];
|
|
3879
|
+
const voidedDecisionIds = /* @__PURE__ */ new Set();
|
|
3856
3880
|
const tasksCreated = [];
|
|
3857
3881
|
const tasksStatusChanged = [];
|
|
3858
3882
|
let latestActivityAt = null;
|
|
@@ -3877,6 +3901,8 @@ async function renderHandoff(input) {
|
|
|
3877
3901
|
occurredAt: ev.occurred_at,
|
|
3878
3902
|
sessionId: entry.sessionId
|
|
3879
3903
|
});
|
|
3904
|
+
} else if (ev.type === "decision_voided") {
|
|
3905
|
+
voidedDecisionIds.add(ev.decision_id);
|
|
3880
3906
|
} else if (ev.type === "task_created") {
|
|
3881
3907
|
tasksCreated.push({
|
|
3882
3908
|
taskId: ev.task_id,
|
|
@@ -3902,6 +3928,14 @@ async function renderHandoff(input) {
|
|
|
3902
3928
|
const c = Date.parse(a.occurredAt) - Date.parse(b.occurredAt);
|
|
3903
3929
|
return c !== 0 ? c : a.decisionId.localeCompare(b.decisionId);
|
|
3904
3930
|
});
|
|
3931
|
+
let latestDecision;
|
|
3932
|
+
for (let i = decisions.length - 1; i >= 0; i -= 1) {
|
|
3933
|
+
const d = decisions[i];
|
|
3934
|
+
if (d !== void 0 && !voidedDecisionIds.has(d.decisionId)) {
|
|
3935
|
+
latestDecision = d;
|
|
3936
|
+
break;
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3905
3939
|
tasksCreated.sort((a, b) => {
|
|
3906
3940
|
const c = Date.parse(a.occurredAt) - Date.parse(b.occurredAt);
|
|
3907
3941
|
return c !== 0 ? c : a.taskId.localeCompare(b.taskId);
|
|
@@ -3945,6 +3979,7 @@ async function renderHandoff(input) {
|
|
|
3945
3979
|
latestSession,
|
|
3946
3980
|
latestActivityAt,
|
|
3947
3981
|
decisions,
|
|
3982
|
+
latestDecision,
|
|
3948
3983
|
pendingApprovalsCount,
|
|
3949
3984
|
suspectCount,
|
|
3950
3985
|
displayedFiles,
|
|
@@ -4011,10 +4046,10 @@ function formatHandoffBody(args) {
|
|
|
4011
4046
|
lines.push("");
|
|
4012
4047
|
lines.push("## \u76F4\u8FD1\u306E\u5224\u65AD");
|
|
4013
4048
|
lines.push("");
|
|
4014
|
-
if (args.
|
|
4049
|
+
if (args.latestDecision === void 0) {
|
|
4015
4050
|
lines.push("(no decisions recorded yet)");
|
|
4016
4051
|
} else {
|
|
4017
|
-
const last = args.
|
|
4052
|
+
const last = args.latestDecision;
|
|
4018
4053
|
lines.push(`- ${last.title} [${shortIdWithPrefix(last.decisionId)}]`);
|
|
4019
4054
|
if (args.latestActivityAt !== null && isTrailingStale(args.latestActivityAt, last.occurredAt)) {
|
|
4020
4055
|
lines.push(
|
|
@@ -4467,6 +4502,7 @@ async function summarizeOrientation(input) {
|
|
|
4467
4502
|
}
|
|
4468
4503
|
) : await loadSessionEntries(input.paths, loadOpts);
|
|
4469
4504
|
const decisions = [];
|
|
4505
|
+
const voidedDecisionIds = /* @__PURE__ */ new Set();
|
|
4470
4506
|
let latestActivityAt = null;
|
|
4471
4507
|
let latestNote = null;
|
|
4472
4508
|
const noteActivity = (iso) => {
|
|
@@ -4490,6 +4526,8 @@ async function summarizeOrientation(input) {
|
|
|
4490
4526
|
sessionId: entry.sessionId,
|
|
4491
4527
|
host: entry.host
|
|
4492
4528
|
});
|
|
4529
|
+
} else if (ev.type === "decision_voided") {
|
|
4530
|
+
voidedDecisionIds.add(ev.decision_id);
|
|
4493
4531
|
}
|
|
4494
4532
|
if (counted && ev.type === "note_added" && ev.kind === "next_step") {
|
|
4495
4533
|
if (latestNote === null || Date.parse(ev.occurred_at) > Date.parse(latestNote.occurredAt)) {
|
|
@@ -4511,7 +4549,14 @@ async function summarizeOrientation(input) {
|
|
|
4511
4549
|
const c = Date.parse(a.occurredAt) - Date.parse(b.occurredAt);
|
|
4512
4550
|
return c !== 0 ? c : a.decisionId.localeCompare(b.decisionId);
|
|
4513
4551
|
});
|
|
4514
|
-
|
|
4552
|
+
let latestDecision;
|
|
4553
|
+
for (let i = decisions.length - 1; i >= 0; i -= 1) {
|
|
4554
|
+
const d = decisions[i];
|
|
4555
|
+
if (d !== void 0 && !voidedDecisionIds.has(d.decisionId)) {
|
|
4556
|
+
latestDecision = d;
|
|
4557
|
+
break;
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4515
4560
|
const taskLoadOpts = {};
|
|
4516
4561
|
if (input.onTaskSkip !== void 0) taskLoadOpts.onSkip = input.onTaskSkip;
|
|
4517
4562
|
const taskEntries = await loadTaskEntries(input.paths, taskLoadOpts);
|
|
@@ -5794,6 +5839,7 @@ async function renderReport(input) {
|
|
|
5794
5839
|
const stats = await computeWorkStats(statsInput);
|
|
5795
5840
|
const statsBySession = new Map(stats.sessions.map((s) => [s.sessionId, s]));
|
|
5796
5841
|
const decisions = [];
|
|
5842
|
+
const voidedDecisionIds = /* @__PURE__ */ new Set();
|
|
5797
5843
|
for (const entry of entries) {
|
|
5798
5844
|
const sessionDir = join17(input.paths.sessions, entry.sessionId);
|
|
5799
5845
|
try {
|
|
@@ -5802,6 +5848,8 @@ async function renderReport(input) {
|
|
|
5802
5848
|
})) {
|
|
5803
5849
|
if (ev.type === "decision_recorded") {
|
|
5804
5850
|
decisions.push({ id: ev.decision_id, title: ev.title, occurredAt: ev.occurred_at });
|
|
5851
|
+
} else if (ev.type === "decision_voided") {
|
|
5852
|
+
voidedDecisionIds.add(ev.decision_id);
|
|
5805
5853
|
}
|
|
5806
5854
|
}
|
|
5807
5855
|
} catch {
|
|
@@ -5810,6 +5858,9 @@ async function renderReport(input) {
|
|
|
5810
5858
|
}
|
|
5811
5859
|
}
|
|
5812
5860
|
}
|
|
5861
|
+
for (const d of decisions) {
|
|
5862
|
+
if (voidedDecisionIds.has(d.id)) d.voided = true;
|
|
5863
|
+
}
|
|
5813
5864
|
decisions.sort((a, b) => {
|
|
5814
5865
|
const c = Date.parse(a.occurredAt) - Date.parse(b.occurredAt);
|
|
5815
5866
|
return c !== 0 ? c : a.id.localeCompare(b.id);
|
|
@@ -5982,7 +6033,8 @@ function formatReportBody(data) {
|
|
|
5982
6033
|
lines.push("");
|
|
5983
6034
|
}
|
|
5984
6035
|
for (const d of shown) {
|
|
5985
|
-
|
|
6036
|
+
const voidedTag = d.voided === true ? " (voided)" : "";
|
|
6037
|
+
lines.push(`- ${d.occurredAt.slice(0, 10)} \xB7 ${d.title}${voidedTag}`);
|
|
5986
6038
|
}
|
|
5987
6039
|
}
|
|
5988
6040
|
lines.push("");
|