@ibgib/vcs-gib 0.0.32 → 0.0.34

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 (133) hide show
  1. package/README.md +14 -7
  2. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  3. package/dist/AUTO-GENERATED-version.mjs +1 -1
  4. package/dist/bootstrap/node-bootstrap.d.mts.map +1 -1
  5. package/dist/bootstrap/node-bootstrap.mjs +6 -20
  6. package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
  7. package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +1 -1
  8. package/dist/cli/commands/cli-add-cmd.d.mts.map +1 -0
  9. package/dist/cli/commands/cli-add-cmd.mjs +45 -0
  10. package/dist/cli/commands/cli-add-cmd.mjs.map +1 -0
  11. package/dist/cli/commands/{branch-cmd.d.mts → cli-branch-cmd.d.mts} +1 -1
  12. package/dist/cli/commands/cli-branch-cmd.d.mts.map +1 -0
  13. package/dist/cli/commands/cli-branch-cmd.mjs +59 -0
  14. package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -0
  15. package/dist/cli/commands/{checkout-cmd.d.mts → cli-checkout-cmd.d.mts} +4 -3
  16. package/dist/cli/commands/cli-checkout-cmd.d.mts.map +1 -0
  17. package/dist/cli/commands/cli-checkout-cmd.mjs +50 -0
  18. package/dist/cli/commands/cli-checkout-cmd.mjs.map +1 -0
  19. package/dist/cli/commands/{commit-cmd.d.mts → cli-commit-cmd.d.mts} +1 -1
  20. package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -0
  21. package/dist/cli/commands/cli-commit-cmd.mjs +52 -0
  22. package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -0
  23. package/dist/cli/commands/{generate-comment-cmd.d.mts → cli-generate-comment-cmd.d.mts} +1 -1
  24. package/dist/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -0
  25. package/dist/cli/commands/{generate-comment-cmd.mjs → cli-generate-comment-cmd.mjs} +8 -6
  26. package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -0
  27. package/dist/cli/commands/{init-cmd.d.mts → cli-init-cmd.d.mts} +1 -1
  28. package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -0
  29. package/dist/cli/commands/cli-init-cmd.mjs +47 -0
  30. package/dist/cli/commands/cli-init-cmd.mjs.map +1 -0
  31. package/dist/cli/commands/{log-cmd.d.mts → cli-log-cmd.d.mts} +1 -1
  32. package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
  33. package/dist/cli/commands/{log-cmd.mjs → cli-log-cmd.mjs} +14 -44
  34. package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
  35. package/dist/cli/commands/{merge-cmd.d.mts → cli-merge-cmd.d.mts} +1 -1
  36. package/dist/cli/commands/cli-merge-cmd.d.mts.map +1 -0
  37. package/dist/cli/commands/cli-merge-cmd.mjs +66 -0
  38. package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -0
  39. package/dist/cli/commands/{reset-cmd.d.mts → cli-reset-cmd.d.mts} +1 -1
  40. package/dist/cli/commands/cli-reset-cmd.d.mts.map +1 -0
  41. package/dist/cli/commands/cli-reset-cmd.mjs +63 -0
  42. package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -0
  43. package/dist/cli/commands/{restore-cmd.d.mts → cli-restore-cmd.d.mts} +1 -1
  44. package/dist/cli/commands/cli-restore-cmd.d.mts.map +1 -0
  45. package/dist/cli/commands/cli-restore-cmd.mjs +55 -0
  46. package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -0
  47. package/dist/cli/commands/{status-cmd.d.mts → cli-status-cmd.d.mts} +1 -1
  48. package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
  49. package/dist/cli/commands/{status-cmd.mjs → cli-status-cmd.mjs} +4 -41
  50. package/dist/cli/commands/cli-status-cmd.mjs.map +1 -0
  51. package/dist/cli/vcs-cli-main.d.mts.map +1 -1
  52. package/dist/cli/vcs-cli-main.mjs +18 -15
  53. package/dist/cli/vcs-cli-main.mjs.map +1 -1
  54. package/dist/cli/vcs-projection-helper.mjs +7 -7
  55. package/dist/cli/vcs-projection-helper.mjs.map +1 -1
  56. package/dist/cli/vcs-repo-helper.d.mts +19 -0
  57. package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
  58. package/dist/cli/vcs-repo-helper.mjs +84 -0
  59. package/dist/cli/vcs-repo-helper.mjs.map +1 -0
  60. package/dist/test/test-helpers.d.mts +9 -0
  61. package/dist/test/test-helpers.d.mts.map +1 -1
  62. package/dist/test/test-helpers.mjs +35 -0
  63. package/dist/test/test-helpers.mjs.map +1 -1
  64. package/package.json +6 -6
  65. package/src/AUTO-GENERATED-version.mts +1 -1
  66. package/src/bootstrap/node-bootstrap.mts +6 -20
  67. package/src/bootstrap/node-bootstrap.respec.mts +2 -2
  68. package/src/cli/cli-arg-parser.respec.mts +2 -2
  69. package/src/cli/cli-e2e.respec.mts +15 -14
  70. package/src/cli/commands/branch-checkout-cmd.respec.mts +28 -14
  71. package/src/cli/commands/cli-add-cmd.mts +65 -0
  72. package/src/cli/commands/cli-branch-cmd.mts +87 -0
  73. package/src/cli/commands/cli-checkout-cmd.mts +72 -0
  74. package/src/cli/commands/cli-commit-cmd.mts +77 -0
  75. package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +8 -6
  76. package/src/cli/commands/cli-init-cmd.mts +78 -0
  77. package/src/cli/commands/{log-cmd.mts → cli-log-cmd.mts} +14 -47
  78. package/src/cli/commands/cli-merge-cmd.mts +99 -0
  79. package/src/cli/commands/cli-reset-cmd.mts +94 -0
  80. package/src/cli/commands/cli-restore-cmd.mts +87 -0
  81. package/src/cli/commands/{status-cmd.mts → cli-status-cmd.mts} +3 -45
  82. package/src/cli/commands/commit-log-cmd.respec.mts +84 -34
  83. package/src/cli/commands/init-cmd.respec.mts +3 -3
  84. package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
  85. package/src/cli/commands/status-add-cmd.respec.mts +13 -9
  86. package/src/cli/vcs-cli-main.mts +18 -15
  87. package/src/cli/vcs-projection-helper.mts +8 -8
  88. package/src/cli/vcs-repo-helper.mts +113 -0
  89. package/src/engine/branch/branch-space.respec.mts +22 -20
  90. package/src/engine/merge/b2tfs-sync-comments.respec.mts +10 -10
  91. package/src/test/test-helpers.mts +49 -1
  92. package/src/vcs-gib.respec.mts +21 -15
  93. package/tsconfig.test.tsbuildinfo +1 -1
  94. package/tsconfig.tsbuildinfo +1 -1
  95. package/vcs-gib_test_output.md +77 -0
  96. package/dist/cli/commands/add-cmd.d.mts.map +0 -1
  97. package/dist/cli/commands/add-cmd.mjs +0 -93
  98. package/dist/cli/commands/add-cmd.mjs.map +0 -1
  99. package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
  100. package/dist/cli/commands/branch-cmd.mjs +0 -107
  101. package/dist/cli/commands/branch-cmd.mjs.map +0 -1
  102. package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
  103. package/dist/cli/commands/checkout-cmd.mjs +0 -95
  104. package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
  105. package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
  106. package/dist/cli/commands/commit-cmd.mjs +0 -99
  107. package/dist/cli/commands/commit-cmd.mjs.map +0 -1
  108. package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
  109. package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
  110. package/dist/cli/commands/init-cmd.d.mts.map +0 -1
  111. package/dist/cli/commands/init-cmd.mjs +0 -69
  112. package/dist/cli/commands/init-cmd.mjs.map +0 -1
  113. package/dist/cli/commands/log-cmd.d.mts.map +0 -1
  114. package/dist/cli/commands/log-cmd.mjs.map +0 -1
  115. package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
  116. package/dist/cli/commands/merge-cmd.mjs +0 -106
  117. package/dist/cli/commands/merge-cmd.mjs.map +0 -1
  118. package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
  119. package/dist/cli/commands/reset-cmd.mjs +0 -91
  120. package/dist/cli/commands/reset-cmd.mjs.map +0 -1
  121. package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
  122. package/dist/cli/commands/restore-cmd.mjs +0 -97
  123. package/dist/cli/commands/restore-cmd.mjs.map +0 -1
  124. package/dist/cli/commands/status-cmd.d.mts.map +0 -1
  125. package/dist/cli/commands/status-cmd.mjs.map +0 -1
  126. package/src/cli/commands/add-cmd.mts +0 -120
  127. package/src/cli/commands/branch-cmd.mts +0 -142
  128. package/src/cli/commands/checkout-cmd.mts +0 -123
  129. package/src/cli/commands/commit-cmd.mts +0 -130
  130. package/src/cli/commands/init-cmd.mts +0 -99
  131. package/src/cli/commands/merge-cmd.mts +0 -143
  132. package/src/cli/commands/reset-cmd.mts +0 -126
  133. package/src/cli/commands/restore-cmd.mts +0 -135
@@ -1,142 +0,0 @@
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
- import fs from 'node:fs/promises';
10
-
11
- import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
- import { executeVcsBranch } from '@ibgib/core-gib/dist/vcs/commands/branch-cmd.mjs';
13
- import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
14
-
15
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
16
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
17
- import { readVcsIndexProjectionFromDisk, writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
18
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
19
-
20
- const lcFile = `[branch-cmd]`;
21
- const logalot = GLOBAL_LOG_A_LOT;
22
-
23
- export interface BranchInfo {
24
- name: string;
25
- isActive: boolean;
26
- addr: string;
27
- rootItemAddr?: string;
28
- }
29
-
30
- export interface BranchCmdOpts {
31
- branchName?: string;
32
- itemPath?: string;
33
- targetDir?: string;
34
- vcsFolderName?: string;
35
- quiet?: boolean;
36
- }
37
-
38
- export interface BranchCmdResult {
39
- branches: BranchInfo[];
40
- createdBranchName?: string;
41
- createdBranchAddr?: string;
42
- }
43
-
44
- export async function executeBranchCmd({
45
- branchName,
46
- itemPath,
47
- targetDir = process.cwd(),
48
- vcsFolderName = '.vcsgib',
49
- quiet = false,
50
- }: BranchCmdOpts = {}): Promise<BranchCmdResult> {
51
- const lc = `${lcFile}[${executeBranchCmd.name}]`;
52
- try {
53
- if (logalot) { console.log(`${lc} starting... (I: 4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f)`); }
54
-
55
- const absTargetDir = path.resolve(targetDir);
56
-
57
- const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
58
- repoPath: absTargetDir,
59
- vcsFolderName,
60
- });
61
-
62
- // Verify repo exists
63
- try {
64
- await fs.access(vcsPath);
65
- } catch {
66
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a)`);
67
- }
68
-
69
- // 1. Fetch authoritative repository index from localSpace
70
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
71
- if (!indexIbGib) {
72
- throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b)`);
73
- }
74
-
75
- const activeBranchName = resolveContextualBranchName({
76
- targetDir: absTargetDir,
77
- repoRoot,
78
- indexIbGib,
79
- });
80
-
81
- // Resolve active branch space b2s_<activeBranch>
82
- const { space: activeBranchSpace } = await getOrCreateBranchSpace({
83
- metaspace,
84
- vcsPath,
85
- branchName: activeBranchName,
86
- });
87
-
88
- // If creating a branch, ensure target branch space exists on Node
89
- if (branchName && branchName.trim().length > 0) {
90
- await getOrCreateBranchSpace({
91
- metaspace,
92
- vcsPath,
93
- branchName: branchName.trim(),
94
- });
95
- }
96
-
97
- const branchRes = await executeVcsBranch({
98
- metaspace,
99
- localSpace,
100
- activeBranchSpace,
101
- indexIbGib,
102
- branchName,
103
- itemPath,
104
- repoRoot,
105
- targetDir: absTargetDir,
106
- vcsFolderName,
107
- });
108
-
109
- if (branchRes.updatedIndex) {
110
- await writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib: branchRes.updatedIndex });
111
- }
112
-
113
- const branches: BranchInfo[] = branchRes.branches.map(b => ({
114
- name: b.name,
115
- isActive: b.isActive,
116
- addr: b.commitAddr || '',
117
- rootItemAddr: b.rootItemAddr,
118
- }));
119
-
120
- if (!quiet) {
121
- if (!branchName) {
122
- for (const b of branches) {
123
- const prefix = b.isActive ? '* ' : ' ';
124
- console.log(`${prefix}${b.name}`);
125
- }
126
- } else {
127
- console.log(`Created branch '${branchRes.createdBranchName}'`);
128
- }
129
- }
130
-
131
- return {
132
- branches,
133
- createdBranchName: branchRes.createdBranchName,
134
- createdBranchAddr: branchRes.createdBranchAddr,
135
- };
136
- } catch (error) {
137
- console.error(`${lc} ${extractErrorMsg(error)} (E: 1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a)`);
138
- throw error;
139
- } finally {
140
- if (logalot) { console.log(`${lc} complete. (I: 2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b)`); }
141
- }
142
- }
@@ -1,123 +0,0 @@
1
- /**
2
- * @module checkout-cmd
3
- *
4
- * CLI command handler for `vcs checkout <branchName>`.
5
- * Bootstraps workspace projection space, delegates to executeVcsCheckout, and writes projection cache.
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 { executeVcsCheckout } from '@ibgib/core-gib/dist/vcs/commands/checkout-cmd.mjs';
13
-
14
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
15
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
16
- import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
17
- import { readVcsIndexProjectionFromDisk, writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
18
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
19
-
20
- const lcFile = `[checkout-cmd]`;
21
- const logalot = GLOBAL_LOG_A_LOT;
22
-
23
- export interface CheckoutCmdOpts {
24
- branchName?: string;
25
- targetDir?: string;
26
- vcsFolderName?: string;
27
- quiet?: boolean;
28
- }
29
-
30
- export interface CheckoutCmdResult {
31
- previousBranch: string;
32
- currentBranch: string;
33
- worktreePath: string;
34
- }
35
-
36
- export async function executeCheckoutCmd({
37
- branchName,
38
- targetDir = process.cwd(),
39
- vcsFolderName = '.vcsgib',
40
- quiet = false,
41
- }: CheckoutCmdOpts = {}): Promise<CheckoutCmdResult> {
42
- const lc = `${lcFile}[${executeCheckoutCmd.name}]`;
43
- try {
44
- if (logalot) { console.log(`${lc} starting... (I: 3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e)`); }
45
-
46
- const trimmedBranchName = branchName?.trim();
47
- if (!trimmedBranchName) {
48
- throw new Error(`Branch name is required for checkout (E: 4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d)`);
49
- }
50
-
51
- const absTargetDir = path.resolve(targetDir);
52
-
53
- const { metaspace, localSpace, repoRoot, vcsPath } = await bootstrapVcsMetaspace({
54
- repoPath: absTargetDir,
55
- vcsFolderName,
56
- });
57
-
58
- // Verify repo exists
59
- try {
60
- await fs.access(vcsPath);
61
- } catch {
62
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0e)`);
63
- }
64
-
65
- // 1. Fetch authoritative repository index from localSpace
66
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
67
- if (!indexIbGib) {
68
- throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f)`);
69
- }
70
-
71
- // 2. Resolve target branch space b2s_<branchName>
72
- const targetBranchSpaceRes = await getOrCreateBranchSpace({
73
- metaspace,
74
- vcsPath,
75
- branchName: trimmedBranchName,
76
- });
77
- const targetBranchSpace = targetBranchSpaceRes.space;
78
-
79
- const isDefaultBranch = trimmedBranchName === 'main';
80
- const worktreePath = isDefaultBranch
81
- ? repoRoot
82
- : path.join(repoRoot, 'b', trimmedBranchName);
83
-
84
- await fs.mkdir(worktreePath, { recursive: true });
85
-
86
- const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
87
- metaspace,
88
- workspaceRoot: worktreePath,
89
- vcsFolderName,
90
- backingSpace: targetBranchSpace,
91
- });
92
-
93
- const checkoutRes = await executeVcsCheckout({
94
- metaspace,
95
- localSpace,
96
- targetBranchSpace,
97
- workspaceSpace,
98
- indexIbGib,
99
- branchName: trimmedBranchName,
100
- repoRoot,
101
- targetDir: absTargetDir,
102
- vcsFolderName,
103
- });
104
-
105
- await writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib: checkoutRes.updatedIndex });
106
-
107
- if (!quiet) {
108
- console.log(`Switched to branch '${trimmedBranchName}' (I: 0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d)`);
109
- console.log(`Worktree path: ${worktreePath}`);
110
- }
111
-
112
- return {
113
- previousBranch: checkoutRes.previousBranch,
114
- currentBranch: checkoutRes.currentBranch,
115
- worktreePath,
116
- };
117
- } catch (error) {
118
- console.error(`${lc} ${extractErrorMsg(error)} (E: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`);
119
- throw error;
120
- } finally {
121
- if (logalot) { console.log(`${lc} complete. (I: 2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e)`); }
122
- }
123
- }
@@ -1,130 +0,0 @@
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
- import fs from 'node:fs/promises';
10
-
11
- import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
- import { executeVcsCommit } from '@ibgib/core-gib/dist/vcs/commands/commit-cmd.mjs';
13
- import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
14
-
15
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
16
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
17
- import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
18
- import { readVcsIndexProjectionFromDisk, writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
19
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
20
-
21
- const lcFile = `[commit-cmd]`;
22
- const logalot = GLOBAL_LOG_A_LOT;
23
-
24
- export interface CommitCmdOpts {
25
- message?: string;
26
- targetDir?: string;
27
- vcsFolderName?: string;
28
- author?: string;
29
- quiet?: boolean;
30
- }
31
-
32
- export interface CommitCmdResult {
33
- branchName: string;
34
- commitAddr: string;
35
- commentAddr?: string;
36
- rootItemAddr: string;
37
- committedPaths: string[];
38
- ingestedCommentsCount: number;
39
- }
40
-
41
- export async function executeCommitCmd({
42
- message,
43
- targetDir = process.cwd(),
44
- vcsFolderName = '.vcsgib',
45
- author = 'vcs-user',
46
- quiet = false,
47
- }: CommitCmdOpts = {}): Promise<CommitCmdResult> {
48
- const lc = `${lcFile}[${executeCommitCmd.name}]`;
49
- try {
50
- if (logalot) { console.log(`${lc} starting... (I: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`); }
51
-
52
- const absTargetDir = path.resolve(targetDir);
53
-
54
- const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
55
- repoPath: absTargetDir,
56
- vcsFolderName,
57
- });
58
-
59
- // Verify repo exists
60
- try {
61
- await fs.access(vcsPath);
62
- } catch {
63
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d)`);
64
- }
65
-
66
- // Fetch authoritative B2tFSIndexIbGib_V1 from space
67
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
68
- if (!indexIbGib) {
69
- throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d)`);
70
- }
71
-
72
- const branchName = resolveContextualBranchName({
73
- targetDir: absTargetDir,
74
- repoRoot,
75
- indexIbGib,
76
- });
77
- const activeWorktreeDir = branchName === 'main' ? repoRoot : path.join(repoRoot, 'b', branchName);
78
-
79
- // Resolve active branch space b2s_<branchName>
80
- const { space: activeSpace } = await getOrCreateBranchSpace({
81
- metaspace,
82
- vcsPath,
83
- branchName,
84
- });
85
-
86
- const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
87
- metaspace,
88
- workspaceRoot: activeWorktreeDir,
89
- vcsFolderName,
90
- backingSpace: activeSpace,
91
- });
92
-
93
- const commitRes = await executeVcsCommit({
94
- metaspace,
95
- localSpace,
96
- activeBranchSpace: activeSpace,
97
- workspaceSpace,
98
- indexIbGib,
99
- message,
100
- author,
101
- repoRoot,
102
- targetDir: absTargetDir,
103
- vcsFolderName,
104
- });
105
-
106
- await writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib: commitRes.updatedIndex });
107
-
108
- if (!quiet) {
109
- console.log(`[${branchName} ${commitRes.commitAddr.slice(0, 7)}] ${message || '(companion comments committed)'}`);
110
- console.log(` ${commitRes.committedPaths.length} file(s) changed`);
111
- if (commitRes.ingestedCommentsCount > 0) {
112
- console.log(` ${commitRes.ingestedCommentsCount} companion comment(s) attached and merged`);
113
- }
114
- }
115
-
116
- return {
117
- branchName: commitRes.branchName,
118
- commitAddr: commitRes.commitAddr,
119
- commentAddr: commitRes.commentAddr,
120
- rootItemAddr: commitRes.rootItemAddr,
121
- committedPaths: commitRes.committedPaths,
122
- ingestedCommentsCount: commitRes.ingestedCommentsCount,
123
- };
124
- } catch (error) {
125
- console.error(`${lc} ${extractErrorMsg(error)} (E: 6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c)`);
126
- throw error;
127
- } finally {
128
- if (logalot) { console.log(`${lc} complete. (I: 7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d)`); }
129
- }
130
- }
@@ -1,99 +0,0 @@
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 { executeVcsInit } from '@ibgib/core-gib/dist/vcs/commands/init-cmd.mjs';
13
-
14
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
15
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
16
- import { writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
17
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.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 = 'main',
40
- quiet = false,
41
- }: InitCmdOpts = {}): Promise<InitCmdResult> {
42
- const lc = `${lcFile}[${executeInitCmd.name}]`;
43
- try {
44
- if (logalot) {
45
- console.log(`${lc} starting... (I: 8a9b10c11d12e13f14a15b16c17d18e1)`);
46
- }
47
-
48
- const absTargetDir = path.resolve(targetDir);
49
- const vcsPath = path.join(absTargetDir, vcsFolderName);
50
-
51
- // Create target repository folder if it doesn't exist
52
- await fs.mkdir(absTargetDir, { recursive: true });
53
-
54
- // Bootstrap Metaspace
55
- const { metaspace, localSpace } = await bootstrapVcsMetaspace({
56
- repoPath: absTargetDir,
57
- vcsFolderName,
58
- defaultSpaceName: `vcs_${path.basename(absTargetDir).replace(/[^a-zA-Z0-9_\-]/g, '_')}`,
59
- });
60
-
61
- // Initialize b2s_main branch space
62
- const { space: branchSpace, spaceId } = await getOrCreateBranchSpace({
63
- metaspace,
64
- vcsPath,
65
- branchName: defaultBranchName,
66
- });
67
-
68
- const folderName = path.basename(absTargetDir) || 'root';
69
-
70
- const initRes = await executeVcsInit({
71
- metaspace,
72
- branchSpace,
73
- localSpace,
74
- rootFolderName: folderName,
75
- defaultBranchName,
76
- vcsFolderName,
77
- });
78
-
79
- await writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib: initRes.indexIbGib });
80
-
81
- if (!quiet) {
82
- console.log(`Initialized empty ibgib repository in ${vcsPath} (branch: ${defaultBranchName}) (I: 3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f)`);
83
- }
84
-
85
- return {
86
- vcsPath,
87
- spaceId: initRes.spaceId,
88
- branchName: initRes.branchName,
89
- rootItemIb: initRes.rootItem.ib,
90
- };
91
- } catch (error) {
92
- console.error(`${lc} ${extractErrorMsg(error)} (E: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`);
93
- throw error;
94
- } finally {
95
- if (logalot) {
96
- console.log(`${lc} complete. (I: 2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e)`);
97
- }
98
- }
99
- }
@@ -1,143 +0,0 @@
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
- import fs from 'node:fs/promises';
10
-
11
- import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
- import { executeVcsMerge } from '@ibgib/core-gib/dist/vcs/commands/merge-cmd.mjs';
13
-
14
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
15
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
16
- import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
17
- import { readVcsIndexProjectionFromDisk, writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
18
- import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
19
-
20
- const lcFile = `[merge-cmd]`;
21
- const logalot = GLOBAL_LOG_A_LOT;
22
-
23
- export interface MergeCmdOpts {
24
- incomingBranchName?: string;
25
- targetDir?: string;
26
- vcsFolderName?: string;
27
- quiet?: boolean;
28
- }
29
-
30
- export interface MergeCmdResult {
31
- baseBranch: string;
32
- incomingBranch: string;
33
- baseSpaceId: string;
34
- incomingSpaceId: string;
35
- mergedBranchAddr?: string;
36
- worktreePath: string;
37
- }
38
-
39
- export async function executeMergeCmd({
40
- incomingBranchName,
41
- targetDir = process.cwd(),
42
- vcsFolderName = '.vcsgib',
43
- quiet = false,
44
- }: MergeCmdOpts = {}): Promise<MergeCmdResult> {
45
- const lc = `${lcFile}[${executeMergeCmd.name}]`;
46
- try {
47
- if (logalot) {
48
- console.log(`${lc} starting... (I: 4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f)`);
49
- }
50
-
51
- const trimmedIncomingBranch = incomingBranchName?.trim();
52
- if (!trimmedIncomingBranch) {
53
- throw new Error(`Branch name is required for merge (E: 5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a)`);
54
- }
55
-
56
- const absTargetDir = path.resolve(targetDir);
57
-
58
- const { metaspace, localSpace, repoRoot, vcsPath } = await bootstrapVcsMetaspace({
59
- repoPath: absTargetDir,
60
- vcsFolderName,
61
- });
62
-
63
- // Verify repo exists
64
- try {
65
- await fs.access(vcsPath);
66
- } catch {
67
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b)`);
68
- }
69
-
70
- // 1. Fetch authoritative repository index from localSpace
71
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
72
- if (!indexIbGib) {
73
- throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c)`);
74
- }
75
-
76
- const baseBranchName = indexIbGib.data?.activeBranch || 'main';
77
-
78
- // 2. Resolve base branch space & incoming branch space
79
- const baseSpaceRes = await getOrCreateBranchSpace({
80
- metaspace,
81
- vcsPath,
82
- branchName: baseBranchName,
83
- });
84
- const baseSpace = baseSpaceRes.space;
85
-
86
- const incomingSpaceRes = await getOrCreateBranchSpace({
87
- metaspace,
88
- vcsPath,
89
- branchName: trimmedIncomingBranch,
90
- });
91
- const incomingSpace = incomingSpaceRes.space;
92
-
93
- const isDefaultBranch = baseBranchName === 'main';
94
- const worktreePath = isDefaultBranch
95
- ? repoRoot
96
- : path.join(repoRoot, 'b', baseBranchName);
97
-
98
- await fs.mkdir(worktreePath, { recursive: true });
99
-
100
- const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
101
- metaspace,
102
- workspaceRoot: worktreePath,
103
- vcsFolderName,
104
- backingSpace: baseSpace,
105
- });
106
-
107
- const mergeRes = await executeVcsMerge({
108
- metaspace,
109
- localSpace,
110
- baseBranchSpace: baseSpace,
111
- incomingBranchSpace: incomingSpace,
112
- workspaceSpace,
113
- indexIbGib,
114
- incomingBranchName: trimmedIncomingBranch,
115
- repoRoot,
116
- targetDir: absTargetDir,
117
- vcsFolderName,
118
- });
119
-
120
- await writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib: mergeRes.updatedIndex });
121
-
122
- if (!quiet) {
123
- console.log(`Successfully merged branch '${trimmedIncomingBranch}' into '${baseBranchName}' (I: 1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a)`);
124
- console.log(` Worktree projection: ${worktreePath}`);
125
- }
126
-
127
- return {
128
- baseBranch: mergeRes.baseBranch,
129
- incomingBranch: mergeRes.incomingBranch,
130
- baseSpaceId: baseSpaceRes.spaceId,
131
- incomingSpaceId: incomingSpaceRes.spaceId,
132
- mergedBranchAddr: mergeRes.mergeCommitAddr,
133
- worktreePath,
134
- };
135
- } catch (error) {
136
- console.error(`${lc} ${extractErrorMsg(error)} (E: 2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b)`);
137
- throw error;
138
- } finally {
139
- if (logalot) {
140
- console.log(`${lc} complete. (I: 3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c)`);
141
- }
142
- }
143
- }