dsh-model-extension 0.1.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/lib/index.js ADDED
@@ -0,0 +1,59 @@
1
+ import { createRequire } from "node:module";
2
+ import { readFileSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+ //#region src/index.ts
5
+ /**
6
+ * dsh-model-extension — host-side entry.
7
+ *
8
+ * The plugin registers a companion "Models+" settings page whose client half is
9
+ * built against the DeepSeek Harness `ui-settings-models` sources pinned by the
10
+ * adapter anchor below. Registration is all-or-nothing: when the running host
11
+ * version does not exactly match the anchor (or cannot be determined), the
12
+ * plugin logs and skips registration — the client bundle never loads because
13
+ * no slot is ever injected.
14
+ */
15
+ const ADAPTER_VERSION = "0.1.1-rc.2";
16
+ /** Cordis service name (distinct from the npm package name). */
17
+ const name = "model-extension";
18
+ /**
19
+ * Read the running host's version by resolving the installed CLI package's
20
+ * manifest.
21
+ *
22
+ * Node resolves symlinks by default, so the plugin module's real path is the
23
+ * project checkout — walking up from there never reaches the global tree.
24
+ * The resolution therefore starts at the *link* path under the profile
25
+ * node_modules (symlink not resolved), then falls back to this module's own
26
+ * real path. Both the global CLI package and its nested dsh-base are tried.
27
+ * @returns the version string, or undefined when unresolvable.
28
+ */
29
+ function readHostVersion() {
30
+ const candidates = [];
31
+ const dshHome = process.env.DSH_HOME;
32
+ if (dshHome !== void 0 && dshHome.length > 0) {
33
+ candidates.push(`${dshHome}/profiles/web/node_modules/dsh-model-extension/lib/index.js`);
34
+ candidates.push(`${dshHome}/profiles/node/node_modules/dsh-model-extension/lib/index.js`);
35
+ }
36
+ try {
37
+ candidates.push(fileURLToPath(import.meta.url));
38
+ } catch {}
39
+ for (const specifier of ["@deepseek-ai/dsh/package.json", "@deepseek-ai/dsh-base/package.json"]) for (const base of candidates) try {
40
+ const manifestPath = createRequire(base).resolve(specifier);
41
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
42
+ if (typeof manifest.version === "string") return manifest.version;
43
+ } catch {}
44
+ }
45
+ /**
46
+ * Host plugin body: register only on an exact version match.
47
+ * @param ctx - cordis context (logger available).
48
+ */
49
+ function apply(ctx) {
50
+ const hostVersion = readHostVersion();
51
+ if (hostVersion === void 0 || hostVersion !== ADAPTER_VERSION) {
52
+ ctx.logger?.warn(`[dsh-model-extension] host version ${hostVersion ?? "<unreadable>"} !== adapter anchor ${ADAPTER_VERSION}; plugin not registered`);
53
+ return;
54
+ }
55
+ }
56
+ //#endregion
57
+ export { apply, name };
58
+
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * dsh-model-extension — host-side entry.\n *\n * The plugin registers a companion \"Models+\" settings page whose client half is\n * built against the DeepSeek Harness `ui-settings-models` sources pinned by the\n * adapter anchor below. Registration is all-or-nothing: when the running host\n * version does not exactly match the anchor (or cannot be determined), the\n * plugin logs and skips registration — the client bundle never loads because\n * no slot is ever injected.\n */\nimport { createRequire } from 'node:module'\nimport { readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\n\n/** Adapter anchor, injected at build time from package.json `dsh.adapter`. */\ndeclare const __DSH_ADAPTER_VERSION__: string\nconst ADAPTER_VERSION: string = typeof __DSH_ADAPTER_VERSION__ === 'string'\n ? __DSH_ADAPTER_VERSION__\n : '0.0.0-unknown'\n\n/** Cordis service name (distinct from the npm package name). */\nexport const name = 'model-extension'\n\n/**\n * Read the running host's version by resolving the installed CLI package's\n * manifest.\n *\n * Node resolves symlinks by default, so the plugin module's real path is the\n * project checkout — walking up from there never reaches the global tree.\n * The resolution therefore starts at the *link* path under the profile\n * node_modules (symlink not resolved), then falls back to this module's own\n * real path. Both the global CLI package and its nested dsh-base are tried.\n * @returns the version string, or undefined when unresolvable.\n */\nfunction readHostVersion(): string | undefined {\n const candidates: string[] = []\n // Link path under the active profile's node_modules (symlink not resolved).\n const dshHome = process.env.DSH_HOME\n if (dshHome !== undefined && dshHome.length > 0) {\n candidates.push(`${dshHome}/profiles/web/node_modules/dsh-model-extension/lib/index.js`)\n candidates.push(`${dshHome}/profiles/node/node_modules/dsh-model-extension/lib/index.js`)\n }\n // Real path of this module (last resort).\n try {\n candidates.push(fileURLToPath(import.meta.url))\n } catch { /* ignore */ }\n\n for (const specifier of ['@deepseek-ai/dsh/package.json', '@deepseek-ai/dsh-base/package.json']) {\n for (const base of candidates) {\n try {\n const require = createRequire(base)\n const manifestPath = require.resolve(specifier)\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { version?: unknown }\n if (typeof manifest.version === 'string') return manifest.version\n } catch { /* next candidate */ }\n }\n }\n return undefined\n}\n\n/**\n * Host plugin body: register only on an exact version match.\n * @param ctx - cordis context (logger available).\n */\nexport function apply(ctx: { logger?: { warn(msg: string): void } }): void {\n const hostVersion = readHostVersion()\n if (hostVersion === undefined || hostVersion !== ADAPTER_VERSION) {\n ctx.logger?.warn(\n `[dsh-model-extension] host version ${hostVersion ?? '<unreadable>'} !== adapter anchor ${ADAPTER_VERSION}; plugin not registered`,\n )\n return\n }\n // Host-side behavior lives entirely in the client bundle; nothing to mount here.\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,kBAAA;;AAKN,MAAa,OAAO;;;;;;;;;;;;AAapB,SAAS,kBAAsC;CAC7C,MAAM,aAAuB,CAAC;CAE9B,MAAM,UAAU,QAAQ,IAAI;CAC5B,IAAI,YAAY,KAAA,KAAa,QAAQ,SAAS,GAAG;EAC/C,WAAW,KAAK,GAAG,QAAQ,4DAA4D;EACvF,WAAW,KAAK,GAAG,QAAQ,6DAA6D;CAC1F;CAEA,IAAI;EACF,WAAW,KAAK,cAAc,YAAY,GAAG,CAAC;CAChD,QAAQ,CAAe;CAEvB,KAAK,MAAM,aAAa,CAAC,iCAAiC,oCAAoC,GAC5F,KAAK,MAAM,QAAQ,YACjB,IAAI;EAEF,MAAM,eADU,cAAc,IACH,CAAC,CAAC,QAAQ,SAAS;EAC9C,MAAM,WAAW,KAAK,MAAM,aAAa,cAAc,MAAM,CAAC;EAC9D,IAAI,OAAO,SAAS,YAAY,UAAU,OAAO,SAAS;CAC5D,QAAQ,CAAuB;AAIrC;;;;;AAMA,SAAgB,MAAM,KAAqD;CACzE,MAAM,cAAc,gBAAgB;CACpC,IAAI,gBAAgB,KAAA,KAAa,gBAAgB,iBAAiB;EAChE,IAAI,QAAQ,KACV,sCAAsC,eAAe,eAAe,sBAAsB,gBAAgB,wBAC5G;EACA;CACF;AAEF"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "dsh-model-extension",
3
+ "version": "0.1.0",
4
+ "description": "DeepSeek Harness plugin: extended per-model LLM configuration (reasoning efforts, input modalities, compat flags) as a companion settings page",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./client": "./lib/client.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "lib",
14
+ "assets",
15
+ "cordis.patch.yml"
16
+ ],
17
+ "scripts": {
18
+ "build": "node scripts/build.mjs"
19
+ },
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/lovezi0/dsh-model-extension.git"
24
+ },
25
+ "publishConfig": {
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "dsh": {
29
+ "adapter": "0.1.1-rc.2",
30
+ "bundle": {
31
+ "patch": "./cordis.patch.yml"
32
+ },
33
+ "client": {
34
+ "platform": "web",
35
+ "inject": [
36
+ "@deepseek-ai/dsh-client-runtime",
37
+ "@deepseek-ai/dsh-client-ui-settings",
38
+ "@deepseek-ai/dsh-client-locale",
39
+ "@deepseek-ai/dsh-api-remotes"
40
+ ],
41
+ "external": [
42
+ "@deepseek-ai/dsh-api-remotes/client",
43
+ "@deepseek-ai/dsh-client-locale/client",
44
+ "@deepseek-ai/dsh-client-ui-settings/client"
45
+ ]
46
+ }
47
+ },
48
+ "peerDependencies": {
49
+ "@deepseek-ai/cordis": "*",
50
+ "@deepseek-ai/dsh-api-remotes": "*",
51
+ "@deepseek-ai/dsh-client-connection": "*",
52
+ "@deepseek-ai/dsh-client-locale": "*",
53
+ "@deepseek-ai/dsh-client-runtime": "*",
54
+ "@deepseek-ai/dsh-client-ui-settings": "*",
55
+ "@deepseek-ai/dsh-invariants": "*"
56
+ },
57
+ "devDependencies": {
58
+ "@tsdown/css": "^0.22.14",
59
+ "lightningcss": "^1.29.0",
60
+ "tsdown": "^0.22.14",
61
+ "typescript": "^5.7.0",
62
+ "yaml": "^2.9.0"
63
+ }
64
+ }