mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-10-26 16:55:08 +00:00
# Conflicts: # packages/shell/bash-local/README.i18n.yaml # packages/shell/bash-local/README.md # packages/shell/bash-local/README.zh.md # packages/shell/bash-local/src/index.ts # packages/shell/bash-local/tests/executor.spec.ts # packages/shell/pwsh-local/README.i18n.yaml # packages/shell/pwsh-local/README.md # packages/shell/pwsh-local/README.zh.md # packages/shell/pwsh-local/src/index.ts # packages/shell/shell/README.i18n.yaml # packages/shell/shell/README.md # packages/shell/shell/README.zh.md # snapshots/session/pwsh-tool-turn/tool-schemas.expected.json
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
/** Exact recorded shell-command path translation; execution and reported outcomes remain real. */
|
|
import type { Context } from '@deepseek-ai/cordis'
|
|
import type {} from '@deepseek-ai/dsh-shell'
|
|
|
|
export const name = 'snapshot-shell-path'
|
|
export const inject = ['shell']
|
|
|
|
/** One recorded command and its isolated live filesystem target. */
|
|
export interface Config {
|
|
command: string
|
|
recordedPath: string
|
|
livePath: string
|
|
}
|
|
|
|
/**
|
|
* Translate one exact fixture command after tool logging and approval.
|
|
* @param ctx - profile context with its real shell executor.
|
|
* @param config - recorded command/path and allocated live target.
|
|
*/
|
|
export function apply(ctx: Context, config: Config): void {
|
|
const shell = ctx.shell
|
|
// oxlint-disable-next-line typescript/unbound-method -- preserve method identity for restoration; calls bind the receiver.
|
|
const execute = shell.execute
|
|
ctx.effect(() => {
|
|
shell.execute = spec => execute.call(shell, spec.command === config.command
|
|
? { ...spec, command: spec.command.replaceAll(config.recordedPath, "'" + config.livePath.replaceAll("'", "'\"'\"'") + "'") }
|
|
: spec)
|
|
return () => { shell.execute = execute }
|
|
})
|
|
}
|