linersh 1.2.0 → 1.2.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/README.md +4 -4
- package/bin/liner.js +45 -9
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -66,10 +66,10 @@ HOME="$home" npm_config_cache="$cache" LINER_DIR="$projects" npx --yes linersh@l
|
|
|
66
66
|
rm -rf "$tmp"
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
The second command opens the
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
The second command opens the navigator, which is read-only. Ask your agent to
|
|
70
|
+
build a test liner with `liner research`, using the same `LINER_DIR`, and watch
|
|
71
|
+
it appear in the navigator. Because `HOME`, the npm cache, and `LINER_DIR` all
|
|
72
|
+
point inside `$tmp`, cleanup is just `rm -rf "$tmp"`.
|
|
73
73
|
|
|
74
74
|
## Run Locally
|
|
75
75
|
|
package/bin/liner.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Entry shim for `npx linersh` / `liner`.
|
|
3
3
|
//
|
|
4
|
-
// No args:
|
|
5
|
-
// unset ->
|
|
6
|
-
// LINER_TUI=go ->
|
|
7
|
-
//
|
|
4
|
+
// No args: open the navigator (the Charm Go TUI).
|
|
5
|
+
// unset -> open the navigator
|
|
6
|
+
// LINER_TUI=go -> open the navigator explicitly
|
|
7
|
+
// A known command: forward to the bundled Python core (or LINER_BIN/dev fallback).
|
|
8
|
+
// Anything else: print an error instead of opening the navigator.
|
|
8
9
|
//
|
|
9
10
|
// This lets the npm package expose one binary name while still supporting
|
|
10
11
|
// mechanical commands like `liner setup-js`, `liner compile`, and `liner status`.
|
|
@@ -106,7 +107,11 @@ const CLI_COMMANDS = new Set(
|
|
|
106
107
|
),
|
|
107
108
|
);
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
// Help wins anywhere unless a command owns the arguments
|
|
111
|
+
// (`liner compile --help` and `liner uninstall --help` print their own help).
|
|
112
|
+
const HELP_ARGS = new Set(["--help", "-h", "help"]);
|
|
113
|
+
const ownsHelp = CLI_COMMANDS.has(argv[0]) || argv[0] === "uninstall";
|
|
114
|
+
if (argv.length > 0 && !ownsHelp && argv.some((arg) => HELP_ARGS.has(arg))) {
|
|
110
115
|
printHelp();
|
|
111
116
|
process.exit(0);
|
|
112
117
|
}
|
|
@@ -145,6 +150,9 @@ if (wantsCli(argv)) {
|
|
|
145
150
|
}
|
|
146
151
|
process.exit(code ?? 1);
|
|
147
152
|
});
|
|
153
|
+
} else if (argv.length > 0) {
|
|
154
|
+
printUnknownCommand(argv[0]);
|
|
155
|
+
process.exit(2);
|
|
148
156
|
} else {
|
|
149
157
|
const tui = (process.env.LINER_TUI || "go").toLowerCase();
|
|
150
158
|
if (tui !== "go") {
|
|
@@ -454,13 +462,13 @@ function readTuiVersion() {
|
|
|
454
462
|
|
|
455
463
|
function printHelp() {
|
|
456
464
|
const lines = [
|
|
457
|
-
"Liner —
|
|
465
|
+
"Liner — a personal library of reusable research.",
|
|
458
466
|
"",
|
|
459
467
|
"Usage:",
|
|
460
|
-
" liner Open the
|
|
468
|
+
" liner Open the navigator",
|
|
461
469
|
" liner <command> [options] Run a command",
|
|
462
470
|
"",
|
|
463
|
-
"liner with no arguments opens the
|
|
471
|
+
"liner with no arguments opens the navigator.",
|
|
464
472
|
"Run `liner <command> --help` for detailed command help.",
|
|
465
473
|
"",
|
|
466
474
|
];
|
|
@@ -479,6 +487,34 @@ function printHelp() {
|
|
|
479
487
|
console.log(lines.join("\n"));
|
|
480
488
|
}
|
|
481
489
|
|
|
490
|
+
// A typo such as `liner compil` used to open the navigator silently. Name the
|
|
491
|
+
// closest command instead, when one is a likely match.
|
|
492
|
+
function printUnknownCommand(name) {
|
|
493
|
+
const known = [...COMMAND_GROUPS.flatMap((group) => group.commands.map((command) => command.name)), "--help"];
|
|
494
|
+
const typed = name.toLowerCase();
|
|
495
|
+
const suggestion = known
|
|
496
|
+
.map((command) => ({ command, distance: editDistance(typed, command) }))
|
|
497
|
+
.filter(({ command, distance }) => distance <= Math.max(1, Math.floor(command.length / 3)))
|
|
498
|
+
.sort((a, b) => a.distance - b.distance)[0];
|
|
499
|
+
const lines = [`Unknown command: ${name}`];
|
|
500
|
+
if (suggestion) lines.push(`Did you mean \`liner ${suggestion.command}\`?`);
|
|
501
|
+
lines.push("Run `liner --help` for the commands, or `liner` alone to open the navigator.");
|
|
502
|
+
console.error(lines.join("\n"));
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function editDistance(a, b) {
|
|
506
|
+
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
507
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
508
|
+
const current = [i];
|
|
509
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
510
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
511
|
+
current.push(Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost));
|
|
512
|
+
}
|
|
513
|
+
previous = current;
|
|
514
|
+
}
|
|
515
|
+
return previous[b.length];
|
|
516
|
+
}
|
|
517
|
+
|
|
482
518
|
// Like resolveCliBinary() but non-fatal: returns null instead of exiting when
|
|
483
519
|
// no core binary is found, so `--version` still prints the TUI version on a
|
|
484
520
|
// host where the bundled core is missing (e.g. Windows pre-unblock).
|
|
@@ -498,5 +534,5 @@ function printVersion() {
|
|
|
498
534
|
coreVer = r.stdout.trim().replace(/^liner\s+/i, "") || null;
|
|
499
535
|
}
|
|
500
536
|
}
|
|
501
|
-
console.log(coreVer ? `liner ${tui} (tui)
|
|
537
|
+
console.log(coreVer ? `liner ${tui} (tui) · ${coreVer} (core)` : `liner ${tui} (tui)`);
|
|
502
538
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linersh",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Liner — npm launcher for the terminal navigator and Core CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"test": "vitest run"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"linersh-darwin-arm64": "1.2.
|
|
45
|
-
"linersh-darwin-x64": "1.2.
|
|
46
|
-
"linersh-linux-arm64": "1.2.
|
|
47
|
-
"linersh-linux-x64": "1.2.
|
|
48
|
-
"linersh-win32-x64": "1.2.
|
|
44
|
+
"linersh-darwin-arm64": "1.2.1",
|
|
45
|
+
"linersh-darwin-x64": "1.2.1",
|
|
46
|
+
"linersh-linux-arm64": "1.2.1",
|
|
47
|
+
"linersh-linux-x64": "1.2.1",
|
|
48
|
+
"linersh-win32-x64": "1.2.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.10.0",
|
|
52
52
|
"typescript": "^5.7.2",
|
|
53
|
-
"vitest": "^4.1.
|
|
53
|
+
"vitest": "^4.1.12"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=18"
|