Skip to content

feat(cli): Preserve original GitHub URLs in agents.toml#29

Open
gricha wants to merge 4 commits intomainfrom
feat/preserve-github-urls
Open

feat(cli): Preserve original GitHub URLs in agents.toml#29
gricha wants to merge 4 commits intomainfrom
feat/preserve-github-urls

Conversation

@gricha
Copy link
Member

@gricha gricha commented Feb 19, 2026

Preserve the user's original GitHub URL form (SSH, HTTPS, or owner/repo shorthand) in agents.toml instead of normalizing everything to owner/repo. This fixes SSH users who need git@ URLs for private repo auth — previously they got silently switched to HTTPS cloning, which fails without credential helpers.

Internal source comparisons now go through normalizeSource() / sourcesMatch() helpers that canonicalize to owner/repo for dedup and matching, while the stored and cloned URL stays in the user's original form.

Also adds a helpful error when HTTPS cloning fails due to auth, suggesting the SSH URL:

Failed to clone https://github.com/org/repo: authentication required.
Hint: for private repos, use the SSH URL instead:
  dotagents add git@github.com:org/repo.git

Changes:

  • src/skills/resolver.tsparseSource() returns cloneUrl preserving protocol; new normalizeSource() and sourcesMatch() exports
  • src/cli/commands/add.ts — stores original URL form, uses sourcesMatch() for dedup
  • src/cli/commands/{install,update,remove,list,sync}.ts — normalized comparisons
  • src/config/writer.ts — normalized comparison in addExcludeToWildcard
  • src/sources/git.ts — HTTPS auth failure detection with SSH hint
  • src/skills/resolver.test.ts — 14 new tests for cloneUrl, normalizeSource, sourcesMatch

Agent transcript: https://claudescope.sentry.dev/share/vm6xSO2oDRmrLw_n9mZVXhi-RuAcYMHxA19lsfjIOYs

Previously, `dotagents add` normalized all GitHub source forms
(SSH, HTTPS, shorthand) to `owner/repo` before storing in agents.toml.
This lost the user's protocol intent — SSH users who need `git@` for
private repo auth got silently switched to HTTPS cloning.

Now the user's original URL is preserved in agents.toml and used for
cloning. Source comparisons throughout the codebase use a new
`sourcesMatch()` helper that normalizes to `owner/repo` internally.

Also adds a helpful error message when HTTPS cloning fails due to
authentication, suggesting the SSH URL form.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/HvJlB3fZbyVt7PcG3LydRzvn89uTZD1uYcvyxXrXhfg
@vercel
Copy link

vercel bot commented Feb 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dotagents Ready Ready Preview, Comment Feb 20, 2026 0:21am

Request Review

@gricha gricha marked this pull request as ready for review February 19, 2026 23:52
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Replace `/(?:\.git)?\/*$/` with a non-backtracking alternative to
fix CodeQL high-severity ReDoS alert. The regex could backtrack on
strings with many '/' characters.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/4KUqW_ZW1-8zKBCW6XUHKriRopxbS0b4adPpUxhK7c4
Use `source.slice(0, -(ref.length + 1))` instead of regex
`/@[^@]+$/` to strip the inline @ref from URLs. The regex only
removes characters after the last @, so it fails for monorepo-style
tags like `packages/foo@1.0.0`.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/OxcFX3PWWoQ_GZIhu0fbKJUQKzYnbDrDM6y9jQv1y-0
Replace regex-based slash stripping with a simple while loop to
avoid CodeQL polynomial regex false positive on /\/+$/.

Co-Authored-By: Claude <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

Comments