Files
deepseek-harness/packages/util/home-paths
Turtle 38c7a9fbf4 feat(release): publish package source, declaration maps, and documentation (#5884)
* feat(release): publish package source, declaration maps, and documentation

Every release member publishes its TypeScript source and the declaration
maps that resolve into it, and @deepseek-ai/dsh publishes the repository
Markdown documentation staged from docs/ at prepack time.

The ./src/* export most members already declared now resolves for an
installed consumer, and a consumer editor follows a declaration to the
implementation. Bundled JavaScript maps stay unpublished; the vendored
family and the Desktop runtime file policy are unchanged.

Rationale: .agents/notes/implemented/process/2026-10-08-published-source-and-docs.md

* feat(release): publish JavaScript maps and compress bundles

Every emitted JavaScript map ships beside the bundle it describes, and the
workspace build and the client preset compress bundles without mangling
identifiers.

The documentation payload now mirrors the website publication manifest and
is removed again by `postpack`; Desktop and the Python executable exclude
the published source, documentation, and maps; `clean` removes a staged
copy. Typert's publication contract gains the Remote declaration map.

* fix(release): keep node bundles readable for the worker image

The browser worker image lowers `yield*` only as a whole statement and
rewrites `for await` loops by their source layout, so compressed node-side
entries either fail that lowering or lower to unparseable code. Only the
browser bundles keep compression, which removes about a third of their text.

The bundle-purity assertion now matches the module-loader call regardless of
the quote style compression picks, and the release-pack fixture exercises
the installed package's new documentation requirement.

* feat(release): publish the whole documentation tree

`@deepseek-ai/dsh` copies `docs/` in full instead of the website's page
set: the maintainer documents, the generated migration records, the
translation guidelines, and the `*.i18n.yaml` consistency records ship
with the installed package, so the documentation's own links resolve
without a checkout.

* feat(release): publish the upgrade guides with the documentation

The staged documentation keeps the website's page set and adds every
`docs/upgrade-guide/` document, which is what an installed reader consults
when a released change breaks something. The rest of the maintainer tree
stays out.

* test(release): expect source and maps in master's new payload cases

* feat(release): keep installed docs and source readable in Desktop

Desktop keeps the published src/ and docs/ trees inside app.asar, and
every model shell call receives DSH_INSTALL_DIR and DSH_NODE_EXECUTABLE
so an agent can read them through Electron's Node mode. Staging also
generates docs/upgrade-guide/README.md, an index of the upgrade guides
grouped by the release they upgrade from.

Minified client bundles print string literals with backticks: the
worker image packer now recognizes those chunk requests, client license
banners are prepended after minification so their text survives, and
the affected artifact tests accept either quote.

* test(desktop): read archived docs through the Windows PowerShell form

Regenerate the config catalog for the shifted shell-env source line.

* test(desktop): wait for the GUI-subsystem Electron process from PowerShell

* build(release): publish source and maps from the message-quotes package

* build(release): publish source and maps from packages new on master

* build(release): publish source and maps from the tool-office package
2026-11-05 00:22:36 +08:00
..

description, kind
description kind
Shared resolution of the DeepSeek Harness home and the shared agent configuration root, plus user-data paths, tilde expansion, and stable watch paths. package-library

@deepseek-ai/dsh-home-paths

English | 中文

Summary

@deepseek-ai/dsh-home-paths lets package authors resolve the DeepSeek Harness data root and the shared agent configuration root their consumers read. An explicit path wins over the environment variable, which wins over the default under the operating-system home; blank environment values are ignored. Its public helpers can render a root without revealing an absolute machine path, expand only bare or current-user tilde forms, and canonicalize watch targets whose final components do not yet exist. Use it as a direct library dependency, not through cordis.yml.

Table of Contents


Use this package

Use these helpers wherever a package must agree with the rest of the harness about where user data lives: resolve the home once, then derive every child path from it.

Resolving the home

import { resolveDshHome, dshHomePath, dshCachePath } from '@deepseek-ai/dsh-home-paths'

const home = resolveDshHome()                // configured path, else $DSH_HOME, else ~/.dsh
const settings = dshHomePath('settings')     // join one child onto the resolved home
const cache = dshCachePath('models')         // $DSH_HOME/cache/models, default ~/.dsh/cache/models

An explicit configured path has the highest precedence, then $DSH_HOME, then the default ~/.dsh. An empty or whitespace-only $DSH_HOME is treated as unset, so a blank override never resolves the home to the current working directory.

dshCachePath(...segments) derives paths from the resolved home's cache directory. With no segments it returns the cache directory itself. Pass an initial options object, dshCachePath({ dshHome: home }, ...segments), to use an explicit configured home with the same precedence and tilde expansion. It returns an absolute path without creating directories.

Resolving the shared agents root

import { resolveAgentsHome, agentsHomeDisplay } from '@deepseek-ai/dsh-home-paths'

const agents = resolveAgentsHome()   // configured path, else $DSH_AGENTS_HOME, else ~/.agents
agentsHomeDisplay(agents)            // ~/.agents, or $DSH_AGENTS_HOME for any configured root

resolveAgentsHome applies the same precedence, blank-value handling, and tilde expansion as resolveDshHome. The root is deliberately outside $DSH_HOME because other agent tools share it; dsh-agent-instructions reads its user-global AGENTS.md, and dsh-skill-filesystem scans its skills/ directory.

Displaying a home

For user-facing paths, render a root symbolically rather than as a machine path: the default harness home displays as ~/.dsh, any configured harness home as $DSH_HOME, the default shared agents root as ~/.agents, and any configured shared agents root as $DSH_AGENTS_HOME. Neither display form leaks an absolute machine path.

Expanding user paths

expandHomePath expands a leading ~, ~/, or ~\ against the operating-system home and leaves everything else untouched — non-tilde paths and named-user forms such as ~alice/... pass through unchanged.

Canonicalizing watch paths

canonicalizeWatchPath gives a native filesystem watcher one canonical spelling of its target: the deepest existing ancestor is resolved through realpath and any missing suffix is restored, so a file or directory can be watched before it is created. This prevents Windows from treating a regular-file ancestor as ordinary absence, and prevents 8.3 short-name aliases from mixing with the long paths the native watcher backend emits.


Understand the implementation

Implementation internals — click to expand

The package is built on one principle: harness user data lives under one root, and the shared agent configuration root stays separate because other agent tools read it too. resolveRoot and rootDisplay own the precedence and display rules for both roots, so neither can drift from the other.

Source map

File Role
src/index.ts Home resolution, path joining, display, tilde expansion, and watch-path canonicalization

Resolution rules

resolveDshHome reads the explicit override, then $DSH_HOME, then falls back to the operating-system home joined with .dsh. resolveAgentsHome reads the same three levels for $DSH_AGENTS_HOME and ~/.agents. The chosen value is tilde-expanded and normalized to an absolute path; dshHomePath joins child segments with Node's platform path rules. dshHomeDisplay and agentsHomeDisplay compare the resolved path against the default root and return the symbolic label, so a configured root never leaks its absolute path.

Canonicalization mechanics

canonicalizeWatchPath walks up from the target until it finds an existing ancestor, resolves it with realpath, proves it is an enumerable directory, and restores the missing suffix. Errors other than absence propagate, and a missing-suffix ancestor that is not a directory is rejected.


Further Exploration

Read these pages when you need the launcher or the consumers that depend on a single home root.


Known Limitations and Deferred Work

These limits define when the helpers are not the right tool. They are current package constraints, not a task backlog.

  • Expansion is deliberately narrow — only bare ~, ~/..., and ~\... use the current operating-system home; named-user forms such as ~alice/..., environment variables, and shell expressions remain unchanged.
  • Canonicalization reads but never mutates — canonicalizeWatchPath performs realpath probes and propagates errors other than absence; callers still own directory creation, permissions, and trust policy for the resulting path.

Dev Note

Working context for maintainers — click to expand

None.