Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
JavaScript agent-skillsai-agentsai-seoclaudeclaude-codeclaude-code-pluginclaude-skillscodexcontent-marketingconversion-rate-optimizationcopywritingcursoremail-marketinggenerative-engine-optimizationgrowth-marketingmarketingmarketing-automationsaas-marketingseoskill-md
fix(keywords-everywhere): send scalar seeds for suggestions
RudyCelekli4415ca9dfdc3
diff --git a/tests/clis/keywords-seed-suggestions.test.cjs b/tests/clis/keywords-seed-suggestions.test.cjsnew file mode 100644index 0000000..630006a--- /dev/null+++ b/tests/clis/keywords-seed-suggestions.test.cjs@@ -0,0 +1,54 @@+const assert = require('node:assert/strict')+const { spawnSync } = require('node:child_process')+const fs = require('node:fs')+const os = require('node:os')+const path = require('node:path')+const { test } = require('node:test')+const cli = path.resolve(__dirname, '../../tools/clis/keywords-everywhere.js')+function run(argv, env = {}, response = "throw new Error('unexpected network request')") {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'marketing-contract-'))+ const mock = path.join(tmp, 'fetch.cjs')+ fs.writeFileSync(mock, `const assert = require('node:assert/strict'); global.fetch = async (url, opts) => { ${response} };`)+ const childEnv = { ...process.env, ...env }+ for (const [key, val] of Object.entries(env)) if (val === undefined) delete childEnv[key]+ try {+ return spawnSync(process.execPath, ['--require', mock, cli, ...argv], { env: childEnv, encoding: 'utf8', timeout: 10000 })+ } finally { fs.rmSync(tmp, { recursive: true, force: true }) }+}+function value(result) {+ assert.equal(result.status, 0, result.stderr)+ return JSON.parse(result.stdout)+}++const env = { KEYWORDS_EVERYWHERE_API_KEY: 'fixture-key' }+for (const sub of ['related', 'pasf']) {+ test(`${sub} sends one seed keyword instead of a keyword-data array`, () => {+ const result = run(['keywords', sub, '--keyword', 'climate + change, impacts', '--num', '5'], env, `+ assert.equal(new URL(url).pathname, '/v1/get_${sub === 'related' ? 'related' : 'pasf'}_keywords');+ assert.equal(opts.method, 'POST'); assert.equal(opts.headers.Authorization, 'Bearer fixture-key');+ assert.deepEqual(JSON.parse(opts.body), {keyword:'climate + change, impacts', num:5});+ return new Response('{"data":[]}');`)+ assert.deepEqual(value(result), {data:[]})+ })+ test(`${sub} preserves --kw as a scalar compatibility alias`, () => {+ const result = value(run(['keywords', sub, '--kw', 'one, literal phrase', '--dry-run'], env))+ assert.deepEqual(result.body, { keyword: 'one, literal phrase' })+ assert.equal(result.headers.Authorization, '***')+ })+ test(`${sub} rejects missing seed`, () => {+ const result = run(['keywords', sub], env)+ assert.equal(result.status, 1)+ assert.match(result.stderr, /--keyword/)+ })+}+test('keyword data continues accepting a comma-separated array', () => {+ const result = value(run(['keywords', 'data', '--kw', 'first,second', '--dry-run'], env))+ assert.deepEqual(result.body.kw, ['first','second'])+})+for (const num of ['0', '-1', 'abc', '1.5', '10001']) {+ test(`invalid suggestion count ${num} fails before any request`, () => {+ const result = run(['keywords', 'related', '--keyword', 'climate change', '--num', num], env)+ assert.equal(result.status, 1)+ assert.match(result.stderr, /--num/)+ })+}diff --git a/tools/clis/keywords-everywhere.js b/tools/clis/keywords-everywhere.jsindex b1b1998..bc02e3d 100755--- a/tools/clis/keywords-everywhere.js+++ b/tools/clis/keywords-everywhere.js@@ -54,6 +54,20 @@ function parseArgs(args) {const args = parseArgs(rawArgs)const [cmd, sub, ...rest] = args._+function suggestionBody() {+ const keyword = args.keyword !== undefined ? args.keyword : args.kw+ if (typeof keyword !== 'string' || !keyword.trim()) throw new Error('--keyword required (one seed keyword; --kw is an alias)')+ const body = { keyword }+ if (args.num !== undefined) {+ const num = Number(args.num)+ if (typeof args.num !== 'string' || !Number.isSafeInteger(num) || num < 1 || num > 10000) {+ throw new Error('--num must be an integer from 1 to 10000')+ }+ body.num = num+ }+ return body+}+async function main() {let resultconst country = args.country || 'us'@@ -70,15 +84,11 @@ async function main() {break}case 'related': {- const kw = args.kw?.split(',')- if (!kw) { result = { error: '--kw required (comma-separated keywords)' }; break }- result = await api('POST', '/get_related_keywords', { country, currency, dataSource, kw })+ result = await api('POST', '/get_related_keywords', suggestionBody())break}case 'pasf': {- const kw = args.kw?.split(',')- if (!kw) { result = { error: '--kw required (comma-separated keywords)' }; break }- result = await api('POST', '/get_pasf_keywords', { country, currency, dataSource, kw })+ result = await api('POST', '/get_pasf_keywords', suggestionBody())break}default:@@ -168,7 +178,7 @@ async function main() {result = {error: 'Unknown command',usage: {- keywords: 'keywords [data|related|pasf] --kw <kw1,kw2,...>',+ keywords: 'keywords data --kw <kw1,kw2,...> | keywords [related|pasf] --keyword <seed> [--num <n>] (--kw is a seed alias)',domain: 'domain [keywords|traffic|backlinks|unique-backlinks] --domain <domain>',url: 'url [keywords|traffic|backlinks|unique-backlinks] --url <url>',account: 'account [credits|countries|currencies]',diff --git a/tools/integrations/keywords-everywhere.md b/tools/integrations/keywords-everywhere.mdindex 337079e..0e2c168 100644--- a/tools/integrations/keywords-everywhere.md+++ b/tools/integrations/keywords-everywhere.md@@ -43,10 +43,8 @@ POST https://api.keywordseverywhere.com/v1/get_related_keywordsAuthorization: Bearer {api_key}{- "country": "us",- "currency": "USD",- "dataSource": "gkp",- "kw": ["email marketing"]+ "keyword": "email marketing",+ "num": 5}```@@ -58,13 +56,23 @@ POST https://api.keywordseverywhere.com/v1/get_pasf_keywordsAuthorization: Bearer {api_key}{- "country": "us",- "currency": "USD",- "dataSource": "gkp",- "kw": ["email marketing"]+ "keyword": "email marketing",+ "num": 5}```+Related and PASF suggestions each take one seed in `keyword`, with optional `num`+for the number of suggestions. The CLI accepts `--keyword`; `--kw` remains a scalar+alias for these two commands. Use comma-separated `--kw` only with `keywords data`.++```bash+node tools/clis/keywords-everywhere.js keywords related --keyword "email marketing" --num 5 --dry-run+node tools/clis/keywords-everywhere.js keywords pasf --keyword "email marketing" --num 5 --dry-run+```++Official request examples: [Related keywords](https://api.keywordseverywhere.com/docs/keyword_data/get_related_keywords.md),+[PASF keywords](https://api.keywordseverywhere.com/docs/keyword_data/get_pasf_keywords.md).+### Get domain keywords (what a domain ranks for)```bash