Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -4,7 +4,7 @@ usage: reading-cost [--reset] [record]
|
||||
|
||||
Run it inside a project checkout or one of its worktrees. record defaults to the
|
||||
docs/reading-cost.md the project's config names, created when missing. It reads build-release's archive of the project,
|
||||
$BUILD_RELEASE_TRANSCRIPTS/<key> (default ~/.claude/loop-claude-transcripts), <key> being the
|
||||
$BUILD_RELEASE_TRANSCRIPTS/<key> (default ~/.local/state/build-release/transcripts), <key> being the
|
||||
checkout's path relative to ~/code, or to / outside it. For each finished chunk the record does not
|
||||
yet hold, it measures what the worker and its subagents read before the worker's first commit: their
|
||||
new input tokens (uncached and cache-written; cache reads excluded), and how often they opened or
|
||||
|
||||
@@ -161,7 +161,7 @@ class ReadingCostTool(unittest.TestCase):
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=cwd, env=self.env, text=True)
|
||||
|
||||
def test_writes_the_record_where_the_config_puts_it_and_fails_without_a_config(self):
|
||||
config = self.home / ".claude-projects" / "proj" / "config.toml"
|
||||
config = self.home / ".config/build-release" / "proj" / "config.toml"
|
||||
config.write_text(config.read_text().replace('"checkout:docs/reading-cost.md"', '"folder:docs/reading-cost.md"'))
|
||||
record = config.parent / "docs" / "reading-cost.md"
|
||||
record.parent.mkdir()
|
||||
@@ -194,17 +194,17 @@ class ReadingCostTool(unittest.TestCase):
|
||||
ran = self.run_tool(worktree)
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
history = worktree / "docs" / "reading-cost.md"
|
||||
self.assertEqual(ran.stdout, f"Appended 2 reading-cost figures from {self.home / '.claude' / 'loop-claude-transcripts' / 'proj'} to {history}.\n2 chunks measured since the last reset; the trend needs 10.\n")
|
||||
self.assertEqual(ran.stdout, f"Appended 2 reading-cost figures from {self.home / '.local/state/build-release' / 'transcripts' / 'proj'} to {history}.\n2 chunks measured since the last reset; the trend needs 10.\n")
|
||||
figure = "## Reading cost, chunk {}, finished {}\n\n33 new input tokens before the first commit.\n\nRead most (opens and searches):\n\n- `a.py` 1\n"
|
||||
self.assertEqual(history.read_text(), "# Reading cost\n\n" + "\n".join(figure.format(chunk.folder[:12], chunk.finished) for chunk in chunks))
|
||||
self.assertTrue(self.run_tool(worktree).stdout.startswith(f"Appended 0 reading-cost figures from"))
|
||||
self.assertEqual(history.read_text().count("## Reading cost"), 2)
|
||||
reset = self.run_tool(worktree, "--reset")
|
||||
self.assertEqual(reset.stdout, f"Appended 0 reading-cost figures from {self.home / '.claude' / 'loop-claude-transcripts' / 'proj'} and a reset to {history}.\n0 chunks measured since the last reset; the trend needs 10.\n")
|
||||
self.assertEqual(reset.stdout, f"Appended 0 reading-cost figures from {self.home / '.local/state/build-release' / 'transcripts' / 'proj'} and a reset to {history}.\n0 chunks measured since the last reset; the trend needs 10.\n")
|
||||
self.assertRegex(history.read_text(), r"\n## Reading cost reset, \d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\n$")
|
||||
|
||||
def test_counts_a_file_read_in_a_worktree_the_configs_branch_template_names(self):
|
||||
config = self.home / ".claude-projects" / "proj" / "config.toml"
|
||||
config = self.home / ".config/build-release" / "proj" / "config.toml"
|
||||
config.write_text(config.read_text() + 'branch = "feature/PAY-{id}"\n')
|
||||
self.archive_chunk(1790000100, worktree=self.home / "code" / "proj-feature-PAY-7")
|
||||
ran = self.run_tool(self.checkout)
|
||||
|
||||
Reference in New Issue
Block a user