kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: init skeleton
commit
6743740d6f
|
@ -0,0 +1,143 @@
|
|||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
---
|
||||
description: General TypeScript coding guidelines
|
||||
globs:
|
||||
---
|
||||
|
||||
## General
|
||||
|
||||
- Write elegant, concise, and readable code
|
||||
- Prefer `const` over `let` (never use `var`)
|
||||
- Use kebab-case for file and directory names
|
||||
- Use clear, descriptive names for variables, functions, and components
|
||||
|
||||
## Modules
|
||||
|
||||
### Imports & Exports
|
||||
|
||||
- Always use ESM `import` and `export` (never use CJS `require`)
|
||||
- File imports should never use an extension (NOT `.js`, `.ts` or `.tsx`).
|
||||
- GOOD examples:
|
||||
- `import { Foo } from './foo'`
|
||||
- `import { type Route } from './types/root'`
|
||||
- `import zod from 'zod'`
|
||||
- `import { logger } from '~/types'`
|
||||
- BAD examples:
|
||||
- `import { Foo } from './foo.js'`
|
||||
- `import { type Route } from './types/root.js'`
|
||||
- `import { Foo } from './foo.ts'`
|
||||
- Always prefer named exports over default exports
|
||||
|
||||
### Packages
|
||||
|
||||
All packages must follow these `package.json` rules:
|
||||
|
||||
- `type` must be set to `module`
|
||||
|
||||
#### Directory Structure
|
||||
|
||||
This project has the following structure:
|
||||
|
||||
- A `src/` directory containing the core source code.
|
||||
- A single entrypoint in index.ts that exports the package's public API.
|
||||
- Place test helpers, utilities, or mocks in `src/test/` with a single entrypoint in `src/test/index.ts`.
|
||||
- Tests should be placed beside source code like `src/my-file.ts` and `src/my-file.test.ts` (NOT `src/test/my-file.test.ts` or `test/my-file.test.ts`).
|
||||
|
||||
## TypeScript
|
||||
|
||||
- Avoid semicolons at the end of lines
|
||||
- Use TypeScript's utility types (e.g., `Partial`, `Pick`, `Omit`) to manipulate existing types
|
||||
- Create custom types for complex data structures used throughout the application
|
||||
- If possible, avoid using `any`/`unknown` or casting values like `(value as any)` or `value!` in TypeScript outside of test files e.g. `*.test.ts` or test fixtures e.g. `**/test-data.ts`.
|
||||
- Don't rely on `typeof`, `ReturnType<>`, `Awaited<>`, etc for complex type inference (it's ok for simple types)
|
||||
- Use `as const` for better type inference
|
||||
- Functions should accept an object parameter instead of multiple parameters
|
||||
- Good examples:
|
||||
```ts
|
||||
function myFunction({ foo, bar }: { foo: boolean; bar: string }) {}
|
||||
function VideoPlayer({ sid }: { sid: string }) {}
|
||||
```
|
||||
- Bad examples:
|
||||
```ts
|
||||
function myFunction(foo: boolean, bar: string, baz: number) {}
|
||||
```
|
||||
- Arguments should generally be destructured in the function definition, not the function body.
|
||||
- Good example:
|
||||
```ts
|
||||
function myFunction({ foo, bar }: { foo: boolean; bar: string }) {}
|
||||
```
|
||||
- Bad example:
|
||||
```ts
|
||||
function myFunction(args: { foo: boolean; bar: string }) {
|
||||
const { foo, bar } = args
|
||||
}
|
||||
```
|
||||
- Zod should be used to parse untrusted data, but not for data that is trusted like function arguments
|
||||
- Zod unions should always be used instead of enums
|
||||
- For example, this union `z.union([z.literal('youtube'), z.literal('spotify')])` is better than this enum `z.enum(['youtube', 'spotify'])`
|
||||
- Promises (and `async` functions which implicitly create Promises) must always be properly handled, either via:
|
||||
- Using `await` to wait for the Promise to resolve successfully
|
||||
- Using `.then` or `.catch` to handle Promise resolution
|
||||
- Returning a Promise to a calling function which itself has to handle the Promise.
|
||||
|
||||
## Node.js
|
||||
|
||||
- Utilize the `node:` protocol when importing Node.js modules (e.g., `import fs from 'node:fs/promises'`)
|
||||
- Prefer promise-based APIs over Node's legacy callback APIs
|
||||
- Use environment variables for secrets (avoid hardcoding sensitive information)
|
||||
|
||||
### Web Standard APIs
|
||||
|
||||
Always prefer using standard web APIs like `fetch`, `WebSocket`, and `ReadableStream` when possible. Avoid redundant libraries (like `node-fetch`).
|
||||
|
||||
- Prefer the `fetch` API for making HTTP requests instead of Node.js modules like `http` or `https`
|
||||
- Use the native `fetch` API instead of `node-fetch` or polyfilled `cross-fetch`
|
||||
- Use the `ky` library for HTTP requests instead of `axios` or `superagent`
|
||||
- Use the WHATWG `URL` and `URLSearchParams` classes instead of the Node.js `url` module
|
||||
- Use `Request` and `Response` objects from the Fetch API instead of Node.js-specific request and response objects
|
||||
|
||||
## Error Handling
|
||||
|
||||
- Prefer `async`/`await` over `.then()` and `.catch()`
|
||||
- Always handle errors correctly (eg: `try`/`catch` or `.catch()`)
|
||||
- Avoid swallowing errors silently; always log or handle caught errors appropriately
|
||||
|
||||
## Comments
|
||||
|
||||
Comments should be used to document and explain code. They should complement the use of descriptive variable and function names and type declarations.
|
||||
|
||||
- Add comments to explain complex sections of code
|
||||
- Add comments that will improve the autocompletion preview in IDEs (eg: functions and types)
|
||||
- Don't add comments that just reword symbol names or repeat type declarations
|
||||
- Use **JSDoc** formatting for comments (not TSDoc or inline comments)
|
||||
|
||||
## Logging
|
||||
|
||||
- Just use `console` for logging.
|
||||
|
||||
## Testing
|
||||
|
||||
### Unit Testing
|
||||
|
||||
- **All unit tests should use Vitest**
|
||||
- DO NOT attempt to install or use other testing libraries like Jest
|
||||
- Write unit tests for individual components and utility functions
|
||||
- Test files should be named `[target].test.ts` and placed in the same directory as the code they are testing (NOT a separate directory)
|
||||
- Good example: `src/my-file.ts` and `src/my-file.test.ts`
|
||||
- Bad example: `src/my-file.ts` and `src/test/my-file.test.ts` or `test/my-file.test.ts` or `src/__tests__/my-file.test.ts`
|
||||
- Tests should be run with `pnpm test:unit`
|
||||
- It's acceptable to use `any`/`unknown` in test files (such as `*.test.ts`) or test fixtures (like `**/test-data.ts`) to facilitate mocking or stubbing external modules or partial function arguments, referencing the usage guidelines in the TypeScript section.
|
||||
|
||||
### Test Coverage
|
||||
|
||||
- Test critical business logic and edge cases
|
||||
- Don't add tests for trivial code or just to increase test coverage
|
||||
- Don't make tests too brittle or flaky by relying on implementation details
|
||||
|
||||
## Git
|
||||
|
||||
- When possible, combine the `git add` and `git commit` commands into a single `git commit -am` command, to speed things up
|
|
@ -0,0 +1,10 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
|
@ -0,0 +1,6 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# This is an example .env file.
|
||||
#
|
||||
# All of these environment vars must be defined either in your environment or in
|
||||
# a local .env file in order to run this project.
|
||||
# ------------------------------------------------------------------------------
|
|
@ -0,0 +1 @@
|
|||
github: [transitive-bullshit]
|
|
@ -0,0 +1,28 @@
|
|||
name: CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test Node.js ${{ matrix.node-version }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
node-version:
|
||||
- 18
|
||||
- 22
|
||||
- 23
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'pnpm'
|
||||
|
||||
- run: pnpm install --frozen-lockfile --strict-peer-dependencies
|
||||
- run: pnpm build
|
||||
- run: pnpm test
|
|
@ -0,0 +1,44 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
.next/
|
||||
|
||||
# production
|
||||
build/
|
||||
dist/
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# turbo
|
||||
.turbo
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
.env
|
||||
|
||||
old/
|
||||
out/
|
|
@ -0,0 +1,2 @@
|
|||
enable-pre-post-scripts=true
|
||||
package-manager-strict=false
|
|
@ -0,0 +1,3 @@
|
|||
import { config } from '@fisch0920/config/eslint'
|
||||
|
||||
export default [ ...config ]
|
|
@ -0,0 +1,3 @@
|
|||
PROPRIETARY License
|
||||
|
||||
Copyright (c) 2025 Agentic; All rights reserved.
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name": "agentic-platform",
|
||||
"private": true,
|
||||
"author": "Travis Fischer <travis@transitivebullsh.it>",
|
||||
"license": "PROPRIETARY",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic-platform.git"
|
||||
},
|
||||
"packageManager": "pnpm@10.7.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "turbo build",
|
||||
"dev": "turbo dev --continue",
|
||||
"clean": "turbo clean",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:format": "prettier --write \"**/*.{js,ts,tsx}\"",
|
||||
"test": "turbo test",
|
||||
"test:format": "prettier --check \"**/*.{js,ts,tsx}\"",
|
||||
"test:lint": "turbo test:lint",
|
||||
"test:typecheck": "turbo test:typecheck",
|
||||
"test:unit": "turbo test:unit",
|
||||
"pretest": "run-s build",
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"prepare": "simple-git-hooks"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fisch0920/config": "catalog:",
|
||||
"@types/node": "catalog:",
|
||||
"del-cli": "catalog:",
|
||||
"dotenv": "catalog:",
|
||||
"eslint": "catalog:",
|
||||
"lint-staged": "catalog:",
|
||||
"npm-run-all2": "catalog:",
|
||||
"only-allow": "catalog:",
|
||||
"prettier": "catalog:",
|
||||
"simple-git-hooks": "catalog:",
|
||||
"tsup": "catalog:",
|
||||
"tsx": "catalog:",
|
||||
"turbo": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:",
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"prettier": "@fisch0920/config/prettier",
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "npx lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx}": [
|
||||
"prettier --ignore-unknown --write",
|
||||
"eslint --fix"
|
||||
]
|
||||
}
|
||||
}
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,30 @@
|
|||
packages:
|
||||
- packages/*
|
||||
- services/*
|
||||
catalog:
|
||||
'@ai-sdk/openai': ^1.3.6
|
||||
'@fisch0920/config': ^1.0.2
|
||||
'@modelcontextprotocol/sdk': ^1.8.0
|
||||
'@types/node': ^22.14.0
|
||||
ai: ^4.2.11
|
||||
cleye: ^1.3.4
|
||||
del-cli: ^6.0.0
|
||||
dotenv: ^16.4.7
|
||||
eslint: ^9.23.0
|
||||
exit-hook: ^4.0.0
|
||||
ky: ^1.8.0
|
||||
lint-staged: ^15.5.0
|
||||
npm-run-all2: ^7.0.2
|
||||
only-allow: ^1.2.1
|
||||
p-map: ^7.0.3
|
||||
p-throttle: 6.2.0 # pinned for now
|
||||
prettier: ^3.5.3
|
||||
restore-cursor: ^5.1.0
|
||||
simple-git-hooks: ^2.12.1
|
||||
tsup: ^8.4.0
|
||||
tsx: ^4.19.3
|
||||
turbo: ^2.5.0
|
||||
type-fest: ^4.39.1
|
||||
typescript: ^5.8.2
|
||||
vitest: ^3.1.1
|
||||
zod: ^3.24.2
|
|
@ -0,0 +1,14 @@
|
|||
<p>
|
||||
<a href="https://github.com/transitive-bullshit/agentic-platform/actions/workflows/main.yml"><img alt="Build Status" src="https://github.com/transitive-bullshit/agentic-platform/actions/workflows/main.yml/badge.svg" /></a>
|
||||
<a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a>
|
||||
</p>
|
||||
|
||||
# Agentic <!-- omit from toc -->
|
||||
|
||||
**TODO**
|
||||
|
||||
## License
|
||||
|
||||
UNLICENSED PROPRIETARY © [Agentic](https://x.com/transitive_bs)
|
||||
|
||||
To stay up to date or learn more, follow [@transitive_bs](https://x.com/transitive_bs) on Twitter.
|
|
@ -0,0 +1,16 @@
|
|||
import { defineConfig } from 'tsup'
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
entry: ['src/index.ts'],
|
||||
outDir: 'dist',
|
||||
target: 'node18',
|
||||
platform: 'node',
|
||||
format: ['esm'],
|
||||
splitting: false,
|
||||
sourcemap: true,
|
||||
minify: false,
|
||||
shims: true,
|
||||
dts: true
|
||||
}
|
||||
])
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"ui": "stream",
|
||||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": ["dist/**"],
|
||||
"outputLogs": "new-only"
|
||||
},
|
||||
"clean": {
|
||||
"cache": false,
|
||||
"dependsOn": ["^clean"]
|
||||
},
|
||||
"test": {
|
||||
"dependsOn": ["test:format", "test:lint", "test:typecheck", "test:unit"]
|
||||
},
|
||||
"test:lint": {
|
||||
"dependsOn": ["^test:lint"],
|
||||
"outputLogs": "errors-only"
|
||||
},
|
||||
"test:typecheck": {
|
||||
"dependsOn": ["^test:typecheck"],
|
||||
"outputLogs": "errors-only"
|
||||
},
|
||||
"test:unit": {
|
||||
"dependsOn": ["^test:unit"],
|
||||
"outputLogs": "errors-only"
|
||||
},
|
||||
"test:format": {
|
||||
"dependsOn": ["//#test:format", "^test:format"]
|
||||
},
|
||||
"//#test:format": {},
|
||||
"dev": {
|
||||
"cache": false,
|
||||
"persistent": true
|
||||
}
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue