Add upstream PR contribution system

Implements a complete workflow for non-technical users to contribute to open source projects:

**New Features:**
- ContributeButton component shows "Propose Changes" when project has upstream remote
- ContributeWizard guides users through 5-step contribution process
- PRStatusBadge shows existing PR status for current branch
- Automatic forking when user lacks push permissions
- OAuth and PAT authentication for GitHub, GitLab, Gitea/Codeberg
- Pre-submission validation (type check + build)
- Automatic remote configuration (upstream/origin)
- PR creation and updates via Git host APIs

**Git Host Abstraction:**
- GitHostProvider interface for platform-agnostic operations
- GitHubProvider with GitHub REST API v3
- GitLabProvider with GitLab REST API v4  
- GiteaProvider for Gitea/Forgejo/Codeberg instances
- Auto-detection of Git host from repository URL

**Components:**
- components/contribute/ContributeButton.tsx - Entry point button
- components/contribute/ContributeWizard.tsx - Multi-step wizard UI
- components/contribute/AuthStep.tsx - Authentication flow
- components/contribute/DiffView.tsx - Changed files review
- components/contribute/PRStatusBadge.tsx - PR status display

**Hooks:**
- hooks/useContribute.ts - Main contribution workflow orchestration

**Context Updates:**
- Extended GitSettings to include hostTokens for API authentication
- Updated GitHubOAuth to save tokens in both formats

**Integration:**
- Added to ProjectView header (mobile and desktop)
- Integrated with existing Git workflow
- Works with existing OAuth callback system

**Documentation:**
- CONTRIBUTING_GUIDE.md with user guide and developer docs

The system handles the entire fork → branch → commit → push → PR flow transparently, making open source contribution accessible to users without Git knowledge.
This commit is contained in:
shakespeare.diy committed 2025-10-14 21:29:15 -05:00
1 parent 4226159f5d
commit add685257b
18 files changed
+2670 -5

No files matched your search

+15 -1
View File
@@ -31,8 +31,16 @@ const gitCredentialSchema = z.object({
password: z.string(),
});
const gitHostTokenSchema = z.object({
token: z.string(),
username: z.string().optional(),
scopes: z.array(z.string()).optional(),
createdAt: z.number().optional(),
});
const gitSettingsSchema = z.object({
credentials: z.record(z.string(), gitCredentialSchema),
hostTokens: z.record(z.string(), gitHostTokenSchema).optional(),
name: z.string().optional(),
email: z.string().optional(),
coAuthorEnabled: z.boolean().optional(),
@@ -84,6 +92,7 @@ export async function writeAISettings(fs: JSRuntimeFS, settings: AISettings): Pr
export async function readGitSettings(fs: JSRuntimeFS): Promise<GitSettings> {
const defaultSettings: GitSettings = {
credentials: {},
hostTokens: {},
coAuthorEnabled: true,
};
@@ -91,7 +100,12 @@ export async function readGitSettings(fs: JSRuntimeFS): Promise<GitSettings> {
try {
const content = await fs.readFile(GIT_CONFIG_PATH, 'utf8');
const data = JSON.parse(content);
return gitSettingsSchema.parse(data);
const parsed = gitSettingsSchema.parse(data);
// Ensure hostTokens exists even if not in parsed data
return {
...parsed,
hostTokens: parsed.hostTokens || {},
};
} catch {
return defaultSettings;
}