@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
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @module add-cmd
3
+ *
4
+ * CLI command handler for `vcs add <path...>`.
5
+ * Bootstraps workspace projection space and delegates to executeVcsAdd.
6
+ */
7
+
8
+ import path from 'node:path';
9
+
10
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
11
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
12
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
13
+
14
+ const lcFile = `[add-cmd]`;
15
+ const logalot = GLOBAL_LOG_A_LOT;
16
+
17
+ export interface AddCmdOpts {
18
+ paths?: string[];
19
+ targetDir?: string;
20
+ vcsFolderName?: string;
21
+ all?: boolean;
22
+ quiet?: boolean;
23
+ }
24
+
25
+ export interface AddCmdResult {
26
+ stagedPaths: string[];
27
+ stagedCount: number;
28
+ }
29
+
30
+ export async function executeAddCmd({
31
+ paths = [],
32
+ targetDir = process.cwd(),
33
+ vcsFolderName = '.vcsgib',
34
+ all = false,
35
+ quiet = false,
36
+ }: AddCmdOpts = {}): Promise<AddCmdResult> {
37
+ const lc = `${lcFile}[${executeAddCmd.name}]`;
38
+ try {
39
+ if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
40
+
41
+ const absTargetDir = path.resolve(targetDir);
42
+ const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
43
+
44
+ const addRes = await repo.add(paths, {
45
+ all,
46
+ targetDir: absTargetDir,
47
+ });
48
+
49
+ if (!quiet) {
50
+ for (const stagedPath of addRes.stagedPaths) {
51
+ console.log(`staged: ${stagedPath}`);
52
+ }
53
+ }
54
+
55
+ return {
56
+ stagedPaths: addRes.stagedPaths,
57
+ stagedCount: addRes.stagedCount,
58
+ };
59
+ } catch (error) {
60
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
61
+ throw error;
62
+ } finally {
63
+ if (logalot) { console.log(`${lc} complete. (I: genuuid)`); }
64
+ }
65
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @module branch-cmd
3
+ *
4
+ * CLI command handler for `vcs branch [branchName]`.
5
+ * Delegates to executeVcsBranch and formats terminal output.
6
+ */
7
+
8
+ import path from 'node:path';
9
+
10
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
11
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
12
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
13
+
14
+ const lcFile = `[branch-cmd]`;
15
+ const logalot = GLOBAL_LOG_A_LOT;
16
+
17
+ export interface BranchInfo {
18
+ name: string;
19
+ isActive: boolean;
20
+ addr: string;
21
+ rootItemAddr?: string;
22
+ }
23
+
24
+ export interface BranchCmdOpts {
25
+ branchName?: string;
26
+ itemPath?: string;
27
+ targetDir?: string;
28
+ vcsFolderName?: string;
29
+ quiet?: boolean;
30
+ }
31
+
32
+ export interface BranchCmdResult {
33
+ branches: BranchInfo[];
34
+ createdBranchName?: string;
35
+ createdBranchAddr?: string;
36
+ }
37
+
38
+ export async function executeBranchCmd({
39
+ branchName,
40
+ itemPath,
41
+ targetDir = process.cwd(),
42
+ vcsFolderName = '.vcsgib',
43
+ quiet = false,
44
+ }: BranchCmdOpts = {}): Promise<BranchCmdResult> {
45
+ const lc = `${lcFile}[${executeBranchCmd.name}]`;
46
+ try {
47
+ if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
48
+
49
+ const absTargetDir = path.resolve(targetDir);
50
+ const { repo, } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
51
+
52
+ const branchRes = await repo.branch({
53
+ branchName,
54
+ itemPath,
55
+ targetDir: absTargetDir,
56
+ });
57
+
58
+ const branches: BranchInfo[] = branchRes.branches.map(b => ({
59
+ name: b.name,
60
+ isActive: b.isActive,
61
+ addr: b.branchAddr || '',
62
+ rootItemAddr: b.rootItemAddr,
63
+ }));
64
+
65
+ if (!quiet) {
66
+ if (!branchName) {
67
+ for (const b of branches) {
68
+ const prefix = b.isActive ? '* ' : ' ';
69
+ console.log(`${prefix}${b.name}`);
70
+ }
71
+ } else {
72
+ console.log(`Created branch '${branchRes.createdBranchName}'`);
73
+ }
74
+ }
75
+
76
+ return {
77
+ branches,
78
+ createdBranchName: branchRes.createdBranchName,
79
+ createdBranchAddr: branchRes.createdBranchAddr,
80
+ };
81
+ } catch (error) {
82
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
83
+ throw error;
84
+ } finally {
85
+ if (logalot) { console.log(`${lc} complete. (I: genuuid)`); }
86
+ }
87
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @module checkout-cmd
3
+ *
4
+ * CLI command handler for `vcs checkout <branchName>`.
5
+ * Thin facade delegating to VcsRepository.checkout.
6
+ */
7
+
8
+ import path from 'node:path';
9
+
10
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
11
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
12
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
13
+
14
+ const lcFile = `[checkout-cmd]`;
15
+ const logalot = GLOBAL_LOG_A_LOT;
16
+
17
+ export interface CheckoutCmdOpts {
18
+ branchName?: string;
19
+ force?: boolean;
20
+ targetDir?: string;
21
+ vcsFolderName?: string;
22
+ quiet?: boolean;
23
+ }
24
+
25
+ export interface CheckoutCmdResult {
26
+ previousBranch: string;
27
+ currentBranch: string;
28
+ worktreePath: string;
29
+ }
30
+
31
+ export async function executeCheckoutCmd({
32
+ branchName,
33
+ force = false,
34
+ targetDir = process.cwd(),
35
+ vcsFolderName = '.vcsgib',
36
+ quiet = false,
37
+ }: CheckoutCmdOpts = {}): Promise<CheckoutCmdResult> {
38
+ const lc = `${lcFile}[${executeCheckoutCmd.name}]`;
39
+ try {
40
+ if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
41
+
42
+ const trimmedBranchName = branchName?.trim();
43
+ if (!trimmedBranchName) {
44
+ throw new Error(`Branch name is required for checkout (E: genuuid)`);
45
+ }
46
+
47
+ const absTargetDir = path.resolve(targetDir);
48
+ const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
49
+
50
+ const checkoutRes = await repo.checkout({
51
+ branchName: trimmedBranchName,
52
+ force,
53
+ targetDir: absTargetDir,
54
+ });
55
+
56
+ if (!quiet) {
57
+ console.log(`Switched to branch '${checkoutRes.currentBranch}' (I: genuuid)`);
58
+ console.log(`Worktree path: ${checkoutRes.worktreePath}`);
59
+ }
60
+
61
+ return {
62
+ previousBranch: checkoutRes.previousBranch,
63
+ currentBranch: checkoutRes.currentBranch,
64
+ worktreePath: checkoutRes.worktreePath,
65
+ };
66
+ } catch (error) {
67
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
68
+ throw error;
69
+ } finally {
70
+ if (logalot) { console.log(`${lc} complete. (I: genuuid)`); }
71
+ }
72
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @module commit-cmd
3
+ *
4
+ * CLI command handler for `vcs commit -m <message>`.
5
+ * Bootstraps workspace projection space and delegates to executeVcsCommit.
6
+ */
7
+
8
+ import path from 'node:path';
9
+
10
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
11
+
12
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
13
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
14
+
15
+ const lcFile = `[commit-cmd]`;
16
+ const logalot = GLOBAL_LOG_A_LOT;
17
+
18
+ export interface CommitCmdOpts {
19
+ message?: string;
20
+ targetDir?: string;
21
+ vcsFolderName?: string;
22
+ author?: string;
23
+ quiet?: boolean;
24
+ }
25
+
26
+ export interface CommitCmdResult {
27
+ branchName: string;
28
+ commitAddr: string;
29
+ commentAddr?: string;
30
+ rootItemAddr: string;
31
+ committedPaths: string[];
32
+ ingestedCommentsCount: number;
33
+ }
34
+
35
+ export async function executeCommitCmd({
36
+ message,
37
+ targetDir = process.cwd(),
38
+ vcsFolderName = '.vcsgib',
39
+ author = 'vcs-user',
40
+ quiet = false,
41
+ }: CommitCmdOpts = {}): Promise<CommitCmdResult> {
42
+ const lc = `${lcFile}[${executeCommitCmd.name}]`;
43
+ try {
44
+ if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
45
+
46
+ const absTargetDir = path.resolve(targetDir);
47
+ const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
48
+
49
+ const commitRes = await repo.commit({
50
+ message,
51
+ author,
52
+ targetDir: absTargetDir,
53
+ });
54
+
55
+ if (!quiet) {
56
+ console.log(`[${commitRes.branchName} ${commitRes.commitAddr.slice(0, 7)}] ${message || '(companion comments committed)'}`);
57
+ console.log(` ${commitRes.committedPaths.length} file(s) changed`);
58
+ if (commitRes.ingestedCommentsCount > 0) {
59
+ console.log(` ${commitRes.ingestedCommentsCount} companion comment(s) attached and merged`);
60
+ }
61
+ }
62
+
63
+ return {
64
+ branchName: commitRes.branchName,
65
+ commitAddr: commitRes.commitAddr,
66
+ commentAddr: commitRes.commentAddr,
67
+ rootItemAddr: commitRes.rootItemAddr,
68
+ committedPaths: commitRes.committedPaths,
69
+ ingestedCommentsCount: commitRes.ingestedCommentsCount,
70
+ };
71
+ } catch (error) {
72
+ console.error(`${lc} ${extractErrorMsg(error)} (E: 4c453a4e7648a5f6058edf489254c826)`);
73
+ throw error;
74
+ } finally {
75
+ if (logalot) { console.log(`${lc} complete. (I: genuuid)`); }
76
+ }
77
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module generate-comment-cmd
3
- *
3
+ *
4
4
  * Command handler for `vcs generate-comment` (synonyms: `gen-comment`, `gen-msg`, `gcomm`, `gmsg`).
5
5
  * Scans repository status or target paths and creates `.ib.<file>.md` or `.ib.<topic>.md` companion metadata files.
6
6
  */
@@ -11,7 +11,9 @@ import fs from 'node:fs/promises';
11
11
  import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
12
  import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
13
13
  import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
14
- import { getRepoStatus } from '../../engine/status/status-helper.mjs';
14
+ import { getRepoStatus } from '@ibgib/core-gib/dist/vcs/status/status-helper.mjs';
15
+ import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
16
+ import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
15
17
 
16
18
  const lcFile = `[generate-comment-cmd]`;
17
19
  const logalot = GLOBAL_LOG_A_LOT;
@@ -40,7 +42,7 @@ export async function executeGenerateCommentCmd({
40
42
 
41
43
  try {
42
44
  if (logalot) {
43
- console.log(`${lc} starting executeGenerateCommentCmd (I: 8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e)`);
45
+ console.log(`${lc} starting... (I: genuuid)`);
44
46
  }
45
47
 
46
48
  const absTargetDir = path.resolve(targetDir);
@@ -54,12 +56,16 @@ export async function executeGenerateCommentCmd({
54
56
  try {
55
57
  await fs.access(vcsPath);
56
58
  } catch {
57
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f)`);
59
+ throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: genuuid)`);
58
60
  }
59
61
 
62
+ const indexIbGib = (await getB2tFSIndexIbGib({ space: localSpace, metaspace }))
63
+ || (await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace }));
64
+
60
65
  const statusRes = await getRepoStatus({
61
66
  metaspace,
62
67
  localSpace,
68
+ indexIbGib,
63
69
  vcsPath,
64
70
  repoRoot,
65
71
  vcsFolderName,
@@ -161,11 +167,11 @@ export async function executeGenerateCommentCmd({
161
167
  skippedFiles,
162
168
  };
163
169
  } catch (error) {
164
- console.error(`${lc} ${extractErrorMsg(error)} (E: 0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a)`);
170
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
165
171
  throw error;
166
172
  } finally {
167
173
  if (logalot) {
168
- console.log(`${lc} complete. (I: 1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b)`);
174
+ console.log(`${lc} complete. (I: genuuid)`);
169
175
  }
170
176
  }
171
177
  }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module init-cmd
3
+ *
4
+ * CLI command handler for `vcs init [targetDir]`.
5
+ * Bootstraps Node environment, creates disk directories, and delegates to executeVcsInit.
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 { VcsRepository } from '@ibgib/core-gib/dist/vcs/vcs-repository.mjs';
13
+ import { B2TFS_BRANCH_DEFAULT_NAME } from '@ibgib/core-gib/dist/vcs/branch/branch-constants.mjs';
14
+
15
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
16
+ import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
17
+ import { writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
18
+
19
+ const lcFile = `[init-cmd]`;
20
+ const logalot = GLOBAL_LOG_A_LOT;
21
+
22
+ export interface InitCmdOpts {
23
+ targetDir?: string;
24
+ vcsFolderName?: string;
25
+ defaultBranchName?: string;
26
+ quiet?: boolean;
27
+ }
28
+
29
+ export interface InitCmdResult {
30
+ vcsPath: string;
31
+ spaceId: string;
32
+ branchName: string;
33
+ rootItemIb: string;
34
+ }
35
+
36
+ export async function executeInitCmd({
37
+ targetDir = process.cwd(),
38
+ vcsFolderName = '.vcsgib',
39
+ defaultBranchName = B2TFS_BRANCH_DEFAULT_NAME,
40
+ quiet = false,
41
+ }: InitCmdOpts = {}): Promise<InitCmdResult> {
42
+ const absTargetDir = path.resolve(targetDir);
43
+ const vcsPath = path.join(absTargetDir, vcsFolderName);
44
+
45
+ // 1. Ensure target directory exists
46
+ await fs.mkdir(absTargetDir, { recursive: true });
47
+
48
+ // 2. Bootstrap Metaspace and localSpace (creates .vcsgib on disk)
49
+ const { metaspace, localSpace } = await bootstrapVcsMetaspace({
50
+ repoPath: absTargetDir,
51
+ vcsFolderName,
52
+ defaultSpaceName: `vcs_${path.basename(absTargetDir).replace(/[^a-zA-Z0-9_\-]/g, '_')}`,
53
+ });
54
+
55
+ // 3. Facade instantiation and domain init
56
+ const repo = new VcsRepository({
57
+ metaspace,
58
+ localSpace,
59
+ repoRoot: absTargetDir,
60
+ vcsFolderName,
61
+ });
62
+
63
+ const initRes = await repo.init({
64
+ rootFolderName: path.basename(absTargetDir) || 'root',
65
+ branchName: defaultBranchName,
66
+ });
67
+
68
+ if (!quiet) {
69
+ console.log(`Initialized empty ibgib repository in ${vcsPath} (branch: ${defaultBranchName})`);
70
+ }
71
+
72
+ return {
73
+ vcsPath,
74
+ spaceId: initRes.spaceId,
75
+ branchName: initRes.branchName,
76
+ rootItemIb: initRes.rootItem.ib,
77
+ };
78
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @module log-cmd
3
+ *
4
+ * CLI command handler for `vcs log`.
5
+ * Delegates to executeVcsLog and formats console output.
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 { getSpaceIdFromIb } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mjs';
13
+
14
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
16
+
17
+ const lcFile = `[log-cmd]`;
18
+ const logalot = GLOBAL_LOG_A_LOT;
19
+
20
+ export interface VcsLogItem {
21
+ branchAddr?: string;
22
+ commitAddr: string;
23
+ commentAddr?: string;
24
+ message: string;
25
+ timestamp: string;
26
+ author: string;
27
+ rootItemAddr?: string;
28
+ committedPaths?: string[];
29
+ itemComments?: Array<{ path: string; name?: string; message: string }>;
30
+ }
31
+
32
+ export interface LogCmdOpts {
33
+ targetDir?: string;
34
+ vcsFolderName?: string;
35
+ filePath?: string;
36
+ allComments?: boolean;
37
+ quiet?: boolean;
38
+ }
39
+
40
+ export interface LogCmdResult {
41
+ branchName: string;
42
+ targetPath?: string;
43
+ commits: VcsLogItem[];
44
+ }
45
+
46
+ export async function executeLogCmd({
47
+ targetDir = process.cwd(),
48
+ vcsFolderName = '.vcsgib',
49
+ filePath,
50
+ allComments = false,
51
+ quiet = false,
52
+ }: LogCmdOpts = {}): Promise<LogCmdResult> {
53
+ const lc = `${lcFile}[${executeLogCmd.name}]`;
54
+
55
+ try {
56
+ if (logalot) {
57
+ console.log(`${lc} starting executeLogCmd (I: genuuid)`);
58
+ }
59
+
60
+ const absTargetDir = path.resolve(targetDir);
61
+ const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
62
+ const indexIbGib = await repo.getIndexIbGib();
63
+ const activeBranchSpace = await repo.getActiveBranchSpace(indexIbGib);
64
+
65
+ const logRes = await repo.log({
66
+ activeBranchSpace,
67
+ indexIbGib,
68
+ // repoRoot, // need this? we need jsdocs on wth repoRoot is
69
+ filePath,
70
+ allComments,
71
+ targetDir: absTargetDir,
72
+ });
73
+
74
+ const commits: VcsLogItem[] = logRes.commits;
75
+
76
+ if (!quiet) {
77
+ if (logRes.targetPath) {
78
+ console.log(`File: ${logRes.targetPath} (branch: ${logRes.branchName}) (I: genuuid)`);
79
+ if (commits.length === 0) {
80
+ console.log('No comments found for this file.');
81
+ } else {
82
+ for (const commit of commits) {
83
+ console.log(`\nitem ${commit.commitAddr}`);
84
+ if (commit.timestamp) { console.log(`Date: ${commit.timestamp}`); }
85
+ console.log(`\n ${commit.message}\n`);
86
+ }
87
+ }
88
+ } else {
89
+ console.log(`Branch: ${logRes.branchName} (I: genuuid)`);
90
+ if (commits.length === 0) {
91
+ console.log('No commits yet.');
92
+ } else {
93
+ for (const commit of commits) {
94
+ console.log(`\ncommit ${commit.commitAddr}`);
95
+ console.log(`Author: ${commit.author}`);
96
+ console.log(`Date: ${commit.timestamp}`);
97
+ console.log(`\n ${commit.message}\n`);
98
+ if (commit.committedPaths && commit.committedPaths.length > 0) {
99
+ console.log(`Changed: ${commit.committedPaths.join(', ')}`);
100
+ }
101
+ if (commit.itemComments && commit.itemComments.length > 0) {
102
+ console.log('Item Comments:');
103
+ for (const ic of commit.itemComments) {
104
+ const label = ic.name ? `${ic.path} (${ic.name})` : ic.path;
105
+ console.log(` * [${label}]: ${ic.message}`);
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ return {
114
+ branchName: logRes.branchName,
115
+ targetPath: logRes.targetPath,
116
+ commits,
117
+ };
118
+ } catch (error) {
119
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
120
+ throw error;
121
+ } finally {
122
+ if (logalot) {
123
+ console.log(`${lc} complete. (I: genuuid)`);
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @module merge-cmd
3
+ *
4
+ * CLI command handler for `vcs merge <branchName>`.
5
+ * Merges incoming branch into base branch and delegates to executeVcsMerge.
6
+ */
7
+
8
+ import path from 'node:path';
9
+
10
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
11
+ import { getOrCreateBranchSpace } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
12
+ import { getSpaceIdFromIb } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mjs';
13
+
14
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
16
+
17
+ const lcFile = `[merge-cmd]`;
18
+ const logalot = GLOBAL_LOG_A_LOT;
19
+
20
+ export interface MergeCmdOpts {
21
+ incomingBranchName?: string;
22
+ targetDir?: string;
23
+ vcsFolderName?: string;
24
+ quiet?: boolean;
25
+ }
26
+
27
+ export interface MergeCmdResult {
28
+ baseBranch: string;
29
+ incomingBranch: string;
30
+ baseSpaceId: string;
31
+ incomingSpaceId: string;
32
+ mergedBranchAddr?: string;
33
+ worktreePath: string;
34
+ }
35
+
36
+ export async function executeMergeCmd({
37
+ incomingBranchName,
38
+ targetDir = process.cwd(),
39
+ vcsFolderName = '.vcsgib',
40
+ quiet = false,
41
+ }: MergeCmdOpts = {}): Promise<MergeCmdResult> {
42
+ const lc = `${lcFile}[${executeMergeCmd.name}]`;
43
+ try {
44
+ if (logalot) {
45
+ console.log(`${lc} starting... (I: genuuid)`);
46
+ }
47
+
48
+ const trimmedIncomingBranchName = incomingBranchName?.trim();
49
+ if (!trimmedIncomingBranchName) {
50
+ throw new Error(`Branch name is required for merge (E: genuuid)`);
51
+ }
52
+
53
+ const absTargetDir = path.resolve(targetDir);
54
+ const { repo, vcsPath, activeWorktreeDir } =
55
+ await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
56
+
57
+ // todo: get baseBranchName based off of targetDir?
58
+ const baseBranchName = await repo.getActiveBranchName();
59
+
60
+ const incomingSpaceRes = await getOrCreateBranchSpace({
61
+ metaspace: repo.metaspace,
62
+ branchName: trimmedIncomingBranchName,
63
+ });
64
+
65
+ const activeBranchSpace = await repo.getActiveBranchSpace();
66
+ const activeBranchSpaceId = getSpaceIdFromIb(activeBranchSpace.ib);
67
+
68
+ const mergeRes = await repo.merge({
69
+ baseBranchSpace: activeBranchSpace, // what should this be? always the active one? Or does the working dir determine it? What is absTargetDir?
70
+ // message,
71
+ // repoRoot,
72
+ incomingBranchName: trimmedIncomingBranchName,
73
+ incomingBranchSpace: incomingSpaceRes.space,
74
+ targetDir: absTargetDir,
75
+ });
76
+
77
+ if (!quiet) {
78
+ console.log(`Successfully merged branch '${trimmedIncomingBranchName}' into '${baseBranchName}' (I: genuuid)`);
79
+ console.log(` Worktree projection: ${activeWorktreeDir}`);
80
+ }
81
+
82
+
83
+ return {
84
+ baseBranch: mergeRes.baseBranch,
85
+ incomingBranch: mergeRes.incomingBranch,
86
+ baseSpaceId: activeBranchSpaceId,
87
+ incomingSpaceId: incomingSpaceRes.spaceId,
88
+ mergedBranchAddr: mergeRes.mergeCommitAddr,
89
+ worktreePath: activeWorktreeDir,
90
+ };
91
+ } catch (error) {
92
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
93
+ throw error;
94
+ } finally {
95
+ if (logalot) {
96
+ console.log(`${lc} complete. (I: genuuid)`);
97
+ }
98
+ }
99
+ }