@gbti/ryker 0.1.1-rc.1

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Ryker Source-Available License
2
+
3
+ Copyright (c) 2026 GETHSEMANE LLC
4
+
5
+ Permission is granted to use, copy, modify, and redistribute Ryker and
6
+ derivative works, subject to the following conditions:
7
+
8
+ 1. This license and its copyright notice must remain intact and accompany every
9
+ copy of Ryker and every fork or derivative work based on Ryker.
10
+ 2. Ryker, a fork of Ryker, or a derivative work based on Ryker may not be sold,
11
+ resold, bundled with, incorporated into, shipped with, distributed as part
12
+ of, or featured as part of a commercial product or software as a service
13
+ product without prior explicit written permission from GETHSEMANE LLC.
14
+
15
+ Use by internal teams and use in support of commercial endeavors are permitted.
16
+ Including and distributing Ryker, a fork, or a derivative work with client
17
+ deliverables are also permitted, provided this license and its copyright notice
18
+ remain intact and Ryker is not sold or presented as a commercial product or
19
+ service.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Ryker
2
+
3
+ Ryker adds inline editing to authored HTML and produces prompt-ready,
4
+ machine-readable change requests.
5
+
6
+ ## Install into an HTML document
7
+
8
+ ```bash
9
+ npx --yes @gbti/ryker@next insert ./report.html
10
+ ```
11
+
12
+ Preview first with `--dry-run`. The installer creates a recoverable
13
+ `report.html.ryker-backup`, copies the dependency-free browser bundle beside the
14
+ document, and adds one identifiable managed block before `</body>`.
15
+
16
+ ```bash
17
+ npx ryker doctor ./report.html
18
+ npx ryker sync ./report.html
19
+ npx ryker remove ./report.html
20
+ ```
21
+
22
+ Ryker requires Node.js 20 or newer for installation. The resulting HTML and
23
+ classic browser script work offline and from `file://` without Node.js.
24
+
25
+ ## License
26
+
27
+ Ryker is source-available under the custom license included with the package.
28
+ Internal-team use, internal commercial use and inclusion with client
29
+ deliverables are permitted. Ryker, its forks and its derivatives may not be
30
+ sold or shipped or featured as part of a commercial product or software as a
31
+ service offering without prior written permission from GETHSEMANE LLC. The
32
+ license and copyright notice must remain intact.
33
+
34
+ This package is not published yet. The `@next` command above becomes available
35
+ after the first release candidate is published. The `@latest` tag is reserved
36
+ for a release that has passed public-package acceptance testing.
package/bin/ryker.js ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+ import { createHash } from 'node:crypto';
3
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
+ import { dirname, extname, relative, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const VERSION = '0.1.1-rc.1';
8
+ const BEGIN = '<!-- ryker:begin -->';
9
+ const END = '<!-- ryker:end -->';
10
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
11
+ const shippedBundle = resolve(root, 'drop-in', 'dist', 'ryker.js');
12
+
13
+ function fail(message) { console.error('Ryker: ' + message); process.exitCode = 1; }
14
+ function hash(buffer) { return createHash('sha256').update(buffer).digest('hex'); }
15
+ function slug(value) {
16
+ return String(value).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 80) || 'untitled';
17
+ }
18
+ function parse(argv) {
19
+ const out = { command: argv[0], target: argv[1], dryRun: false, documentId: null, assetDir: 'ryker' };
20
+ for (let i = 2; i < argv.length; i++) {
21
+ if (argv[i] === '--dry-run') out.dryRun = true;
22
+ else if (argv[i] === '--document-id') out.documentId = argv[++i];
23
+ else if (argv[i] === '--asset-dir') out.assetDir = argv[++i];
24
+ else throw new Error('Unknown option: ' + argv[i]);
25
+ }
26
+ return out;
27
+ }
28
+ function usage() {
29
+ console.log(`Ryker ${VERSION}\n\nUsage:\n ryker insert <file.html> [--dry-run] [--document-id id] [--asset-dir dir]\n ryker sync <file.html> [--dry-run] [--asset-dir dir]\n ryker doctor <file.html> [--asset-dir dir]\n ryker remove <file.html> [--dry-run] [--asset-dir dir]\n ryker --version`);
30
+ }
31
+ function targetInfo(options) {
32
+ if (!options.target) throw new Error('Name an HTML file.');
33
+ const cwd = resolve(process.cwd());
34
+ const file = resolve(cwd, options.target);
35
+ const rel = relative(cwd, file);
36
+ if (rel.startsWith('..') || resolve(cwd, rel) !== file) throw new Error('Target must be inside the current working directory.');
37
+ if (!['.html', '.htm'].includes(extname(file).toLowerCase())) throw new Error('Target must be an .html or .htm file.');
38
+ if (!existsSync(file)) throw new Error('Target does not exist: ' + file);
39
+ if (!options.assetDir || resolve(dirname(file), options.assetDir).startsWith(dirname(file)) === false) throw new Error('Asset directory must stay beside or below the target.');
40
+ const asset = resolve(dirname(file), options.assetDir, 'dist', 'ryker.js');
41
+ return { cwd, file, rel, asset, html: readFileSync(file, 'utf8') };
42
+ }
43
+ function managedRange(html) {
44
+ const start = html.indexOf(BEGIN), end = html.indexOf(END);
45
+ if ((start < 0) !== (end < 0)) throw new Error('Found an incomplete managed Ryker block.');
46
+ if (start < 0) return null;
47
+ if (html.indexOf(BEGIN, start + 1) >= 0 || html.indexOf(END, end + 1) >= 0) throw new Error('Found multiple managed Ryker blocks.');
48
+ return { start, end: end + END.length };
49
+ }
50
+ function block(info, options, newline) {
51
+ const id = options.documentId || slug(relative(info.cwd, info.file).replace(/\\/g, '/'));
52
+ const src = relative(dirname(info.file), info.asset).replace(/\\/g, '/');
53
+ return [BEGIN, '<script type="application/json" id="ryker-config">', JSON.stringify({ RYKER_DOCUMENT_ID: id, RYKER_DOCUMENT_PATH: relative(info.cwd, info.file).replace(/\\/g, '/') }), '</script>', `<script src="${src}" data-ryker></script>`, END].join(newline);
54
+ }
55
+ function install(options) {
56
+ const info = targetInfo(options), range = managedRange(info.html);
57
+ if (!range && /<script\b[^>]*\bdata-ryker\b/i.test(info.html)) throw new Error('An unmanaged Ryker insert already exists; refusing to overwrite it.');
58
+ const newline = info.html.includes('\r\n') ? '\r\n' : '\n';
59
+ const insertion = block(info, options, newline);
60
+ let next;
61
+ if (range) next = info.html.slice(0, range.start) + insertion + info.html.slice(range.end);
62
+ else {
63
+ const body = info.html.search(/<\/body\s*>/i);
64
+ if (body < 0) throw new Error('No closing body element was found.');
65
+ next = info.html.slice(0, body) + insertion + newline + info.html.slice(body);
66
+ }
67
+ const packaged = readFileSync(shippedBundle);
68
+ if (existsSync(info.asset) && hash(readFileSync(info.asset)) !== hash(packaged)) throw new Error('The destination Ryker bundle is unrecognized; refusing to overwrite it: ' + info.asset);
69
+ console.log(`${options.dryRun ? 'Would install' : 'Installing'} Ryker ${VERSION}`);
70
+ console.log(' document: ' + info.file);
71
+ console.log(' bundle: ' + info.asset);
72
+ if (options.dryRun) return;
73
+ const backup = info.file + '.ryker-backup';
74
+ if (!existsSync(backup)) copyFileSync(info.file, backup);
75
+ mkdirSync(dirname(info.asset), { recursive: true });
76
+ copyFileSync(shippedBundle, info.asset);
77
+ writeFileSync(info.file, next, 'utf8');
78
+ console.log(' backup: ' + backup);
79
+ }
80
+ function doctor(options) {
81
+ const info = targetInfo(options), range = managedRange(info.html);
82
+ const problems = [];
83
+ if (!range) problems.push('managed insert is missing');
84
+ if (!existsSync(info.asset)) problems.push('bundle is missing: ' + info.asset);
85
+ else if (hash(readFileSync(info.asset)) !== hash(readFileSync(shippedBundle))) problems.push('bundle does not match this package version');
86
+ if (problems.length) { problems.forEach((p) => console.error('FAIL ' + p)); process.exitCode = 1; }
87
+ else console.log('OK Ryker ' + VERSION + ' is installed and current in ' + info.file);
88
+ }
89
+ function remove(options) {
90
+ const info = targetInfo(options), range = managedRange(info.html);
91
+ if (!range) throw new Error('No managed Ryker insert was found.');
92
+ const next = info.html.slice(0, range.start) + info.html.slice(range.end).replace(/^(\r?\n)/, '');
93
+ console.log(`${options.dryRun ? 'Would remove' : 'Removing'} Ryker from ${info.file}`);
94
+ if (options.dryRun) return;
95
+ writeFileSync(info.file, next, 'utf8');
96
+ if (existsSync(info.asset) && hash(readFileSync(info.asset)) === hash(readFileSync(shippedBundle))) rmSync(info.asset);
97
+ }
98
+
99
+ try {
100
+ const args = process.argv.slice(2);
101
+ if (!args.length || args[0] === '--help' || args[0] === '-h') usage();
102
+ else if (args[0] === '--version' || args[0] === '-v') console.log(VERSION);
103
+ else {
104
+ const options = parse(args);
105
+ if (options.command === 'insert' || options.command === 'sync') install(options);
106
+ else if (options.command === 'doctor') doctor(options);
107
+ else if (options.command === 'remove') remove(options);
108
+ else throw new Error('Unknown command: ' + options.command);
109
+ }
110
+ } catch (error) { fail(error.message); }