docx-shell-workaround
यह क्या करती है
यह स्किल टूल्स टूटने पर शेल कमांड और XML पार्सिंग से .docx फ़ाइलें पढ़ने का तरीका बताती है। यह उन लोगों के लिए है जिनका AI Word फ़ाइलें सीधे नहीं पढ़ पाता।
कब इस्तेमाल करें
- ✓जब फ़ाइल रीडर .docx फ़ाइल से सामग्री न निकाल पाए।
- ✓जब Word फ़ाइल बनाते या बदलते समय कोड सैंडबॉक्स विफल हो।
- ✓जब मुझे Word फ़ाइल की सामग्री के साथ काम करने के लिए भरोसेमंद बैकअप चाहिए।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-workaround/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“AI मेरी Word फ़ाइल नहीं पढ़ पा रहा। कृपया शेल से उसका टेक्स्ट निकालिए, ताकि उसी से आगे काम कर सकें।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI दस्तावेज़ XML को unzip करता है और शेल रन में Python के ElementTree से उसे पार्स करता है, हर पैराग्राफ़ से टेक्स्ट इकट्ठा करते हुए।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
DOCX Shell Workaround
When to Use
Use this skill when:
read_filecannot extract content from .docx filesexecute_code_sandboxencounters failures when creating or modifying docx files- You need a reliable fallback for docx file manipulation
Reading DOCX Files
Step 1: Extract document.xml using unzip
Use run_shell to unzip the .docx file (which is a ZIP archive) and extract the main document XML:
unzip -p input.docx word/document.xml > document.xml
Step 2: Parse XML with ElementTree via run_shell
Extract text content by parsing the XML. Use run_shell to execute Python code:
python3 << 'EOF'
import xml.etree.ElementTree as ET
tree = ET.parse('document.xml')
root = tree.getroot()
namespace = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
text_content = []
for elem in root.iter():
if elem.tag.endswith('t'):
if elem.text:
text_content.append(elem.text)
text = ''.join(text_content)
print(text)
EOF
Step 3: Optional - More robust XML parsing
For better text extraction that handles paragraphs:
python3 << 'EOF'
import xml.etree.ElementTree as ET
tree = ET.parse('document.xml')
root = tree.getroot()
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
paragraphs = []
for p in root.findall('.//w:p', ns):
para_text = []
for t in p.findall('.//w:t', ns):
if t.text:
para_text.append(t.text)
if para_text:
paragraphs.append(''.join(para_text))
for para in paragraphs:
print(para)
EOF
Creating DOCX Files
Use python-docx via run_shell (NOT execute_code_sandbox)
When execute_code_sandbox fails for docx operations, use run_shell instead:
python3 << 'EOF'
from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document()
# Add heading
doc.add_heading('Document Title', 0)
# Add paragraph
doc.add_paragraph('Your content here.')
# Add section with heading
doc.add_heading('Section Title', level=1)
doc.add_paragraph('Section content with multiple paragraphs.')
# Add table if needed
table = doc.add_table(rows=3, cols=3)
table.style = 'Table Grid'
# Save document
doc.save('output.docx')
print("Document created successfully")
EOF
Example: Creating a structured business document
python3 << 'EOF'
from docx import Document
from docx.shared import Pt
doc = Document()
# Title
title = doc.add_heading('Business Strategy Memo', 0)
title.alignment = 1 # Center
# Executive Summary
doc.add_heading('Executive Summary', level=1)
doc.add_paragraph('Brief overview of key points and recommendations.')
# Market Overview
doc.add_heading('Market Overview', level=1)
doc.add_paragraph('Analysis of current market conditions and trends.')
# Recommendations
doc.add_heading('Recommendations', level=1)
doc.add_paragraph('Actionable recommendations based on analysis.')
doc.save('Strategy_Memo.docx')
EOF
Full Workflow Example
Complete example showing extraction and creation:
# Step 1: Extract content from existing docx
unzip -p existing.docx word/document.xml > doc.xml
# Step 2: Parse and transform content
python3 << 'EOF'
import xml.etree.ElementTree as ET
tree = ET.parse('doc.xml')
root = tree.getroot()
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
content = []
for p in root.findall('.//w:p', ns):
para_text = []
for t in p.findall('.//w:t', ns):
if t.text:
para_text.append(t.text)
if para_text:
content.append(''.join(para_text))
# Write extracted content to file for reference
with open('extracted.txt', 'w') as f:
for line in content:
f.write(line + '\n')
EOF
# Step 3: Create new docx with modified content
python3 << 'EOF'
from docx import Document
doc = Document()
doc.add_heading('Updated Document', 0)
with open('extracted.txt', 'r') as f:
for line in f:
if line.strip():
doc.add_paragraph(line.strip())
doc.save('updated.docx')
EOF
Key Points
- Always use
run_shell- Notexecute_code_sandboxfor docx operations - DOCX is a ZIP archive - Contains XML files including word/document.xml
- Use
unzip -p- The-pflag outputs to stdout, useful for piping - Handle XML namespaces - Word XML uses the
w:namespace prefix - Install python-docx if needed - Run
pip install python-docxin the shell if not avai
अक्सर पूछे जाने वाले सवाल
ElementTree क्या है?
यह XML फ़ाइलें पढ़ने के लिए Python की स्टैंडर्ड लाइब्रेरी का मॉड्यूल है।
पैराग्राफ़ के हिसाब से क्यों पार्स करें?
पैराग्राफ़ के हिसाब से पार्स करने से टेक्स्ट व्यवस्थित रहता है, सारे शब्द एक साथ नहीं जुड़ते।
क्या ये उदाहरण फ़ाइल बदलते हैं?
नहीं, दिखाए गए उदाहरण फ़ाइल से टेक्स्ट पढ़ने पर केंद्रित हैं।
जानकारी
लेखक का मूल विवरण
Handle docx files using shell-based XML extraction and python-docx via run_shell when standard tools fail
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12871
- लाइसेंस
- MIT
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
feishu-doc
394kयह आपके एजेंट को document टूल से Feishu क्लाउड दस्तावेज़ पढ़ने, बनाने और बदलने में मदद करती है, जिसमें टेक्स्ट, इमेज और टेबल शामिल हैं।
feishu-drive
394kयह आपके एजेंट को बॉट के साथ साझा किए गए Feishu क्लाउड फ़ोल्डर में फ़ाइलें देखने, व्यवस्थित करने और उन पर टिप्पणी करने देती है।
feishu-perm
394kयह आपके एजेंट को Feishu फ़ाइल तक किसकी पहुंच है, यह जांचने और बदलने देती है, और आपके अनुरोध के लिए सबसे छोटी अनुमति चुनती है।