mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
Compare commits
6 Commits
90ad2f3885
...
v1.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c2e0eace8 | ||
|
|
77bb669dc5 | ||
|
|
b9d09cbebf | ||
|
|
d2191d09a2 | ||
|
|
11ad2a875f | ||
|
|
33186f1a93 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "everything-claude-code",
|
||||
"version": "1.2.0",
|
||||
"version": "1.4.1",
|
||||
"description": "Complete collection of battle-tested Claude Code configs from an Anthropic hackathon winner - agents, skills, hooks, and rules evolved over 10+ months of intensive daily use",
|
||||
"author": {
|
||||
"name": "Affaan Mustafa",
|
||||
|
||||
12
.github/workflows/release.yml
vendored
12
.github/workflows/release.yml
vendored
@@ -25,6 +25,18 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Verify plugin.json version matches tag
|
||||
env:
|
||||
TAG_NAME: ${{ github.ref_name }}
|
||||
run: |
|
||||
TAG_VERSION="${TAG_NAME#v}"
|
||||
PLUGIN_VERSION=$(grep -oE '"version": *"[^"]*"' .claude-plugin/plugin.json | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
if [ "$TAG_VERSION" != "$PLUGIN_VERSION" ]; then
|
||||
echo "::error::Tag version ($TAG_VERSION) does not match plugin.json version ($PLUGIN_VERSION)"
|
||||
echo "Run: ./scripts/release.sh $TAG_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
run: |
|
||||
|
||||
@@ -13,18 +13,21 @@
|
||||
* - SessionEnd → session.deleted
|
||||
*/
|
||||
|
||||
import type { PluginContext } from "@opencode-ai/plugin"
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
|
||||
export const ECCHooksPlugin = async ({
|
||||
project,
|
||||
client,
|
||||
$,
|
||||
directory,
|
||||
worktree,
|
||||
}: PluginContext) => {
|
||||
}: PluginInput) => {
|
||||
// Track files edited in current session for console.log audit
|
||||
const editedFiles = new Set<string>()
|
||||
|
||||
// Helper to call the SDK's log API with correct signature
|
||||
const log = (level: "debug" | "info" | "warn" | "error", message: string) =>
|
||||
client.app.log({ body: { service: "ecc", level, message } })
|
||||
|
||||
return {
|
||||
/**
|
||||
* Prettier Auto-Format Hook
|
||||
@@ -41,7 +44,7 @@ export const ECCHooksPlugin = async ({
|
||||
if (event.path.match(/\.(ts|tsx|js|jsx)$/)) {
|
||||
try {
|
||||
await $`prettier --write ${event.path} 2>/dev/null`
|
||||
client.app.log("info", `[ECC] Formatted: ${event.path}`)
|
||||
log("info", `[ECC] Formatted: ${event.path}`)
|
||||
} catch {
|
||||
// Prettier not installed or failed - silently continue
|
||||
}
|
||||
@@ -53,7 +56,7 @@ export const ECCHooksPlugin = async ({
|
||||
const result = await $`grep -n "console\\.log" ${event.path} 2>/dev/null`.text()
|
||||
if (result.trim()) {
|
||||
const lines = result.trim().split("\n").length
|
||||
client.app.log(
|
||||
log(
|
||||
"warn",
|
||||
`[ECC] console.log found in ${event.path} (${lines} occurrence${lines > 1 ? "s" : ""})`
|
||||
)
|
||||
@@ -82,21 +85,21 @@ export const ECCHooksPlugin = async ({
|
||||
) {
|
||||
try {
|
||||
await $`npx tsc --noEmit 2>&1`
|
||||
client.app.log("info", "[ECC] TypeScript check passed")
|
||||
log("info", "[ECC] TypeScript check passed")
|
||||
} catch (error: unknown) {
|
||||
const err = error as { stdout?: string }
|
||||
client.app.log("warn", "[ECC] TypeScript errors detected:")
|
||||
log("warn", "[ECC] TypeScript errors detected:")
|
||||
if (err.stdout) {
|
||||
// Log first few errors
|
||||
const errors = err.stdout.split("\n").slice(0, 5)
|
||||
errors.forEach((line: string) => client.app.log("warn", ` ${line}`))
|
||||
errors.forEach((line: string) => log("warn", ` ${line}`))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PR creation logging
|
||||
if (input.tool === "bash" && input.args?.toString().includes("gh pr create")) {
|
||||
client.app.log("info", "[ECC] PR created - check GitHub Actions status")
|
||||
log("info", "[ECC] PR created - check GitHub Actions status")
|
||||
}
|
||||
},
|
||||
|
||||
@@ -115,7 +118,7 @@ export const ECCHooksPlugin = async ({
|
||||
input.tool === "bash" &&
|
||||
input.args?.toString().includes("git push")
|
||||
) {
|
||||
client.app.log(
|
||||
log(
|
||||
"info",
|
||||
"[ECC] Remember to review changes before pushing: git diff origin/main...HEAD"
|
||||
)
|
||||
@@ -135,7 +138,7 @@ export const ECCHooksPlugin = async ({
|
||||
!filePath.includes("LICENSE") &&
|
||||
!filePath.includes("CONTRIBUTING")
|
||||
) {
|
||||
client.app.log(
|
||||
log(
|
||||
"warn",
|
||||
`[ECC] Creating ${filePath} - consider if this documentation is necessary`
|
||||
)
|
||||
@@ -150,7 +153,7 @@ export const ECCHooksPlugin = async ({
|
||||
cmd.match(/^cargo\s+(build|test|run)/) ||
|
||||
cmd.match(/^go\s+(build|test|run)/)
|
||||
) {
|
||||
client.app.log(
|
||||
log(
|
||||
"info",
|
||||
"[ECC] Long-running command detected - consider using background execution"
|
||||
)
|
||||
@@ -166,13 +169,13 @@ export const ECCHooksPlugin = async ({
|
||||
* Action: Loads context and displays welcome message
|
||||
*/
|
||||
"session.created": async () => {
|
||||
client.app.log("info", "[ECC] Session started - Everything Claude Code hooks active")
|
||||
log("info", "[ECC] Session started - Everything Claude Code hooks active")
|
||||
|
||||
// Check for project-specific context files
|
||||
try {
|
||||
const hasClaudeMd = await $`test -f ${worktree}/CLAUDE.md && echo "yes"`.text()
|
||||
if (hasClaudeMd.trim() === "yes") {
|
||||
client.app.log("info", "[ECC] Found CLAUDE.md - loading project context")
|
||||
log("info", "[ECC] Found CLAUDE.md - loading project context")
|
||||
}
|
||||
} catch {
|
||||
// No CLAUDE.md found
|
||||
@@ -189,7 +192,7 @@ export const ECCHooksPlugin = async ({
|
||||
"session.idle": async () => {
|
||||
if (editedFiles.size === 0) return
|
||||
|
||||
client.app.log("info", "[ECC] Session idle - running console.log audit")
|
||||
log("info", "[ECC] Session idle - running console.log audit")
|
||||
|
||||
let totalConsoleLogCount = 0
|
||||
const filesWithConsoleLogs: string[] = []
|
||||
@@ -210,16 +213,16 @@ export const ECCHooksPlugin = async ({
|
||||
}
|
||||
|
||||
if (totalConsoleLogCount > 0) {
|
||||
client.app.log(
|
||||
log(
|
||||
"warn",
|
||||
`[ECC] Audit: ${totalConsoleLogCount} console.log statement(s) in ${filesWithConsoleLogs.length} file(s)`
|
||||
)
|
||||
filesWithConsoleLogs.forEach((f) =>
|
||||
client.app.log("warn", ` - ${f}`)
|
||||
log("warn", ` - ${f}`)
|
||||
)
|
||||
client.app.log("warn", "[ECC] Remove console.log statements before committing")
|
||||
log("warn", "[ECC] Remove console.log statements before committing")
|
||||
} else {
|
||||
client.app.log("info", "[ECC] Audit passed: No console.log statements found")
|
||||
log("info", "[ECC] Audit passed: No console.log statements found")
|
||||
}
|
||||
|
||||
// Desktop notification (macOS)
|
||||
@@ -241,7 +244,7 @@ export const ECCHooksPlugin = async ({
|
||||
* Action: Final cleanup and state saving
|
||||
*/
|
||||
"session.deleted": async () => {
|
||||
client.app.log("info", "[ECC] Session ended - cleaning up")
|
||||
log("info", "[ECC] Session ended - cleaning up")
|
||||
editedFiles.clear()
|
||||
},
|
||||
|
||||
@@ -266,7 +269,7 @@ export const ECCHooksPlugin = async ({
|
||||
* Action: Logs for audit trail
|
||||
*/
|
||||
"permission.asked": async (event: { tool: string; args: unknown }) => {
|
||||
client.app.log("info", `[ECC] Permission requested for: ${event.tool}`)
|
||||
log("info", `[ECC] Permission requested for: ${event.tool}`)
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -280,7 +283,7 @@ export const ECCHooksPlugin = async ({
|
||||
const completed = event.todos.filter((t) => t.done).length
|
||||
const total = event.todos.length
|
||||
if (total > 0) {
|
||||
client.app.log("info", `[ECC] Progress: ${completed}/${total} tasks completed`)
|
||||
log("info", `[ECC] Progress: ${completed}/${total} tasks completed`)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* while taking advantage of OpenCode's more sophisticated 20+ event types.
|
||||
*/
|
||||
|
||||
export { ECCHooksPlugin, default } from "./ecc-hooks"
|
||||
export { ECCHooksPlugin, default } from "./ecc-hooks.js"
|
||||
|
||||
// Re-export for named imports
|
||||
export * from "./ecc-hooks"
|
||||
export * from "./ecc-hooks.js"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Supports common coverage report formats.
|
||||
*/
|
||||
|
||||
import { tool } from "@opencode-ai/plugin"
|
||||
import { tool } from "@opencode-ai/plugin/tool"
|
||||
import * as path from "path"
|
||||
import * as fs from "fs"
|
||||
|
||||
@@ -58,13 +58,13 @@ export default tool({
|
||||
}
|
||||
|
||||
if (!coverageData) {
|
||||
return {
|
||||
return JSON.stringify({
|
||||
success: false,
|
||||
error: "No coverage report found",
|
||||
suggestion:
|
||||
"Run tests with coverage first: npm test -- --coverage",
|
||||
searchedPaths: coveragePaths,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const passed = coverageData.total.percentage >= threshold
|
||||
@@ -96,7 +96,7 @@ export default tool({
|
||||
.join("\n")}`
|
||||
}
|
||||
|
||||
return result
|
||||
return JSON.stringify(result)
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Automatically detects the package manager and test framework.
|
||||
*/
|
||||
|
||||
import { tool } from "@opencode-ai/plugin"
|
||||
import { tool } from "@opencode-ai/plugin/tool"
|
||||
import * as path from "path"
|
||||
import * as fs from "fs"
|
||||
|
||||
@@ -82,7 +82,7 @@ export default tool({
|
||||
|
||||
const command = cmd.join(" ")
|
||||
|
||||
return {
|
||||
return JSON.stringify({
|
||||
command,
|
||||
packageManager,
|
||||
testFramework,
|
||||
@@ -93,7 +93,7 @@ export default tool({
|
||||
updateSnapshots: updateSnapshots || false,
|
||||
},
|
||||
instructions: `Run this command to execute tests:\n\n${command}`,
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* The regex patterns below are used to DETECT potential issues in user code.
|
||||
*/
|
||||
|
||||
import { tool } from "@opencode-ai/plugin"
|
||||
import { tool } from "@opencode-ai/plugin/tool"
|
||||
import * as path from "path"
|
||||
import * as fs from "fs"
|
||||
|
||||
@@ -102,7 +102,7 @@ export default tool({
|
||||
// Generate recommendations
|
||||
results.recommendations = generateRecommendations(results)
|
||||
|
||||
return results
|
||||
return JSON.stringify(results)
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||

|
||||

|
||||
|
||||
> **41K+ stars** | **5K+ forks** | **22 contributors** | **6 languages supported**
|
||||
> **42K+ stars** | **5K+ forks** | **24 contributors** | **6 languages supported**
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ REPEAT → Next test case
|
||||
|
||||
## Example Session
|
||||
|
||||
````
|
||||
```text
|
||||
User: /go-test I need a function to validate email addresses
|
||||
|
||||
Agent:
|
||||
@@ -167,7 +167,7 @@ ok project/validator 0.003s
|
||||
✓ Coverage: 100%
|
||||
|
||||
## TDD Complete!
|
||||
````
|
||||
```
|
||||
|
||||
## Test Patterns
|
||||
|
||||
|
||||
51
install.sh
Executable file
51
install.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# install.sh — Install claude rules while preserving directory structure.
|
||||
#
|
||||
# Usage:
|
||||
# ./install.sh <language> [<language> ...]
|
||||
#
|
||||
# Examples:
|
||||
# ./install.sh typescript
|
||||
# ./install.sh typescript python golang
|
||||
#
|
||||
# This script copies rules into ~/.claude/rules/ keeping the common/ and
|
||||
# language-specific subdirectories intact so that:
|
||||
# 1. Files with the same name in common/ and <language>/ don't overwrite
|
||||
# each other.
|
||||
# 2. Relative references (e.g. ../common/coding-style.md) remain valid.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
RULES_DIR="$(cd "$(dirname "$0")/rules" && pwd)"
|
||||
DEST_DIR="${CLAUDE_RULES_DIR:-$HOME/.claude/rules}"
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: $0 <language> [<language> ...]"
|
||||
echo ""
|
||||
echo "Available languages:"
|
||||
for dir in "$RULES_DIR"/*/; do
|
||||
name="$(basename "$dir")"
|
||||
[[ "$name" == "common" ]] && continue
|
||||
echo " - $name"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Always install common rules
|
||||
echo "Installing common rules -> $DEST_DIR/common/"
|
||||
mkdir -p "$DEST_DIR/common"
|
||||
cp -r "$RULES_DIR/common/." "$DEST_DIR/common/"
|
||||
|
||||
# Install each requested language
|
||||
for lang in "$@"; do
|
||||
lang_dir="$RULES_DIR/$lang"
|
||||
if [[ ! -d "$lang_dir" ]]; then
|
||||
echo "Warning: rules/$lang/ does not exist, skipping." >&2
|
||||
continue
|
||||
fi
|
||||
echo "Installing $lang rules -> $DEST_DIR/$lang/"
|
||||
mkdir -p "$DEST_DIR/$lang"
|
||||
cp -r "$lang_dir/." "$DEST_DIR/$lang/"
|
||||
done
|
||||
|
||||
echo "Done. Rules installed to $DEST_DIR/"
|
||||
@@ -25,17 +25,36 @@ rules/
|
||||
|
||||
## Installation
|
||||
|
||||
### Option 1: Install Script (Recommended)
|
||||
|
||||
```bash
|
||||
# Install common + one or more language-specific rule sets
|
||||
./install.sh typescript
|
||||
./install.sh python
|
||||
./install.sh golang
|
||||
|
||||
# Install multiple languages at once
|
||||
./install.sh typescript python
|
||||
```
|
||||
|
||||
### Option 2: Manual Installation
|
||||
|
||||
> **Important:** Copy entire directories — do NOT flatten with `/*`.
|
||||
> Common and language-specific directories contain files with the same names.
|
||||
> Flattening them into one directory causes language-specific files to overwrite
|
||||
> common rules, and breaks the relative `../common/` references used by
|
||||
> language-specific files.
|
||||
|
||||
```bash
|
||||
# Install common rules (required for all projects)
|
||||
cp -r rules/common/* ~/.claude/rules/
|
||||
cp -r rules/common ~/.claude/rules/common
|
||||
|
||||
# Install language-specific rules based on your project's tech stack
|
||||
cp -r rules/typescript/* ~/.claude/rules/
|
||||
cp -r rules/python/* ~/.claude/rules/
|
||||
cp -r rules/golang/* ~/.claude/rules/
|
||||
cp -r rules/typescript ~/.claude/rules/typescript
|
||||
cp -r rules/python ~/.claude/rules/python
|
||||
cp -r rules/golang ~/.claude/rules/golang
|
||||
|
||||
# Attention ! ! ! Configure according to your actual project requirements; the configuration here is for reference only.
|
||||
|
||||
```
|
||||
|
||||
## Rules vs Skills
|
||||
|
||||
@@ -10,7 +10,6 @@ const {
|
||||
getClaudeDir,
|
||||
ensureDir,
|
||||
readFile,
|
||||
writeFile,
|
||||
log
|
||||
} = require('./utils');
|
||||
|
||||
|
||||
67
scripts/release.sh
Executable file
67
scripts/release.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Release script for bumping plugin version
|
||||
# Usage: ./scripts/release.sh VERSION
|
||||
|
||||
VERSION="${1:-}"
|
||||
PLUGIN_JSON=".claude-plugin/plugin.json"
|
||||
|
||||
# Function to show usage
|
||||
usage() {
|
||||
echo "Usage: $0 VERSION"
|
||||
echo "Example: $0 1.5.0"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Validate VERSION is provided
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
echo "Error: VERSION argument is required"
|
||||
usage
|
||||
fi
|
||||
|
||||
# Validate VERSION is semver format (X.Y.Z)
|
||||
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Error: VERSION must be in semver format (e.g., 1.5.0)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check current branch is main
|
||||
CURRENT_BRANCH=$(git branch --show-current)
|
||||
if [[ "$CURRENT_BRANCH" != "main" ]]; then
|
||||
echo "Error: Must be on main branch (currently on $CURRENT_BRANCH)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check working tree is clean
|
||||
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||||
echo "Error: Working tree is not clean. Commit or stash changes first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify plugin.json exists
|
||||
if [[ ! -f "$PLUGIN_JSON" ]]; then
|
||||
echo "Error: $PLUGIN_JSON not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read current version
|
||||
OLD_VERSION=$(grep -oE '"version": *"[^"]*"' "$PLUGIN_JSON" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
echo "Bumping version: $OLD_VERSION -> $VERSION"
|
||||
|
||||
# Update version in plugin.json (cross-platform sed)
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
sed -i '' "s/\"version\": *\"[^\"]*\"/\"version\": \"$VERSION\"/" "$PLUGIN_JSON"
|
||||
else
|
||||
# Linux
|
||||
sed -i "s/\"version\": *\"[^\"]*\"/\"version\": \"$VERSION\"/" "$PLUGIN_JSON"
|
||||
fi
|
||||
|
||||
# Stage, commit, tag, and push
|
||||
git add "$PLUGIN_JSON"
|
||||
git commit -m "chore: bump plugin version to $VERSION"
|
||||
git tag "v$VERSION"
|
||||
git push origin main "v$VERSION"
|
||||
|
||||
echo "Released v$VERSION"
|
||||
165
skills/nutrient-document-processing/SKILL.md
Normal file
165
skills/nutrient-document-processing/SKILL.md
Normal file
@@ -0,0 +1,165 @@
|
||||
---
|
||||
name: nutrient-document-processing
|
||||
description: Process, convert, OCR, extract, redact, sign, and fill documents using the Nutrient DWS API. Works with PDFs, DOCX, XLSX, PPTX, HTML, and images.
|
||||
---
|
||||
|
||||
# Nutrient Document Processing
|
||||
|
||||
Process documents with the [Nutrient DWS Processor API](https://www.nutrient.io/api/). Convert formats, extract text and tables, OCR scanned documents, redact PII, add watermarks, digitally sign, and fill PDF forms.
|
||||
|
||||
## Setup
|
||||
|
||||
Get a free API key at **https://dashboard.nutrient.io/sign_up/?product=processor**
|
||||
|
||||
```bash
|
||||
export NUTRIENT_API_KEY="pdf_live_..."
|
||||
```
|
||||
|
||||
All requests go to `https://api.nutrient.io/build` as multipart POST with an `instructions` JSON field.
|
||||
|
||||
## Operations
|
||||
|
||||
### Convert Documents
|
||||
|
||||
```bash
|
||||
# DOCX to PDF
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.docx=@document.docx" \
|
||||
-F 'instructions={"parts":[{"file":"document.docx"}]}' \
|
||||
-o output.pdf
|
||||
|
||||
# PDF to DOCX
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.pdf=@document.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"document.pdf"}],"output":{"type":"docx"}}' \
|
||||
-o output.docx
|
||||
|
||||
# HTML to PDF
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "index.html=@index.html" \
|
||||
-F 'instructions={"parts":[{"html":"index.html"}]}' \
|
||||
-o output.pdf
|
||||
```
|
||||
|
||||
Supported inputs: PDF, DOCX, XLSX, PPTX, DOC, XLS, PPT, PPS, PPSX, ODT, RTF, HTML, JPG, PNG, TIFF, HEIC, GIF, WebP, SVG, TGA, EPS.
|
||||
|
||||
### Extract Text and Data
|
||||
|
||||
```bash
|
||||
# Extract plain text
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.pdf=@document.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"document.pdf"}],"output":{"type":"text"}}' \
|
||||
-o output.txt
|
||||
|
||||
# Extract tables as Excel
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.pdf=@document.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"document.pdf"}],"output":{"type":"xlsx"}}' \
|
||||
-o tables.xlsx
|
||||
```
|
||||
|
||||
### OCR Scanned Documents
|
||||
|
||||
```bash
|
||||
# OCR to searchable PDF (supports 100+ languages)
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "scanned.pdf=@scanned.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"scanned.pdf"}],"actions":[{"type":"ocr","language":"english"}]}' \
|
||||
-o searchable.pdf
|
||||
```
|
||||
|
||||
Languages: Supports 100+ languages via ISO 639-2 codes (e.g., `eng`, `deu`, `fra`, `spa`, `jpn`, `kor`, `chi_sim`, `chi_tra`, `ara`, `hin`, `rus`). Full language names like `english` or `german` also work. See the [complete OCR language table](https://www.nutrient.io/guides/document-engine/ocr/language-support/) for all supported codes.
|
||||
|
||||
### Redact Sensitive Information
|
||||
|
||||
```bash
|
||||
# Pattern-based (SSN, email)
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.pdf=@document.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"redaction","strategy":"preset","strategyOptions":{"preset":"social-security-number"}},{"type":"redaction","strategy":"preset","strategyOptions":{"preset":"email-address"}}]}' \
|
||||
-o redacted.pdf
|
||||
|
||||
# Regex-based
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.pdf=@document.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"redaction","strategy":"regex","strategyOptions":{"regex":"\\b[A-Z]{2}\\d{6}\\b"}}]}' \
|
||||
-o redacted.pdf
|
||||
```
|
||||
|
||||
Presets: `social-security-number`, `email-address`, `credit-card-number`, `international-phone-number`, `north-american-phone-number`, `date`, `time`, `url`, `ipv4`, `ipv6`, `mac-address`, `us-zip-code`, `vin`.
|
||||
|
||||
### Add Watermarks
|
||||
|
||||
```bash
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.pdf=@document.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"watermark","text":"CONFIDENTIAL","fontSize":72,"opacity":0.3,"rotation":-45}]}' \
|
||||
-o watermarked.pdf
|
||||
```
|
||||
|
||||
### Digital Signatures
|
||||
|
||||
```bash
|
||||
# Self-signed CMS signature
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "document.pdf=@document.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"sign","signatureType":"cms"}]}' \
|
||||
-o signed.pdf
|
||||
```
|
||||
|
||||
### Fill PDF Forms
|
||||
|
||||
```bash
|
||||
curl -X POST https://api.nutrient.io/build \
|
||||
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
|
||||
-F "form.pdf=@form.pdf" \
|
||||
-F 'instructions={"parts":[{"file":"form.pdf"}],"actions":[{"type":"fillForm","formFields":{"name":"Jane Smith","email":"jane@example.com","date":"2026-02-06"}}]}' \
|
||||
-o filled.pdf
|
||||
```
|
||||
|
||||
## MCP Server (Alternative)
|
||||
|
||||
For native tool integration, use the MCP server instead of curl:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"nutrient-dws": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@nutrient-sdk/dws-mcp-server"],
|
||||
"env": {
|
||||
"NUTRIENT_DWS_API_KEY": "YOUR_API_KEY",
|
||||
"SANDBOX_PATH": "/path/to/working/directory"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## When to Use
|
||||
|
||||
- Converting documents between formats (PDF, DOCX, XLSX, PPTX, HTML, images)
|
||||
- Extracting text, tables, or key-value pairs from PDFs
|
||||
- OCR on scanned documents or images
|
||||
- Redacting PII before sharing documents
|
||||
- Adding watermarks to drafts or confidential documents
|
||||
- Digitally signing contracts or agreements
|
||||
- Filling PDF forms programmatically
|
||||
|
||||
## Links
|
||||
|
||||
- [API Playground](https://dashboard.nutrient.io/processor-api/playground/)
|
||||
- [Full API Docs](https://www.nutrient.io/guides/dws-processor/)
|
||||
- [Agent Skill Repo](https://github.com/PSPDFKit-labs/nutrient-agent-skill)
|
||||
- [npm MCP Server](https://www.npmjs.com/package/@nutrient-sdk/dws-mcp-server)
|
||||
Reference in New Issue
Block a user