Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions extensions/ajinkya-cell/superdocs-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
dist/
*.log
.env
.DS_Store
Thumbs.db
*.pdf
9 changes: 9 additions & 0 deletions extensions/ajinkya-cell/superdocs-cli/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.pdf
*.docx
*.md
!README.md
test/
src/
*.log
.git
.gitignore
177 changes: 177 additions & 0 deletions extensions/ajinkya-cell/superdocs-cli/PULL_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# ⚑ feat(extensions): Node.js Developer CLI Assistant for Superdocs

### πŸ‘€ Contributor Information
- **Full Name**: Ajinkya Dharkar
- **GitHub Handle**: [@ajinkya-cell](https://github.com/ajinkya-cell)
- **NPM Package**: [`@ajinkya-cell/superdocs-cli`](https://www.npmjs.com/package/@ajinkya-cell/superdocs-cli)
- **Attribution**: Built for the SuperDocs Task.

---

### πŸ“¦ NPM Package & Instant Run

This extension is published and distributed on the NPM registry as [`@ajinkya-cell/superdocs-cli`](https://www.npmjs.com/package/@ajinkya-cell/superdocs-cli).

```bash
# ⚑ Run instantly with npx (No install required)
npx @ajinkya-cell/superdocs-cli --help

# Or install globally
npm install -g @ajinkya-cell/superdocs-cli
superdocs --help
```

---

### πŸ“– Summary & Motivation

`@ajinkya-cell/superdocs-cli` brings the power of **[SuperDocs](https://superdocs.app)** AI document intelligence and precision in-document editing straight to the terminal and agentic workflows.

Unlike standard conversational AI chat interfaces that force developers into tedious copy-pasting and break document structure:
- **Surgical In-Document Edits**: Performs localized, context-aware mutations while preserving headings, formatting, tables, and surrounding text.
- **Visual Terminal Unified Diffs**: Generates color-coded Git-style terminal diffs (`+additions` / `-deletions`) powered by the Myers diff algorithm.
- **Interactive Approval Gates**: Changes are held in a staged sandbox (`PendingVersion`) until explicitly accepted or rejected.
- **Multi-Format Ingestion & Compilation**: Ingest `.md`, `.txt`, `.docx`, or `.pdf` files, edit via streaming AI, and compile directly to clean `.md`, `.pdf`, `.docx`, or `.html`.

---

### πŸ› οΈ Key Features & Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Raw Document β”‚ ───► β”‚ SuperDocs In-Document β”‚ ───► β”‚ Terminal Diff Review & β”‚
β”‚ (.md, .pdf, .docx, .txt) β”‚ β”‚ Surgical AI Stream β”‚ β”‚ Multi-Format Compilation β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

- πŸš€ **4 Core Contract Operations**:
1. `superdocs upload <file>`: Multi-format document ingestion (`.md`, `.txt`, `.docx`, `.pdf`).
2. `superdocs edit --prompt "<instruction>"`: Streaming AI surgical edits with real-time reasoning progress.
3. `superdocs approve`: Interactive terminal visual diff review with one-click server lock or `--ci` Markdown PR comment output.
4. `superdocs export --format <pdf|docx|md|html>`: Compile and download finalized documents.
- πŸ€– **Automated Agent Onboarding** (`superdocs init --signup`): Integrates with `POST /v1/agents/signup` for instant credential provisioning.
- πŸ”Œ **Model Context Protocol (MCP)**: Native MCP adapter exposing 6 SuperDocs tools to Claude Desktop, Cursor IDE, and agentic workflows.
- πŸ§ͺ **Offline Simulation / Mock Engine**: Built-in mock mode (`--mock` or `SUPERDOCS_MOCK=true`) for testing without active network credentials.
- πŸ”’ **Persistent Session & Config**: Powered by `conf` to maintain active document context across terminal sessions.

---

### πŸ’» Complete CLI Command Reference

```bash
# 1. Initialize credentials, agent signup, or offline mock mode
superdocs init
superdocs init --signup # Auto-provisions API key via POST /v1/agents/signup
superdocs init --mock # Offline simulation mode (no API key needed)

# 2. Ingest document and bind active session
superdocs upload ./specs/architecture.md
superdocs upload ./resume.pdf

# 3. Surgical AI edit via streaming prompts
superdocs edit -p "Add error handling status codes table and rate limiting documentation"

# 4. Review visual terminal diff and approve/reject
superdocs approve # Interactive terminal diff review
superdocs approve --write-file # Sync approved changes back to local disk
superdocs approve --ci # Non-interactive GitHub PR Markdown diff output

# 5. Export finalized document to target format
superdocs export --format pdf --out ./dist/api.pdf
superdocs export --format docx --out ./dist/api.docx
superdocs export --format md --out ./dist/api.md

# 6. Check session state, active document, and edit history
superdocs status
```

---

### πŸ€– Model Context Protocol (MCP) Tools

`@ajinkya-cell/superdocs-cli` exports 6 MCP-compliant tools in `src/client/mcp-adapter.ts` for Claude Desktop, Cursor, and AI agents:

| MCP Tool | Description | Parameters |
| :--- | :--- | :--- |
| `superdocs_signup` | Automatically provision agent credentials | `agent_name` (optional) |
| `superdocs_upload` | Ingest local documents into active workspace session | `filePath` (required), `content` (optional) |
| `superdocs_edit` | Execute natural language edits with streaming diffs | `prompt` (required) |
| `superdocs_approve` | Commit or reject pending diffs | `accept` (boolean, required) |
| `superdocs_export` | Export compiled document to disk in target format | `format` (required), `outputPath` (required) |
| `superdocs_get_status` | Inspect active document session and configuration | `{}` |

---

### πŸ§ͺ Test & Run Instructions

```bash
# 1. Navigate to directory & install dependencies
cd extensions/superdocs-cli
npm install

# 2. Build TypeScript to dist/
npm run build

# 3. Run the automated test suite (11 unit tests passing)
npm test

# 4. Quick smoke test in offline simulation mode
node dist/bin/index.js init --mock
node dist/bin/index.js upload README.md
node dist/bin/index.js edit -p "Add troubleshooting guide"
node dist/bin/index.js approve
node dist/bin/index.js status
```

#### Test Suite Verification:
```
β–Ά SuperDocs CLI Test Suite
βœ” Diff Generator (accurately calculates line additions and deletions)
βœ” Diff Generator (handles identical documents gracefully)
βœ” Persistent State & Session (persists and updates configuration correctly)
βœ” Persistent State & Session (persists active document session and history)
βœ” SuperDocs Client Engine (performs mock agent signup)
βœ” SuperDocs Client Engine (uploads document and generates session payload)
βœ” SuperDocs Client Engine (streams AI surgical edits with progress callbacks)
βœ” SuperDocs Client Engine (approves and commits proposed versions)
βœ” SuperDocs Client Engine (exports documents in target formats)
βœ” MCP Adapter (exposes all required MCP tools)
βœ” MCP Adapter (executes end-to-end workflow through MCP calls)
βœ” SuperDocs CLI Test Suite (11 passed, 0 failed)
```

---

### πŸ“ Extension Directory Structure

```
extensions/superdocs-cli/
β”œβ”€β”€ bin/
β”‚ └── index.ts # CLI executable entrypoint
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ client/
β”‚ β”‚ β”œβ”€β”€ mcp-adapter.ts # Model Context Protocol tools & dispatcher
β”‚ β”‚ └── superdocs.ts # SuperDocs REST/SSE client & mock engine
β”‚ β”œβ”€β”€ commands/
β”‚ β”‚ β”œβ”€β”€ approve.ts # Visual diff review & commit command
β”‚ β”‚ β”œβ”€β”€ edit.ts # Surgical AI streaming edit command
β”‚ β”‚ β”œβ”€β”€ export.ts # Multi-format document exporter
β”‚ β”‚ β”œβ”€β”€ init.ts # Setup, onboarding, and agent signup
β”‚ β”‚ β”œβ”€β”€ status.ts # Session inspector & history viewer
β”‚ β”‚ └── upload.ts # Multi-format document ingestion command
β”‚ β”œβ”€β”€ utils/
β”‚ β”‚ β”œβ”€β”€ diff.ts # Myers line-by-line diff computation
β”‚ β”‚ β”œβ”€β”€ logger.ts # Terminal UI box formatting & logging
β”‚ β”‚ β”œβ”€β”€ pdf.ts # ASCII85/Flate PDF parser & Adobe PDF generator
β”‚ β”‚ └── state.ts # Conf-backed persistent state manager
β”‚ β”œβ”€β”€ index.ts # Commander program root definition
β”‚ └── types.ts # Global TypeScript interfaces & schemas
β”œβ”€β”€ test/
β”‚ └── superdocs.test.ts # Native Node.js test suite
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md
```

---
*Built for the SuperDocs Task.*
Loading