codex-overleaf-link 1.1.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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +457 -0
  3. package/bin/codex-overleaf-link.mjs +223 -0
  4. package/extension/src/shared/agentTranscript.js +1175 -0
  5. package/extension/src/shared/auditRecords.js +568 -0
  6. package/extension/src/shared/compatibility.js +372 -0
  7. package/extension/src/shared/compileAdapter.js +176 -0
  8. package/extension/src/shared/governanceRules.js +252 -0
  9. package/extension/src/shared/i18n.js +565 -0
  10. package/extension/src/shared/models.js +106 -0
  11. package/extension/src/shared/otText.js +505 -0
  12. package/extension/src/shared/projectFiles.js +180 -0
  13. package/extension/src/shared/reviewing.js +99 -0
  14. package/extension/src/shared/sensitiveScan.js +116 -0
  15. package/extension/src/shared/sessionState.js +1084 -0
  16. package/extension/src/shared/staleGuard.js +150 -0
  17. package/extension/src/shared/storageDb.js +986 -0
  18. package/extension/src/shared/storageKeys.js +29 -0
  19. package/extension/src/shared/storageMigration.js +168 -0
  20. package/extension/src/shared/summary.js +248 -0
  21. package/extension/src/shared/undoOperations.js +369 -0
  22. package/native-host/src/codexArgs.js +43 -0
  23. package/native-host/src/codexHome.js +538 -0
  24. package/native-host/src/codexModels.js +247 -0
  25. package/native-host/src/codexPrompt.js +192 -0
  26. package/native-host/src/codexPromptAssembly.js +411 -0
  27. package/native-host/src/codexSessionRunner.js +1247 -0
  28. package/native-host/src/commandApproval.js +914 -0
  29. package/native-host/src/debugLog.js +78 -0
  30. package/native-host/src/diffEngine.js +247 -0
  31. package/native-host/src/index.js +132 -0
  32. package/native-host/src/launcher.js +81 -0
  33. package/native-host/src/localSkills.js +476 -0
  34. package/native-host/src/manifest.js +226 -0
  35. package/native-host/src/mirrorSensitiveScan.js +119 -0
  36. package/native-host/src/mirrorWorkspace.js +1019 -0
  37. package/native-host/src/nativeDoctor.js +826 -0
  38. package/native-host/src/nativeEnvironment.js +315 -0
  39. package/native-host/src/nativeHostPlatform.js +112 -0
  40. package/native-host/src/nativeMessaging.js +60 -0
  41. package/native-host/src/nativeQuotas.js +294 -0
  42. package/native-host/src/nativeResponseBudget.js +194 -0
  43. package/native-host/src/runtimeInstaller.js +357 -0
  44. package/native-host/src/taskRunner.js +3 -0
  45. package/native-host/src/taskRunnerRuntime.js +1083 -0
  46. package/native-host/src/textPatch.js +287 -0
  47. package/package.json +40 -0
  48. package/scripts/codex-json-agent.mjs +269 -0
  49. package/scripts/install-native-host.mjs +255 -0
  50. package/scripts/npm-package-files-v1.1.1.txt +52 -0
  51. package/scripts/uninstall-native-host.mjs +298 -0
  52. package/scripts/verify-npm-package.mjs +296 -0
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env node
2
+ import path from 'node:path';
3
+ import { createRequire } from 'node:module';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const require = createRequire(import.meta.url);
7
+ const packageJson = require('../package.json');
8
+ const packageRoot = path.resolve(fileURLToPath(new URL('..', import.meta.url)));
9
+
10
+ let command = process.argv[2] ?? 'help';
11
+ const args = process.argv.slice(3);
12
+
13
+ if (command === '--help') {
14
+ command = 'help';
15
+ }
16
+
17
+ function printHelp() {
18
+ console.log(`codex-overleaf-link ${packageJson.version}
19
+
20
+ Commands:
21
+ install-native Install the native host
22
+ uninstall-native Uninstall the native host
23
+ doctor Check local native host setup
24
+ version Print the package version
25
+ help Show this help message`);
26
+ }
27
+
28
+ const OPTION_DEFINITIONS = {
29
+ '--extension-id': { key: 'extensionId', takesValue: true },
30
+ '--browser': { key: 'browser', takesValue: true },
31
+ '--runtime-root': { key: 'runtimeRoot', takesValue: true },
32
+ '--force': { key: 'force', takesValue: false },
33
+ '--keep-runtime': { key: 'keepRuntime', takesValue: false },
34
+ '--reveal-paths': { key: 'revealPaths', takesValue: false },
35
+ '--json': { key: 'json', takesValue: false },
36
+ '--help': { key: 'help', takesValue: false }
37
+ };
38
+
39
+ const INSTALL_NATIVE_OPTIONS = new Set([
40
+ '--extension-id',
41
+ '--browser',
42
+ '--runtime-root',
43
+ '--force',
44
+ '--reveal-paths',
45
+ '--json',
46
+ '--help'
47
+ ]);
48
+
49
+ const UNINSTALL_NATIVE_OPTIONS = new Set([
50
+ '--browser',
51
+ '--runtime-root',
52
+ '--force',
53
+ '--keep-runtime',
54
+ '--reveal-paths',
55
+ '--json',
56
+ '--help'
57
+ ]);
58
+
59
+ function parseNativeArgs(argv, allowedOptions) {
60
+ const parsed = {};
61
+
62
+ for (let index = 0; index < argv.length; index += 1) {
63
+ const arg = argv[index];
64
+ const definition = OPTION_DEFINITIONS[arg];
65
+ if (!definition || !allowedOptions.has(arg)) {
66
+ throw new Error(`Unknown option: ${arg}`);
67
+ }
68
+
69
+ if (definition.takesValue) {
70
+ parsed[definition.key] = readOptionValue(argv, index, arg);
71
+ index += 1;
72
+ } else {
73
+ parsed[definition.key] = true;
74
+ }
75
+ }
76
+
77
+ validateBrowserOption(parsed.browser);
78
+ return parsed;
79
+ }
80
+
81
+ function parseDoctorArgs(argv) {
82
+ const parsed = {
83
+ browser: 'auto',
84
+ json: false,
85
+ revealPaths: false
86
+ };
87
+
88
+ for (let index = 0; index < argv.length; index += 1) {
89
+ const arg = argv[index];
90
+ if (arg === '--json') {
91
+ parsed.json = true;
92
+ } else if (arg === '--reveal-paths') {
93
+ parsed.revealPaths = true;
94
+ } else if (arg === '--browser') {
95
+ parsed.browser = readOptionValue(argv, index, arg);
96
+ index += 1;
97
+ } else if (arg === '--runtime-root') {
98
+ parsed.runtimeRoot = readOptionValue(argv, index, arg);
99
+ index += 1;
100
+ } else {
101
+ throw new Error(`Unknown doctor option: ${arg}`);
102
+ }
103
+ }
104
+
105
+ if (!['auto', 'chrome', 'chromium'].includes(parsed.browser)) {
106
+ throw new Error('Usage: codex-overleaf-link doctor [--json] [--browser chrome|chromium|auto] [--runtime-root <path>] [--reveal-paths]');
107
+ }
108
+
109
+ return parsed;
110
+ }
111
+
112
+ function readOptionValue(argv, index, optionName) {
113
+ const value = argv[index + 1];
114
+ if (!value || value.startsWith('--')) {
115
+ throw new Error(`Missing value for ${optionName}`);
116
+ }
117
+ return value;
118
+ }
119
+
120
+ function validateBrowserOption(browser) {
121
+ if (browser && !['auto', 'chrome', 'chromium'].includes(browser)) {
122
+ throw new Error('Usage: --browser must be one of chrome, chromium, or auto');
123
+ }
124
+ }
125
+
126
+ function exitWithError(error) {
127
+ console.error(error instanceof Error ? error.message : String(error));
128
+ process.exit(1);
129
+ }
130
+
131
+ switch (command) {
132
+ case 'help':
133
+ printHelp();
134
+ break;
135
+ case 'version':
136
+ if (args.includes('--json')) {
137
+ console.log(JSON.stringify({ packageVersion: packageJson.version }));
138
+ } else {
139
+ console.log(packageJson.version);
140
+ }
141
+ break;
142
+ case 'install-native': {
143
+ let installArgs;
144
+ try {
145
+ installArgs = parseNativeArgs(args, INSTALL_NATIVE_OPTIONS);
146
+ } catch (error) {
147
+ exitWithError(error);
148
+ }
149
+ if (installArgs.help) {
150
+ printHelp();
151
+ break;
152
+ }
153
+
154
+ try {
155
+ const { formatInstallNativeHostHuman, installNativeHost } = await import('../scripts/install-native-host.mjs');
156
+ const result = installNativeHost({
157
+ ...installArgs,
158
+ packageRoot
159
+ });
160
+ if (installArgs.json) {
161
+ console.log(JSON.stringify(result, null, 2));
162
+ } else {
163
+ process.stdout.write(formatInstallNativeHostHuman(result));
164
+ }
165
+ } catch (error) {
166
+ exitWithError(error);
167
+ }
168
+ break;
169
+ }
170
+ case 'uninstall-native': {
171
+ let uninstallArgs;
172
+ try {
173
+ uninstallArgs = parseNativeArgs(args, UNINSTALL_NATIVE_OPTIONS);
174
+ } catch (error) {
175
+ exitWithError(error);
176
+ }
177
+ if (uninstallArgs.help) {
178
+ printHelp();
179
+ break;
180
+ }
181
+
182
+ try {
183
+ const { formatUninstallNativeHostHuman, uninstallNativeHost } = await import('../scripts/uninstall-native-host.mjs');
184
+ const result = uninstallNativeHost(uninstallArgs);
185
+ if (uninstallArgs.json) {
186
+ console.log(JSON.stringify(result, null, 2));
187
+ } else {
188
+ process.stdout.write(formatUninstallNativeHostHuman(result));
189
+ }
190
+ } catch (error) {
191
+ exitWithError(error);
192
+ }
193
+ break;
194
+ }
195
+ case 'doctor': {
196
+ const { formatDoctorHuman, runDoctor } = require('../native-host/src/nativeDoctor.js');
197
+ let doctorArgs;
198
+ try {
199
+ doctorArgs = parseDoctorArgs(args);
200
+ } catch (error) {
201
+ console.error(error.message);
202
+ process.exit(2);
203
+ }
204
+
205
+ let result;
206
+ try {
207
+ result = await runDoctor(doctorArgs);
208
+ } catch (error) {
209
+ console.error(`Doctor failed: ${error.message}`);
210
+ process.exit(3);
211
+ }
212
+ if (doctorArgs.json) {
213
+ console.log(JSON.stringify(result.body, null, 2));
214
+ } else {
215
+ process.stdout.write(formatDoctorHuman(result.body));
216
+ }
217
+ process.exit(result.exitCode);
218
+ break;
219
+ }
220
+ default:
221
+ console.error(`Unknown command: ${command}`);
222
+ process.exit(1);
223
+ }