@christang/keel 5.95.2 → 5.96.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,4 +1,4 @@
1
- <!-- keel:start version=5.95.2 -->
1
+ <!-- keel:start version=5.96.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.95.2",
3
+ "version": "5.96.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.95.2",
9
+ "version": "5.96.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.95.2",
5
+ "version": "5.96.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.95.2",
3
+ "version": "5.96.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.95.2",
3
+ "version": "5.96.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",
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
47
47
  "scripts/validate_plugin.py",
48
48
  ]
49
49
 
50
- PACKAGE_VERSION = "5.95.2"
51
- PROTOCOL_VERSION = "5.95.2"
50
+ PACKAGE_VERSION = "5.96.0"
51
+ PROTOCOL_VERSION = "5.96.0"
52
52
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
53
53
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
54
54
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -3862,6 +3862,82 @@ def validate_chat_slack_format_scenario() -> int:
3862
3862
  return 0
3863
3863
 
3864
3864
 
3865
+ def validate_chat_issue_links_scenario() -> int:
3866
+ """Owner's request of 2026-10-05: an issue mentioned in Slack links to GitHub.
3867
+
3868
+ `owner/repo#N` links to that repository, and a bare `#N` to the project's
3869
+ own repository read from a GitHub `origin`; `C#`, `abc#9`, and code stay
3870
+ text; a project without a GitHub origin keeps a bare `#N` as text; and an
3871
+ issue link a person sends comes back as the text it showed.
3872
+ """
3873
+ label = "chat-issue-links:"
3874
+ if chat_bridge_node_missing("chat-issue-links"):
3875
+ return 3
3876
+ FakeSlack = fake_slack_class()
3877
+ with tempfile.TemporaryDirectory(prefix="keel-chat-issues-") as raw, FakeSlack() as slack:
3878
+ base = Path(raw)
3879
+ rtl, _verify, env = chat_scratch_group(base)
3880
+ chat_slack_config(rtl, {"soc": "CSOC"})
3881
+ benv = chat_bridge_environment(env, base / "home", slack)
3882
+ run_keel(rtl, "chat", "bridge", "add", env=benv)
3883
+ subprocess.run(["git", "remote", "remove", "origin"], cwd=rtl, capture_output=True, check=False)
3884
+ subprocess.run(["git", "remote", "add", "origin", "git@github.com:acme/rtl.git"], cwd=rtl, capture_output=True, check=True)
3885
+
3886
+ def posted(body: str) -> str:
3887
+ record_id = chat_json(run_keel(rtl, "chat", "post", "soc", body, "--json", env=benv)).get("id", "")
3888
+ once = run_keel(rtl, "chat", "bridge", "run", "--once", env=benv)
3889
+ sent = next((c["params"].get("text", "") for c in slack.calls_to("chat.postMessage") if slack_payload(c).get("id") == record_id), None)
3890
+ if sent is None:
3891
+ raise AssertionError(f"the record was never posted: {once.stderr.strip()}")
3892
+ if body not in (chat_log(rtl, "soc") / f"{record_id}.md").read_text(encoding="utf-8"):
3893
+ raise AssertionError("linking changed the local record")
3894
+ return sent
3895
+
3896
+ try:
3897
+ sent = posted("see #42, acme/other#7, C# and abc#9 and `#5`")
3898
+ for needle in ("<https://github.com/acme/rtl/issues/42|#42>", "<https://github.com/acme/other/issues/7|acme/other#7>", "C# and abc#9", "`#5`"):
3899
+ if needle not in sent:
3900
+ report(f"{label} the posted text lacks {needle!r}: {sent!r}")
3901
+ return 1
3902
+ subprocess.run(["git", "remote", "remove", "origin"], cwd=rtl, capture_output=True, check=True)
3903
+ sent = posted("see #43 and acme/other#8")
3904
+ if "github.com/acme/rtl" in sent or "see #43 and" not in sent:
3905
+ report(f"{label} a bare #43 was linked although origin is not on GitHub: {sent!r}")
3906
+ return 1
3907
+ if "<https://github.com/acme/other/issues/8|acme/other#8>" not in sent:
3908
+ report(f"{label} acme/other#8 was not linked without an origin: {sent!r}")
3909
+ return 1
3910
+ except AssertionError as error:
3911
+ report(f"{label} {error}")
3912
+ return 1
3913
+
3914
+ bridge = start_chat_bridge(rtl, benv)
3915
+ try:
3916
+ if not slack.wait_for(lambda: slack.sockets, 10):
3917
+ report(f"{label} the bridge never connected: {stop_chat_bridge(bridge).strip()}")
3918
+ return 1
3919
+ slack.push(slack_event("CSOC", user="UOWNER", text="<https://github.com/acme/rtl/issues/42|#42> done", ts="1800000001.000100"))
3920
+ if not slack.wait_for(lambda: chat_records_with(rtl, "soc", "done")):
3921
+ report(f"{label} the owner's message was not imported.")
3922
+ return 1
3923
+ stored = chat_records_with(rtl, "soc", "done")[0]
3924
+ if "#42 done" not in stored or "](" in stored:
3925
+ report(f"{label} the issue link did not come back as its text:\n{stored}")
3926
+ return 1
3927
+ finally:
3928
+ stop_chat_bridge(bridge)
3929
+
3930
+ for relative, needle in (("docs/chat-slack-setup.md", "link to GitHub"), ("docs/chat-slack-setup.zh-CN.md", "跳转到 GitHub")):
3931
+ if needle not in (ROOT / relative).read_text(encoding="utf-8"):
3932
+ report(f"{label} {relative} does not say {needle!r}.")
3933
+ return 1
3934
+ if "chat-issue-links" not in {name for name, _ in SCENARIOS}:
3935
+ report(f"{label} scenario is not registered.")
3936
+ return 1
3937
+ report("chat-issue-links scenario passed.")
3938
+ return 0
3939
+
3940
+
3865
3941
  def validate_chat_role_apps_are_documented_scenario() -> int:
3866
3942
  """Issue #187: the setup guides and READMEs describe shared bots.
3867
3943
 
@@ -4211,6 +4287,72 @@ def validate_chat_bridge_start_race_scenario() -> int:
4211
4287
  return 0
4212
4288
 
4213
4289
 
4290
+ def validate_chat_owner_mention_scenario() -> int:
4291
+ """Owner's rule of 2026-10-05: a Slack message the owner needs mentions them.
4292
+
4293
+ The session-start notice of a Slack-enabled project that names an owner
4294
+ tells the session to write `@owner` on what the owner needs to see or
4295
+ decide, and says nothing of it when no owner is named; a record with
4296
+ `@owner` is posted as a real mention; both setup guides state the rule.
4297
+ """
4298
+ label = "chat-owner-mention:"
4299
+ if chat_bridge_node_missing("chat-owner-mention"):
4300
+ return 3
4301
+ FakeSlack = fake_slack_class()
4302
+ with tempfile.TemporaryDirectory(prefix="keel-chat-owner-") as raw, FakeSlack() as slack:
4303
+ base = Path(raw)
4304
+ rtl, _verify, env = chat_scratch_group(base)
4305
+ chat_slack_config(rtl, {"soc": "CSOC"})
4306
+ benv = chat_bridge_environment(env, base / "home", slack)
4307
+
4308
+ def notice() -> str:
4309
+ session = subprocess.run(
4310
+ ["node", str(ROOT / PLUGIN_ROOT / "scripts/mail-hook.js"), "session-start"],
4311
+ cwd=rtl, env={**benv, "KEEL_CLI": f'node "{ROOT / "bin" / "keel.js"}"'},
4312
+ text=True, capture_output=True, check=False,
4313
+ input=json.dumps({"hook_event_name": "SessionStart", "cwd": str(rtl)}),
4314
+ )
4315
+ return chat_json(session).get("hookSpecificOutput", {}).get("additionalContext", "")
4316
+
4317
+ told = notice()
4318
+ if "@owner" not in told:
4319
+ report(f"{label} the session-start notice does not tell the session to write @owner: {told!r}")
4320
+ return 1
4321
+ if "decide" not in told:
4322
+ report(f"{label} the notice does not say which messages need @owner: {told!r}")
4323
+ return 1
4324
+
4325
+ run_keel(rtl, "chat", "bridge", "add", env=benv)
4326
+ record_id = chat_json(run_keel(rtl, "chat", "post", "soc", "@owner 需要你决定 CSR 复位值", "--json", env=benv)).get("id", "")
4327
+ once = run_keel(rtl, "chat", "bridge", "run", "--once", env=benv)
4328
+ posted = [c for c in slack.calls_to("chat.postMessage") if slack_payload(c).get("id") == record_id]
4329
+ if not posted:
4330
+ report(f"{label} the @owner record was not posted: {once.stderr.strip()}")
4331
+ return 1
4332
+ if not posted[0]["params"].get("text", "").startswith("<@UOWNER>"):
4333
+ report(f"{label} the @owner record was not posted as a mention: {posted[0]['params'].get('text')!r}")
4334
+ return 1
4335
+
4336
+ config = json.loads((rtl / "keel" / "chat.json").read_text(encoding="utf-8"))
4337
+ del config["slack"]["owner"]
4338
+ write_text(rtl / "keel" / "chat.json", json.dumps(config, indent=2) + "\n")
4339
+ untold = notice()
4340
+ if "@owner" in untold:
4341
+ report(f"{label} the notice asks for @owner although no owner is named: {untold!r}")
4342
+ return 1
4343
+
4344
+ for guide, needle in (("docs/chat-slack-setup.md", "needs to see or decide"), ("docs/chat-slack-setup.zh-CN.md", "需要你知道或决定")):
4345
+ if needle not in (ROOT / guide).read_text(encoding="utf-8"):
4346
+ report(f"{label} {guide} does not state the owner-mention rule ({needle!r}).")
4347
+ return 1
4348
+
4349
+ if "chat-owner-mention" not in {name for name, _ in SCENARIOS}:
4350
+ report(f"{label} scenario is not registered.")
4351
+ return 1
4352
+ report("chat-owner-mention scenario passed.")
4353
+ return 0
4354
+
4355
+
4214
4356
  def validate_chat_archive_scenario() -> int:
4215
4357
  """Issue #187: chat history is archived to an orphan branch, never exposed.
4216
4358
 
@@ -36369,6 +36511,10 @@ SCENARIOS: tuple = (
36369
36511
  "chat-bridge-start-race",
36370
36512
  validate_chat_bridge_start_race_scenario,
36371
36513
  ),
36514
+ (
36515
+ "chat-owner-mention",
36516
+ validate_chat_owner_mention_scenario,
36517
+ ),
36372
36518
  (
36373
36519
  "chat-role-apps",
36374
36520
  validate_chat_role_apps_scenario,
@@ -36389,6 +36535,10 @@ SCENARIOS: tuple = (
36389
36535
  "chat-slack-format",
36390
36536
  validate_chat_slack_format_scenario,
36391
36537
  ),
36538
+ (
36539
+ "chat-issue-links",
36540
+ validate_chat_issue_links_scenario,
36541
+ ),
36392
36542
  (
36393
36543
  "chat-archive",
36394
36544
  validate_chat_archive_scenario,
@@ -71,14 +71,14 @@ const BUNDLED = {
71
71
  sendsTo: "DeepSeek, through the provider the profile configures (by default deepseek-official, model deepseek-flash)",
72
72
  pitfalls: [
73
73
  {
74
- date: "2026-10-04",
75
- source: "dsh --version, 0.2.0-rc.2",
76
- text: "The CLI lives inside the app bundle and is not on PATH.",
74
+ date: "2026-10-05",
75
+ source: "ls -l ~/.local/bin/dsh and dsh --version, 0.2.0-rc.2 (rtl_ppa_prj #191)",
76
+ text: "The CLI lives inside the app bundle. A `~/.local/bin/dsh` on PATH, where one exists, is a symlink to that same file, so the catalog keeps the bundle path, which works with or without it.",
77
77
  },
78
78
  {
79
79
  date: "2026-10-05",
80
- source: "dsh --profile headless, 0.2.0-rc.2",
81
- text: "The headless profile fails with MISSING_CREDENTIAL until a DeepSeek API key is stored through the app's Models page or DEEPSEEK_API_KEY is exported where it is launched.",
80
+ source: "dsh --profile headless, 0.2.0-rc.2 (rtl_ppa_prj #191)",
81
+ text: "First use needs a DeepSeek API key, stored once through the app's Models page or exported as DEEPSEEK_API_KEY where it is launched; until then the headless profile fails with MISSING_CREDENTIAL. With the key stored it runs from any directory.",
82
82
  },
83
83
  {
84
84
  date: "2026-10-04",
@@ -172,7 +172,7 @@ function bodyText(record) {
172
172
  // `[redacted]`, and neither the cut pointer nor the owner mention is Markdown
173
173
  // to translate (chat-slack-format D1).
174
174
  function slackText(project, record, text) {
175
- let result = mrkdwn.toSlack(redact(text));
175
+ let result = mrkdwn.toSlack(redact(text), { repo: project.github });
176
176
  if (result.length > TEXT_LIMIT) {
177
177
  result = `${result.slice(0, TEXT_LIMIT)}… (cut; full text: \`keel chat show ${record.id}\`)`;
178
178
  }
@@ -850,10 +850,19 @@ function prepareProjects() {
850
850
  if (!project.channelGroups.has(channel)) project.channelGroups.set(channel, group);
851
851
  }
852
852
  buildTsIndex(project);
853
+ project.github = githubRepo(project.where.worktree);
853
854
  }
854
855
  return projects;
855
856
  }
856
857
 
858
+ // `owner/repo` of the project's `origin` when it is on GitHub, which a bare
859
+ // `#N` in a record links to (chat-issue-links D1); null otherwise.
860
+ function githubRepo(worktree) {
861
+ const result = require("child_process").spawnSync("git", ["remote", "get-url", "origin"], { cwd: worktree, encoding: "utf8", timeout: 5000 });
862
+ const match = String(result.stdout || "").trim().match(/github\.com[:/]([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/);
863
+ return result.status === 0 && match ? match[1] : null;
864
+ }
865
+
857
866
  async function createContext(log, { needApp }) {
858
867
  requireWebSocket();
859
868
  const { bot, app } = lifecycle.tokens();
@@ -16,6 +16,11 @@ const BOLD = "\u0001";
16
16
  // on each side of every marker pair supplies the boundary, checked against
17
17
  // real Slack on 2026-10-05 (#187). Inbound text drops them again.
18
18
  const ZWSP = "\u200b";
19
+ // An issue reference at a word boundary, `owner/repo#N` or a bare `#N`, and
20
+ // any Slack link already made, which is matched first so that a reference
21
+ // inside one is left alone (chat-issue-links D3).
22
+ const ISSUE = /(<[^>\n]*>)|(?<![\w#/;&.-])((?:([\w.-]+\/[\w.-]+))?#(\d{1,7}))(?![\w#])/g;
23
+ const ISSUE_LINK = /<https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/(?:issues|pull)\/\d+\|((?:[\w.-]+\/[\w.-]+)?#\d+)>/g;
19
24
 
20
25
  // Calls `prose` on the text outside code and `code` on the code itself.
21
26
  function byCode(text, prose, code) {
@@ -45,9 +50,20 @@ function unescape(text) {
45
50
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
46
51
  }
47
52
 
48
- function proseToSlack(text) {
49
- return escape(text)
50
- .replace(/\[([^\]\n]+)\]\((https?:\/\/[^)\s]+|mailto:[^)\s]+)\)/g, (match, label, url) => `<${url}|${label}>`)
53
+ // `owner/repo#N` links to that repository; a bare `#N` to `repo`, the
54
+ // project's own GitHub repository, and stays text without one (D1, D2).
55
+ function linkIssues(text, repo) {
56
+ return text.replace(ISSUE, (match, link, ref, named, number) => {
57
+ if (link) return link;
58
+ const target = named || repo;
59
+ if (!target) return match;
60
+ return `<https://github.com/${target}/issues/${number}|${ref}>`;
61
+ });
62
+ }
63
+
64
+ function proseToSlack(text, repo) {
65
+ return linkIssues(escape(text)
66
+ .replace(/\[([^\]\n]+)\]\((https?:\/\/[^)\s]+|mailto:[^)\s]+)\)/g, (match, label, url) => `<${url}|${label}>`), repo)
51
67
  .replace(/^(\s*)[-*+][ \t]+/gm, "$1• ")
52
68
  .replace(/^#{1,6}[ \t]+(.+?)[ \t]*#*[ \t]*$/gm, `${BOLD}$1${BOLD}`)
53
69
  .replace(/\*\*(?!\s)([^\n]+?)\*\*/g, `${BOLD}$1${BOLD}`)
@@ -59,6 +75,7 @@ function proseToSlack(text) {
59
75
 
60
76
  function proseFromSlack(text) {
61
77
  return unescape(text.split(ZWSP).join("")
78
+ .replace(ISSUE_LINK, "$1")
62
79
  .replace(/<((?:https?:\/\/|mailto:)[^|>\s]+)\|([^>]+)>/g, "[$2]($1)")
63
80
  .replace(/<((?:https?:\/\/|mailto:)[^|>\s]+)>/g, "$1")
64
81
  .replace(/(^|[^\w*])\*(?![\s*])([^*\n]+?)\*(?![\w*])/g, `$1${BOLD}${BOLD}$2${BOLD}${BOLD}`)
@@ -67,8 +84,8 @@ function proseFromSlack(text) {
67
84
  .split(BOLD).join("*"));
68
85
  }
69
86
 
70
- function toSlack(text) {
71
- return byCode(String(text || ""), proseToSlack, escape);
87
+ function toSlack(text, { repo = null } = {}) {
88
+ return byCode(String(text || ""), (prose) => proseToSlack(prose, repo), escape);
72
89
  }
73
90
 
74
91
  function fromSlack(text) {
@@ -132,14 +132,24 @@ function bridgeLine(where) {
132
132
  }
133
133
  if (!settings.enabled) return null;
134
134
  const status = require("./bridge").fullStatus();
135
+ let line;
135
136
  if (!status.running) {
136
- return "keel chat bridge: not running on this machine, so Slack messages are not reaching this session "
137
+ line = "keel chat bridge: not running on this machine, so Slack messages are not reaching this session "
137
138
  + "(local chat still works). `keel chat bridge start`, or `keel chat bridge install` once, brings it up.";
139
+ } else if (status.paused) {
140
+ line = `keel chat bridge: paused until ${status.paused_until}; messages wait until then.`;
141
+ } else {
142
+ line = `keel chat bridge: running${status.connected ? " and connected" : ", reconnecting"}, serving ${status.projects.length} project${status.projects.length === 1 ? "" : "s"}.`;
138
143
  }
139
- if (status.paused) return `keel chat bridge: paused until ${status.paused_until}; messages wait until then.`;
140
- return `keel chat bridge: running${status.connected ? " and connected" : ", reconnecting"}, serving ${status.projects.length} project${status.projects.length === 1 ? "" : "s"}.`;
144
+ return settings.owner ? `${line}\n${OWNER_RULE}` : line;
141
145
  }
142
146
 
147
+ // The owner's rule of 2026-10-05 (chat-owner-mention D1-D3): Slack notifies
148
+ // the owner only for a mention, and the bridge mentions them only for
149
+ // `@owner`, so whether a message reaches their phone is the session's choice.
150
+ const OWNER_RULE = "Slack notifies the owner only for messages that write `@owner`: write it in any message the owner "
151
+ + "needs to see or decide on, and leave it out of routine discussion.";
152
+
143
153
  const HOST_EVENTS = {
144
154
  "session-start": "SessionStart",
145
155
  "user-prompt-submit": "UserPromptSubmit",