outrank-cli 0.5.0 → 0.6.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 (58) hide show
  1. package/README.md +317 -20
  2. package/SKILL.md +20 -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 +30 -58
  55. package/src/commands/marketplace.js +0 -740
  56. package/src/commands/products.js +0 -1185
  57. package/src/core/api.js +0 -82
  58. package/src/core/args.js +0 -144
package/src/index.js CHANGED
@@ -1,28 +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
- import { handleMarketplaceCommand } from './commands/marketplace.js';
17
-
18
- const getVersion = () => {
19
- try {
20
- const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
21
- return packageJson.version || 'unknown';
22
- } catch {
23
- return 'unknown';
24
- }
25
- };
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'];
26
13
 
27
14
  const ROOT_HELP = `Outrank CLI
28
15
 
@@ -43,9 +30,13 @@ Groups:
43
30
  usage Inspect current usage and quota consumption.
44
31
  billing Product-slot purchase flows.
45
32
 
33
+ MCP Server:
34
+ outrank-cli mcp Start the Outrank MCP server on stdio (see outrank-cli mcp --help).
35
+
46
36
  Global Auth Options:
47
37
  --api-key <key> Override the API key for this command only.
48
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).
49
40
 
50
41
  JSON Input Conventions:
51
42
  Complex write commands accept one of:
@@ -81,7 +72,6 @@ Examples:
81
72
 
82
73
  const main = async () => {
83
74
  const argv = process.argv.slice(2);
84
- const parsed = parseArgs(argv);
85
75
  const first = argv[0];
86
76
 
87
77
  if (argv.length === 0 || first === '--help' || first === '-h' || first === 'help') {
@@ -108,44 +98,26 @@ const main = async () => {
108
98
  return;
109
99
  }
110
100
 
111
- const group = argv[0];
112
- const rest = argv.slice(1);
113
-
114
- let result;
115
- if (group === 'auth') {
116
- result = await handleAuthCommand(rest);
117
- } else if (group === 'products') {
118
- result = await handleProductsCommand(rest);
119
- } else if (group === 'keywords') {
120
- result = await handleKeywordsCommand(rest);
121
- } else if (group === 'articles') {
122
- result = await handleArticlesCommand(rest);
123
- } else if (group === 'improvements') {
124
- result = await handleImprovementsCommand(rest);
125
- } else if (group === 'marketplace') {
126
- result = await handleMarketplaceCommand(rest);
127
- } else if (group === 'subscription') {
128
- result = await handleSubscriptionCommand(rest);
129
- } else if (group === 'usage') {
130
- result = await handleUsageCommand(rest);
131
- } else if (group === 'billing') {
132
- result = await handleBillingCommand(rest);
133
- } else {
134
- throw Object.assign(new Error(`Unknown command group: ${group}.`), {
135
- cliCode: 'CLI_INVALID_USAGE',
136
- guidance: 'Run `outrank-cli --help` to see the available top-level groups.',
137
- });
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;
138
109
  }
139
110
 
140
- 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);
141
119
  };
142
120
 
143
121
  main().catch((error) => {
144
- const message = error?.message || 'Unexpected CLI failure.';
145
- const code = error?.cliCode || 'CLI_UNEXPECTED_ERROR';
146
- const guidance =
147
- error?.guidance ||
148
- 'Retry with --help for usage details. If the command and inputs look correct, inspect the error details and try again.';
149
-
150
- emitAndExit(cliError(code, message, guidance), 1);
122
+ emitAndExit(toErrorEnvelope(error), EXIT_FAILURE);
151
123
  });