+36
![github-actions[bot]](/assets/img/avatar_default.png)








Julius Marminge
maria-rcks
Bilal Bakr
shivam
Vitalii Yehorov
Jake Leventhal
Claude Opus 5
Alex Southwell
github-actions[bot]
Nicholas Wasmiller
PB
Exotic
Yash Singh
Devin
Theo Browne
Gabriel De Andrade
Dara Adedeji
scratchyone
Dominic Roy
chukfinley
Primož Ajdišek
benthecarman
NaveDanan
aaditagrawal
Aditya Garud
Nick Anisimov
MacKinley Smith
Yordis Prieto
t3-code[bot]
AKolenda
Guillermo Casanova
Otavio Salvador
Shirish Pothi
Ishaan Kothari
Bob Fowler
Anton Bezdenezhnykh
ValeraZSD
Ephraim
Ryan Ilano
Alex
maco
Cursor
Tristan Knight
PR Batch Tester
oliver
kamkm
de34391427
Co-authored-by: maria-rcks <[email protected]> Co-authored-by: Bilal Bakr <[email protected]> Co-authored-by: shivam <[email protected]> Co-authored-by: Vitalii Yehorov <[email protected]> Co-authored-by: Jake Leventhal <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Alex Southwell <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Nicholas Wasmiller <[email protected]> Co-authored-by: PB <[email protected]> Co-authored-by: Exotic <[email protected]> Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Theo Browne <[email protected]> Co-authored-by: Gabriel De Andrade <[email protected]> Co-authored-by: Dara Adedeji <[email protected]> Co-authored-by: scratchyone <[email protected]> Co-authored-by: Dominic Roy <[email protected]> Co-authored-by: chukfinley <[email protected]> Co-authored-by: Primož Ajdišek <[email protected]> Co-authored-by: benthecarman <[email protected]> Co-authored-by: NaveDanan <[email protected]> Co-authored-by: aaditagrawal <[email protected]> Co-authored-by: Aditya Garud <[email protected]> Co-authored-by: Nick Anisimov <[email protected]> Co-authored-by: MacKinley Smith <[email protected]> Co-authored-by: Yordis Prieto <[email protected]> Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> Co-authored-by: AKolenda <[email protected]> Co-authored-by: Guillermo Casanova <[email protected]> Co-authored-by: Otavio Salvador <[email protected]> Co-authored-by: Shirish Pothi <[email protected]> Co-authored-by: Ishaan Kothari <[email protected]> Co-authored-by: Bob Fowler <[email protected]> Co-authored-by: Anton Bezdenezhnykh <[email protected]> Co-authored-by: ValeraZSD <[email protected]> Co-authored-by: Ephraim <[email protected]> Co-authored-by: Ryan Ilano <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: maco <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Tristan Knight <[email protected]> Co-authored-by: PR Batch Tester <[email protected]> Co-authored-by: oliver <[email protected]> Co-authored-by: kamkm <[email protected]> Signed-off-by: Yordis Prieto <[email protected]>
144 lines
5.9 KiB
TypeScript
144 lines
5.9 KiB
TypeScript
import * as Schema from "effect/Schema";
|
|
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
|
|
import { ThreadEnvMode, WorktreeSubmodules } from "./environment.ts";
|
|
import { ProjectScriptIcon } from "./project.ts";
|
|
import type { ProjectScopedServerSettingKey, ServerSettings } from "./settings.ts";
|
|
|
|
/** File name of the checked-in T3 project file, resolved at the workspace root. */
|
|
export const T3_PROJECT_FILE_NAME = "t3.json";
|
|
|
|
/** Public URL of the published JSON Schema for {@link T3ProjectFile}. */
|
|
export const T3_PROJECT_FILE_SCHEMA_URL = "https://t3.codes/schema/t3.json";
|
|
|
|
const T3_PROJECT_FILE_PATH_MAX_LENGTH = 512;
|
|
const T3_PROJECT_FILE_MAX_SCRIPTS = 50;
|
|
|
|
// Annotations go on the encoded (string) side so they survive into the
|
|
// published JSON Schema; decoding still trims and re-validates non-emptiness.
|
|
const trimmedNonEmpty = (annotations: { readonly description: string }, maxLength?: number) => {
|
|
const annotated = Schema.String.annotate(annotations);
|
|
const encoded =
|
|
maxLength === undefined
|
|
? annotated.check(Schema.isNonEmpty())
|
|
: annotated.check(Schema.isNonEmpty(), Schema.isMaxLength(maxLength));
|
|
return encoded.pipe(Schema.decodeTo(encoded, SchemaTransformation.trim()));
|
|
};
|
|
|
|
export const T3ProjectFileScript = Schema.Struct({
|
|
name: trimmedNonEmpty({
|
|
description: "Display name for the script, shown in the T3 Code scripts menu.",
|
|
}),
|
|
command: trimmedNonEmpty({
|
|
description: "Shell command executed in a T3 Code terminal at the project root.",
|
|
}),
|
|
icon: Schema.optionalKey(
|
|
ProjectScriptIcon.annotate({
|
|
description: 'Icon shown next to the script in the scripts menu. Defaults to "play".',
|
|
}),
|
|
),
|
|
runOnWorktreeCreate: Schema.optionalKey(
|
|
Schema.Boolean.annotate({
|
|
description:
|
|
"When true, the script runs automatically after a worktree is created for a new thread.",
|
|
}),
|
|
),
|
|
async: Schema.optionalKey(
|
|
Schema.Boolean.annotate({
|
|
description:
|
|
"Only for runOnWorktreeCreate scripts. When true (the default), the agent starts while the script is still running. Set false to hold the agent until the script exits.",
|
|
}),
|
|
),
|
|
previewUrl: Schema.optionalKey(
|
|
trimmedNonEmpty({
|
|
description:
|
|
"URL opened in the in-app browser preview when this script runs. Only honored on the desktop build.",
|
|
}),
|
|
),
|
|
autoOpenPreview: Schema.optionalKey(
|
|
Schema.Boolean.annotate({
|
|
description:
|
|
"When true, automatically open the preview panel at `previewUrl` the moment the script starts.",
|
|
}),
|
|
),
|
|
}).annotate({
|
|
description: "A project script that team members can import into T3 Code.",
|
|
});
|
|
export type T3ProjectFileScript = typeof T3ProjectFileScript.Type;
|
|
|
|
export const T3ProjectFile = Schema.Struct({
|
|
$schema: Schema.optionalKey(
|
|
Schema.String.annotate({
|
|
description: `URL of the JSON Schema for this file, typically "${T3_PROJECT_FILE_SCHEMA_URL}".`,
|
|
}),
|
|
),
|
|
iconPath: Schema.optionalKey(
|
|
trimmedNonEmpty(
|
|
{
|
|
description:
|
|
'Workspace-relative path to the project icon (e.g. "assets/logo.svg"). Checked before T3 Code\'s built-in icon locations.',
|
|
},
|
|
T3_PROJECT_FILE_PATH_MAX_LENGTH,
|
|
),
|
|
),
|
|
defaultThreadEnvMode: Schema.optionalKey(
|
|
ThreadEnvMode.annotate({
|
|
description:
|
|
'Where new threads start for this repository: "worktree" for a fresh git worktree, "local" for the current checkout. A per-project setting in T3 Code overrides this; when neither is set, the global default applies.',
|
|
}),
|
|
),
|
|
worktreeSubmodules: Schema.optionalKey(
|
|
WorktreeSubmodules.annotate({
|
|
description:
|
|
'How new worktrees populate git submodules: "recursive" (the default) initializes nested submodules too, "top-level" initializes only those declared by this repository, and "none" leaves every submodule empty for a setup script to handle. A project or environment setting in T3 Code overrides this.',
|
|
}),
|
|
),
|
|
scripts: Schema.optionalKey(
|
|
Schema.Array(T3ProjectFileScript)
|
|
.annotate({
|
|
description: "Project scripts shared with everyone who opens this repository in T3 Code.",
|
|
})
|
|
.check(Schema.isMaxLength(T3_PROJECT_FILE_MAX_SCRIPTS)),
|
|
),
|
|
}).annotate({
|
|
title: "T3 project file",
|
|
description:
|
|
"Checked-in project configuration for T3 Code (t3.json at the repository root). See https://t3.codes for documentation.",
|
|
});
|
|
export type T3ProjectFile = typeof T3ProjectFile.Type;
|
|
|
|
/**
|
|
* Settings a repository can also declare in t3.json. A key here must be
|
|
* nullable on `ServerSettings` (null means inherit) so both the project
|
|
* override and the environment value can defer to the file; `field` names
|
|
* the t3.json field carrying the same value and `builtIn` is what applies
|
|
* when every tier is unset. `resolveProjectSettings` walks project override,
|
|
* environment value, file, built-in, so listing a key here is the whole
|
|
* change for a new file-backed setting.
|
|
*/
|
|
export const PROJECT_FILE_BACKED_SETTINGS = {
|
|
defaultThreadEnvMode: { field: "defaultThreadEnvMode", builtIn: "local" },
|
|
worktreeSubmodules: { field: "worktreeSubmodules", builtIn: "recursive" },
|
|
} as const satisfies {
|
|
readonly [K in ProjectScopedServerSettingKey]?: {
|
|
readonly field: {
|
|
readonly [F in keyof T3ProjectFile]: T3ProjectFile[F] extends
|
|
| Exclude<ServerSettings[K], null>
|
|
| undefined
|
|
? F
|
|
: never;
|
|
}[keyof T3ProjectFile];
|
|
readonly builtIn: Exclude<ServerSettings[K], null>;
|
|
};
|
|
};
|
|
export type ProjectFileBackedSettingKey = keyof typeof PROJECT_FILE_BACKED_SETTINGS;
|
|
|
|
/**
|
|
* `ServerSettings` with every file-backed key resolved to a concrete value.
|
|
* What `resolveProjectSettings(...).settings` produces once a t3.json (or
|
|
* its absence) has been accounted for.
|
|
*/
|
|
export type ResolvedServerSettings = Omit<ServerSettings, ProjectFileBackedSettingKey> & {
|
|
readonly [K in ProjectFileBackedSettingKey]: Exclude<ServerSettings[K], null>;
|
|
};
|