jules-orchestrator-kit 0.1.9 → 0.2.8

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,9 @@
1
+ ---
2
+ type: jules_dispatch
3
+ title: "Test Swarm Task"
4
+ timestamp: "2026-07-27T09:25:41.107Z"
5
+ ---
6
+ # Jules Task Dispatch: Test Swarm Task
7
+
8
+ ## Prompt
9
+ Test Prompt Description
@@ -16,7 +16,14 @@ Implement sliding window rate limiting for public API routes.
16
16
  - Must pass `npm test` before submitting PR.
17
17
  ```
18
18
 
19
- Dispatch queued tasks using `scripts/jules-dispatch.mjs`:
19
+ Process all queued tasks in batch:
20
+
21
+ ```bash
22
+ npm run jules:queue
23
+ # or node scripts/jules-queue-runner.mjs
24
+ ```
25
+
26
+ Or dispatch a single queued task using `scripts/jules-dispatch.mjs`:
20
27
 
21
28
  ```bash
22
29
  node scripts/jules-dispatch.mjs "TASK-001 Rate Limiting" .agent/jules-queue/TASK-001-rate-limiting.md
package/.env.example ADDED
@@ -0,0 +1,17 @@
1
+ # Google Jules Orchestration Kit - Environment Configuration Example
2
+ # Copy this file to .env and populate with your credentials/settings.
3
+
4
+ # Google Jules API Key (Required for direct REST API dispatches)
5
+ JULES_API_KEY=your_google_jules_api_key_here
6
+
7
+ # Target GitHub Repository (Format: owner/repo)
8
+ JULES_REPO=FullThrottle83/jules-orchestrator-kit
9
+
10
+ # Base Branch for PR Audits & Merge-Base Calculations (Default: main)
11
+ BASE_BRANCH=main
12
+
13
+ # Swarm Concurrency Limit (Maximum parallel dispatches, default: 3)
14
+ JULES_SWARM_CONCURRENCY=3
15
+
16
+ # Swarm Dispatch Stagger Interval in Milliseconds (Default: 1500)
17
+ JULES_SWARM_STAGGER_MS=1500
@@ -0,0 +1,32 @@
1
+ name: Jules PR Audit & Test Gatekeeper
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ audit-and-test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout repository
14
+ uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: Setup Node.js
19
+ uses: actions/setup-node@v4
20
+ with:
21
+ node-version: "20"
22
+
23
+ - name: Run Unit Tests
24
+ run: npm test
25
+
26
+ - name: Run Jules PR Self-Audit Gatekeeper
27
+ if: github.event_name == 'pull_request' && (startsWith(github.actor, 'google-labs-jules') || contains(github.actor, 'jules'))
28
+ run: node scripts/jules-self-audit.mjs
29
+ env:
30
+ CI: "true"
31
+ BASE_BRANCH: "main"
32
+
@@ -0,0 +1,21 @@
1
+ name: Jules Nightly Self-Audit
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 3 * * *'
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ nightly-audit:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-node@v4
14
+ with:
15
+ node-version: 20
16
+ - name: Dispatch Nightly Maintenance to Jules
17
+ env:
18
+ JULES_API_KEY: ${{ secrets.JULES_API_KEY }}
19
+ JULES_REPO: ${{ github.repository }}
20
+ run: |
21
+ node scripts/jules-nightly.mjs
@@ -0,0 +1,24 @@
1
+ name: Auto Publish to npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: "20"
20
+ registry-url: 'https://registry.npmjs.org'
21
+ - run: npm test
22
+ - run: npm publish --provenance --access public
23
+ env:
24
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -24,6 +24,8 @@ Dispatch tasks to Jules when ALL of the following apply:
24
24
  <rule>2. READ-BEFORE-WRITE (ZERO HALLUCINATION): You are FORBIDDEN from guessing internal API signatures. Before editing, you MUST use code search or MCP doc tools to inspect exact function signatures.</rule>
25
25
  <rule>3. VERIFICATION LOOP: After patching code, you MUST execute the project's verification commands (tests/build) and ensure 0 errors.</rule>
26
26
  <rule>4. ABORT CONDITION: On repeated unresolvable test failures (4+ attempts), output <status>ABORT_UNRESOLVABLE</status> and terminate immediately.</rule>
27
+ <rule>5. NO OUT-OF-BAND RUNNER SCRIPTS / CHEATING: You are FORBIDDEN from creating temporary shell scripts (e.g. patch.sh, test-fix.sh), disabling assertions, or bypassing verification tooling to force tests to pass.</rule>
28
+ <rule>6. ASSERTION QUALITY: Unit tests created or modified MUST contain explicit, non-trivial assertions (e.g. assert/expect) testing realistic input/output contracts. Empty test functions or tests asserting tautologies (e.g. true === true) are strictly forbidden.</rule>
27
29
  </strict_invariants>
28
30
  </MCP_DIRECTIVE>
29
31
  ```
@@ -32,20 +34,22 @@ Dispatch tasks to Jules when ALL of the following apply:
32
34
 
33
35
  ## 3. Dynamic Command Resolution
34
36
 
35
- Jules automatically infers test and build verification commands based on project manifest files:
36
- - `package.json` -> `npm test && npm run build`
37
+ Jules automatically infers test and build verification commands via `scripts/command-resolver.mjs`:
38
+ - `.agent/jules.yml` -> Custom user commands (`test_cmd`, `build_cmd`)
39
+ - `package.json` -> `npm test` (or `npm run lint && npm test` if lint script exists)
37
40
  - `Cargo.toml` -> `cargo test --workspace && cargo build`
38
41
  - `go.mod` -> `go test ./... && go build ./...`
39
42
  - `pyproject.toml` -> `pytest`
40
43
  - `pom.xml` -> `mvn test`
41
44
  - `build.gradle` -> `./gradlew test`
42
- - `.agent/jules.yml` -> Custom user commands
45
+ - Workspace graphs (`turbo.json`, `pnpm-workspace.yaml`, `nx.json`) -> targeted affected package filters
43
46
 
44
47
  ---
45
48
 
46
49
  ## 4. Operational & Code Quality Directives
47
50
 
48
51
  - **Read Before Write**: Always inspect target files and surrounding symbol signatures (via grep or view tools) before applying changes.
52
+ - **Scope Locks**: Strictly adhere to designated file bounds. Do NOT modify files outside the explicit task scope or alter shared infrastructural components unless assigned.
49
53
  - **Rebase Before PR**: Fetch latest `main`, rebase onto `origin/main`, re-execute verification suite. If the resulting diff is empty, close/abort PR without pushing.
50
54
  - **Minimal Interference**: Preserve existing function signatures, comments, and style conventions.
51
55
  - **Falsifiable Claims**: Base all code changes on explicit error logs, file paths, line numbers, or test results.
package/README.md CHANGED
@@ -1,90 +1,161 @@
1
- # Google Jules Orchestration Kit
1
+ # Google Jules Orchestration Kit šŸ¤–āš”
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/jules-orchestrator-kit.svg)](https://www.npmjs.com/package/jules-orchestrator-kit)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-green.svg)](https://nodejs.org)
6
+ [![Zero Dependencies](https://img.shields.io/badge/Dependencies-0-blue.svg)](#)
5
7
 
6
- A lightweight, framework-agnostic toolkit for turning **Google Jules** into a deterministic, autonomous background code builder for any repository (Next.js, Vite, Node, Bun, Deno, Python, Go, Rust, Elixir, Ruby, Swift, Java, C/C++, Monorepos, etc.).
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.).
7
9
 
8
- > **TL;DR**: Don't use Google Jules like a chat assistant. Use it as an autonomous background worker. Run `npx jules-orchestrator-kit` inside any repository to automatically detect your tech stack, generate prompt guardrails, set up test/build verification gates, and install Jules orchestration scripts.
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
+
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.
13
+
14
+ ---
15
+
16
+ ## šŸŽÆ Who is this for?
17
+
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.
9
23
 
10
24
  ---
11
25
 
12
- ## ⚔ 1-Step Quick Setup for Any Project
26
+ ## šŸš€ Quick Start: Zero to Autonomous AI
13
27
 
14
- Run this command inside the root of **any target repository**:
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:
15
30
 
16
31
  ```bash
17
32
  npx jules-orchestrator-kit
18
- # or
19
- npx jules-init
33
+
34
+ # Or launch the interactive setup wizard:
35
+ npx jules-init --interactive
20
36
  ```
21
37
 
22
- This single command will:
23
- 1. **Detect your tech stack & workspace structure** (Node, Bun, Deno, Rust, Go, Python, Elixir, Ruby, Swift, Java, C/C++, Turborepo, Nx, pnpm) via `command-resolver.mjs`.
24
- 2. **Generate `AGENTS.md`** pre-populated with pre-execution `<MCP_DIRECTIVE>` rules and verification invariants.
25
- 3. **Create `.agent/jules.yml` (v2 Schema)** pre-configured with detected test/build commands and glob-based `forbidden_paths`.
26
- 4. **Install `.agent/rules/dynamic-guardrails.json`** for RegEx-based dynamic prompt guardrail injection.
27
- 5. **Install orchestration scripts** into `./scripts/` (`jules-dispatch.mjs`, `jules-self-audit.mjs`, `jules-swarm.mjs`, `jules-queue-runner.mjs`, `jules-nightly.mjs`).
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:
28
40
 
29
- ---
41
+ ```bash
42
+ node scripts/jules-dispatch.mjs "Refactor rate limiter" "Implement sliding window rate limiting in src/utils/rate-limit.ts"
43
+ ```
44
+
45
+ *(**Pro-tip:** Add `JULES_DRY_RUN=1` before the command to test prompt generation locally without executing the remote API).*
30
46
 
31
- ## šŸ’” What This Toolkit Provides
47
+ ---
32
48
 
33
- 1. **Init Scaffolding CLI (`bin/init.js`)**: Auto-scaffolds any repo in 1 second.
34
- 2. **Monorepo & Command Resolver (`scripts/command-resolver.mjs`)**: Auto-detects project manifests and monorepo workspace graphs (`turbo.json`, `pnpm-workspace.yaml`, `nx.json`, `Cargo.toml` workspaces) to run targeted affected package verifications instead of full-repo test suites.
35
- 3. **Dynamic Guardrail Composition (`.agent/rules/dynamic-guardrails.json`)**: RegEx-based rule matching that injects targeted stack guardrails into prompts on-the-fly.
36
- 4. **Pre-Flight Secret Redaction & REST/stdin Dispatcher (`scripts/jules-dispatch.mjs`)**: Auto-redacts API keys (`ghp_`, `AKIA`, `sk-`, `Bearer`, RSA keys), streams prompts over REST / stdin to bypass OS `ARG_MAX` shell limits, and handles HTTP 429 rate limits.
49
+ ## 🧠 How It Works: The Autonomous Loop
50
+
51
+ Instead of blindly trusting AI code mutations, the Orchestrator acts as a strict manager enforcing a **Tiered Verification Gate**:
52
+
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-Correction (OODA Loop):** If tests fail, stderr traces are fed back to Jules to self-correct (up to 4 attempts).
58
+ 6. **Clean Pull Request:** Once verified green, commits & pushes clean code to GitHub.
59
+
60
+ <details>
61
+ <summary><b>šŸ” View System Architecture Diagram (For Power Users)</b></summary>
62
+
63
+ ```mermaid
64
+ sequenceDiagram
65
+ autonumber
66
+ participant CLI as CI Trigger / CLI
67
+ participant Orc as jules-orchestrator
68
+ participant Jules as Google Jules Agent
69
+ participant Git as Git Worktree Sandbox
70
+
71
+ CLI->>Orc: Dispatch Task ("Refactor Auth")
72
+
73
+ note over Orc,Git: Phase 1: Isolation & Setup
74
+ Orc->>Orc: Redact Secrets & Check Path Traversal
75
+ Orc->>Git: Provision Worktree (`git worktree add`)
76
+ Orc->>Jules: Dispatch Context, Invariants & Target Scope
77
+
78
+ loop Max Retries (Attempts < 4)
79
+ Jules->>Git: Propose Code Mutations
80
+
81
+ note over Orc,Git: Phase 2: Tiered Verification
82
+ Orc->>Git: Scope Audit (`git diff --name-only` vs forbidden_paths)
83
+ alt Scope Breach
84
+ Git-->>Orc: Scope Violation Error
85
+ else Scope OK
86
+ Orc->>Git: Run Fast-Fail Checks (Lint / Typecheck)
87
+ opt Pass Static Checks
88
+ Orc->>Git: Run Heavy Suite (`build_cmd` & `test_cmd`)
89
+ end
90
+ end
91
+
92
+ alt Verification Gates Pass
93
+ Orc->>Git: Commit, Push & Cleanup Worktree
94
+ Orc->>CLI: Return Success + Metrics (.agent/history/metrics.jsonl)
95
+ note over Jules,Git: Exit Loop
96
+ else Verification Gates Fail (Attempts < 4)
97
+ Git-->>Orc: Execution Trace (stdout/stderr / Diff)
98
+ Orc->>Jules: Inject OODA Feedback & Error Context
99
+ end
100
+ end
101
+
102
+ opt Verification Gates Fail (Attempts >= 4)
103
+ Orc->>Git: Abort & Rollback Worktree (`git worktree remove --force`)
104
+ Orc->>CLI: Return Terminal Failure (.agent/history/errors.jsonl)
105
+ end
106
+ ```
37
107
 
38
- 5. **PR Self-Auditor & Glob Boundary Gatekeeper (`scripts/jules-self-audit.mjs`)**: Unshallows git history in CI runners (`git fetch --unshallow`), filters token bloat, enforces dynamic glob-based security boundaries (`forbidden_paths`), and runs scoped workspace test suites.
39
- 6. **Queue Runner (`scripts/jules-queue-runner.mjs`)**: Iterates through `.agent/jules-queue/`, dispatches queued markdown tasks, and moves finished tasks to `.agent/jules-queue/completed/`.
40
- 7. **Rate-Limited Swarm Orchestrator (`scripts/jules-swarm.mjs`)**: Manages multi-task batches with controlled concurrency (`JULES_SWARM_CONCURRENCY`, default 3), staggered dispatches (1.5s interval), and batch cooldowns to eliminate API rate-limit thrashing.
41
- 8. **Nightly Maintenance Suite (`scripts/jules-nightly.mjs`)**: Schedules automated background audits (security leak scans, WCAG accessibility checks, dead code pruning, unused env var cleanup).
108
+ </details>
42
109
 
43
110
  ---
44
111
 
45
- ## šŸ› ļø Usage Examples
112
+ ## šŸ’” Core Capabilities (8 Component Suite)
46
113
 
47
- ### Dispatch a single task to Jules
114
+ ### šŸ› ļø The Basics
48
115
 
49
- ```bash
50
- node scripts/jules-dispatch.mjs "Refactor rate limiter" "Implement sliding window rate limiting using Redis. Must pass tests."
51
- ```
116
+ * **Auto-Configuration (`bin/init.js`)**: Instantly scaffolds your repo using `node:util.parseArgs` with an interactive TTY wizard (`-i`) or silent CI fallback.
117
+ * **Queue Runner (`scripts/jules-queue-runner.mjs`)**: Drop markdown task specifications into `.agent/jules-queue/` and let the runner process them sequentially.
118
+ * **Nightly Maintenance (`scripts/jules-nightly.mjs`)**: Schedules automated background audits (security leak scans, WCAG accessibility checks, dead code pruning).
52
119
 
53
- ### Dispatch an entire queue of markdown task specifications
120
+ ### šŸ”’ Security & Guardrails
54
121
 
55
- ```bash
56
- npm run jules:queue
57
- ```
122
+ * **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`).
123
+ * **Dynamic Guardrails (`.agent/rules/dynamic-guardrails.json`)**: RegEx-based rule matching that injects targeted stack guardrails into prompts on-the-fly.
58
124
 
59
- ```bash
60
- JULES_SWARM_CONCURRENCY=5 node scripts/jules-swarm.mjs tasks.json
61
- ```
125
+ ### šŸ Advanced Orchestration
62
126
 
63
- Where `tasks.json` is formatted as:
64
- ```json
65
- [
66
- { "id": "t1", "title": "Refactor Auth", "prompt": "Refactor auth middleware to ESM" },
67
- { "id": "t2", "title": "Fix Memory Leak", "prompt": "Fix listener memory leak in websocket event loop" }
68
- ]
69
- ```
127
+ * **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.
128
+ * **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`.
129
+ * **Git Worktree Swarms (`scripts/jules-swarm.mjs`)**: Manages multi-task batches in isolated Git worktrees (`JULES_USE_WORKTREES=true`) with scope boundary isolation.
70
130
 
71
- ### Run Nightly Maintenance Suite
131
+ ---
72
132
 
73
- ```bash
74
- node scripts/jules-nightly.mjs --dry-run
75
- ```
133
+ ## āš™ļø Configuration & Zero-Trust Security
76
134
 
77
- ### Audit Jules PRs before merging
135
+ The orchestrator creates an `.agent/jules.yml` file to manage repo-level verification and security:
78
136
 
79
- ```bash
80
- node scripts/jules-self-audit.mjs
137
+ ```yaml
138
+ # Google Jules Repository Configuration (Version 2)
139
+ version: 2
140
+ test_cmd: "npm test"
141
+ build_cmd: "npm run build"
142
+ forbidden_paths:
143
+ - ".github/**"
144
+ - "**/secrets/**"
145
+ - "**/*.pem"
146
+ - "**/lock-manager/**"
147
+ - "scripts/jules-*"
148
+ - ".agent/jules.yml"
149
+ allow_paths: []
81
150
  ```
82
151
 
83
- ---
152
+ > šŸ›”ļø **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`.
153
+ > ā„¹ļø 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.
84
154
 
85
- ## šŸ› ļø Supported Language Manifests & Workspace Graphs
155
+ ---
86
156
 
87
- The command resolver automatically sniffs your codebase and invokes the right verification chain:
157
+ <details>
158
+ <summary><b>šŸ› ļø Supported Language Manifests & Workspace Graphs (15+ Tech Stacks)</b></summary>
88
159
 
89
160
  | Stack / Ecosystem | Manifest / Workspace File | Default Verification Command |
90
161
  |---|---|---|
@@ -93,40 +164,98 @@ The command resolver automatically sniffs your codebase and invokes the right ve
93
164
  | **Nx Workspace** | `nx.json` | `npx nx run-many -t test -p <pkg> --with-deps` |
94
165
  | **Bun** | `bunfig.toml` / `bun.lockb` | `bun test && bun run build` |
95
166
  | **Deno** | `deno.json` / `deno.jsonc` | `deno test && deno task build` |
96
- | **JavaScript / TypeScript** | `package.json` | `npm run check:all` or `npm test` |
167
+ | **JavaScript / TypeScript** | `package.json` | `npm run lint && npm test` (or `npm run check:all`) |
97
168
  | **Rust** | `Cargo.toml` | `cargo test -p <pkg>` / `cargo test --workspace` |
98
169
  | **Go** | `go.mod` | `go test ./... && go build ./...` |
99
170
  | **Python** | `pyproject.toml` / `requirements.txt` | `pytest` |
100
171
  | **Elixir** | `mix.exs` | `mix test && mix compile` |
101
172
  | **Ruby** | `Gemfile` | `bundle exec rake test` |
102
173
  | **Swift** | `Package.swift` | `swift test && swift build` |
103
- | **Java (Maven)** | `pom.xml` | `mvn test && mvn compile` |
104
- | **Java (Gradle)** | `build.gradle` | `./gradlew test && ./gradlew assemble` |
174
+ | **Java (Maven/Gradle)** | `pom.xml` / `build.gradle` | `mvn test` / `./gradlew test` |
105
175
  | **C / C++** | `Makefile` | `make test && make build` |
106
- | **Custom Config (v2)** | `.agent/jules.yml` | Configurable `test_cmd`, `build_cmd`, `forbidden_paths` & `allow_paths` |
176
+
177
+ </details>
107
178
 
108
179
  ---
109
180
 
110
- ## āš™ļø Configuration (`.agent/jules.yml`)
181
+ <details>
182
+ <summary><b>šŸ“– Advanced Workflows (Queues, Swarms, Nightly Maintenance)</b></summary>
111
183
 
112
- ```yaml
113
- # Google Jules Repository Configuration (Version 2)
114
- version: 2
115
- test_cmd: "npm test"
116
- build_cmd: "npm run build"
117
- forbidden_paths:
118
- - ".github/**"
119
- - "**/secrets/**"
120
- - "**/*.pem"
121
- - "**/lock-manager/**"
122
- - "scripts/jules-*"
123
- - ".agent/jules.yml"
124
- allow_paths: []
184
+ ### 1. Process an entire queue of background tasks
185
+
186
+ ```bash
187
+ npm run jules:queue
125
188
  ```
126
189
 
127
- > šŸ›”ļø **Security Trust Model**: `allow_paths` is read **strictly from the target base branch** (`origin/main`), never from untrusted PR branches. Any path specified in `allow_paths` on `main` overrides the immutable default forbidden paths for automated background workers.
190
+ ### 2. Run Rate-Limited Swarms with Scope Isolation
128
191
 
192
+ Run massive parallel refactors safely. The orchestrator uses `tasks.json` file boundary `scope` segregation to prevent parallel task collisions:
129
193
 
194
+ ```bash
195
+ JULES_SWARM_CONCURRENCY=5 JULES_USE_WORKTREES=true node scripts/jules-swarm.mjs tasks.json
196
+ ```
197
+
198
+ *(Example `tasks.json` constraint: `[ { "id": "t1", "prompt": "Refactor auth", "scope": ["src/auth/**"] } ]`)*
199
+
200
+ ### 3. Run Nightly Maintenance Suite
201
+
202
+ ```bash
203
+ node scripts/jules-nightly.mjs --dry-run
204
+ ```
205
+
206
+ ### 4. Audit Jules PRs before merging in CI
207
+
208
+ ```bash
209
+ node scripts/jules-self-audit.mjs
210
+ ```
211
+
212
+ </details>
213
+
214
+ ---
215
+
216
+ <details>
217
+ <summary><b>🌐 Integration Interfaces: CLI, REST API & MCP Directives</b></summary>
218
+
219
+ `jules-orchestrator-kit` supports three primary integration channels:
220
+
221
+ ### 1. Direct REST API Mode (`jules.googleapis.com`)
222
+ 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.
223
+ - Handles HTTP 429 rate limits gracefully.
224
+ - Automatically maps `startingBranch` and `sourceContext`.
225
+
226
+ ### 2. Native Jules CLI Fallback (`jules new`)
227
+ 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.
228
+
229
+ ### 3. MCP (Model Context Protocol) Directives
230
+ All task dispatches dynamically inject `<MCP_DIRECTIVE>` envelopes into task prompts:
231
+ ```xml
232
+ <MCP_DIRECTIVE>
233
+ <system_state>HEADLESS_CI_MODE</system_state>
234
+ <strict_invariants>
235
+ <rule>1. READ-BEFORE-WRITE: Inspect symbol definitions before editing.</rule>
236
+ <rule>2. VERIFICATION LOOP: Execute test_cmd and pass with 0 errors.</rule>
237
+ <rule>3. ABORT CONDITION: Terminate on 4+ repeated test failures.</rule>
238
+ <rule>4. ASSERTION QUALITY: Unit tests created or modified MUST contain explicit assertions.</rule>
239
+ </strict_invariants>
240
+ </MCP_DIRECTIVE>
241
+ ```
242
+ This forces Jules to adhere to strict read-before-write invariants and deterministic execution when operating alongside MCP server tools.
243
+
244
+ </details>
245
+
246
+ ---
247
+
248
+ <details>
249
+ <summary><b>šŸ¤ Contributing & Code Guidelines</b></summary>
250
+
251
+ We welcome contributions! Please follow these core principles when submitting Pull Requests:
252
+
253
+ 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`).
254
+ 2. **Verification Suite**: Ensure 100% of unit tests pass cleanly (`npm test`).
255
+ 3. **Conventional Commits**: Use standardized commit message prefixes (`feat:`, `fix:`, `docs:`, `test:`, `chore:`).
256
+ 4. **Cross-Platform Compatibility**: Always normalize Windows backslashes (`\`) to POSIX slashes (`/`) for glob patterns and paths.
257
+
258
+ </details>
130
259
 
131
260
  ---
132
261
 
@@ -135,5 +264,3 @@ allow_paths: []
135
264
  MIT License - feel free to use, modify, and share!
136
265
 
137
266
  *Disclaimer: This is an independent open-source orchestration tool and is not officially affiliated with or endorsed by Google.*
138
-
139
-
package/bin/init.js CHANGED
@@ -3,6 +3,8 @@
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { parseArgs } from "node:util";
7
+ import readline from "node:readline/promises";
6
8
  import { resolveProjectCommands } from "../scripts/command-resolver.mjs";
7
9
 
8
10
  const __filename = fileURLToPath(import.meta.url);
@@ -10,8 +12,27 @@ const __dirname = path.dirname(__filename);
10
12
  const kitRoot = path.resolve(__dirname, "..");
11
13
  const targetDir = process.cwd();
12
14
 
13
- const isHelp = process.argv.includes("--help") || process.argv.includes("-h");
14
- const isForce = process.argv.includes("--force") || process.argv.includes("-f");
15
+ let isHelp = false;
16
+ let isForce = false;
17
+ let isInteractive = false;
18
+
19
+ try {
20
+ const { values } = parseArgs({
21
+ options: {
22
+ help: { type: "boolean", short: "h", default: false },
23
+ force: { type: "boolean", short: "f", default: false },
24
+ interactive: { type: "boolean", short: "i", default: false },
25
+ },
26
+ allowPositionals: true,
27
+ });
28
+ isHelp = values.help;
29
+ isForce = values.force;
30
+ isInteractive = values.interactive;
31
+ } catch (err) {
32
+ isHelp = process.argv.includes("--help") || process.argv.includes("-h");
33
+ isForce = process.argv.includes("--force") || process.argv.includes("-f");
34
+ isInteractive = process.argv.includes("--interactive") || process.argv.includes("-i");
35
+ }
15
36
 
16
37
  if (isHelp) {
17
38
  console.log(`
@@ -22,8 +43,9 @@ Usage:
22
43
  npx jules-init [options]
23
44
 
24
45
  Options:
25
- -f, --force Overwrite existing AGENTS.md, .agent/jules.yml, and orchestration scripts.
26
- -h, --help Show this help message.
46
+ -f, --force Overwrite existing AGENTS.md, .agent/jules.yml, and orchestration scripts.
47
+ -i, --interactive Launch interactive wizard to prompt for repository and branch configuration.
48
+ -h, --help Show this help message.
27
49
  `);
28
50
  process.exit(0);
29
51
  }
@@ -32,6 +54,52 @@ console.log("\nšŸš€ Initializing Google Jules Orchestration Kit...\n");
32
54
  console.log(`šŸ“ Target Directory: ${targetDir}`);
33
55
  if (isForce) console.log("āš ļø Force mode enabled (existing files will be overwritten).");
34
56
 
57
+ let answerRepoVal = "";
58
+ let answerBranchVal = "";
59
+
60
+ // Dual TTY Interactive Wizard
61
+ if (process.stdin.isTTY && (isInteractive || (!fs.existsSync(path.join(targetDir, ".agent/jules.yml")) && !process.env.CI))) {
62
+ try {
63
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
64
+ const answerRepo = await rl.question("šŸ“¦ Enter target GitHub repository (e.g. owner/repo) [optional]: ");
65
+ if (answerRepo.trim()) {
66
+ answerRepoVal = answerRepo.trim();
67
+ process.env.JULES_REPO = answerRepoVal;
68
+ }
69
+ const answerBranch = await rl.question("🌿 Enter base branch [default: main]: ");
70
+ if (answerBranch.trim()) {
71
+ answerBranchVal = answerBranch.trim();
72
+ process.env.BASE_BRANCH = answerBranchVal;
73
+ }
74
+ rl.close();
75
+ } catch (err) {
76
+ console.warn("āš ļø Interactive setup prompt failed:", err.message);
77
+ }
78
+ }
79
+
80
+ // 0. Persist wizard values to .env if provided
81
+ const envPath = path.join(targetDir, ".env");
82
+ let envAdditions = [];
83
+ if (answerRepoVal) envAdditions.push(`JULES_REPO="${answerRepoVal}"`);
84
+ if (answerBranchVal) envAdditions.push(`BASE_BRANCH="${answerBranchVal}"`);
85
+
86
+ if (envAdditions.length > 0) {
87
+ if (fs.existsSync(envPath)) {
88
+ const existingEnv = fs.readFileSync(envPath, "utf-8");
89
+ const toAppend = envAdditions.filter((line) => {
90
+ const key = line.split("=")[0];
91
+ return !existingEnv.includes(`${key}=`);
92
+ });
93
+ if (toAppend.length > 0) {
94
+ fs.appendFileSync(envPath, `\n${toAppend.join("\n")}\n`, "utf-8");
95
+ console.log("āœ… Appended interactive configuration to .env");
96
+ }
97
+ } else {
98
+ fs.writeFileSync(envPath, `${envAdditions.join("\n")}\n`, "utf-8");
99
+ console.log("āœ… Created: .env with repository configuration");
100
+ }
101
+ }
102
+
35
103
  // 1. Detect Stack & Manifests
36
104
  const detected = resolveProjectCommands(targetDir);
37
105
  console.log(`šŸ” Detected Project Type: ${detected.source}`);
@@ -102,6 +170,21 @@ if ((!fs.existsSync(reviewTarget) || isForce) && fs.existsSync(reviewSource)) {
102
170
  console.log("āœ… Created: .agent/workflows/jules-review.md");
103
171
  }
104
172
 
173
+ // Scaffold .github/workflows/jules-audit.yml
174
+ const githubWorkflowsDir = path.join(targetDir, ".github/workflows");
175
+ const auditWfSource = path.join(kitRoot, ".github/workflows/jules-audit.yml");
176
+ const auditWfTarget = path.join(githubWorkflowsDir, "jules-audit.yml");
177
+
178
+ if (fs.existsSync(auditWfSource)) {
179
+ if (!fs.existsSync(githubWorkflowsDir)) {
180
+ fs.mkdirSync(githubWorkflowsDir, { recursive: true });
181
+ }
182
+ if (!fs.existsSync(auditWfTarget) || isForce) {
183
+ fs.copyFileSync(auditWfSource, auditWfTarget);
184
+ console.log("āœ… Scaffolded CI Audit Workflow: .github/workflows/jules-audit.yml");
185
+ }
186
+ }
187
+
105
188
  // 4. Copy scripts/ directory with PER-FILE existence guard
106
189
  const targetScriptsDir = path.join(targetDir, "scripts");
107
190
  if (!fs.existsSync(targetScriptsDir)) {
@@ -121,7 +204,9 @@ if (fs.existsSync(sourceScriptsDir)) {
121
204
  fs.copyFileSync(srcFile, destFile);
122
205
  try {
123
206
  fs.chmodSync(destFile, 0o755);
124
- } catch (_) {}
207
+ } catch (err) {
208
+ console.warn(`āš ļø Could not set executable permissions on ${file}:`, err.message);
209
+ }
125
210
  copiedCount++;
126
211
  } else {
127
212
  skippedCount++;
@@ -156,7 +241,9 @@ if (fs.existsSync(targetPkgPath) && targetDir !== kitRoot) {
156
241
  fs.writeFileSync(targetPkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
157
242
  console.log("āœ… Injected jules:* helper scripts into package.json");
158
243
  }
159
- } catch (_) {}
244
+ } catch (err) {
245
+ console.warn("āš ļø Failed to inject helper scripts into target package.json:", err.message);
246
+ }
160
247
  }
161
248
 
162
249
  console.log("\nšŸŽ‰ Google Jules Orchestration Kit successfully initialized!");
@@ -164,4 +251,3 @@ console.log("\nNext Steps:");
164
251
  console.log(" 1. Set environment variables: JULES_REPO=\"owner/repo\"");
165
252
  console.log(" 2. Dispatch your first task: node scripts/jules-dispatch.mjs \"Task Title\" \"Task prompt\"");
166
253
  console.log(" 3. Run pre-merge PR audit: node scripts/jules-self-audit.mjs\n");
167
-