An original asset-key command reference with full source, accepted input, exact error output and observed boundary cases

HTML for this example

Select the code and use your copy shortcut. Changes in this preview are temporary.

<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; form-action 'none'; base-uri 'none'"><title>Asset-key technical reference</title><style>*{box-sizing:border-box}body{margin:0;font:16px/1.5 Arial,Helvetica,sans-serif;color:#24313b;background:#fff}main{max-width:900px;margin:auto;padding:22px}h1{font-size:26px;line-height:1.2;margin:8px 0 18px}h2{font-size:19px;margin:22px 0 10px}h3{font-size:17px;margin:14px 0 8px}p{margin:10px 0}ul,ol{padding-left:22px}li{margin:6px 0}.note{font-size:13px;color:#53616a}.callout{border-left:4px solid #405d73;background:#f2f5f7;padding:10px 14px}table{border-collapse:collapse;width:100%;margin:12px 0}caption{text-align:left;font-weight:bold;padding:0 0 8px}th,td{padding:9px 8px;text-align:left;vertical-align:top;border-bottom:1px solid #b8c3ca;overflow-wrap:anywhere}th{background:#edf2f5}td b{display:none}footer{border-top:1px solid #aeb9bf;margin-top:22px;padding-top:12px}pre{white-space:pre-wrap;overflow-wrap:anywhere;font:16px/1.5 ui-monospace,monospace;background:#f5f5f5;padding:12px}@media(max-width:560px){main{padding:16px}h1{font-size:23px}thead{display:none}table,tbody,tr,td{display:block;width:100%}caption{display:block}tr{border-bottom:1px solid #aeb9bf;padding:6px 0}td{border:0;padding:3px 0}td b{display:inline}}@media print{@page{size:letter;margin:.5in}main{padding:0}}table th:first-child{width:110px}table pre{font-size:14px;background:transparent;padding:0;margin:0}code{overflow-wrap:anywhere}</style></head><body><main><p class="note">Original teaching script • actual local execution, not a deployed product</p><h1>Asset-key: command and errors</h1><p data-environment>Observed environment: Node v24.11.0 on win32. Save the supplied source as asset-key.mjs. No packages, file operations or network access.</p><h2>Input contract</h2><p data-contract>KEY-1: exactly one argument, one through sixteen characters, starting with an ASCII lowercase letter; remaining characters lowercase letters, digits or hyphens. A trailing hyphen is permitted. KEY-2: a wrong argument count is a usage error. No trimming, case conversion or Unicode normalization.</p><pre data-command>node asset-key.mjs a
OK a</pre><h2>Output and error rules</h2><table><caption>Streams and exit codes are distinct</caption><thead><tr><th scope="col">Condition</th><th scope="col">Output stream / text</th><th scope="col">Exit</th></tr></thead><tbody><tr data-rule="success"><td><b>Condition: </b>Accepted value</td><td><b>Output stream / text: </b>stdout: OK unchanged value</td><td><b>Exit: </b>0</td></tr><tr data-rule="format"><td><b>Condition: </b>Invalid content</td><td><b>Output stream / text: </b>stderr: Invalid key</td><td><b>Exit: </b>1</td></tr><tr data-rule="usage"><td><b>Condition: </b>Missing / extra arguments</td><td><b>Output stream / text: </b>stderr: Usage: node asset-key.mjs KEY</td><td><b>Exit: </b>1</td></tr></tbody></table><h2>Observed boundary and error examples</h2><p data-observation>These eight commands were actually run against the supplied source. PASS means the case matched its expectation; an expected error can pass. Every case is independent: save this source, then run its listed command in Node.</p><table><caption>Expected versus actual output; empty stream shown as an empty string</caption><thead><tr><th scope="col">Case / requirement</th><th scope="col">Action</th><th scope="col">Expected</th><th scope="col">Actual</th><th scope="col">Case status</th></tr></thead><tbody><tr data-case="TC-01" data-requirement="KEY-1" data-exit="0"><td><b>Case / requirement: </b>TC-01 · KEY-1</td><td><b>Action: </b><code>node asset-key.mjs "a"</code></td><td><b>Expected: </b><pre>{"exit":0,"stdout":"OK a\n","stderr":""}</pre></td><td><b>Actual: </b><pre>{"exit":0,"stdout":"OK a\n","stderr":""}</pre></td><td><b>Case status: </b>PASS</td></tr><tr data-case="TC-02" data-requirement="KEY-1" data-exit="0"><td><b>Case / requirement: </b>TC-02 · KEY-1</td><td><b>Action: </b><code>node asset-key.mjs "abcdefghijklmnop"</code></td><td><b>Expected: </b><pre>{"exit":0,"stdout":"OK abcdefghijklmnop\n","stderr":""}</pre></td><td><b>Actual: </b><pre>{"exit":0,"stdout":"OK abcdefghijklmnop\n","stderr":""}</pre></td><td><b>Case status: </b>PASS</td></tr><tr data-case="TC-03" data-requirement="KEY-1" data-exit="0"><td><b>Case / requirement: </b>TC-03 · KEY-1</td><td><b>Action: </b><code>node asset-key.mjs "a-"</code></td><td><b>Expected: </b><pre>{"exit":0,"stdout":"OK a-\n","stderr":""}</pre></td><td><b>Actual: </b><pre>{"exit":0,"stdout":"OK a-\n","stderr":""}</pre></td><td><b>Case status: </b>PASS</td></tr><tr data-case="TC-04" data-requirement="KEY-1" data-exit="1"><td><b>Case / requirement: </b>TC-04 · KEY-1</td><td><b>Action: </b><code>node asset-key.mjs "abcdefghijklmnopq"</code></td><td><b>Expected: </b><pre>{"exit":1,"stdout":"","stderr":"Invalid key\n"}</pre></td><td><b>Actual: </b><pre>{"exit":1,"stdout":"","stderr":"Invalid key\n"}</pre></td><td><b>Case status: </b>PASS</td></tr><tr data-case="TC-05" data-requirement="KEY-1" data-exit="1"><td><b>Case / requirement: </b>TC-05 · KEY-1</td><td><b>Action: </b><code>node asset-key.mjs "A"</code></td><td><b>Expected: </b><pre>{"exit":1,"stdout":"","stderr":"Invalid key\n"}</pre></td><td><b>Actual: </b><pre>{"exit":1,"stdout":"","stderr":"Invalid key\n"}</pre></td><td><b>Case status: </b>PASS</td></tr><tr data-case="TC-06" data-requirement="KEY-1" data-exit="1"><td><b>Case / requirement: </b>TC-06 · KEY-1</td><td><b>Action: </b><code>node asset-key.mjs "a b"</code></td><td><b>Expected: </b><pre>{"exit":1,"stdout":"","stderr":"Invalid key\n"}</pre></td><td><b>Actual: </b><pre>{"exit":1,"stdout":"","stderr":"Invalid key\n"}</pre></td><td><b>Case status: </b>PASS</td></tr><tr data-case="TC-07" data-requirement="KEY-2" data-exit="1"><td><b>Case / requirement: </b>TC-07 · KEY-2</td><td><b>Action: </b><code>node asset-key.mjs</code></td><td><b>Expected: </b><pre>{"exit":1,"stdout":"","stderr":"Usage: node asset-key.mjs KEY\n"}</pre></td><td><b>Actual: </b><pre>{"exit":1,"stdout":"","stderr":"Usage: node asset-key.mjs KEY\n"}</pre></td><td><b>Case status: </b>PASS</td></tr><tr data-case="TC-08" data-requirement="KEY-2" data-exit="1"><td><b>Case / requirement: </b>TC-08 · KEY-2</td><td><b>Action: </b><code>node asset-key.mjs "a" "b"</code></td><td><b>Expected: </b><pre>{"exit":1,"stdout":"","stderr":"Usage: node asset-key.mjs KEY\n"}</pre></td><td><b>Actual: </b><pre>{"exit":1,"stdout":"","stderr":"Usage: node asset-key.mjs KEY\n"}</pre></td><td><b>Case status: </b>PASS</td></tr></tbody></table><h2>Complete original source</h2><pre data-source>const args = process.argv.slice(2);
if (args.length !== 1) {
  console.error("Usage: node asset-key.mjs KEY");
  process.exit(1);
}
const value = args[0];
if (!new RegExp("^[a-z][a-z0-9-]{0,15}$").test(value)) {
  console.error("Invalid key");
  process.exit(1);
}
console.log("OK " + value);
</pre><footer><h2>Reproduce before changing the record</h2><p data-boundary>This contract checks a proposed key only. It does not upload an asset or claim compatibility with an asset service; keep implementation and repository reference together.</p><p>Ask another developer or tester to repeat the boundary and argument-count cases from the same source. Record any new result in the actual repository or test tool; this reading copy does not run commands.</p></footer></main></body></html>