sinapse-ai 1.9.0 → 1.9.1

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 (88) hide show
  1. package/.claude/rules/mandatory-delegation.md +1 -1
  2. package/.codex/delegation-matrix.json +4 -3
  3. package/.codex/delegation-parity.json +4 -3
  4. package/.codex/instructions.md +2 -2
  5. package/.sinapse-ai/constitution.md +2 -2
  6. package/.sinapse-ai/core/doctor/checks/git-hooks.js +76 -10
  7. package/.sinapse-ai/core/execution/subagent-dispatcher.js +1 -1
  8. package/.sinapse-ai/core/synapse/engine.js +15 -0
  9. package/.sinapse-ai/data/entity-registry.yaml +13 -13
  10. package/.sinapse-ai/development/agents/snps-orqx.md +4 -4
  11. package/.sinapse-ai/git-hooks/lib/secret-scanner-core.js +76 -4
  12. package/.sinapse-ai/git-hooks/pre-push +7 -1
  13. package/.sinapse-ai/install-manifest.yaml +9 -9
  14. package/AGENTS.md +2 -2
  15. package/CHANGELOG.md +1247 -0
  16. package/bin/commands/uninstall.js +2 -2
  17. package/bin/utils/secret-scanner-core.js +76 -4
  18. package/docs/agent-reference-guide.md +1 -1
  19. package/docs/framework/architecture-overview.md +4 -4
  20. package/docs/framework/guiding-principles.md +9 -9
  21. package/docs/getting-started.md +1 -1
  22. package/docs/guides/agent-reference.md +1 -1
  23. package/docs/guides/codex-config.md +4 -5
  24. package/docs/pt/architecture/sub-orqx-pattern.md +20 -18
  25. package/package.json +8 -2
  26. package/packages/installer/src/installer/git-hooks-installer.js +3 -1
  27. package/packages/installer/src/wizard/ide-config-generator.js +9 -1
  28. package/packages/installer/src/wizard/index.js +3 -4
  29. package/scripts/regenerate-orqx-stubs.ps1 +0 -1
  30. package/scripts/sync-counts.js +10 -2
  31. package/scripts/sync-squad-yaml-components.js +108 -6
  32. package/scripts/validate-squad-orqx.js +19 -9
  33. package/sinapse/agents/sinapse-orqx.md +4 -4
  34. package/sinapse/agents/snps-orqx.md +4 -4
  35. package/sinapse/knowledge-base/routing-catalog.md +1 -1
  36. package/sinapse/tasks/diagnose-and-route.md +1 -1
  37. package/sinapse/tasks/squad-status-report.md +1 -1
  38. package/squads/claude-code-mastery/agents/claude-mastery-chief.md +1 -1
  39. package/squads/claude-code-mastery/agents/hooks-architect.md +60 -68
  40. package/squads/claude-code-mastery/knowledge-base/swarm-orchestration-patterns.md +1 -1
  41. package/squads/claude-code-mastery/tasks/audit-setup.md +1 -1
  42. package/squads/claude-code-mastery/workflows/optimization-cycle.yaml +4 -4
  43. package/squads/claude-code-mastery/workflows/project-setup-cycle.yaml +4 -4
  44. package/squads/squad-animations/README.md +1 -1
  45. package/squads/squad-cloning/README.md +1 -1
  46. package/squads/squad-commercial/README.md +1 -1
  47. package/squads/squad-content/README.md +1 -1
  48. package/squads/squad-copy/README.md +1 -1
  49. package/squads/squad-council/README.md +1 -1
  50. package/squads/squad-courses/README.md +1 -1
  51. package/squads/squad-cybersecurity/README.md +1 -1
  52. package/squads/squad-design/README.md +1 -1
  53. package/squads/squad-finance/README.md +1 -1
  54. package/squads/squad-growth/README.md +1 -1
  55. package/squads/squad-paidmedia/README.md +1 -1
  56. package/squads/squad-product/README.md +1 -1
  57. package/squads/squad-research/README.md +1 -1
  58. package/squads/squad-storytelling/README.md +1 -1
  59. package/.sinapse-ai/core/memory/__tests__/active-modules.verify.js +0 -265
  60. package/.sinapse-ai/core/permissions/__tests__/permission-mode.test.js +0 -293
  61. package/.sinapse-ai/infrastructure/tests/project-status-loader.test.js +0 -569
  62. package/.sinapse-ai/infrastructure/tests/regression-suite-v2.md +0 -622
  63. package/.sinapse-ai/infrastructure/tests/validate-module.js +0 -98
  64. package/.sinapse-ai/infrastructure/tests/worktree-manager.test.js +0 -620
  65. package/.sinapse-ai/workflow-intelligence/__tests__/confidence-scorer.test.js +0 -335
  66. package/.sinapse-ai/workflow-intelligence/__tests__/integration.test.js +0 -340
  67. package/.sinapse-ai/workflow-intelligence/__tests__/suggestion-engine.test.js +0 -438
  68. package/.sinapse-ai/workflow-intelligence/__tests__/wave-analyzer.test.js +0 -448
  69. package/.sinapse-ai/workflow-intelligence/__tests__/workflow-registry.test.js +0 -303
  70. package/packages/installer/src/__tests__/performance-benchmark.js +0 -383
  71. package/packages/installer/tests/integration/environment-configuration.test.js +0 -332
  72. package/packages/installer/tests/integration/wizard-detection.test.js +0 -352
  73. package/packages/installer/tests/unit/artifact-copy-pipeline/artifact-copy-pipeline.test.js +0 -402
  74. package/packages/installer/tests/unit/claude-md-template-v5/claude-md-template-v5.test.js +0 -193
  75. package/packages/installer/tests/unit/config-validator.test.js +0 -315
  76. package/packages/installer/tests/unit/detection/detect-project-type.test.js +0 -539
  77. package/packages/installer/tests/unit/doctor/doctor-checks.test.js +0 -675
  78. package/packages/installer/tests/unit/doctor/doctor-orchestrator.test.js +0 -192
  79. package/packages/installer/tests/unit/entity-registry-bootstrap.test.js +0 -192
  80. package/packages/installer/tests/unit/env-template.test.js +0 -187
  81. package/packages/installer/tests/unit/generate-settings-json/generate-settings-json.test.js +0 -310
  82. package/packages/installer/tests/unit/git-hooks-installer.test.js +0 -262
  83. package/packages/installer/tests/unit/ide-sync-integration/ide-sync-integration.test.js +0 -231
  84. package/packages/installer/tests/unit/merger/env-merger.test.js +0 -191
  85. package/packages/installer/tests/unit/merger/markdown-merger.test.js +0 -262
  86. package/packages/installer/tests/unit/merger/strategies.test.js +0 -154
  87. package/packages/installer/tests/unit/merger/yaml-merger.test.js +0 -328
  88. package/packages/sinapse-install/tests/unit/chrome-brain.smoke.test.js +0 -66
@@ -1,154 +0,0 @@
1
- /**
2
- * @fileoverview Tests for Merge Strategy Factory
3
- * Story 9.1: Smart Merge Foundation
4
- */
5
-
6
- const {
7
- getMergeStrategy,
8
- hasMergeStrategy,
9
- getSupportedTypes,
10
- registerStrategy,
11
- registerFileNameStrategy,
12
- } = require('../../../src/merger/strategies/index.js');
13
- const { EnvMerger } = require('../../../src/merger/strategies/env-merger.js');
14
- const { MarkdownMerger } = require('../../../src/merger/strategies/markdown-merger.js');
15
- const { ReplaceMerger } = require('../../../src/merger/strategies/replace-merger.js');
16
-
17
- describe('getMergeStrategy', () => {
18
- it('should return EnvMerger for .env files', () => {
19
- const merger = getMergeStrategy('.env');
20
- expect(merger).toBeInstanceOf(EnvMerger);
21
- });
22
-
23
- it('should return EnvMerger for .env.local files', () => {
24
- const merger = getMergeStrategy('.env.local');
25
- expect(merger).toBeInstanceOf(EnvMerger);
26
- });
27
-
28
- it('should return EnvMerger for .env.example files', () => {
29
- const merger = getMergeStrategy('.env.example');
30
- expect(merger).toBeInstanceOf(EnvMerger);
31
- });
32
-
33
- it('should return MarkdownMerger for .md files', () => {
34
- const merger = getMergeStrategy('CLAUDE.md');
35
- expect(merger).toBeInstanceOf(MarkdownMerger);
36
- });
37
-
38
- it('should return MarkdownMerger for README.md', () => {
39
- const merger = getMergeStrategy('README.md');
40
- expect(merger).toBeInstanceOf(MarkdownMerger);
41
- });
42
-
43
- it('should return ReplaceMerger for unknown file types', () => {
44
- const merger = getMergeStrategy('config.toml');
45
- expect(merger).toBeInstanceOf(ReplaceMerger);
46
- });
47
-
48
- it('should return ReplaceMerger for .json files', () => {
49
- const merger = getMergeStrategy('package.json');
50
- expect(merger).toBeInstanceOf(ReplaceMerger);
51
- });
52
-
53
- it('should handle full paths', () => {
54
- const merger = getMergeStrategy('/path/to/project/.env');
55
- expect(merger).toBeInstanceOf(EnvMerger);
56
- });
57
-
58
- it('should handle paths with directories', () => {
59
- const merger = getMergeStrategy('/path/to/.claude/CLAUDE.md');
60
- expect(merger).toBeInstanceOf(MarkdownMerger);
61
- });
62
- });
63
-
64
- describe('hasMergeStrategy', () => {
65
- it('should return true for .env files', () => {
66
- expect(hasMergeStrategy('.env')).toBe(true);
67
- });
68
-
69
- it('should return true for .md files', () => {
70
- expect(hasMergeStrategy('CLAUDE.md')).toBe(true);
71
- });
72
-
73
- it('should return false for unsupported files', () => {
74
- expect(hasMergeStrategy('config.toml')).toBe(false);
75
- });
76
-
77
- it('should return false for .json files', () => {
78
- expect(hasMergeStrategy('package.json')).toBe(false);
79
- });
80
-
81
- it('should be case-insensitive for extensions', () => {
82
- expect(hasMergeStrategy('README.MD')).toBe(true);
83
- });
84
- });
85
-
86
- describe('getSupportedTypes', () => {
87
- it('should return extensions and filenames', () => {
88
- const types = getSupportedTypes();
89
-
90
- expect(types).toHaveProperty('extensions');
91
- expect(types).toHaveProperty('filenames');
92
- expect(Array.isArray(types.extensions)).toBe(true);
93
- expect(Array.isArray(types.filenames)).toBe(true);
94
- });
95
-
96
- it('should include .md in extensions', () => {
97
- const types = getSupportedTypes();
98
- expect(types.extensions).toContain('.md');
99
- });
100
-
101
- it('should include .env in filenames', () => {
102
- const types = getSupportedTypes();
103
- expect(types.filenames).toContain('.env');
104
- });
105
- });
106
-
107
- describe('registerStrategy', () => {
108
- it('should allow registering custom strategies for extensions', () => {
109
- class CustomMerger extends ReplaceMerger {
110
- name = 'custom';
111
- }
112
-
113
- registerStrategy('.custom', CustomMerger);
114
-
115
- const merger = getMergeStrategy('file.custom');
116
- expect(merger.name).toBe('custom');
117
- });
118
- });
119
-
120
- describe('registerFileNameStrategy', () => {
121
- it('should allow registering strategies for specific filenames', () => {
122
- class SpecialMerger extends ReplaceMerger {
123
- name = 'special';
124
- }
125
-
126
- registerFileNameStrategy('.special-config', SpecialMerger);
127
-
128
- const merger = getMergeStrategy('.special-config');
129
- expect(merger.name).toBe('special');
130
- });
131
- });
132
-
133
- describe('ReplaceMerger', () => {
134
- let merger;
135
-
136
- beforeEach(() => {
137
- merger = new ReplaceMerger();
138
- });
139
-
140
- it('should return new content as-is', async () => {
141
- const existing = 'old content';
142
- const newContent = 'new content';
143
-
144
- const result = await merger.merge(existing, newContent);
145
-
146
- expect(result.content).toBe('new content');
147
- expect(result.stats.updated).toBe(1);
148
- });
149
-
150
- it('should report canMerge as false', () => {
151
- expect(merger.canMerge('', '')).toBe(false);
152
- });
153
- });
154
-
@@ -1,328 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * YAML Merger Strategy Tests (Story INS-4.7)
5
- *
6
- * Validates Phase 1 merge rules:
7
- * - New keys added from source (framework)
8
- * - User values preserved on conflict (target wins)
9
- * - Deprecated keys kept with warning
10
- * - Output is valid YAML
11
- */
12
-
13
- const yaml = require('js-yaml');
14
- const path = require('path');
15
- const fs = require('fs');
16
-
17
- const { YamlMerger } = require(path.join(
18
- __dirname, '..', '..', '..', 'src', 'merger', 'strategies', 'yaml-merger.js'
19
- ));
20
-
21
- describe('YamlMerger (Story INS-4.7)', () => {
22
- let merger;
23
-
24
- beforeAll(() => {
25
- merger = new YamlMerger();
26
- });
27
-
28
- describe('AC1: Strategy interface', () => {
29
- test('extends BaseMerger with name "yaml"', () => {
30
- expect(merger.name).toBe('yaml');
31
- });
32
-
33
- test('canMerge returns true for valid YAML', () => {
34
- expect(merger.canMerge('key: value\n', 'other: data\n')).toBe(true);
35
- });
36
-
37
- test('canMerge returns false for invalid YAML', () => {
38
- expect(merger.canMerge('key: value\n', '{{invalid')).toBe(false);
39
- });
40
-
41
- test('merge is async and returns MergeResult', async () => {
42
- const result = await merger.merge('a: 1\n', 'a: 1\n');
43
- expect(result).toHaveProperty('content');
44
- expect(result).toHaveProperty('stats');
45
- expect(result).toHaveProperty('changes');
46
- });
47
-
48
- test('getDescription returns meaningful text', () => {
49
- expect(merger.getDescription()).toContain('YAML');
50
- expect(merger.getDescription()).toContain('Phase 1');
51
- });
52
- });
53
-
54
- describe('AC1: Strategy registration', () => {
55
- test('.yaml extension registered in strategies/index.js', () => {
56
- const { hasMergeStrategy, getMergeStrategy } = require(path.join(
57
- __dirname, '..', '..', '..', 'src', 'merger', 'strategies', 'index.js'
58
- ));
59
-
60
- expect(hasMergeStrategy('config.yaml')).toBe(true);
61
- const strategy = getMergeStrategy('config.yaml');
62
- expect(strategy.name).toBe('yaml');
63
- });
64
-
65
- test('.yml extension also registered', () => {
66
- const { hasMergeStrategy } = require(path.join(
67
- __dirname, '..', '..', '..', 'src', 'merger', 'strategies', 'index.js'
68
- ));
69
-
70
- expect(hasMergeStrategy('config.yml')).toBe(true);
71
- });
72
-
73
- test('YamlMerger exported from merger/index.js', () => {
74
- const mergerModule = require(path.join(
75
- __dirname, '..', '..', '..', 'src', 'merger', 'index.js'
76
- ));
77
-
78
- expect(mergerModule.YamlMerger).toBeDefined();
79
- });
80
- });
81
-
82
- describe('AC2: Phase 1 merge rules', () => {
83
- test('new key in source → added to merged output', async () => {
84
- const source = yaml.dump({ existingKey: 'a', newFeature: { enabled: true } });
85
- const target = yaml.dump({ existingKey: 'a' });
86
-
87
- const result = await merger.merge(source, target);
88
- const merged = yaml.load(result.content);
89
-
90
- expect(merged.newFeature).toEqual({ enabled: true });
91
- expect(result.stats.added).toBeGreaterThanOrEqual(1);
92
-
93
- const addedChange = result.changes.find(
94
- c => c.type === 'added' && c.identifier === 'newFeature'
95
- );
96
- expect(addedChange).toBeDefined();
97
- });
98
-
99
- test('key in both with same value → target value preserved', async () => {
100
- const source = yaml.dump({ key: 'same' });
101
- const target = yaml.dump({ key: 'same' });
102
-
103
- const result = await merger.merge(source, target);
104
- const merged = yaml.load(result.content);
105
-
106
- expect(merged.key).toBe('same');
107
- expect(result.stats.preserved).toBeGreaterThanOrEqual(1);
108
-
109
- const preservedChange = result.changes.find(
110
- c => c.type === 'preserved' && c.identifier === 'key'
111
- );
112
- expect(preservedChange).toBeDefined();
113
- });
114
-
115
- test('conflict (different values) → target wins', async () => {
116
- const source = yaml.dump({ setting: 'framework-default' });
117
- const target = yaml.dump({ setting: 'user-custom' });
118
-
119
- const result = await merger.merge(source, target);
120
- const merged = yaml.load(result.content);
121
-
122
- expect(merged.setting).toBe('user-custom');
123
- expect(result.stats.conflicts).toBeGreaterThanOrEqual(1);
124
-
125
- const conflictChange = result.changes.find(
126
- c => c.type === 'conflict' && c.identifier === 'setting'
127
- );
128
- expect(conflictChange).toBeDefined();
129
- expect(conflictChange.reason).toContain('Keeping user value');
130
- });
131
-
132
- test('deprecated key (in target, not in source) → kept with warning', async () => {
133
- const source = yaml.dump({ current: true });
134
- const target = yaml.dump({ current: true, legacyKey: 'old-value' });
135
-
136
- const result = await merger.merge(source, target);
137
- const merged = yaml.load(result.content);
138
-
139
- expect(merged.legacyKey).toBe('old-value');
140
-
141
- const deprecatedChange = result.changes.find(
142
- c => c.type === 'conflict' && c.identifier === 'legacyKey'
143
- );
144
- expect(deprecatedChange).toBeDefined();
145
- expect(deprecatedChange.reason).toContain('Deprecated');
146
- });
147
-
148
- test('output is valid YAML', async () => {
149
- const source = yaml.dump({ a: 1, b: { c: 2 }, d: [1, 2, 3] });
150
- const target = yaml.dump({ a: 99, e: 'user' });
151
-
152
- const result = await merger.merge(source, target);
153
-
154
- expect(() => yaml.load(result.content)).not.toThrow();
155
- });
156
-
157
- test('all changes in MergeResult.changes array (no separate warnings)', async () => {
158
- const source = yaml.dump({ a: 1, b: 2 });
159
- const target = yaml.dump({ a: 99, c: 3 });
160
-
161
- const result = await merger.merge(source, target);
162
-
163
- expect(result).not.toHaveProperty('warnings');
164
- expect(Array.isArray(result.changes)).toBe(true);
165
- expect(result.changes.length).toBeGreaterThan(0);
166
- });
167
- });
168
-
169
- describe('AC2: Deep merge', () => {
170
- test('nested new keys added at depth', async () => {
171
- const source = yaml.dump({
172
- boundary: { frameworkProtection: true, newSetting: 'added' },
173
- });
174
- const target = yaml.dump({
175
- boundary: { frameworkProtection: false },
176
- });
177
-
178
- const result = await merger.merge(source, target);
179
- const merged = yaml.load(result.content);
180
-
181
- expect(merged.boundary.frameworkProtection).toBe(false); // user wins
182
- expect(merged.boundary.newSetting).toBe('added'); // new key added
183
- });
184
-
185
- test('nested conflict preserves user value', async () => {
186
- const source = yaml.dump({
187
- pvMindContext: { location: 'default-path' },
188
- });
189
- const target = yaml.dump({
190
- pvMindContext: { location: 'user-custom-path' },
191
- });
192
-
193
- const result = await merger.merge(source, target);
194
- const merged = yaml.load(result.content);
195
-
196
- expect(merged.pvMindContext.location).toBe('user-custom-path');
197
- });
198
- });
199
-
200
- describe('AC4: User config preservation', () => {
201
- test('custom pvMindContext.location preserved after upgrade', async () => {
202
- const source = yaml.dump({
203
- project: { type: 'EXISTING_SINAPSE', version: '2.2.0' },
204
- pvMindContext: { location: 'default' },
205
- });
206
- const target = yaml.dump({
207
- project: { type: 'EXISTING_SINAPSE', version: '2.1.0' },
208
- pvMindContext: { location: '/my/custom/path' },
209
- });
210
-
211
- const result = await merger.merge(source, target);
212
- const merged = yaml.load(result.content);
213
-
214
- expect(merged.pvMindContext.location).toBe('/my/custom/path');
215
- });
216
-
217
- test('new framework key added alongside preserved user config', async () => {
218
- const source = yaml.dump({
219
- existing: 'value',
220
- someNewFeature: { enabled: true },
221
- });
222
- const target = yaml.dump({
223
- existing: 'value',
224
- });
225
-
226
- const result = await merger.merge(source, target);
227
- const merged = yaml.load(result.content);
228
-
229
- expect(merged.existing).toBe('value');
230
- expect(merged.someNewFeature).toEqual({ enabled: true });
231
- });
232
- });
233
-
234
- describe('AC5: Boundary section preservation', () => {
235
- test('user-customized boundary paths NOT removed', async () => {
236
- const source = yaml.dump({
237
- boundary: {
238
- frameworkProtection: true,
239
- protected: ['.sinapse-ai/core/'],
240
- },
241
- });
242
- const target = yaml.dump({
243
- boundary: {
244
- frameworkProtection: false,
245
- protected: ['.sinapse-ai/core/', 'my-custom-path/'],
246
- exceptions: ['my-exception/'],
247
- },
248
- });
249
-
250
- const result = await merger.merge(source, target);
251
- const merged = yaml.load(result.content);
252
-
253
- // User boundary values preserved (target wins on arrays — no deep array merge)
254
- expect(merged.boundary.frameworkProtection).toBe(false);
255
- expect(merged.boundary.protected).toContain('my-custom-path/');
256
- expect(merged.boundary.exceptions).toContain('my-exception/');
257
- });
258
- });
259
-
260
- describe('AC6: Edge cases', () => {
261
- test('empty source → target preserved as-is', async () => {
262
- const source = '';
263
- const target = yaml.dump({ user: 'config' });
264
-
265
- const result = await merger.merge(source, target);
266
- const merged = yaml.load(result.content);
267
-
268
- expect(merged.user).toBe('config');
269
- });
270
-
271
- test('empty target → source keys added', async () => {
272
- const source = yaml.dump({ framework: 'config' });
273
- const target = '';
274
-
275
- const result = await merger.merge(source, target);
276
- const merged = yaml.load(result.content);
277
-
278
- expect(merged.framework).toBe('config');
279
- });
280
-
281
- test('arrays treated as scalar (target wins, not merged)', async () => {
282
- const source = yaml.dump({ list: [1, 2, 3] });
283
- const target = yaml.dump({ list: [4, 5] });
284
-
285
- const result = await merger.merge(source, target);
286
- const merged = yaml.load(result.content);
287
-
288
- expect(merged.list).toEqual([4, 5]); // target wins
289
- });
290
- });
291
- });
292
-
293
- describe('Brownfield Upgrader Integration (Story INS-4.7)', () => {
294
- test('brownfield-upgrader imports YamlMerger', () => {
295
- const upgraderSource = fs.readFileSync(
296
- path.join(__dirname, '..', '..', '..', 'src', 'installer', 'brownfield-upgrader.js'),
297
- 'utf8'
298
- );
299
- expect(upgraderSource).toContain('YamlMerger');
300
- expect(upgraderSource).toContain('yaml-merger.js');
301
- });
302
-
303
- test('upgrader has core-config.yaml merge exception in userModifiedFiles loop', () => {
304
- const upgraderSource = fs.readFileSync(
305
- path.join(__dirname, '..', '..', '..', 'src', 'installer', 'brownfield-upgrader.js'),
306
- 'utf8'
307
- );
308
- expect(upgraderSource).toContain("file.path.endsWith('core-config.yaml')");
309
- expect(upgraderSource).toContain('merger.merge(sourceContent, targetContent)');
310
- expect(upgraderSource).toContain('.backup-');
311
- });
312
-
313
- test('upgrader still skips non-yaml user-modified files', () => {
314
- const upgraderSource = fs.readFileSync(
315
- path.join(__dirname, '..', '..', '..', 'src', 'installer', 'brownfield-upgrader.js'),
316
- 'utf8'
317
- );
318
- expect(upgraderSource).toContain('User modified - preserving local changes');
319
- });
320
- });
321
-
322
- describe('Existing strategies still work', () => {
323
- test('strategies.test.js file exists (regression guard)', () => {
324
- const testPath = path.join(__dirname, 'strategies.test.js');
325
- expect(fs.existsSync(testPath)).toBe(true);
326
- });
327
- });
328
-
@@ -1,66 +0,0 @@
1
- /**
2
- * Chrome Brain — smoke tests
3
- *
4
- * @audit Audit 2 P0 (Q1.2) — flagship capability shipped at 0% coverage.
5
- * This suite locks in the public contract so future regressions surface
6
- * without exercising real Chrome / filesystem mutations (those require an
7
- * integration env). Coverage of `detectChrome()` and `getChromeBrainStatus()`
8
- * is best-effort because both are environment-aware.
9
- */
10
-
11
- 'use strict';
12
-
13
- const path = require('path');
14
-
15
- const chromeBrain = require(
16
- path.join(__dirname, '..', '..', 'src', 'capabilities', 'chrome-brain'),
17
- );
18
-
19
- describe('chrome-brain — public contract (Audit 2 Q1.2 smoke)', () => {
20
- test('exports the documented surface', () => {
21
- expect(typeof chromeBrain.installChromeBrain).toBe('function');
22
- expect(typeof chromeBrain.uninstallChromeBrain).toBe('function');
23
- expect(typeof chromeBrain.getChromeBrainStatus).toBe('function');
24
- expect(typeof chromeBrain.detectChrome).toBe('function');
25
- });
26
-
27
- test('detectChrome returns the documented shape', () => {
28
- const result = chromeBrain.detectChrome();
29
- expect(result).toEqual(expect.objectContaining({
30
- found: expect.any(Boolean),
31
- }));
32
- // path is string|null, variant is string|null
33
- expect(['string', 'object']).toContain(typeof result.path);
34
- expect(['string', 'object']).toContain(typeof result.variant);
35
- if (result.path !== null) expect(typeof result.path).toBe('string');
36
- if (result.variant !== null) expect(typeof result.variant).toBe('string');
37
- });
38
-
39
- test('detectChrome is deterministic across calls', () => {
40
- const first = chromeBrain.detectChrome();
41
- const second = chromeBrain.detectChrome();
42
- expect(first).toEqual(second);
43
- });
44
-
45
- test('getChromeBrainStatus returns an object without throwing', () => {
46
- expect(() => chromeBrain.getChromeBrainStatus()).not.toThrow();
47
- const status = chromeBrain.getChromeBrainStatus();
48
- expect(typeof status).toBe('object');
49
- expect(status).not.toBeNull();
50
- });
51
-
52
- test('uninstallChromeBrain accepts options without throwing on dry path', () => {
53
- // Dry-run / status-only call should not perform destructive ops when
54
- // the install markers are absent. We do NOT pass `{ force: true }`.
55
- expect(() => chromeBrain.uninstallChromeBrain({ dryRun: true })).not.toThrow();
56
- });
57
-
58
- test('installChromeBrain function arity is callable (not invoked here)', () => {
59
- // Sanity-check arity without invoking (install is destructive). A
60
- // real install requires a Chrome binary + writes to ~/.claude/, which
61
- // is out of scope for unit-test smoke. Integration coverage is a
62
- // separate follow-up story.
63
- expect(chromeBrain.installChromeBrain.length).toBeGreaterThanOrEqual(0);
64
- expect(chromeBrain.installChromeBrain.length).toBeLessThanOrEqual(2);
65
- });
66
- });