Extract client SDK package (#1052)

* Extract client SDK package

* Polish SDK client identity defaults

* Build client before dependent CI jobs

* Restore daemon client server export

* Extract protocol and client SDK packages

* Fix provider override schema validation

* Fix app test daemon client imports

* Simplify workspace build targets

* Fix CLI test server build bootstrap

* Run SDK package tests in CI

* Fix rebase package split drift

* Restore lockfile registry metadata

* Update SDK config test for prompt default

* Move terminal stream router test to client package

* Fix rebase drift for protocol imports

* Fix SDK agent capability fixture

* Restore legacy server client exports

* Fix server export compatibility test

* Advertise custom mode icon client capability

* Remove server daemon-client exports

* Format rebased mode control import

* Fix rebase drift for protocol imports

Files added by upstream PRs (#893, #1147, #1154) referenced the pre-split
shared/ paths that this branch moves into @getpaseo/protocol. Redirect
those imports to the protocol package so typecheck stays green after the
rebase.
This commit is contained in:
Mohamed Boudra
2026-05-28 01:58:18 +08:00
committed by GitHub
parent 0ea41378a4
commit 53c14d9855
403 changed files with 3193 additions and 1417 deletions
@@ -1,5 +1,5 @@
import { readPaseoConfigJson } from "./paseo-config-file.js";
import { PaseoConfigSchema } from "./paseo-config-schema.js";
import { PaseoConfigSchema } from "@getpaseo/protocol/paseo-config-schema";
import { wrapWithUserInstructions } from "./wrap-user-instructions.js";
export type MetadataConfigKey = "agentTitle" | "branchName" | "commitMessage" | "pullRequest";
+2 -2
View File
@@ -4,7 +4,7 @@ import {
parseGitHubRemoteIdentity,
parseGitRemoteLocation,
type GitHubRemoteIdentity as ResolvedGitHubRemoteIdentity,
} from "../shared/git-remote.js";
} from "@getpaseo/protocol/git-remote";
import { findExecutable } from "./executable.js";
import { execCommand } from "./spawn.js";
@@ -13,7 +13,7 @@ const sshHostnameResolutionCache = new Map<string, Promise<string | null>>();
export type SshHostnameResolver = (host: string) => Promise<string | null>;
export { parseGitHubRemoteUrl, type GitHubRemoteIdentity } from "../shared/git-remote.js";
export { parseGitHubRemoteUrl, type GitHubRemoteIdentity } from "@getpaseo/protocol/git-remote";
export async function resolveGitHubRemote(input: {
remoteUrl: string;
@@ -6,13 +6,13 @@ import {
type PaseoConfigRaw,
type PaseoConfigRevision,
type ProjectConfigRpcError,
} from "./paseo-config-schema.js";
} from "@getpaseo/protocol/paseo-config-schema";
export {
PaseoConfigRevisionSchema,
ProjectConfigRpcErrorSchema,
type PaseoConfigRevision,
type ProjectConfigRpcError,
} from "./paseo-config-schema.js";
} from "@getpaseo/protocol/paseo-config-schema";
export const PASEO_CONFIG_FILE_NAME = "paseo.json";
@@ -1,154 +0,0 @@
import { describe, expect, it } from "vitest";
import { PaseoConfigRawSchema, PaseoConfigSchema } from "./paseo-config-schema.js";
describe("paseo config schema", () => {
it("parses an empty config without metadata generation", () => {
const parsed = PaseoConfigSchema.parse({});
expect(parsed).toEqual({});
expect(parsed.metadataGeneration).toBeUndefined();
});
it("parses old-style worktree and scripts config unchanged", () => {
const config = {
worktree: {
setup: "npm install",
teardown: ["npm run clean"],
},
scripts: {
dev: {
type: "service",
command: "npm run dev",
port: 5173,
},
},
};
expect(PaseoConfigSchema.parse(config)).toEqual({
worktree: {
setup: ["npm install"],
teardown: ["npm run clean"],
},
scripts: config.scripts,
});
});
it("parses all metadata generation instruction entries", () => {
expect(
PaseoConfigSchema.parse({
metadataGeneration: {
agentTitle: { instructions: "Use concise titles." },
branchName: { instructions: "Prefix branches with feat/." },
commitMessage: { instructions: "Use imperative mood." },
pullRequest: { instructions: "Include risk notes." },
},
}),
).toEqual({
metadataGeneration: {
agentTitle: { instructions: "Use concise titles." },
branchName: { instructions: "Prefix branches with feat/." },
commitMessage: { instructions: "Use imperative mood." },
pullRequest: { instructions: "Include risk notes." },
},
});
});
it("parses partial metadata generation instructions with missing entries undefined", () => {
const parsed = PaseoConfigSchema.parse({
metadataGeneration: {
agentTitle: { instructions: "Keep it short." },
},
});
expect(parsed.metadataGeneration).toEqual({
agentTitle: { instructions: "Keep it short." },
});
expect(parsed.metadataGeneration?.branchName).toBeUndefined();
expect(parsed.metadataGeneration?.commitMessage).toBeUndefined();
expect(parsed.metadataGeneration?.pullRequest).toBeUndefined();
});
it("passes through unknown metadata generation fields", () => {
expect(
PaseoConfigSchema.parse({
metadataGeneration: {
agentTitle: { instructions: "Use concise titles." },
futureField: 42,
},
}),
).toEqual({
metadataGeneration: {
agentTitle: { instructions: "Use concise titles." },
futureField: 42,
},
});
});
it("passes through unknown metadata generator entry fields", () => {
expect(
PaseoConfigSchema.parse({
metadataGeneration: {
agentTitle: {
instructions: "Use concise titles.",
model: "haiku",
},
},
}),
).toEqual({
metadataGeneration: {
agentTitle: {
instructions: "Use concise titles.",
model: "haiku",
},
},
});
});
it("falls back to an empty metadata generator entry when instructions has an invalid type", () => {
expect(
PaseoConfigSchema.parse({
metadataGeneration: {
agentTitle: { instructions: 42 },
},
}),
).toEqual({
metadataGeneration: {
agentTitle: {},
},
});
});
it("raw schema preserves old-style config while accepting metadata generation", () => {
const config = {
worktree: {
setup: "npm install",
teardown: ["npm run clean"],
},
scripts: {
dev: {
type: "service",
command: "npm run dev",
},
},
metadataGeneration: {
agentTitle: { instructions: "Use concise titles." },
},
};
expect(PaseoConfigRawSchema.parse(config)).toEqual(config);
});
it("raw schema falls back to an empty metadata generator entry when instructions has an invalid type", () => {
expect(
PaseoConfigRawSchema.parse({
metadataGeneration: {
agentTitle: { instructions: 42 },
},
}),
).toEqual({
metadataGeneration: {
agentTitle: {},
},
});
});
});
@@ -1,96 +0,0 @@
import { z } from "zod";
export function normalizeLifecycleCommands(commands: unknown): string[] {
if (typeof commands === "string") {
return commands.trim().length > 0 ? [commands] : [];
}
if (!Array.isArray(commands)) {
return [];
}
return commands.filter((command): command is string => {
return typeof command === "string" && command.trim().length > 0;
});
}
export const PaseoLifecycleCommandRawSchema = z.union([z.string(), z.array(z.string())]);
export const PaseoScriptEntryRawSchema = z
.object({
type: z.unknown().optional(),
command: z.unknown().optional(),
port: z.unknown().optional(),
})
.passthrough();
export const PaseoWorktreeConfigRawSchema = z
.object({
setup: PaseoLifecycleCommandRawSchema.optional(),
teardown: PaseoLifecycleCommandRawSchema.optional(),
terminals: z.unknown().optional(),
})
.passthrough();
export const PaseoMetadataGenerationEntrySchema = z
.object({
instructions: z.string().optional(),
})
.passthrough()
.catch({});
export const PaseoMetadataGenerationSchema = z
.object({
agentTitle: PaseoMetadataGenerationEntrySchema.optional(),
branchName: PaseoMetadataGenerationEntrySchema.optional(),
commitMessage: PaseoMetadataGenerationEntrySchema.optional(),
pullRequest: PaseoMetadataGenerationEntrySchema.optional(),
})
.passthrough()
.catch({});
export const PaseoConfigRawSchema = z
.object({
worktree: PaseoWorktreeConfigRawSchema.optional(),
scripts: z.record(z.string(), PaseoScriptEntryRawSchema).optional(),
metadataGeneration: PaseoMetadataGenerationSchema.optional(),
})
.passthrough();
export const WorktreeConfigSchema = PaseoWorktreeConfigRawSchema.extend({
setup: z.unknown().transform(normalizeLifecycleCommands),
teardown: z.unknown().transform(normalizeLifecycleCommands),
})
.passthrough()
.catch({ setup: [], teardown: [] });
export const ScriptEntrySchema = PaseoScriptEntryRawSchema.catch({});
export const PaseoConfigSchema = PaseoConfigRawSchema.extend({
worktree: WorktreeConfigSchema.optional(),
scripts: z.record(z.string(), ScriptEntrySchema).optional().catch({}),
metadataGeneration: PaseoMetadataGenerationSchema.optional(),
})
.passthrough()
.catch({});
export const PaseoConfigRevisionSchema = z.object({
mtimeMs: z.number(),
size: z.number(),
});
export const ProjectConfigRpcErrorSchema = z.discriminatedUnion("code", [
z.object({ code: z.literal("project_not_found") }),
z.object({ code: z.literal("invalid_project_config") }),
z.object({
code: z.literal("stale_project_config"),
currentRevision: PaseoConfigRevisionSchema.nullable(),
}),
z.object({ code: z.literal("write_failed") }),
]);
export type PaseoScriptEntryRaw = z.infer<typeof PaseoScriptEntryRawSchema>;
export type PaseoMetadataGenerationEntry = z.infer<typeof PaseoMetadataGenerationEntrySchema>;
export type PaseoMetadataGeneration = z.infer<typeof PaseoMetadataGenerationSchema>;
export type PaseoConfigRaw = z.infer<typeof PaseoConfigRawSchema>;
export type PaseoConfig = z.infer<typeof PaseoConfigSchema>;
export type PaseoConfigRevision = z.infer<typeof PaseoConfigRevisionSchema>;
export type ProjectConfigRpcError = z.infer<typeof ProjectConfigRpcErrorSchema>;
@@ -1,5 +1,5 @@
import { z } from "zod";
import { stripCwdPrefix } from "../shared/path-utils.js";
import { stripCwdPrefix } from "@getpaseo/protocol/path-utils";
const SHELL_WRAPPER_PREFIX_PATTERN = /^\/bin\/(?:zsh|bash|sh)\s+(?:-[a-zA-Z]+\s+)?/;
const CD_AND_PATTERN = /^cd\s+(?:"[^"]+"|'[^']+'|\S+)\s+&&\s+/;
@@ -20,7 +20,7 @@ import {
type CreateWorktreeOptions,
type WorktreeConfig,
} from "./worktree";
import type { PaseoConfig } from "./paseo-config-schema.js";
import type { PaseoConfig } from "@getpaseo/protocol/paseo-config-schema";
import { getPaseoWorktreeMetadataPath } from "./worktree-metadata.js";
import { execFileSync } from "child_process";
import { isPlatform } from "../test-utils/platform.js";
+2 -2
View File
@@ -16,8 +16,8 @@ export {
PaseoConfigSchema,
type PaseoConfig,
type PaseoConfigRaw,
} from "./paseo-config-schema.js";
import { PaseoConfigSchema, type PaseoConfig } from "./paseo-config-schema.js";
} from "@getpaseo/protocol/paseo-config-schema";
import { PaseoConfigSchema, type PaseoConfig } from "@getpaseo/protocol/paseo-config-schema";
import {
normalizeBaseRefName,
readPaseoWorktreeMetadata,