Add Tangled as git provider#261
Conversation
Add support for Tangled (tangled.org), an AT Protocol-based git forge. Uses custom URI parsing to support both usernames and DIDs (e.g. did:plc:abc123) as repository owners. Adds `stripPrefix` option to TemplateInfo since Tangled archives lack a top-level wrapper directory.
📝 WalkthroughWalkthroughAdds Tangled as a built-in template provider, extends types with Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as CLI/Client
participant Provider as providers.ts (tangled)
participant Server as Tangled Registry
participant Extractor as downloadTemplate (giget.ts)
User->>CLI: run clone/init with `tangled:owner/repo[`#ref`][/subdir]`
CLI->>Provider: parse URI -> owner, repo, subdir, ref
Provider->>Server: request tar URL (use GIGET_TANGLED_URL) with Authorization header if provided
CLI->>Extractor: downloadTemplate(templateInfo with stripPrefix:false)
Extractor->>Server: fetch tar stream
Server->>Extractor: respond with tar
Extractor->>Extractor: extract entries (do NOT strip top-level when stripPrefix:false)
Extractor->>CLI: return extracted files
CLI->>User: notify completion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/providers.ts (1)
142-145: Reject empty Tangled repo names during parse.Inputs like
tangled:did:plc:abc123/currently pass parsing and generate invalid archive URLs instead of failing early. Add a repo presence check right after parsing.Proposed patch
const rest = pathPart.slice(slashIndex + 1); const restParts = rest.split("/"); const repo = restParts[0]!; + if (!owner || !repo) { + throw new Error(`Invalid Tangled URI: ${input}`); + } const subdir = restParts.length > 1 ? "/" + restParts.slice(1).join("/") : "/";As per coding guidelines,
src/providers.ts: Tangled provider URI handling is expected to support owner/repo parsing (including DIDs) with custom parsing logic.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/providers.ts` around lines 142 - 145, After splitting the Tangled rest segment into restParts and assigning repo and subdir, add a presence check that rejects empty repo names: verify repo is a non-empty string (e.g., if (!repo || repo.trim() === "") ) and throw or return a clear parse error (e.g., "Invalid Tangled URI: missing repo name") so URIs like "tangled:.../ " fail early; update the parsing logic immediately after the const restParts/const repo/const subdir assignments to enforce this validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/providers.ts`:
- Around line 142-145: After splitting the Tangled rest segment into restParts
and assigning repo and subdir, add a presence check that rejects empty repo
names: verify repo is a non-empty string (e.g., if (!repo || repo.trim() === "")
) and throw or return a clear parse error (e.g., "Invalid Tangled URI: missing
repo name") so URIs like "tangled:.../ " fail early; update the parsing logic
immediately after the const restParts/const repo/const subdir assignments to
enforce this validation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5094fec2-2af2-4c93-ad37-94227da500d4
📒 Files selected for processing (5)
AGENTS.mdREADME.mdsrc/giget.tssrc/providers.tssrc/types.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/providers.ts`:
- Around line 149-152: The validation currently throws for owners that don't
start with "did:" and don't include a dot, which rejects plain usernames; update
the check around the owner variable so it allows three cases: DID
(owner.startsWith("did:")), domain (owner.includes(".")), or a valid plain
username (e.g. match a username regex like /^[a-zA-Z0-9_-]+$/). Replace the
existing conditional that throws with one that only throws when owner matches
none of those three cases and keep the error message clear about allowed formats
(DID, domain, or username).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c1eba8dc-d903-47e6-9fc8-f0a210ec57b9
📒 Files selected for processing (2)
src/providers.tssrc/types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/types.ts
|
I'm struggling to please the reviewbot; I'd appreciate a look from someone more familiar with the codebase than me, so I can be sure I'm not breaking an assumption with Tangled's usernames that are domain names or DIDs. (I've also added Docstrings to meet the requirement above, but it appears to be incorrectly configured, as I think the 0% is measuring JSDoc strings, which this repo doesn't use at all — advice on how to proceed would be appreciated!) |
Adds support for Tangled as a provider.
I've had to use customised URI parsing to support both usernames and DIDs (e.g.
did:plc:abc123def456ordid:web:example.org, as well astangled.orgorbyjp.me) as repo owners, as both are supported by Tangled.I also added a
stripPrefixoption toTemplateInfosince Tangled archives don't have a top-level wrapper directory.resolves #260
Summary by CodeRabbit
New Features
Documentation
Bug Fixes