Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): keep sync alive for SSH origins without a token (#2834)

omar-inkeep04fac131b888
diff --git a/.changeset/ssh-origin-probe-leniency.md b/.changeset/ssh-origin-probe-leniency.md
new file mode 100644
index 000000000..2ff12181a
--- /dev/null
+++ b/.changeset/ssh-origin-probe-leniency.md
@@ -0,0 +1,15 @@
+---
+'@inkeep/open-knowledge': patch
+'@inkeep/open-knowledge-server': patch
+'@inkeep/open-knowledge-core': patch
+---
+
+**Fix:** auto-sync no longer silently pauses for SSH-origin remotes with no
+GitHub credential. The push-permission probe used to treat "no gh/OK token"
+as signed-out and pause sync with a Sign-in prompt — wrong for self-hosted
+forges (Gitea/Forgejo) and github.com-over-SSH setups, where pushes
+authenticate with SSH keys and no OK sign-in path can ever help. The probe
+now keys off the origin transport: HTTPS origins keep the signed-out denial
+(and its Sign-in affordance, including GHES); `ssh://`, scp-style, and
+`git://` origins abstain with a new `unknown/ssh-unverified` result, so sync
+proceeds and the real push decides.
diff --git a/knip.config.ts b/knip.config.ts
index 6e3847861..296751a02 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -121,9 +121,7 @@ export default {
'packages/server': {
entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],
project: 'src/**',
- ignoreDependencies: [
- '@types/shell-quote',
- ],
+ ignoreDependencies: ['@types/shell-quote'],
},
'packages/cli': {
entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],
diff --git a/packages/app/src/components/SyncStatusBadge.dom.test.tsx b/packages/app/src/components/SyncStatusBadge.dom.test.tsx
index 8bd58e5ce..33fbc98fb 100644
--- a/packages/app/src/components/SyncStatusBadge.dom.test.tsx
+++ b/packages/app/src/components/SyncStatusBadge.dom.test.tsx
@@ -174,6 +174,13 @@ describe('SyncStatusBadge helper behavior', () => {
);
expect(shouldOfferSignInAgain({ checkStatus: 'denied' })).toBe(false);
expect(shouldOfferSignInAgain({ checkStatus: 'unknown', unknownError: 'network' })).toBe(false);
+ // ssh-unverified is the abstaining probe result for SSH-origin repos with
+ // no GitHub credential. Signing in can never help there (push auths with
+ // SSH keys), so broadening this predicate to match it would resurrect the
+ // misleading sign-in affordance the transport-keyed probe fix removed.
+ expect(shouldOfferSignInAgain({ checkStatus: 'unknown', unknownError: 'ssh-unverified' })).toBe(
+ false,
+ );
expect(shouldOfferSignInAgain(undefined)).toBe(false);
});
});
diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.ts
index 8f9d95287..c014b1413 100644
--- a/packages/core/src/bridge/bind-frontmatter-doc.ts
+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts
@@ -1,4 +1,3 @@
-
import type * as Y from 'yjs';
import type { Err, Ok, Result } from '../config/result.ts';
import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';
diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.ts
index 8bfdb40cd..005627195 100644
--- a/packages/core/src/bridge/bridge-invariant.ts
+++ b/packages/core/src/bridge/bridge-invariant.ts
@@ -1,4 +1,3 @@
-
import { fnv1aDigest } from './hash-util.ts';
export type BridgeInvariantSite = 'observer-b' | 'persistence' | 'test-harness';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index c18c086d5..8890f6739 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,4 +1,3 @@
-
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
const LEADING_BOUNDARY_RE = /^(?:\r?\n)+/;
diff --git a/packages/core/src/bridge/growth-detect.ts b/packages/core/src/bridge/growth-detect.ts
index 463e89595..9d9c244b0 100644
--- a/packages/core/src/bridge/growth-detect.ts
+++ b/packages/core/src/bridge/growth-detect.ts
@@ -1,4 +1,3 @@
-
const DEFAULT_MIN_SUBSTANTIVE_LINE_LENGTH = 16;
export const DUPLICATION_GATE_MIN_LINE_LENGTH = 8;
diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.ts
index 3c927eb47..3ab9cc6ef 100644
--- a/packages/core/src/bridge/merge-three-way.ts
+++ b/packages/core/src/bridge/merge-three-way.ts
@@ -38,7 +38,6 @@ function mergeThreeWayImpl(baseline: string, userText: string, agentText: string
return parts.join('\n');
}
-
export type BridgeMergeContentLossSide = 'user' | 'agent';
export type BridgeMergeContentLossWhich = 'substring' | 'order' | 'growth';
diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.ts
index 3f0880aa5..4b8890476 100644
--- a/packages/core/src/bridge/normalize.ts
+++ b/packages/core/src/bridge/normalize.ts
@@ -1,4 +1,3 @@
-
const COMMONMARK_ESCAPE_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g;
const TABLE_ALIGN_ROW_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;
diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.ts
index 0be5203e4..754dc5cc2 100644
--- a/packages/core/src/bridge/pm-structural-equivalence.ts
+++ b/packages/core/src/bridge/pm-structural-equivalence.ts
@@ -32,7 +32,6 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };
const BR_LITERAL_RE = /^<br\s*\/?>$/i;
-
interface DegradeEntry {
readonly label: string;
readonly severity: ToleranceClassSeverity;
@@ -128,7 +127,6 @@ export interface ComparePmStructuralOptions {
ignoreAttrs?: (attrKey: string) => boolean;
}
-
/** Rebuild a node with `fn` applied to each child; identity when childless.
* Shared by the degrade canonicalizers so none re-implements the walk. */
function mapChildren(
@@ -250,7 +248,6 @@ function applyDegrades(tree: PmStructuralNode): {
return { normalized: current, fired };
}
-
export function comparePmStructural(
expected: PmStructuralNode,
actual: PmStructuralNode,
diff --git a/packages/core/src/bridge/subsequence.ts b/packages/core/src/bridge/subsequence.ts
index dca644141..af20de1e2 100644
--- a/packages/core/src/bridge/subsequence.ts
+++ b/packages/core/src/bridge/subsequence.ts
@@ -1,4 +1,3 @@
-
/** True when `needle` is a subsequence of `haystack` (two-pointer, O(n+m)):
* insertions in `haystack` are free; any dropped or substituted `needle` byte
* fails. */
diff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.ts
index a363dfd54..83d47404a 100644
--- a/packages/core/src/markdown/callout-transformer.ts
+++ b/packages/core/src/markdown/callout-transformer.ts
@@ -1,4 +1,3 @@
-
import type { Blockquote, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index 47f0d07e4..193e286b0 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.ts
index b6299a948..ece5c02a1 100644
--- a/packages/core/src/markdown/dedent-block-jsx-close.ts
+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts
@@ -1,4 +1,3 @@
-
import { findFencedRegions, isInsideFence } from './fence-regions.ts';
const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;
diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.ts
index acd398aa6..54774764a 100644
--- a/packages/core/src/markdown/details-accordion-promoter.ts
+++ b/packages/core/src/markdown/details-accordion-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/fence-regions.ts b/packages/core/src/markdown/fence-regions.ts
index fb5ac8e8a..c7518d614 100644
--- a/packages/core/src/markdown/fence-regions.ts
+++ b/packages/core/src/markdown/fence-regions.ts
@@ -1,4 +1,3 @@
-
const FENCE_RE = /^(`{3,}|~{3,})/gm;
export function findFencedRegions(src: string): Array<[number, number]> {
diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.ts
index 6931623c7..00f5771ee 100644
--- a/packages/core/src/markdown/fixtures/index.ts
+++ b/packages/core/src/markdown/fixtures/index.ts
@@ -1,4 +1,3 @@
-
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -9,7 +8,6 @@ function fixturePath(...segments: string[]): string {
return resolve(FIXTURES_DIR, ...segments);
}
-
interface GfmExample {
section: string;
markdown: string;
@@ -19,7 +17,6 @@ export function loadGfmExamples(): GfmExample[] {
return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];
}
-
interface MdxCrashEntry {
id: string;
input: string;
@@ -71,7 +68,6 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {
) as LargeEmbedFixture[];
}
-
export function loadPrd6955Before(): string {
return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');
}
@@ -80,7 +76,6 @@ export function loadPrd6955CorruptedTriplicated(): string {
return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');
}
-
export interface NgPinnedCase {
id: string;
name: string;
@@ -97,7 +92,6 @@ export function loadNgPinnedCases(): NgPinnedCase[] {
) as NgPinnedCase[];
}
-
export function loadLargeRealistic(): string {
return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');
}
diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.ts
index daa3ef82b..8b1eb8519 100644
--- a/packages/core/src/markdown/fixtures/perf/generate.ts
+++ b/packages/core/src/markdown/fixtures/perf/generate.ts
@@ -1,4 +1,3 @@
-
import { writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -11,7 +10,6 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;
const SEED = 0xf1de1117;
-
function mulberry32(seed: number): () => number {
let a = seed >>> 0;
return () => {
@@ -38,7 +36,6 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {
return items[items.length - 1][0];
}
-
const WORDS = [
'lorem',
'ipsum',
@@ -156,7 +153,6 @@ function mdxBlock(rand: () => number): string {
return `<${name}>\n\n${sentence(rand)}\n\n</${name}>`;
}
-
type BlockKind = 'paragraph' | 'heading' | 'list' | 'code' | 'table' | 'mdx';
const MIX: readonly [BlockKind, number][] = [
@@ -195,7 +191,6 @@ function generateDocument(blockCount: number, seed: number): string {
return `${blocks.join('\n\n')}\n`;
}
-
function main(): void {
for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {
const doc = generateDocument(count, SEED);
diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.ts
index 32c055c5b..420dc0fe5 100644
--- a/packages/core/src/markdown/guard-flanking-matrix.ts
+++ b/packages/core/src/markdown/guard-flanking-matrix.ts
@@ -7,7 +7,6 @@ import {
import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';
import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';
-
export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;
export type FlankClass = 'whitespace' | 'punctuation' | 'other';
diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.ts
index 283913255..2653473da 100644
--- a/packages/core/src/markdown/handler-shadow-audit.ts
+++ b/packages/core/src/markdown/handler-shadow-audit.ts
@@ -1,4 +1,3 @@
-
export interface HandlerShadowWitness {
input: string;
expect: 'byte' | 'byte-and-reparse-type';
diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.ts
index 6319f264f..f55912407 100644
--- a/packages/core/src/markdown/highlight-promoter.ts
+++ b/packages/core/src/markdown/highlight-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';
import type { MdxJsxTextElement } from 'mdast-util-mdx';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.ts
index 8dc3a81b5..b1f252c31 100644
--- a/packages/core/src/markdown/html-to-mdast.ts
+++ b/packages/core/src/markdown/html-to-mdast.ts
@@ -1,4 +1,3 @@
-
import type { Root as HastRoot } from 'hast';
import type { List, Root as MdastRoot } from 'mdast';
import rehypeParse from 'rehype-parse';
@@ -86,8 +85,7 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRo
throw new HtmlPayloadTooLargeError(html.length, maxBytes);
}
- const processor = unified()
- .use(rehypeParse, { fragment: true });
+ const processor = unified().use(rehypeParse, { fragment: true });
for (const plugin of cleanupPlugins) {
processor.use(plugin);
diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.ts
index 994eb6917..706fa9afb 100644
--- a/packages/core/src/markdown/image-promoter.ts
+++ b/packages/core/src/markdown/image-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Image, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.ts
index fc30bda02..8b36807fd 100644
--- a/packages/core/src/markdown/index.ts
+++ b/packages/core/src/markdown/index.ts
@@ -1,4 +1,3 @@
-
import {
type FromProseMirrorOptions,
fromPmMark,
@@ -197,7 +196,6 @@ export class MarkdownManager {
}
}
-
const registry = createRegistry();
function destructureAttrs(
@@ -246,7 +244,6 @@ function destructureAttrs(
return result;
}
-
function hasDirtyDescendant(node: PmNode): boolean {
let found = false;
node.descendants((child) => {
@@ -266,7 +263,6 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChec
return freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;
}
-
function isEmptyMdastParagraph(node: MdastNodes): boolean {
if (node.type !== 'paragraph') return false;
const children = node.children ?? [];
@@ -335,7 +331,6 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {
return out;
}
-
import {
AUDIO_EXTENSIONS,
FILE_ATTACHMENT_EXTENSIONS,
@@ -582,7 +577,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.emphasis) {
handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({
sourceDelimiter: node.data?.sourceDelimiter ?? '*',
@@ -663,7 +657,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.link) {
const sourceLiteralMark = m.sourceLiteral;
handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {
@@ -942,7 +935,6 @@ function buildMdastToPmHandlers(
};
}
-
const blockUnknownHandler = (node: {
type: string;
position?: { start: { offset: number }; end: { offset: number } };
@@ -1068,7 +1060,6 @@ function buildMdastToPmHandlers(
return handlers as RemarkProseMirrorOptions['handlers'];
}
-
function buildPmToMdastHandlers(
schema: Schema,
freshness: FreshnessCheckerHolder,
diff --git a/packages/core/src/markdown/lint/config-files.ts b/packages/core/src/markdown/lint/config-files.ts
index 94b34dee1..312c9c74b 100644
--- a/packages/core/src/markdown/lint/config-files.ts
+++ b/packages/core/src/markdown/lint/config-files.ts
@@ -1,4 +1,3 @@
-
const MARKDOWNLINT_JSON_CONFIG_FILES: ReadonlySet<string> = new Set([
'.markdownlint.json',
'.markdownlint.jsonc',
diff --git a/packages/core/src/markdown/lint/config-schemas.ts b/packages/core/src/markdown/lint/config-schemas.ts
index 207cd95c2..e78a1381d 100644
--- a/packages/core/src/markdown/lint/config-schemas.ts
+++ b/packages/core/src/markdown/lint/config-schemas.ts
@@ -29,7 +29,6 @@ const fullPluginShape = Object.fromEntries(
LINT_PLUGINS.map((plugin) => [plugin.id, plugin.sliceSchema]),
) as z.ZodRawShape;
-
export const LinterConfigSchema = z.object({
enabled: z.boolean(),
plugins: z.object(fullPluginShape),
diff --git a/packages/core/src/markdown/lint/default-config.ts b/packages/core/src/markdown/lint/default-config.ts
index a51f2ffb0..d48eea5e4 100644
--- a/packages/core/src/markdown/lint/default-config.ts
+++ b/packages/core/src/markdown/lint/default-config.ts
@@ -6,7 +6,6 @@ export const DEFAULT_MARKDOWNLINT_CONFIG: Record<string, MarkdownlintRuleSetting
MD013: false,
};
-
export function resolveMarkdownlintConfig(
rules: Record<string, MarkdownlintRuleSetting> | undefined,
): Configuration {
diff --git a/packages/core/src/markdown/lint/index.ts b/packages/core/src/markdown/lint/index.ts
index d763d8d28..8a154ce30 100644
--- a/packages/core/src/markdown/lint/index.ts
+++ b/packages/core/src/markdown/lint/index.ts
@@ -1,4 +1,3 @@
-
import { LINT_PLUGINS, type LinterConfig } from './plugins.ts';
import type { LintDiagnostic } from './types.ts';
diff --git a/packages/core/src/markdown/lint/plugins.ts b/packages/core/src/markdown/lint/plugins.ts
index 65a1b564c..1cd40ef3a 100644
--- a/packages/core/src/markdown/lint/plugins.ts
+++ b/packages/core/src/markdown/lint/plugins.ts
@@ -1,4 +1,3 @@
-
import { z } from 'zod';
import { DEFAULT_MARKDOWNLINT_CONFIG, resolveMarkdownlintConfig } from './default-config.ts';
import { fixMarkdownText, runMarkdownlint } from './markdownlint-runner.ts';
@@ -9,7 +8,6 @@ import {
type MarkdownlintSlice,
} from './types.ts';
-
const MarkdownlintRuleSettingSchema = z.union([
z.boolean(),
z.enum(MARKDOWNLINT_RULE_SEVERITIES),
diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.ts
index 3651bd7eb..617f6e5b9 100644
--- a/packages/core/src/markdown/lint/types.ts
+++ b/packages/core/src/markdown/lint/types.ts
@@ -1,4 +1,3 @@
-
export const LINT_PLUGIN_IDS = ['markdownlint'] as const;
export type LintPluginId = (typeof LINT_PLUGIN_IDS)[number];
@@ -42,7 +41,6 @@ export interface MarkdownlintSlice {
rules: Record<string, MarkdownlintRuleSetting>;
}
-
interface RuleOptionSpecBase {
key: string;
description: string;
diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.ts
index bd79424c7..a5b511f25 100644
--- a/packages/core/src/markdown/math-promoter.ts
+++ b/packages/core/src/markdown/math-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Code, Root } from 'mdast';
import type { Math as MdastMath } from 'mdast-util-math';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.ts
index f84967798..679c72ef7 100644
--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts
+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, ElementContent, Properties } from 'hast';
import type { FootnoteDefinition, FootnoteReference } from 'mdast';
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.ts
index df788a80d..8ce2b2492 100644
--- a/packages/core/src/markdown/mdast-to-html.ts
+++ b/packages/core/src/markdown/mdast-to-html.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root as HastRoot, Text as HastText } from 'hast';
import type { Root as MdastRoot, Text as MdastText } from 'mdast';
import type { Handler } from 'mdast-util-to-hast';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index fa3cfcd86..bfd7e3109 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.ts
index 17ed2b829..1a897fca8 100644
--- a/packages/core/src/markdown/mermaid-promoter.ts
+++ b/packages/core/src/markdown/mermaid-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Code, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.ts
index 7e4a9a48b..9864b3b60 100644
--- a/packages/core/src/markdown/parse-with-fallback.ts
+++ b/packages/core/src/markdown/parse-with-fallback.ts
@@ -168,7 +168,6 @@ export function parseRecursive(
}
}
-
interface VFilePlace {
offset?: number;
start?: { offset?: number };
@@ -187,7 +186,6 @@ function extractErrorOffset(err: unknown): number | undefined {
return undefined;
}
-
interface Region {
start: number;
end: number;
@@ -211,7 +209,6 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {
return null;
}
-
export interface TagEvent {
kind: 'open' | 'close' | 'self-close';
name: string;
@@ -358,7 +355,6 @@ function findFallbackRegion(src: string, errorOffset: number): Region {
return { start: blockStart, end: blockEnd };
}
-
interface SourceBlock {
src: string;
start: number;
@@ -456,7 +452,6 @@ function tryPerBlockFallback(
};
}
-
function wholeDocRawText(source: string): JSONContent {
return {
type: 'doc',
diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.ts
index 43d420187..e6ab4fd57 100644
--- a/packages/core/src/markdown/parser-drop-closure.ts
+++ b/packages/core/src/markdown/parser-drop-closure.ts
@@ -1,4 +1,3 @@
-
export type DroppedTokenAdjudication =
| {
kind: 'format-dof-axis';
diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.ts
index e9e507469..7f2d5adca 100644
--- a/packages/core/src/markdown/pipeline.ts
+++ b/packages/core/src/markdown/pipeline.ts
@@ -1,4 +1,3 @@
-
import {
type FromProseMirrorOptions,
fromProseMirror,
diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.ts
index f8f5e8530..5a5e4c42a 100644
--- a/packages/core/src/markdown/position-aware-join.ts
+++ b/packages/core/src/markdown/position-aware-join.ts
@@ -1,4 +1,3 @@
-
import type { Join } from 'mdast-util-to-markdown';
import type { Position } from 'unist';
diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.ts
index e5b4c9eba..0f399d34c 100644
--- a/packages/core/src/markdown/position-slice.ts
+++ b/packages/core/src/markdown/position-slice.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Root } from 'mdast';
import { visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
@@ -477,8 +476,7 @@ export function applyPositionSliceToNode(
const first = source[startOff];
if (first !== '[' && first !== '<' && !node.title) {
node.data.sourceStyle = 'gfm-autolink';
- }
- else if (first === '[') {
+ } else if (first === '[') {
const slice = source.slice(startOff, endOff);
const closeBracketIdx = slice.lastIndexOf('](');
if (closeBracketIdx !== -1) {
diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
index ca225ce9b..db10fa54b 100644
--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, Root, Text } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
index 3a2524a9a..34068d103 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
index 2279a0189..93151d43b 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
index a0f467c42..188f02d83 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
index 4e8542a21..4ba2c3418 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
index a3c96b24a..1a74b1272 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
index e95cf43d6..de35e7b79 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
index ffdb4d5b5..b4be1b2ea 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
index e2a96d1a7..3c8d88b7c 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.ts
index 0389575ac..cf2c9da8e 100644
--- a/packages/core/src/markdown/resolve-image-url.ts
+++ b/packages/core/src/markdown/resolve-image-url.ts
@@ -1,4 +1,3 @@
-
import { isRelativeUrl } from './safe-url.ts';
function isDevDiagnosticContext(): boolean {
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 8be632ba4..4d3250d3a 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,4 +1,3 @@
-
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');
diff --git a/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.ts
index 542204403..46cc6a074 100644
--- a/packages/core/src/markdown/serialize-helpers.ts
+++ b/packages/core/src/markdown/serialize-helpers.ts
@@ -1,4 +1,3 @@
-
import type { Node as PmNode } from '@tiptap/pm/model';
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { PropDef, SerializeContext } from '../registry/types.ts';
diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.ts
index fe73659e6..be97d4d62 100644
--- a/packages/core/src/markdown/single-dollar-math-promoter.ts
+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts
@@ -1,4 +1,3 @@
-
import type { PhrasingContent, Root, Text } from 'mdast';
import type { InlineMath } from 'mdast-util-math';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.ts
index 7bce04302..8f4e9a41c 100644
--- a/packages/core/src/markdown/to-markdown-handlers.ts
+++ b/packages/core/src/markdown/to-markdown-handlers.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parents } from 'mdast';
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { Handle, Info, State } from 'mdast-util-to-markdown';
diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.ts
index c5bfd2386..cd245c38c 100644
--- a/packages/core/src/markdown/unknown-mdast-guard.ts
+++ b/packages/core/src/markdown/unknown-mdast-guard.ts
@@ -1,4 +1,3 @@
-
import type { Root as MdastRoot } from 'mdast';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.ts
index ac9f5239b..d578476a7 100644
--- a/packages/core/src/markdown/whitespace-char-ref.ts
+++ b/packages/core/src/markdown/whitespace-char-ref.ts
@@ -1,4 +1,3 @@
-
const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([
[0x20, ' '],
[0x09, '\t'],
diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.ts
index afd9936fe..6dad26200 100644
--- a/packages/core/src/markdown/wiki-link-micromark.ts
+++ b/packages/core/src/markdown/wiki-link-micromark.ts
@@ -17,7 +17,6 @@ declare module 'micromark-util-types' {
}
}
-
const CODE_BANG = 33; // !
const CODE_LBRACKET = 91; // [
const CODE_RBRACKET = 93; // ]
@@ -261,7 +260,6 @@ export function wikiLinkSyntax(): Extension {
};
}
-
function enterWikiLink(this: CompileContext, token: Token) {
this.enter(
{
@@ -387,7 +385,6 @@ export const wikiLinkToMarkdown: {
unsafe: [{ character: '[', inConstruct: ['phrasing'] }],
};
-
const MICROMARK_EXT = wikiLinkSyntax();
export function remarkWikiLink(this: Processor) {
diff --git a/packages/core/src/schemas/api/sync-seed.test.ts b/packages/core/src/schemas/api/sync-seed.test.ts
index 234b97916..bf1544f50 100644
--- a/packages/core/src/schemas/api/sync-seed.test.ts
+++ b/packages/core/src/schemas/api/sync-seed.test.ts
@@ -3,6 +3,7 @@ import {
ConflictEntrySchema,
InstallSkillSuccessSchema,
ProblemTypeSchema,
+ PushPermissionSchema,
SeedApplyRequestSchema,
SeedApplySuccessSchema,
SeedPlanSuccessSchema,
@@ -123,6 +124,32 @@ describe('SyncStatusSchema', () => {
});
});
+describe('PushPermissionSchema', () => {
+ test('parses every unknown variant including ssh-unverified', () => {
+ for (const unknownError of [
+ 'network',
+ 'timeout',
+ 'rate-limit',
+ 'token-invalid',
+ 'malformed-response',
+ 'ssh-unverified',
+ ]) {
+ const parsed = PushPermissionSchema.safeParse({ checkStatus: 'unknown', unknownError });
+ expect(parsed.success).toBe(true);
+ }
+ });
+ test('round-trips the ssh-unverified member', () => {
+ const wire = { checkStatus: 'unknown' as const, unknownError: 'ssh-unverified' as const };
+ const parsed = PushPermissionSchema.parse(wire);
+ expect(parsed).toEqual(wire);
+ });
+ test('rejects an unlisted unknownError code', () => {
+ expect(
+ PushPermissionSchema.safeParse({ checkStatus: 'unknown', unknownError: 'bogus' }).success,
+ ).toBe(false);
+ });
+});
+
describe('SyncRemoteSchema', () => {
test('accepts a github remote with label + https webUrl', () => {
expect(
diff --git a/packages/core/src/schemas/api/sync-seed.ts b/packages/core/src/schemas/api/sync-seed.ts
index 7cbfd3ccc..4483d2dfd 100644
--- a/packages/core/src/schemas/api/sync-seed.ts
+++ b/packages/core/src/schemas/api/sync-seed.ts
@@ -78,7 +78,14 @@ export const PushPermissionSchema = z.discriminatedUnion('checkStatus', [
.object({
checkStatus: z.literal('unknown'),
unknownError: z
- .enum(['network', 'timeout', 'rate-limit', 'token-invalid', 'malformed-response'])
+ .enum([
+ 'network',
+ 'timeout',
+ 'rate-limit',
+ 'token-invalid',
+ 'malformed-response',
+ 'ssh-unverified',
+ ])
.optional(),
})
.loose(),
diff --git a/packages/server/src/github-permissions.test.ts b/packages/server/src/github-permissions.test.ts
index 4dba0c0d8..b3dd05d91 100644
--- a/packages/server/src/github-permissions.test.ts
+++ b/packages/server/src/github-permissions.test.ts
@@ -302,6 +302,84 @@ describe('checkPushPermission — token resolution', () => {
expect(calls).toHaveLength(0);
});
+ test('anonymous + transport ssh → unknown/ssh-unverified with NO HTTP call', async () => {
+ // Self-hosted forge (Gitea/Forgejo) pushed over SSH: no gh/OK token can
+ // ever exist for that host, but the push auths with SSH keys. The probe
+ // must abstain, not deny — denying pauses sync for a fully working setup.
+ const { fetch, calls } = mockFetch(() => jsonResponse(200, {}));
+ const { store } = fakeStore(null);
+ const result = await checkPushPermission({
+ owner: 'acme',
+ repo: 'kb',
+ host: 'git.example.com',
+ transport: 'ssh',
+ detectGh: ghUnavailable(),
+ tokenStore: store,
+ _fetchFn: fetch,
+ });
+ expect(result).toEqual({ kind: 'unknown', error: 'ssh-unverified' });
+ expect(calls).toHaveLength(0);
+ });
+
+ test('anonymous + transport git → unknown/ssh-unverified (unauthenticated protocol, tokens irrelevant)', async () => {
+ const { fetch, calls } = mockFetch(() => jsonResponse(200, {}));
+ const result = await checkPushPermission({
+ owner: 'acme',
+ repo: 'kb',
+ host: 'git.example.com',
+ transport: 'git',
+ _fetchFn: fetch,
+ });
+ expect(result).toEqual({ kind: 'unknown', error: 'ssh-unverified' });
+ expect(calls).toHaveLength(0);
+ });
+
+ test('anonymous + explicit transport https → denied/not-authenticated unchanged', async () => {
+ // HTTPS pushes auth with tokens; no token ⇒ the push cannot succeed, so
+ // the signed-out denial (and its Sign-in affordance) stays correct —
+ // including for GHES over HTTPS.
+ const { fetch, calls } = mockFetch(() => jsonResponse(200, {}));
+ const result = await checkPushPermission({
+ owner: 'acme',
+ repo: 'kb',
+ host: 'ghes.acme.test',
+ transport: 'https',
+ _fetchFn: fetch,
+ });
+ expect(result).toEqual({ kind: 'denied', reason: 'not-authenticated' });
+ expect(calls).toHaveLength(0);
+ });
+
+ test('anonymous + github.com over SSH is lenient too (deliberate)', async () => {
+ // A github.com user with SSH keys and no gh CLI / stored token pushes
+ // fine; keying leniency on transport (not host) un-breaks them as well.
+ const { fetch, calls } = mockFetch(() => jsonResponse(200, {}));
+ const result = await checkPushPermission({
+ owner: 'inkeep',
+ repo: 'open-knowledge',
+ host: 'github.com',
+ transport: 'ssh',
+ _fetchFn: fetch,
+ });
+ expect(result).toEqual({ kind: 'unknown', error: 'ssh-unverified' });
+ expect(calls).toHaveLength(0);
+ });
+
+ test('transport ssh with a resolved credential still probes normally', async () => {
+ // Transport only gates the ANONYMOUS branch. With a token the API answer
+ // is authoritative regardless of how git would transport the push.
+ const { fetch, calls } = mockFetch(() => jsonResponse(200, { permissions: { push: true } }));
+ const result = await checkPushPermission({
+ owner: 'inkeep',
+ repo: 'open-knowledge',
+ transport: 'ssh',
+ detectGh: ghAvailable(),
+ _fetchFn: fetch,
+ });
+ expect(result).toEqual({ kind: 'allowed' });
+ expect(calls).toHaveLength(1);
+ });
+
test('gh detection is scoped to the requested host', async () => {
const seenHosts: Array<string | undefined> = [];
const detectGh: DetectGhFn = (host) => {
diff --git a/packages/server/src/github-permissions.ts b/packages/server/src/github-permissions.ts
index 6d1c80fbf..fd9fc1909 100644
--- a/packages/server/src/github-permissions.ts
+++ b/packages/server/src/github-permissions.ts
@@ -18,6 +18,7 @@
import type { Counter, Histogram } from '@opentelemetry/api';
import { getLogger } from './logger.ts';
+import type { OriginTransport } from './share/git-context.ts';
import { getMeter } from './telemetry.ts';
const log = getLogger('github-permissions');
@@ -36,12 +37,18 @@ type PushPermissionDeniedReason =
| 'repo-not-found'
| 'not-authenticated';
+// 'ssh-unverified' = anonymous credential resolution over a non-token
+// transport (ssh/git origins). git auths those pushes with SSH keys, so token
+// absence proves nothing about push ability — the probe abstains and lets the
+// real push decide. Distinct from the transient errors so telemetry can tell
+// "we couldn't reach GitHub" apart from "we deliberately didn't ask".
type PushPermissionUnknownError =
| 'network'
| 'timeout'
| 'rate-limit'
| 'token-invalid'
- | 'malformed-response';
+ | 'malformed-response'
+ | 'ssh-unverified';
/**
* Outcome of a single push-permission probe.
@@ -72,6 +79,14 @@ export interface CheckPushPermissionOptions {
repo: string;
/** GitHub host. Defaults to `'github.com'`. */
host?: string;
+ /**
+ * How the origin URL authenticates a push. Defaults to `'https'` (token
+ * auth — the pre-transport behavior). For `'ssh'`/`'git'` origins an
+ * anonymous probe abstains (`unknown/ssh-unverified`) instead of denying:
+ * no token ⇒ no HTTPS push, but SSH pushes auth with keys the probe
+ * cannot see.
+ */
+ transport?: OriginTransport;
/** Tier A resolver (`gh` CLI). Defaults to "no gh available". */
detectGh?: DetectGhFn;
/** Tier B/C credential store. Omit to skip stored-token resolution. */
@@ -207,6 +222,7 @@ async function runProbe(opts: CheckPushPermissionOptions): Promise<PushPermissio
owner,
repo,
host = 'github.com',
+ transport = 'https',
detectGh = () => ({ available: false }),
tokenStore,
_fetchFn = fetch,
@@ -219,13 +235,30 @@ async function runProbe(opts: CheckPushPermissionOptions): Promise<PushPermissio
tokenStore,
);
- // No credential at all → no push, definitionally. Short-circuit to the
+ // No credential resolved. What that MEANS depends on the origin transport:
+ //
+ // HTTPS: no credential → no push, definitionally. Short-circuit to the
// denied posture WITHOUT a network call: an anonymous `GET /repos` returns
// 200 with no `permissions` field, which classifies as `unknown` and makes
// callers fall through to the doomed sync-onboarding + 403-push path. An
// anonymous receiver opening a public shared repo (read-only by nature) must
// instead land directly in the suppressed-onboarding, no-push UX.
+ //
+ // SSH/git: pushes auth with SSH keys (or nothing, for git://), so token
+ // absence proves nothing — a self-hosted-forge or github.com-over-SSH user
+ // with working keys and no gh/OK token pushes fine. Abstain (`unknown` is
+ // the lenient posture end-to-end: sync proceeds; a genuinely unauthorized
+ // push surfaces through the existing push-failure path). Also no network
+ // call: forge hosts aren't GitHub, and an anonymous GitHub call decides
+ // nothing.
if (tokenSource === 'anonymous') {
+ if (transport === 'ssh' || transport === 'git') {
+ log.info(
+ { host, transport },
+ '[permissions] no credential resolved for ssh/git origin — abstaining (push auths with SSH keys, not tokens)',
+ );
+ return { kind: 'unknown', error: 'ssh-unverified' };
+ }
log.info({ host }, '[permissions] no credential resolved — denying push (read-only)');
// 'not-authenticated' (not 'no-collaborator'): reconnecting resolves this,
// so the UI can offer a sign-in affordance rather than a dead-end.
@@ -319,7 +352,7 @@ let _outcomeCounter: Counter | null = null;
function outcomeCounter(): Counter {
_outcomeCounter ||= getMeter().createCounter('ok.permissions.probe.outcome_total', {
description:
- 'Push-permission probe outcomes. Bounded labels: outcome ∈ {allowed,denied,unknown}; denied_reason ∈ {no-collaborator,private-no-access,repo-not-found,not-authenticated,none}; error_class ∈ {network,timeout,rate-limit,token-invalid,malformed-response,none}.',
+ 'Push-permission probe outcomes. Bounded labels: outcome ∈ {allowed,denied,unknown}; denied_reason ∈ {no-collaborator,private-no-access,repo-not-found,not-authenticated,none}; error_class ∈ {network,timeout,rate-limit,token-invalid,malformed-response,ssh-unverified,none}.',
});
return _outcomeCounter;
}
diff --git a/packages/server/src/share/git-context.test.ts b/packages/server/src/share/git-context.test.ts
index 6a45a08c3..3bcc32132 100644
--- a/packages/server/src/share/git-context.test.ts
+++ b/packages/server/src/share/git-context.test.ts
@@ -119,6 +119,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'https',
});
});
@@ -131,6 +132,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'ssh',
});
});
@@ -143,6 +145,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'ssh',
});
});
@@ -155,6 +158,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'https',
});
});
@@ -178,6 +182,7 @@ describe('readOriginGitHubRepo', () => {
host: 'ghes.acme.test',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'https',
});
});
@@ -190,6 +195,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.corp.example.com',
owner: 'team',
repo: 'kb',
+ transport: 'ssh',
});
});
@@ -204,6 +210,7 @@ describe('readOriginGitHubRepo', () => {
host: 'ghes.acme.test',
owner: 'acme',
repo: 'kb',
+ transport: 'https',
});
});
@@ -216,6 +223,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'git',
});
});
@@ -228,6 +236,23 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'https',
+ });
+ });
+
+ test('ssh:// origin with a port carries transport ssh and a port-stripped host', () => {
+ // The exact shape of the local-forge repro: `ssh://git@localhost:2222/...`
+ // against a self-hosted Gitea. Must classify as ssh so the anonymous
+ // probe abstains instead of pausing sync.
+ seedRepo(dir, {
+ config: '[remote "origin"]\n\turl = ssh://[email protected]:2222/acme/kb.git\n',
+ });
+ expect(readOriginGitHubRepo(dir)).toEqual({
+ kind: 'ok',
+ host: 'git.acme.test',
+ owner: 'acme',
+ repo: 'kb',
+ transport: 'ssh',
});
});
@@ -276,6 +301,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'https',
});
});
@@ -289,6 +315,7 @@ describe('readOriginGitHubRepo', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'https',
});
});
});
@@ -502,6 +529,7 @@ describe('linked-worktree common-dir resolution', () => {
host: 'github.com',
owner: 'inkeep',
repo: 'open-knowledge',
+ transport: 'https',
});
});
diff --git a/packages/server/src/share/git-context.ts b/packages/server/src/share/git-context.ts
index 7a14910fd..612a267ee 100644
--- a/packages/server/src/share/git-context.ts
+++ b/packages/server/src/share/git-context.ts
@@ -33,9 +33,18 @@ import { getLogger } from '../logger.ts';
const log = getLogger('git-context');
+/**
+ * Which URL form the origin was written in. Determines how a push would
+ * authenticate: `https` pushes auth with tokens; `ssh` (both `ssh://` and
+ * scp-style) auths with SSH keys; `git://` is unauthenticated. The
+ * push-permission probe keys leniency off this — token absence proves nothing
+ * about push ability for a non-token transport.
+ */
+export type OriginTransport = 'https' | 'ssh' | 'git';
+
/** Outcome of `readOriginGitHubRepo`. */
export type OriginResult =
- | { kind: 'ok'; host: string; owner: string; repo: string }
+ | { kind: 'ok'; host: string; owner: string; repo: string; transport: OriginTransport }
| { kind: 'no-remote' }
| { kind: 'non-github' };
@@ -58,6 +67,7 @@ interface ParsedOriginRepo {
host: string;
owner: string;
repo: string;
+ transport: OriginTransport;
}
/**
@@ -82,30 +92,35 @@ function parseGitHubOriginUrl(originUrl: string): ParsedOriginRepo | null {
const raw = originUrl.trim();
if (!raw) return null;
- const classify = (host: string, owner: string, repo: string): ParsedOriginRepo | null => {
+ const classify = (
+ host: string,
+ owner: string,
+ repo: string,
+ transport: OriginTransport,
+ ): ParsedOriginRepo | null => {
const normalized = normalizeGitHost(host);
if (KNOWN_NON_GITHUB_GIT_HOSTS.has(normalized)) return null;
- return { host: normalized, owner, repo };
+ return { host: normalized, owner, repo, transport };
};
// https://<host>[:port]/<owner>/<repo>(.git)?
let m = /^https?:\/\/([\w.-]+(?::\d+)?)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(raw);
- if (m) return classify(m[1], m[2], m[3]);
+ if (m) return classify(m[1], m[2], m[3], 'https');
// ssh://[user@]<host>[:port]/<owner>/<repo>(.git)?
m = /^ssh:\/\/(?:[\w.-]+@)?([\w.-]+)(?::\d+)?\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(
raw,
);
- if (m) return classify(m[1], m[2], m[3]);
+ if (m) return classify(m[1], m[2], m[3], 'ssh');
// <user>@<host>:<owner>/<repo>(.git)? (scp-style; `@` is required, so
// Windows drive paths like `C:\x` can never match)
m = /^[\w.-]+@([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(raw);
- if (m) return classify(m[1], m[2], m[3]);
+ if (m) return classify(m[1], m[2], m[3], 'ssh');
// git://<host>[:port]/<owner>/<repo>(.git)?
m = /^git:\/\/([\w.-]+(?::\d+)?)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(raw);
- if (m) return classify(m[1], m[2], m[3]);
+ if (m) return classify(m[1], m[2], m[3], 'git');
return null;
}
@@ -131,8 +146,8 @@ export function readOriginGitHubRepo(projectDir: string): OriginResult {
const parsed = readParsedOrigin(projectDir);
if (!parsed) return { kind: 'no-remote' };
if (parsed.github) {
- const { host, owner, repo } = parsed.github;
- return { kind: 'ok', host, owner, repo };
+ const { host, owner, repo, transport } = parsed.github;
+ return { kind: 'ok', host, owner, repo, transport };
}
// Origin URL present but a known non-GitHub forge or unparseable — surface
// as `non-github` so the caller renders the matching toast.
diff --git a/packages/server/src/sync-engine.test.ts b/packages/server/src/sync-engine.test.ts
index f4ad0d3b8..722a268c4 100644
--- a/packages/server/src/sync-engine.test.ts
+++ b/packages/server/src/sync-engine.test.ts
@@ -1597,6 +1597,39 @@ describe('SyncEngine push-permission probe', () => {
expect(persisted).toBe(false);
});
+ test('passes the origin transport through to the probe (ssh origin)', async () => {
+ await initGitWithOrigin('[email protected]:acme/kb.git');
+ const probe = fakeProbe({ kind: 'unknown', error: 'ssh-unverified' });
+ const engine = makeProbeEngine({ syncEnabled: false, fakeProbe: probe.fn });
+ await engine.start();
+ await waitForPushPermissionResolved(engine);
+ expect(probe.opts[0]).toMatchObject({
+ owner: 'acme',
+ repo: 'kb',
+ host: 'git.example.com',
+ transport: 'ssh',
+ });
+ });
+
+ test('ssh-unverified probe result does NOT pause the engine (self-hosted forge over SSH)', async () => {
+ // The regression behind the forge sync pause: an SSH-origin user with no
+ // gh/OK token used to land in denied/not-authenticated → pausedReason=
+ // 'no-push-permission' → disabled, with a GitHub Sign-in button that can
+ // never help. The abstaining probe result must leave sync running.
+ await initGitWithOrigin('[email protected]:acme/kb.git');
+ const probe = fakeProbe({ kind: 'unknown', error: 'ssh-unverified' });
+ const engine = makeProbeEngine({ syncEnabled: true, fakeProbe: probe.fn });
+ await engine.start();
+ await waitForPushPermissionResolved(engine);
+ const status = engine.getStatus();
+ expect(status.pushPermission).toEqual({
+ checkStatus: 'unknown',
+ unknownError: 'ssh-unverified',
+ });
+ expect(status.state).toBe('idle');
+ expect(status.pausedReason).not.toBe('no-push-permission');
+ });
+
test('records `unknown` without changing state', async () => {
await initGitWithOrigin();
const probe = fakeProbe({ kind: 'unknown', error: 'network' });
diff --git a/packages/server/src/sync-engine.ts b/packages/server/src/sync-engine.ts
index 64a1fa81e..560f1d916 100644
--- a/packages/server/src/sync-engine.ts
+++ b/packages/server/src/sync-engine.ts
@@ -92,15 +92,16 @@ export type PushPermissionStatus =
| { checkStatus: 'allowed' }
| {
checkStatus: 'denied';
- deniedReason:
- | 'no-collaborator'
- | 'private-no-access'
- | 'repo-not-found'
- | 'not-authenticated';
+ // Both payload unions derive structurally from the source-of-truth
+ // `PushPermission` in github-permissions.ts so a code added there can't
+ // silently drift from this wire shape. The Zod enum in core's
+ // sync-seed.ts still needs a manual matching update; its round-trip
+ // test is the runtime net for that half.
+ deniedReason: Extract<PushPermission, { kind: 'denied' }>['reason'];
}
| {
checkStatus: 'unknown';
- unknownError?: 'network' | 'timeout' | 'rate-limit' | 'token-invalid' | 'malformed-response';
+ unknownError?: Extract<PushPermission, { kind: 'unknown' }>['error'];
};
/** Flatten the tagged `PushPermission` from `github-permissions.ts` to wire shape. */
@@ -875,6 +876,7 @@ export class SyncEngine {
owner: origin.owner,
repo: origin.repo,
host: origin.host,
+ transport: origin.transport,
detectGh: this.detectGh,
tokenStore: this.tokenStore,
});