Files
smartrequest/readme.plan.md
Juergen Kunz bbb57004d9
Some checks failed
Default (tags) / security (push) Failing after 24s
Default (tags) / test (push) Failing after 13s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
BREAKING CHANGE(core): major architectural refactoring with fetch-like API
2025-07-27 21:23:20 +00:00

53 lines
2.0 KiB
Markdown

# Smartrequest Refactoring Plan
Command to reread CLAUDE.md: `cat /home/philkunz/.claude/CLAUDE.md`
## Objective
Refactor smartrequest to use native fetch-like API with a streamlined core that supports unix sockets and keep-alive.
## Architecture Overview
- Rename `legacy/` to `core/` and remove "smartrequest." prefix from filenames
- Create a modern Response class similar to fetch API
- Use core as foundation for modern API, not as legacy adapter
- Maintain unix socket and keep-alive support
## Task Checklist
- [x] Reread /home/philkunz/.claude/CLAUDE.md
- [x] Create ts/core directory structure with request.ts, types.ts, and plugins.ts
- [x] Migrate core request logic from legacy to core/request.ts
- [x] Create modern Response class with fetch-like API
- [x] Update modern API to use new core module
- [x] Create legacy adapter for backward compatibility
- [x] Update exports in ts/index.ts
- [x] Run tests and fix any issues
- [x] Clean up old legacy files
## Implementation Details
### Core Module Structure
```
ts/core/
├── request.ts # Core HTTP/HTTPS request logic with unix socket support
├── types.ts # Core interfaces and types
├── plugins.ts # Dependencies (http, https, agentkeepalive, etc.)
└── response.ts # Modern Response class
```
### Response Class API
The new Response class will provide fetch-like methods:
- `json()`: Promise<T> - Parse response as JSON
- `text()`: Promise<string> - Get response as text
- `arrayBuffer()`: Promise<ArrayBuffer> - Get response as ArrayBuffer
- `stream()`: ReadableStream - Get response as stream
- `ok`: boolean - Status is 2xx
- `status`: number - HTTP status code
- `statusText`: string - HTTP status text
- `headers`: Headers - Response headers
### Migration Strategy
1. Move core request logic without breaking changes
2. Create Response wrapper that provides modern API
3. Update SmartRequestClient to use new core
4. Add legacy adapter for backward compatibility
5. Ensure all tests pass throughout migration