explain_directive
Understand NoJS framework directives by retrieving detailed explanations with syntax examples and usage guidance for template development.
Instructions
Get a detailed explanation of a NoJS directive with syntax and examples
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directive | Yes | The directive name to explain (e.g., "bind", "each", "model") |
Implementation Reference
- src/tools/index.ts:162-225 (handler)The `explain_directive` tool is defined and implemented in `src/tools/index.ts`. It takes a `directive` name as input, looks it up in `directives.json`, and returns a detailed explanation including category, syntax, examples, and notes.
// ── explain_directive ── server.tool( "explain_directive", "Get a detailed explanation of a NoJS directive with syntax and examples", { directive: z .string() .describe( 'The directive name to explain (e.g., "bind", "each", "model")' ), }, async ({ directive }) => { const kb = loadJSON<DirectivesKB>("directives.json"); const name = directive.toLowerCase().trim(); // Find exact match or partial match const found = kb.directives.find( (d) => d.name === name || d.name === `${name}` || d.name.startsWith(name) ); if (!found) { // Suggest similar const suggestions = kb.directives .filter( (d) => d.name.includes(name) || d.category.includes(name) ) .map((d) => d.name) .slice(0, 5); return { content: [ { type: "text" as const, text: `Directive "${directive}" not found.${suggestions.length > 0 ? ` Did you mean: ${suggestions.join(", ")}?` : ""}\n\nUse list_directives to see all available directives.`, }, ], }; } const category = kb.categories.find((c) => c.id === found.category); let explanation = `# ${found.name}\n\n`; explanation += `**Category**: ${category?.name || found.category}\n`; explanation += `**Description**: ${found.description}\n\n`; explanation += `## Syntax\n\n\`\`\`html\n${found.syntax}\n\`\`\`\n\n`; if (found.examples && found.examples.length > 0) { explanation += `## Examples\n\n`; for (const ex of found.examples) { explanation += `### ${ex.description}\n\n\`\`\`html\n${ex.html}\n\`\`\`\n\n`; } } if (found.notes) { explanation += `## Notes\n\n${found.notes}\n`; } return { content: [{ type: "text" as const, text: explanation }], }; } );