diff --git a/cptr/env.py b/cptr/env.py
index 5d856a5..14ad9d4 100644
--- a/cptr/env.py
+++ b/cptr/env.py
@@ -66,6 +66,10 @@ CHAT_COMPACT_TOKEN_THRESHOLD = int(os.environ.get("CHAT_COMPACT_TOKEN_THRESHOLD"
# Claude SDK stdout JSON buffer; chat/tool output caps apply later after parsing.
CLAUDE_CODE_MAX_BUFFER_SIZE = _env_int("CPTR_CLAUDE_CODE_MAX_BUFFER_SIZE", 128 * 1024 * 1024)
+# ── Workspace storage ───────────────────────────────────────
+WORKSPACE_AUTO_GITIGNORE_DOT_CPTR_ENV = os.environ.get("CPTR_AUTO_GITIGNORE_DOT_CPTR")
+WORKSPACE_AUTO_GITIGNORE_DOT_CPTR = _env_bool("CPTR_AUTO_GITIGNORE_DOT_CPTR", "true")
+
# ── Execute timeout ─────────────────────────────────────────
# Default wait (seconds) for run_command / check_task when the caller
# doesn't pass an explicit wait value. None = return immediately.
diff --git a/cptr/frontend/package.json b/cptr/frontend/package.json
index 8c07701..60d9fa0 100644
--- a/cptr/frontend/package.json
+++ b/cptr/frontend/package.json
@@ -93,4 +93,4 @@
"tippy.js": "^6.3.7",
"xlsx": "^0.18.5"
}
-}
\ No newline at end of file
+}
diff --git a/cptr/frontend/src/app.css b/cptr/frontend/src/app.css
index c29a90c..e03784f 100644
--- a/cptr/frontend/src/app.css
+++ b/cptr/frontend/src/app.css
@@ -29,8 +29,8 @@
--app-fg: #525252;
--app-fg-muted: color-mix(in oklab, var(--app-fg) 62%, var(--app-bg));
--app-fg-subtle: color-mix(in oklab, var(--app-fg) 48%, var(--app-bg));
- --app-border: color-mix(in oklab, var(--app-fg) 7%, transparent);
- --app-divider: color-mix(in oklab, var(--app-fg) 5%, transparent);
+ --app-border: color-mix(in oklab, var(--app-fg) 5%, transparent);
+ --app-divider: color-mix(in oklab, var(--app-fg) 3.5%, transparent);
--app-hover: color-mix(in oklab, var(--app-fg) 6%, transparent);
--app-active: color-mix(in oklab, var(--app-fg) 7%, transparent);
--app-ui-font: var(--font-sans);
diff --git a/cptr/frontend/src/lib/components/Admin/Workspace.svelte b/cptr/frontend/src/lib/components/Admin/Workspace.svelte
new file mode 100644
index 0000000..a2859ee
--- /dev/null
+++ b/cptr/frontend/src/lib/components/Admin/Workspace.svelte
@@ -0,0 +1,69 @@
+
+
+
+
{$t('admin.workspace')}
+
+ {#if loading}
+
+ {:else}
+
+
+
+ {$t('admin.workspaceAutoGitignoreDotCptrHint')}
+
+
+
+
+
+
+ {/if}
+
diff --git a/cptr/frontend/src/lib/components/SettingsModal.svelte b/cptr/frontend/src/lib/components/SettingsModal.svelte
index 7d3c7d0..44154bb 100644
--- a/cptr/frontend/src/lib/components/SettingsModal.svelte
+++ b/cptr/frontend/src/lib/components/SettingsModal.svelte
@@ -21,6 +21,7 @@
import AdminWeb from './Admin/Web.svelte';
import ToolServers from './Admin/ToolServers.svelte';
import Subagents from './Admin/Subagents.svelte';
+ import Workspace from './Admin/Workspace.svelte';
import { session } from '$lib/session';
import { t } from '$lib/i18n';
@@ -43,7 +44,8 @@
| 'images'
| 'web'
| 'toolservers'
- | 'subagents';
+ | 'subagents'
+ | 'workspace';
interface Props {
onclose: () => void;
@@ -71,6 +73,7 @@
'web',
'toolservers',
'subagents',
+ 'workspace',
'memory',
'skills'
];
@@ -99,6 +102,7 @@
{ id: 'web', label: $t('admin.web'), icon: 'globe' },
{ id: 'toolservers', label: $t('admin.toolServers'), icon: 'plug' },
{ id: 'subagents', label: $t('admin.subagents'), icon: 'user' },
+ { id: 'workspace', label: $t('admin.workspace'), icon: 'folder' },
{ id: 'memory', label: $t('settings.memory'), icon: 'brain' },
{ id: 'skills', label: 'Skills', icon: 'spark' }
]);
@@ -218,6 +222,8 @@
{:else if activeTab === 'subagents'}
+ {:else if activeTab === 'workspace'}
+
{/if}
diff --git a/cptr/frontend/src/lib/i18n/locales/en.json b/cptr/frontend/src/lib/i18n/locales/en.json
index ce65fc1..ad952ae 100644
--- a/cptr/frontend/src/lib/i18n/locales/en.json
+++ b/cptr/frontend/src/lib/i18n/locales/en.json
@@ -274,6 +274,9 @@
"admin.minCharsPassword": "Min 6 characters",
"admin.connections": "Connections",
"admin.agents": "Agents",
+ "admin.workspace": "Workspace",
+ "admin.workspaceAutoGitignoreDotCptr": "Add .cptr to .gitignore",
+ "admin.workspaceAutoGitignoreDotCptrHint": "Keeps local chats, memory, caches, and generated assets out of git by default. Turn this off if you want to track .cptr and manage exclusions inside .cptr/.gitignore.",
"admin.agentsRefresh": "Refresh",
"admin.agentsAddProfile": "Add profile",
"admin.agentsDeleteProfile": "Delete",
diff --git a/cptr/routers/audio.py b/cptr/routers/audio.py
index e0ba52a..d63dc66 100644
--- a/cptr/routers/audio.py
+++ b/cptr/routers/audio.py
@@ -72,8 +72,8 @@ def _get_user(request: Request) -> str:
def _workspace_audio_cache_dir(workspace: str | None, kind: str) -> Path | None:
# Voice samples are project context, so they live under the workspace .cptr
# folder and move with the project. That keeps STT and TTS artifacts available
- # for reuse, debugging, and the local data flywheel while ensure_cptr_gitignored
- # keeps them out of git.
+ # for reuse, debugging, and the local data flywheel. By default,
+ # ensure_cptr_gitignored keeps them out of git.
if not workspace:
return None
ws = Path(workspace).expanduser().resolve()
diff --git a/cptr/routers/git.py b/cptr/routers/git.py
index 90319f0..23d2b71 100644
--- a/cptr/routers/git.py
+++ b/cptr/routers/git.py
@@ -11,6 +11,7 @@ from typing import List, Optional
from fastapi import APIRouter, HTTPException, Request
from pydantic import BaseModel
+from cptr.utils.json_parser import extract_json
from cptr.utils.git import (
GitError,
branches,
@@ -153,6 +154,23 @@ The summary must be imperative, under 72 characters, and have no trailing period
The description should be one short paragraph explaining the meaningful change. Do not invent details."""
+def _parse_commit_message_response(text: str) -> tuple[str, str]:
+ message = extract_json(text)
+ summary = str(message.get("summary", "")).strip() if isinstance(message, dict) else ""
+ description = str(message.get("description", "")).strip() if isinstance(message, dict) else ""
+ if summary:
+ return summary.splitlines()[0][:72], description
+
+ lines = [
+ line.strip()
+ for line in text.strip().splitlines()
+ if line.strip() and not line.strip().startswith("```")
+ ]
+ if not lines:
+ return "", ""
+ return lines[0][:72], "\n".join(lines[1:]).strip()
+
+
class CheckoutRequest(BaseModel):
root: str
branch: str
@@ -260,7 +278,6 @@ async def generate_commit_message(body: CommitMessageRequest, request: Request):
from cptr.utils.chat_task import _default_base_url
from cptr.utils.config import _get_jwt_secret
from cptr.utils.crypto import decrypt_key
- from cptr.utils.json_parser import extract_json
from cptr.utils.model_targets import ApiModelTarget, resolve_model_target
from cptr.models import Config
@@ -285,12 +302,10 @@ async def generate_commit_message(body: CommitMessageRequest, request: Request):
)
except Exception as e:
raise HTTPException(status_code=502, detail="Could not generate a commit message") from e
- message = extract_json(text)
- summary = str(message.get("summary", "")).strip().splitlines()[0] if isinstance(message, dict) else ""
- description = str(message.get("description", "")).strip() if isinstance(message, dict) else ""
+ summary, description = _parse_commit_message_response(text)
if not summary:
raise HTTPException(status_code=502, detail="Could not generate a commit message")
- return {"summary": summary[:72], "description": description}
+ return {"summary": summary, "description": description}
@router.post("/checkout")
diff --git a/cptr/utils/workspace.py b/cptr/utils/workspace.py
index c71ae34..1d22624 100644
--- a/cptr/utils/workspace.py
+++ b/cptr/utils/workspace.py
@@ -4,9 +4,30 @@ from __future__ import annotations
from pathlib import Path
+from cptr import env
+from cptr.utils.config import load_config
+
+
+def auto_gitignore_cptr_enabled() -> bool:
+ if env.WORKSPACE_AUTO_GITIGNORE_DOT_CPTR_ENV is not None:
+ return env.WORKSPACE_AUTO_GITIGNORE_DOT_CPTR
+
+ config = load_config()
+ value = None
+ workspace = config.get("workspace", {})
+ if isinstance(workspace, dict):
+ value = workspace.get("auto_gitignore_dot_cptr")
+ app_config = config.get("app_config", {})
+ if isinstance(app_config, dict):
+ value = app_config.get("workspace.auto_gitignore_dot_cptr", value)
+ return _bool_config(value, default=True)
+
def ensure_cptr_gitignored(workspace: str | Path) -> None:
"""If workspace is a git repo, ensure .cptr is listed in .gitignore."""
+ if not auto_gitignore_cptr_enabled():
+ return
+
ws = Path(workspace)
if not (ws / ".git").exists():
return
@@ -26,3 +47,15 @@ def ensure_cptr_gitignored(workspace: str | Path) -> None:
gitignore.write_text(content, encoding="utf-8")
else:
gitignore.write_text(f"{entry}\n", encoding="utf-8")
+
+
+def _bool_config(value: object, default: bool) -> bool:
+ if isinstance(value, bool):
+ return value
+ if isinstance(value, str):
+ normalized = value.strip().lower()
+ if normalized in {"true", "1", "yes", "on"}:
+ return True
+ if normalized in {"false", "0", "no", "off"}:
+ return False
+ return default