@dreamorosi/agent-timekeeper-claude-code 0.2.3 → 0.2.4

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,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-timekeeper",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Claude Code plugin for Agent Timekeeper: records Sessions, Runs, tool calls and Interactions as Signals, and uploads them to your own endpoint",
5
5
  "author": {
6
6
  "name": "Andrea Amorosi"
package/hooks/register.js CHANGED
@@ -21522,12 +21522,60 @@ var unwrap = (command) => {
21522
21522
  };
21523
21523
  var commandHead2 = (command) => {
21524
21524
  const unwrapped = unwrap(command);
21525
- const words = (unwrapped === "" ? command : unwrapped).trim().split(/\s+/);
21525
+ const words = (unwrapped === "" ? command : unwrapped).trim().replace(/^git\s+-C\s+(?:"[^"]*"|'[^']*'|\S+)\s*/, "git ").split(/\s+/);
21526
21526
  const [first, second] = words;
21527
21527
  if (first === void 0 || !WORD.test(first)) return void 0;
21528
21528
  if (second !== void 0 && WORD.test(second)) return `${first} ${second}`;
21529
21529
  return first;
21530
21530
  };
21531
+ var normalisePath = (path) => {
21532
+ const parts = [];
21533
+ for (const part of path.split("/")) {
21534
+ if (part === "" || part === ".") continue;
21535
+ if (part === "..") parts.pop();
21536
+ else parts.push(part);
21537
+ }
21538
+ return `/${parts.join("/")}`;
21539
+ };
21540
+ var argument = (raw) => {
21541
+ const text = raw.trim();
21542
+ const quoted = /^"([^"]*)"$|^'([^']*)'$/.exec(text);
21543
+ const word = quoted ? quoted[1] ?? quoted[2] ?? "" : text;
21544
+ if (word === "" || !quoted && /\s/.test(word)) return void 0;
21545
+ if (/[$`*?[\]{}]/.test(word)) return void 0;
21546
+ return word;
21547
+ };
21548
+ var resolveFrom = (base, target, home) => {
21549
+ if (target === "~" || target.startsWith("~/")) {
21550
+ return home === void 0 ? void 0 : normalisePath(home + target.slice(1));
21551
+ }
21552
+ if (target.startsWith("~") || target === "-") return void 0;
21553
+ return normalisePath(target.startsWith("/") ? target : `${base}/${target}`);
21554
+ };
21555
+ var commandDirectories = (command, base, home) => {
21556
+ let cwd = base;
21557
+ let rest = command.trim();
21558
+ for (; ; ) {
21559
+ const cd = /^cd(?:\s+([^;&|]*?))?\s*(?:&&|;|\|\||$)\s*/.exec(rest);
21560
+ if (cd !== null && cd[0] !== "") {
21561
+ const raw = cd[1]?.trim() ?? "";
21562
+ const target2 = raw === "" ? "~" : argument(raw);
21563
+ const next = target2 === void 0 ? void 0 : resolveFrom(cwd, target2, home);
21564
+ if (next === void 0) return { place: cwd, cwd };
21565
+ cwd = next;
21566
+ rest = rest.slice(cd[0].length);
21567
+ if (rest === "") break;
21568
+ continue;
21569
+ }
21570
+ const other = [/^export(?:\s[\s\S]*?)?(?:&&|;)\s*/, ...WRAPPERS.slice(1)].map((pattern) => pattern.exec(rest)).find((match) => match !== null && match[0] !== "");
21571
+ if (other == null) break;
21572
+ rest = rest.slice(other[0].length);
21573
+ }
21574
+ const git = /^git\s+-C\s+("[^"]*"|'[^']*'|\S+)/.exec(rest);
21575
+ const target = git?.[1] === void 0 ? void 0 : argument(git[1]);
21576
+ const place = target === void 0 ? void 0 : resolveFrom(cwd, target, home);
21577
+ return { place: place ?? cwd, cwd };
21578
+ };
21531
21579
  var sshAliases = (config2) => {
21532
21580
  const aliases = /* @__PURE__ */ new Map();
21533
21581
  let hosts = [];
@@ -21738,7 +21786,12 @@ var createTranslator = (options) => {
21738
21786
  const stateOf = (sessionId2) => {
21739
21787
  let state = sessions.get(sessionId2);
21740
21788
  if (state === void 0) {
21741
- state = { runs: /* @__PURE__ */ new Map(), steps: /* @__PURE__ */ new Map(), skillCalls: /* @__PURE__ */ new Map() };
21789
+ state = {
21790
+ runs: /* @__PURE__ */ new Map(),
21791
+ steps: /* @__PURE__ */ new Map(),
21792
+ skillCalls: /* @__PURE__ */ new Map(),
21793
+ shells: /* @__PURE__ */ new Map()
21794
+ };
21742
21795
  sessions.set(sessionId2, state);
21743
21796
  }
21744
21797
  return state;
@@ -21940,11 +21993,19 @@ var createTranslator = (options) => {
21940
21993
  if (SHELL_TOOLS.has(o.tool)) {
21941
21994
  const command = str(input2.command);
21942
21995
  const head = command === void 0 ? void 0 : commandHead2(command);
21996
+ const shell = agentId ?? MAIN;
21997
+ const start2 = state.shells.get(shell) ?? state.directory;
21998
+ let directory = start2;
21999
+ if (command !== void 0 && start2 !== void 0) {
22000
+ const where = commandDirectories(command, start2, options.home);
22001
+ directory = where.place;
22002
+ state.shells.set(shell, where.cwd);
22003
+ }
21943
22004
  return [
21944
22005
  {
21945
22006
  ...base,
21946
22007
  ...head === void 0 ? {} : { commandHead: head },
21947
- ...await place(state.directory)
22008
+ ...await place(directory)
21948
22009
  }
21949
22010
  ];
21950
22011
  }
@@ -22107,6 +22168,7 @@ async function start($, interactive) {
22107
22168
  const translator = createTranslator({
22108
22169
  machineId: await loadModMachineId(host),
22109
22170
  harnessVersion: (await $.session.version()).version,
22171
+ ...home === void 0 ? {} : { home },
22110
22172
  place: placeLookup(
22111
22173
  {
22112
22174
  run: (argv) => $.process.run(argv, { timeoutMs: 5e3 }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamorosi/agent-timekeeper-claude-code",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Claude Code plugin for Agent Timekeeper: records Sessions, Runs, tool calls and Interactions as Signals, and uploads them to your own endpoint",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {