@snap/valdi 1.1.7 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/.metadata/.bazelrc.template +8 -2
  2. package/.metadata/MODULE.bazel.template +20 -3
  3. package/.metadata/bzl/patches/rules_python/1.9.0/BUILD.bazel.template +1 -0
  4. package/.metadata/bzl/patches/rules_python/1.9.0/remove_setuptools_spaces.patch.template +96 -0
  5. package/README.md +35 -1
  6. package/bundled-skills/registry.json +2 -1
  7. package/bundled-skills/skills/valdi-animations/skill.md +49 -0
  8. package/bundled-skills/skills/valdi-async/skill.md +3 -2
  9. package/bundled-skills/skills/valdi-bazel/skill.md +2 -6
  10. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +18 -0
  11. package/bundled-skills/skills/valdi-error-handling/skill.md +1 -1
  12. package/bundled-skills/skills/valdi-gestures/skill.md +3 -3
  13. package/bundled-skills/skills/valdi-migrate/skill.md +2 -1
  14. package/bundled-skills/skills/valdi-mock-breakdown/skill.md +4 -4
  15. package/bundled-skills/skills/valdi-mock-to-module/skill.md +9 -6
  16. package/bundled-skills/skills/valdi-overview/skill.md +2 -1
  17. package/bundled-skills/skills/valdi-perf/skill.md +121 -5
  18. package/bundled-skills/skills/valdi-pr-review/skill.md +189 -0
  19. package/bundled-skills/skills/valdi-profile/skill.md +5 -3
  20. package/bundled-skills/skills/valdi-setup/skill.md +3 -6
  21. package/bundled-skills/skills/valdi-testing/skill.md +1 -1
  22. package/bundled-skills/skills/valdi-tsx/skill.md +47 -11
  23. package/debugger/README.md +356 -0
  24. package/debugger/debugger-actions.js +373 -0
  25. package/debugger/debugger-api.js +225 -0
  26. package/debugger/debugger-bootstrap.js +295 -0
  27. package/debugger/debugger-model.js +790 -0
  28. package/debugger/debugger-performance.js +573 -0
  29. package/debugger/debugger-preview-html.js +676 -0
  30. package/debugger/debugger-providers.js +389 -0
  31. package/debugger/debugger-render.js +529 -0
  32. package/debugger/debugger-runtime.js +387 -0
  33. package/debugger/debugger-session.js +188 -0
  34. package/debugger/debugger-settings.js +209 -0
  35. package/debugger/debugger-state.js +221 -0
  36. package/debugger/debugger-tree-model.js +539 -0
  37. package/debugger/debugger.css +1865 -0
  38. package/debugger/devtools-panel.css +1318 -0
  39. package/debugger/devtools-panel.html +273 -0
  40. package/debugger/devtools-panel.js +3329 -0
  41. package/debugger/index.html +279 -0
  42. package/dist/commands/bootstrap.js +6 -5
  43. package/dist/commands/debugger.js +163 -0
  44. package/dist/commands/doctor.js +3 -62
  45. package/dist/commands/inspect.js +5 -2
  46. package/dist/commands/inspect_commands/input.js +176 -0
  47. package/dist/commands/inspect_commands/snapshot.js +1 -1
  48. package/dist/commands/inspect_commands/tree.js +1 -1
  49. package/dist/commands/projectsync.js +15 -0
  50. package/dist/commands/webHotreload.js +31 -0
  51. package/dist/core/constants.js +22 -6
  52. package/dist/debugger/chromiumConsole.js +279 -0
  53. package/dist/debugger/inputClient.js +473 -0
  54. package/dist/debugger/server.js +3801 -0
  55. package/dist/debugger/targetRegistry.js +436 -0
  56. package/dist/debugger/webPreviewPerformance.js +864 -0
  57. package/dist/index.js +0 -0
  58. package/dist/utils/BazelClient.js +34 -5
  59. package/dist/utils/applicationUtils.js +3 -0
  60. package/dist/utils/chromiumDevToolsClient.js +350 -0
  61. package/dist/utils/daemonClient.js +364 -44
  62. package/dist/utils/hermesClient.js +82 -176
  63. package/dist/utils/loopbackHost.js +14 -0
  64. package/dist/utils/owlCdpClient.js +282 -0
  65. package/dist/utils/owlDevToolsExtension.js +142 -0
  66. package/dist/utils/stringUtils.js +13 -1
  67. package/package.json +4 -2
  68. package/dist/commands/inspect_commands/snapshot.spec.js +0 -105
  69. package/dist/core/packageFiles.spec.js +0 -29
  70. package/dist/preview/previewGenerator.spec.js +0 -203
  71. package/dist/preview/viewModelParser.spec.js +0 -171
  72. package/dist/utils/linuxDistro.spec.js +0 -122
  73. package/dist/utils/skillsAdapters.spec.js +0 -141
  74. package/dist/utils/stringUtils.spec.js +0 -81
@@ -1,171 +0,0 @@
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 os = tslib_1.__importStar(require("os"));
7
- const path = tslib_1.__importStar(require("path"));
8
- const viewModelParser_1 = require("./viewModelParser");
9
- describe('viewModelParser', () => {
10
- let tmpDir;
11
- beforeEach(() => {
12
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vmp-test-'));
13
- });
14
- afterEach(() => {
15
- fs.rmSync(tmpDir, { recursive: true, force: true });
16
- });
17
- function writeComponent(filename, content) {
18
- const filePath = path.join(tmpDir, filename);
19
- fs.writeFileSync(filePath, content, 'utf8');
20
- return filePath;
21
- }
22
- describe('parseComponentFile', () => {
23
- it('parses a simple Component with ViewModel', () => {
24
- const filePath = writeComponent('Simple.tsx', `
25
- import { Component } from 'valdi_core/src/Component';
26
-
27
- export interface SimpleViewModel {
28
- title: string;
29
- count: number;
30
- enabled: boolean;
31
- }
32
-
33
- export class Simple extends Component<SimpleViewModel, {}> {
34
- onRender(): void {}
35
- }
36
- `);
37
- const result = (0, viewModelParser_1.parseComponentFile)(filePath);
38
- expect(result.componentName).toBe('Simple');
39
- expect(result.viewModelName).toBe('SimpleViewModel');
40
- expect(result.props.length).toBe(3);
41
- expect(result.props[0].name).toBe('title');
42
- expect(result.props[0].typeString).toBe('string');
43
- expect(result.props[0].optional).toBe(false);
44
- expect(result.props[1].name).toBe('count');
45
- expect(result.props[1].typeString).toBe('number');
46
- expect(result.props[2].name).toBe('enabled');
47
- expect(result.props[2].isBoolean).toBe(true);
48
- });
49
- it('parses optional props', () => {
50
- const filePath = writeComponent('Optional.tsx', `
51
- export interface OptViewModel {
52
- label: string;
53
- subtitle?: string;
54
- icon?: number;
55
- }
56
- export class OptComponent extends Component<OptViewModel, {}> {
57
- onRender(): void {}
58
- }
59
- `);
60
- const result = (0, viewModelParser_1.parseComponentFile)(filePath);
61
- expect(result.props.length).toBe(3);
62
- expect(result.props[0].optional).toBe(false);
63
- expect(result.props[1].optional).toBe(true);
64
- expect(result.props[2].optional).toBe(true);
65
- });
66
- it('parses callback props', () => {
67
- const filePath = writeComponent('Callback.tsx', `
68
- export interface CbViewModel {
69
- onTap: () => void;
70
- onChange: (val: boolean) => void;
71
- onSelect: (item: string) => void;
72
- }
73
- export class CbComponent extends Component<CbViewModel, {}> {
74
- onRender(): void {}
75
- }
76
- `);
77
- const result = (0, viewModelParser_1.parseComponentFile)(filePath);
78
- expect(result.props.length).toBe(3);
79
- expect(result.props[0].isCallback).toBe(true);
80
- expect(result.props[0].callbackParamType).toBeUndefined();
81
- expect(result.props[1].isCallback).toBe(true);
82
- expect(result.props[1].callbackParamType).toBe('boolean');
83
- expect(result.props[2].isCallback).toBe(true);
84
- expect(result.props[2].callbackParamType).toBe('string');
85
- });
86
- it('parses StatefulComponent', () => {
87
- const filePath = writeComponent('Stateful.tsx', `
88
- export interface StatefulVM {
89
- checked: boolean;
90
- }
91
- export class MyStateful extends StatefulComponent<StatefulVM> {
92
- onRender(): void {}
93
- }
94
- `);
95
- const result = (0, viewModelParser_1.parseComponentFile)(filePath);
96
- expect(result.componentName).toBe('MyStateful');
97
- expect(result.viewModelName).toBe('StatefulVM');
98
- });
99
- it('throws when no Component class is found', () => {
100
- const filePath = writeComponent('NoClass.tsx', `
101
- export interface SomeViewModel { title: string; }
102
- `);
103
- expect(() => (0, viewModelParser_1.parseComponentFile)(filePath)).toThrowError(/Could not find an exported Component class/);
104
- });
105
- it('throws when ViewModel interface is missing', () => {
106
- const filePath = writeComponent('NoVM.tsx', `
107
- export class Broken extends Component<MissingViewModel, {}> {
108
- onRender(): void {}
109
- }
110
- `);
111
- expect(() => (0, viewModelParser_1.parseComponentFile)(filePath)).toThrowError(/Could not find interface MissingViewModel/);
112
- });
113
- });
114
- describe('detectInteractiveState', () => {
115
- it('pairs boolean prop with onChange callback', () => {
116
- const props = [
117
- { name: 'on', typeString: 'boolean', optional: false, isBoolean: true, isCallback: false, callbackParamType: undefined },
118
- { name: 'onChange', typeString: '(val: boolean) => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: 'boolean' },
119
- ];
120
- const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
121
- expect(pairs.length).toBe(1);
122
- expect(pairs[0].boolPropName).toBe('on');
123
- expect(pairs[0].callbackPropName).toBe('onChange');
124
- });
125
- it('pairs boolean prop with onTap callback', () => {
126
- const props = [
127
- { name: 'selected', typeString: 'boolean', optional: false, isBoolean: true, isCallback: false, callbackParamType: undefined },
128
- { name: 'onTap', typeString: '(val: boolean) => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: 'boolean' },
129
- ];
130
- const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
131
- expect(pairs.length).toBe(1);
132
- expect(pairs[0].boolPropName).toBe('selected');
133
- expect(pairs[0].callbackPropName).toBe('onTap');
134
- });
135
- it('returns empty when no matching pair exists', () => {
136
- const props = [
137
- { name: 'title', typeString: 'string', optional: false, isBoolean: false, isCallback: false, callbackParamType: undefined },
138
- { name: 'onTap', typeString: '() => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: undefined },
139
- ];
140
- const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
141
- expect(pairs.length).toBe(0);
142
- });
143
- it('skips optional boolean props', () => {
144
- const props = [
145
- { name: 'checked', typeString: 'boolean', optional: true, isBoolean: true, isCallback: false, callbackParamType: undefined },
146
- { name: 'onToggle', typeString: '(val: boolean) => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: 'boolean' },
147
- ];
148
- const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
149
- expect(pairs.length).toBe(0);
150
- });
151
- });
152
- describe('sampleValueForType', () => {
153
- it('returns correct sample for primitive types', () => {
154
- expect((0, viewModelParser_1.sampleValueForType)('boolean')).toBe('false');
155
- expect((0, viewModelParser_1.sampleValueForType)('string')).toBe("'Sample'");
156
- expect((0, viewModelParser_1.sampleValueForType)('number')).toBe('42');
157
- expect((0, viewModelParser_1.sampleValueForType)('Date')).toBe('new Date()');
158
- });
159
- it('returns noop for function types', () => {
160
- expect((0, viewModelParser_1.sampleValueForType)('() => void')).toBe('() => {}');
161
- expect((0, viewModelParser_1.sampleValueForType)('(val: boolean) => void')).toBe('() => {}');
162
- });
163
- it('returns empty array for array types', () => {
164
- expect((0, viewModelParser_1.sampleValueForType)('string[]')).toBe('[]');
165
- expect((0, viewModelParser_1.sampleValueForType)('Array<number>')).toBe('[]');
166
- });
167
- it('falls back to undefined for unknown types', () => {
168
- expect((0, viewModelParser_1.sampleValueForType)('SomeCustomType')).toBe('undefined as any');
169
- });
170
- });
171
- });
@@ -1,122 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("jasmine");
4
- const linuxDistro_1 = require("./linuxDistro");
5
- describe('linuxDistro', () => {
6
- describe('getPackageName', () => {
7
- it('returns Debian package name for Debian distribution', () => {
8
- const packageMap = {
9
- debian: 'openjdk-17-jdk',
10
- redhat: 'java-17-openjdk-devel',
11
- unknown: 'openjdk-17',
12
- };
13
- const distro = {
14
- type: linuxDistro_1.LinuxDistroType.DEBIAN,
15
- name: 'Ubuntu',
16
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
17
- };
18
- const result = (0, linuxDistro_1.getPackageName)(packageMap, distro);
19
- expect(result).toBe('openjdk-17-jdk');
20
- });
21
- it('returns RedHat package name for RedHat distribution', () => {
22
- const packageMap = {
23
- debian: 'openjdk-17-jdk',
24
- redhat: 'java-17-openjdk-devel',
25
- unknown: 'openjdk-17',
26
- };
27
- const distro = {
28
- type: linuxDistro_1.LinuxDistroType.REDHAT,
29
- name: 'Fedora',
30
- packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
31
- };
32
- const result = (0, linuxDistro_1.getPackageName)(packageMap, distro);
33
- expect(result).toBe('java-17-openjdk-devel');
34
- });
35
- it('returns unknown fallback for distributions without specific mapping', () => {
36
- const packageMap = {
37
- debian: 'openjdk-17-jdk',
38
- unknown: 'openjdk-17',
39
- };
40
- const distro = {
41
- type: linuxDistro_1.LinuxDistroType.ARCH,
42
- name: 'Arch Linux',
43
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
44
- };
45
- const result = (0, linuxDistro_1.getPackageName)(packageMap, distro);
46
- expect(result).toBe('openjdk-17');
47
- });
48
- });
49
- describe('buildInstallCommand', () => {
50
- it('builds install command for Debian', () => {
51
- const distro = {
52
- type: linuxDistro_1.LinuxDistroType.DEBIAN,
53
- name: 'Ubuntu',
54
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
55
- };
56
- const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm', 'watchman'], distro);
57
- expect(result).toBe('sudo apt-get install git npm watchman');
58
- });
59
- it('builds install command for RedHat', () => {
60
- const distro = {
61
- type: linuxDistro_1.LinuxDistroType.REDHAT,
62
- name: 'Fedora',
63
- packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
64
- };
65
- const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm'], distro);
66
- expect(result).toBe('sudo dnf install git npm');
67
- });
68
- it('builds install command for Arch', () => {
69
- const distro = {
70
- type: linuxDistro_1.LinuxDistroType.ARCH,
71
- name: 'Arch Linux',
72
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
73
- };
74
- const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm'], distro);
75
- expect(result).toBe('sudo pacman -S git npm');
76
- });
77
- it('returns comment for unknown distribution', () => {
78
- const distro = {
79
- type: linuxDistro_1.LinuxDistroType.UNKNOWN,
80
- name: 'Unknown',
81
- packageManager: { name: 'unknown', installCommand: '', requiresSudo: true },
82
- };
83
- const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm'], distro);
84
- expect(result).toContain('Unable to determine package manager');
85
- expect(result).toContain('git, npm');
86
- });
87
- });
88
- describe('getCommonPackageMappings', () => {
89
- it('returns package mappings for common dependencies', () => {
90
- const mappings = (0, linuxDistro_1.getCommonPackageMappings)();
91
- expect(mappings['git']).toBeDefined();
92
- expect(mappings['npm']).toBeDefined();
93
- expect(mappings['openjdk-17']).toBeDefined();
94
- expect(mappings['watchman']).toBeDefined();
95
- expect(mappings['adb']).toBeDefined();
96
- expect(mappings['fontconfig']).toBeDefined();
97
- expect(mappings['zlib']).toBeDefined();
98
- });
99
- it('has platform-specific mappings for Java', () => {
100
- const mappings = (0, linuxDistro_1.getCommonPackageMappings)();
101
- const javaMappings = mappings['openjdk-17'];
102
- expect(javaMappings).toBeDefined();
103
- if (javaMappings) {
104
- expect(javaMappings.debian).toBe('openjdk-17-jdk');
105
- expect(javaMappings.redhat).toBe('java-17-openjdk-devel');
106
- expect(javaMappings.arch).toBe('jdk17-openjdk');
107
- expect(javaMappings.suse).toBe('java-17-openjdk-devel');
108
- }
109
- });
110
- it('has platform-specific mappings for adb', () => {
111
- const mappings = (0, linuxDistro_1.getCommonPackageMappings)();
112
- const adbMappings = mappings['adb'];
113
- expect(adbMappings).toBeDefined();
114
- if (adbMappings) {
115
- expect(adbMappings.debian).toBe('adb');
116
- expect(adbMappings.redhat).toBe('android-tools');
117
- expect(adbMappings.arch).toBe('android-tools');
118
- expect(adbMappings.suse).toBe('android-tools');
119
- }
120
- });
121
- });
122
- });
@@ -1,141 +0,0 @@
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
- });
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("jasmine");
4
- const stringUtils_1 = require("./stringUtils");
5
- describe('stringUtils', () => {
6
- it('converts strings to pascal case', () => {
7
- const testCases = [['hello', 'Hello'], ['hello world', 'HelloWorld'], ['My New Module', 'MyNewModule'], ['my_new_module', 'MyNewModule']];
8
- testCases.forEach(([input, expected]) => {
9
- expect((0, stringUtils_1.toPascalCase)(input)).toBe(expected);
10
- });
11
- });
12
- it('converts strings to snake case', () => {
13
- const testCases = [['hello', 'hello'], ['hello world', 'hello_world']];
14
- testCases.forEach(([input, expected]) => {
15
- expect((0, stringUtils_1.toSnakeCase)(input)).toBe(expected);
16
- });
17
- });
18
- describe('sanitizeProjectName', () => {
19
- it('replaces dashes with underscores', () => {
20
- expect((0, stringUtils_1.sanitizeProjectName)('my-project')).toBe('my_project');
21
- expect((0, stringUtils_1.sanitizeProjectName)('my-cool-app')).toBe('my_cool_app');
22
- });
23
- it('preserves original case', () => {
24
- expect((0, stringUtils_1.sanitizeProjectName)('MyProject')).toBe('MyProject');
25
- expect((0, stringUtils_1.sanitizeProjectName)('MY_PROJECT')).toBe('MY_PROJECT');
26
- expect((0, stringUtils_1.sanitizeProjectName)('testNewModule')).toBe('testNewModule');
27
- });
28
- it('removes invalid characters', () => {
29
- expect((0, stringUtils_1.sanitizeProjectName)('my project!')).toBe('myproject');
30
- expect((0, stringUtils_1.sanitizeProjectName)('my@project#')).toBe('myproject');
31
- expect((0, stringUtils_1.sanitizeProjectName)('my.project')).toBe('myproject');
32
- });
33
- it('prefixes with underscore if starts with number', () => {
34
- expect((0, stringUtils_1.sanitizeProjectName)('123project')).toBe('_123project');
35
- expect((0, stringUtils_1.sanitizeProjectName)('7-eleven')).toBe('_7_eleven');
36
- });
37
- it('handles mixed cases', () => {
38
- expect((0, stringUtils_1.sanitizeProjectName)('My-Cool_Project123')).toBe('My_Cool_Project123');
39
- });
40
- it('handles already valid names', () => {
41
- expect((0, stringUtils_1.sanitizeProjectName)('my_project')).toBe('my_project');
42
- expect((0, stringUtils_1.sanitizeProjectName)('myproject')).toBe('myproject');
43
- expect((0, stringUtils_1.sanitizeProjectName)('my_project_123')).toBe('my_project_123');
44
- });
45
- });
46
- describe('validateProjectName', () => {
47
- it('rejects empty names', () => {
48
- expect((0, stringUtils_1.validateProjectName)('')).toBeTruthy();
49
- expect((0, stringUtils_1.validateProjectName)(' ')).toBeTruthy();
50
- });
51
- it('rejects reserved words (case-insensitive)', () => {
52
- expect((0, stringUtils_1.validateProjectName)('test')).toContain('reserved word');
53
- expect((0, stringUtils_1.validateProjectName)('Test')).toContain('reserved word');
54
- expect((0, stringUtils_1.validateProjectName)('TEST')).toContain('reserved word');
55
- expect((0, stringUtils_1.validateProjectName)('build')).toContain('reserved word');
56
- expect((0, stringUtils_1.validateProjectName)('workspace')).toContain('reserved word');
57
- expect((0, stringUtils_1.validateProjectName)('native')).toContain('reserved word');
58
- expect((0, stringUtils_1.validateProjectName)('package')).toContain('reserved word');
59
- });
60
- it('accepts valid names with mixed case', () => {
61
- expect((0, stringUtils_1.validateProjectName)('my_project')).toBeNull();
62
- expect((0, stringUtils_1.validateProjectName)('myproject')).toBeNull();
63
- expect((0, stringUtils_1.validateProjectName)('my_cool_app')).toBeNull();
64
- expect((0, stringUtils_1.validateProjectName)('project123')).toBeNull();
65
- expect((0, stringUtils_1.validateProjectName)('MyProject')).toBeNull();
66
- expect((0, stringUtils_1.validateProjectName)('testNewModule')).toBeNull();
67
- });
68
- it('accepts names with dashes (they will be sanitized)', () => {
69
- expect((0, stringUtils_1.validateProjectName)('my-project')).toBeNull();
70
- expect((0, stringUtils_1.validateProjectName)('my-cool-app')).toBeNull();
71
- });
72
- it('rejects names with only invalid characters', () => {
73
- expect((0, stringUtils_1.validateProjectName)('!!!')).toBeTruthy();
74
- expect((0, stringUtils_1.validateProjectName)('...')).toBeTruthy();
75
- expect((0, stringUtils_1.validateProjectName)('@#$')).toBeTruthy();
76
- });
77
- it('handles names that start with numbers', () => {
78
- expect((0, stringUtils_1.validateProjectName)('123project')).toContain('sanitized');
79
- });
80
- });
81
- });