diffwiki 0.4.0-rc.202607221626.1556159 → 0.4.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.
Files changed (2) hide show
  1. package/dist/bin.js +7 -128
  2. package/package.json +2 -4
package/dist/bin.js CHANGED
@@ -9,16 +9,9 @@ import {
9
9
  doctor,
10
10
  getConfigValue,
11
11
  initRepoWiki,
12
- installPlugin,
13
12
  listCollections,
14
- listAvailablePlugins,
15
- listPlugins,
16
- listSearchModes,
17
- loadSearchProvider,
18
- search,
19
- registerPlugin,
13
+ query,
20
14
  removeArticle,
21
- removePlugin,
22
15
  removeTags,
23
16
  setConfigValue,
24
17
  setTags,
@@ -154,7 +147,7 @@ async function stopUi() {
154
147
  var icon = (level) => level === "ok" ? "\u2713" : level === "warn" ? "!" : "\u2716";
155
148
  function createProgram() {
156
149
  const program = new Command();
157
- program.name("diffwiki").description("A git-based knowledge base").version(version).showHelpAfterError().option("-v, --verbose", "verbose logging (sets the log level to debug)").option("--log <level>", "log level: trace|debug|info|warning|error|fatal");
150
+ program.name("diffwiki").description("A git-based knowledge base").version(version).showHelpAfterError();
158
151
  program.action(() => {
159
152
  program.outputHelp();
160
153
  });
@@ -209,82 +202,15 @@ function createProgram() {
209
202
  registerTagCommand("add-tags", addTags);
210
203
  registerTagCommand("remove-tags", removeTags);
211
204
  registerTagCommand("update-tags", setTags);
212
- program.command("index").description("Rebuild the search index via the active plugin").option("--embed", "also build vector embeddings (may download models on first run)").action(
213
- withErrors(async (opts) => {
214
- const provider = await loadSearchProvider();
215
- if (!provider) {
216
- const installable = (await listSearchModes()).filter((m) => m.plugin !== "native");
217
- console.log(
218
- installable.length > 0 ? `No index-backed plugin active. Available modes: ${installable.map((m) => `${m.plugin}\xB7${m.type}`).join(", ")}` : "No search plugin installed \u2014 using native search (nothing to index). Install one with: diffwiki plugin install <spec>"
219
- );
220
- return;
221
- }
222
- const indexed = await provider.reindex(await listCollections(), { embed: !!opts.embed });
223
- console.log(`Indexed ${indexed} document(s).`);
224
- })
225
- );
226
- program.command("query").description("Search articles via the resolved search engine (native fallback if none)").option("--engine <name>", "search engine/plugin (default: config defaultSearch, else native)").option("-c, --collection <name>", "limit to a collection").option("-t, --type <type>", "search type (engine-defined, e.g. keyword|semantic|hybrid)").argument("[term]", "search term", "").action(
205
+ program.command("query").description("Search articles (dummy \u2014 QMD coming later)").option("-c, --collection <name>", "limit to a collection").argument("[term]", "search term", "").action(
227
206
  withErrors(async (term, opts) => {
228
- const queryOpts = { engine: opts.engine, collection: opts.collection, type: opts.type };
229
- const outcome = await search(term, queryOpts);
230
- const hits = outcome.hits;
231
- console.log(`${hits.length} result(s)`);
207
+ const hits = await query(term, opts.collection);
208
+ console.log(`(dummy search \u2014 QMD coming later) ${hits.length} result(s)`);
232
209
  for (const hit of hits) {
233
- const line = `${hit.collection} ${hit.title} ${hit.path}`;
234
- console.log(hit.snippet ? `${line} ${hit.snippet}` : line);
235
- }
236
- if (outcome.error) {
237
- console.error(`\u26A0 engine "${outcome.engine}" failed: ${outcome.error} \u2014 used native (${hits.length} results)`);
210
+ console.log(`${hit.collection} ${hit.title} ${hit.path}`);
238
211
  }
239
212
  })
240
213
  );
241
- const plugin = program.command("plugin").description("Manage search plugins");
242
- plugin.command("install").description("Install a search plugin from an npm spec and provision it (setup)").argument("<spec>", "npm package spec (name, name@version, or path)").option("--no-setup", "skip the end-to-end setup after install").option("--prefetch-models", "pre-download models during setup (heavy)").action(
243
- withErrors(async (spec, opts) => {
244
- const record = await installPlugin(spec, {
245
- setup: opts.setup,
246
- prefetchModels: opts.prefetchModels
247
- });
248
- console.log(`Installed "${record.name}"${record.version ? ` v${record.version}` : ""}`);
249
- if (!opts.setup) console.log("Skipped setup (--no-setup) \u2014 run: diffwiki index");
250
- })
251
- );
252
- plugin.command("register").description("Register an existing executable as a search plugin").argument("<name>", "plugin name").requiredOption("--command <cmd...>", "command argv to spawn the plugin (e.g. node /abs/adapter.js)").action(
253
- withErrors(async (name, opts) => {
254
- const record = await registerPlugin(name, opts.command);
255
- console.log(`Registered "${record.name}" \u2192 ${record.command.join(" ")}`);
256
- })
257
- );
258
- plugin.command("list").description("List installed and available search plugins").action(
259
- withErrors(async () => {
260
- const installed = await listPlugins();
261
- const installedNames = new Set(installed.map((p) => p.name));
262
- console.log("Installed:");
263
- if (installed.length === 0) {
264
- console.log(" (none)");
265
- } else {
266
- for (const p of installed) {
267
- console.log(
268
- ` ${p.name} ${p.kind} ${p.version ?? "-"} enabled=${p.enabled} managed=${!!p.managed} spawnable=${p.spawnable}`
269
- );
270
- }
271
- }
272
- const available = listAvailablePlugins().filter((k) => !installedNames.has(k.name));
273
- if (available.length > 0) {
274
- console.log("\nAvailable (install with: diffwiki plugin install <name>):");
275
- for (const k of available) {
276
- console.log(` ${k.name} [${k.kind}] ${k.description}`);
277
- console.log(` requires ${k.requires ?? "nothing"}`);
278
- }
279
- }
280
- })
281
- );
282
- plugin.command("remove").description("Remove a search plugin").argument("<name>", "plugin name").action(
283
- withErrors(async (name) => {
284
- await removePlugin(name);
285
- console.log(`Removed "${name}"`);
286
- })
287
- );
288
214
  program.command("init").description("Initialize an in-repo wiki and register it globally").option("-c, --collection <name>", "collection name (default: repo name)").option("-p, --path <path>", "wiki path within the repo (default: wiki)").action(
289
215
  withErrors(async (opts) => {
290
216
  const entry = await initRepoWiki({
@@ -296,7 +222,7 @@ function createProgram() {
296
222
  console.log("Registered globally \u2014 discoverable via: diffwiki list");
297
223
  })
298
224
  );
299
- program.command("config-set").description("Set a config value (e.g. defaultCollection, or defaultSearch <engine[:type]>)").argument("<key>", "config key").argument("<value>", "config value").action(
225
+ program.command("config-set").description("Set a config value (e.g. defaultCollection)").argument("<key>", "config key").argument("<value>", "config value").action(
300
226
  withErrors(async (key, value) => {
301
227
  await setConfigValue(key, value);
302
228
  console.log(`Set ${key} = ${value}`);
@@ -363,52 +289,5 @@ function createProgram() {
363
289
  return program;
364
290
  }
365
291
 
366
- // src/logging.ts
367
- import { mkdirSync } from "fs";
368
- import os from "os";
369
- import path2 from "path";
370
- import { configureSync, getConfig } from "@logtape/logtape";
371
- import { getRotatingFileSink } from "@logtape/file";
372
- import { resolveLogLevel } from "diffwiki-core";
373
- var configured = false;
374
- function diffwikiHome() {
375
- const override = process.env.DIFFWIKI_HOME;
376
- return override && override.length > 0 ? override : path2.join(os.homedir(), ".diffwiki");
377
- }
378
- function resolveCliLevel(argv) {
379
- if (argv.includes("-v") || argv.includes("--verbose")) return "debug";
380
- const flagIdx = argv.indexOf("--log");
381
- const flagValue = flagIdx !== -1 ? argv[flagIdx + 1] : void 0;
382
- return resolveLogLevel(flagValue ? { DIFFWIKI_LOG: flagValue } : process.env);
383
- }
384
- function formatLine(record) {
385
- const category = record.category.join(".");
386
- const message = record.message.map((part) => typeof part === "string" ? part : String(part)).join("");
387
- return `${record.level.toUpperCase()} [${category}] ${message}`;
388
- }
389
- function configureCliLogging(argv = process.argv) {
390
- if (configured || getConfig() != null) return;
391
- configured = true;
392
- const level = resolveCliLevel(argv);
393
- const logsDir = path2.join(diffwikiHome(), "logs");
394
- mkdirSync(logsDir, { recursive: true });
395
- const logFile = path2.join(logsDir, "diffwiki.log");
396
- const stderrSink = (record) => {
397
- process.stderr.write(formatLine(record) + "\n");
398
- };
399
- configureSync({
400
- sinks: {
401
- stderr: stderrSink,
402
- file: getRotatingFileSink(logFile)
403
- },
404
- loggers: [
405
- { category: ["diffwiki"], lowestLevel: level, sinks: ["stderr", "file"] },
406
- // Silence everything else (incl. LogTape meta logs).
407
- { category: [], lowestLevel: "fatal", sinks: [] }
408
- ]
409
- });
410
- }
411
-
412
292
  // src/bin.ts
413
- configureCliLogging(process.argv);
414
293
  createProgram().parseAsync(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffwiki",
3
- "version": "0.4.0-rc.202607221626.1556159",
3
+ "version": "0.4.0",
4
4
  "description": "diffwiki command-line interface",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,10 +14,8 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@logtape/logtape": "^2.2.4",
18
- "@logtape/file": "^2.2.4",
19
17
  "commander": "^13.0.0",
20
- "diffwiki-core": "0.4.0-rc.202607221626.1556159"
18
+ "diffwiki-core": "0.4.0"
21
19
  },
22
20
  "devDependencies": {
23
21
  "@types/node": "^22.0.0"