11import type { TemplateConfig } from "../domain.js"
2+ export { renderEntrypointCodexResumeHint } from "./codex-resume-hint.js"
23
34export const renderEntrypointCodexHome = ( config : TemplateConfig ) : string =>
45 `# Ensure Codex home exists if mounted
6566 cat <<'EOF' > "$CODEX_CONFIG_FILE"
6667# docker-git codex config
6768model = "gpt-5.4"
68- model_context_window = 1050000
69- model_auto_compact_token_limit = 945000
7069model_reasoning_effort = "xhigh"
7170plan_mode_reasoning_effort = "xhigh"
7271personality = "pragmatic"
@@ -80,6 +79,13 @@ shell_snapshot = true
8079multi_agent = true
8180apps = true
8281shell_tool = true
82+
83+ [profiles.longcontx]
84+ model = "gpt-5.4"
85+ model_context_window = 1050000
86+ model_auto_compact_token_limit = 945000
87+ model_reasoning_effort = "xhigh"
88+ plan_mode_reasoning_effort = "xhigh"
8389EOF
8490 chown 1000:1000 "$CODEX_CONFIG_FILE" || true
8591 fi
@@ -114,100 +120,6 @@ export const renderEntrypointMcpPlaywright = (config: TemplateConfig): string =>
114120 . replaceAll ( "__CODEX_HOME__" , config . codexHome )
115121 . replaceAll ( "__SERVICE_NAME__" , config . serviceName )
116122
117- const entrypointCodexResumeHintTemplate = `# Ensure codex resume hint is shown for interactive shells
118- CODEX_HINT_PATH="/etc/profile.d/zz-codex-resume.sh"
119- if [[ ! -s "$CODEX_HINT_PATH" ]]; then
120- cat <<'EOF' > "$CODEX_HINT_PATH"
121- docker_git_workspace_context_line() {
122- REPO_REF_VALUE="\${REPO_REF:-__REPO_REF_DEFAULT__}"
123- REPO_URL_VALUE="\${REPO_URL:-__REPO_URL_DEFAULT__}"
124-
125- if [[ "$REPO_REF_VALUE" == issue-* ]]; then
126- ISSUE_ID_VALUE="$(printf "%s" "$REPO_REF_VALUE" | sed -E 's#^issue-##')"
127- ISSUE_URL_VALUE=""
128- if [[ "$REPO_URL_VALUE" == https://github.com/* ]]; then
129- ISSUE_REPO_VALUE="$(printf "%s" "$REPO_URL_VALUE" | sed -E 's#^https://github.com/##; s#[.]git$##; s#/*$##')"
130- if [[ -n "$ISSUE_REPO_VALUE" ]]; then
131- ISSUE_URL_VALUE="https://github.com/$ISSUE_REPO_VALUE/issues/$ISSUE_ID_VALUE"
132- fi
133- fi
134- if [[ -n "$ISSUE_URL_VALUE" ]]; then
135- printf "%s\n" "Контекст workspace: issue #$ISSUE_ID_VALUE ($ISSUE_URL_VALUE)"
136- else
137- printf "%s\n" "Контекст workspace: issue #$ISSUE_ID_VALUE"
138- fi
139- return
140- fi
141-
142- if [[ "$REPO_REF_VALUE" == refs/pull/*/head ]]; then
143- PR_ID_VALUE="$(printf "%s" "$REPO_REF_VALUE" | sed -nE 's#^refs/pull/([0-9]+)/head$#\\1#p')"
144- PR_URL_VALUE=""
145- if [[ "$REPO_URL_VALUE" == https://github.com/* && -n "$PR_ID_VALUE" ]]; then
146- PR_REPO_VALUE="$(printf "%s" "$REPO_URL_VALUE" | sed -E 's#^https://github.com/##; s#[.]git$##; s#/*$##')"
147- if [[ -n "$PR_REPO_VALUE" ]]; then
148- PR_URL_VALUE="https://github.com/$PR_REPO_VALUE/pull/$PR_ID_VALUE"
149- fi
150- fi
151- if [[ -n "$PR_ID_VALUE" && -n "$PR_URL_VALUE" ]]; then
152- printf "%s\n" "Контекст workspace: PR #$PR_ID_VALUE ($PR_URL_VALUE)"
153- elif [[ -n "$PR_ID_VALUE" ]]; then
154- printf "%s\n" "Контекст workspace: PR #$PR_ID_VALUE"
155- elif [[ -n "$REPO_REF_VALUE" ]]; then
156- printf "%s\n" "Контекст workspace: pull request ($REPO_REF_VALUE)"
157- fi
158- return
159- fi
160-
161- if [[ -n "$REPO_URL_VALUE" ]]; then
162- printf "%s\n" "Контекст workspace: $REPO_URL_VALUE"
163- fi
164- }
165-
166- docker_git_print_codex_resume_hint() {
167- if [ -z "\${CODEX_RESUME_HINT_SHOWN-}" ]; then
168- DOCKER_GIT_CONTEXT_LINE="$(docker_git_workspace_context_line)"
169- if [[ -n "$DOCKER_GIT_CONTEXT_LINE" ]]; then
170- echo "$DOCKER_GIT_CONTEXT_LINE"
171- fi
172- echo "Старые сессии можно запустить с помощью codex resume или codex resume <id>, если знаешь айди."
173- export CODEX_RESUME_HINT_SHOWN=1
174- fi
175- }
176-
177- if [ -n "$BASH_VERSION" ]; then
178- case "$-" in
179- *i*)
180- docker_git_print_codex_resume_hint
181- ;;
182- esac
183- fi
184- if [ -n "$ZSH_VERSION" ]; then
185- if [[ "$-" == *i* ]]; then
186- docker_git_print_codex_resume_hint
187- fi
188- fi
189- EOF
190- chmod 0644 "$CODEX_HINT_PATH"
191- fi
192- if ! grep -q "zz-codex-resume.sh" /etc/bash.bashrc 2>/dev/null; then
193- printf "%s\\n" "if [ -f /etc/profile.d/zz-codex-resume.sh ]; then . /etc/profile.d/zz-codex-resume.sh; fi" >> /etc/bash.bashrc
194- fi
195- if [[ -s /etc/zsh/zshrc ]] && ! grep -q "zz-codex-resume.sh" /etc/zsh/zshrc 2>/dev/null; then
196- printf "%s\\n" "if [ -f /etc/profile.d/zz-codex-resume.sh ]; then source /etc/profile.d/zz-codex-resume.sh; fi" >> /etc/zsh/zshrc
197- fi`
198-
199- const escapeForDoubleQuotes = ( value : string ) : string => {
200- const backslash = String . fromCodePoint ( 92 )
201- return value
202- . replaceAll ( backslash , `${ backslash } ${ backslash } ` )
203- . replaceAll ( String . fromCodePoint ( 34 ) , `${ backslash } ${ String . fromCodePoint ( 34 ) } ` )
204- }
205-
206- export const renderEntrypointCodexResumeHint = ( config : TemplateConfig ) : string =>
207- entrypointCodexResumeHintTemplate
208- . replaceAll ( "__REPO_REF_DEFAULT__" , escapeForDoubleQuotes ( config . repoRef ) )
209- . replaceAll ( "__REPO_URL_DEFAULT__" , escapeForDoubleQuotes ( config . repoUrl ) )
210-
211123const entrypointAgentsNoticeTemplate = String . raw `# Ensure global AGENTS.md exists for container context
212124AGENTS_PATH="__CODEX_HOME__/AGENTS.md"
213125LEGACY_AGENTS_PATH="/home/__SSH_USER__/AGENTS.md"
0 commit comments