Stevesolun commited on
Commit
2811452
·
verified ·
1 Parent(s): 66c18c4

Add files using upload-large-folder tool

Browse files
scripts/ci_preflight.py CHANGED
@@ -36,28 +36,28 @@ GRAPH_VALIDATE_ARGS = (
36
  "89000",
37
  "--min-semantic-edges",
38
  "1000000",
39
- "--expected-nodes",
40
- "102720",
41
- "--expected-edges",
42
- "2911575",
43
  "--expected-semantic-edges",
44
  "1683163",
45
- "--expected-harness-nodes",
46
- "16",
47
  "--expected-skills-sh-nodes",
48
  "89471",
49
  "--expected-skills-sh-catalog-entries",
50
  "89465",
51
  "--expected-skills-sh-converted",
52
  "89465",
53
- "--expected-skill-pages",
54
- "91450",
55
  "--expected-agent-pages",
56
  "467",
57
- "--expected-mcp-pages",
58
- "10787",
59
- "--expected-harness-pages",
60
- "16",
61
  "--line-threshold",
62
  "180",
63
  "--max-stage-lines",
 
36
  "89000",
37
  "--min-semantic-edges",
38
  "1000000",
39
+ "--expected-nodes",
40
+ "102925",
41
+ "--expected-edges",
42
+ "2913930",
43
  "--expected-semantic-edges",
44
  "1683163",
45
+ "--expected-harness-nodes",
46
+ "207",
47
  "--expected-skills-sh-nodes",
48
  "89471",
49
  "--expected-skills-sh-catalog-entries",
50
  "89465",
51
  "--expected-skills-sh-converted",
52
  "89465",
53
+ "--expected-skill-pages",
54
+ "91463",
55
  "--expected-agent-pages",
56
  "467",
57
+ "--expected-mcp-pages",
58
+ "10788",
59
+ "--expected-harness-pages",
60
+ "207",
61
  "--line-threshold",
62
  "180",
63
  "--max-stage-lines",
scripts/overlay_wiki_entities.py CHANGED
@@ -11,6 +11,7 @@ from __future__ import annotations
11
  import argparse
12
  import json
13
  import tarfile
 
14
  from collections import Counter
15
  from dataclasses import dataclass
16
  from datetime import datetime, timezone
@@ -19,6 +20,7 @@ from typing import Any
19
 
20
  from ctx.core.wiki.artifact_promotion import promote_staged_artifact
21
  from ctx.utils._fs_utils import atomic_write_text, reject_symlink_path
 
22
 
23
  GRAPH_EXPORT_NAMES = {
24
  "graphify-out/graph.json",
@@ -27,6 +29,7 @@ GRAPH_EXPORT_NAMES = {
27
  "graphify-out/graph-report.md",
28
  "graphify-out/graph-export-manifest.json",
29
  }
 
30
 
31
 
32
  @dataclass(frozen=True)
@@ -82,6 +85,7 @@ def overlay_entities(
82
  )
83
  replacements.update({
84
  "graphify-out/graph.json": _json_bytes(graph, compact=True),
 
85
  "graphify-out/graph-delta.json": _json_bytes(
86
  _render_delta(graph, selected, export_id=export_id, generated=timestamp),
87
  compact=False,
@@ -213,12 +217,20 @@ def _collect_replacements(
213
  if page is not None and (not runtime or entity_type == "harness"):
214
  replacements[page.relative_to(source_wiki).as_posix()] = page.read_bytes()
215
  if not runtime and entity_type == "skill":
216
- body = _skill_body(source_wiki, slug, skills_root=skills_root)
217
- if body is not None:
218
- replacements[f"converted/{slug}/SKILL.md"] = body.read_bytes()
219
  return replacements
220
 
221
 
 
 
 
 
 
 
 
 
 
 
222
  def _entity_page(source_wiki: Path, entity_type: str, slug: str) -> Path | None:
223
  candidates = {
224
  "skill": [source_wiki / "entities" / "skills" / f"{slug}.md"],
@@ -238,7 +250,7 @@ def _entity_page(source_wiki: Path, entity_type: str, slug: str) -> Path | None:
238
  return None
239
 
240
 
241
- def _skill_body(source_wiki: Path, slug: str, *, skills_root: Path | None) -> Path | None:
242
  root = skills_root or Path.home() / ".claude" / "skills"
243
  candidates = [
244
  source_wiki / "converted" / slug / "SKILL.md",
@@ -246,8 +258,13 @@ def _skill_body(source_wiki: Path, slug: str, *, skills_root: Path | None) -> Pa
246
  ]
247
  for candidate in candidates:
248
  if candidate.is_file():
249
- return candidate
250
- return None
 
 
 
 
 
251
 
252
 
253
  def _rewrite_tarball(tarball: Path, replacements: dict[str, bytes]) -> None:
@@ -255,7 +272,11 @@ def _rewrite_tarball(tarball: Path, replacements: dict[str, bytes]) -> None:
255
  staged = tarball.with_name(f"{tarball.name}.staged")
256
  reject_symlink_path(staged)
257
  skip_names = set(replacements)
258
- with tarfile.open(tarball, "r:gz") as src, tarfile.open(staged, "w:gz") as dst:
 
 
 
 
259
  for member in src:
260
  safe_name = _safe_tar_name(member.name)
261
  if safe_name is None:
 
11
  import argparse
12
  import json
13
  import tarfile
14
+ import tempfile
15
  from collections import Counter
16
  from dataclasses import dataclass
17
  from datetime import datetime, timezone
 
20
 
21
  from ctx.core.wiki.artifact_promotion import promote_staged_artifact
22
  from ctx.utils._fs_utils import atomic_write_text, reject_symlink_path
23
+ from scripts.build_dashboard_graph_index import build_dashboard_index
24
 
25
  GRAPH_EXPORT_NAMES = {
26
  "graphify-out/graph.json",
 
29
  "graphify-out/graph-report.md",
30
  "graphify-out/graph-export-manifest.json",
31
  }
32
+ OVERLAY_GZIP_COMPRESSLEVEL = 3
33
 
34
 
35
  @dataclass(frozen=True)
 
85
  )
86
  replacements.update({
87
  "graphify-out/graph.json": _json_bytes(graph, compact=True),
88
+ "graphify-out/dashboard-neighborhoods.sqlite3": _dashboard_index_bytes(graph),
89
  "graphify-out/graph-delta.json": _json_bytes(
90
  _render_delta(graph, selected, export_id=export_id, generated=timestamp),
91
  compact=False,
 
217
  if page is not None and (not runtime or entity_type == "harness"):
218
  replacements[page.relative_to(source_wiki).as_posix()] = page.read_bytes()
219
  if not runtime and entity_type == "skill":
220
+ replacements.update(_skill_replacements(source_wiki, slug, skills_root=skills_root))
 
 
221
  return replacements
222
 
223
 
224
+ def _dashboard_index_bytes(graph: dict[str, Any]) -> bytes:
225
+ with tempfile.TemporaryDirectory(prefix="ctx-overlay-index-") as tmp:
226
+ tmp_path = Path(tmp)
227
+ graph_path = tmp_path / "graph.json"
228
+ index_path = tmp_path / "dashboard-neighborhoods.sqlite3"
229
+ graph_path.write_bytes(_json_bytes(graph, compact=True))
230
+ build_dashboard_index(graph_path, index_path)
231
+ return index_path.read_bytes()
232
+
233
+
234
  def _entity_page(source_wiki: Path, entity_type: str, slug: str) -> Path | None:
235
  candidates = {
236
  "skill": [source_wiki / "entities" / "skills" / f"{slug}.md"],
 
250
  return None
251
 
252
 
253
+ def _skill_replacements(source_wiki: Path, slug: str, *, skills_root: Path | None) -> dict[str, bytes]:
254
  root = skills_root or Path.home() / ".claude" / "skills"
255
  candidates = [
256
  source_wiki / "converted" / slug / "SKILL.md",
 
258
  ]
259
  for candidate in candidates:
260
  if candidate.is_file():
261
+ skill_dir = candidate.parent
262
+ return {
263
+ f"converted/{slug}/{path.relative_to(skill_dir).as_posix()}": path.read_bytes()
264
+ for path in sorted(skill_dir.rglob("*"))
265
+ if path.is_file() and not path.name.endswith((".original", ".lock"))
266
+ }
267
+ return {}
268
 
269
 
270
  def _rewrite_tarball(tarball: Path, replacements: dict[str, bytes]) -> None:
 
272
  staged = tarball.with_name(f"{tarball.name}.staged")
273
  reject_symlink_path(staged)
274
  skip_names = set(replacements)
275
+ with tarfile.open(tarball, "r:gz") as src, tarfile.open(
276
+ staged,
277
+ "w:gz",
278
+ compresslevel=OVERLAY_GZIP_COMPRESSLEVEL,
279
+ ) as dst:
280
  for member in src:
281
  safe_name = _safe_tar_name(member.name)
282
  if safe_name is None:
src/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
  """ctx — skill and agent recommendation for Claude Code."""
2
 
3
- __version__ = "1.0.8"
 
1
  """ctx — skill and agent recommendation for Claude Code."""
2
 
3
+ __version__ = "1.0.9"
src/ctx/__init__.py CHANGED
@@ -30,7 +30,7 @@ Package layout:
30
  ctx.utils - low-level primitives (safe names, atomic IO)
31
  """
32
 
33
- __version__ = "1.0.8"
34
 
35
 
36
  # Public library surface — anything listed here is safe for third-
 
30
  ctx.utils - low-level primitives (safe names, atomic IO)
31
  """
32
 
33
+ __version__ = "1.0.9"
34
 
35
 
36
  # Public library surface — anything listed here is safe for third-
src/ctx_init.py CHANGED
@@ -225,10 +225,10 @@ _GRAPH_ARCHIVE_NAMES = {
225
  "runtime": _GRAPH_RUNTIME_ARCHIVE_NAME,
226
  "full": _GRAPH_ARCHIVE_NAME,
227
  }
228
- _GRAPH_ARCHIVE_SHA256 = {
229
- "runtime": "68b8e3fdc6c36beb845860011da7d57ea24e992b2a0b2f751fb35bffe3a3a9c0",
230
- "full": "6613fb7e10ee9a8884efe9a493aa06f97b6dbdaf4f47a379639f6bff9fadb0d4",
231
- }
232
  _GRAPH_RELEASE_URL = (
233
  "https://github.com/stevesolun/ctx/releases/download/"
234
  "v{version}/{archive_name}"
 
225
  "runtime": _GRAPH_RUNTIME_ARCHIVE_NAME,
226
  "full": _GRAPH_ARCHIVE_NAME,
227
  }
228
+ _GRAPH_ARCHIVE_SHA256 = {
229
+ "runtime": "d00d34d995e0d55bdaba9957b2d8fcf1938bfeca0d0e755874e4ea990360775d",
230
+ "full": "502fd22c570259d47c3aa5874a728fc533bd11d404ff43a611f3d1e1224db250",
231
+ }
232
  _GRAPH_RELEASE_URL = (
233
  "https://github.com/stevesolun/ctx/releases/download/"
234
  "v{version}/{archive_name}"
src/tests/test_overlay_wiki_entities.py CHANGED
@@ -1,6 +1,7 @@
1
  from __future__ import annotations
2
 
3
  import json
 
4
  import tarfile
5
  from datetime import datetime, timezone
6
  from pathlib import Path
@@ -29,11 +30,12 @@ def test_overlay_entities_preserves_existing_graph_and_adds_selected_pages(tmp_p
29
  (source_wiki / "entities" / "skills").mkdir(parents=True)
30
  (source_wiki / "entities" / "harnesses").mkdir(parents=True)
31
  skills_root = tmp_path / "skills"
32
- (skills_root / "new-skill").mkdir(parents=True)
33
  (source_wiki / "entities" / "skills" / "new-skill.md").write_text("# New skill\n")
34
  (source_wiki / "entities" / "harnesses" / "new-harness.md").write_text("# Harness\n")
35
  body = skills_root / "new-skill" / "SKILL.md"
36
  body.write_text("# body\n", encoding="utf-8")
 
37
  source_graph = {
38
  "graph": {"export_id": "source"},
39
  "nodes": [
@@ -104,4 +106,14 @@ def test_overlay_entities_preserves_existing_graph_and_adds_selected_pages(tmp_p
104
  assert tf.extractfile("./entities/skills/new-skill.md") is not None
105
  assert tf.extractfile("./entities/harnesses/new-harness.md") is not None
106
  assert tf.extractfile("./converted/new-skill/SKILL.md") is not None
 
 
 
 
 
 
 
 
 
 
107
  assert json.loads(root_communities.read_text())["export_id"] == stats.export_id
 
1
  from __future__ import annotations
2
 
3
  import json
4
+ import sqlite3
5
  import tarfile
6
  from datetime import datetime, timezone
7
  from pathlib import Path
 
30
  (source_wiki / "entities" / "skills").mkdir(parents=True)
31
  (source_wiki / "entities" / "harnesses").mkdir(parents=True)
32
  skills_root = tmp_path / "skills"
33
+ (skills_root / "new-skill" / "references").mkdir(parents=True)
34
  (source_wiki / "entities" / "skills" / "new-skill.md").write_text("# New skill\n")
35
  (source_wiki / "entities" / "harnesses" / "new-harness.md").write_text("# Harness\n")
36
  body = skills_root / "new-skill" / "SKILL.md"
37
  body.write_text("# body\n", encoding="utf-8")
38
+ (skills_root / "new-skill" / "references" / "guide.md").write_text("# guide\n", encoding="utf-8")
39
  source_graph = {
40
  "graph": {"export_id": "source"},
41
  "nodes": [
 
106
  assert tf.extractfile("./entities/skills/new-skill.md") is not None
107
  assert tf.extractfile("./entities/harnesses/new-harness.md") is not None
108
  assert tf.extractfile("./converted/new-skill/SKILL.md") is not None
109
+ assert tf.extractfile("./converted/new-skill/references/guide.md") is not None
110
+ index_member = tf.extractfile("./graphify-out/dashboard-neighborhoods.sqlite3")
111
+ assert index_member is not None
112
+ index_path = tmp_path / "dashboard-neighborhoods.sqlite3"
113
+ index_path.write_bytes(index_member.read())
114
+ with sqlite3.connect(index_path) as conn:
115
+ assert conn.execute(
116
+ "SELECT node_id FROM slug_index WHERE slug = ?",
117
+ ("new-skill",),
118
+ ).fetchone() == ("skill:new-skill",)
119
  assert json.loads(root_communities.read_text())["export_id"] == stats.export_id