@slats/claude-assets-sync 0.1.4 → 0.3.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 (239) hide show
  1. package/README.md +89 -581
  2. package/bin/inject-claude-settings.mjs +4 -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 +53 -0
  7. package/dist/commands/runCli/runCli.d.ts +14 -0
  8. package/dist/commands/runCli/runCli.mjs +51 -0
  9. package/dist/commands/runCli/type.d.ts +19 -0
  10. package/dist/commands/runCli/utils/classifyTarget.cjs +48 -0
  11. package/dist/commands/runCli/utils/classifyTarget.d.ts +19 -0
  12. package/dist/commands/runCli/utils/classifyTarget.mjs +46 -0
  13. package/dist/commands/runCli/utils/injectOne.cjs +47 -0
  14. package/dist/commands/runCli/utils/injectOne.d.ts +3 -0
  15. package/dist/commands/runCli/utils/injectOne.mjs +45 -0
  16. package/dist/commands/runCli/utils/resolvePackage.cjs +77 -0
  17. package/dist/commands/runCli/utils/resolvePackage.d.ts +16 -0
  18. package/dist/commands/runCli/utils/resolvePackage.mjs +74 -0
  19. package/dist/commands/runCli/utils/resolveScopeAlias.cjs +69 -0
  20. package/dist/commands/runCli/utils/resolveScopeAlias.d.ts +2 -0
  21. package/dist/commands/runCli/utils/resolveScopeAlias.mjs +67 -0
  22. package/dist/commands/runCli/utils/resolveScopeFlag.cjs +28 -0
  23. package/dist/commands/runCli/utils/resolveScopeFlag.d.ts +2 -0
  24. package/dist/commands/runCli/utils/resolveScopeFlag.mjs +26 -0
  25. package/dist/commands/runCli/utils/resolveTargets.cjs +40 -0
  26. package/dist/commands/runCli/utils/resolveTargets.d.ts +15 -0
  27. package/dist/commands/runCli/utils/resolveTargets.mjs +38 -0
  28. package/dist/commands/runCli/utils/runInject.cjs +52 -0
  29. package/dist/commands/runCli/utils/runInject.d.ts +3 -0
  30. package/dist/commands/runCli/utils/runInject.mjs +50 -0
  31. package/dist/core/buildPlan/buildPlan.cjs +42 -0
  32. package/dist/core/buildPlan/buildPlan.d.ts +2 -0
  33. package/dist/core/buildPlan/buildPlan.mjs +40 -0
  34. package/dist/core/buildPlan/index.d.ts +2 -0
  35. package/dist/core/buildPlan/type.d.ts +32 -0
  36. package/dist/core/buildPlan/utils/toPosix.cjs +9 -0
  37. package/dist/core/buildPlan/utils/toPosix.d.ts +1 -0
  38. package/dist/core/buildPlan/utils/toPosix.mjs +7 -0
  39. package/dist/core/buildPlan/utils/walkFiles.cjs +25 -0
  40. package/dist/core/buildPlan/utils/walkFiles.d.ts +1 -0
  41. package/dist/core/buildPlan/utils/walkFiles.mjs +23 -0
  42. package/dist/core/hash/hash.cjs +30 -0
  43. package/dist/core/hash/hash.d.ts +4 -0
  44. package/dist/core/hash/hash.mjs +26 -0
  45. package/dist/core/hash/index.d.ts +1 -0
  46. package/dist/core/hashManifest/hashManifest.cjs +27 -0
  47. package/dist/core/hashManifest/hashManifest.d.ts +17 -0
  48. package/dist/core/hashManifest/hashManifest.mjs +23 -0
  49. package/dist/core/hashManifest/index.d.ts +1 -0
  50. package/dist/core/index.d.ts +5 -0
  51. package/dist/core/injectDocs/index.d.ts +2 -0
  52. package/dist/core/injectDocs/injectDocs.cjs +43 -0
  53. package/dist/core/injectDocs/injectDocs.d.ts +2 -0
  54. package/dist/core/injectDocs/injectDocs.mjs +41 -0
  55. package/dist/core/injectDocs/type.d.ts +30 -0
  56. package/dist/core/injectDocs/utils/applyAction.cjs +21 -0
  57. package/dist/core/injectDocs/utils/applyAction.d.ts +2 -0
  58. package/dist/core/injectDocs/utils/applyAction.mjs +19 -0
  59. package/dist/core/injectDocs/utils/emitCiForceList.cjs +10 -0
  60. package/dist/core/injectDocs/utils/emitCiForceList.d.ts +2 -0
  61. package/dist/core/injectDocs/utils/emitCiForceList.mjs +8 -0
  62. package/dist/core/injectDocs/utils/printPlan.cjs +20 -0
  63. package/dist/core/injectDocs/utils/printPlan.d.ts +2 -0
  64. package/dist/core/injectDocs/utils/printPlan.mjs +18 -0
  65. package/dist/core/injectDocs/utils/summarize.cjs +27 -0
  66. package/dist/core/injectDocs/utils/summarize.d.ts +3 -0
  67. package/dist/core/injectDocs/utils/summarize.mjs +25 -0
  68. package/dist/core/scope/index.d.ts +1 -0
  69. package/dist/core/scope/scope.cjs +46 -0
  70. package/dist/core/scope/scope.d.ts +16 -0
  71. package/dist/core/scope/scope.mjs +41 -0
  72. package/dist/core/scope/utils/isDirectory.cjs +14 -0
  73. package/dist/core/scope/utils/isDirectory.d.ts +1 -0
  74. package/dist/core/scope/utils/isDirectory.mjs +12 -0
  75. package/dist/index.cjs +15 -9
  76. package/dist/index.d.ts +3 -5
  77. package/dist/index.mjs +7 -3
  78. package/dist/prompts/confirmForce.cjs +27 -0
  79. package/dist/prompts/confirmForce.d.ts +1 -0
  80. package/dist/prompts/confirmForce.mjs +25 -0
  81. package/dist/prompts/index.d.ts +2 -0
  82. package/dist/prompts/selectScope.cjs +30 -0
  83. package/dist/prompts/selectScope.d.ts +2 -0
  84. package/dist/prompts/selectScope.mjs +28 -0
  85. package/dist/utils/heartbeat.cjs +25 -0
  86. package/dist/utils/heartbeat.d.ts +16 -0
  87. package/dist/utils/heartbeat.mjs +23 -0
  88. package/dist/utils/logger.cjs +7 -0
  89. package/dist/utils/logger.d.ts +8 -0
  90. package/dist/utils/logger.mjs +7 -0
  91. package/dist/utils/types.d.ts +1 -252
  92. package/dist/utils/version.cjs +2 -14
  93. package/dist/utils/version.d.ts +3 -53
  94. package/dist/utils/version.mjs +2 -13
  95. package/docs/bundle-size-decision.md +36 -0
  96. package/docs/claude/skills/claude-docs-asset-wiring/SKILL.md +159 -0
  97. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/claude-md-template.md +86 -0
  98. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/dependency-cruiser.md +54 -0
  99. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/gotchas.md +122 -0
  100. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/package-json-patches.md +145 -0
  101. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/reference-files.md +37 -0
  102. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/smoke-tests.md +111 -0
  103. package/docs/consumer-integration.md +94 -0
  104. package/package.json +24 -16
  105. package/scripts/build-hashes.mjs +30 -0
  106. package/scripts/buildHashes.d.mts +15 -0
  107. package/scripts/buildHashes.mjs +82 -0
  108. package/scripts/claude-build-hashes.mjs +42 -0
  109. package/scripts/inject-version.js +112 -0
  110. package/dist/cli.cjs +0 -8
  111. package/dist/cli.d.ts +0 -1
  112. package/dist/cli.mjs +0 -7
  113. package/dist/commands/add.cjs +0 -80
  114. package/dist/commands/add.d.ts +0 -8
  115. package/dist/commands/add.mjs +0 -78
  116. package/dist/commands/list.cjs +0 -94
  117. package/dist/commands/list.d.ts +0 -15
  118. package/dist/commands/list.mjs +0 -91
  119. package/dist/commands/migrate.cjs +0 -9
  120. package/dist/commands/migrate.d.ts +0 -6
  121. package/dist/commands/migrate.mjs +0 -7
  122. package/dist/commands/remove.cjs +0 -127
  123. package/dist/commands/remove.d.ts +0 -6
  124. package/dist/commands/remove.mjs +0 -105
  125. package/dist/commands/status.cjs +0 -193
  126. package/dist/commands/status.d.ts +0 -6
  127. package/dist/commands/status.mjs +0 -171
  128. package/dist/commands/sync.cjs +0 -28
  129. package/dist/commands/sync.d.ts +0 -6
  130. package/dist/commands/sync.mjs +0 -26
  131. package/dist/commands/types.d.ts +0 -89
  132. package/dist/commands/update.cjs +0 -209
  133. package/dist/commands/update.d.ts +0 -29
  134. package/dist/commands/update.mjs +0 -206
  135. package/dist/components/add/AddCommand.cjs +0 -103
  136. package/dist/components/add/AddCommand.d.ts +0 -14
  137. package/dist/components/add/AddCommand.mjs +0 -101
  138. package/dist/components/add/BulkAddView.cjs +0 -165
  139. package/dist/components/add/BulkAddView.d.ts +0 -11
  140. package/dist/components/add/BulkAddView.mjs +0 -163
  141. package/dist/components/add/index.d.ts +0 -2
  142. package/dist/components/index.d.ts +0 -2
  143. package/dist/components/list/EditableTreeItem.d.ts +0 -13
  144. package/dist/components/list/ListCommand.cjs +0 -651
  145. package/dist/components/list/ListCommand.d.ts +0 -5
  146. package/dist/components/list/ListCommand.mjs +0 -649
  147. package/dist/components/list/SyncedPackageTree.d.ts +0 -14
  148. package/dist/components/list/index.d.ts +0 -10
  149. package/dist/components/list/types.d.ts +0 -14
  150. package/dist/components/primitives/Box.d.ts +0 -4
  151. package/dist/components/primitives/Spinner.d.ts +0 -6
  152. package/dist/components/primitives/Text.d.ts +0 -4
  153. package/dist/components/primitives/index.d.ts +0 -3
  154. package/dist/components/remove/RemoveConfirm.cjs +0 -18
  155. package/dist/components/remove/RemoveConfirm.d.ts +0 -11
  156. package/dist/components/remove/RemoveConfirm.mjs +0 -16
  157. package/dist/components/shared/Confirm.cjs +0 -30
  158. package/dist/components/shared/Confirm.d.ts +0 -8
  159. package/dist/components/shared/Confirm.mjs +0 -28
  160. package/dist/components/shared/MenuItem.cjs +0 -18
  161. package/dist/components/shared/MenuItem.d.ts +0 -7
  162. package/dist/components/shared/MenuItem.mjs +0 -16
  163. package/dist/components/shared/ProgressBar.d.ts +0 -7
  164. package/dist/components/shared/StepRunner.cjs +0 -58
  165. package/dist/components/shared/StepRunner.d.ts +0 -15
  166. package/dist/components/shared/StepRunner.mjs +0 -56
  167. package/dist/components/shared/Table.cjs +0 -19
  168. package/dist/components/shared/Table.d.ts +0 -8
  169. package/dist/components/shared/Table.mjs +0 -17
  170. package/dist/components/shared/index.d.ts +0 -6
  171. package/dist/components/status/PackageStatusCard.d.ts +0 -10
  172. package/dist/components/status/StatusDisplay.cjs +0 -26
  173. package/dist/components/status/StatusDisplay.d.ts +0 -23
  174. package/dist/components/status/StatusDisplay.mjs +0 -24
  175. package/dist/components/status/StatusTreeNode.cjs +0 -40
  176. package/dist/components/status/StatusTreeNode.d.ts +0 -15
  177. package/dist/components/status/StatusTreeNode.mjs +0 -38
  178. package/dist/components/status/index.d.ts +0 -6
  179. package/dist/components/tree/AssetTreeNode.cjs +0 -54
  180. package/dist/components/tree/AssetTreeNode.d.ts +0 -12
  181. package/dist/components/tree/AssetTreeNode.mjs +0 -52
  182. package/dist/components/tree/TreeSelect.cjs +0 -129
  183. package/dist/components/tree/TreeSelect.d.ts +0 -12
  184. package/dist/components/tree/TreeSelect.mjs +0 -127
  185. package/dist/components/tree/index.d.ts +0 -4
  186. package/dist/core/assetStructure.cjs +0 -30
  187. package/dist/core/assetStructure.d.ts +0 -36
  188. package/dist/core/assetStructure.mjs +0 -27
  189. package/dist/core/cli.cjs +0 -106
  190. package/dist/core/cli.d.ts +0 -9
  191. package/dist/core/cli.mjs +0 -103
  192. package/dist/core/constants.cjs +0 -28
  193. package/dist/core/constants.d.ts +0 -94
  194. package/dist/core/constants.mjs +0 -21
  195. package/dist/core/filesystem.cjs +0 -98
  196. package/dist/core/filesystem.d.ts +0 -94
  197. package/dist/core/filesystem.mjs +0 -88
  198. package/dist/core/github.cjs +0 -115
  199. package/dist/core/github.d.ts +0 -61
  200. package/dist/core/github.mjs +0 -107
  201. package/dist/core/io.cjs +0 -46
  202. package/dist/core/io.d.ts +0 -40
  203. package/dist/core/io.mjs +0 -39
  204. package/dist/core/listOperations.cjs +0 -228
  205. package/dist/core/listOperations.d.ts +0 -43
  206. package/dist/core/listOperations.mjs +0 -205
  207. package/dist/core/localSource.cjs +0 -126
  208. package/dist/core/localSource.d.ts +0 -33
  209. package/dist/core/localSource.mjs +0 -120
  210. package/dist/core/migration.cjs +0 -201
  211. package/dist/core/migration.d.ts +0 -57
  212. package/dist/core/migration.mjs +0 -198
  213. package/dist/core/packageScanner.cjs +0 -360
  214. package/dist/core/packageScanner.d.ts +0 -22
  215. package/dist/core/packageScanner.mjs +0 -356
  216. package/dist/core/sync.cjs +0 -400
  217. package/dist/core/sync.d.ts +0 -21
  218. package/dist/core/sync.mjs +0 -397
  219. package/dist/core/syncMeta.cjs +0 -242
  220. package/dist/core/syncMeta.d.ts +0 -75
  221. package/dist/core/syncMeta.mjs +0 -229
  222. package/dist/utils/dependencies.cjs +0 -57
  223. package/dist/utils/dependencies.d.ts +0 -10
  224. package/dist/utils/dependencies.mjs +0 -34
  225. package/dist/utils/nameTransform.cjs +0 -13
  226. package/dist/utils/nameTransform.d.ts +0 -65
  227. package/dist/utils/nameTransform.mjs +0 -11
  228. package/dist/utils/package.cjs +0 -170
  229. package/dist/utils/package.d.ts +0 -105
  230. package/dist/utils/package.mjs +0 -157
  231. package/dist/utils/packageName.cjs +0 -24
  232. package/dist/utils/packageName.d.ts +0 -32
  233. package/dist/utils/packageName.mjs +0 -21
  234. package/dist/utils/paths.cjs +0 -18
  235. package/dist/utils/paths.d.ts +0 -55
  236. package/dist/utils/paths.mjs +0 -15
  237. package/dist/version.cjs +0 -5
  238. package/dist/version.d.ts +0 -5
  239. package/dist/version.mjs +0 -3
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import type { TreeNode } from '../../utils/types.js';
3
- export interface AssetTreeNodeProps {
4
- node: TreeNode;
5
- isLastAtDepth: boolean[];
6
- isSelected: boolean;
7
- onToggle: () => void;
8
- }
9
- /**
10
- * Single tree node component for asset selection
11
- */
12
- export declare const AssetTreeNode: React.FC<AssetTreeNodeProps>;
@@ -1,52 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { Box, Text } from 'ink';
3
-
4
- function hasPartialSelection(node) {
5
- if (!node.children || node.children.length === 0) {
6
- return false;
7
- }
8
- const selectedCount = node.children.filter((child) => child.selected).length;
9
- return selectedCount > 0 && selectedCount < node.children.length;
10
- }
11
- function getTreePrefix(isLastAtDepth) {
12
- let prefix = '';
13
- const depth = isLastAtDepth.length;
14
- for (let i = 0; i < depth; i++) {
15
- if (i === depth - 1) {
16
- prefix += isLastAtDepth[i] ? '└─ ' : '├─ ';
17
- }
18
- else {
19
- prefix += isLastAtDepth[i] ? ' ' : '│ ';
20
- }
21
- }
22
- return prefix;
23
- }
24
- const AssetTreeNode = ({ node, isLastAtDepth, isSelected, }) => {
25
- const treePrefix = getTreePrefix(isLastAtDepth);
26
- if (node.disabled) {
27
- return (jsx(Box, { children: jsxs(Text, { color: isSelected ? 'cyan' : undefined, dimColor: !isSelected, children: [treePrefix, node.label] }) }));
28
- }
29
- let selectionIcon;
30
- let iconColor;
31
- if (hasPartialSelection(node)) {
32
- selectionIcon = '◐';
33
- iconColor = 'yellow';
34
- }
35
- else if (node.selected) {
36
- selectionIcon = '◉';
37
- iconColor = 'green';
38
- }
39
- else {
40
- selectionIcon = '○';
41
- iconColor = 'red';
42
- }
43
- const expandIcon = (node.type === 'directory' || node.type === 'skill-directory') &&
44
- node.children
45
- ? node.expanded
46
- ? '▼'
47
- : '▶'
48
- : ' ';
49
- return (jsx(Box, { children: jsxs(Text, { color: isSelected ? 'cyan' : undefined, children: [treePrefix, expandIcon, " ", jsx(Text, { color: iconColor, children: selectionIcon }), " ", node.label] }) }));
50
- };
51
-
52
- export { AssetTreeNode };
@@ -1,129 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var ink = require('ink');
5
- var React = require('react');
6
- var AssetTreeNode = require('./AssetTreeNode.cjs');
7
-
8
- const TreeSelect = ({ trees, onSubmit, onCancel, onRefresh, }) => {
9
- const [selectedIndex, setSelectedIndex] = React.useState(0);
10
- const [treeData, setTreeData] = React.useState(trees);
11
- const flattenTree = (nodes, depth = 0) => {
12
- const result = [];
13
- const traverse = (items, currentDepth, parentPath = [], ancestorIsLast = []) => {
14
- items.forEach((item, index) => {
15
- const isLast = index === items.length - 1;
16
- const currentIsLast = [...ancestorIsLast, isLast];
17
- const currentPath = [...parentPath, index];
18
- result.push({ node: item, depth: currentDepth, path: currentPath, isLastAtDepth: currentIsLast });
19
- if (item.expanded && item.children) {
20
- traverse(item.children, currentDepth + 1, currentPath, currentIsLast);
21
- }
22
- });
23
- };
24
- traverse(nodes, depth);
25
- return result;
26
- };
27
- const flatItems = flattenTree(treeData);
28
- ink.useInput((input, key) => {
29
- if (key.upArrow) {
30
- setSelectedIndex((prev) => Math.max(0, prev - 1));
31
- }
32
- else if (key.downArrow) {
33
- setSelectedIndex((prev) => Math.min(flatItems.length - 1, prev + 1));
34
- }
35
- else if (key.rightArrow) {
36
- const current = flatItems[selectedIndex];
37
- if ((current.node.type === 'directory' || current.node.type === 'skill-directory') &&
38
- !current.node.expanded &&
39
- current.node.children) {
40
- const newTrees = updateNodeAtPath(treeData, current.path, (node) => ({
41
- ...node,
42
- expanded: true,
43
- }));
44
- setTreeData(newTrees);
45
- }
46
- }
47
- else if (key.leftArrow) {
48
- const current = flatItems[selectedIndex];
49
- if ((current.node.type === 'directory' || current.node.type === 'skill-directory') &&
50
- current.node.expanded) {
51
- const newTrees = updateNodeAtPath(treeData, current.path, (node) => ({
52
- ...node,
53
- expanded: false,
54
- }));
55
- setTreeData(newTrees);
56
- }
57
- }
58
- else if (input === ' ') {
59
- const current = flatItems[selectedIndex];
60
- if (current.node.disabled) {
61
- return;
62
- }
63
- const newTrees = toggleNodeSelection(treeData, current.path);
64
- setTreeData(newTrees);
65
- }
66
- else if (input === 'r' && onRefresh) {
67
- onRefresh();
68
- }
69
- else if (key.return) {
70
- onSubmit(treeData);
71
- }
72
- else if (key.escape || input === 'q') {
73
- onCancel();
74
- }
75
- });
76
- return (jsxRuntime.jsx(ink.Box, { flexDirection: "column", children: flatItems.map((item, index) => (jsxRuntime.jsx(AssetTreeNode.AssetTreeNode, { node: item.node, isLastAtDepth: item.isLastAtDepth, isSelected: index === selectedIndex, onToggle: () => {
77
- const newTrees = toggleNodeSelection(treeData, item.path);
78
- setTreeData(newTrees);
79
- } }, item.path.join('-')))) }));
80
- };
81
- function updateNodeAtPath(trees, path, updater) {
82
- if (path.length === 0)
83
- return trees;
84
- const [index, ...rest] = path;
85
- const newTrees = [...trees];
86
- if (rest.length === 0) {
87
- newTrees[index] = updater(newTrees[index]);
88
- }
89
- else if (newTrees[index].children) {
90
- newTrees[index] = {
91
- ...newTrees[index],
92
- children: updateNodeAtPath(newTrees[index].children, rest, updater),
93
- };
94
- }
95
- return newTrees;
96
- }
97
- function toggleNodeSelection(trees, path) {
98
- const updatedTrees = updateNodeAtPath(trees, path, (node) => {
99
- const newSelected = !node.selected;
100
- return toggleNodeAndChildren(node, newSelected);
101
- });
102
- return updateAncestors(updatedTrees, path);
103
- }
104
- function toggleNodeAndChildren(node, selected) {
105
- const newNode = { ...node, selected };
106
- if (node.children) {
107
- newNode.children = node.children.map((child) => toggleNodeAndChildren(child, selected));
108
- }
109
- return newNode;
110
- }
111
- function updateAncestors(trees, path) {
112
- if (path.length <= 1) {
113
- return trees;
114
- }
115
- const parentPath = path.slice(0, -1);
116
- const updatedTrees = updateNodeAtPath(trees, parentPath, (parentNode) => {
117
- if (!parentNode.children || parentNode.children.length === 0) {
118
- return parentNode;
119
- }
120
- const anySelected = parentNode.children.some((child) => child.selected);
121
- return {
122
- ...parentNode,
123
- selected: anySelected,
124
- };
125
- });
126
- return updateAncestors(updatedTrees, parentPath);
127
- }
128
-
129
- exports.TreeSelect = TreeSelect;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import type { TreeNode } from '../../utils/types.js';
3
- export interface TreeSelectProps {
4
- trees: TreeNode[];
5
- onSubmit: (trees: TreeNode[]) => void;
6
- onCancel: () => void;
7
- onRefresh?: () => void;
8
- }
9
- /**
10
- * Interactive tree selection component
11
- */
12
- export declare const TreeSelect: React.FC<TreeSelectProps>;
@@ -1,127 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useInput, Box } from 'ink';
3
- import { useState } from 'react';
4
- import { AssetTreeNode } from './AssetTreeNode.mjs';
5
-
6
- const TreeSelect = ({ trees, onSubmit, onCancel, onRefresh, }) => {
7
- const [selectedIndex, setSelectedIndex] = useState(0);
8
- const [treeData, setTreeData] = useState(trees);
9
- const flattenTree = (nodes, depth = 0) => {
10
- const result = [];
11
- const traverse = (items, currentDepth, parentPath = [], ancestorIsLast = []) => {
12
- items.forEach((item, index) => {
13
- const isLast = index === items.length - 1;
14
- const currentIsLast = [...ancestorIsLast, isLast];
15
- const currentPath = [...parentPath, index];
16
- result.push({ node: item, depth: currentDepth, path: currentPath, isLastAtDepth: currentIsLast });
17
- if (item.expanded && item.children) {
18
- traverse(item.children, currentDepth + 1, currentPath, currentIsLast);
19
- }
20
- });
21
- };
22
- traverse(nodes, depth);
23
- return result;
24
- };
25
- const flatItems = flattenTree(treeData);
26
- useInput((input, key) => {
27
- if (key.upArrow) {
28
- setSelectedIndex((prev) => Math.max(0, prev - 1));
29
- }
30
- else if (key.downArrow) {
31
- setSelectedIndex((prev) => Math.min(flatItems.length - 1, prev + 1));
32
- }
33
- else if (key.rightArrow) {
34
- const current = flatItems[selectedIndex];
35
- if ((current.node.type === 'directory' || current.node.type === 'skill-directory') &&
36
- !current.node.expanded &&
37
- current.node.children) {
38
- const newTrees = updateNodeAtPath(treeData, current.path, (node) => ({
39
- ...node,
40
- expanded: true,
41
- }));
42
- setTreeData(newTrees);
43
- }
44
- }
45
- else if (key.leftArrow) {
46
- const current = flatItems[selectedIndex];
47
- if ((current.node.type === 'directory' || current.node.type === 'skill-directory') &&
48
- current.node.expanded) {
49
- const newTrees = updateNodeAtPath(treeData, current.path, (node) => ({
50
- ...node,
51
- expanded: false,
52
- }));
53
- setTreeData(newTrees);
54
- }
55
- }
56
- else if (input === ' ') {
57
- const current = flatItems[selectedIndex];
58
- if (current.node.disabled) {
59
- return;
60
- }
61
- const newTrees = toggleNodeSelection(treeData, current.path);
62
- setTreeData(newTrees);
63
- }
64
- else if (input === 'r' && onRefresh) {
65
- onRefresh();
66
- }
67
- else if (key.return) {
68
- onSubmit(treeData);
69
- }
70
- else if (key.escape || input === 'q') {
71
- onCancel();
72
- }
73
- });
74
- return (jsx(Box, { flexDirection: "column", children: flatItems.map((item, index) => (jsx(AssetTreeNode, { node: item.node, isLastAtDepth: item.isLastAtDepth, isSelected: index === selectedIndex, onToggle: () => {
75
- const newTrees = toggleNodeSelection(treeData, item.path);
76
- setTreeData(newTrees);
77
- } }, item.path.join('-')))) }));
78
- };
79
- function updateNodeAtPath(trees, path, updater) {
80
- if (path.length === 0)
81
- return trees;
82
- const [index, ...rest] = path;
83
- const newTrees = [...trees];
84
- if (rest.length === 0) {
85
- newTrees[index] = updater(newTrees[index]);
86
- }
87
- else if (newTrees[index].children) {
88
- newTrees[index] = {
89
- ...newTrees[index],
90
- children: updateNodeAtPath(newTrees[index].children, rest, updater),
91
- };
92
- }
93
- return newTrees;
94
- }
95
- function toggleNodeSelection(trees, path) {
96
- const updatedTrees = updateNodeAtPath(trees, path, (node) => {
97
- const newSelected = !node.selected;
98
- return toggleNodeAndChildren(node, newSelected);
99
- });
100
- return updateAncestors(updatedTrees, path);
101
- }
102
- function toggleNodeAndChildren(node, selected) {
103
- const newNode = { ...node, selected };
104
- if (node.children) {
105
- newNode.children = node.children.map((child) => toggleNodeAndChildren(child, selected));
106
- }
107
- return newNode;
108
- }
109
- function updateAncestors(trees, path) {
110
- if (path.length <= 1) {
111
- return trees;
112
- }
113
- const parentPath = path.slice(0, -1);
114
- const updatedTrees = updateNodeAtPath(trees, parentPath, (parentNode) => {
115
- if (!parentNode.children || parentNode.children.length === 0) {
116
- return parentNode;
117
- }
118
- const anySelected = parentNode.children.some((child) => child.selected);
119
- return {
120
- ...parentNode,
121
- selected: anySelected,
122
- };
123
- });
124
- return updateAncestors(updatedTrees, parentPath);
125
- }
126
-
127
- export { TreeSelect };
@@ -1,4 +0,0 @@
1
- export { TreeSelect } from './TreeSelect.js';
2
- export { AssetTreeNode } from './AssetTreeNode.js';
3
- export type { TreeSelectProps } from './TreeSelect.js';
4
- export type { AssetTreeNodeProps } from './AssetTreeNode.js';
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- require('node:fs');
4
- require('node:path');
5
-
6
- const DEFAULT_ASSET_STRUCTURES = {
7
- commands: 'nested',
8
- skills: 'flat',
9
- agents: 'flat',
10
- };
11
- function getAssetStructure(assetType, config) {
12
- if (!config) {
13
- return DEFAULT_ASSET_STRUCTURES[assetType] || 'flat';
14
- }
15
- let assetsConfig;
16
- if ('assetPath' in config) {
17
- assetsConfig = config
18
- .assets;
19
- }
20
- else {
21
- assetsConfig = config;
22
- }
23
- if (assetsConfig?.[assetType]?.structure) {
24
- return assetsConfig[assetType].structure;
25
- }
26
- return DEFAULT_ASSET_STRUCTURES[assetType] || 'nested';
27
- }
28
-
29
- exports.DEFAULT_ASSET_STRUCTURES = DEFAULT_ASSET_STRUCTURES;
30
- exports.getAssetStructure = getAssetStructure;
@@ -1,36 +0,0 @@
1
- import type { AssetStructure, AssetsConfig } from '../utils/types.js';
2
- import { DEFAULT_ASSET_TYPES } from './constants.js';
3
- export { DEFAULT_ASSET_TYPES };
4
- /**
5
- * Default structure configuration for built-in asset types
6
- */
7
- export declare const DEFAULT_ASSET_STRUCTURES: Record<string, AssetStructure>;
8
- /**
9
- * Get the structure type for a given asset type
10
- * @param assetType - The asset type to query
11
- * @param config - Optional ClaudeConfig or AssetsConfig
12
- * @returns The structure type ('nested' or 'flat')
13
- */
14
- export declare function getAssetStructure(assetType: string, config?: AssetsConfig | {
15
- assetPath: string;
16
- assets?: AssetsConfig;
17
- }): AssetStructure;
18
- /**
19
- * Detect the structure type of an asset directory
20
- * @param dir - Directory path to check
21
- * @returns Structure type ('flat' | 'nested') or null if directory doesn't exist
22
- */
23
- export declare function detectStructureType(dir: string): AssetStructure | null;
24
- /**
25
- * Validate that an asset structure value is valid
26
- * @param structure - Structure value to validate
27
- * @returns True if valid, false otherwise
28
- */
29
- export declare function validateAssetStructure(structure: unknown): structure is AssetStructure;
30
- /**
31
- * Validate and normalize asset structure value
32
- * @param structure - Structure value to normalize
33
- * @param defaultValue - Default value if validation fails
34
- * @returns Validated structure or default
35
- */
36
- export declare function normalizeAssetStructure(structure: unknown, defaultValue?: AssetStructure): AssetStructure;
@@ -1,27 +0,0 @@
1
- import 'node:fs';
2
- import 'node:path';
3
-
4
- const DEFAULT_ASSET_STRUCTURES = {
5
- commands: 'nested',
6
- skills: 'flat',
7
- agents: 'flat',
8
- };
9
- function getAssetStructure(assetType, config) {
10
- if (!config) {
11
- return DEFAULT_ASSET_STRUCTURES[assetType] || 'flat';
12
- }
13
- let assetsConfig;
14
- if ('assetPath' in config) {
15
- assetsConfig = config
16
- .assets;
17
- }
18
- else {
19
- assetsConfig = config;
20
- }
21
- if (assetsConfig?.[assetType]?.structure) {
22
- return assetsConfig[assetType].structure;
23
- }
24
- return DEFAULT_ASSET_STRUCTURES[assetType] || 'nested';
25
- }
26
-
27
- export { DEFAULT_ASSET_STRUCTURES, getAssetStructure };
package/dist/core/cli.cjs DELETED
@@ -1,106 +0,0 @@
1
- 'use strict';
2
-
3
- var commander = require('commander');
4
- var sync = require('../commands/sync.cjs');
5
- var list = require('../commands/list.cjs');
6
- var remove = require('../commands/remove.cjs');
7
- var status = require('../commands/status.cjs');
8
- var migrate = require('../commands/migrate.cjs');
9
- var add = require('../commands/add.cjs');
10
- var update = require('../commands/update.cjs');
11
- var version = require('../version.cjs');
12
-
13
- const createProgram = () => {
14
- const program = new commander.Command();
15
- program
16
- .name('claude-assets-sync')
17
- .description('Sync Claude commands and skills from npm packages to your project')
18
- .version(version.VERSION);
19
- program
20
- .command('sync', { isDefault: true })
21
- .description('Sync Claude assets from npm packages')
22
- .option('-p, --package <name>', 'Package name to sync (can be specified multiple times)', (value, previous) => [...previous, value], [])
23
- .option('-f, --force', 'Force sync even if version matches', false)
24
- .option('--dry-run', 'Preview changes without writing files', false)
25
- .option('-l, --local', 'Read packages from local workspace instead of node_modules', false)
26
- .option('-r, --ref <ref>', 'Git ref (branch, tag, or commit) to fetch from (overrides version tag)')
27
- .option('--no-flat', 'Use legacy nested directory structure instead of flat structure (default: flat)')
28
- .action(async (opts) => {
29
- await sync.runSyncCommand({
30
- package: opts.package,
31
- force: opts.force,
32
- dryRun: opts.dryRun,
33
- local: opts.local,
34
- ref: opts.ref,
35
- flat: opts.flat,
36
- });
37
- });
38
- program
39
- .command('add')
40
- .description('Add a package with interactive asset selection')
41
- .option('-p, --package <name>', 'Package name to add')
42
- .option('--pattern <regex>', 'Regex pattern to bulk add matching packages')
43
- .option('-l, --local', 'Read packages from local workspace instead of node_modules', false)
44
- .option('-r, --ref <ref>', 'Git ref (branch, tag, or commit) to fetch from')
45
- .action(async (opts) => {
46
- await add.runAddCommand({
47
- package: opts.package,
48
- pattern: opts.pattern,
49
- local: opts.local,
50
- ref: opts.ref,
51
- });
52
- });
53
- list.registerListCommand(program);
54
- program
55
- .command('remove')
56
- .description('Remove a synced package')
57
- .requiredOption('-p, --package <name>', 'Package name to remove')
58
- .option('-y, --yes', 'Skip confirmation prompt')
59
- .option('--dry-run', 'Preview changes without removing files')
60
- .action(async (opts) => {
61
- await remove.runRemoveCommand({
62
- package: opts.package,
63
- yes: opts.yes,
64
- dryRun: opts.dryRun,
65
- });
66
- });
67
- program
68
- .command('status')
69
- .description('Show sync status of all packages')
70
- .option('--no-remote', 'Skip remote version check')
71
- .action(async (opts) => {
72
- await status.runStatusCommand({ noRemote: !opts.remote });
73
- });
74
- program
75
- .command('migrate')
76
- .description('Migrate from legacy nested structure to flat structure')
77
- .option('--dry-run', 'Preview migration without making changes')
78
- .action(async (opts) => {
79
- await migrate.runMigrateCommand({ dryRun: opts.dryRun });
80
- });
81
- program
82
- .command('update')
83
- .description('Update package metadata in .sync-meta.json')
84
- .option('-p, --package <name>', 'Package name to update (default: all)')
85
- .option('-l, --local', 'Read packages from local workspace instead of node_modules', false)
86
- .option('-r, --ref <ref>', 'Git ref (branch, tag, or commit) to fetch from')
87
- .option('--dry-run', 'Preview changes without writing files', false)
88
- .option('--sync', 'Re-sync files after updating metadata', false)
89
- .action(async (opts) => {
90
- await update.runUpdateCommand({
91
- package: opts.package,
92
- local: opts.local,
93
- ref: opts.ref,
94
- dryRun: opts.dryRun,
95
- sync: opts.sync,
96
- });
97
- });
98
- return program;
99
- };
100
- const run = async () => {
101
- const program = createProgram();
102
- await program.parseAsync(process.argv);
103
- };
104
-
105
- exports.createProgram = createProgram;
106
- exports.run = run;
@@ -1,9 +0,0 @@
1
- import { Command } from 'commander';
2
- /**
3
- * Create and configure the CLI program
4
- */
5
- export declare const createProgram: () => Command;
6
- /**
7
- * Run the CLI
8
- */
9
- export declare const run: () => Promise<void>;
package/dist/core/cli.mjs DELETED
@@ -1,103 +0,0 @@
1
- import { Command } from 'commander';
2
- import { runSyncCommand } from '../commands/sync.mjs';
3
- import { registerListCommand } from '../commands/list.mjs';
4
- import { runRemoveCommand } from '../commands/remove.mjs';
5
- import { runStatusCommand } from '../commands/status.mjs';
6
- import { runMigrateCommand } from '../commands/migrate.mjs';
7
- import { runAddCommand } from '../commands/add.mjs';
8
- import { runUpdateCommand } from '../commands/update.mjs';
9
- import { VERSION } from '../version.mjs';
10
-
11
- const createProgram = () => {
12
- const program = new Command();
13
- program
14
- .name('claude-assets-sync')
15
- .description('Sync Claude commands and skills from npm packages to your project')
16
- .version(VERSION);
17
- program
18
- .command('sync', { isDefault: true })
19
- .description('Sync Claude assets from npm packages')
20
- .option('-p, --package <name>', 'Package name to sync (can be specified multiple times)', (value, previous) => [...previous, value], [])
21
- .option('-f, --force', 'Force sync even if version matches', false)
22
- .option('--dry-run', 'Preview changes without writing files', false)
23
- .option('-l, --local', 'Read packages from local workspace instead of node_modules', false)
24
- .option('-r, --ref <ref>', 'Git ref (branch, tag, or commit) to fetch from (overrides version tag)')
25
- .option('--no-flat', 'Use legacy nested directory structure instead of flat structure (default: flat)')
26
- .action(async (opts) => {
27
- await runSyncCommand({
28
- package: opts.package,
29
- force: opts.force,
30
- dryRun: opts.dryRun,
31
- local: opts.local,
32
- ref: opts.ref,
33
- flat: opts.flat,
34
- });
35
- });
36
- program
37
- .command('add')
38
- .description('Add a package with interactive asset selection')
39
- .option('-p, --package <name>', 'Package name to add')
40
- .option('--pattern <regex>', 'Regex pattern to bulk add matching packages')
41
- .option('-l, --local', 'Read packages from local workspace instead of node_modules', false)
42
- .option('-r, --ref <ref>', 'Git ref (branch, tag, or commit) to fetch from')
43
- .action(async (opts) => {
44
- await runAddCommand({
45
- package: opts.package,
46
- pattern: opts.pattern,
47
- local: opts.local,
48
- ref: opts.ref,
49
- });
50
- });
51
- registerListCommand(program);
52
- program
53
- .command('remove')
54
- .description('Remove a synced package')
55
- .requiredOption('-p, --package <name>', 'Package name to remove')
56
- .option('-y, --yes', 'Skip confirmation prompt')
57
- .option('--dry-run', 'Preview changes without removing files')
58
- .action(async (opts) => {
59
- await runRemoveCommand({
60
- package: opts.package,
61
- yes: opts.yes,
62
- dryRun: opts.dryRun,
63
- });
64
- });
65
- program
66
- .command('status')
67
- .description('Show sync status of all packages')
68
- .option('--no-remote', 'Skip remote version check')
69
- .action(async (opts) => {
70
- await runStatusCommand({ noRemote: !opts.remote });
71
- });
72
- program
73
- .command('migrate')
74
- .description('Migrate from legacy nested structure to flat structure')
75
- .option('--dry-run', 'Preview migration without making changes')
76
- .action(async (opts) => {
77
- await runMigrateCommand({ dryRun: opts.dryRun });
78
- });
79
- program
80
- .command('update')
81
- .description('Update package metadata in .sync-meta.json')
82
- .option('-p, --package <name>', 'Package name to update (default: all)')
83
- .option('-l, --local', 'Read packages from local workspace instead of node_modules', false)
84
- .option('-r, --ref <ref>', 'Git ref (branch, tag, or commit) to fetch from')
85
- .option('--dry-run', 'Preview changes without writing files', false)
86
- .option('--sync', 'Re-sync files after updating metadata', false)
87
- .action(async (opts) => {
88
- await runUpdateCommand({
89
- package: opts.package,
90
- local: opts.local,
91
- ref: opts.ref,
92
- dryRun: opts.dryRun,
93
- sync: opts.sync,
94
- });
95
- });
96
- return program;
97
- };
98
- const run = async () => {
99
- const program = createProgram();
100
- await program.parseAsync(process.argv);
101
- };
102
-
103
- export { createProgram, run };