Skip to content

rohitg00/pro-workflow / skills/wiki-query

wiki-query

Verified

Query pro-workflow wikis via SQLite FTS5 BM25 retrieval. Returns top-K passages with citations. Use when answering a question that any of the user's wikis already covers, when the user says "what does the wiki say about X", "ask wiki", "search wikis", or before drafting a new wiki page (to avoid duplication).

FileKindSize
SKILL.mdskill md2.2 KB
scripts/query.jsexecutablescript3.4 KB

scripts/query.js

View on GitHub
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');

const PRO_WORKFLOW_ROOT = path.resolve(__dirname, '..', '..', '..');

function getStore() {
  const distPath = path.join(PRO_WORKFLOW_ROOT, 'dist', 'db', 'store.js');
  if (!fs.existsSync(distPath)) {
    console.error(`[wiki-query] built store missing at ${distPath}. Run: cd ${PRO_WORKFLOW_ROOT} && npm install && npm run build`);
    process.exit(1);
  }
  return require(distPath).createStore();
}

function parseArgs(argv) {
  const out = { _: [] };
  for (let i = 0; i < argv.length; i++) {
    const a = argv[i];
    if (a.startsWith('--')) {
      const key = a.slice(2);
      const next = argv[i + 1];
      if (next && !next.startsWith('--')) { out[key] = next; i++; }
      else out[key] = true;
    } else {
      out._.push(a);
    }
  }
  return out;
}

function cmdSearch(args) {
  const query = args._[0];
  if (!query) { console.error('search: query required'); process.exit(1); }
  const limit = parseInt(args.limit, 10) || 10;
  const store = getStore();
  try {
    const hits = store.searchWiki(query, { wikiSlug: args.wiki, limit });
    if (args.json) {
      console.log(JSON.stringify(hits, null, 2));
    } else if (!hits.length) {
      console.log('(no matches)');
    } else {
      for (const h of hits) {
        console.log(`${h.wiki_slug} · ${h.rel_path}  [${h.rank.toFixed(2)}]`);
        console.log(`  ${h.title}`);
        if (h.snippet) console.log(`  ${h.snippet.replace(/\n/g, ' ')}`);
      }
    }
  } finally {
    store.close();
  }
}

function cmdRelated(args) {
  const slug = args._[0];
  const relPath = args._[1];
  if (!slug || !relPath) { console.error('related: slug and rel-path required'); process.exit(1); }
  const limit = parseInt(args.limit, 10) || 5;
  const store = getStore();
  try {
    const page = store.getWikiPage(slug, relPath);
    if (!page) { console.error(`page not found: ${slug}/${relPath}`); process.exit(1); }
    const seed = [page.title, page.summary].filter(Boolean).join(' ');
    const hits = store.searchWiki(seed, { wikiSlug: slug, limit: limit + 1 })
      .filter(h => h.rel_path !== relPath)
      .slice(0, limit);
    if (args.json) console.log(JSON.stringify(hits, null, 2));
    else if (!hits.length) console.log('(no related pages)');
    else hits.forEach(h => console.log(`${h.rel_path}  ${h.title}  [${h.rank.toFixed(2)}]`));
  } finally {
    store.close();
  }
}

function cmdShow(args) {
  const slug = args._[0];
  const relPath = args._[1];
  if (!slug || !relPath) { console.error('show: slug and rel-path required'); process.exit(1); }
  const store = getStore();
  try {
    const page = store.getWikiPage(slug, relPath);
    if (!page) { console.error('page not found'); process.exit(1); }
    if (args.json) console.log(JSON.stringify({ ...page, content: undefined, content_preview: page.content?.slice(0, 1000) }, null, 2));
    else console.log(page.content || '');
  } finally {
    store.close();
  }
}

function usage() {
  console.error(`Usage:
  query.js search "<query>" [--wiki <slug>] [--limit 10] [--json]
  query.js related <slug> <rel-path> [--limit 5] [--json]
  query.js show <slug> <rel-path> [--json]`);
  process.exit(1);
}

function main() {
  const [, , cmd, ...rest] = process.argv;
  const args = parseArgs(rest);
  switch (cmd) {
    case 'search': return cmdSearch(args);
    case 'related': return cmdRelated(args);
    case 'show': return cmdShow(args);
    default: usage();
  }
}

main();
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall