Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/deslop-repo-wide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@mdcms/cli": patch
"@mdcms/shared": patch
"@mdcms/studio": patch
---

Remove AI-generated slop (redundant comments, dead code, gratuitous casts and defensive guards). No behavior change.
1 change: 0 additions & 1 deletion apps/cli/src/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ export function createInitCommand(options?: InitCommandOptions): CliCommand {
);

if (!initOpts.noExamplePost) {
// Create example post
const examplePath = join(cwd, dirName, "example.md");
await mkdir(join(cwd, dirName), { recursive: true });
await writeFile(
Expand Down
4 changes: 0 additions & 4 deletions apps/cli/src/lib/init/generate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function renderType(type: InferredType): string {
export function generateConfigSource(input: GenerateConfigInput): string {
const lines: string[] = [];

// Imports
const sharedImports = ["defineConfig", "defineType"];
if (hasReferences(input.types)) {
sharedImports.push("reference");
Expand All @@ -77,7 +76,6 @@ export function generateConfigSource(input: GenerateConfigInput): string {
` contentDirectories: [${input.contentDirectories.map((d) => JSON.stringify(d)).join(", ")}],`,
);

// Locales
if (input.localeConfig) {
const lc = input.localeConfig;
lines.push(" locales: {");
Expand All @@ -95,12 +93,10 @@ export function generateConfigSource(input: GenerateConfigInput): string {
lines.push(" },");
}

// Environments
lines.push(" environments: {");
lines.push(` ${input.environment}: {},`);
lines.push(" },");

// Types
if (input.types.length > 0) {
lines.push(" types: [");
for (const type of input.types) {
Expand Down
2 changes: 0 additions & 2 deletions apps/cli/src/lib/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,13 @@ function printPlan(context: CliCommandContext, changes: PullChange[]): void {
}
}

// Guidance for locally modified (server unchanged) files
const serverUnchanged = groups.get("Locally modified (server unchanged)");
if (serverUnchanged && serverUnchanged.length > 0) {
context.stdout.write(
`\nNote: ${serverUnchanged.length} file(s) modified locally but unchanged on server. Use 'cms push' to upload your changes.\n`,
);
}

// Guidance for both-modified files
const bothModified = groups.get("Both modified");
if (bothModified && bothModified.length > 0) {
context.stdout.write(
Expand Down
1 change: 0 additions & 1 deletion apps/cli/src/lib/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,6 @@ async function runSchemaPreflight(
return runSyncInline();
}

// Non-interactive branch
if (!options.syncSchema) {
context.stderr.write(
`SCHEMA_DRIFT: Local schema differs from server schema for ${context.project}/${context.environment}.\n` +
Expand Down
5 changes: 1 addition & 4 deletions apps/cli/src/lib/schema-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export async function performSchemaSync(
const { config, serverUrl, project, environment, apiKey, cwd, fetcher } =
input;

const payload = buildSchemaSyncPayload(
config as ParsedMdcmsConfig,
environment,
);
const payload = buildSchemaSyncPayload(config, environment);

if (Object.keys(payload.resolvedSchema).length === 0) {
return {
Expand Down
3 changes: 1 addition & 2 deletions apps/cli/src/lib/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ function validateField(
return [];
}

const kindErrors = validateKind(value, schema, path);
return kindErrors;
return validateKind(value, schema, path);
}

function validateKind(
Expand Down
2 changes: 0 additions & 2 deletions apps/server/src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4582,7 +4582,6 @@ export function createAuthService(
statusCode: 409,
});
}
// Check if user already exists
const existingUser = await options.db.query.authUsers.findFirst({
where: eq(authUsers.email, email),
});
Expand Down Expand Up @@ -4948,7 +4947,6 @@ export function createAuthService(
statusCode: 409,
});
}
// Check email not already registered
const existingUser = await tx.query.authUsers.findFirst({
where: eq(authUsers.email, invite.email),
});
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/lib/collaboration-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function originIsAllowed(
): boolean {
const origin = request.headers.get("origin")?.trim();

if (!origin || origin.length === 0) {
if (!origin) {
return false;
}

Expand Down
18 changes: 7 additions & 11 deletions apps/server/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ export async function loadServerConfig(
return undefined;
}

try {
const configModule = await import(
`${pathToFileURL(configPath).href}?t=${Date.now()}`
);
const configModule = await import(
`${pathToFileURL(configPath).href}?t=${Date.now()}`
);

return {
config: parseMdcmsConfig(configModule.default ?? configModule),
configPath,
};
} catch (error) {
throw error;
}
return {
config: parseMdcmsConfig(configModule.default ?? configModule),
configPath,
};
}
6 changes: 1 addition & 5 deletions apps/server/src/lib/content-api/database-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,7 @@ export function createDatabaseContentStore(
scopeIds: { projectId: string; environmentId: string },
headRow: typeof documents.$inferSelect,
): Promise<ContentDocument | undefined> {
if (
headRow.isDeleted ||
headRow.publishedVersion === null ||
headRow.publishedVersion === undefined
) {
if (headRow.isDeleted || headRow.publishedVersion === null) {
return undefined;
}

Expand Down
6 changes: 1 addition & 5 deletions apps/server/src/lib/content-api/in-memory-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ export function createInMemoryContentStore(
return input.document;
}

if (
input.document.isDeleted ||
input.document.publishedVersion === null ||
input.document.publishedVersion === undefined
) {
if (input.document.isDeleted || input.document.publishedVersion === null) {
return undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/lib/content-api/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function toVersionDocumentResponse(
export function toIsoString(value: unknown): string {
return value instanceof Date
? value.toISOString()
: new Date(value as any).toISOString();
: new Date(value as string | number).toISOString();
}

function getDatabaseErrorObjects(
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/lib/runtime-with-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export function createServerRequestHandlerWithModules(
documentId,
{ draft: true },
);
return doc !== null && doc !== undefined && !doc.isDeleted;
return doc !== undefined && !doc.isDeleted;
};

// Schema-aware proposal validator. The AI orchestrator's chat tools
Expand Down
4 changes: 1 addition & 3 deletions apps/studio-example/app/admin/[[...path]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export default async function AdminCatchAllPage() {
: undefined
}
schemaHash={
"_schemaHash" in preparedConfig
? (preparedConfig._schemaHash as string)
: undefined
"_schemaHash" in preparedConfig ? preparedConfig._schemaHash : undefined
}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/core.ai/src/server/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function mapProviderError(error: unknown): RuntimeError {
if (
error instanceof RuntimeError &&
isAiErrorCode(error.code) &&
PROVIDER_FACING_CODES.has(error.code as AiErrorCode)
PROVIDER_FACING_CODES.has(error.code)
) {
return error;
}
Expand Down
10 changes: 2 additions & 8 deletions packages/modules/core.ai/src/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,9 +1196,7 @@ async function handleProposalReject(
}
}

// ─────────────────────────────────────────────────────────────────────
// Chat-message endpoint — POST /api/v1/ai/chat/messages
// ─────────────────────────────────────────────────────────────────────

/**
* Actions the client could conceivably ask for that the chat surface
Expand Down Expand Up @@ -1583,9 +1581,7 @@ async function prepareChatTurn(
draftRevision: attachedDocument.draftRevision,
body: attachedDocument.body,
frontmatter: attachedDocument.frontmatter,
hasPublishedVersion:
attachedDocument.publishedVersion !== null &&
attachedDocument.publishedVersion !== undefined,
hasPublishedVersion: attachedDocument.publishedVersion !== null,
},
}
: {}),
Expand Down Expand Up @@ -1907,9 +1903,7 @@ async function handleChatMessage(
draftRevision: attachedDocument.draftRevision,
body: attachedDocument.body,
frontmatter: attachedDocument.frontmatter,
hasPublishedVersion:
attachedDocument.publishedVersion !== null &&
attachedDocument.publishedVersion !== undefined,
hasPublishedVersion: attachedDocument.publishedVersion !== null,
},
}
: {}),
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/core.system/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const coreSystemServerSurface: ServerSurface<
try {
route = new URL(request.url).pathname;
} catch {
route = "/api/v1/modules/core-system/ping";
// keep the default route
}

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/domain.content/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const domainContentServerSurface: ServerSurface<
try {
route = new URL(request.url).pathname;
} catch {
route = "/api/v1/modules/domain-content/preview";
// keep the default route
}

return {
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/lib/mdx/extracted-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,6 @@ function getStringEnumValues(type: ts.Type): string[] | undefined {
(candidate) => (candidate.flags & ts.TypeFlags.Undefined) === 0,
);
const values = definedTypes
.filter((candidate) => (candidate.flags & ts.TypeFlags.Undefined) === 0)
.map((candidate) =>
candidate.isStringLiteral() ? candidate.value : undefined,
)
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/lib/runtime/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type ProcessHealthPayloadInput = {

/**
* createProcessHealthPayload builds the process-level health response used
* by the `/healthz` endpoint in CMS-2.
* by the `/healthz` endpoint.
*/
export function createProcessHealthPayload(
input: ProcessHealthPayloadInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ function useContentTypePageController() {
const create = useCreateDocument(typeId);
const showLoading = list.status === "loading";

// Debounced search
useEffect(() => {
const timer = setTimeout(() => {
list.setFilters({ q: searchInput || undefined });
Expand Down Expand Up @@ -637,7 +636,6 @@ function useContentTypePageController() {
duplicateMutation.isPending ||
deleteMutation.isPending;

// Pagination
const totalPages = list.pagination
? Math.ceil(list.pagination.total / PAGE_SIZE)
: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2047,12 +2047,10 @@ function useEnvironmentPageController(): EnvironmentManagementPageViewProps {
{ auth, csrfToken: sessionState.csrfToken },
);
const preallocatedTargetIds: Record<string, string> = {};
if (promoteState.preview.status === "ready") {
for (const entry of promoteState.preview.results) {
if (entry.status === "created" && entry.targetDocumentId) {
preallocatedTargetIds[entry.sourceDocumentId] =
entry.targetDocumentId;
}
for (const entry of promoteState.preview.results) {
if (entry.status === "created" && entry.targetDocumentId) {
preallocatedTargetIds[entry.sourceDocumentId] =
entry.targetDocumentId;
}
}
const result = await environmentApi.promote(snapshot.targetEnvId, {
Expand Down
2 changes: 0 additions & 2 deletions packages/studio/src/lib/runtime-ui/app/admin/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ function useAdminLayoutRoutedElement({
if (previousAuthTokenRef.current === context.auth.token) return;
previousAuthTokenRef.current = context.auth.token;
void queryClient.invalidateQueries({ queryKey: ["studio"] });
return () => {};
}, [queryClient, context.auth.token]);

// Capabilities
Expand Down Expand Up @@ -586,7 +585,6 @@ function useAdminLayoutRoutedElement({
if (loginRedirectPath) {
replace(loginRedirectPath);
}
return () => {};
}, [loginRedirectPath, replace]);

const mdxCatalog = useMemo<MdxComponentCatalog>(
Expand Down
3 changes: 0 additions & 3 deletions packages/studio/src/lib/runtime-ui/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ export default function DashboardPage() {
<PageHeader breadcrumbs={[{ label: "Dashboard" }]} />

<div className="space-y-8 p-6 lg:p-8">
{/* Page Title */}
<div className="flex flex-wrap items-end justify-between gap-4">
<div>
<h1 className="font-heading text-[36px] font-semibold leading-[1.05] tracking-tight text-foreground">
Expand All @@ -202,7 +201,6 @@ export default function DashboardPage() {
)}
</div>

{/* Stats Row */}
<div className="grid gap-4 md:grid-cols-3">
<StatCard
label="Total documents"
Expand Down Expand Up @@ -232,7 +230,6 @@ export default function DashboardPage() {
/>
</div>

{/* Content Types & Recently updated */}
<div className="grid gap-4 lg:grid-cols-[400px_1fr]">
<ContentTypesCard data={data} />
<RecentDraftsCard data={data} formatTime={formatRelativeTime} />
Expand Down
3 changes: 0 additions & 3 deletions packages/studio/src/lib/runtime-ui/app/admin/trash-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ export default function TrashPage() {
},
});

// Pagination
const totalPages = list.pagination
? Math.ceil(list.pagination.total / TRASH_PAGE_SIZE)
: 0;
Expand All @@ -469,7 +468,6 @@ export default function TrashPage() {
<PageHeader breadcrumbs={[{ label: "Trash" }]} />

<div className="p-6 space-y-6">
{/* Header */}
<div>
<h1 className="text-2xl font-semibold">Deleted Content</h1>
<p className="mt-1 text-sm text-foreground-muted">
Expand Down Expand Up @@ -505,7 +503,6 @@ export default function TrashPage() {
</div>
)}

{/* Content area */}
{list.status === "loading" && (
<div className="flex items-center justify-center py-16">
<Loader2 className="size-6 animate-spin text-foreground-muted" />
Expand Down
Loading
Loading