@discovery-tree/runner 0.1.2 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +9 -1
  2. package/dist/cli.js +49 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -118,9 +118,17 @@ could not do it. What it may do without asking:
118
118
  `cargo` and `go` run code**, from the repository (package scripts, build files, tests) or
119
119
  written by the agent, so this list amounts to arbitrary code execution as you. It keeps the
120
120
  agent from stalling on every command; it is not a sandbox.
121
+ Also on it, the `gh` commands that only read (`gh pr view/diff/checks/list/status`,
122
+ `gh run view/list`, `gh issue view/list`, `gh repo view`), so the agent can see the pull
123
+ request Discovery Tree opened from its branch, its checks and review comments. They run as
124
+ your `gh` login and can read whatever it can. Install the [GitHub CLI](https://cli.github.com)
125
+ and run `gh auth login` for them to work; `doctor` checks.
121
126
  Left off on purpose: `WebFetch` and `WebSearch` (the easiest way for a manipulated agent to
122
127
  send data out), `find` (`-exec`), `sed`, `cp`, `mv` (they can write anywhere; the Edit and
123
- Write tools cover changes in the worktree) and `git push` (the runner pushes).
128
+ Write tools cover changes in the worktree), `git push` (the runner pushes) and `gh` commands
129
+ that change GitHub, `gh api` included (Discovery Tree opens the pull request). Add, say,
130
+ `"Bash(gh pr comment *)"` to `extraAllowedTools` if you want the agent to reply on its pull
131
+ request as you.
124
132
  - **The deny list** (`--disallowedTools`, which wins over the allow-list): the agent's file
125
133
  tools may not read or edit `~/.ssh`, `~/.aws`, `~/.config/gcloud`, `~/.azure`, `~/.gnupg`,
126
134
  `~/.netrc`, `~/.git-credentials`, `~/.config/gh`, `~/.docker/config.json`, `~/.kube`,
package/dist/cli.js CHANGED
@@ -33,7 +33,7 @@ var RUNNER_EVENT_TEXT_MAX_LENGTH = 64e3;
33
33
  var RUNNER_EVENTS_MAX_BODY_BYTES = 8 * 1024 * 1024;
34
34
 
35
35
  // src/version.ts
36
- var RUNNER_VERSION = true ? "0.1.2" : "0.0.0-dev";
36
+ var RUNNER_VERSION = true ? "0.1.4" : "0.0.0-dev";
37
37
  var RUNNER_PLATFORM = `${process.platform}-${process.arch}`;
38
38
 
39
39
  // src/api.ts
@@ -331,7 +331,13 @@ function runnerSystemPrompt(input) {
331
331
  "Commit your work to this branch as you go, with clear, descriptive commit messages.",
332
332
  "Do not push, do not switch, create or delete branches, and do not rewrite commits that may",
333
333
  "already be pushed: the runner commits anything left over and pushes this branch for you",
334
- "at the end of every turn."
334
+ "at the end of every turn.",
335
+ "Do not open a pull request either: Discovery Tree opens it from this branch when a turn",
336
+ "ends, with that turn\u2019s final message as its description, and later turns add to it.",
337
+ "Before then (your first turn) there is none; say so rather than trying to open one.",
338
+ `To read it, use \`gh pr view ${input.workBranch}\` (\`--comments\` for the conversation),`,
339
+ "`gh pr diff`, `gh pr checks`, and `gh run view` for a check run\u2019s logs. Only `gh` commands",
340
+ "that read are allowed; ones that change GitHub (comment, edit, merge, `gh api`) are denied."
335
341
  ].join(" ");
336
342
  }
337
343
 
@@ -403,6 +409,16 @@ var DEFAULT_ALLOWED_TOOLS = [
403
409
  "Bash(git stash *)",
404
410
  "Bash(git blame *)",
405
411
  "Bash(git grep *)",
412
+ "Bash(gh pr view *)",
413
+ "Bash(gh pr diff *)",
414
+ "Bash(gh pr checks *)",
415
+ "Bash(gh pr list *)",
416
+ "Bash(gh pr status *)",
417
+ "Bash(gh run view *)",
418
+ "Bash(gh run list *)",
419
+ "Bash(gh issue view *)",
420
+ "Bash(gh issue list *)",
421
+ "Bash(gh repo view *)",
406
422
  "Bash(npm *)",
407
423
  "Bash(npx *)",
408
424
  "Bash(pnpm *)",
@@ -1627,8 +1643,10 @@ ${text}`;
1627
1643
  const mapped = this.mapper.map(line);
1628
1644
  let dirty = false;
1629
1645
  if (mapped.claudeSessionId) this.sawInitSinceSpawn = true;
1646
+ let learnedSessionId = null;
1630
1647
  if (mapped.claudeSessionId && mapped.claudeSessionId !== this.record.claudeSessionId) {
1631
1648
  this.record.claudeSessionId = mapped.claudeSessionId;
1649
+ learnedSessionId = mapped.claudeSessionId;
1632
1650
  dirty = true;
1633
1651
  }
1634
1652
  if (mapped.turnStarted && !this.record.turnActive) {
@@ -1636,6 +1654,21 @@ ${text}`;
1636
1654
  dirty = true;
1637
1655
  }
1638
1656
  if (dirty) await this.deps.store.save(this.record);
1657
+ if (learnedSessionId) {
1658
+ const at = mapped.events.findIndex((e) => e.type === "status");
1659
+ if (at >= 0) {
1660
+ mapped.events[at] = {
1661
+ ...mapped.events[at],
1662
+ claudeSessionId: learnedSessionId
1663
+ };
1664
+ } else {
1665
+ mapped.events.push({
1666
+ type: "status",
1667
+ status: "running",
1668
+ claudeSessionId: learnedSessionId
1669
+ });
1670
+ }
1671
+ }
1639
1672
  if (mapped.events.length) this.emit(...mapped.events);
1640
1673
  if (mapped.turnEnd && this.resumeNotFound(mapped.turnEnd.isError)) {
1641
1674
  this.planFreshRetry();
@@ -2468,6 +2501,20 @@ async function runDoctor(env = process.env) {
2468
2501
  } catch {
2469
2502
  checks.push({ name: "git", level: "fail", detail: "git is not installed (or not on PATH)" });
2470
2503
  }
2504
+ try {
2505
+ const res = await exec("gh", ["auth", "status"], { timeoutMs: 1e4 });
2506
+ checks.push({
2507
+ name: "GitHub CLI",
2508
+ level: res.code === 0 ? "ok" : "warn",
2509
+ detail: res.code === 0 ? "signed in: the agent can read its pull request, checks and runs" : "not signed in: run `gh auth login` so the agent can read its pull request"
2510
+ });
2511
+ } catch {
2512
+ checks.push({
2513
+ name: "GitHub CLI",
2514
+ level: "warn",
2515
+ detail: "not installed (no `gh` on PATH): the agent cannot read its pull request; see https://cli.github.com"
2516
+ });
2517
+ }
2471
2518
  const bin = await findClaude(env);
2472
2519
  if (!bin) {
2473
2520
  checks.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discovery-tree/runner",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "dt-runner: run Discovery Tree agent sessions on your own computer with your own signed-in Claude Code",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {