@snap/valdi 1.0.11 → 1.1.7

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 (74) hide show
  1. package/.metadata/.bazelrc.template +7 -6
  2. package/.metadata/MODULE.bazel.template +154 -0
  3. package/bundled-skills/registry.json +13 -2
  4. package/bundled-skills/skills/valdi-animations/skill.md +197 -0
  5. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +1 -1
  6. package/bundled-skills/skills/valdi-compiler/skill.md +4 -4
  7. package/bundled-skills/skills/valdi-component-dedup/skill.md +263 -0
  8. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +1 -1
  9. package/bundled-skills/skills/valdi-custom-view/skill.md +43 -1
  10. package/bundled-skills/skills/valdi-error-handling/skill.md +238 -0
  11. package/bundled-skills/skills/valdi-gestures/skill.md +198 -0
  12. package/bundled-skills/skills/valdi-inspect/skill.md +19 -1
  13. package/bundled-skills/skills/valdi-localization/skill.md +142 -0
  14. package/bundled-skills/skills/valdi-mock-breakdown/skill.md +327 -0
  15. package/bundled-skills/skills/valdi-mock-iterate/skill.md +216 -0
  16. package/bundled-skills/skills/valdi-mock-to-module/scripts/diff.py +392 -0
  17. package/bundled-skills/skills/valdi-mock-to-module/scripts/extract_colors.py +277 -0
  18. package/bundled-skills/skills/valdi-mock-to-module/scripts/find_icon.py +303 -0
  19. package/bundled-skills/skills/valdi-mock-to-module/scripts/snapshot-and-diff.sh +53 -0
  20. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_diff.py +207 -0
  21. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_extract_colors.py +167 -0
  22. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_find_icon.py +188 -0
  23. package/bundled-skills/skills/valdi-mock-to-module/scripts/watch-and-diff.sh +181 -0
  24. package/bundled-skills/skills/valdi-mock-to-module/skill.md +451 -0
  25. package/bundled-skills/skills/valdi-navigation/skill.md +187 -0
  26. package/bundled-skills/skills/valdi-overview/skill.md +7 -4
  27. package/bundled-skills/skills/valdi-perf/skill.md +223 -0
  28. package/bundled-skills/skills/valdi-polyglot-module/skill.md +80 -0
  29. package/bundled-skills/skills/valdi-preview/skill.md +303 -0
  30. package/bundled-skills/skills/valdi-setup/skill.md +55 -5
  31. package/bundled-skills/skills/valdi-testing/skill.md +23 -7
  32. package/bundled-skills/skills/valdi-tsx/skill.md +69 -5
  33. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +29 -5
  34. package/dist/commands/agentCheck.js +184 -0
  35. package/dist/commands/analyze.js +16 -0
  36. package/dist/commands/analyze_commands/duplicates.js +134 -0
  37. package/dist/commands/bootstrap.js +57 -73
  38. package/dist/commands/build.js +6 -0
  39. package/dist/commands/doctor.js +42 -266
  40. package/dist/commands/hotreload.js +15 -0
  41. package/dist/commands/inspect_commands/snapshot.js +71 -6
  42. package/dist/commands/inspect_commands/snapshot.spec.js +105 -0
  43. package/dist/commands/install.js +6 -0
  44. package/dist/commands/preview.js +81 -0
  45. package/dist/commands/projectsync.js +9 -7
  46. package/dist/commands/skills_commands/install.js +6 -1
  47. package/dist/commands/skills_commands/update.js +2 -1
  48. package/dist/core/analyze/clusterer.js +150 -0
  49. package/dist/core/analyze/fingerprint.js +2 -0
  50. package/dist/core/analyze/knownPatterns.js +76 -0
  51. package/dist/core/analyze/parser.js +177 -0
  52. package/dist/core/analyze/reporter.js +83 -0
  53. package/dist/core/analyze/scanner.js +172 -0
  54. package/dist/core/analyze/similarity.js +56 -0
  55. package/dist/core/constants.js +6 -3
  56. package/dist/core/packageFiles.spec.js +1 -1
  57. package/dist/preview/previewGenerator.js +240 -0
  58. package/dist/preview/previewGenerator.spec.js +203 -0
  59. package/dist/preview/viewModelParser.js +86 -0
  60. package/dist/preview/viewModelParser.spec.js +171 -0
  61. package/dist/setup/DevSetupHelper.js +0 -54
  62. package/dist/setup/linuxSetup.js +0 -16
  63. package/dist/setup/macOSSetup.js +1 -5
  64. package/dist/utils/BazelClient.js +15 -0
  65. package/dist/utils/applicationUtils.js +15 -0
  66. package/dist/utils/daemonClient.js +3 -1
  67. package/dist/utils/linuxDistro.js +0 -21
  68. package/dist/utils/linuxDistro.spec.js +0 -48
  69. package/dist/utils/skillsAdapters.js +126 -19
  70. package/dist/utils/skillsAdapters.spec.js +141 -0
  71. package/dist/utils/skillsRegistry.js +8 -0
  72. package/package.json +16 -8
  73. package/.metadata/WORKSPACE.template +0 -57
  74. package/dist/setup/versions.js +0 -8
@@ -77,6 +77,9 @@ function getApplicationTargetTagForPlatform(platform) {
77
77
  case constants_1.PLATFORM.MACOS: {
78
78
  return constants_1.MACOS_BAZEL_APPLICATION_TAG;
79
79
  }
80
+ case constants_1.PLATFORM.LINUX: {
81
+ return constants_1.LINUX_BAZEL_APPLICATION_TAG;
82
+ }
80
83
  case constants_1.PLATFORM.CLI: {
81
84
  return constants_1.CLI_BAZEL_APPLICATION_TAG;
82
85
  }
@@ -93,6 +96,9 @@ function getExportedLibraryTargetTagForPlatform(platform) {
93
96
  case constants_1.PLATFORM.MACOS: {
94
97
  throw new errors_1.CliError('Exported library is not yet supported for macOS platform');
95
98
  }
99
+ case constants_1.PLATFORM.LINUX: {
100
+ throw new errors_1.CliError('Exported library is not yet supported for Linux platform');
101
+ }
96
102
  case constants_1.PLATFORM.CLI: {
97
103
  throw new errors_1.CliError('Exported library is not supported for CLI platform');
98
104
  }
@@ -109,6 +115,9 @@ function applicationExtensionForPlatform(platform) {
109
115
  case constants_1.PLATFORM.MACOS: {
110
116
  return '.zip';
111
117
  }
118
+ case constants_1.PLATFORM.LINUX: {
119
+ return '';
120
+ }
112
121
  case constants_1.PLATFORM.CLI: {
113
122
  return '';
114
123
  }
@@ -125,6 +134,9 @@ function exportedLibraryExtensionForPlatform(platform) {
125
134
  case constants_1.PLATFORM.MACOS: {
126
135
  return '.zip';
127
136
  }
137
+ case constants_1.PLATFORM.LINUX: {
138
+ return '.zip';
139
+ }
128
140
  case constants_1.PLATFORM.CLI: {
129
141
  return '.zip';
130
142
  }
@@ -188,6 +200,9 @@ function resolveBazelBuildArgs(platform, buildConfig, architectures, forDevice,
188
200
  else if (platform === constants_1.PLATFORM.MACOS) {
189
201
  allArgs.push(...constants_1.MACOS_BUILD_FLAGS);
190
202
  }
203
+ else if (platform === constants_1.PLATFORM.LINUX) {
204
+ allArgs.push(...constants_1.LINUX_BUILD_FLAGS);
205
+ }
191
206
  if (platform === constants_1.PLATFORM.ANDROID) {
192
207
  allArgs.push(...constants_1.ANDROID_BUILD_FLAGS);
193
208
  for (const architecture of architectures) {
@@ -274,7 +274,9 @@ async function tryAdbForward(port) {
274
274
  }
275
275
  }
276
276
  async function connectToDaemon(port = exports.DEFAULT_PORT) {
277
- await tryAdbForward(port);
277
+ if (port !== exports.STANDALONE_PORT) {
278
+ await tryAdbForward(port);
279
+ }
278
280
  return new Promise((resolve, reject) => {
279
281
  const socket = net.createConnection({ port, host: '127.0.0.1' });
280
282
  const timer = setTimeout(() => {
@@ -5,8 +5,6 @@ exports.detectLinuxDistro = detectLinuxDistro;
5
5
  exports.getPackageName = getPackageName;
6
6
  exports.buildInstallCommand = buildInstallCommand;
7
7
  exports.getCommonPackageMappings = getCommonPackageMappings;
8
- exports.needsGitLfsRepoSetup = needsGitLfsRepoSetup;
9
- exports.getGitLfsRepoSetupCommand = getGitLfsRepoSetupCommand;
10
8
  const tslib_1 = require("tslib");
11
9
  const fs_1 = tslib_1.__importDefault(require("fs"));
12
10
  const cliUtils_1 = require("./cliUtils");
@@ -194,9 +192,6 @@ function getCommonPackageMappings() {
194
192
  git: {
195
193
  unknown: 'git',
196
194
  },
197
- 'git-lfs': {
198
- unknown: 'git-lfs',
199
- },
200
195
  npm: {
201
196
  unknown: 'npm',
202
197
  },
@@ -237,19 +232,3 @@ function getCommonPackageMappings() {
237
232
  },
238
233
  };
239
234
  }
240
- function needsGitLfsRepoSetup(distro = detectLinuxDistro()) {
241
- return distro.type === LinuxDistroType.DEBIAN;
242
- }
243
- function getGitLfsRepoSetupCommand(distro = detectLinuxDistro()) {
244
- switch (distro.type) {
245
- case LinuxDistroType.DEBIAN: {
246
- return 'curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash';
247
- }
248
- case LinuxDistroType.REDHAT: {
249
- return 'curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash';
250
- }
251
- default: {
252
- return null;
253
- }
254
- }
255
- }
@@ -85,58 +85,10 @@ describe('linuxDistro', () => {
85
85
  expect(result).toContain('git, npm');
86
86
  });
87
87
  });
88
- describe('needsGitLfsRepoSetup', () => {
89
- it('returns true for Debian distributions', () => {
90
- const distro = {
91
- type: linuxDistro_1.LinuxDistroType.DEBIAN,
92
- name: 'Ubuntu',
93
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
94
- };
95
- expect((0, linuxDistro_1.needsGitLfsRepoSetup)(distro)).toBe(true);
96
- });
97
- it('returns false for Arch distributions', () => {
98
- const distro = {
99
- type: linuxDistro_1.LinuxDistroType.ARCH,
100
- name: 'Arch Linux',
101
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
102
- };
103
- expect((0, linuxDistro_1.needsGitLfsRepoSetup)(distro)).toBe(false);
104
- });
105
- });
106
- describe('getGitLfsRepoSetupCommand', () => {
107
- it('returns Debian script for Debian distributions', () => {
108
- const distro = {
109
- type: linuxDistro_1.LinuxDistroType.DEBIAN,
110
- name: 'Ubuntu',
111
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
112
- };
113
- const result = (0, linuxDistro_1.getGitLfsRepoSetupCommand)(distro);
114
- expect(result).toContain('script.deb.sh');
115
- });
116
- it('returns RPM script for RedHat distributions', () => {
117
- const distro = {
118
- type: linuxDistro_1.LinuxDistroType.REDHAT,
119
- name: 'Fedora',
120
- packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
121
- };
122
- const result = (0, linuxDistro_1.getGitLfsRepoSetupCommand)(distro);
123
- expect(result).toContain('script.rpm.sh');
124
- });
125
- it('returns null for distributions with git-lfs in standard repos', () => {
126
- const distro = {
127
- type: linuxDistro_1.LinuxDistroType.ARCH,
128
- name: 'Arch Linux',
129
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
130
- };
131
- const result = (0, linuxDistro_1.getGitLfsRepoSetupCommand)(distro);
132
- expect(result).toBeNull();
133
- });
134
- });
135
88
  describe('getCommonPackageMappings', () => {
136
89
  it('returns package mappings for common dependencies', () => {
137
90
  const mappings = (0, linuxDistro_1.getCommonPackageMappings)();
138
91
  expect(mappings['git']).toBeDefined();
139
- expect(mappings['git-lfs']).toBeDefined();
140
92
  expect(mappings['npm']).toBeDefined();
141
93
  expect(mappings['openjdk-17']).toBeDefined();
142
94
  expect(mappings['watchman']).toBeDefined();
@@ -1,32 +1,113 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALL_ADAPTERS = void 0;
3
+ exports.ALL_ADAPTERS = exports.conflictingClaudePluginKeys = void 0;
4
4
  exports.detectAdapters = detectAdapters;
5
5
  exports.getAdapterByName = getAdapterByName;
6
6
  const tslib_1 = require("tslib");
7
7
  const fs = tslib_1.__importStar(require("fs"));
8
8
  const path = tslib_1.__importStar(require("path"));
9
9
  const os = tslib_1.__importStar(require("os"));
10
+ function copyDirSync(src, dst) {
11
+ fs.mkdirSync(dst, { recursive: true });
12
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
13
+ if (entry.name.startsWith('test_') || entry.name.endsWith('.spec.ts') || entry.name === '__pycache__') {
14
+ continue;
15
+ }
16
+ const srcEntry = path.join(src, entry.name);
17
+ const dstEntry = path.join(dst, entry.name);
18
+ if (entry.isDirectory()) {
19
+ copyDirSync(srcEntry, dstEntry);
20
+ }
21
+ else {
22
+ fs.copyFileSync(srcEntry, dstEntry);
23
+ }
24
+ }
25
+ }
26
+ exports.conflictingClaudePluginKeys = [];
27
+ function getClaudeSkillsDir() {
28
+ return path.join(os.homedir(), '.claude', 'skills');
29
+ }
30
+ function cleanupLegacyPluginArtifacts() {
31
+ const claudeDir = path.join(os.homedir(), '.claude');
32
+ const valdiPluginDir = path.join(claudeDir, 'plugins', 'local', 'valdi');
33
+ if (fs.existsSync(valdiPluginDir)) {
34
+ fs.rmSync(valdiPluginDir, { recursive: true, force: true });
35
+ }
36
+ const valdiCacheDir = path.join(claudeDir, 'plugins', 'cache', 'local', 'valdi');
37
+ if (fs.existsSync(valdiCacheDir)) {
38
+ fs.rmSync(valdiCacheDir, { recursive: true, force: true });
39
+ }
40
+ const installedPath = path.join(claudeDir, 'plugins', 'installed_plugins.json');
41
+ if (fs.existsSync(installedPath)) {
42
+ try {
43
+ const data = JSON.parse(fs.readFileSync(installedPath, 'utf8'));
44
+ if (Array.isArray(data)) {
45
+ const filtered = data.filter((entry) => !entry.key?.startsWith('valdi'));
46
+ if (filtered.length !== data.length) {
47
+ fs.writeFileSync(installedPath, JSON.stringify(filtered, null, 2), 'utf8');
48
+ }
49
+ }
50
+ }
51
+ catch {
52
+ }
53
+ }
54
+ const settingsPath = path.join(claudeDir, 'settings.json');
55
+ if (fs.existsSync(settingsPath)) {
56
+ try {
57
+ const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
58
+ let changed = false;
59
+ if (Array.isArray(settings.enabledPlugins)) {
60
+ const before = settings.enabledPlugins.length;
61
+ settings.enabledPlugins = settings.enabledPlugins.filter((p) => !p.includes('valdi'));
62
+ if (settings.enabledPlugins.length === 0)
63
+ delete settings.enabledPlugins;
64
+ if ((settings.enabledPlugins?.length ?? 0) !== before)
65
+ changed = true;
66
+ }
67
+ if (Array.isArray(settings.extraKnownMarketplaces)) {
68
+ const before = settings.extraKnownMarketplaces.length;
69
+ settings.extraKnownMarketplaces = settings.extraKnownMarketplaces.filter((m) => m.name !== 'local');
70
+ if (settings.extraKnownMarketplaces.length === 0)
71
+ delete settings.extraKnownMarketplaces;
72
+ if ((settings.extraKnownMarketplaces?.length ?? 0) !== before)
73
+ changed = true;
74
+ }
75
+ if (changed) {
76
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
77
+ }
78
+ }
79
+ catch {
80
+ }
81
+ }
82
+ }
10
83
  const ClaudeCodeAdapter = {
11
84
  name: 'claude',
12
85
  detect() {
13
86
  const claudeDir = path.join(os.homedir(), '.claude');
14
87
  return fs.existsSync(claudeDir);
15
88
  },
16
- install(skillName, content, meta) {
17
- const skillDir = path.join(os.homedir(), '.claude', 'plugins', 'valdi', 'skills', skillName);
89
+ install(skillName, content, meta, resourceDir) {
90
+ cleanupLegacyPluginArtifacts();
91
+ const skillDir = path.join(getClaudeSkillsDir(), skillName);
18
92
  fs.mkdirSync(skillDir, { recursive: true });
19
93
  const frontmatter = `---\nname: ${meta.name}\ndescription: ${meta.description}\n---\n\n`;
20
94
  fs.writeFileSync(path.join(skillDir, 'SKILL.md'), frontmatter + content, 'utf8');
95
+ if (resourceDir) {
96
+ for (const entry of fs.readdirSync(resourceDir, { withFileTypes: true })) {
97
+ if (entry.isDirectory()) {
98
+ copyDirSync(path.join(resourceDir, entry.name), path.join(skillDir, entry.name));
99
+ }
100
+ }
101
+ }
21
102
  },
22
103
  remove(skillName) {
23
- const skillDir = path.join(os.homedir(), '.claude', 'plugins', 'valdi', 'skills', skillName);
104
+ const skillDir = path.join(getClaudeSkillsDir(), skillName);
24
105
  if (fs.existsSync(skillDir)) {
25
106
  fs.rmSync(skillDir, { recursive: true, force: true });
26
107
  }
27
108
  },
28
109
  listInstalled() {
29
- const skillsDir = path.join(os.homedir(), '.claude', 'plugins', 'valdi', 'skills');
110
+ const skillsDir = getClaudeSkillsDir();
30
111
  if (!fs.existsSync(skillsDir))
31
112
  return [];
32
113
  return fs
@@ -40,26 +121,52 @@ const CursorAdapter = {
40
121
  const cursorDir = path.join(os.homedir(), '.cursor');
41
122
  return fs.existsSync(cursorDir);
42
123
  },
43
- install(skillName, content, meta) {
44
- const rulesDir = path.join(os.homedir(), '.cursor', 'rules');
45
- fs.mkdirSync(rulesDir, { recursive: true });
46
- const frontmatter = `---\ndescription: ${meta.description}\nalwaysApply: false\n---\n\n`;
47
- fs.writeFileSync(path.join(rulesDir, `valdi-${skillName}.mdc`), frontmatter + content, 'utf8');
124
+ install(skillName, content, meta, resourceDir) {
125
+ const skillDir = path.join(os.homedir(), '.cursor', 'skills', skillName);
126
+ fs.mkdirSync(skillDir, { recursive: true });
127
+ const frontmatter = `---\nname: ${meta.name}\ndescription: ${meta.description}\n---\n\n`;
128
+ fs.writeFileSync(path.join(skillDir, 'SKILL.md'), frontmatter + content, 'utf8');
129
+ if (resourceDir) {
130
+ for (const entry of fs.readdirSync(resourceDir, { withFileTypes: true })) {
131
+ if (entry.isDirectory()) {
132
+ copyDirSync(path.join(resourceDir, entry.name), path.join(skillDir, entry.name));
133
+ }
134
+ }
135
+ }
136
+ const legacyFile = path.join(os.homedir(), '.cursor', 'rules', `valdi-${skillName}.mdc`);
137
+ if (fs.existsSync(legacyFile)) {
138
+ fs.unlinkSync(legacyFile);
139
+ }
48
140
  },
49
141
  remove(skillName) {
50
- const filePath = path.join(os.homedir(), '.cursor', 'rules', `valdi-${skillName}.mdc`);
51
- if (fs.existsSync(filePath)) {
52
- fs.unlinkSync(filePath);
142
+ const skillDir = path.join(os.homedir(), '.cursor', 'skills', skillName);
143
+ if (fs.existsSync(skillDir)) {
144
+ fs.rmSync(skillDir, { recursive: true, force: true });
145
+ }
146
+ const legacyFile = path.join(os.homedir(), '.cursor', 'rules', `valdi-${skillName}.mdc`);
147
+ if (fs.existsSync(legacyFile)) {
148
+ fs.unlinkSync(legacyFile);
53
149
  }
54
150
  },
55
151
  listInstalled() {
152
+ const installed = new Set();
153
+ const skillsDir = path.join(os.homedir(), '.cursor', 'skills');
154
+ if (fs.existsSync(skillsDir)) {
155
+ for (const entry of fs.readdirSync(skillsDir)) {
156
+ if (fs.existsSync(path.join(skillsDir, entry, 'SKILL.md'))) {
157
+ installed.add(entry);
158
+ }
159
+ }
160
+ }
56
161
  const rulesDir = path.join(os.homedir(), '.cursor', 'rules');
57
- if (!fs.existsSync(rulesDir))
58
- return [];
59
- return fs
60
- .readdirSync(rulesDir)
61
- .filter((f) => f.startsWith('valdi-') && f.endsWith('.mdc'))
62
- .map((f) => f.replace(/^valdi-/u, '').replace(/\.mdc$/u, ''));
162
+ if (fs.existsSync(rulesDir)) {
163
+ for (const f of fs.readdirSync(rulesDir)) {
164
+ if (f.startsWith('valdi-') && f.endsWith('.mdc')) {
165
+ installed.add(f.replace(/^valdi-/u, '').replace(/\.mdc$/u, ''));
166
+ }
167
+ }
168
+ }
169
+ return Array.from(installed);
63
170
  },
64
171
  };
65
172
  const CopilotAdapter = {
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ require("jasmine");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const os = tslib_1.__importStar(require("os"));
8
+ const skillsAdapters_1 = require("./skillsAdapters");
9
+ describe('ClaudeCodeAdapter', () => {
10
+ let tmpHome;
11
+ let origHome;
12
+ beforeEach(() => {
13
+ tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'valdi-test-'));
14
+ origHome = process.env['HOME'];
15
+ process.env['HOME'] = tmpHome;
16
+ fs.mkdirSync(path.join(tmpHome, '.claude'), { recursive: true });
17
+ });
18
+ afterEach(() => {
19
+ process.env['HOME'] = origHome;
20
+ fs.rmSync(tmpHome, { recursive: true, force: true });
21
+ });
22
+ function getAdapter() {
23
+ const adapter = (0, skillsAdapters_1.getAdapterByName)('claude');
24
+ expect(adapter).toBeDefined();
25
+ return adapter;
26
+ }
27
+ it('writes SKILL.md with frontmatter to ~/.claude/skills/', () => {
28
+ const adapter = getAdapter();
29
+ adapter.install('my-skill', '# My content', { name: 'my-skill', description: 'Desc', tags: [], path: '', category: [] });
30
+ const skillPath = path.join(tmpHome, '.claude', 'skills', 'my-skill', 'SKILL.md');
31
+ expect(fs.existsSync(skillPath)).toBe(true);
32
+ const content = fs.readFileSync(skillPath, 'utf8');
33
+ expect(content).toContain('name: my-skill');
34
+ expect(content).toContain('description: Desc');
35
+ expect(content).toContain('# My content');
36
+ });
37
+ it('does not modify settings.json', () => {
38
+ const settingsFile = path.join(tmpHome, '.claude', 'settings.json');
39
+ fs.writeFileSync(settingsFile, JSON.stringify({ model: 'claude-opus-4-6' }), 'utf8');
40
+ const adapter = getAdapter();
41
+ adapter.install('test-skill', '# Content', { name: 'test-skill', description: 'Desc', tags: [], path: '', category: [] });
42
+ const settings = JSON.parse(fs.readFileSync(settingsFile, 'utf8'));
43
+ expect(settings).toEqual({ model: 'claude-opus-4-6' });
44
+ });
45
+ it('lists installed skills', () => {
46
+ const adapter = getAdapter();
47
+ adapter.install('skill-a', '# A', { name: 'skill-a', description: 'A', tags: [], path: '', category: [] });
48
+ adapter.install('skill-b', '# B', { name: 'skill-b', description: 'B', tags: [], path: '', category: [] });
49
+ const installed = adapter.listInstalled();
50
+ expect(installed).toContain('skill-a');
51
+ expect(installed).toContain('skill-b');
52
+ });
53
+ it('removes a skill', () => {
54
+ const adapter = getAdapter();
55
+ adapter.install('to-remove', '# Remove me', { name: 'to-remove', description: 'R', tags: [], path: '', category: [] });
56
+ expect(adapter.listInstalled()).toContain('to-remove');
57
+ adapter.remove('to-remove');
58
+ expect(adapter.listInstalled()).not.toContain('to-remove');
59
+ });
60
+ });
61
+ describe('CursorAdapter', () => {
62
+ let tmpHome;
63
+ let origHome;
64
+ beforeEach(() => {
65
+ tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'valdi-test-'));
66
+ origHome = process.env['HOME'];
67
+ process.env['HOME'] = tmpHome;
68
+ fs.mkdirSync(path.join(tmpHome, '.cursor'), { recursive: true });
69
+ });
70
+ afterEach(() => {
71
+ process.env['HOME'] = origHome;
72
+ fs.rmSync(tmpHome, { recursive: true, force: true });
73
+ });
74
+ function getAdapter() {
75
+ const adapter = (0, skillsAdapters_1.getAdapterByName)('cursor');
76
+ expect(adapter).toBeDefined();
77
+ return adapter;
78
+ }
79
+ it('installs SKILL.md to ~/.cursor/skills/ without double-prefixing', () => {
80
+ const adapter = getAdapter();
81
+ adapter.install('valdi-bazel', '# Content', { name: 'valdi-bazel', description: 'A skill', tags: [], path: '', category: [] });
82
+ const skillPath = path.join(tmpHome, '.cursor', 'skills', 'valdi-bazel', 'SKILL.md');
83
+ expect(fs.existsSync(skillPath)).toBe(true);
84
+ const content = fs.readFileSync(skillPath, 'utf8');
85
+ expect(content).toContain('name: valdi-bazel');
86
+ expect(content).toContain('description: A skill');
87
+ expect(content).toContain('# Content');
88
+ const badPath = path.join(tmpHome, '.cursor', 'skills', 'valdi-valdi-bazel', 'SKILL.md');
89
+ expect(fs.existsSync(badPath)).toBe(false);
90
+ });
91
+ it('does not install to deprecated ~/.cursor/rules/', () => {
92
+ const adapter = getAdapter();
93
+ adapter.install('valdi-bazel', '# Content', { name: 'valdi-bazel', description: 'A skill', tags: [], path: '', category: [] });
94
+ const legacyPath = path.join(tmpHome, '.cursor', 'rules', 'valdi-valdi-bazel.mdc');
95
+ expect(fs.existsSync(legacyPath)).toBe(false);
96
+ });
97
+ it('cleans up double-prefixed legacy .mdc file on install', () => {
98
+ const legacyDir = path.join(tmpHome, '.cursor', 'rules');
99
+ fs.mkdirSync(legacyDir, { recursive: true });
100
+ fs.writeFileSync(path.join(legacyDir, 'valdi-valdi-bazel.mdc'), 'old content', 'utf8');
101
+ const adapter = getAdapter();
102
+ adapter.install('valdi-bazel', '# New content', { name: 'valdi-bazel', description: 'A skill', tags: [], path: '', category: [] });
103
+ expect(fs.existsSync(path.join(legacyDir, 'valdi-valdi-bazel.mdc'))).toBe(false);
104
+ expect(fs.existsSync(path.join(tmpHome, '.cursor', 'skills', 'valdi-bazel', 'SKILL.md'))).toBe(true);
105
+ });
106
+ it('lists installed skills', () => {
107
+ const adapter = getAdapter();
108
+ adapter.install('valdi-tsx', '# A', { name: 'valdi-tsx', description: 'A', tags: [], path: '', category: [] });
109
+ adapter.install('valdi-bazel', '# B', { name: 'valdi-bazel', description: 'B', tags: [], path: '', category: [] });
110
+ const installed = adapter.listInstalled();
111
+ expect(installed).toContain('valdi-tsx');
112
+ expect(installed).toContain('valdi-bazel');
113
+ });
114
+ it('lists legacy .mdc skills from ~/.cursor/rules/', () => {
115
+ const rulesDir = path.join(tmpHome, '.cursor', 'rules');
116
+ fs.mkdirSync(rulesDir, { recursive: true });
117
+ fs.writeFileSync(path.join(rulesDir, 'valdi-valdi-legacy.mdc'), 'old content', 'utf8');
118
+ const adapter = getAdapter();
119
+ expect(adapter.listInstalled()).toContain('valdi-legacy');
120
+ });
121
+ it('deduplicates skills present in both locations', () => {
122
+ const adapter = getAdapter();
123
+ adapter.install('valdi-both', '# New', { name: 'valdi-both', description: 'B', tags: [], path: '', category: [] });
124
+ const rulesDir = path.join(tmpHome, '.cursor', 'rules');
125
+ fs.mkdirSync(rulesDir, { recursive: true });
126
+ fs.writeFileSync(path.join(rulesDir, 'valdi-valdi-both.mdc'), 'old', 'utf8');
127
+ const installed = adapter.listInstalled();
128
+ const count = installed.filter((s) => s === 'valdi-both').length;
129
+ expect(count).toBe(1);
130
+ });
131
+ it('removes a skill and cleans up legacy file', () => {
132
+ const adapter = getAdapter();
133
+ adapter.install('valdi-to-remove', '# Remove', { name: 'valdi-to-remove', description: 'R', tags: [], path: '', category: [] });
134
+ const legacyDir = path.join(tmpHome, '.cursor', 'rules');
135
+ fs.mkdirSync(legacyDir, { recursive: true });
136
+ fs.writeFileSync(path.join(legacyDir, 'valdi-valdi-to-remove.mdc'), 'old', 'utf8');
137
+ adapter.remove('valdi-to-remove');
138
+ expect(adapter.listInstalled()).not.toContain('valdi-to-remove');
139
+ expect(fs.existsSync(path.join(legacyDir, 'valdi-valdi-to-remove.mdc'))).toBe(false);
140
+ });
141
+ });
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadLocalRegistry = loadLocalRegistry;
4
4
  exports.fetchRegistry = fetchRegistry;
5
5
  exports.fetchSkillContent = fetchSkillContent;
6
+ exports.getSkillResourceDir = getSkillResourceDir;
6
7
  const tslib_1 = require("tslib");
7
8
  const path = tslib_1.__importStar(require("path"));
8
9
  const fs = tslib_1.__importStar(require("fs"));
@@ -38,3 +39,10 @@ async function fetchSkillContent(skillPath) {
38
39
  }
39
40
  throw new Error(`Skill content not found for "${skillPath}". Re-install @snap/valdi to get the latest bundle.`);
40
41
  }
42
+ function getSkillResourceDir(skillPath) {
43
+ const bundledDir = findBundledSkillsDir();
44
+ if (bundledDir == null)
45
+ return null;
46
+ const dir = path.join(bundledDir, path.dirname(skillPath));
47
+ return fs.existsSync(dir) ? dir : null;
48
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snap/valdi",
3
- "version": "1.0.11",
3
+ "version": "1.1.7",
4
4
  "description": "Valdi CLI tools for developers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,11 +40,6 @@
40
40
  "@bazel/bazelisk": "^1.19.0",
41
41
  "@types/inquirer": "^9.0.7",
42
42
  "@types/yargs": "^17.0.32",
43
- "@typescript-eslint/eslint-plugin": "^5.59.9",
44
- "eslint": "^8.42.0",
45
- "eslint-config-prettier": "^8.8.0",
46
- "eslint-plugin-import": "^2.27.5",
47
- "eslint-plugin-unicorn": "^47.0.0",
48
43
  "extract-zip": "^2.0.1",
49
44
  "glob": "^11.0.1",
50
45
  "inquirer": "^8.0.0",
@@ -52,16 +47,29 @@
52
47
  "ora": "^8.2.0",
53
48
  "prettier": "^3.3.1",
54
49
  "tslib": "^2.5.3",
55
- "typescript": "^5.3.3",
56
50
  "yaml": "^2.4.5",
57
51
  "yargs": "^17.7.2"
58
52
  },
53
+ "peerDependencies": {
54
+ "@typescript-eslint/eslint-plugin": "^5.59.9",
55
+ "eslint": "^8.42.0",
56
+ "eslint-config-prettier": "^8.8.0",
57
+ "eslint-plugin-import": "^2.27.5",
58
+ "eslint-plugin-unicorn": "^47.0.0",
59
+ "typescript": "^5.3.3"
60
+ },
59
61
  "devDependencies": {
60
62
  "@types/eslint": "^9.6.1",
61
63
  "@types/jasmine": "^5.1.7",
64
+ "@typescript-eslint/eslint-plugin": "^5.59.9",
65
+ "eslint": "^8.42.0",
66
+ "eslint-config-prettier": "^8.8.0",
67
+ "eslint-plugin-import": "^2.27.5",
68
+ "eslint-plugin-unicorn": "^47.0.0",
62
69
  "jasmine": "^5.6.0",
63
70
  "ts-node": "^10.9.2",
64
- "tsx": "^4.19.0"
71
+ "tsx": "^4.19.0",
72
+ "typescript": "^5.3.3"
65
73
  },
66
74
  "overrides": {
67
75
  "minimatch@3": {
@@ -1,57 +0,0 @@
1
- workspace(name = "{{WORKSPACE_NAME}}")
2
-
3
- load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
4
- load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
5
-
6
- {{VALDI_IMPORT}}
7
-
8
- {{VALDI_WIDGETS_IMPORT}}
9
-
10
- load("@valdi//bzl:workspace_prepare.bzl", "valdi_prepare_workspace")
11
-
12
- valdi_prepare_workspace()
13
-
14
- load("@valdi//bzl:workspace_preinit.bzl", "valdi_preinitialize_workspace")
15
-
16
- valdi_preinitialize_workspace()
17
-
18
- load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains", "register_yq_toolchains")
19
-
20
- register_yq_toolchains()
21
-
22
- # Required bazel-lib dependencies
23
-
24
- aspect_bazel_lib_dependencies()
25
-
26
- # Required rules_shell dependencies
27
- load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
28
-
29
- rules_shell_dependencies()
30
-
31
- rules_shell_toolchains()
32
-
33
- # Register bazel-lib toolchains
34
-
35
- aspect_bazel_lib_register_toolchains()
36
-
37
- # Create the host platform repository transitively required by bazel-lib
38
-
39
- load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
40
- load("@platforms//host:extension.bzl", "host_platform_repo")
41
-
42
- maybe(
43
- host_platform_repo,
44
- name = "host_platform",
45
- )
46
-
47
- load("@valdi//bzl:workspace_init.bzl", "valdi_initialize_workspace")
48
-
49
- valdi_initialize_workspace()
50
-
51
- load("@valdi_npm//:repositories.bzl", "npm_repositories")
52
-
53
- npm_repositories()
54
-
55
- load("@valdi//bzl:workspace_postinit.bzl", "valdi_post_initialize_workspace")
56
-
57
- valdi_post_initialize_workspace()
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ANDROID_LINUX_COMMANDLINE_TOOLS = exports.ANDROID_MACOS_COMMANDLINE_TOOLS = exports.ANDROID_PLATFORM_VERSION = exports.ANDROID_NDK_VERSION = exports.ANDROID_BUILD_TOOLS_VERSION = void 0;
4
- exports.ANDROID_BUILD_TOOLS_VERSION = '34.0.0';
5
- exports.ANDROID_NDK_VERSION = '25.2.9519653';
6
- exports.ANDROID_PLATFORM_VERSION = 'android-36';
7
- exports.ANDROID_MACOS_COMMANDLINE_TOOLS = 'https://dl.google.com/android/repository/commandlinetools-mac-13114758_latest.zip';
8
- exports.ANDROID_LINUX_COMMANDLINE_TOOLS = 'https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip';