@ibgib/vcs-gib 0.0.30 → 0.0.33

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 (216) hide show
  1. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  2. package/dist/AUTO-GENERATED-version.mjs +1 -1
  3. package/dist/bootstrap/node-bootstrap.d.mts.map +1 -1
  4. package/dist/bootstrap/node-bootstrap.mjs +7 -21
  5. package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
  6. package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +3 -4
  7. package/dist/cli/commands/cli-add-cmd.d.mts.map +1 -0
  8. package/dist/cli/commands/cli-add-cmd.mjs +45 -0
  9. package/dist/cli/commands/cli-add-cmd.mjs.map +1 -0
  10. package/dist/cli/commands/{branch-cmd.d.mts → cli-branch-cmd.d.mts} +9 -9
  11. package/dist/cli/commands/cli-branch-cmd.d.mts.map +1 -0
  12. package/dist/cli/commands/cli-branch-cmd.mjs +59 -0
  13. package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -0
  14. package/dist/cli/commands/cli-checkout-cmd.d.mts +20 -0
  15. package/dist/cli/commands/cli-checkout-cmd.d.mts.map +1 -0
  16. package/dist/cli/commands/cli-checkout-cmd.mjs +50 -0
  17. package/dist/cli/commands/cli-checkout-cmd.mjs.map +1 -0
  18. package/dist/cli/commands/cli-commit-cmd.d.mts +23 -0
  19. package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -0
  20. package/dist/cli/commands/cli-commit-cmd.mjs +52 -0
  21. package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -0
  22. package/dist/cli/commands/{generate-comment-cmd.d.mts → cli-generate-comment-cmd.d.mts} +1 -1
  23. package/dist/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -0
  24. package/dist/cli/commands/{generate-comment-cmd.mjs → cli-generate-comment-cmd.mjs} +11 -6
  25. package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -0
  26. package/dist/cli/commands/{init-cmd.d.mts → cli-init-cmd.d.mts} +3 -3
  27. package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -0
  28. package/dist/cli/commands/cli-init-cmd.mjs +47 -0
  29. package/dist/cli/commands/cli-init-cmd.mjs.map +1 -0
  30. package/dist/cli/commands/{log-cmd.d.mts → cli-log-cmd.d.mts} +3 -4
  31. package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
  32. package/dist/cli/commands/cli-log-cmd.mjs +90 -0
  33. package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
  34. package/dist/cli/commands/cli-merge-cmd.d.mts +22 -0
  35. package/dist/cli/commands/cli-merge-cmd.d.mts.map +1 -0
  36. package/dist/cli/commands/cli-merge-cmd.mjs +66 -0
  37. package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -0
  38. package/dist/cli/commands/{reset-cmd.d.mts → cli-reset-cmd.d.mts} +2 -2
  39. package/dist/cli/commands/cli-reset-cmd.d.mts.map +1 -0
  40. package/dist/cli/commands/cli-reset-cmd.mjs +63 -0
  41. package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -0
  42. package/dist/cli/commands/cli-restore-cmd.d.mts +23 -0
  43. package/dist/cli/commands/cli-restore-cmd.d.mts.map +1 -0
  44. package/dist/cli/commands/cli-restore-cmd.mjs +55 -0
  45. package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -0
  46. package/dist/cli/commands/{status-cmd.d.mts → cli-status-cmd.d.mts} +3 -3
  47. package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
  48. package/dist/cli/commands/cli-status-cmd.mjs +96 -0
  49. package/dist/cli/commands/cli-status-cmd.mjs.map +1 -0
  50. package/dist/cli/vcs-cli-main.d.mts.map +1 -1
  51. package/dist/cli/vcs-cli-main.mjs +18 -15
  52. package/dist/cli/vcs-cli-main.mjs.map +1 -1
  53. package/dist/cli/vcs-projection-helper.d.mts +23 -0
  54. package/dist/cli/vcs-projection-helper.d.mts.map +1 -0
  55. package/dist/cli/vcs-projection-helper.mjs +91 -0
  56. package/dist/cli/vcs-projection-helper.mjs.map +1 -0
  57. package/dist/cli/vcs-repo-helper.d.mts +19 -0
  58. package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
  59. package/dist/cli/vcs-repo-helper.mjs +74 -0
  60. package/dist/cli/vcs-repo-helper.mjs.map +1 -0
  61. package/dist/test/test-helpers.d.mts +11 -2
  62. package/dist/test/test-helpers.d.mts.map +1 -1
  63. package/dist/test/test-helpers.mjs +35 -0
  64. package/dist/test/test-helpers.mjs.map +1 -1
  65. package/package.json +6 -6
  66. package/src/AUTO-GENERATED-version.mts +1 -1
  67. package/src/bootstrap/node-bootstrap.mts +7 -21
  68. package/src/bootstrap/node-bootstrap.respec.mts +2 -2
  69. package/src/cli/cli-arg-parser.respec.mts +2 -2
  70. package/src/cli/cli-e2e.respec.mts +12 -12
  71. package/src/cli/commands/branch-checkout-cmd.respec.mts +426 -412
  72. package/src/cli/commands/cli-add-cmd.mts +65 -0
  73. package/src/cli/commands/cli-branch-cmd.mts +87 -0
  74. package/src/cli/commands/cli-checkout-cmd.mts +72 -0
  75. package/src/cli/commands/cli-commit-cmd.mts +77 -0
  76. package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +12 -6
  77. package/src/cli/commands/cli-init-cmd.mts +78 -0
  78. package/src/cli/commands/cli-log-cmd.mts +126 -0
  79. package/src/cli/commands/cli-merge-cmd.mts +99 -0
  80. package/src/cli/commands/cli-reset-cmd.mts +94 -0
  81. package/src/cli/commands/cli-restore-cmd.mts +87 -0
  82. package/src/cli/commands/cli-status-cmd.mts +131 -0
  83. package/src/cli/commands/commit-log-cmd.respec.mts +85 -28
  84. package/src/cli/commands/init-cmd.respec.mts +3 -3
  85. package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
  86. package/src/cli/commands/status-add-cmd.respec.mts +21 -17
  87. package/src/cli/vcs-cli-main.mts +18 -15
  88. package/src/cli/vcs-projection-helper.mts +112 -0
  89. package/src/cli/vcs-repo-helper.mts +99 -0
  90. package/src/engine/branch/branch-space.respec.mts +23 -21
  91. package/src/engine/merge/b2tfs-sync-comments.respec.mts +11 -11
  92. package/src/test/test-helpers.mts +50 -2
  93. package/src/vcs-gib.respec.mts +25 -16
  94. package/tsconfig.test.tsbuildinfo +1 -1
  95. package/tsconfig.tsbuildinfo +1 -1
  96. package/vcs-gib_test_output.md +58 -0
  97. package/dist/cli/commands/add-cmd.d.mts.map +0 -1
  98. package/dist/cli/commands/add-cmd.mjs +0 -346
  99. package/dist/cli/commands/add-cmd.mjs.map +0 -1
  100. package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
  101. package/dist/cli/commands/branch-cmd.mjs +0 -238
  102. package/dist/cli/commands/branch-cmd.mjs.map +0 -1
  103. package/dist/cli/commands/checkout-cmd.d.mts +0 -21
  104. package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
  105. package/dist/cli/commands/checkout-cmd.mjs +0 -174
  106. package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
  107. package/dist/cli/commands/commit-cmd.d.mts +0 -24
  108. package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
  109. package/dist/cli/commands/commit-cmd.mjs +0 -449
  110. package/dist/cli/commands/commit-cmd.mjs.map +0 -1
  111. package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
  112. package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
  113. package/dist/cli/commands/init-cmd.d.mts.map +0 -1
  114. package/dist/cli/commands/init-cmd.mjs +0 -119
  115. package/dist/cli/commands/init-cmd.mjs.map +0 -1
  116. package/dist/cli/commands/log-cmd.d.mts.map +0 -1
  117. package/dist/cli/commands/log-cmd.mjs +0 -349
  118. package/dist/cli/commands/log-cmd.mjs.map +0 -1
  119. package/dist/cli/commands/merge-cmd.d.mts +0 -36
  120. package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
  121. package/dist/cli/commands/merge-cmd.mjs +0 -292
  122. package/dist/cli/commands/merge-cmd.mjs.map +0 -1
  123. package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
  124. package/dist/cli/commands/reset-cmd.mjs +0 -93
  125. package/dist/cli/commands/reset-cmd.mjs.map +0 -1
  126. package/dist/cli/commands/restore-cmd.d.mts +0 -22
  127. package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
  128. package/dist/cli/commands/restore-cmd.mjs +0 -115
  129. package/dist/cli/commands/restore-cmd.mjs.map +0 -1
  130. package/dist/cli/commands/status-cmd.d.mts.map +0 -1
  131. package/dist/cli/commands/status-cmd.mjs +0 -132
  132. package/dist/cli/commands/status-cmd.mjs.map +0 -1
  133. package/dist/engine/branch/branch-graph-helper.d.mts +0 -28
  134. package/dist/engine/branch/branch-graph-helper.d.mts.map +0 -1
  135. package/dist/engine/branch/branch-graph-helper.mjs +0 -81
  136. package/dist/engine/branch/branch-graph-helper.mjs.map +0 -1
  137. package/dist/engine/branch/branch-helper.d.mts +0 -40
  138. package/dist/engine/branch/branch-helper.d.mts.map +0 -1
  139. package/dist/engine/branch/branch-helper.mjs +0 -78
  140. package/dist/engine/branch/branch-helper.mjs.map +0 -1
  141. package/dist/engine/branch/branch-space-helper.d.mts +0 -23
  142. package/dist/engine/branch/branch-space-helper.d.mts.map +0 -1
  143. package/dist/engine/branch/branch-space-helper.mjs +0 -78
  144. package/dist/engine/branch/branch-space-helper.mjs.map +0 -1
  145. package/dist/engine/branch/branch-types.d.mts +0 -26
  146. package/dist/engine/branch/branch-types.d.mts.map +0 -1
  147. package/dist/engine/branch/branch-types.mjs +0 -7
  148. package/dist/engine/branch/branch-types.mjs.map +0 -1
  149. package/dist/engine/diff/line-diff-helper.d.mts +0 -76
  150. package/dist/engine/diff/line-diff-helper.d.mts.map +0 -1
  151. package/dist/engine/diff/line-diff-helper.mjs +0 -144
  152. package/dist/engine/diff/line-diff-helper.mjs.map +0 -1
  153. package/dist/engine/filter/glob-helper.d.mts +0 -51
  154. package/dist/engine/filter/glob-helper.d.mts.map +0 -1
  155. package/dist/engine/filter/glob-helper.mjs +0 -132
  156. package/dist/engine/filter/glob-helper.mjs.map +0 -1
  157. package/dist/engine/index/index-helper.d.mts +0 -113
  158. package/dist/engine/index/index-helper.d.mts.map +0 -1
  159. package/dist/engine/index/index-helper.mjs +0 -533
  160. package/dist/engine/index/index-helper.mjs.map +0 -1
  161. package/dist/engine/index/index-types.d.mts +0 -63
  162. package/dist/engine/index/index-types.d.mts.map +0 -1
  163. package/dist/engine/index/index-types.mjs +0 -7
  164. package/dist/engine/index/index-types.mjs.map +0 -1
  165. package/dist/engine/item/item-atom-helper.d.mts +0 -20
  166. package/dist/engine/item/item-atom-helper.d.mts.map +0 -1
  167. package/dist/engine/item/item-atom-helper.mjs +0 -30
  168. package/dist/engine/item/item-atom-helper.mjs.map +0 -1
  169. package/dist/engine/item/item-helper.d.mts +0 -94
  170. package/dist/engine/item/item-helper.d.mts.map +0 -1
  171. package/dist/engine/item/item-helper.mjs +0 -424
  172. package/dist/engine/item/item-helper.mjs.map +0 -1
  173. package/dist/engine/item/item-types.d.mts +0 -128
  174. package/dist/engine/item/item-types.d.mts.map +0 -1
  175. package/dist/engine/item/item-types.mjs +0 -16
  176. package/dist/engine/item/item-types.mjs.map +0 -1
  177. package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts +0 -74
  178. package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts.map +0 -1
  179. package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs +0 -570
  180. package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs.map +0 -1
  181. package/dist/engine/merge/b2tfs-3way-graft-types.d.mts +0 -34
  182. package/dist/engine/merge/b2tfs-3way-graft-types.d.mts.map +0 -1
  183. package/dist/engine/merge/b2tfs-3way-graft-types.mjs +0 -2
  184. package/dist/engine/merge/b2tfs-3way-graft-types.mjs.map +0 -1
  185. package/dist/engine/status/status-helper.d.mts +0 -90
  186. package/dist/engine/status/status-helper.d.mts.map +0 -1
  187. package/dist/engine/status/status-helper.mjs +0 -286
  188. package/dist/engine/status/status-helper.mjs.map +0 -1
  189. package/src/cli/commands/add-cmd.mts +0 -435
  190. package/src/cli/commands/branch-cmd.mts +0 -311
  191. package/src/cli/commands/checkout-cmd.mts +0 -227
  192. package/src/cli/commands/commit-cmd.mts +0 -557
  193. package/src/cli/commands/init-cmd.mts +0 -152
  194. package/src/cli/commands/log-cmd.mts +0 -449
  195. package/src/cli/commands/merge-cmd.mts +0 -363
  196. package/src/cli/commands/reset-cmd.mts +0 -128
  197. package/src/cli/commands/restore-cmd.mts +0 -155
  198. package/src/cli/commands/status-cmd.mts +0 -168
  199. package/src/engine/branch/branch-graph-helper.mts +0 -117
  200. package/src/engine/branch/branch-helper.mts +0 -112
  201. package/src/engine/branch/branch-space-helper.mts +0 -110
  202. package/src/engine/branch/branch-types.mts +0 -29
  203. package/src/engine/diff/line-diff-helper.mts +0 -210
  204. package/src/engine/diff/line-diff-helper.respec.mts +0 -84
  205. package/src/engine/filter/glob-helper.mts +0 -165
  206. package/src/engine/filter/glob-helper.respec.mts +0 -94
  207. package/src/engine/index/index-helper.mts +0 -705
  208. package/src/engine/index/index-types.mts +0 -66
  209. package/src/engine/item/item-atom-helper.mts +0 -30
  210. package/src/engine/item/item-helper.mts +0 -544
  211. package/src/engine/item/item-types.mts +0 -137
  212. package/src/engine/item/item.respec.mts +0 -92
  213. package/src/engine/merge/b2tfs-3way-graft-strategy.mts +0 -630
  214. package/src/engine/merge/b2tfs-3way-graft-strategy.respec.mts +0 -346
  215. package/src/engine/merge/b2tfs-3way-graft-types.mts +0 -34
  216. package/src/engine/status/status-helper.mts +0 -383
@@ -1,168 +0,0 @@
1
- /**
2
- * @module status-cmd
3
- *
4
- * Command handler for `vcs status`.
5
- * Compares physical workspace state against active branch snapshot tip and in-band index staging area.
6
- */
7
-
8
- import path from 'node:path';
9
- import fs from 'node:fs/promises';
10
-
11
- import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
13
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
14
- import { getRepoStatus, VcsStatusItem, PendingCommentInfo } from '../../engine/status/status-helper.mjs';
15
-
16
- const lcFile = `[status-cmd]`;
17
- const logalot = GLOBAL_LOG_A_LOT;
18
-
19
- export { VcsStatusItem, PendingCommentInfo };
20
-
21
- export interface StatusCmdResult {
22
- branchName: string;
23
- staged: VcsStatusItem[];
24
- modified: VcsStatusItem[];
25
- deleted: VcsStatusItem[];
26
- untracked: VcsStatusItem[];
27
- pendingComments: PendingCommentInfo[];
28
- }
29
-
30
- export interface StatusCmdOpts {
31
- targetDir?: string;
32
- vcsFolderName?: string;
33
- quiet?: boolean;
34
- comments?: boolean;
35
- }
36
-
37
- export async function executeStatusCmd({
38
- targetDir = process.cwd(),
39
- vcsFolderName = '.vcsgib',
40
- quiet = false,
41
- comments = false,
42
- }: StatusCmdOpts = {}): Promise<StatusCmdResult> {
43
- const lc = `${lcFile}[${executeStatusCmd.name}]`;
44
-
45
- try {
46
- if (logalot) {
47
- console.log(`${lc} starting executeStatusCmd (I: 7a8b9c10d11e12f13a14b15c16d17e18)`);
48
- }
49
-
50
- const absTargetDir = path.resolve(targetDir);
51
-
52
- const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
53
- repoPath: absTargetDir,
54
- vcsFolderName,
55
- });
56
-
57
- // Verify repo exists
58
- try {
59
- await fs.access(vcsPath);
60
- } catch {
61
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 4d5e6f7a8b9c10d11e12f13a14b15c6d)`);
62
- }
63
-
64
- const statusRes = await getRepoStatus({
65
- metaspace,
66
- localSpace,
67
- vcsPath,
68
- repoRoot,
69
- targetDir: absTargetDir,
70
- vcsFolderName,
71
- });
72
-
73
- const { branchName, staged, modified, deleted, untracked, pendingComments } = statusRes;
74
-
75
- const commentsByTarget = new Map<string, PendingCommentInfo[]>();
76
- for (const c of pendingComments) {
77
- const list = commentsByTarget.get(c.targetRelPath) || [];
78
- list.push(c);
79
- commentsByTarget.set(c.targetRelPath, list);
80
- }
81
-
82
- if (!quiet) {
83
- console.log(`On branch ${branchName} (I: 9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b)`);
84
-
85
- if (staged.length > 0) {
86
- console.log('\nChanges to be committed:');
87
- for (const item of staged) {
88
- const itemComments = commentsByTarget.get(item.path) || [];
89
- console.log(` staged: ${item.path}`);
90
- if (itemComments.length === 0) {
91
- console.log(` (hint: no comment file found for ${item.path} - run 'vcs gmsg')`);
92
- } else if (comments) {
93
- for (const comm of itemComments) {
94
- console.log(` [comment: ${comm.commentRelPath}]`);
95
- const lines = comm.content.trim().split('\n');
96
- for (const line of lines) {
97
- console.log(` ${line}`);
98
- }
99
- }
100
- }
101
- }
102
- }
103
-
104
- if (modified.length > 0 || deleted.length > 0) {
105
- console.log('\nChanges not staged for commit:');
106
- for (const item of modified) {
107
- const itemComments = commentsByTarget.get(item.path) || [];
108
- console.log(` modified: ${item.path}`);
109
- if (comments && itemComments.length > 0) {
110
- for (const comm of itemComments) {
111
- console.log(` [comment: ${comm.commentRelPath}]`);
112
- const lines = comm.content.trim().split('\n');
113
- for (const line of lines) {
114
- console.log(` ${line}`);
115
- }
116
- }
117
- }
118
- }
119
- for (const item of deleted) {
120
- console.log(` deleted: ${item.path}`);
121
- }
122
- }
123
-
124
- if (untracked.length > 0) {
125
- console.log('\nUntracked files:');
126
- for (const item of untracked) {
127
- console.log(` untracked:${item.path}`);
128
- }
129
- }
130
-
131
- // Pending folder-level comments
132
- const folderComments = pendingComments.filter(c => c.targetType === 'folder');
133
- if (folderComments.length > 0) {
134
- console.log('\nPending folder comments:');
135
- for (const fc of folderComments) {
136
- const folderLabel = fc.targetRelPath ? fc.targetRelPath : '(root)';
137
- console.log(` folder: ${folderLabel} [${fc.commentRelPath}]`);
138
- if (comments) {
139
- const lines = fc.content.trim().split('\n');
140
- for (const line of lines) {
141
- console.log(` ${line}`);
142
- }
143
- }
144
- }
145
- }
146
-
147
- if (staged.length === 0 && modified.length === 0 && deleted.length === 0 && untracked.length === 0) {
148
- console.log('nothing to commit, working tree clean');
149
- }
150
- }
151
-
152
- return {
153
- branchName,
154
- staged,
155
- modified,
156
- deleted,
157
- untracked,
158
- pendingComments,
159
- };
160
- } catch (error) {
161
- console.error(`${lc} ${extractErrorMsg(error)} (E: 5e6f7a8b9c10d11e12f13a14b15c6d7e)`);
162
- throw error;
163
- } finally {
164
- if (logalot) {
165
- console.log(`${lc} complete. (I: 6f7a8b9c10d11e12f13a14b15c6d7e8f)`);
166
- }
167
- }
168
- }
@@ -1,117 +0,0 @@
1
- /**
2
- * @module branch-graph-helper
3
- *
4
- * Helper for populating branch spaces via SyncSagaCoordinator.
5
- */
6
-
7
- import { clone, extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
8
- import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
9
- import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
10
- import { MetaspaceService } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs';
11
- import { SyncSagaCoordinator } from '@ibgib/core-gib/dist/sync/sync-saga-coordinator.mjs';
12
- import { SyncPeerInnerspace_V1 } from '@ibgib/core-gib/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
13
- import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from '@ibgib/core-gib/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
14
-
15
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
16
- import { B2tFSBranchIbGib_V1 } from './branch-types.mjs';
17
- import { createB2tFSBranchIbGib } from './branch-helper.mjs';
18
-
19
- const lcFile = `[branch-graph-helper]`;
20
- const logalot = GLOBAL_LOG_A_LOT;
21
-
22
- export interface PopulateBranchSpaceFromGraphOpts {
23
- sourceSpace: IbGibSpaceAny;
24
- targetBranchSpace: IbGibSpaceAny;
25
- rootItemIbGib: IbGib_V1;
26
- branchName?: string;
27
- metaspace?: MetaspaceService;
28
- }
29
-
30
- export interface PopulateBranchSpaceFromGraphResult {
31
- syncedCount: number;
32
- branchIbGib?: B2tFSBranchIbGib_V1;
33
- }
34
-
35
- /**
36
- * Executes SSM (Space - Sync - Metadata) for branch space initialization:
37
- * 1. Space: Target branch space targetBranchSpace (b2s_<branchName>).
38
- * 2. Sync: Syncs rootItemIbGib from sourceSpace -> targetBranchSpace using SyncSagaCoordinator.
39
- * 3. Metadata: Creates B2tFSBranchIbGib_V1 metadata node in targetBranchSpace pointing to rootItem.
40
- */
41
- export async function populateBranchSpaceFromGraph({
42
- sourceSpace,
43
- targetBranchSpace,
44
- rootItemIbGib,
45
- branchName,
46
- metaspace,
47
- }: PopulateBranchSpaceFromGraphOpts): Promise<PopulateBranchSpaceFromGraphResult> {
48
- const lc = `${lcFile}[${populateBranchSpaceFromGraph.name}]`;
49
- try {
50
- if (logalot) {
51
- console.log(`${lc} starting... (I: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`);
52
- }
53
-
54
- if (!sourceSpace || !targetBranchSpace || !rootItemIbGib || !metaspace) {
55
- throw new Error(`sourceSpace, targetBranchSpace, rootItemIbGib, and metaspace are required (E: 2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e)`);
56
- }
57
-
58
- // 1. Space: targetBranchSpace provided/instantiated
59
-
60
- // 2. Sync: Execute SyncSagaCoordinator space-to-space sync (sourceSpace -> targetBranchSpace)
61
- const senderCoordinator = new SyncSagaCoordinator();
62
- const receiverCoordinator = new SyncSagaCoordinator();
63
-
64
- const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
65
- await peer.initialized;
66
- await peer.initializeOpts({
67
- localMetaspace: metaspace,
68
- localSpace: sourceSpace,
69
- receiverSpace: targetBranchSpace,
70
- receiverCoordinator,
71
- receiverMetaspace: metaspace,
72
- });
73
-
74
- const resSync = await senderCoordinator.sync({
75
- peer,
76
- localSpace: sourceSpace,
77
- metaspace,
78
- domainIbGibs: [rootItemIbGib],
79
- });
80
-
81
- await resSync.done;
82
-
83
- if (logalot) {
84
- console.log(`${lc} SyncSagaCoordinator sync initiated for ${rootItemIbGib.ib} (I: 3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f)`);
85
- }
86
-
87
- const syncedCount = 1;
88
-
89
- // 3. Metadata: Create B2tFSBranchIbGib_V1 metadata node in targetBranchSpace pointing to rootItem
90
- let branchIbGib: B2tFSBranchIbGib_V1 | undefined;
91
- if (branchName && metaspace) {
92
- branchIbGib = await createB2tFSBranchIbGib({
93
- branchName,
94
- rootItem: rootItemIbGib as any,
95
- space: targetBranchSpace,
96
- metaspace,
97
- });
98
- }
99
-
100
- if (logalot) {
101
- console.log(`${lc} Populated target branch space via SyncSagaCoordinator (I: 4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f)`);
102
- }
103
-
104
- return {
105
- syncedCount,
106
- branchIbGib,
107
- };
108
- } catch (error) {
109
- console.error(`${lc} ${extractErrorMsg(error)} (E: 4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a)`);
110
- throw error;
111
- } finally {
112
- if (logalot) {
113
- console.log(`${lc} complete. (I: 5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b)`);
114
- }
115
- }
116
- }
117
-
@@ -1,112 +0,0 @@
1
- /**
2
- * @module branch-helper
3
- *
4
- * B2tFS Branch Helper functions: dedicated branch spaces (`b2s_...`), branch creation,
5
- * and branch timeline tracking.
6
- */
7
-
8
- import path from 'node:path';
9
- import { getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
10
- import { ROOT } from '@ibgib/ts-gib/dist/V1/constants.mjs';
11
- import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
12
- import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
13
- import { MetaspaceService } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs';
14
- import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
15
- import { putInSpace, persistTransformResult } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
16
-
17
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
18
- import { B2tFSBranchIbGib_V1, B2tFSBranchData_V1, B2tFSBranchRel8ns_V1 } from './branch-types.mjs';
19
- import { B2tFSItemIbGib_V1 } from '../item/item-types.mjs';
20
-
21
- const lcFile = `[branch-helper]`;
22
- const logalot = GLOBAL_LOG_A_LOT;
23
-
24
- export const B2TFS_BRANCH_SPACE_PREFIX = 'b2s_';
25
-
26
- /**
27
- * Generates a dedicated branch space name.
28
- * Example: 'main' -> 'b2s_main'
29
- */
30
- export function getB2tFSBranchSpaceName(branchName: string): string {
31
- const safeName = branchName.replace(/[^a-zA-Z0-9_\-]/g, '_');
32
- return `${B2TFS_BRANCH_SPACE_PREFIX}${safeName}`;
33
- }
34
-
35
- /**
36
- * Creates a new B2tFSBranchIbGib pointing to a root folder item.
37
- */
38
- export async function createB2tFSBranchIbGib(opts: {
39
- branchName: string;
40
- rootItem: B2tFSItemIbGib_V1;
41
- space: IbGibSpaceAny;
42
- metaspace: MetaspaceService;
43
- }): Promise<B2tFSBranchIbGib_V1> {
44
- const lc = `${lcFile}[${createB2tFSBranchIbGib.name}]`;
45
- const { branchName, rootItem, space, metaspace } = opts;
46
-
47
- if (!branchName || !rootItem) {
48
- throw new Error(`branchName and rootItem required (E: 9012a472c9104b2d)`);
49
- }
50
-
51
- const uuid = await getUUID();
52
- const rootAddr = getIbGibAddr({ ibGib: rootItem });
53
-
54
- const data: B2tFSBranchData_V1 = {
55
- name: branchName,
56
- uuid,
57
- classname: 'B2tFSBranchIbGib_V1',
58
- };
59
-
60
- const rel8ns: B2tFSBranchRel8ns_V1 = {
61
- b2tfs_item: [rootAddr],
62
- };
63
-
64
- const res = await Factory_V1.firstGen({
65
- parentIbGib: ROOT,
66
- ib: `b2tfs_branch ${branchName} v1 ${uuid}`,
67
- data,
68
- rel8ns,
69
- });
70
-
71
- const branchIbGib = res.newIbGib as B2tFSBranchIbGib_V1;
72
- await persistTransformResult({ resTransform: res, space });
73
- await metaspace.registerNewIbGib({ ibGib: branchIbGib });
74
-
75
- if (logalot) {
76
- console.log(`${lc} Created branch IbGib: ${branchIbGib.ib}`);
77
- }
78
-
79
- return branchIbGib;
80
- }
81
-
82
- /**
83
- * Resolves the contextual branch name given the target directory and repository root.
84
- * If targetDir is physically located inside a secondary branch worktree (`repoRoot/b/<branchName>`),
85
- * that worktree's branchName is returned. Otherwise, the index's activeBranch (defaulting to 'main') is returned.
86
- */
87
- export function resolveContextualBranchName({
88
- targetDir,
89
- repoRoot,
90
- indexIbGib,
91
- }: {
92
- targetDir: string;
93
- repoRoot: string;
94
- indexIbGib?: { data?: { activeBranch?: string } } | null;
95
- }): string {
96
- const absTarget = path.resolve(targetDir);
97
- const absRoot = path.resolve(repoRoot);
98
- const rel = path.relative(absRoot, absTarget).replace(/\\/g, '/');
99
-
100
- if (rel.startsWith('b/') || rel === 'b') {
101
- const parts = rel.split('/').filter(Boolean);
102
- if (parts.length >= 2 && parts[0] === 'b') {
103
- const candidateBranch = parts[1];
104
- if (candidateBranch) {
105
- return candidateBranch;
106
- }
107
- }
108
- }
109
-
110
- return indexIbGib?.data?.activeBranch || 'main';
111
- }
112
-
@@ -1,110 +0,0 @@
1
- /**
2
- * @module branch-space-helper
3
- *
4
- * Helper for managing dedicated branch spaces (`b2s_...`) in metaspace.
5
- */
6
-
7
- import { clone, extractErrorMsg, getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
8
- import { getGib } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
9
- import { Metaspace_Nodespace } from '@ibgib/node-gib/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.mjs';
10
- import { NodeFilesystemSpace_V1 } from '@ibgib/node-gib/dist/witness/space/node-filesystem-space/node-filesystem-space-v1.mjs';
11
- import { DEFAULT_NODE_FILESYSTEM_SPACE_DATA_V1 } from '@ibgib/node-gib/dist/witness/space/node-filesystem-space/node-filesystem-space-types.mjs';
12
- import { putInSpace } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
13
-
14
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
- import { getB2tFSBranchSpaceName } from './branch-helper.mjs';
16
-
17
- export {
18
- populateBranchSpaceFromGraph,
19
- PopulateBranchSpaceFromGraphOpts,
20
- PopulateBranchSpaceFromGraphResult,
21
- } from './branch-graph-helper.mjs';
22
-
23
- const lcFile = `[branch-space-helper]`;
24
- const logalot = GLOBAL_LOG_A_LOT;
25
-
26
- export interface GetOrCreateBranchSpaceOpts {
27
- metaspace: Metaspace_Nodespace;
28
- vcsPath: string;
29
- branchName: string;
30
- }
31
-
32
- export interface GetOrCreateBranchSpaceResult {
33
- space: NodeFilesystemSpace_V1;
34
- spaceId: string;
35
- spaceName: string;
36
- }
37
-
38
- /**
39
- * Gets an existing branch space or creates and registers a new dedicated NodeFilesystemSpace_V1 in metaspace.
40
- */
41
- export async function getOrCreateBranchSpace({
42
- metaspace,
43
- vcsPath,
44
- branchName,
45
- }: GetOrCreateBranchSpaceOpts): Promise<GetOrCreateBranchSpaceResult> {
46
- const lc = `${lcFile}[${getOrCreateBranchSpace.name}]`;
47
- try {
48
- if (logalot) {
49
- console.log(`${lc} starting... (I: a1b2c3d4e5f60718293a4b5c6d7e8f9a)`);
50
- }
51
-
52
- if (!metaspace || !vcsPath || !branchName) {
53
- throw new Error(`metaspace, vcsPath, and branchName are required (E: b2c3d4e5f60718293a4b5c6d7e8f9a0b)`);
54
- }
55
-
56
- const spaceName = getB2tFSBranchSpaceName(branchName);
57
-
58
- const localSpaces = await metaspace.getLocalUserSpaces({ lock: false });
59
- const existingSpace = localSpaces.find(s => s.data?.name === spaceName || s.ib === spaceName);
60
-
61
- if (existingSpace) {
62
- const spaceId = existingSpace.data?.uuid || existingSpace.data?.spaceId || spaceName;
63
- if (logalot) {
64
- console.log(`${lc} Found existing branch space ${spaceName} (spaceId: ${spaceId}) (I: c3d4e5f60718293a4b5c6d7e8f9a0b1c)`);
65
- }
66
- return {
67
- space: existingSpace as NodeFilesystemSpace_V1,
68
- spaceId,
69
- spaceName,
70
- };
71
- }
72
-
73
- const spaceUuid = await getUUID();
74
- const spaceData = {
75
- ...clone(DEFAULT_NODE_FILESYSTEM_SPACE_DATA_V1),
76
- uuid: spaceUuid,
77
- isTjp: true,
78
- name: spaceName,
79
- baseDir: vcsPath,
80
- spaceSubPath: spaceName,
81
- };
82
-
83
- const space = new NodeFilesystemSpace_V1(spaceData);
84
- space.gib = await getGib({ ibGib: space, hasTjp: true });
85
- await space.initialized;
86
-
87
- await putInSpace({ space: metaspace.zeroSpace, ibGib: space });
88
- await metaspace.registerNewIbGib({ ibGib: space });
89
- if (metaspace.fnUpdateBootstrap) {
90
- await metaspace.fnUpdateBootstrap(space);
91
- }
92
-
93
- if (logalot) {
94
- console.log(`${lc} Created new branch space ${spaceName} (spaceId: ${spaceUuid}) (I: d4e5f60718293a4b5c6d7e8f9a0b1c2d)`);
95
- }
96
-
97
- return {
98
- space,
99
- spaceId: spaceUuid,
100
- spaceName,
101
- };
102
- } catch (error) {
103
- console.error(`${lc} ${extractErrorMsg(error)} (E: e5f60718293a4b5c6d7e8f9a0b1c2d3e)`);
104
- throw error;
105
- } finally {
106
- if (logalot) {
107
- console.log(`${lc} complete. (I: f60718293a4b5c6d7e8f9a0b1c2d3e4f)`);
108
- }
109
- }
110
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * @module branch-types
3
- *
4
- * B2tFS Branch type definitions.
5
- */
6
-
7
- import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
8
- import { IbGibData_V1, IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
9
-
10
- export interface B2tFSBranchData_V1 extends IbGibData_V1 {
11
- /**
12
- * Branch name (e.g. 'main', 'feature/login')
13
- */
14
- name: string;
15
- /**
16
- * Relative path from repository root to working directory
17
- */
18
- relativePathFromMetaspaceToFSPath?: string;
19
- }
20
-
21
- export interface B2tFSBranchRel8ns_V1 extends IbGibRel8ns_V1 {
22
- /**
23
- * Link pointing to the root folder B2tFSItemIbGib_V1
24
- */
25
- b2tfs_item?: IbGibAddr[];
26
- }
27
-
28
- export interface B2tFSBranchIbGib_V1 extends IbGib_V1<B2tFSBranchData_V1, B2tFSBranchRel8ns_V1> {
29
- }