From 8dd3f48c8a39ecb1e02461f104987df440563d1a Mon Sep 17 00:00:00 2001 From: akadeepesh Date: Sun, 23 Aug 2026 03:03:34 +0530 Subject: [PATCH] feat: update workspace structure and improve gitignore handling --- .contextzip/.gitignore | 7 +++++++ .gitignore | 3 --- contextzip/config.py | 2 +- contextzip/watcher.py | 12 ++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 .contextzip/.gitignore diff --git a/.contextzip/.gitignore b/.contextzip/.gitignore new file mode 100644 index 0000000..8f41bff --- /dev/null +++ b/.contextzip/.gitignore @@ -0,0 +1,7 @@ +# contextzip workspace +# Everything here is a local, per-machine artifact except config.json, +# which holds project-level contextzip preferences meant to be shared +# with your team via Git. +* +!.gitignore +!config.json diff --git a/.gitignore b/.gitignore index febc5f2..5ee9beb 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,5 @@ desktop.ini # contextzip output files (don't commit test zips) *_context_*.zip -# contextzip workspace -.contextzip/ - # contextzip workspace exports/ diff --git a/contextzip/config.py b/contextzip/config.py index 293f18f..dc31172 100644 --- a/contextzip/config.py +++ b/contextzip/config.py @@ -153,7 +153,7 @@ def config_path() -> Path: # now just output zips) gets created, when nothing more specific overrides # it. This is a *personal*, per-machine preference — for a setting the whole # team should share, use the project-level config instead (project_config.py, -# a .contextzip.json file meant to be committed to the repo). +# a .contextzip/config.json file meant to be committed to the repo). # # Resolution order (highest wins), enforced by packager.py, not here: # CLI flag > CONTEXTZIP_WORKSPACE_LOCATION env var > project config diff --git a/contextzip/watcher.py b/contextzip/watcher.py index c4bd72a..80462ca 100644 --- a/contextzip/watcher.py +++ b/contextzip/watcher.py @@ -605,31 +605,31 @@ def _write_debug_zip( console: Console, ) -> Path | None: """ - Write debug-context.zip to .contextzip/ workspace. + Write debug-context.zip to the .contextzip/output/ workspace. Structure (flat): prompt.txt terminal-error.txt source-files.zip (inner zip with referenced source files) """ - from contextzip.packager import _workspace_dir, _ensure_gitignore + from contextzip.packager import _workspace_dir, _ensure_workspace_gitignore workspace, is_git_repo = _workspace_dir(project_dir) + output_dir = workspace / "output" try: - workspace.mkdir(parents=True, exist_ok=True) + output_dir.mkdir(parents=True, exist_ok=True) except OSError as exc: console.print(f"[red] ✗[/] Could not create workspace: {exc}") return None if is_git_repo: try: - git_root = workspace.parent - _ensure_gitignore(git_root) + _ensure_workspace_gitignore(workspace) except OSError: pass - zip_path = workspace / "debug-context.zip" + zip_path = output_dir / "debug-context.zip" try: with zipfile.ZipFile(