@basou/core 0.30.0 → 0.31.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.js CHANGED
@@ -910,7 +910,10 @@ import { z as z2 } from "zod";
910
910
 
911
911
  // src/schemas/shared.schema.ts
912
912
  import { z } from "zod";
913
- var SchemaVersionSchema = z.literal("0.1.0");
913
+ var SchemaVersionSchema = z.string().regex(/^0\.\d+\.\d+$/, {
914
+ message: "unsupported .basou format version: this basou reads format major 0 (0.x.y). If this workspace was written by a newer basou, upgrade basou to open it."
915
+ });
916
+ var CacheVersionSchema = z.literal("0.1.0");
914
917
  var IsoTimestampSchema = z.string().datetime({ offset: true });
915
918
  var createPrefixedIdSchema = (prefix) => {
916
919
  const refiner = (value) => isValidPrefixedId(value) && value.startsWith(`${prefix}_`);
@@ -930,14 +933,14 @@ var EventSourceSchema = z.string().min(1);
930
933
 
931
934
  // src/schemas/approval.schema.ts
932
935
  var ApprovalStatusSchema = z2.enum(["pending", "approved", "rejected", "expired"]);
933
- var ApprovalSchema = z2.object({
936
+ var ApprovalSchema = z2.looseObject({
934
937
  schema_version: SchemaVersionSchema,
935
938
  id: ApprovalIdSchema,
936
939
  session_id: SessionIdSchema,
937
940
  created_at: IsoTimestampSchema,
938
941
  status: ApprovalStatusSchema,
939
942
  risk_level: RiskLevelSchema,
940
- action: z2.object({ kind: z2.string() }).passthrough(),
943
+ action: z2.looseObject({ kind: z2.string() }).passthrough(),
941
944
  reason: z2.string(),
942
945
  expires_at: IsoTimestampSchema.nullable().default(null),
943
946
  // The four fields below are null while `status === "pending"` and set
@@ -1590,7 +1593,7 @@ var SessionSourceKindSchema = z4.enum([
1590
1593
  "import",
1591
1594
  "terminal"
1592
1595
  ]);
1593
- var SessionSourceSchema = z4.object({
1596
+ var SessionSourceSchema = z4.looseObject({
1594
1597
  kind: SessionSourceKindSchema,
1595
1598
  version: z4.literal("0.1.0"),
1596
1599
  // Optional id of the originating session in the SOURCE tool's own
@@ -1606,20 +1609,20 @@ var SessionSourceSchema = z4.object({
1606
1609
  // fresh import or `--force`).
1607
1610
  source_size_bytes: z4.number().int().nonnegative().optional()
1608
1611
  });
1609
- var InvocationSchema = z4.object({
1612
+ var InvocationSchema = z4.looseObject({
1610
1613
  command: z4.string().min(1),
1611
1614
  args: z4.array(z4.string()).default([]),
1612
1615
  // Nullable to record signal-terminated runs where the child has no exit
1613
1616
  // code; the same nullability is mirrored in CommandExecutedEventSchema.
1614
1617
  exit_code: z4.number().int().nullable()
1615
1618
  });
1616
- var SessionMetricsSchema = z4.object({
1619
+ var SessionMetricsSchema = z4.looseObject({
1617
1620
  output_tokens: z4.number().int().nonnegative().optional(),
1618
1621
  input_tokens: z4.number().int().nonnegative().optional(),
1619
1622
  cached_input_tokens: z4.number().int().nonnegative().optional(),
1620
1623
  reasoning_output_tokens: z4.number().int().nonnegative().optional(),
1621
1624
  active_time_ms: z4.number().int().nonnegative().optional(),
1622
- active_intervals: z4.array(z4.object({ start: IsoTimestampSchema, end: IsoTimestampSchema })).optional(),
1625
+ active_intervals: z4.array(z4.looseObject({ start: IsoTimestampSchema, end: IsoTimestampSchema })).optional(),
1623
1626
  active_gap_cap_ms: z4.number().int().nonnegative().optional(),
1624
1627
  active_time_method: z4.string().optional(),
1625
1628
  machine_active_time_ms: z4.number().int().nonnegative().optional()
@@ -1628,7 +1631,7 @@ var SessionIntegritySchema = z4.object({
1628
1631
  head_hash: z4.string(),
1629
1632
  event_count: z4.number().int().nonnegative()
1630
1633
  }).strict();
1631
- var SessionInnerSchema = z4.object({
1634
+ var SessionInnerSchema = z4.looseObject({
1632
1635
  id: SessionIdSchema,
1633
1636
  label: z4.string().optional(),
1634
1637
  task_id: TaskIdSchema.nullable().optional(),
@@ -1646,7 +1649,7 @@ var SessionInnerSchema = z4.object({
1646
1649
  metrics: SessionMetricsSchema.optional(),
1647
1650
  integrity: SessionIntegritySchema.optional()
1648
1651
  });
1649
- var SessionSchema = z4.object({
1652
+ var SessionSchema = z4.looseObject({
1650
1653
  schema_version: SchemaVersionSchema,
1651
1654
  session: SessionInnerSchema
1652
1655
  });
@@ -2146,12 +2149,16 @@ import * as fsp from "fs/promises";
2146
2149
  // src/schemas/status.schema.ts
2147
2150
  import { z as z5 } from "zod";
2148
2151
  var StatusSchema = z5.object({
2149
- schema_version: SchemaVersionSchema,
2152
+ // status.json is a rebuildable cache: exact-match-or-rebuild, not the
2153
+ // durable forward-compat gate.
2154
+ schema_version: CacheVersionSchema,
2150
2155
  generated_at: IsoTimestampSchema,
2151
2156
  workspace: z5.object({
2152
2157
  id: WorkspaceIdSchema,
2153
2158
  name: z5.string().min(1),
2154
- basou_version: z5.literal("0.1.0")
2159
+ // Mirrors the manifest's basou_version, so it uses the same
2160
+ // forward-compatible format gate (accept 0.x.y) rather than a literal.
2161
+ basou_version: SchemaVersionSchema
2155
2162
  }).strict(),
2156
2163
  directories_present: z5.object({
2157
2164
  sessions: z5.boolean(),
@@ -2511,7 +2518,7 @@ import { z as z8 } from "zod";
2511
2518
  // src/schemas/task.schema.ts
2512
2519
  import { z as z6 } from "zod";
2513
2520
  var TaskStatusSchema = z6.enum(["planned", "in_progress", "done", "cancelled"]);
2514
- var TaskInnerSchema = z6.object({
2521
+ var TaskInnerSchema = z6.looseObject({
2515
2522
  id: TaskIdSchema,
2516
2523
  title: z6.string().min(1),
2517
2524
  label: z6.string().min(1).optional(),
@@ -2540,7 +2547,7 @@ var TaskInnerSchema = z6.object({
2540
2547
  */
2541
2548
  linked_sessions: z6.array(SessionIdSchema).default([])
2542
2549
  });
2543
- var TaskSchema = z6.object({
2550
+ var TaskSchema = z6.looseObject({
2544
2551
  schema_version: SchemaVersionSchema,
2545
2552
  task: TaskInnerSchema
2546
2553
  });
@@ -2790,7 +2797,8 @@ var TaskIndexEntrySchema = z7.object({
2790
2797
  updated_at: IsoTimestampSchema
2791
2798
  }).strict();
2792
2799
  var TaskIndexSchema = z7.object({
2793
- schema_version: SchemaVersionSchema,
2800
+ // Rebuildable cache: exact-match-or-rebuild, not the durable forward-compat gate.
2801
+ schema_version: CacheVersionSchema,
2794
2802
  tasks: z7.array(TaskIndexEntrySchema),
2795
2803
  last_rebuilt_at: IsoTimestampSchema
2796
2804
  }).strict();
@@ -4728,8 +4736,7 @@ import { lstat as lstat3 } from "fs/promises";
4728
4736
  import { z as z9 } from "zod";
4729
4737
  var ProjectSchema = z9.looseObject({
4730
4738
  name: z9.string().optional(),
4731
- description: z9.string().optional(),
4732
- repository_url: z9.string().nullable().optional()
4739
+ description: z9.string().optional()
4733
4740
  });
4734
4741
  var CapabilitiesSchema = z9.looseObject({
4735
4742
  enabled: z9.array(z9.string())
@@ -4787,7 +4794,11 @@ var WorkspaceMetaSchema = z9.looseObject({
4787
4794
  });
4788
4795
  var ManifestSchema = z9.looseObject({
4789
4796
  schema_version: SchemaVersionSchema,
4790
- basou_version: z9.literal("0.1.0"),
4797
+ // Same forward-compatible format gate as schema_version (accept 0.x.y, gate a
4798
+ // higher major with an upgrade error) rather than a hard literal. `basou_version`
4799
+ // is a format stamp, not the npm/product version; consolidating it with
4800
+ // schema_version is a candidate cleanup for the M4 freeze pass.
4801
+ basou_version: SchemaVersionSchema,
4791
4802
  workspace: WorkspaceMetaSchema,
4792
4803
  project: ProjectSchema,
4793
4804
  capabilities: CapabilitiesSchema,
@@ -4811,8 +4822,7 @@ function createManifest(input) {
4811
4822
  const workspaceId = input.workspaceId ?? prefixedUlid("ws");
4812
4823
  const project = {
4813
4824
  ...input.projectName !== void 0 ? { name: input.projectName } : {},
4814
- ...input.projectDescription !== void 0 ? { description: input.projectDescription } : {},
4815
- ...input.repositoryUrl !== void 0 ? { repository_url: input.repositoryUrl } : {}
4825
+ ...input.projectDescription !== void 0 ? { description: input.projectDescription } : {}
4816
4826
  };
4817
4827
  const manifest = {
4818
4828
  schema_version: "0.1.0",
@@ -4842,6 +4852,7 @@ function createManifest(input) {
4842
4852
  async function writeManifest(paths, manifest, options) {
4843
4853
  const force = options?.force === true;
4844
4854
  const validated = ManifestSchema.parse(manifest);
4855
+ delete validated.project.repository_url;
4845
4856
  if (!force) {
4846
4857
  let existed = false;
4847
4858
  try {