/** * Reading Harness's own profile machinery: which profiles exist, which one * this process booted, and what each one composes. * * A Harness PROFILE is the layer above a preset. `dsh --profile ` boots * `$DSH_HOME/profiles/`, whose `package.json` carries the ordered * `dsh.profile.bundles` list; each bundle is an npm package declaring * `dsh.bundle.patch`, and the Host's composition is those patch layers applied * in order, then the profile's own `cordis.patch.yml`. Profiles PROVIDE * capabilities to the Host; presets (`/plugins`) EXPOSE them to an agent. * * Two Harness-owned facts are read here and nothing else is derived: * * ``` * ctx.dshHomePath('profiles') the profiles root — Harness's own home-path * service, provided by `boot()` before any entry * mounts, so this is the same directory the * launcher resolved * ctx.baseUrl the booted profile's own directory — `boot()` * anchors it at `dirname(rootConfigPath)`, and * the profile launcher passes * `/cordis.yml`, so this IS which * profile is running * ``` * * Deliberately NOT importing `@deepseek-ai/dsh-app-boot`, even though it * exports `resolveProfileDir`/`readProfileManifest`/`PROFILES_DIR`. That * package's own peer list is nine entries (four `cordis-plugin-*`, * `dsh-launch-environment`, `dsh-invariants`, `dsh-home-paths`, * `dsh-system-prompt`, `cordis`), and declaring them here would print * unmet-peer warnings for every profile that composes a frontend without the * launcher's boot graph — for helpers that, on the read side, amount to a * `JSON.parse` of a documented manifest. What this module reuses instead is * the SERVICE (`ctx.dshHomePath`) and the FORMAT, with every borrowed constant * named against its upstream definition below. Nothing here re-implements * bundle module resolution: the two directories a bundle can be installed in * are read in the order `profile.ts`'s own header documents, and a bundle * found in neither simply reports no version rather than being resolved by * some other route. * * Read-only by construction. Every mutation goes through `actions.ts`, which * shells out to `dsh plugin` — Harness's own package lifecycle — rather than * writing a manifest from here. * @module dshline/profiles/harness */ import type { Context } from '@deepseek-ai/cordis'; /** * Directory under the Harness home holding every profile. * * Mirrors `PROFILES_DIR` in `@deepseek-ai/dsh-app-boot`'s `profile.ts`. A * literal rather than an import for the reason in this module's header; if * Harness ever moves it, the `/profiles` browser reports an empty roster * rather than misbehaving, and the sibling-name check below fails closed. */ export declare const PROFILES_DIR = "profiles"; /** The user's own patch layer inside a profile directory. */ export declare const PROFILE_PATCH_FILENAME = "cordis.patch.yml"; /** * Harness's `dshHomePath` service: join segments onto the resolved Harness * home. Provided by `boot()` before any entry mounts. */ export type DshHomePath = (...segments: string[]) => string; /** One bundle layer of a profile, as its manifest and installed state report it. */ export interface BundleRow { /** The package name, exactly as `dsh.profile.bundles` lists it. */ readonly packageName: string; /** * The installed version, when a manifest for this package was found in one * of the two directories a bundle can live in. Absent is a fact, not a * failure: an in-box bundle listed by a profile template is not a * dependency, and a fresh profile that has never had `install` run has no * `node_modules` at all. */ readonly version: string | undefined; /** * Whether the profile's `dependencies` name this package. * * This is what `dsh plugin`'s own reconciliation keys removal on: a template * bundle is not a dependency and `remove` would not touch it. Presenting the * distinction is what keeps the browser from offering a removal Harness * would decline to perform. */ readonly managed: boolean; /** * Whether the resolved package still declares `dsh.bundle`, when a manifest * was found. Harness reconciles the layer list against exactly this fact. */ readonly declaresBundle: boolean | undefined; } /** * One dependency of a profile that is NOT one of its bundle layers. * * Shown because "installed but inert" is otherwise invisible, and it is a state * a reader reaches easily: `dsh plugin` reconciles the layer list against the * INSTALLED state, so a package that declares no `dsh.bundle` is installed as * an ordinary dependency and contributes no patches. Harness warns about it * once, on stderr, at install time — after which nothing on screen explains why * the thing that was just installed changed nothing. */ export interface PlainDependencyRow { /** The package name, as `dependencies` lists it. */ readonly packageName: string; /** The installed version, when a manifest for it was found. */ readonly version: string | undefined; /** * Whether the installed copy declares `dsh.bundle` after all. `true` here * means the layer list is STALE — Harness reconciles on its next run, and * that reconciliation is skipped when pnpm exits non-zero. */ readonly declaresBundle: boolean | undefined; } /** One profile directory, as Harness's own machinery would load it. */ export interface ProfileRow { /** The profile name; its directory basename, and the `--profile` argument. */ readonly name: string; /** Absolute profile directory. */ readonly dir: string; /** Whether this is the profile the running Host booted. */ readonly current: boolean; /** The ordered bundle layers, or empty when the manifest declares none. */ readonly bundles: readonly BundleRow[]; /** * Dependencies that are not bundle layers. Empty for most profiles; a * mistyped or not-yet-a-bundle install is exactly what puts one here. */ readonly plain: readonly PlainDependencyRow[]; /** * Packages whose build script pnpm is waiting on a decision about. * * pnpm will not run a dependency's install-time build script unattended: it * writes a placeholder per package into the profile's `pnpm-workspace.yaml` * and fails every operation until each is a real boolean. Read here so the * state is visible BEFORE an operation is attempted, rather than only in the * error of the one that hit it. */ readonly pendingBuilds: readonly string[]; /** * Why this profile could not be read, when it could not. A directory under * the profiles root with an unreadable or non-object manifest is still shown * — it occupies its name, so hiding it would leave a profile that cannot be * created and cannot be seen. */ readonly broken: string | undefined; } /** What one pass over the profiles root found. */ export interface ProfilesReading { /** Absolute profiles root (`$DSH_HOME/profiles`). */ readonly root: string; /** Every profile directory, ordered by name. */ readonly profiles: readonly ProfileRow[]; /** * The profile this Host booted, when it could be determined from * `ctx.baseUrl`. Undefined means dshline cannot say — never a guess, since * every mutation is addressed by profile name and acting on the wrong one * would edit a composition nobody asked about. */ readonly currentName: string | undefined; } /** * Read Harness's `dshHomePath` service off a context. * @param ctx - the plugin context. * @returns the service, or undefined when this deployment provides none. */ export declare function dshHomePathOf(ctx: Context): DshHomePath | undefined; /** * The profile this process booted, from the Loader's own base URL. * * `boot()` sets `ctx.baseUrl` to `dirname(absoluteConfigPath)`, and the * profile launcher's config path is `/cordis.yml`, so the base * URL's directory IS the running profile's directory. Verified against the * profiles root rather than trusted: a deployment booting a config from * somewhere else entirely (a bare `boot()` embedder, a test) has a perfectly * valid `baseUrl` that names no profile, and answering with its basename would * invent one. * @param ctx - the plugin context. * @param root - the absolute profiles root. * @returns the profile name, or undefined when this Host booted no profile. */ export declare function currentProfileName(ctx: Context, root: string): string | undefined; /** * Read every profile under the Harness home, and which one is running. * * Unmemoized, like every other reading in this frontend: a profile directory * is created by `dsh plugin` (possibly by the action this browser just ran) * and a held copy is how a browser disagrees with the filesystem. * @param ctx - the plugin context, for `dshHomePath` and `baseUrl`. * @returns the reading, or undefined when no `dshHomePath` service is provided. */ export declare function readProfiles(ctx: Context): Promise; //# sourceMappingURL=harness.d.ts.map