refactor: apply repository naming contract
Apply the accepted pre-release package, service, type, directory, and role renames as one repository-wide change.
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/context/tmux-context/README.md
|
||||
README.md: 59c452be53b8bb7cb7244a9bb2017749750ce4bf
|
||||
README.zh.md: 792000403f7757b8d5e35eb6fb6f543ad044b1eb
|
||||
README.md: 006d4b1e6d824fd255d745cba2ae78ae86eed751
|
||||
README.zh.md: e3e89f62fce3371e8f53f164f89ac5d08feb172c
|
||||
|
||||
@@ -17,7 +17,7 @@ Opt-in durable context naming the tmux session, window, and pane this agent proc
|
||||
|
||||
## How it reads tmux
|
||||
|
||||
The plugin prepends an `agent/pre-step` listener that runs only on the first step of each turn. When due, it runs one read-only command through the `ctx.bash` executor service:
|
||||
The plugin prepends an `agent/pre-step` listener that runs only on the first step of each turn. When due, it runs one read-only command through the `ctx.shell` executor service:
|
||||
|
||||
```sh
|
||||
[ -n "$TMUX_PANE" ] || exit 1
|
||||
@@ -27,7 +27,7 @@ pane_tty=$(tmux display-message -t "$TMUX_PANE" -p '#{pane_tty}') || exit 1
|
||||
exec tmux display-message -t "$TMUX_PANE" -p '<format>'
|
||||
```
|
||||
|
||||
`$TMUX_PANE` alone is insufficient: a terminal launched from a tmux shell (a VS Code integrated terminal, a desktop launcher) **inherits** `$TMUX` and `$TMUX_PANE` from that ancestor, so the variables are present even though the process does not live in that pane. The command therefore also compares the pane's `#{pane_tty}` against this process's own controlling terminal (`ps -o tty=` for its pid): a genuine pane owns this process's tty, while an inherited environment names some other pane's tty. Running through `ctx.bash` applies the deployment's sandbox and policy; the plugin owns no subprocess code. When `ctx.bash` is absent, the process is not in a real tmux pane (`$TMUX_PANE` unset, or the tty does not match ⇒ nonzero exit), or the reading is malformed, the attempt is a no-op, never an error. The location is optional, so an executor rejection — a policy refusal from `resolve()` or an infrastructure failure from `run()` — is contained and logged as a warning rather than failing the turn.
|
||||
`$TMUX_PANE` alone is insufficient: a terminal launched from a tmux shell (a VS Code integrated terminal, a desktop launcher) **inherits** `$TMUX` and `$TMUX_PANE` from that ancestor, so the variables are present even though the process does not live in that pane. The command therefore also compares the pane's `#{pane_tty}` against this process's own controlling terminal (`ps -o tty=` for its pid): a genuine pane owns this process's tty, while an inherited environment names some other pane's tty. Running through `ctx.shell` applies the deployment's sandbox and policy; the plugin owns no subprocess code. When `ctx.shell` is absent, the process is not in a real tmux pane (`$TMUX_PANE` unset, or the tty does not match ⇒ nonzero exit), or the reading is malformed, the attempt is a no-op, never an error. The location is optional, so an executor rejection — a policy refusal from `resolve()` or an infrastructure failure from `run()` — is contained and logged as a warning rather than failing the turn.
|
||||
|
||||
State is pulled on every eligible turn — a moved, renamed, or re-laid-out pane is picked up without any tmux hook or background process. The plugin re-injects only when the rendered tmux state differs from its last injection, so an unchanged location adds nothing.
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
## 如何读取 tmux
|
||||
|
||||
插件前置注册一个 `agent/pre-step` 监听器,仅在每轮的第一个步骤运行。当需要注入时,它通过 `ctx.bash` 执行器服务运行一条只读命令:
|
||||
插件前置注册一个 `agent/pre-step` 监听器,仅在每轮的第一个步骤运行。当需要注入时,它通过 `ctx.shell` 执行器服务运行一条只读命令:
|
||||
|
||||
```sh
|
||||
[ -n "$TMUX_PANE" ] || exit 1
|
||||
@@ -27,7 +27,7 @@ pane_tty=$(tmux display-message -t "$TMUX_PANE" -p '#{pane_tty}') || exit 1
|
||||
exec tmux display-message -t "$TMUX_PANE" -p '<format>'
|
||||
```
|
||||
|
||||
仅凭 `$TMUX_PANE` 并不足够:从 tmux shell 启动的终端(VS Code 集成终端、桌面启动器)会从该祖先进程**继承** `$TMUX` 与 `$TMUX_PANE`,因此即使进程并不位于那个 pane 中,这些变量依然存在。为此该命令还会把 pane 的 `#{pane_tty}` 与本进程自己的控制终端(对其 pid 执行 `ps -o tty=`)作比较:真正的 pane 拥有本进程的 tty,而继承而来的环境指向的是另一个 pane 的 tty。通过 `ctx.bash` 运行会应用部署方的沙箱与策略;插件不拥有任何子进程代码。当 `ctx.bash` 缺失、进程不在真实的 tmux pane 内(`$TMUX_PANE` 未设置,或 tty 不匹配 ⇒ 非零退出)或读取结果格式非法时,本次尝试为空操作,绝不报错。由于位置信息是可选的,执行器的拒绝——`resolve()` 的策略拒绝或 `run()` 的基础设施故障——会被兜住并记录为警告,而不会使该轮失败。
|
||||
仅凭 `$TMUX_PANE` 并不足够:从 tmux shell 启动的终端(VS Code 集成终端、桌面启动器)会从该祖先进程**继承** `$TMUX` 与 `$TMUX_PANE`,因此即使进程并不位于那个 pane 中,这些变量依然存在。为此该命令还会把 pane 的 `#{pane_tty}` 与本进程自己的控制终端(对其 pid 执行 `ps -o tty=`)作比较:真正的 pane 拥有本进程的 tty,而继承而来的环境指向的是另一个 pane 的 tty。通过 `ctx.shell` 运行会应用部署方的沙箱与策略;插件不拥有任何子进程代码。当 `ctx.shell` 缺失、进程不在真实的 tmux pane 内(`$TMUX_PANE` 未设置,或 tty 不匹配 ⇒ 非零退出)或读取结果格式非法时,本次尝试为空操作,绝不报错。由于位置信息是可选的,执行器的拒绝——`resolve()` 的策略拒绝或 `run()` 的基础设施故障——会被兜住并记录为警告,而不会使该轮失败。
|
||||
|
||||
状态在每个符合条件的轮次拉取——pane 被移动、改名或重新布局都会被感知,无需任何 tmux hook 或后台进程。插件仅在渲染出的 tmux 状态与上次注入不同时才重新注入,因此位置不变时不会新增任何内容。
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@deepseek-ai/dsh-agent": "workspace:^",
|
||||
"@deepseek-ai/dsh-bash": "workspace:^",
|
||||
"@deepseek-ai/dsh-shell": "workspace:^",
|
||||
"@deepseek-ai/dsh-invariants": "workspace:^",
|
||||
"@deepseek-ai/dsh-session": "workspace:^",
|
||||
"@deepseek-ai/cordis": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@deepseek-ai/dsh-agent": "workspace:^",
|
||||
"@deepseek-ai/dsh-bash": "workspace:^",
|
||||
"@deepseek-ai/dsh-shell": "workspace:^",
|
||||
"@deepseek-ai/dsh-invariants": "workspace:^",
|
||||
"@deepseek-ai/dsh-llm": "workspace:^",
|
||||
"@deepseek-ai/dsh-session": "workspace:^",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* and pane this agent process runs in, plus the window's pane-tree layout.
|
||||
*
|
||||
* The plugin pulls state once per turn, for the first request (`step === 1`), by
|
||||
* running one `tmux display-message` through the `ctx.bash` executor service. It
|
||||
* running one `tmux display-message` through the `ctx.shell` executor service. It
|
||||
* confirms this process genuinely runs inside the pane `$TMUX_PANE` names by
|
||||
* matching the pane's `#{pane_tty}` against this process's controlling terminal,
|
||||
* so a terminal that merely inherited `$TMUX`/`$TMUX_PANE` from a tmux ancestor
|
||||
@@ -12,7 +12,7 @@
|
||||
* only when the rendered tmux state changes since the last injection (a moved,
|
||||
* renamed, or re-laid-out pane), with an optional `refreshIntervalMs` floor
|
||||
* between injections. Absent tmux environment, an inherited-only environment,
|
||||
* absent `ctx.bash`, or a failed query is a no-op, never an error: an executor
|
||||
* absent `ctx.shell`, or a failed query is a no-op, never an error: an executor
|
||||
* rejection is contained and logged as a warning so the turn continues.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-tmux-context
|
||||
@@ -21,7 +21,7 @@
|
||||
import type { Context, LoggerService } from '@deepseek-ai/cordis'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import type { Agent, PreStepDecision } from '@deepseek-ai/dsh-agent'
|
||||
import type { BashExecutor, BashRunResult } from '@deepseek-ai/dsh-bash'
|
||||
import type { ShellExecutor, ShellRunResult } from '@deepseek-ai/dsh-shell'
|
||||
import { createUserMessage } from '@deepseek-ai/dsh-llm'
|
||||
|
||||
/** Cordis plugin name used by loader diagnostics. */
|
||||
@@ -105,7 +105,7 @@ const FIELD_SEP = '\\t'
|
||||
* @returns the parsed location, or `undefined` when not in a real pane or on any failure.
|
||||
*/
|
||||
async function queryTmuxLocation(
|
||||
bash: BashExecutor,
|
||||
bash: ShellExecutor,
|
||||
logger: LoggerService,
|
||||
processId: number,
|
||||
signal: AbortSignal,
|
||||
@@ -119,7 +119,7 @@ async function queryTmuxLocation(
|
||||
'[ "$pane_tty" = "/dev/$self_tty" ] || exit 1',
|
||||
`exec tmux display-message -t "$TMUX_PANE" -p '${format}'`,
|
||||
].join('\n')
|
||||
let result: BashRunResult
|
||||
let result: ShellRunResult
|
||||
try {
|
||||
result = await bash.run(bash.resolve({ command, signal }))
|
||||
} catch (error: unknown) {
|
||||
@@ -221,7 +221,7 @@ export function apply(ctx: Context, config: Config): void {
|
||||
): Promise<PreStepDecision> => {
|
||||
const decision = await next()
|
||||
if (decision.kind === 'reject' || signal.aborted || step !== 1) return decision
|
||||
const bash = ctx.get('bash')
|
||||
const bash = ctx.get('shell')
|
||||
if (bash === undefined) return decision
|
||||
const previous = latestInjectedState(agent)
|
||||
if (refreshIntervalMs !== undefined && refreshIntervalMs > 0 && previous !== undefined) {
|
||||
|
||||
@@ -3,8 +3,8 @@ import { Context } from '@deepseek-ai/cordis'
|
||||
import { Session, SessionId } from '@deepseek-ai/dsh-session'
|
||||
import AgentRegistry, { agentEvents, Inbox, type Agent } from '@deepseek-ai/dsh-agent'
|
||||
import { createUserMessage } from '@deepseek-ai/dsh-llm'
|
||||
import { BashExecutor } from '@deepseek-ai/dsh-bash'
|
||||
import type { BashExecRequest, BashExecSpec, BashProcess, BashRunResult } from '@deepseek-ai/dsh-bash'
|
||||
import { ShellExecutor } from '@deepseek-ai/dsh-shell'
|
||||
import type { ShellExecRequest, ShellExecSpec, ShellProcess, ShellRunResult } from '@deepseek-ai/dsh-shell'
|
||||
import * as tmuxContext from '@deepseek-ai/dsh-tmux-context'
|
||||
import type { Config } from '@deepseek-ai/dsh-tmux-context'
|
||||
|
||||
@@ -33,7 +33,7 @@ function tmuxLine(fields: {
|
||||
].join('\\t')
|
||||
}
|
||||
|
||||
function runResult(stdout: string, overrides: Partial<BashRunResult> = {}): BashRunResult {
|
||||
function runResult(stdout: string, overrides: Partial<ShellRunResult> = {}): ShellRunResult {
|
||||
return {
|
||||
exitCode: 0,
|
||||
signal: null,
|
||||
@@ -46,14 +46,14 @@ function runResult(stdout: string, overrides: Partial<BashRunResult> = {}): Bash
|
||||
}
|
||||
}
|
||||
|
||||
/** A scriptable fake `ctx.bash` recording the command it was asked to run. */
|
||||
class FakeBash extends BashExecutor {
|
||||
/** A scriptable fake `ctx.shell` recording the command it was asked to run. */
|
||||
class FakeBash extends ShellExecutor {
|
||||
commands: string[] = []
|
||||
result: BashRunResult = runResult(`${tmuxLine()}\n`)
|
||||
result: ShellRunResult = runResult(`${tmuxLine()}\n`)
|
||||
runError?: Error
|
||||
resolveError?: Error
|
||||
|
||||
override resolve(request: BashExecRequest): BashExecSpec {
|
||||
override resolve(request: ShellExecRequest): ShellExecSpec {
|
||||
if (this.resolveError) throw this.resolveError
|
||||
return {
|
||||
command: request.command,
|
||||
@@ -64,13 +64,13 @@ class FakeBash extends BashExecutor {
|
||||
sandboxPolicy: request.sandboxPolicy,
|
||||
}
|
||||
}
|
||||
override async run(spec: BashExecSpec): Promise<BashRunResult> {
|
||||
override async run(spec: ShellExecSpec): Promise<ShellRunResult> {
|
||||
this.commands.push(spec.command)
|
||||
if (this.runError) throw this.runError
|
||||
return this.result
|
||||
}
|
||||
override start(): BashProcess {
|
||||
throw new Error('tmux-context must never start a background task')
|
||||
override start(): ShellProcess {
|
||||
throw new Error('tmux-context must never start a background job')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ async function mount(
|
||||
let bash: FakeBash | undefined
|
||||
if (withBash) {
|
||||
await ctx.plugin(FakeBash)
|
||||
bash = ctx.bash as FakeBash
|
||||
bash = ctx.shell as FakeBash
|
||||
}
|
||||
await ctx.plugin(tmuxContext, config)
|
||||
return { ctx, bash }
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"path": "../../llm/llm"
|
||||
},
|
||||
{
|
||||
"path": "../../bash/bash"
|
||||
"path": "../../shell/shell"
|
||||
},
|
||||
{
|
||||
"path": "../../core/agent"
|
||||
@@ -28,7 +28,7 @@
|
||||
"path": "../../core/system-prompt"
|
||||
},
|
||||
{
|
||||
"path": "../../support/invariants"
|
||||
"path": "../../runtime-diagnostics/invariants"
|
||||
},
|
||||
{
|
||||
"path": "../../core/session"
|
||||
|
||||
Reference in New Issue
Block a user