Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c48e9cabd9 | ||
|
|
4152c72730 | ||
|
|
1697c24c3c | ||
|
|
616cad75ce |
No files matched your search
@@ -2,6 +2,21 @@
|
||||
|
||||
Every release, newest first, generated from the commits in each release.
|
||||
|
||||
## v0.4.2 — 2026-11-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- rebuild both shipped presets from the harness standard
|
||||
|
||||
### Documented
|
||||
|
||||
- install the latest release, not the 0.1 line
|
||||
|
||||
### Other
|
||||
|
||||
- fail when a preset drifts from the harness standard
|
||||
|
||||
|
||||
## v0.4.1 — 2026-10-19
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -74,7 +74,7 @@ because otherwise there would be no way to grant anything at all.
|
||||
From the repository, following releases:
|
||||
|
||||
```sh
|
||||
dsh plugin --profile web add "git+https://git.notexpectedyet.com/Not-Expected-Yet/dsh-facet.git#semver:^0.1.0"
|
||||
dsh plugin --profile web add "git+https://git.notexpectedyet.com/Not-Expected-Yet/dsh-facet.git#semver:>=0.1.0"
|
||||
dsh --profile web --dump-config | grep preset-facet # expect the row
|
||||
```
|
||||
|
||||
@@ -84,13 +84,16 @@ Or from a checkout, while working on the plugin itself:
|
||||
dsh plugin --profile web add "/path/to/dsh-facet"
|
||||
```
|
||||
|
||||
The `#semver:^0.1.0` fragment is the difference between an install that can be
|
||||
The `#semver:>=0.1.0` fragment is the difference between an install that can be
|
||||
updated and one that cannot. Leave it off and pnpm resolves the default branch to
|
||||
a **commit** and records that commit in `pnpm-lock.yaml` — `dsh plugin update`
|
||||
then has no version to move to, because there is nothing to move between. With
|
||||
the fragment, pnpm resolves against the repository's tags, which the release
|
||||
workflow creates on every push to `master`. The fragment needs a tag to resolve
|
||||
against, so it only works once the first release has been published.
|
||||
workflow creates on every push to `master`. The range is written `>=` rather
|
||||
than `^` because this package is still `0.x`: a caret range stops before the next
|
||||
minor, so `^0.1.0` can never reach the `0.4.x` line and would silently install an
|
||||
old release. The fragment needs a tag to resolve against, so it only works once
|
||||
the first release has been published.
|
||||
|
||||
Either way the command is `pnpm add` run inside the profile, and it registers the
|
||||
bundle in `dsh.profile.bundles` for you. A git-hosted plugin that builds on
|
||||
@@ -237,6 +240,21 @@ replaces the whole plugin list rather than merging into it, so the file is a
|
||||
frozen copy of `standard` that will not follow the harness when `standard`
|
||||
changes.
|
||||
|
||||
### Preset drift, and why one dead row breaks the preset
|
||||
|
||||
A preset declaration mounts every row it lists, so a single row the harness no
|
||||
longer provides fails the whole declaration rather than just that tool: the
|
||||
roster shows the preset with a `broken` diagnostic and no session can compose it.
|
||||
That is how this bundle broke on dsh `0.2.2-rc.1`. The harness folded
|
||||
`list_agents` into `@deepseek-ai/dsh-tool-subagent-control` and stopped exporting
|
||||
its `./list-agents` subpath; the frozen copy still named it, the row could never
|
||||
start, and every session on the `facet` preset failed to resume.
|
||||
|
||||
`test/presets.test.js` now compares both files under `presets/` against the
|
||||
`standard` preset of the installed harness — after removing the documented
|
||||
deltas — and resolves every plugin name they list, so the next time the harness
|
||||
moves a row the copy fails the tests instead of failing sessions.
|
||||
|
||||
### Prompt variables, and why the preset's persona has no suffix
|
||||
|
||||
Both preset files used to copy the deployment's persona line, *Your working
|
||||
@@ -285,7 +303,7 @@ Honest boundaries, because each one is a decision rather than an oversight:
|
||||
|
||||
Verified:
|
||||
|
||||
- 95 tests (`npm test`) over the scope algebra, the policy state, the guard, and
|
||||
- 98 tests (`npm test`) over the scope algebra, the policy state, the guard, and
|
||||
the browser half — including that containment is decided on canonical targets
|
||||
(a symlink inside the facet pointing outside it is refused), that a prefix is
|
||||
not a parent (`/a/room` does not contain `/a/roommate`), that a malformed tool
|
||||
@@ -298,7 +316,9 @@ Verified:
|
||||
out of a self-narrowing, that both listings normalise into one picker level and
|
||||
that a file listing the Host confines still leaves a browsable one, that no
|
||||
preset or contributed prompt text references a prompt variable the harness
|
||||
does not register, and that every `facet` result satisfies the tool's own
|
||||
does not register, that each shipped preset is the installed harness's
|
||||
`standard` composition plus only its documented changes and names only plugins
|
||||
the harness provides, and that every `facet` result satisfies the tool's own
|
||||
declared output schema.
|
||||
- The bundle's patch layers parse, merge and land correctly against the real
|
||||
profile: `dsh --profile web --patch ./cordis.patch.yml --patch
|
||||
@@ -357,15 +377,17 @@ would publish.
|
||||
## Development
|
||||
|
||||
```sh
|
||||
node scripts/dev-links.mjs # link the harness's cordis/schemastery/dsh-tools
|
||||
node scripts/dev-links.mjs # link the harness's cordis/schemastery/dsh-tools/js-yaml
|
||||
npm test
|
||||
```
|
||||
|
||||
`dev-links.mjs` links rather than installs those three packages, and for
|
||||
`dev-links.mjs` links rather than installs those four packages, and for
|
||||
`@deepseek-ai/cordis` that is a correctness requirement rather than tidiness: a
|
||||
second copy of Cordis means a second `Context` class, two service registries in
|
||||
one process, and a plugin whose services are invisible to the harness that loaded
|
||||
it.
|
||||
it. `js-yaml` is there so the preset-drift tests can read the harness's own
|
||||
`standard` patch; the scope search both share lives in
|
||||
`scripts/harness-scope.mjs`.
|
||||
|
||||
## Layout
|
||||
|
||||
@@ -377,7 +399,7 @@ lib/scope.js the pure half — argument extraction, text, reason
|
||||
lib/guard.js preset row: rule, binding, tool, pre-execute guard
|
||||
presets/facet.patch.yml the `facet` agent preset
|
||||
presets/standard-compaction.patch.yml optional: the same budget for `standard`
|
||||
test/ 95 tests
|
||||
test/ 98 tests
|
||||
```
|
||||
|
||||
`client/client.js` is a browser half rather than a module the host imports, and
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-facet",
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.2",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Scope an agent session to one facet of a multi-faceted system: the session's own folder, plus whatever files the user grants it.",
|
||||
|
||||
+29
-45
@@ -1,8 +1,8 @@
|
||||
# Agent preset facet: one `@deepseek-ai/dsh-agent-preset` declaration inserted
|
||||
# after the web patch.
|
||||
#
|
||||
# The composition is `standard` with three changes, and this file is the only
|
||||
# place any of them is decided:
|
||||
# The composition is the shipped `standard` patch with three changes, and this
|
||||
# file is the only place any of them is decided:
|
||||
#
|
||||
# * compaction is configured (see the `compaction` row below) so the pressure
|
||||
# trigger is a budget rather than a formality. The shipped ratio is 0.80 of a
|
||||
@@ -11,17 +11,23 @@
|
||||
#
|
||||
# * `facet-guard` is mounted, which confines the session to its own folder;
|
||||
#
|
||||
# * the persona row carries no suffix. The shipped one states the working
|
||||
# directory through a prompt variable the harness no longer registers, and
|
||||
# an unregistered variable fails the whole turn — see the note on that row.
|
||||
# * the persona row carries no suffix. The shipped one used to state the
|
||||
# working directory through a prompt variable the harness no longer
|
||||
# registers, and an unregistered variable fails the whole turn — see the
|
||||
# note on that row.
|
||||
#
|
||||
# Everything else is copied verbatim from the shipped `standard` patch, and that
|
||||
# is deliberate: a preset declaration replaces the whole plugin list rather than
|
||||
# merging into it, so a clone that drifts from the original silently loses
|
||||
# whatever it drifted past. When the harness next changes `standard`, re-copy
|
||||
# this file and re-apply the three changes — do not hand-patch around it. The
|
||||
# persona row must be re-checked by hand: re-copying it from `standard` restores
|
||||
# the suffix, and the harness's variable set is what decides whether it composes.
|
||||
# whatever it drifted past — and a clone that keeps a row the harness has since
|
||||
# removed fails to mount at all. That is how this preset broke on dsh
|
||||
# 0.2.2-rc.1: the harness folded `list_agents` into
|
||||
# `@deepseek-ai/dsh-tool-subagent-control` and stopped exporting its
|
||||
# `./list-agents` subpath, so the copied row could never start and the whole
|
||||
# preset reported as broken. When the harness next changes `standard`, re-copy
|
||||
# this file and re-apply the three changes — do not hand-patch around it.
|
||||
# `test/presets.test.js` compares this file against the installed `standard`
|
||||
# and fails on any drift, so the reminder is enforced rather than remembered.
|
||||
- insert:
|
||||
- id: preset-facet
|
||||
name: '@deepseek-ai/dsh-agent-preset'
|
||||
@@ -31,13 +37,6 @@
|
||||
description: One module of the system, not all of it — the session's own folder, plus the files you grant.
|
||||
order: 5
|
||||
plugins:
|
||||
# No suffix. It used to state the working directory through the `cwd`
|
||||
# prompt variable, which the harness does not register — and an unknown
|
||||
# variable is not rendered as text: assembly throws and the whole turn
|
||||
# fails with it. Only `provider` and `model` are registered now, so the
|
||||
# prefix keeps its model reference and the folder is stated per session
|
||||
# by `facet-guard`'s runtime binding instead, which follows the user
|
||||
# when they narrow it.
|
||||
- id: persona
|
||||
name: '@deepseek-ai/dsh-persona'
|
||||
config:
|
||||
@@ -46,6 +45,8 @@
|
||||
name: '@deepseek-ai/dsh-agent-instructions'
|
||||
config:
|
||||
maxBytes: 65536
|
||||
- id: time-context
|
||||
name: '@deepseek-ai/dsh-time-context'
|
||||
# The facet itself: a rule in the system prompt, the binding in the
|
||||
# runtime context, the `facet` tool, and the pre-execute guard that
|
||||
# asks before a file call leaves the session's folder. Configured by
|
||||
@@ -61,12 +62,17 @@
|
||||
disabled: !!js process.platform !== 'win32'
|
||||
- id: tool-fs
|
||||
name: '@deepseek-ai/dsh-tool-fs'
|
||||
config:
|
||||
# Set false to drop the apply_patch tool beside edit.
|
||||
applyPatch: false
|
||||
- id: tool-fs-search
|
||||
name: '@deepseek-ai/dsh-tool-fs-search'
|
||||
config:
|
||||
sampleOverCapGlobResults: false
|
||||
- id: tool-jobs
|
||||
name: '@deepseek-ai/dsh-tool-jobs'
|
||||
- id: tool-schedule
|
||||
name: '@deepseek-ai/dsh-tool-schedule'
|
||||
- id: skill-filesystem
|
||||
name: '@deepseek-ai/dsh-skill-filesystem'
|
||||
- id: tool-skill
|
||||
@@ -85,7 +91,7 @@
|
||||
name: '@deepseek-ai/dsh-plan-mode'
|
||||
config:
|
||||
section: |
|
||||
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
||||
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
||||
|
||||
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
||||
|
||||
@@ -106,7 +112,7 @@
|
||||
- id: compaction-basic
|
||||
name: '@deepseek-ai/dsh-compaction-basic'
|
||||
config:
|
||||
# 0.80 of a 1M window is a 800k trigger, and the deepest session
|
||||
# 0.80 of a 1M window is an 800k trigger, and the deepest session
|
||||
# ever recorded here peaked at 787,668 pressure tokens: the
|
||||
# trigger was never reached, so every token below it was re-read
|
||||
# on every subsequent step. 0.35 puts the ceiling at 350k.
|
||||
@@ -134,49 +140,24 @@
|
||||
config:
|
||||
- id: tool-subagent-control
|
||||
name: '@deepseek-ai/dsh-tool-subagent-control'
|
||||
- id: tool-subagent-list-agents
|
||||
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
||||
- id: tool-subagent
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
config:
|
||||
provider: spawn
|
||||
toolName: subagent
|
||||
modelSelectionSettings: true
|
||||
backgroundMode: continuable
|
||||
modelSelection: true
|
||||
modelDiscovery: true
|
||||
- id: tool-subagent-fork
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
config:
|
||||
provider: fork
|
||||
toolName: subagent_fork
|
||||
backgroundMode: continuable
|
||||
- id: tool-subagent-codex
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
disabled: true
|
||||
config:
|
||||
provider: codex
|
||||
toolName: subagent_codex
|
||||
backgroundMode: one-shot
|
||||
maxDepth: provider-managed
|
||||
- id: tool-subagent-claude-code
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
disabled: true
|
||||
config:
|
||||
provider: claude-code
|
||||
toolName: subagent_claude_code
|
||||
backgroundMode: one-shot
|
||||
maxDepth: provider-managed
|
||||
- id: workflow-ptc
|
||||
name: '@deepseek-ai/dsh-workflow-ptc'
|
||||
config:
|
||||
provider: spawn
|
||||
- id: tool-workflow
|
||||
name: '@deepseek-ai/dsh-tool-workflow'
|
||||
- id: tool-ralph
|
||||
name: '@deepseek-ai/dsh-tool-ralph'
|
||||
disabled: true
|
||||
config:
|
||||
subagentProvider: spawn
|
||||
maxRounds: 64
|
||||
- id: tool-ask-user
|
||||
name: '@deepseek-ai/dsh-tool-ask-user'
|
||||
- id: tool-todo
|
||||
@@ -192,4 +173,7 @@
|
||||
name: '@deepseek-ai/dsh-tool-present'
|
||||
- id: tool-plugin-manager
|
||||
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
||||
disabled: !!js "!ctx.get('profileContext')"
|
||||
- id: tool-plugin-market
|
||||
name: '@deepseek-ai/dsh-plugin-market/tools'
|
||||
disabled: true
|
||||
@@ -11,17 +11,16 @@
|
||||
# It is deliberately not applied for you, and the reason is a real hazard rather
|
||||
# than caution: a preset declaration replaces the whole plugin list, never merges
|
||||
# into it, so this file is a frozen copy of the shipped `standard` composition
|
||||
# plus two changes. When the harness next updates `standard` — a new tool, a
|
||||
# plus one change. When the harness next updates `standard` — a new tool, a
|
||||
# renamed row — this copy will not follow it, and the sessions on this preset
|
||||
# will silently lose whatever was added. Use it if you are prepared to re-copy
|
||||
# and re-apply when that happens; otherwise take the compaction settings into
|
||||
# whichever preset you actually run.
|
||||
# will silently lose whatever was added, or fail to mount if the copy keeps a
|
||||
# row the harness removed. Use it if you are prepared to re-copy and re-apply
|
||||
# when that happens; otherwise take the compaction settings into whichever
|
||||
# preset you actually run.
|
||||
#
|
||||
# The two changes from the shipped file are the `compaction-basic` row's config,
|
||||
# and the persona row's missing suffix: the shipped one names the working
|
||||
# directory with a prompt variable the harness no longer registers, and an
|
||||
# unregistered variable fails the whole turn instead of rendering. Re-copying
|
||||
# this file from a newer `standard` reintroduces that suffix — re-apply both.
|
||||
# The one change from the shipped file is the `compaction-basic` row's config.
|
||||
# `test/presets.test.js` compares this file against the installed `standard`
|
||||
# and fails on any other difference.
|
||||
- insert:
|
||||
- id: preset-standard
|
||||
name: '@deepseek-ai/dsh-agent-preset'
|
||||
@@ -29,12 +28,6 @@
|
||||
id: standard
|
||||
order: 1
|
||||
plugins:
|
||||
# No suffix, for the reason in `facet.patch.yml`: the harness registers
|
||||
# only `provider` and `model` as prompt variables, and an unregistered
|
||||
# one now throws instead of rendering. Nothing in this preset states the
|
||||
# session's working directory any more — a static prompt template cannot
|
||||
# name a folder that changes per session, so a deployment that needs it
|
||||
# belongs in the runtime context rather than here.
|
||||
- id: persona
|
||||
name: '@deepseek-ai/dsh-persona'
|
||||
config:
|
||||
@@ -43,6 +36,8 @@
|
||||
name: '@deepseek-ai/dsh-agent-instructions'
|
||||
config:
|
||||
maxBytes: 65536
|
||||
- id: time-context
|
||||
name: '@deepseek-ai/dsh-time-context'
|
||||
- id: tool-bash
|
||||
name: '@deepseek-ai/dsh-tool-bash'
|
||||
disabled: !!js process.platform === 'win32'
|
||||
@@ -51,12 +46,17 @@
|
||||
disabled: !!js process.platform !== 'win32'
|
||||
- id: tool-fs
|
||||
name: '@deepseek-ai/dsh-tool-fs'
|
||||
config:
|
||||
# Set false to drop the apply_patch tool beside edit.
|
||||
applyPatch: false
|
||||
- id: tool-fs-search
|
||||
name: '@deepseek-ai/dsh-tool-fs-search'
|
||||
config:
|
||||
sampleOverCapGlobResults: false
|
||||
- id: tool-jobs
|
||||
name: '@deepseek-ai/dsh-tool-jobs'
|
||||
- id: tool-schedule
|
||||
name: '@deepseek-ai/dsh-tool-schedule'
|
||||
- id: skill-filesystem
|
||||
name: '@deepseek-ai/dsh-skill-filesystem'
|
||||
- id: tool-skill
|
||||
@@ -75,7 +75,7 @@
|
||||
name: '@deepseek-ai/dsh-plan-mode'
|
||||
config:
|
||||
section: |
|
||||
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
||||
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
||||
|
||||
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
||||
|
||||
@@ -116,49 +116,24 @@
|
||||
config:
|
||||
- id: tool-subagent-control
|
||||
name: '@deepseek-ai/dsh-tool-subagent-control'
|
||||
- id: tool-subagent-list-agents
|
||||
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
||||
- id: tool-subagent
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
config:
|
||||
provider: spawn
|
||||
toolName: subagent
|
||||
modelSelectionSettings: true
|
||||
backgroundMode: continuable
|
||||
modelSelection: true
|
||||
modelDiscovery: true
|
||||
- id: tool-subagent-fork
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
config:
|
||||
provider: fork
|
||||
toolName: subagent_fork
|
||||
backgroundMode: continuable
|
||||
- id: tool-subagent-codex
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
disabled: true
|
||||
config:
|
||||
provider: codex
|
||||
toolName: subagent_codex
|
||||
backgroundMode: one-shot
|
||||
maxDepth: provider-managed
|
||||
- id: tool-subagent-claude-code
|
||||
name: '@deepseek-ai/dsh-tool-subagent'
|
||||
disabled: true
|
||||
config:
|
||||
provider: claude-code
|
||||
toolName: subagent_claude_code
|
||||
backgroundMode: one-shot
|
||||
maxDepth: provider-managed
|
||||
- id: workflow-ptc
|
||||
name: '@deepseek-ai/dsh-workflow-ptc'
|
||||
config:
|
||||
provider: spawn
|
||||
- id: tool-workflow
|
||||
name: '@deepseek-ai/dsh-tool-workflow'
|
||||
- id: tool-ralph
|
||||
name: '@deepseek-ai/dsh-tool-ralph'
|
||||
disabled: true
|
||||
config:
|
||||
subagentProvider: spawn
|
||||
maxRounds: 64
|
||||
- id: tool-ask-user
|
||||
name: '@deepseek-ai/dsh-tool-ask-user'
|
||||
- id: tool-todo
|
||||
@@ -174,4 +149,7 @@
|
||||
name: '@deepseek-ai/dsh-tool-present'
|
||||
- id: tool-plugin-manager
|
||||
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
||||
disabled: !!js "!ctx.get('profileContext')"
|
||||
- id: tool-plugin-market
|
||||
name: '@deepseek-ai/dsh-plugin-market/tools'
|
||||
disabled: true
|
||||
+13
-21
@@ -5,10 +5,12 @@
|
||||
*
|
||||
* ## Why this exists
|
||||
*
|
||||
* The plugin imports `@deepseek-ai/dsh-tools` and `@deepseek-ai/schemastery`.
|
||||
* Once installed into a profile those resolve from the profile's own
|
||||
* `node_modules`, which is where the harness lives — but a bare checkout has no
|
||||
* such tree, so the tests cannot even load the module under test.
|
||||
* The plugin imports `@deepseek-ai/dsh-tools` and `@deepseek-ai/schemastery`,
|
||||
* and `test/presets.test.js` reads the shipped `standard` preset through
|
||||
* `js-yaml` to compare it with this bundle's frozen copies. Once installed into
|
||||
* a profile those resolve from the profile's own `node_modules`, which is where
|
||||
* the harness lives — but a bare checkout has no such tree, so the tests cannot
|
||||
* even load the module under test.
|
||||
*
|
||||
* The alternative is declaring them as dependencies, and for `@deepseek-ai/cordis`
|
||||
* that would be a genuine bug rather than untidiness: a second copy of Cordis
|
||||
@@ -23,25 +25,14 @@ import { existsSync, mkdirSync, readdirSync, rmSync, symlinkSync } from 'node:fs
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { findHarnessScope } from './harness-scope.mjs'
|
||||
|
||||
/** Packages this checkout imports at runtime, and which the harness must supply. */
|
||||
const NEEDED = ['cordis', 'schemastery', 'dsh-tools']
|
||||
const NEEDED = ['@deepseek-ai/cordis', '@deepseek-ai/schemastery', '@deepseek-ai/dsh-tools', 'js-yaml']
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const packageRoot = resolve(here, '..')
|
||||
|
||||
/** Where a dsh installation keeps the scope, newest layout first. */
|
||||
function findHarnessScope() {
|
||||
const candidates = [
|
||||
process.env.DSH_HARNESS_NODE_MODULES,
|
||||
resolve(process.env.DSH_HOME ?? join(process.env.HOME ?? '', '.dsh'), 'profiles', 'node_modules'),
|
||||
'/usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules',
|
||||
]
|
||||
for (const candidate of candidates) {
|
||||
if (typeof candidate === 'string' && existsSync(join(candidate, '@deepseek-ai', 'cordis'))) return candidate
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
const scope = findHarnessScope()
|
||||
if (scope === undefined) {
|
||||
console.error('dev-links: no dsh installation found. Set DSH_HARNESS_NODE_MODULES to its node_modules directory.')
|
||||
@@ -49,16 +40,17 @@ if (scope === undefined) {
|
||||
}
|
||||
|
||||
const target = join(packageRoot, 'node_modules')
|
||||
mkdirSync(join(target, '@deepseek-ai'), { recursive: true })
|
||||
mkdirSync(target, { recursive: true })
|
||||
|
||||
let linked = 0
|
||||
for (const name of NEEDED) {
|
||||
const source = join(scope, '@deepseek-ai', name)
|
||||
const source = join(scope, name)
|
||||
if (!existsSync(source)) {
|
||||
console.error(`dev-links: ${name} is not in ${scope}; skipping`)
|
||||
continue
|
||||
}
|
||||
const link = join(target, '@deepseek-ai', name)
|
||||
const link = join(target, name)
|
||||
mkdirSync(dirname(link), { recursive: true })
|
||||
if (existsSync(link)) rmSync(link, { recursive: true, force: true })
|
||||
symlinkSync(source, link, 'dir')
|
||||
linked += 1
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Locate a dsh installation's dependency scope from a checkout.
|
||||
*
|
||||
* The plugin links harness packages into a bare checkout (see `dev-links.mjs`)
|
||||
* and `test/presets.test.js` reads the shipped `standard` preset to compare it
|
||||
* with this bundle's frozen copies. Both need the same answer to "where is the
|
||||
* harness?", so the search lives here rather than twice.
|
||||
*
|
||||
* There can be more than one answer. A harness home may carry the legacy
|
||||
* `profiles/node_modules` mirror that an older link backend projected, and that
|
||||
* mirror is a snapshot: packages added to the installation later are missing
|
||||
* from it. Callers that resolve more than one package should therefore try
|
||||
* every scope, not only {@link findHarnessScope}'s first answer.
|
||||
*/
|
||||
|
||||
import { existsSync } from 'node:fs'
|
||||
import { join, resolve } from 'node:path'
|
||||
|
||||
/**
|
||||
* Every dependency scope a dsh installation may occupy, newest layout first.
|
||||
*
|
||||
* @returns the directories that hold `@deepseek-ai/cordis`, deduplicated, in
|
||||
* preference order.
|
||||
*/
|
||||
export function harnessScopes() {
|
||||
const candidates = [
|
||||
process.env.DSH_HARNESS_NODE_MODULES,
|
||||
resolve(process.env.DSH_HOME ?? join(process.env.HOME ?? '', '.dsh'), 'profiles', 'node_modules'),
|
||||
'/usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules',
|
||||
]
|
||||
const scopes = []
|
||||
for (const candidate of candidates) {
|
||||
if (typeof candidate !== 'string' || !existsSync(join(candidate, '@deepseek-ai', 'cordis'))) continue
|
||||
if (!scopes.includes(candidate)) scopes.push(candidate)
|
||||
}
|
||||
return scopes
|
||||
}
|
||||
|
||||
/**
|
||||
* The preferred dependency scope of a dsh installation.
|
||||
*
|
||||
* @returns the first directory that holds `@deepseek-ai/cordis`, or undefined.
|
||||
*/
|
||||
export function findHarnessScope() {
|
||||
return harnessScopes()[0]
|
||||
}
|
||||
+165
-1
@@ -1,10 +1,14 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync, readdirSync } from 'node:fs'
|
||||
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { test } from 'node:test'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import yaml from 'js-yaml'
|
||||
|
||||
import { facetContextText, facetRuleText } from '../lib/scope.js'
|
||||
import { harnessScopes } from '../scripts/harness-scope.mjs'
|
||||
|
||||
const PRESETS = join(dirname(fileURLToPath(import.meta.url)), '..', 'presets')
|
||||
|
||||
@@ -59,3 +63,163 @@ test('the text this bundle contributes to the prompt holds no variable reference
|
||||
assert.deepEqual(referencesIn(rule), [])
|
||||
assert.deepEqual(referencesIn(binding), [])
|
||||
})
|
||||
|
||||
/*
|
||||
* Drift against the shipped `standard` composition.
|
||||
*
|
||||
* A preset declaration replaces the whole plugin list rather than merging into
|
||||
* it, so both files under `presets/` are frozen copies of the harness's
|
||||
* `standard` patch. That copy is what breaks when the harness changes: on dsh
|
||||
* 0.2.2-rc.1 the harness folded `list_agents` into
|
||||
* `@deepseek-ai/dsh-tool-subagent-control` and dropped its `./list-agents`
|
||||
* subpath, and the copied row could never start — which breaks the *whole*
|
||||
* preset, because one row that fails to mount fails the declaration. These
|
||||
* tests turn "remember to re-copy it" into a build failure.
|
||||
*
|
||||
* They need the installed harness, so they skip on a checkout without one.
|
||||
*/
|
||||
|
||||
const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const FACET_PRESET = join(PRESETS, 'facet.patch.yml')
|
||||
const COMPACTION_PRESET = join(PRESETS, 'standard-compaction.patch.yml')
|
||||
const HARNESS_SCOPES = harnessScopes()
|
||||
const STANDARD_PRESET = HARNESS_SCOPES
|
||||
.map((scope) => join(scope, '@deepseek-ai', 'dsh-web-app', 'presets', 'standard.patch.yml'))
|
||||
.find((file) => existsSync(file))
|
||||
|
||||
const SKIP_DRIFT =
|
||||
HARNESS_SCOPES.length === 0
|
||||
? 'no dsh installation found; set DSH_HARNESS_NODE_MODULES to compare against the shipped standard preset'
|
||||
: STANDARD_PRESET === undefined
|
||||
? 'the shipped standard preset was not found in any harness scope'
|
||||
: false
|
||||
|
||||
/** The `!!js` tag carries a source expression; both compared sides keep it as text. */
|
||||
const PRESET_SCHEMA = yaml.DEFAULT_SCHEMA.extend([
|
||||
new yaml.Type('tag:yaml.org,2002:js', { kind: 'scalar', construct: (value) => value }),
|
||||
])
|
||||
|
||||
/** The plugin rows of a single-preset patch file, as written. */
|
||||
function presetPlugins(file) {
|
||||
const [patch] = yaml.load(readFileSync(file, 'utf8'), { schema: PRESET_SCHEMA })
|
||||
return patch.insert[0].config.plugins
|
||||
}
|
||||
|
||||
/** Drop absent keys, so a missing field and an undefined field compare the same. */
|
||||
function normalizedRows(rows) {
|
||||
return rows.map((row) => ({
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
...(row.disabled === undefined ? {} : { disabled: row.disabled }),
|
||||
...(row.group === true ? { group: true } : {}),
|
||||
...(row.isolate === undefined ? {} : { isolate: row.isolate }),
|
||||
...(row.config === undefined ? {} : { config: Array.isArray(row.config) ? normalizedRows(row.config) : row.config }),
|
||||
}))
|
||||
}
|
||||
|
||||
/** One row by id, at any depth. */
|
||||
function rowById(rows, id) {
|
||||
for (const row of rows) {
|
||||
if (row.id === id) return row
|
||||
if (Array.isArray(row.config)) {
|
||||
const found = rowById(row.config, id)
|
||||
if (found !== undefined) return found
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** A copy with the bundle's compaction budget removed, so everything else can be compared. */
|
||||
function withoutCompactionBudget(rows) {
|
||||
const copy = structuredClone(rows)
|
||||
const strip = (list) => {
|
||||
for (const row of list) {
|
||||
if (row.id === 'compaction-basic') delete row.config
|
||||
if (Array.isArray(row.config)) strip(row.config)
|
||||
}
|
||||
}
|
||||
strip(copy)
|
||||
return copy
|
||||
}
|
||||
|
||||
/** The only settings either file adds to a `standard` row. */
|
||||
const COMPACTION_BUDGET = { thresholdRatio: 0.35, retainTokens: 80000, maxTokens: 16384 }
|
||||
|
||||
test('the facet preset is the shipped standard composition plus its documented changes', { skip: SKIP_DRIFT }, () => {
|
||||
const standard = normalizedRows(presetPlugins(STANDARD_PRESET))
|
||||
const facet = normalizedRows(presetPlugins(FACET_PRESET))
|
||||
|
||||
const guard = facet.filter((row) => row.id === 'facet-guard')
|
||||
assert.deepEqual(guard, [{ id: 'facet-guard', name: 'dsh-facet/guard' }], 'the facet preset mounts facet-guard exactly once')
|
||||
|
||||
const withoutGuard = facet.filter((row) => row.id !== 'facet-guard')
|
||||
assert.deepEqual(
|
||||
withoutCompactionBudget(withoutGuard),
|
||||
withoutCompactionBudget(standard),
|
||||
'presets/facet.patch.yml has drifted from the shipped standard composition; re-copy it from the harness and re-apply only the guard and the compaction budget',
|
||||
)
|
||||
assert.deepEqual(
|
||||
rowById(withoutGuard, 'compaction-basic')?.config,
|
||||
COMPACTION_BUDGET,
|
||||
'the facet preset keeps its compaction budget',
|
||||
)
|
||||
})
|
||||
|
||||
test('the standard-compaction overlay is the shipped standard composition plus the compaction budget', { skip: SKIP_DRIFT }, () => {
|
||||
const standard = normalizedRows(presetPlugins(STANDARD_PRESET))
|
||||
const overlay = normalizedRows(presetPlugins(COMPACTION_PRESET))
|
||||
|
||||
assert.deepEqual(
|
||||
rowById(overlay, 'compaction-basic')?.config,
|
||||
COMPACTION_BUDGET,
|
||||
'the optional overlay configures the compaction budget',
|
||||
)
|
||||
assert.deepEqual(
|
||||
withoutCompactionBudget(overlay),
|
||||
withoutCompactionBudget(standard),
|
||||
'presets/standard-compaction.patch.yml has drifted from the shipped standard composition; re-copy it from the harness and re-apply only the compaction budget',
|
||||
)
|
||||
})
|
||||
|
||||
/** Every row's id and module specifier, groups included. */
|
||||
function namedRows(rows) {
|
||||
return rows.flatMap((row) => [
|
||||
{ id: row.id, name: row.name },
|
||||
...(Array.isArray(row.config) ? namedRows(row.config) : []),
|
||||
])
|
||||
}
|
||||
|
||||
test('every plugin a shipped preset names resolves against the installed harness', { skip: SKIP_DRIFT }, () => {
|
||||
// Anchoring inside a scope makes Node look in that scope's own node_modules:
|
||||
// its parent directory carries the scope as a `node_modules` entry, which is
|
||||
// exactly the lookup the profile uses. Several scopes are tried because a
|
||||
// legacy `profiles/node_modules` mirror is only a snapshot of the installation.
|
||||
const harnessResolvers = HARNESS_SCOPES.map((scope) => createRequire(join(scope, 'noop.mjs')))
|
||||
const fromPlugin = createRequire(join(PACKAGE_ROOT, 'package.json'))
|
||||
const unresolved = []
|
||||
|
||||
for (const file of [FACET_PRESET, COMPACTION_PRESET]) {
|
||||
for (const { id, name } of namedRows(presetPlugins(file))) {
|
||||
// `cordis:group` is a loader builtin rather than an installed package.
|
||||
if (name === 'cordis:group') continue
|
||||
const resolvers = name === 'dsh-facet/guard' ? [fromPlugin] : harnessResolvers
|
||||
let failure
|
||||
const resolved = resolvers.some((resolver) => {
|
||||
try {
|
||||
resolver.resolve(name)
|
||||
return true
|
||||
} catch (error) {
|
||||
failure = error
|
||||
return false
|
||||
}
|
||||
})
|
||||
if (!resolved) unresolved.push(`${file.split('/').pop()}: ${id} (${name}): ${failure?.code ?? failure?.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
assert.deepEqual(
|
||||
unresolved,
|
||||
[],
|
||||
'a preset names a plugin or subpath the harness no longer provides; re-copy the preset from the shipped standard',
|
||||
)
|
||||
})
|
||||
Reference in new issue
Block a user