Skip to content

Experience-Driven Black-Box Cost Control for Coding Agents

Merge main into windows-integration

Aarona712de4e7509
diff --cc plugin/scripts/te_bootstrap.py
index 1ebd83b,7986a9e..02c2302
--- a/plugin/scripts/te_bootstrap.py
+++ b/plugin/scripts/te_bootstrap.py
@@@ -41,21 -41,8 +41,21 @@@ def _marketplace_sources(plugin_root)
return []
home, market = os.sep.join(parts[:-5]), parts[-3]
out = [os.path.join(home, ".tmp", "marketplaces", market)]
+ # Claude Code keeps the same cache layout under `~/.claude/plugins/cache/`; on a checkout
+ # without symlinks (Windows) the copy has no `lib`, so the package is found in the clone
+ # its `known_marketplaces.json` records for this marketplace.
+ try:
+ import json
+ known = json.load(open(os.path.join(home, "plugins", "known_marketplaces.json")))
+ entry = known.get(market) or {}
+ source = entry.get("source") or {}
+ for cand in (source.get("path"), entry.get("installLocation")):
+ if cand:
+ out.append(cand)
+ except (IOError, OSError, ValueError, AttributeError):
+ pass
try:
- text = open(os.path.join(home, "config.toml")).read()
+ text = open(os.path.join(home, "config.toml"), encoding="utf-8", errors="replace").read()
except (IOError, OSError):
return out
section = None
diff --cc tokeneconomizer/plugin/context.py
index 0b09a41,a391b70..85865d3
--- a/tokeneconomizer/plugin/context.py
+++ b/tokeneconomizer/plugin/context.py
@@@ -82,10 -84,7 +84,10 @@@ class LiveContext
cmd = [sys.executable, "-m", "tokeneconomizer.plugin.cli", *argv,
"--host", self.host.name, "--cwd", self.repo.root]
self.store.ensure()
+ if os.name == "nt":
+ from . import winspawn
+ return winspawn.spawn(cmd, self.repo.root, env, self.store.path(log_name))
- log = open(self.store.path(log_name), "a")
+ log = open(self.store.path(log_name), "a", encoding="utf-8")
try:
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=log, stderr=log,
cwd=self.repo.root, env=env, start_new_session=True)
diff --cc tokeneconomizer/plugin/store.py
index 7389d75,4d02002..72b172d
--- a/tokeneconomizer/plugin/store.py
+++ b/tokeneconomizer/plugin/store.py
@@@ -101,10 -78,10 +101,10 @@@ class Store
`timeout` seconds -- a hook must never hang the agent, and a hook's caller proceeds
either way. A caller that must not run unlocked (the fold) checks the yielded flag."""
os.makedirs(self.base, exist_ok=True)
- if fcntl is None:
+ if fcntl is None and msvcrt is None:
yield True
return
- fh = open(self.path(f".{name}.lock"), "a+")
+ fh = open(self.path(f".{name}.lock"), "a+", encoding="utf-8")
got = False
deadline = time.time() + timeout
try: