@christang/keel 5.79.0 → 5.81.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.
package/README.md CHANGED
@@ -46,9 +46,10 @@ Node.js `>=20.19.0` (the bundled OpenSpec CLI needs it).
46
46
 
47
47
  ## Install
48
48
 
49
- **Claude Code** — the plugin is the whole install. It is the published `@christang/keel`
50
- package, so it carries the `keel` CLI and the bundled OpenSpec along with the skills and hooks,
51
- and the agent's `keel` commands run the copy the plugin brought:
49
+ **Claude Code** — the plugin is the whole install. It is this repository at the release's tag,
50
+ the same tree npm publishes as `@christang/keel`, so it carries the `keel` CLI along with the
51
+ skills and hooks, and Claude installs the pinned OpenSpec from its lockfile when it installs the
52
+ plugin. The agent's `keel` commands run the copy the plugin brought:
52
53
 
53
54
  ```bash
54
55
  claude plugin marketplace add TanglmChris/keel
@@ -62,6 +63,10 @@ in the background after a session's first message; `/reload-plugins` applies it
62
63
  session, and otherwise it applies at the next start. To opt out, set that entry's `autoUpdate` to
63
64
  `false`; Keel keeps a value the project states, and `keel --doctor` reports which one is declared.
64
65
 
66
+ Each release's notes also carry the entry Anthropic's official plugin directory would list for it,
67
+ pinned to the commit the release tag points at. The directory takes the same tagged tree this
68
+ marketplace installs.
69
+
65
70
  **Codex, and your own terminal** — install the CLI as well (it also installs the bundled
66
71
  OpenSpec CLI):
67
72
 
package/README.zh-CN.md CHANGED
@@ -38,8 +38,9 @@ Node.js `>=20.19.0`(内置的 OpenSpec CLI 需要)。
38
38
 
39
39
  ## 安装
40
40
 
41
- **Claude Code** —— 装插件就够了。插件本身就是发布的 `@christang/keel` 包,技能和 hook 之外还带着
42
- `keel` CLI 和捆绑的 OpenSpec;agent 运行的 `keel` 就是插件带来的这一份:
41
+ **Claude Code** —— 装插件就够了。插件就是本仓库在发布 tag 上的那棵树,和 npm 发布的 `@christang/keel`
42
+ 是同一份,技能和 hook 之外还带着 `keel` CLI;安装插件时 Claude 会按锁文件装好锁定版本的 OpenSpec。
43
+ agent 运行的 `keel` 就是插件带来的这一份:
43
44
 
44
45
  ```bash
45
46
  claude plugin marketplace add TanglmChris/keel
@@ -51,6 +52,9 @@ claude plugin install keel@keel-marketplace
51
52
  新版本会在会话发出第一条消息后在后台下载;执行 `/reload-plugins` 即在当前会话生效,否则下次启动时生效。
52
53
  不想自动更新,就把那一项的 `autoUpdate` 设为 `false`;项目写明的值 Keel 会保留,`keel --doctor` 会报告当前声明的是哪一个。
53
54
 
55
+ 每个版本的 release notes 里还附有 Anthropic 官方插件目录对应的条目,锁定到该版本 tag 指向的 commit。
56
+ 官方目录装到的就是这个 marketplace 装的同一棵带 tag 的树。
57
+
54
58
  **Codex,以及你自己的终端** —— 另外装一份 CLI(同时装上捆绑的 OpenSpec CLI):
55
59
 
56
60
  ```bash
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.79.0 -->
1
+ <!-- keel:start version=5.81.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.
package/bin/keel CHANGED
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  // The bare `keel` a Claude plugin's `bin/` puts on the agent's PATH (#164).
5
- // On Claude the plugin is this published package, and the host adds `bin/`
5
+ // On Claude the plugin is this repository's tagged tree, and the host adds `bin/`
6
6
  // to PATH by file name, so `keel.js` alone would answer to `keel.js`. npm's
7
7
  // own `bin` map keeps pointing at `keel.js`; this file only gives the plugin
8
8
  // the same name.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.79.0",
3
+ "version": "5.81.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.79.0",
9
+ "version": "5.81.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.79.0",
5
+ "version": "5.81.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.79.0",
3
+ "version": "5.81.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.79.0",
3
+ "version": "5.81.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",
@@ -137,7 +137,7 @@ function pluginManifest() {
137
137
  return { version: null, remedy: HOST_UPDATE };
138
138
  }
139
139
 
140
- // On Claude the plugin is the published package, cached at
140
+ // On Claude the plugin is the repository's tagged tree, cached at
141
141
  // <plugins>/cache/<marketplace>/<plugin>/<version>, and the host records what
142
142
  // it installed in <plugins>/installed_plugins.json (#172). Another install of
143
143
  // this same plugin at a different version means the update already happened
@@ -315,7 +315,7 @@ function panel(lines) {
315
315
  ].join("\n");
316
316
  }
317
317
 
318
- // On Claude the plugin is the published package (#164), so the CLI it shipped
318
+ // On Claude the plugin is the repository's tagged tree (#164), so the CLI it shipped
319
319
  // with sits three levels above this script. It is recognized by the package's
320
320
  // name and not by the path alone: a Codex cache holds only `plugins/keel`, and
321
321
  // whatever lies above that is not this plugin's to run.
@@ -4,8 +4,8 @@
4
4
  // One-shot version bump across every place Keel pins its version.
5
5
  //
6
6
  // The Keel validation suite requires the same version in package.json,
7
- // npm-shrinkwrap.json, both native plugin manifests, the Claude marketplace
8
- // entry and the package release it pins, the validator constants, the
7
+ // npm-shrinkwrap.json, the native plugin manifests, the Claude marketplace
8
+ // entry and the release tag it installs, the validator constants, the
9
9
  // protocol docs, and the changelog. This script updates all of them together
10
10
  // so a release never ships half-aligned.
11
11
  //
@@ -62,19 +62,31 @@ function bumpPackageFiles(newVersion) {
62
62
  process.stdout.write(" updated npm-shrinkwrap.json\n");
63
63
  }
64
64
 
65
- // On Claude the plugin is the published package (#164): the marketplace entry
66
- // is its manifest, labeled with the release and pinned to that same release of
67
- // `@christang/keel`. Both numbers move, or a refresh installs the old package.
65
+ // On Claude the plugin is the tagged repository tree. Its root manifest carries
66
+ // the release version, and Keel's marketplace entry names that version and the
67
+ // tag it installs from git. All three move, or a refresh installs the old tree.
68
68
  function bumpClaudeMarketplace(newVersion) {
69
+ const manifestRel = ".claude-plugin/plugin.json";
70
+ const manifestPath = path.join(ROOT, manifestRel);
71
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
72
+ manifest.version = newVersion;
73
+ writeJson(manifestPath, manifest);
74
+ process.stdout.write(` updated ${manifestRel}\n`);
75
+
69
76
  const relPath = ".claude-plugin/marketplace.json";
70
77
  const filePath = path.join(ROOT, relPath);
71
78
  const market = JSON.parse(fs.readFileSync(filePath, "utf8"));
72
79
  const entry = (market.plugins || []).find((plugin) => plugin.name === "keel");
73
- if (!entry || !entry.source || typeof entry.source !== "object") {
74
- fail(`expected an npm-sourced keel entry in ${relPath}`);
80
+ if (
81
+ !entry
82
+ || !entry.source
83
+ || typeof entry.source !== "object"
84
+ || entry.source.source !== "url"
85
+ ) {
86
+ fail(`expected a git-sourced keel entry in ${relPath}`);
75
87
  }
76
88
  entry.version = newVersion;
77
- entry.source.version = newVersion;
89
+ entry.source.ref = `v${newVersion}`;
78
90
  writeJson(filePath, market);
79
91
  process.stdout.write(` updated ${relPath}\n`);
80
92
  }
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // The entry Anthropic's official plugin directory would list for a release.
5
+ //
6
+ // The directory pins every third-party plugin to a commit of its git
7
+ // repository, so the entry is only useful pinned to the commit the release
8
+ // tag points at. The release job appends this output to the release notes;
9
+ // submitting it, or asking the directory to move its pin, is the owner's act.
10
+ // This script reads the root manifest and nothing else, and runs nothing.
11
+ //
12
+ // Usage:
13
+ // node scripts/official_entry.js <X.Y.Z> <40-character commit sha>
14
+
15
+ const fs = require("fs");
16
+ const path = require("path");
17
+
18
+ const ROOT = path.resolve(__dirname, "..");
19
+ const REPOSITORY = "https://github.com/TanglmChris/keel";
20
+
21
+ const [version, sha] = process.argv.slice(2);
22
+ // A pin the directory could not use prints nothing, so a pipe into the notes
23
+ // cannot carry a half-formed entry.
24
+ if (!/^\d+\.\d+\.\d+$/.test(version || "") || !/^[0-9a-f]{40}$/.test(sha || "")) {
25
+ process.stderr.write(
26
+ "official-entry: usage: node scripts/official_entry.js <X.Y.Z> <40-hex commit sha>\n"
27
+ );
28
+ process.exit(1);
29
+ }
30
+ const manifest = JSON.parse(
31
+ fs.readFileSync(path.join(ROOT, ".claude-plugin", "plugin.json"), "utf8")
32
+ );
33
+ const entry = {
34
+ name: manifest.name,
35
+ description: manifest.description,
36
+ category: "development",
37
+ source: { source: "url", url: `${REPOSITORY}.git`, sha },
38
+ homepage: REPOSITORY,
39
+ };
40
+ process.stdout.write(`${JSON.stringify(entry, null, 2)}\n`);
@@ -38,8 +38,8 @@ REQUIRED_SCRIPTS = [
38
38
  "scripts/validate_plugin.py",
39
39
  ]
40
40
 
41
- PACKAGE_VERSION = "5.79.0"
42
- PROTOCOL_VERSION = "5.79.0"
41
+ PACKAGE_VERSION = "5.81.0"
42
+ PROTOCOL_VERSION = "5.81.0"
43
43
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
44
44
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
45
45
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -1702,7 +1702,7 @@ def validate_unparsed_covers_critical_statement_scenario() -> int:
1702
1702
  f"must report Unparsed, got: {message!r}"
1703
1703
  )
1704
1704
  return 1
1705
- if "D2 — one-line statement" not in message:
1705
+ if "D2 — statement" not in message:
1706
1706
  report(
1707
1707
  "unparsed-covers-critical-statement: the Unparsed message must "
1708
1708
  f"name the required shape, got: {message!r}"
@@ -1873,6 +1873,248 @@ def validate_widened_critical_statement_shapes_scenario() -> int:
1873
1873
  return 0
1874
1874
 
1875
1875
 
1876
+ def validate_whole_critical_statement_authority_scenario() -> int:
1877
+ """Issue #177: every owned line, but no sibling, binds cited authority."""
1878
+ task = task_capsule_compact_fixture().replace(
1879
+ " - E1: Public behavior passes.\n", " - D1\n"
1880
+ )
1881
+ base = (
1882
+ "## Decisions\n\n"
1883
+ "- D1 — Preserve semantics.\n"
1884
+ " continuation alpha\n"
1885
+ " - nested detail alpha\n\n"
1886
+ "- D2 — Peer decision.\n\n"
1887
+ "Independent paragraph.\n\n"
1888
+ "## Following heading\n"
1889
+ )
1890
+
1891
+ with tempfile.TemporaryDirectory(prefix="keel-whole-critical-") as raw:
1892
+ repo = Path(raw)
1893
+ design_path = repo / "openspec/changes/demo/design.md"
1894
+ write_text(repo / "openspec/changes/demo/tasks.md", task)
1895
+
1896
+ def start(design: str, *extra: str) -> tuple[int, dict]:
1897
+ write_text(design_path, design)
1898
+ result = run_keel(
1899
+ repo, "gate", "task-start", "--change", "demo", "--task", "1.1",
1900
+ *extra, "--json",
1901
+ )
1902
+ return result.returncode, json.loads(result.stdout)
1903
+
1904
+ code, initial = start(base)
1905
+ if code != 0:
1906
+ report("whole-critical-statement-authority: accepted D1 did not compile.")
1907
+ report(str(initial))
1908
+ return 1
1909
+ authority = initial["contract"]["capsule"]["authority"]
1910
+ if authority[0]["text"] != (
1911
+ "Preserve semantics. continuation alpha - nested detail alpha"
1912
+ ):
1913
+ report(
1914
+ "whole-critical-statement-authority: the D1 authority omitted "
1915
+ f"an owned line: {authority[0]['text']!r}"
1916
+ )
1917
+ return 1
1918
+ fingerprint = initial["contract"]["fingerprint"]["value"]
1919
+
1920
+ for old, new, label in (
1921
+ ("continuation alpha", "continuation beta", "continuation"),
1922
+ ("nested detail alpha", "nested detail beta", "nested bullet"),
1923
+ ):
1924
+ code, changed = start(base.replace(old, new))
1925
+ if code != 0:
1926
+ report(f"whole-critical-statement-authority: {label} edit failed to compile.")
1927
+ return 1
1928
+ if changed["contract"]["fingerprint"]["value"] == fingerprint:
1929
+ report(
1930
+ f"whole-critical-statement-authority: {label} edit left "
1931
+ "the cited contract fingerprint unchanged."
1932
+ )
1933
+ return 1
1934
+
1935
+ for old, new, label in (
1936
+ ("Peer decision", "Changed peer", "peer bullet"),
1937
+ ("Independent paragraph", "Changed paragraph", "peer paragraph"),
1938
+ ("Following heading", "Changed heading", "heading"),
1939
+ ):
1940
+ code, changed = start(base.replace(old, new))
1941
+ if code != 0:
1942
+ report(f"whole-critical-statement-authority: {label} edit failed to compile.")
1943
+ return 1
1944
+ if changed["contract"]["fingerprint"]["value"] != fingerprint:
1945
+ report(
1946
+ f"whole-critical-statement-authority: {label} edit "
1947
+ "incorrectly changed D1 authority."
1948
+ )
1949
+ return 1
1950
+
1951
+ # A `#` line nested inside the item is owned content (a code sample's
1952
+ # comment, a heading inside the list item), and an unindented line
1953
+ # with no blank before it continues the paragraph lazily. Neither may
1954
+ # cut the statement short; a blank-separated paragraph still ends it.
1955
+ for design, old, new, label in (
1956
+ (
1957
+ "## Decisions\n\n- D1 — Opener.\n - detail one\n"
1958
+ " # sample comment\n - detail after hash\n",
1959
+ "detail after hash", "detail changed", "detail after a nested #",
1960
+ ),
1961
+ (
1962
+ "## Decisions\n\n- D1 — Opener wraps\nlazily onto this line.\n\n"
1963
+ "Separate paragraph.\n",
1964
+ "lazily onto", "lazily into", "lazy continuation",
1965
+ ),
1966
+ ):
1967
+ before_code, before = start(design)
1968
+ after_code, after = start(design.replace(old, new))
1969
+ if before_code != 0 or after_code != 0:
1970
+ report(f"whole-critical-statement-authority: {label} case failed to compile.")
1971
+ return 1
1972
+ if before["contract"]["fingerprint"]["value"] == after["contract"]["fingerprint"]["value"]:
1973
+ report(
1974
+ f"whole-critical-statement-authority: {label} edit left "
1975
+ "the cited contract fingerprint unchanged."
1976
+ )
1977
+ return 1
1978
+ if "Separate paragraph" not in design:
1979
+ continue
1980
+ _, peer = start(design.replace("Separate paragraph", "Changed paragraph"))
1981
+ if peer["contract"]["fingerprint"]["value"] != before["contract"]["fingerprint"]["value"]:
1982
+ report(
1983
+ f"whole-critical-statement-authority: {label} case let a "
1984
+ "blank-separated paragraph change D1 authority."
1985
+ )
1986
+ return 1
1987
+
1988
+ # Consecutive unbulleted openers are one CommonMark paragraph, but
1989
+ # each is its own decision: a peer opener is never a lazy line.
1990
+ adjacent = "## Decisions\n\nD1 — First.\n**D2** — Second.\n"
1991
+ before_code, before = start(adjacent)
1992
+ after_code, after = start(adjacent.replace("Second", "Changed"))
1993
+ if before_code != 0 or after_code != 0:
1994
+ report("whole-critical-statement-authority: adjacent-opener case failed to compile.")
1995
+ return 1
1996
+ if before["contract"]["fingerprint"]["value"] != after["contract"]["fingerprint"]["value"]:
1997
+ report(
1998
+ "whole-critical-statement-authority: an adjacent unbulleted "
1999
+ "peer opener was absorbed into D1 authority."
2000
+ )
2001
+ return 1
2002
+
2003
+ code, recorded = start(base, "--record", "--no-guard")
2004
+ if code != 0 or recorded.get("record", {}).get("status") != "recorded":
2005
+ report("whole-critical-statement-authority: could not record D1 anchor.")
2006
+ return 1
2007
+ write_text(design_path, base.replace("nested detail alpha", "nested detail beta"))
2008
+ completion = run_keel(
2009
+ repo, "gate", "task-complete", "--change", "demo", "--task", "1.1", "--json"
2010
+ )
2011
+ problems = json.loads(completion.stdout).get("problems", [])
2012
+ if not any(item.get("code") == "contract-drift" for item in problems):
2013
+ report(
2014
+ "whole-critical-statement-authority: task-complete missed "
2015
+ "drift after a nested detail changed."
2016
+ )
2017
+ report(completion.stdout.strip())
2018
+ return 1
2019
+
2020
+ code, colon = start("## Decisions\n\n- D1: colon shape.\n")
2021
+ messages = [item.get("message", "") for item in colon.get("problems", [])]
2022
+ if code == 0 or not any(
2023
+ "Unparsed Covers critical statement: D1." in message
2024
+ and "D1 —" in message
2025
+ for message in messages
2026
+ ):
2027
+ report("whole-critical-statement-authority: colon shape lost its actionable refusal.")
2028
+ return 1
2029
+
2030
+ if "whole-critical-statement-authority" not in {name for name, _ in SCENARIOS}:
2031
+ report("whole-critical-statement-authority: scenario is not registered.")
2032
+ return 1
2033
+ report("whole-critical-statement-authority scenario passed.")
2034
+ return 0
2035
+
2036
+
2037
+ def validate_unlinked_critical_covers_scenario() -> int:
2038
+ """Issue #177: critical citations must not silently become legacy prose."""
2039
+ design = (
2040
+ "## Decisions\n\n"
2041
+ "- D1 — First decision.\n"
2042
+ "- D2 — Second decision.\n"
2043
+ )
2044
+ with tempfile.TemporaryDirectory(prefix="keel-unlinked-critical-") as raw:
2045
+ repo = Path(raw)
2046
+ write_text(repo / "openspec/changes/demo/design.md", design)
2047
+
2048
+ def start(covers: str) -> tuple[int, dict]:
2049
+ write_text(
2050
+ repo / "openspec/changes/demo/tasks.md",
2051
+ task_capsule_compact_fixture().replace(
2052
+ " - E1: Public behavior passes.\n", f" - {covers}\n"
2053
+ ),
2054
+ )
2055
+ result = run_keel(
2056
+ repo, "gate", "task-start", "--change", "demo", "--task", "1.1", "--json"
2057
+ )
2058
+ return result.returncode, json.loads(result.stdout)
2059
+
2060
+ for covers in (
2061
+ "D1、D2",
2062
+ "D1,D2",
2063
+ "D1 D2",
2064
+ "Implement both decisions(D1、D2)",
2065
+ ):
2066
+ code, payload = start(covers)
2067
+ messages = [item.get("message", "") for item in payload.get("problems", [])]
2068
+ if code == 0:
2069
+ report(f"unlinked-critical-covers: {covers!r} passed as unlinked prose.")
2070
+ return 1
2071
+ if not any(covers in message and "D1, D2" in message for message in messages):
2072
+ report(
2073
+ f"unlinked-critical-covers: {covers!r} lacks a diagnostic "
2074
+ "naming the entry and the supported list form."
2075
+ )
2076
+ report(str(messages))
2077
+ return 1
2078
+
2079
+ for covers, expected in (
2080
+ ("D1", ["D1"]),
2081
+ ("D1, D2", ["D1", "D2"]),
2082
+ ("D1 — annotation", ["D1"]),
2083
+ ):
2084
+ code, payload = start(covers)
2085
+ if code != 0:
2086
+ report(f"unlinked-critical-covers: supported {covers!r} failed.")
2087
+ report(str(payload.get("problems", [])))
2088
+ return 1
2089
+ authority = payload["contract"]["capsule"]["authority"]
2090
+ actual = [item["reference"] for item in authority]
2091
+ if actual != expected or any(
2092
+ item["kind"] != "critical-statement" for item in authority
2093
+ ):
2094
+ report(
2095
+ f"unlinked-critical-covers: supported {covers!r} lost "
2096
+ f"linked authority: {authority!r}"
2097
+ )
2098
+ return 1
2099
+
2100
+ for covers in (
2101
+ "F13 (Q1 resolved: the answer is recorded)",
2102
+ "D2: colon-form legacy description",
2103
+ "D2-compatible fixture text",
2104
+ ):
2105
+ code, payload = start(covers)
2106
+ if code != 0:
2107
+ report(f"unlinked-critical-covers: existing free text {covers!r} was rejected.")
2108
+ report(str(payload.get("problems", [])))
2109
+ return 1
2110
+
2111
+ if "unlinked-critical-covers" not in {name for name, _ in SCENARIOS}:
2112
+ report("unlinked-critical-covers: scenario is not registered.")
2113
+ return 1
2114
+ report("unlinked-critical-covers scenario passed.")
2115
+ return 0
2116
+
2117
+
1876
2118
  def validate_covers_annotation_entry_scenario() -> int:
1877
2119
  """Issue #49 Section 1's fail-open half, owner-decided 2026-08-17: a Covers
1878
2120
  entry that opens with a critical-statement identifier and a dash
@@ -2371,9 +2613,10 @@ def validate_version_alignment_scenario() -> int:
2371
2613
  )
2372
2614
  return 1
2373
2615
 
2374
- # M5 — on Claude the marketplace entry is the manifest and names the
2375
- # package release it installs (#164), so both of its numbers are version
2376
- # markers, and the script that moves every marker has to move them.
2616
+ # M5 — on Claude the plugin is the tagged repository: the root manifest
2617
+ # carries the version, and the marketplace entry names it and the tag it
2618
+ # installs, so all three are version markers, and the script that moves
2619
+ # every marker has to move them.
2377
2620
  def claude_entry_versions(root: Path) -> dict:
2378
2621
  market = json.loads(
2379
2622
  (root / ".claude-plugin/marketplace.json").read_text(encoding="utf-8")
@@ -2382,11 +2625,23 @@ def validate_version_alignment_scenario() -> int:
2382
2625
  (e for e in market.get("plugins", []) if e.get("name") == "keel"), {}
2383
2626
  )
2384
2627
  source = entry.get("source") if isinstance(entry.get("source"), dict) else {}
2385
- return {"version": entry.get("version"), "source.version": source.get("version")}
2628
+ ref = source.get("ref")
2629
+ return {
2630
+ "version": entry.get("version"),
2631
+ "source.ref": ref[1:] if isinstance(ref, str) and ref.startswith("v") else ref,
2632
+ }
2633
+
2634
+ def root_manifest_version(root: Path) -> str | None:
2635
+ manifest = root / ".claude-plugin/plugin.json"
2636
+ if not manifest.is_file():
2637
+ return None
2638
+ return json.loads(manifest.read_text(encoding="utf-8")).get("version")
2386
2639
 
2387
2640
  stale = {
2388
2641
  k: v for k, v in claude_entry_versions(ROOT).items() if v != PACKAGE_VERSION
2389
2642
  }
2643
+ if root_manifest_version(ROOT) != PACKAGE_VERSION:
2644
+ stale["root plugin manifest"] = root_manifest_version(ROOT)
2390
2645
  if stale:
2391
2646
  report(
2392
2647
  "version-alignment scenario claude marketplace entry version "
@@ -2399,6 +2654,7 @@ def validate_version_alignment_scenario() -> int:
2399
2654
  "package.json",
2400
2655
  "npm-shrinkwrap.json",
2401
2656
  ".claude-plugin/marketplace.json",
2657
+ ".claude-plugin/plugin.json",
2402
2658
  "plugins/keel/.claude-plugin/plugin.json",
2403
2659
  "plugins/keel/.codex-plugin/plugin.json",
2404
2660
  "scripts/bump_version.js",
@@ -2421,6 +2677,12 @@ def validate_version_alignment_scenario() -> int:
2421
2677
  report("version-alignment scenario: bump_version.js failed in a scratch copy.")
2422
2678
  report((bumped.stderr or bumped.stdout).strip())
2423
2679
  return 1
2680
+ if root_manifest_version(scratch) != "99.0.0":
2681
+ report(
2682
+ "version-alignment scenario root plugin manifest was not moved "
2683
+ f"by bump_version.js: {root_manifest_version(scratch)!r}"
2684
+ )
2685
+ return 1
2424
2686
  left = {
2425
2687
  k: v
2426
2688
  for k, v in claude_entry_versions(scratch).items()
@@ -14834,51 +15096,53 @@ def validate_native_plugin_manifests_scenario() -> int:
14834
15096
  ),
14835
15097
  None,
14836
15098
  )
14837
- # M1 — on Claude the plugin is the published package (#164): the entry
14838
- # fetches it from npm, pinned to the release it is labeled with, and acts
14839
- # as the manifest. An unpinned source would let a refresh between merge
14840
- # and publish cache the previous package under the new label.
14841
- source = (claude_entry or {}).get("source")
14842
- if (
14843
- not isinstance(source, dict)
14844
- or source.get("source") != "npm"
14845
- or source.get("package") != "@christang/keel"
14846
- ):
15099
+ # M1 — on Claude the plugin is the tagged repository tree, and the manifest
15100
+ # at its root is the one Claude manifest, so a directory entry nobody here
15101
+ # controls only has to say where the repository is.
15102
+ root_manifest_path = ROOT / ".claude-plugin/plugin.json"
15103
+ if not root_manifest_path.is_file():
14847
15104
  report(
14848
- "native-plugin-manifests claude marketplace entry is not the "
14849
- f"published package: source {source!r}"
15105
+ "native-plugin-manifests has no root plugin manifest at "
15106
+ ".claude-plugin/plugin.json, so a git-sourced entry has nothing to "
15107
+ "read the skills, agent, and hooks from."
14850
15108
  )
14851
15109
  return 1
14852
- pinned = {
14853
- "version": claude_entry.get("version"),
14854
- "source.version": source.get("version"),
14855
- }
14856
- unpinned = {k: v for k, v in pinned.items() if v != package_version}
14857
- if unpinned:
15110
+ root_manifest = json.loads(root_manifest_path.read_text(encoding="utf-8"))
15111
+ plugin_manifest = json.loads(
15112
+ (ROOT / PLUGIN_ROOT / ".claude-plugin/plugin.json").read_text(
15113
+ encoding="utf-8"
15114
+ )
15115
+ )
15116
+ differing = [
15117
+ key
15118
+ for key in ("name", "version", "description")
15119
+ if root_manifest.get(key) != plugin_manifest.get(key)
15120
+ or root_manifest.get(key) in (None, "")
15121
+ ]
15122
+ if differing or root_manifest.get("version") != package_version:
14858
15123
  report(
14859
- "native-plugin-manifests claude marketplace entry is not the "
14860
- f"published package at {package_version}: {unpinned!r}"
15124
+ "native-plugin-manifests root plugin manifest disagrees with "
15125
+ f"{PLUGIN_ROOT}/.claude-plugin/plugin.json or the package version "
15126
+ f"{package_version} on {differing or ['version']!r}"
14861
15127
  )
14862
15128
  return 1
14863
15129
  declared_paths = [
14864
- *claude_entry.get("skills", []),
14865
- *claude_entry.get("agents", []),
15130
+ *root_manifest.get("skills", []),
15131
+ *root_manifest.get("agents", []),
14866
15132
  ]
14867
15133
  unresolved = [
14868
15134
  path for path in declared_paths if not (ROOT / path).exists()
14869
15135
  ]
14870
15136
  if not declared_paths or unresolved:
14871
15137
  report(
14872
- "native-plugin-manifests claude marketplace entry is not the "
14873
- "published package's manifest: its skills and agents must resolve "
14874
- f"inside the package; declared {declared_paths!r}, unresolved "
14875
- f"{unresolved!r}"
15138
+ "native-plugin-manifests root plugin manifest's skills and agents "
15139
+ f"must resolve inside the repository; declared {declared_paths!r}, "
15140
+ f"unresolved {unresolved!r}"
14876
15141
  )
14877
15142
  return 1
14878
-
14879
- # M2 — the entry states the hooks a second time, so it is held to the
14880
- # file Codex discovers: the same events, matchers, scripts, and timeouts,
14881
- # with each script path resolved from the package root instead.
15143
+ # The manifest states the hooks a second time, so it is held to the file
15144
+ # Codex discovers: the same events, matchers, scripts, and timeouts, with
15145
+ # each script path resolved from the repository root instead.
14882
15146
  plugin_hooks = json.loads(
14883
15147
  (ROOT / PLUGIN_ROOT / "hooks/hooks.json").read_text(encoding="utf-8")
14884
15148
  )["hooks"]
@@ -14888,11 +15152,37 @@ def validate_native_plugin_manifests_scenario() -> int:
14888
15152
  "${CLAUDE_PLUGIN_ROOT}/plugins/keel/scripts/",
14889
15153
  )
14890
15154
  )
14891
- if claude_entry.get("hooks") != expected_hooks:
15155
+ if root_manifest.get("hooks") != expected_hooks:
14892
15156
  report(
14893
- "native-plugin-manifests claude marketplace entry hooks diverge "
15157
+ "native-plugin-manifests root plugin manifest hooks diverge "
14894
15158
  f"from {PLUGIN_ROOT}/hooks/hooks.json after resolving script paths "
14895
- f"from the package root: {claude_entry.get('hooks')!r}"
15159
+ f"from the repository root: {root_manifest.get('hooks')!r}"
15160
+ )
15161
+ return 1
15162
+
15163
+ # M2 — Keel's own entry installs the same tagged tree the official
15164
+ # directory would, from git. It pins the tag rather than a commit because
15165
+ # the file is part of the commit it would have to name, and it restates no
15166
+ # component, so the root manifest stays the only place they are declared.
15167
+ source = (claude_entry or {}).get("source")
15168
+ want_source = {
15169
+ "source": "url",
15170
+ "url": KEEL_REPOSITORY_GIT_URL,
15171
+ "ref": f"v{package_version}",
15172
+ }
15173
+ restated = [
15174
+ key for key in ("skills", "agents", "hooks") if key in (claude_entry or {})
15175
+ ]
15176
+ if (
15177
+ source != want_source
15178
+ or (claude_entry or {}).get("version") != package_version
15179
+ or restated
15180
+ ):
15181
+ report(
15182
+ "native-plugin-manifests claude marketplace entry is not the "
15183
+ f"tagged repository at v{package_version}: source {source!r}, "
15184
+ f"version {(claude_entry or {}).get('version')!r}, restated "
15185
+ f"components {restated!r}"
14896
15186
  )
14897
15187
  return 1
14898
15188
 
@@ -15450,6 +15740,9 @@ def validate_native_plugin_session_start_scenario() -> int:
15450
15740
  # one independently: the plugin's by planting a manifest beside a copy of the
15451
15741
  # shipping hook, the CLI's by what the fake CLI prints, and the repository's by
15452
15742
  # the managed block in its AGENTS.md.
15743
+ # Where the Claude plugin is fetched from, by Keel's marketplace and by the
15744
+ # official directory entry each release states.
15745
+ KEEL_REPOSITORY_GIT_URL = "https://github.com/TanglmChris/keel.git"
15453
15746
  VERSION_DRIFT_STATEMENT = "runtime versions disagree"
15454
15747
  # How an update applies: the hooks are fixed when the plugin loads, and the
15455
15748
  # host's `/reload-plugins` reloads it in the running session (#164). A restart
@@ -15867,7 +16160,7 @@ def plant_path_keel(directory: Path, cli_script: Path) -> Path:
15867
16160
 
15868
16161
 
15869
16162
  def validate_plugin_runs_its_own_cli_scenario() -> int:
15870
- """Issue #164: on Claude the plugin is the published package.
16163
+ """Issue #164: on Claude the plugin carries the whole package.
15871
16164
 
15872
16165
  The hook, running from inside that package, must run the CLI the package
15873
16166
  ships rather than whatever `keel` is on PATH, and must report a PATH copy
@@ -16131,44 +16424,160 @@ def validate_drift_names_a_pending_reload_scenario() -> int:
16131
16424
  return 0
16132
16425
 
16133
16426
 
16427
+ def validate_official_directory_entry_scenario() -> int:
16428
+ """Each release states the entry Anthropic's official directory would list.
16429
+
16430
+ The directory pins third-party plugins to a commit of a git repository, so
16431
+ the entry is only useful pinned to the commit the release tag points at.
16432
+ Keel prints it and submits nothing.
16433
+ """
16434
+ label = "official-directory-entry"
16435
+ script = ROOT / "scripts/official_entry.js"
16436
+ sha = "0123456789abcdef0123456789abcdef01234567"
16437
+
16438
+ def run(*args: str) -> subprocess.CompletedProcess[str]:
16439
+ return subprocess.run(
16440
+ ["node", str(script), *args],
16441
+ cwd=ROOT,
16442
+ text=True,
16443
+ encoding="utf-8",
16444
+ errors="replace",
16445
+ capture_output=True,
16446
+ check=False,
16447
+ )
16448
+
16449
+ # M1 — the entry, pinned to the given commit.
16450
+ printed = run("5.80.0", sha)
16451
+ try:
16452
+ entry = json.loads(printed.stdout) if printed.returncode == 0 else None
16453
+ except ValueError:
16454
+ entry = None
16455
+ if not isinstance(entry, dict):
16456
+ report(
16457
+ f"{label} M1 printed no official directory entry: exit "
16458
+ f"{printed.returncode}, {(printed.stderr or printed.stdout).strip()!r}"
16459
+ )
16460
+ return 1
16461
+ manifest = json.loads(
16462
+ (ROOT / ".claude-plugin/plugin.json").read_text(encoding="utf-8")
16463
+ )
16464
+ want = {
16465
+ "name": "keel",
16466
+ "description": manifest.get("description"),
16467
+ "category": "development",
16468
+ "source": {"source": "url", "url": KEEL_REPOSITORY_GIT_URL, "sha": sha},
16469
+ "homepage": "https://github.com/TanglmChris/keel",
16470
+ }
16471
+ if entry != want:
16472
+ report(
16473
+ f"{label} M1 printed an entry that is not the release's: "
16474
+ f"{entry!r}, expected {want!r}"
16475
+ )
16476
+ return 1
16477
+
16478
+ # M2 — a pin the directory could not use is refused, and prints nothing a
16479
+ # careless pipe could paste.
16480
+ for args in (("5.80", sha), ("5.80.0", sha[:-1])):
16481
+ refused = run(*args)
16482
+ if refused.returncode == 0 or refused.stdout.strip():
16483
+ report(
16484
+ f"{label} M2 accepted a malformed pin {args!r}: exit "
16485
+ f"{refused.returncode}, stdout {refused.stdout!r}"
16486
+ )
16487
+ return 1
16488
+
16489
+ # M3 — the release job appends the entry for the tag's commit to the notes
16490
+ # before it creates the release.
16491
+ workflow = (ROOT / ".github/workflows/publish.yml").read_text(encoding="utf-8")
16492
+ step = workflow[workflow.find("name: Tag and release the landed version"):]
16493
+ create = step.find("gh release create")
16494
+ append = step.find('node scripts/official_entry.js "$VERSION" "$SHA"')
16495
+ if append < 0:
16496
+ report(
16497
+ f"{label} M3 release notes do not carry the official directory "
16498
+ "entry: the release step never runs `node scripts/official_entry.js "
16499
+ '"$VERSION" "$SHA"`.'
16500
+ )
16501
+ return 1
16502
+ if create < 0:
16503
+ report(f"{label} M3 the release step no longer runs `gh release create`.")
16504
+ return 1
16505
+ if create < append:
16506
+ report(
16507
+ f"{label} M3 the release step creates the release before it "
16508
+ "writes the official directory entry, so the notes miss it."
16509
+ )
16510
+ return 1
16511
+ if ">> notes.md" not in step[append:create]:
16512
+ report(
16513
+ f"{label} M3 the release step runs official_entry.js but does not "
16514
+ "append its output to notes.md."
16515
+ )
16516
+ return 1
16517
+
16518
+ report(f"{label} scenario passed.")
16519
+ return 0
16520
+
16521
+
16134
16522
  def stage_claude_market_under_test(tmp: Path) -> tuple[Path, str, str] | str:
16135
- """A Claude marketplace that installs this tree rather than the registry.
16136
-
16137
- The committed entry installs the published package at this release, which
16138
- does not exist on the registry until the release lands (#164), and at a
16139
- version that does exist it installs the registry's copy and tests nothing
16140
- here. So an install smoke packs the tree the way npm publishes it and puts
16141
- it behind a copy of the committed entry whose source points at it and whose
16142
- manifest fields are unchanged. A sentinel only the packed tree carries lets
16143
- the caller prove which copy was installed. Returns the marketplace
16144
- directory, its name, and the sentinel, or a failure message.
16523
+ """A Claude marketplace that installs this tree rather than GitHub's.
16524
+
16525
+ The committed entry installs the Keel repository at this release's tag,
16526
+ which does not exist until the release lands, and at a tag that does exist
16527
+ it installs GitHub's copy and tests nothing here. So an install smoke
16528
+ stages the working tree — tracked and untracked-but-not-ignored files, as
16529
+ they are on disk — as a scratch git repository tagged the same way, and
16530
+ puts it behind a copy of the committed entry whose URL points at it and
16531
+ whose other fields are unchanged. The host then fetches it through git and
16532
+ installs its dependencies exactly as it would from GitHub. A sentinel only
16533
+ the staged tree carries lets the caller prove which copy was installed.
16534
+ Returns the marketplace directory, its name, and the sentinel, or a failure
16535
+ message.
16145
16536
  """
16146
- npm = shutil.which("npm")
16147
- if npm is None:
16148
- return "needs npm to pack the package under test."
16149
- packed = subprocess.run(
16150
- [npm, "pack", "--json", "--pack-destination", str(tmp)],
16537
+ git = shutil.which("git")
16538
+ if git is None:
16539
+ return "needs git to stage the tree under test."
16540
+ listed = subprocess.run(
16541
+ [git, "ls-files", "-z", "--cached", "--others", "--exclude-standard"],
16151
16542
  cwd=ROOT,
16152
- text=True,
16153
- encoding="utf-8",
16154
- errors="replace",
16155
16543
  capture_output=True,
16156
16544
  check=False,
16157
16545
  )
16158
- if packed.returncode != 0:
16159
- return "npm pack failed: " + (packed.stderr or packed.stdout).strip()
16160
- tarball = tmp / json.loads(packed.stdout)[0]["filename"]
16161
- market = tmp / "claude-market"
16162
- market.mkdir()
16163
- subprocess.run(["tar", "-xzf", str(tarball), "-C", str(market)], check=True)
16546
+ if listed.returncode != 0:
16547
+ return "git ls-files failed: " + listed.stderr.decode("utf-8", "replace")
16548
+ staged = tmp / "keel-under-test"
16549
+ for relative in filter(None, listed.stdout.decode("utf-8").split("\0")):
16550
+ source = ROOT / relative
16551
+ if not source.is_file():
16552
+ continue
16553
+ target = staged / relative
16554
+ target.parent.mkdir(parents=True, exist_ok=True)
16555
+ shutil.copy2(source, target)
16164
16556
  sentinel = ".keel-package-under-test"
16165
- write_text(market / "package" / sentinel, "\n")
16557
+ write_text(staged / sentinel, "\n")
16166
16558
  committed = json.loads(
16167
16559
  (ROOT / ".claude-plugin/marketplace.json").read_text(encoding="utf-8")
16168
16560
  )
16169
- for entry in committed.get("plugins", []):
16170
- if entry.get("name") == "keel":
16171
- entry["source"] = "./package"
16561
+ entry = next(
16562
+ (e for e in committed.get("plugins", []) if e.get("name") == "keel"), None
16563
+ )
16564
+ source_field = (entry or {}).get("source")
16565
+ if not isinstance(source_field, dict) or not source_field.get("ref"):
16566
+ return f"the committed Claude entry pins no git ref: {source_field!r}"
16567
+ identity = ["-c", "user.name=keel", "-c", "user.email=keel@invalid"]
16568
+ for args in (
16569
+ ["init", "-q"],
16570
+ ["add", "-A"],
16571
+ [*identity, "commit", "-q", "-m", "tree under test"],
16572
+ ["tag", source_field["ref"]],
16573
+ ):
16574
+ done = subprocess.run(
16575
+ [git, *args], cwd=staged, capture_output=True, text=True, check=False
16576
+ )
16577
+ if done.returncode != 0:
16578
+ return f"git {args[-1]} failed staging the tree: {done.stderr.strip()}"
16579
+ source_field["url"] = staged.resolve().as_uri()
16580
+ market = tmp / "claude-market"
16172
16581
  write_text(
16173
16582
  market / ".claude-plugin/marketplace.json",
16174
16583
  json.dumps(committed, indent=2) + "\n",
@@ -16176,6 +16585,16 @@ def stage_claude_market_under_test(tmp: Path) -> tuple[Path, str, str] | str:
16176
16585
  return market, committed["name"], sentinel
16177
16586
 
16178
16587
 
16588
+ def shrinkwrap_openspec_version() -> str | None:
16589
+ """The OpenSpec version the committed lockfile pins."""
16590
+ lock = json.loads((ROOT / "npm-shrinkwrap.json").read_text(encoding="utf-8"))
16591
+ return (
16592
+ lock.get("packages", {})
16593
+ .get("node_modules/@fission-ai/openspec", {})
16594
+ .get("version")
16595
+ )
16596
+
16597
+
16179
16598
  def installed_elsewhere(config: Path, market_name: str, sentinel: str) -> list | None:
16180
16599
  """None when Keel was installed from the package under test, else the paths."""
16181
16600
  installed = json.loads(
@@ -16695,7 +17114,69 @@ def validate_native_plugin_marketplaces_scenario() -> int:
16695
17114
  report(
16696
17115
  "native-plugin-marketplaces claude plugin install failed to use "
16697
17116
  f"the package under test; it installed from {elsewhere!r}, "
16698
- "which does not carry the sentinel the packed tree does."
17117
+ "which does not carry the sentinel the staged tree does."
17118
+ )
17119
+ return 1
17120
+ # M4 — the git install is a working plugin: the host loaded the
17121
+ # skills and both hooks from the root manifest, and installed the
17122
+ # OpenSpec the lockfile pins, since nothing in the tree carries it.
17123
+ details = run_claude("plugin", "details", f"keel@{claude_market_name}")
17124
+ details_text = details.stdout or ""
17125
+ missing = [
17126
+ needle
17127
+ for needle in (
17128
+ "keel-align-expectations",
17129
+ "keel-review-checklist",
17130
+ "SessionStart",
17131
+ "PreToolUse",
17132
+ )
17133
+ if needle not in details_text
17134
+ ]
17135
+ if details.returncode != 0:
17136
+ report(
17137
+ "native-plugin-marketplaces claude plugin details failed for "
17138
+ f"the git-installed plugin: {(details.stderr or details_text).strip()!r}"
17139
+ )
17140
+ return 1
17141
+ if missing:
17142
+ report(
17143
+ "native-plugin-marketplaces the git-installed plugin lacks "
17144
+ f"{missing!r} in claude plugin details: {details_text!r}"
17145
+ )
17146
+ return 1
17147
+ installed = json.loads(
17148
+ (claude_config / "plugins/installed_plugins.json").read_text(
17149
+ encoding="utf-8"
17150
+ )
17151
+ )
17152
+ install_path = Path(
17153
+ installed["plugins"][f"keel@{claude_market_name}"][0]["installPath"]
17154
+ )
17155
+ openspec_bin = install_path / "node_modules/.bin/openspec"
17156
+ if not openspec_bin.exists():
17157
+ report(
17158
+ "native-plugin-marketplaces the git-installed plugin has no "
17159
+ f"installed OpenSpec at {openspec_bin}; the host did not "
17160
+ "install the tree's dependencies."
17161
+ )
17162
+ return 1
17163
+ probe = subprocess.run(
17164
+ [str(openspec_bin), "--version"],
17165
+ text=True,
17166
+ capture_output=True,
17167
+ check=False,
17168
+ )
17169
+ pinned = shrinkwrap_openspec_version()
17170
+ if probe.returncode != 0:
17171
+ report(
17172
+ "native-plugin-marketplaces the git-installed OpenSpec failed "
17173
+ f"to run: {(probe.stderr or probe.stdout).strip()!r}"
17174
+ )
17175
+ return 1
17176
+ if pinned not in probe.stdout:
17177
+ report(
17178
+ "native-plugin-marketplaces the git-installed plugin does not "
17179
+ f"carry the pinned OpenSpec {pinned}: {probe.stdout.strip()!r}"
16699
17180
  )
16700
17181
  return 1
16701
17182
  claude_list = run_claude("plugin", "list")
@@ -31356,6 +31837,14 @@ SCENARIOS: tuple = (
31356
31837
  "widened-critical-statement-shapes",
31357
31838
  validate_widened_critical_statement_shapes_scenario,
31358
31839
  ),
31840
+ (
31841
+ "whole-critical-statement-authority",
31842
+ validate_whole_critical_statement_authority_scenario,
31843
+ ),
31844
+ (
31845
+ "unlinked-critical-covers",
31846
+ validate_unlinked_critical_covers_scenario,
31847
+ ),
31359
31848
  (
31360
31849
  "covers-annotation-entry",
31361
31850
  validate_covers_annotation_entry_scenario,
@@ -31576,6 +32065,7 @@ SCENARIOS: tuple = (
31576
32065
  ("runtime-version-drift", validate_runtime_version_drift_scenario),
31577
32066
  ("plugin-runs-its-own-cli", validate_plugin_runs_its_own_cli_scenario),
31578
32067
  ("drift-names-a-pending-reload", validate_drift_names_a_pending_reload_scenario),
32068
+ ("official-directory-entry", validate_official_directory_entry_scenario),
31579
32069
  ("init-declares-plugin-auto-update", validate_init_declares_plugin_auto_update_scenario),
31580
32070
  ("context-names-the-protocol-refresh", validate_context_names_the_protocol_refresh_scenario),
31581
32071
  ("init-never-downgrades-openspec", validate_init_never_downgrades_openspec_scenario),
@@ -1033,18 +1033,22 @@ function criticalAuthority(repo, change, reference) {
1033
1033
  };
1034
1034
  }
1035
1035
  const content = fs.readFileSync(designPath, "utf8");
1036
- // Accepted line shapes: an optional CommonMark list bullet, the identifier
1037
- // bare or wrapped in balanced `**`, then the dash and statement. Authors
1038
- // overwhelmingly write the bulleted and bold shapes (issue #49).
1039
- const matches = [
1040
- ...content.matchAll(
1041
- new RegExp(
1042
- `^\\s*(?:[-*+]\\s+)?(?:\\*\\*${reference}\\*\\*|${reference})`
1043
- + `\\s*[—-]\\s*(.+?)\\s*$`,
1044
- "gmi"
1045
- )
1046
- ),
1047
- ];
1036
+ // Resolve the opener by line, then collect its owned indented lines. A
1037
+ // multiline regex matched only the opener (issue #177), so changing a nested
1038
+ // decision detail left the contract fingerprint unchanged. Keep the accepted
1039
+ // bullet/bold/dash opener shapes from issue #49; colon remains unparsed.
1040
+ const lines = content.split(/\r?\n/);
1041
+ const opener = new RegExp(
1042
+ `^([ \\t]*)((?:[-*+][ \\t]+)?)(?:\\*\\*${reference}\\*\\*|${reference})`
1043
+ + `[ \\t]*[—-][ \\t]*(.+?)[ \\t]*$`,
1044
+ "i"
1045
+ );
1046
+ const matches = lines.flatMap((line, index) => {
1047
+ const match = line.match(opener);
1048
+ return match
1049
+ ? [{ index, indent: match[1], bullet: match[2], text: match[3] }]
1050
+ : [];
1051
+ });
1048
1052
  if (matches.length !== 1) {
1049
1053
  // Zero matches is ambiguous: the identifier may never appear in design.md,
1050
1054
  // or it may appear in some other shape (bulleted, bold) that the strict
@@ -1062,7 +1066,7 @@ function criticalAuthority(repo, change, reference) {
1062
1066
  `Unparsed Covers critical statement: ${reference}. It appears in `
1063
1067
  + "design.md but not in an accepted line shape — write it as a "
1064
1068
  + "line opening with the identifier and a dash, "
1065
- + `\`${reference} — one-line statement\`, optionally as a list `
1069
+ + `\`${reference} — statement\`, optionally as a list `
1066
1070
  + `bullet (\`- ${reference} — …\`) and/or with the identifier `
1067
1071
  + `bold (\`**${reference}** — …\`).`,
1068
1072
  },
@@ -1077,13 +1081,53 @@ function criticalAuthority(repo, change, reference) {
1077
1081
  },
1078
1082
  };
1079
1083
  }
1084
+ const indentColumns = (prefix) => {
1085
+ let columns = 0;
1086
+ for (const character of prefix) {
1087
+ columns += character === "\t" ? 4 - (columns % 4) : 1;
1088
+ }
1089
+ return columns;
1090
+ };
1091
+ const match = matches[0];
1092
+ const openerIndent = indentColumns(match.indent);
1093
+ // A heading shallower than the item's content column closes the item; one
1094
+ // at or past it is nested inside the item and stays owned, as does a deeper
1095
+ // `#` line such as a code sample's comment. An unbulleted opener has no
1096
+ // content column beyond itself, so CommonMark's three-space heading indent
1097
+ // applies there.
1098
+ const headingLimit = match.bullet
1099
+ ? openerIndent + indentColumns(match.bullet)
1100
+ : openerIndent + 4;
1101
+ // A line opening with another critical identifier and a dash is a peer
1102
+ // statement even without a bullet, never a lazy continuation of this one.
1103
+ const blockStart = new RegExp(
1104
+ "^[ \\t]*(?:[-*+][ \\t]|\\d+[.)][ \\t]|>|```|~~~|#{1,6}(?:[ \\t]|$)"
1105
+ + "|(?:\\*\\*)?[DFAQ]\\d+(?:\\*\\*)?[ \\t]*[—-])",
1106
+ "i"
1107
+ );
1108
+ const statementLines = [match.text];
1109
+ let previousBlank = false;
1110
+ for (const line of lines.slice(match.index + 1)) {
1111
+ if (!line.trim()) {
1112
+ previousBlank = true;
1113
+ continue;
1114
+ }
1115
+ const columns = indentColumns(line.match(/^[ \t]*/)[0]);
1116
+ if (/^[ \t]*#{1,6}(?:[ \t]|$)/.test(line) && columns < headingLimit) break;
1117
+ // A shallower line directly after owned text, starting no block of its
1118
+ // own, is a lazy paragraph continuation; after a blank line it is a peer.
1119
+ const lazy = !previousBlank && !blockStart.test(line);
1120
+ if (columns <= openerIndent && !lazy) break;
1121
+ previousBlank = false;
1122
+ statementLines.push(line.trim());
1123
+ }
1080
1124
  return {
1081
1125
  authority: {
1082
1126
  kind: "critical-statement",
1083
1127
  reference,
1084
1128
  source:
1085
1129
  `${path.relative(repo, designPath).replace(/\\/g, "/")}#${reference}`,
1086
- text: normalizeText(matches[0][1]),
1130
+ text: normalizeText(statementLines.join("\n")),
1087
1131
  acceptance: [],
1088
1132
  },
1089
1133
  };
@@ -1135,6 +1179,30 @@ function resolveAuthority(repo, change, task) {
1135
1179
  if (spec.authority) authority.push(spec.authority);
1136
1180
  continue;
1137
1181
  }
1182
+ // A combined citation that missed the supported ASCII-comma expansion
1183
+ // must not become unlinked legacy prose (issue #177). This scan excludes
1184
+ // hyphenated words such as `D2-compatible`, and preserves the existing
1185
+ // colon-form legacy entry and closed-question note beside a fact. Valid
1186
+ // opening references and their annotations already continued above.
1187
+ const criticalMentions = [
1188
+ ...entry.matchAll(/(?:^|[^A-Za-z0-9_-])([DFAQ]\d+)(?![A-Za-z0-9_-])/g),
1189
+ ].map((match) => match[1]);
1190
+ const colonLegacy =
1191
+ criticalMentions.length === 1
1192
+ && /^[DFAQ]\d+\s*:\s*.+$/.test(entry);
1193
+ const closedQuestionNote =
1194
+ criticalMentions.length === 2
1195
+ && /^F\d+\s*\(\s*Q\d+\s+resolved\s*:/i.test(entry);
1196
+ if (criticalMentions.length > 0 && !colonLegacy && !closedQuestionNote) {
1197
+ diagnostics.push({
1198
+ code: "unresolved-covers",
1199
+ message:
1200
+ `Covers critical references are not linked: ${entry}. `
1201
+ + "Write each identifier as its own Covers entry, or use an "
1202
+ + "ASCII-comma list such as `D1, D2`.",
1203
+ });
1204
+ continue;
1205
+ }
1138
1206
  const match = entry.match(/^([A-Za-z]\d+)\s*:\s*(.+)$/);
1139
1207
  authority.push({
1140
1208
  kind: "legacy-task-reference",