@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
@@ -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
  */
@@ -12,6 +12,7 @@ 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
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';
15
16
  import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
16
17
 
17
18
  const lcFile = `[generate-comment-cmd]`;
@@ -41,7 +42,7 @@ export async function executeGenerateCommentCmd({
41
42
 
42
43
  try {
43
44
  if (logalot) {
44
- console.log(`${lc} starting... (I: 8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e)`);
45
+ console.log(`${lc} starting... (I: genuuid)`);
45
46
  }
46
47
 
47
48
  const absTargetDir = path.resolve(targetDir);
@@ -55,10 +56,11 @@ export async function executeGenerateCommentCmd({
55
56
  try {
56
57
  await fs.access(vcsPath);
57
58
  } catch {
58
- 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)`);
59
60
  }
60
61
 
61
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
62
+ const indexIbGib = (await getB2tFSIndexIbGib({ space: localSpace, metaspace }))
63
+ || (await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace }));
62
64
 
63
65
  const statusRes = await getRepoStatus({
64
66
  metaspace,
@@ -165,11 +167,11 @@ export async function executeGenerateCommentCmd({
165
167
  skippedFiles,
166
168
  };
167
169
  } catch (error) {
168
- console.error(`${lc} ${extractErrorMsg(error)} (E: 0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a)`);
170
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
169
171
  throw error;
170
172
  } finally {
171
173
  if (logalot) {
172
- console.log(`${lc} complete. (I: 1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b)`);
174
+ console.log(`${lc} complete. (I: genuuid)`);
173
175
  }
174
176
  }
175
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
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module log-cmd
3
- *
3
+ *
4
4
  * CLI command handler for `vcs log`.
5
5
  * Delegates to executeVcsLog and formats console output.
6
6
  */
@@ -9,13 +9,10 @@ import path from 'node:path';
9
9
  import fs from 'node:fs/promises';
10
10
 
11
11
  import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
- import { executeVcsLog } from '@ibgib/core-gib/dist/vcs/commands/log-cmd.mjs';
13
- import { resolveContextualBranchName } 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';
14
13
 
15
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
16
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
17
- import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
18
14
  import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
19
16
 
20
17
  const lcFile = `[log-cmd]`;
21
18
  const logalot = GLOBAL_LOG_A_LOT;
@@ -57,50 +54,20 @@ export async function executeLogCmd({
57
54
 
58
55
  try {
59
56
  if (logalot) {
60
- console.log(`${lc} starting executeLogCmd (I: 1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e)`);
57
+ console.log(`${lc} starting executeLogCmd (I: genuuid)`);
61
58
  }
62
59
 
63
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
64
 
65
- const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
66
- repoPath: absTargetDir,
67
- vcsFolderName,
68
- });
69
-
70
- // Verify repo exists
71
- try {
72
- await fs.access(vcsPath);
73
- } catch {
74
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f)`);
75
- }
76
-
77
- // 1. Fetch authoritative B2tFSIndexIbGib_V1 directly from localSpace
78
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
79
- if (!indexIbGib) {
80
- throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a)`);
81
- }
82
-
83
- const branchName = resolveContextualBranchName({
84
- targetDir: absTargetDir,
85
- repoRoot,
86
- indexIbGib,
87
- });
88
-
89
- // Target active branch space b2s_<activeBranch>
90
- const { space: activeSpace } = await getOrCreateBranchSpace({
91
- metaspace,
92
- vcsPath,
93
- branchName,
94
- });
95
-
96
- const logRes = await executeVcsLog({
97
- metaspace,
98
- localSpace,
99
- activeBranchSpace: activeSpace,
65
+ const logRes = await repo.log({
66
+ activeBranchSpace,
100
67
  indexIbGib,
68
+ // repoRoot, // need this? we need jsdocs on wth repoRoot is
101
69
  filePath,
102
70
  allComments,
103
- repoRoot,
104
71
  targetDir: absTargetDir,
105
72
  });
106
73
 
@@ -108,7 +75,7 @@ export async function executeLogCmd({
108
75
 
109
76
  if (!quiet) {
110
77
  if (logRes.targetPath) {
111
- console.log(`File: ${logRes.targetPath} (branch: ${logRes.branchName}) (I: 6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d)`);
78
+ console.log(`File: ${logRes.targetPath} (branch: ${logRes.branchName}) (I: genuuid)`);
112
79
  if (commits.length === 0) {
113
80
  console.log('No comments found for this file.');
114
81
  } else {
@@ -119,7 +86,7 @@ export async function executeLogCmd({
119
86
  }
120
87
  }
121
88
  } else {
122
- console.log(`Branch: ${logRes.branchName} (I: 4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b)`);
89
+ console.log(`Branch: ${logRes.branchName} (I: genuuid)`);
123
90
  if (commits.length === 0) {
124
91
  console.log('No commits yet.');
125
92
  } else {
@@ -149,11 +116,11 @@ export async function executeLogCmd({
149
116
  commits,
150
117
  };
151
118
  } catch (error) {
152
- console.error(`${lc} ${extractErrorMsg(error)} (E: 5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c)`);
119
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
153
120
  throw error;
154
121
  } finally {
155
122
  if (logalot) {
156
- console.log(`${lc} complete. (I: 6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d)`);
123
+ console.log(`${lc} complete. (I: genuuid)`);
157
124
  }
158
125
  }
159
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
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @module reset-cmd
3
+ *
4
+ * CLI command handler for `vcs reset [path...]`.
5
+ * Unstages specified files (or all files) from active branch index in localSpace.
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 { promptForConfirm } from '@ibgib/helper-gib/dist/helpers/node-helper.mjs';
13
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
14
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
+
16
+ const lcFile = `[reset-cmd]`;
17
+ const logalot = GLOBAL_LOG_A_LOT;
18
+
19
+ export interface ResetCmdOpts {
20
+ paths?: string[];
21
+ targetDir?: string;
22
+ vcsFolderName?: string;
23
+ all?: boolean;
24
+ yes?: boolean;
25
+ force?: boolean;
26
+ quiet?: boolean;
27
+ }
28
+
29
+ export interface ResetCmdResult {
30
+ unstagedPaths: string[];
31
+ stagedCount: number;
32
+ }
33
+
34
+ export async function executeResetCmd({
35
+ paths = [],
36
+ targetDir = process.cwd(),
37
+ vcsFolderName = '.vcsgib',
38
+ all = false,
39
+ yes = false,
40
+ force = false,
41
+ quiet = false,
42
+ }: ResetCmdOpts = {}): Promise<ResetCmdResult> {
43
+ const lc = `${lcFile}[${executeResetCmd.name}]`;
44
+ try {
45
+ if (logalot) {
46
+ console.log(`${lc} starting... (I: genuuid)`);
47
+ }
48
+
49
+ const absTargetDir = path.resolve(targetDir);
50
+ const { repo, activeWorktreeDir } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
51
+
52
+ const indexIbGib = await repo.getIndexIbGib();
53
+ const activeBranchSpace = await repo.getActiveBranchSpace(indexIbGib);
54
+
55
+ const skipPrompt = yes || force || quiet || !process.stdin.isTTY;
56
+ if (!skipPrompt) {
57
+ const confirmed = await promptForConfirm({ msg: 'Unstage specified files from index?' });
58
+ if (!confirmed) {
59
+ if (!quiet) {
60
+ console.log('Operation cancelled.');
61
+ }
62
+ const stagedCount = Object.keys(indexIbGib.data.stagedPaths || {}).length;
63
+ return { unstagedPaths: [], stagedCount };
64
+ }
65
+ }
66
+
67
+ const resetRes = await repo.reset({
68
+ activeBranchSpace,
69
+ indexIbGib,
70
+ paths,
71
+ all,
72
+ targetDir: absTargetDir,
73
+ activeWorktreeDir,
74
+ });
75
+
76
+ if (!quiet) {
77
+ for (const unstagedPath of resetRes.unstagedPaths) {
78
+ console.log(`unstaged: ${unstagedPath}`);
79
+ }
80
+ }
81
+
82
+ return {
83
+ unstagedPaths: resetRes.unstagedPaths,
84
+ stagedCount: resetRes.stagedCount,
85
+ };
86
+ } catch (error) {
87
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
88
+ throw error;
89
+ } finally {
90
+ if (logalot) {
91
+ console.log(`${lc} complete. (I: genuuid)`);
92
+ }
93
+ }
94
+ }