@mergeline/agent 0.5.1 → 0.5.3

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
@@ -73,12 +73,14 @@ name exists or where the file still carries the kit's marker line, adds its
73
73
  permissions to `.claude/settings.json` (plus the repository's own package
74
74
  manager: install and its test, lint and typecheck scripts, from the lockfile
75
75
  and `package.json`) and removes only the broad rules an older kit wrote
76
- (`Bash(board *)`, `Bash(git push *)` and the like), and adds a `board` server to
76
+ (`Bash(board *)`, `Bash(git push *)` and the like) and the deny rule
77
+ `Bash(git push *:*)` of kits 3 and 4, which Claude Code reads as a literal
78
+ prefix, so it stopped nothing; it adds a `board` server to
77
79
  `.mcp.json` that reads `${BOARD_URL}` and `${BOARD_AGENT_KEY}` from the
78
80
  environment, or else the key `login` saved: the key is never written to the
79
81
  repository.
80
82
 
81
- What the agent may run without asking (kit 4, in `.claude/settings.json`):
83
+ What the agent may run without asking (kit 5, in `.claude/settings.json`):
82
84
 
83
85
  - the board's MCP tools, and `board` (or `npx -y @mergeline/agent`) with
84
86
  `claim`, `heartbeat`, `log`, `record-spec`, `ask`, `submit`, `release`,
@@ -102,7 +104,9 @@ option),
102
104
  `--pathspec-from-file` (from `--pathspec-fr`) on any `git` command;
103
105
  `git diff` with `--no-index`, an argument starting with `/`, `~` or `$`
104
106
  (bare or quoted), or `../`; a push to `main`, with `--force`, a refspec
105
- with `:`,
107
+ with `:`
108
+ (`git push origin agent/x:main`; kit 5's rule is `git push *:**`, since
109
+ Claude Code reads a rule that ends in `:*` as a literal prefix),
106
110
  `--delete`, `-d`, `--mirror`, `--all` or `--tags`; a worktree path that
107
111
  leaves `../.wt/`; `--repo` (`-R`) on `gh pr`, `--body-file` (`-F`) on
108
112
  `gh pr create`; `gh pr merge`, `gh api`, `gh repo`, `curl`. An agent
@@ -136,7 +140,9 @@ board watch --follow --interval 60 -- <command> # keep waiting for n
136
140
 
137
141
  With `--usage-from claude-json` (and `claude -p --output-format json`), the
138
142
  watcher reads each run's tokens and cost from Claude Code's final JSON and
139
- reports them on the ticket the run worked on; `board usage <ticket> --usage
143
+ reports them on the ticket the run worked on. The tokens are the whole
144
+ run's, subagents included (`modelUsage`, summed over models; `usage` alone
145
+ has only the last query loop), and the cost is `total_cost_usd`; `board usage <ticket> --usage
140
146
  <json>` does the same by hand. The board stores usage only for agents whose
141
147
  "Report usage" is on.
142
148
 
package/dist/init.js CHANGED
@@ -8,7 +8,8 @@
8
8
  // the kit's marker line; a file of the same name that the kit did not write
9
9
  // is skipped with a note.
10
10
  // - .claude/settings.json gets the kit's permissions added to its lists
11
- // (and loses the broad allow rules of kits 1 and 2, RETIRED_ALLOW);
11
+ // (and loses the broad allow rules of kits 1 and 2, RETIRED_ALLOW, and
12
+ // the deny rule Claude Code misreads in kits 3 and 4, RETIRED_DENY);
12
13
  // .mcp.json gets a `board` server unless it already has one. The agent key
13
14
  // is never written: .mcp.json refers to ${BOARD_URL} and ${BOARD_AGENT_KEY}.
14
15
  // The permissions also allow the repository's own package manager (from its
@@ -44,7 +45,7 @@ export const PACKAGE_VERSION = PACKAGE.version;
44
45
  * which wrote no version. The board says when a claim's kit is older than it
45
46
  * expects (KIT_MIN in pocketbase/pb_hooks/board_lib.js).
46
47
  */
47
- export const KIT_VERSION = 4;
48
+ export const KIT_VERSION = 5;
48
49
  const START = `<!-- mergeline:start (kit ${KIT_VERSION}; managed by \`board init\`; edit outside these markers) -->`;
49
50
  /** Markers are found by these prefixes, so an edited marker line or an older kit's still counts. */
50
51
  const START_PREFIX = "<!-- mergeline:start";
@@ -72,6 +73,13 @@ const RETIRED_ALLOW = [
72
73
  "Bash(git push *)",
73
74
  "Bash(git commit *)",
74
75
  ];
76
+ /**
77
+ * Deny rules an older kit wrote that a newer one replaces: `Bash(git push *:*)`
78
+ * (kits 3 and 4) ends in `:*`, which Claude Code reads as its old prefix form
79
+ * (a literal prefix `git push *`, with the `*` not expanded), so it matched
80
+ * nothing and Claude Code warned at every start. Kit 5 has `git push *:**`.
81
+ */
82
+ const RETIRED_DENY = ["Bash(git push *:*)"];
75
83
  /** Scripts the agent runs before a PR (done.md), when the project has them. */
76
84
  const CHECK_SCRIPTS = ["test", "lint", "typecheck", "check"];
77
85
  /**
@@ -250,6 +258,8 @@ export function init(opts) {
250
258
  let have = Array.isArray(data.permissions[list]) ? data.permissions[list] : [];
251
259
  if (list === "allow")
252
260
  have = have.filter((e) => !RETIRED_ALLOW.includes(e));
261
+ if (list === "deny")
262
+ have = have.filter((e) => !RETIRED_DENY.includes(e));
253
263
  data.permissions[list] = [...have, ...entries.filter((e) => !have.includes(e))];
254
264
  }
255
265
  });
package/dist/watch.js CHANGED
@@ -29,18 +29,33 @@ export function usageFromClaudeJson(output) {
29
29
  catch {
30
30
  continue;
31
31
  }
32
- if (!run || typeof run !== "object" || (run.total_cost_usd === undefined && !run.usage))
32
+ if (!run || typeof run !== "object" || (run.total_cost_usd === undefined && !run.usage && !run.modelUsage))
33
33
  continue;
34
- const u = run.usage ?? {};
35
34
  const usage = { source: "claude-code" };
36
- if (Number.isInteger(u.input_tokens))
37
- usage.input_tokens = u.input_tokens;
38
- if (Number.isInteger(u.output_tokens))
39
- usage.output_tokens = u.output_tokens;
40
- if (Number.isInteger(u.cache_read_input_tokens))
41
- usage.cache_read_tokens = u.cache_read_input_tokens;
42
- if (Number.isInteger(u.cache_creation_input_tokens))
43
- usage.cache_write_tokens = u.cache_creation_input_tokens;
35
+ // `usage` has only the main thread's last query loop; `modelUsage` has the
36
+ // whole run, subagents and later loops included, like `total_cost_usd`.
37
+ const models = run.modelUsage && typeof run.modelUsage === "object"
38
+ ? Object.values(run.modelUsage).filter((m) => !!m && typeof m === "object")
39
+ : [];
40
+ const fields = models.length
41
+ ? [
42
+ ["input_tokens", "inputTokens"],
43
+ ["output_tokens", "outputTokens"],
44
+ ["cache_read_tokens", "cacheReadInputTokens"],
45
+ ["cache_write_tokens", "cacheCreationInputTokens"],
46
+ ]
47
+ : [
48
+ ["input_tokens", "input_tokens"],
49
+ ["output_tokens", "output_tokens"],
50
+ ["cache_read_tokens", "cache_read_input_tokens"],
51
+ ["cache_write_tokens", "cache_creation_input_tokens"],
52
+ ];
53
+ const sources = models.length ? models : [run.usage ?? {}];
54
+ for (const [to, from] of fields) {
55
+ const counts = sources.map((m) => m[from]).filter((n) => Number.isInteger(n));
56
+ if (counts.length)
57
+ usage[to] = counts.reduce((a, b) => a + b, 0);
58
+ }
44
59
  if (typeof run.total_cost_usd === "number") {
45
60
  usage.cost = Math.round(run.total_cost_usd * 10000) / 10000;
46
61
  usage.currency = "USD";
@@ -114,7 +114,7 @@
114
114
  "Bash(git push -f *)",
115
115
  "Bash(git push * --force*)",
116
116
  "Bash(git push * -f*)",
117
- "Bash(git push *:*)",
117
+ "Bash(git push *:**)",
118
118
  "Bash(git push origin agent/* *)",
119
119
  "Bash(git push -u origin agent/* *)",
120
120
  "Bash(git push * --delete*)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mergeline/agent",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "The agent's side of a Mergeline board: an MCP server and the `board` CLI. Works with any agent tool that runs MCP servers or shell commands.",
5
5
  "license": "MIT",
6
6
  "author": "frontender-ua",