* feat(system-prompt): admit section updates incrementally * docs(system-prompt): accept retirement restart gap * test(system-prompt): cover retirement and reentry before admission * test(system-prompt): align rebase fixtures and persistence history * fix: align section prompt consumers and CI fixtures * test: pin credentials for section snapshot fixtures * test: align remaining snapshots with section admission * test: preserve section metadata in Web and PowerShell replays * refactor(system-prompt): retire sections through Cordis cleanup * chore: refresh section admission history after rebase * fix(system-prompt): advance admission head after compaction * fix(system-prompt): trim sections before admission hashing * docs: move system upgrade guides to current version * docs: add system message contribution cookbook * perf(system-prompt): avoid indexing history for admission * refactor(system-prompt): derive admission from logged sections * test(system-prompt): update lifecycle and compaction consumers * test(system-prompt): refresh CLI section event expectations * test(system-prompt): refresh question composer section metadata * feat(system-prompt): resolve same-name sections by scope * refactor(persona): use ordinary section registrations * refactor(system-prompt): clarify assembly and related control flow * test(system-prompt): reconcile rebased section snapshots * test(python): use current system text helper after rebase * test(system-prompt): refresh CLI expected section blocks * test(system-prompt): reconcile latest master integration * test(agent-loop): seed tools before deferred addition assertion * refactor(compaction): replace system heads when compacting prefixes * refactor(system-prompt): separate source text and notice attribution * fix(system-prompt): preserve legacy instructions in compaction snapshots * refactor(compaction): build system snapshots while reading the summary prefix * refactor(compaction): rebuild current system instructions * refactor(system-prompt): defer compaction rebuild to admission * refactor(system-prompt): remove redundant fixtures and setup * fix(plan-mode): announce committed user transitions * docs(system-prompt): reconcile section lifecycle and compaction design * refactor(system-prompt): consolidate projection version increments * fix(system-prompt): reconcile master integration and replay fixtures * docs(system-prompt): align upgrade guide with current release * refactor(system-prompt): make admission operations explicit * fix(system-prompt): reconcile master API and release changes * docs(system-prompt): regenerate catalogs after master refresh * refactor(llm-pi-ai): delegate text rendering to pi-ai * fix(llm-pi-ai): preserve blank lines between system text parts * refactor(system-prompt): remove redundant retirement metadata * refactor(system-prompt): own admission and use canonical surface targets * refactor(system-prompt): compare captured sections at commitment Assembly fixes section text and lifecycle; PromptAssembly.systemUpdates() compares them with the committed projection when the loop commits. This replaces SystemPrompt.admit(), needsRebuild() and isCurrent(), the SystemAdmission export, the loop's reassembly after compaction, and SessionSurface.systemHeadResetSeq. The projection records a pending rebuild as a boolean that an attributed reset clears. After a compaction inside a step, the rebuilt head uses the sections captured for that step; later source changes arrive as ordinary updates at the next step. * test: await the session read fixture and type a matcher for lint * test(tool-executor-ptc): describe same-name section override on executor replacement Duplicate section names no longer reject a scoped executor; the earlier registration is overridden and returns as an ordinary update when the executor leaves. * docs(upgrade-guide): move system-prompt integrations to v0.2.2-rc.3 The root version on master is 0.2.2-rc.3; verify-upgrade-guides rejects a guide added under an earlier version directory. * refactor(system-prompt): rebuild over system messages without sections A system message without source.sections now marks rebuilding pending, like a compaction summary. The next model attempt replaces the head with current sections and clears later system messages. This removes the separate legacy flag and its appended whole-prompt replacement and notice. Sessions written by earlier releases, migrated logs, and imported DeepSeek conversations take the same path, so the importer and its tests return to their master versions. * test(web): refresh the imported-conversation recording and drop a stray bytecode file The Web recording for a resumed DeepSeek import was recorded while the prompt was appended after the imported history; the head is replaced again, as on master. The .pyc under the macOS signing skill was staged by accident in an earlier merge. * refactor(session): scan system nodes on read surface.systemNodes is read only when a system rebuild is written. Scanning the current surface nodes on each read restores the surface fold's plan types and state to their master definitions, which no longer carry the system message. * refactor(session): rename SystemSurfaceNode.hasContent to isEmpty The flag reports that the logged content array has no blocks. isEmpty matches the documented "empty head" wording and covers a head that was written empty without ever being cleared. * refactor(llm): join system text through extractTextContent extractTextContent gains a trim option that trims each text block and omits blocks left empty. The DeepSeek serializer, the pi-ai converter, and the prompt inspector use it with a blank-line separator in place of three hand-written joins. The pi-ai converter now trims system and developer text like the other two, so whitespace-only blocks are omitted there as well. * test(snapshots): refresh the PowerShell and cordis-inspect recordings The two PowerShell scenarios still held the initial system message as one unattributed block; replay now writes one block per section with its attribution. The cordis-inspect-jsdoc recording embeds the API catalog, which names SystemSurfaceNode.isEmpty since the rename. * test(plan-mode,harness-dev-context): cover a rejected pre-step and a repeated legacy prompt A rejected pre-step must leave a queued plan-mode switch pending and unannounced until the next accepted step. A second unattributed system message with the same legacy paragraphs must keep the admitted paragraphs. * test(web): refresh Web recordings for section-attributed system messages Twenty-seven Web recordings still held the initial system message as one unattributed block. Replay now writes one text block per section with its attribution; twenty-six recordings differ only in that line. plan-review also records the plan-mode switch notice before the first prompt and appends a plan:status update on exit in place of a head replacement and a series header, so its expanded golden gains the notice row. The Creator persona test joins the system text blocks with blank lines, as the adapters do, before matching the persona line. * refactor(system-prompt): require the retry argument of systemUpdates The agent loop passes it on every attempt. A custom loop that omitted it on a retry received a full comparison in place of the pending rebuild, with no diagnostic; the type now makes each caller state which attempt it is. * docs(upgrade-guide): move the system prompt integrations guide to v0.2.2-rc.5 The root version is 0.2.2-rc.5 after the master merge, and verify-upgrade-guides rejects a guide added under an earlier version directory. * test(web): refresh the mention path presence recording for section-attributed system messages * test: align two specs that master left failing The DeepSeek settings spec waited for a saved notice carrying the provider label from before the rename to DeepSeek API. The Windows packaging workflow spec seeded one of the two helpers that the Stage workflow helpers step copies. * chore: remove a Python cache file committed by mistake
description, kind
| description | kind |
|---|---|
| Register a CLI app plugin's vendor CLI and account with the Host Service `ctx.cliAccounts`: the model gets the CLI's absolute path in runtime context, account operations run one at a time through bounded commands, and the account appears on the Plugins page. | package-reference |
@deepseek-ai/dsh-cli-account
English | 中文
Summary
CLI app plugins such as Feishu and WeCom register their vendor CLI and its account once with ctx.cliAccounts. The model then reads the CLI's absolute path in runtime context, and the Plugins page shows the account with the plugin's own text. The Service runs the plugin's account operations one at a time, gives each command a deadline and an output limit, and passes authorization links to the page only from the hosts the plugin trusts. Each plugin keeps its own commands, parsing, and account states. The base bundle loads the Service, which does nothing until a plugin registers.
Table of Contents
- Use this package
- Understand the implementation
- Further Exploration
- Model Experience
- Known Limitations and Deferred Work
- Dev Note
Use this package
A CLI app plugin's Host row injects cliAccounts and calls register once; the registration lasts until the plugin unloads or disposes the returned handle.
When to choose it
Register from the Host row of a plugin whose vendor CLI signs the user in and keeps the credentials, so DSH only starts commands, shows their results, and owns their processes. A plugin that connects a hosted service over MCP uses the MCP manager instead, which owns OAuth itself. The Service shows each account through ctx.connectorAccounts from @deepseek-ai/dsh-client-ui-connector-account, which a plugin without a vendor CLI registers with directly.
Minimal configuration
The base bundle loads the Service in every profile built on it, beside the subprocess and systemPrompt services it injects:
- id: cli-account
name: '@deepseek-ai/dsh-cli-account'
| Field | Default | Meaning |
|---|---|---|
commandTimeoutMs |
30000 |
Deadline in milliseconds for a command that does not wait for the user, including executable lookup; it applies to every registered CLI |
The generated configuration catalog is the exhaustive source for every accepted field. A value below 1 or above 2147483647 fails at load.
Register a CLI and its account
The plugin's Host row lists cliAccounts in inject and registers from apply:
import type { Context } from '@deepseek-ai/cordis'
import type { CliAccountRegistration } from '@deepseek-ai/dsh-cli-account'
interface Account { readonly state: 'unchecked' | 'out' | 'in' }
const dictionaries = {
en: { title: 'Vendor account', hint: 'The account vendor-cli keeps.', connect: 'Connect', in: 'Connected', out: 'Not connected' },
zh: { title: 'Vendor 账号', hint: 'vendor-cli 保管的账号。', connect: '连接', in: '已连接', out: '未连接' },
}
const registration: CliAccountRegistration<Account, 'check', never, 'status', keyof typeof dictionaries.en> = {
name: 'vendor',
packageName: '@acme/dsh-vendor',
cli: { product: 'Vendor', program: 'vendor-cli', executable: '/opt/vendor/bin/vendor-cli' },
account: { state: 'unchecked' },
check: 'check',
cancellable: [],
authorizationHosts: ['vendor.example'],
async perform(_kind, control, signal) {
const result = await control.run('status', ['auth', 'status'], signal)
if (result.exitCode !== 0) throw new Error('vendor-cli: auth status failed')
control.publish({ state: result.stdout.trim() === 'authorized' ? 'in' : 'out' })
},
dictionaries,
operations: () => [{ kind: 'check' }],
copy: text => ({ title: text('title'), hint: text('hint'), activation: { title: text('title'), body: text('hint'), connect: text('connect') } }),
present: (view, text) => view.account.state === 'in'
? { phase: 'connected', status: text('in'), buttons: [], notes: [] }
: { phase: 'disconnected', status: text('out'), buttons: [], notes: [] },
}
export const inject = ['cliAccounts']
export function apply(ctx: Context): void {
ctx.cliAccounts.register(registration)
}
register adds the CLI's path to runtime context, runs perform for one operation at a time, and shows the account on the Plugins page while connectorAccounts is loaded; a composition without that registry, such as a headless profile, gets the first two. The registration belongs to the plugin whose ctx made the call. Unloading that plugin removes the account from the Plugins page, cancels the active operation, waits for it and for the CLI processes it started, and then removes the runtime-context entry. A second registration under one name throws and leaves the first in place.
nameis the plugin's short name: the prefix of its errors and log records, and the stem of its runtime-context name<name>:cli.packageNameis the npm package whose Plugins page shows the account.clinames the product, the program, and the absolute path of the executable that the model and the operations both run.accountis the account before the first check, andcheckis the operation the page starts for each new subscriber when none runs.perform(kind, control, signal)carries out one operation:control.runruns one command of the CLI,control.stageenters a phase of the plugin,control.offeroffers an authorization link to the page, andcontrol.publishreplaces the account.operations(text)lists the operations a page button may start,copy(text)writes the fixed text of the account section, andpresent(view, text)maps the current view to what the section shows.text(key, params)writes one key ofdictionariesin every language they hold and fills each{name}placeholder fromparams; the browser resolves the result in its active language.
The returned handle serves the plugin outside an operation: snapshot() returns the current CliAccountView, publish(account) replaces the account, refresh() starts a check unless an operation already runs, and dispose() withdraws the registration before the plugin unloads. The JSDoc in src/types.ts states each member's exact behavior.
Runtime context
register adds one required runtime-context entry, named <name>:cli, that tells the model to run cli.program by cli.executable, the path the operations' commands run. With cli.scripts, it also tells the model to put the executable's directory first on PATH only in the commands that run the skill's scripts, and never to run cli.program by name. The text follows the shell that shipped compositions give the model on the Host platform. Outside Windows it uses POSIX shell syntax: the prefix is PATH="<executable directory>:$PATH", which changes PATH for that command only, and the text also forbids exporting PATH. On Windows, where the model runs PowerShell, it names the executable with the call operator, & '<executable>', and gives the prefix as $env:PATH = '<executable directory>;' + $env:PATH, which lasts only for that call because each PowerShell call runs in a fresh process. With cli.ready, the entry contributes nothing while ready() returns false. The text is never interpolated. Model Experience shows the text.
Commands, links, and failures
A command that does not wait for the user gets the Service's commandTimeoutMs, including executable lookup; a command run with awaitsUser waits up to 10 minutes. control.run returns at most 1 MiB of stdout and the last 4 KiB of stderr, both counted in UTF-8 bytes and the tail cut at a character boundary, and settles only after the process exits. It reads the pipes until they close, at most until 2 seconds after the subprocess runtime reports the exit, so the result does not wait for a descendant that inherited them to close them; what the descendant writes after that is dropped. onLine receives each line as the command writes it: \n, \r\n, and a lone \r each end a line, as in Node's readline, so a spinner the CLI redraws with \r after a link line does not hold the link back. The unterminated rest arrives at exit, and a line longer than its stream's limit is skipped whole rather than truncated. No line arrives after the command settles. A command rejects instead of returning its exit code when executable lookup or spawning fails, the deadline elapses, the process ends by a signal, stdout exceeds 1 MiB, or onLine throws; an operation that then fails reports a null exit code.
control.offer(url) accepts only an HTTPS URL without credentials on one of the plugin's authorizationHosts or their subdomains, and returns whether it accepted the link. Write each host in lowercase ASCII, with an internationalized domain name in punycode, because the Service compares it with the URL's normalized host name. control.stage(phase) withdraws the current link, and the page can cancel an operation only in a phase listed in cancellable.
A failed operation returns only its last command and that command's exit code, { command, exitCode }, and its log record adds only the operation's id, kind, and phase; exception messages and native output are neither logged nor returned, because they may contain credentials. On the Plugins page, present writes the failure's text, and the Service adds the command and its exit code, such as login and exit 3, as the untranslated diagnostic items the page shows after that text.
Understand the implementation
Implementation internals — click to expand
The Service owns each registration's lifetime and the plugin owns the meaning of each command. register runs in the calling plugin's context, so the runtime-context entry, the account runtime, and the Plugins page registration are effects of that plugin, disposed with it in the reverse order. Each registration has one runtime, whose active operation holds its abort controller, phase, and link; the runtime builds the view from them and calls each observer after every change. Each registration also has one executor, which verifies the absolute path through the subprocess runtime and spawns it without adding environment variables; the runtime context names the same path, so the plugin's operations and the model's Shell commands run the same executable.
| File | Role |
|---|---|
src/executor.ts |
Bounded command execution and process ownership |
src/runtime.ts |
One-at-a-time operations, cancellation, link filtering, failure reporting, and observers |
src/context.ts |
The runtime-context entry that names the executable path |
src/text.ts |
The LocalizedText a plugin's presenter writes from its dictionaries |
src/types.ts |
The registration, operation control, handle, account view, command failure, and dictionary types |
src/index.ts |
The ctx.cliAccounts Service, its config, and register |
Further Exploration
- Connector packages — the group this package and the CLI app plugins belong to.
- Connector account surfaces — the Plugins page registry the Service registers each account with.
- System prompt — the registry that orders and renders runtime context.
- Subprocess — the runtime that resolves and spawns the CLI.
- Base bundle — the bundle that loads the Service, and how a profile overrides one of its rows.
Model Experience
CLI path
What the model sees
One required runtime-context entry, at context order 220, for each plugin registered with ctx.cliAccounts whose cli.ready is absent or returns true; it stays when optional runtime context is off. The second line appears only with cli.scripts. The placeholders come from the registration's cli. Outside Windows the quoted values are JSON strings; on Windows they are PowerShell single-quoted strings, in which a single quote is doubled. While no plugin is registered, the Service adds nothing to a model request.
Runtime-context entry
<Product> CLI: run `<program>` by its absolute path "<executable>"; the bare name may resolve to another installation or to none.
Scripts in the <Product> skill call `<program>` by name; prefix only the commands that run them with PATH="<executable directory>:$PATH", and never export PATH or run `<program>` by name yourself.
Runtime-context entry on Windows
<Product> CLI: run `<program>` by its absolute path with the call operator, & '<executable>'; the bare name may resolve to another installation or to none.
Scripts in the <Product> skill call `<program>` by name; start only the commands that run them with $env:PATH = '<executable directory>;' + $env:PATH, and never run `<program>` by name yourself.
Token effect
One or two lines in each runtime-context snapshot for each registering plugin. A changed path, or an entry that appears or disappears, adds one snapshot.
KV Cache effect
The path is runtime context rather than system prompt, so the cached prompt prefix is the same for every installation path; a change appends one runtime-context snapshot after it.
Known Limitations and Deferred Work
- The 10-minute deadline for commands that wait for the user and the 1 MiB stdout limit are fixed; a CLI whose sign-in waits longer fails with a retryable result.
commandTimeoutMsis one value for every registered CLI; a plugin cannot set a deadline of its own.- Authorization hosts match their subdomains too; a plugin cannot restrict links to one exact host.
- A failed operation reports only its last command and that command's exit code; a plugin cannot add an error code its CLI printed to the failure.
- The base bundle loads the Service whether or not a CLI app plugin is installed.
- The runtime context asks the model to run the CLI by its absolute path but cannot enforce it; a command that names the CLI by bare name runs whatever installation PATH resolves, or fails.
- The text's shell dialect follows the Host platform, not the mounted shell tool: a composition that gives the model a POSIX shell on Windows, or PowerShell elsewhere, gets the other platform's syntax.
Dev Note
Working context for maintainers — click to expand
None.