auditor-lambda 0.3.25 → 0.3.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auditor-lambda",
3
- "version": "0.3.25",
3
+ "version": "0.3.26",
4
4
  "private": false,
5
5
  "description": "Portable hybrid code-auditing framework for arbitrary repositories.",
6
6
  "type": "module",
@@ -94,14 +94,25 @@ function renderOpenCodeExternalDirectoryPermission() {
94
94
 
95
95
  function renderGlobalMcpLauncher(installedPkgRoot) {
96
96
  return [
97
- "import { access, readFile } from 'node:fs/promises';",
97
+ "import { access, readFile, appendFile } from 'node:fs/promises';",
98
98
  "import { constants } from 'node:fs';",
99
99
  "import { spawn } from 'node:child_process';",
100
100
  "import { join } from 'node:path';",
101
+ "import { homedir } from 'node:os';",
101
102
  '',
102
103
  'const repoRoot = process.cwd();',
103
104
  "const artifactsDir = join(repoRoot, '.audit-artifacts');",
104
105
  `const globalPackageRoot = ${JSON.stringify(installedPkgRoot)};`,
106
+ "const logPath = join(homedir(), '.audit-code', 'mcp-server.log');",
107
+ '',
108
+ 'async function log(msg) {',
109
+ ' try {',
110
+ ' const ts = new Date().toISOString();',
111
+ " await appendFile(logPath, `${ts} ${msg}\\n`, 'utf8');",
112
+ ' } catch {',
113
+ ' // ignore log failures',
114
+ ' }',
115
+ '}',
105
116
  '',
106
117
  'async function exists(path) {',
107
118
  ' try {',
@@ -134,6 +145,7 @@ function renderGlobalMcpLauncher(installedPkgRoot) {
134
145
  " const sharedArgs = ['mcp', '--root', repoRoot, '--artifacts-dir', artifactsDir];",
135
146
  '',
136
147
  ' if (await exists(localPackageEntrypoint)) {',
148
+ " await log(`launching local node_modules candidate: ${localPackageEntrypoint}`);",
137
149
  ' return await spawnForward(process.execPath, [localPackageEntrypoint, ...sharedArgs]);',
138
150
  ' }',
139
151
  '',
@@ -141,6 +153,7 @@ function renderGlobalMcpLauncher(installedPkgRoot) {
141
153
  ' try {',
142
154
  " const packageJson = JSON.parse(await readFile(repoPackageJsonPath, 'utf8'));",
143
155
  " if (packageJson?.name === 'auditor-lambda') {",
156
+ " await log(`launching repo-root candidate: ${join(repoRoot, 'audit-code.mjs')}`);",
144
157
  " return await spawnForward(process.execPath, [join(repoRoot, 'audit-code.mjs'), ...sharedArgs]);",
145
158
  ' }',
146
159
  ' } catch {',
@@ -149,14 +162,17 @@ function renderGlobalMcpLauncher(installedPkgRoot) {
149
162
  ' }',
150
163
  '',
151
164
  ' if (globalPackageEntrypoint && await exists(globalPackageEntrypoint)) {',
165
+ " await log(`launching global candidate: ${globalPackageEntrypoint}`);",
152
166
  ' return await spawnForward(process.execPath, [globalPackageEntrypoint, ...sharedArgs]);',
153
167
  ' }',
154
168
  '',
155
169
  ' if (await exists(localBin)) {',
170
+ " await log(`launching local bin candidate: ${localBin}`);",
156
171
  ' return await spawnForward(localBin, sharedArgs);',
157
172
  ' }',
158
173
  '',
159
174
  " const pathCandidate = process.platform === 'win32' ? 'audit-code.cmd' : 'audit-code';",
175
+ " await log(`trying PATH candidate: ${pathCandidate}`);",
160
176
  ' let exitCode = await spawnForward(pathCandidate, sharedArgs).catch(() => null);',
161
177
  " if (typeof exitCode === 'number') {",
162
178
  ' return exitCode;',
@@ -167,12 +183,18 @@ function renderGlobalMcpLauncher(installedPkgRoot) {
167
183
  ' return exitCode;',
168
184
  ' }',
169
185
  '',
186
+ " await log('ERROR: no candidate found');",
170
187
  ' throw new Error(',
171
188
  " 'Unable to locate an audit-code executable. Install auditor-lambda globally or as a local dependency.',",
172
189
  ' );',
173
190
  '}',
174
191
  '',
175
- 'const code = await tryCandidates();',
192
+ "log(`run-mcp-server.mjs started: node=${process.execPath} cwd=${repoRoot} globalPkg=${globalPackageRoot}`).catch(() => {});",
193
+ 'const code = await tryCandidates().catch(async (err) => {',
194
+ " await log(`FATAL: ${err.message}`);",
195
+ ' process.stderr.write(err.message + "\\n");',
196
+ ' return 1;',
197
+ '});',
176
198
  'process.exitCode = code;',
177
199
  '',
178
200
  ].join('\n');
@@ -276,8 +298,8 @@ function mergeOpenCodeGlobalConfig(existing) {
276
298
  const parsed = existing ? JSON.parse(existing) : {};
277
299
  const auditPermission = renderOpenCodePermissionConfig();
278
300
  const existingAuditor = objectValue(objectValue(parsed.agent).auditor);
279
- const globalLauncherPath = replaceBackslashes(join(homedir(), '.audit-code', 'run-mcp-server.mjs'));
280
301
  const nodeExecPath = replaceBackslashes(process.execPath);
302
+ const pkgEntrypoint = replaceBackslashes(join(pkgRoot, 'audit-code.mjs'));
281
303
  return {
282
304
  ...parsed,
283
305
  command: {
@@ -295,7 +317,7 @@ function mergeOpenCodeGlobalConfig(existing) {
295
317
  ...objectValue(parsed.mcp),
296
318
  auditor: {
297
319
  type: 'local',
298
- command: [nodeExecPath, globalLauncherPath],
320
+ command: [nodeExecPath, pkgEntrypoint, 'mcp'],
299
321
  enabled: true,
300
322
  timeout: 10000,
301
323
  },