programming_cli_core_sdk 2.1.1
programming_cli_core_sdk: ^2.1.1 copied to clipboard
Core abstractions shared across the Zenscrap CLI SDK packages.
2.1.1 #
Bug Fixes #
- Fixed "No pubspec.yaml file found" error during schema validation: The schema test functionality now creates a minimal
pubspec.yamlfile in the chat's working directory before runningdart test. This ensures the Dart test runner can execute properly even in isolated/scoped directories.
Technical Details #
- Added
schemaPubspecFilePathgetter to track the pubspec.yaml location _setupSchemaFiles()now creates a temporarypubspec.yamlwith thetestpackage dependency_removeSchemaFiles()now cleans up the temporarypubspec.yamlfile- The pubspec uses a unique package name (
cli_schema_test_$chatNanoId) to prevent conflicts
Context #
When using schema validation (sendMessageWithSchema), the AI is instructed to run dart test to validate its JSON output. Previously, this would fail with "No pubspec.yaml file found" when the chat was scoped to an isolated directory (ai_generated_files/$chatNanoId/). Now, a minimal pubspec.yaml is automatically created and cleaned up, allowing the test to run successfully.
2.1.0 #
Features #
- Made
chatNanoIdpublic: The_chatNanoIdfield is now public, allowing implementations to access the unique chat identifier for scoping file operations. - Added
updateOptionsmethod: New method allows updating chat options after the chat has been created, enabling dynamic configuration changes like setting the working directory. - Added
aiGeneratedFilesDirgetter: Smart getter that returns the correct directory for AI-generated files, handling both cases wherecwdis explicitly set (web scrapper implementations) and when it's not (direct SDK usage).
Improvements #
- Optimized cleanup process: Replaced file-by-file deletion with directory-level deletion. The
_cleanupTemporaryFilesmethod now deletes the entire AI-generated files directory recursively, which is more efficient and ensures complete cleanup. - Fixed nested directory issue: Corrected path construction to prevent creating nested
ai_generated_files/directories. Whencwdis set, paths now use it directly instead of adding the scoped path again. - Better scoping of file operations: With the public
chatNanoIdandupdateOptionsmethod, implementations can now properly scope all CLI operations to their specific chat directory, preventing files from being created at the root level.
Breaking Changes #
_chatNanoIdis nowchatNanoId(public instead of private).
2.0.1 #
Critical Bug Fixes #
- Fixed file cleanup leak in
_handleTemporaryFilesWrapper: Refactored to use try-finally pattern to guarantee cleanup of temporary files and schema test files in ALL scenarios, including:- When schema validation fails after retry (previously leaked files at line 200-203)
- When exceptions are thrown during processing
- When early returns occur in the flow
- Added tracking flags:
schemaFilesCreatedandtemporaryFilesCreatedflags ensure cleanup only runs when files were actually created - Removed redundant cleanup calls: Cleanup now happens exclusively in the
finallyblock, ensuring it runs exactly once regardless of success, failure, or early return
Impact #
This fix ensures that ai_generated_files/ directory never accumulates leftover test files or schema response files, preventing disk space leaks and maintaining a clean working directory.
2.0.0 #
Breaking Changes #
- Removed
apiKeyfromCodingCliInterface: API keys are no longer stored in the interface constructor. Each implementation now manages its own API key. - Constructor change:
CodingCliInterfaceno longer requires anapiKeyparameter in its constructor.
Added #
- New method
addApiKeyToEnvironment(String apiKey): Abstract method that implementations must override to add their respective API keys to environment variables. This ensures CLI tools can authenticate without requiring login sessions.
Migration Guide #
- When creating SDK instances (Codex, Claude, Gemini), you still pass the API key to their constructors.
- Call
addApiKeyToEnvironment(apiKey)after creating the SDK instance to ensure the CLI can authenticate. - Example:
final codex = Codex(apiKey: 'your-api-key'); await codex.addApiKeyToEnvironment('your-api-key');
1.0.0 #
- Initial version.