wtf-p 0.6.0 → 0.7.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 (53) hide show
  1. package/README.md +18 -11
  2. package/bin/lib/adapter-compiler.js +28 -10
  3. package/bin/lib/citation-fetcher.js +4 -1
  4. package/bin/lib/cite-nexus-client.js +120 -0
  5. package/package.json +2 -2
  6. package/vendors/antigravity/.wtfp-generated.json +9 -5
  7. package/vendors/antigravity/plugin.json +1 -1
  8. package/vendors/antigravity/tools/README.md +5 -2
  9. package/vendors/antigravity/tools/citation/fetch.js +4 -1
  10. package/vendors/antigravity/tools/support/cite-nexus-client.js +120 -0
  11. package/vendors/antigravity/tools/wtfp-tool.js +18 -7
  12. package/vendors/claude/.claude-plugin/marketplace.json +2 -2
  13. package/vendors/claude/.claude-plugin/plugin.json +1 -1
  14. package/vendors/claude/.wtfp-generated.json +12 -8
  15. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/help.md +1 -1
  16. package/vendors/claude/plugin.json +1 -1
  17. package/vendors/claude/tools/README.md +5 -2
  18. package/vendors/claude/tools/citation/fetch.js +4 -1
  19. package/vendors/claude/tools/support/cite-nexus-client.js +120 -0
  20. package/vendors/claude/tools/wtfp-tool.js +18 -7
  21. package/vendors/codex/plugins/wtfp/.codex-plugin/plugin.json +1 -1
  22. package/vendors/codex/plugins/wtfp/.wtfp-generated.json +10 -6
  23. package/vendors/codex/plugins/wtfp/plugin.json +1 -1
  24. package/vendors/codex/plugins/wtfp/tools/README.md +5 -2
  25. package/vendors/codex/plugins/wtfp/tools/citation/fetch.js +4 -1
  26. package/vendors/codex/plugins/wtfp/tools/support/cite-nexus-client.js +120 -0
  27. package/vendors/codex/plugins/wtfp/tools/wtfp-tool.js +18 -7
  28. package/vendors/copilot/.wtfp-generated.json +2 -2
  29. package/vendors/copilot/marketplace.json +2 -2
  30. package/vendors/copilot/plugins/wtfp/.claude-plugin/plugin.json +1 -1
  31. package/vendors/copilot/plugins/wtfp/.wtfp-generated.json +9 -5
  32. package/vendors/copilot/plugins/wtfp/tools/README.md +5 -2
  33. package/vendors/copilot/plugins/wtfp/tools/citation/fetch.js +4 -1
  34. package/vendors/copilot/plugins/wtfp/tools/support/cite-nexus-client.js +120 -0
  35. package/vendors/copilot/plugins/wtfp/tools/wtfp-tool.js +18 -7
  36. package/vendors/gemini/.wtfp-generated.json +9 -5
  37. package/vendors/gemini/gemini-extension.json +1 -1
  38. package/vendors/gemini/tools/README.md +5 -2
  39. package/vendors/gemini/tools/citation/fetch.js +4 -1
  40. package/vendors/gemini/tools/support/cite-nexus-client.js +120 -0
  41. package/vendors/gemini/tools/wtfp-tool.js +18 -7
  42. package/vendors/opencode/.wtfp-generated.json +8 -4
  43. package/vendors/opencode/tools/README.md +5 -2
  44. package/vendors/opencode/tools/citation/fetch.js +4 -1
  45. package/vendors/opencode/tools/support/cite-nexus-client.js +120 -0
  46. package/vendors/opencode/tools/wtfp-tool.js +18 -7
  47. package/vendors/plugin/.wtfp-generated.json +10 -6
  48. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/help.md +1 -1
  49. package/vendors/plugin/plugin.json +1 -1
  50. package/vendors/plugin/tools/README.md +5 -2
  51. package/vendors/plugin/tools/citation/fetch.js +4 -1
  52. package/vendors/plugin/tools/support/cite-nexus-client.js +120 -0
  53. package/vendors/plugin/tools/wtfp-tool.js +18 -7
@@ -54,7 +54,7 @@ const COMMANDS = [
54
54
  {
55
55
  "command": "citation-search",
56
56
  "tool": "citation.fetch",
57
- "usage": "citation-search --query=<text> [--limit=<1-25>] [--intent=<seminal|recent|balanced>] [--year=<yyyy>] [--timeout=<seconds>]",
57
+ "usage": "citation-search --query=<text> [--backend=<legacy|cite-nexus>] [--providers=<comma-separated-IDs>] [--limit=<1-25>] [--intent=<seminal|recent|balanced>] [--year=<yyyy>] [--timeout=<seconds>]",
58
58
  "effects": [
59
59
  "network.search"
60
60
  ]
@@ -96,9 +96,9 @@ function offlineRequested(argv) {
96
96
  return argv.includes('--offline') || flag === '1' || flag === 'true';
97
97
  }
98
98
 
99
- function fail(message) {
99
+ function fail(message, status = 1) {
100
100
  process.stderr.write(`${JSON.stringify({ error: message })}\n`);
101
- process.exit(1);
101
+ process.exit(status);
102
102
  }
103
103
 
104
104
  function emit(value) {
@@ -153,7 +153,7 @@ function requirePath(candidate) {
153
153
 
154
154
  function timeoutOf(flags) {
155
155
  if (!flags.has('timeout')) return DEFAULT_TIMEOUT_SECONDS;
156
- const seconds = Number.parseInt(flags.get('timeout'), 10);
156
+ const seconds = /^\d+$/.test(flags.get('timeout')) ? Number(flags.get('timeout')) : NaN;
157
157
  if (!Number.isInteger(seconds) || seconds < 1 || seconds > MAX_TIMEOUT_SECONDS) {
158
158
  fail(`--timeout must be an integer number of seconds between 1 and ${MAX_TIMEOUT_SECONDS}`);
159
159
  }
@@ -184,7 +184,7 @@ function uniqueEntry(bib, content, key) {
184
184
 
185
185
  function limitOf(flags) {
186
186
  if (!flags.has('limit')) return 10;
187
- const limit = Number.parseInt(flags.get('limit'), 10);
187
+ const limit = /^\d+$/.test(flags.get('limit')) ? Number(flags.get('limit')) : NaN;
188
188
  if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) fail(`--limit must be an integer between 1 and ${MAX_LIMIT}`);
189
189
  return limit;
190
190
  }
@@ -221,6 +221,13 @@ async function main(rawArgv) {
221
221
  fail(`${command} is refused in offline mode: it declares ${networkEffects.join(', ')}`);
222
222
  }
223
223
  const { flags, positional } = parseArguments(argv.slice(1));
224
+ const allowedFlags = {
225
+ 'bib-index': ['key', 'query'], 'bib-format': ['key', 'style'],
226
+ 'bib-impact': ['timeout'], 'citation-search': ['query', 'backend', 'providers', 'limit', 'intent', 'year', 'timeout'],
227
+ 'scholar-search': ['query', 'limit', 'timeout'], 's2-search': ['query', 'limit', 'year', 'timeout'],
228
+ 'rank': ['intent']
229
+ };
230
+ for (const key of flags.keys()) if (!allowedFlags[command].includes(key)) fail(`unknown --${key} for ${command}`);
224
231
  if (positional.length > 1) fail(`${command} accepts at most one positional argument: ${declared.usage}`);
225
232
  const load = () => require(MODULES[declared.tool]);
226
233
 
@@ -255,7 +262,11 @@ async function main(rawArgv) {
255
262
  const query = requireText(flags.get('query'), '--query');
256
263
  const year = yearOf(flags);
257
264
  const seconds = timeoutOf(flags);
258
- return emit(await withTimeout(load().search(query, { limit: limitOf(flags), intent: intentOf(flags), ...(year ? { year } : {}) }), seconds, command));
265
+ const backend = flags.get('backend') || 'legacy';
266
+ if (!['legacy', 'cite-nexus'].includes(backend)) fail('--backend must be legacy or cite-nexus');
267
+ const providers = flags.has('providers') ? flags.get('providers').split(',').map((p) => p.trim()) : undefined;
268
+ if (providers && backend !== 'cite-nexus') fail('--providers requires --backend=cite-nexus');
269
+ return emit(await withTimeout(load().search(query, { backend, providers, timeoutSeconds: seconds, limit: limitOf(flags), intent: intentOf(flags), ...(year ? { year } : {}) }), seconds, command));
259
270
  }
260
271
  if (command === 'scholar-search') {
261
272
  if (positional.length > 0) fail(`${command} takes its query through --query: ${declared.usage}`);
@@ -282,5 +293,5 @@ async function main(rawArgv) {
282
293
  // config root as a custom-tool module; an unconditional main() printed a
283
294
  // dispatcher error and exited the host process at session start.
284
295
  if (require.main === module) {
285
- main(process.argv.slice(2)).catch((error) => fail(error && error.message ? error.message : String(error)));
296
+ main(process.argv.slice(2)).catch((error) => fail(error && error.message ? error.message : String(error), error && error.code === 'WTFP_TIMEOUT' ? EXIT_TIMEOUT : 1));
286
297
  }