kash-shell 0.3.9__py3-none-any.whl → 0.3.10__py3-none-any.whl

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 (135) hide show
  1. kash/actions/__init__.py +4 -4
  2. kash/actions/core/markdownify.py +5 -2
  3. kash/actions/core/readability.py +5 -2
  4. kash/actions/core/render_as_html.py +18 -0
  5. kash/actions/core/webpage_config.py +12 -4
  6. kash/commands/__init__.py +8 -20
  7. kash/commands/base/basic_file_commands.py +15 -0
  8. kash/commands/base/debug_commands.py +13 -0
  9. kash/commands/base/general_commands.py +21 -16
  10. kash/commands/base/logs_commands.py +4 -2
  11. kash/commands/base/model_commands.py +8 -8
  12. kash/commands/base/search_command.py +3 -2
  13. kash/commands/base/show_command.py +5 -3
  14. kash/commands/extras/parse_uv_lock.py +186 -0
  15. kash/commands/help/doc_commands.py +2 -31
  16. kash/commands/help/welcome.py +33 -0
  17. kash/commands/workspace/selection_commands.py +11 -6
  18. kash/commands/workspace/workspace_commands.py +18 -15
  19. kash/config/colors.py +2 -0
  20. kash/config/env_settings.py +14 -1
  21. kash/config/init.py +2 -2
  22. kash/config/logger.py +59 -56
  23. kash/config/logger_basic.py +3 -3
  24. kash/config/settings.py +116 -57
  25. kash/config/setup.py +28 -12
  26. kash/config/text_styles.py +3 -13
  27. kash/docs/load_api_docs.py +2 -1
  28. kash/docs/markdown/topics/a3_getting_started.md +3 -2
  29. kash/{concepts → embeddings}/text_similarity.py +2 -2
  30. kash/exec/__init__.py +20 -3
  31. kash/exec/action_decorators.py +18 -4
  32. kash/exec/action_exec.py +41 -23
  33. kash/exec/action_registry.py +13 -48
  34. kash/exec/command_registry.py +2 -1
  35. kash/exec/fetch_url_metadata.py +4 -6
  36. kash/exec/importing.py +56 -0
  37. kash/exec/llm_transforms.py +6 -7
  38. kash/exec/precondition_registry.py +2 -1
  39. kash/exec/preconditions.py +16 -1
  40. kash/exec/shell_callable_action.py +33 -19
  41. kash/file_storage/file_store.py +23 -10
  42. kash/file_storage/item_file_format.py +5 -2
  43. kash/file_storage/metadata_dirs.py +11 -2
  44. kash/help/assistant.py +1 -1
  45. kash/help/assistant_instructions.py +2 -1
  46. kash/help/help_embeddings.py +2 -2
  47. kash/help/help_printing.py +7 -11
  48. kash/llm_utils/clean_headings.py +1 -1
  49. kash/llm_utils/llm_api_keys.py +4 -4
  50. kash/llm_utils/llm_features.py +68 -0
  51. kash/llm_utils/llm_messages.py +1 -2
  52. kash/llm_utils/llm_names.py +1 -1
  53. kash/llm_utils/llms.py +8 -3
  54. kash/local_server/__init__.py +5 -2
  55. kash/local_server/local_server.py +8 -5
  56. kash/local_server/local_server_commands.py +2 -2
  57. kash/local_server/local_url_formatters.py +1 -1
  58. kash/mcp/__init__.py +5 -2
  59. kash/mcp/mcp_cli.py +5 -5
  60. kash/mcp/mcp_server_commands.py +5 -5
  61. kash/mcp/mcp_server_routes.py +5 -5
  62. kash/mcp/mcp_server_sse.py +4 -2
  63. kash/media_base/media_cache.py +8 -8
  64. kash/media_base/media_services.py +1 -1
  65. kash/media_base/media_tools.py +6 -6
  66. kash/media_base/services/local_file_media.py +2 -2
  67. kash/media_base/{speech_transcription.py → transcription_deepgram.py} +25 -110
  68. kash/media_base/transcription_format.py +73 -0
  69. kash/media_base/transcription_whisper.py +38 -0
  70. kash/model/__init__.py +73 -5
  71. kash/model/actions_model.py +38 -4
  72. kash/model/concept_model.py +30 -0
  73. kash/model/items_model.py +44 -7
  74. kash/model/params_model.py +24 -0
  75. kash/shell/completions/completion_scoring.py +37 -5
  76. kash/shell/output/kerm_codes.py +1 -2
  77. kash/shell/output/shell_formatting.py +14 -4
  78. kash/shell/shell_main.py +2 -2
  79. kash/shell/utils/exception_printing.py +6 -0
  80. kash/shell/utils/native_utils.py +26 -20
  81. kash/text_handling/custom_sliding_transforms.py +12 -4
  82. kash/text_handling/doc_normalization.py +6 -2
  83. kash/text_handling/markdown_render.py +117 -0
  84. kash/text_handling/markdown_utils.py +204 -0
  85. kash/utils/common/import_utils.py +12 -3
  86. kash/utils/common/type_utils.py +0 -29
  87. kash/utils/common/url.py +27 -3
  88. kash/utils/errors.py +6 -0
  89. kash/utils/file_utils/file_formats.py +2 -2
  90. kash/utils/file_utils/file_formats_model.py +3 -0
  91. kash/web_content/dir_store.py +1 -2
  92. kash/web_content/file_cache_utils.py +37 -10
  93. kash/web_content/file_processing.py +68 -0
  94. kash/web_content/local_file_cache.py +12 -9
  95. kash/web_content/web_extract.py +8 -3
  96. kash/web_content/web_fetch.py +12 -4
  97. kash/web_gen/tabbed_webpage.py +5 -2
  98. kash/web_gen/templates/base_styles.css.jinja +120 -14
  99. kash/web_gen/templates/base_webpage.html.jinja +60 -13
  100. kash/web_gen/templates/content_styles.css.jinja +4 -2
  101. kash/web_gen/templates/item_view.html.jinja +2 -2
  102. kash/web_gen/templates/tabbed_webpage.html.jinja +1 -2
  103. kash/workspaces/__init__.py +15 -2
  104. kash/workspaces/selections.py +18 -3
  105. kash/workspaces/source_items.py +0 -1
  106. kash/workspaces/workspaces.py +5 -11
  107. kash/xonsh_custom/command_nl_utils.py +40 -19
  108. kash/xonsh_custom/custom_shell.py +43 -11
  109. kash/xonsh_custom/customize_prompt.py +39 -21
  110. kash/xonsh_custom/load_into_xonsh.py +22 -25
  111. kash/xonsh_custom/shell_load_commands.py +2 -2
  112. kash/xonsh_custom/xonsh_completers.py +2 -249
  113. kash/xonsh_custom/xonsh_keybindings.py +282 -0
  114. kash/xonsh_custom/xonsh_modern_tools.py +3 -3
  115. kash/xontrib/kash_extension.py +5 -6
  116. {kash_shell-0.3.9.dist-info → kash_shell-0.3.10.dist-info}/METADATA +8 -6
  117. {kash_shell-0.3.9.dist-info → kash_shell-0.3.10.dist-info}/RECORD +122 -123
  118. kash/concepts/concept_formats.py +0 -23
  119. kash/shell/clideps/api_keys.py +0 -100
  120. kash/shell/clideps/dotenv_setup.py +0 -115
  121. kash/shell/clideps/dotenv_utils.py +0 -98
  122. kash/shell/clideps/pkg_deps.py +0 -257
  123. kash/shell/clideps/platforms.py +0 -11
  124. kash/shell/clideps/terminal_features.py +0 -56
  125. kash/shell/utils/osc_utils.py +0 -95
  126. kash/shell/utils/terminal_images.py +0 -133
  127. kash/text_handling/markdown_util.py +0 -167
  128. kash/utils/common/atomic_var.py +0 -171
  129. kash/utils/common/string_replace.py +0 -93
  130. kash/utils/common/string_template.py +0 -101
  131. /kash/{concepts → embeddings}/cosine.py +0 -0
  132. /kash/{concepts → embeddings}/embeddings.py +0 -0
  133. {kash_shell-0.3.9.dist-info → kash_shell-0.3.10.dist-info}/WHEEL +0 -0
  134. {kash_shell-0.3.9.dist-info → kash_shell-0.3.10.dist-info}/entry_points.txt +0 -0
  135. {kash_shell-0.3.9.dist-info → kash_shell-0.3.10.dist-info}/licenses/LICENSE +0 -0
@@ -11,7 +11,7 @@ from prettyfmt import fmt_path
11
11
  from strif import atomic_output_file, copyfile_atomic
12
12
 
13
13
  from kash.utils.common.url import Url, is_file_url, is_url, normalize_url, parse_file_url
14
- from kash.utils.errors import FileNotFound, InvalidInput
14
+ from kash.utils.errors import FileNotFound
15
15
  from kash.utils.file_utils.file_formats_model import choose_file_ext
16
16
  from kash.web_content.dir_store import DirStore
17
17
  from kash.web_content.web_fetch import download_url
@@ -56,19 +56,21 @@ class Loadable:
56
56
 
57
57
  key: str
58
58
  """
59
- The unique identifier for the item. If it ends in a recognized file extension,
60
- both the key and the extension will be used when creating unique cache filenames.
59
+ The unique identifier for the item. Used when creating unique cache filenames,
60
+ as is or with added suffixes.
61
61
  """
62
62
 
63
63
  save: Callable[[Path], None]
64
64
  """
65
65
  Method that saves the item to the given path. Caller will handle path selection
66
- and atomicity of file creation.
66
+ and atomicity of file creation. Raise an exception if the item cannot be saved.
67
67
  """
68
68
 
69
69
 
70
70
  Cacheable = Url | Path | Loadable
71
- """An item that can be cached as a file."""
71
+ """
72
+ An item that can be cached as a file.
73
+ """
72
74
 
73
75
 
74
76
  def _suffix_for(cacheable: Cacheable) -> str | None:
@@ -151,9 +153,7 @@ class LocalFileCache(DirStore):
151
153
  if isinstance(url_or_path, Path):
152
154
  file_path = url_or_path
153
155
  else:
154
- parsed = parse_file_url(url_or_path)
155
- if not parsed:
156
- raise InvalidInput(f"Not a file URL: {url_or_path}")
156
+ parsed = parse_file_url(url_or_path) # Raises ValueError if not a file URL.
157
157
  file_path = parsed
158
158
  if not file_path.exists():
159
159
  raise FileNotFound(f"File not found: {file_path}")
@@ -173,7 +173,10 @@ class LocalFileCache(DirStore):
173
173
  ) as tmp_path:
174
174
  source.save(tmp_path)
175
175
  if not cache_path.exists():
176
- raise InvalidCacheState(f"Failed to save to cache: {source}: {cache_path}")
176
+ # The source should have raised an exception if it failed to save.
177
+ raise InvalidCacheState(
178
+ f"Loadable source failed to save to cache: {source}: {cache_path}"
179
+ )
177
180
  else:
178
181
  raise ValueError(f"Invalid source: {source}")
179
182
 
@@ -10,14 +10,19 @@ from kash.web_content.web_page_model import PageExtractor, WebPageData
10
10
 
11
11
  @log_calls(level="message")
12
12
  def fetch_extract(
13
- url: Url, use_cache: bool = True, extractor: PageExtractor = extract_text_justext
13
+ url: Url,
14
+ refetch: bool = False,
15
+ use_cache: bool = True,
16
+ extractor: PageExtractor = extract_text_justext,
14
17
  ) -> WebPageData:
15
18
  """
16
19
  Fetches a URL and extracts the title, description, and content.
20
+ By default, uses the content cache if available. Can force re-fetching and
21
+ updating the cache by setting `refetch` to true.
17
22
  """
18
-
23
+ expiration_sec = 0 if refetch else None
19
24
  if use_cache:
20
- path, _was_cached = cache_file(url)
25
+ path, _was_cached = cache_file(url, expiration_sec=expiration_sec)
21
26
  with open(path, "rb") as file:
22
27
  content = file.read()
23
28
  page_data = extractor(url, content)
@@ -7,17 +7,22 @@ import httpx
7
7
  from strif import atomic_output_file, copyfile_atomic
8
8
  from tqdm import tqdm
9
9
 
10
+ from kash.config.env_settings import KashEnv
10
11
  from kash.utils.common.url import Url
11
12
 
12
13
  log = logging.getLogger(__name__)
13
14
 
14
- USER_AGENT = "Mozilla/5.0 (Compatible)"
15
15
 
16
16
  DEFAULT_TIMEOUT = 30
17
17
 
18
18
 
19
+ DEFAULT_USER_AGENT = (
20
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:126.0) Gecko/20100101 Firefox/126.0"
21
+ )
22
+
23
+
19
24
  def default_headers() -> dict[str, str]:
20
- return {"User-Agent": USER_AGENT}
25
+ return {"User-Agent": KashEnv.KASH_USER_AGENT.read_str(default=DEFAULT_USER_AGENT)}
21
26
 
22
27
 
23
28
  def fetch_url(
@@ -36,6 +41,7 @@ def fetch_url(
36
41
  auth=auth,
37
42
  headers=headers or default_headers(),
38
43
  ) as client:
44
+ log.debug("fetch_url: using headers: %s", client.headers)
39
45
  response = client.get(url)
40
46
  log.info("Fetched: %s (%s bytes): %s", response.status_code, len(response.content), url)
41
47
  response.raise_for_status()
@@ -52,7 +58,7 @@ def download_url(
52
58
  headers: dict[str, str] | None = None,
53
59
  ) -> None:
54
60
  """
55
- Download given file, optionally with progress bar.
61
+ Download given file, optionally with progress bar, streaming to a target file.
56
62
  Also handles file:// and s3:// URLs. Output file is created atomically.
57
63
  Raise httpx.HTTPError for non-2xx responses.
58
64
  """
@@ -73,13 +79,15 @@ def download_url(
73
79
  client = session or httpx.Client(follow_redirects=True, timeout=timeout)
74
80
  response: httpx.Response | None = None
75
81
  try:
82
+ headers = headers or default_headers()
83
+ log.debug("download_url: using headers: %s", headers)
76
84
  with client.stream(
77
85
  "GET",
78
86
  url,
79
87
  follow_redirects=True,
80
88
  timeout=timeout,
81
89
  auth=auth,
82
- headers=headers or default_headers(),
90
+ headers=headers,
83
91
  ) as response:
84
92
  response.raise_for_status()
85
93
  total_size = int(response.headers.get("content-length", "0"))
@@ -2,6 +2,7 @@ import os
2
2
  from dataclasses import asdict, dataclass
3
3
 
4
4
  from frontmatter_format import read_yaml_file, to_yaml_string, write_yaml_file
5
+ from prettyfmt import sanitize_title
5
6
 
6
7
  from kash.config.logger import get_logger
7
8
  from kash.exec.preconditions import has_thumbnail_url
@@ -41,7 +42,7 @@ def _fill_in_ids(tabs: list[TabInfo]):
41
42
  tab.id = f"tab_{i}"
42
43
 
43
44
 
44
- def webpage_config(items: list[Item]) -> Item:
45
+ def webpage_config(items: list[Item], clean_headings: bool = False) -> Item:
45
46
  """
46
47
  Get an item with the config for a tabbed web page.
47
48
  """
@@ -57,9 +58,11 @@ def webpage_config(items: list[Item]) -> Item:
57
58
  log.warning("Item has no thumbnail URL: %s", item)
58
59
  return None
59
60
 
61
+ clean = clean_heading if clean_headings else sanitize_title
62
+
60
63
  tabs = [
61
64
  TabInfo(
62
- label=clean_heading(item.abbrev_title()),
65
+ label=clean(item.abbrev_title()),
63
66
  store_path=item.store_path,
64
67
  thumbnail_url=get_thumbnail_url(item),
65
68
  )
@@ -1,8 +1,9 @@
1
1
  :root {
2
2
  font-size: 16px;
3
- {# Adding Hack Nerd Font to all fonts for icon support, if it is installed. #}
4
- --font-sans: "Varta", sans-serif, "Hack Nerd Font";
3
+ /* Adding Hack Nerd Font to all fonts for icon support, if it is installed. */
4
+ --font-sans: "Source Sans 3 Variable", sans-serif, "Hack Nerd Font";
5
5
  --font-serif: "PT Serif", serif, "Hack Nerd Font";
6
+ --font-weight-sans-bold: 625; /* Source Sans 3 Variable better at this weight. */
6
7
  --font-mono: "Hack Nerd Font", "Menlo", "DejaVu Sans Mono", Consolas, "Lucida Console", monospace;
7
8
 
8
9
  --font-size-large: 1.2rem;
@@ -63,16 +64,32 @@
63
64
  body {
64
65
  font-family: var(--font-serif);
65
66
  color: var(--color-text);
66
- line-height: 1.3;
67
+ line-height: 1.4;
67
68
  padding: 0; /* No padding so we can have full width elements. */
68
69
  margin: auto;
69
70
  background-color: var(--color-bg);
71
+ overflow-wrap: break-word; /* Don't let long words/URLs break layout. */
70
72
  }
71
73
 
72
74
  p {
73
75
  margin-bottom: 1rem;
74
76
  }
75
77
 
78
+ b, strong {
79
+ font-weight: var(--font-weight-sans-bold);
80
+ }
81
+
82
+ a {
83
+ color: var(--color-primary);
84
+ text-decoration: none;
85
+ }
86
+
87
+ a:hover {
88
+ color: var(--color-primary-light);
89
+ text-decoration: underline;
90
+ transition: all 0.15s ease-in-out;
91
+ }
92
+
76
93
  h1,
77
94
  h2,
78
95
  h3,
@@ -88,19 +105,19 @@ h1 {
88
105
 
89
106
  h2 {
90
107
  font-size: 1.4rem;
91
- margin-top: 2rem;
108
+ margin-top: 2.5rem;
92
109
  margin-bottom: 1rem;
93
110
  }
94
111
 
95
112
  h3 {
96
- font-size: 1.15rem;
97
- margin-top: 1.5rem;
98
- margin-bottom: 1rem;
113
+ font-size: 1.09rem;
114
+ margin-top: 1.7rem;
115
+ margin-bottom: 0.7rem;
99
116
  }
100
117
 
101
118
  h4 {
102
119
  margin-top: 1rem;
103
- margin-bottom: 1rem;
120
+ margin-bottom: 0.7rem;
104
121
  }
105
122
 
106
123
  /* Long text stylings, for nicely formatting blog post length or longer texts. */
@@ -118,8 +135,9 @@ h4 {
118
135
 
119
136
  .long-text h3 {
120
137
  font-family: var(--font-sans);
121
- font-weight: 700;
138
+ font-weight: var(--font-weight-sans-bold);
122
139
  text-transform: uppercase;
140
+ letter-spacing: 0.02em;
123
141
  }
124
142
 
125
143
  .long-text h4 {
@@ -141,22 +159,31 @@ ul {
141
159
  }
142
160
 
143
161
  li {
144
- margin-top: 0.5rem;
162
+ margin-top: 0.7rem;
145
163
  margin-bottom: 0;
146
164
  position: relative;
147
165
  }
148
166
 
149
- ul>li::before {
167
+ li > p {
168
+ margin-bottom: 0;
169
+ }
170
+
171
+ ul > li::before {
150
172
  content: "▪︎";
151
173
  position: absolute;
152
- left: -1rem;
153
- font-size: 0.9rem;
174
+ left: -.85rem;
175
+ top: .25rem;
176
+ font-size: 0.62rem;
154
177
  }
155
178
 
156
179
  ol {
180
+ margin-bottom: 0.7rem;
157
181
  list-style-type: decimal;
158
182
  margin-left: 2rem;
159
- margin-bottom: 1rem;
183
+ }
184
+
185
+ ol > li {
186
+ padding-left: 0.25rem;
160
187
  }
161
188
 
162
189
  blockquote {
@@ -181,6 +208,37 @@ pre {
181
208
  {# overflow-x: auto; #}
182
209
  }
183
210
 
211
+ table {
212
+ font-family: var(--font-sans);
213
+ font-size: var(--font-size-small);
214
+ width: auto;
215
+ margin-left: auto;
216
+ margin-right: auto;
217
+ border-collapse: collapse;
218
+ word-break: break-word; /* long words/URLs wrap instead of inflating the column */
219
+ border: 1px solid var(--color-border-hint);
220
+ }
221
+
222
+ th {
223
+ text-transform: uppercase;
224
+ letter-spacing: 0.02em;
225
+ border-bottom: 1px solid var(--color-border-hint);
226
+ }
227
+
228
+ th, td {
229
+ padding: 0.3rem 0.6rem;
230
+ max-width: 40rem;
231
+ min-width: 6rem;
232
+ }
233
+
234
+ th {
235
+ background-color: var(--color-bg-alt-solid);
236
+ }
237
+
238
+ tbody tr:nth-child(even) {
239
+ background-color: var(--color-bg-alt-solid);
240
+ }
241
+
184
242
  nav {
185
243
  display: flex;
186
244
  flex-wrap: wrap;
@@ -190,3 +248,51 @@ nav {
190
248
  gap: 1rem;
191
249
  /* Add some space between the buttons */
192
250
  }
251
+
252
+ /* Container for wide tables to allow tables to break out of parent width. */
253
+ .table-container {
254
+ {# max-width: calc(100vw - 6rem); #}
255
+ position: relative;
256
+ left: 50%;
257
+ transform: translateX(-50%);
258
+ box-sizing: border-box;
259
+ margin-bottom: 1rem;
260
+ background-color: var(--color-bg-solid);
261
+
262
+ }
263
+
264
+ /* Bleed wide on larger screens. */
265
+ /* TODO: Don't make so wide if table itself isn't large? */
266
+ @media (min-width: 768px) {
267
+ table {
268
+ width: calc(100vw - 6rem);
269
+ }
270
+ .table-container {
271
+ width: calc(100vw - 6rem);
272
+ }
273
+ }
274
+
275
+ @media (max-width: 768px) {
276
+ table {
277
+ font-size: var(--font-size-smaller);
278
+ }
279
+ }
280
+
281
+ /* Footnotes. */
282
+ sup {
283
+ font-size: 80%;
284
+ }
285
+
286
+ .footnote-ref a, .footnote {
287
+ text-decoration: none;
288
+ padding: 0 0.15rem;
289
+ border-radius: 4px;
290
+ transition: all 0.15s ease-in-out;
291
+ }
292
+
293
+ .footnote-ref a:hover, .footnote:hover {
294
+ background-color: var(--color-hover-bg);
295
+ color: var(--color-primary-light);
296
+ text-decoration: none;
297
+ }
298
+
@@ -20,12 +20,19 @@
20
20
  <link rel="preload" as="font" type="font/woff2" crossorigin
21
21
  href="https://cdn.jsdelivr.net/fontsource/fonts/pt-serif@latest/latin-700-italic.woff2" />
22
22
  <link rel="preload" as="font" type="font/woff2" crossorigin
23
- href="https://cdn.jsdelivr.net/fontsource/fonts/varta:vf@latest/latin-wght-normal.woff2" />
23
+ href="https://cdn.jsdelivr.net/fontsource/fonts/source-sans-3:vf@latest/latin-wght-normal.woff2" />
24
+ <link rel="preload" as="font" type="font/woff2" crossorigin
25
+ href="https://cdn.jsdelivr.net/fontsource/fonts/source-sans-3:vf@latest/latin-wght-italic.woff2" />
24
26
 
25
27
  <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet" />
26
28
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js" defer></script>
27
29
 
30
+ {% if extra_head %}
31
+ {{ extra_head|safe }}
32
+ {% endif %}
33
+
28
34
  <style>
35
+ /* https://fontsource.org/fonts/pt-serif/cdn */
29
36
  /* pt-serif-latin-400-normal */
30
37
  @font-face {
31
38
  font-family: 'PT Serif';
@@ -62,14 +69,27 @@
62
69
  src: url(https://cdn.jsdelivr.net/fontsource/fonts/pt-serif@latest/latin-700-italic.woff2) format('woff2');
63
70
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
64
71
  }
72
+ /* https://fontsource.org/fonts/source-sans-3/cdn */
73
+ /* source-sans-3-latin-wght-normal */
65
74
  @font-face {
66
- font-family: 'Varta';
75
+ font-family: 'Source Sans 3 Variable';
67
76
  font-style: normal;
68
77
  font-display: block;
69
- font-weight: 300 700;
70
- src: url(https://cdn.jsdelivr.net/fontsource/fonts/varta:vf@latest/latin-wght-normal.woff2) format('woff2-variations');
71
- unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
78
+ font-weight: 200 900;
79
+ src: url(https://cdn.jsdelivr.net/fontsource/fonts/source-sans-3:vf@latest/latin-wght-normal.woff2) format('woff2-variations');
80
+ unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
72
81
  }
82
+ /* source-sans-3-latin-wght-normal */
83
+ @font-face {
84
+ font-family: 'Source Sans 3 Variable';
85
+ font-style: italic;
86
+ font-display: block;
87
+ font-weight: 200 900;
88
+ src: url(https://cdn.jsdelivr.net/fontsource/fonts/source-sans-3:vf@latest/latin-wght-italic.woff2) format('woff2-variations');
89
+ unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
90
+ }
91
+
92
+ {# Other decent sans serif options: Work Sans Variable, Nunito Sans Variable #}
73
93
 
74
94
  {% include "base_styles.css.jinja" %}
75
95
  {% include "content_styles.css.jinja" %}
@@ -82,24 +102,45 @@
82
102
  </head>
83
103
 
84
104
  <body>
85
- {{ content|safe }}
86
- </body>
105
+ {{ content|safe }}
87
106
 
88
107
  <script>
89
- // Some messages are sent to the parent window, in case we are in a viewport like a
90
- // tooltip that supports it.
91
-
92
- // Request a resize of the parent viewport (e.g. tooltip).
93
108
  document.addEventListener('DOMContentLoaded', () => {
109
+ // Send messages to the parent window, in case we are in a viewport where that matters
110
+ // (e.g. an iframe tooltip).
111
+ // Request a resize of the parent viewport. This iframe size message format isn't
112
+ // standardized by ResizeObserver, but is common. It is supported by Kerm.
94
113
  const content = document.body;
95
114
  console.log("Suggesting resize to parent:", content.offsetWidth, content.offsetHeight);
96
- // This iframe size message format isn't standardized by ResizeObserver, but is common.
97
- // It is supported by Kerm.
115
+
98
116
  window.parent.postMessage({
99
117
  type: 'resize',
100
118
  width: Math.max(content.offsetWidth, 600),
101
119
  height: Math.max(content.offsetHeight, 100)
102
120
  }, '*');
121
+
122
+ // Wrap tables within the main content area for horizontal scrolling.
123
+ const containers = [];
124
+ document.querySelectorAll('.long-text').forEach(el => {
125
+ const pane = el.querySelector('.tab-pane');
126
+ containers.push(pane || el);
127
+ });
128
+ containers.forEach(container => {
129
+ // Grab all tables, then only wrap the ones whose parent is this container.
130
+ container.querySelectorAll('table').forEach(table => {
131
+ if (table.parentElement !== container) {
132
+ return; // Only direct children.
133
+ }
134
+ if (table.parentNode.classList.contains('table-container')) {
135
+ return; // Already wrapped.
136
+ }
137
+ const wrapper = document.createElement('div');
138
+ wrapper.className = 'table-container';
139
+ container.insertBefore(wrapper, table);
140
+ wrapper.appendChild(table);
141
+ });
142
+ });
143
+
103
144
  });
104
145
 
105
146
  // Double-click to expand (e.g. expand tooltip to popover).
@@ -119,6 +160,12 @@
119
160
  }, '*');
120
161
  }
121
162
  });
163
+
164
+ {% if extra_footer_js %}
165
+ {{ extra_footer_js|safe }}
166
+ {% endif %}
122
167
  </script>
123
168
 
169
+ </body>
170
+
124
171
  </html>
@@ -15,7 +15,7 @@
15
15
  padding: 0 0.4rem;
16
16
  }
17
17
 
18
- /* More novel bracket ideas: [❲⟦⟪⟬〔〘〚〖 ]❳⟧⟫⟭ 〕〙〛〗 */
18
+ {# More novel bracket ideas: [❲⟦⟪⟬〔〘〚〖 ]❳⟧⟫⟭ 〕〙〛〗 #}
19
19
  .citation::before {
20
20
  content: "[";
21
21
  }
@@ -57,6 +57,7 @@
57
57
  font-weight: 500;
58
58
  font-size: 1.2rem;
59
59
  text-transform: uppercase;
60
+ letter-spacing: 0.02em;
60
61
  margin-bottom: 0.5rem;
61
62
  }
62
63
 
@@ -81,6 +82,7 @@
81
82
  font-weight: 500;
82
83
  font-size: 1.2rem;
83
84
  text-transform: uppercase;
85
+ letter-spacing: 0.02em;
84
86
  margin-bottom: 0.5rem;
85
87
 
86
88
  /* Hack to center the header above the columns */
@@ -107,7 +109,7 @@
107
109
  font-size: var(--font-size-small);
108
110
  font-weight: 600;
109
111
  text-transform: uppercase;
110
- letter-spacing: 0.05em;
112
+ letter-spacing: 0.02em;
111
113
  line-height: 1.2;
112
114
  padding: 0 0.5rem;
113
115
  border-bottom-width: 2px;
@@ -19,9 +19,9 @@
19
19
  .item-type {
20
20
  font-family: var(--font-sans);
21
21
  text-transform: uppercase;
22
+ letter-spacing: 0.02em;
22
23
  font-size: var(--font-size-smaller);
23
- font-weight: 800;
24
- letter-spacing: 0.05em;
24
+ font-weight: var(--font-weight-sans-bold);
25
25
  padding-right: 1rem;
26
26
  }
27
27
 
@@ -1,4 +1,4 @@
1
- <div class="long-text container max-w-3xl mx-auto bg-white py-8 px-16 shadow-lg">
1
+ <div class="long-text container max-w-3xl mx-auto bg-white py-8 px-6 md:px-16 md:shadow-lg">
2
2
  <h1 class="text-center text-4xl mt-6 mb-6">{{ title }}</h1>
3
3
  <div>
4
4
  <!-- Navigation Tabs -->
@@ -30,7 +30,6 @@
30
30
  {% endfor %}
31
31
  </div>
32
32
  </div>
33
- <!-- TODO: Footer info (match with pdf export) -->
34
33
  </div>
35
34
 
36
35
  <script>
@@ -1,5 +1,3 @@
1
- # flake8: noqa: F401
2
-
3
1
  from kash.workspaces.selections import Selection, SelectionHistory
4
2
  from kash.workspaces.workspaces import (
5
3
  Workspace,
@@ -9,5 +7,20 @@ from kash.workspaces.workspaces import (
9
7
  get_ws,
10
8
  global_ws_dir,
11
9
  resolve_ws,
10
+ switch_to_ws,
12
11
  ws_param_value,
13
12
  )
13
+
14
+ __all__ = [
15
+ "Selection",
16
+ "SelectionHistory",
17
+ "Workspace",
18
+ "current_ignore",
19
+ "current_ws",
20
+ "get_global_ws",
21
+ "get_ws",
22
+ "global_ws_dir",
23
+ "resolve_ws",
24
+ "ws_param_value",
25
+ "switch_to_ws",
26
+ ]
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  from collections.abc import Callable, Sequence
2
4
  from functools import wraps
3
5
  from pathlib import Path
@@ -78,6 +80,12 @@ class Selection(BaseModel):
78
80
  if current_path == old_path:
79
81
  self.paths[idx] = new_path
80
82
 
83
+ def refresh(self, base_dir: Path) -> None:
84
+ """
85
+ Refresh the selection paths, dropping any that no longer exist.
86
+ """
87
+ self.paths[:] = [p for p in self.paths if (base_dir / p).exists()]
88
+
81
89
  def as_str(self, max_lines: int = SELECTION_DISPLAY_MAX) -> str:
82
90
  lines = [
83
91
  f"{fmt_count_items(len(self.paths), 'item')}:",
@@ -113,7 +121,7 @@ class SelectionHistory(BaseModel):
113
121
  }
114
122
 
115
123
  @classmethod
116
- def init(cls, save_path: Path, max_history: int = SELECTION_HISTORY_MAX) -> "SelectionHistory":
124
+ def init(cls, save_path: Path, max_history: int = SELECTION_HISTORY_MAX) -> SelectionHistory:
117
125
  """
118
126
  Initialize selection history, loading from save_path if it exists.
119
127
  """
@@ -144,9 +152,9 @@ class SelectionHistory(BaseModel):
144
152
  yaml_util.write_yaml_file(data, str(self._save_path))
145
153
 
146
154
  @persist_after(_save)
147
- def clear(self) -> None:
155
+ def clear_all(self) -> None:
148
156
  """
149
- Clear the history.
157
+ Clear the entire selection history.
150
158
  """
151
159
  self.history.clear()
152
160
  self.current_index = 0
@@ -306,6 +314,13 @@ class SelectionHistory(BaseModel):
306
314
  for selection in self.history:
307
315
  selection.replace_values(replacements)
308
316
 
317
+ @persist_after(_save)
318
+ def refresh_current(self, base_dir: Path) -> None:
319
+ """
320
+ Refresh the current selection to drop any paths that no longer exist.
321
+ """
322
+ self.current.refresh(base_dir)
323
+
309
324
  def previous_n(self, n: int, expected_size: int | None = None) -> list[Selection]:
310
325
  """
311
326
  Get the `n` previous selections (backwards and including the current position),
@@ -7,7 +7,6 @@ from kash.model.items_model import Item
7
7
  from kash.model.paths_model import StorePath
8
8
  from kash.model.preconditions_model import Precondition
9
9
  from kash.utils.common.format_utils import fmt_loc
10
- from kash.utils.common.type_utils import not_none
11
10
  from kash.utils.errors import NoMatch
12
11
  from kash.workspaces import current_ws
13
12