opencode-sonarqube 0.2.8 → 0.2.10

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 +55 -9
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -20099,6 +20099,47 @@ try {
20099
20099
  appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [LOAD] Module loaded! id=${moduleLoadId} cwd=${process.cwd()} import.meta.url=${import.meta.url}
20100
20100
  `);
20101
20101
  } catch {}
20102
+ var SHARED_STATE_FILE = "/tmp/sonarqube-plugin-shared-state.json";
20103
+ var globalSafeLog = (msg) => {
20104
+ try {
20105
+ appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [GLOBAL] ${msg}
20106
+ `);
20107
+ } catch {}
20108
+ };
20109
+ var readSharedState = () => {
20110
+ try {
20111
+ const content = __require("fs").readFileSync(SHARED_STATE_FILE, "utf-8");
20112
+ return JSON.parse(content);
20113
+ } catch {
20114
+ return { sessionToDirectory: {}, registeredDirectories: [], lastUpdated: "" };
20115
+ }
20116
+ };
20117
+ var writeSharedState = (state) => {
20118
+ try {
20119
+ state.lastUpdated = new Date().toISOString();
20120
+ __require("fs").writeFileSync(SHARED_STATE_FILE, JSON.stringify(state, null, 2));
20121
+ } catch (e) {
20122
+ globalSafeLog(`Failed to write shared state: ${e}`);
20123
+ }
20124
+ };
20125
+ var mapSessionToDirectory = (sessionId, directory) => {
20126
+ const state = readSharedState();
20127
+ state.sessionToDirectory[sessionId] = directory;
20128
+ writeSharedState(state);
20129
+ globalSafeLog(`Mapped session ${sessionId} to ${directory}`);
20130
+ };
20131
+ var getDirectoryForSession = (sessionId) => {
20132
+ const state = readSharedState();
20133
+ return state.sessionToDirectory[sessionId];
20134
+ };
20135
+ var registerDirectory = (directory) => {
20136
+ const state = readSharedState();
20137
+ if (!state.registeredDirectories.includes(directory)) {
20138
+ state.registeredDirectories.push(directory);
20139
+ writeSharedState(state);
20140
+ }
20141
+ globalSafeLog(`Registered directory: ${directory}, total: ${state.registeredDirectories.length}`);
20142
+ };
20102
20143
  var IGNORED_FILE_PATTERNS2 = [
20103
20144
  /node_modules/,
20104
20145
  /\.git/,
@@ -20166,6 +20207,7 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
20166
20207
  };
20167
20208
  const effectiveDirectory = resolveValidDirectory();
20168
20209
  safeLog(`FINAL effectiveDirectory=${effectiveDirectory}`);
20210
+ registerDirectory(effectiveDirectory);
20169
20211
  try {
20170
20212
  await client.app.log({
20171
20213
  body: {
@@ -20332,6 +20374,9 @@ After fixing, I will re-run the analysis to verify.`;
20332
20374
  const payload = event.properties;
20333
20375
  if (payload?.id) {
20334
20376
  currentSessionId = payload.id;
20377
+ if (event.type === "session.created") {
20378
+ mapSessionToDirectory(payload.id, effectiveDirectory);
20379
+ }
20335
20380
  }
20336
20381
  };
20337
20382
  const handleFileEditedEvent = (event) => {
@@ -20583,14 +20628,17 @@ Git operation completed with changes. Consider running:
20583
20628
  }, "experimental.session.compacting"),
20584
20629
  "experimental.chat.system.transform": safeAsync(async (_input, output) => {
20585
20630
  safeLog(`=== system.transform ENTERED ===`);
20586
- safeLog(` _input keys: ${JSON.stringify(Object.keys(_input || {}))}`);
20587
- safeLog(` _input: ${JSON.stringify(_input, null, 2)?.substring(0, 1000)}`);
20588
- safeLog(` output keys: ${JSON.stringify(Object.keys(output || {}))}`);
20589
- safeLog(` pluginImportUrl: "${pluginImportUrl}"`);
20590
- safeLog(` effectiveDirectory: "${effectiveDirectory}"`);
20591
20631
  const inputAny = _input;
20592
- const contextDir = inputAny?.directory || inputAny?.worktree || inputAny?.cwd || inputAny?.context?.directory;
20593
- safeLog(` contextDir from input: "${contextDir}"`);
20632
+ const sessionID = inputAny?.sessionID;
20633
+ safeLog(` sessionID: "${sessionID}"`);
20634
+ const sharedState = readSharedState();
20635
+ safeLog(` sharedState sessions: ${JSON.stringify(sharedState.sessionToDirectory)}`);
20636
+ safeLog(` sharedState directories: ${JSON.stringify(sharedState.registeredDirectories)}`);
20637
+ const sessionDir = sessionID ? getDirectoryForSession(sessionID) : undefined;
20638
+ safeLog(` sessionDir from shared state: "${sessionDir}"`);
20639
+ safeLog(` effectiveDirectory (fallback): "${effectiveDirectory}"`);
20640
+ const dir = sessionDir || effectiveDirectory;
20641
+ safeLog(` FINAL dir used: "${dir}"`);
20594
20642
  await loadPluginConfig();
20595
20643
  const sonarConfig = pluginConfig?.["sonarqube"];
20596
20644
  const config2 = loadConfig(sonarConfig);
@@ -20598,8 +20646,6 @@ Git operation completed with changes. Consider running:
20598
20646
  safeLog(` config level is off or null, returning early`);
20599
20647
  return;
20600
20648
  }
20601
- const dir = contextDir || getDirectory();
20602
- safeLog(` FINAL dir used: "${dir}"`);
20603
20649
  const state = await getProjectState(dir);
20604
20650
  if (!state?.projectKey)
20605
20651
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sonarqube",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
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.7",
41
+ "opencode-sonarqube": "0.2.9",
42
42
  "zod": "^3.24.0"
43
43
  },
44
44
  "devDependencies": {