Skip to content

Conversation

@ant-louis
Copy link

Summary

Add a file-based IPC system that enables external tools (like AI agents) to programmatically edit DOCX documents via JSON commands written to .superdoc/{docname}.json.

Commands added

  • getText - Read document content (text/html/both formats)
  • getNodes - Get document structure by node type (paragraph, heading, table, etc.)
  • replaceText - Find and replace with track changes support
  • insertContent - Insert content at anchor positions (before/after text)
  • formatText - Apply formatting (font, color, bold, italic, links, highlight)
  • insertImage - Insert images from URL or file path (auto base64 conversion)
  • insertTable - Create tables with optional data population
  • deleteNode - Delete nodes by type and index
  • addComment - Add comments to text ranges
  • undo/redo - History navigation

Key features

  • File-based communication via .superdoc/{docname}.json
  • Track changes support (suggesting mode) for content edits
  • Configurable author attribution for changes
  • Image URL/path to base64 conversion handled by extension

Example usage

# Read document content
echo '{"id":"1","command":"getText","args":{"format":"text"}}' > .superdoc/contract.json

# Replace text with track changes
echo '{"id":"2","command":"replaceText","args":{"search":"2024","replacement":"2025"}}' > .superdoc/contract.json

# Add a comment
echo '{"id":"3","command":"addComment","args":{"search":"confidential","comment":"Needs legal review"}}' > .superdoc/contract.json

Test plan

  • Open a DOCX file in VS Code with SuperDoc
  • Write a getText command to .superdoc/{docname}.json
  • Verify response is written back to the same file
  • Test replaceText and verify track changes appear
  • Test addComment and verify comment balloon appears
  • Export DOCX and verify changes persist in Word

Add a file-based IPC system that enables external tools (like AI agents)
to programmatically edit DOCX documents via JSON commands.

Commands added:
- getText: read document content (text/html/both)
- getNodes: get document structure by node type
- replaceText: find and replace with track changes
- insertContent: insert content at anchor positions
- formatText: apply formatting (font, color, bold, links, etc.)
- insertImage: insert images from URL/path (auto base64 conversion)
- insertTable: create tables with optional data population
- deleteNode: delete nodes by type and index
- addComment: add comments to text ranges
- undo/redo: history navigation

Key features:
- File-based communication via .superdoc/{docname}.json
- Track changes support (suggesting mode) for content edits
- Configurable author attribution for changes
- Image URL/path to base64 conversion in extension

Files changed:
- src/superdocEditorProvider.ts: command file watcher and processing
- webview/main.js: complete command execution API
- src/extension.ts: remove noisy activation message
- main.js: delete unused legacy script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant