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.
- package/LICENSE +21 -0
- package/README.md +457 -0
- package/bin/codex-overleaf-link.mjs +223 -0
- package/extension/src/shared/agentTranscript.js +1175 -0
- package/extension/src/shared/auditRecords.js +568 -0
- package/extension/src/shared/compatibility.js +372 -0
- package/extension/src/shared/compileAdapter.js +176 -0
- package/extension/src/shared/governanceRules.js +252 -0
- package/extension/src/shared/i18n.js +565 -0
- package/extension/src/shared/models.js +106 -0
- package/extension/src/shared/otText.js +505 -0
- package/extension/src/shared/projectFiles.js +180 -0
- package/extension/src/shared/reviewing.js +99 -0
- package/extension/src/shared/sensitiveScan.js +116 -0
- package/extension/src/shared/sessionState.js +1084 -0
- package/extension/src/shared/staleGuard.js +150 -0
- package/extension/src/shared/storageDb.js +986 -0
- package/extension/src/shared/storageKeys.js +29 -0
- package/extension/src/shared/storageMigration.js +168 -0
- package/extension/src/shared/summary.js +248 -0
- package/extension/src/shared/undoOperations.js +369 -0
- package/native-host/src/codexArgs.js +43 -0
- package/native-host/src/codexHome.js +538 -0
- package/native-host/src/codexModels.js +247 -0
- package/native-host/src/codexPrompt.js +192 -0
- package/native-host/src/codexPromptAssembly.js +411 -0
- package/native-host/src/codexSessionRunner.js +1247 -0
- package/native-host/src/commandApproval.js +914 -0
- package/native-host/src/debugLog.js +78 -0
- package/native-host/src/diffEngine.js +247 -0
- package/native-host/src/index.js +132 -0
- package/native-host/src/launcher.js +81 -0
- package/native-host/src/localSkills.js +476 -0
- package/native-host/src/manifest.js +226 -0
- package/native-host/src/mirrorSensitiveScan.js +119 -0
- package/native-host/src/mirrorWorkspace.js +1019 -0
- package/native-host/src/nativeDoctor.js +826 -0
- package/native-host/src/nativeEnvironment.js +315 -0
- package/native-host/src/nativeHostPlatform.js +112 -0
- package/native-host/src/nativeMessaging.js +60 -0
- package/native-host/src/nativeQuotas.js +294 -0
- package/native-host/src/nativeResponseBudget.js +194 -0
- package/native-host/src/runtimeInstaller.js +357 -0
- package/native-host/src/taskRunner.js +3 -0
- package/native-host/src/taskRunnerRuntime.js +1083 -0
- package/native-host/src/textPatch.js +287 -0
- package/package.json +40 -0
- package/scripts/codex-json-agent.mjs +269 -0
- package/scripts/install-native-host.mjs +255 -0
- package/scripts/npm-package-files-v1.1.1.txt +52 -0
- package/scripts/uninstall-native-host.mjs +298 -0
- package/scripts/verify-npm-package.mjs +296 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const FORBIDDEN_NPM_PACKAGE_PATH_PATTERNS = [
|
|
8
|
+
/(^|\/)(docs|specs|superpowers|private|test|tests|fixtures|dist|\.github|node_modules)(\/|$)/,
|
|
9
|
+
/(\.env(?:\.[^/]*)?|\.pem|\.key|\.p12)$/
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const scriptPath = fileURLToPath(import.meta.url);
|
|
13
|
+
const scriptDir = path.dirname(scriptPath);
|
|
14
|
+
const repoRoot = path.resolve(scriptDir, '..');
|
|
15
|
+
|
|
16
|
+
export function normalizePackagePathList(paths) {
|
|
17
|
+
const normalized = new Set();
|
|
18
|
+
|
|
19
|
+
for (const rawPath of paths) {
|
|
20
|
+
if (typeof rawPath !== 'string') {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let packagePath = rawPath.trim().replace(/\\/g, '/');
|
|
25
|
+
packagePath = packagePath.replace(/^\.\//, '').replace(/^\/+/, '');
|
|
26
|
+
packagePath = packagePath.replace(/\/+$|\r$/g, '');
|
|
27
|
+
|
|
28
|
+
if (!packagePath) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!packagePath.startsWith('package/')) {
|
|
33
|
+
packagePath = `package/${packagePath}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
normalized.add(packagePath);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return [...normalized].sort();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function findForbiddenNpmPackagePaths(paths) {
|
|
43
|
+
return normalizePackagePathList(paths).filter((packagePath) => (
|
|
44
|
+
FORBIDDEN_NPM_PACKAGE_PATH_PATTERNS.some((pattern) => pattern.test(packagePath))
|
|
45
|
+
));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function compareExactManifest(actualPaths, expectedPaths) {
|
|
49
|
+
const actual = normalizePackagePathList(actualPaths);
|
|
50
|
+
const expected = normalizePackagePathList(expectedPaths);
|
|
51
|
+
const actualSet = new Set(actual);
|
|
52
|
+
const expectedSet = new Set(expected);
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
missing: expected.filter((packagePath) => !actualSet.has(packagePath)),
|
|
56
|
+
extra: actual.filter((packagePath) => !expectedSet.has(packagePath))
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getDefaultManifestPath() {
|
|
61
|
+
const packageJson = readPackageMetadata();
|
|
62
|
+
return path.join(scriptDir, `npm-package-files-v${packageJson.version}.txt`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function readExpectedManifest(manifestPath = getDefaultManifestPath()) {
|
|
66
|
+
return normalizePackagePathList(
|
|
67
|
+
fs.readFileSync(manifestPath, 'utf8')
|
|
68
|
+
.split(/\r?\n/)
|
|
69
|
+
.map((line) => line.trim())
|
|
70
|
+
.filter((line) => line && !line.startsWith('#'))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function verifyPackagePaths(actualPaths, expectedPaths = readExpectedManifest()) {
|
|
75
|
+
const actual = normalizePackagePathList(actualPaths);
|
|
76
|
+
const expected = normalizePackagePathList(expectedPaths);
|
|
77
|
+
const forbidden = findForbiddenNpmPackagePaths(actual);
|
|
78
|
+
const { missing, extra } = compareExactManifest(actual, expected);
|
|
79
|
+
const errors = [];
|
|
80
|
+
|
|
81
|
+
if (forbidden.length > 0) {
|
|
82
|
+
errors.push(`Forbidden npm package paths:\n${forbidden.map((packagePath) => ` - ${packagePath}`).join('\n')}`);
|
|
83
|
+
}
|
|
84
|
+
if (missing.length > 0) {
|
|
85
|
+
errors.push(`Missing npm package manifest entries:\n${missing.map((packagePath) => ` - ${packagePath}`).join('\n')}`);
|
|
86
|
+
}
|
|
87
|
+
if (extra.length > 0) {
|
|
88
|
+
errors.push(`Extra npm package manifest entries:\n${extra.map((packagePath) => ` - ${packagePath}`).join('\n')}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
ok: errors.length === 0,
|
|
93
|
+
actual,
|
|
94
|
+
expected,
|
|
95
|
+
forbidden,
|
|
96
|
+
missing,
|
|
97
|
+
extra,
|
|
98
|
+
errors
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function readPackageMetadata() {
|
|
103
|
+
return JSON.parse(fs.readFileSync(path.join(repoRoot, 'package.json'), 'utf8'));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getCurrentPackageTarballName() {
|
|
107
|
+
const packageJson = readPackageMetadata();
|
|
108
|
+
return `${packageJson.name}-${packageJson.version}.tgz`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function runNpm(args) {
|
|
112
|
+
const result = spawnSync(process.platform === 'win32' ? 'npm.cmd' : 'npm', args, {
|
|
113
|
+
cwd: repoRoot,
|
|
114
|
+
encoding: 'utf8',
|
|
115
|
+
shell: process.platform === 'win32',
|
|
116
|
+
windowsHide: true
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (result.error) {
|
|
120
|
+
throw result.error;
|
|
121
|
+
}
|
|
122
|
+
if (result.status !== 0) {
|
|
123
|
+
throw new Error(result.stderr || result.stdout || `npm ${args.join(' ')} exited with status ${result.status}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return result.stdout;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function parsePackJsonText(text) {
|
|
130
|
+
const parsed = JSON.parse(text);
|
|
131
|
+
const packuments = Array.isArray(parsed) ? parsed : [parsed];
|
|
132
|
+
return packuments;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function getFilePathsFromPackuments(packuments) {
|
|
136
|
+
return packuments.flatMap((packument) => (
|
|
137
|
+
Array.isArray(packument?.files) ? packument.files.map((file) => file.path) : []
|
|
138
|
+
));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function readPackJsonFile(filePath) {
|
|
142
|
+
return getFilePathsFromPackuments(parsePackJsonText(fs.readFileSync(filePath, 'utf8')));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function runNpmPackDryRun() {
|
|
146
|
+
return parsePackJsonText(runNpm(['pack', '--dry-run', '--json']));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function readNewlineFileList(filePath) {
|
|
150
|
+
return fs.readFileSync(filePath, 'utf8').split(/\r?\n/).filter(Boolean);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function assertVerified(result, label) {
|
|
154
|
+
if (!result.ok) {
|
|
155
|
+
throw new Error(`${label} failed:\n${result.errors.join('\n')}`);
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function verifyActualPaths(actualPaths, label) {
|
|
161
|
+
return assertVerified(verifyPackagePaths(actualPaths), label);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function verifyPackuments(packuments, label) {
|
|
165
|
+
return verifyActualPaths(getFilePathsFromPackuments(packuments), label);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function verifyNpmPackDryRun() {
|
|
169
|
+
return verifyPackuments(runNpmPackDryRun(), 'npm pack --dry-run --json verification');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function packAndVerifyNpmPackage() {
|
|
173
|
+
const generatedTarballs = new Set([path.resolve(repoRoot, getCurrentPackageTarballName())]);
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
const dryRunResult = verifyNpmPackDryRun();
|
|
177
|
+
const packuments = parsePackJsonText(runNpm(['pack', '--json']));
|
|
178
|
+
|
|
179
|
+
if (packuments.length === 0) {
|
|
180
|
+
throw new Error('npm pack did not report a package artifact.');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
for (const packument of packuments) {
|
|
184
|
+
if (typeof packument?.filename !== 'string' || packument.filename.length === 0) {
|
|
185
|
+
throw new Error('npm pack did not report a package filename.');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const tarballPath = path.resolve(repoRoot, packument.filename);
|
|
189
|
+
generatedTarballs.add(tarballPath);
|
|
190
|
+
if (!fs.existsSync(tarballPath)) {
|
|
191
|
+
throw new Error(`npm pack did not create expected tarball: ${packument.filename}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
dryRun: dryRunResult,
|
|
197
|
+
packages: packuments.map((packument) => ({
|
|
198
|
+
name: packument.name,
|
|
199
|
+
version: packument.version,
|
|
200
|
+
filename: packument.filename,
|
|
201
|
+
size: packument.size,
|
|
202
|
+
shasum: packument.shasum,
|
|
203
|
+
integrity: packument.integrity
|
|
204
|
+
})),
|
|
205
|
+
tarballs: [...generatedTarballs]
|
|
206
|
+
};
|
|
207
|
+
} finally {
|
|
208
|
+
for (const tarballPath of generatedTarballs) {
|
|
209
|
+
fs.rmSync(tarballPath, { force: true });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function printUsage() {
|
|
215
|
+
console.error([
|
|
216
|
+
'Usage:',
|
|
217
|
+
' node scripts/verify-npm-package.mjs',
|
|
218
|
+
' node scripts/verify-npm-package.mjs --pack',
|
|
219
|
+
' node scripts/verify-npm-package.mjs --pack-json <path>',
|
|
220
|
+
' node scripts/verify-npm-package.mjs --file-list <path>'
|
|
221
|
+
].join('\n'));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function getMode(args) {
|
|
225
|
+
if (args.length === 0) {
|
|
226
|
+
return { mode: '--dry-run' };
|
|
227
|
+
}
|
|
228
|
+
if (args.length === 1 && args[0] === '--pack') {
|
|
229
|
+
return { mode: '--pack' };
|
|
230
|
+
}
|
|
231
|
+
if (args.length !== 2) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
const [mode, filePath] = args;
|
|
235
|
+
if (!['--pack-json', '--file-list'].includes(mode)) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return { mode, filePath };
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function readActualPathsForMode(mode, filePath) {
|
|
242
|
+
if (mode === '--dry-run') {
|
|
243
|
+
return getFilePathsFromPackuments(runNpmPackDryRun());
|
|
244
|
+
}
|
|
245
|
+
if (mode === '--pack-json') {
|
|
246
|
+
return readPackJsonFile(filePath);
|
|
247
|
+
}
|
|
248
|
+
if (mode === '--file-list') {
|
|
249
|
+
return readNewlineFileList(filePath);
|
|
250
|
+
}
|
|
251
|
+
throw new Error(`Unsupported mode: ${mode}`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async function main() {
|
|
255
|
+
const mode = getMode(process.argv.slice(2));
|
|
256
|
+
if (!mode) {
|
|
257
|
+
printUsage();
|
|
258
|
+
process.exitCode = 2;
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
try {
|
|
263
|
+
if (mode.mode === '--pack') {
|
|
264
|
+
const result = packAndVerifyNpmPackage();
|
|
265
|
+
console.log(`Verified npm pack dry-run manifest with ${result.dryRun.actual.length} files.`);
|
|
266
|
+
for (const packageInfo of result.packages) {
|
|
267
|
+
const details = [
|
|
268
|
+
`${packageInfo.name}@${packageInfo.version}`,
|
|
269
|
+
`filename=${packageInfo.filename}`
|
|
270
|
+
];
|
|
271
|
+
if (Number.isFinite(packageInfo.size)) {
|
|
272
|
+
details.push(`size=${packageInfo.size}`);
|
|
273
|
+
}
|
|
274
|
+
if (packageInfo.shasum) {
|
|
275
|
+
details.push(`shasum=${packageInfo.shasum}`);
|
|
276
|
+
}
|
|
277
|
+
if (packageInfo.integrity) {
|
|
278
|
+
details.push(`integrity=${packageInfo.integrity}`);
|
|
279
|
+
}
|
|
280
|
+
console.log(`Created npm package ${details.join(' ')}`);
|
|
281
|
+
}
|
|
282
|
+
console.log('Removed generated npm tarball.');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const result = verifyActualPaths(readActualPathsForMode(mode.mode, mode.filePath), 'npm package manifest verification');
|
|
287
|
+
console.log(`Verified npm package manifest with ${result.actual.length} files.`);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.error(error.message);
|
|
290
|
+
process.exitCode = 1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === scriptPath) {
|
|
295
|
+
await main();
|
|
296
|
+
}
|