@jkwd/inbase 0.1.16 → 0.1.17

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.
@@ -1,5 +1,6 @@
1
1
  import { defineConfig, type Plugin } from 'vite'
2
2
  import react from '@vitejs/plugin-react'
3
+ import { createRequire } from 'node:module'
3
4
  import { spawnSync } from 'node:child_process'
4
5
  import fs from 'node:fs'
5
6
  import path from 'node:path'
@@ -7,7 +8,7 @@ import { fileURLToPath } from 'node:url'
7
8
  import type { IncomingMessage, ServerResponse } from 'node:http'
8
9
  import { emptyIntent } from './scripts/patch-lib.mjs'
9
10
  import { readBranchChanges } from './scripts/branch-changes.mjs'
10
- import { writeRunningInstance } from '../../bin/project.mjs'
11
+ import { writeRunningInstance, isolatedViteConfig, packageRoot } from '../../bin/project.mjs'
11
12
  import { dataDir, targetRoot } from './scripts/target-config.mjs'
12
13
  import { editorFileUri, openInEditor } from './scripts/open-editor.mjs'
13
14
  import {
@@ -35,6 +36,12 @@ import {
35
36
  } from './scripts/session-store.mjs'
36
37
 
37
38
  const here = path.dirname(fileURLToPath(import.meta.url))
39
+ const requireFromPackage = createRequire(path.join(packageRoot, 'package.json'))
40
+ const isolation = isolatedViteConfig(dataDir)
41
+
42
+ function pkgDir(name: string) {
43
+ return path.dirname(requireFromPackage.resolve(`${name}/package.json`))
44
+ }
38
45
  const userContextFile = path.join(dataDir, 'user-context.json')
39
46
  const codebaseFile = path.join(dataDir, 'codebase.json')
40
47
  const scanScript = path.resolve(here, 'scripts/scan-target.mjs')
@@ -478,16 +485,35 @@ function isDataDirPath(filePath: string) {
478
485
  }
479
486
 
480
487
  export default defineConfig({
488
+ ...isolation,
481
489
  plugins: [react(), jsonFilePlugin()],
490
+ resolve: {
491
+ alias: {
492
+ react: pkgDir('react'),
493
+ 'react-dom': pkgDir('react-dom'),
494
+ three: pkgDir('three'),
495
+ '@react-three/fiber': pkgDir('@react-three/fiber'),
496
+ '@react-three/drei': pkgDir('@react-three/drei'),
497
+ },
498
+ dedupe: ['react', 'react-dom', 'three', '@react-three/fiber', '@react-three/drei'],
499
+ },
500
+ optimizeDeps: {
501
+ ...isolation.optimizeDeps,
502
+ include: [
503
+ 'react',
504
+ 'react-dom',
505
+ 'three',
506
+ '@react-three/fiber',
507
+ '@react-three/drei',
508
+ ],
509
+ },
482
510
  server: {
511
+ ...isolation.server,
483
512
  port: 5173,
484
513
  watch: {
485
514
  // Session snapshots copy target source into the data dir. If Vite
486
515
  // watches those writes, Create proposal full-reloads the visualizer.
487
516
  ignored: ['**/src/data/**', isDataDirPath],
488
517
  },
489
- fs: {
490
- allow: [here, dataDir],
491
- },
492
518
  },
493
519
  })
package/bin/inbase.mjs CHANGED
@@ -9,6 +9,8 @@ import {
9
9
  ensureDataDir,
10
10
  ensureGitignoreEntry,
11
11
  explorerRoot,
12
+ isolatedViteConfig,
13
+ resolveFromPackage,
12
14
  skillTemplateDir,
13
15
  commandTemplateDir,
14
16
  takeFlagValue,
@@ -95,16 +97,15 @@ async function runServer(args) {
95
97
  dest: path.join(dataDir, 'codebase.json'),
96
98
  })
97
99
 
98
- const { createServer } = await import('vite')
100
+ const { createServer } = await import(pathToFileURL(resolveFromPackage('vite')).href)
101
+ const isolation = isolatedViteConfig(dataDir)
99
102
  const server = await createServer({
100
103
  configFile: path.join(explorerRoot, 'vite.config.ts'),
101
- root: explorerRoot,
104
+ ...isolation,
102
105
  server: {
106
+ ...isolation.server,
103
107
  port,
104
108
  host: '127.0.0.1',
105
- fs: {
106
- allow: [explorerRoot, targetRoot, dataDir],
107
- },
108
109
  },
109
110
  })
110
111
  await server.listen()
package/bin/project.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
+ import { createRequire } from 'node:module'
3
4
  import { fileURLToPath } from 'node:url'
4
5
 
5
6
  const here = path.dirname(fileURLToPath(import.meta.url))
@@ -8,6 +9,35 @@ export const explorerRoot = path.join(packageRoot, 'apps/explorer')
8
9
  export const skillTemplateDir = path.join(packageRoot, 'skill/inbase')
9
10
  export const commandTemplateDir = path.join(packageRoot, 'skill/commands')
10
11
 
12
+ const requireFromPackage = createRequire(path.join(packageRoot, 'package.json'))
13
+
14
+ export function resolveFromPackage(specifier) {
15
+ return requireFromPackage.resolve(specifier)
16
+ }
17
+
18
+ /** Vite config that never uses the host project's cache, deps, or browser targets. */
19
+ export function isolatedViteConfig(dataDir) {
20
+ return {
21
+ root: explorerRoot,
22
+ envDir: explorerRoot,
23
+ cacheDir: path.join(dataDir, 'vite'),
24
+ publicDir: false,
25
+ appType: 'spa',
26
+ build: { target: 'esnext' },
27
+ esbuild: { target: 'esnext' },
28
+ optimizeDeps: {
29
+ entries: [path.join(explorerRoot, 'index.html')],
30
+ esbuildOptions: { target: 'esnext' },
31
+ },
32
+ server: {
33
+ fs: {
34
+ strict: true,
35
+ allow: [explorerRoot, packageRoot, dataDir],
36
+ },
37
+ },
38
+ }
39
+ }
40
+
11
41
  export function resolveOptionalPath(value, fallback) {
12
42
  const raw = value?.trim()
13
43
  if (!raw) return fallback
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jkwd/inbase",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "A first-person 3D map of a codebase, with a visual coding workflow for Cursor.",
5
5
  "license": "MIT",
6
6
  "author": "Joris Kuijper",