Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): generic host extractor for ssh:// subgroup remotes
[._.]/ Adam Eivy9ded4fd86625
diff --git a/server/lib/workTracker.js b/server/lib/workTracker.jsindex 4bfac4d83c..2b26890306 100644--- a/server/lib/workTracker.js+++ b/server/lib/workTracker.js@@ -8,14 +8,14 @@// per-app JIRA config (`app.jira`) — so a user picks it deliberately.//// The pure mappers (hostToWorkTracker / forgeCliForTracker / trackerToClaimTaskType-// / resolveWorkTracker) are side-effect-free and unit-tested. resolveAppWorkTracker-// is the async wrapper that reads the app's origin host via getOriginInfo — it-// shells out to git, mirroring gitRemote.js (which also lives in lib/ despite-// running `git`). See server/services/cosTaskGenerator.js for the claim-work-// router that consumes trackerToClaimTaskType.+// / resolveWorkTracker / hostFromOriginUrl) are side-effect-free and unit-tested.+// resolveAppWorkTracker is the async wrapper that reads the app's origin URL via+// readOriginRemoteUrl and extracts the host with hostFromOriginUrl — it shells+// out to git, mirroring gitRemote.js (which also lives in lib/ despite running+// `git`). See server/services/cosTaskGenerator.js for the claim-work router+// that consumes trackerToClaimTaskType.-import { readOriginRemoteUrl, parseGitRemoteUrl } from './gitRemote.js';-import { parseGitRemote } from './gitForge.js';+import { readOriginRemoteUrl } from './gitRemote.js';// Every selectable value (UI + Zod enum). `'auto'` is the default; the rest are// concrete sources.@@ -104,21 +104,30 @@ export function resolveWorkTracker({ configured, host } = {}) {}/**- * Extract just the host from a git origin URL. Tries the strict- * owner/repo parser first (handles ssh:// scheme + ports), then falls back to- * the GitLab-subgroup-tolerant parser (`group/subgroup/repo`) — otherwise a- * subgroup remote yields no host and `'auto'` wrongly falls back to PLAN.md- * instead of GitLab. Returns null for unparseable input.+ * Extract just the host from a git origin URL — only the host is needed to+ * classify the forge, so this handles EVERY remote form in one pass rather than+ * chaining structure-validating owner/repo parsers (which variously reject+ * GitLab subgroup paths, `ssh://` scheme + subgroups, or ports). Returns null+ * for unparseable input. Handles:+ * - scheme URLs: `https://`, `ssh://`, `git://` … with optional `user[:pw]@`+ * and `:port`, and ANY path depth (so GitLab `group/subgroup/repo` works)+ * - scp-style: `[user@]host:path`*- * URL-form credentials (`https://user:token@host/…`) are stripped FIRST: the- * subgroup fallback parser would otherwise capture `user:token@host` as the- * host and leak the PAT through `GET /api/apps/:id/work-tracker`. SCP-style- * `git@host:…` carries only an ssh username (no secret), so it's left intact.+ * Embedded credentials are dropped inherently — the `user[:token]@` segment is+ * matched and discarded, never returned — so a PAT in an https remote can't+ * leak through `GET /api/apps/:id/work-tracker`. Ports are stripped too.*/export function hostFromOriginUrl(url) {- if (!url) return null;- const cleaned = url.replace(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)[^/@]+@/, '$1');- return parseGitRemoteUrl(cleaned)?.host || parseGitRemote(cleaned)?.host || null;+ if (typeof url !== 'string') return null;+ const trimmed = url.trim();+ if (!trimmed) return null;+ // scheme://[userinfo@]host[:port]/... — host is the run up to the next / : @+ const scheme = trimmed.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/(?:[^/@]+@)?([^/:]+)/);+ if (scheme) return scheme[1] || null;+ // scp-style [user@]host:path+ const scp = trimmed.match(/^(?:[^@/]+@)?([^/:]+):/);+ if (scp) return scp[1] || null;+ return null;}/**diff --git a/server/lib/workTracker.test.js b/server/lib/workTracker.test.jsindex c28a3e7167..175cd192fc 100644--- a/server/lib/workTracker.test.js+++ b/server/lib/workTracker.test.js@@ -96,11 +96,13 @@ describe('hostFromOriginUrl', () => {expect(hostFromOriginUrl('ssh://[email protected]:22/atomantic/PortOS.git')).toBe('github.com');});- it('resolves the host for GitLab subgroup remotes (>2 path segments)', () => {- // The strict owner/repo parser rejects these; the subgroup-tolerant- // fallback must still surface the host so auto → GitLab (not PLAN.md).+ it('resolves the host for GitLab subgroup remotes across every URL form', () => {+ // owner/repo-only parsers reject these; host extraction must still surface+ // the host so auto → GitLab (not PLAN.md). Covers scp, https, and ssh://.expect(hostFromOriginUrl('[email protected]:group/subgroup/repo.git')).toBe('gitlab.com');expect(hostFromOriginUrl('https://gitlab.example.com/group/sub/deep/repo.git')).toBe('gitlab.example.com');+ expect(hostFromOriginUrl('ssh://[email protected]/group/subgroup/repo.git')).toBe('gitlab.com');+ expect(hostFromOriginUrl('ssh://[email protected]:2222/group/subgroup/repo.git')).toBe('gitlab.com');});it('returns null for empty / unparseable input', () => {