@dreamorosi/agent-timekeeper-claude-code 0.2.2 → 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.2",
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
@@ -21504,13 +21504,78 @@ var signalId = ({
21504
21504
 
21505
21505
  // ../signal/src/producer.ts
21506
21506
  var WORD = /^[A-Za-z0-9._/@+-]{1,32}$/;
21507
+ var WRAPPERS = [
21508
+ /^(?:cd|export)(?:\s[\s\S]*?)?(?:&&|;)\s*/,
21509
+ /^[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|[^\s"'])*\s*/,
21510
+ /^timeout\s+\d+(?:\.\d+)?[smhd]?(?:\s+|$)/,
21511
+ /^env(?:\s+|$)/
21512
+ ];
21513
+ var unwrap = (command) => {
21514
+ let rest = command.trim();
21515
+ for (; ; ) {
21516
+ const wrapper = WRAPPERS.map((pattern) => pattern.exec(rest)).find(
21517
+ (match) => match !== null
21518
+ );
21519
+ if (wrapper === void 0) return rest;
21520
+ rest = rest.slice(wrapper[0].length);
21521
+ }
21522
+ };
21507
21523
  var commandHead2 = (command) => {
21508
- const words = command.trim().split(/\s+/);
21524
+ const unwrapped = unwrap(command);
21525
+ const words = (unwrapped === "" ? command : unwrapped).trim().replace(/^git\s+-C\s+(?:"[^"]*"|'[^']*'|\S+)\s*/, "git ").split(/\s+/);
21509
21526
  const [first, second] = words;
21510
21527
  if (first === void 0 || !WORD.test(first)) return void 0;
21511
21528
  if (second !== void 0 && WORD.test(second)) return `${first} ${second}`;
21512
21529
  return first;
21513
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
+ };
21514
21579
  var sshAliases = (config2) => {
21515
21580
  const aliases = /* @__PURE__ */ new Map();
21516
21581
  let hosts = [];
@@ -21721,7 +21786,12 @@ var createTranslator = (options) => {
21721
21786
  const stateOf = (sessionId2) => {
21722
21787
  let state = sessions.get(sessionId2);
21723
21788
  if (state === void 0) {
21724
- 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
+ };
21725
21795
  sessions.set(sessionId2, state);
21726
21796
  }
21727
21797
  return state;
@@ -21923,11 +21993,19 @@ var createTranslator = (options) => {
21923
21993
  if (SHELL_TOOLS.has(o.tool)) {
21924
21994
  const command = str(input2.command);
21925
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
+ }
21926
22004
  return [
21927
22005
  {
21928
22006
  ...base,
21929
22007
  ...head === void 0 ? {} : { commandHead: head },
21930
- ...await place(state.directory)
22008
+ ...await place(directory)
21931
22009
  }
21932
22010
  ];
21933
22011
  }
@@ -22090,6 +22168,7 @@ async function start($, interactive) {
22090
22168
  const translator = createTranslator({
22091
22169
  machineId: await loadModMachineId(host),
22092
22170
  harnessVersion: (await $.session.version()).version,
22171
+ ...home === void 0 ? {} : { home },
22093
22172
  place: placeLookup(
22094
22173
  {
22095
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.2",
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": {