claude-token-saver 3.28.2 → 3.28.3
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.
- package/README.en.md +14 -0
- package/README.md +15 -1
- package/package.json +1 -1
- package/presets/doc2md/convert.py +62 -0
- package/src/doc2md.cjs +20 -3
package/README.en.md
CHANGED
|
@@ -461,6 +461,20 @@ Conversion is one-way — editing the cached `.md` changes nothing in the source
|
|
|
461
461
|
|
|
462
462
|
All four formats were exercised end to end on 2026-09-06: 10 docx run replacements plus three consecutive re-saves, a pptx bar-to-line chart swap with an added data point, xlsx value edits and a new row, and a fig text edit with re-encode and re-parse. In every case the original was byte-identical afterwards and the re-converted copy showed the change. One caveat: removing a chart shape from a pptx leaves the old chart XML part orphaned — PowerPoint ignores it, but delete the part and its rels for a clean file. Charts and images never appear in a conversion, so visual edits must be confirmed in the application itself.
|
|
463
463
|
|
|
464
|
+
### DRM-wrapped documents
|
|
465
|
+
|
|
466
|
+
Encryption and DRM are different problems with different answers. Enterprise DRM (Fasoo, MarkAny, SoftCamp and the like) does not password a document — it wraps the whole file, and only processes the vendor's agent has whitelisted ever see plaintext. Python is not one of them, so what sits on disk is ciphertext behind a vendor header, and **no password will open it.**
|
|
467
|
+
|
|
468
|
+
The first bytes decide which story to tell: a zip header means a truncated download, an OLE container means a password, and neither means the file is not that format at all.
|
|
469
|
+
|
|
470
|
+
```
|
|
471
|
+
✗ bad-archive: File is not a zip file → download it again
|
|
472
|
+
✗ encrypted: password-protected Office file → ask for an unlocked copy
|
|
473
|
+
✗ drm-protected: DRM-wrapped file (FASOO) → ask for a copy released from DRM
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
Vendor names are matched only to say which client to go to; the classification stands without recognising the vendor. PDFs are judged the same way through their public DRM security-handler names (FOPN_foweb, EBX_HANDLER, Adobe.APS).
|
|
477
|
+
|
|
464
478
|
### Locked documents, and Windows
|
|
465
479
|
|
|
466
480
|
**A password-protected document is a state, not an error.** Office encrypts by wrapping the package in an OLE compound file rather than a zip, so opening one as a zip used to report "not a zip file" — which reads as a broken download and sends the user after the wrong problem. It is now identified before conversion:
|
package/README.md
CHANGED
|
@@ -457,6 +457,20 @@ PDF 는 첨부하면 모델이 내용을 그대로 읽습니다. 대신 페이
|
|
|
457
457
|
|
|
458
458
|
네 형식 모두 실제로 몇 바퀴 돌려 검증했습니다(2026-09-06): docx 텍스트 치환 10건과 3회 연속 재저장, pptx 막대→꺾은선 차트 교체와 데이터 행 추가, xlsx 값 정정·행 추가, fig 텍스트 수정·재인코드·재파싱. 전 케이스에서 원본은 바이트 그대로였고, 수정본 재변환에 변경 내용이 반영됐습니다. 한 가지 주의: pptx 에서 차트 도형을 제거하면 옛 차트 XML 파트가 고아로 남습니다. PowerPoint 는 무시하지만, 깔끔히 하려면 파트와 rels 도 지우십시오. 차트·이미지 같은 시각 요소는 변환본에 잡히지 않으므로, 시각 편집의 최종 확인은 해당 프로그램에서 해야 합니다.
|
|
459
459
|
|
|
460
|
+
### DRM 으로 보호된 문서
|
|
461
|
+
|
|
462
|
+
암호와 DRM 은 다른 문제이고 해법도 다릅니다. 사내 DRM(파수·마크애니·소프트캠프 등)은 문서에 암호를 거는 것이 아니라 파일 전체를 감싸며, 벤더 에이전트가 허용한 프로그램만 평문을 봅니다. 파이썬은 거기 없으므로 디스크에 있는 것은 벤더 헤더가 붙은 암호문입니다. **암호를 입력해서 풀 수 있는 문제가 아닙니다.**
|
|
463
|
+
|
|
464
|
+
판별은 첫 바이트가 무엇을 말하는지로 갈립니다. zip 헤더면 내려받다 끊긴 파일, OLE 컨테이너면 암호 걸린 문서, 둘 다 아니면 애초에 그 형식이 아닙니다.
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
✗ bad-archive: File is not a zip file ← 다시 받으십시오
|
|
468
|
+
✗ encrypted: password-protected Office file ← 암호를 푼 사본을 요청하십시오
|
|
469
|
+
✗ drm-protected: DRM-wrapped file (FASOO) ← DRM 해제본이나 반출 승인 사본을 요청하십시오
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
벤더 이름은 어느 클라이언트로 가야 하는지 알려 주려고 맞춰 볼 뿐이고, 판별 자체는 벤더를 몰라도 성립합니다. PDF 는 공개된 DRM 보안 핸들러 이름(FOPN_foweb·EBX_HANDLER·Adobe.APS)으로 같은 판정을 합니다.
|
|
473
|
+
|
|
460
474
|
### 암호가 걸린 문서와 Windows
|
|
461
475
|
|
|
462
476
|
**암호 문서는 오류가 아니라 상태로 다룹니다.** 사내에서 받는 문서 중 일부는 암호가 걸려 있습니다. 이전에는 암호 걸린 docx 를 "손상된 zip"이라고 알려서 사용자가 원인을 엉뚱한 곳에서 찾게 만들었습니다. 암호가 걸린 Office 문서는 zip 이 아니라 OLE 복합 문서로 저장되기 때문입니다. 지금은 변환 전에 판별해서 이렇게 알립니다.
|
|
@@ -468,7 +482,7 @@ PDF 는 첨부하면 모델이 내용을 그대로 읽습니다. 대신 페이
|
|
|
468
482
|
|
|
469
483
|
모델에게는 암호를 푼 사본을 사용자에게 요청하라고 안내합니다. 이 도구는 암호를 묻지도 저장하지도 않습니다. 어느 경우에도 원본 `Read` 를 막지 않으므로 작업이 중단되지 않습니다. 열람은 자유롭고 인쇄만 제한된 PDF 는 암호 문서가 아니므로 그대로 변환합니다(오탐 확인 완료). 구형 `.xls` 도 원래 OLE 형식이라 암호로 오인하지 않습니다.
|
|
470
484
|
|
|
471
|
-
**Windows 를
|
|
485
|
+
**Windows 를 지원하며, 실제 Windows 러너에서 검증합니다.** 사내에 Windows 사용자가 있어 다음을 맞췄습니다.
|
|
472
486
|
|
|
473
487
|
- 파이썬 탐색이 `py -3` 런처를 씁니다. Windows 에서는 `python3` 가 PATH 에 없는 경우가 많고, 맨 `python` 은 실행 대신 마이크로소프트 스토어를 여는 별칭 스텁일 수 있습니다. venv 기반 인터프리터도 `Scripts\python.exe` 경로로 찾습니다.
|
|
474
488
|
- `.fig` 파서 설치가 `npm.cmd` 를 셸로 호출합니다. 그리고 패키지 지정자에서 캐럿을 뺐습니다(`openfig-core@0.4.x`). cmd.exe 에서 `^` 는 이스케이프 문자라 npm 에 닿기 전에 먹힙니다.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-token-saver",
|
|
3
|
-
"version": "3.28.
|
|
3
|
+
"version": "3.28.3",
|
|
4
4
|
"description": "Route the easy work your expensive Claude model keeps repeating down to haiku/sonnet — post-hoc session analysis, no realtime router, no extra LLM calls.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -92,6 +92,62 @@ def encryption_problem(path, ext):
|
|
|
92
92
|
return None
|
|
93
93
|
|
|
94
94
|
|
|
95
|
+
# Enterprise DRM (Fasoo, MarkAny, SoftCamp and the like) does not password a
|
|
96
|
+
# document — it wraps the whole file, and only processes the vendor's agent
|
|
97
|
+
# has whitelisted ever see plaintext. Python is not one of them, so the bytes
|
|
98
|
+
# on disk are ciphertext with a vendor header. Names are matched only to say
|
|
99
|
+
# *which* product to go to; the classification does not depend on them.
|
|
100
|
+
DRM_MARKERS = [b"FASOO", b"MarkAny", b"MAWDRM", b"SoftCamp", b"Sherpa", b"TrustDRM",
|
|
101
|
+
b"DocuGate", b"WISEDRM", b"UNIDOCS", b"SecureDoc"]
|
|
102
|
+
# PDF DRM announces itself as a security handler, and these names are public.
|
|
103
|
+
PDF_DRM_FILTERS = [b"FOPN_foweb", b"EBX_HANDLER", b"Adobe.APS", b"FOPN_fLock"]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def drm_hint(head):
|
|
107
|
+
"""Vendor name found in the file header, or None."""
|
|
108
|
+
for marker in DRM_MARKERS:
|
|
109
|
+
if marker in head or marker.decode().encode("utf-16-le") in head:
|
|
110
|
+
return marker.decode()
|
|
111
|
+
return None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def wrapper_problem(path, ext):
|
|
115
|
+
"""('drm-protected', detail) when the container is not the format at all."""
|
|
116
|
+
try:
|
|
117
|
+
with open(path, "rb") as fh:
|
|
118
|
+
head = fh.read(8192)
|
|
119
|
+
except OSError:
|
|
120
|
+
return None
|
|
121
|
+
if not head:
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
if ext in ZIP_EXTS:
|
|
125
|
+
# A truncated download still starts with a zip local-file header; a
|
|
126
|
+
# wrapped file does not start with anything of the format at all.
|
|
127
|
+
# Telling those two apart is the difference between "re-download it"
|
|
128
|
+
# and "get it released from DRM".
|
|
129
|
+
if head[:2] == b"PK" or head[:8] == OLE_MAGIC:
|
|
130
|
+
return None
|
|
131
|
+
vendor = drm_hint(head)
|
|
132
|
+
return ("drm-protected",
|
|
133
|
+
"DRM-wrapped file (%s)" % vendor if vendor else "the file is not an Office container at all")
|
|
134
|
+
|
|
135
|
+
if ext == ".pdf":
|
|
136
|
+
if not head.startswith(b"%PDF"):
|
|
137
|
+
vendor = drm_hint(head)
|
|
138
|
+
return ("drm-protected",
|
|
139
|
+
"DRM-wrapped file (%s)" % vendor if vendor else "the file is not a PDF at all")
|
|
140
|
+
try:
|
|
141
|
+
with open(path, "rb") as fh:
|
|
142
|
+
blob = fh.read(2_000_000)
|
|
143
|
+
except OSError:
|
|
144
|
+
return None
|
|
145
|
+
for f in PDF_DRM_FILTERS:
|
|
146
|
+
if f in blob:
|
|
147
|
+
return ("drm-protected", "PDF with a DRM security handler (%s)" % f.decode())
|
|
148
|
+
return None
|
|
149
|
+
|
|
150
|
+
|
|
95
151
|
def check_zip(path):
|
|
96
152
|
"""Classify an archive before opening it as a document.
|
|
97
153
|
|
|
@@ -245,6 +301,12 @@ def main():
|
|
|
245
301
|
if locked:
|
|
246
302
|
fail(locked[0], locked[1])
|
|
247
303
|
|
|
304
|
+
# After the password check, because an OLE-wrapped Office file is an
|
|
305
|
+
# encrypted document rather than a DRM-wrapped one.
|
|
306
|
+
wrapped = wrapper_problem(path, ext)
|
|
307
|
+
if wrapped:
|
|
308
|
+
fail(wrapped[0], wrapped[1])
|
|
309
|
+
|
|
248
310
|
if ext in ZIP_EXTS:
|
|
249
311
|
problem = check_zip(path)
|
|
250
312
|
if problem:
|
package/src/doc2md.cjs
CHANGED
|
@@ -413,8 +413,9 @@ function installConverter({ onProgress = () => {} } = {}) {
|
|
|
413
413
|
/**
|
|
414
414
|
* Convert one file. Returns `{ ok: true, cacheFile, meta }`, or
|
|
415
415
|
* `{ ok: false, reason, detail }` where reason is one of:
|
|
416
|
-
* no-markitdown | python-too-old | no-figparser | encrypted |
|
|
417
|
-
* sensitive | unsafe-archive | no-text |
|
|
416
|
+
* no-markitdown | python-too-old | no-figparser | encrypted |
|
|
417
|
+
* drm-protected | too-large | sensitive | unsafe-archive | no-text |
|
|
418
|
+
* convert-failed | timeout
|
|
418
419
|
*
|
|
419
420
|
* Every failure is a reason to leave the original Read alone, never to break
|
|
420
421
|
* it. That is the whole contract with the hook.
|
|
@@ -680,6 +681,14 @@ function decideForRead(context, opts = {}) {
|
|
|
680
681
|
+ ` 진행 상황: ${INSTALL_HINT} 를 직접 실행하면 설치 로그를 볼 수 있습니다.`,
|
|
681
682
|
};
|
|
682
683
|
}
|
|
684
|
+
if (result.reason === 'drm-protected') {
|
|
685
|
+
return {
|
|
686
|
+
deny: false,
|
|
687
|
+
reason: `[doc2md] ${name} 는 DRM 으로 보호된 파일이라 변환하지 못했습니다(${result.detail || ''}).\n`
|
|
688
|
+
+ ' DRM 은 암호 입력으로 풀리지 않습니다. 벤더 에이전트가 허용한 프로그램에서만 평문이 보이므로, '
|
|
689
|
+
+ '사용자에게 DRM 클라이언트에서 연 뒤 해제본으로 저장하거나 반출 승인을 받은 사본을 요청하십시오.',
|
|
690
|
+
};
|
|
691
|
+
}
|
|
683
692
|
if (result.reason === 'encrypted') {
|
|
684
693
|
return {
|
|
685
694
|
deny: false,
|
|
@@ -754,7 +763,11 @@ function decideForRead(context, opts = {}) {
|
|
|
754
763
|
function documentPathsIn(text) {
|
|
755
764
|
if (typeof text !== 'string' || !text) return [];
|
|
756
765
|
const exts = TARGET_EXTENSIONS.map((e) => e.slice(1)).join('|');
|
|
757
|
-
|
|
766
|
+
// Backslashes count as path characters, not just separators to tolerate:
|
|
767
|
+
// `C:\\Users\\me\\deck.pptx` and `\\\\server\\share\\deck.pptx` are how
|
|
768
|
+
// Windows users write a path, and without them the scanner silently sees no
|
|
769
|
+
// documents at all on that platform.
|
|
770
|
+
const re = new RegExp(`[@'"\`]?((?:[A-Za-z]:)?[~./\\\\][^\\s'"\`]*\\.(?:${exts}))`, 'gi');
|
|
758
771
|
const found = [];
|
|
759
772
|
for (const m of text.matchAll(re)) {
|
|
760
773
|
const raw = m[1];
|
|
@@ -817,6 +830,10 @@ function contextForPrompt(payload, opts = {}) {
|
|
|
817
830
|
lines.push(lang === 'ko'
|
|
818
831
|
? ` ${name}: 변환기를 설치하는 중입니다(첫 실행에만 걸립니다). 설치가 끝나면 다음 요청부터 자동 변환됩니다.`
|
|
819
832
|
: ` ${name}: the converter is installing now (first run only). It will convert automatically from the next request.`);
|
|
833
|
+
} else if (result.reason === 'drm-protected') {
|
|
834
|
+
lines.push(lang === 'ko'
|
|
835
|
+
? ` ${name}: DRM 으로 보호된 파일입니다(${result.detail || ''}). 암호로는 풀 수 없으므로, DRM 클라이언트에서 저장한 해제본이나 반출 승인 사본을 달라고 사용자에게 요청하십시오.`
|
|
836
|
+
: ` ${name}: the file is DRM-wrapped (${result.detail || ''}). A password will not open it — ask the user for a copy released from DRM.`);
|
|
820
837
|
} else if (result.reason === 'encrypted') {
|
|
821
838
|
lines.push(lang === 'ko'
|
|
822
839
|
? ` ${name}: 암호가 걸린 문서입니다. 암호를 푼 사본을 달라고 사용자에게 요청하십시오.`
|