tracehub 0.5.6 → 0.5.7

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.
package/README.md CHANGED
@@ -78,7 +78,7 @@ Everything is computed on the developer's machine, redacted there, checked again
78
78
  Set it up once with `setup` (the other commands are under [Commands](#commands)). Run it in your terminal:
79
79
 
80
80
  ```sh
81
- npx --yes tracehub@0.5.6 setup
81
+ npx --yes tracehub@0.5.7 setup
82
82
  ```
83
83
 
84
84
  Setup is a form of three steps. Each step saves what you chose before the next one starts; cancelling (Ctrl-C) keeps the steps already done.
@@ -89,7 +89,7 @@ Setup is a form of three steps. Each step saves what you chose before the next o
89
89
 
90
90
  It ends with a summary of the account, the allowed rules and the hooks, and what is left to do. Setup needs an interactive terminal; without one it exits 1.
91
91
 
92
- To skip npx on every commit, install it globally instead: `npm install -g tracehub@0.5.6`, then `tracehub setup`.
92
+ To skip npx on every commit, install it globally instead: `npm install -g tracehub@0.5.7`, then `tracehub setup`.
93
93
 
94
94
  ### Git hooks
95
95
 
@@ -110,7 +110,7 @@ Setup installs global Git hooks: it points the global `core.hooksPath` at `~/.co
110
110
  ### Uninstall
111
111
 
112
112
  ```sh
113
- npx --yes tracehub@0.5.6 uninstall
113
+ npx --yes tracehub@0.5.7 uninstall
114
114
  ```
115
115
 
116
116
  Lists what it removes and asks first (default no); with nothing set up it says so and asks nothing. Then it removes the global Git hooks and restores your previous global `core.hooksPath` setting, deletes the permission rules (`consent.json`) and signs you out (`auth.json`). It asks before deleting the deny list and the current repository's `.git/tracehub` (its markers, including ones not uploaded yet). Other repositories keep their `.git/tracehub`; delete it by hand if you want. Before signing out it asks TraceHub to forget this machine's rules (see [Consent registry](#consent-registry)); when TraceHub can't be reached it says that TraceHub still lists them, and goes on. If the global hooks setting was changed by another tool since setup, uninstall leaves the hooks alone, still removes the rest, and exits 1.
@@ -436,7 +436,7 @@ Do not try it with the session you are working in: what is uploaded stays in the
436
436
 
437
437
  ```sh
438
438
  gh repo create assistant-ui/tracehub-playground --private --clone && cd tracehub-playground
439
- npx --yes tracehub@0.5.6 setup # allow this repository, install the hooks
439
+ npx --yes tracehub@0.5.7 setup # allow this repository, install the hooks
440
440
 
441
441
  # open a fresh agent session in this directory, ask it for something harmless
442
442
  export TRACEHUB_ID=claude:<throwaway session id>
@@ -1,7 +1,7 @@
1
1
  import { execFileSync, spawnSync } from "node:child_process";
2
2
  import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync, } from "node:fs";
3
3
  import { basename, dirname, join, resolve } from "node:path";
4
- import { hookBlock, hookRunner, hookVersion, legacyHookBlock, sameRunner, } from "./hooks.js";
4
+ import { hookBlock, hookRunner, hookVersion, legacyHookBlock, repoNpxHookBlock, sameRunner, } from "./hooks.js";
5
5
  const HOOKS = [
6
6
  "applypatch-msg",
7
7
  "pre-applypatch",
@@ -61,15 +61,22 @@ function globalPath(cwd, env, expand = false) {
61
61
  throw new Error("Multiple global core.hooksPath values require manual setup.");
62
62
  return paths[0];
63
63
  }
64
- function source(hook, manifest) {
64
+ // The tracehub blocks a hook of this manifest may hold, the one this
65
+ // release writes first.
66
+ function blocks(hook, manifest) {
67
+ if (hook !== "prepare-commit-msg" && hook !== "pre-push")
68
+ return [""];
69
+ const version = manifest.cliVersion;
70
+ if (manifest.runner === undefined)
71
+ return [legacyHookBlock(hook, version)];
72
+ if (manifest.runner === null)
73
+ return [hookBlock(hook, version, null), repoNpxHookBlock(hook, version)];
74
+ return [hookBlock(hook, version, manifest.runner)];
75
+ }
76
+ function source(hook, manifest, block = blocks(hook, manifest)[0]) {
65
77
  const delegated = manifest.delegate === null
66
78
  ? 'tracehub_hooks="$(git rev-parse --path-format=absolute --git-common-dir)/hooks"'
67
79
  : `tracehub_hooks=${quote(manifest.delegate)}`;
68
- const block = hook === "prepare-commit-msg" || hook === "pre-push"
69
- ? manifest.runner === undefined
70
- ? legacyHookBlock(hook, manifest.cliVersion)
71
- : hookBlock(hook, manifest.cliVersion, manifest.runner)
72
- : "";
73
80
  // An installed push-to-checkout hook replaces Git's built-in updateInstead behavior.
74
81
  const fallback = hook === "push-to-checkout"
75
82
  ? 'cd "$GIT_WORK_TREE" || exit 1\ngit update-index -q --ignore-submodules --refresh || exit 1\ngit diff-files --quiet --ignore-submodules -- || exit 1\ngit diff --cached --quiet --ignore-submodules -- || exit 1\nexec git read-tree -u -m "$1"\n'
@@ -121,7 +128,7 @@ function verifyFiles(directory, manifest) {
121
128
  !lstatSync(path).isFile() ||
122
129
  lstatSync(path).isSymbolicLink() ||
123
130
  (lstatSync(path).mode & 0o777) !== 0o755 ||
124
- readFileSync(path, "utf8") !== source(hook, manifest))
131
+ !blocks(hook, manifest).some((block) => readFileSync(path, "utf8") === source(hook, manifest, block)))
125
132
  throw new Error(`Global dispatcher changed; preserve it and repair manually: ${path}`);
126
133
  }
127
134
  }
package/dist/git/hooks.js CHANGED
@@ -51,9 +51,17 @@ function invocation(hook, version, runner, stdin) {
51
51
  export function hookBlock(hook, version = hookVersion(), runner = hookRunner()) {
52
52
  if (!VERSION.test(version))
53
53
  throw new Error("Invalid tracehub hook version.");
54
+ return wrap(hook, (stdin) => invocation(hook, version, runner, stdin));
55
+ }
56
+ // The npx block of releases that ran npx inside the repository: recognized
57
+ // so the next setup can rewrite it.
58
+ export function repoNpxHookBlock(hook, version) {
59
+ return wrap(hook, (stdin) => `npx --yes --prefer-offline tracehub@${version} hook ${hook} "$@" ${stdin} || ${warning(`the ${hook} hook could not run tracehub@${version}; run "tracehub setup" to repair the hooks`)}`);
60
+ }
61
+ function wrap(hook, invoke) {
54
62
  const body = hook === "pre-push"
55
- ? `if tracehub_input=$(mktemp); then\n if cat > "$tracehub_input"; then\n${indent(invocation(hook, version, runner, '< "$tracehub_input"'), 4)}\n else\n printf '%s\\n' 'tracehub: unable to preserve push input; trace upload skipped' >&2\n fi\n exec < "$tracehub_input"\n rm -f "$tracehub_input"\nelse\n printf '%s\\n' 'tracehub: unable to preserve push input; trace upload skipped' >&2\nfi`
56
- : invocation(hook, version, runner, "</dev/null");
63
+ ? `if tracehub_input=$(mktemp); then\n if cat > "$tracehub_input"; then\n${indent(invoke('< "$tracehub_input"'), 4)}\n else\n printf '%s\\n' 'tracehub: unable to preserve push input; trace upload skipped' >&2\n fi\n exec < "$tracehub_input"\n rm -f "$tracehub_input"\nelse\n printf '%s\\n' 'tracehub: unable to preserve push input; trace upload skipped' >&2\nfi`
64
+ : invoke("</dev/null");
57
65
  return `${START}\n${body}\n${END}\n`;
58
66
  }
59
67
  const indent = (text, n) => text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tracehub",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Attach coding-agent sessions (Claude Code, Codex, OpenCode) to git commits and pull requests, redacted.",
5
5
  "type": "module",
6
6
  "license": "MIT",