@slats/claude-assets-sync 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/README.md +111 -587
  2. package/bin/claude-sync.mjs +24 -0
  3. package/dist/claude-hashes.json +20 -0
  4. package/dist/commands/index.d.ts +1 -112
  5. package/dist/commands/runCli/index.d.ts +2 -0
  6. package/dist/commands/runCli/runCli.cjs +31 -0
  7. package/dist/commands/runCli/runCli.d.ts +10 -0
  8. package/dist/commands/runCli/runCli.mjs +29 -0
  9. package/dist/commands/runCli/type.d.ts +28 -0
  10. package/dist/commands/runCli/utils/injectOne.cjs +48 -0
  11. package/dist/commands/runCli/utils/injectOne.d.ts +3 -0
  12. package/dist/commands/runCli/utils/injectOne.mjs +46 -0
  13. package/dist/commands/runCli/utils/resolveScopeFlag.cjs +28 -0
  14. package/dist/commands/runCli/utils/resolveScopeFlag.d.ts +2 -0
  15. package/dist/commands/runCli/utils/resolveScopeFlag.mjs +26 -0
  16. package/dist/commands/runCli/utils/runInject.cjs +36 -0
  17. package/dist/commands/runCli/utils/runInject.d.ts +2 -0
  18. package/dist/commands/runCli/utils/runInject.mjs +34 -0
  19. package/dist/core/buildPlan/buildPlan.cjs +42 -0
  20. package/dist/core/buildPlan/buildPlan.d.ts +2 -0
  21. package/dist/core/buildPlan/buildPlan.mjs +40 -0
  22. package/dist/core/buildPlan/index.d.ts +2 -0
  23. package/dist/core/buildPlan/type.d.ts +32 -0
  24. package/dist/core/buildPlan/utils/toPosix.cjs +9 -0
  25. package/dist/core/buildPlan/utils/toPosix.d.ts +1 -0
  26. package/dist/core/buildPlan/utils/toPosix.mjs +7 -0
  27. package/dist/core/buildPlan/utils/walkFiles.cjs +25 -0
  28. package/dist/core/buildPlan/utils/walkFiles.d.ts +1 -0
  29. package/dist/core/buildPlan/utils/walkFiles.mjs +23 -0
  30. package/dist/core/hash/hash.cjs +30 -0
  31. package/dist/core/hash/hash.d.ts +4 -0
  32. package/dist/core/hash/hash.mjs +26 -0
  33. package/dist/core/hash/index.d.ts +1 -0
  34. package/dist/core/hashManifest/hashManifest.cjs +27 -0
  35. package/dist/core/hashManifest/hashManifest.d.ts +17 -0
  36. package/dist/core/hashManifest/hashManifest.mjs +23 -0
  37. package/dist/core/hashManifest/index.d.ts +1 -0
  38. package/dist/core/index.d.ts +5 -0
  39. package/dist/core/injectDocs/index.d.ts +2 -0
  40. package/dist/core/injectDocs/injectDocs.cjs +43 -0
  41. package/dist/core/injectDocs/injectDocs.d.ts +2 -0
  42. package/dist/core/injectDocs/injectDocs.mjs +41 -0
  43. package/dist/core/injectDocs/type.d.ts +30 -0
  44. package/dist/core/injectDocs/utils/applyAction.cjs +21 -0
  45. package/dist/core/injectDocs/utils/applyAction.d.ts +2 -0
  46. package/dist/core/injectDocs/utils/applyAction.mjs +19 -0
  47. package/dist/core/injectDocs/utils/emitCiForceList.cjs +10 -0
  48. package/dist/core/injectDocs/utils/emitCiForceList.d.ts +2 -0
  49. package/dist/core/injectDocs/utils/emitCiForceList.mjs +8 -0
  50. package/dist/core/injectDocs/utils/printPlan.cjs +20 -0
  51. package/dist/core/injectDocs/utils/printPlan.d.ts +2 -0
  52. package/dist/core/injectDocs/utils/printPlan.mjs +18 -0
  53. package/dist/core/injectDocs/utils/summarize.cjs +27 -0
  54. package/dist/core/injectDocs/utils/summarize.d.ts +3 -0
  55. package/dist/core/injectDocs/utils/summarize.mjs +25 -0
  56. package/dist/core/scope/index.d.ts +1 -0
  57. package/dist/core/scope/scope.cjs +46 -0
  58. package/dist/core/scope/scope.d.ts +16 -0
  59. package/dist/core/scope/scope.mjs +41 -0
  60. package/dist/core/scope/utils/isDirectory.cjs +14 -0
  61. package/dist/core/scope/utils/isDirectory.d.ts +1 -0
  62. package/dist/core/scope/utils/isDirectory.mjs +12 -0
  63. package/dist/index.cjs +15 -9
  64. package/dist/index.d.ts +3 -5
  65. package/dist/index.mjs +7 -3
  66. package/dist/prompts/confirmForce.cjs +27 -0
  67. package/dist/prompts/confirmForce.d.ts +1 -0
  68. package/dist/prompts/confirmForce.mjs +25 -0
  69. package/dist/prompts/index.d.ts +2 -0
  70. package/dist/prompts/selectScope.cjs +30 -0
  71. package/dist/prompts/selectScope.d.ts +2 -0
  72. package/dist/prompts/selectScope.mjs +28 -0
  73. package/dist/utils/heartbeat.cjs +25 -0
  74. package/dist/utils/heartbeat.d.ts +16 -0
  75. package/dist/utils/heartbeat.mjs +23 -0
  76. package/dist/utils/logger.cjs +7 -0
  77. package/dist/utils/logger.d.ts +8 -0
  78. package/dist/utils/logger.mjs +7 -0
  79. package/dist/utils/types.d.ts +1 -252
  80. package/dist/utils/version.cjs +2 -14
  81. package/dist/utils/version.d.ts +3 -53
  82. package/dist/utils/version.mjs +2 -13
  83. package/docs/bundle-size-decision.md +36 -0
  84. package/docs/claude/skills/claude-sync-applier/SKILL.md +195 -0
  85. package/docs/claude/skills/claude-sync-applier/knowledge/claude-md-template.md +77 -0
  86. package/docs/claude/skills/claude-sync-applier/knowledge/dependency-cruiser.md +126 -0
  87. package/docs/claude/skills/claude-sync-applier/knowledge/gotchas.md +139 -0
  88. package/docs/claude/skills/claude-sync-applier/knowledge/package-json-patches.md +130 -0
  89. package/docs/claude/skills/claude-sync-applier/knowledge/reference-files.md +120 -0
  90. package/docs/claude/skills/claude-sync-applier/knowledge/smoke-tests.md +102 -0
  91. package/docs/consumer-integration.md +153 -0
  92. package/package.json +24 -16
  93. package/scripts/build-hashes.mjs +30 -0
  94. package/scripts/buildHashes.d.mts +15 -0
  95. package/scripts/buildHashes.mjs +82 -0
  96. package/scripts/claude-build-hashes.mjs +42 -0
  97. package/scripts/inject-version.js +112 -0
  98. package/dist/cli.cjs +0 -8
  99. package/dist/cli.d.ts +0 -1
  100. package/dist/cli.mjs +0 -7
  101. package/dist/commands/add.cjs +0 -80
  102. package/dist/commands/add.d.ts +0 -8
  103. package/dist/commands/add.mjs +0 -78
  104. package/dist/commands/list.cjs +0 -94
  105. package/dist/commands/list.d.ts +0 -15
  106. package/dist/commands/list.mjs +0 -91
  107. package/dist/commands/migrate.cjs +0 -9
  108. package/dist/commands/migrate.d.ts +0 -6
  109. package/dist/commands/migrate.mjs +0 -7
  110. package/dist/commands/remove.cjs +0 -127
  111. package/dist/commands/remove.d.ts +0 -6
  112. package/dist/commands/remove.mjs +0 -105
  113. package/dist/commands/status.cjs +0 -193
  114. package/dist/commands/status.d.ts +0 -6
  115. package/dist/commands/status.mjs +0 -171
  116. package/dist/commands/sync.cjs +0 -28
  117. package/dist/commands/sync.d.ts +0 -6
  118. package/dist/commands/sync.mjs +0 -26
  119. package/dist/commands/types.d.ts +0 -89
  120. package/dist/commands/update.cjs +0 -209
  121. package/dist/commands/update.d.ts +0 -29
  122. package/dist/commands/update.mjs +0 -206
  123. package/dist/components/add/AddCommand.cjs +0 -103
  124. package/dist/components/add/AddCommand.d.ts +0 -14
  125. package/dist/components/add/AddCommand.mjs +0 -101
  126. package/dist/components/add/BulkAddView.cjs +0 -165
  127. package/dist/components/add/BulkAddView.d.ts +0 -11
  128. package/dist/components/add/BulkAddView.mjs +0 -163
  129. package/dist/components/add/index.d.ts +0 -2
  130. package/dist/components/index.d.ts +0 -2
  131. package/dist/components/list/EditableTreeItem.d.ts +0 -13
  132. package/dist/components/list/ListCommand.cjs +0 -651
  133. package/dist/components/list/ListCommand.d.ts +0 -5
  134. package/dist/components/list/ListCommand.mjs +0 -649
  135. package/dist/components/list/SyncedPackageTree.d.ts +0 -14
  136. package/dist/components/list/index.d.ts +0 -10
  137. package/dist/components/list/types.d.ts +0 -14
  138. package/dist/components/primitives/Box.d.ts +0 -4
  139. package/dist/components/primitives/Spinner.d.ts +0 -6
  140. package/dist/components/primitives/Text.d.ts +0 -4
  141. package/dist/components/primitives/index.d.ts +0 -3
  142. package/dist/components/remove/RemoveConfirm.cjs +0 -18
  143. package/dist/components/remove/RemoveConfirm.d.ts +0 -11
  144. package/dist/components/remove/RemoveConfirm.mjs +0 -16
  145. package/dist/components/shared/Confirm.cjs +0 -30
  146. package/dist/components/shared/Confirm.d.ts +0 -8
  147. package/dist/components/shared/Confirm.mjs +0 -28
  148. package/dist/components/shared/MenuItem.cjs +0 -18
  149. package/dist/components/shared/MenuItem.d.ts +0 -7
  150. package/dist/components/shared/MenuItem.mjs +0 -16
  151. package/dist/components/shared/ProgressBar.d.ts +0 -7
  152. package/dist/components/shared/StepRunner.cjs +0 -58
  153. package/dist/components/shared/StepRunner.d.ts +0 -15
  154. package/dist/components/shared/StepRunner.mjs +0 -56
  155. package/dist/components/shared/Table.cjs +0 -19
  156. package/dist/components/shared/Table.d.ts +0 -8
  157. package/dist/components/shared/Table.mjs +0 -17
  158. package/dist/components/shared/index.d.ts +0 -6
  159. package/dist/components/status/PackageStatusCard.d.ts +0 -10
  160. package/dist/components/status/StatusDisplay.cjs +0 -26
  161. package/dist/components/status/StatusDisplay.d.ts +0 -23
  162. package/dist/components/status/StatusDisplay.mjs +0 -24
  163. package/dist/components/status/StatusTreeNode.cjs +0 -40
  164. package/dist/components/status/StatusTreeNode.d.ts +0 -15
  165. package/dist/components/status/StatusTreeNode.mjs +0 -38
  166. package/dist/components/status/index.d.ts +0 -6
  167. package/dist/components/tree/AssetTreeNode.cjs +0 -54
  168. package/dist/components/tree/AssetTreeNode.d.ts +0 -12
  169. package/dist/components/tree/AssetTreeNode.mjs +0 -52
  170. package/dist/components/tree/TreeSelect.cjs +0 -129
  171. package/dist/components/tree/TreeSelect.d.ts +0 -12
  172. package/dist/components/tree/TreeSelect.mjs +0 -127
  173. package/dist/components/tree/index.d.ts +0 -4
  174. package/dist/core/assetStructure.cjs +0 -30
  175. package/dist/core/assetStructure.d.ts +0 -36
  176. package/dist/core/assetStructure.mjs +0 -27
  177. package/dist/core/cli.cjs +0 -106
  178. package/dist/core/cli.d.ts +0 -9
  179. package/dist/core/cli.mjs +0 -103
  180. package/dist/core/constants.cjs +0 -28
  181. package/dist/core/constants.d.ts +0 -94
  182. package/dist/core/constants.mjs +0 -21
  183. package/dist/core/filesystem.cjs +0 -98
  184. package/dist/core/filesystem.d.ts +0 -94
  185. package/dist/core/filesystem.mjs +0 -88
  186. package/dist/core/github.cjs +0 -115
  187. package/dist/core/github.d.ts +0 -61
  188. package/dist/core/github.mjs +0 -107
  189. package/dist/core/io.cjs +0 -46
  190. package/dist/core/io.d.ts +0 -40
  191. package/dist/core/io.mjs +0 -39
  192. package/dist/core/listOperations.cjs +0 -228
  193. package/dist/core/listOperations.d.ts +0 -43
  194. package/dist/core/listOperations.mjs +0 -205
  195. package/dist/core/localSource.cjs +0 -126
  196. package/dist/core/localSource.d.ts +0 -33
  197. package/dist/core/localSource.mjs +0 -120
  198. package/dist/core/migration.cjs +0 -201
  199. package/dist/core/migration.d.ts +0 -57
  200. package/dist/core/migration.mjs +0 -198
  201. package/dist/core/packageScanner.cjs +0 -360
  202. package/dist/core/packageScanner.d.ts +0 -22
  203. package/dist/core/packageScanner.mjs +0 -356
  204. package/dist/core/sync.cjs +0 -400
  205. package/dist/core/sync.d.ts +0 -21
  206. package/dist/core/sync.mjs +0 -397
  207. package/dist/core/syncMeta.cjs +0 -242
  208. package/dist/core/syncMeta.d.ts +0 -75
  209. package/dist/core/syncMeta.mjs +0 -229
  210. package/dist/utils/dependencies.cjs +0 -57
  211. package/dist/utils/dependencies.d.ts +0 -10
  212. package/dist/utils/dependencies.mjs +0 -34
  213. package/dist/utils/nameTransform.cjs +0 -13
  214. package/dist/utils/nameTransform.d.ts +0 -65
  215. package/dist/utils/nameTransform.mjs +0 -11
  216. package/dist/utils/package.cjs +0 -170
  217. package/dist/utils/package.d.ts +0 -105
  218. package/dist/utils/package.mjs +0 -157
  219. package/dist/utils/packageName.cjs +0 -24
  220. package/dist/utils/packageName.d.ts +0 -32
  221. package/dist/utils/packageName.mjs +0 -21
  222. package/dist/utils/paths.cjs +0 -18
  223. package/dist/utils/paths.d.ts +0 -55
  224. package/dist/utils/paths.mjs +0 -15
  225. package/dist/version.cjs +0 -5
  226. package/dist/version.d.ts +0 -5
  227. package/dist/version.mjs +0 -3
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { dirname, join } from 'node:path';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+
10
+ /**
11
+ * Semantic version regex (https://semver.org/)
12
+ * Matches: 0.0.1, 1.2.3, 1.0.0-beta.1, 2.0.0+build.123, etc.
13
+ */
14
+ const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
15
+
16
+ /**
17
+ * Read and validate package.json version
18
+ */
19
+ function readPackageVersion() {
20
+ const packageJsonPath = join(__dirname, '..', 'package.json');
21
+
22
+ try {
23
+ const content = readFileSync(packageJsonPath, 'utf-8');
24
+ const pkg = JSON.parse(content);
25
+
26
+ if (!pkg.version) {
27
+ console.error('❌ Error: No version field found in package.json');
28
+ process.exit(1);
29
+ }
30
+
31
+ if (!SEMVER_REGEX.test(pkg.version)) {
32
+ console.error(`❌ Error: Invalid semantic version "${pkg.version}" in package.json`);
33
+ console.error(' Expected format: MAJOR.MINOR.PATCH (e.g., 1.2.3, 1.0.0-beta.1)');
34
+ process.exit(1);
35
+ }
36
+
37
+ return pkg.version;
38
+ } catch (error) {
39
+ if (error.code === 'ENOENT') {
40
+ console.error('❌ Error: package.json not found at', packageJsonPath);
41
+ } else if (error instanceof SyntaxError) {
42
+ console.error('❌ Error: Invalid JSON in package.json');
43
+ } else {
44
+ console.error('❌ Error reading package.json:', error.message);
45
+ }
46
+ process.exit(1);
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Generate src/version.ts with current version
52
+ */
53
+ function generateVersionFile(version) {
54
+ const versionFilePath = join(__dirname, '..', 'src', 'utils', 'version.ts');
55
+
56
+ try {
57
+ // Check if file exists and read current version
58
+ let currentVersion = null;
59
+ try {
60
+ const existingContent = readFileSync(versionFilePath, 'utf-8');
61
+ const match = existingContent.match(/VERSION = ['"]([^'"]+)['"]/);
62
+ if (match) {
63
+ currentVersion = match[1];
64
+ }
65
+ } catch {
66
+ // File doesn't exist yet, that's fine
67
+ }
68
+
69
+ if (currentVersion === version) {
70
+ console.log(`✓ Version file already up to date: ${version}`);
71
+ return false;
72
+ }
73
+
74
+ // Generate new version file
75
+ const content = `// Auto-generated by scripts/inject-version.js
76
+ // DO NOT EDIT MANUALLY - This file is generated during build
77
+
78
+ /**
79
+ * Current package version from package.json
80
+ * Automatically synchronized during build process
81
+ */
82
+ export const VERSION = '${version}';
83
+ `;
84
+
85
+ writeFileSync(versionFilePath, content, 'utf-8');
86
+
87
+ if (currentVersion) {
88
+ console.log(`✓ Version file updated: ${currentVersion} → ${version}`);
89
+ } else {
90
+ console.log(`✓ Version file created: ${version}`);
91
+ }
92
+ return true;
93
+ } catch (error) {
94
+ console.error('❌ Error generating version file:', error.message);
95
+ process.exit(1);
96
+ }
97
+ }
98
+
99
+ // Main execution
100
+ try {
101
+ const version = readPackageVersion();
102
+ const updated = generateVersionFile(version);
103
+
104
+ if (!updated) {
105
+ console.log(`\n✅ Version is synchronized: ${version}`);
106
+ } else {
107
+ console.log(`\n✅ Version synchronization complete: ${version}`);
108
+ }
109
+ } catch (error) {
110
+ console.error('❌ Unexpected error:', error.message);
111
+ process.exit(1);
112
+ }
package/dist/cli.cjs DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var cli = require('./core/cli.cjs');
4
-
5
- cli.run().catch((error) => {
6
- console.error('Fatal error:', error.message);
7
- process.exit(1);
8
- });
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/cli.mjs DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import { run } from './core/cli.mjs';
3
-
4
- run().catch((error) => {
5
- console.error('Fatal error:', error.message);
6
- process.exit(1);
7
- });
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- var ink = require('ink');
4
- var React = require('react');
5
- var AddCommand = require('../components/add/AddCommand.cjs');
6
- var BulkAddView = require('../components/add/BulkAddView.cjs');
7
- var sync = require('../core/sync.cjs');
8
-
9
- async function runAddCommand(options, cwd) {
10
- const workingDir = process.cwd();
11
- if (options.pattern) {
12
- try {
13
- new RegExp(options.pattern);
14
- }
15
- catch (err) {
16
- const msg = err instanceof Error ? err.message : String(err);
17
- throw new Error(`Invalid regex pattern "${options.pattern}": ${msg}`);
18
- }
19
- const { waitUntilExit } = ink.render(React.createElement(BulkAddView.BulkAddView, {
20
- pattern: options.pattern,
21
- cwd: workingDir,
22
- local: options.local ?? false,
23
- ref: options.ref,
24
- }));
25
- await waitUntilExit();
26
- return;
27
- }
28
- if (!options.package) {
29
- console.error('Error: either --package or --pattern must be provided');
30
- console.error(' Usage: claude-assets-sync add -p <name>');
31
- console.error(' claude-assets-sync add --pattern <regex>');
32
- process.exit(1);
33
- }
34
- return new Promise((resolve, reject) => {
35
- const { waitUntilExit } = ink.render(React.createElement(AddCommand.AddCommand, {
36
- packageName: options.package,
37
- local: options.local ?? false,
38
- ref: options.ref,
39
- onComplete: async (selection) => {
40
- try {
41
- await performSync(selection, workingDir);
42
- resolve();
43
- }
44
- catch (error) {
45
- reject(error);
46
- }
47
- },
48
- onError: (error) => {
49
- reject(error);
50
- },
51
- onCancel: () => {
52
- console.log('\nSync cancelled');
53
- resolve();
54
- },
55
- }));
56
- waitUntilExit().catch(reject);
57
- });
58
- }
59
- async function performSync(selection, cwd) {
60
- const exclusions = {
61
- directories: [],
62
- files: [],
63
- };
64
- for (const assetType of Object.keys(selection.excludedAssets)) {
65
- for (const excludedPath of selection.excludedAssets[assetType]) {
66
- exclusions.files.push(excludedPath);
67
- }
68
- }
69
- await sync.syncPackage(selection.packageName, {
70
- force: true,
71
- dryRun: false,
72
- local: selection.source === 'local',
73
- ref: selection.ref,
74
- flat: true,
75
- }, cwd, exclusions.directories.length > 0 || exclusions.files.length > 0
76
- ? exclusions
77
- : undefined, undefined);
78
- }
79
-
80
- exports.runAddCommand = runAddCommand;
@@ -1,8 +0,0 @@
1
- import type { AddCommandOptions } from '../commands/types.js';
2
- /**
3
- * Run the add command with interactive asset selection or bulk pattern mode
4
- *
5
- * @param options - Add command options
6
- * @param cwd - Current working directory
7
- */
8
- export declare function runAddCommand(options: AddCommandOptions, cwd?: string): Promise<void>;
@@ -1,78 +0,0 @@
1
- import { render } from 'ink';
2
- import React from 'react';
3
- import { AddCommand } from '../components/add/AddCommand.mjs';
4
- import { BulkAddView } from '../components/add/BulkAddView.mjs';
5
- import { syncPackage } from '../core/sync.mjs';
6
-
7
- async function runAddCommand(options, cwd) {
8
- const workingDir = process.cwd();
9
- if (options.pattern) {
10
- try {
11
- new RegExp(options.pattern);
12
- }
13
- catch (err) {
14
- const msg = err instanceof Error ? err.message : String(err);
15
- throw new Error(`Invalid regex pattern "${options.pattern}": ${msg}`);
16
- }
17
- const { waitUntilExit } = render(React.createElement(BulkAddView, {
18
- pattern: options.pattern,
19
- cwd: workingDir,
20
- local: options.local ?? false,
21
- ref: options.ref,
22
- }));
23
- await waitUntilExit();
24
- return;
25
- }
26
- if (!options.package) {
27
- console.error('Error: either --package or --pattern must be provided');
28
- console.error(' Usage: claude-assets-sync add -p <name>');
29
- console.error(' claude-assets-sync add --pattern <regex>');
30
- process.exit(1);
31
- }
32
- return new Promise((resolve, reject) => {
33
- const { waitUntilExit } = render(React.createElement(AddCommand, {
34
- packageName: options.package,
35
- local: options.local ?? false,
36
- ref: options.ref,
37
- onComplete: async (selection) => {
38
- try {
39
- await performSync(selection, workingDir);
40
- resolve();
41
- }
42
- catch (error) {
43
- reject(error);
44
- }
45
- },
46
- onError: (error) => {
47
- reject(error);
48
- },
49
- onCancel: () => {
50
- console.log('\nSync cancelled');
51
- resolve();
52
- },
53
- }));
54
- waitUntilExit().catch(reject);
55
- });
56
- }
57
- async function performSync(selection, cwd) {
58
- const exclusions = {
59
- directories: [],
60
- files: [],
61
- };
62
- for (const assetType of Object.keys(selection.excludedAssets)) {
63
- for (const excludedPath of selection.excludedAssets[assetType]) {
64
- exclusions.files.push(excludedPath);
65
- }
66
- }
67
- await syncPackage(selection.packageName, {
68
- force: true,
69
- dryRun: false,
70
- local: selection.source === 'local',
71
- ref: selection.ref,
72
- flat: true,
73
- }, cwd, exclusions.directories.length > 0 || exclusions.files.length > 0
74
- ? exclusions
75
- : undefined, undefined);
76
- }
77
-
78
- export { runAddCommand };
@@ -1,94 +0,0 @@
1
- 'use strict';
2
-
3
- var ink = require('ink');
4
- var pc = require('picocolors');
5
- var React = require('react');
6
- var ListCommand = require('../components/list/ListCommand.cjs');
7
- var syncMeta = require('../core/syncMeta.cjs');
8
- var logger = require('../utils/logger.cjs');
9
- var _package = require('../utils/package.cjs');
10
-
11
- function isTTY() {
12
- return process.stdout.isTTY === true && process.stdin.isTTY === true;
13
- }
14
- const runListCommand = async (options, cwd = process.cwd()) => {
15
- const destDir = _package.findGitRoot(cwd) ?? cwd;
16
- const meta = syncMeta.readUnifiedSyncMeta(destDir);
17
- if (!meta || Object.keys(meta.packages).length === 0) {
18
- if (options.json) {
19
- console.log(JSON.stringify([], null, 2));
20
- }
21
- else {
22
- logger.logger.info('No packages synced yet.');
23
- }
24
- return;
25
- }
26
- if (options.json) {
27
- const packages = [];
28
- for (const [, packageInfo] of Object.entries(meta.packages)) {
29
- const assets = {};
30
- let totalCount = 0;
31
- for (const [assetType, files] of Object.entries(packageInfo.files)) {
32
- const count = Array.isArray(files) ? files.length : 0;
33
- assets[assetType] = count;
34
- totalCount += count;
35
- }
36
- packages.push({
37
- name: packageInfo.originalName,
38
- version: packageInfo.version,
39
- syncedAt: meta.syncedAt,
40
- assetCount: totalCount,
41
- assets,
42
- });
43
- }
44
- packages.sort((a, b) => a.name.localeCompare(b.name));
45
- console.log(JSON.stringify(packages, null, 2));
46
- return;
47
- }
48
- if (isTTY()) {
49
- const { waitUntilExit } = ink.render(React.createElement(ListCommand.ListCommand, { cwd: destDir }));
50
- await waitUntilExit();
51
- return;
52
- }
53
- const packages = [];
54
- for (const [, packageInfo] of Object.entries(meta.packages)) {
55
- const assets = {};
56
- let totalCount = 0;
57
- for (const [assetType, files] of Object.entries(packageInfo.files)) {
58
- const count = Array.isArray(files) ? files.length : 0;
59
- assets[assetType] = count;
60
- totalCount += count;
61
- }
62
- packages.push({
63
- name: packageInfo.originalName,
64
- version: packageInfo.version,
65
- syncedAt: meta.syncedAt,
66
- assetCount: totalCount,
67
- assets,
68
- });
69
- }
70
- packages.sort((a, b) => a.name.localeCompare(b.name));
71
- console.log(pc.bold('\nSynced Packages:\n'));
72
- for (const pkg of packages) {
73
- console.log(pc.cyan(` ${pkg.name}@${pkg.version}`));
74
- console.log(` Synced: ${new Date(pkg.syncedAt).toLocaleString()}`);
75
- console.log(` Assets: ${pkg.assetCount} files`);
76
- const assetBreakdown = Object.entries(pkg.assets)
77
- .map(([type, count]) => `${count} ${type}`)
78
- .join(', ');
79
- console.log(` Types: ${assetBreakdown}`);
80
- console.log('');
81
- }
82
- };
83
- function registerListCommand(program) {
84
- program
85
- .command('list')
86
- .description('List all synced packages')
87
- .option('--json', 'Output as JSON')
88
- .action(async (opts) => {
89
- await runListCommand({ json: opts.json });
90
- });
91
- }
92
-
93
- exports.registerListCommand = registerListCommand;
94
- exports.runListCommand = runListCommand;
@@ -1,15 +0,0 @@
1
- /**
2
- * List command - list all synced packages
3
- */
4
- import type { Command } from 'commander';
5
- import type { ListCommandOptions } from './types.js';
6
- /**
7
- * Run the list command
8
- * @param options - List command options
9
- */
10
- declare const runListCommand: (options: ListCommandOptions, cwd?: string) => Promise<void>;
11
- /**
12
- * Register the list command with the CLI program
13
- */
14
- export declare function registerListCommand(program: Command): void;
15
- export { runListCommand };
@@ -1,91 +0,0 @@
1
- import { render } from 'ink';
2
- import pc from 'picocolors';
3
- import React from 'react';
4
- import { ListCommand } from '../components/list/ListCommand.mjs';
5
- import { readUnifiedSyncMeta } from '../core/syncMeta.mjs';
6
- import { logger } from '../utils/logger.mjs';
7
- import { findGitRoot } from '../utils/package.mjs';
8
-
9
- function isTTY() {
10
- return process.stdout.isTTY === true && process.stdin.isTTY === true;
11
- }
12
- const runListCommand = async (options, cwd = process.cwd()) => {
13
- const destDir = findGitRoot(cwd) ?? cwd;
14
- const meta = readUnifiedSyncMeta(destDir);
15
- if (!meta || Object.keys(meta.packages).length === 0) {
16
- if (options.json) {
17
- console.log(JSON.stringify([], null, 2));
18
- }
19
- else {
20
- logger.info('No packages synced yet.');
21
- }
22
- return;
23
- }
24
- if (options.json) {
25
- const packages = [];
26
- for (const [, packageInfo] of Object.entries(meta.packages)) {
27
- const assets = {};
28
- let totalCount = 0;
29
- for (const [assetType, files] of Object.entries(packageInfo.files)) {
30
- const count = Array.isArray(files) ? files.length : 0;
31
- assets[assetType] = count;
32
- totalCount += count;
33
- }
34
- packages.push({
35
- name: packageInfo.originalName,
36
- version: packageInfo.version,
37
- syncedAt: meta.syncedAt,
38
- assetCount: totalCount,
39
- assets,
40
- });
41
- }
42
- packages.sort((a, b) => a.name.localeCompare(b.name));
43
- console.log(JSON.stringify(packages, null, 2));
44
- return;
45
- }
46
- if (isTTY()) {
47
- const { waitUntilExit } = render(React.createElement(ListCommand, { cwd: destDir }));
48
- await waitUntilExit();
49
- return;
50
- }
51
- const packages = [];
52
- for (const [, packageInfo] of Object.entries(meta.packages)) {
53
- const assets = {};
54
- let totalCount = 0;
55
- for (const [assetType, files] of Object.entries(packageInfo.files)) {
56
- const count = Array.isArray(files) ? files.length : 0;
57
- assets[assetType] = count;
58
- totalCount += count;
59
- }
60
- packages.push({
61
- name: packageInfo.originalName,
62
- version: packageInfo.version,
63
- syncedAt: meta.syncedAt,
64
- assetCount: totalCount,
65
- assets,
66
- });
67
- }
68
- packages.sort((a, b) => a.name.localeCompare(b.name));
69
- console.log(pc.bold('\nSynced Packages:\n'));
70
- for (const pkg of packages) {
71
- console.log(pc.cyan(` ${pkg.name}@${pkg.version}`));
72
- console.log(` Synced: ${new Date(pkg.syncedAt).toLocaleString()}`);
73
- console.log(` Assets: ${pkg.assetCount} files`);
74
- const assetBreakdown = Object.entries(pkg.assets)
75
- .map(([type, count]) => `${count} ${type}`)
76
- .join(', ');
77
- console.log(` Types: ${assetBreakdown}`);
78
- console.log('');
79
- }
80
- };
81
- function registerListCommand(program) {
82
- program
83
- .command('list')
84
- .description('List all synced packages')
85
- .option('--json', 'Output as JSON')
86
- .action(async (opts) => {
87
- await runListCommand({ json: opts.json });
88
- });
89
- }
90
-
91
- export { registerListCommand, runListCommand };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var migration = require('../core/migration.cjs');
4
-
5
- const runMigrateCommand = async (options, cwd = process.cwd()) => {
6
- await migration.migrateToFlat(cwd, { dryRun: options.dryRun });
7
- };
8
-
9
- exports.runMigrateCommand = runMigrateCommand;
@@ -1,6 +0,0 @@
1
- import type { MigrateCommandOptions } from './types.js';
2
- /**
3
- * Run the migrate command
4
- * @param options - Migration options
5
- */
6
- export declare const runMigrateCommand: (options: MigrateCommandOptions, cwd?: string) => Promise<void>;
@@ -1,7 +0,0 @@
1
- import { migrateToFlat } from '../core/migration.mjs';
2
-
3
- const runMigrateCommand = async (options, cwd = process.cwd()) => {
4
- await migrateToFlat(cwd, { dryRun: options.dryRun });
5
- };
6
-
7
- export { runMigrateCommand };
@@ -1,127 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('node:fs');
4
- var path = require('node:path');
5
- var ink = require('ink');
6
- var pc = require('picocolors');
7
- var React = require('react');
8
- var RemoveConfirm = require('../components/remove/RemoveConfirm.cjs');
9
- var syncMeta = require('../core/syncMeta.cjs');
10
- var logger = require('../utils/logger.cjs');
11
- var packageName = require('../utils/packageName.cjs');
12
-
13
- function _interopNamespaceDefault(e) {
14
- var n = Object.create(null);
15
- if (e) {
16
- Object.keys(e).forEach(function (k) {
17
- if (k !== 'default') {
18
- var d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: function () { return e[k]; }
22
- });
23
- }
24
- });
25
- }
26
- n.default = e;
27
- return Object.freeze(n);
28
- }
29
-
30
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
31
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
32
-
33
- function isTTY() {
34
- return process.stdout.isTTY === true && process.stdin.isTTY === true;
35
- }
36
- function performRemoval(filesToRemove, meta, prefix, packageName, cwd) {
37
- for (const { path: filePath } of filesToRemove) {
38
- try {
39
- const stat = fs__namespace.statSync(filePath);
40
- if (stat.isDirectory()) {
41
- fs__namespace.rmSync(filePath, { recursive: true, force: true });
42
- console.log(`${pc.red('-')} ${filePath}`);
43
- }
44
- else {
45
- fs__namespace.unlinkSync(filePath);
46
- console.log(`${pc.red('-')} ${filePath}`);
47
- }
48
- }
49
- catch (error) {
50
- if (error.code !== 'ENOENT') {
51
- logger.logger.error(`Failed to remove ${filePath}: ${error}`);
52
- }
53
- }
54
- }
55
- if (meta) {
56
- delete meta.packages[prefix];
57
- meta.syncedAt = new Date().toISOString();
58
- syncMeta.writeUnifiedSyncMeta(cwd, meta);
59
- }
60
- logger.logger.success(`\nRemoved package ${packageName}`);
61
- }
62
- const runRemoveCommand = async (options, cwd = process.cwd()) => {
63
- const { package: packageName$1, yes, dryRun } = options;
64
- const prefix = packageName.packageNameToPrefix(packageName$1);
65
- const meta = syncMeta.readUnifiedSyncMeta(cwd);
66
- if (!meta || !meta.packages || !meta.packages[prefix]) {
67
- logger.logger.error(`Package ${packageName$1} is not synced.`);
68
- process.exit(1);
69
- return;
70
- }
71
- const packageInfo = meta.packages[prefix];
72
- if (!packageInfo || !packageInfo.files) {
73
- logger.logger.error(`Package ${packageName$1} has no files to remove.`);
74
- process.exit(1);
75
- return;
76
- }
77
- const filesToRemove = [];
78
- for (const [assetType, files] of Object.entries(packageInfo.files)) {
79
- if (!Array.isArray(files) || files.length === 0)
80
- continue;
81
- const units = files;
82
- const firstUnit = units[0];
83
- if (firstUnit.transformed) {
84
- for (const unit of units) {
85
- const targetPath = path__namespace.join(cwd, '.claude', assetType, unit.transformed);
86
- filesToRemove.push({ assetType, path: targetPath });
87
- }
88
- }
89
- else {
90
- const dirPath = path__namespace.join(cwd, '.claude', assetType, packageName$1);
91
- filesToRemove.push({ assetType, path: dirPath });
92
- }
93
- }
94
- console.log(pc.bold('\nFiles to remove:\n'));
95
- for (const { assetType, path: filePath } of filesToRemove) {
96
- console.log(` ${pc.red('-')} ${assetType}: ${filePath}`);
97
- }
98
- console.log('');
99
- if (dryRun) {
100
- logger.logger.info('[DRY RUN] No changes made.');
101
- return;
102
- }
103
- if (!yes) {
104
- if (isTTY()) {
105
- let confirmed = false;
106
- const { waitUntilExit } = ink.render(React.createElement(RemoveConfirm.RemoveConfirm, {
107
- packageName: packageName$1,
108
- filesToRemove,
109
- onConfirm: (result) => {
110
- confirmed = result;
111
- },
112
- }));
113
- await waitUntilExit();
114
- if (!confirmed) {
115
- logger.logger.info('Cancelled.');
116
- return;
117
- }
118
- }
119
- else {
120
- logger.logger.info('Cancelled (non-interactive terminal).');
121
- return;
122
- }
123
- }
124
- performRemoval(filesToRemove, meta, prefix, packageName$1, cwd);
125
- };
126
-
127
- exports.runRemoveCommand = runRemoveCommand;
@@ -1,6 +0,0 @@
1
- import type { RemoveCommandOptions } from './types.js';
2
- /**
3
- * Run the remove command
4
- * @param options - Remove command options
5
- */
6
- export declare const runRemoveCommand: (options: RemoveCommandOptions, cwd?: string) => Promise<void>;