AI assistant grounded in your docs.
Reads your documentation, answers questions in context. Works with 100+ models, any website, and keeps your API keys secure.
Install docmd-assistant via npm:
npm install docmd-assistantInitialise the AI engine in your application:
import { DocmdAssistantEngine } from 'docmd-assistant';
const assistant = new DocmdAssistantEngine({
provider: 'openai',
model: 'gpt-4o-mini',
apiKey: process.env.OPENAI_API_KEY,
systemPrompt: 'You are a technical documentation assistant.'
});
const response = await assistant.sendMessage('How do I configure routing?');
console.log(response.message);Designed to be 100% UI-agnostic, headless, and lightweight.
- Powered directly by
aiplugmulti-provider runtime - Supports OpenAI, Anthropic, Gemini, DeepSeek, Groq, MiniMax, Ollama, and more
- Hot-swappable providers and models at runtime
- Register custom client-side or server-side tools
- Native execution pipeline for document search, page navigation, and code copying
- Dynamic tool registration surface (
registerTool,unregisterTool)
- Pure logic engine with no hardcoded DOM elements or mandatory UI
- Embed into React, Vue, Svelte, Angular, Vanilla JS, Node.js servers, or CLI tools
- Event-driven architecture with subscriptions for message, tool, and error events
- Connect directly via local provider API keys or proxy through custom relay endpoints
- Seamless integration with docmd Cloud AI Relay backend
Application Layer (React / Vue / Custom UI / CLI)
─────────────────────────────────────────────────
1. Call assistant.sendMessage("query")
→ Emits 'message' event to UI
2. Headless Engine processes turn:
├─ Direct Mode (aiplug) → Interacts with OpenAI / Claude / Gemini / Ollama
└─ Relay Mode (Cloud API) → Proxies securely via relay endpoint
3. Tool Calling Pipeline:
├─ LLM triggers registered tool (e.g. search_documentation)
├─ Engine executes handler & appends context
└─ Final response returned & 'message' event fired
import { DocmdAssistantEngine } from 'docmd-assistant';
const assistant = new DocmdAssistantEngine({
provider: 'anthropic',
model: 'claude-3-5-haiku-20241022',
apiKey: process.env.ANTHROPIC_API_KEY
});
// Register custom tool
assistant.registerTool({
name: 'lookup_user_account',
description: 'Retrieve user details by email address',
parameters: {
type: 'object',
properties: {
email: { type: 'string', description: 'User email address' }
},
required: ['email']
},
execute: async ({ email }) => {
return { accountId: 'acc_12345', plan: 'pro', status: 'active' };
}
});assistant.on('message', (event) => {
console.log(`[${event.data.role}]: ${event.data.content}`);
});
assistant.on('tool_call', (event) => {
console.log(`Tool invoked: ${event.data.name}`, event.data.args);
});
assistant.on('error', (event) => {
console.error('Assistant error:', event.data);
});assistant.setSystemPrompt('Act as a senior software architect.');
assistant.appendSystemPrompt('Always provide complete code snippets in TypeScript.');| Option | Type | Description | Default |
|---|---|---|---|
provider |
string |
AI Provider name | 'openai' |
model |
string |
Model identifier | 'gpt-4o-mini' |
apiKey |
string |
Direct provider API key | undefined |
baseURL |
string |
Custom API gateway URL | undefined |
relayUrl |
string |
Relay endpoint URL | undefined |
systemPrompt |
string |
System instruction prompt | Default prompt |
history |
ChatMessage[] |
Initial conversation history | [] |
tools |
AssistantTool[] |
Array of initial tools | [] |
Keeps the codebase modular, typed, and clean.
docmd-assistant/
├── dist/ # Compiled ESM and CJS bundles
├── src/
│ ├── engine.ts # Core DocmdAssistantEngine class & event pipeline
│ ├── index.ts # Barrel module exports
│ ├── tools/
│ │ └── index.ts # Standard documentation & navigation tools
│ └── types.ts # TypeScript interfaces and event schemas
├── build.js # Dual ESM/CJS esbuild bundler
├── package.json # Package manifest
└── tsconfig.json # TypeScript compiler configuration
docmd-assistant works standalone with any project or web framework. It also powers AI capabilities across docmd documentation tools.
| Tool | What it does |
|---|---|
| docmd | Zero-config documentation engine |
| docmd-search | Offline semantic search engine |
| docmd-assistant | Universal headless AI Assistant engine |
- Contributions are welcome
- If you find it useful, consider sponsoring or starring the repo ⭐
MIT License. See LICENSE for details.