@christang/keel 5.204.0 → 5.205.0

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": "keel",
3
- "version": "5.204.0",
3
+ "version": "5.205.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
package/README.md CHANGED
@@ -908,7 +908,7 @@ at that task boundary — with `keel shift ready --wake` if another todo is stil
908
908
  within one (#313); and when a note it filed with `ready --wake` was never resumed. A note filed without `--wake` — a coordinator parking a role — is left alone, and
909
909
  Keel's own messages never count as waiting.
910
910
 
911
- With `--issues`, patrol also routes issue updates (#242): `issue_roles:` in `keel/config.yaml`
911
+ With `--issues`, which `keel tick` supplies itself, patrol also routes issue updates (#242): `issue_roles:` in `keel/config.yaml`
912
912
  maps a label to a role, and each role gets one direct message per update of an issue carrying its
913
913
  label — so a handoff labelled `role:verify` reaches `verify` without a second message. A key may
914
914
  name a set of labels joined by ` + ` (#433), which matches an issue carrying all of them, so teams of
@@ -979,6 +979,14 @@ that owns repository-wide risks reports them.
979
979
  echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty' > ~/.claude/keel-quota.txt
980
980
  ```
981
981
 
982
+ The tick fetches issue state for the patrol itself (#473), so `issue_roles:` routing and
983
+ `keel chat wait --issue <n> --closed` work under it. When a route is declared or such a wait is open,
984
+ it runs `gh issue list` for the 100 most recently updated issues, and `gh issue view` for each waited
985
+ issue that list left out, and passes the result as `--issues`. Unlike quota, this is a command Keel
986
+ runs. When nothing needs issues, no `gh` runs. When `gh` is missing, not logged in, or fails, the tick
987
+ says once that issue checks are not run, and why, and `keel --doctor` prints an `issue checks` line
988
+ from the last tick.
989
+
982
990
  ## The owner's language
983
991
 
984
992
  An agent reads mostly English — tool output, issues, specs, Keel's own output — and drifts into it when it answers you. Declare the language you want to be addressed in, and the rule is restated where replies are written: in `keel context`, the session-start note, and the chat hook on every prompt, in every worktree (#305) — and, on Claude, after every 15 tool calls or 10 minutes of them, since a status update written mid-turn follows no prompt (#311). The agent may still work in any language; identifiers, commands, paths, and quoted output stay as they are.
package/README.zh-CN.md CHANGED
@@ -754,7 +754,7 @@ keel patrol --issues /tmp/issues.json # 以协调者的角色运行
754
754
  完成的任务之后,而宿主会在一个任务之内做 compaction(#313);以及当它用 `ready --wake` 留下的便条一直没被
755
755
  恢复时。不带 `--wake` 留下的便条——协调者搁置某个角色——不会被打扰,Keel 自己的消息也从不算作等待。
756
756
 
757
- 带上 `--issues` 时,巡查还会分派 issue 更新(#242):`keel/config.yaml` 里的 `issue_roles:` 把一个标签映射到
757
+ 带上 `--issues` 时(`keel tick` 会自己传),巡查还会分派 issue 更新(#242):`keel/config.yaml` 里的 `issue_roles:` 把一个标签映射到
758
758
  一个角色,每个角色会为带着它标签的 issue 的每次更新收到一条私信——这样一个标为 `role:verify` 的交接无需第二条
759
759
  消息就能到达 `verify`。一个键也可以是用 ` + ` 连起来的一组标签(#433),只匹配同时带着这些标签的 issue,这样
760
760
  结构相同的几个团队就能共用能力标签。当一条匹配路由的标签是另一条的子集时,只有标签更多的那条的角色收到更新;
@@ -816,6 +816,12 @@ tick 还会把以前由宿主任务传的数字交给巡查(#456)。它测
816
816
  echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty' > ~/.claude/keel-quota.txt
817
817
  ```
818
818
 
819
+ tick 会自己替巡查取 issue 状态(#473),所以 `issue_roles:` 分派和 `keel chat wait --issue <n> --closed`
820
+ 在 tick 下都能生效。声明了路由,或者有这样的等待未满足时,它运行 `gh issue list` 取最近更新的 100 个 issue,
821
+ 再对列表里没有的每个被等待的 issue 运行 `gh issue view`,把结果作为 `--issues` 传给巡查。和配额不同,这是 Keel
822
+ 自己执行的命令。没有任何东西需要 issue 时,不运行 `gh`。`gh` 不在、没登录或执行失败时,tick 说一次 issue 检查
823
+ 没有执行以及原因,`keel --doctor` 也会根据上一次 tick 打印一行 `issue checks`。
824
+
819
825
  ## 负责人的语言
820
826
 
821
827
  agent 读到的大多是英文——工具输出、issue、spec、Keel 自己的输出——回答你时也会滑向英文。声明你希望被使用的语言,这条规则就会在写回复的地方被重申:在 `keel context`、会话启动提示,以及每个 worktree 里每次提示时的 chat hook 中(#305)——在 Claude 上,还会在每 15 次工具调用或连续 10 分钟的工具调用之后重申,因为回合中途写的状态更新并不跟在某次提示之后(#311)。agent 仍可以用任何语言工作;标识符、命令、路径和引用的输出保持原样。
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.204.0 -->
1
+ <!-- keel:start version=5.205.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
package/bin/keel.js CHANGED
@@ -2496,6 +2496,7 @@ function runDoctor(options) {
2496
2496
  printFastPrePushSurface(repo);
2497
2497
  printSourceRepoCliResolution(repo);
2498
2498
  printChatRoleDrift(repo);
2499
+ printTickIssueChecks(repo);
2499
2500
  printMergedBranches(repo);
2500
2501
  printLaunchdJobs();
2501
2502
 
@@ -2523,6 +2524,29 @@ function printLaunchdJobs() {
2523
2524
 
2524
2525
  // Each role's merged, unused task branches (#469 D5): a count pointing at
2525
2526
  // `keel branches`, never a deletion.
2527
+ // The issue state `keel tick` last recorded (#473 D3); nothing when no tick
2528
+ // has fetched here.
2529
+ function printTickIssueChecks(repo) {
2530
+ let where = null;
2531
+ try {
2532
+ where = require("../src/core/chat/store").locate(repo);
2533
+ } catch {
2534
+ where = null;
2535
+ }
2536
+ if (!where) return;
2537
+ const file = path.join(where.root, "tick", "state.json");
2538
+ let issues = null;
2539
+ try {
2540
+ issues = JSON.parse(fs.readFileSync(file, "utf8")).issues || null;
2541
+ } catch {
2542
+ issues = null;
2543
+ }
2544
+ if (!issues || !issues.state) return;
2545
+ if (issues.state === "failed") printDoctorLine("issue checks", "not checked", `${issues.text} (tick at ${issues.at})`);
2546
+ else if (issues.state === "read") printDoctorLine("issue checks", "ok", `last read by \`keel tick\` at ${issues.at}`);
2547
+ else printDoctorLine("issue checks", "ok", "nothing needs them: no issue_roles route and no issue wait");
2548
+ }
2549
+
2526
2550
  function printMergedBranches(repo) {
2527
2551
  let where = null;
2528
2552
  try {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.204.0",
3
+ "version": "5.205.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.204.0",
9
+ "version": "5.205.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.204.0",
5
+ "version": "5.205.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.204.0",
3
+ "version": "5.205.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.204.0",
3
+ "version": "5.205.0",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
35
35
  os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
36
36
 
37
37
 
38
- PACKAGE_VERSION = "5.204.0"
38
+ PACKAGE_VERSION = "5.205.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.204.0"
41
+ PROTOCOL_VERSION = "5.205.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -473,6 +473,8 @@ SCENARIOS: tuple = (
473
473
  ("tick-runs-each-patrol", shift.validate_tick_runs_each_patrol_scenario),
474
474
  ("tick-passes-free-disk", shift.validate_tick_passes_free_disk_scenario),
475
475
  ("tick-reads-quota-file", shift.validate_tick_reads_quota_file_scenario),
476
+ ("tick-checks-issues", shift.validate_tick_checks_issues_scenario),
477
+ ("tick-reports-issue-checks", shift.validate_tick_reports_issue_checks_scenario),
476
478
  ("launchd-stable-node", shift.validate_launchd_stable_node_scenario),
477
479
  ("shift-slash-command", shift.validate_shift_slash_command_scenario),
478
480
  ("shift-check-skips-host-keep-awake", shift.validate_shift_check_skips_host_keep_awake_scenario),
@@ -1069,6 +1069,112 @@ def validate_tick_reads_quota_file_scenario() -> int:
1069
1069
  return 0
1070
1070
 
1071
1071
 
1072
+ def stub_gh(base: Path) -> tuple[Path, Path]:
1073
+ """A `gh` that logs its arguments and prints `list.json` or `view-<n>.json`.
1074
+
1075
+ With a `fail` file beside it, it prints `gh: not logged in` and exits 1.
1076
+ """
1077
+ bin_dir = base / "stub-bin"
1078
+ bin_dir.mkdir(parents=True, exist_ok=True)
1079
+ log = base / "gh.log"
1080
+ script = bin_dir / "gh"
1081
+ script.write_text(
1082
+ "#!/bin/sh\n"
1083
+ f'echo "$*" >> "{log}"\n'
1084
+ f'if [ -f "{bin_dir}/fail" ]; then echo "gh: not logged in" >&2; exit 1; fi\n'
1085
+ 'case "$1 $2" in\n'
1086
+ f' "issue list") cat "{bin_dir}/list.json" ;;\n'
1087
+ f' "issue view") cat "{bin_dir}/view-$3.json" ;;\n'
1088
+ "esac\n",
1089
+ encoding="utf-8",
1090
+ )
1091
+ script.chmod(0o755)
1092
+ return bin_dir, log
1093
+
1094
+
1095
+ def told_by(repo: Path, sender: str, role: str, needle: str) -> int:
1096
+ return len(chat_records_with(repo, "dm-" + "--".join(sorted((sender, role))), needle))
1097
+
1098
+
1099
+ def validate_tick_checks_issues_scenario() -> int:
1100
+ """Issue #473 D1, D4: `keel tick` fetches issue state with `gh` when something needs it.
1101
+
1102
+ A labelled issue reaches the role `issue_roles:` names, and an issue wait
1103
+ is met from a closed issue the list left out; with neither declared, no
1104
+ `gh` runs.
1105
+ """
1106
+ label = "tick-checks-issues:"
1107
+ with tempfile.TemporaryDirectory(prefix="keel-tick-issues-") as raw:
1108
+ base = Path(raw)
1109
+ bin_dir, log = stub_gh(base)
1110
+ (bin_dir / "list.json").write_text(json.dumps([{
1111
+ "number": 7, "title": "dev handoff", "state": "OPEN",
1112
+ "labels": [{"name": "dev"}], "updatedAt": "2026-10-26T01:00:00Z",
1113
+ }]), encoding="utf-8")
1114
+ (bin_dir / "view-42.json").write_text(json.dumps({
1115
+ "number": 42, "title": "clock fix", "state": "CLOSED", "labels": [], "updatedAt": "2026-10-26T00:30:00Z",
1116
+ }), encoding="utf-8")
1117
+ repo, env, wt, state = tick_scopes_scratch(base / "declared", tail="issue_roles:\n dev: dev-b\n")
1118
+ env = {**env, "PATH": f"{bin_dir}{os.pathsep}{env.get('PATH', '')}"}
1119
+ run_keel(wt["dev-a"], "chat", "wait", "team-a", "--issue", "42", "--closed", env=env)
1120
+ for _ in range(2):
1121
+ ran = due_tick(repo, env, wt, state)
1122
+ if ran.returncode != 0:
1123
+ report(f"{label} keel tick exited {ran.returncode}: {ran.stdout!r} {ran.stderr!r}")
1124
+ return 1
1125
+ routed = told_by(repo, "pm-b", "dev-b", "#7")
1126
+ met = told_by(repo, "pm-a", "dev-a", "issue #42 closed")
1127
+ if (routed, met) != (1, 1):
1128
+ calls = log.read_text(encoding="utf-8") if log.exists() else ""
1129
+ report(f"{label} dev-b was told of #7 {routed} times and dev-a of issue #42 {met} times, not once each: {ran.stdout!r} gh calls {calls!r}")
1130
+ return 1
1131
+
1132
+ log.unlink(missing_ok=True)
1133
+ repo, env, wt, state = tick_scopes_scratch(base / "undeclared")
1134
+ env = {**env, "PATH": f"{bin_dir}{os.pathsep}{env.get('PATH', '')}"}
1135
+ due_tick(repo, env, wt, state)
1136
+ if log.exists() and log.read_text(encoding="utf-8").strip():
1137
+ report(f"{label} with no issue_roles and no issue wait the tick ran gh: {log.read_text(encoding='utf-8')!r}")
1138
+ return 1
1139
+ report("tick-checks-issues scenario passed.")
1140
+ return 0
1141
+
1142
+
1143
+ def validate_tick_reports_issue_checks_scenario() -> int:
1144
+ """Issue #473 D2, D3: a failed `gh` is said once, and `keel --doctor` shows it.
1145
+
1146
+ The tick says issue checks are not run, with the reason, when that state
1147
+ first appears and again only when it changes.
1148
+ """
1149
+ label = "tick-reports-issue-checks:"
1150
+ with tempfile.TemporaryDirectory(prefix="keel-tick-issue-state-") as raw:
1151
+ base = Path(raw)
1152
+ bin_dir, _log = stub_gh(base)
1153
+ (bin_dir / "list.json").write_text("[]", encoding="utf-8")
1154
+ (bin_dir / "fail").write_text("", encoding="utf-8")
1155
+ repo, env, wt, state = tick_scopes_scratch(base / "repo", tail="issue_roles:\n dev: dev-b\n")
1156
+ env = {**env, "PATH": f"{bin_dir}{os.pathsep}{env.get('PATH', '')}"}
1157
+ first = due_tick(repo, env, wt, state)
1158
+ if not any("issue checks are not run" in line and "not logged in" in line for line in first.stdout.splitlines()):
1159
+ report(f"{label} the first tick with gh failing does not say issue checks are not run and why: {first.stdout!r}")
1160
+ return 1
1161
+ second = due_tick(repo, env, wt, state)
1162
+ if any("issue checks" in line for line in second.stdout.splitlines()):
1163
+ report(f"{label} the tick repeats an unchanged issue state: {second.stdout!r}")
1164
+ return 1
1165
+ doctor = run_keel(wt["dev-a"], "--doctor", str(wt["dev-a"]), env=env)
1166
+ if not any("issue checks" in line and "not checked" in line for line in doctor.stdout.splitlines()):
1167
+ report(f"{label} keel --doctor does not show issue checks as not checked: {doctor.stdout!r}")
1168
+ return 1
1169
+ (bin_dir / "fail").unlink()
1170
+ third = due_tick(repo, env, wt, state)
1171
+ if not any("issue checks" in line and "read" in line for line in third.stdout.splitlines()):
1172
+ report(f"{label} once gh succeeds the tick does not say issue checks read: {third.stdout!r}")
1173
+ return 1
1174
+ report("tick-reports-issue-checks scenario passed.")
1175
+ return 0
1176
+
1177
+
1072
1178
  def validate_patrol_nudge_scenario() -> int:
1073
1179
  """Issues #307 part 1 and #313: the patrol nudges idle roles directly.
1074
1180
 
package/src/core/tick.js CHANGED
@@ -77,6 +77,62 @@ function readQuota(where, declared, now) {
77
77
  return { state: "read", percent, text: `quota is read from ${file} (${percent}%)` };
78
78
  }
79
79
 
80
+ const ISSUE_FIELDS = "number,title,state,labels,updatedAt";
81
+ const ISSUE_WINDOW = 100;
82
+
83
+ // The issues open `issue #<n> closed` waits name, in any group (#473 D1).
84
+ function waitedIssues(where) {
85
+ const numbers = store.openWaits(where).map((wait) => (String(wait.condition).match(/^issue #(\d+) closed$/) || [])[1]);
86
+ return [...new Set(numbers.filter(Boolean).map(Number))].sort((a, b) => a - b);
87
+ }
88
+
89
+ function runGh(cwd, args) {
90
+ const command = `gh ${args.slice(0, args[1] === "view" ? 3 : 2).join(" ")}`;
91
+ const ran = spawnSync("gh", args, { cwd, encoding: "utf8", timeout: 60000 });
92
+ if (ran.error || ran.status !== 0) {
93
+ const why = ran.error
94
+ ? (ran.error.code === "ENOENT" ? "gh is not on PATH" : ran.error.message)
95
+ : String(ran.stderr || `exit ${ran.status}`).trim().split("\n")[0];
96
+ return { error: `\`${command}\` failed: ${why}` };
97
+ }
98
+ try {
99
+ return { value: JSON.parse(ran.stdout) };
100
+ } catch {
101
+ return { error: `\`${command}\` printed no JSON` };
102
+ }
103
+ }
104
+
105
+ // Issue state for the patrol, fetched with `gh` only when an `issue_roles:`
106
+ // route or an issue wait needs it (#473 D1, D2; owner, 2026-10-26). What was
107
+ // read is passed even when a call failed.
108
+ function fetchIssues(where, worktree, now) {
109
+ const routes = require("./config").readIssueRoles(worktree).routes;
110
+ const waited = waitedIssues(where);
111
+ if (!routes.length && !waited.length) {
112
+ return { state: "unneeded", file: null, text: "issue checks: nothing needs them (no issue_roles route, no issue wait), so gh is not run" };
113
+ }
114
+ const issues = [];
115
+ const errors = [];
116
+ const listed = runGh(worktree, ["issue", "list", "--state", "all", "--search", "sort:updated-desc", "--limit", String(ISSUE_WINDOW), "--json", ISSUE_FIELDS]);
117
+ if (listed.error) errors.push(listed.error);
118
+ else if (!Array.isArray(listed.value)) errors.push("`gh issue list` printed no JSON array");
119
+ else issues.push(...listed.value.filter((issue) => issue && Number.isInteger(issue.number)));
120
+ for (const number of waited) {
121
+ if (issues.some((issue) => issue.number === number)) continue;
122
+ const viewed = runGh(worktree, ["issue", "view", String(number), "--json", ISSUE_FIELDS]);
123
+ if (viewed.error) errors.push(viewed.error);
124
+ else if (viewed.value && Number.isInteger(viewed.value.number)) issues.push(viewed.value);
125
+ else errors.push(`\`gh issue view ${number}\` printed no issue`);
126
+ }
127
+ let file = null;
128
+ if (issues.length || !errors.length) {
129
+ file = path.join(where.root, "tick", "issues.json");
130
+ store.writeJsonAtomic(where, file, issues);
131
+ }
132
+ if (errors.length) return { state: "failed", file, text: `issue checks are not run: ${errors.join("; ")}` };
133
+ return { state: "read", file, text: `issue checks: read ${issues.length} issue(s) with gh at ${store.isoLocal(now)}` };
134
+ }
135
+
80
136
  function patrolWorktree(where) {
81
137
  const all = patrolWorktrees(where);
82
138
  return all.find((found) => found.worktree) || all[0];
@@ -136,6 +192,8 @@ function tick(where, now = new Date()) {
136
192
  state.quota_state = quota.state;
137
193
  store.writeJsonAtomic(where, stateFile(where), state);
138
194
  }
195
+ // Fetched once per step, before the first due patrol (#473 D1).
196
+ let issues = null;
139
197
  result.patrols = all.map((found) => {
140
198
  if (!found.worktree) return { role: found.declaration ? found.declaration.role : null, ran: false, why: found.why };
141
199
  const role = found.declaration.role;
@@ -153,6 +211,8 @@ function tick(where, now = new Date()) {
153
211
  if (disk.gb !== null) args.push("--disk-free-gb", String(disk.gb));
154
212
  if (diskMinGb) args.push("--disk-min-gb", String(diskMinGb));
155
213
  if (quota.percent !== null) args.push("--quota", String(quota.percent));
214
+ if (!issues) issues = fetchIssues(where, found.worktree, now);
215
+ if (issues.file) args.push("--issues", issues.file);
156
216
  const ran = spawnSync(process.execPath, args, { cwd: found.worktree, encoding: "utf8" });
157
217
  let payload = {};
158
218
  try {
@@ -171,6 +231,13 @@ function tick(where, now = new Date()) {
171
231
  };
172
232
  });
173
233
  result.patrol = result.patrols[0];
234
+ // Kept for `keel --doctor` every time, said only when it changes (#473 D2, D3).
235
+ if (issues) {
236
+ const latest = readState(where);
237
+ if (!latest.issues || latest.issues.state !== issues.state) result.issues = issues;
238
+ latest.issues = { state: issues.state, text: issues.text, at: store.isoLocal(now) };
239
+ store.writeJsonAtomic(where, stateFile(where), latest);
240
+ }
174
241
  return result;
175
242
  }
176
243
 
@@ -178,7 +245,8 @@ function render(result) {
178
245
  const woke = (result.woken || []).map((w) => `keel tick: ${w.ok ? "resumed" : "could not resume"} ${w.role}'s CLI session ${w.session} for ${w.record}`);
179
246
  const handed = (result.handedOver || []).map((h) => `keel tick: ${h.role}'s hand-off ${h.state}${h.new_session ? ` as session ${h.new_session}` : ""}${h.error ? `: ${h.error}` : ""}`);
180
247
  const quota = result.quota ? [`keel tick: ${result.quota.text}`] : [];
181
- return [...handed, ...woke, ...quota, ...(result.patrols || [result.patrol]).map(renderPatrol)].join("\n");
248
+ const issues = result.issues ? [`keel tick: ${result.issues.text}`] : [];
249
+ return [...handed, ...woke, ...quota, ...issues,...(result.patrols || [result.patrol]).map(renderPatrol)].join("\n");
182
250
  }
183
251
 
184
252
  function renderPatrol(p) {