Metadata-Version: 2.4
Name: ultra-plan
Version: 0.5.0
Summary: Ultra planning: web-sourced skills/tools/permissions bundle for coding agents.
Author-email: Andrii Andriichuk <andrey000mar@gmail.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://github.com/avrilfanomar/ultra-planning
Project-URL: Source, https://github.com/avrilfanomar/ultra-planning
Project-URL: Issues, https://github.com/avrilfanomar/ultra-planning/issues
Keywords: claude,claude-code,agents,mcp,planning,bundles,opencode
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: jsonschema>=4.18
Requires-Dist: referencing>=0.30
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-cov>=4; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: build>=1; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"
Requires-Dist: tomli>=2; extra == "dev"
Requires-Dist: cyclonedx-bom>=4; extra == "dev"
Requires-Dist: pre-commit>=3; extra == "dev"
Provides-Extra: type
Requires-Dist: mypy>=1.10; extra == "type"
Requires-Dist: types-jsonschema; extra == "type"
Dynamic: license-file

# ultra-plan

[![CI](https://github.com/avrilfanomar/ultra-planning/actions/workflows/ci.yml/badge.svg)](https://github.com/avrilfanomar/ultra-planning/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/ultra-plan)](https://pypi.org/project/ultra-plan/)
[![Python versions](https://img.shields.io/pypi/pyversions/ultra-plan)](https://pypi.org/project/ultra-plan/)
[![License](https://img.shields.io/pypi/l/ultra-plan)](LICENSE)

ultra-plan is a CLI that produces a reviewable bundle of skills, tools, MCP
servers, and permission patches for a task by delegating discovery to
a headless agent (Claude Code by default; opencode also supported). The
bundle is written to disk; nothing is installed.

Planned work is tracked in [ROADMAP.md](ROADMAP.md).

## WHY ULTRA-PLAN

Many agent setups let the agent configure its own tools and permissions as it
goes, with no chance to review before anything runs. ultra-plan instead writes
a reviewable bundle to disk — skills, tools, MCP servers, and a permission
patch — and stops for a human review gate before any of it executes. Skills
fetched from GitHub are pinned to an immutable commit SHA and verified by
SHA-256, so what you reviewed is what actually runs (see *Skill pinning*
below). The permission patch and tool list are scoped to the task rather than
granted wholesale, and every item is editable or toggleable before you
confirm. ultra-plan only writes files; nothing is installed or executed until
you approve it.

![The ultra-plan review UI: six panels showing the expected outcome, prompt
recommendations, plan, skills, tools, and permission patch for a bundle, with a
Confirm button.](docs/media/review-ui.png)

*The review UI for the sample bundle — every skill, tool, and permission is
editable and toggleable before you confirm. See the [walkthrough](#walkthrough).*

![Review flow: toggle a skill, edit a permission, save draft, confirm](docs/media/review-flow.gif)

*Toggling a skill, editing a permission, saving a draft, and confirming — recorded against the sample bundle.*

## WHAT IS IN A BUNDLE

A bundle is a directory under `--out` (default `./ultra-plan/<slug>/`)
containing:

    bundle.json                 canonical, validated bundle
    preflight-settings.json     permissions used during planning (claude)
    preflight-config.json       permissions used during planning (opencode)

The review UI (`index.html`, `app.js`, `style.css`) is served locally from the
installed package; it is not copied into the bundle directory.

After you click Confirm in the review UI, the server also writes:

    expected-outcome.md         deliverables and success criteria
    skills.json                 enabled skills only
    tools.json                  enabled tools only
    plan.md                     implementation plan
    prompt-recommendations.md   instructions for the executing agent

When `execute` runs, the directory also gains the agent config materialized
from the bundle. For Claude that is `settings.json` (permissions) plus, when any
enabled MCP tool carries transport (`command`/`url`), `mcp-servers.json` (passed
to Claude via `--mcp-config`; Claude does not read MCP servers from
`settings.json`). For opencode it is `opencode.json` (permissions + MCP).
`execute` also downloads enabled skills' bodies into `skills/<name>/` so they
can be inlined into the prompt (`--no-fetch-skills` to skip; fetching is
restricted to GitHub and runs only after the review gate).

## INSTALLING

**Development install:**

    pip install -e .

**User install (via pipx):**

    pipx install ultra-plan

Requires Python 3.10+. The `claude` CLI (or `opencode`) must be on `$PATH`
for live runs.

## USING IT

    ultra-plan "<task>" [flags]
    ultra-plan run "<task>" [flags]
    ultra-plan review <dir>
    ultra-plan fetch-skills <dir>
    ultra-plan pin-skills <dir>
    ultra-plan execute <dir> [flags]

`run` plans a task: it invokes the agent headless, validates the resulting
bundle against JSON schemas, starts a local review server, and opens a
browser. On confirm the final bundle is persisted to `--out`. `--agent`
selects the planning CLI (`claude` or `opencode`), `--model` picks the model
it runs (e.g. `--model opus` for claude, `--model anthropic/claude-sonnet-5`
for opencode), and `--timeout` bounds the planning subprocess.

`review` re-opens the review UI for an existing bundle directory. Pass
`--agent claude` (or `--agent opencode`) to enable the review UI's **Request
changes** button, which re-plans the bundle from your feedback in place (see
*Review and re-plan* below); omit it to review without re-planning (no agent
needed on `$PATH`).

`fetch-skills` downloads enabled skills' bodies from their GitHub `source_url`
into `<dir>/skills/<name>/` so they can be inlined at execute time. `execute`
runs this automatically; the standalone command is for preparing a bundle ahead
of time (or with `--force` to re-fetch).

`pin-skills` repairs an unpinned bundle in place: it pins every enabled GitHub
skill in `<dir>/bundle.json` that isn't already pinned to an immutable commit
SHA + per-file SHA-256 (see *Skill pinning* below), so a subsequent `execute`
needs no `--allow-unpinned`. This is the recovery path when `run`'s pinning
step failed (offline, or rate limited without a `GITHUB_TOKEN`) or when a
bundle was hand-authored. Already-pinned skills are left untouched. Exits 0
when every enabled skill ends up pinned, 1 (naming the skills in a warning)
when any remain unpinned — useful for gating scripts.

`execute` reads `bundle.json`, materializes agent config into the bundle
directory, builds an execution prompt from the plan, prompt recommendations,
expected outcome, and original task, and launches the configured agent. By
default execute is interactive; `--headless` runs non-interactively with
JSON output, and `--model` selects the model the executing agent runs with.
`--dry-run` performs every step up to the launch — config
materialization, skill fetch, prompt assembly — writes the prompt to
`execution-prompt.md`, prints the exact agent argv and the files written, and
exits 0 without prompting for confirmation or starting the agent.

For the full flag list run `ultra-plan <command> --help`.

## WALKTHROUGH

End to end, from a task to a running agent. Live planning needs the `claude`
CLI (or `opencode`) on your `$PATH`; the review step below runs without either.

**1. Plan.** Describe the task; the headless agent discovers candidate skills,
tools, MCP servers, and a permission patch, and writes a validated bundle:

    ultra-plan "Create a simple Python CLI calculator" --out ./ultra-plan/calc

This produces `./ultra-plan/calc/bundle.json` (plus the `preflight-*.json`
permissions used during planning), then starts the review server and opens your
browser.

**2. Review.** You do not have to run `run` to see the UI — any existing bundle
directory can be re-opened. The screenshot above is exactly this command against
the checked-in sample bundle:

    ultra-plan review examples/sample-bundle
    [ultra-plan] review UI: http://127.0.0.1:7788/

Each panel is editable: rewrite the expected outcome, plan, prompt
recommendations, or permission patch in place, and toggle individual skills and
tools on or off. Nothing is written and nothing is installed until you click
**Confirm**.

**Re-plan (optional).** If the plan is wrong in ways that go beyond hand-edits,
expand **Request changes**, describe what to change, and submit. Your current
edits are saved first, then the original task, the current bundle, and your
feedback are handed to the same hardened planning agent (identical preflight to
`run` — scrubbed environment, denied tools, fresh temp working directory). The
revised bundle is validated, re-pinned, written to `bundle.json`, and rendered
in place without restarting the CLI; the agent runs for a few minutes, so the
button and inputs disable while it works. Re-planning is available when the UI
was started with an agent — always after `run`, or after `review <dir> --agent
<claude|opencode>`. Agent or validation failures surface in the status line.

**3. Confirm.** Confirming persists the reviewed decisions next to the bundle:
`expected-outcome.md`, `plan.md`, `prompt-recommendations.md`, and
`skills.json` / `tools.json` (enabled items only).

**4. Execute.** `execute` materializes the agent config from `bundle.json`,
fetches (and verifies — see *Skill pinning*) enabled skill bodies, builds the
execution prompt, and launches the agent with the tools and permissions you
approved:

    ultra-plan execute ./ultra-plan/calc

By default this is interactive; add `--headless` for a non-interactive run with
JSON output. Add `--dry-run` to see exactly what would run — materialized
config, assembled prompt, and agent argv — without launching anything:

    ultra-plan execute ./ultra-plan/calc --dry-run

## SECURITY

The planning agent runs against attacker-controlled web content (search
results, fetched pages, MCP registries), so the preflight run is hardened
against prompt injection:

  - The agent subprocess inherits only a small allowlist of environment
    variables; tokens, API keys, and `AWS_*`/`GITHUB_*` secrets are dropped.
  - The materialized `settings.json` denies `Read`, `Write`, `Edit`,
    `NotebookEdit`, and `Bash` regardless of any `--allowedTools` passed in.
  - `WebFetch` denies a broad set of local and cloud-metadata targets:
    `file://`; `localhost`; IPv4 loopback (`127.0.0.0/8`); IPv6 loopback
    (`::1`), link-local (`fe80::/10`), and unique-local (`fc00::/7`) ranges;
    the AWS metadata endpoint (`169.254.169.254`); and the GCP metadata
    endpoints (`metadata.google.internal`, `metadata.internal`).
  - Prompts are piped via stdin, so leading `-` cannot be parsed as a flag.
  - The agent runs in a fresh temp `cwd` containing only `settings.json`.
  - The preflight permissions are persisted to the bundle directory as
    `preflight-settings.json` (claude) or `preflight-config.json` (opencode)
    for transparency and audit purposes.

**opencode caveat:** opencode's config supports only coarse allow/deny/ask
permissions, so the URL-pattern `WebFetch` denylist above **cannot** be
expressed when planning with `--agent opencode`. Environment scrubbing, the
sandboxed temp `cwd`, and denial of file/edit/bash tools still apply, but SSRF
protection during planning is weaker than with claude. Prefer claude for the
planning (`run`) phase when fetching untrusted web content.

These protections apply to `run` only. `execute` runs with the tools and
permissions you confirmed in the review UI — review them before executing.

Skill bodies fetched for `execute` are pinned: `run` resolves each GitHub skill
to an immutable commit SHA and records a SHA-256 for every file, and `execute`
refuses to run a skill whose downloaded bytes don't match (or that was never
pinned, unless `--allow-unpinned` is passed). See *Skill pinning* below.

See `src/ultra_plan/agents/_env.py` for the environment allowlist.

## SKILL PINNING

Skills are fetched from GitHub, and a mutable ref like `tree/main` can change
between the moment you review a bundle and the moment you execute it. To close
that gap, ultra-plan pins skills to immutable content:

  - During `run` (after the bundle validates, before the review UI opens),
    each enabled GitHub skill's `source_url` ref is resolved to a 40-hex commit
    SHA via the GitHub API, and a SHA-256 is computed for every `*.md` file at
    that commit. Both are recorded in `bundle.json` (`commit_sha` and a `files`
    list). Pinning is best-effort — if it can't reach GitHub (offline, or rate
    limited without a `GITHUB_TOKEN`), the skill is left unpinned and a warning
    is logged; `run` still succeeds.
  - During `execute` / `fetch-skills`, a pinned skill is downloaded **by its
    commit SHA** (not the mutable ref) and every file's SHA-256 is verified.
    A mismatch aborts that skill's fetch. A skill that was never pinned is
    refused unless you pass `--allow-unpinned`, which restores the old
    fetch-the-current-ref behavior for hand-authored or pre-pinning bundles.

Because a `GITHUB_TOKEN`-less environment is rate limited, pinning may fail and
you may need `--allow-unpinned` more often — that's the safe default for an
integrity feature. Set `GITHUB_TOKEN`/`GH_TOKEN` to make pinning reliable.

If a bundle was written with unpinned skills — `run`'s pinning step failed, or
the bundle was hand-authored — `ultra-plan pin-skills <dir>` repairs it without
re-planning: it pins every enabled skill that isn't already pinned and rewrites
`bundle.json` in place, so `execute` no longer needs `--allow-unpinned` for
those skills. It's the same idempotent `pin_skills()` step `run` uses, exposed
as a standalone command.
