Skip to content

add --from-live flag to aisw add#7

Merged
burakdede merged 6 commits intoburakdede:mainfrom
JulioJair:add-from-live
Apr 19, 2026
Merged

add --from-live flag to aisw add#7
burakdede merged 6 commits intoburakdede:mainfrom
JulioJair:add-from-live

Conversation

@JulioJair
Copy link
Copy Markdown
Contributor

@JulioJair JulioJair commented Apr 16, 2026

Problem

aisw add runs a full interactive login flow. When it fails or is interrupted, the native claude login / codex login / gemini login is always available as a fallback — but there was no way to hand those credentials over to aisw afterward.

Solution

aisw add <tool> <profile_name> --from-live captures whatever credentials the tool currently has in its live config and stores them as a new aisw-managed profile — no login flow launched. The profile is always activated immediately, since those credentials are already live by definition.

aisw add claude work --from-live
aisw add codex personal --from-live --label "Personal OpenAI account"
aisw add gemini work --from-live

This is the recovery/adoption path for cases where a native tool login already succeeded but aisw was not used. --from-live fits within the existing add model alongside --api-key, --from-env, and interactive OAuth.

Scope

Supports all three tools, reading from each tool's live config location:

Tool Source
claude ~/.claude/.credentials.json or system keyring (macOS)
codex ~/.codex/auth.json
gemini ~/.gemini/.env (API key) or OAuth files in ~/.gemini/

--yes skips the overwrite prompt when a same-name profile already exists. Deduplication identity checks match existing add behavior.

Changes

  • src/cli.rs--from-live and --yes added to AddArgs
  • src/commands/add.rs--from-live branch + per-tool capture functions + 12 new tests
  • completions/ — bash, zsh, fish updated for new flags
  • docs/commands.md--from-live documented under aisw add

All 369 existing tests pass. New tests cover profile creation, auto-activation, overwrite with --yes, and the no-credentials error path for all three tools.

Closes #6

@JulioJair JulioJair mentioned this pull request Apr 16, 2026
Comment thread src/commands/add.rs Outdated
Comment thread docs/commands.md Outdated
@burakdede
Copy link
Copy Markdown
Owner

Thanks @JulioJair, overall PR looks solid with baseline tests for --from-live

But for this new functionality, I’d still call test coverage partial considering my goal is to reliably support 3 coding agents.

  • No explicit --from-live tests for Codex API-key live shape (auth.json with token) vs OAuth branch.
  • No explicit --from-live tests for Gemini .env API-key path (current tests cover Gemini OAuth files).
  • No tests for --yes semantics beyond Claude (Codex/Gemini overwrite behavior is untested).
  • No tests for duplicate-identity/duplicate-secret handling in the new --from-live paths.

Aside from PR comments, adding those would get this to mergeable state.

@burakdede burakdede added the enhancement New feature or request label Apr 17, 2026
@JulioJair
Copy link
Copy Markdown
Contributor Author

Added 7 tests covering the gaps you noted: Codex API-key live shape ({"token":"..."} in auth.json), Codex --yes overwrite, Codex duplicate API-key rejection, Gemini .env API-key path, Gemini --yes overwrite, Gemini duplicate API-key rejection, and the mtime heuristic (both credential types present, each direction). All 376 tests pass.

@burakdede
Copy link
Copy Markdown
Owner

@JulioJair can you rebase with main and run the pipeline again? If tests pass, this PR is good to go.

JulioJair and others added 6 commits April 18, 2026 17:56
Captures whatever credentials the tool currently has in its live config
and stores them as a new aisw-managed profile without launching any login
flow. This is the recovery path when a native tool login (claude login,
codex login, gemini login) already succeeded but aisw add was not used.

Supported for all three tools, reading from each tool's live credential
location:
- Claude: ~/.claude/.credentials.json or system keyring (macOS)
- Codex:  ~/.codex/auth.json
- Gemini: ~/.gemini/.env (API key) or OAuth files in ~/.gemini/

Deduplication and overwrite-confirmation logic match the existing add
command. Activation follows --set-active semantics (opt-in, same as all
other add paths). --yes skips the overwrite prompt.

Adds --from-live and --yes to completions (bash, zsh, fish) and docs.
New tests cover profile creation, stored-not-active default, overwrite
with --yes, and the no-credentials error path for all three tools.
Credentials captured with --from-live are already the live credentials,
so the profile is activated unconditionally rather than requiring
--set-active. --set-active is a no-op for --from-live and ignored.
@burakdede burakdede merged commit b4905f5 into burakdede:main Apr 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants