jules-orchestrator-kit 0.3.0 β†’ 0.5.2

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.
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.5.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 3 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
 
package/bin/init.js CHANGED
@@ -5,6 +5,8 @@ import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { parseArgs } from "node:util";
7
7
  import readline from "node:readline/promises";
8
+ import zlib from "node:zlib";
9
+ import crypto from "node:crypto";
8
10
  import { resolveProjectCommands } from "../scripts/command-resolver.mjs";
9
11
 
10
12
  const __filename = fileURLToPath(import.meta.url);
@@ -57,10 +59,13 @@ if (isForce) console.log("⚠️ Force mode enabled (existing files will be over
57
59
  let answerRepoVal = "";
58
60
  let answerBranchVal = "";
59
61
 
60
- // Dual TTY Interactive Wizard
61
62
  if (process.stdin.isTTY && (isInteractive || (!fs.existsSync(path.join(targetDir, ".agent/jules.yml")) && !process.env.CI))) {
62
63
  try {
63
64
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
65
+ rl.on('SIGINT', () => {
66
+ console.log("\nπŸ›‘ Initialization aborted by user.");
67
+ process.exit(130);
68
+ });
64
69
  const answerRepo = await rl.question("πŸ“¦ Enter target GitHub repository (e.g. owner/repo) [optional]: ");
65
70
  if (answerRepo.trim()) {
66
71
  answerRepoVal = answerRepo.trim();
@@ -73,6 +78,10 @@ if (process.stdin.isTTY && (isInteractive || (!fs.existsSync(path.join(targetDir
73
78
  }
74
79
  rl.close();
75
80
  } catch (err) {
81
+ if (err.name === 'AbortError') {
82
+ console.log("\nπŸ›‘ Initialization aborted by user.");
83
+ process.exit(130);
84
+ }
76
85
  console.warn("⚠️ Interactive setup prompt failed:", err.message);
77
86
  }
78
87
  }
@@ -181,7 +190,7 @@ if (fs.existsSync(auditWfSource)) {
181
190
  }
182
191
  if (!fs.existsSync(auditWfTarget) || isForce) {
183
192
  fs.copyFileSync(auditWfSource, auditWfTarget);
184
- console.log("βœ… Scaffolded CI Audit Workflow: .github/workflows/jules-audit.yml");
193
+ console.log("βœ… Added GitHub Actions workflow: .github/workflows/jules-audit.yml");
185
194
  }
186
195
  }
187
196
 
@@ -225,6 +234,8 @@ if (fs.existsSync(targetPkgPath) && targetDir !== kitRoot) {
225
234
  const julesScripts = {
226
235
  "jules:dispatch": "node scripts/jules-dispatch.mjs",
227
236
  "jules:queue": "node scripts/jules-queue-runner.mjs",
237
+ "jules:create": "node scripts/jules-create.mjs",
238
+ "jules:status": "node scripts/jules-status.mjs",
228
239
  "jules:audit": "node scripts/jules-self-audit.mjs",
229
240
  "jules:swarm": "node scripts/jules-swarm.mjs",
230
241
  "jules:nightly": "node scripts/jules-nightly.mjs"
@@ -239,7 +250,7 @@ if (fs.existsSync(targetPkgPath) && targetDir !== kitRoot) {
239
250
 
240
251
  if (updated) {
241
252
  fs.writeFileSync(targetPkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
242
- console.log("βœ… Injected jules:* helper scripts into package.json");
253
+ console.log("βœ… Added Jules commands to package.json");
243
254
  }
244
255
  } catch (err) {
245
256
  console.warn("⚠️ Failed to inject helper scripts into target package.json:", err.message);
@@ -247,7 +258,55 @@ if (fs.existsSync(targetPkgPath) && targetDir !== kitRoot) {
247
258
  }
248
259
 
249
260
  console.log("\nπŸŽ‰ Google Jules Orchestration Kit successfully initialized!");
261
+
262
+ // 6. Generate Cryptographic Handshake (JULES_WEB_SETUP.md)
263
+ const agentState = {
264
+ v: 1,
265
+ schema: "jules.init/v1",
266
+ generatedAt: new Date().toISOString(),
267
+ repo: {
268
+ name: answerRepoVal || process.env.JULES_REPO || "unknown/repo",
269
+ branch: answerBranchVal || process.env.BASE_BRANCH || "main"
270
+ },
271
+ workspace: {
272
+ testCmd: detected.testCmd || "",
273
+ buildCmd: detected.buildCmd || "",
274
+ source: detected.source || "unknown"
275
+ }
276
+ };
277
+
278
+ const canonicalJson = JSON.stringify(agentState);
279
+ const hash = crypto.createHash("sha256").update(canonicalJson, "utf8").digest("hex");
280
+ const compressed = zlib.brotliCompressSync(Buffer.from(canonicalJson, "utf8"));
281
+ const payloadToken = `JULES1.${hash}.${compressed.toString("base64url")}`;
282
+
283
+ const setupMdContent = `# JULES Web Setup
284
+
285
+ > **Generated**: ${agentState.generatedAt}
286
+ > **Setup Code**: \`${payloadToken}\`
287
+
288
+ ## πŸ”— Web Dashboard Setup
289
+ 1. Open Jules Web UI (https://app.jules.ai/setup)
290
+ 2. Paste your Setup Code:
291
+ \`\`\`
292
+ ${payloadToken}
293
+ \`\`\`
294
+
295
+ ## πŸ”§ Detected Configuration
296
+ * Test Command: \`${agentState.workspace.testCmd}\`
297
+ * Build Command: \`${agentState.workspace.buildCmd}\`
298
+ * Source: \`${agentState.workspace.source}\`
299
+ `;
300
+
301
+ fs.writeFileSync(path.join(targetDir, ".agent", "JULES_WEB_SETUP.md"), setupMdContent, "utf-8");
302
+
303
+ console.log("\nπŸ”— Web Dashboard Setup");
304
+ console.log(" Your local agent configurations are ready.");
305
+ console.log(` πŸ‘‰ Setup Code: \x1b[36m${payloadToken}\x1b[0m`);
306
+ console.log("\n (A backup of this setup code was written to .agent/JULES_WEB_SETUP.md)");
250
307
  console.log("\nNext Steps:");
251
- console.log(" 1. Set environment variables: JULES_REPO=\"owner/repo\"");
252
- console.log(" 2. Dispatch your first task: node scripts/jules-dispatch.mjs \"Task Title\" \"Task prompt\"");
253
- console.log(" 3. Run pre-merge PR audit: node scripts/jules-self-audit.mjs\n");
308
+ console.log(" 1. Paste the Setup Code into Jules Web UI.");
309
+ console.log(" 2. Set environment variables: JULES_REPO=\"owner/repo\"");
310
+ console.log(" 3. Scaffold a new task: npm run jules:create \"My Feature\"");
311
+ console.log(" 4. Dispatch the queue: npm run jules:queue");
312
+ console.log(" 5. Run pre-merge audit: npm run jules:audit\n");
package/index.mjs ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * jules-orchestrator-kit Node.js SDK
3
+ * Primary entrypoint for programmatically orchestrating Google Jules workflows.
4
+ * Zero external dependencies.
5
+ */
6
+
7
+ export { resolveProjectCommands, resolveWorkspaceExecutionBoundary } from "./scripts/command-resolver.mjs";
8
+ export { runSelfAudit, runPreflightSandbox, loadForbiddenPatterns, loadAllowedPatterns, matchGlob } from "./scripts/jules-self-audit.mjs";
9
+ export { scanCodebaseForTodos, runScanner } from "./scripts/jules-scan-todos.mjs";
10
+ export { log, logToHistory, ensureDir, resolveMarkdownConflict } from "./scripts/utils.mjs";
11
+ export { redactSecrets, getDynamicGuardrails } from "./scripts/jules-dispatch.mjs";