@teamix-evo/registry 0.7.0 → 0.8.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
@@ -244,6 +244,16 @@ var TokensPackLinkedSchema = z2.object({
244
244
  "biz-ui": z2.string().optional(),
245
245
  templates: z2.string().optional()
246
246
  });
247
+ var TokenRenameEntrySchema = z2.object({
248
+ /** Variant version at which the rename took effect (semver). */
249
+ sinceVersion: z2.string().regex(SEMVER_RE, "Invalid semver version"),
250
+ /** Old token name (with or without leading `--`; both forms accepted). */
251
+ from: z2.string().min(1),
252
+ /** New token name. */
253
+ to: z2.string().min(1),
254
+ /** Optional one-liner rationale surfaced in the upgrade-hints file. */
255
+ description: z2.string().optional()
256
+ });
247
257
  var TokensVariantEntrySchema = z2.object({
248
258
  /** Variant id — lowercase kebab-case. */
249
259
  name: z2.string().min(1).regex(
@@ -263,7 +273,12 @@ var TokensVariantEntrySchema = z2.object({
263
273
  */
264
274
  files: z2.array(z2.string().min(1)).min(1),
265
275
  /** Soft cross-package links (biz-ui / templates with the same variant name). */
266
- linked: TokensPackLinkedSchema.optional()
276
+ linked: TokensPackLinkedSchema.optional(),
277
+ /**
278
+ * Token rename log accumulated across this variant's version history.
279
+ * Empty / absent when the variant has never renamed a token.
280
+ */
281
+ renames: z2.array(TokenRenameEntrySchema).optional()
267
282
  });
268
283
  var TokensPackageManifestSchema = z2.object({
269
284
  $schema: z2.string().optional(),
@@ -390,7 +405,28 @@ var PackageEntrySchema = z4.object({
390
405
  /** Whether to emit React Server Components markers (`"use client"`). ui-specific. */
391
406
  rsc: z4.boolean().optional()
392
407
  });
393
- var ProjectConfigSchema = z4.object({
408
+ var TokenRenameRecordSchema = z4.object({
409
+ /** ISO-8601 UTC timestamp at which the variant switch was performed. */
410
+ ts: z4.string().min(1),
411
+ /** Variant the project was on before the switch. */
412
+ fromVariant: z4.string().min(1),
413
+ /** Variant the project switched to. */
414
+ toVariant: z4.string().min(1),
415
+ /**
416
+ * Token rename mapping — old token name → new token name.
417
+ * Empty object is legal (e.g. switch with zero rename).
418
+ */
419
+ renames: z4.record(z4.string(), z4.string())
420
+ });
421
+ var LastUpdateRecordSchema = z4.object({
422
+ /** ISO-8601 UTC timestamp of the last successful update. */
423
+ ts: z4.string().min(1),
424
+ /** Version the package was on before this update. */
425
+ fromVersion: z4.string().min(1),
426
+ /** Version the package was on after this update. */
427
+ toVersion: z4.string().min(1)
428
+ });
429
+ var ProjectConfigV1Schema = z4.object({
394
430
  $schema: z4.string().optional(),
395
431
  schemaVersion: z4.literal(1),
396
432
  /** IDE identifier */
@@ -398,6 +434,31 @@ var ProjectConfigSchema = z4.object({
398
434
  /** Installed packages keyed by package name */
399
435
  packages: z4.record(z4.string(), PackageEntrySchema)
400
436
  });
437
+ var ProjectConfigV2Schema = z4.object({
438
+ $schema: z4.string().optional(),
439
+ schemaVersion: z4.literal(2),
440
+ /** IDE identifier */
441
+ ide: z4.string().min(1),
442
+ /** Installed packages keyed by package name */
443
+ packages: z4.record(z4.string(), PackageEntrySchema),
444
+ /** Variant in effect before the most recent `variant switch`, if any. */
445
+ priorVariant: z4.string().min(1).optional(),
446
+ /** Last successful update record keyed by package name. */
447
+ lastUpdate: z4.record(z4.string(), LastUpdateRecordSchema).optional(),
448
+ /** Token rename log accumulated across variant switches (oldest → newest). */
449
+ tokenRenameHistory: z4.array(TokenRenameRecordSchema).optional()
450
+ });
451
+ var ProjectConfigSchema = z4.discriminatedUnion("schemaVersion", [
452
+ ProjectConfigV1Schema,
453
+ ProjectConfigV2Schema
454
+ ]).transform((cfg) => {
455
+ if (cfg.schemaVersion === 2) return cfg;
456
+ const { schemaVersion: _v1, ...rest } = cfg;
457
+ return {
458
+ ...rest,
459
+ schemaVersion: 2
460
+ };
461
+ });
401
462
 
402
463
  // src/schema/installed.ts
403
464
  import { z as z5 } from "zod";
@@ -459,6 +520,98 @@ var SkillsLockSchema = z6.object({
459
520
  skills: z6.record(z6.string().min(1), SkillsLockEntrySchema)
460
521
  });
461
522
 
523
+ // src/schema/upgrade-staging.ts
524
+ import { z as z7 } from "zod";
525
+ var UpgradeRiskLevelSchema = z7.enum([
526
+ /** Hash matches — nothing to do. */
527
+ "unchanged",
528
+ /** Single-file change, no exported API surface delta. */
529
+ "upgradable-low",
530
+ /** Multi-file change or new exports / new cva variants (additive). */
531
+ "upgradable-medium",
532
+ /** Removed cva variants / renamed exports / props type narrowing. */
533
+ "risky",
534
+ /** Entry no longer exists upstream / file removed. */
535
+ "breaking",
536
+ /** Present in `src/components/{ui,biz-ui}/` but absent from installed manifest. */
537
+ "foreign"
538
+ ]);
539
+ var ComponentLineageSchema = z7.enum([
540
+ "teamix-evo",
541
+ "shadcn-native",
542
+ "mixed",
543
+ "custom-only"
544
+ ]);
545
+ var UpgradeStagingCategorySchema = z7.enum(["ui", "biz-ui"]);
546
+ var UpgradeStagingTriggerSchema = z7.enum([
547
+ "update",
548
+ "ui-upgrade",
549
+ "biz-ui-upgrade"
550
+ ]);
551
+ var UpgradeStagingCurrentSchema = z7.object({
552
+ /** Project-relative path of the component file (e.g. `src/components/ui/button.tsx`). */
553
+ target: z7.string().min(1),
554
+ /** Hash recorded in `.teamix-evo/manifest.json` at install time, or null when foreign. */
555
+ hash: z7.string().nullable(),
556
+ /** Lineage of *this specific component* (independent of project-wide lineage). */
557
+ sourceLineage: z7.enum(["teamix-evo", "shadcn-native", "custom", "absent"])
558
+ });
559
+ var UpgradeStagingIncomingSchema = z7.object({
560
+ /** Package-level version the incoming source comes from. */
561
+ sourceVersion: z7.string().min(1),
562
+ /** Hash of incoming source after applying the consumer's import-rewrite aliases. */
563
+ hash: z7.string().min(1),
564
+ /** Path of the incoming source file relative to the staging dir (e.g. `button/incoming.tsx`). */
565
+ relPath: z7.string().min(1)
566
+ });
567
+ var UpgradeStagingDiffSchema = z7.object({
568
+ riskLevel: UpgradeRiskLevelSchema,
569
+ /** Human-readable, machine-parsable hints (e.g. `"new prop: loading"`, `"removed cva variant: ghost"`). */
570
+ hints: z7.array(z7.string()),
571
+ /** Number of files that differ for this entry (almost always 1 today; reserved for multi-file entries). */
572
+ filesChangedCount: z7.number().int().nonnegative(),
573
+ /**
574
+ * Path of the unified diff relative to the staging dir, when CLI emitted one.
575
+ * Reserved for a future emitter — in schema v1 the CLI does **not** pre-render
576
+ * `diff.unified.patch`; the consumer of the staging (the `teamix-evo-upgrade`
577
+ * skill) computes the diff on the fly from `current.tsx` vs `incoming.tsx`.
578
+ */
579
+ diffRelPath: z7.string().optional()
580
+ });
581
+ var UpgradeStagingEntrySchema = z7.object({
582
+ /** Component identifier matching the upstream registry (e.g. `"button"`). */
583
+ id: z7.string().min(1),
584
+ /** Which package category this entry belongs to. */
585
+ category: UpgradeStagingCategorySchema,
586
+ current: UpgradeStagingCurrentSchema,
587
+ /** Absent when the entry is `breaking` (no incoming) or `foreign` (no upstream). */
588
+ incoming: UpgradeStagingIncomingSchema.optional(),
589
+ diff: UpgradeStagingDiffSchema
590
+ });
591
+ var UpgradeStagingManifestSchema = z7.object({
592
+ schemaVersion: z7.literal(1),
593
+ /** ISO-8601 timestamp the staging dir was created (matches dir suffix). */
594
+ ts: z7.string().min(1),
595
+ /** Which package category this staging covers. */
596
+ package: UpgradeStagingCategorySchema,
597
+ /** Which command produced this staging. */
598
+ trigger: UpgradeStagingTriggerSchema,
599
+ /** Variant applicable to the staging (always `_flat` for ui; concrete variant for biz-ui). */
600
+ variant: z7.string().min(1),
601
+ /** Installed package version (from `.teamix-evo/manifest.json`); empty string when foreign-only. */
602
+ fromVersion: z7.string(),
603
+ /** Upstream package version. */
604
+ toVersion: z7.string().min(1),
605
+ /** Project-wide lineage classification. */
606
+ lineage: ComponentLineageSchema,
607
+ /** Aggregate counts grouped by riskLevel for quick AI summarization. */
608
+ summary: z7.object({
609
+ total: z7.number().int().nonnegative(),
610
+ byRisk: z7.record(UpgradeRiskLevelSchema, z7.number().int().nonnegative())
611
+ }),
612
+ entries: z7.array(UpgradeStagingEntrySchema)
613
+ });
614
+
462
615
  // src/loader.ts
463
616
  import * as fs from "fs/promises";
464
617
  import * as path from "path";
@@ -883,9 +1036,48 @@ function hasManagedRegion(content, id) {
883
1036
  );
884
1037
  return pattern.test(content);
885
1038
  }
1039
+ function splitManagedRegions(content) {
1040
+ parseManagedRegions(content);
1041
+ const regionRe = new RegExp(REGION_PATTERN.source, "g");
1042
+ const segments = [];
1043
+ let cursor = 0;
1044
+ let match;
1045
+ while ((match = regionRe.exec(content)) !== null) {
1046
+ const id = match[1];
1047
+ const regionContent = match[2];
1048
+ const start = match.index;
1049
+ const end = start + match[0].length;
1050
+ segments.push({ kind: "unmanaged", content: content.slice(cursor, start) });
1051
+ segments.push({
1052
+ kind: "managed",
1053
+ region: {
1054
+ id,
1055
+ startMarker: `<!-- teamix-evo:managed:start id="${id}" -->`,
1056
+ endMarker: `<!-- teamix-evo:managed:end id="${id}" -->`,
1057
+ content: regionContent
1058
+ }
1059
+ });
1060
+ cursor = end;
1061
+ }
1062
+ segments.push({ kind: "unmanaged", content: content.slice(cursor) });
1063
+ return segments;
1064
+ }
886
1065
  function escapeRegExp(str) {
887
1066
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
888
1067
  }
1068
+ var FRONTMATTER_PATTERN = /^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/;
1069
+ function extractFrontmatter(content) {
1070
+ const m = content.match(FRONTMATTER_PATTERN);
1071
+ return m ? m[0] : null;
1072
+ }
1073
+ function replaceFrontmatter(content, newFrontmatter) {
1074
+ const m = content.match(FRONTMATTER_PATTERN);
1075
+ if (!m) {
1076
+ return newFrontmatter.endsWith("\n") ? newFrontmatter + content : `${newFrontmatter}
1077
+ ${content}`;
1078
+ }
1079
+ return newFrontmatter + content.slice(m[0].length);
1080
+ }
889
1081
 
890
1082
  // src/strategy.ts
891
1083
  function shouldUpdate(strategy, resourceExists) {
@@ -922,11 +1114,15 @@ function getUpdateAction(strategy, options) {
922
1114
  }
923
1115
  }
924
1116
  export {
1117
+ ComponentLineageSchema,
925
1118
  InstalledManifestSchema,
926
1119
  InstalledPackageSchema,
927
1120
  InstalledResourceSchema,
1121
+ LastUpdateRecordSchema,
928
1122
  PackageEntrySchema,
929
1123
  ProjectConfigSchema,
1124
+ ProjectConfigV1Schema,
1125
+ ProjectConfigV2Schema,
930
1126
  ResourceSchema,
931
1127
  ResourceTypeSchema,
932
1128
  SkillEntrySchema,
@@ -936,6 +1132,8 @@ export {
936
1132
  SkillsLockSchema,
937
1133
  SkillsPackageManifestSchema,
938
1134
  TailwindVersionSchema,
1135
+ TokenRenameEntrySchema,
1136
+ TokenRenameRecordSchema,
939
1137
  TokensPackLinkedSchema,
940
1138
  TokensPackLockSchema,
941
1139
  TokensPackageManifestSchema,
@@ -947,10 +1145,19 @@ export {
947
1145
  UiEntryTypeSchema,
948
1146
  UiPackageManifestSchema,
949
1147
  UpdateStrategySchema,
1148
+ UpgradeRiskLevelSchema,
1149
+ UpgradeStagingCategorySchema,
1150
+ UpgradeStagingCurrentSchema,
1151
+ UpgradeStagingDiffSchema,
1152
+ UpgradeStagingEntrySchema,
1153
+ UpgradeStagingIncomingSchema,
1154
+ UpgradeStagingManifestSchema,
1155
+ UpgradeStagingTriggerSchema,
950
1156
  VariantManifestSchema,
951
1157
  VariantUiPackageCatalogSchema,
952
1158
  VariantUiPackageManifestSchema,
953
1159
  VariantUiPackageNameSchema,
1160
+ extractFrontmatter,
954
1161
  getUpdateAction,
955
1162
  getVariantEntry,
956
1163
  hasManagedRegion,
@@ -961,9 +1168,11 @@ export {
961
1168
  loadVariantUiPackageCatalog,
962
1169
  loadVariantUiPackageManifest,
963
1170
  parseManagedRegions,
1171
+ replaceFrontmatter,
964
1172
  replaceManagedRegion,
965
1173
  resolveUiEntryOrder,
966
1174
  shouldUpdate,
1175
+ splitManagedRegions,
967
1176
  validateConfig,
968
1177
  validateInstalled,
969
1178
  validateManifest,