Skip to content

fix(dsh): treat missing session cwd as unscoped - #1267

Open
knqiufan wants to merge 3 commits into
oceanbase:masterfrom
knqiufan:fix/issue-1266-dsh-optional-session-cwd
Open

fix(dsh): treat missing session cwd as unscoped#1267
knqiufan wants to merge 3 commits into
oceanbase:masterfrom
knqiufan:fix/issue-1266-dsh-optional-session-cwd

Conversation

@knqiufan

@knqiufan knqiufan commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Closes #1266.

Rationale for this change

Latest DeepSeek Harness(dsh-0.1.0-rc.7) made SessionHeader.cwd optional. Sessions created without a workspace (sessions.create() with no meta.cwd) leave the field unset. The plugin treated cwd as required, so /pc could throw, recall was swallowed by fail-open, and tools could scope Memory to the Harness process directory.

What changes are included in this PR?

  • Treat missing or blank session.header.cwd as no workspace. Never fall back to process.cwd().
  • If scopeId / POWERCONTEXT_DSH_SCOPE_ID is set, recall, /pc, and tools work without cwd.
  • If neither workspace nor scopeId is available: recall skips with missing_session_cwd; /pc and tools return an explicit unscoped error; capture metadata omits a fabricated cwd.
  • Align plugin types/shims to cwd?: string.
  • Add unit coverage and a live-server e2e that drives the plugin runtime with header.cwd === undefined.
  • Update en/zh DSH setup docs to match.

Are there any user-facing changes?

Yes, for sessions without a workspace:

  • Recall no longer throws or silently uses the Harness process directory.
  • /pc and pc_* tools return a clear unscoped message unless POWERCONTEXT_DSH_SCOPE_ID is set.
  • Docs now say to set scopeId when the session has no workspace cwd.

No Server API or storage format changes.

How was this change tested?

  • npx vitest run --exclude tests/e2e/** in integrations/dsh/plugins/powercontext (60 passed)
  • npx vitest run tests/e2e (4 passed: existing HTTP call-through plus the new unscoped-session runtime e2e)

AI usage statement

Assisted by an AI coding model for the compatibility change, tests, and this write-up.

Latest DeepSeek Harness leaves SessionHeader.cwd unset when a
session has no workspace. Stop inventing a project scope from
the Harness process directory.
The quality job's end-of-file-fixer rejects the bundled lib outputs
when they omit a final newline.

@Teingi Teingi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cwd handling looks good. One test runner issue needs fixing before this merges.

return `local:${createHash('sha256').update(resolve(process.cwd())).digest('hex')}`
}

describe('plugin runtime with header.cwd === undefined', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This second e2e file exposes a shell glob issue in the existing test script. On Linux, vitest run --exclude tests/e2e/** expands to both e2e paths. Vitest uses the first path as the exclude value and treats this file as a positional filter, so pnpm test runs this e2e file and skips all 60 unit tests. I reproduced this at ade1124; vitest run --exclude=tests/e2e/** runs all 12 unit test files. Can we keep the glob in one argument and make sure make js-test reports 60 passing tests?

@knqiufan knqiufan Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Teingi catching this and for the clear reproduction. Fixed in 71b0e8b by keeping the exclude glob in one argument (--exclude=tests/e2e/**). I verified pnpm --dir integrations/dsh/plugins/powercontext test (the command used by make js-test) now reports 12 test files / 60 passing tests. The separate E2E suite still reports 2 files / 4 passing tests. I really appreciate the careful review and suggested fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(dsh): treat session.header.cwd as optional for latest DeepSeek Harness

2 participants