@var-ia/cli 0.2.0 → 0.3.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 (36) hide show
  1. package/README.md +27 -0
  2. package/dist/src/commands/analyze.d.ts +5 -2
  3. package/dist/src/commands/analyze.d.ts.map +1 -1
  4. package/dist/src/commands/analyze.js +214 -13
  5. package/dist/src/commands/analyze.js.map +1 -1
  6. package/dist/src/commands/cache.d.ts +2 -2
  7. package/dist/src/commands/cache.d.ts.map +1 -1
  8. package/dist/src/commands/cache.js.map +1 -1
  9. package/dist/src/commands/claim.d.ts +4 -1
  10. package/dist/src/commands/claim.d.ts.map +1 -1
  11. package/dist/src/commands/claim.js +5 -5
  12. package/dist/src/commands/claim.js.map +1 -1
  13. package/dist/src/commands/eval.d.ts +2 -0
  14. package/dist/src/commands/eval.d.ts.map +1 -0
  15. package/dist/src/commands/eval.js +38 -0
  16. package/dist/src/commands/eval.js.map +1 -0
  17. package/dist/src/commands/export.d.ts +1 -1
  18. package/dist/src/commands/export.d.ts.map +1 -1
  19. package/dist/src/commands/export.js +30 -2
  20. package/dist/src/commands/export.js.map +1 -1
  21. package/dist/src/commands/watch.d.ts +1 -1
  22. package/dist/src/commands/watch.d.ts.map +1 -1
  23. package/dist/src/commands/watch.js +2 -2
  24. package/dist/src/commands/watch.js.map +1 -1
  25. package/dist/src/index.d.ts.map +1 -1
  26. package/dist/src/index.js +46 -24
  27. package/dist/src/index.js.map +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +6 -5
  30. package/src/commands/analyze.ts +260 -14
  31. package/src/commands/cache.ts +3 -2
  32. package/src/commands/claim.ts +5 -4
  33. package/src/commands/eval.ts +41 -0
  34. package/src/commands/export.ts +48 -2
  35. package/src/commands/watch.ts +2 -1
  36. package/src/index.ts +62 -31
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { runAnalyze } from "./commands/analyze.js";
2
2
  import { runClaim } from "./commands/claim.js";
3
+ import { runEval } from "./commands/eval.js";
3
4
  import { runExport } from "./commands/export.js";
4
5
  import { runWatch } from "./commands/watch.js";
5
6
  import type { ModelConfig } from "@var-ia/interpreter";
@@ -9,9 +10,11 @@ wikihistory — Wikipedia edit history analysis
9
10
 
10
11
  Usage:
11
12
  wikihistory analyze <page> [--depth brief|detailed|forensic] [--from <revId>] [--to <revId>] [--cache] [--model <provider>]
13
+ wikihistory analyze --pages-file <path> [--depth brief|detailed|forensic] [--cache] [--model <provider>]
12
14
  wikihistory claim <page> --text "<claim text>" [--cache] [--model <provider>]
13
- wikihistory export <page> --format json|csv [--model <provider>]
15
+ wikihistory export <page> --format json|csv [--bundle] [--model <provider>]
14
16
  wikihistory watch <page> [--section <name>]
17
+ wikihistory eval [--page <title>]
15
18
 
16
19
  Options:
17
20
  --depth Analysis depth (default: detailed)
@@ -25,6 +28,7 @@ Options:
25
28
  --model-api-key API key for model provider (or set env var OPENAI_API_KEY etc.)
26
29
  --model-name Model name override (default: provider-specific)
27
30
  --model-endpoint API endpoint override
31
+ --api MediaWiki API base URL (default: https://en.wikipedia.org/w/api.php)
28
32
  `;
29
33
 
30
34
  export async function cli(args: string[]): Promise<void> {
@@ -33,40 +37,58 @@ export async function cli(args: string[]): Promise<void> {
33
37
  switch (command) {
34
38
  case "analyze": {
35
39
  const pageTitle = args[1];
36
- if (!pageTitle) {
37
- console.error("Usage: wikihistory analyze <page> [--depth brief|detailed|forensic] [--cache] [--model <provider>]");
38
- process.exit(1);
39
- }
40
+ const pagesFile = parseFlag(args, "pages-file");
40
41
  const depth = parseFlag(args, "depth") ?? "detailed";
41
42
  const fromRev = parseFlag(args, "from");
42
43
  const toRev = parseFlag(args, "to");
43
44
  const useCache = args.includes("--cache");
44
45
  const modelConfig = parseModelConfig(args);
46
+ const apiUrl = parseFlag(args, "api");
45
47
 
46
- const events = await runAnalyze(
47
- pageTitle,
48
- depth,
49
- fromRev ? parseInt(fromRev, 10) : undefined,
50
- toRev ? parseInt(toRev, 10) : undefined,
51
- useCache,
52
- modelConfig,
53
- );
48
+ if (pagesFile) {
49
+ const result = await runAnalyze(
50
+ "",
51
+ depth,
52
+ fromRev ? parseInt(fromRev, 10) : undefined,
53
+ toRev ? parseInt(toRev, 10) : undefined,
54
+ useCache,
55
+ modelConfig,
56
+ apiUrl,
57
+ pagesFile,
58
+ );
59
+ const events = result.events;
60
+ console.log(`\nBatch complete. Total events: ${events.length}`);
61
+ } else {
62
+ if (!pageTitle) {
63
+ console.error("Usage: wikihistory analyze <page> [--depth brief|detailed|forensic] [--cache] [--model <provider>]");
64
+ process.exit(1);
65
+ }
66
+ const { events } = await runAnalyze(
67
+ pageTitle,
68
+ depth,
69
+ fromRev ? parseInt(fromRev, 10) : undefined,
70
+ toRev ? parseInt(toRev, 10) : undefined,
71
+ useCache,
72
+ modelConfig,
73
+ apiUrl,
74
+ );
54
75
 
55
- console.log(`\n=== Analysis Results ===`);
56
- console.log(`Page: ${pageTitle}`);
57
- console.log(`Events detected: ${events.length}`);
58
- console.log();
76
+ console.log(`\n=== Analysis Results ===`);
77
+ console.log(`Page: ${pageTitle}`);
78
+ console.log(`Events detected: ${events.length}`);
79
+ console.log();
59
80
 
60
- for (const event of events) {
61
- console.log(`[${event.timestamp}] ${event.eventType} (rev ${event.fromRevisionId}→${event.toRevisionId})`);
62
- if (event.section) console.log(` Section: ${event.section}`);
63
- for (const fact of event.deterministicFacts) {
64
- console.log(` • ${fact.fact}${fact.detail ? `: ${fact.detail}` : ""}`);
65
- }
66
- if (event.modelInterpretation) {
67
- console.log(` ↳ ${event.modelInterpretation.semanticChange} (confidence: ${event.modelInterpretation.confidence.toFixed(2)})`);
68
- if (event.modelInterpretation.policyDimension) {
69
- console.log(` ↳ policy: ${event.modelInterpretation.policyDimension}`);
81
+ for (const event of events) {
82
+ console.log(`[${event.timestamp}] ${event.eventType} (rev ${event.fromRevisionId}→${event.toRevisionId})`);
83
+ if (event.section) console.log(` Section: ${event.section}`);
84
+ for (const fact of event.deterministicFacts) {
85
+ console.log(` • ${fact.fact}${fact.detail ? `: ${fact.detail}` : ""}`);
86
+ }
87
+ if (event.modelInterpretation) {
88
+ console.log(` ↳ ${event.modelInterpretation.semanticChange} (confidence: ${event.modelInterpretation.confidence.toFixed(2)})`);
89
+ if (event.modelInterpretation.policyDimension) {
90
+ console.log(` ↳ policy: ${event.modelInterpretation.policyDimension}`);
91
+ }
70
92
  }
71
93
  }
72
94
  }
@@ -81,18 +103,21 @@ export async function cli(args: string[]): Promise<void> {
81
103
  }
82
104
  const useCache = args.includes("--cache");
83
105
  const modelConfig = parseModelConfig(args);
84
- await runClaim(pageTitle, claimText, useCache, modelConfig);
106
+ const apiUrl = parseFlag(args, "api");
107
+ await runClaim(pageTitle, claimText, useCache, modelConfig, apiUrl);
85
108
  break;
86
109
  }
87
110
  case "export": {
88
111
  const pageTitle = args[1];
89
112
  const format = parseFlag(args, "format") ?? "json";
113
+ const bundle = args.includes("--bundle");
90
114
  if (!pageTitle) {
91
- console.error("Usage: wikihistory export <page> --format json|csv [--model <provider>]");
115
+ console.error("Usage: wikihistory export <page> --format json|csv [--bundle] [--model <provider>]");
92
116
  process.exit(1);
93
117
  }
94
118
  const modelConfig = parseModelConfig(args);
95
- await runExport(pageTitle, format, modelConfig);
119
+ const apiUrl = parseFlag(args, "api");
120
+ await runExport(pageTitle, format, modelConfig, apiUrl, bundle);
96
121
  break;
97
122
  }
98
123
  case "watch": {
@@ -102,7 +127,13 @@ export async function cli(args: string[]): Promise<void> {
102
127
  process.exit(1);
103
128
  }
104
129
  const section = parseFlag(args, "section");
105
- await runWatch(pageTitle, section);
130
+ const apiUrl = parseFlag(args, "api");
131
+ await runWatch(pageTitle, section, apiUrl);
132
+ break;
133
+ }
134
+ case "eval": {
135
+ const pageOverride = parseFlag(args, "page");
136
+ await runEval(pageOverride);
106
137
  break;
107
138
  }
108
139
  case "--help":