Skip to content

Add Tangled as git provider#261

Open
jphastings wants to merge 4 commits into
unjs:mainfrom
jphastings:add-tangled
Open

Add Tangled as git provider#261
jphastings wants to merge 4 commits into
unjs:mainfrom
jphastings:add-tangled

Conversation

@jphastings

@jphastings jphastings commented Apr 13, 2026

Copy link
Copy Markdown

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:abc123def456 or did:web:example.org, as well as tangled.org or byjp.me) as repo owners, as both are supported by Tangled.

I also added a stripPrefix option to TemplateInfo since Tangled archives don't have a top-level wrapper directory.

resolves #260

Summary by CodeRabbit

  • New Features

    • Tangled added as a built-in provider with DID-based owners and tangled: URL formats; optional custom Tangled API URL for self-hosting.
  • Documentation

    • README and provider docs updated with Tangled usage and CLI examples.
  • Bug Fixes

    • Archive extraction now respects the stripPrefix setting so top-level directory behavior is preserved when configured.

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.
@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds Tangled as a built-in template provider, extends types with tangled and stripPrefix, implements Tangled URI parsing/URL/header construction, and makes tar extraction respect stripPrefix: false. Documentation and README updated with usage and examples.

Changes

Cohort / File(s) Summary
Documentation
AGENTS.md, README.md
Add Tangled to supported providers, document tangled: URI formats (including DID owners), add CLI examples, mention GIGET_TANGLED_URL, and document stripPrefix: false behavior.
Types
src/types.ts
Add "tangled" to GitInfo.provider union and add optional stripPrefix?: boolean to TemplateInfo.
Provider Implementation
src/providers.ts
Add exported tangled: TemplateProvider that parses tangled: inputs (owner, repo, optional subdir, ref via # defaulting to main), validates owner (DID or domain), builds name/version/subdir, sets stripPrefix: false, constructs url/tar using GIGET_TANGLED_URL, and attaches Authorization header when auth provided.
Archive Extraction Logic
src/giget.ts
During tar extraction, only strip the first path segment when template.stripPrefix !== false (preserve top-level directories when stripPrefix is explicitly false).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • pi0

Poem

🐰 I hopped through docs and code with glee,
Tangled branches now join the tree.
DIDs and domains come hop-hop along,
No extra folder — the paths stay strong.
🥕 A tiny rabbit sings, “Good job!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding Tangled as a supported git provider.
Linked Issues check ✅ Passed The PR implements all coding requirements from #260: Tangled provider support with DID and username parsing, custom handling with no parseGitURI, stripPrefix:false for unwrapped archives, and environment variable configuration.
Out of Scope Changes check ✅ Passed All changes are within scope: documentation updates (AGENTS.md, README.md), new tangled provider implementation, type definitions extended for tangled and stripPrefix, and conditional tar extraction logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 94e8233 and 6c4cdfa.

📒 Files selected for processing (5)
  • AGENTS.md
  • README.md
  • src/giget.ts
  • src/providers.ts
  • src/types.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b6cdfc and be6eed0.

📒 Files selected for processing (2)
  • src/providers.ts
  • src/types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/types.ts

Comment thread src/providers.ts
@jphastings

Copy link
Copy Markdown
Author

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!)

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.

Feature Request: Support for Tangled git repos

1 participant