refactor(tool-fs): drop per-tool subpath plugins; adopt single-tsconfig build

Adapt the four fs packages to master's single-tsconfig build convention
(lib/types outDir + types path + files allowlist), brought in by the merge.

While doing so, drop dsh-tool-fs's /read//write//edit subpath plugins. They
were the only subpath-export package in the tree and forced bespoke tsdown,
tsconfig path, package.json files, and workspace-constraint handling that no
sibling tool package (e.g. dsh-tool-bash) carries, for a focused-deployment
use case no consumer needed. dsh-tool-fs is now a single root plugin that
registers read/write/edit, mirroring dsh-tool-bash; the per-tool registration
helpers stay internal modules the root composes. The file-context event-gate
RFC is amended to record the narrowed scope.
This commit is contained in:
Dudu-0223
2026-06-28 17:43:29 +08:00
parent 89b27ad442
commit 4a1177093a
16 changed files with 34 additions and 189 deletions

View File

@@ -5,10 +5,9 @@
*
* - DEFAULT — with the real `dsh-file-context` policy gate plugin: read-before-
* write/edit, version-guarded mutation, FS_NOT_OBSERVED for unread edits.
* - BARE — WITHOUT the policy plugin, loading only SUBPATH plugins: every
* `fs/*` waterfall falls through to its undefined default, so write/edit are
* unconditional. This proves the subpaths (not just the root) carry no policy
* dependency.
* - BARE — WITHOUT the policy plugin: every `fs/*` waterfall falls through to
* its undefined default, so write/edit are unconditional. This proves the
* tool carries no dependency on the policy plugin.
*
* These verify the WORLD — files are read back from disk and asserted
* byte-for-byte — not the tool's self-report.
@@ -25,9 +24,6 @@ import ToolRegistry from '@deepseek-ai/dsh-tools'
import { LocalFileSystem } from '@deepseek-ai/dsh-fs-local'
import * as FileContext from '@deepseek-ai/dsh-file-context'
import * as ToolFs from '@deepseek-ai/dsh-tool-fs'
import * as readPlugin from '@deepseek-ai/dsh-tool-fs/read'
import * as writePlugin from '@deepseek-ai/dsh-tool-fs/write'
import * as editPlugin from '@deepseek-ai/dsh-tool-fs/edit'
let dir: string
let ctx: Context
@@ -243,18 +239,16 @@ describe('default deployment (with dsh-file-context)', () => {
})
// --------------------------------------------------------------------------
// BARE deployment: SUBPATH plugins only, NO policy gate.
// BARE deployment: the tool suite WITHOUT the policy gate.
// --------------------------------------------------------------------------
describe('bare provider (subpath plugins, no dsh-file-context)', () => {
describe('bare provider (no dsh-file-context)', () => {
beforeEach(async () => {
dir = await mkdtemp(join(tmpdir(), 'dsh-tool-fs-bare-'))
ctx = new Context()
await ctx.plugin(SystemPrompt)
await ctx.plugin(ToolRegistry)
await ctx.plugin(LocalFileSystem, { cwd: dir })
await ctx.plugin(readPlugin)
await ctx.plugin(writePlugin)
fiber = await ctx.plugin(editPlugin)
fiber = await ctx.plugin(ToolFs)
})
it('read works (it never needed policy)', async () => {

View File

@@ -1,83 +0,0 @@
/**
* Tests for the per-tool subpath plugins (`@deepseek-ai/dsh-tool-fs/read`,
* `/write`, `/edit`): each registers exactly one tool, injects the same services
* (`tools`, `fs`, `systemPrompt`) — NOT a policy service — and cleans up on
* disposal. They boot over the bare `ctx.fs` provider with NO
* `@deepseek-ai/dsh-file-context`, proving each subpath carries no policy-plugin
* dependency.
*/
import { describe, expect, it } from 'vitest'
import { Context } from 'cordis'
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
import ToolRegistry from '@deepseek-ai/dsh-tools'
import { FileSystem, FsTargetKey, FsVersion } from '@deepseek-ai/dsh-fs'
import type {
FsEditOutcome,
FsInfo,
FsTarget,
FsWriteOutcome,
} from '@deepseek-ai/dsh-fs'
import * as readPlugin from '@deepseek-ai/dsh-tool-fs/read'
import * as writePlugin from '@deepseek-ai/dsh-tool-fs/write'
import * as editPlugin from '@deepseek-ai/dsh-tool-fs/edit'
class StubFs extends FileSystem {
override async resolve(path: string): Promise<FsTarget> {
return { inputPath: path, targetKey: FsTargetKey(path), displayPath: path }
}
override async stat(): Promise<FsInfo | undefined> {
return { version: FsVersion('v'), type: 'file', size: 0 }
}
override async readText(): Promise<string> {
return ''
}
override async streamText(): Promise<AsyncIterable<string>> {
return (async function* () { yield '' })()
}
override async writeText(): Promise<FsWriteOutcome> {
return { operation: 'create', version: FsVersion('v') }
}
override async editText(): Promise<FsEditOutcome> {
return { replacements: 1, replaceAll: false, version: FsVersion('v') }
}
}
async function base() {
const ctx = new Context()
await ctx.plugin(SystemPrompt)
await ctx.plugin(ToolRegistry)
await ctx.plugin(StubFs)
return ctx
}
describe('subpath plugins', () => {
it('each registers exactly its one tool (over the bare provider, no policy plugin)', async () => {
const cases: Array<[unknown, string]> = [
[readPlugin, 'read'],
[writePlugin, 'write'],
[editPlugin, 'edit'],
]
for (const [plugin, toolName] of cases) {
const ctx = await base()
await ctx.plugin(plugin as Parameters<Context['plugin']>[0])
expect(ctx.tools.schemas().map(s => s.name)).toEqual([toolName])
}
})
it('cleans up on disposal (HMR safety)', async () => {
const ctx = await base()
const fiber = await ctx.plugin(readPlugin as Parameters<Context['plugin']>[0])
expect(ctx.tools.schemas()).toHaveLength(1)
await fiber.dispose()
expect(ctx.tools.schemas()).toHaveLength(0)
})
it('stays pending without a ctx.fs provider', async () => {
const ctx = new Context()
await ctx.plugin(SystemPrompt)
await ctx.plugin(ToolRegistry)
await ctx.plugin(writePlugin as Parameters<Context['plugin']>[0])
expect(ctx.tools.schemas()).toHaveLength(0)
})
})