Skip to content

Commit 70a48b5

Browse files
authored
Merge pull request #38 from jmbish04/fix/lint-and-migrations
fix: resolve ESLint, TypeScript errors, and remote migration conflicts
2 parents 61a6d23 + 1e89273 commit 70a48b5

444 files changed

Lines changed: 21342 additions & 3695 deletions

File tree

Some content is hidden

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

.agent/rules/agent-registry.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Rule: Agent Registry and Dynamic UI
2+
3+
## 1. Dynamic UI Consumption
4+
5+
- Frontend agent selectors, wizards, and sidebars (e.g., `AgentSidebar.tsx`) **MUST NEVER** hardcode the list of available specialist agents.
6+
- All dynamic agent discovery must occur via the `GET /api/agents/specialists` REST endpoint. This ensures the backend remains the single source of truth for agent capabilities, routing, and availability.
7+
8+
## 2. The Specialist Pattern
9+
10+
- Avoid creating numerous bespoke subclasses of `HonoBaseAgent` (e.g., `DataAgent`, `UXAgent`, `SREAgent`) unless they require fundamentally distinct toolsets or event lifecycles.
11+
- Default to using **ONE** flexible `SpecialistAgent` class.
12+
- Dictate the specific persona dynamically at runtime by overriding the `systemPrompt` or passing a `specialty` configuration parameter when the frontend initiates the session.
13+
- **Why?** This prevents sprawling class files, keeps the agent execution logic DRY, and enables the system to spin up arbitrary expert subsets without code deployments.
14+
15+
## 3. Plan Generation Output
16+
17+
- The ultimate goal of a Workshop or Consultation flow is actionable output.
18+
- Specialist Agents should be equipped with a `save_plan(plan: JSON)` tool.
19+
- When the agent and user align on a roadmap, the agent must invoke `save_plan` to persist the structured JSON to the `projects`, `plans`, or `todos` table via Drizzle.
20+
- The UI should then react to this database mutation (e.g., by advancing the Wizard, redirecting to the Kanban board, or pushing a toast).

.agent/rules/ai-routing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AI Routing & Fallback Rules
2+
3+
- **Silent Failures:** Never allow a third-party AI provider failure to crash the request if a `worker-ai` equivalent model can handle the prompt.
4+
- **Type Safety:** Do not alter the return types (`string`, `T`) of the core generation functions to include metadata. Always use the `onFallback` callback mechanism in `AIOptions` to bubble up execution state.
5+
- **Observability:** Every fallback event must be aggressively logged to D1 to track provider reliability and API Gateway latency over time.

.agent/rules/alerts-standards.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Alerts Standards
2+
3+
## 1. The `createAlert()` Contract
4+
5+
Every new feature that may fail, produce notable events, or require user attention **MUST** emit alerts using the canonical `createAlert()` function:
6+
7+
```typescript
8+
import { createAlert } from "@alerts";
9+
10+
await createAlert(env, {
11+
type: "deployment", // AlertType: health | webhook | security | deployment | agent | info
12+
severity: "error", // AlertSeverity: info | warning | error | critical
13+
title: "Deploy failed",
14+
description: "Wrangler exited with code 1. Check logs.",
15+
link_url: "/webhooks", // Optional deep-link (relative path)
16+
process_origin: "DeployWorkflow", // Human-readable origin
17+
});
18+
```
19+
20+
`createAlert()` is fire-and-forget: it never throws, never blocks the main thread, and auto-gates based on `ALERTS_CONFIG` in KV.
21+
22+
## 2. When to Emit Alerts
23+
24+
| Scenario | Type | Severity |
25+
| ----------------------------------- | ------------ | --------------------- |
26+
| Health check failure | `health` | `error` or `critical` |
27+
| Webhook delivery failure (repeated) | `webhook` | `warning` |
28+
| Detected secret leak | `security` | `critical` |
29+
| Worker deploy failure | `deployment` | `error` |
30+
| Agent task failure after retries | `agent` | `error` |
31+
| Informational system event | `info` | `info` |
32+
33+
Do **NOT** alert on:
34+
35+
- Expected/transient 4xx responses
36+
- Individual tool-call retries (only alert on final failure)
37+
- Debug or verbose logs (use `console.log` / `@logging` for those)
38+
39+
## 3. Config-Gated Alerts
40+
41+
`createAlert()` reads `ALERTS_CONFIG` from `KV_CONFIGS` at emit time. If a type is disabled or the master switch is off, the alert is dropped silently. You do not need to check the config yourself — the service handles it.
42+
43+
## 4. Path Alias
44+
45+
Always use `@alerts` — never use a relative import:
46+
47+
```typescript
48+
// ✅ Correct
49+
import { createAlert } from "@alerts";
50+
51+
// ❌ Wrong
52+
import { createAlert } from "../../alerts";
53+
```
54+
55+
## 5. New Alert Types
56+
57+
If you need a new alert type (beyond the 6 built-in), you must:
58+
59+
1. Add it to `ALERT_TYPES` in `backend/src/db/schemas/app/alerts.ts`
60+
2. Add it to `AlertTypeFlags` in `backend/src/alerts/config.ts`
61+
3. Add its `TYPE_META` entry in `AlertTray.tsx` and `Alerts.tsx`
62+
4. Run `pnpm drizzle-kit generate` if schema changed

.agent/rules/alerts.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Rule: Notifications & Alerts
2+
3+
## 1. Zero Native Alerts
4+
5+
- **Forbidden**: You MUST NEVER use the native browser `alert()`, `confirm()`, or `prompt()` functions under any circumstances.
6+
- **Why**: Native alerts break the UI/UX consistency, block the main thread, and violate our \"True Dark\" and premium aesthetic standards.
7+
8+
## 2. Sonner Toasts
9+
10+
- **Required**: For all transient user notifications (success, error, info, loading), you MUST use `toast` from the `sonner` package.
11+
- **Implementation**:
12+
- `import { toast } from \"sonner\";`
13+
- Success: `toast.success(\"Message\");`
14+
- Error: `toast.error(\"Message\");`
15+
- Generic: `toast(\"Message\");`
16+
- Ensure that the notification is concise and actionable.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# .agent/rules/cloudflare-deployments.md
2+
3+
## Rule: Large Bundle Deployment Protections
4+
5+
When operating on Cloudflare Workers that exceed 5MB uncompressed:
6+
7+
1. Always enable `minify = true` in `wrangler.jsonc`.
8+
2. Never rely on the default `wrangler deploy` CLI command directly if timeouts occur; wrap it in a Node script that overrides the `undici` global dispatcher timeout to at least 120,000ms.
9+
3. Inject `NODE_OPTIONS=--max-old-space-size=8192` to prevent heap exhaustion during `esbuild` minification phases.
10+
4. Ensure `compatibility_flags = ["nodejs_compat"]` is set and `node_compat = false` is enforced to prevent polyfill bloat.

.agent/rules/cloudflare-stack.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Cloudflare & Stack Standards
2+
3+
- **Routing:** Hono strictly typed with `@hono/zod-openapi` targeting OpenAPI v3.1.0.
4+
- **Data:** Drizzle ORM mapping to D1 SQLite. Complex nested arrays MUST use `text('col', { mode: 'json' }).$type<StrictInterface[]>()`.
5+
- **AI Execution:** Use `@google/genai` utilizing the `GEMINI_API_KEY` and the provided environment model name. Route base URLs through `https://gateway.ai.cloudflare.com/v1/{account}/{gateway}/google-genai`.
6+
- **UI Styling:** React + Shadcn UI. Enforce Dark Theme default (`bg-slate-950`).
7+
- **Code Completeness:** Never truncate files. Generate full end-to-end code during every update pass.

.agent/rules/discord-cloudflare.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Architecture Rules: Discord API on Cloudflare Workers
2+
3+
## 1. Secrets Store Compliance
4+
5+
Cloudflare Secrets Store requires all account-level secrets to be fetched asynchronously.
6+
7+
- **Rule:** NEVER use synchronous mapping for Secret Store bindings.
8+
- **Enforcement:** Always use `await env.BINDING_NAME.get()`.
9+
- **Example:** `const token = await c.env.DISCORD_TOKEN.get();`
10+
11+
## 2. Discord Bot Search Constraints
12+
13+
Standard Discord Bot tokens cannot natively hit the `GET /guilds/{guild.id}/messages/search` API endpoint, as this is restricted to user contexts.
14+
15+
- **Rule:** When executing cross-channel or thread search tasks, the agent MUST implement a map-reduce pattern locally on the Worker.
16+
- **Enforcement:** Fetch recent message batches from target channels/threads via `GET /channels/{id}/messages` and run local regex/string filtering to extract query matches.
17+
18+
## 3. OpenAPI Standard
19+
20+
All module expansions must utilize `@hono/zod-openapi` enforcing `openapi: 3.1.0`. Any newly added Discord interaction must map its return to a `z.object()` and expose it cleanly in the `/openapi.json` ledger.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# .agent/rules/durable-object-agents.md
2+
3+
## Rules
4+
5+
- **Dynamic Heavy SDKs:** Never statically import large orchestration libraries (like `@openai/agents` or `langchain`) at the top level of a Cloudflare Worker or Durable Object. Always use dynamic `import()` inside the execution method to preserve sub-50ms cold starts.
6+
- **Client Injection over Globals:** When executing an agent run via the OpenAI Agents SDK, ALWAYS inject the `client` explicitly into the `run()` options (e.g., `run(agent, prompt, { client })`). Never rely on global environment variables to implicitly configure the client.
7+
- **Prefix Namespacing:** Always format the model identifier as `${provider}/${model}` immediately prior to passing it into the `OpenAIAgent` constructor to ensure Cloudflare AI Gateway routes it correctly.

.agent/rules/jules.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Rule: Jules Integration Maintenance
2+
3+
## 1. Source of Truth
4+
5+
- The central hub for all Jules interactions is `backend/src/routes/api/agents/jules.ts` and `backend/src/services/jules.ts`.
6+
- **DO NOT** create a new Jules router mapped elsewhere (such as `services/jules.ts`). Ensure `/api/agents/jules` is the canonical invocation endpoint.
7+
8+
## 2. Invoking Jules
9+
10+
- Clients use `/api/agents/jules/start` (or `/invoke`). You must pass `inject_standards: true` (default) to push `JULES_STANDARDS` alongside the prompt.
11+
- **Jobs and Sessions**: `julesSessions` tracks the state returned by `@google/jules-sdk`. `julesJobs` wraps tracking around full repository-bound interactions. Do not query Jules SDK polling functions from the frontend; use `get /api/agents/jules/status/:id` instead.
12+
13+
## 3. Modifying Jules Code
14+
15+
- **CRITICAL**: Anytime a change is made to any Jules related code (e.g., schemas, routes, services, or the sdk version), you MUST:
16+
1. Update `AGENTS.md` to reflect new patterns or architecture updates if necessary.
17+
2. Update this `.agent/rules/jules.md` file if any constraints or conventions change.
18+
3. Ensure the frontend `Docs` page for Jules integration accurately reflects the state of the API.
19+
20+
## 4. Workflows & Autonomy
21+
22+
- Jules SDK runs synchronously within the environment. For detached executions, the user request can trigger `force_overseer: true`, which kicks off a workflow check via the `JulesOverseer` Durable Object Singleton.

.agent/rules/shadcn-mandatory.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
Shadcn + Astro + Worker Assets Standard Rule
6+
7+
You must ALWAYS implement the frontend using the "Moody Modern" architectural pattern: Astro as the host, React for interactive islands, and Shadcn UI (Default Dark Theme) for all UI components.
8+
9+
Mandatory Tech Stack
10+
11+
Framework: Astro (latest) with @astrojs/react and @astrojs/cloudflare integrations.
12+
13+
Styling: Tailwind CSS v4 using OKLCH color space.
14+
15+
Components: Shadcn UI (Official) and Shadcn-compatible registries (e.g., kibo-ui, assistant-ui).
16+
17+
Deployment: Cloudflare Worker Static Assets (Unified Main Worker + Assets directory).
18+
19+
Backend: Hono with @hono/zod-openapi for typesafe API endpoints.
20+
21+
Rule Enforcement
22+
23+
Dark Theme: The <html> tag MUST have class="dark" by default. No light mode toggles unless explicitly requested.
24+
25+
Hydration: All interactive components (Forms, Buttons, Modals, Nav) must be React components used as Astro islands with client:load or client:visible.
26+
27+
No Raw HTML: Do not use raw HTML/Tailwind mockups for final output. Retrofit all plain mockups into Shadcn components (e.g., <div class="rounded-lg border..."> -> <Card>).
28+
29+
Unified Routing: Every page must have its own dedicated .astro file in src/pages/ to support direct URL access and server-side refreshes.
30+
31+
Types: Use wrangler types patterns. Never hand-write Environment bindings.
32+
33+
Component Sourcing
34+
35+
Use lucide-react for all iconography.
36+
37+
Use recharts with Shadcn-specific configuration for data visualization.
38+
39+
Use assistant-ui for all AI/Chat interfaces.

0 commit comments

Comments
 (0)