@kowloonzh/dsh-tui 0.2.3-alpha.2.tui.1 → 0.2.3-alpha.2.tui.2
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 +6 -0
- package/lib/index.js +14 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,12 @@ The package depends on an exact release of [`@deepseek-ai/dsh`](https://www.npmj
|
|
|
21
21
|
installed with it, and starts that release's Host. Each `dsh-tui` version is built and tested
|
|
22
22
|
against the Host version it pins; `npm ls -g @deepseek-ai/dsh` shows which one.
|
|
23
23
|
|
|
24
|
+
On an older Node, `npm install -g @kowloonzh/dsh-tui` stops with
|
|
25
|
+
`No matching version found for @kowloonzh/dsh-tui@*`: every release is a semver prerelease
|
|
26
|
+
(it follows the Host version, such as `0.2.3-alpha.2.tui.1`), and npm passes over `latest`
|
|
27
|
+
when its engine range excludes the running Node. Upgrade Node; `npm install -g
|
|
28
|
+
@kowloonzh/dsh-tui@latest` installs anyway, but the Host then runs on an unsupported Node.
|
|
29
|
+
|
|
24
30
|
## Usage
|
|
25
31
|
|
|
26
32
|
```sh
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { appendFileSync, existsSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
2
|
import { format, promisify } from "node:util";
|
|
4
3
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
@@ -55970,22 +55969,29 @@ function unwrap(result, operation) {
|
|
|
55970
55969
|
const DSH_PACKAGE = "@deepseek-ai/dsh";
|
|
55971
55970
|
/**
|
|
55972
55971
|
* Locate the `dsh` executable of the installed `@deepseek-ai/dsh`.
|
|
55973
|
-
*
|
|
55972
|
+
*
|
|
55973
|
+
* Only the `node_modules` directories above this package are searched, never `NODE_PATH` or
|
|
55974
|
+
* the global folders: the Host must be the release installed with this TUI, not whichever
|
|
55975
|
+
* `dsh` the environment happens to expose.
|
|
55976
|
+
* @param from - URL of a file inside the package doing the lookup.
|
|
55974
55977
|
* @returns the absolute path of the `dsh` bin script.
|
|
55975
55978
|
* @throws {Error} when the package is not installed or declares no `dsh` bin.
|
|
55976
55979
|
*/
|
|
55977
55980
|
function resolveDshEntrypoint(from = import.meta.url) {
|
|
55978
|
-
|
|
55979
|
-
|
|
55980
|
-
manifestPath = createRequire(from).resolve(`${DSH_PACKAGE}/package.json`);
|
|
55981
|
-
} catch {
|
|
55982
|
-
throw new Error(`dsh-tui: ${DSH_PACKAGE} is not installed next to this package; reinstall @kowloonzh/dsh-tui`);
|
|
55983
|
-
}
|
|
55981
|
+
const manifestPath = findInstalled(dirname(fileURLToPath(from)), join(DSH_PACKAGE, "package.json"));
|
|
55982
|
+
if (manifestPath === void 0) throw new Error(`dsh-tui: ${DSH_PACKAGE} is not installed next to this package; reinstall @kowloonzh/dsh-tui`);
|
|
55984
55983
|
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
55985
55984
|
const bin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.dsh;
|
|
55986
55985
|
if (bin === void 0) throw new Error(`dsh-tui: ${DSH_PACKAGE} declares no dsh executable`);
|
|
55987
55986
|
return join(dirname(manifestPath), bin);
|
|
55988
55987
|
}
|
|
55988
|
+
function findInstalled(start, relative) {
|
|
55989
|
+
for (let directory = start;; directory = dirname(directory)) {
|
|
55990
|
+
const candidate = join(directory, "node_modules", relative);
|
|
55991
|
+
if (existsSync(candidate)) return candidate;
|
|
55992
|
+
if (dirname(directory) === directory) return void 0;
|
|
55993
|
+
}
|
|
55994
|
+
}
|
|
55989
55995
|
/**
|
|
55990
55996
|
* Run the TUI as the standalone `dsh-tui` command.
|
|
55991
55997
|
* @param options - command-line arguments and process facts; the entrypoint is resolved here.
|