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,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { scanSensitiveText } = require('../../extension/src/shared/sensitiveScan');
|
|
6
|
+
const { getProjectMirror } = require('./mirrorWorkspace');
|
|
7
|
+
|
|
8
|
+
const MAX_SCANNED_FILE_BYTES = 512 * 1024;
|
|
9
|
+
const MAX_FINDINGS = 100;
|
|
10
|
+
|
|
11
|
+
function scanMirrorSensitiveFiles(options = {}) {
|
|
12
|
+
const mirror = getProjectMirror(options.projectId || 'unknown', { rootDir: options.rootDir });
|
|
13
|
+
const findings = [];
|
|
14
|
+
const skippedFiles = [];
|
|
15
|
+
let scannedFiles = 0;
|
|
16
|
+
|
|
17
|
+
for (const filePath of listMirrorFiles(mirror.workspacePath)) {
|
|
18
|
+
if (!isSensitiveScanTextPath(filePath)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const target = resolveWorkspacePath(mirror.workspacePath, filePath);
|
|
22
|
+
const stat = fs.statSync(target);
|
|
23
|
+
if (stat.size > MAX_SCANNED_FILE_BYTES) {
|
|
24
|
+
skippedFiles.push({
|
|
25
|
+
path: filePath,
|
|
26
|
+
reason: 'file_too_large',
|
|
27
|
+
size: stat.size
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const content = fs.readFileSync(target, 'utf8');
|
|
32
|
+
scannedFiles += 1;
|
|
33
|
+
findings.push(...scanSensitiveText('mirror-file', content, { path: filePath }));
|
|
34
|
+
if (findings.length >= MAX_FINDINGS) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const redactedFindings = collapseRedundantFindings(findings);
|
|
40
|
+
return {
|
|
41
|
+
findings: redactedFindings.slice(0, MAX_FINDINGS),
|
|
42
|
+
scannedFiles,
|
|
43
|
+
skippedFiles
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function listMirrorFiles(workspacePath) {
|
|
48
|
+
if (!fs.existsSync(workspacePath)) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const files = [];
|
|
52
|
+
walk(workspacePath, '');
|
|
53
|
+
return files.sort();
|
|
54
|
+
|
|
55
|
+
function walk(dir, prefix) {
|
|
56
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
57
|
+
if (entry.name === '.DS_Store') {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
61
|
+
const absolute = path.join(dir, entry.name);
|
|
62
|
+
if (entry.isDirectory()) {
|
|
63
|
+
walk(absolute, relative);
|
|
64
|
+
} else if (entry.isFile()) {
|
|
65
|
+
files.push(normalizeRelativePath(relative));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isSensitiveScanTextPath(filePath) {
|
|
72
|
+
const normalized = normalizeRelativePath(filePath).toLowerCase();
|
|
73
|
+
const basename = path.posix.basename(normalized);
|
|
74
|
+
if (basename === '.latexmkrc') {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return /\.(tex|bib|bst|cls|sty|clo|cfg|def|bbx|cbx|lbx|ist|tikz|pgf|asy|txt|md|csv|tsv|dat|json|ya?ml|py|r|m|sh)$/i.test(normalized);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function resolveWorkspacePath(workspacePath, filePath) {
|
|
81
|
+
const target = path.resolve(workspacePath, normalizeRelativePath(filePath));
|
|
82
|
+
const root = path.resolve(workspacePath);
|
|
83
|
+
if (target !== root && !target.startsWith(root + path.sep)) {
|
|
84
|
+
throw new Error(`Unsafe project path: ${filePath}`);
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function normalizeRelativePath(filePath) {
|
|
90
|
+
const normalized = String(filePath || '').replace(/\\/g, '/').replace(/^\/+/, '');
|
|
91
|
+
if (!normalized || normalized.split('/').some(part => part === '..' || part === '.')) {
|
|
92
|
+
throw new Error(`Unsafe project path: ${filePath}`);
|
|
93
|
+
}
|
|
94
|
+
return normalized;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function collapseRedundantFindings(findings = []) {
|
|
98
|
+
const specificKeys = new Set(
|
|
99
|
+
findings
|
|
100
|
+
.filter(finding => finding?.detectorId !== 'secret-assignment')
|
|
101
|
+
.map(finding => findingKey(finding))
|
|
102
|
+
);
|
|
103
|
+
return findings.filter(finding => (
|
|
104
|
+
finding?.detectorId !== 'secret-assignment' ||
|
|
105
|
+
!specificKeys.has(findingKey(finding))
|
|
106
|
+
));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function findingKey(finding = {}) {
|
|
110
|
+
return [
|
|
111
|
+
finding.source || '',
|
|
112
|
+
finding.path || '',
|
|
113
|
+
finding.preview || ''
|
|
114
|
+
].join('\u0000');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = {
|
|
118
|
+
scanMirrorSensitiveFiles
|
|
119
|
+
};
|