/** * What `/profiles` knows, as rows and decisions a terminal can draw. * * The one judgement this module makes that the filesystem does not is about * RESTART. A profile's bundle layers are composed when a Host boots; Harness * may re-apply a profile or bundle patch to a running Host at runtime (the * adopted generation's HMR service), while replacing an installed package's * module generation still needs a fresh process. This module owns no part of * that lifecycle: it drives `dsh plugin` in a subprocess and observes no * reload. What it knows is the scope of the operation it ran — a landed * mutation changes what the NEXT Host composes those files into — so it reports * each profile's restart claim from that scope rather than asserting what the * running process did or did not pick up. * * Switching profiles is not offered at all. A profile is chosen by the * launcher before any of this exists, and the composed tree that results is * what the running process serves; dshline builds no re-linking of its own on * top of whatever Harness reloads, which would be exactly the competing * lifecycle this frontend does not build. Another profile is presented, and the * command that boots it is named. * @module dshline/profiles/model */ import type { BundleRow, PlainDependencyRow, ProfileRow } from './harness.ts'; /** * One argument as it is safe to SHOW. * * Redaction is display-only: the launcher receives the argument verbatim, as * one argv element, because that is what the user asked to install. What is * not safe is writing it into the transcript, which outlives the overlay and * is exactly where a token pasted into a prompt would otherwise be preserved. * @param argument - the argument as typed. * @returns the argument, or a placeholder naming what was withheld. */ export declare function displayArgument(argument: string): string; /** * Single-quote one argument unless it plainly needs no quoting. * @param argument - the argument to render. * @returns the shell-safe rendering. */ export declare function shellQuote(argument: string): string; /** The mark a profile row earns. */ export type ProfileMark = '●' | '○'; /** * The glyph for one profile: filled for the profile this Host booted. * @param row - the profile row. * @returns the mark. */ export declare function profileMark(row: ProfileRow): ProfileMark; /** * The tags after a profile's name: which one is running, and whether it can * be read at all. * @param row - the profile row. * @returns the tags, most important first. */ export declare function profileTags(row: ProfileRow): string[]; /** * What to do about a profile whose operations pnpm is holding. * * The instruction, not the decision. Allowing a build script runs arbitrary * install-time code from a dependency, so this names the file, the packages, * and the two values — and stops there. Harness does not answer it either: it * seeds `pnpm-workspace.yaml` when a profile is created and never touches it * again. * @param row - the profile row. * @returns the instruction lines, or empty when nothing is pending. */ export declare function pendingBuildInstructions(row: ProfileRow): string[]; /** The mark a bundle row earns from its installed state. */ export type BundleMark = '✓' | '·' | '⚠'; /** * The glyph for one bundle layer. * * Three states, and the third is the one worth a mark: a package the profile * composes as a layer but whose installed copy declares no `dsh.bundle` * contributes no patches, and Harness's own reconciliation drops it from the * layer list on the next `dsh plugin` run. A bundle with no manifest found is * neither confirmed nor broken — an in-box template bundle is not a * dependency and a never-installed profile has no `node_modules` — so it gets * the neutral mark rather than a warning it has not earned. * @param row - the bundle row. * @returns the mark. */ export declare function bundleMark(row: BundleRow): BundleMark; /** * The right-hand facts for one bundle: its version, and anything unusual. * @param row - the bundle row. * @returns the facts, most useful first. */ export declare function bundleFacts(row: BundleRow): string[]; /** * The facts for one dependency that is not a bundle layer. * * Says what it IS rather than only what it is not: the common case is a package * that simply declares no `dsh.bundle`, which is a fact about that package and * not a mistake this browser should scold. The uncommon case — it DOES declare * one, so the layer list is stale — is the one worth pointing at, because * Harness reconciles on its next run and skips that when pnpm fails. * @param row - the dependency row. * @returns the facts, most useful first. */ export declare function plainDependencyFacts(row: PlainDependencyRow): string[]; /** Which `dsh plugin` operation a keystroke asks for. */ export type ProfileOperation = 'add' | 'update' | 'update-all' | 'remove' | 'remove-plain' | 'init'; /** * One operation, resolved into the `dsh plugin` arguments that perform it. * * These are pnpm's own subcommands, forwarded verbatim — `dsh plugin` is * documented as "a thin pnpm forwarder", and the reconciliation of * `dsh.profile.bundles` happens on ITS side afterwards. Nothing here invents * an install step, a version resolution rule, or a lockfile touch. */ export interface ResolvedOperation { /** The operation asked for. */ readonly operation: ProfileOperation; /** * Arguments after `dsh plugin --profile `, RAW. * * The only field carrying a package spec verbatim, because the launcher must * receive exactly what the reader asked to install. Nothing displays this * directly: `pluginCommand` runs it through `displayArgument` and * `shellQuote` first. */ readonly args: readonly string[]; /** * What to say while it runs — SAFE to display and to keep. * * Built through {@link displayArgument}, never from the raw spec, because * this string is the one that travels: it reaches the persistent activity * row, the success and failure messages, and the transcript row committed * when the browser closes over running work. A raw URL spec placed here * would bypass every other redaction in this domain by being a label rather * than an argument. */ readonly running: string; /** Whether success means the running Host is now out of date. */ readonly restartRequired: boolean; } /** * Resolve one operation into its `dsh plugin` arguments. * * `init` is `install` deliberately: `dsh plugin` initializes a profile * directory on first use for ANY invocation, so the way to create a profile is * to run a harmless command against it. There is no separate `init` * subcommand to call, and writing the manifest here instead would be a second * profile creator with its own idea of the template. * @param operation - the operation asked for. * @param packageName - the bundle it targets, where one applies. * @returns the resolved operation. */ export declare function resolveOperation(operation: ProfileOperation, packageName?: string, bundles?: readonly string[]): ResolvedOperation; /** Why an operation cannot be offered on a given row. */ export type OperationRefusal = /** It can be performed. */ { readonly kind: 'allowed'; readonly resolved: ResolvedOperation; } /** It cannot, and this is what to say. */ | { readonly kind: 'refused'; readonly reason: string; }; /** * Whether removing one bundle is an operation Harness would actually perform. * * `dsh plugin`'s reconciliation only removes a layer whose package was a * DEPENDENCY: "template bundles (dsh-base and friends) are not dependencies". * Offering `remove @deepseek-ai/dsh-base` would run pnpm, succeed at removing * nothing, and leave the layer exactly where it was — a button that reports * success and changes nothing is worse than one that explains itself. * @param row - the bundle row. * @returns whether removal applies, or why it does not. */ export declare function removeEligibility(row: BundleRow): OperationRefusal; /** * Whether updating one bundle applies. * * Same dependency rule as removal: pnpm updates what the manifest depends on, * and an in-box bundle moves when the dsh installation does. * @param row - the bundle row. * @returns whether an update applies, or why it does not. */ export declare function updateEligibility(row: BundleRow): OperationRefusal; /** * Whether "update every bundle" has anything to update. * * Only dependency-managed bundles can be updated by pnpm at all — an in-box * one moves when the dsh installation does — so the set this offers is exactly * the visible managed layers. An empty set is refused rather than turned into a * bare `pnpm update`, which would quietly widen the operation to every * dependency the profile has. * @param profile - the profile whose bundles to update. * @returns the operation, or why there is nothing to do. */ export declare function updateAllEligibility(profile: ProfileRow): OperationRefusal; /** * Whether an operation on this profile can be performed at all right now. * * A non-current profile is fully operable: `dsh plugin --profile ` is * addressed by name and never touches the running Host, which is exactly why * the restart note below talks about the NEXT boot rather than this one. What * is refused is naming no profile at all. * @param profile - the profile the operation targets, when one is selected. * @returns whether operations apply, or why they do not. */ export declare function profileOperable(profile: ProfileRow | undefined): { readonly ok: boolean; readonly reason: string; }; /** * How a landed operation affects the running Host. * * Named per profile, because the answer genuinely differs: a change to the * profile this Host booted means the process is now composing something older * than the file says, while a change to any other profile has no bearing on it * whatsoever. Reporting "restart required" for the second would be theatre. * @param resolved - the operation that landed. * @param profile - the profile it was performed on. * @returns the sentence to append, or undefined when nothing needs saying. */ export declare function restartNote(resolved: ResolvedOperation, profile: ProfileRow): string | undefined; /** * The command that boots one profile, for a reader who wants to switch. * * The honest answer to "make this profile current". A composed Host cannot * swap its bundle layers, so this is not a fallback for a switch that failed — * it is what switching profiles IS. * @param row - the profile to boot. * @returns the command line. */ export declare function bootCommand(row: ProfileRow): string; /** * Whether a typed name could be a new profile directory. * * The same containment rule `resolveProfileDir` enforces, for the same reason * it gives: the name becomes a path segment, so a separator or a dot-segment * would place the profile outside the root the deployment authorized. * `node_modules` is refused because the launcher's own flat module fallback * occupies that sibling name. * Judges the name as given. Callers that read one from a prompt trim its edges * first — see `performCreate` for why invisible leading and trailing spaces are * input handling rather than a narrowing of this rule. * @param name - the candidate profile name. * @returns whether Harness would accept it. */ export declare function validProfileName(name: string): boolean; /** * Whether a typed string could be a package spec `dsh plugin add` would accept. * * Deliberately permissive: pnpm accepts registry names, versioned names, * tarball URLs, git specs, and filesystem paths, and re-deciding that grammar * here would be a second package resolver that disagrees with the real one on * its first edge case. What is refused is only what cannot be an argument at * all — empty, or a leading dash that pnpm would read as a flag. * @param spec - the typed package spec. * @returns whether it is worth forwarding. */ export declare function plausiblePackageSpec(spec: string): boolean; /** * Apply a query to profile rows, preserving name order. * @param rows - the profile rows. * @param query - raw query text. * @returns the matching rows. */ export declare function filterProfileRows(rows: readonly ProfileRow[], query: string): readonly ProfileRow[]; //# sourceMappingURL=model.d.ts.map