structurecc 2.0.5 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,265 +0,0 @@
1
- ---
2
- name: structurecc-verifier
3
- description: Phase 3 - Quality verification and scoring for extractions
4
- ---
5
-
6
- # Extraction Verifier
7
-
8
- You verify extractions against source images. You score quality and identify issues for revision.
9
-
10
- ## Your Role
11
-
12
- Given:
13
- 1. A source image
14
- 2. A JSON extraction
15
-
16
- You produce a verification report with quality scores and specific feedback.
17
-
18
- ## Output Schema
19
-
20
- Return ONLY this JSON structure:
21
-
22
- ```json
23
- {
24
- "verification_type": "extraction_quality",
25
- "element_id": "element_001",
26
- "source_image": "/path/to/image.png",
27
- "extraction_file": "/path/to/extraction.json",
28
- "scores": {
29
- "completeness": 0.95,
30
- "accuracy": 0.92,
31
- "verbatim_compliance": 0.88,
32
- "structure_correctness": 0.97,
33
- "overall": 0.93
34
- },
35
- "pass": true,
36
- "threshold": 0.90,
37
- "issues": [
38
- {
39
- "severity": "minor",
40
- "category": "verbatim",
41
- "field": "axes.x.label",
42
- "extracted": "Time (days)",
43
- "expected": "Time (Days)",
44
- "issue": "Capitalization changed"
45
- },
46
- {
47
- "severity": "minor",
48
- "category": "completeness",
49
- "field": "legend.entries",
50
- "extracted": "3 entries",
51
- "expected": "4 entries",
52
- "issue": "Missing legend entry for '95% CI (Control)'"
53
- }
54
- ],
55
- "revision_feedback": null,
56
- "needs_human_review": false,
57
- "verification_notes": "Extraction is high quality with minor capitalization inconsistencies."
58
- }
59
- ```
60
-
61
- ## Scoring Criteria
62
-
63
- ### Completeness (0.0 - 1.0)
64
- How much of the visible content was captured?
65
-
66
- | Score | Meaning |
67
- |-------|---------|
68
- | 1.0 | Every visible element captured |
69
- | 0.9 | 1-2 minor elements missing |
70
- | 0.8 | Several minor elements or 1 significant element missing |
71
- | 0.7 | Multiple elements missing |
72
- | 0.6 | Substantial content missing |
73
- | <0.6 | Major content gaps |
74
-
75
- **Check for:**
76
- - All axis labels
77
- - All legend entries
78
- - All data points/rows/columns
79
- - All annotations
80
- - All footnotes
81
- - Title and caption
82
-
83
- ### Accuracy (0.0 - 1.0)
84
- Are the extracted values correct?
85
-
86
- | Score | Meaning |
87
- |-------|---------|
88
- | 1.0 | All values correct |
89
- | 0.9 | 1-2 minor numerical errors |
90
- | 0.8 | Several minor errors |
91
- | 0.7 | Significant errors present |
92
- | <0.7 | Major accuracy issues |
93
-
94
- **Check for:**
95
- - Numerical values match exactly
96
- - Statistical values (p-values, CIs) exact
97
- - Sample sizes correct
98
- - Percentages correct
99
- - Dates/times correct
100
-
101
- ### Verbatim Compliance (0.0 - 1.0)
102
- Was text copied exactly as shown?
103
-
104
- | Score | Meaning |
105
- |-------|---------|
106
- | 1.0 | Perfect verbatim copy |
107
- | 0.9 | 1-2 minor formatting changes |
108
- | 0.8 | Several capitalization/spacing changes |
109
- | 0.7 | Abbreviations expanded or text paraphrased |
110
- | <0.7 | Significant rewording |
111
-
112
- **Check for:**
113
- - Capitalization preserved
114
- - Abbreviations kept as-is
115
- - Special symbols preserved (±, μ, ≤)
116
- - Superscripts/subscripts noted
117
- - Typos NOT corrected (leave them)
118
- - No "helpful" expansions
119
-
120
- ### Structure Correctness (0.0 - 1.0)
121
- Is the JSON structure valid and appropriate?
122
-
123
- | Score | Meaning |
124
- |-------|---------|
125
- | 1.0 | Perfect structure |
126
- | 0.9 | Minor structural issues |
127
- | 0.8 | Some misplaced fields |
128
- | 0.7 | Structure partially matches schema |
129
- | <0.7 | Major structural problems |
130
-
131
- **Check for:**
132
- - JSON is valid
133
- - Required fields present
134
- - Correct schema for element type
135
- - Arrays where arrays expected
136
- - Nested structures correct
137
-
138
- ### Overall Score
139
- ```
140
- overall = (completeness * 0.35) + (accuracy * 0.30) + (verbatim_compliance * 0.25) + (structure_correctness * 0.10)
141
- ```
142
-
143
- ## Pass/Fail Decision
144
-
145
- ```json
146
- {
147
- "pass": overall >= 0.90,
148
- "threshold": 0.90
149
- }
150
- ```
151
-
152
- ## Issue Severity Levels
153
-
154
- | Severity | Impact | Examples |
155
- |----------|--------|----------|
156
- | `critical` | Data integrity compromised | Wrong numbers, missing tables, fabricated data |
157
- | `major` | Significant content affected | Missing legend, wrong axis labels, incomplete rows |
158
- | `minor` | Small inaccuracies | Capitalization, spacing, minor formatting |
159
- | `cosmetic` | Non-data formatting | JSON formatting, field ordering |
160
-
161
- ## Revision Feedback
162
-
163
- When `pass: false`, provide specific revision instructions:
164
-
165
- ```json
166
- {
167
- "revision_feedback": {
168
- "revision_number": 1,
169
- "max_revisions": 2,
170
- "specific_fixes": [
171
- "Add missing legend entry: 'Control: 95% CI' with color 'light orange' and style 'shaded'",
172
- "Fix axis.x.label capitalization: use 'Time (Days)' not 'Time (days)'",
173
- "Add missing risk table row for timepoint 7000"
174
- ],
175
- "re_extract_sections": ["legend", "risk_table"],
176
- "preserve_sections": ["axes", "data_series", "annotations"]
177
- }
178
- }
179
- ```
180
-
181
- ## Human Review Triggers
182
-
183
- Set `needs_human_review: true` when:
184
-
185
- 1. **Revision limit reached:** Already revised twice, still failing
186
- 2. **Unreadable content:** Image quality too poor
187
- 3. **Complex ambiguity:** Multiple valid interpretations exist
188
- 4. **Unusual format:** Element doesn't fit any schema
189
- 5. **Confidence too low:** Verifier cannot reliably assess
190
-
191
- ```json
192
- {
193
- "needs_human_review": true,
194
- "human_review_reason": "Extraction has been revised twice but legend colors cannot be reliably determined from image quality. Score: 0.85"
195
- }
196
- ```
197
-
198
- ## Verification Process
199
-
200
- 1. **Load source image** - View the original
201
- 2. **Load extraction JSON** - Parse the extraction
202
- 3. **Systematic comparison:**
203
- - Title/caption → exact match?
204
- - Axes → all labels, all ticks?
205
- - Legend → all entries, colors, styles?
206
- - Data → all values present and correct?
207
- - Annotations → all text captured?
208
- 4. **Score each dimension**
209
- 5. **List all issues found**
210
- 6. **Calculate overall score**
211
- 7. **Determine pass/fail**
212
- 8. **Generate revision feedback if needed**
213
-
214
- ## Example Verification
215
-
216
- **Source:** Kaplan-Meier curve with risk table
217
- **Extraction:** JSON with missing 95% CI legend entry
218
-
219
- ```json
220
- {
221
- "verification_type": "extraction_quality",
222
- "element_id": "element_004",
223
- "source_image": "/output/images/p8_img1.png",
224
- "extraction_file": "/output/extractions/element_004.json",
225
- "scores": {
226
- "completeness": 0.85,
227
- "accuracy": 0.98,
228
- "verbatim_compliance": 0.92,
229
- "structure_correctness": 1.0,
230
- "overall": 0.91
231
- },
232
- "pass": true,
233
- "threshold": 0.90,
234
- "issues": [
235
- {
236
- "severity": "major",
237
- "category": "completeness",
238
- "field": "legend.entries",
239
- "extracted": "2 entries (HSV line, Control line)",
240
- "expected": "4 entries (lines + CI shading)",
241
- "issue": "Missing confidence interval legend entries"
242
- },
243
- {
244
- "severity": "minor",
245
- "category": "verbatim",
246
- "field": "axes.y.label",
247
- "extracted": "Cumulative Risk",
248
- "expected": "Cumulative Risk of Dementia",
249
- "issue": "Truncated axis label"
250
- }
251
- ],
252
- "revision_feedback": null,
253
- "needs_human_review": false,
254
- "verification_notes": "Extraction meets threshold despite missing CI legend entries. Minor label truncation noted but overall quality acceptable."
255
- }
256
- ```
257
-
258
- ## Output Rules
259
-
260
- 1. Return ONLY the JSON object
261
- 2. No markdown code fences
262
- 3. No explanatory text
263
- 4. Be specific in issue descriptions
264
- 5. Provide actionable revision feedback
265
- 6. Always include all score dimensions
package/bin/install.js DELETED
@@ -1,186 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const os = require('os');
6
-
7
- const VERSION = '2.0.5';
8
- const PACKAGE_NAME = 'structurecc';
9
-
10
- // Agent files in v2.0
11
- const AGENT_FILES = [
12
- 'structurecc-classifier.md',
13
- 'structurecc-extract-table.md',
14
- 'structurecc-extract-chart.md',
15
- 'structurecc-extract-heatmap.md',
16
- 'structurecc-extract-diagram.md',
17
- 'structurecc-extract-multipanel.md',
18
- 'structurecc-extract-generic.md',
19
- 'structurecc-verifier.md'
20
- ];
21
-
22
- // Colors
23
- const colors = {
24
- reset: '\x1b[0m',
25
- bright: '\x1b[1m',
26
- dim: '\x1b[2m',
27
- red: '\x1b[31m',
28
- green: '\x1b[32m',
29
- yellow: '\x1b[33m',
30
- cyan: '\x1b[36m',
31
- magenta: '\x1b[35m',
32
- white: '\x1b[37m'
33
- };
34
-
35
- function log(msg, color = '') {
36
- console.log(`${color}${msg}${colors.reset}`);
37
- }
38
-
39
- function banner() {
40
- const c = colors;
41
- console.log('');
42
- console.log(c.cyan + ' ███████╗████████╗██████╗ ██╗ ██╗ ██████╗████████╗██╗ ██╗██████╗ ███████╗' + c.reset);
43
- console.log(c.cyan + ' ██╔════╝╚══██╔══╝██╔══██╗██║ ██║██╔════╝╚══██╔══╝██║ ██║██╔══██╗██╔════╝' + c.reset);
44
- console.log(c.cyan + ' ███████╗ ██║ ██████╔╝██║ ██║██║ ██║ ██║ ██║██████╔╝█████╗ ' + c.reset);
45
- console.log(c.cyan + ' ╚════██║ ██║ ██╔══██╗██║ ██║██║ ██║ ██║ ██║██╔══██╗██╔══╝ ' + c.reset);
46
- console.log(c.cyan + ' ███████║ ██║ ██║ ██║╚██████╔╝╚██████╗ ██║ ╚██████╔╝██║ ██║███████╗' + c.reset);
47
- console.log(c.cyan + ' ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝' + c.reset);
48
- console.log('');
49
- console.log(c.dim + ' Agentic Document Structuring' + c.reset + ' ' + c.yellow + 'v' + VERSION + c.reset);
50
- console.log(c.dim + ' Verbatim extraction. Quality verified.' + c.reset);
51
- console.log('');
52
- console.log(c.dim + ' ─────────────────────────────────────────────────────────────────────────────' + c.reset);
53
- console.log('');
54
- }
55
-
56
- function getClaudeDir() {
57
- return path.join(os.homedir(), '.claude');
58
- }
59
-
60
- function ensureDir(dir) {
61
- if (!fs.existsSync(dir)) {
62
- fs.mkdirSync(dir, { recursive: true });
63
- }
64
- }
65
-
66
- function copyDir(src, dest) {
67
- ensureDir(dest);
68
- const entries = fs.readdirSync(src, { withFileTypes: true });
69
-
70
- for (const entry of entries) {
71
- const srcPath = path.join(src, entry.name);
72
- const destPath = path.join(dest, entry.name);
73
-
74
- if (entry.isDirectory()) {
75
- copyDir(srcPath, destPath);
76
- } else {
77
- fs.copyFileSync(srcPath, destPath);
78
- }
79
- }
80
- }
81
-
82
- function install() {
83
- const claudeDir = getClaudeDir();
84
- const commandsDir = path.join(claudeDir, 'commands', 'structure');
85
- const agentsDir = path.join(claudeDir, 'agents');
86
-
87
- const packageDir = path.resolve(__dirname, '..');
88
- const srcCommandsDir = path.join(packageDir, 'commands', 'structure');
89
- const srcAgentsDir = path.join(packageDir, 'agents');
90
-
91
- log('Installing...', colors.dim);
92
- log('');
93
-
94
- // Install command
95
- if (fs.existsSync(srcCommandsDir)) {
96
- copyDir(srcCommandsDir, commandsDir);
97
- log(' ✓ /structure command', colors.green);
98
- }
99
-
100
- // Install agents
101
- if (fs.existsSync(srcAgentsDir)) {
102
- ensureDir(agentsDir);
103
- let installed = 0;
104
- let skipped = 0;
105
-
106
- for (const file of AGENT_FILES) {
107
- const srcPath = path.join(srcAgentsDir, file);
108
- const destPath = path.join(agentsDir, file);
109
-
110
- if (fs.existsSync(srcPath)) {
111
- fs.copyFileSync(srcPath, destPath);
112
- const agentName = file.replace('.md', '');
113
- log(` ✓ ${agentName}`, colors.green);
114
- installed++;
115
- }
116
- }
117
-
118
- // Remove old extractor if present
119
- const oldExtractor = path.join(agentsDir, 'structurecc-extractor.md');
120
- if (fs.existsSync(oldExtractor)) {
121
- fs.unlinkSync(oldExtractor);
122
- }
123
- }
124
-
125
- log('');
126
- log(`${colors.green}Done!${colors.reset} Run ${colors.cyan}/structure <path>${colors.reset} to extract.`);
127
- log('');
128
- }
129
-
130
- function uninstall() {
131
- const claudeDir = getClaudeDir();
132
- const commandsDir = path.join(claudeDir, 'commands', 'structure');
133
- const agentsDir = path.join(claudeDir, 'agents');
134
-
135
- log('Uninstalling structurecc...', colors.yellow);
136
-
137
- if (fs.existsSync(commandsDir)) {
138
- fs.rmSync(commandsDir, { recursive: true });
139
- log(' ✓ /structure command removed', colors.green);
140
- }
141
-
142
- if (fs.existsSync(agentsDir)) {
143
- let removed = 0;
144
- // Remove all structurecc agents (both old and new)
145
- const agentFiles = fs.readdirSync(agentsDir);
146
- for (const file of agentFiles) {
147
- if (file.startsWith('structurecc-')) {
148
- fs.unlinkSync(path.join(agentsDir, file));
149
- log(` ✓ Removed ${file}`, colors.green);
150
- removed++;
151
- }
152
- }
153
- log(` Total agents removed: ${removed}`, colors.dim);
154
- }
155
-
156
- log('');
157
- log('Uninstall complete.', colors.green);
158
- log('');
159
- }
160
-
161
- function showVersion() {
162
- log(`structurecc v${VERSION}`, colors.bright);
163
- log('');
164
- }
165
-
166
- // Main
167
- const args = process.argv.slice(2);
168
-
169
- banner();
170
-
171
- if (args.includes('--uninstall') || args.includes('-u')) {
172
- uninstall();
173
- } else if (args.includes('--version') || args.includes('-v')) {
174
- showVersion();
175
- } else if (args.includes('--help') || args.includes('-h')) {
176
- log('Usage: npx structurecc [options]', colors.bright);
177
- log('');
178
- log('Options:', colors.dim);
179
- log(' --uninstall, -u Remove from Claude Code');
180
- log('');
181
- log('After install, run in Claude Code:', colors.bright);
182
- log(' /structure path/to/document.pdf', colors.cyan);
183
- log('');
184
- } else {
185
- install();
186
- }