Skip to content

Commit ae2167c

Browse files
Copilothckhanhautofix-ci[bot]Copilot
authored
Complete repository conversion from what-the-fetch to format-prompt (#3)
* Initial plan * Update package.json and create tests for format-prompt Co-authored-by: hckhanh <6380436+hckhanh@users.noreply.github.com> * Update documentation for format-prompt Co-authored-by: hckhanh <6380436+hckhanh@users.noreply.github.com> * Update all remaining what-the-fetch references to format-prompt Co-authored-by: hckhanh <6380436+hckhanh@users.noreply.github.com> * Update dependencies and improve whitespace handling in prompt * Add tests for tab-based code indentation Co-authored-by: hckhanh <6380436+hckhanh@users.noreply.github.com> * Remove dependency optimization step from autofix.yml * Update dependencies to latest versions * Update autofix.yml to use 'bun format' for code formatting * Update autofix.yml to install dependencies and change formatting command * [autofix.ci] apply automated fixes * Update src/index.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/prompt.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix grammar errors and update SECURITY.md for format-prompt Co-authored-by: hckhanh <6380436+hckhanh@users.noreply.github.com> * Add changeset for repository conversion Co-authored-by: hckhanh <6380436+hckhanh@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hckhanh <6380436+hckhanh@users.noreply.github.com> Co-authored-by: Khánh Hoàng <hi@khanh.id> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5c848be commit ae2167c

24 files changed

+862
-3967
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"access": "restricted",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
10-
"ignore": ["what-the-fetch-docs"]
10+
"ignore": ["format-prompt-docs"]
1111
}

.changeset/thirty-meals-feel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"format-prompt": patch
3+
---
4+
5+
Complete repository conversion from what-the-fetch to format-prompt. This is a new library for formatting prompts for LLMs with optimal token usage.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Before submitting a pull request, please make sure the following is done:
66
7-
1. Fork [the repository](https://github.com/hckhanh/what-the-fetch) and create your branch from `main`.
7+
1. Fork [the repository](https://github.com/hckhanh/format-prompt) and create your branch from `main`.
88
2. Run `npm install` in the repository root.
99
3. If you've fixed a bug or added code that should be tested, add tests!
1010
4. Ensure the test suite passes (`npm test`).

.github/copilot-instructions.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Copilot Instructions for what-the-fetch
1+
# Copilot Instructions for format-prompt
22

33
## Project Overview
44

5-
This is **what-the-fetch**, a type-safe API client library with schema validation using Standard Schema. The project provides end-to-end type inference for API requests and responses, integrating with popular schema validation libraries like Zod, Valibot, and ArkType.
5+
This is **format-prompt**, a utility library for formatting prompts for cleaner presentation and optimal token usage. The project removes unnecessary whitespace and line breaks while preserving the intended structure of prompts.
66

77
## Installation & Setup
88

@@ -42,29 +42,28 @@ npm run format
4242
### Testing
4343
- Tests are located in the `test/` directory
4444
- Use Vitest as the test framework
45-
- Mock external dependencies (e.g., `global.fetch`)
4645
- Test file naming: `*.test.ts`
4746
- Include tests for:
4847
- Happy paths
49-
- Error cases
5048
- Edge cases
51-
- Type safety validations
49+
- Whitespace handling
50+
- Interpolation
5251

5352
## Project Structure
5453

5554
```
5655
src/
57-
├── index.ts # Main export and createFetch function
58-
├── types.ts # Type definitions
59-
└── utils.ts # Utility functions (e.g., validation)
56+
└── index.ts # Main export and prompt function
6057
test/
61-
└── createFetch.test.ts # Test suite
58+
└── prompt.test.ts # Test suite
59+
benchmark/
60+
└── prompt.bench.ts # Benchmarks
6261
```
6362

6463
## Key Dependencies
6564

66-
- **@standard-schema/spec**: Standard Schema specification for validation
67-
- **fast-url**: URL building and parameter substitution
65+
- **string-collapse-leading-whitespace**: Collapse leading whitespace
66+
- **string-collapse-white-space**: Collapse general whitespace
6867
- **vitest**: Testing framework
6968
- **biome**: Linting and formatting
7069
- **tsdown**: TypeScript bundler powered by rolldown
@@ -111,15 +110,15 @@ The CLI will ask you:
111110
- **Be descriptive**: Write summaries that explain what changed and why
112111
- **Include examples**: For new features, include code examples in the changeset
113112
- **One changeset per PR**: Generally, create one changeset per pull request
114-
- **Edit the changeset file**: After creation, you can manually edit `.changeset/*.md` to add more details, examples, or formatting
113+
- **Edit the changeset file**: After creation, you can manually edit `.changeset/*.md` to add more details
115114

116115
### Changeset File Format
117116

118117
Changesets are stored in `.changeset/*.md` files with the following format:
119118

120119
```markdown
121120
---
122-
"what-the-fetch": minor
121+
"format-prompt": minor
123122
---
124123

125124
Brief summary of the change
@@ -131,21 +130,20 @@ More details, code examples, migration guides, etc.
131130

132131
## API Design Principles
133132

134-
- **Type Safety First**: All APIs must provide full type inference
135-
- **Standard Schema Compatible**: Work with any schema library implementing Standard Schema
136-
- **Minimal Surface Area**: Keep the API simple and focused
133+
- **Simplicity First**: The API should be simple and intuitive
134+
- **Template Literal Support**: Work seamlessly with JavaScript template literals
135+
- **Minimal Surface Area**: Keep the API focused on one thing - formatting prompts
137136
- **Zero Breaking Changes**: Maintain backward compatibility
138137
- **Bundle Size**: Keep dependencies minimal and bundle size small
139138

140139
## Common Tasks
141140

142141
### Adding a New Feature
143-
1. Define types in `types.ts` if needed
144-
2. Implement functionality in `index.ts` or `utils.ts`
145-
3. Add JSDoc comments with examples
146-
4. Write comprehensive tests
147-
5. Update README.md if adding public APIs
148-
6. Add a changeset with `npx changeset add` (select "minor")
142+
1. Implement functionality in `src/index.ts`
143+
2. Add JSDoc comments with examples
144+
3. Write comprehensive tests
145+
4. Update README.md if adding public APIs
146+
5. Add a changeset with `npx changeset add` (select "minor")
149147

150148
### Fixing a Bug
151149
1. Write a failing test that reproduces the bug
@@ -165,6 +163,4 @@ More details, code examples, migration guides, etc.
165163
- This project uses **Bun** in CI but supports all package managers
166164
- The package is published to both npm and JSR (Deno)
167165
- The library must remain framework-agnostic
168-
- Response validation happens automatically when schemas are provided
169-
- Default method is GET; POST is used when body is present
170-
- Custom headers merge with default headers (Content-Type: application/json)
166+
- The function uses string manipulation utilities for optimal performance

.github/workflows/autofix.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
uses: SocketDev/action@4337a545deecc20f19a909e52db7a2f6ba292f42 # v1.2.0
2626
with:
2727
mode: firewall
28-
- name: Optimize dependencies with @socketregistry overrides
29-
run: socket optimize
28+
- name: Install dependencies
29+
run: sfw bun install
3030
- name: Format code
3131
run: bun biome check --write
3232
- name: Fix package.json

SECURITY.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We release patches for security vulnerabilities. Currently supported versions:
1111

1212
## Reporting a Vulnerability
1313

14-
We take the security of what-the-fetch seriously. If you believe you have found a security vulnerability, please report it to us as described below.
14+
We take the security of format-prompt seriously. If you believe you have found a security vulnerability, please report it to us as described below.
1515

1616
### Please do NOT:
1717

@@ -41,23 +41,21 @@ Please include the following information in your report:
4141

4242
## Security Best Practices
4343

44-
When using what-the-fetch in your applications:
44+
When using format-prompt in your applications:
4545

46-
1. **Keep Dependencies Updated**: Regularly update to the latest version of what-the-fetch to receive security patches
47-
2. **Input Validation**: Always validate user input before passing it to API calls, even with schema validation enabled
48-
3. **Use TypeScript**: Take advantage of TypeScript's type safety to catch potential issues at compile time
49-
4. **Schema Validation**: Ensure your schemas properly validate all response data to prevent unexpected data from being processed
46+
1. **Keep Dependencies Updated**: Regularly update to the latest version of format-prompt to receive security patches
47+
2. **Use TypeScript**: Take advantage of TypeScript's type safety to catch potential issues at compile time
48+
3. **Sanitize Interpolated Values**: Be cautious when interpolating user-provided values into prompts to prevent prompt injection attacks
5049

5150
## Scope
5251

5352
The following are considered in scope for security reports:
5453

55-
- Schema validation bypass vulnerabilities
5654
- Type safety violations
57-
- URL injection vulnerabilities
58-
- XSS vectors through API responses
59-
- Data leakage through improper validation
60-
- Any behavior that could lead to security issues in applications using what-the-fetch
55+
- String manipulation vulnerabilities that could lead to prompt injection
56+
- XSS vectors through improper string handling
57+
- Data leakage through template literal interpolation
58+
- Any behavior that could lead to security issues in applications using format-prompt
6159

6260
## Out of Scope
6361

@@ -82,4 +80,4 @@ For any questions about this security policy, please contact: hi@khanh.id
8280

8381
## Learn More
8482

85-
For general bugs and feature requests, please use our [GitHub Issues](https://github.com/hckhanh/what-the-fetch/issues).
83+
For general bugs and feature requests, please use our [GitHub Issues](https://github.com/hckhanh/format-prompt/issues).

benchmark/createFetch.bench.ts

Lines changed: 0 additions & 205 deletions
This file was deleted.

0 commit comments

Comments
 (0)