codebase-brief 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+
5
+ - Add `brief --demo`, which generates a real example brief from temporary sample files without reading or modifying the user's project.
6
+ - Clarify how to try the demo and install the CLI when pipx is not already available.
7
+ - Show the menu's actual `0` exit key correctly in the README.
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  - Clarify the product's best-fit use case as browser-based coding chats that cannot inspect a local working tree.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codebase-brief
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Local-first CLI that builds task-focused context briefs from code repositories
5
5
  Author: Mohamed Maggy
6
6
  License-Expression: MIT
@@ -53,7 +53,7 @@ The first image is a terminal-style rendering of the app's actual numbered menu.
53
53
 
54
54
  You need Python 3.10 or newer. Git is optional, but required for recent-history and base-diff details.
55
55
 
56
- The current PyPI release is `0.1.1` and includes the reviewed-file feedback summary and importer-aware `--base` selection. Install it with `pipx`:
56
+ The current PyPI release is `0.1.2` and includes the review-feedback summary, importer-aware `--base` selection, and a sample demo. Install it with `pipx`:
57
57
 
58
58
  ```powershell
59
59
  pipx install codebase-brief
@@ -62,6 +62,10 @@ brief "C:\work\my-app" --task "Trace the login flow" --copy
62
62
 
63
63
  The brief is copied to your clipboard for pasting into your assistant. Replace the example path and task with yours. To use the numbered menu, run `brief` with no arguments.
64
64
 
65
+ Want to see a real example before choosing your project? Run `brief --demo`. It uses a tiny temporary example project and does not read or change your files.
66
+
67
+ If you do not have `pipx` installed, skip the command above and use the virtual-environment steps below instead; they work with the project's minimum Python version. To install `pipx` first, follow its [official installation guide](https://pipx.pypa.io/latest/how-to/install-pipx.html). The current pipx installer requires Python 3.11 or newer, while Codebase Brief itself supports Python 3.10 and newer.
68
+
65
69
  Or use a virtual environment:
66
70
 
67
71
  ```powershell
@@ -79,10 +83,10 @@ If the `brief` command is not available, use `python -m context_inject` while th
79
83
 
80
84
  When the menu opens, it uses the folder you launched it from as the starting project. Type a number and press Enter:
81
85
 
82
- 1. **Build a context brief** — describe the coding task, optionally enter a Git base ref, then accept or change the approximate size limit.
83
- 2. **Choose a different project** — point the tool at another local repository or source folder.
84
- 3. **Help and examples** — see the workflow and an example command.
85
- 0. **Exit** — close the menu.
86
+ - **1 — Build a context brief:** Describe the coding task, optionally enter a Git base ref, then accept or change the approximate size limit.
87
+ - **2 — Choose a different project:** Point the tool at another local repository or source folder.
88
+ - **3 — Help and examples:** See the workflow and an example command.
89
+ - **0 — Exit:** Close the menu.
86
90
 
87
91
  In plain terms, Codebase Brief makes a small guide to a project so an AI coding assistant can get oriented before helping with a task. It does not write or fix code. It reads project information locally and prepares a guide for you to review and share.
88
92
 
@@ -28,7 +28,7 @@ The first image is a terminal-style rendering of the app's actual numbered menu.
28
28
 
29
29
  You need Python 3.10 or newer. Git is optional, but required for recent-history and base-diff details.
30
30
 
31
- The current PyPI release is `0.1.1` and includes the reviewed-file feedback summary and importer-aware `--base` selection. Install it with `pipx`:
31
+ The current PyPI release is `0.1.2` and includes the review-feedback summary, importer-aware `--base` selection, and a sample demo. Install it with `pipx`:
32
32
 
33
33
  ```powershell
34
34
  pipx install codebase-brief
@@ -37,6 +37,10 @@ brief "C:\work\my-app" --task "Trace the login flow" --copy
37
37
 
38
38
  The brief is copied to your clipboard for pasting into your assistant. Replace the example path and task with yours. To use the numbered menu, run `brief` with no arguments.
39
39
 
40
+ Want to see a real example before choosing your project? Run `brief --demo`. It uses a tiny temporary example project and does not read or change your files.
41
+
42
+ If you do not have `pipx` installed, skip the command above and use the virtual-environment steps below instead; they work with the project's minimum Python version. To install `pipx` first, follow its [official installation guide](https://pipx.pypa.io/latest/how-to/install-pipx.html). The current pipx installer requires Python 3.11 or newer, while Codebase Brief itself supports Python 3.10 and newer.
43
+
40
44
  Or use a virtual environment:
41
45
 
42
46
  ```powershell
@@ -54,10 +58,10 @@ If the `brief` command is not available, use `python -m context_inject` while th
54
58
 
55
59
  When the menu opens, it uses the folder you launched it from as the starting project. Type a number and press Enter:
56
60
 
57
- 1. **Build a context brief** — describe the coding task, optionally enter a Git base ref, then accept or change the approximate size limit.
58
- 2. **Choose a different project** — point the tool at another local repository or source folder.
59
- 3. **Help and examples** — see the workflow and an example command.
60
- 0. **Exit** — close the menu.
61
+ - **1 — Build a context brief:** Describe the coding task, optionally enter a Git base ref, then accept or change the approximate size limit.
62
+ - **2 — Choose a different project:** Point the tool at another local repository or source folder.
63
+ - **3 — Help and examples:** See the workflow and an example command.
64
+ - **0 — Exit:** Close the menu.
61
65
 
62
66
  In plain terms, Codebase Brief makes a small guide to a project so an AI coding assistant can get oriented before helping with a task. It does not write or fix code. It reads project information locally and prepares a guide for you to review and share.
63
67
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codebase-brief
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Local-first CLI that builds task-focused context briefs from code repositories
5
5
  Author: Mohamed Maggy
6
6
  License-Expression: MIT
@@ -53,7 +53,7 @@ The first image is a terminal-style rendering of the app's actual numbered menu.
53
53
 
54
54
  You need Python 3.10 or newer. Git is optional, but required for recent-history and base-diff details.
55
55
 
56
- The current PyPI release is `0.1.1` and includes the reviewed-file feedback summary and importer-aware `--base` selection. Install it with `pipx`:
56
+ The current PyPI release is `0.1.2` and includes the review-feedback summary, importer-aware `--base` selection, and a sample demo. Install it with `pipx`:
57
57
 
58
58
  ```powershell
59
59
  pipx install codebase-brief
@@ -62,6 +62,10 @@ brief "C:\work\my-app" --task "Trace the login flow" --copy
62
62
 
63
63
  The brief is copied to your clipboard for pasting into your assistant. Replace the example path and task with yours. To use the numbered menu, run `brief` with no arguments.
64
64
 
65
+ Want to see a real example before choosing your project? Run `brief --demo`. It uses a tiny temporary example project and does not read or change your files.
66
+
67
+ If you do not have `pipx` installed, skip the command above and use the virtual-environment steps below instead; they work with the project's minimum Python version. To install `pipx` first, follow its [official installation guide](https://pipx.pypa.io/latest/how-to/install-pipx.html). The current pipx installer requires Python 3.11 or newer, while Codebase Brief itself supports Python 3.10 and newer.
68
+
65
69
  Or use a virtual environment:
66
70
 
67
71
  ```powershell
@@ -79,10 +83,10 @@ If the `brief` command is not available, use `python -m context_inject` while th
79
83
 
80
84
  When the menu opens, it uses the folder you launched it from as the starting project. Type a number and press Enter:
81
85
 
82
- 1. **Build a context brief** — describe the coding task, optionally enter a Git base ref, then accept or change the approximate size limit.
83
- 2. **Choose a different project** — point the tool at another local repository or source folder.
84
- 3. **Help and examples** — see the workflow and an example command.
85
- 0. **Exit** — close the menu.
86
+ - **1 — Build a context brief:** Describe the coding task, optionally enter a Git base ref, then accept or change the approximate size limit.
87
+ - **2 — Choose a different project:** Point the tool at another local repository or source folder.
88
+ - **3 — Help and examples:** See the workflow and an example command.
89
+ - **0 — Exit:** Close the menu.
86
90
 
87
91
  In plain terms, Codebase Brief makes a small guide to a project so an AI coding assistant can get oriented before helping with a task. It does not write or fix code. It reads project information locally and prepares a guide for you to review and share.
88
92
 
@@ -11,6 +11,7 @@ import re
11
11
  import shutil
12
12
  import subprocess
13
13
  import sys
14
+ import tempfile
14
15
  from pathlib import Path
15
16
 
16
17
  CHARS_PER_TOKEN = 4 # rough estimate; real token counts vary by model and text
@@ -23,7 +24,7 @@ MAX_KEY_FILES = 12
23
24
  MAX_SELECTION_CHOICES = 30
24
25
  MAX_DISCOVERED_FILES = 20_000
25
26
  IMPORT_SUFFIXES = {".py", ".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".mts", ".cts"}
26
- VERSION = "0.1.1"
27
+ VERSION = "0.1.2"
27
28
  MANIFESTS = (
28
29
  "package.json", "pyproject.toml", "requirements.txt", "Cargo.toml",
29
30
  "go.mod", "Gemfile", "composer.json", "pom.xml",
@@ -943,6 +944,46 @@ def terminal_supports_color() -> bool:
943
944
  return False
944
945
 
945
946
 
947
+ DEMO_TASK = "Trace how a sign-in request is checked"
948
+ DEMO_FILES = {
949
+ "README.md": (
950
+ "# Sample Shop\n\n"
951
+ "A tiny example storefront. Its sign-in route checks a password through a small auth helper.\n"
952
+ ),
953
+ "pyproject.toml": (
954
+ "[project]\nname = 'sample-shop'\nversion = '0.1.0'\n"
955
+ "requires-python = '>=3.10'\ndependencies = []\n"
956
+ ),
957
+ "src/sample_shop/auth.py": (
958
+ "def check_password(saved_password: str, supplied_password: str) -> bool:\n"
959
+ " return saved_password == supplied_password\n"
960
+ ),
961
+ "src/sample_shop/routes.py": (
962
+ "from .auth import check_password\n\n"
963
+ "def sign_in(saved_password: str, supplied_password: str) -> str:\n"
964
+ " if check_password(saved_password, supplied_password):\n"
965
+ " return 'Welcome back'\n"
966
+ " return 'Password did not match'\n"
967
+ ),
968
+ "tests/test_auth.py": (
969
+ "from sample_shop.auth import check_password\n\n"
970
+ "def test_matching_password_is_accepted():\n"
971
+ " assert check_password('correct horse', 'correct horse')\n"
972
+ ),
973
+ }
974
+
975
+
976
+ def generate_demo_brief() -> str:
977
+ """Generate a real sample brief without reading or changing the user's project."""
978
+ with tempfile.TemporaryDirectory(prefix="codebase-brief-demo-") as temporary:
979
+ root = Path(temporary)
980
+ for relative, content in DEMO_FILES.items():
981
+ path = root / relative
982
+ path.parent.mkdir(parents=True, exist_ok=True)
983
+ path.write_text(content, encoding="utf-8")
984
+ return gather(root, DEMO_TASK, budget_tokens=1_200)
985
+
986
+
946
987
  def interactive() -> int:
947
988
  """Run the guided, numbered terminal interface."""
948
989
  repo = Path.cwd().resolve()
@@ -1036,6 +1077,7 @@ def interactive() -> int:
1036
1077
  print("\nA base ref only helps when your current Git commit differs from that ref. Matching covers static imports, literal dynamic imports, and simple TS/JS aliases; runtime-built names may be missed.")
1037
1078
  print(f"The default guide size is about {DEFAULT_BUDGET_TOKENS:,} tokens ({CHARS_PER_TOKEN} characters per token, roughly).")
1038
1079
  print("Save creates a Markdown file; copy puts the guide on your clipboard only when you choose it.")
1080
+ print("Run 'brief --demo' to see a sample brief without using your project.")
1039
1081
  print('\nExample: codebase-brief "C:\\work\\my-app" --task "Find login handling" --base main --budget 2400 --copy')
1040
1082
  input("\nPress Enter to return to the menu...")
1041
1083
  continue
@@ -1135,7 +1177,14 @@ def main(argv: list[str] | None = None) -> int:
1135
1177
  parser.add_argument("--output", help="Write Markdown to this path (default: stdout)")
1136
1178
  parser.add_argument("--copy", action="store_true", help="Copy the generated Markdown to your system clipboard")
1137
1179
  parser.add_argument("-i", "--interactive", action="store_true", help="Open the numbered interactive menu")
1180
+ parser.add_argument("--demo", action="store_true", help="Print a real sample brief without reading your project")
1138
1181
  args = parser.parse_args(argv)
1182
+ if args.demo:
1183
+ if args.interactive or args.repo_path or args.task or args.base or args.output or args.copy or args.budget != DEFAULT_BUDGET_TOKENS:
1184
+ parser.error("--demo cannot be combined with repo_path, --task, --base, --budget, --output, --copy, or --interactive")
1185
+ print("Preview from a built-in sample project. Your project folder was not read or changed.\n")
1186
+ sys.stdout.write(generate_demo_brief())
1187
+ return 0
1139
1188
  if args.interactive:
1140
1189
  if args.repo_path or args.task or args.base or args.output or args.copy or args.budget != DEFAULT_BUDGET_TOKENS:
1141
1190
  parser.error("--interactive cannot be combined with repo_path, --task, --base, --budget, --output, or --copy")
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codebase-brief"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "Local-first CLI that builds task-focused context briefs from code repositories"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -222,6 +222,26 @@ class ContextInjectTests(unittest.TestCase):
222
222
  self.assertIn("First use:", stdout.getvalue())
223
223
  self.assertIn("--budget", stdout.getvalue())
224
224
  self.assertIn("--copy", stdout.getvalue())
225
+ self.assertIn("--demo", stdout.getvalue())
226
+
227
+ def test_demo_generates_real_brief_without_reading_or_changing_current_folder(self):
228
+ output = io.StringIO()
229
+ before = set(self.root.rglob("*"))
230
+ with patch("pathlib.Path.cwd", return_value=self.root), contextlib.redirect_stdout(output):
231
+ self.assertEqual(main(["--demo"]), 0)
232
+ brief = output.getvalue()
233
+ self.assertIn("Trace how a sign-in request is checked", brief)
234
+ self.assertIn("src/sample_shop/auth.py", brief)
235
+ self.assertIn("src/sample_shop/routes.py", brief)
236
+ self.assertIn("check_password", brief)
237
+ self.assertEqual(set(self.root.rglob("*")), before)
238
+
239
+ def test_demo_rejects_combined_project_arguments(self):
240
+ stderr = io.StringIO()
241
+ with contextlib.redirect_stderr(stderr), self.assertRaises(SystemExit) as error:
242
+ main([str(self.root), "--demo"])
243
+ self.assertEqual(error.exception.code, 2)
244
+ self.assertIn("--demo cannot be combined", stderr.getvalue())
225
245
 
226
246
  def test_cli_copy_generates_a_brief_and_calls_clipboard(self):
227
247
  self.put("README.md", "# Clipboard fixture")
@@ -466,7 +486,7 @@ class ContextInjectTests(unittest.TestCase):
466
486
  plain = __import__("re").sub(r"\x1b\[[0-9;]*m", "", output.getvalue())
467
487
  self.assertIn("CODEBASE", plain)
468
488
  self.assertIn("BRIEF", plain)
469
- self.assertIn("v0.1.1", plain)
489
+ self.assertIn("v0.1.2", plain)
470
490
  self.assertIn("Meet Briefy - your repo guide", plain)
471
491
  self.assertIn("WHAT THIS DOES", plain)
472
492
  self.assertIn("Makes a short guide to your project for an AI coding assistant", plain)
File without changes
File without changes