@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,75 +0,0 @@
1
- import type { PackageSyncInfo, SkillUnit, UnifiedSyncMeta } from '../utils/types.js';
2
- /**
3
- * Schema version for the unified metadata format
4
- */
5
- export declare const SCHEMA_VERSION: "0.1.4";
6
- /**
7
- * Read unified sync metadata from .claude/.sync-meta.json
8
- *
9
- * @param cwd - Project root directory
10
- * @returns Unified metadata object or null if file doesn't exist
11
- */
12
- export declare function readUnifiedSyncMeta(cwd: string): UnifiedSyncMeta | null;
13
- /**
14
- * Write unified sync metadata to .claude/.sync-meta.json
15
- *
16
- * @param cwd - Project root directory
17
- * @param meta - Unified metadata to write
18
- */
19
- export declare function writeUnifiedSyncMeta(cwd: string, meta: UnifiedSyncMeta): void;
20
- /**
21
- * Update or add package information in unified metadata
22
- *
23
- * @param meta - Current unified metadata
24
- * @param prefix - Package prefix (e.g., 'canard-schema-form')
25
- * @param info - Package sync information to store
26
- * @returns Updated metadata object
27
- */
28
- export declare function updatePackageInMeta(meta: UnifiedSyncMeta, prefix: string, info: PackageSyncInfo): UnifiedSyncMeta;
29
- /**
30
- * Remove package from unified metadata
31
- *
32
- * @param meta - Current unified metadata
33
- * @param prefix - Package prefix to remove
34
- * @returns Updated metadata object
35
- */
36
- export declare function removePackageFromMeta(meta: UnifiedSyncMeta, prefix: string): UnifiedSyncMeta;
37
- /**
38
- * Check if package needs sync based on version comparison
39
- *
40
- * @param meta - Current unified metadata (null if no metadata exists)
41
- * @param prefix - Package prefix to check
42
- * @param version - Current package version
43
- * @returns true if sync is needed (no metadata, no package entry, or version mismatch)
44
- */
45
- export declare function needsSyncUnified(meta: UnifiedSyncMeta | null, prefix: string, version: string): boolean;
46
- /**
47
- * Create empty unified metadata structure
48
- *
49
- * @returns New empty unified metadata object
50
- */
51
- export declare function createEmptyUnifiedMeta(): UnifiedSyncMeta;
52
- /**
53
- * Add a skill unit to a package's asset type in unified metadata
54
- */
55
- export declare function addSkillUnitToPackage(meta: UnifiedSyncMeta, prefix: string, assetType: string, unit: SkillUnit): UnifiedSyncMeta;
56
- /**
57
- * Remove a skill unit from a package's asset type in unified metadata
58
- */
59
- export declare function removeSkillUnitFromPackage(meta: UnifiedSyncMeta, prefix: string, assetType: string, skillName: string): UnifiedSyncMeta;
60
- /**
61
- * Update package version in unified metadata
62
- */
63
- export declare function updatePackageVersion(meta: UnifiedSyncMeta, prefix: string, newVersion: string): UnifiedSyncMeta;
64
- /**
65
- * Update filesystem metadata for a package's asset type
66
- */
67
- export declare function updatePackageFilesystemMeta(meta: UnifiedSyncMeta, prefix: string, assetType: string, updatedUnits: SkillUnit[]): UnifiedSyncMeta;
68
- /**
69
- * Check if unified metadata needs migration to SkillUnit format
70
- */
71
- export declare function needsSkillUnitMigration(meta: UnifiedSyncMeta): boolean;
72
- /**
73
- * Migrate unified metadata from old format to SkillUnit format (in-memory only)
74
- */
75
- export declare function migrateToSkillUnitSchema(meta: UnifiedSyncMeta): UnifiedSyncMeta;
@@ -1,229 +0,0 @@
1
- import { join } from 'node:path';
2
- import { needsVersionSync } from '../utils/version.mjs';
3
- import { META_FILES, SCHEMA_VERSIONS } from './constants.mjs';
4
- import { readJsonFile, writeJsonFile } from './io.mjs';
5
-
6
- const UNIFIED_META_PATH = META_FILES.UNIFIED_SYNC_META;
7
- const SCHEMA_VERSION = SCHEMA_VERSIONS.UNIFIED_SYNC_META;
8
- function readUnifiedSyncMeta(cwd) {
9
- const metaPath = join(cwd, UNIFIED_META_PATH);
10
- const meta = readJsonFile(metaPath);
11
- if (meta && needsSkillUnitMigration(meta)) {
12
- return migrateToSkillUnitSchema(meta);
13
- }
14
- return meta;
15
- }
16
- function writeUnifiedSyncMeta(cwd, meta) {
17
- const metaPath = join(cwd, UNIFIED_META_PATH);
18
- try {
19
- writeJsonFile(metaPath, meta);
20
- }
21
- catch (error) {
22
- console.error(`Failed to write unified sync meta to ${metaPath}:`, error);
23
- throw error;
24
- }
25
- }
26
- function updatePackageInMeta(meta, prefix, info) {
27
- return {
28
- ...meta,
29
- syncedAt: new Date().toISOString(),
30
- packages: {
31
- ...meta.packages,
32
- [prefix]: info,
33
- },
34
- };
35
- }
36
- function removePackageFromMeta(meta, prefix) {
37
- const { [prefix]: removed, ...remainingPackages } = meta.packages;
38
- return {
39
- ...meta,
40
- packages: remainingPackages,
41
- };
42
- }
43
- function needsSyncUnified(meta, prefix, version) {
44
- if (!meta) {
45
- return true;
46
- }
47
- const pkgInfo = meta.packages[prefix];
48
- if (!pkgInfo) {
49
- return true;
50
- }
51
- return needsVersionSync(version, pkgInfo.version);
52
- }
53
- function createEmptyUnifiedMeta() {
54
- return {
55
- schemaVersion: SCHEMA_VERSION,
56
- syncedAt: new Date().toISOString(),
57
- packages: {},
58
- };
59
- }
60
- function removeSkillUnitFromPackage(meta, prefix, assetType, skillName) {
61
- const pkgInfo = meta.packages[prefix];
62
- if (!pkgInfo) {
63
- throw new Error(`Package ${prefix} not found in metadata`);
64
- }
65
- const existingUnits = (pkgInfo.files[assetType] || []);
66
- const updatedUnits = existingUnits.filter((u) => u.name !== skillName);
67
- if (existingUnits.length === updatedUnits.length) {
68
- return meta;
69
- }
70
- return {
71
- ...meta,
72
- syncedAt: new Date().toISOString(),
73
- packages: {
74
- ...meta.packages,
75
- [prefix]: {
76
- ...pkgInfo,
77
- files: {
78
- ...pkgInfo.files,
79
- [assetType]: updatedUnits,
80
- },
81
- },
82
- },
83
- };
84
- }
85
- function updatePackageVersion(meta, prefix, newVersion) {
86
- const pkgInfo = meta.packages[prefix];
87
- if (!pkgInfo) {
88
- throw new Error(`Package ${prefix} not found in metadata`);
89
- }
90
- return {
91
- ...meta,
92
- syncedAt: new Date().toISOString(),
93
- packages: {
94
- ...meta.packages,
95
- [prefix]: {
96
- ...pkgInfo,
97
- version: newVersion,
98
- },
99
- },
100
- };
101
- }
102
- function updatePackageFilesystemMeta(meta, prefix, assetType, updatedUnits) {
103
- const pkgInfo = meta.packages[prefix];
104
- if (!pkgInfo) {
105
- throw new Error(`Package ${prefix} not found in metadata`);
106
- }
107
- return {
108
- ...meta,
109
- syncedAt: new Date().toISOString(),
110
- skillUnitFormat: SCHEMA_VERSIONS.SKILL_UNIT_FORMAT,
111
- packages: {
112
- ...meta.packages,
113
- [prefix]: {
114
- ...pkgInfo,
115
- files: {
116
- ...pkgInfo.files,
117
- [assetType]: updatedUnits,
118
- },
119
- },
120
- },
121
- };
122
- }
123
- function needsSkillUnitMigration(meta) {
124
- if (meta.skillUnitFormat === SCHEMA_VERSIONS.SKILL_UNIT_FORMAT) {
125
- return false;
126
- }
127
- for (const pkgInfo of Object.values(meta.packages)) {
128
- for (const rawFiles of Object.values(pkgInfo.files)) {
129
- const files = rawFiles;
130
- if (!Array.isArray(files) || files.length === 0) {
131
- continue;
132
- }
133
- const first = files[0];
134
- if (typeof first === 'string') {
135
- return true;
136
- }
137
- if (typeof first === 'object' &&
138
- first !== null &&
139
- 'original' in first &&
140
- 'transformed' in first &&
141
- !('isDirectory' in first)) {
142
- return true;
143
- }
144
- if (typeof first === 'object' &&
145
- first !== null &&
146
- 'isDirectory' in first) {
147
- return false;
148
- }
149
- }
150
- }
151
- return false;
152
- }
153
- function migrateToSkillUnitSchema(meta) {
154
- const migratedPackages = {};
155
- for (const [prefix, pkgInfo] of Object.entries(meta.packages)) {
156
- const migratedFiles = {};
157
- for (const [assetType, rawFiles] of Object.entries(pkgInfo.files)) {
158
- const files = rawFiles;
159
- if (!Array.isArray(files) || files.length === 0) {
160
- migratedFiles[assetType] = [];
161
- continue;
162
- }
163
- const first = files[0];
164
- if (typeof first === 'string') {
165
- migratedFiles[assetType] = files.map((name) => ({
166
- name,
167
- isDirectory: false,
168
- }));
169
- }
170
- else if (typeof first === 'object' &&
171
- first !== null &&
172
- 'original' in first &&
173
- !('isDirectory' in first)) {
174
- const fileMappings = files;
175
- const groupedByDir = new Map();
176
- const singleFiles = [];
177
- for (const mapping of fileMappings) {
178
- const slashIndex = mapping.original.indexOf('/');
179
- if (slashIndex === -1) {
180
- singleFiles.push({
181
- name: mapping.original,
182
- isDirectory: false,
183
- transformed: mapping.transformed,
184
- });
185
- }
186
- else {
187
- const dirName = mapping.original.substring(0, slashIndex);
188
- const internalFile = mapping.original.substring(slashIndex + 1);
189
- const transformedSlashIndex = mapping.transformed.indexOf('/');
190
- const transformedDir = transformedSlashIndex !== -1
191
- ? mapping.transformed.substring(0, transformedSlashIndex)
192
- : mapping.transformed;
193
- if (!groupedByDir.has(dirName)) {
194
- groupedByDir.set(dirName, {
195
- transformed: transformedDir,
196
- internalFiles: [],
197
- });
198
- }
199
- groupedByDir.get(dirName).internalFiles.push(internalFile);
200
- }
201
- }
202
- const dirSkillUnits = [];
203
- for (const [dirName, data] of groupedByDir.entries()) {
204
- dirSkillUnits.push({
205
- name: dirName,
206
- isDirectory: true,
207
- transformed: data.transformed,
208
- internalFiles: data.internalFiles,
209
- });
210
- }
211
- migratedFiles[assetType] = [...singleFiles, ...dirSkillUnits];
212
- }
213
- else {
214
- migratedFiles[assetType] = files;
215
- }
216
- }
217
- migratedPackages[prefix] = {
218
- ...pkgInfo,
219
- files: migratedFiles,
220
- };
221
- }
222
- return {
223
- ...meta,
224
- skillUnitFormat: SCHEMA_VERSIONS.SKILL_UNIT_FORMAT,
225
- packages: migratedPackages,
226
- };
227
- }
228
-
229
- export { SCHEMA_VERSION, createEmptyUnifiedMeta, migrateToSkillUnitSchema, needsSkillUnitMigration, needsSyncUnified, readUnifiedSyncMeta, removePackageFromMeta, removeSkillUnitFromPackage, updatePackageFilesystemMeta, updatePackageInMeta, updatePackageVersion, writeUnifiedSyncMeta };
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('node:fs');
4
- var path = require('node:path');
5
-
6
- function _interopNamespaceDefault(e) {
7
- var n = Object.create(null);
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- if (k !== 'default') {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
16
- }
17
- });
18
- }
19
- n.default = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
24
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
25
-
26
- function readProjectDependencies(cwd) {
27
- const pkgPath = path__namespace.join(cwd, 'package.json');
28
- if (!fs__namespace.existsSync(pkgPath)) {
29
- throw new Error(`package.json not found at: ${pkgPath}`);
30
- }
31
- let pkg;
32
- try {
33
- pkg = JSON.parse(fs__namespace.readFileSync(pkgPath, 'utf-8'));
34
- }
35
- catch (error) {
36
- throw new Error(`Failed to parse package.json at ${pkgPath}: ${error instanceof Error ? error.message : String(error)}`);
37
- }
38
- return {
39
- ...pkg.dependencies,
40
- ...pkg.devDependencies,
41
- ...pkg.peerDependencies,
42
- ...pkg.optionalDependencies,
43
- };
44
- }
45
- function filterByPattern(deps, pattern) {
46
- let regex;
47
- try {
48
- regex = new RegExp(pattern);
49
- }
50
- catch (error) {
51
- throw new Error(`Invalid regex pattern "${pattern}": ${error instanceof Error ? error.message : String(error)}`);
52
- }
53
- return Object.keys(deps).filter(name => regex.test(name));
54
- }
55
-
56
- exports.filterByPattern = filterByPattern;
57
- exports.readProjectDependencies = readProjectDependencies;
@@ -1,10 +0,0 @@
1
- /**
2
- * Reads all dependencies from the project's package.json
3
- * (dependencies, devDependencies, peerDependencies, optionalDependencies)
4
- */
5
- export declare function readProjectDependencies(cwd: string): Record<string, string>;
6
- /**
7
- * Filters dependency names by regex pattern.
8
- * Wraps RegExp construction in try/catch for invalid patterns.
9
- */
10
- export declare function filterByPattern(deps: Record<string, string>, pattern: string): string[];
@@ -1,34 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as path from 'node:path';
3
-
4
- function readProjectDependencies(cwd) {
5
- const pkgPath = path.join(cwd, 'package.json');
6
- if (!fs.existsSync(pkgPath)) {
7
- throw new Error(`package.json not found at: ${pkgPath}`);
8
- }
9
- let pkg;
10
- try {
11
- pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
12
- }
13
- catch (error) {
14
- throw new Error(`Failed to parse package.json at ${pkgPath}: ${error instanceof Error ? error.message : String(error)}`);
15
- }
16
- return {
17
- ...pkg.dependencies,
18
- ...pkg.devDependencies,
19
- ...pkg.peerDependencies,
20
- ...pkg.optionalDependencies,
21
- };
22
- }
23
- function filterByPattern(deps, pattern) {
24
- let regex;
25
- try {
26
- regex = new RegExp(pattern);
27
- }
28
- catch (error) {
29
- throw new Error(`Invalid regex pattern "${pattern}": ${error instanceof Error ? error.message : String(error)}`);
30
- }
31
- return Object.keys(deps).filter(name => regex.test(name));
32
- }
33
-
34
- export { filterByPattern, readProjectDependencies };
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- function toFlatFileName(prefix, fileName) {
4
- const slashIndex = fileName.indexOf('/');
5
- if (slashIndex === -1) {
6
- return `${prefix}_${fileName}`;
7
- }
8
- const dirName = fileName.substring(0, slashIndex);
9
- const rest = fileName.substring(slashIndex);
10
- return `${prefix}_${dirName}${rest}`;
11
- }
12
-
13
- exports.toFlatFileName = toFlatFileName;
@@ -1,65 +0,0 @@
1
- /**
2
- * Converts kebab-case string to camelCase
3
- * All hyphens are removed and the following character is capitalized
4
- *
5
- * @param str - Input string in kebab-case format
6
- * @returns String in camelCase format
7
- *
8
- * @example
9
- * ```ts
10
- * kebabToCamel('schema-form') // 'schemaForm'
11
- * kebabToCamel('schema-form-plugin') // 'schemaFormPlugin'
12
- * kebabToCamel('my-long-name') // 'myLongName'
13
- * ```
14
- */
15
- export declare function kebabToCamel(str: string): string;
16
- /**
17
- * Creates a flat file name by combining prefix and original file name.
18
- * For single files (no path separator), creates prefix_filename.
19
- * For directory-based entries (with path separator), applies prefix only
20
- * to the top-level directory name, preserving internal path structure.
21
- *
22
- * @param prefix - Package prefix (e.g., 'canard-schemaForm')
23
- * @param fileName - Original file name (e.g., 'guide.md' or 'expert/SKILL.md')
24
- * @returns Flat file name with prefix
25
- *
26
- * @example
27
- * ```ts
28
- * toFlatFileName('canard-schemaForm', 'guide.md')
29
- * // 'canard-schemaForm_guide.md'
30
- *
31
- * toFlatFileName('canard-schemaForm', 'expert/SKILL.md')
32
- * // 'canard-schemaForm_expert/SKILL.md'
33
- *
34
- * toFlatFileName('canard-schemaForm', 'expert/knowledge/api.md')
35
- * // 'canard-schemaForm_expert/knowledge/api.md'
36
- * ```
37
- */
38
- export declare function toFlatFileName(prefix: string, fileName: string): string;
39
- /**
40
- * Parses a flat file name back into prefix and original file name.
41
- * Reverses the transformation done by toFlatFileName.
42
- * Returns null if the file name doesn't match the expected pattern.
43
- *
44
- * @param flatName - Flat file name (e.g., 'canard-schemaForm_guide.md' or 'canard-schemaForm_expert/SKILL.md')
45
- * @returns Object with prefix and original name, or null if invalid
46
- *
47
- * @example
48
- * ```ts
49
- * parseFlatFileName('canard-schemaForm_guide.md')
50
- * // { prefix: 'canard-schemaForm', original: 'guide.md' }
51
- *
52
- * parseFlatFileName('canard-schemaForm_expert/SKILL.md')
53
- * // { prefix: 'canard-schemaForm', original: 'expert/SKILL.md' }
54
- *
55
- * parseFlatFileName('canard-schemaForm_expert/knowledge/api.md')
56
- * // { prefix: 'canard-schemaForm', original: 'expert/knowledge/api.md' }
57
- *
58
- * parseFlatFileName('invalid-name.md')
59
- * // null (no underscore separator)
60
- * ```
61
- */
62
- export declare function parseFlatFileName(flatName: string): {
63
- prefix: string;
64
- original: string;
65
- } | null;
@@ -1,11 +0,0 @@
1
- function toFlatFileName(prefix, fileName) {
2
- const slashIndex = fileName.indexOf('/');
3
- if (slashIndex === -1) {
4
- return `${prefix}_${fileName}`;
5
- }
6
- const dirName = fileName.substring(0, slashIndex);
7
- const rest = fileName.substring(slashIndex);
8
- return `${prefix}_${dirName}${rest}`;
9
- }
10
-
11
- export { toFlatFileName };
@@ -1,170 +0,0 @@
1
- 'use strict';
2
-
3
- var node_child_process = require('node:child_process');
4
- var fs = require('node:fs');
5
- var path = require('node:path');
6
- var constants = require('../core/constants.cjs');
7
-
8
- const resolvePackagePath = (packageName, cwd) => {
9
- let dir = cwd;
10
- while (true) {
11
- const candidate = path.join(dir, 'node_modules', packageName);
12
- if (fs.existsSync(path.join(candidate, 'package.json'))) {
13
- return candidate;
14
- }
15
- const parent = path.dirname(dir);
16
- if (parent === dir)
17
- break;
18
- dir = parent;
19
- }
20
- return null;
21
- };
22
- const readPackageJson = (packageName, cwd = process.cwd()) => {
23
- try {
24
- const packagePath = resolvePackagePath(packageName, cwd);
25
- if (!packagePath)
26
- return null;
27
- const content = fs.readFileSync(path.join(packagePath, 'package.json'), 'utf-8');
28
- const json = JSON.parse(content);
29
- if (!json.name || !json.version || !json.repository)
30
- return null;
31
- return {
32
- name: json.name,
33
- version: json.version,
34
- repository: json.repository,
35
- claude: json.claude,
36
- };
37
- }
38
- catch {
39
- return null;
40
- }
41
- };
42
- const parseGitHubRepo = (repository) => {
43
- if (!repository || typeof repository.url !== 'string')
44
- return null;
45
- const url = repository.url;
46
- const httpsMatch = url.match(constants.FS_PATTERNS.GITHUB_HTTPS_URL);
47
- if (httpsMatch)
48
- return {
49
- owner: httpsMatch[1],
50
- repo: httpsMatch[2],
51
- directory: repository.directory,
52
- };
53
- const sshMatch = url.match(constants.FS_PATTERNS.GITHUB_SSH_URL);
54
- if (sshMatch)
55
- return {
56
- owner: sshMatch[1],
57
- repo: sshMatch[2],
58
- directory: repository.directory,
59
- };
60
- const shorthandMatch = url.match(constants.FS_PATTERNS.GITHUB_SHORTHAND);
61
- if (shorthandMatch)
62
- return {
63
- owner: shorthandMatch[1],
64
- repo: shorthandMatch[2],
65
- directory: repository.directory,
66
- };
67
- return null;
68
- };
69
- const buildVersionTag = (packageName, version) => `${packageName}@${version}`;
70
- const buildAssetPath = (assetPath, directory) => (assetPath);
71
- const findGitRoot = (cwd = process.cwd()) => {
72
- try {
73
- const gitRoot = node_child_process.execSync('git rev-parse --show-toplevel', {
74
- cwd,
75
- encoding: 'utf-8',
76
- stdio: ['pipe', 'pipe', 'pipe'],
77
- }).trim();
78
- return gitRoot;
79
- }
80
- catch {
81
- return null;
82
- }
83
- };
84
- const findWorkspaceRoot = (startDir = process.cwd()) => {
85
- let currentDir = startDir;
86
- while (currentDir !== '/') {
87
- const packageJsonPath = path.join(currentDir, 'package.json');
88
- if (fs.existsSync(packageJsonPath)) {
89
- try {
90
- const content = fs.readFileSync(packageJsonPath, 'utf-8');
91
- const json = JSON.parse(content);
92
- if (json.workspaces)
93
- return currentDir;
94
- }
95
- catch {
96
- }
97
- }
98
- currentDir = path.dirname(currentDir);
99
- }
100
- return null;
101
- };
102
- const getWorkspaceList = (workspaceRoot) => {
103
- try {
104
- const output = node_child_process.execSync('yarn workspaces list --json', {
105
- cwd: workspaceRoot,
106
- encoding: 'utf-8',
107
- stdio: ['pipe', 'pipe', 'pipe'],
108
- });
109
- return output
110
- .trim()
111
- .split('\n')
112
- .filter(Boolean)
113
- .map((line) => JSON.parse(line));
114
- }
115
- catch {
116
- return [];
117
- }
118
- };
119
- const findWorkspaceLocation = (packageName, workspaceRoot) => {
120
- const workspaces = getWorkspaceList(workspaceRoot);
121
- const workspace = workspaces.find((ws) => ws.name === packageName);
122
- return workspace ? path.join(workspaceRoot, workspace.location) : null;
123
- };
124
- const readLocalPackageJson = (packageName, cwd = process.cwd()) => {
125
- try {
126
- const workspaceRoot = findWorkspaceRoot(cwd);
127
- if (!workspaceRoot)
128
- return null;
129
- const packageLocation = findWorkspaceLocation(packageName, workspaceRoot);
130
- if (!packageLocation)
131
- return null;
132
- const packageJsonPath = path.join(packageLocation, 'package.json');
133
- const content = fs.readFileSync(packageJsonPath, 'utf-8');
134
- const json = JSON.parse(content);
135
- if (!json.name || !json.version || !json.repository)
136
- return null;
137
- return {
138
- name: json.name,
139
- version: json.version,
140
- repository: json.repository,
141
- claude: json.claude,
142
- };
143
- }
144
- catch {
145
- return null;
146
- }
147
- };
148
- function getAssetTypes(config) {
149
- if (!config.assets) {
150
- return Array.from(constants.DEFAULT_ASSET_TYPES);
151
- }
152
- return Object.keys(config.assets);
153
- }
154
- const resolveClaudeConfig = (claude) => ({
155
- assetPath: claude?.assetPath ?? constants.DEFAULT_ASSET_PATH,
156
- ...(claude?.assets ? { assets: claude.assets } : {}),
157
- });
158
-
159
- exports.buildAssetPath = buildAssetPath;
160
- exports.buildVersionTag = buildVersionTag;
161
- exports.findGitRoot = findGitRoot;
162
- exports.findWorkspaceLocation = findWorkspaceLocation;
163
- exports.findWorkspaceRoot = findWorkspaceRoot;
164
- exports.getAssetTypes = getAssetTypes;
165
- exports.getWorkspaceList = getWorkspaceList;
166
- exports.parseGitHubRepo = parseGitHubRepo;
167
- exports.readLocalPackageJson = readLocalPackageJson;
168
- exports.readPackageJson = readPackageJson;
169
- exports.resolveClaudeConfig = resolveClaudeConfig;
170
- exports.resolvePackagePath = resolvePackagePath;