@git-stunts/git-warp 11.2.1 → 11.5.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.
Files changed (114) hide show
  1. package/README.md +24 -1
  2. package/bin/cli/commands/check.js +2 -2
  3. package/bin/cli/commands/doctor/checks.js +12 -12
  4. package/bin/cli/commands/doctor/index.js +2 -2
  5. package/bin/cli/commands/doctor/types.js +1 -1
  6. package/bin/cli/commands/history.js +12 -5
  7. package/bin/cli/commands/install-hooks.js +5 -5
  8. package/bin/cli/commands/materialize.js +2 -2
  9. package/bin/cli/commands/patch.js +142 -0
  10. package/bin/cli/commands/path.js +4 -4
  11. package/bin/cli/commands/query.js +54 -13
  12. package/bin/cli/commands/registry.js +4 -0
  13. package/bin/cli/commands/seek.js +17 -11
  14. package/bin/cli/commands/tree.js +230 -0
  15. package/bin/cli/commands/trust.js +3 -3
  16. package/bin/cli/commands/verify-audit.js +8 -7
  17. package/bin/cli/commands/view.js +6 -5
  18. package/bin/cli/infrastructure.js +26 -12
  19. package/bin/cli/shared.js +2 -2
  20. package/bin/cli/types.js +19 -8
  21. package/bin/presenters/index.js +35 -9
  22. package/bin/presenters/json.js +14 -12
  23. package/bin/presenters/text.js +155 -33
  24. package/index.d.ts +118 -22
  25. package/index.js +2 -0
  26. package/package.json +5 -3
  27. package/src/domain/WarpGraph.js +4 -1
  28. package/src/domain/crdt/ORSet.js +8 -8
  29. package/src/domain/errors/EmptyMessageError.js +2 -2
  30. package/src/domain/errors/ForkError.js +1 -1
  31. package/src/domain/errors/IndexError.js +1 -1
  32. package/src/domain/errors/OperationAbortedError.js +1 -1
  33. package/src/domain/errors/QueryError.js +1 -1
  34. package/src/domain/errors/SchemaUnsupportedError.js +1 -1
  35. package/src/domain/errors/ShardCorruptionError.js +2 -2
  36. package/src/domain/errors/ShardLoadError.js +2 -2
  37. package/src/domain/errors/ShardValidationError.js +4 -4
  38. package/src/domain/errors/StorageError.js +2 -2
  39. package/src/domain/errors/SyncError.js +1 -1
  40. package/src/domain/errors/TraversalError.js +1 -1
  41. package/src/domain/errors/TrustError.js +1 -1
  42. package/src/domain/errors/WarpError.js +2 -2
  43. package/src/domain/errors/WormholeError.js +1 -1
  44. package/src/domain/services/AuditReceiptService.js +6 -6
  45. package/src/domain/services/AuditVerifierService.js +52 -38
  46. package/src/domain/services/BitmapIndexBuilder.js +3 -3
  47. package/src/domain/services/BitmapIndexReader.js +28 -19
  48. package/src/domain/services/BoundaryTransitionRecord.js +18 -17
  49. package/src/domain/services/CheckpointSerializerV5.js +17 -16
  50. package/src/domain/services/CheckpointService.js +22 -3
  51. package/src/domain/services/CommitDagTraversalService.js +13 -13
  52. package/src/domain/services/DagPathFinding.js +7 -7
  53. package/src/domain/services/DagTopology.js +1 -1
  54. package/src/domain/services/DagTraversal.js +1 -1
  55. package/src/domain/services/HealthCheckService.js +1 -1
  56. package/src/domain/services/HookInstaller.js +1 -1
  57. package/src/domain/services/HttpSyncServer.js +92 -41
  58. package/src/domain/services/IndexRebuildService.js +7 -7
  59. package/src/domain/services/IndexStalenessChecker.js +4 -3
  60. package/src/domain/services/JoinReducer.js +26 -11
  61. package/src/domain/services/KeyCodec.js +7 -0
  62. package/src/domain/services/LogicalTraversal.js +1 -1
  63. package/src/domain/services/MessageCodecInternal.js +1 -1
  64. package/src/domain/services/MigrationService.js +1 -1
  65. package/src/domain/services/ObserverView.js +8 -8
  66. package/src/domain/services/PatchBuilderV2.js +96 -30
  67. package/src/domain/services/ProvenanceIndex.js +1 -1
  68. package/src/domain/services/ProvenancePayload.js +1 -1
  69. package/src/domain/services/QueryBuilder.js +3 -3
  70. package/src/domain/services/StateDiff.js +14 -11
  71. package/src/domain/services/StateSerializerV5.js +2 -2
  72. package/src/domain/services/StreamingBitmapIndexBuilder.js +26 -24
  73. package/src/domain/services/SyncAuthService.js +3 -2
  74. package/src/domain/services/SyncProtocol.js +25 -11
  75. package/src/domain/services/TemporalQuery.js +9 -6
  76. package/src/domain/services/TranslationCost.js +7 -5
  77. package/src/domain/services/WormholeService.js +16 -7
  78. package/src/domain/trust/TrustCanonical.js +3 -3
  79. package/src/domain/trust/TrustEvaluator.js +18 -3
  80. package/src/domain/trust/TrustRecordService.js +30 -23
  81. package/src/domain/trust/TrustStateBuilder.js +21 -8
  82. package/src/domain/trust/canonical.js +6 -6
  83. package/src/domain/types/TickReceipt.js +1 -1
  84. package/src/domain/types/WarpErrors.js +45 -0
  85. package/src/domain/types/WarpOptions.js +29 -0
  86. package/src/domain/types/WarpPersistence.js +41 -0
  87. package/src/domain/types/WarpTypes.js +2 -2
  88. package/src/domain/types/WarpTypesV2.js +2 -2
  89. package/src/domain/utils/MinHeap.js +6 -5
  90. package/src/domain/utils/canonicalStringify.js +5 -4
  91. package/src/domain/utils/roaring.js +31 -5
  92. package/src/domain/warp/PatchSession.js +40 -18
  93. package/src/domain/warp/_wiredMethods.d.ts +199 -45
  94. package/src/domain/warp/checkpoint.methods.js +5 -1
  95. package/src/domain/warp/fork.methods.js +2 -2
  96. package/src/domain/warp/materialize.methods.js +55 -5
  97. package/src/domain/warp/materializeAdvanced.methods.js +15 -4
  98. package/src/domain/warp/patch.methods.js +54 -29
  99. package/src/domain/warp/provenance.methods.js +5 -3
  100. package/src/domain/warp/query.methods.js +89 -6
  101. package/src/domain/warp/sync.methods.js +16 -11
  102. package/src/globals.d.ts +64 -0
  103. package/src/infrastructure/adapters/BunHttpAdapter.js +14 -9
  104. package/src/infrastructure/adapters/CasSeekCacheAdapter.js +9 -4
  105. package/src/infrastructure/adapters/DenoHttpAdapter.js +5 -6
  106. package/src/infrastructure/adapters/GitGraphAdapter.js +18 -13
  107. package/src/infrastructure/adapters/NodeHttpAdapter.js +2 -2
  108. package/src/infrastructure/adapters/WebCryptoAdapter.js +2 -2
  109. package/src/visualization/layouts/converters.js +2 -2
  110. package/src/visualization/layouts/elkAdapter.js +1 -1
  111. package/src/visualization/layouts/elkLayout.js +10 -7
  112. package/src/visualization/layouts/index.js +1 -1
  113. package/src/visualization/renderers/ascii/seek.js +16 -6
  114. package/src/visualization/renderers/svg/index.js +1 -1
@@ -7,20 +7,23 @@
7
7
 
8
8
  /**
9
9
  * @typedef {{ id: string, x?: number, y?: number, width?: number, height?: number, labels?: Array<{ text: string }> }} ElkResultChild
10
- * @typedef {{ id: string, sources?: string[], targets?: string[], labels?: Array<{ text: string }>, sections?: any[] }} ElkResultEdge
10
+ * @typedef {{ id: string, sources?: string[], targets?: string[], labels?: Array<{ text: string }>, sections?: unknown[] }} ElkResultEdge
11
11
  * @typedef {{ children?: ElkResultChild[], edges?: ElkResultEdge[], width?: number, height?: number }} ElkResult
12
- * @typedef {{ id: string, x: number, y: number, width: number, height: number, label: string }} PosNode
13
- * @typedef {{ id: string, source: string, target: string, label?: string, sections: any[] }} PosEdge
12
+ * @typedef {{ id: string, x: number, y: number, width: number, height: number, label?: string }} PosNode
13
+ * @typedef {{ x: number, y: number }} LayoutPoint
14
+ * @typedef {{ startPoint?: LayoutPoint, endPoint?: LayoutPoint, bendPoints?: LayoutPoint[] }} LayoutSection
15
+ * @typedef {{ id: string, source: string, target: string, label?: string, sections?: LayoutSection[] }} PosEdge
14
16
  * @typedef {{ nodes: PosNode[], edges: PosEdge[], width: number, height: number }} PositionedGraph
15
17
  * @typedef {{ id: string, children?: Array<{ id: string, width?: number, height?: number, labels?: Array<{ text: string }> }>, edges?: Array<{ id: string, sources?: string[], targets?: string[], labels?: Array<{ text: string }> }>, layoutOptions?: Record<string, string> }} ElkGraphInput
18
+ * @typedef {{ layout: (graph: ElkGraphInput) => Promise<ElkResult> }} ElkEngine
16
19
  */
17
20
 
18
- /** @type {Promise<any> | null} */
21
+ /** @type {Promise<unknown> | null} */
19
22
  let elkPromise = null;
20
23
 
21
24
  /**
22
25
  * Returns (or creates) a singleton ELK instance.
23
- * @returns {Promise<any>} ELK instance
26
+ * @returns {Promise<unknown>} ELK instance
24
27
  */
25
28
  function getElk() {
26
29
  if (!elkPromise) {
@@ -39,7 +42,7 @@ export async function runLayout(elkGraph) {
39
42
  /** @type {ElkResult | undefined} */
40
43
  let result;
41
44
  try {
42
- const elk = await getElk();
45
+ const elk = /** @type {ElkEngine} */ (await getElk());
43
46
  result = await elk.layout(elkGraph);
44
47
  } catch {
45
48
  return fallbackLayout(elkGraph);
@@ -67,7 +70,7 @@ function toPositionedGraph(result) {
67
70
  source: e.sources?.[0] ?? '',
68
71
  target: e.targets?.[0] ?? '',
69
72
  label: e.labels?.[0]?.text,
70
- sections: e.sections ?? [],
73
+ sections: /** @type {LayoutSection[]} */ (e.sections ?? []),
71
74
  }));
72
75
 
73
76
  return {
@@ -21,7 +21,7 @@ import { runLayout } from './elkLayout.js';
21
21
  *
22
22
  * @param {{ nodes: Array<{ id: string, label: string }>, edges: Array<{ from: string, to: string, label?: string }> }} graphData - Normalised graph data
23
23
  * @param {{ type?: 'query'|'path'|'slice', layoutOptions?: Record<string, string> }} [options]
24
- * @returns {Promise<{ nodes: any[], edges: any[], width: number, height: number }>} PositionedGraph
24
+ * @returns {Promise<import('./elkLayout.js').PositionedGraph>} PositionedGraph
25
25
  */
26
26
  export async function layoutGraph(graphData, options = {}) {
27
27
  const elkGraph = toElkGraph(graphData, options);
@@ -30,7 +30,7 @@ import { formatOpSummary } from './opSummary.js';
30
30
  * @property {number} patchCount
31
31
  * @property {Map<string, WriterInfo> | Record<string, WriterInfo>} perWriter
32
32
  * @property {{ nodes?: number, edges?: number }} [diff]
33
- * @property {Record<string, any>} [tickReceipt]
33
+ * @property {Record<string, unknown>} [tickReceipt]
34
34
  * @property {import('../../../domain/services/StateDiff.js').StateDiffResult | null} [structuralDiff]
35
35
  * @property {string} [diffBaseline]
36
36
  * @property {number | null} [baselineTick]
@@ -73,7 +73,7 @@ function pluralize(n, singular, plural) {
73
73
  return n === 1 ? singular : plural;
74
74
  }
75
75
 
76
- /** @param {Record<string, any> | undefined} tickReceipt @returns {string[]} */
76
+ /** @param {Record<string, unknown> | undefined} tickReceipt @returns {string[]} */
77
77
  function buildReceiptLines(tickReceipt) {
78
78
  if (!tickReceipt || typeof tickReceipt !== 'object') {
79
79
  return [];
@@ -85,8 +85,12 @@ function buildReceiptLines(tickReceipt) {
85
85
 
86
86
  const lines = [];
87
87
  for (const [writerId, entry] of entries) {
88
- const sha = typeof entry.sha === 'string' ? entry.sha : null;
89
- const opSummary = entry.opSummary && typeof entry.opSummary === 'object' ? entry.opSummary : entry;
88
+ /** @type {Record<string, unknown>} */
89
+ const rec = /** @type {Record<string, unknown>} */ (entry);
90
+ const sha = typeof rec.sha === 'string' ? rec.sha : null;
91
+ const opSummary = rec.opSummary && typeof rec.opSummary === 'object'
92
+ ? /** @type {Record<string, number>} */ (rec.opSummary)
93
+ : /** @type {Record<string, number>} */ (rec);
90
94
  const name = padRight(formatWriterName(writerId, NAME_W), NAME_W);
91
95
  const shaStr = sha ? ` ${formatSha(sha)}` : '';
92
96
  lines.push(` ${name}${shaStr} ${formatOpSummary(opSummary, 40)}`);
@@ -443,14 +447,20 @@ function collectDiffEntries(diff) {
443
447
 
444
448
  /**
445
449
  * Formats a property value for display (truncated if too long).
446
- * @param {*} value
450
+ * @param {unknown} value
447
451
  * @returns {string}
448
452
  */
449
453
  function formatPropValue(value) {
450
454
  if (value === undefined) {
451
455
  return 'undefined';
452
456
  }
453
- const s = typeof value === 'string' ? `"${value}"` : String(value);
457
+ if (typeof value === 'string') {
458
+ const s = `"${value}"`;
459
+ return s.length > 40 ? `${s.slice(0, 37)}...` : s;
460
+ }
461
+ const s = typeof value === 'number' || typeof value === 'boolean'
462
+ ? String(value)
463
+ : JSON.stringify(value) ?? '';
454
464
  return s.length > 40 ? `${s.slice(0, 37)}...` : s;
455
465
  }
456
466
 
@@ -119,7 +119,7 @@ function renderEdge(edge) {
119
119
  /**
120
120
  * Renders a PositionedGraph as an SVG string.
121
121
  *
122
- * @param {{ nodes?: Array<{ id: string, x: number, y: number, width: number, height: number, label?: string }>, edges?: Array<{ sections?: Array<any>, label?: string }>, width?: number, height?: number }} positionedGraph - PositionedGraph from runLayout()
122
+ * @param {{ nodes?: Array<{ id: string, x: number, y: number, width: number, height: number, label?: string }>, edges?: Array<{ sections?: Array<{ startPoint?: { x: number, y: number }, endPoint?: { x: number, y: number }, bendPoints?: Array<{ x: number, y: number }> }>, label?: string }>, width?: number, height?: number }} positionedGraph - PositionedGraph from runLayout()
123
123
  * @param {{ title?: string }} [options]
124
124
  * @returns {string} Complete SVG markup
125
125
  */