diffwiki 0.4.0-rc.202607221918.a124bf3 → 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 -135
  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,89 +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 score = typeof hit.score === "number" ? hit.score.toFixed(3) : "-";
234
- const line = `${score} ${hit.collection} ${hit.title} ${hit.path}`;
235
- console.log(hit.snippet ? `${line} ${hit.snippet}` : line);
236
- }
237
- if (outcome.error) {
238
- console.error(`\u26A0 engine "${outcome.engine}" failed: ${outcome.error} \u2014 used native (${hits.length} results)`);
239
- }
240
- })
241
- );
242
- const plugin = program.command("plugin").description("Manage search plugins");
243
- 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(
244
- withErrors(async (spec, opts) => {
245
- const { record, setup } = await installPlugin(spec, {
246
- setup: opts.setup,
247
- prefetchModels: opts.prefetchModels
248
- });
249
- console.log(`Installed "${record.name}"${record.version ? ` v${record.version}` : ""}`);
250
- if (!opts.setup) {
251
- console.log("Skipped setup (--no-setup) \u2014 run: diffwiki index");
252
- } else if (setup && !setup.ready) {
253
- const reason = setup.steps.find((s) => !s.ok)?.message ?? "setup did not complete";
254
- console.log(`\u26A0 Not ready: ${reason}`);
255
- console.log(" \u2192 run: diffwiki doctor");
256
- }
257
- })
258
- );
259
- 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(
260
- withErrors(async (name, opts) => {
261
- const record = await registerPlugin(name, opts.command);
262
- console.log(`Registered "${record.name}" \u2192 ${record.command.join(" ")}`);
263
- })
264
- );
265
- plugin.command("list").description("List installed and available search plugins").action(
266
- withErrors(async () => {
267
- const installed = await listPlugins();
268
- const installedNames = new Set(installed.map((p) => p.name));
269
- console.log("Installed:");
270
- if (installed.length === 0) {
271
- console.log(" (none)");
272
- } else {
273
- for (const p of installed) {
274
- console.log(
275
- ` ${p.name} ${p.kind} ${p.version ?? "-"} enabled=${p.enabled} managed=${!!p.managed} spawnable=${p.spawnable}`
276
- );
277
- }
278
- }
279
- const available = listAvailablePlugins().filter((k) => !installedNames.has(k.name));
280
- if (available.length > 0) {
281
- console.log("\nAvailable (install with: diffwiki plugin install <name>):");
282
- for (const k of available) {
283
- console.log(` ${k.name} [${k.kind}] ${k.description}`);
284
- console.log(` requires ${k.requires ?? "nothing"}`);
285
- }
210
+ console.log(`${hit.collection} ${hit.title} ${hit.path}`);
286
211
  }
287
212
  })
288
213
  );
289
- plugin.command("remove").description("Remove a search plugin").argument("<name>", "plugin name").action(
290
- withErrors(async (name) => {
291
- await removePlugin(name);
292
- console.log(`Removed "${name}"`);
293
- })
294
- );
295
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(
296
215
  withErrors(async (opts) => {
297
216
  const entry = await initRepoWiki({
@@ -303,7 +222,7 @@ function createProgram() {
303
222
  console.log("Registered globally \u2014 discoverable via: diffwiki list");
304
223
  })
305
224
  );
306
- 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(
307
226
  withErrors(async (key, value) => {
308
227
  await setConfigValue(key, value);
309
228
  console.log(`Set ${key} = ${value}`);
@@ -370,52 +289,5 @@ function createProgram() {
370
289
  return program;
371
290
  }
372
291
 
373
- // src/logging.ts
374
- import { mkdirSync } from "fs";
375
- import os from "os";
376
- import path2 from "path";
377
- import { configureSync, getConfig } from "@logtape/logtape";
378
- import { getRotatingFileSink } from "@logtape/file";
379
- import { resolveLogLevel } from "diffwiki-core";
380
- var configured = false;
381
- function diffwikiHome() {
382
- const override = process.env.DIFFWIKI_HOME;
383
- return override && override.length > 0 ? override : path2.join(os.homedir(), ".diffwiki");
384
- }
385
- function resolveCliLevel(argv) {
386
- if (argv.includes("-v") || argv.includes("--verbose")) return "debug";
387
- const flagIdx = argv.indexOf("--log");
388
- const flagValue = flagIdx !== -1 ? argv[flagIdx + 1] : void 0;
389
- return resolveLogLevel(flagValue ? { DIFFWIKI_LOG: flagValue } : process.env);
390
- }
391
- function formatLine(record) {
392
- const category = record.category.join(".");
393
- const message = record.message.map((part) => typeof part === "string" ? part : String(part)).join("");
394
- return `${record.level.toUpperCase()} [${category}] ${message}`;
395
- }
396
- function configureCliLogging(argv = process.argv) {
397
- if (configured || getConfig() != null) return;
398
- configured = true;
399
- const level = resolveCliLevel(argv);
400
- const logsDir = path2.join(diffwikiHome(), "logs");
401
- mkdirSync(logsDir, { recursive: true });
402
- const logFile = path2.join(logsDir, "diffwiki.log");
403
- const stderrSink = (record) => {
404
- process.stderr.write(formatLine(record) + "\n");
405
- };
406
- configureSync({
407
- sinks: {
408
- stderr: stderrSink,
409
- file: getRotatingFileSink(logFile)
410
- },
411
- loggers: [
412
- { category: ["diffwiki"], lowestLevel: level, sinks: ["stderr", "file"] },
413
- // Silence everything else (incl. LogTape meta logs).
414
- { category: [], lowestLevel: "fatal", sinks: [] }
415
- ]
416
- });
417
- }
418
-
419
292
  // src/bin.ts
420
- configureCliLogging(process.argv);
421
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.202607221918.a124bf3",
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.202607221918.a124bf3"
18
+ "diffwiki-core": "0.4.0"
21
19
  },
22
20
  "devDependencies": {
23
21
  "@types/node": "^22.0.0"