opencode-sonarqube 0.2.5 → 0.2.7

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 (2) hide show
  1. package/dist/index.js +40 -19
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -4133,7 +4133,9 @@ async function hasProjectState(directory) {
4133
4133
  }
4134
4134
  async function loadProjectState(directory) {
4135
4135
  const statePath = getStatePath(directory);
4136
- logger4.info(">>> loadProjectState called", { directory, statePath });
4136
+ const stack = new Error().stack?.split(`
4137
+ `).slice(1, 5).join(" <- ") || "no stack";
4138
+ logger4.info(">>> loadProjectState called", { directory, statePath, caller: stack });
4137
4139
  const exists = await Bun.file(statePath).exists();
4138
4140
  logger4.info("State file exists check", { exists, statePath });
4139
4141
  if (!exists) {
@@ -20093,7 +20095,8 @@ function getSeveritiesFromLevel(level) {
20093
20095
  // src/index.ts
20094
20096
  import { appendFileSync as appendFileSync4 } from "node:fs";
20095
20097
  try {
20096
- appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [LOAD] Plugin module loaded! CWD=${process.cwd()}
20098
+ const moduleLoadId = Math.random().toString(36).substring(7);
20099
+ appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [LOAD] Module loaded! id=${moduleLoadId} cwd=${process.cwd()} import.meta.url=${import.meta.url}
20097
20100
  `);
20098
20101
  } catch {}
20099
20102
  var IGNORED_FILE_PATTERNS2 = [
@@ -20123,7 +20126,27 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
20123
20126
  safeLog(` worktree param: "${worktree}"`);
20124
20127
  safeLog(` process.cwd(): "${process.cwd()}"`);
20125
20128
  safeLog(` import.meta.url: "${import.meta.url}"`);
20129
+ const pluginImportUrl = import.meta.url;
20130
+ const resolveDirectoryFromImportUrl = () => {
20131
+ try {
20132
+ const pluginPath = decodeURIComponent(pluginImportUrl.replace("file://", ""));
20133
+ const pathParts = pluginPath.split("/");
20134
+ const nodeModulesIndex = pathParts.indexOf("node_modules");
20135
+ if (nodeModulesIndex > 0) {
20136
+ const projectPath = pathParts.slice(0, nodeModulesIndex).join("/");
20137
+ if (projectPath && projectPath !== "/" && projectPath.length > 1) {
20138
+ return projectPath;
20139
+ }
20140
+ }
20141
+ } catch {}
20142
+ return null;
20143
+ };
20126
20144
  const resolveValidDirectory = () => {
20145
+ const fromImportUrl = resolveDirectoryFromImportUrl();
20146
+ if (fromImportUrl) {
20147
+ safeLog(`USING import.meta.url derived path=${fromImportUrl}`);
20148
+ return fromImportUrl;
20149
+ }
20127
20150
  if (worktree && worktree !== "/" && worktree.length > 1) {
20128
20151
  safeLog(`USING worktree=${worktree}`);
20129
20152
  return worktree;
@@ -20137,19 +20160,6 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
20137
20160
  safeLog(`USING cwd=${cwd}`);
20138
20161
  return cwd;
20139
20162
  }
20140
- try {
20141
- const pluginUrl = import.meta.url;
20142
- const pluginPath = decodeURIComponent(pluginUrl.replace("file://", ""));
20143
- const pathParts = pluginPath.split("/");
20144
- const nodeModulesIndex = pathParts.indexOf("node_modules");
20145
- if (nodeModulesIndex > 0) {
20146
- const projectPath = pathParts.slice(0, nodeModulesIndex).join("/");
20147
- if (projectPath && projectPath !== "/" && projectPath.length > 1) {
20148
- safeLog(`USING import.meta.url derived path=${projectPath}`);
20149
- return projectPath;
20150
- }
20151
- }
20152
- } catch {}
20153
20163
  const homeDir = process.env["HOME"] || "/Users";
20154
20164
  safeLog(`FALLBACK home=${homeDir}`);
20155
20165
  return homeDir;
@@ -20171,7 +20181,13 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
20171
20181
  let pluginConfig;
20172
20182
  let lastAnalysisResult;
20173
20183
  const getConfig = () => pluginConfig;
20174
- const getDirectory = () => effectiveDirectory;
20184
+ const getDirectory = () => {
20185
+ const fromImportUrl = resolveDirectoryFromImportUrl();
20186
+ if (fromImportUrl) {
20187
+ return fromImportUrl;
20188
+ }
20189
+ return effectiveDirectory;
20190
+ };
20175
20191
  const loadPluginConfig = async () => {
20176
20192
  if (pluginConfig)
20177
20193
  return;
@@ -20528,6 +20544,9 @@ Git operation completed with changes. Consider running:
20528
20544
  }
20529
20545
  };
20530
20546
  };
20547
+ safeLog(`=== PLUGIN INIT COMPLETE, returning hooks ===`);
20548
+ safeLog(` This instance's pluginImportUrl: "${pluginImportUrl}"`);
20549
+ safeLog(` This instance's effectiveDirectory: "${effectiveDirectory}"`);
20531
20550
  const returnHooks = {
20532
20551
  event: safeAsync(async ({ event }) => {
20533
20552
  handleSessionTrackingEvent(event);
@@ -20563,16 +20582,18 @@ Git operation completed with changes. Consider running:
20563
20582
  }
20564
20583
  }, "experimental.session.compacting"),
20565
20584
  "experimental.chat.system.transform": safeAsync(async (_input, output) => {
20566
- safeLog("experimental.chat.system.transform ENTERED");
20585
+ safeLog(`=== system.transform ENTERED ===`);
20586
+ safeLog(` pluginImportUrl: "${pluginImportUrl}"`);
20587
+ safeLog(` effectiveDirectory: "${effectiveDirectory}"`);
20567
20588
  await loadPluginConfig();
20568
20589
  const sonarConfig = pluginConfig?.["sonarqube"];
20569
20590
  const config2 = loadConfig(sonarConfig);
20570
20591
  if (!config2 || config2.level === "off") {
20592
+ safeLog(` config level is off or null, returning early`);
20571
20593
  return;
20572
20594
  }
20573
20595
  const dir = getDirectory();
20574
- safeLog(`system.transform: getDirectory() returned: "${dir}"`);
20575
- safeLog(`system.transform: effectiveDirectory is: "${effectiveDirectory}"`);
20596
+ safeLog(` getDirectory() returned: "${dir}"`);
20576
20597
  const state = await getProjectState(dir);
20577
20598
  if (!state?.projectKey)
20578
20599
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sonarqube",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "OpenCode Plugin for SonarQube integration - Enterprise-level code quality from the start",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -38,7 +38,7 @@
38
38
  "homepage": "https://github.com/mguttmann/opencode-sonarqube#readme",
39
39
  "dependencies": {
40
40
  "@opencode-ai/plugin": "^1.1.34",
41
- "opencode-sonarqube": "0.2.5",
41
+ "opencode-sonarqube": "0.2.6",
42
42
  "zod": "^3.24.0"
43
43
  },
44
44
  "devDependencies": {