Skip to content

feat(deepseek): add file upload support via --file flag#1093

Merged
jackwener merged 5 commits intojackwener:mainfrom
Benjamin-eecs:feat/deepseek-file-upload
Apr 21, 2026
Merged

feat(deepseek): add file upload support via --file flag#1093
jackwener merged 5 commits intojackwener:mainfrom
Benjamin-eecs:feat/deepseek-file-upload

Conversation

@Benjamin-eecs
Copy link
Copy Markdown
Contributor

@Benjamin-eecs Benjamin-eecs commented Apr 20, 2026

Summary

Closes #1092.

Adds --file flag to deepseek ask for attaching files (PDF, image, text) with prompts.

Changes

Only additive, no existing code modified:

  • utils.js: added sendWithFile() function (attach file via browser UI, type prompt, click send)
  • ask.js: added --file arg, branches to sendWithFile when file is provided
  • deepseek.md: updated docs with --file option and usage example

Test plan

  • npx tsc --noEmit passes
  • opencli deepseek ask "read file just the code" --new --file ./test.txt returns correct file content
  • File not found returns CommandExecutionError
  • Basic deepseek ask without --file still works
  • File upload with --think and --model expert combinations work

Copilot AI review requested due to automatic review settings April 20, 2026 11:05
@Benjamin-eecs Benjamin-eecs force-pushed the feat/deepseek-file-upload branch from 6376e06 to a7943b1 Compare April 20, 2026 11:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds --file support to the DeepSeek browser adapter so opencli deepseek ask can attach a local file before sending a prompt (issue #1092).

Changes:

  • Add --file argument to deepseek ask and route to a new sendWithFile() upload+send flow.
  • Implement sendWithFile() in clis/deepseek/utils.js (read file, base64-inject into page, wait for preview, send).
  • Update DeepSeek adapter documentation and CLI manifest to include the new option (plus additional manifest regeneration updates).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
docs/adapters/browser/deepseek.md Documents new --file flag and notes base64/memory behavior.
clis/deepseek/utils.js Adds sendWithFile() implementation for file injection + send sequence.
clis/deepseek/ask.js Adds CLI arg and file-send branch for deepseek ask.
cli-manifest.json Adds deepseek ask --file to manifest; also updates some unrelated command columns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Default mode is Instant with DeepThink and Search disabled; each flag (`--model`, `--think`, `--search`) is synced on every invocation so omitting a flag resets it
- Long responses (code, essays) may need a higher `--timeout`
- File upload is not yet supported
- File upload reads the file into memory and passes it via base64 to the browser; files over 100 MB are rejected
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Docs state files up to 100 MB are supported, but the implementation base64-encodes the entire file and injects it into page.evaluate(), which can hit memory/transport limits well below 100 MB in practice. Please align this documented limit with a safe, tested maximum (or add a warning about potential failures for large files).

Copilot uses AI. Check for mistakes.
Comment thread cli-manifest.json
Comment on lines 16179 to +16183
"author",
"publish_time",
"status",
"size"
"size",
"saved"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This PR’s description says the changes are limited to the DeepSeek adapter files/docs, but this manifest hunk also updates the web read command columns (adds saved). If this is intentional (e.g. a full manifest regeneration), please update the PR description to reflect the extra scope; otherwise consider reverting unrelated manifest changes to keep the PR focused.

Copilot uses AI. Check for mistakes.
Comment thread cli-manifest.json
Comment on lines 16441 to +16445
"author",
"publish_time",
"status",
"size"
"size",
"saved"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This manifest hunk updates the weixin download command columns (adds saved), which is outside the scope described in the PR summary (DeepSeek --file). If this comes from regenerating cli-manifest.json, please call it out in the PR description; otherwise revert unrelated manifest diffs to reduce review/merge risk.

Copilot uses AI. Check for mistakes.
Comment thread clis/deepseek/ask.js
Comment on lines +72 to +74
await page.wait(3);
const response = await waitForResponse(page, 0, prompt, timeoutMs);
if (!response) {
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

When sending with --file, waitForResponse is called with baselineCount set to 0. In an existing conversation this can cause waitForResponse to immediately treat a previous assistant message as the “new” response (since result.count > 0), returning stale output. Capture the current bubble count before calling sendWithFile (same as the non-file path) and pass that baseline into waitForResponse (or have sendWithFile return the baseline it used).

Copilot uses AI. Check for mistakes.
Comment thread clis/deepseek/utils.js Outdated
Comment on lines +197 to +203
const stats = fs.default.statSync(absPath);
if (stats.size > 100 * 1024 * 1024) {
return { ok: false, reason: `File too large (${(stats.size / 1024 / 1024).toFixed(1)} MB). Max: 100 MB` };
}

const content = fs.default.readFileSync(absPath);
const base64 = content.toString('base64');
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The 100 MB cap is likely unsafe for this implementation: the file is read into memory, base64-encoded (~33% larger), then injected into a page.evaluate() string and decoded with atob, which can cause very large transient allocations and/or transport payload limits. The repo already documents OOM risk for this pattern (e.g. clis/yollomi/upload.js caps at 10–20 MB for the same reason). Consider lowering the maximum size to a safer limit and/or reworking the upload to avoid injecting huge base64 strings into page.evaluate().

Copilot uses AI. Check for mistakes.
@Benjamin-eecs Benjamin-eecs force-pushed the feat/deepseek-file-upload branch from a7943b1 to 407afb8 Compare April 20, 2026 11:10
@Benjamin-eecs Benjamin-eecs force-pushed the feat/deepseek-file-upload branch from 407afb8 to 09b547b Compare April 20, 2026 11:11
@jackwener jackwener merged commit b9bb302 into jackwener:main Apr 21, 2026
11 checks passed
luxiaolei pushed a commit to luxiaolei/OpenCLI that referenced this pull request Apr 22, 2026
* WIP: deepseek file upload (blocked by 30s idle timeout)

* feat(deepseek): add file upload support via --file flag

Closes jackwener#1092

* fix(deepseek): use native file input path for --file

---------

Co-authored-by: Benjamin Liu <beneecs@Benjamins-Mac-mini.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
(cherry picked from commit b9bb302)
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.

[Feature]: deepseek ask file upload support

3 participants