Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 04:30 UTC
docs: improve prompt quality — language detection, tab labels, cleanup
- Detect code block language from data-language attr, class, or content - Label code blocks with their tab name (Python/TypeScript) when in tabs - Remove redundant "Latest docs" URL from all 6 prompts - Drop prose paragraphs from extraction (just step titles + code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmitha Mallesh committed
Mar 6, 2026 at 23:51 UTC
4b2040f4d4974e2195859ba2d0e6e86e9a60c993
2 files changed
+32
-20
docs/components/quickstart/prompt-banner.tsx
+32
-14
@@ -11,6 +11,22 @@ export function PromptBanner({ children }: PromptBannerProps) {
11
const [copied, setCopied] = useState(false);
12
const contentRef = useRef<HTMLDivElement>(null);
13
14
+ const detectLang = (pre: Element): string => {
15
+ // Check data-language on <pre> or <code>
16
+ const code = pre.querySelector('code');
17
+ const dataLang = pre.getAttribute('data-language') ?? code?.getAttribute('data-language');
18
+ if (dataLang) return dataLang;
19
+ // Check class="language-xxx"
20
+ const cls = Array.from(code?.classList ?? []).find(c => c.startsWith('language-'));
21
+ if (cls) return cls.replace('language-', '');
22
+ // Guess from content
23
+ const text = code?.textContent ?? '';
24
+ if (text.includes('pip install') || text.includes('npm install')) return 'bash';
25
+ if (text.includes('import ') && text.includes('from ')) return 'python';
26
+ if (text.includes('import ') && text.includes('from "')) return 'typescript';
27
+ return '';
28
+ };
29
+
30
const extractSteps = (stepsEl: Element): string => {
31
const parts: string[] = [];
32
const steps = stepsEl.querySelectorAll('.fd-step');
@@ -20,20 +36,22 @@ export function PromptBanner({ children }: PromptBannerProps) {
36
const title = step.querySelector('h3, h4, [class*="StepTitle"]');
37
if (title) parts.push(`### ${title.textContent?.trim()}`);
38
23
- // Code blocks — preserve as fenced code
24
- const codeBlocks = step.querySelectorAll('pre code');
25
- codeBlocks.forEach((code) => {
26
- // Try to detect language from class (e.g. "language-python")
27
- const langClass = Array.from(code.classList).find(c => c.startsWith('language-'));
28
- const lang = langClass?.replace('language-', '') ?? '';
29
- parts.push(`\`\`\`${lang}\n${code.textContent?.trim()}\n\`\`\``);
30
- });
31
-
32
- // Callouts / prose text (skip if it's just whitespace)
33
- const paragraphs = step.querySelectorAll(':scope > p, :scope > div:not(:has(pre)) > p');
34
- paragraphs.forEach((p) => {
35
- const text = p.textContent?.trim();
36
- if (text) parts.push(text);
39
+ // Find code blocks, checking if they're inside tabs
40
+ const pres = step.querySelectorAll('pre');
41
+ pres.forEach((pre) => {
42
+ const lang = detectLang(pre);
43
+ const code = pre.querySelector('code')?.textContent?.trim() ?? '';
44
+ if (!code) return;
45
+
46
+ // Check if inside a tab panel — use tab name as label
47
+ const tabPanel = pre.closest('[role="tabpanel"]');
48
+ const tabId = tabPanel?.getAttribute('data-value') ?? tabPanel?.getAttribute('aria-labelledby');
49
+ if (tabId) {
50
+ const label = tabId.replace(/-/g, ' ');
51
+ parts.push(`**${label}**\n\n\`\`\`${lang}\n${code}\n\`\`\``);
52
+ } else {
53
+ parts.push(`\`\`\`${lang}\n${code}\n\`\`\``);
54
+ }
55
});
56
});
57
docs/content/docs/quickstart.mdx
-6
@@ -57,7 +57,6 @@ from composio_core import Composio
57
4. Are API keys in .env, not hardcoded?
58
5. Are imports from `composio` (Python) or `@composio/core` (TS)?
59
60
-Latest docs: https://docs.composio.dev/docs/quickstart
60
</PromptBanner>
61
62
<Steps>
@@ -241,7 +240,6 @@ from composio_core import Composio
240
4. Is `require_approval` set to `"never"` in Python?
241
5. Are API keys in .env, not hardcoded?
242
244
-Latest docs: https://docs.composio.dev/docs/quickstart
243
</PromptBanner>
244
245
<Steps>
@@ -445,7 +443,6 @@ from composio_core import Composio
443
4. Is the code using `async/await`?
444
5. Are API keys in .env, not hardcoded?
445
448
-Latest docs: https://docs.composio.dev/docs/quickstart
446
</PromptBanner>
447
448
<Steps>
@@ -655,7 +652,6 @@ from composio_core import Composio
652
5. Is the code using `async/await`?
653
6. Are API keys in .env, not hardcoded?
654
658
-Latest docs: https://docs.composio.dev/docs/quickstart
655
</PromptBanner>
656
657
<Steps>
@@ -881,7 +877,6 @@ const result = await generateText({ model, tools, prompt });
877
4. Is `maxSteps` set in `streamText` / `generateText`?
878
5. Are API keys in .env, not hardcoded?
879
884
-Latest docs: https://docs.composio.dev/docs/quickstart
880
</PromptBanner>
881
882
<Steps>
@@ -1026,7 +1021,6 @@ const result = await generateText({ model, tools, prompt });
1021
5. Is `client.close()` called when done?
1022
6. Are API keys in .env, not hardcoded?
1023
1029
-Latest docs: https://docs.composio.dev/docs/quickstart
1024
</PromptBanner>
1025
1026
<Steps>