Skip to content

Commit 815aa6c

Browse files
authored
Merge pull request #447 from jmbish04/feat/jules-planning-enhancements
2 parents 3b3c561 + 0768bd4 commit 815aa6c

1,284 files changed

Lines changed: 160359 additions & 336784 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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
## 2. The Specialist Pattern
99

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.
10+
- Avoid creating numerous bespoke specialist Durable Object classes unless they require fundamentally distinct toolsets or event lifecycles.
11+
- Do not reintroduce `HonoBaseAgent` or `BaseAgent`; the specialist pattern is now Honi-based.
12+
- Default to using **ONE** flexible specialist runtime created with `createAgent(...)`.
1213
- Dictate the specific persona dynamically at runtime by overriding the `systemPrompt` or passing a `specialty` configuration parameter when the frontend initiates the session.
1314
- **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.
1415

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Rule: AI Provider Standards (Antigravity)
2+
3+
## 1. Zod Supremacy
4+
- Every structured AI call (`generateStructuredResponse`, `generateStructuredWithTools`) MUST accept a `z.ZodType<T>` payload.
5+
- Weak interfaces (`any` or `Record<string, unknown>`) are forbidden for output generation.
6+
- Use `zod-to-json-schema` to natively pipe the schema into the payload's `response_format` for supported compat endpoints.
7+
- Always call `schema.parse(rawParsed)` on the final JSON result to guarantee structural integrity.
8+
9+
## 2. Universal File Context
10+
- Any method ending in `*FromFiles` must handle payloads consisting of `FileInput` objects (`{ name, type, data, isBase64 }`).
11+
- Providers with native file processing (e.g., Gemini's `inlineData`) should construct standard multi-part arrays.
12+
- Providers without native large-file limits (e.g., Worker AI) MUST use the transparent Vectorize RAG chunking algorithm if the total string length exceeds 6,000 characters to prevent hitting input limits.
13+
14+
## 3. Jules SDK Integration
15+
- Since Jules operates via long-running chat streams, large structured responses should be handled by getting broad context from Jules, and piping its output into `worker-ai` `generateStructuredResponse` to enforce strict formatting.
16+
- Explicit reasoning and agent orchestration features (`analyzeRepo`, `completeTask`, `createPlan`) should exclusively utilize Jules.
17+
18+
## 4. No Vercel AI SDK
19+
- Under no circumstances will you import `ai` or `@ai-sdk/`. It has been banned due to edge runtime parsing inconsistencies on Workers.
20+
- Use the native `fetch` API against the Cloudflare AI Gateway instead.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Cross-Repository Architecture Standards
2+
3+
- **Separation of Concerns:** `core-github-api` (Cloudflare Worker) is the state manager, API gateway, and real-time broadcaster. `core-github-standardization` is the asynchronous compute engine for long-running scripts, AI tasks, and Git mutations.
4+
- **Parity Requirement:** Whenever a new task type is added to `unified-api-worker.yml` in the standardization repo, a corresponding Zod validation schema and webhook ingestion handler MUST be created in the `core-github-api`.
5+
- **Data Traceability:** Every `repository_dispatch` event must carry a unique `taskId` generated by the API. This ID must be returned in the `callback_url` webhook payload to guarantee exactly-once processing and accurate D1 logging.
6+
- **OpenAPI Compliance:** All inter-service webhooks and dispatch triggers must be strictly typed and registered in the Hono OpenAPI registry (`/openapi.json`).

.agent/rules/error-handling.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Rule: Global Error Handling & Logging
2+
3+
## Context
4+
When an error occurs anywhere in the stack, we must ensure it is persistently logged and properly surfaced to the user. We DO NOT rely on generic `console.error` throws or hardcoded inline alerts in the frontend.
5+
6+
## 1. Backend Error Logging (D1 Mirror)
7+
Whenever a backend tool, AI agent, or API action fails, you **MUST** record the failure into the D1 `system_logs` table.
8+
9+
- **Import the Logger**: `import { Logger } from '@/lib/logger'`
10+
- **Initialize**: `const logger = new Logger(env, 'ContextName');`
11+
- **Record**: `logger.error("Description", { details: error.message, ...context })`
12+
- **Mandatory Flush**: Call `await logger.flush()` before the request terminates to commit the array of logs to the database.
13+
14+
## 2. Frontend Error UI (Shadcn + Copy)
15+
When a frontend component catches an error, you **MUST** pass the literal error string to the centralized error service. This service invokes a Shadcn Sonner toast that includes the raw error stack and a "Copy to Clipboard" button.
16+
17+
- **Import the Service**: `import { handleGlobalError } from '@/lib/error-handler'`
18+
- **Usage**:
19+
```ts
20+
try {
21+
const res = await fetch('/api/endpoint');
22+
if (!res.ok) {
23+
const data = await res.json();
24+
// Pass the literal error string from the server
25+
throw new Error(data.error || "Server error");
26+
}
27+
} catch (err) {
28+
handleGlobalError(err);
29+
}
30+
```
31+
- **Forbidden**: Do not use `console.error(err)` as the sole failure mechanism. Do not write local `<Alert variant="destructive">` blocks for API failures unless it's a localized form validation constraint.
32+
33+
## 3. Strict Passthrough
34+
Agents must ensure that backend routes return the actual error string generated by the failed service (e.g. GitHub API 404s, Stripe 402s).
35+
- **Forbidden**: Returning `error: "Failed to extract comments"` masking the true `"Resource not found"` from Octokit.

.agent/rules/full-code-output.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
# Rule: Full-Code Output Only
6+
7+
## Core Requirement
8+
- When generating, rewriting, or reviewing code, always return complete, ready-to-use code for every file or function you touch.
9+
- If a file is in scope, return the full file content for that file.
10+
- If a function is rewritten, return the full rewritten function.
11+
12+
## Forbidden Output
13+
Do not use placeholders, elisions, or shorthand such as:
14+
15+
- `// ... rest of the function remains the same ...`
16+
- `// leaving as is`
17+
- `// ... rest of code ...`
18+
- `# existing code omitted`
19+
- `/* unchanged */`
20+
21+
## Required Behavior
22+
- Do not replace omitted code with commentary.
23+
- Do not describe skipped sections in prose.
24+
- Either provide the complete code for the touched file or leave the file out of the response entirely.
25+
- When returning structured outputs that contain code fields, those fields must contain the full final code, not a partial patch summary.
26+
27+
## Applies To
28+
- onboarding agents
29+
- repository specialist agents
30+
- coding assistants
31+
- slash-command agents
32+
- planning/codegen helpers
33+
- documentation agents when they emit code examples
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- **Framework**: Do not use legacy local Node.js proxies (`workers-mcp` or `mcp-remote`). We are building a native Remote MCP Server. Use `McpServer` from `@modelcontextprotocol/sdk/server/mcp.js` and export it using `createMcpHandler(server)` from `agents/mcp`.
2+
- **No Node execution in Workers**: You cannot use `child_process`, `exec`, or `npx` inside a Cloudflare Worker. Any MCP server requiring a local Node process must be reverse-engineered into native `server.tool(...)` calls or hosted externally.
3+
- **SSE Client Transport**: When connecting to remote MCPs (like `docs.mcp.cloudflare.com`), always use `SSEClientTransport` instead of `StdioClientTransport`. Wrap the client connection in a try/finally block to ensure `.close()` is called, preventing hanging sockets on the edge.
4+
- **AI Gateway Binding**: Never hardcode standard `fetch` AI calls. Always use configuration suitable for Cloudflare's ecosystem to maintain multi-provider AI Gateway compliance.
5+
- **Completeness**: Provide full files start-to-finish without truncation or using `// ... rest of code` shortcuts.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Python in GitHub Actions Constraints
2+
3+
- **Inline Python Indentation:** When utilizing `cat << 'EOF' > file.py` inside a YAML step, the contents must have strict, non-broken indentation. Python will fail to execute if YAML spacing mixes tabs or trailing spaces.
4+
- **AI Gateway URI Structuring:** When calling Cloudflare Workers AI models via the native `openai` python SDK, the `base_url` must target the `/workers-ai/v1` path wrapper on the gateway, not `/compat` or standard `/openai`.
5+
- **Dependency Completeness:** Any inline Python script containing imports from PyPI must have those exact matching packages installed in an upstream step (e.g., `github` package translates to `pip install PyGithub`).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Rule: Webhook Refactor Standards
2+
3+
- Every automation MUST extend `BaseAutomation` and live in its own isolated `.ts` file.
4+
- **Strict Conditional Routing**: The webhook router must NEVER contain conditional `if/else` logic regarding payload traits or repos. It must act strictly as a dumb dispatcher reading from D1, and it MUST call `await instance.shouldExecute()` to let the class decide if it applies to the payload.
5+
- All frontend components must use Shadcn strictly, ensuring the global dark theme is maintained without custom raw CSS.
6+
- The workflow execution logs must always be sorted by `createdAt DESC`.
7+
- **Global Automations**: Use the AutomationArchitect agent via the Workflows Dashboard to rapidly scaffold new automation files and ensure they are added to `AutomationRegistry.ts`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Unified Action Worker Constraints
2+
3+
- **Single Source of Truth:** All cross-repository template syncing, heavy scraping, and complex Git mutations belong in `unified-api-worker.yml` (located in `core-github-standardization`). The Cloudflare Worker strictly acts as the orchestrator and state manager.
4+
- **Modular Dispatching:** Never hardcode disparate task payloads into a single massive function. Each task type MUST have its own dedicated module in `src/services/github/unified-action-worker/` that exports a strongly-typed function.
5+
- **WebSocket Delegation:** The GitHub Action is ephemeral and lacks direct access to the Cloudflare internal network bindings (D1, AI, DOs). It MUST use the WebSocket API to request the Cloudflare Worker to run DB queries, execute LLM prompts via bindings, or query the CF v4 API using the Worker's injected secrets.
6+
- **State Tracking:** Every dispatch must generate a `taskId` (UUID) before firing. This UUID is passed to the GitHub Action, which must echo it back during WebSocket connections and final webhook completions so the D1 `unified_action_logs` record can be updated securely.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
# Rule: CLI Authentication Delegation (Zero-Touch Auth)
6+
7+
## Context
8+
The host environment utilizes custom Just-In-Time (JIT) token wrappers in `.zshrc` that automatically intercept specific CLI tools (e.g., `wrangler`, `gh`). These wrappers dynamically fetch secrets (like `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`, and `GH_TOKEN`) and inject them into the execution context for that single command.
9+
10+
## Directives
11+
1. **NEVER export secrets manually:** Do not generate commands that use `export CLOUDFLARE_API_TOKEN=...` or `export GH_TOKEN=...` before executing a script.
12+
2. **NEVER inline secrets:** Do not prepend environment variables to deployment or CLI commands.
13+
***INCORRECT:** `CLOUDFLARE_API_TOKEN=your_token wrangler deploy`
14+
***INCORRECT:** `GH_TOKEN=your_token gh pr create`
15+
***INCORRECT:** `CLOUDFLARE_API_TOKEN=$MY_TOKEN pnpm run deploy`
16+
3. **USE standard invocations:** Always generate the simplest, standard invocation for the CLI tool or package script. Assume the host environment handles authentication transparently.
17+
***CORRECT:** `wrangler deploy`
18+
***CORRECT:** `pnpm run deploy`
19+
***CORRECT:** `gh repo view`
20+
4. **NO Auth Flags:** Do not attempt to pass tokens via command-line arguments or flags (e.g., avoid `--token`, `--auth`, etc.) unless specifically requested by the user for a novel CLI tool that lacks a `.zshrc` wrapper.

0 commit comments

Comments
 (0)