From 7a720d958b20e746ef813a49ec9b57888cbb55cc Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Sun, 29 Nov 2026 04:42:07 +0100 Subject: [PATCH] refactor(tooling): drop exports nothing imports (#1356) knip reported 100 unused exports. 55 are used only inside their own module and no file, test or harness imports them: drop them from module.exports and keep the code. The other 45 are CommonJS namespace or source-loaded uses knip does not follow, and stay. --- classify-title-activity.js | 2 +- claude-auth.js | 2 +- delete-session-guard.js | 2 +- fts-match.js | 2 +- jsonl-scan.js | 2 +- local-transcript-activity.js | 2 +- remote-activity.js | 2 +- src/main/app/unsaved-guard.js | 2 +- src/main/bg-agents/bg-handoff.js | 2 +- src/main/changes/git-changes-file.js | 1 - src/main/changes/git-changes-target.js | 2 +- src/main/changes/git-changes-watch.js | 2 +- src/main/changes/touched-transcript-cache.js | 2 +- src/main/integrations/activitywatch/activitywatch-reporter.js | 2 +- src/main/projects/last-known-projects.js | 2 +- src/main/remote/remote-enrol.js | 2 +- src/main/remote/remote-hosts.js | 3 --- src/main/remote/remote-index.js | 2 +- src/main/remote/remote-launch.js | 3 +-- src/main/remote/remote-mirror.js | 2 +- src/main/remote/remote-send.js | 2 -- src/main/remote/remote-transport.js | 4 +--- src/main/remote/remote-watch.js | 4 +--- src/main/schedules/schedule-background.js | 2 +- src/main/session-index/session-refs.js | 2 +- src/main/terminals/composer-state.js | 2 +- src/main/terminals/pty-size.js | 2 -- src/main/terminals/shell-profiles.js | 2 +- src/main/triggers/trigger-actions.js | 2 +- src/main/triggers/trigger-watcher.js | 2 +- task-records.js | 2 +- transcript-turn.js | 2 +- viewer-file-watch.js | 2 +- viewer-save-guard.js | 2 +- 34 files changed, 30 insertions(+), 43 deletions(-) diff --git a/classify-title-activity.js b/classify-title-activity.js index 1dc986c8f..3f11da0b7 100644 --- a/classify-title-activity.js +++ b/classify-title-activity.js @@ -30,4 +30,4 @@ function classifyTitleActivity(title, options) { return none; } -module.exports = { classifyTitleActivity, IDLE_GLYPH, SPINNER_RANGES }; +module.exports = { classifyTitleActivity }; diff --git a/claude-auth.js b/claude-auth.js index ffe90f017..af9c93703 100644 --- a/claude-auth.js +++ b/claude-auth.js @@ -199,4 +199,4 @@ async function fetchAndTransformUsage() { } } -module.exports = { getOAuthToken, fetchUsage, fetchAndTransformUsage, getConfigDir, formatResetTime }; +module.exports = { fetchAndTransformUsage, formatResetTime }; diff --git a/delete-session-guard.js b/delete-session-guard.js index 8f60c7634..f7e96357d 100644 --- a/delete-session-guard.js +++ b/delete-session-guard.js @@ -45,4 +45,4 @@ function makeDeleteSessionGuard({ activeSessions, bgAgents, cliSessionState, ses }; } -module.exports = { deleteSessionRefusal, makeDeleteSessionGuard, harnessTranscriptRefusal }; +module.exports = { deleteSessionRefusal, makeDeleteSessionGuard }; diff --git a/fts-match.js b/fts-match.js index cc1996aa2..becc3c335 100644 --- a/fts-match.js +++ b/fts-match.js @@ -80,4 +80,4 @@ function createSessionSearch(db) { }; } -module.exports = { FTS_QUERY_MAX_CHARS, FTS_MIN_TERM_CHARS, searchTerms, buildFtsMatch, idLookupTerm, createSessionSearch }; +module.exports = { FTS_QUERY_MAX_CHARS, searchTerms, buildFtsMatch, idLookupTerm, createSessionSearch }; diff --git a/jsonl-scan.js b/jsonl-scan.js index d52cd8dbe..54f4d8b0c 100644 --- a/jsonl-scan.js +++ b/jsonl-scan.js @@ -78,4 +78,4 @@ function readHead(filePath, maxBytes) { } } -module.exports = { scanLines, readHead, CHUNK_BYTES, MAX_LINE_BYTES }; +module.exports = { scanLines, readHead, MAX_LINE_BYTES }; diff --git a/local-transcript-activity.js b/local-transcript-activity.js index e693550a1..abcde06ea 100644 --- a/local-transcript-activity.js +++ b/local-transcript-activity.js @@ -231,4 +231,4 @@ function createLocalTranscriptTracker(opts = {}) { return { record, dispose, stats }; } -module.exports = { createLocalTranscriptTracker, sessionIdFromWatchParts, SESSION_ID_RE }; +module.exports = { createLocalTranscriptTracker, sessionIdFromWatchParts }; diff --git a/remote-activity.js b/remote-activity.js index 27def7451..8adbd8f7f 100644 --- a/remote-activity.js +++ b/remote-activity.js @@ -127,4 +127,4 @@ function createRemoteActivityTracker(opts = {}) { return { record, activeAt, stats, dispose }; } -module.exports = { createRemoteActivityTracker, sessionIdFromRel, SESSION_ID_RE }; +module.exports = { createRemoteActivityTracker, sessionIdFromRel }; diff --git a/src/main/app/unsaved-guard.js b/src/main/app/unsaved-guard.js index 5d991b360..13d58f45b 100644 --- a/src/main/app/unsaved-guard.js +++ b/src/main/app/unsaved-guard.js @@ -439,4 +439,4 @@ function createUnsavedGuard({ ipcMain, timeoutMs = DEFAULT_TIMEOUT_MS, probeMs = committedToken: attempts.token, launchAllowed: attempts.launchAllowed, capture: attempts.capture, invalidate: attempts.invalidate }; } -module.exports = { createUnsavedGuard, DEFAULT_TIMEOUT_MS, DEFAULT_PROBE_MS, DEFAULT_DIALOG_CEILING_MS, LOGOFF_CANCEL_MS }; +module.exports = { createUnsavedGuard, LOGOFF_CANCEL_MS }; diff --git a/src/main/bg-agents/bg-handoff.js b/src/main/bg-agents/bg-handoff.js index 3a0af55db..998fa842a 100644 --- a/src/main/bg-agents/bg-handoff.js +++ b/src/main/bg-agents/bg-handoff.js @@ -209,4 +209,4 @@ function askContinuationChoice({ ipcMain, window, sessionId, jobs, signal, timeo }); } -module.exports = { askContinuationChoice, backgroundRefusal, createContinuationReader, findHandoff, cancellationIn, holdBackgroundExit, sendToBackground, BG_HANDOFF_TIMEOUT_MS, BG_HANDOFF_EXIT_TIMEOUT_MS }; +module.exports = { askContinuationChoice, backgroundRefusal, createContinuationReader, cancellationIn, holdBackgroundExit, sendToBackground }; diff --git a/src/main/changes/git-changes-file.js b/src/main/changes/git-changes-file.js index 9c6a193e4..30257a6aa 100644 --- a/src/main/changes/git-changes-file.js +++ b/src/main/changes/git-changes-file.js @@ -373,7 +373,6 @@ module.exports = { buildBlobRev, versionOf, resolveRepoDirs, - lineEndingsOf, soleEol, decodeUtf8, toLf, diff --git a/src/main/changes/git-changes-target.js b/src/main/changes/git-changes-target.js index c25cb3602..f22e56d6b 100644 --- a/src/main/changes/git-changes-target.js +++ b/src/main/changes/git-changes-target.js @@ -322,4 +322,4 @@ function resolveGitChangesTarget(sessionId, deps, opts) { return { ok: false, error: 'could not resolve a working directory for this session' }; } -module.exports = { resolveGitChangesTarget, isValidChangesSessionId, parseSubagentId, listSubagentWorktrees, collectSubagentChanges, checkSubagentRepo }; +module.exports = { resolveGitChangesTarget, isValidChangesSessionId, listSubagentWorktrees, collectSubagentChanges, checkSubagentRepo }; diff --git a/src/main/changes/git-changes-watch.js b/src/main/changes/git-changes-watch.js index f75519838..ede2a401a 100644 --- a/src/main/changes/git-changes-watch.js +++ b/src/main/changes/git-changes-watch.js @@ -90,4 +90,4 @@ function createChangesWatchRegistry(deps) { return { watch, unwatch, closeAll, size: () => entries.size }; } -module.exports = { createChangesWatchRegistry, DEFAULT_DEBOUNCE_MS }; +module.exports = { createChangesWatchRegistry }; diff --git a/src/main/changes/touched-transcript-cache.js b/src/main/changes/touched-transcript-cache.js index f843472b8..d4dcf799e 100644 --- a/src/main/changes/touched-transcript-cache.js +++ b/src/main/changes/touched-transcript-cache.js @@ -207,4 +207,4 @@ function compareTouch(a, b) { || a.path.localeCompare(b.path) || a.tool.localeCompare(b.tool); } -module.exports = { createTouchedFilesCache, timestampOf }; +module.exports = { createTouchedFilesCache }; diff --git a/src/main/integrations/activitywatch/activitywatch-reporter.js b/src/main/integrations/activitywatch/activitywatch-reporter.js index 9f1af05fc..80da69c42 100644 --- a/src/main/integrations/activitywatch/activitywatch-reporter.js +++ b/src/main/integrations/activitywatch/activitywatch-reporter.js @@ -218,4 +218,4 @@ function createActivityWatchReporter(deps) { }; } -module.exports = { createActivityWatchReporter, KEEPALIVE_MS, PULSETIME_SECONDS, CHECKPOINT_MS, IDLE_SECONDS }; +module.exports = { createActivityWatchReporter, KEEPALIVE_MS, PULSETIME_SECONDS, CHECKPOINT_MS }; diff --git a/src/main/projects/last-known-projects.js b/src/main/projects/last-known-projects.js index 31c5d32cf..ac48b6cef 100644 --- a/src/main/projects/last-known-projects.js +++ b/src/main/projects/last-known-projects.js @@ -140,4 +140,4 @@ function createLastKnownProjectsStore({ dir, appVersion, log = console, maxBytes return { load, remember, flush, filename }; } -module.exports = { createLastKnownProjectsStore, FORMAT_VERSION, MAX_BYTES, WRITE_DELAY_MS }; +module.exports = { createLastKnownProjectsStore, FORMAT_VERSION, MAX_BYTES }; diff --git a/src/main/remote/remote-enrol.js b/src/main/remote/remote-enrol.js index 76c7ac9f4..7828b543c 100644 --- a/src/main/remote/remote-enrol.js +++ b/src/main/remote/remote-enrol.js @@ -92,4 +92,4 @@ async function handleEnrolRequest(payload, deps) { } } -module.exports = { buildChecklist, handleEnrolRequest, UNKNOWN_AUTH_TEXT, LOGIN_COMMAND }; +module.exports = { buildChecklist, handleEnrolRequest, UNKNOWN_AUTH_TEXT }; diff --git a/src/main/remote/remote-hosts.js b/src/main/remote/remote-hosts.js index 3839ef1a0..7aa049bda 100644 --- a/src/main/remote/remote-hosts.js +++ b/src/main/remote/remote-hosts.js @@ -88,9 +88,7 @@ function topFolderOf(rel) { } module.exports = { - FOLDER_SEP, MIN_REFRESH_MS, - DEFAULT_REFRESH_MS, isValidAlias, joinFolderKey, parseFolderKey, @@ -98,7 +96,6 @@ module.exports = { normalizeHosts, enabledHosts, normalizeRefreshMs, - mirrorDirFor, mirrorProjectsDirFor, manifestPathFor, isSafeRelPath, diff --git a/src/main/remote/remote-index.js b/src/main/remote/remote-index.js index 1aa3a5a75..c3da00ace 100644 --- a/src/main/remote/remote-index.js +++ b/src/main/remote/remote-index.js @@ -689,4 +689,4 @@ async function refreshRemoteHeadTurns(ctx, hostAlias) { if (rows.length) await ctx.readBatch(rows); } -module.exports = { createRemoteIndexer, refreshRemoteHeadTurns, PROBE_INTERVAL_MS, PROBE_RETRY_MS, backoffDelayMs, buildPlaceholderSession, placeholderTitle, sanitizeWaitingFor }; +module.exports = { createRemoteIndexer, refreshRemoteHeadTurns, PROBE_INTERVAL_MS, PROBE_RETRY_MS, backoffDelayMs, sanitizeWaitingFor }; diff --git a/src/main/remote/remote-launch.js b/src/main/remote/remote-launch.js index bb13cba90..42227d33c 100644 --- a/src/main/remote/remote-launch.js +++ b/src/main/remote/remote-launch.js @@ -178,5 +178,4 @@ module.exports = { NO_DIR_EXIT_CODE, NO_TMUX_EXIT_CODE, NO_CLAUDE_EXIT_CODE, - PERMISSION_MODES, -}; + }; diff --git a/src/main/remote/remote-mirror.js b/src/main/remote/remote-mirror.js index 842ea5e9c..5cef8007a 100644 --- a/src/main/remote/remote-mirror.js +++ b/src/main/remote/remote-mirror.js @@ -248,4 +248,4 @@ async function syncMirror({ alias, transport, projectsDir, manifestPath, log }) }; } -module.exports = { syncMirror, readManifest, writeManifest, MAX_CYCLE_FILES, MAX_CYCLE_BYTES, MAX_FILE_BYTES }; +module.exports = { syncMirror, readManifest, writeManifest, MAX_CYCLE_FILES, MAX_CYCLE_BYTES }; diff --git a/src/main/remote/remote-send.js b/src/main/remote/remote-send.js index 16bb9964d..b7c28f764 100644 --- a/src/main/remote/remote-send.js +++ b/src/main/remote/remote-send.js @@ -192,8 +192,6 @@ module.exports = { validateSocketPath, MAX_LINE_BYTES, DEDUPE_WINDOW_MS, - RATE_CAPACITY, - RATE_REFILL_PER_MS, NOT_CLAUDE_EXIT_CODE, NO_SOCKET_EXIT_CODE, NC_MISSING_EXIT_CODE, diff --git a/src/main/remote/remote-transport.js b/src/main/remote/remote-transport.js index 1ab3485af..09f7b99c1 100644 --- a/src/main/remote/remote-transport.js +++ b/src/main/remote/remote-transport.js @@ -541,7 +541,6 @@ module.exports = { parseInventory, parseSessions, splitListOutput, - transcriptSessionIds, LIST_COMMAND, PROBE_COMMAND, parseProbe, @@ -553,5 +552,4 @@ module.exports = { SESSIONS_MARKER, MAX_SESSION_DESCRIPTORS, MAX_SESSION_DESCRIPTOR_BYTES, - MAX_RANGE_FETCH_BYTES, -}; + }; diff --git a/src/main/remote/remote-watch.js b/src/main/remote/remote-watch.js index 74a16e320..0910fe8d9 100644 --- a/src/main/remote/remote-watch.js +++ b/src/main/remote/remote-watch.js @@ -217,8 +217,6 @@ function createRemoteWatcher(opts = {}) { module.exports = { createRemoteWatcher, parseWatchLine, - buildWatchCommand, buildSshArgs, NO_INOTIFYWAIT_MARKER, - NO_INOTIFYWAIT_EXIT_CODE, -}; + }; diff --git a/src/main/schedules/schedule-background.js b/src/main/schedules/schedule-background.js index 279c25580..8176a8d8e 100644 --- a/src/main/schedules/schedule-background.js +++ b/src/main/schedules/schedule-background.js @@ -358,4 +358,4 @@ function resumeBackgroundRuns(deps, claim) { return lifetimes; } -module.exports = { launchBackgroundSchedule, resumeBackgroundRuns, discoverBackgroundRuns, backgroundRefusal, BACKGROUND_RUN_LIMIT_MS, LAUNCH_TIMEOUT_MS }; +module.exports = { launchBackgroundSchedule, resumeBackgroundRuns, backgroundRefusal }; diff --git a/src/main/session-index/session-refs.js b/src/main/session-index/session-refs.js index 02be17931..a62a9f30a 100644 --- a/src/main/session-index/session-refs.js +++ b/src/main/session-index/session-refs.js @@ -94,4 +94,4 @@ function mergeSearchBodyRefs(body, newer) { return searchBody(text, mergeRefLists(newer, refs)); } -module.exports = { REFS_MAX_CHARS, REFS_MAX_ENTRIES, SEARCH_BODY_MAX_CHARS, REFS_MARKER, collectRefs, collectEntryRefs, newestFirst, splitSearchBody, searchBody, mergeRefLists, mergeSearchBodyRefs }; +module.exports = { REFS_MAX_CHARS, collectRefs, collectEntryRefs, newestFirst, splitSearchBody, searchBody, mergeSearchBodyRefs }; diff --git a/src/main/terminals/composer-state.js b/src/main/terminals/composer-state.js index 140f80864..9462ec742 100644 --- a/src/main/terminals/composer-state.js +++ b/src/main/terminals/composer-state.js @@ -375,4 +375,4 @@ function noteUserInput(state, data, now) { return finish(); } -module.exports = { createComposerState, noteUserInput, isComposerEmpty, MAX_PARTIAL }; +module.exports = { createComposerState, noteUserInput, isComposerEmpty }; diff --git a/src/main/terminals/pty-size.js b/src/main/terminals/pty-size.js index ad29dde27..e31445561 100644 --- a/src/main/terminals/pty-size.js +++ b/src/main/terminals/pty-size.js @@ -47,8 +47,6 @@ module.exports = { normalizePtySize, DEFAULT_COLS, DEFAULT_ROWS, - MIN_COLS, - MIN_ROWS, MAX_COLS, MAX_ROWS, }; diff --git a/src/main/terminals/shell-profiles.js b/src/main/terminals/shell-profiles.js index 93cdf3478..dbbeb6fc5 100644 --- a/src/main/terminals/shell-profiles.js +++ b/src/main/terminals/shell-profiles.js @@ -339,4 +339,4 @@ function shellArgs(shellPath, cmd, extraArgs, { pty = false, windows = isWindows return []; } -module.exports = { isCmdShell, discoverShellProfiles, getShellProfiles, resolveShell, isWindows, isWslShell, windowsToWslPath, shellArgs, quoteArgForShell, quoteArgvForShell, claudeCommand, codexCommand, customArgsForLaunch, headlessClaudeLaunch }; +module.exports = { discoverShellProfiles, getShellProfiles, resolveShell, isWindows, isWslShell, windowsToWslPath, shellArgs, quoteArgForShell, quoteArgvForShell, claudeCommand, codexCommand, customArgsForLaunch, headlessClaudeLaunch }; diff --git a/src/main/triggers/trigger-actions.js b/src/main/triggers/trigger-actions.js index 6a010de9e..1770b2378 100644 --- a/src/main/triggers/trigger-actions.js +++ b/src/main/triggers/trigger-actions.js @@ -813,4 +813,4 @@ async function executeOpen(trigger, execution) { } } -module.exports = { createNewSessionLimiter, resolveLocalTarget, resolveProject, createTriggerActions, isVersioned, validateTrigger, refusal }; +module.exports = { createNewSessionLimiter, resolveLocalTarget, resolveProject, createTriggerActions, isVersioned, validateTrigger }; diff --git a/src/main/triggers/trigger-watcher.js b/src/main/triggers/trigger-watcher.js index d82bf39e7..4e185b01b 100644 --- a/src/main/triggers/trigger-watcher.js +++ b/src/main/triggers/trigger-watcher.js @@ -2409,4 +2409,4 @@ function start(ctx) { }; } -module.exports = { deliverSingle, start, getTriggersDir, getQuietMs, describeBusyComposer, weakestSubmitted, SUBMITTED_RANK, normalizeCwd, submitWithVerify, waitForCliIdleAfter, waitForBusyFall, transcriptOwnEntryAt, transcriptShowsTurnOver, isCompactCommand, REASON_REMOTE_NO_FRESH_PULL, REASON_REMOTE_SHELL }; +module.exports = { deliverSingle, start, getTriggersDir, getQuietMs, describeBusyComposer, weakestSubmitted, SUBMITTED_RANK, normalizeCwd, submitWithVerify, waitForCliIdleAfter, waitForBusyFall, transcriptOwnEntryAt, transcriptShowsTurnOver, isCompactCommand }; diff --git a/task-records.js b/task-records.js index d4262e854..5f6f5a412 100644 --- a/task-records.js +++ b/task-records.js @@ -26,4 +26,4 @@ function normalizeTaskEvidence(raw) { inFlightKinds: (flight?.kinds || []).map(kind => ({ kind, label: IN_FLIGHT_LABELS.get(kind) || `Unknown activity (${kind.length > 40 ? kind.slice(0, 40) + '…' : kind})`, known: IN_FLIGHT_KINDS.has(kind) })), terminal }; } -module.exports = { normalizeTaskEvidence, TASK_KINDS, IN_FLIGHT_KINDS }; +module.exports = { normalizeTaskEvidence, IN_FLIGHT_KINDS }; diff --git a/transcript-turn.js b/transcript-turn.js index 0aaeb1974..7d70e75fb 100644 --- a/transcript-turn.js +++ b/transcript-turn.js @@ -252,4 +252,4 @@ function createTranscriptTurnReader({ tailBytes = DEFAULT_TAIL_BYTES } = {}) { }; } -module.exports = { classifyTranscriptTail, createTranscriptTurnReader, promptMatches, CLOSED_STOP_REASONS }; +module.exports = { classifyTranscriptTail, createTranscriptTurnReader, promptMatches }; diff --git a/viewer-file-watch.js b/viewer-file-watch.js index 13b50ebbd..e3671dde0 100644 --- a/viewer-file-watch.js +++ b/viewer-file-watch.js @@ -137,4 +137,4 @@ function createViewerWatchRegistry(deps) { return { watch, unwatch, closeAll, size: () => entries.size, refs: (p) => (entries.get(p) || { refs: 0 }).refs }; } -module.exports = { watchFileForViewer, createViewerWatchRegistry, sameFileName, watchTargets, DEFAULT_DEBOUNCE_MS }; +module.exports = { watchFileForViewer, createViewerWatchRegistry, sameFileName, watchTargets }; diff --git a/viewer-save-guard.js b/viewer-save-guard.js index d84f09bfc..d94c7017f 100644 --- a/viewer-save-guard.js +++ b/viewer-save-guard.js @@ -111,4 +111,4 @@ function createMainPanelSaves({ getKnownProjectPaths, invalidateFtsSignature, on }); } -module.exports = { refuseIfMoved, writeIfUnmoved, createPanelSaveHandlers, createMainPanelSaves, asEditorText }; +module.exports = { refuseIfMoved, createPanelSaveHandlers, createMainPanelSaves };