Skip to content

feat: smart saveTo with full path support#62

Open
mikesoennichsen wants to merge 4 commits intomainfrom
feat/smart-save-to
Open

feat: smart saveTo with full path support#62
mikesoennichsen wants to merge 4 commits intomainfrom
feat/smart-save-to

Conversation

@mikesoennichsen
Copy link
Copy Markdown
Collaborator

@mikesoennichsen mikesoennichsen commented Apr 9, 2026

Summary

saveTo now accepts a full file path ending in .json in addition to a directory path.

// Directory mode (existing behavior)
client.extract({ markdown: stream, saveTo: './output' })
// → ./output/doc_extract_output.json

// Full path mode (new)
client.extract({ markdown: result.markdown, saveTo: './output/my_result.json' })
// → ./output/my_result.json

Companion PR: landing-ai/ade-python#85

Test plan

  • 17 unit tests passing
  • tsc --noEmit clean
  • Manual: chain parse()extract() with both saveTo modes

🤖 Generated with Claude Code

saveTo now accepts either a directory path (auto-generates filename as
{input_file}_{method}_output.json) or a full file path ending in .json
(saves to that exact path). Parent directories are created automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 “smart” saveTo handling so callers can either provide an output directory (existing behavior) or an explicit .json filepath (new behavior), improving usability for chained workflows without an input filename.

Changes:

  • Update _saveResponse to detect saveTo ending with .json and write to that exact file path (creating parent dirs as needed).
  • Preserve directory-mode behavior when saveTo is not a .json path (auto-generated output filename).
  • Add tests covering exact-path mode, parent directory creation, and JSON formatting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/client.ts Implements exact .json path support in _saveResponse while preserving directory mode.
tests/save-to.test.ts Adds coverage for the new .json full-path saving behavior.

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

mikesoennichsen and others added 3 commits April 9, 2026 13:49
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When no input filename can be derived (e.g. raw markdown string), the
auto-generated name is now {method}_output.json instead of the redundant
output_{method}_output.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants