Skip to content

knowledgestack/ks-microsoft-word-agent

Repository files navigation

KS Word Add-in

Knowledge Stack

Focus on agents. We handle document intelligence.

The official Microsoft Word add-in for Knowledge Stack — an AI assistant that lives in the Word sidebar and connects to your permission-scoped knowledge base.

License: MIT Discord Cookbook Office Add-in React 18 TypeScript


What it does

The add-in opens as a taskpane in Word and connects to the Knowledge Stack agent for AI-powered document workflows:

Mode What it does
Chat Free-form Q&A about the document or knowledge base
Edit Insert or replace content in the document (supports multi-paragraph, fill-the-blanks)
Review Add, edit, resolve, and reply to comments with findings
Summarize Generate structured summaries of selected text or the full document
Format Analyze and fix paragraph styles (heading hierarchy, list styles)
Extract Pull structured data (dates, names, obligations, metrics) into tables

See docs/modes.md for detailed mode architecture and pipeline reference.

Tech Stack

  • React 18 + TypeScript — UI framework
  • Fluent UI React (@fluentui/react-components) — component library and theming
  • Office.js — Word JavaScript API for document read/write
  • Webpack — bundler and dev server
  • KS Backend — FastAPI + Temporal agent (separate repo)

Project Structure

src/
  taskpane/
    components/
      chat/           ChatPanel, MessageBubble, InputBox, ThreadList, ModeSelector
      document/       WordActionStatusLine, EditPlanCard, CommentActionDetails, ToolStepper
      citations/      CitationMark, CitationFooter
      mentions/       MentionBar, MentionChip, MentionDropdown
      settings/       SettingsPanel, SettingsModal
    hooks/
      useKSChat.ts    Chat orchestration: prompt building, streaming, post-processing
      useKSThreads.ts Thread CRUD and navigation
      useWordDoc.ts   Word API operations (edit, comments, styles, gaps)
      useMentions.ts  @ mention scoping with folder browser
    services/
      ksThreadApi.ts  Thread CRUD
      ksMessageApi.ts Message send + list
      ksStreamApi.ts  SSE streaming client
      folderApi.ts    Folder browsing for mentions
    lib/
      wordPrompts.ts  Prompt builders, fence extraction, output parsers
      modes.ts        Mode definitions (label, fence, command mapping)
      slashCommands.ts Command metadata
    styles/           CSS modules (glass, animations)
    types.ts          Shared type definitions
    types/
      ksBackend.ts    KS backend API type definitions
    App.tsx           Root component with settings routing
    theme.ts          Fluent UI theme configuration
  commands/
    commands.ts       Office ribbon command handlers
manifest.xml          Office add-in manifest

Install in Word

Two paths — end users use the hosted manifest; developers build and sideload locally.

For end users (no build required)

The hosted add-in runs at https://msword.knowledgestack.ai. To install it into Word:

  1. Download the manifest: manifest_prod.xml (right-click → Save link as…)
  2. Open Word (desktop). Go to Insert → My Add-ins → Manage My Add-ins → Upload My Add-in.
    • On macOS: Insert → Add-ins → More Add-ins → MY ADD-INS → Upload My Add-in.
    • On Word on the Web: Home → Add-ins → More Add-ins → Upload My Add-in.
  3. Select the downloaded manifest_prod.xml.
  4. The KS Chat button appears in the Home ribbon.
  5. On first launch, enter your API settings:

For enterprise rollout (centralized deployment via Microsoft 365 admin center, tenant-wide install, AppSource publishing): see docs/DISTRIBUTION.md.

For developers (build and sideload)

Prerequisites

  • Node.js v18+
  • Microsoft Word (desktop, Mac or Windows)
  • KS backend running locally (see ks-backend repo)

1. Start KS Backend

In the ks-backend repo, run three terminals:

Terminal 1: make dev-stack     # Docker services (Postgres, Redis, Temporal, etc.)
Terminal 2: make dev-api       # FastAPI (nginx exposes https://localhost:18000)
Terminal 3: make dev-agent     # Agent worker (Temporal)

2. Start the Add-in

make install    # npm install (first time only)
make dev        # Webpack dev server on https://localhost:1122

Once webpack finishes compiling:

make sideload   # Registers the manifest in Word (one-time)

3. Open Word

  1. Open any Word document
  2. Go to the Home tab
  3. Click KS Chat in the ribbon
  4. On first load, enter your settings:
    • API URL: https://localhost:18000
    • API Key: your KS API key (seed data: sk-user-pwuser1-personal-api-key-secret-pwuser1)
  5. Start chatting

CORS

KS backend must allow https://localhost:1122. In ks-backend's .env.dev:

CORS_EXTRA_ORIGINS=["https://localhost:1122"]

Troubleshooting

If the add-in doesn't appear in the ribbon:

make reset    # Kills servers, clears sideloaded manifests, reinstalls

Then quit Word completely (Cmd+Q), restart make dev, run make sideload, and reopen Word.

Available Commands

make install    # Install npm dependencies
make dev        # Start webpack dev server
make sideload   # Register manifest in Word
make clean      # Kill dev servers and remove sideloaded manifests
make reset      # Full reset: clean + install

Distribution

See docs/SETUP.md for setup and deployment details, and docs/DISTRIBUTION.md for enterprise distribution options (shared SaaS, dedicated, hybrid, AppSource).

The short version: a Word add-in is a manifest XML + a hosted frontend. Deploy the dist/ build to any static HTTPS host, update the manifest URLs, and share the manifest with users.

Related repos

  • ks-cookbook — 32 production-style agent flagships across banking, legal, healthcare, insurance, real estate, sales, HR, engineering, government, pharma, and energy.
  • ks-mcp — Model Context Protocol server that plugs Knowledge Stack into LangChain, LangGraph, CrewAI, Temporal, OpenAI Agents SDK, pydantic-ai, Claude Desktop, and Cursor.
  • ks-sdk-python — Python SDK (ksapi on PyPI).
  • ks-sdk-ts — TypeScript SDK (@knowledge-stack/ksapi on npm).
  • ks-docs — central developer docs (Mintlify → docs.knowledgestack.ai).

Community

Contributing

See CONTRIBUTING.md and the PR template. Every PR auto-requests review from @knowledgestack/ks-admins.

License

MIT.

About

Microsoft Word add-in for Knowledge Stack — chat, edit, review, summarize, format, and extract data from Word documents with permission-scoped retrieval and chunk-level citations. React + TypeScript + Fluent UI + Office.js.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages