@neuralsea/workspace-indexer 0.1.0 → 0.3.2

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/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  OpenAIEmbeddingsProvider,
6
6
  WorkspaceIndexer,
7
7
  loadConfigFile
8
- } from "./chunk-QPQCSCBN.js";
8
+ } from "./chunk-GGL3XTMV.js";
9
9
 
10
10
  // src/cli.ts
11
11
  import yargs from "yargs";
@@ -29,63 +29,66 @@ function loadConfig(argv) {
29
29
  if (!fs.existsSync(cfgPath)) throw new Error(`Config file not found: ${cfgPath}`);
30
30
  return loadConfigFile(cfgPath);
31
31
  }
32
- await yargs(hideBin(process.argv)).scriptName("petri-index").option("config", { type: "string", describe: "Path to a JSON config file" }).option("provider", { type: "string", default: "ollama", choices: ["ollama", "openai", "hash"] }).option("model", { type: "string", default: "nomic-embed-text" }).option("baseUrl", { type: "string", describe: "Base URL for Ollama/OpenAI compatible endpoints" }).option("apiKey", { type: "string", describe: "API key for OpenAI (or set OPENAI_API_KEY)" }).option("dim", { type: "number", default: 384, describe: "Dimension for hash embedder" }).command(
33
- "index [root]",
34
- "Index all Git repos under a workspace root",
35
- (y) => y.positional("root", { type: "string", default: process.cwd() }),
36
- async (argv) => {
37
- const cfg = loadConfig(argv);
38
- const embedder = makeEmbedder(argv);
39
- const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
40
- await ix.indexAll();
41
- await ix.closeAsync();
42
- console.log("Index complete.");
43
- }
44
- ).command(
45
- "watch [root]",
46
- "Watch and keep indexes up to date",
47
- (y) => y.positional("root", { type: "string", default: process.cwd() }),
48
- async (argv) => {
49
- const cfg = loadConfig(argv);
50
- const embedder = makeEmbedder(argv);
51
- const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
52
- await ix.indexAll();
53
- await ix.watch();
54
- console.log("Watching. Press Ctrl+C to exit.");
55
- }
56
- ).command(
57
- "query <q> [root]",
58
- "Quick semantic search (profile: search) and print top hits",
59
- (y) => y.positional("q", { type: "string", demandOption: true }).positional("root", { type: "string", default: process.cwd() }).option("k", { type: "number", default: 10 }),
60
- async (argv) => {
61
- const cfg = loadConfig(argv);
62
- const embedder = makeEmbedder(argv);
63
- const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
64
- await ix.indexAll();
65
- const bundle = await ix.retrieve(argv.q, { profile: "search", profileOverrides: { k: argv.k } });
66
- for (const h of bundle.hits) {
67
- console.log(`
32
+ async function main() {
33
+ await yargs(hideBin(process.argv)).scriptName("petri-index").option("config", { type: "string", describe: "Path to a JSON config file" }).option("provider", { type: "string", default: "ollama", choices: ["ollama", "openai", "hash"] }).option("model", { type: "string", default: "nomic-embed-text" }).option("baseUrl", { type: "string", describe: "Base URL for Ollama/OpenAI compatible endpoints" }).option("apiKey", { type: "string", describe: "API key for OpenAI (or set OPENAI_API_KEY)" }).option("dim", { type: "number", default: 384, describe: "Dimension for hash embedder" }).command(
34
+ "index [root]",
35
+ "Index all Git repos under a workspace root",
36
+ (y) => y.positional("root", { type: "string", default: process.cwd() }),
37
+ async (argv) => {
38
+ const cfg = loadConfig(argv);
39
+ const embedder = makeEmbedder(argv);
40
+ const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
41
+ await ix.indexAll();
42
+ await ix.closeAsync();
43
+ console.log("Index complete.");
44
+ }
45
+ ).command(
46
+ "watch [root]",
47
+ "Watch and keep indexes up to date",
48
+ (y) => y.positional("root", { type: "string", default: process.cwd() }),
49
+ async (argv) => {
50
+ const cfg = loadConfig(argv);
51
+ const embedder = makeEmbedder(argv);
52
+ const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
53
+ await ix.indexAll();
54
+ await ix.watch();
55
+ console.log("Watching. Press Ctrl+C to exit.");
56
+ }
57
+ ).command(
58
+ "query <q> [root]",
59
+ "Quick semantic search (profile: search) and print top hits",
60
+ (y) => y.positional("q", { type: "string", demandOption: true }).positional("root", { type: "string", default: process.cwd() }).option("k", { type: "number", default: 10 }),
61
+ async (argv) => {
62
+ const cfg = loadConfig(argv);
63
+ const embedder = makeEmbedder(argv);
64
+ const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
65
+ await ix.indexAll();
66
+ const bundle = await ix.retrieve(argv.q, { profile: "search", profileOverrides: { k: argv.k } });
67
+ for (const h of bundle.hits) {
68
+ console.log(`
68
69
  [${h.score.toFixed(4)}] ${h.chunk.repoRoot} :: ${h.chunk.path}:${h.chunk.startLine}-${h.chunk.endLine} (${h.chunk.kind})`);
69
- console.log(` ${h.chunk.preview}`);
70
+ console.log(` ${h.chunk.preview}`);
71
+ }
72
+ await ix.closeAsync();
70
73
  }
71
- await ix.closeAsync();
72
- }
73
- ).command(
74
- "retrieve <q> [root]",
75
- "Run full retrieval with a chosen profile and output JSON context bundle",
76
- (y) => y.positional("q", { type: "string", demandOption: true }).positional("root", { type: "string", default: process.cwd() }).option("profile", { type: "string", default: "search", choices: ["search", "refactor", "review", "architecture", "rca", "custom"] }).option("k", { type: "number", describe: "Override k in the profile" }).option("changedOnly", { type: "boolean", default: false, describe: "Restrict to files changed compared to baseRef" }).option("baseRef", { type: "string", default: "HEAD~1", describe: "Git ref to diff against when changedOnly is set" }),
77
- async (argv) => {
78
- const cfg = loadConfig(argv);
79
- const embedder = makeEmbedder(argv);
80
- const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
81
- await ix.indexAll();
82
- const profile = argv.profile;
83
- const bundle = await ix.retrieve(argv.q, {
84
- profile,
85
- profileOverrides: argv.k ? { k: argv.k } : void 0,
86
- scope: argv.changedOnly ? { changedOnly: true, baseRef: argv.baseRef } : void 0
87
- });
88
- process.stdout.write(JSON.stringify(bundle, null, 2) + "\n");
89
- await ix.closeAsync();
90
- }
91
- ).demandCommand().strict().help().parseAsync();
74
+ ).command(
75
+ "retrieve <q> [root]",
76
+ "Run full retrieval with a chosen profile and output JSON context bundle",
77
+ (y) => y.positional("q", { type: "string", demandOption: true }).positional("root", { type: "string", default: process.cwd() }).option("profile", { type: "string", default: "search", choices: ["search", "refactor", "review", "architecture", "rca", "custom"] }).option("k", { type: "number", describe: "Override k in the profile" }).option("changedOnly", { type: "boolean", default: false, describe: "Restrict to files changed compared to baseRef" }).option("baseRef", { type: "string", default: "HEAD~1", describe: "Git ref to diff against when changedOnly is set" }),
78
+ async (argv) => {
79
+ const cfg = loadConfig(argv);
80
+ const embedder = makeEmbedder(argv);
81
+ const ix = new WorkspaceIndexer(argv.root, embedder, cfg);
82
+ await ix.indexAll();
83
+ const profile = argv.profile;
84
+ const bundle = await ix.retrieve(argv.q, {
85
+ profile,
86
+ profileOverrides: argv.k ? { k: argv.k } : void 0,
87
+ scope: argv.changedOnly ? { changedOnly: true, baseRef: argv.baseRef } : void 0
88
+ });
89
+ process.stdout.write(JSON.stringify(bundle, null, 2) + "\n");
90
+ await ix.closeAsync();
91
+ }
92
+ ).demandCommand().strict().help().parseAsync();
93
+ }
94
+ void main();