rewritable 0.9.0 → 0.11.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.
- package/README.md +2 -0
- package/bin/rwa.mjs +58 -0
- package/package.json +1 -1
- package/seeds/rewritable.html +876 -89
- package/src/import.mjs +206 -122
- package/src/skill-manifest.mjs +7 -0
- package/src/skill-publish.mjs +59 -0
package/README.md
CHANGED
|
@@ -74,6 +74,8 @@ Embeds the input file's content as the document's initial state. Supported forma
|
|
|
74
74
|
- `.html`, `.htm` — `<!DOCTYPE>`/`<html>`/`<head>`/`<body>` shells stripped, `<style>` tags retained from `<head>`, body content kept as-is. **`<script>` tags are preserved** (rwa documents support inline JS); a stderr warning is printed when scripts are detected.
|
|
75
75
|
- `.csv` — parsed via [`papaparse`](https://www.papaparse.com/) (RFC 4180; handles quoted commas, embedded newlines, escaped quotes, BOM). First row becomes `<thead>`, remaining rows `<tbody>`; every cell is HTML-escaped. Parse warnings print to stderr but don't abort the import.
|
|
76
76
|
- `.txt` — paragraph-split on blank lines, HTML chars escaped
|
|
77
|
+
- `.docx` — converted via [`mammoth`](https://github.com/mwilliamson/mammoth.js) to semantic HTML; `href`/`src` URLs are scheme-sanitized (same allow-list as `.md`).
|
|
78
|
+
- `.pdf` — reconstructed with **maximum geometry fidelity**: each page is rebuilt as positioned, real (still editable) text at its original coordinates, with the document's rules and boxes drawn from the PDF's own vector operators — so an invoice, form, or statement *looks like the original* while staying a rewritable you can edit with `⌘K`. Bold/italic are recovered from the embedded font names; near-perfect, not pixel-exact (system substitute fonts, black text). A scanned/image-only PDF (no text layer) exits `2` — OCR is not supported. For a model-based alternative, see `--vision` / `--claude`.
|
|
77
79
|
|
|
78
80
|
Output defaults to `<input-basename>.html` in the input's directory. Conversion is deterministic and offline — no API key, no network.
|
|
79
81
|
|
package/bin/rwa.mjs
CHANGED
|
@@ -77,6 +77,10 @@ Usage:
|
|
|
77
77
|
skill into the frozen #rwa-skills zone. Requires --yes
|
|
78
78
|
(no dialog to consent in); gate failures are final.
|
|
79
79
|
--json emits {skillId,name,kind,verified,status}.
|
|
80
|
+
rwa skill publish <file> publish a SIGNED .rwa-skill.json to the marketplace
|
|
81
|
+
index (POST /skills/publish). The envelope is already
|
|
82
|
+
signed — no key needed. Online; --url overrides the
|
|
83
|
+
service, --json emits {skillId,registryUrl,verified}.
|
|
80
84
|
rwa skin <path> <name> apply a named style preset to a rewritable in
|
|
81
85
|
place (deterministic, offline, model-free). Names:
|
|
82
86
|
notion-clean, linear-dark, editorial-serif,
|
|
@@ -721,6 +725,60 @@ function detectProductKind(fileText) {
|
|
|
721
725
|
return;
|
|
722
726
|
}
|
|
723
727
|
|
|
728
|
+
// `rwa skill publish <file.rwa-skill.json> [--url base] [--json]` — publish a SIGNED skill
|
|
729
|
+
// envelope to the marketplace index (POST /skills/publish, I6 §11). The envelope is already
|
|
730
|
+
// signed (no key needed). Online by design; exit 4 labeled `publish_error` (like `publish`).
|
|
731
|
+
if (verb === 'skill') {
|
|
732
|
+
const sub = rest[0];
|
|
733
|
+
const subRest = rest.slice(1);
|
|
734
|
+
if (sub !== 'publish') {
|
|
735
|
+
process.stderr.write("rwa skill: unknown subcommand '" + (sub || '') + "' (try: rwa skill publish <file>)\n");
|
|
736
|
+
process.exitCode = 1;
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
const jsonMode = subRest.includes('--json');
|
|
740
|
+
const urlFlag = getFlag('--url', subRest);
|
|
741
|
+
const urlIdx = subRest.indexOf('--url');
|
|
742
|
+
const skip = urlIdx >= 0 ? urlIdx + 1 : -1;
|
|
743
|
+
const filePath = subRest.find((a, i) => !a.startsWith('-') && i !== skip);
|
|
744
|
+
const emitSP = (payload) => {
|
|
745
|
+
if (jsonMode) { process.stderr.write(JSON.stringify(payload) + '\n'); return; }
|
|
746
|
+
const parts = [payload.code, payload.subcode].filter(Boolean);
|
|
747
|
+
let line = 'rwa skill publish: ' + parts.join('/');
|
|
748
|
+
if (payload.details && Object.keys(payload.details).length) line += ' ' + JSON.stringify(payload.details);
|
|
749
|
+
process.stderr.write(line + '\n');
|
|
750
|
+
};
|
|
751
|
+
if (!filePath) { emitSP({ code: 'usage_error', subcode: 'missing_file_arg' }); process.exitCode = 1; return; }
|
|
752
|
+
if (urlFlag.present && (urlFlag.value === undefined || urlFlag.value.startsWith('-'))) {
|
|
753
|
+
emitSP({ code: 'usage_error', subcode: 'missing_flag_value', details: { flag: '--url' } }); process.exitCode = 1; return;
|
|
754
|
+
}
|
|
755
|
+
const baseUrl = urlFlag.value || process.env.RWA_PUBLISH_URL || undefined;
|
|
756
|
+
const { skillPublishCmd } = await import('../src/skill-publish.mjs');
|
|
757
|
+
let result;
|
|
758
|
+
try {
|
|
759
|
+
result = await skillPublishCmd(filePath, { baseUrl });
|
|
760
|
+
} catch (e) {
|
|
761
|
+
if (e && typeof e.exitCode === 'number') {
|
|
762
|
+
const code = e.exitCode === 4 ? 'publish_error' : codeName(e.exitCode);
|
|
763
|
+
emitSP({ code, subcode: e.subcode, details: e.details });
|
|
764
|
+
process.exitCode = e.exitCode;
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
throw e;
|
|
768
|
+
}
|
|
769
|
+
if (jsonMode) {
|
|
770
|
+
process.stdout.write(JSON.stringify(result) + '\n');
|
|
771
|
+
} else {
|
|
772
|
+
process.stdout.write(
|
|
773
|
+
'✓ Published skill to the index!\n' +
|
|
774
|
+
` skillId: ${result.skillId}\n` +
|
|
775
|
+
` URL: ${result.registryUrl}\n` +
|
|
776
|
+
` verified: ${result.verified}\n`,
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
|
|
724
782
|
// `rwa publish-site <file> [--host h] [--path p] [--url base] [--json]` —
|
|
725
783
|
// copy a rewritable VERBATIM onto a static site over scp; print the live URL.
|
|
726
784
|
// Durable counterpart to `rwa publish` (ephemeral share). Online by design.
|