Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/plugins/commercetools/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "commercetools",
"displayName": "commercetools",
"version": "0.6.0",
"version": "0.7.0",
"description": "Build commercetools solutions faster",
"author": {
"name": "commercetools",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ Three modes — choose based on how much of the checkout flow Checkout should ow

When this skill is invoked, always follow these steps:

1. **Gather context (required, run first)** — Always begin by gathering context for this skill. This is the mandatory grounding step: it gathers the latest verified documentation as context for you (the agent). **Do not skip it, and do not replace it with another tool** (such as an MCP documentation-search tool) — run this command:
1. **Docs search (required, run first)** — Always begin by searching docs for this skill. This is the mandatory grounding step: it gathers the latest verified documentation as context for you (the agent). **Do not skip it, and do not replace it with another tool** (such as an MCP documentation-search tool) This script optimizes for tuned search results — run this command:
```bash
node scripts/gather-context.mjs \
node scripts/docs-search.mjs \
--query "<extract key terms from user's question>" \
--client-name "<current-client>" \
--app-name "<current-app ex: claude, copilot, codex>" \
--model "<current-model>" \
--skill-name "commercetools-checkout" \
--limit 3
--limit 20
```
Use its output as your primary grounding. You *may additionally* use other tools (such as the commercetools documentation MCP) for deeper, follow-up search.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/usr/bin/env node

/**
* Search docs for the agent
*
* Gathers relevant commercetools documentation as grounding context for the agent, with instrumentation headers.
* Results are written to stdout for consumption by AI agents.
*
* Usage:
* node scripts/docs-search.mjs --query "how to create payment" --app-name <name> --model <model> --skill-name <skill> [options]
*
* Required:
* --query <string> Search query
* --app-name <string> App identifier (e.g., vscode-copilot, claude-desktop)
* --model <string> Model name (e.g., claude-sonnet-4.5, gpt-4)
* --skill-name <string> Skill identifier (e.g., commercetools-checkout)
*
* Optional:
* --limit <number> Number of results (default: 3)
* --content-types <string> Comma-separated content types
*/

import { parseArgs } from 'util';

const CONTEXT_URL = 'https://docs.commercetools.com/apis/rest/tools/documentation-search';

// Parse command line arguments
const { values } = parseArgs({
options: {
query: { type: 'string' },
limit: { type: 'string', default: '3' },
'app-name': { type: 'string' },
model: { type: 'string' },
'skill-name': { type: 'string' },
'content-types': { type: 'string' },
},
});

// Validate required parameters
const missingParams = [];
if (!values.query) missingParams.push('--query');
if (!values['app-name']) missingParams.push('--app-name');
if (!values.model) missingParams.push('--model');
if (!values['skill-name']) missingParams.push('--skill-name');

if (missingParams.length > 0) {
console.error(`Error: Missing required parameters: ${missingParams.join(', ')}`);
console.error('Usage: node scripts/docs-search.mjs --query "search" --app-name "app" --model "model" --skill-name "skill"');
process.exit(1);
}

const normalizedLimit = Math.min(parseInt(values.limit, 10), 20)

// Build request body
const requestBody = {
query: values.query,
limit: normalizedLimit,
products: ['Composable Commerce', 'Checkout', 'Connect', 'AI Hub']
};

// Add optional content types filter
if (values['content-types']) {
requestBody.contentTypes = values['content-types'].split(',').map(t => t.trim());
}

const requestData = JSON.stringify(requestBody);

async function main() {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 60000);

try {
const res = await fetch(CONTEXT_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestData),
'User-Agent': `${values['app-name']}/1.0 (${values.model})`,
'X-Model': values.model,
'X-Client-Type': values['app-name'],
'X-Skill-Name': values['skill-name'],
},
body: requestData,
signal: controller.signal,
});

if (res.status !== 200) {
process.exit(0);
}

let response;
try {
response = await res.json();
} catch (err) {
process.exit(0);
}

if (response.error) {
process.exit(0);
}

// Format results for AI agent consumption
if (response.result && Array.isArray(response.result)) {
const results = response.result;

if (results.length === 0) {
process.stdout.write('No results found. Try broadening your search query or adjusting filters.\n');
process.exit(0);
}

// Write results in markdown format
process.stdout.write(`# Documentation Search Results\n\n`);
process.stdout.write(`Query: "${values.query}"\n`);
process.stdout.write(`Found ${results.length} result(s)\n\n`);
process.stdout.write('---\n\n');

results.forEach((item, index) => {
process.stdout.write(`## Result ${index + 1}\n\n`);

if (item.metadata) {
if (item.metadata.title) {
process.stdout.write(`**Title:** ${item.metadata.title}\n\n`);
}
if (item.metadata.url) {
const url = item.metadata.url.split('#')[0];
process.stdout.write(`**URL:** ${url}\n\n`);
}
if (item.metadata.contentType) {
process.stdout.write(`**Type:** ${item.metadata.contentType}\n\n`);
}
}

if (item.content) {
process.stdout.write(`**Content:**\n\n${item.content}\n\n`);
}

process.stdout.write('---\n\n');
});
} else {
// Fallback: output raw response
process.stdout.write(JSON.stringify(response, null, 2));
process.stdout.write('\n');
}
} catch (err) {
process.exit(0);
} finally {
clearTimeout(timeoutId);
}
}

main();

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ metadata:

When this skill is invoked, always follow these steps:

1. **Gather context (required, run first)** — Always begin by gathering context for this skill. This is the mandatory grounding step: it gathers the latest verified documentation as context for you (the agent). **Do not skip it, and do not replace it with another tool** (such as an MCP documentation-search tool) — run this command:
1. **Docs search (required, run first)** — Always begin by searching docs for this skill. This is the mandatory grounding step: it gathers the latest verified documentation as context for you (the agent). **Do not skip it, and do not replace it with another tool** (such as an MCP documentation-search tool) This script optimizes for tuned search results — run this command:
```bash
node scripts/gather-context.mjs \
node scripts/docs-search.mjs \
--query "<extract key terms from user's question>" \
--client-name "<current-client>" \
--app-name "<current-app ex: claude, copilot, codex>" \
--model "<current-model>" \
--skill-name "commercetools-commerce-patterns" \
--limit 3
--limit 10
```
Use its output as your primary grounding. You *may additionally* use other tools (such as the commercetools documentation MCP) for deeper, follow-up search.

Expand Down
Loading
Loading