-
Notifications
You must be signed in to change notification settings - Fork 0
Set up GitHub Copilot coding agent instructions #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,174 @@ | ||||||||||||||||||||||||||||||||||||||||
| # GitHub Copilot Instructions — ChittyCommand | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Project Overview | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ChittyCommand is a unified life management and action dashboard for the ChittyOS ecosystem. It ingests data from 15+ financial, legal, and administrative sources, scores urgency with AI, recommends actions, and executes them via APIs, email, or browser automation. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - **Repo:** `CHITTYOS/chittycommand` | ||||||||||||||||||||||||||||||||||||||||
| - **Deploy:** Cloudflare Workers at `command.chitty.cc` | ||||||||||||||||||||||||||||||||||||||||
| - **Stack:** Hono (TypeScript), React + Tailwind (frontend), Neon PostgreSQL via Hyperdrive, Cloudflare R2/KV | ||||||||||||||||||||||||||||||||||||||||
| - **Canonical URI:** `chittycanon://core/services/chittycommand` | Tier 5 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Common Commands | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||
| npm run dev # Start Hono dev server (wrangler dev) | ||||||||||||||||||||||||||||||||||||||||
| npm run build # Typecheck (tsc --noEmit) | ||||||||||||||||||||||||||||||||||||||||
| npm run test # Run Vitest tests | ||||||||||||||||||||||||||||||||||||||||
| npm run deploy # Deploy to Cloudflare Workers | ||||||||||||||||||||||||||||||||||||||||
| npm run ui:dev # Start React frontend (localhost:5173) | ||||||||||||||||||||||||||||||||||||||||
| npm run ui:build # Build frontend for Cloudflare Pages | ||||||||||||||||||||||||||||||||||||||||
| npm run db:generate # Generate Drizzle migrations | ||||||||||||||||||||||||||||||||||||||||
| npm run db:migrate # Run Drizzle migrations | ||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Secrets are managed via `wrangler secret put` — **never hardcode** them: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||
| wrangler secret put PLAID_CLIENT_ID | ||||||||||||||||||||||||||||||||||||||||
| wrangler secret put PLAID_SECRET | ||||||||||||||||||||||||||||||||||||||||
| wrangler secret put DATABASE_URL | ||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Architecture | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Single Cloudflare Worker serving API + scheduled cron jobs. Frontend is a separate React SPA (Cloudflare Pages) at `app.command.chitty.cc`. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ### Key Files | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - `src/index.ts` — Hono app entry point, route mounting, CORS, error handler | ||||||||||||||||||||||||||||||||||||||||
| - `src/middleware/auth.ts` — Three auth middlewares: `authMiddleware`, `bridgeAuthMiddleware`, `mcpAuthMiddleware` | ||||||||||||||||||||||||||||||||||||||||
| - `src/db/schema.ts` — Drizzle ORM schema (all tables prefixed `cc_`) | ||||||||||||||||||||||||||||||||||||||||
| - `src/lib/cron.ts` — Cron sync orchestrator | ||||||||||||||||||||||||||||||||||||||||
| - `src/lib/integrations.ts` — Service clients (Mercury, Plaid, ChittyScrape, etc.) | ||||||||||||||||||||||||||||||||||||||||
| - `src/lib/urgency.ts` — Deterministic urgency scoring (0–100) | ||||||||||||||||||||||||||||||||||||||||
| - `src/lib/validators.ts` — Zod schemas for all request validation | ||||||||||||||||||||||||||||||||||||||||
| - `src/routes/` — Route handlers (one file per domain) | ||||||||||||||||||||||||||||||||||||||||
| - `src/routes/bridge/` — Inter-service bridge routes | ||||||||||||||||||||||||||||||||||||||||
| - `src/routes/mcp.ts` — MCP server (28 tools for Claude integration) | ||||||||||||||||||||||||||||||||||||||||
| - `migrations/` — SQL migration files (0001–0007) | ||||||||||||||||||||||||||||||||||||||||
| - `ui/` — React frontend (Vite + Tailwind) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Code Conventions | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ### TypeScript | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - Strict mode is enabled (`"strict": true`). No `any` unless explicitly cast. | ||||||||||||||||||||||||||||||||||||||||
| - Target: `ES2022`. Module resolution: `bundler`. | ||||||||||||||||||||||||||||||||||||||||
| - All Hono apps/routes are typed: `new Hono<{ Bindings: Env; Variables: AuthVariables }>()`. | ||||||||||||||||||||||||||||||||||||||||
| - Import `AuthVariables` from `src/middleware/auth.ts` for route-level context variables. | ||||||||||||||||||||||||||||||||||||||||
| - Use `c.set('userId', ...)` and `c.get('userId')` for auth context in middleware and handlers. | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+60
|
||||||||||||||||||||||||||||||||||||||||
| - All Hono apps/routes are typed: `new Hono<{ Bindings: Env; Variables: AuthVariables }>()`. | |
| - Import `AuthVariables` from `src/middleware/auth.ts` for route-level context variables. | |
| - Use `c.set('userId', ...)` and `c.get('userId')` for auth context in middleware and handlers. | |
| - Default Hono apps/routes are typed: `new Hono<{ Bindings: Env }>()`. | |
| - When a route or app needs auth context via `c.get('userId')` / `c.get('scopes')`, type it as `new Hono<{ Bindings: Env; Variables: AuthVariables }>()`. | |
| - Import `AuthVariables` from `src/middleware/auth.ts` only in files that use these auth context variables. | |
| - Use `c.set('userId', ...)` and `c.get('userId')` (and similarly `scopes`) for auth context in middleware and handlers. |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Validation section says to use @hono/zod-validator with zValidator('json'|'query', ...), but the codebase currently validates with schema.safeParse(...) inside handlers (no zValidator usage found). Please update these instructions to match the established safeParse pattern (or, if you want to standardize on @hono/zod-validator, update the route handlers accordingly).
| - Use `@hono/zod-validator` with `zValidator('json', schema)` for request body validation. | |
| - Validate query params with `zValidator('query', schema)`. | |
| - In route handlers, validate request bodies with `schema.safeParse(await c.req.json())`. | |
| - Validate query params with `schema.safeParse(c.req.query())` (or an equivalent object). | |
| - On validation failure, return `c.json({ error: 'Invalid request', details: zodError.flatten() }, 400)` or a similarly safe, non-sensitive error shape. |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Routing guidance says to always return c.json(...), but there is at least one streaming endpoint returning c.newResponse(...) (SSE). Suggest loosening this to “use c.json for standard API responses” while allowing c.newResponse/streams where required.
| - Always return `c.json(...)` — never return raw strings or untyped responses. | |
| - For standard API responses, return `c.json(...)`. Use `c.newResponse`/streaming APIs only when you intentionally need SSE, streaming, or non-JSON responses — avoid raw/untyped responses otherwise. |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CORS allowlist here is missing currently-configured origins (e.g., https://cmd.chitty.cc) and the existing list includes schemes like http://localhost:5173. Please update the documented allowlist to match src/index.ts so future edits don’t inadvertently “fix” CORS to the wrong set of origins.
| - CORS is restricted to approved origins: `app.command.chitty.cc`, `command.mychitty.com`, `chittycommand-ui.pages.dev`, `localhost:5173`. | |
| - CORS is restricted to approved origins: `https://app.command.chitty.cc`, `https://command.mychitty.com`, `https://chittycommand-ui.pages.dev`, `https://cmd.chitty.cc`, `http://localhost:5173`. |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The markdown tables use a leading double pipe (|| ...) which renders as an extra empty column in most markdown renderers. Switching these rows to single-pipe table syntax will render correctly.
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment bindings table is incomplete vs the actual Env type / wrangler.toml (e.g., CHITTYCHARGE_URL, CHITTYBOOKS_URL, CHITTYASSETS_URL, CHITTYROUTER_URL, CHITTYREGISTER_URL, CHITTYCHAT_DATA_API, CHITTYSCHEMA_URL, CHITTYCERT_URL, CHITTY_CONNECT_TOKEN, PLAID_ENV, and optional DATABASE_URL). Consider either listing all current bindings or explicitly pointing readers to src/index.ts / wrangler.toml as the source of truth.
| | `PLAID_CLIENT_ID` | string (secret) | Plaid API key | | |
| | `PLAID_SECRET` | string (secret) | Plaid API secret | | |
| Always check if optional URL bindings are present before using them (e.g., `if (c.env.CHITTYAUTH_URL)`). | |
| | `CHITTYCHARGE_URL` | string | ChittyCharge service URL | | |
| | `CHITTYBOOKS_URL` | string | ChittyBooks service URL | | |
| | `CHITTYASSETS_URL` | string | ChittyAssets service URL | | |
| | `CHITTYROUTER_URL` | string | ChittyRouter service URL | | |
| | `CHITTYREGISTER_URL` | string | ChittyRegister service URL | | |
| | `CHITTYCHAT_DATA_API` | string | ChittyChat data API base URL | | |
| | `CHITTYSCHEMA_URL` | string | ChittySchema service URL | | |
| | `CHITTYCERT_URL` | string | ChittyCert service URL | | |
| | `CHITTY_CONNECT_TOKEN` | string (secret) | ChittyConnect service token | | |
| | `PLAID_CLIENT_ID` | string (secret) | Plaid API key | | |
| | `PLAID_SECRET` | string (secret) | Plaid API secret | | |
| | `PLAID_ENV` | string | Plaid environment (e.g. `sandbox`, `development`, `production`) | | |
| | `DATABASE_URL` | string (optional) | Direct PostgreSQL connection URL (optional, may be unused when using Hyperdrive) | | |
| Always check if optional URL bindings are present before using them (e.g., `if (c.env.CHITTYAUTH_URL)`), and refer to `Env` in `src/index.ts` and `wrangler.toml` as the source of truth for the full, up-to-date bindings list. |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Cron Schedule table also uses ||-prefixed rows, which will render with an extra blank column. Consider converting it to standard markdown table formatting.
| | Schedule | Purpose | | |
| |----------|---------| | |
| | `0 12 * * *` | Daily 6 AM CT: Plaid + ChittyFinance sync | | |
| | `0 13 * * *` | Daily 7 AM CT: Court docket check | | |
| | `0 14 * * 1` | Weekly Mon 8 AM CT: Utility scrapers | | |
| | `0 15 1 * *` | Monthly 1st 9 AM CT: Mortgage, property tax | | |
| | Schedule | Purpose | | |
| | -------------- | ------------------------------------------------ | | |
| | `0 12 * * *` | Daily 6 AM CT: Plaid + ChittyFinance sync | | |
| | `0 13 * * *` | Daily 7 AM CT: Court docket check | | |
| | `0 14 * * 1` | Weekly Mon 8 AM CT: Utility scrapers | | |
| | `0 15 1 * *` | Monthly 1st 9 AM CT: Mortgage, property tax | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Files list says migrations are
0001–0007, but the repo currently has migrations through0009_*. Please update this to avoid future confusion (or change to something like “0001+”).