Skip to content

Commit d0982a2

Browse files
committed
new agents
1 parent b6b74ca commit d0982a2

File tree

1 file changed

+67
-10
lines changed

1 file changed

+67
-10
lines changed

AGENTS.md

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11

22
# Project Coding Guidelines
33

4-
NOTICE: This file is generated using AGENTS.sh and should NEVER be manually updated.
5-
6-
This file contains all coding guidelines and standards for this project.
4+
NOTICE: AGENTS.md is generated using AGENTS.sh and should NEVER be manually updated.
75

86
---
97

108

9+
1110
when summarizing changes at the end of the message, be super short, a few words and in bullet points, use bold text to highlight important keywords. use markdown.
1211

1312
please ask questions and confirm assumptions before generating complex architecture code.
@@ -22,6 +21,12 @@ NEVER add comments unless I tell you
2221

2322
always use kebab case for new filenames. never use uppercase letters in filenames
2423

24+
25+
## see files in the repo
26+
27+
use `git ls-files | tree --fromfile` to see files in the repo. this command will ignore files ignored by git
28+
29+
2530
---
2631

2732
# typescript
@@ -58,6 +63,8 @@ always use kebab case for new filenames. never use uppercase letters in filename
5863

5964
- NEVER start the development server with pnpm dev yourself. there is no reason to do so, even with &
6065

66+
- When creating classes do not add setters and getters for a simple private field. instead make the field public directly so user can get it or set it himself without abstractions on top
67+
6168
- if you encounter typescript lint errors for an npm package, read the node_modules/package/\*.d.ts files to understand the typescript types of the package. if you cannot understand them, ask me to help you with it.
6269

6370
```ts
@@ -117,6 +124,7 @@ const users: User[] = []
117124

118125
remember to always add the explicit type to avoid unexpected type inference.
119126

127+
120128
---
121129

122130
# package manager: pnpm with workspace
@@ -129,6 +137,12 @@ if you need to install packages always use pnpm
129137

130138
instead of adding packages directly in package.json use `pnpm install package` inside the right workspace folder. NEVER manually add a package by updating package.json
131139

140+
## updating a package
141+
142+
when i ask you to update a package always run `pnpm update -r packagename`. to update to latest also add --latest
143+
144+
Do not do `pnpm add packagename` to update a package. only to add a missing one. otherwise other packages versions will get out of sync.
145+
132146
## fixing duplicate pnpm dependencies
133147

134148
sometimes typescript will fail if there are 2 duplicate packages in the workspace node_modules. this can happen in pnpm if a package is used in 2 different places (even if inside a node_module package, transitive dependency) with a different set of versions for a peer dependency
@@ -234,6 +248,7 @@ in this case, we could have only updated @better-auth/stripe to fix the issue to
234248

235249
if after doing this we still have duplicate packages, you will have to ask the user for help. you can try deleting the node_modules and restarting the approach, but it rarely helps.
236250

251+
237252
---
238253

239254
## reading github repositories
@@ -243,12 +258,13 @@ you can use gitchamber.com to read repo files. run `curl https://gitchamber.com`
243258
### vercel ai sdk documentation
244259

245260
when working with the vercel ai sdk, you can fetch the latest docs using:
246-
https://gitchamber.com/repos/vercel/ai/main/files
261+
https://gitchamber.com/repos/repos/vercel/ai/main/files
247262

248263
use gitchamber to read the .md files using curl
249264

250265
you can swap out the topic with text you want to search docs for. you can also limit the total results returned with the param token to limit the tokens that will be added to the context window
251266

267+
252268
---
253269

254270
## react
@@ -455,8 +471,6 @@ in typescript never use process.env directly. instead find the closest `env.ts`
455471
456472
the cli uses cac npm package.
457473
458-
notice that if you add a route in the spiceflow server you will need to run `pnpm --filter website gen-client` to update the apiClient inside cli.
459-
460474
461475
---
462476
@@ -823,14 +837,22 @@ use lucide-react to import icons. always add the Icon import name, for example `
823837

824838
---
825839

840+
# spiceflow
841+
842+
before writing or updating spiceflow related code always execute this command to get Spiceflow full documentation: `curl -s https://gitchamber.com/repos/remorses/spiceflow/main/files/README.md`
843+
844+
spiceflow is an API library similar to hono, it allows you to write api servers using whatwg requests and responses
845+
846+
use zod to create schemas and types that need to be used for tool inputs or spiceflow API routes.
847+
826848
## calling the server from the client
827849

850+
you can obtain a type safe client for the API using `createSpiceflowClient` from `spiceflow/client`
851+
828852
for simple routes that only have one interaction in the page, for example a form page, you should use react-router forms and actions to interact with the server.
829853

830854
but when you do interactions from a component that can be rendered from multiple routes, or simply is not implemented inside a route page, you should use spiceflow client instead.
831855

832-
the website exposes an API via spiceflow. here is spiceflow docs: https://getspiceflow.com/
833-
834856
> ALWAYS use the fetch tool to get the latest docs if you need to implement a new route in a spiceflow API app server or need to add a new rpc call with a spiceflow api client!
835857

836858
spiceflow has support for client-side type-safe rpc. use this client when you need to interact with the server from the client, for example for a settings save deep inside a component. here is example usage of it
@@ -848,6 +870,24 @@ spiceflow is a little-known api framework. if you add server routes to a file th
848870

849871
this url returns a single long documentation that covers your use case. always fetch this document so you know how to use spiceflow. spiceflow is different from hono and other api frameworks, that's why you should ALWAYS fetch the docs first before using it
850872

873+
## using spiceflow client in published public workspace packages
874+
875+
usually you can just import the App type from the server workspace to create the client with createSpiceflowClient
876+
877+
if you want to use the spiceflow client in a published package instead we will use the pattern of generating .d.ts and copying these in the workspace package, this way the package does not need to depend on unpublished private server package.
878+
879+
example:
880+
881+
```json
882+
{
883+
"scripts": {
884+
"gen-client": "export DIR=../plugin-mcp/src/generated/ && cd ../website && tsc --incremental && cd ../plugin-mcp && rm -rf $DIR && mkdir -p $DIR && cp ../website/dist/src/lib/api-client.* $DIR"
885+
}
886+
}
887+
```
888+
889+
notice that if you add a route in the spiceflow server you will need to run `pnpm --filter website gen-client` to update the apiClient inside cli.
890+
851891

852892
---
853893

@@ -874,9 +914,26 @@ if i ask you to test something in the browser, know that the website dev server
874914

875915
## zod
876916

877-
use zod to create schemas and types that need to be used for tool inputs or spiceflow API routes.
878-
879917
when you need to create a complex type that comes from a prisma table, do not create a new schema that tries to recreate the prisma table structure. instead just use `z.any() as ZodType<PrismaTable>)` to get type safety but leave any in the schema. this gets most of the benefits of zod without having to define a new zod schema that can easily go out of sync.
880918

919+
## converting zod schema to jsonschema
920+
921+
you MUST use the built in zod v4 toJSONSchema and not the npm package `zod-to-json-schema` which is outdated and does not support zod v4.
922+
923+
```ts
924+
import { toJSONSchema } from "zod";
925+
926+
const mySchema = z.object({
927+
id: z.string().uuid(),
928+
name: z.string().min(3).max(100),
929+
age: z.number().min(0).optional(),
930+
});
931+
932+
const jsonSchema = toJSONSchema(mySchema, {
933+
removeAdditionalStrategy: "strict",
934+
});
935+
```
936+
937+
881938
---
882939

0 commit comments

Comments
 (0)