scanruler-mcp 0.4.1 → 0.5.0

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/src/config.js CHANGED
@@ -64,10 +64,32 @@ export function loadFolders(dir = configDir()) {
64
64
  }
65
65
  }
66
66
 
67
- /** Keep the folders for the next run, and for the other copies. */
67
+ /** Keep the folders for the next run, and for the other copies — the
68
+ * last project kept beside them as it was. */
68
69
  export function saveFolders(folders, dir = configDir()) {
70
+ writeKept(dir, { folders, project: loadLastProject(dir) })
71
+ }
72
+
73
+ /** The project file last opened or saved through a copy of this server,
74
+ * or null — kept with the folders: what a page that came back empty is
75
+ * pointed to. */
76
+ export function loadLastProject(dir = configDir()) {
77
+ try {
78
+ const kept = JSON.parse(readFileSync(join(dir, 'folders.json'), 'utf8'))
79
+ return typeof kept.project === 'string' && kept.project ? kept.project : null
80
+ } catch {
81
+ return null
82
+ }
83
+ }
84
+
85
+ /** Keep the last project, the folders as they were. */
86
+ export function saveLastProject(project, dir = configDir()) {
87
+ writeKept(dir, { folders: loadFolders(dir) ?? [], project })
88
+ }
89
+
90
+ const writeKept = (dir, { folders, project }) => {
69
91
  mkdirSync(dir, { recursive: true })
70
- writeFileSync(join(dir, 'folders.json'), JSON.stringify({ saved: new Date().toISOString(), folders }) + '\n')
92
+ writeFileSync(join(dir, 'folders.json'), JSON.stringify({ saved: new Date().toISOString(), folders, ...(project ? { project } : {}) }) + '\n')
71
93
  }
72
94
 
73
95
  /** The stored config, with a token made and saved if there was none. */
package/src/main.js CHANGED
@@ -10,7 +10,7 @@ import { resolve } from 'node:path'
10
10
  import { format, parseArgs } from 'node:util'
11
11
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
12
12
  import { openInBrowser } from './browser.js'
13
- import { configDir, loadConfig, loadFolders, loadRemembered, saveFolders, saveRemembered } from './config.js'
13
+ import { configDir, loadConfig, loadFolders, loadLastProject, loadRemembered, saveFolders, saveLastProject, saveRemembered } from './config.js'
14
14
  import { CHECKOUT_ENGINE, EngineLink, loadEngine } from './engine.js'
15
15
  import { originAllowed } from './link.js'
16
16
  import { ANSWER_WITHIN_MS, createMcpServer, TOOL_MODES } from './mcp.js'
@@ -194,7 +194,7 @@ export async function main(argv = process.argv.slice(2)) {
194
194
  connectHelp: () => (link.error ? `${link.error} ` : '') + connectHelp(),
195
195
  serverInfo: () => ({ name: 'scanruler-mcp', version: VERSION, ...updates.info(), port, role: link.role, ...(link.role === 'relay' ? { holder: { version: link.holderVersion ?? null } } : {}), tools, outDir, config: config.file, ...(trace ? { trace: trace.file } : {}), ...(link.error ? { error: link.error } : {}) }),
196
196
  remembered: { load: () => loadRemembered(), save: (commands) => saveRemembered(commands) },
197
- folderStore: { load: () => loadFolders(), save: (folders) => saveFolders(folders) },
197
+ folderStore: { load: () => loadFolders(), save: (folders) => saveFolders(folders), loadProject: () => loadLastProject(), saveProject: (project) => saveLastProject(project) },
198
198
  openPage: () => openInBrowser(pairing),
199
199
  tools,
200
200
  trace,