kbforge-okfquery 0.2.2__tar.gz → 0.3.0__tar.gz

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 (28) hide show
  1. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/PKG-INFO +24 -1
  2. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/README.md +23 -0
  3. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/pyproject.toml +1 -1
  4. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/src/okfquery/cli.py +35 -1
  5. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/src/okfquery/index.py +20 -11
  6. kbforge_okfquery-0.3.0/src/okfquery/related.py +85 -0
  7. kbforge_okfquery-0.3.0/tests/test_related.py +166 -0
  8. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/.gitignore +0 -0
  9. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/src/okfquery/__init__.py +0 -0
  10. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/src/okfquery/load.py +0 -0
  11. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/src/okfquery/parse.py +0 -0
  12. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/src/okfquery/schema.py +0 -0
  13. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/clean/concepts/api/overview.md +0 -0
  14. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/badyaml/overview.md +0 -0
  15. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/claims/index.md +0 -0
  16. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/incomplete/overview.md +0 -0
  17. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/index.md +0 -0
  18. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/log.md +0 -0
  19. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/nofence/overview.md +0 -0
  20. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/notmapping/overview.md +0 -0
  21. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/ok/overview.md +0 -0
  22. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/fixtures/messy/concepts/unterminated/overview.md +0 -0
  23. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/test_index.py +0 -0
  24. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/test_load.py +0 -0
  25. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/test_okfquery_cli.py +0 -0
  26. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/test_okfquery_live.py +0 -0
  27. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/test_parse.py +0 -0
  28. {kbforge_okfquery-0.2.2 → kbforge_okfquery-0.3.0}/tests/test_roundtrip.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: kbforge-okfquery
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: SQL over an OKF v0.2 bundle, via DuckDB
5
5
  Author-email: Qing <qingye779@gmail.com>
6
6
  License: MIT
@@ -148,6 +148,29 @@ every request that adds or retitles a concept would fail it, and fixing that on
148
148
  the sync branches makes several systems edit one whole-bundle file, the
149
149
  collision this job exists to avoid.
150
150
 
151
+ ## `related`: what one concept connects to
152
+
153
+ ```bash
154
+ okfquery related concepts/gaps/redundant-supply/overview.md --bundle .
155
+ okfquery related concepts/reports/q3/overview.md --by tags,scenario --limit 5
156
+ ```
157
+
158
+ Three sections, each line in `index`'s `* [Title](path) - description` format:
159
+
160
+ - **Links to**: the concept's `links`. A target not in the bundle is listed by
161
+ its path.
162
+ - **Linked from**: concepts whose `links` name it. No single file shows these.
163
+ - **Shares**: concepts sharing at least one value of the `--by` facets (default
164
+ `tags`), most shared values first, then by path, each naming what it shares
165
+ (`(shares tags: 800v, sic)`). Concepts already listed above are left out, and
166
+ `--limit` (default 10) caps this section only.
167
+
168
+ An empty section prints `(none)`, so "nothing" reads differently from "not
169
+ checked". These relations are derived when asked, not stored: OKF §3.1 leaves
170
+ tag views to the consumer, and a derived view cannot go stale. A path with a
171
+ leading `/` (OKF §6.1's bundle-absolute form) or `./` is accepted, in the
172
+ argument and in `links`.
173
+
151
174
  ## Schema
152
175
 
153
176
  ```
@@ -135,6 +135,29 @@ every request that adds or retitles a concept would fail it, and fixing that on
135
135
  the sync branches makes several systems edit one whole-bundle file, the
136
136
  collision this job exists to avoid.
137
137
 
138
+ ## `related`: what one concept connects to
139
+
140
+ ```bash
141
+ okfquery related concepts/gaps/redundant-supply/overview.md --bundle .
142
+ okfquery related concepts/reports/q3/overview.md --by tags,scenario --limit 5
143
+ ```
144
+
145
+ Three sections, each line in `index`'s `* [Title](path) - description` format:
146
+
147
+ - **Links to**: the concept's `links`. A target not in the bundle is listed by
148
+ its path.
149
+ - **Linked from**: concepts whose `links` name it. No single file shows these.
150
+ - **Shares**: concepts sharing at least one value of the `--by` facets (default
151
+ `tags`), most shared values first, then by path, each naming what it shares
152
+ (`(shares tags: 800v, sic)`). Concepts already listed above are left out, and
153
+ `--limit` (default 10) caps this section only.
154
+
155
+ An empty section prints `(none)`, so "nothing" reads differently from "not
156
+ checked". These relations are derived when asked, not stored: OKF §3.1 leaves
157
+ tag views to the consumer, and a derived view cannot go stale. A path with a
158
+ leading `/` (OKF §6.1's bundle-absolute form) or `./` is accepted, in the
159
+ argument and in `links`.
160
+
138
161
  ## Schema
139
162
 
140
163
  ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kbforge-okfquery"
3
- version = "0.2.2"
3
+ version = "0.3.0"
4
4
  description = "SQL over an OKF v0.2 bundle, via DuckDB"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -1,4 +1,4 @@
1
- """argparse over `load()`. Five verbs, no query logic of its own.
1
+ """argparse over `load()`. Six verbs, no query logic of its own.
2
2
 
3
3
  There is deliberately no --format parquet and no --output: DuckDB writes parquet
4
4
  from inside the SQL (`COPY (...) TO 'out.parquet'`), and a second export path
@@ -23,6 +23,7 @@ from okfquery.index import (
23
23
  write_index,
24
24
  )
25
25
  from okfquery.load import EmptyMirrorError, load
26
+ from okfquery.related import render_related
26
27
  from okfquery.schema import SCHEMA_SQL
27
28
 
28
29
 
@@ -125,6 +126,19 @@ def _index_in(bundle: Path, args: argparse.Namespace) -> int:
125
126
  return 0
126
127
 
127
128
 
129
+ def _related(args: argparse.Namespace) -> int:
130
+ if _bundle_missing(args.bundle):
131
+ print(f"no concepts/ directory under {args.bundle}", file=sys.stderr)
132
+ return 2
133
+ by = [key.strip() for key in args.by.split(",") if key.strip()]
134
+ try:
135
+ print(render_related(Path(args.bundle), args.path, by, args.limit), end="")
136
+ except ValueError as exc:
137
+ print(exc, file=sys.stderr)
138
+ return 2
139
+ return 0
140
+
141
+
128
142
  def main(argv: list[str] | None = None) -> int:
129
143
  parser = argparse.ArgumentParser(prog="okfquery", description=__doc__)
130
144
  sub = parser.add_subparsers(dest="command", required=True)
@@ -165,6 +179,24 @@ def main(argv: list[str] | None = None) -> int:
165
179
  "--force", action="store_true", help="replace a hand-written index.md"
166
180
  )
167
181
 
182
+ related = sub.add_parser(
183
+ "related", help="links, backlinks and shared-facet neighbours of a concept"
184
+ )
185
+ related.add_argument("path", help="the concept, e.g. concepts/x/overview.md")
186
+ related.add_argument("--bundle", default=".", help="bundle root (default: .)")
187
+ related.add_argument(
188
+ "--by",
189
+ default="tags",
190
+ metavar="FACETS",
191
+ help="comma-separated facets to match on (default: tags)",
192
+ )
193
+ related.add_argument(
194
+ "--limit",
195
+ type=int,
196
+ default=10,
197
+ help="most shared-facet neighbours to list (default: 10)",
198
+ )
199
+
168
200
  args = parser.parse_args(argv)
169
201
 
170
202
  if args.command == "schema":
@@ -174,6 +206,8 @@ def main(argv: list[str] | None = None) -> int:
174
206
  return _shell(args)
175
207
  if args.command == "index":
176
208
  return _index(args)
209
+ if args.command == "related":
210
+ return _related(args)
177
211
 
178
212
  if _bundle_missing(args.bundle):
179
213
  print(f"no concepts/ directory under {args.bundle}", file=sys.stderr)
@@ -60,7 +60,7 @@ def _one_line(text: str | None) -> str:
60
60
  return " ".join((text or "").split())
61
61
 
62
62
 
63
- def _entry(path: str, title: str | None, description: str | None) -> str:
63
+ def entry(path: str, title: str | None, description: str | None) -> str:
64
64
  line = f"* [{_link_text(_one_line(title) or path)}]({_target(path)})"
65
65
  summary = _one_line(description)
66
66
  return f"{line} - {summary}" if summary else line
@@ -72,21 +72,30 @@ def _label(value: object) -> str:
72
72
  return value if isinstance(value, str) else json.dumps(value)
73
73
 
74
74
 
75
+ def _labels(values: list[object]) -> list[str]:
76
+ labels = (_one_line(_label(v)) for v in values if v is not None)
77
+ return sorted({label for label in labels if label})
78
+
79
+
80
+ def facet_values(facets: str | dict | None, key: str) -> list[str]:
81
+ """One facet's values as sorted labels; a scalar is a one-value list and an
82
+ empty value counts as missing. Shared by `index --group-by` and `related`,
83
+ so "shares a tag" and "listed under the same heading" cannot disagree."""
84
+ if isinstance(facets, str): # DuckDB hands a JSON column back as text
85
+ facets = json.loads(facets)
86
+ value = facets.get(key) if isinstance(facets, dict) else None
87
+ return _labels(value if isinstance(value, list) else [value])
88
+
89
+
75
90
  def _groups(
76
91
  type_: str | None, facets: str | dict | None, group_by: str | None
77
92
  ) -> list[str]:
78
93
  """The sections a concept is listed under; [] means the trailing one. A list
79
94
  facet (tags, say) lists the concept once under each of its values, so
80
- concepts sharing a tag share a section. An empty value counts as missing."""
95
+ concepts sharing a tag share a section."""
81
96
  if group_by is None:
82
- values: list[object] = [type_]
83
- else:
84
- if isinstance(facets, str): # DuckDB hands a JSON column back as text
85
- facets = json.loads(facets)
86
- value = facets.get(group_by) if isinstance(facets, dict) else None
87
- values = value if isinstance(value, list) else [value]
88
- labels = (_one_line(_label(v)) for v in values if v is not None)
89
- return sorted({label for label in labels if label})
97
+ return _labels([type_])
98
+ return facet_values(facets, group_by)
90
99
 
91
100
 
92
101
  def render_bundle(bundle: Path, group_by: str | None = None) -> str:
@@ -117,7 +126,7 @@ def render_bundle(bundle: Path, group_by: str | None = None) -> str:
117
126
  groups[key], key=lambda e: ((_one_line(e[1]) or e[0]).casefold(), e[0])
118
127
  )
119
128
  lines += ["", f"# {heading}", ""]
120
- lines += [_entry(*e) for e in entries]
129
+ lines += [entry(*e) for e in entries]
121
130
  return "\n".join(lines) + "\n"
122
131
 
123
132
 
@@ -0,0 +1,85 @@
1
+ """`okfquery related`: what one concept connects to, derived when asked.
2
+
3
+ OKF §3.1 leaves tag views to the consumer ("synthesize one at consumption time
4
+ by scanning frontmatter"), so relations implied by a shared tag or facet value
5
+ are computed here rather than stored as links a producer must keep fresh.
6
+ Backlinks are here for the same reason: no single file shows them.
7
+
8
+ Lines use `okfquery index`'s format, so an agent reads both the same way."""
9
+
10
+ from __future__ import annotations
11
+
12
+ from pathlib import Path
13
+
14
+ from okfquery.index import entry, facet_values
15
+ from okfquery.load import load
16
+ from okfquery.parse import OKF_OWNED
17
+
18
+ NONE = "(none)"
19
+ """An empty section says so: an agent must tell "nothing" from "not checked"."""
20
+
21
+
22
+ def _norm(path: str) -> str:
23
+ """Bundle-relative, as the `concepts` table stores it. OKF §6.1 recommends
24
+ a leading `/` for bundle-absolute links, and a shell user types `./`."""
25
+ return path.removeprefix("./").lstrip("/")
26
+
27
+
28
+ def _section(heading: str, lines: list[str]) -> list[str]:
29
+ return [f"# {heading}", "", *(lines or [NONE])]
30
+
31
+
32
+ def render_related(
33
+ bundle: Path, path: str, by: list[str] | None = None, limit: int = 10
34
+ ) -> str:
35
+ """Links to, linked from, and up to `limit` concepts sharing a value of any
36
+ `by` facet (default `tags`), ranked by how many values they share, then by
37
+ path. Deterministic: every ordering is total."""
38
+ if limit < 1:
39
+ # A slice would take a negative limit from the END, dropping neighbours
40
+ # silently, and 0 would print a "(none)" that claims nothing is shared.
41
+ raise ValueError(f"--limit must be at least 1, not {limit}")
42
+ by = by or ["tags"]
43
+ for key in by:
44
+ if key in OKF_OWNED:
45
+ # Those keys never reach `facets`, so nothing would ever match and
46
+ # the section would read as a real "(none)".
47
+ raise ValueError(f"{key!r} is not a facet: OKF owns it")
48
+ path = _norm(path)
49
+ con = load(bundle)
50
+ rows = {
51
+ p: (title, description, facets)
52
+ for p, title, description, facets in con.execute(
53
+ "select path, title, description, facets from concepts"
54
+ ).fetchall()
55
+ }
56
+ if path not in rows:
57
+ raise ValueError(f"{path} is not a concept in {bundle}")
58
+
59
+ def line(p: str) -> str:
60
+ title, description, _ = rows.get(p, (None, None, None))
61
+ return entry(p, title, description)
62
+
63
+ # Normalized in Python, not SQL: `_norm` is the one rule for what a link
64
+ # target names, and a bundle may mix `/concepts/...` with `concepts/...`.
65
+ links = con.execute("select path, target from links").fetchall()
66
+ out_ = sorted({_norm(t) for p, t in links if p == path} - {path})
67
+ in_ = sorted({p for p, t in links if _norm(t) == path and p != path})
68
+ seen = {path, *out_, *in_}
69
+
70
+ own = {key: set(facet_values(rows[path][2], key)) for key in by}
71
+ ranked: list[tuple[int, str, str]] = []
72
+ for p, (_, _, facets) in rows.items():
73
+ if p in seen:
74
+ continue
75
+ shared = {key: sorted(own[key] & set(facet_values(facets, key))) for key in by}
76
+ count = sum(len(v) for v in shared.values())
77
+ if count:
78
+ what = "; ".join(f"{k}: {', '.join(v)}" for k, v in shared.items() if v)
79
+ ranked.append((count, p, f"{line(p)} (shares {what})"))
80
+ ranked.sort(key=lambda r: (-r[0], r[1]))
81
+
82
+ lines = _section("Links to", [line(p) for p in out_])
83
+ lines += ["", *_section("Linked from", [line(p) for p in in_])]
84
+ lines += ["", *_section(f"Shares {', '.join(by)}", [r[2] for r in ranked[:limit]])]
85
+ return "\n".join(lines) + "\n"
@@ -0,0 +1,166 @@
1
+ """`okfquery related`: links, backlinks, and shared-facet neighbours of one
2
+ concept, derived at query time (OKF §3.1) rather than stored in the bundle."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from pathlib import Path
7
+
8
+ import pytest
9
+
10
+ from okfquery.cli import main
11
+ from okfquery.related import render_related
12
+
13
+
14
+ def _concept(bundle: Path, slug: str, front: str) -> str:
15
+ path = bundle / "concepts" / slug / "overview.md"
16
+ path.parent.mkdir(parents=True, exist_ok=True)
17
+ path.write_text(f"---\n{front}---\nBody of {slug}.\n", "utf-8")
18
+ return f"concepts/{slug}/overview.md"
19
+
20
+
21
+ @pytest.fixture
22
+ def bundle(tmp_path: Path) -> Path:
23
+ _concept(
24
+ tmp_path,
25
+ "gap",
26
+ "type: gap\ntitle: Redundant supply\n"
27
+ "description: A missing backup rail.\ntags: [800v, sic]\n"
28
+ # `gone` is a dangling target; the leading `/` is OKF §6.1's
29
+ # bundle-absolute form, which must name the same concept.
30
+ "links: [/concepts/req/overview.md, concepts/gone/overview.md]\n",
31
+ )
32
+ _concept(
33
+ tmp_path,
34
+ "req",
35
+ "type: requirement\ntitle: Fail-mode requirement\ntags: [800v]\n",
36
+ )
37
+ _concept(
38
+ tmp_path,
39
+ "deck",
40
+ "type: deck\ntitle: Roadmap deck\ndescription: The plan.\n"
41
+ # A bundle-absolute backlink must still count as linking to `gap`.
42
+ "links: [/concepts/gap/overview.md]\ntags: [800v]\n",
43
+ )
44
+ _concept(
45
+ tmp_path,
46
+ "both",
47
+ "type: report\ntitle: Q3 report\ndescription: Both tags.\n"
48
+ "tags: [sic, 800v]\nscenario: ev\n",
49
+ )
50
+ _concept(
51
+ tmp_path, "one", "type: report\ntitle: Q2 report\ntags: [sic]\nscenario: ev\n"
52
+ )
53
+ _concept(tmp_path, "none", "type: report\ntitle: Untagged\n")
54
+ return tmp_path
55
+
56
+
57
+ GAP = "concepts/gap/overview.md"
58
+
59
+
60
+ def test_three_sections_in_index_line_format(bundle):
61
+ assert render_related(bundle, GAP) == (
62
+ "# Links to\n"
63
+ "\n"
64
+ "* [concepts/gone/overview.md](concepts/gone/overview.md)\n"
65
+ "* [Fail-mode requirement](concepts/req/overview.md)\n"
66
+ "\n"
67
+ "# Linked from\n"
68
+ "\n"
69
+ "* [Roadmap deck](concepts/deck/overview.md) - The plan.\n"
70
+ "\n"
71
+ "# Shares tags\n"
72
+ "\n"
73
+ "* [Q3 report](concepts/both/overview.md) - Both tags."
74
+ " (shares tags: 800v, sic)\n"
75
+ "* [Q2 report](concepts/one/overview.md) (shares tags: sic)\n"
76
+ )
77
+
78
+
79
+ def test_already_linked_concepts_are_not_repeated_under_shares(bundle):
80
+ # `req` and `deck` share 800v with `gap`, but a reader already sees them.
81
+ shares = render_related(bundle, GAP).split("# Shares tags", 1)[1]
82
+ assert "concepts/req/" not in shares
83
+ assert "concepts/deck/" not in shares
84
+
85
+
86
+ def test_ranked_by_shared_value_count_then_path(bundle):
87
+ text = render_related(bundle, "concepts/one/overview.md", by=["tags", "scenario"])
88
+ shares = text.split("# Shares tags, scenario\n\n", 1)[1].splitlines()
89
+ assert shares == [
90
+ "* [Q3 report](concepts/both/overview.md) - Both tags."
91
+ " (shares tags: sic; scenario: ev)",
92
+ "* [Redundant supply](concepts/gap/overview.md) - A missing backup rail."
93
+ " (shares tags: sic)",
94
+ ]
95
+
96
+
97
+ def test_more_shared_values_outrank_an_earlier_path(tmp_path):
98
+ a = _concept(tmp_path, "a", "type: x\ntags: [p, q]\n")
99
+ _concept(tmp_path, "b-one", "type: x\ntitle: One\ntags: [p]\n")
100
+ _concept(tmp_path, "z-two", "type: x\ntitle: Two\ntags: [p, q]\n")
101
+ shares = render_related(tmp_path, a).split("# Shares tags\n\n", 1)[1]
102
+ assert shares.splitlines() == [
103
+ "* [Two](concepts/z-two/overview.md) (shares tags: p, q)",
104
+ "* [One](concepts/b-one/overview.md) (shares tags: p)",
105
+ ]
106
+
107
+
108
+ def test_limit_applies_to_shares_only(bundle):
109
+ text = render_related(bundle, GAP, limit=1)
110
+ assert "concepts/both/" in text
111
+ assert "concepts/one/" not in text
112
+ assert "concepts/gone/" in text and "concepts/deck/" in text
113
+
114
+
115
+ @pytest.mark.parametrize("limit", [0, -1])
116
+ def test_a_limit_below_one_is_an_error(bundle, limit):
117
+ # -1 would slice off the last neighbour silently, and 0 would print a
118
+ # "(none)" that claims nothing shares a tag.
119
+ with pytest.raises(ValueError, match=f"--limit must be at least 1, not {limit}"):
120
+ render_related(bundle, GAP, limit=limit)
121
+
122
+
123
+ def test_cli_limit_below_one_is_a_message(bundle, capsys):
124
+ assert main(["related", GAP, "--bundle", str(bundle), "--limit", "0"]) == 2
125
+ assert "--limit must be at least 1, not 0" in capsys.readouterr().err
126
+
127
+
128
+ def test_empty_sections_say_none(bundle):
129
+ assert render_related(bundle, "concepts/none/overview.md") == (
130
+ "# Links to\n\n(none)\n\n# Linked from\n\n(none)\n\n# Shares tags\n\n(none)\n"
131
+ )
132
+
133
+
134
+ def test_leading_slash_or_dot_slash_is_accepted(bundle):
135
+ expected = render_related(bundle, GAP)
136
+ assert render_related(bundle, "/" + GAP) == expected
137
+ assert render_related(bundle, "./" + GAP) == expected
138
+
139
+
140
+ def test_unknown_path_is_an_error(bundle):
141
+ with pytest.raises(ValueError, match="concepts/nope/overview.md is not a concept"):
142
+ render_related(bundle, "concepts/nope/overview.md")
143
+
144
+
145
+ def test_an_okf_owned_key_is_not_a_facet(bundle):
146
+ with pytest.raises(ValueError, match="'type' is not a facet: OKF owns it"):
147
+ render_related(bundle, GAP, by=["type"])
148
+
149
+
150
+ def test_cli_prints_and_exits_zero(bundle, capsys):
151
+ code = main(["related", GAP, "--bundle", str(bundle), "--by", "tags,scenario"])
152
+ assert code == 0
153
+ assert "# Shares tags, scenario" in capsys.readouterr().out
154
+
155
+
156
+ def test_cli_unknown_path_is_a_message_not_a_traceback(bundle, capsys):
157
+ code = main(["related", "concepts/nope/overview.md", "--bundle", str(bundle)])
158
+ assert code == 2
159
+ assert "concepts/nope/overview.md is not a concept" in capsys.readouterr().err
160
+
161
+
162
+ def test_cli_missing_bundle(tmp_path, capsys):
163
+ missing = tmp_path / "nonexistent"
164
+ code = main(["related", GAP, "--bundle", str(missing)])
165
+ assert code == 2
166
+ assert str(missing) in capsys.readouterr().err