Skip to content

Commit 9f0dcba

Browse files
chad-syntaxChad $yntax
andauthored
Chad/prototype (#1)
* start work on prototype * start of prototype, gen types, sdk, tests * added openrouter and prompt tester * start on more robust data schema and api routes * cursor written api endpoint tests * move files around, add placeholders for bullmq, rest services * fix nextjs public folder * slight adjustment to typegen cmd * path fixes for build passing * add supabase github actions, and first migration, delete agent rest api exploration * fix gh actions directory * seeding and migration changes * fucking tests man * add llm logs table * sign in with github auth * add tests to gh actions * try updating cli version for running tests * try latest? * refactored openrouter implementation to work with vault and code verifier per user * add pgTAP tests for new rpc fns * consolidate supabase migration check and tests into one workflow * rename workflow * test prompt running * change app to studio routes, add prompt pages from supabase, add llm logs view, RLS, and RLS tests * start onboarding logic * upgrade tailwind to v4, add onboarding logic * add org and project switcher, adjust client side context, consolidate migration, refactor user_keys into organization_keys * refactor routes * layout and context kinda fixed * adjust prompt schema, adjust openrouter calling, fix routing on some pages * fix ts err for now * openrouter clean up, org page listing users * prompts pages, template extracting, component consolidation * remove uneeded code * prompt editorial workflow fixes * add api tests * move util * shadcn overhaul, colors, and themes * refactor keys so orgs get an sdk api key on creation, allow for users to execute via api key, add api key reveal component to org page * fix prompt config saving, add additional openrouter typing * finish services refactor * progress towards github repo sync * start of sync work that was vibing so it probably doesnt work * refactor migration into using schemas * remove test migration, replace initial schema migration * attempt to pin postgres-version because of permissions error * Refactor GitHub App installation flow Create a pending installation record before redirecting to GitHub. Verify the installation on callback against the pending record and GitHub user installations. On successful verification, activate the installation and create repository records for all accessible repositories linked to the organization. * Create .prettierrc.json * Github App installation record flow working (still need to save and refresh provider tokens in future update, right now it will only work if we install the app directly after logging in before the token expires) Got github webhooks updating the installation record working with a github_webhook service account and role. * Remove supabase declarative schemas, still kinda buggy refactor installation validation to just check for the installation via app REST request rather than user oauth REST request adjust the connecting modal * Refactor: Centralize external URLs in routes utility Consolidate GitHub and OpenRouter URLs into a new `src/utils/routes.ts` utility for improved maintainability and consistency across the codebase. Update relevant services and components to use the new routes object. Pass project UUID during GitHub project connection. Add UI check for incomplete GitHub app installation. * Add GitHub repository sync functionality This provides project-level sync capability with GitHub and improves repository connection handling. Changes include: - Add sync button and action to project page - Enhance repository sync logic - Add unique constraint to active GitHub app installations - Fix installation ID handling - Also add tests for github_app_installations and project_repositories * Enhance project connection and repository handling This update introduces several improvements to the project connection process and repository management. Key changes include: - Added organization UUID to the connectProject function. - Updated the ConnectProjectModal to handle default repository IDs. - Enhanced GitHub service to store repository default branch information. - Improved error handling in prompt version creation and updates. - Refactored code for better readability and maintainability. These changes aim to streamline the integration with GitHub and improve user experience when connecting projects. * Update project_repositories test to include default branch This commit enhances the project_repositories test by adding the repository_default_branch field to the insert statements. The default branch is now set to 'main' for all test cases, ensuring consistency and accuracy in repository data handling during tests. * Refactor GitHub services and update user authentication handling This commit includes significant refactoring of the GitHub services, transitioning from a single GitHubService to multiple specialized services: GitHubAppService, GitHubWebhookService, and GitHubSyncService. Additionally, the user authentication process has been streamlined by replacing the initialize method with a getAuthUser method across various components and services. The connectProject action has been moved, and related imports have been updated accordingly. These changes aim to enhance code organization and improve the overall user experience. * Update environment configuration and enhance template variable handling This commit modifies the environment configuration to load the default `.env` file in the smee proxy and updates the template variable extraction logic to include a `default_value` field for all variables. Additionally, new types and relationships have been added to the Supabase schema for agentsmith events, for logging sync events. Added tests for variable compiling. * Big GitHubSync Service refactor Enhance project data retrieval and user notifications This commit updates the project data retrieval methods to use UUIDs consistently across the application, improving data integrity and reducing errors. Additionally, it introduces a toast notification system to inform users about project sync events, enhancing user experience. The layout has been updated to include a Toaster component for displaying notifications. Other minor refactorings and optimizations have been made throughout the codebase to improve maintainability. * Janky but working version of repo -> agentsmith syncing * complete sync service refactor * add support for global context * add erorr alert for authoring with missing globals * refactor a lot of fe component names, add studio header and hooks * styling refactors * logger refactor * add emoji mode * fix migration ordering * comment out test for now * adjust supabase migrations cicd yml * adjust landing styling --------- Co-authored-by: Chad $yntax <chad@ttpspodcast.com>
1 parent ba7f057 commit 9f0dcba

File tree

270 files changed

+30577
-4940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+30577
-4940
lines changed

.cursor/mcp.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"mcpServers": {
3+
"supabase": {
4+
"command": "npx",
5+
"args": [
6+
"-y",
7+
"@modelcontextprotocol/server-postgres",
8+
"postgresql://postgres:postgres@127.0.0.1:54322/postgres"
9+
]
10+
}
11+
}
12+
}

.cursor/rules/psql.mdc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
description:
3+
globs: *.sql, *.psql
4+
alwaysApply: false
5+
---
6+
1. All psql should be written in lowercase syntax
7+
2. When creating psql indices we should be as concise as we can, omitting defaults like the index name and the type. So we rather do `create index on table(column)` instead of `create idx_table_column on table using btree (column)`
8+
3. We should add indices to columns that reference other tables and columns that are queried frequently. e.g. if the column is `slug` it will most likely be queried on that instead of `id` so we should create an index on it.

.cursor/rules/typescript.mdc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
description: These rules are helpful for contrubuting to the front-end Nextjs code and the typescript code.
3+
globs: *.tsx, *.ts
4+
alwaysApply: false
5+
---
6+
7+
# Agentsmith tsx contributing rules for cursor AI
8+
9+
1. Only use named exports (`export const thing`, not `export default`)¹
10+
2. All pages should have a single top level page component in page-components
11+
3. All components should be in components folder either as a single file named after the component or in a subfolder named after the component¹
12+
4. All functions should be declared in const rocket format: `const rocket = async (payload: any) => { ... }`¹
13+
5. All props should be explicitly typed as `type ComponentProps = { ... }` and not typed inline ex: `props: { foo: any }` is bad `props: ComponentProps` is good. DO NOT deconstruct props, if a component has props, it should be named as `props` and deconstructed in the body of the component. Write `const foo = (props: FooProps) => { const { arg, arg2 } = props; }` rather than `const foo = ({ arg, arg2 }: FooProps) => {}`
14+
6. Only use icons from `lucide-react`
15+
7. Only use tailwind css
16+
8. Each component file should have at most 2 react components, any more than that and it should be split up into multiple component files/folders.
17+
9. Any links to pages that exist under the web-studio should be prefixed with /app
18+
10. All functions that take more than 1 argument, should use an `options` syntax instead of adding many arguments. i.e. `const foo = (options: FooOptions) => {}` rather than `const foo = (bar: string, baz: string, quux: string) => {}`
19+
11. If the response for a function is an object, then it should be typed separately rather than inline. i.e. `const foo = (): FooResult => {}` instead of `const foo = (): { foo: string; bar: string; baz: string } => {}`
20+
12. DO NOT edit any generated files within the `__generated__` folder.
21+
13. DO NOT create new types if they can be inferred from the supabase generated types OR can be inferred from the return of a supabase.from call using `Awaited<ReturnType><>`
22+
23+
24+
¹ Exception for the Nextjs page.tsx files. They should only have one default function export.
25+

.env.example

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# FREE_MODELS_ONLY=true
2+
3+
NEXT_PUBLIC_SITE_URL="http://localhost:3000"
4+
5+
NEXT_PUBLIC_SUPABASE_URL=
6+
NEXT_PUBLIC_SUPABASE_ANON_KEY=
7+
8+
NEXT_PUBLIC_POSTHOG_KEY=
9+
NEXT_PUBLIC_POSTHOG_HOST=
10+
11+
SUPABASE_AUTH_GITHUB_CLIENT_ID=
12+
SUPABASE_AUTH_GITHUB_SECRET=
13+
14+
SUPABASE_JWT_SECRET=
15+
16+
# used for testing local dev
17+
SMEE_WEBHOOK_PROXY_URL=
18+
19+
GITHUB_APP_NAME=
20+
GITHUB_APP_ID=
21+
GITHUB_APP_PRIVATE_KEY=
22+
GITHUB_APP_WEBHOOK_SECRET=
23+
GITHUB_WEBHOOK_SERVICE_USER_ID=
24+
25+
26+
# TESTING TURNSTILE LOCALLY
27+
# NEXT_PUBLIC_CF_TURNSTILE_SITE_KEY=1x00000000000000000000AA # Always passes visible
28+
# NEXT_PUBLIC_CF_TURNSTILE_SITE_KEY=2x00000000000000000000AB # Always blocks visible
29+
NEXT_PUBLIC_CF_TURNSTILE_SITE_KEY=1x00000000000000000000BB # Always passes invisible
30+
# NEXT_PUBLIC_CF_TURNSTILE_SITE_KEY=2x00000000000000000000BB # Always blocks invisible
31+
# NEXT_PUBLIC_CF_TURNSTILE_SITE_KEY=3x00000000000000000000FF # Forces an interactive challenge visible
32+
33+
# unused right now, but good to have in case we validate on our end
34+
CF_TURNSTILE_SECRET_KEY=1x0000000000000000000000000000000AA # Always passes
35+
# CF_TURNSTILE_SECRET_KEY=2x0000000000000000000000000000000AA # Always fails
36+
# CF_TURNSTILE_SECRET_KEY=3x0000000000000000000000000000000AA # Yields a "token already spent" error
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Supabase Tests
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
supabase_tests:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- uses: supabase/setup-cli@v1
15+
with:
16+
version: latest
17+
18+
- name: Overwrite Supabase db version
19+
run: |
20+
mkdir -p supabase/.temp
21+
echo "15.8.1.038" > supabase/.temp/postgres-version
22+
23+
- name: Start Supabase local development setup
24+
run: supabase db start
25+
26+
- name: Run Tests
27+
run: supabase test db
28+
29+
- name: Verify generated types are checked in
30+
run: |
31+
supabase gen types typescript --local > types.gen.ts
32+
if ! git diff --ignore-space-at-eol --exit-code --quiet types.gen.ts; then
33+
echo "Detected uncommitted changes after build. See status below:"
34+
git diff
35+
exit 1
36+
fi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Push Supabase Migrations to Production
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
push_supabase_migrations_production:
11+
environment: Production
12+
runs-on: ubuntu-latest
13+
14+
env:
15+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
16+
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
17+
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- uses: supabase/setup-cli@v1
23+
with:
24+
version: latest
25+
26+
- run: supabase link --project-ref $SUPABASE_PROJECT_ID
27+
- run: supabase db push
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Push Supabase Migrations to Staging
2+
3+
on:
4+
push:
5+
branches:
6+
- staging
7+
workflow_dispatch:
8+
9+
jobs:
10+
push_supabase_migrations_staging:
11+
environment: Staging
12+
runs-on: ubuntu-latest
13+
14+
env:
15+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
16+
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
17+
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- uses: supabase/setup-cli@v1
23+
with:
24+
version: latest
25+
26+
- run: supabase link --project-ref $SUPABASE_PROJECT_ID
27+
- run: supabase db push

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.13.1
1+
22.14.0

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 100,
5+
"tabWidth": 2,
6+
"useTabs": false,
7+
"semi": true
8+
}

CLAUDE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CLAUDE.md - AgentSmith Development Guidelines
2+
3+
## Build and Test Commands
4+
5+
- **Development**: `npm run dev` - Start Next.js dev server
6+
- **Build**: `npm run build` - Build the Next.js application
7+
- **Start**: `npm run start` - Start production server
8+
- **Test**: `npm run test` - Run all tests with Jest
9+
- **Test (Watch)**: `npm run test:watch` - Run tests in watch mode
10+
- **Test Single File**: `npm run test -- -t "test name"` or `npm run test -- path/to/file.test.ts`
11+
- **Type Generation**: `npm run typegen` - Generate Supabase TypeScript types
12+
13+
## Code Style Guidelines
14+
15+
- **Components**: Use named exports only; default exports only for Next.js page files
16+
- **Functions**: Declare with const arrow format: `const myFunc = (params: Type) => {}`
17+
- **Types**: Always explicitly type props as separate types, not inline
18+
- **File Structure**:
19+
- Components in `/components` folder with max 2 components per file
20+
- Page components in `/page-components`
21+
- **Imports**: Use path aliases: `@/` for src, `&/` for lib, `~/` for root
22+
- **Naming**: PascalCase for components, camelCase for functions, kebab-case for files
23+
- **Icons**: Only use icons from `lucide-react`
24+
- **Styling**: Only use Tailwind CSS, no custom CSS
25+
- **SQL**: Lowercase syntax for queries, concise index declarations with `create index concurrently`
26+
- **Error Handling**: Use try/catch with appropriate error logging
27+
28+
Always follow existing patterns in the codebase.

0 commit comments

Comments
 (0)