@inspecto-dev/cli 0.3.3 → 0.3.5

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 (46) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/.turbo/turbo-test.log +10594 -4044
  3. package/CHANGELOG.md +28 -0
  4. package/dist/bin.js +36 -2
  5. package/dist/{chunk-LJOKPCPD.js → chunk-7ABJRH3F.js} +1701 -182
  6. package/dist/index.d.ts +69 -4
  7. package/dist/index.js +7 -1
  8. package/package.json +3 -3
  9. package/src/bin.ts +49 -1
  10. package/src/commands/dev-config.ts +109 -0
  11. package/src/commands/doctor.ts +189 -9
  12. package/src/commands/init.ts +10 -3
  13. package/src/commands/integration-automation.ts +2 -0
  14. package/src/commands/integration-host-ide.ts +18 -15
  15. package/src/commands/integration-install.ts +100 -5
  16. package/src/commands/onboard.ts +80 -15
  17. package/src/detect/build-tool.ts +212 -15
  18. package/src/detect/framework.ts +3 -0
  19. package/src/detect/package-manager.ts +1 -1
  20. package/src/index.ts +1 -0
  21. package/src/inject/gitignore.ts +13 -2
  22. package/src/instructions.ts +33 -7
  23. package/src/onboarding/apply.ts +255 -28
  24. package/src/onboarding/nextjs-guidance.ts +257 -0
  25. package/src/onboarding/nuxt-guidance.ts +129 -0
  26. package/src/onboarding/planner.ts +337 -10
  27. package/src/onboarding/session.ts +127 -31
  28. package/src/onboarding/target-resolution.ts +79 -3
  29. package/src/onboarding/umi-guidance.ts +139 -0
  30. package/src/types.ts +58 -3
  31. package/tests/apply.test.ts +553 -0
  32. package/tests/build-tool.test.ts +199 -0
  33. package/tests/dev-config.test.ts +73 -0
  34. package/tests/doctor.test.ts +130 -0
  35. package/tests/init.test.ts +17 -0
  36. package/tests/install-wrapper.test.ts +56 -0
  37. package/tests/instructions.test.ts +10 -6
  38. package/tests/integration-host-ide.test.ts +20 -0
  39. package/tests/integration-install.test.ts +193 -0
  40. package/tests/nextjs-guidance.test.ts +128 -0
  41. package/tests/nuxt-guidance.test.ts +67 -0
  42. package/tests/onboard.test.ts +511 -0
  43. package/tests/plan.test.ts +283 -21
  44. package/tests/runner-script.test.ts +120 -1
  45. package/tests/session-resolve.test.ts +116 -0
  46. package/tests/session.test.ts +120 -0
@@ -68,6 +68,101 @@ describe('target resolution', () => {
68
68
  expect(resolution.status).toBe('resolved')
69
69
  expect(resolution.selected?.packagePath).toBe('apps/web')
70
70
  })
71
+
72
+ it('requires explicit selection when one package has multiple supported build configs', () => {
73
+ const resolution = resolveOnboardingTarget({
74
+ repoRoot: '/repo',
75
+ buildTools: [
76
+ {
77
+ tool: 'vite',
78
+ configPath: 'finder/vite.config.mts',
79
+ label: 'Vite (finder/vite.config.mts)',
80
+ packagePath: 'finder',
81
+ },
82
+ {
83
+ tool: 'rspack',
84
+ configPath: 'finder/rspack-config/rspack.config.dev.ts',
85
+ label: 'Rspack (finder/rspack-config/rspack.config.dev.ts)',
86
+ packagePath: 'finder',
87
+ isLegacyRspack: true,
88
+ },
89
+ ],
90
+ frameworkSupportByPackage: {
91
+ finder: ['react'],
92
+ },
93
+ })
94
+
95
+ expect(resolution.status).toBe('needs_selection')
96
+ expect(resolution.candidates).toHaveLength(2)
97
+ expect(new Set(resolution.candidates.map(item => item.id)).size).toBe(2)
98
+ expect(new Set(resolution.candidates.map(item => item.candidateId)).size).toBe(2)
99
+ expect(resolution.candidates.map(item => item.configPath)).toEqual([
100
+ 'finder/vite.config.mts',
101
+ 'finder/rspack-config/rspack.config.dev.ts',
102
+ ])
103
+ expect(resolution.selectionPurpose).toContain('build target')
104
+ expect(resolution.selectionInstructions).toContain('--target <candidateId>')
105
+ })
106
+
107
+ it('resolves an explicitly selected build target by candidate id', () => {
108
+ const resolution = resolveOnboardingTarget({
109
+ repoRoot: '/repo',
110
+ buildTools: [
111
+ {
112
+ tool: 'vite',
113
+ configPath: 'finder/vite.config.mts',
114
+ label: 'Vite (finder/vite.config.mts)',
115
+ packagePath: 'finder',
116
+ },
117
+ {
118
+ tool: 'rspack',
119
+ configPath: 'finder/rspack-config/rspack.config.dev.ts',
120
+ label: 'Rspack (finder/rspack-config/rspack.config.dev.ts)',
121
+ packagePath: 'finder',
122
+ isLegacyRspack: true,
123
+ },
124
+ ],
125
+ frameworkSupportByPackage: {
126
+ finder: ['react'],
127
+ },
128
+ selectedPackagePath: 'finder:rspack:finder/rspack-config/rspack.config.dev.ts',
129
+ })
130
+
131
+ expect(resolution.status).toBe('resolved')
132
+ expect(resolution.selected?.buildTool).toBe('rspack')
133
+ expect(resolution.selected?.configPath).toBe('finder/rspack-config/rspack.config.dev.ts')
134
+ expect(resolution.selected?.isLegacyRspack).toBe(true)
135
+ })
136
+
137
+ it('resolves an explicitly selected build target by config path for root-level candidates', () => {
138
+ const resolution = resolveOnboardingTarget({
139
+ repoRoot: '/repo',
140
+ buildTools: [
141
+ {
142
+ tool: 'webpack',
143
+ configPath: 'webpack.config.common.js',
144
+ label: 'Webpack (webpack.config.common.js)',
145
+ packagePath: '',
146
+ isLegacyWebpack: true,
147
+ },
148
+ {
149
+ tool: 'webpack',
150
+ configPath: 'webpack.dll.config.js',
151
+ label: 'Webpack (webpack.dll.config.js)',
152
+ packagePath: '',
153
+ isLegacyWebpack: true,
154
+ },
155
+ ],
156
+ frameworkSupportByPackage: {
157
+ '': ['react'],
158
+ },
159
+ selectedPackagePath: 'webpack.config.common.js',
160
+ })
161
+
162
+ expect(resolution.status).toBe('resolved')
163
+ expect(resolution.selected?.configPath).toBe('webpack.config.common.js')
164
+ expect(resolution.selected?.buildTool).toBe('webpack')
165
+ })
71
166
  })
72
167
 
73
168
  describe('onboard command', () => {
@@ -172,6 +267,173 @@ describe('onboard command', () => {
172
267
  expect(result.verification?.devCommand).toBe('pnpm dev')
173
268
  })
174
269
 
270
+ it('keeps guided Next.js patch metadata in deferred JSON output', async () => {
271
+ const session: ResolvedOnboardingSession = {
272
+ status: 'needs_confirmation',
273
+ target: {
274
+ status: 'guided',
275
+ candidates: [],
276
+ reason: 'Awaiting confirmation before guided onboarding.',
277
+ },
278
+ summary: {
279
+ headline: 'Inspecto can partially onboard /repo, but manual follow-up remains.',
280
+ changes: ['Install the Inspecto runtime packages with pnpm.'],
281
+ risks: [],
282
+ manualFollowUp: [
283
+ 'Generate a guided patch plan for the Next.js Inspecto webpack integration.',
284
+ 'Complete the remaining client-side Inspecto mount step in your assistant or editor.',
285
+ ],
286
+ },
287
+ confirmation: {
288
+ required: true,
289
+ question:
290
+ 'Proceed with Inspecto onboarding using the proposed default target and settings?',
291
+ },
292
+ verification: {
293
+ available: true,
294
+ devCommand: 'pnpm dev',
295
+ message: 'Start the local dev server with `pnpm dev` to verify Inspecto in the browser.',
296
+ },
297
+ context: {
298
+ root: '/repo',
299
+ packageManager: 'pnpm',
300
+ buildTools: { supported: [], unsupported: ['Next.js'] },
301
+ frameworks: { supported: ['react'], unsupported: [] },
302
+ ides: [{ ide: 'vscode', supported: true }],
303
+ providers: [{ id: 'codex', label: 'Codex CLI', supported: true, preferredMode: 'cli' }],
304
+ },
305
+ plan: {
306
+ status: 'warning',
307
+ warnings: [],
308
+ blockers: [],
309
+ strategy: 'guided',
310
+ actions: [],
311
+ defaults: {
312
+ provider: 'codex',
313
+ ide: 'vscode',
314
+ shared: false,
315
+ extension: true,
316
+ },
317
+ framework: 'react',
318
+ metaFramework: 'Next.js',
319
+ routerMode: 'app',
320
+ autoApplied: ['dependencies', 'inspecto_settings'],
321
+ pendingSteps: [
322
+ 'Review the generated Next.js patch plan for next.config.mjs.',
323
+ 'Complete the remaining client-side mount step for your App Router entry.',
324
+ ],
325
+ assistantPrompt: 'Complete the remaining Inspecto onboarding for this Next.js project.',
326
+ patches: [
327
+ {
328
+ path: 'next.config.mjs',
329
+ status: 'planned',
330
+ reason: 'next_config_object_export',
331
+ confidence: 'high',
332
+ snippet: '...',
333
+ },
334
+ {
335
+ path: 'app/layout.tsx',
336
+ status: 'manual_patch_required',
337
+ reason: 'next_app_router_mount',
338
+ confidence: 'medium',
339
+ snippet: '...',
340
+ },
341
+ ],
342
+ },
343
+ projectRoot: '/repo',
344
+ selectedIDE: { ide: 'vscode', supported: true },
345
+ providerDefault: 'codex.cli',
346
+ framework: 'react',
347
+ metaFramework: 'Next.js',
348
+ routerMode: 'app',
349
+ autoApplied: ['dependencies', 'inspecto_settings'],
350
+ pendingSteps: [
351
+ 'Review the generated Next.js patch plan for next.config.mjs.',
352
+ 'Complete the remaining client-side mount step for your App Router entry.',
353
+ ],
354
+ assistantPrompt: 'Complete the remaining Inspecto onboarding for this Next.js project.',
355
+ patches: [
356
+ {
357
+ path: 'next.config.mjs',
358
+ status: 'planned',
359
+ reason: 'next_config_object_export',
360
+ confidence: 'high',
361
+ snippet: '...',
362
+ },
363
+ {
364
+ path: 'app/layout.tsx',
365
+ status: 'manual_patch_required',
366
+ reason: 'next_app_router_mount',
367
+ confidence: 'medium',
368
+ snippet: '...',
369
+ },
370
+ ],
371
+ }
372
+
373
+ const deferred: OnboardCommandResult = {
374
+ status: 'needs_confirmation',
375
+ target: session.target,
376
+ summary: session.summary,
377
+ confirmation: session.confirmation,
378
+ ideExtension: {
379
+ required: true,
380
+ installed: false,
381
+ manualRequired: true,
382
+ installCommand: 'code --install-extension inspecto.inspecto',
383
+ marketplaceUrl: 'https://marketplace.visualstudio.com/items?itemName=inspecto.inspecto',
384
+ openVsxUrl: 'https://open-vsx.org/extension/inspecto/inspecto',
385
+ },
386
+ verification: session.verification,
387
+ framework: 'react',
388
+ metaFramework: 'Next.js',
389
+ routerMode: 'app',
390
+ autoApplied: ['dependencies', 'inspecto_settings'],
391
+ pendingSteps: [
392
+ 'Review the generated Next.js patch plan for next.config.mjs.',
393
+ 'Complete the remaining client-side mount step for your App Router entry.',
394
+ ],
395
+ assistantPrompt: 'Complete the remaining Inspecto onboarding for this Next.js project.',
396
+ patches: [
397
+ {
398
+ path: 'next.config.mjs',
399
+ status: 'planned',
400
+ reason: 'next_config_object_export',
401
+ confidence: 'high',
402
+ snippet: '...',
403
+ },
404
+ {
405
+ path: 'app/layout.tsx',
406
+ status: 'manual_patch_required',
407
+ reason: 'next_app_router_mount',
408
+ confidence: 'medium',
409
+ snippet: '...',
410
+ },
411
+ ],
412
+ }
413
+
414
+ vi.mocked(resolveOnboardingSession).mockResolvedValue(session)
415
+ vi.mocked(buildDeferredOnboardResult).mockReturnValue(deferred)
416
+
417
+ const result = await onboard({ json: true })
418
+
419
+ expect(result.metaFramework).toBe('Next.js')
420
+ expect(result.routerMode).toBe('app')
421
+ expect(result.handoff?.metaFramework).toBe('Next.js')
422
+ expect(result.handoff?.pendingSteps).toEqual(
423
+ expect.arrayContaining([
424
+ 'Review the generated Next.js patch plan for next.config.mjs.',
425
+ 'Complete the remaining client-side mount step for your App Router entry.',
426
+ ]),
427
+ )
428
+ expect(result.assistantPrompt).toContain('Complete the remaining Inspecto onboarding')
429
+ expect(result.patches).toEqual(
430
+ expect.arrayContaining([
431
+ expect.objectContaining({ path: 'next.config.mjs', reason: 'next_config_object_export' }),
432
+ expect.objectContaining({ path: 'app/layout.tsx', reason: 'next_app_router_mount' }),
433
+ ]),
434
+ )
435
+ })
436
+
175
437
  it('returns needs_target_selection without applying when target selection is ambiguous', async () => {
176
438
  const session: ResolvedOnboardingSession = {
177
439
  status: 'needs_target_selection',
@@ -359,6 +621,255 @@ describe('onboard command', () => {
359
621
  ).toBe(false)
360
622
  })
361
623
 
624
+ it('prints guided patch targets and assistant handoff in text mode', async () => {
625
+ const session: ResolvedOnboardingSession = {
626
+ status: 'partial_success',
627
+ target: {
628
+ status: 'resolved',
629
+ selected: {
630
+ packagePath: '',
631
+ configPath: 'next.config.mjs',
632
+ buildTool: 'webpack',
633
+ frameworks: ['react'],
634
+ automaticInjection: false,
635
+ },
636
+ candidates: [],
637
+ reason: 'Guided onboarding is available.',
638
+ },
639
+ summary: {
640
+ headline: 'Inspecto can partially onboard /repo, but manual follow-up remains.',
641
+ changes: ['Install the Inspecto runtime packages with pnpm.'],
642
+ risks: [],
643
+ manualFollowUp: [
644
+ 'Generate a guided patch plan for the Next.js Inspecto webpack integration.',
645
+ 'Complete the remaining client-side Inspecto mount step in your assistant or editor.',
646
+ ],
647
+ },
648
+ confirmation: { required: false },
649
+ verification: {
650
+ available: true,
651
+ devCommand: 'pnpm dev',
652
+ message: 'Start the local dev server with `pnpm dev` to verify Inspecto in the browser.',
653
+ },
654
+ context: {
655
+ root: '/repo',
656
+ packageManager: 'pnpm',
657
+ buildTools: { supported: [], unsupported: ['Next.js'] },
658
+ frameworks: { supported: ['react'], unsupported: [] },
659
+ ides: [{ ide: 'vscode', supported: true }],
660
+ providers: [{ id: 'codex', label: 'Codex CLI', supported: true, preferredMode: 'cli' }],
661
+ },
662
+ plan: {
663
+ status: 'warning',
664
+ warnings: [],
665
+ blockers: [],
666
+ strategy: 'guided',
667
+ actions: [],
668
+ defaults: {
669
+ provider: 'codex',
670
+ ide: 'vscode',
671
+ shared: false,
672
+ extension: true,
673
+ },
674
+ },
675
+ projectRoot: '/repo',
676
+ selectedIDE: { ide: 'vscode', supported: true },
677
+ providerDefault: 'codex.cli',
678
+ }
679
+
680
+ const applied: OnboardCommandResult = {
681
+ status: 'partial_success',
682
+ target: session.target,
683
+ summary: session.summary,
684
+ confirmation: session.confirmation,
685
+ ideExtension: {
686
+ required: true,
687
+ installed: true,
688
+ manualRequired: false,
689
+ installCommand: 'code --install-extension inspecto.inspecto',
690
+ marketplaceUrl: 'https://marketplace.visualstudio.com/items?itemName=inspecto.inspecto',
691
+ openVsxUrl: 'https://open-vsx.org/extension/inspecto/inspecto',
692
+ },
693
+ verification: session.verification,
694
+ diagnostics: {
695
+ warnings: [],
696
+ errors: [],
697
+ nextSteps: [
698
+ 'Generate a guided patch plan for the Next.js Inspecto webpack integration.',
699
+ 'Complete the remaining client-side Inspecto mount step in your assistant or editor.',
700
+ ],
701
+ },
702
+ metaFramework: 'Next.js',
703
+ routerMode: 'app',
704
+ pendingSteps: [
705
+ 'Review the generated Next.js patch plan for next.config.mjs.',
706
+ 'Complete the remaining client-side mount step for your App Router entry.',
707
+ ],
708
+ assistantPrompt: 'Complete the remaining Inspecto onboarding for this Next.js project.',
709
+ patches: [
710
+ {
711
+ path: 'next.config.mjs',
712
+ status: 'planned',
713
+ reason: 'next_config_object_export',
714
+ confidence: 'high',
715
+ snippet: '...',
716
+ },
717
+ {
718
+ path: 'app/layout.tsx',
719
+ status: 'manual_patch_required',
720
+ reason: 'next_app_router_mount',
721
+ confidence: 'medium',
722
+ snippet: '...',
723
+ },
724
+ ],
725
+ }
726
+
727
+ vi.mocked(resolveOnboardingSession).mockResolvedValue(session)
728
+ vi.mocked(applyResolvedOnboardingSession).mockResolvedValue(applied)
729
+
730
+ const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
731
+
732
+ await onboard({ json: false })
733
+
734
+ expect(consoleSpy.mock.calls.some(call => String(call[0]).includes('next.config.mjs'))).toBe(
735
+ true,
736
+ )
737
+ expect(
738
+ consoleSpy.mock.calls.some(call =>
739
+ String(call[0]).includes('Complete the remaining Inspecto onboarding'),
740
+ ),
741
+ ).toBe(true)
742
+ expect(
743
+ consoleSpy.mock.calls.some(call =>
744
+ String(call[0]).includes(
745
+ 'Complete the remaining client-side mount step for your App Router entry.',
746
+ ),
747
+ ),
748
+ ).toBe(true)
749
+ })
750
+
751
+ it('keeps guided Nuxt handoff metadata in applied JSON output', async () => {
752
+ const session: ResolvedOnboardingSession = {
753
+ status: 'partial_success',
754
+ target: {
755
+ status: 'resolved',
756
+ selected: {
757
+ packagePath: '',
758
+ configPath: 'nuxt.config.ts',
759
+ buildTool: 'vite',
760
+ frameworks: ['vue'],
761
+ automaticInjection: false,
762
+ },
763
+ candidates: [],
764
+ reason: 'Guided onboarding is available.',
765
+ },
766
+ summary: {
767
+ headline: 'Inspecto can partially onboard /repo, but manual follow-up remains.',
768
+ changes: ['Install the Inspecto runtime packages with pnpm.'],
769
+ risks: [],
770
+ manualFollowUp: [
771
+ 'Generate a guided patch plan for the Nuxt Inspecto Vite integration.',
772
+ 'Complete the remaining Nuxt client plugin mount step in your assistant or editor.',
773
+ ],
774
+ },
775
+ confirmation: { required: false },
776
+ verification: {
777
+ available: true,
778
+ devCommand: 'pnpm dev',
779
+ message: 'Start the local dev server with `pnpm dev` to verify Inspecto in the browser.',
780
+ },
781
+ context: {
782
+ root: '/repo',
783
+ packageManager: 'pnpm',
784
+ buildTools: { supported: [], unsupported: ['Nuxt'] },
785
+ frameworks: { supported: ['vue'], unsupported: [] },
786
+ ides: [{ ide: 'vscode', supported: true }],
787
+ providers: [{ id: 'codex', label: 'Codex CLI', supported: true, preferredMode: 'cli' }],
788
+ },
789
+ plan: {
790
+ status: 'warning',
791
+ warnings: [],
792
+ blockers: [],
793
+ strategy: 'guided',
794
+ actions: [],
795
+ defaults: {
796
+ provider: 'codex',
797
+ ide: 'vscode',
798
+ shared: false,
799
+ extension: true,
800
+ },
801
+ },
802
+ projectRoot: '/repo',
803
+ selectedIDE: { ide: 'vscode', supported: true },
804
+ providerDefault: 'codex.cli',
805
+ }
806
+
807
+ const applied: OnboardCommandResult = {
808
+ status: 'partial_success',
809
+ target: session.target,
810
+ summary: session.summary,
811
+ confirmation: session.confirmation,
812
+ ideExtension: {
813
+ required: true,
814
+ installed: true,
815
+ manualRequired: false,
816
+ installCommand: 'code --install-extension inspecto.inspecto',
817
+ marketplaceUrl: 'https://marketplace.visualstudio.com/items?itemName=inspecto.inspecto',
818
+ openVsxUrl: 'https://open-vsx.org/extension/inspecto/inspecto',
819
+ },
820
+ verification: session.verification,
821
+ diagnostics: {
822
+ warnings: [],
823
+ errors: [],
824
+ nextSteps: [
825
+ 'Generate a guided patch plan for the Nuxt Inspecto Vite integration.',
826
+ 'Complete the remaining Nuxt client plugin mount step in your assistant or editor.',
827
+ ],
828
+ },
829
+ framework: 'vue',
830
+ metaFramework: 'Nuxt',
831
+ autoApplied: ['dependencies', 'inspecto_settings'],
832
+ pendingSteps: [
833
+ 'Review the generated Nuxt patch plan for nuxt.config.ts.',
834
+ 'Complete the remaining Nuxt client plugin mount step in plugins/inspecto.client.ts.',
835
+ ],
836
+ assistantPrompt: 'Complete the remaining Inspecto onboarding for this Nuxt project.',
837
+ patches: [
838
+ {
839
+ path: 'nuxt.config.ts',
840
+ status: 'planned',
841
+ reason: 'nuxt_config_object_export',
842
+ confidence: 'high',
843
+ snippet: '...',
844
+ },
845
+ {
846
+ path: 'plugins/inspecto.client.ts',
847
+ status: 'manual_patch_required',
848
+ reason: 'nuxt_client_plugin_mount',
849
+ confidence: 'medium',
850
+ snippet: '...',
851
+ },
852
+ ],
853
+ }
854
+
855
+ vi.mocked(resolveOnboardingSession).mockResolvedValue(session)
856
+ vi.mocked(applyResolvedOnboardingSession).mockResolvedValue(applied)
857
+
858
+ const result = await onboard({ json: true })
859
+
860
+ expect(result.handoff?.metaFramework).toBe('Nuxt')
861
+ expect(result.handoff?.framework).toBe('vue')
862
+ expect(result.handoff?.patches).toEqual(
863
+ expect.arrayContaining([
864
+ expect.objectContaining({ path: 'nuxt.config.ts', reason: 'nuxt_config_object_export' }),
865
+ expect.objectContaining({
866
+ path: 'plugins/inspecto.client.ts',
867
+ reason: 'nuxt_client_plugin_mount',
868
+ }),
869
+ ]),
870
+ )
871
+ })
872
+
362
873
  it('prints manual extension guidance only when the IDE extension still needs manual completion', async () => {
363
874
  const session: ResolvedOnboardingSession = {
364
875
  status: 'success',