estimetry 0.1.1 → 0.1.2

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/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to estimetry. Versions follow [semantic versioning](https://
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.1.2 — 2026-11-12
8
+
9
+ - The hooks `init` writes run the installation of estimetry that ran it, by the paths of its Node.js and entry point, and fall back to `estimetry` on `PATH`. A version manager (asdf, nvm) that picks another Node.js for a project, or one without estimetry, no longer stops the Claude Code hooks or the `post-commit` hook. Settings and hooks the project commits keep the plain `estimetry hook …`. Run `emt upgrade` once to rewrite the hooks.
10
+
7
11
  ## 0.1.1 — 2026-11-12
8
12
 
9
13
  - The npm page shows the English README: the Russian one is now `README-ru.md`, which npm does not pack.
package/README.md CHANGED
@@ -18,7 +18,7 @@ npm install -g estimetry
18
18
  emt --version
19
19
  ```
20
20
 
21
- Install it globally: the hooks of Claude Code call `estimetry` from `PATH`.
21
+ Install it globally. The hooks `init` writes run this installation by its paths, so neither a version manager (asdf, nvm) that picks another Node.js for a project nor a program without your shell's `PATH` stops them.
22
22
 
23
23
  To update later: `npm install -g estimetry@latest`, then `emt upgrade` once (see [After upgrading estimetry](#after-upgrading-estimetry)).
24
24
 
@@ -61,13 +61,13 @@ In a terminal it asks a few questions:
61
61
 
62
62
  | What | Where | Who gets it |
63
63
  |---|---|---|
64
- | Hooks for 12 Claude Code events, each running `estimetry hook claude-code <event>` | `.claude/settings.local.json` | you |
64
+ | Hooks for 12 Claude Code events, each running this installation (`<node> <estimetry> hook claude-code <event>`, else `estimetry hook claude-code <event>` from `PATH`) | `.claude/settings.local.json` | you |
65
65
  | Skills `estimetry`, `emt-estimate`, `emt-start`, `emt-extra`, `emt-parallel`, `emt-manual`, `emt-close`, `emt-retro` (also the `/emt-…` commands) | `~/.claude/skills/` (or `$CLAUDE_CONFIG_DIR/skills/`) | you, in every project |
66
66
  | Project id and development process | `.estimetry/config.yaml` | the team; commit it so clones of the repository are one project |
67
67
 
68
68
  With `--shared-hooks` the hooks go to `.claude/settings.json` and the skills to `.claude/skills/` of the project. A reminder to run `/emt-estimate` before naming a deadline is added to `CLAUDE.md`, between `<!-- estimetry:start -->` and `<!-- estimetry:end -->`. These are files the project commits, so the whole team gets them.
69
69
 
70
- With `--track-commits` a `post-commit` hook is installed into the repository's hooks directory. This respects `core.hooksPath`, worktrees and husky (`.husky/post-commit`). An existing hook keeps its content: estimetry adds its own block between `# >>> estimetry >>>` and `# <<< estimetry <<<`. The hook runs estimetry in the background, so commits never wait for it. Colleagues without estimetry see nothing. A commit from a program that does not get your shell's `PATH` (an IDE started from the Dock on macOS) is recorded too: a personal hook (in `.git`, or a hooks directory outside the repository) falls back to the Node.js, estimetry and data directory `init` ran with. After switching Node.js versions, run `emt upgrade` so it points to the new ones. A hook the project commits (husky, `core.hooksPath` inside the repository) holds no paths of your machine and needs `estimetry` on `PATH`.
70
+ With `--track-commits` a `post-commit` hook is installed into the repository's hooks directory. This respects `core.hooksPath`, worktrees and husky (`.husky/post-commit`). An existing hook keeps its content: estimetry adds its own block between `# >>> estimetry >>>` and `# <<< estimetry <<<`. The hook runs estimetry in the background, so commits never wait for it. Colleagues without estimetry see nothing. A personal hook (in `.git`, or a hooks directory outside the repository) runs this installation by its paths, like the Claude Code hooks, so a commit from an IDE started from the Dock is recorded too. A hook the project commits (husky, `core.hooksPath` inside the repository) holds no paths of your machine and needs `estimetry` on `PATH`.
71
71
 
72
72
  No task data ever goes into the repository. Tasks, estimates and the event journal live in `~/.local/share/estimetry/`, or in `ESTIMETRY_HOME` if set.
73
73
 
@@ -89,9 +89,9 @@ A repeated run keeps what is installed: once the git hook or the shared install
89
89
  ### Good to know
90
90
 
91
91
  - **Your edits to generated skills are kept.** Every generated skill carries `metadata.generatedBy` and a hash of its content. If you edit one, init keeps your version and reports it as `skipped`; `--force` overwrites it. A file of the same name that estimetry did not create is never touched.
92
- - **A rewritten hook is yours.** estimetry recognises its hooks by the command prefix `estimetry hook claude-code`. If you change that command, init treats the hook as yours and adds its own next to it.
92
+ - **A rewritten hook is yours.** estimetry recognises its hooks by the command it writes: the paths of the installation that fall back to `estimetry hook claude-code`, or that prefix alone. If you change that command, init treats the hook as yours and adds its own next to it.
93
93
  - **`settings.local.json` may not be ignored by git.** Claude Code adds `**/.claude/settings.local.json` to your global git excludes only when it writes that file itself. If init creates it and git does not ignore it, init offers to add the same line. With `--no-interactive` it only warns.
94
- - **Hooks need `estimetry` on `PATH`.** When run through `npx`, the hooks will not find it, and init warns about that.
94
+ - **Hooks run the installation that ran `init`.** `npm install -g` under the same Node.js replaces it in place. After installing estimetry under another Node.js, or removing the one that ran `init`, run `emt upgrade`: until then the hooks run the old installation or fall back to `estimetry` on `PATH`. Run through `npx`, or on Windows, init writes no paths, and the hooks need `estimetry` on `PATH`. The hooks also keep the data directory of that `init` unless `ESTIMETRY_HOME` is set where they run: an `init` with a temporary `ESTIMETRY_HOME` sends the hooks of the project there too.
95
95
 
96
96
  ## Estimating a task
97
97
 
@@ -307,7 +307,7 @@ The journal keeps when things happened, not what was said or done: no prompt tex
307
307
 
308
308
  Run `emt upgrade` once, from any directory. It sets estimetry up again in every working copy of every registered project on this machine (worktrees included), each with the choices it already has: tools, flow, a personal or shared install, the commit hook. It shows what will change and asks first; without a terminal it needs `--yes`. A copy where estimetry was never set up is skipped, and so is one that is not on this machine. With a shared install the plan warns that the files it changes are committed by the project. To update a single project instead, run `emt init` inside it.
309
309
 
310
- Until then the hooks keep working: they run the new `estimetry` from `PATH`; only what `init` wrote is old — the hook settings in each project, the skills and, with a shared install, the reminder in `CLAUDE.md`. At the start of a session in a project set up by an older version, the agent is told to suggest `emt upgrade`; it never runs it on its own.
310
+ Until then the hooks keep working: an update under the same Node.js replaces the installation they run; only what `init` wrote is old — the hook settings in each project, the skills and, with a shared install, the reminder in `CLAUDE.md`. At the start of a session in a project set up by an older version, the agent is told to suggest `emt upgrade`; it never runs it on its own.
311
311
 
312
312
  Update every installed copy of estimetry at once. Cards written by an older version are rebuilt from the journals on the next closing, `emt task show` or `emt rebuild`. A newer card stops an older estimetry from rewriting `calibration.json` and is reported instead; versions before this check skip such cards silently, so close no task with them.
313
313
 
@@ -0,0 +1,34 @@
1
+ /** The first word of a command with the paths of an installation. */
2
+ const RUNNER_MARKER = 'estimetry_home=';
3
+ /**
4
+ * A POSIX shell command that runs `estimetry <args>` (estimetry-command, one
5
+ * rule for every hook): this installation by its paths while they exist, else
6
+ * `estimetry` from PATH. ESTIMETRY_HOME set by the user wins over the one of `init`.
7
+ */
8
+ export function estimetryCommand(runner, args) {
9
+ const fromPath = `estimetry ${args}`;
10
+ if (runner === undefined) {
11
+ return fromPath;
12
+ }
13
+ const node = quoted(runner.node);
14
+ const main = quoted(runner.main);
15
+ return (`${RUNNER_MARKER}${quoted(runner.home)}; ` +
16
+ `if [ -x ${node} ] && [ -f ${main} ]; then ESTIMETRY_HOME="\${ESTIMETRY_HOME:-$estimetry_home}" ${node} ${main} ${args}; ` +
17
+ `else ${fromPath}; fi`);
18
+ }
19
+ /**
20
+ * Whether a command is one `estimetryCommand` writes for these arguments, in
21
+ * either form, or a command of an older version (`estimetry <args> …`): hooks
22
+ * are recognised on reinstall by the same rule that writes them.
23
+ */
24
+ export function isEstimetryCommand(command, argsPrefix) {
25
+ const fromPath = `estimetry ${argsPrefix}`;
26
+ const plain = command === fromPath || command.startsWith(`${fromPath} `);
27
+ const withPaths = command.startsWith(RUNNER_MARKER) && command.includes(`; else ${fromPath} `) && command.endsWith('; fi');
28
+ return plain || withPaths;
29
+ }
30
+ /** A path for a POSIX shell in single quotes: spaces and quotes in it stay one word. */
31
+ function quoted(path) {
32
+ return `'${path.replaceAll("'", `'\\''`)}'`;
33
+ }
34
+ //# sourceMappingURL=estimetry-command.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=estimetry-runner.js.map
@@ -63,7 +63,8 @@ export class InitProject {
63
63
  if (this.deps.sharing.mode() !== share) {
64
64
  this.deps.sharing.save(share);
65
65
  }
66
- if (!this.deps.commands.has(HOOK_COMMAND)) {
66
+ // Personal hooks run this installation by its paths; shared ones, and all without paths (npx, Windows), need PATH.
67
+ if ((shared || this.deps.installation.runner === undefined) && !this.deps.commands.has(HOOK_COMMAND)) {
67
68
  warnings.push(`${HOOK_COMMAND} is not on PATH, so the hooks will not run until the package is installed globally (npm install -g estimetry)`);
68
69
  }
69
70
  return {
@@ -16,9 +16,11 @@ export class InstallCopy {
16
16
  }
17
17
  plan(choices) {
18
18
  const { root } = choices;
19
+ const { version, runner } = this.deps.installation;
20
+ const context = { projectRoot: root, files: this.deps.files, shared: choices.shared, force: choices.force, version };
19
21
  const plan = mergePlans([
20
- ...choices.tools.map((tool) => tool.plan({ projectRoot: root, files: this.deps.files, shared: choices.shared, force: choices.force, version: this.deps.version })),
21
- this.deps.git.commitHook.plan(root, choices.trackCommits),
22
+ ...choices.tools.map((tool) => tool.plan(runner === undefined ? context : { ...context, runner })),
23
+ this.deps.git.commitHook.plan(root, choices.trackCommits, runner),
22
24
  { changes: [this.projectConfig.plan(root, { project: choices.project, flow: choices.flow.id })], skipped: [], warnings: [] },
23
25
  choices.shared ? EMPTY_PLAN : this.excludePersonalFiles(root, choices.tools, choices.excludePersonalFiles),
24
26
  ]);
@@ -51,7 +53,7 @@ export class InstallCopy {
51
53
  this.deps.files.write(change.path, change.content, change.executable ? { executable: true } : {});
52
54
  }
53
55
  }
54
- this.versions.record(plan.root, this.deps.version);
56
+ this.versions.record(plan.root, this.deps.installation.version);
55
57
  }
56
58
  statusOf(change) {
57
59
  const current = this.deps.files.read(change.path);
@@ -45,7 +45,7 @@ export class UpgradePlanner {
45
45
  copies.push({ ...result, files, warnings });
46
46
  }
47
47
  }
48
- return { version: this.deps.version, copies, skipped };
48
+ return { version: this.deps.installation.version, copies, skipped };
49
49
  }
50
50
  copy(project, root) {
51
51
  const id = project.id.value;
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { homedir, userInfo } from 'node:os';
4
- import { dirname, join, sep } from 'node:path';
4
+ import { basename, dirname, join, sep } from 'node:path';
5
5
  import { StorageLayout } from '../infrastructure/fs/storage-layout.js';
6
6
  import { FileErrorReporter } from '../infrastructure/system/file-error-reporter.js';
7
7
  export function processEnvironment() {
@@ -10,20 +10,23 @@ export function processEnvironment() {
10
10
  import { packageVersion } from './package-version.js';
11
11
  export { packageVersion };
12
12
  /**
13
- * How this installation is started, for a commit hook run without the user's
14
- * PATH: the entry point beside this file, the node of its install prefix (a
13
+ * How hooks start this installation (estimetry-command): the entry point beside
14
+ * this file, the node of its npm prefix when it is a global npm install (a
15
15
  * stable link such as Homebrew's `/opt/homebrew/bin/node`, which survives an
16
- * upgrade of Node.js) or else the running one, and the data directory. None
17
- * from the cache of `npx`, which is cleared.
16
+ * upgrade of Node.js), else the running node, and the data directory. None on
17
+ * Windows, where Claude Code may run hooks without a POSIX shell, and none from
18
+ * the cache of `npx`, which is cleared: hooks then call `estimetry` from PATH.
18
19
  */
19
20
  function estimetryRunner(layout) {
20
21
  const main = fileURLToPath(new URL('./main.js', import.meta.url));
21
- if (main.includes(`${sep}_npx${sep}`)) {
22
+ if (process.platform === 'win32' || main.includes(`${sep}_npx${sep}`)) {
22
23
  return undefined;
23
24
  }
24
- // <prefix>/lib/node_modules/estimetry/dist/bootstrap/main.js → <prefix>/bin/node
25
- const prefixed = join(dirname(main), '..', '..', '..', '..', '..', 'bin', 'node');
26
- return { node: existsSync(prefixed) ? prefixed : process.execPath, main, home: layout.root };
25
+ // <prefix>/lib/node_modules/estimetry/dist/bootstrap/main.js → <prefix>/bin/node, only for that layout.
26
+ const pkg = dirname(dirname(dirname(main)));
27
+ const globalNpm = basename(pkg) === 'estimetry' && basename(dirname(pkg)) === 'node_modules' && basename(dirname(dirname(pkg))) === 'lib';
28
+ const prefixed = join(dirname(dirname(dirname(pkg))), 'bin', 'node');
29
+ return { node: globalNpm && existsSync(prefixed) ? prefixed : process.execPath, main, home: layout.root };
27
30
  }
28
31
  /** Claude Code keeps personal skills in `$CLAUDE_CONFIG_DIR`, else `~/.claude`. */
29
32
  function claudeConfigDir(environment) {
@@ -71,6 +74,7 @@ async function installDependencies(environment, sharing, layout) {
71
74
  import('../infrastructure/git/git-excludes-file.js'),
72
75
  import('../infrastructure/system/path-command-locator.js'),
73
76
  ]);
77
+ const runner = estimetryRunner(layout);
74
78
  return {
75
79
  files: new NodeProjectFiles(),
76
80
  registries: {
@@ -80,12 +84,12 @@ async function installDependencies(environment, sharing, layout) {
80
84
  detectors: [nodeDetector, dartDetector, mavenDetector, gradleDetector, pythonDetector, goDetector, composeDetector].reduce((registry, detector) => registry.register(detector), new StackDetectorRegistry()),
81
85
  },
82
86
  git: {
83
- commitHook: new GitCommitHookInstaller(estimetryRunner(layout)),
87
+ commitHook: new GitCommitHookInstaller(),
84
88
  excludes: new GitExcludesFile(environment.env, environment.homeDir),
85
89
  },
86
90
  sharing,
87
91
  commands: new PathCommandLocator(environment.env),
88
- version: packageVersion(),
92
+ installation: { version: packageVersion(), ...(runner === undefined ? {} : { runner }) },
89
93
  };
90
94
  }
91
95
  async function buildApp(layout, environment, errors) {
@@ -2,6 +2,7 @@ import { execFileSync } from 'node:child_process';
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { isAbsolute, join, normalize, relative, sep } from 'node:path';
4
4
  import { realPathAhead } from '../fs/worktree.js';
5
+ import { estimetryCommand } from '../../application/contracts/estimetry-command.js';
5
6
  export const BLOCK_START = '# >>> estimetry >>>';
6
7
  export const BLOCK_END = '# <<< estimetry <<<';
7
8
  /**
@@ -11,15 +12,15 @@ export const BLOCK_END = '# <<< estimetry <<<';
11
12
  */
12
13
  export const BLOCK_COMMAND = 'if command -v estimetry >/dev/null 2>&1; then estimetry_sha=$(git rev-parse HEAD 2>/dev/null); printf \'%s\' "$estimetry_sha" | estimetry hook git post-commit >/dev/null 2>&1 & fi';
13
14
  /**
14
- * The personal hook also runs when the commit comes from a program without the
15
- * user's PATH (an IDE started from the Dock on macOS): `estimetry` from PATH
16
- * first, so a terminal always gets the current one, else node and the entry
17
- * point `init` ran with. A hook the project commits never holds them: they are paths of this machine.
15
+ * The personal hook runs this installation by its paths first, so neither the
16
+ * node a version manager picks for the project nor a program without the
17
+ * user's PATH (an IDE started from the Dock) stops it; else `estimetry` from
18
+ * PATH. A hook the project commits never holds the paths: they are this machine's.
18
19
  */
19
- const FALLBACK_COMMAND = 'estimetry_sha=$(git rev-parse HEAD 2>/dev/null); ' +
20
- 'if command -v estimetry >/dev/null 2>&1; then printf \'%s\' "$estimetry_sha" | estimetry hook git post-commit >/dev/null 2>&1 & ' +
21
- 'elif [ -x "$estimetry_node" ] && [ -f "$estimetry_main" ]; then ' +
22
- 'printf \'%s\' "$estimetry_sha" | ESTIMETRY_HOME="$estimetry_home" "$estimetry_node" "$estimetry_main" hook git post-commit >/dev/null 2>&1 & fi';
20
+ function personalCommand(runner) {
21
+ return ('estimetry_sha=$(git rev-parse HEAD 2>/dev/null); ' +
22
+ `printf '%s' "$estimetry_sha" | { ${estimetryCommand(runner, 'hook git post-commit')}; } >/dev/null 2>&1 &`);
23
+ }
23
24
  const HUSKY_LOADER = '. "$(dirname "$0")/_/husky.sh"';
24
25
  const SHELLS = /^#!.*\b(sh|bash|zsh|dash|ksh)\b/;
25
26
  const MANAGERS = [
@@ -29,24 +30,20 @@ const MANAGERS = [
29
30
  ];
30
31
  /** `post-commit` next to the hooks the repository already has: `core.hooksPath`, worktrees and husky. */
31
32
  export class GitCommitHookInstaller {
32
- runner;
33
- constructor(runner) {
34
- this.runner = runner;
35
- }
36
33
  installed(projectRoot) {
37
34
  const layout = this.layout(projectRoot);
38
35
  return layout !== undefined && (read(layout.path) ?? '').includes(BLOCK_START);
39
36
  }
40
- plan(projectRoot, enabled) {
37
+ plan(projectRoot, enabled, runner) {
41
38
  const layout = this.layout(projectRoot);
42
39
  if (layout === undefined) {
43
40
  return enabled ? { changes: [], skipped: [], warnings: ['not a git repository, so --track-commits was skipped'] } : EMPTY;
44
41
  }
45
42
  const current = read(layout.path);
46
- return enabled ? this.install(layout, current) : this.uninstall(layout, current);
43
+ return enabled ? this.install(layout, current, runner) : this.uninstall(layout, current);
47
44
  }
48
- install(layout, current) {
49
- const block = this.block(layout);
45
+ install(layout, current, runner) {
46
+ const block = blockFor(layout, runner);
50
47
  const warnings = [];
51
48
  if (layout.husky !== undefined) {
52
49
  warnings.push(`${layout.shown} is part of the repository: the hook runs for colleagues who have estimetry installed`);
@@ -73,15 +70,6 @@ export class GitCommitHookInstaller {
73
70
  }
74
71
  return { changes: [{ path: layout.path, content: withBlock(lines, block), executable: true }], skipped: [], warnings };
75
72
  }
76
- /** The lines between the markers: with the paths of this installation only in a personal hook. */
77
- block(layout) {
78
- if (!layout.personal || this.runner === undefined) {
79
- return [BLOCK_START, BLOCK_COMMAND, BLOCK_END];
80
- }
81
- const { node, main, home } = this.runner;
82
- const paths = `estimetry_node=${quoted(node)}; estimetry_main=${quoted(main)}; estimetry_home=${quoted(home)}`;
83
- return [BLOCK_START, paths, FALLBACK_COMMAND, BLOCK_END];
84
- }
85
73
  uninstall(layout, current) {
86
74
  if (current === undefined || !current.includes(BLOCK_START)) {
87
75
  return EMPTY;
@@ -124,9 +112,9 @@ function located(projectRoot, path, husky) {
124
112
  const personal = husky === undefined && (outside || inside.split(sep)[0] === '.git');
125
113
  return husky === undefined ? { path, shown, personal } : { path, shown, personal, husky };
126
114
  }
127
- /** A path for a POSIX shell in single quotes: spaces and quotes in it stay one word. */
128
- function quoted(path) {
129
- return `'${path.replaceAll("'", `'\\''`)}'`;
115
+ /** The lines between the markers: with the paths of this installation only in a personal hook. */
116
+ function blockFor(layout, runner) {
117
+ return [BLOCK_START, layout.personal && runner !== undefined ? personalCommand(runner) : BLOCK_COMMAND, BLOCK_END];
130
118
  }
131
119
  /** The block right after the shebang (and the husky loader), so an `exit` at the end cannot skip it. */
132
120
  function withBlock(lines, block) {
@@ -1,6 +1,7 @@
1
1
  import { join } from 'node:path';
2
2
  import { COMMANDS, ESTIMETRY_SKILL } from '../content/commands.js';
3
3
  import { withBlock, withoutBlock } from './claude-md.js';
4
+ import { estimetryCommand } from '../../../application/contracts/estimetry-command.js';
4
5
  import { hasOurHooks, isBrokenJson, withHooks, withoutHooks } from './hook-settings.js';
5
6
  import { CLAUDE_CODE_HOOK_EVENTS, SYNCHRONOUS_HOOK_EVENTS } from './hook-events.js';
6
7
  import { ownership, renderSkill } from './skill-file.js';
@@ -47,12 +48,14 @@ export class ClaudeCodeAdapter {
47
48
  warnings: plans.flatMap((plan) => plan.warnings),
48
49
  };
49
50
  }
50
- hooks({ projectRoot, files, shared }) {
51
+ hooks({ projectRoot, files, shared, runner }) {
51
52
  const [target, previous] = shared ? [SHARED_SETTINGS, LOCAL_SETTINGS] : [LOCAL_SETTINGS, SHARED_SETTINGS];
53
+ // Personal settings run this installation by its paths; settings the team commits hold no paths of this machine.
54
+ const command = (event) => estimetryCommand(shared ? undefined : runner, `hook claude-code ${event}`);
52
55
  const changes = [
53
56
  {
54
57
  path: join(projectRoot, target),
55
- content: withHooks(files.read(join(projectRoot, target)), this.hookEvents, target, SYNCHRONOUS_HOOK_EVENTS),
58
+ content: withHooks(files.read(join(projectRoot, target)), { events: this.hookEvents, synchronous: SYNCHRONOUS_HOOK_EVENTS, command }, target),
56
59
  },
57
60
  ];
58
61
  const warnings = [];
@@ -1,12 +1,18 @@
1
+ import { isEstimetryCommand } from '../../../application/contracts/estimetry-command.js';
1
2
  import { InstallBlocked } from '../../../application/contracts/install-blocked.js';
2
- /** Our hooks are recognised by this prefix; a hook the user rewrote is theirs. */
3
- export const HOOK_PREFIX = 'estimetry hook claude-code';
3
+ /**
4
+ * Our hooks are recognised by this prefix, or by the command of this installation
5
+ * (`estimetryCommand`) that falls back to it; a hook the user rewrote is theirs.
6
+ */
7
+ const HOOK_ARGS = 'hook claude-code';
8
+ export const HOOK_PREFIX = `estimetry ${HOOK_ARGS}`;
4
9
  export const HOOK_TIMEOUT_SECONDS = 10;
5
10
  /**
6
11
  * Adds one hook per event and drops our earlier ones; every other key, hook and
7
12
  * their order stay. `displayPath` names the file in the error a broken one gives.
8
13
  */
9
- export function withHooks(text, events, displayPath, synchronous = events) {
14
+ export function withHooks(text, set, displayPath) {
15
+ const { events, synchronous } = set;
10
16
  const settings = parse(text, displayPath) ?? {};
11
17
  const hooks = withoutOurHooks(hooksOf(settings, displayPath));
12
18
  for (const event of events) {
@@ -14,7 +20,7 @@ export function withHooks(text, events, displayPath, synchronous = events) {
14
20
  // The agent does not wait for an async hook: only hooks whose context it needs now, or the session end, are synchronous.
15
21
  const handler = {
16
22
  type: 'command',
17
- command: `${HOOK_PREFIX} ${event}`,
23
+ command: set.command(event),
18
24
  timeout: HOOK_TIMEOUT_SECONDS,
19
25
  ...(synchronous.includes(event) ? {} : { async: true }),
20
26
  };
@@ -88,7 +94,10 @@ function isOurs(handler) {
88
94
  return (isObject(handler) &&
89
95
  handler['type'] === 'command' &&
90
96
  typeof handler['command'] === 'string' &&
91
- (handler['command'] === HOOK_PREFIX || handler['command'].startsWith(`${HOOK_PREFIX} `)));
97
+ isOurCommand(handler['command']));
98
+ }
99
+ function isOurCommand(command) {
100
+ return isEstimetryCommand(command, HOOK_ARGS);
92
101
  }
93
102
  function hooksOf(settings, displayPath) {
94
103
  const hooks = settings['hooks'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "estimetry",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Compares work estimates with actual effort in AI-agent development and reuses that experience in the next estimate",
5
5
  "keywords": [
6
6
  "estimation",