Skip to content

feat(cli): export — patch a local agent back to its source-of-truth repo - #180

Open
matheusmlopess wants to merge 3 commits into
mainfrom
feature/cli-export-git
Open

feat(cli): export — patch a local agent back to its source-of-truth repo#180
matheusmlopess wants to merge 3 commits into
mainfrom
feature/cli-export-git

Conversation

@matheusmlopess

Copy link
Copy Markdown
Owner

agentfactory-gen export — patch a local agent back to its source repo

The inverse of import. When you've edited an imported agent in
.ai/agents/<name>/, export flows those changes back upstream to the
agent's source-of-truth repo as a reviewable PR.

flowchart LR
    A[".ai/agents/&lt;name&gt;/<br/>(local edits)"] --> E([agentfactory-gen export])
    E --> C[clone source repo]
    C --> P["apply over agent/ subpath<br/>(auto-detected)"]
    P --> B["branch agentfactory/export-&lt;name&gt;<br/>commit + push"]
    B --> R([gh pr create])
Loading

What it does

  1. Resolves the source repo: --git URL, else the source recorded at import.
  2. Clones it; detects where the agent lives (agent/ subpath or repo root).
  3. Copies the local agent-manifest.json + tracked dirs (skills/ commands/ docs/ scripts/ orchestration/) over it.
  4. Commits on agentfactory/export-<name>, pushes, opens a PR.

Options

--git URL · --subpath · --branch · -m/--message · --project-root ·
--push/--no-push (writes a .patch) · --pr/--no-pr.

Also in this PR

  • import records the source ({"git": url} / {"registry": slug}) in the agent
    manifest, so export defaults to it (no need to retype the URL).
  • --git accepts local paths / file:// — offline use + makes the feature testable
    against a bare repo. (Also a step toward AgentFactory#179 gap 2.)

Tests

src/tests/test_export.py — 5 tests (push-to-recorded-source, explicit --git,
no-source error, --no-push patch, missing-agent error). All pass.

Full suite: 300 passed, 2 failed — the 2 are pre-existing live external-CLI tests
(test_live_agent_acknowledges_harness[gemini/codex]) failing on Gemini/Codex auth,
confirmed failing on clean main. Unrelated to this change.

🤖 Generated with Claude Code

matheusmlopess and others added 3 commits June 22, 2026 15:32
`agentfactory-gen export <name>` clones the agent's source repo, applies this
project's .ai/agents/<name>/ over the agent's location (auto-detected agent/
subpath or repo root), commits on a branch (agentfactory/export-<name>),
pushes, and opens a PR — the inverse of `import`.

- import now records the source ({"git": url} / {"registry": slug}) in the
  agent manifest so export defaults to it; override with --git URL.
- --git also accepts local paths / file:// (offline + testable); --no-push
  emits a .patch; --no-pr stops after pushing the branch.
- tests: push-to-recorded-source, explicit --git, no-source error,
  --no-push patch, missing-agent error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- docs/FEATURE-EXPORT-CLI.md — feature + operational doc: round-trip diagram,
  execution flow, all scenarios (happy/edge/failure), validation/error/recovery,
  before/after tree + behaviour comparison. Box-drawing, terminal-safe.
- docs/TESTING-EXPORT-CLI-E2E.md — E2E guide using a local bare repo:
  preconditions, steps, expected results, validation checks, failure indicators.
- docs/reviews/REVIEW-EXPORT-CLI.md — consolidated analysis: design/trade-offs,
  assumptions, gaps/risks, missing scenarios, enhancements, safeguards; doc-
  tracking verification; honest infra-alignment audit (CLI-only → no compose/
  ansible drift; operator-console/routes N/A with reasoning) + PR checklist.
- README: export added to the command list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant