@xortex/xcode 3.0.5 → 3.1.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 (75) hide show
  1. package/INSTALLATION.md +285 -0
  2. package/QUICKSTART.md +151 -0
  3. package/SYSTEM_PROMPT.md +583 -0
  4. package/SYSTEM_PROMPT_EXTRACTED.md +1 -0
  5. package/Untitled +1 -0
  6. package/bin/xcode +69 -120
  7. package/bootstrap/state.ts +1758 -0
  8. package/bun-bundle-hook.js +38 -17
  9. package/bun-bundle-shim.ts +12 -0
  10. package/bun.lock +645 -0
  11. package/context/QueuedMessageContext.tsx +63 -0
  12. package/context/fpsMetrics.tsx +30 -0
  13. package/context/mailbox.tsx +38 -0
  14. package/context/modalContext.tsx +58 -0
  15. package/context/notifications.tsx +240 -0
  16. package/context/overlayContext.tsx +151 -0
  17. package/context/promptOverlayContext.tsx +125 -0
  18. package/context/stats.tsx +220 -0
  19. package/context/voice.tsx +88 -0
  20. package/coordinator/coordinatorMode.ts +369 -0
  21. package/costHook.ts +22 -0
  22. package/dialogLaunchers.tsx +133 -0
  23. package/entrypoints/cli.tsx +1 -1
  24. package/extract_prompt.ts +304 -0
  25. package/ink.ts +85 -0
  26. package/install.sh +221 -0
  27. package/interactiveHelpers.tsx +366 -0
  28. package/macro.ts +1 -1
  29. package/memdir/findRelevantMemories.ts +141 -0
  30. package/memdir/memdir.ts +511 -0
  31. package/memdir/memoryAge.ts +53 -0
  32. package/memdir/memoryScan.ts +94 -0
  33. package/memdir/memoryTypes.ts +271 -0
  34. package/memdir/paths.ts +291 -0
  35. package/memdir/teamMemPaths.ts +292 -0
  36. package/memdir/teamMemPrompts.ts +100 -0
  37. package/moreright/useMoreRight.tsx +26 -0
  38. package/native-ts/color-diff/index.ts +999 -0
  39. package/native-ts/file-index/index.ts +370 -0
  40. package/native-ts/yoga-layout/enums.ts +134 -0
  41. package/native-ts/yoga-layout/index.ts +2578 -0
  42. package/outputStyles/loadOutputStylesDir.ts +98 -0
  43. package/package.json +5 -42
  44. package/plugins/builtinPlugins.ts +159 -0
  45. package/plugins/bundled/index.ts +23 -0
  46. package/projectOnboardingState.ts +83 -0
  47. package/public/claude-files.png +0 -0
  48. package/public/leak-tweet.png +0 -0
  49. package/query/config.ts +46 -0
  50. package/query/deps.ts +40 -0
  51. package/query/stopHooks.ts +470 -0
  52. package/query/tokenBudget.ts +93 -0
  53. package/replLauncher.tsx +27 -0
  54. package/schemas/hooks.ts +222 -0
  55. package/screens/Doctor.tsx +575 -0
  56. package/screens/REPL.tsx +7107 -0
  57. package/screens/ResumeConversation.tsx +399 -0
  58. package/scripts/postinstall.js +90 -0
  59. package/server/createDirectConnectSession.ts +88 -0
  60. package/server/directConnectManager.ts +213 -0
  61. package/server/types.ts +57 -0
  62. package/setup.ts +477 -0
  63. package/stub_types.sh +13 -0
  64. package/tasks.ts +39 -0
  65. package/tools.ts +396 -0
  66. package/tsconfig.json +16 -0
  67. package/upstreamproxy/relay.ts +455 -0
  68. package/upstreamproxy/upstreamproxy.ts +285 -0
  69. package/vim/motions.ts +82 -0
  70. package/vim/operators.ts +556 -0
  71. package/vim/textObjects.ts +186 -0
  72. package/vim/transitions.ts +490 -0
  73. package/vim/types.ts +199 -0
  74. package/voice/voiceModeEnabled.ts +54 -0
  75. package/utils/bunBundleCompat.ts +0 -44
package/bin/xcode CHANGED
@@ -1,164 +1,113 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * XCode CLI Entry Point
4
- *
5
- * This is the executable that gets installed when users run:
6
- * - npm install -g @xortex/xcode
7
- * - Or use the curl installer
4
+ * Installed via: npm install -g @xortex/xcode
5
+ *
6
+ * Bun is installed as part of npm postinstall.
7
+ * This launcher finds Bun and runs the app with it.
8
8
  */
9
9
 
10
+ const { execSync } = require('child_process');
10
11
  const { spawn } = require('child_process');
11
12
  const path = require('path');
12
13
  const fs = require('fs');
14
+ const os = require('os');
13
15
 
14
- // Get the project root (where this script is located)
15
16
  const projectRoot = path.resolve(__dirname, '..');
16
17
  const mainScript = path.join(projectRoot, 'entrypoints', 'cli.tsx');
17
- const bunBundleHook = path.join(projectRoot, 'bun-bundle-hook.js');
18
18
 
19
- // Check if bun is available
20
- function getRuntime() {
19
+ // ── find Bun ──────────────────────────────────────────────────────────────────
20
+
21
+ function findBun() {
22
+ // 1. Check PATH
21
23
  try {
22
- require('child_process').execSync('bun --version', { stdio: 'ignore' });
23
- return 'bun';
24
- } catch {
25
- try {
26
- require('child_process').execSync('node --version', { stdio: 'ignore' });
27
- return 'node';
28
- } catch {
29
- console.error('❌ Error: Neither Bun nor Node.js is installed.');
30
- console.error('');
31
- console.error('Please install one of the following:');
32
- console.error(' • Bun (recommended): curl -fsSL https://bun.sh/install | bash');
33
- console.error(' Node.js: https://nodejs.org/');
34
- console.error('');
35
- process.exit(1);
36
- }
24
+ const p = execSync('which bun', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
25
+ if (p && fs.existsSync(p)) return p;
26
+ } catch {}
27
+
28
+ // 2. Common install locations
29
+ const candidates = [
30
+ path.join(os.homedir(), '.bun', 'bin', 'bun'),
31
+ '/usr/local/bin/bun',
32
+ '/usr/bin/bun',
33
+ 'C:\\Users\\' + (process.env.USERNAME || '') + '\\.bun\\bin\\bun.exe',
34
+ ];
35
+ for (const c of candidates) {
36
+ if (fs.existsSync(c)) return c;
37
37
  }
38
+ return null;
38
39
  }
39
40
 
40
- // Set up environment
41
+ // ── CLI flags ─────────────────────────────────────────────────────────────────
42
+
41
43
  process.env.XCODE_CLI = 'true';
42
44
  process.env.NODE_ENV = process.env.NODE_ENV || 'production';
43
45
 
44
- // Handle special commands
45
46
  const args = process.argv.slice(2);
46
- const command = args[0];
47
47
 
48
- if (command === '--version' || command === '-v') {
49
- console.log('xcode v3.0.5 — AI coding assistant with XMem memory');
48
+ if (args[0] === '--version' || args[0] === '-v' || args[0] === '-V') {
49
+ console.log('xcode v3.1.0 — AI coding assistant with XMem memory');
50
50
  process.exit(0);
51
51
  }
52
52
 
53
- if (command === '--help' || command === '-h') {
53
+ if (args[0] === '--help' || args[0] === '-h') {
54
54
  console.log(`
55
55
  XCode - AI-powered coding assistant with XMem memory
56
56
 
57
- Usage: xcode [options] [command]
57
+ Usage: xcode [options]
58
58
 
59
59
  Options:
60
- -v, --version Show version number
61
- -h, --help Show help
62
- --model <model> Start with specific model (e.g., gemini-2.5-pro, kimi-k2.5)
60
+ -v, --version Show version
61
+ -h, --help Show help
62
+ --model <name> Model: gemini-2.5-pro, kimi-k2.5, deepseek-v3.2, sonnet, opus
63
+ --openrouter Use OpenRouter provider
63
64
 
64
- Commands:
65
- (none) Start interactive session
66
-
67
- Environment Variables:
68
- OPENROUTER_API_KEY OpenRouter API key (optional, has default)
69
- XMEM_API_URL XMem memory server URL (default: http://localhost:8000)
65
+ Environment:
70
66
  ANTHROPIC_API_KEY Anthropic API key (for Claude models)
71
-
72
- Examples:
73
- xcode # Start with default model
74
- xcode --model gemini-2.5-pro # Use Gemini via OpenRouter
75
- xcode --model kimi-k2.5 # Use Kimi via OpenRouter
67
+ OPENROUTER_API_KEY OpenRouter API key (optional, default provided)
68
+ XMEM_API_URL XMem memory server URL (default: http://localhost:8000)
76
69
  `);
77
70
  process.exit(0);
78
71
  }
79
72
 
80
- // Check for model argument
81
- const modelIndex = args.indexOf('--model');
82
- if (modelIndex !== -1 && args[modelIndex + 1]) {
83
- const model = args[modelIndex + 1];
73
+ // Model / provider flags
74
+ const modelIdx = args.indexOf('--model');
75
+ if (modelIdx !== -1 && args[modelIdx + 1]) {
76
+ const model = args[modelIdx + 1];
84
77
  process.env.ANTHROPIC_MODEL = model;
85
-
86
- // If using OpenRouter models, auto-enable OpenRouter
87
- const openRouterModels = ['kimi', 'deepseek', 'gemini', 'moonshot', 'google/gemini'];
88
- if (openRouterModels.some(m => model.toLowerCase().includes(m.toLowerCase()))) {
78
+ const orModels = ['kimi', 'deepseek', 'gemini', 'moonshot', 'google/'];
79
+ if (orModels.some(m => model.toLowerCase().includes(m))) {
89
80
  process.env.CLAUDE_CODE_USE_OPENROUTER = 'true';
90
81
  }
91
82
  }
92
-
93
- // Check for explicit OpenRouter flag
94
83
  if (args.includes('--openrouter')) {
95
84
  process.env.CLAUDE_CODE_USE_OPENROUTER = 'true';
96
85
  }
97
86
 
98
- // Run the main application
99
- const runtime = getRuntime();
100
-
101
- if (runtime === 'bun') {
102
- // Use Bun - it handles TypeScript natively
103
- const child = spawn('bun', ['run', mainScript, ...args], {
104
- cwd: projectRoot,
105
- stdio: 'inherit',
106
- env: process.env,
107
- });
108
-
109
- child.on('exit', (code) => {
110
- process.exit(code || 0);
111
- });
112
- } else {
113
- // Use Node with ts-node or tsx
114
- // First check if tsx is installed globally or locally
115
- let tsxPath;
116
- try {
117
- // Try local tsx first
118
- tsxPath = require.resolve('tsx/dist/cli.mjs', { paths: [projectRoot] });
119
- } catch {
120
- try {
121
- // Try global tsx
122
- tsxPath = require.resolve('tsx/dist/cli.mjs');
123
- } catch {
124
- // Fallback to npx tsx
125
- tsxPath = null;
126
- }
127
- }
128
-
129
- let child;
130
- const hasHook = fs.existsSync(bunBundleHook);
131
-
132
- if (tsxPath) {
133
- // Use direct tsx path with bun:bundle shim
134
- const nodeArgs = hasHook ? ['--require', bunBundleHook, tsxPath, mainScript] : [tsxPath, mainScript];
135
- child = spawn('node', [...nodeArgs, ...args], {
136
- cwd: projectRoot,
137
- stdio: 'inherit',
138
- env: process.env,
139
- });
140
- } else {
141
- // Fallback to npx
142
- const npxArgs = hasHook ? ['--node-options', `--require ${bunBundleHook}`, 'tsx'] : ['tsx'];
143
- child = spawn('npx', [...npxArgs, mainScript, ...args], {
144
- cwd: projectRoot,
145
- stdio: 'inherit',
146
- env: process.env,
147
- });
148
- }
149
-
150
- child.on('exit', (code) => {
151
- process.exit(code || 0);
152
- });
153
-
154
- child.on('error', (err) => {
155
- console.error('❌ Failed to start XCode:', err.message);
156
- console.error('');
157
- console.error('Please ensure tsx is installed:');
158
- console.error(' npm install -g tsx');
159
- console.error('');
160
- console.error('Or use Bun instead:');
161
- console.error(' curl -fsSL https://bun.sh/install | bash');
162
- process.exit(1);
163
- });
87
+ // ── launch with Bun ───────────────────────────────────────────────────────────
88
+
89
+ const bun = findBun();
90
+
91
+ if (!bun) {
92
+ console.error('');
93
+ console.error('❌ Bun runtime not found.');
94
+ console.error('');
95
+ console.error(' Please install Bun and try again:');
96
+ console.error(' curl -fsSL https://bun.sh/install | bash');
97
+ console.error('');
98
+ console.error(' Then restart your terminal and run: xcode');
99
+ console.error('');
100
+ process.exit(1);
164
101
  }
102
+
103
+ const child = spawn(bun, ['run', mainScript, ...args], {
104
+ cwd: projectRoot,
105
+ stdio: 'inherit',
106
+ env: process.env,
107
+ });
108
+
109
+ child.on('exit', code => process.exit(code ?? 0));
110
+ child.on('error', err => {
111
+ console.error('\n❌ Failed to start XCode:', err.message);
112
+ process.exit(1);
113
+ });