knowmind 0.3.1 → 0.3.4

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/install.js CHANGED
@@ -81,6 +81,20 @@ const IDES = {
81
81
  globalPath: () => appData("Claude", "claude_desktop_config.json"),
82
82
  projectPath: null,
83
83
  },
84
+ gemini: {
85
+ label: "Gemini CLI",
86
+ family: "mcpServers",
87
+ secret: "literal-only",
88
+ globalPath: () => home(".gemini", "settings.json"),
89
+ projectPath: (cwd) => join(cwd, ".gemini", "settings.json"),
90
+ },
91
+ codex: {
92
+ label: "Codex CLI",
93
+ family: "toml",
94
+ secret: "literal-only",
95
+ globalPath: () => home(".codex", "config.toml"),
96
+ projectPath: null,
97
+ },
84
98
  "claude-code": {
85
99
  label: "Claude Code",
86
100
  family: "mcpServers",
@@ -137,6 +151,35 @@ function snippet(ide, opts) {
137
151
  return { [ide.family]: { knowmind: entry } };
138
152
  }
139
153
 
154
+ // ── TOML (Codex CLI) ────────────────────────────────────────────────────────
155
+ // Codex liest ~/.codex/config.toml. Es gibt keinen TOML-Parser als Abhängigkeit
156
+ // und es soll keiner dazukommen — der knowmind-Block wird zeilenbasiert ersetzt:
157
+ // Abschnittskopf [mcp_servers.knowmind] (und Unterabschnitte) samt Folgezeilen
158
+ // bis zum nächsten Abschnittskopf entfernen, dann den frischen Block anhängen.
159
+ function tomlBlock(opts) {
160
+ const token = tokenRef("literal-only", opts.literalToken);
161
+ return [
162
+ "[mcp_servers.knowmind]",
163
+ `command = "${NPX}"`,
164
+ `args = [${NPX_ARGS.map((a) => `"${a}"`).join(", ")}]`,
165
+ "",
166
+ "[mcp_servers.knowmind.env]",
167
+ `KNOWMIND_TOKEN = "${token}"`,
168
+ `KNOWMIND_API_URL = "${opts.apiUrl}"`,
169
+ ].join("\n");
170
+ }
171
+
172
+ function mergeToml(text, opts) {
173
+ // Erst Zeilenenden vereinheitlichen: `.` matcht kein \r, mit CRLF-Dateien
174
+ // bräche die Abschnitts-Entfernung sonst mitten im Block ab (Test 04.08.).
175
+ const quelltext = (text || "").replace(/\r\n/g, "\n");
176
+ // Kopfzeile + alle Folgezeilen, die keinen neuen Abschnitt beginnen.
177
+ const alt = /(^|\n)\[mcp_servers\.knowmind(\.[^\]]+)?\](?:\n(?!\[).*)*/g;
178
+ let neu = quelltext.replace(alt, "$1");
179
+ neu = neu.replace(/\n{3,}/g, "\n\n").trimEnd();
180
+ return (neu ? neu + "\n\n" : "") + tomlBlock(opts) + "\n";
181
+ }
182
+
140
183
  function readJsonSafe(path) {
141
184
  if (!existsSync(path)) return {};
142
185
  try {
@@ -214,11 +257,35 @@ export function runInstall(opts) {
214
257
  continue;
215
258
  }
216
259
  console.log(`# ${ide.label} — Snippet (manuell einfügen):`);
217
- console.log(JSON.stringify(snippet(ide, entryOpts), null, 2));
260
+ console.log(ide.family === "toml" ? tomlBlock(entryOpts) : JSON.stringify(snippet(ide, entryOpts), null, 2));
218
261
  console.log("");
219
262
  continue;
220
263
  }
221
264
 
265
+ // TOML-Ziel (Codex): Text mergen statt JSON.
266
+ if (ide.family === "toml") {
267
+ const tomlPath = project ? (ide.projectPath && ide.projectPath(cwd)) : ide.globalPath();
268
+ if (!tomlPath) {
269
+ console.log(`# ${ide.label}: kein ${project ? "Projekt" : "globaler"}-Dateipfad — Snippet:`);
270
+ console.log(tomlBlock(entryOpts));
271
+ continue;
272
+ }
273
+ const alterText = existsSync(tomlPath) ? readFileSync(tomlPath, "utf-8") : "";
274
+ const neuerText = mergeToml(alterText, entryOpts);
275
+ if (dryRun) {
276
+ console.log(`# ${ide.label} — DRY RUN → ${tomlPath}`);
277
+ console.log(neuerText);
278
+ continue;
279
+ }
280
+ mkdirSync(dirname(tomlPath), { recursive: true });
281
+ writeFileSync(tomlPath, neuerText, "utf-8");
282
+ console.log(`✓ ${ide.label}: knowmind eingetragen in ${tomlPath}`);
283
+ if (!literalToken) {
284
+ console.log(` → Platzhalter gesetzt: KNOWMIND_TOKEN in ${tomlPath} durch dein Token ersetzen.`);
285
+ }
286
+ continue;
287
+ }
288
+
222
289
  const path = project ? (ide.projectPath && ide.projectPath(cwd)) : (ide.globalPath && ide.globalPath());
223
290
  if (!path) {
224
291
  // Kein Datei-Ziel für diesen Scope → Snippet zeigen.
@@ -244,7 +311,9 @@ export function runInstall(opts) {
244
311
 
245
312
  writeJson(path, merged);
246
313
  console.log(`✓ ${ide.label}: knowmind eingetragen in ${path}`);
247
- if (ide.secret === "env") {
314
+ if (literalToken) {
315
+ console.log(` → ${ide.label} neu starten — fertig.`);
316
+ } else if (ide.secret === "env") {
248
317
  console.log(` → setze KNOWMIND_TOKEN in deiner Umgebung (oder nutze --token).`);
249
318
  } else if (ide.secret === "literal-only" && !literalToken) {
250
319
  console.log(` → Platzhalter gesetzt: KNOWMIND_TOKEN in ${path} durch dein Token ersetzen.`);