outrank-cli 0.4.0 → 0.6.0-rc.1

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 (57) hide show
  1. package/README.md +341 -20
  2. package/SKILL.md +77 -2
  3. package/bin/outrank-mcp.js +3 -0
  4. package/package.json +21 -5
  5. package/src/adapters/cli/jsonInput.js +42 -0
  6. package/src/adapters/cli/parse.js +124 -0
  7. package/src/adapters/cli/run.js +139 -0
  8. package/src/adapters/mcp/constants.js +49 -0
  9. package/src/adapters/mcp/descriptions.js +87 -0
  10. package/src/adapters/mcp/help.js +34 -0
  11. package/src/adapters/mcp/input.js +195 -0
  12. package/src/adapters/mcp/instructions.js +139 -0
  13. package/src/adapters/mcp/logger.js +45 -0
  14. package/src/adapters/mcp/main.js +36 -0
  15. package/src/adapters/mcp/options.js +118 -0
  16. package/src/adapters/mcp/result.js +33 -0
  17. package/src/adapters/mcp/server.js +174 -0
  18. package/src/adapters/mcp/session.js +274 -0
  19. package/src/adapters/mcp/toolNotes.js +426 -0
  20. package/src/adapters/mcp/toolsets.js +106 -0
  21. package/src/commands/articles.js +285 -301
  22. package/src/commands/auth.js +204 -86
  23. package/src/commands/billing.js +102 -104
  24. package/src/commands/improvements.js +319 -211
  25. package/src/commands/index.js +22 -0
  26. package/src/commands/keywords.js +266 -249
  27. package/src/commands/marketplace/buyer.js +386 -0
  28. package/src/commands/marketplace/index.js +83 -0
  29. package/src/commands/marketplace/notifications.js +60 -0
  30. package/src/commands/marketplace/seller.js +595 -0
  31. package/src/commands/marketplace/shared.js +27 -0
  32. package/src/commands/products/backlinks.js +181 -0
  33. package/src/commands/products/core.js +149 -0
  34. package/src/commands/products/gsc.js +250 -0
  35. package/src/commands/products/index.js +174 -0
  36. package/src/commands/products/integrations.js +343 -0
  37. package/src/commands/products/linking.js +192 -0
  38. package/src/commands/products/shared.js +8 -0
  39. package/src/commands/registry.js +272 -0
  40. package/src/commands/subscription.js +20 -30
  41. package/src/commands/usage.js +17 -30
  42. package/src/core/config.js +243 -62
  43. package/src/core/constants.js +101 -0
  44. package/src/core/context.js +311 -0
  45. package/src/core/errors.js +39 -0
  46. package/src/core/execute.js +71 -0
  47. package/src/core/files.js +186 -0
  48. package/src/core/http.js +393 -0
  49. package/src/core/profileSelection.js +7 -0
  50. package/src/core/query.js +11 -0
  51. package/src/core/redact.js +27 -0
  52. package/src/core/schema.js +222 -0
  53. package/src/core/version.js +12 -0
  54. package/src/index.js +34 -55
  55. package/src/commands/products.js +0 -1185
  56. package/src/core/api.js +0 -82
  57. package/src/core/args.js +0 -144
package/src/index.js CHANGED
@@ -1,27 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { readFileSync } from 'node:fs';
4
-
5
- import { parseArgs } from './core/args.js';
6
3
  import { emitAndExit } from './core/io.js';
7
- import { cliError, cliSuccess } from './core/errors.js';
8
- import { handleAuthCommand } from './commands/auth.js';
9
- import { handleProductsCommand } from './commands/products.js';
10
- import { handleBillingCommand } from './commands/billing.js';
11
- import { handleSubscriptionCommand } from './commands/subscription.js';
12
- import { handleUsageCommand } from './commands/usage.js';
13
- import { handleKeywordsCommand } from './commands/keywords.js';
14
- import { handleArticlesCommand } from './commands/articles.js';
15
- import { handleImprovementsCommand } from './commands/improvements.js';
16
-
17
- const getVersion = () => {
18
- try {
19
- const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
20
- return packageJson.version || 'unknown';
21
- } catch {
22
- return 'unknown';
23
- }
24
- };
4
+ import { cliSuccess, toErrorEnvelope, usageError } from './core/errors.js';
5
+ import { runRegistryCommand } from './adapters/cli/run.js';
6
+ import { MCP_COMMAND } from './adapters/mcp/constants.js';
7
+ import { MCP_HELP, MCP_HELP_GUIDANCE } from './adapters/mcp/help.js';
8
+ import { registry } from './commands/index.js';
9
+ import { getVersion } from './core/version.js';
10
+
11
+ const EXIT_FAILURE = 1;
12
+ const HELP_TOKENS = ['--help', '-h', 'help'];
25
13
 
26
14
  const ROOT_HELP = `Outrank CLI
27
15
 
@@ -37,13 +25,18 @@ Groups:
37
25
  keywords Inspect, check write status, add, reschedule, delete, suggest, generate, and export keyword plans.
38
26
  articles Inspect article metadata and bodies, edit content, retry publish, precreate, and generate.
39
27
  improvements Discover, brief, schedule, run, review, and publish article improvements for existing posts.
28
+ marketplace Seller onboarding, eligibility, placements, earnings, Stripe payouts, and buyer setup for the Outrank Marketplace.
40
29
  subscription Inspect plan, trial, quota, and add-on status.
41
30
  usage Inspect current usage and quota consumption.
42
31
  billing Product-slot purchase flows.
43
32
 
33
+ MCP Server:
34
+ outrank-cli mcp Start the Outrank MCP server on stdio (see outrank-cli mcp --help).
35
+
44
36
  Global Auth Options:
45
37
  --api-key <key> Override the API key for this command only.
46
38
  --base-url <url> Override the Outrank base URL for this command only.
39
+ --profile <name> Use a stored profile for this command only (see auth --help).
47
40
 
48
41
  JSON Input Conventions:
49
42
  Complex write commands accept one of:
@@ -72,11 +65,13 @@ Examples:
72
65
  outrank-cli products backlinks get <product-id>
73
66
  outrank-cli products backlinks earned <product-id> --limit 20 --include-article
74
67
  outrank-cli billing purchase-products quote --additional-products 2
68
+ outrank-cli marketplace seller status <product-id>
69
+ outrank-cli marketplace seller onboard <product-id> --country US
70
+ outrank-cli marketplace seller placements list <product-id> --status needs_approval
75
71
  `;
76
72
 
77
73
  const main = async () => {
78
74
  const argv = process.argv.slice(2);
79
- const parsed = parseArgs(argv);
80
75
  const first = argv[0];
81
76
 
82
77
  if (argv.length === 0 || first === '--help' || first === '-h' || first === 'help') {
@@ -103,42 +98,26 @@ const main = async () => {
103
98
  return;
104
99
  }
105
100
 
106
- const group = argv[0];
107
- const rest = argv.slice(1);
108
-
109
- let result;
110
- if (group === 'auth') {
111
- result = await handleAuthCommand(rest);
112
- } else if (group === 'products') {
113
- result = await handleProductsCommand(rest);
114
- } else if (group === 'keywords') {
115
- result = await handleKeywordsCommand(rest);
116
- } else if (group === 'articles') {
117
- result = await handleArticlesCommand(rest);
118
- } else if (group === 'improvements') {
119
- result = await handleImprovementsCommand(rest);
120
- } else if (group === 'subscription') {
121
- result = await handleSubscriptionCommand(rest);
122
- } else if (group === 'usage') {
123
- result = await handleUsageCommand(rest);
124
- } else if (group === 'billing') {
125
- result = await handleBillingCommand(rest);
126
- } else {
127
- throw Object.assign(new Error(`Unknown command group: ${group}.`), {
128
- cliCode: 'CLI_INVALID_USAGE',
129
- guidance: 'Run `outrank-cli --help` to see the available top-level groups.',
130
- });
101
+ if (first === MCP_COMMAND) {
102
+ if (argv.slice(1).some((token) => HELP_TOKENS.includes(token))) {
103
+ emitAndExit(cliSuccess({ usage: MCP_HELP.trim() }, MCP_HELP_GUIDANCE));
104
+ return;
105
+ }
106
+ const { runMcpServer } = await import('./adapters/mcp/main.js');
107
+ await runMcpServer(argv.slice(1), { input: process.stdin });
108
+ return;
131
109
  }
132
110
 
133
- emitAndExit(result, result?.ok === false ? 1 : 0);
111
+ const registryOutcome = await runRegistryCommand(registry, argv);
112
+ if (!registryOutcome) {
113
+ throw usageError(
114
+ `Unknown command group: ${argv[0]}.`,
115
+ 'Run `outrank-cli --help` to see the available top-level groups.',
116
+ );
117
+ }
118
+ emitAndExit(registryOutcome.envelope, registryOutcome.exitCode);
134
119
  };
135
120
 
136
121
  main().catch((error) => {
137
- const message = error?.message || 'Unexpected CLI failure.';
138
- const code = error?.cliCode || 'CLI_UNEXPECTED_ERROR';
139
- const guidance =
140
- error?.guidance ||
141
- 'Retry with --help for usage details. If the command and inputs look correct, inspect the error details and try again.';
142
-
143
- emitAndExit(cliError(code, message, guidance), 1);
122
+ emitAndExit(toErrorEnvelope(error), EXIT_FAILURE);
144
123
  });