npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@skaldapp/milkdown-copilot

v1.0.1

Published

A Milkdown plugin that provides AI-powered code completions using Mistral AI’s Codestral model with debounced requests and tab-to-accept functionality.

Downloads

1,267

Readme

@skaldapp/milkdown-copilot

AI-powered code completion plugin for Milkdown editor

License npm

Description

@skaldapp/milkdown-copilot is a Milkdown plugin that provides AI-powered code completion suggestions directly within your Markdown editor. It integrates with Mistral AI's Codestral model to offer intelligent, context-aware completions as you type.

Features

  • 🤖 AI-Powered Completions: Get intelligent code suggestions powered by Mistral AI's Codestral model
  • Debounced Requests: Automatic debouncing (1 second) to optimize API calls and performance
  • 📝 Markdown Support: Seamlessly works with Markdown syntax and Milkdown's editor state
  • 🎯 Context-Aware: Analyzes text before and after cursor for relevant completions
  • 🔌 Easy Integration: Simple plugin setup with Milkdown's plugin system
  • 💡 Tab to Accept: Press Tab to accept completion suggestions
  • 🔄 Reactive: Automatically updates suggestions based on editor changes

Installation

npm install @skaldapp/milkdown-copilot

Requirements

  • Node.js >= 18
  • Milkdown >= 7.19.2
  • A valid Mistral AI API key

Usage

Basic Setup

import { Editor, rootCtx } from "@milkdown/kit/core";
import {
  copilotPlugin,
  apiKeySlice,
  filenameSlice,
} from "@skaldapp/milkdown-copilot";

// Create Milkdown editor with copilot plugin
const editor = new Editor()
  .config((ctx) => {
    ctx.set(apiKeySlice, "your-mistral-ai-api-key");
    ctx.set(filenameSlice, "example.md");
  })
  .create();

// Mount to DOM
editor.mount(document.querySelector("#editor"));

Configuration Options

The plugin uses two separate context slices for configuration:

| Slice | Type | Description | | --------------- | -------- | ----------------------------------------------------- | | apiKeySlice | string | Your Mistral AI API key for authentication | | filenameSlice | string | Current filename (used for context-aware completions) |

Default Settings

The plugin comes with sensible defaults:

| Setting | Value | Description | | ---------------- | ---------------------------------- | --------------------------------------- | | Model | codestral | Mistral's code-focused model | | Provider | mistral | AI provider | | Language | markdown | Target language for completions | | Debounce | 1000ms | Delay before sending completion request | | Technologies | ['vue', 'tailwindcss', 'comark'] | Technology stack context |

How It Works

  1. Trigger: Completions are triggered on:

    • Single character input
    • Pressing Enter key
  2. Context Collection: The plugin gathers:

    • Text before cursor (serialized to Markdown)
    • Text after cursor (serialized to Markdown)
    • Current cursor position
    • Filename and language context
  3. AI Request: Sends context to Mistral AI's Codestral model via monacopilot

  4. Display: Completions appear as inline decorations (widgets) in a <pre> element

  5. Accept: Press Tab to insert the completion at cursor position

Trigger Conditions

| Key | Action | | ------------------------------------- | ---------------------------- | | Any single character (a-z, 0-9, etc.) | Trigger completion request | | Enter | Trigger completion request | | Tab (with active completion) | Accept and insert completion | | Any other key | Cancel pending request |

API

Exports

copilotPlugin

The main Milkdown plugin array that provides AI completion functionality. It consists of:

  1. A setup function that injects the required context slices
  2. A ProseMirror plugin that handles completions

apiKeySlice

A Milkdown context slice for storing the API key:

export const apiKeySlice = createSlice("", "apiKey");

filenameSlice

A Milkdown context slice for storing the current filename:

export const filenameSlice = createSlice("", "filename");

Plugin Internals

The plugin uses a ProseMirror Plugin with:

  • State: Manages completion message and decoration set
  • Props:
    • decorations: Renders completion hints as widgets
    • handleKeyDown: Intercepts keyboard events for triggers
  • Debouncing: 1 second delay to prevent excessive API calls

Dependencies

| Package | Version | Purpose | | --------------- | ------- | ---------------------------- | | @milkdown/ctx | ^7.19.2 | Context management | | @milkdown/kit | ^7.19.2 | Core Milkdown editor | | monacopilot | ^1.2.12 | AI completion client | | quasar | ^2.19.1 | Utility functions (debounce) |

Development

Prerequisites

  • Node.js >= 18
  • npm or pnpm

Setup

# Install dependencies
npm install

# Build the package
npm run build

# Lint code
npm run lint

Project Structure

milkdown-copilot/
├── src/
│   └── index.ts          # Main plugin implementation
├── dist/                  # Built output
├── package.json           # Project configuration
├── tsconfig.json          # TypeScript configuration
├── eslint.config.ts       # ESLint configuration
└── README.md              # This file

Build Output

The package exports as an ES module:

{
  "type": "module",
  "exports": {
    ".": "./dist/index.js"
  }
}

License

This project is licensed under the AGPL-3.0-only License.

Author

Jerry Bruwes
Email: [email protected]
GitHub: jbruwes

Repository

Issues & Contributions

  • Report bugs: GitHub Issues
  • Contributions are welcome! Please open an issue or submit a PR.

Related Projects


Made with ❤️ by Jerry Bruwes