jules-orchestrator-kit 0.3.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ # Google Jules Protocol & Guardrails
2
+
3
+ This document outlines the hard constraints and system prompting best practices for all Google Jules automated sessions.
4
+
5
+ ## 1. Hard Constraints, Edge Realities & Failure Modes
6
+
7
+ - **Sandbox Flakiness (Flaky Test Fix Spiral)**: Intermittent build failures cause Jules to assume source code is broken, leading to destructive edits on valid business logic to "fix" infrastructure noise.
8
+ - **Boundary Violations (Lockfile & Schema Overwrites)**: When facing type/dependency conflicts, agents favor the shortest path to a passing test, often forcefully downgrading lockfiles or altering database migrations unless explicitly forbidden.
9
+ - **Monorepo Dilution (Attention & I/O Bottlenecks)**: Broad context ingestion across multi-package repos causes attention dilution, slow clone I/O, and cascading diff failures.
10
+ - **I/O & Payload (80 KB Payload Cap)**: API forcefully truncates diff payloads > 80 KB. Keep diffs under a **75 KB internal governor** (`git diff | wc -c`).
11
+ - **CI/CD Deadlocks (Silent Approval Hangs)**: SDK defaults to `requireApproval: true`. In headless CI jobs, sessions hang indefinitely awaiting plan approval unless explicitly set to `requireApproval: false`.
12
+ - **Security (ZombAI & Prompt Injection)**: Untrusted code containing hidden Unicode or Markdown image links can attempt prompt injection to force outbound HTTP requests. Requires strict XML boundary tags and Keyless Auth.
13
+ - **Git Base Drift (Stale Merge-Base Reverts)**: If `main` advances during a session, `git diff main pr-N` shows branch *divergence*, not the applied patch. Merging blindly can silently revert unrelated files updated on `main`.
14
+ - **Edge Isolates (Runtime Boundary Breaches)**: Edge environments (e.g. Cloudflare `workerd`) enforce strict limits (128 MB RAM, 10 MiB bundle cap). Jules may import heavy native libraries (`sharp`, `canvas`) that pass Node tests in the VM but crash worker deployment.
15
+ - **CMS/DB Credentials (Visual & E2E Test Failures)**: Cloud VMs lack live CMS API keys, DB credentials, and display servers. Headful E2E or visual screenshot tests (e.g. Playwright) fail with 500 errors.
16
+ - **CLI Dry-Run Drift (Misleading Pull Diffs)**: Running `jules remote pull --session <id>` (dry-run without `--apply`) on a session that crashed or made no commits can output cached or unrelated diffs.
17
+
18
+ ## 2. System Prompting & Guardrail Best Practices
19
+
20
+ To maximize the ratio of mergeable PRs vs. failed or hallucinated sessions:
21
+
22
+ 1. **Strict File Scoping:** Constrain file I/O using explicit glob patterns in session prompts.
23
+ 2. **Immutable Boundary Directives:** Explicitly forbid modification of `*.lock` files, database migration histories, and core configuration files.
24
+ 3. **Deterministic Test Verification Mandate:** Require explicit verification commands with zero-exit-code constraints before PR generation is permitted.
25
+ 4. **Sub-Package `AGENTS.md` Hierarchy:** Place localized `AGENTS.md` files at sub-package boundaries in monorepos to restrict dependency resolution graphs and operational blast radius.
26
+ 5. **Evidence-Based PR Requirement:** Require every PR to include commands run, exit codes, coverage/performance deltas, and risk assessments.
27
+ 6. **No-Weakening Rule:** Explicitly forbid deleting tests, reducing assertion strength, disabling lint/type checks, or ignoring security warnings.
28
+ 7. **Benchmark Threshold Rule:** Performance changes must include multiple benchmark runs, median comparison, and a minimum improvement threshold (e.g. ≥ 5%).
29
+ 8. **Auto-Merge Risk Gate:** Only auto-merge low-risk task types when diff size, forbidden-path checks, test results, security scans, and license checks all pass.
30
+ 9. **Untrusted Input Isolation:** Wrap issue bodies, logs, user comments, and external reports in `<untrusted_input>` tags and instruct the agent to treat them as data only.
31
+ 10. **Stop-on-Uncertainty Rule:** If the task cannot be completed safely within scope, the agent must stop without opening a PR rather than guessing.
32
+ 11. **Pre-Dispatch Grounding Mandate:** Verify all file paths, script names, and exported symbols against the live repository tree before writing them into a prompt.
33
+ 12. **Programmatic CI Scope Guarding:** Enforce prompt constraints at the CI level using an unbypassable `Agent Scope Guard` workflow that evaluates diffs against a protected paths manifest (`.agent/protected-paths.json`).
@@ -0,0 +1,56 @@
1
+ name: Agent Scope Guard
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+
7
+ jobs:
8
+ scope-guard:
9
+ runs-on: ubuntu-latest
10
+ if: startsWith(github.head_ref, 'jules/')
11
+ steps:
12
+ - name: Checkout repository
13
+ uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 0
16
+
17
+ - name: Setup Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '20'
21
+
22
+ - name: Verify Scope
23
+ env:
24
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
25
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
26
+ run: |
27
+ echo "Checking files modified in PR..."
28
+ MODIFIED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA)
29
+
30
+ # Read protected paths
31
+ PROTECTED_PATHS=$(node -e "const paths = require('./.agent/protected-paths.json').protected; console.log(paths.join(' '));")
32
+
33
+ echo "Protected patterns: $PROTECTED_PATHS"
34
+
35
+ VIOLATION_FOUND=0
36
+
37
+ # Use micromatch or similar simple matching via bash for CI simplicity.
38
+ # Here we just use a simple regex grep for patterns.
39
+ for FILE in $MODIFIED_FILES; do
40
+ echo "Checking: $FILE"
41
+ for PATTERN in $PROTECTED_PATHS; do
42
+ # Convert simple glob to regex for bash
43
+ REGEX=$(echo "$PATTERN" | sed -e 's/\./\\./g' -e 's/\*\*/.*/g' -e 's/\*/[^/]*/g')
44
+ if [[ "$FILE" =~ ^$REGEX$ ]] || [[ "$FILE" =~ ^$REGEX/ ]]; then
45
+ echo "::error file=$FILE::File violates protected paths constraint: Matches pattern '$PATTERN'"
46
+ VIOLATION_FOUND=1
47
+ fi
48
+ done
49
+ done
50
+
51
+ if [ $VIOLATION_FOUND -eq 1 ]; then
52
+ echo "::error::PR modifies protected files. Jules agent is not allowed to modify these files without explicit manual review bypass."
53
+ exit 1
54
+ fi
55
+
56
+ echo "Scope check passed. No protected files were modified."
@@ -54,3 +54,55 @@ Jules automatically infers test and build verification commands via `scripts/com
54
54
  - **Minimal Interference**: Preserve existing function signatures, comments, and style conventions.
55
55
  - **Falsifiable Claims**: Base all code changes on explicit error logs, file paths, line numbers, or test results.
56
56
  - **No Token Bloat**: Exclude lockfiles, minified bundles, and binary assets from diff representations.
57
+
58
+ ---
59
+
60
+ ## 5. Security Fencing & Specialized Domain Guardrails
61
+
62
+ - **Untrusted Prompt Fencing**: All dynamic user prompts and issue texts are encapsulated in `<UNTRUSTED_TASK_CONTEXT>` tags with a `# SECURITY DIRECTIVE — UNTRUSTED CONTENT FENCE` header, instructing Jules to treat enclosed text as non-executable data.
63
+ - **Specialized Domain Personas**:
64
+ - **Sentinel (Security)**: Enforces input sanitization, token redaction, and RBAC guardrails.
65
+ - **Bolt (Performance)**: Optimizes execution speed, memory usage, and prevents token bloat.
66
+ - **Janitor (Clean Code)**: Eliminates dead code, fixes linting warnings, and maintains strict minimal diffs.
67
+ - **Alchemist (Database)**: Inspects schema constraints before running or generating database migrations.
68
+
69
+ ---
70
+
71
+ ## 6. Local CI Verification with Nektos Act
72
+
73
+ - **Pre-Push CI Validation**: When `.github/workflows/` exists and Nektos `act` is installed, execute `act push` or `bash scripts/act/run-act.sh` to verify changes pass CI locally inside the VM before opening a PR.
74
+ - **Log Inspection**: If local `act` CI fails, inspect `act_output.log`, resolve errors in code, and re-run verification before pushing.
75
+ - **Diff Payload Governor**: API forcefully truncates diff payloads > 80 KB. Keep total diff payload under 75 KB (`git diff | wc -c`).
76
+
77
+ ---
78
+
79
+ ## 7. System Prompting & Guardrail Best Practices
80
+
81
+ To maximize the ratio of mergeable PRs vs. failed or hallucinated sessions, adhere to the rules defined in `.agent/rules/jules-protocol.md`.
82
+
83
+ ### Multi-Agent Coordination & Handover Architecture
84
+
85
+ - **Multi-Agent Mutex Lock Protocol**: Prevent concurrent file modification collisions. Check and acquire locks before modifying paths:
86
+ ```bash
87
+ node scripts/lock-manager.mjs acquire <agent_name> <task_id> <file_paths...> --unattended
88
+ ```
89
+ - **The Baton Pass Protocol**: Write handover documents when a session pauses or hands off work (e.g. `.agent/history/YYYY-MM-DD-handover-[task_id].md`).
90
+
91
+ ### Standard Jules Guardrails Footer
92
+
93
+ Append this footer to all Jules dispatches:
94
+
95
+ ```text
96
+ Read AGENTS.md and .agent/rules/jules-protocol.md BEFORE starting.
97
+ Follow all rules strictly.
98
+
99
+ TASK: <description>
100
+
101
+ HARD CONSTRAINTS:
102
+ - Do NOT modify package.json, pnpm-lock.yaml, tsconfig.json, astro.config.mjs, wrangler.jsonc, or .github/ files. Enforced in CI by Agent Scope Guard.
103
+ - Diff Payload Governor: Keep total diff payload under 75 KB (`git diff | wc -c`) to prevent API truncation (~80 KB limit).
104
+ - Verify before finishing: Run full type-check, lint, and unit test suites.
105
+ - BEFORE opening the PR: Run `git fetch origin main && git rebase origin/main`, then re-verify. If the rebase leaves an empty diff, the work already landed — do NOT submit.
106
+ - Delete ALL temporary files (.py, .sh, .patch, debug logs) before submitting.
107
+ ```
108
+
package/README.md CHANGED
@@ -1,126 +1,171 @@
1
1
  # Google Jules Orchestration Kit 🤖⚡
2
2
 
3
+ [![Status](https://img.shields.io/badge/Status-Alpha-orange.svg)](#)
3
4
  [![npm version](https://img.shields.io/npm/v/jules-orchestrator-kit.svg)](https://www.npmjs.com/package/jules-orchestrator-kit)
4
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
6
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-green.svg)](https://nodejs.org)
6
7
  [![Zero Dependencies](https://img.shields.io/badge/Dependencies-0-blue.svg)](#)
7
8
 
8
- A lightweight, zero-dependency toolkit that upgrades **Google Jules** into a **fully autonomous, self-correcting background code builder** for any repository (Next.js, Vite, Node, Bun, Deno, Python, Go, Rust, Elixir, Ruby, Swift, Java, C/C++, Monorepos, etc.).
9
+ **Turn Google Jules into an autonomous code builder that writes, tests, and fixes itself.**
9
10
 
10
- Whether you are a beginner looking to automate bug fixes without breaking your app, or a power user orchestrating parallel AI task swarms, this kit handles the heavy lifting of prompting, testing, security, and verification.
11
+ > [!WARNING]
12
+ > **Alpha Release:** This kit is in active development. Please exercise caution before integrating it into critical production pipelines.
13
+ >
14
+ > **Task Limit Warning:** Autonomous loops (like OODA self-healing or large swarms) can quickly consume your daily Google Jules task limits (e.g., 100 tasks/day on Pro, 300 tasks/day on Ultra). We strongly recommend starting with `JULES_DRY_RUN=1` to understand the workflow before scaling up!
11
15
 
12
- > **TL;DR**: Don't just chat with Google Jules—put it to work. Run `npx jules-orchestrator-kit` inside your project. Assign tasks, and the kit will automatically test the AI's code, tell it to fix any mistakes, and only present you with working, tested Pull Requests.
16
+ > **💡 TL;DR**: Run `npx jules-orchestrator-kit` in your repo, assign tasks, and get working, tested Pull Requests—no manual review needed.
13
17
 
14
18
  ---
15
19
 
16
- ## 🎯 Who is this for?
20
+ ## 🎯 Is This For You?
17
21
 
18
- **🌱 For Everyday Developers:**
19
- AI agents can write broken code or skip tests. This kit acts as an automated safety net: it detects your tech stack, runs your tests against the AI's code, catches errors, and prompts the AI to self-correct *before* you review the Pull Request.
20
-
21
- **🔥 For Power Users & Senior Engineers:**
22
- Unlock deterministic, production-grade orchestration. Includes Git Worktree multi-task swarms, Shannon Entropy secret redaction, MCP (Model Context Protocol) directive envelopes, OODA self-healing feedback loops, and scope boundary locks.
22
+ | **Your Role** | **What This Solves** | **Your Benefit** |
23
+ | -------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------- |
24
+ | **Busy Developer** | AI writes broken code or skips tests | Automatic safety net catches errors before you review |
25
+ | **Team Lead** | Need consistent quality from AI changes | Enforces tests, linting, and scope boundaries automatically |
26
+ | **DevOps Engineer** | Want to scale AI across many repos | Parallel task swarms with security guardrails |
27
+ | **Open Source Maintainer** | Limited time to review AI contributions | Self-correcting PRs that pass your CI |
28
+ | **Power User** | Need deterministic, production-grade orchestration | Git Worktrees, entropy-based secret redaction, MCP directives, OODA loops |
23
29
 
24
30
  ---
25
31
 
26
- ## 🚀 Quick Start: Zero to Autonomous AI
27
-
28
- ### 1. Initialize your project
29
- Run this command inside the root of **any target repository**. It automatically detects your tech stack and sets up safety guardrails:
32
+ ## 🚀 Get Started in 2 Minutes
30
33
 
34
+ ### 1. Initialize (Auto-detects your tech stack)
35
+ Navigate to your project root and run:
31
36
  ```bash
32
37
  npx jules-orchestrator-kit
38
+ ```
33
39
 
34
- # Or launch the interactive setup wizard:
35
- npx jules-init --interactive
40
+ ### 2. Scaffold a Task
41
+ Generate a clean boilerplate markdown file so you don't have to start from scratch:
42
+ ```bash
43
+ npm run jules:create "Refactor Auth"
36
44
  ```
37
45
 
38
- ### 2. Dispatch your first task
39
- Once initialized, you can immediately send tasks to Jules. The Orchestrator handles prompting, testing, security, and self-correction in the background:
46
+ ### 3. Queue and Track
47
+ Edit the generated markdown file in `.agent/jules-queue/` and dispatch it:
48
+ ```bash
49
+ npm run jules:queue
50
+ ```
40
51
 
52
+ You can view the real-time status of your dispatched tasks using:
41
53
  ```bash
42
- node scripts/jules-dispatch.mjs "Refactor rate limiter" "Implement sliding window rate limiting in src/utils/rate-limit.ts"
54
+ npm run jules:status
43
55
  ```
44
56
 
45
- *(**Pro-tip:** Add `JULES_DRY_RUN=1` before the command to test prompt generation locally without executing the remote API).*
57
+ **What just happened?**
58
+ - Jules wrote code to fulfill your task.
59
+ - The orchestrator ran your tests automatically.
60
+ - If tests failed, Jules fixed the code and re-ran tests.
61
+ - You'll receive a Pull Request with working, verified code.
62
+
63
+ > 🔐 **New in v0.3.0 (The Epistemic Bridge)**: The init script generates a cryptographic Handshake Token (`.agent/JULES_WEB_SETUP.md`). Paste this into the Jules Web UI to sync your environment perfectly.
46
64
 
47
65
  ---
48
66
 
49
- ## 🧠 How It Works: The Autonomous Loop
67
+ ## 🤖 How It Works
68
+
69
+ ### Simple Version (For Everyone)
50
70
 
51
- Instead of blindly trusting AI code mutations, the Orchestrator acts as a strict manager enforcing a **Tiered Verification Gate**:
71
+ ```mermaid
72
+ graph TD
73
+ A["You Assign Task"] --> B["Jules Writes Code<br/>in Sandbox"]
74
+ B --> C["Run Tests & Linters"]
75
+ C --> D{"Tests Pass?"}
76
+ D -->|Yes| E["Create PR for Review"]
77
+ D -->|No| F["Jules Fixes Code"]
78
+ F --> C
79
+ ```
52
80
 
53
- 1. **Queue a Task:** Dispatch via CLI, REST API, or drop markdown files into `.agent/jules-queue/`.
54
- 2. **Secret & Path Defense:** Hides passwords, API keys (`entropy > 3.6`), and blocks path traversal (`../`).
55
- 3. **Jules Proposes Code:** Google Jules mutates code in an isolated environment.
56
- 4. **Tiered Verification:** Enforces scope bounds (`git diff`), runs fast-fail linters/type-checks, then executes full test/build suites.
57
- 5. **Self-Healing PR Gatekeeper (OODA Feedback):** Parses execution stderr traces, logs diagnostic telemetry to `.agent/history/metrics.jsonl`, and enforces strict exit code 1 to block bad code from merging.
81
+ 1. **You define the task** - "Fix the memory leak in the cache module"
82
+ 2. **Jules proposes changes** - In an isolated Git worktree sandbox
83
+ 3. **Automatic verification** - Runs your test suite, linters, and type checks
84
+ 4. **Self-correction** - If anything fails, Jules automatically retries with fixes
85
+ 5. **Safe delivery** - Only working, tested code reaches your main branch
86
+
87
+ ## 🏗️ Architecture & Pipeline Flow
88
+
89
+ ```mermaid
90
+ graph TD
91
+ classDef start fill:#1f2937,stroke:#4b5563,color:#f9fafb;
92
+ classDef core fill:#111827,stroke:#374151,color:#f9fafb;
93
+ classDef gate fill:#1e1b4b,stroke:#4338ca,color:#e0e7ff;
94
+ classDef success fill:#064e3b,stroke:#059669,color:#ecfdf5;
95
+ classDef error fill:#4c0519,stroke:#e11d48,color:#fff1f2;
96
+
97
+ A["1. Client Trigger<br/><i>(CLI / CI / SDK / REST API)</i>"]:::start --> B["2. Orchestrator Core<br/><i>(Redaction & Guardrails)</i>"]:::core
98
+ B --> C["3. Google Jules Agent<br/><i>(Code Gen in Sandbox)</i>"]:::core
99
+ C --> D{"4. Gatekeeper<br/><i>(Scope & Tests)</i>"}:::gate
100
+
101
+ D -->|Scope Breach| E["❌ Exit 3<br/>Security Violation"]:::error
102
+ D -->|100% Passed| F["✅ Exit 0<br/>Success & Log"]:::success
103
+ D -->|Test Failure| G{"5. OODA Repair<br/><i>(Retries < 3?)</i>"}:::gate
104
+
105
+ G -->|Retry| C
106
+ G -->|Circuit Tripped| H["❌ Exit 4<br/>Diagnostic Abort"]:::error
107
+ ```
108
+
109
+ > 💡 **Core Architectural Invariants**:
110
+ > - **Zero-Trust Base-Branch Security**: Security rules (`forbidden_paths`) are fetched exclusively from `origin/main` (never untrusted PR branches).
111
+ > - **Dynamic Command Resolution (`command-resolver.mjs`)**: Auto-detects workspace boundaries (Turborepo, pnpm, Nx, Cargo, pytest, npm).
112
+ > - **SHA-256 OODA Circuit Breaker**: Fingerprints failure traces (`ooda-circuit.json`). Halts auto-repair if identical errors repeat.
58
113
 
59
114
  <details>
60
- <summary><b>🔍 View System Architecture Diagram (For Power Users)</b></summary>
115
+ <summary><b>🔍 View Detailed Sequence Diagram (Step-by-Step Execution Protocol)</b></summary>
61
116
 
62
117
  ```mermaid
63
118
  sequenceDiagram
64
119
  autonumber
65
- participant CLI as CI Trigger / CLI
66
- participant Orc as jules-orchestrator
67
- participant Jules as Google Jules Agent
68
- participant Git as Git Worktree Sandbox
120
+ actor Trigger as Client (CLI / CI / SDK)
121
+ participant Orc as Orchestrator Core
122
+ participant API as Google Jules API
123
+ participant Git as Git / Worktree Sandbox
124
+ participant Gate as Self-Audit Gatekeeper
69
125
 
70
- CLI->>Orc: Dispatch Task ("Refactor Auth")
126
+ Trigger->>Orc: Dispatch Task Payload
71
127
 
72
- note over Orc,Git: Phase 1: Isolation & Setup
73
- Orc->>Orc: Redact Secrets & Check Path Traversal
74
- Orc->>Git: Provision Worktree (`git worktree add`)
75
- Orc->>Jules: Dispatch Context, Invariants & Target Scope
128
+ note over Orc,Git: Phase 1: Security Redaction & Context Enrichment
129
+ Orc->>Orc: Redact Secrets (Entropy > 3.6) & Enforce Dynamic Guardrails
130
+ Orc->>Git: Provision Isolation Sandbox (Worktree / Repoless)
131
+ Orc->>API: Dispatch Task + <MCP_DIRECTIVE> & Target Scope
76
132
 
77
- Jules->>Git: Propose Code Mutations
133
+ API->>Git: Apply Proposed Code Changes
78
134
 
79
- note over Orc,Git: Phase 2: Tiered Verification Gatekeeper
80
- Orc->>Git: Scope Audit (`git diff -z --name-only` vs forbidden_paths)
81
- alt Scope Breach
82
- Git-->>Orc: Scope Violation Error (Exit 1)
83
- else Scope OK
84
- Orc->>Git: Run Verification Suite (`test_cmd` & `build_cmd`)
135
+ note over Orc,Gate: Phase 2: Tiered Verification & OODA Gatekeeper
136
+ Orc->>Gate: Trigger Self-Audit (fetch trusted origin/main rules)
137
+ Gate->>Git: Scope Audit (`git diff -z --name-only` vs forbidden_paths)
138
+
139
+ alt Scope Breach (Forbidden Path Modified)
140
+ Gate-->>Orc: Security Violation Detected
141
+ Orc-->>Trigger: Abort Execution (Exit 3)
142
+ else Scope Verification Passed
143
+ Gate->>Git: Resolve & Run Dynamic Verification Suite (`test_cmd` & `build_cmd`)
85
144
  end
86
145
 
87
- alt Verification Gates Pass
88
- Orc->>Git: Commit, Push & Log Telemetry (.agent/history/metrics.jsonl)
89
- Orc->>CLI: Return Success (Exit 0)
90
- else Verification Gates Fail
91
- Git-->>Orc: Execution Trace (stdout/stderr / Diff)
92
- Orc->>CLI: Log OODA Diagnostic Telemetry & Block PR (Exit 1)
146
+ alt 100% Verification Suite Passed
147
+ Gate->>Orc: Verification Success
148
+ Orc->>Git: Record Telemetry (`metrics.jsonl`)
149
+ Orc-->>Trigger: Dispatch Succeeded (Exit 0)
150
+ else Verification Failed (OODA Feedback Triggered)
151
+ Gate->>Gate: Fingerprint Trace (SHA-256 Error Hash & Check Circuit Breaker)
152
+ alt Auto-Repair Eligible (Retries < 3 & Circuit OK)
153
+ Gate->>API: Auto-Dispatch Repair Prompt with Stderr Trace
154
+ else Circuit Tripped / Max Retries Exceeded
155
+ Gate-->>Orc: Verification Exhausted
156
+ Orc-->>Trigger: Abort & Log Diagnostic Feedback (Exit 4)
157
+ end
93
158
  end
94
159
  ```
95
-
96
160
  </details>
97
161
 
98
162
  ---
99
163
 
100
- ## 💡 Core Capabilities (8 Component Suite)
101
-
102
- ### 🛠️ The Basics
103
-
104
- * **Auto-Configuration (`bin/init.js`)**: Instantly scaffolds your repo using `node:util.parseArgs` with an interactive TTY wizard (`-i`) or silent CI fallback.
105
- * **Queue Runner (`scripts/jules-queue-runner.mjs`)**: Drop markdown task specifications into `.agent/jules-queue/` and let the runner process them sequentially.
106
- * **Nightly Maintenance (`scripts/jules-nightly.mjs`)**: Schedules automated background audits (security leak scans, WCAG accessibility checks, dead code pruning).
107
-
108
- ### 🔒 Security & Guardrails
109
-
110
- * **Secret & Traversal Redaction (`scripts/jules-dispatch.mjs`)**: Shannon Entropy detector strips API keys and secrets (`entropy > 3.6`, `length >= 20`) while preserving valid file paths. Supports dry-run testing (`JULES_DRY_RUN=1`).
111
- * **Dynamic Guardrails (`.agent/rules/dynamic-guardrails.json`)**: RegEx-based rule matching that injects targeted stack guardrails into prompts on-the-fly.
112
-
113
- ### 🐝 Advanced Orchestration
114
-
115
- * **Monorepo Boundary Resolver (`scripts/command-resolver.mjs`)**: Auto-detects `turbo`, `nx`, `pnpm`, or `Cargo` workspaces to run targeted affected package verifications (`git diff`) instead of full-repo test suites.
116
- * **Self-Healing Gatekeeper (`scripts/jules-self-audit.mjs`)**: Unshallows git history in CI runners (`git fetch --unshallow`), enforces `forbidden_paths`, extracts OODA feedback error traces, and logs telemetry to `.agent/history/metrics.jsonl`.
117
- * **Git Worktree Swarms (`scripts/jules-swarm.mjs`)**: Manages multi-task batches in isolated Git worktrees (`JULES_USE_WORKTREES=true`) with scope boundary isolation.
118
-
119
- ---
164
+ ## ⚙️ Configuration
120
165
 
121
- ## ⚙️ Configuration & Zero-Trust Security
166
+ ### Custom Configuration (`.agent/jules.yml`)
122
167
 
123
- The orchestrator creates an `.agent/jules.yml` file to manage repo-level verification and security:
168
+ The orchestrator automatically detects your tech stack, but you can edit `.agent/jules.yml` for fine-grained control:
124
169
 
125
170
  ```yaml
126
171
  # Google Jules Repository Configuration (Version 2)
@@ -137,118 +182,128 @@ forbidden_paths:
137
182
  allow_paths: []
138
183
  ```
139
184
 
140
- > 🛡️ **Zero-Trust Security Model**: `allow_paths` and `forbidden_paths` rules are read **strictly from the target base branch** (`origin/main`), never from untrusted PR branches. Even if an AI agent hallucinates and tries to modify its own security rules in a PR branch, the Orchestrator enforces the immutable rules defined on `main`.
141
- > ℹ️ Setting `build_cmd: ""` explicitly skips the build verification step (useful for pure test suites or scripts). Note that `.agent/jules.yml` uses a zero-dependency parser that supports flow (`[...]`) and block (`- item`) list subsets.
142
- > 📦 `.github/` is intentionally included in `package.json`'s `files` array so that `npx jules-init` can automatically scaffold `.github/workflows/jules-audit.yml` into target repositories.
185
+ > 🛡️ **Zero-Trust Security Model**: Configuration is always read from your target base branch (`origin/main`), never from untrusted PR branches.
143
186
 
144
187
  ---
145
188
 
146
- <details>
147
- <summary><b>🛠️ Supported Language Manifests & Workspace Graphs (15+ Tech Stacks)</b></summary>
148
-
149
- | Stack / Ecosystem | Manifest / Workspace File | Test Command (`testCmd`) | Build Command (`buildCmd`) |
150
- |---|---|---|---|
151
- | **Turborepo** | `turbo.json` | `npx turbo run test --filter=<pkg>...` | `npx turbo run build --filter=<pkg>...` |
152
- | **pnpm Workspace** | `pnpm-workspace.yaml` | `pnpm --filter=...<pkg> test` | `pnpm --filter=...<pkg> build` |
153
- | **Nx Workspace** | `nx.json` | `npx nx run-many -t test -p <pkg> --with-deps` | `npx nx run-many -t build -p <pkg> --with-deps` |
154
- | **Bun** | `bunfig.toml` / `bun.lockb` | `bun test` | `bun run build` |
155
- | **Deno** | `deno.json` / `deno.jsonc` | `deno test` | `deno task build` |
156
- | **JavaScript / TypeScript** | `package.json` | `npm run lint && npm test` | `npm run build` |
157
- | **Rust** | `Cargo.toml` | `cargo test --workspace` | `cargo build` |
158
- | **Go** | `go.mod` | `go test ./...` | `go build ./...` |
159
- | **Python** | `pyproject.toml` / `requirements.txt` | `pytest` | *(none)* |
160
- | **Elixir** | `mix.exs` | `mix test` | `mix compile` |
161
- | **Ruby** | `Gemfile` | `bundle exec rake test` | *(none)* |
162
- | **Swift** | `Package.swift` | `swift test` | `swift build` |
163
- | **Java (Maven/Gradle)** | `pom.xml` / `build.gradle` | `mvn test` / `./gradlew test` | `mvn compile` / `./gradlew assemble` |
164
- | **C / C++** | `Makefile` | `make test` | `make build` |
165
-
166
- </details>
189
+ ## 💡 Features
190
+
191
+ ### 🛡️ Core Safety (For Everyone)
192
+
193
+ | Feature | What It Does | Example |
194
+ | --------------------- | -------------------------------------------- | ------------------------------------- |
195
+ | **Automatic Testing** | Runs test suite against every AI change | `test_cmd: "npm test"` |
196
+ | **Self-Fixing** | Jules automatically corrects failed tests | Retries up to 4 times before blocking |
197
+ | **Secret Protection** | Hides API keys, passwords, tokens | Entropy > 3.6, length ≥ 20 |
198
+ | **Path Restrictions** | Blocks changes to sensitive files | `.env`, `*.pem`, `.github/**` |
199
+ | **Scope Boundaries** | Prevents changes outside task scope | `scope: ["src/auth/**"]` |
200
+ | **Agent Scope Guard** | CI-enforced protected paths manifestation | `.agent/protected-paths.json` |
201
+ | **Payload Governor** | Hard cap to prevent > 80 KB payload failures | Diffs capped at 75 KB |
202
+
203
+
204
+ | Feature | Use Case | Command |
205
+ | ----------------------- | ----------------------------------------- | ------------------------------------------ |
206
+ | **Git Worktree Swarms** | Parallel tasks with slot isolation | `node scripts/jules-swarm.mjs tasks.json` |
207
+ | **Suggested Scanner** | Scan TODO/FIXME comments into task queues | `npm run jules:scan` |
208
+ | **Session Cleanup** | Audit & close merged/stale REST sessions | `npm run jules:cleanup -- --close-merged` |
209
+ | **Repoless Sessions** | Serverless ad-hoc analysis without repos | `npm run jules:dispatch -- --repoless ...` |
210
+ | **Monorepo Support** | Auto-detects Turbo, Nx, pnpm, Cargo | Runs affected package tests only |
211
+ | **Queue Pacing** | Rate-limit queue launches (`--pace-ms`) | `npm run jules:queue -- --pace-ms 500` |
212
+ | **Pre-Flight Sandbox** | Test setup locally before cloud execution | `node scripts/jules-self-audit.mjs --preflight` |
213
+ | **Security Fencing** | Prompt injection defense & secret masking | Automatic `<UNTRUSTED_TASK_CONTEXT>` encapsulation |
214
+ | **OODA Feedback** | Self-healing from test failures | Logs to `.agent/history/metrics.jsonl` |
215
+ | **Mutex Lock Protocol** | Prevent concurrent file collisions | `node scripts/lock-manager.mjs acquire` |
216
+ | **Baton Pass Protocol** | Stateful handovers to human/other AI | `.agent/history/*-handover-*.md` |
167
217
 
168
218
  ---
169
219
 
170
- <details>
171
- <summary><b>📖 Advanced Workflows (Queues, Swarms, Nightly Maintenance)</b></summary>
220
+ ## 🔌 Expand with MCP (Model Context Protocol)
172
221
 
173
- ### 1. Process an entire queue of background tasks
222
+ All task dispatches dynamically inject `<MCP_DIRECTIVE>` envelopes into task prompts. This forces Jules to adhere to strict read-before-write invariants and deterministic execution when operating alongside **MCP server tools**.
174
223
 
175
- ```bash
176
- npm run jules:queue
177
- ```
224
+ **Pro-tip:** You can supercharge Jules with external MCP servers! By connecting standard MCP servers to your environment, you give Jules direct access to your infrastructure and real-time documentation. Some powerful examples include:
178
225
 
179
- ### 2. Run Rate-Limited Swarms with Scope Isolation
226
+ * **SaaS APIs & Tooling:** Context 7, Linear, and v0 for issue tracking and UI generation.
227
+ * **Databases & Cloud:** Render, Neon, Supabase, Stitch, and Tinybird.
228
+ * **Framework Documentation:** Astro Docs, Cloudflare Docs, Next.js Docs, etc.
180
229
 
181
- Run massive parallel refactors safely. The orchestrator uses `tasks.json` file boundary `scope` segregation to prevent parallel task collisions:
230
+ By feeding these MCPs into your ecosystem, Jules can automatically read the latest framework documentation or query your live database schema before writing code!
182
231
 
183
- ```bash
184
- JULES_SWARM_CONCURRENCY=5 JULES_USE_WORKTREES=true node scripts/jules-swarm.mjs tasks.json
185
- ```
232
+ ---
186
233
 
187
- *(Example `tasks.json` constraint: `[ { "id": "t1", "prompt": "Refactor auth", "scope": ["src/auth/**"] } ]`)*
234
+ ## 🌐 Integration Interfaces
188
235
 
189
- ### 3. Run Nightly Maintenance Suite
236
+ The orchestrator supports two primary integration channels for manual tasks:
190
237
 
191
- ```bash
192
- node scripts/jules-nightly.mjs --dry-run
193
- ```
238
+ **1. Direct REST API Mode (`jules.googleapis.com`)**
239
+ When `JULES_API_KEY` and `JULES_REPO` are present in your environment, payloads are dispatched directly to the official Google Jules REST API endpoint. Handles HTTP 429 rate limits gracefully.
194
240
 
195
- ### 4. Audit Jules PRs before merging in CI
241
+ **2. Native Jules CLI Fallback**
242
+ If no API key is configured, the kit seamlessly falls back to invoking your local `jules` CLI binary via standard streams.
196
243
 
197
- ```bash
198
- node scripts/jules-self-audit.mjs
244
+ **3. Programmatic Node.js SDK (`index.mjs`)**
245
+ Downstream Node.js tools, MCP servers, and LLM orchestrators can import kit functions directly:
246
+ ```js
247
+ import { runSelfAudit, scanCodebaseForTodos, resolveProjectCommands } from "jules-orchestrator-kit";
248
+
249
+ // Run pre-flight sandbox check
250
+ await runPreflightSandbox();
251
+
252
+ // Scan codebase for TODO/FIXME tasks
253
+ const tasks = scanCodebaseForTodos(process.cwd());
199
254
  ```
200
255
 
201
- </details>
256
+ ---
257
+
258
+ ## ⚠️ Known Limitations & Workarounds
259
+
260
+ While this kit automates the heavy lifting of code generation and PR creation, there are a few limitations in how it interacts with the underlying Jules platform:
261
+
262
+ ### Code Suggestions (Web UI Only)
263
+ Currently, there is no way to automatically extract "Suggestions" (the inline code review comments Jules sometimes proposes instead of direct commits) via the CLI or API. Suggestions can only be read directly inside the **Jules Web UI**.
264
+
265
+ * **Workaround for Local LLM Users:** If you are tinkering with Jules alongside a local LLM (e.g., Claude, Cursor, Antigravity) and Jules leaves a Suggestion, the easiest workflow is to open the Jules Web UI, copy the suggestion block, and paste it back into your local LLM to let it review and integrate the proposed changes.
202
266
 
203
267
  ---
204
268
 
269
+ ## 📦 Supported Tech Stacks
270
+
205
271
  <details>
206
- <summary><b>🌐 Integration Interfaces: CLI, REST API & MCP Directives</b></summary>
207
-
208
- `jules-orchestrator-kit` supports three primary integration channels:
209
-
210
- ### 1. Direct REST API Mode (`jules.googleapis.com`)
211
- When `JULES_API_KEY` and `JULES_REPO` are present in your environment (`.env` or CI secrets), payloads are dispatched directly to the official Google Jules REST API endpoint.
212
- - Handles HTTP 429 rate limits gracefully.
213
- - Automatically maps `startingBranch` and `sourceContext`.
214
-
215
- ### 2. Native Jules CLI Fallback (`jules new`)
216
- If no API key is configured, the kit seamlessly falls back to invoking your local `jules` CLI binary. Prompts are piped directly via `stdin` to bypass OS `ARG_MAX` shell argument length limits.
217
-
218
- ### 3. MCP (Model Context Protocol) Directives
219
- All task dispatches dynamically inject `<MCP_DIRECTIVE>` envelopes into task prompts:
220
- ```xml
221
- <MCP_DIRECTIVE>
222
- <system_state>HEADLESS_CI_MODE</system_state>
223
- <strict_invariants>
224
- <rule>1. READ-BEFORE-WRITE: Inspect symbol definitions before editing.</rule>
225
- <rule>2. VERIFICATION LOOP: Execute test_cmd and pass with 0 errors.</rule>
226
- <rule>3. ABORT CONDITION: Terminate on 4+ repeated test failures.</rule>
227
- <rule>4. ASSERTION QUALITY: Unit tests created or modified MUST contain explicit assertions.</rule>
228
- </strict_invariants>
229
- </MCP_DIRECTIVE>
230
- ```
231
- This forces Jules to adhere to strict read-before-write invariants and deterministic execution when operating alongside MCP server tools.
272
+ <summary><b>🛠️ View Supported Language Manifests & Workspace Graphs</b></summary>
273
+
274
+ | Stack / Ecosystem | Manifest / Workspace File | Test Command | Build Command |
275
+ | --------------------------- | ------------------------------------- | ---------------------------------------- | ---------------------------------------- |
276
+ | **Turborepo** | `turbo.json` | `npx turbo run test --filter=...` | `npx turbo run build --filter=...` |
277
+ | **pnpm Workspace** | `pnpm-workspace.yaml` | `pnpm --filter=... test` | `pnpm --filter=... build` |
278
+ | **Nx Workspace** | `nx.json` | `npx nx run-many -t test -p ...` | `npx nx run-many -t build -p ...` |
279
+ | **Bun** | `bunfig.toml` / `bun.lockb` | `bun test` | `bun run build` |
280
+ | **Deno** | `deno.json` / `deno.jsonc` | `deno test` | `deno task build` |
281
+ | **JavaScript / TypeScript** | `package.json` | `npm test` | `npm run build` |
282
+ | **Rust** | `Cargo.toml` | `cargo test --workspace` | `cargo build` |
283
+ | **Go** | `go.mod` | `go test ./...` | `go build ./...` |
284
+ | **Python** | `pyproject.toml` / `requirements.txt` | `pytest` | *(none)* |
285
+ | **Elixir** | `mix.exs` | `mix test` | `mix compile` |
286
+ | **Ruby** | `Gemfile` | `bundle exec rake test` | *(none)* |
287
+ | **Swift** | `Package.swift` | `swift test` | `swift build` |
288
+ | **Java (Maven/Gradle)** | `pom.xml` / `build.gradle` | `mvn test` / `./gradlew test` | `mvn compile` / `./gradlew assemble` |
289
+ | **C / C++** | `Makefile` | `make test` | `make build` |
232
290
 
233
291
  </details>
234
292
 
235
293
  ---
236
294
 
237
- <details>
238
- <summary><b>🤝 Contributing & Code Guidelines</b></summary>
239
-
240
- We welcome contributions! Please follow these core principles when submitting Pull Requests:
295
+ ## 🤝 Contributing
241
296
 
242
- 1. **Zero External Dependencies**: Keep the orchestrator engine 100% dependency-free. Use ONLY native Node.js built-in modules (`node:fs`, `node:path`, `node:child_process`, `node:crypto`, `node:util`).
243
- 2. **Verification Suite**: Ensure 100% of unit tests pass cleanly (`npm test`).
244
- 3. **Conventional Commits**: Use standardized commit message prefixes (`feat:`, `fix:`, `docs:`, `test:`, `chore:`).
245
- 4. **Cross-Platform Compatibility**: Always normalize Windows backslashes (`\`) to POSIX slashes (`/`) for glob patterns and paths.
297
+ We welcome contributions! Please follow these core principles:
246
298
 
247
- </details>
299
+ 1. **Zero External Dependencies**: Use ONLY native Node.js built-in modules (`node:fs`, `node:path`, `node:child_process`, `node:crypto`, `node:util`)
300
+ 2. **Verification Suite**: Ensure 100% of unit tests pass cleanly (`npm test`)
301
+ 3. **Conventional Commits**: Use standardized prefixes (`feat:`, `fix:`, `docs:`, `test:`, `chore:`)
302
+ 4. **Cross-Platform Compatibility**: Normalize Windows backslashes (`\`) to POSIX slashes (`/`) for glob patterns and paths
248
303
 
249
304
  ---
250
305
 
251
- ## 📜 License & Disclaimer
306
+ ## 📜 License
252
307
 
253
308
  MIT License - feel free to use, modify, and share!
254
309