awesome-core 2.1.0__tar.gz → 2.2.2__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 (38) hide show
  1. {awesome_core-2.1.0 → awesome_core-2.2.2}/PKG-INFO +12 -5
  2. {awesome_core-2.1.0 → awesome_core-2.2.2}/README.md +11 -4
  3. {awesome_core-2.1.0 → awesome_core-2.2.2}/awesome_core.egg-info/PKG-INFO +12 -5
  4. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/builder.py +31 -6
  5. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/fetcher.py +1 -1
  6. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/leaks.py +107 -8
  7. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/mcp.py +81 -37
  8. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/poisoning.py +64 -17
  9. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/status.py +115 -14
  10. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/untrusted.py +16 -1
  11. {awesome_core-2.1.0 → awesome_core-2.2.2}/pyproject.toml +1 -1
  12. {awesome_core-2.1.0 → awesome_core-2.2.2}/LICENSE +0 -0
  13. {awesome_core-2.1.0 → awesome_core-2.2.2}/awesome_core.egg-info/SOURCES.txt +0 -0
  14. {awesome_core-2.1.0 → awesome_core-2.2.2}/awesome_core.egg-info/dependency_links.txt +0 -0
  15. {awesome_core-2.1.0 → awesome_core-2.2.2}/awesome_core.egg-info/entry_points.txt +0 -0
  16. {awesome_core-2.1.0 → awesome_core-2.2.2}/awesome_core.egg-info/top_level.txt +0 -0
  17. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/__init__.py +0 -0
  18. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/aliases.py +0 -0
  19. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/api.py +0 -0
  20. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/backfill.py +0 -0
  21. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/bootstrap.py +0 -0
  22. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/clones.py +0 -0
  23. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/curator.py +0 -0
  24. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/database.py +0 -0
  25. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/doctor.py +0 -0
  26. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/enrich.py +0 -0
  27. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/langmap.py +0 -0
  28. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/md.py +0 -0
  29. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/parser.py +0 -0
  30. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/scoring.py +0 -0
  31. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/selfcheck.py +0 -0
  32. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/shortlist.py +0 -0
  33. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/store.py +0 -0
  34. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/tools_db.py +0 -0
  35. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/trust.py +0 -0
  36. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/validator.py +0 -0
  37. {awesome_core-2.1.0 → awesome_core-2.2.2}/core/watcher.py +0 -0
  38. {awesome_core-2.1.0 → awesome_core-2.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awesome-core
3
- Version: 2.1.0
3
+ Version: 2.2.2
4
4
  Summary: Offline-first catalog of tools from GitHub awesome lists, exposed as a read-only MCP server (stdio). Pure stdlib core, no network, no API keys.
5
5
  Author: Arkadiusz Słowik
6
6
  License-Expression: MIT
@@ -20,8 +20,11 @@ Dynamic: license-file
20
20
 
21
21
  [![PyPI](https://img.shields.io/pypi/v/awesome-core?label=PyPI)](https://pypi.org/project/awesome-core/)
22
22
  [![Python versions](https://img.shields.io/pypi/pyversions/awesome-core)](https://pypi.org/project/awesome-core/)
23
+ [![CI](https://github.com/twojlogin/awesome-core/actions/workflows/ci.yml/badge.svg)](https://github.com/twojlogin/awesome-core/actions/workflows/ci.yml)
23
24
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](#license)
24
25
  [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-io.github.twojlogin%2Fawesome--core-6f42c1)](https://registry.modelcontextprotocol.io/v0/servers?search=awesome-core)
26
+ [![awesome-core MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/twojlogin/awesome-core/badges/score.svg)](https://glama.ai/mcp/servers/twojlogin/awesome-core)
27
+ [![Listed on L’Atlas](https://latlas.dev/badge/fiche/io.github.twojlogin/awesome-core.svg?lang=en)](https://latlas.dev/en/mcp/io.github.twojlogin/awesome-core)
25
28
 
26
29
  <!-- mcp-name: io.github.twojlogin/awesome-core -->
27
30
 
@@ -159,6 +162,7 @@ Quick path if you're short on time:
159
162
  ./awesome audit sindresorhus/awesome # audit a single repository
160
163
  ./awesome leaks # scan for possible leaked secrets (local)
161
164
  ./awesome leaks --readmes # also scan raw README files (offline)
165
+ ./awesome leaks --repo # also scan tracked repo files (incl. hidden)
162
166
  ./awesome lists # top lists
163
167
  ./awesome info nmap # details + install hint
164
168
  ./awesome install nmap # install (git clone)
@@ -303,14 +307,17 @@ Notes:
303
307
 
304
308
  This is pattern-based filtering, not a guarantee. Treat descriptions as data.
305
309
 
306
- You can also scan locally for possible leaked secrets/tokens in descriptions and README files:
310
+ You can also scan locally for possible leaked secrets/tokens in descriptions, README files, and tracked repository files:
307
311
 
308
312
  ```bash
309
313
  ./awesome leaks
310
314
  ./awesome leaks --readmes # also scan raw README files (offline)
315
+ ./awesome leaks --repo # also scan tracked repo files, including hidden dotfiles
316
+ ./awesome leaks --repo /path/to/repo --no-db # audit another repo without scanning the tools DB
317
+ ./awesome leaks --repo --pattern 'mcp_[A-Za-z0-9_-]{20,}' # add your own pattern
311
318
  ```
312
319
 
313
- This is heuristic (masked results, no external reporting) — useful for awareness, not a security guarantee.
320
+ This is heuristic (masked results, no external reporting). It helps spot issues early, but it is not a security guarantee. Scanning git history (removed but previously committed secrets) is not included yet.
314
321
 
315
322
  ---
316
323
 
@@ -337,12 +344,12 @@ The catalog is built from **third-party repositories**, so malicious or low-qual
337
344
  ./awesome audit
338
345
  ```
339
346
 
340
- Signals include: many tools with zero stars, single-owner link farms, self-promotion (lists pushing the same owner's repositories), many dead links, very new repos with lots of tools, clones of other lists, and suspicious links/domains (typosquatting-like, IPs, punycode, etc.).
347
+ Signals include (heuristic, for manual review): many tools with zero stars, low-diversity or single-owner external GitHub link sets, self-promotion of **other repositories** by the same owner (links inside the audited list's own repo are treated separately as internal/monorepo structure), many dead links, clones of other lists, and suspicious links/domains (typosquatting-like, IPs, punycode, etc.). Audit may also add context labels such as auto-generated star dumps or same-owner multi-list low-reputation farms.
341
348
 
342
349
  Important caveats:
343
350
  - **Not malware scanning of target repos.** It flags suspicious signals, not proof of malice.
344
351
  - **Signals are for manual review**, not automatic verdicts.
345
- - Ranking already resists single-list influence: tools benefit from agreement across independent lists and clone detection reduces duplicate influence.
352
+ - Ranking/build also reduce single-source influence: tools benefit from agreement across independent lists, clone detection reduces duplicate influence, and suspected SEO farms/mass aggregators are tracked to limit their impact on consensus/quality.
346
353
  - **`awesome install` is only `git clone`.** It does not execute remote code, but you decide what to do with cloned code afterward.
347
354
 
348
355
  Rule of thumb: a tool from one new/unknown list is a reason to inspect, not blindly install.
@@ -2,8 +2,11 @@
2
2
 
3
3
  [![PyPI](https://img.shields.io/pypi/v/awesome-core?label=PyPI)](https://pypi.org/project/awesome-core/)
4
4
  [![Python versions](https://img.shields.io/pypi/pyversions/awesome-core)](https://pypi.org/project/awesome-core/)
5
+ [![CI](https://github.com/twojlogin/awesome-core/actions/workflows/ci.yml/badge.svg)](https://github.com/twojlogin/awesome-core/actions/workflows/ci.yml)
5
6
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](#license)
6
7
  [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-io.github.twojlogin%2Fawesome--core-6f42c1)](https://registry.modelcontextprotocol.io/v0/servers?search=awesome-core)
8
+ [![awesome-core MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/twojlogin/awesome-core/badges/score.svg)](https://glama.ai/mcp/servers/twojlogin/awesome-core)
9
+ [![Listed on L’Atlas](https://latlas.dev/badge/fiche/io.github.twojlogin/awesome-core.svg?lang=en)](https://latlas.dev/en/mcp/io.github.twojlogin/awesome-core)
7
10
 
8
11
  <!-- mcp-name: io.github.twojlogin/awesome-core -->
9
12
 
@@ -141,6 +144,7 @@ Quick path if you're short on time:
141
144
  ./awesome audit sindresorhus/awesome # audit a single repository
142
145
  ./awesome leaks # scan for possible leaked secrets (local)
143
146
  ./awesome leaks --readmes # also scan raw README files (offline)
147
+ ./awesome leaks --repo # also scan tracked repo files (incl. hidden)
144
148
  ./awesome lists # top lists
145
149
  ./awesome info nmap # details + install hint
146
150
  ./awesome install nmap # install (git clone)
@@ -285,14 +289,17 @@ Notes:
285
289
 
286
290
  This is pattern-based filtering, not a guarantee. Treat descriptions as data.
287
291
 
288
- You can also scan locally for possible leaked secrets/tokens in descriptions and README files:
292
+ You can also scan locally for possible leaked secrets/tokens in descriptions, README files, and tracked repository files:
289
293
 
290
294
  ```bash
291
295
  ./awesome leaks
292
296
  ./awesome leaks --readmes # also scan raw README files (offline)
297
+ ./awesome leaks --repo # also scan tracked repo files, including hidden dotfiles
298
+ ./awesome leaks --repo /path/to/repo --no-db # audit another repo without scanning the tools DB
299
+ ./awesome leaks --repo --pattern 'mcp_[A-Za-z0-9_-]{20,}' # add your own pattern
293
300
  ```
294
301
 
295
- This is heuristic (masked results, no external reporting) — useful for awareness, not a security guarantee.
302
+ This is heuristic (masked results, no external reporting). It helps spot issues early, but it is not a security guarantee. Scanning git history (removed but previously committed secrets) is not included yet.
296
303
 
297
304
  ---
298
305
 
@@ -319,12 +326,12 @@ The catalog is built from **third-party repositories**, so malicious or low-qual
319
326
  ./awesome audit
320
327
  ```
321
328
 
322
- Signals include: many tools with zero stars, single-owner link farms, self-promotion (lists pushing the same owner's repositories), many dead links, very new repos with lots of tools, clones of other lists, and suspicious links/domains (typosquatting-like, IPs, punycode, etc.).
329
+ Signals include (heuristic, for manual review): many tools with zero stars, low-diversity or single-owner external GitHub link sets, self-promotion of **other repositories** by the same owner (links inside the audited list's own repo are treated separately as internal/monorepo structure), many dead links, clones of other lists, and suspicious links/domains (typosquatting-like, IPs, punycode, etc.). Audit may also add context labels such as auto-generated star dumps or same-owner multi-list low-reputation farms.
323
330
 
324
331
  Important caveats:
325
332
  - **Not malware scanning of target repos.** It flags suspicious signals, not proof of malice.
326
333
  - **Signals are for manual review**, not automatic verdicts.
327
- - Ranking already resists single-list influence: tools benefit from agreement across independent lists and clone detection reduces duplicate influence.
334
+ - Ranking/build also reduce single-source influence: tools benefit from agreement across independent lists, clone detection reduces duplicate influence, and suspected SEO farms/mass aggregators are tracked to limit their impact on consensus/quality.
328
335
  - **`awesome install` is only `git clone`.** It does not execute remote code, but you decide what to do with cloned code afterward.
329
336
 
330
337
  Rule of thumb: a tool from one new/unknown list is a reason to inspect, not blindly install.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awesome-core
3
- Version: 2.1.0
3
+ Version: 2.2.2
4
4
  Summary: Offline-first catalog of tools from GitHub awesome lists, exposed as a read-only MCP server (stdio). Pure stdlib core, no network, no API keys.
5
5
  Author: Arkadiusz Słowik
6
6
  License-Expression: MIT
@@ -20,8 +20,11 @@ Dynamic: license-file
20
20
 
21
21
  [![PyPI](https://img.shields.io/pypi/v/awesome-core?label=PyPI)](https://pypi.org/project/awesome-core/)
22
22
  [![Python versions](https://img.shields.io/pypi/pyversions/awesome-core)](https://pypi.org/project/awesome-core/)
23
+ [![CI](https://github.com/twojlogin/awesome-core/actions/workflows/ci.yml/badge.svg)](https://github.com/twojlogin/awesome-core/actions/workflows/ci.yml)
23
24
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](#license)
24
25
  [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-io.github.twojlogin%2Fawesome--core-6f42c1)](https://registry.modelcontextprotocol.io/v0/servers?search=awesome-core)
26
+ [![awesome-core MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/twojlogin/awesome-core/badges/score.svg)](https://glama.ai/mcp/servers/twojlogin/awesome-core)
27
+ [![Listed on L’Atlas](https://latlas.dev/badge/fiche/io.github.twojlogin/awesome-core.svg?lang=en)](https://latlas.dev/en/mcp/io.github.twojlogin/awesome-core)
25
28
 
26
29
  <!-- mcp-name: io.github.twojlogin/awesome-core -->
27
30
 
@@ -159,6 +162,7 @@ Quick path if you're short on time:
159
162
  ./awesome audit sindresorhus/awesome # audit a single repository
160
163
  ./awesome leaks # scan for possible leaked secrets (local)
161
164
  ./awesome leaks --readmes # also scan raw README files (offline)
165
+ ./awesome leaks --repo # also scan tracked repo files (incl. hidden)
162
166
  ./awesome lists # top lists
163
167
  ./awesome info nmap # details + install hint
164
168
  ./awesome install nmap # install (git clone)
@@ -303,14 +307,17 @@ Notes:
303
307
 
304
308
  This is pattern-based filtering, not a guarantee. Treat descriptions as data.
305
309
 
306
- You can also scan locally for possible leaked secrets/tokens in descriptions and README files:
310
+ You can also scan locally for possible leaked secrets/tokens in descriptions, README files, and tracked repository files:
307
311
 
308
312
  ```bash
309
313
  ./awesome leaks
310
314
  ./awesome leaks --readmes # also scan raw README files (offline)
315
+ ./awesome leaks --repo # also scan tracked repo files, including hidden dotfiles
316
+ ./awesome leaks --repo /path/to/repo --no-db # audit another repo without scanning the tools DB
317
+ ./awesome leaks --repo --pattern 'mcp_[A-Za-z0-9_-]{20,}' # add your own pattern
311
318
  ```
312
319
 
313
- This is heuristic (masked results, no external reporting) — useful for awareness, not a security guarantee.
320
+ This is heuristic (masked results, no external reporting). It helps spot issues early, but it is not a security guarantee. Scanning git history (removed but previously committed secrets) is not included yet.
314
321
 
315
322
  ---
316
323
 
@@ -337,12 +344,12 @@ The catalog is built from **third-party repositories**, so malicious or low-qual
337
344
  ./awesome audit
338
345
  ```
339
346
 
340
- Signals include: many tools with zero stars, single-owner link farms, self-promotion (lists pushing the same owner's repositories), many dead links, very new repos with lots of tools, clones of other lists, and suspicious links/domains (typosquatting-like, IPs, punycode, etc.).
347
+ Signals include (heuristic, for manual review): many tools with zero stars, low-diversity or single-owner external GitHub link sets, self-promotion of **other repositories** by the same owner (links inside the audited list's own repo are treated separately as internal/monorepo structure), many dead links, clones of other lists, and suspicious links/domains (typosquatting-like, IPs, punycode, etc.). Audit may also add context labels such as auto-generated star dumps or same-owner multi-list low-reputation farms.
341
348
 
342
349
  Important caveats:
343
350
  - **Not malware scanning of target repos.** It flags suspicious signals, not proof of malice.
344
351
  - **Signals are for manual review**, not automatic verdicts.
345
- - Ranking already resists single-list influence: tools benefit from agreement across independent lists and clone detection reduces duplicate influence.
352
+ - Ranking/build also reduce single-source influence: tools benefit from agreement across independent lists, clone detection reduces duplicate influence, and suspected SEO farms/mass aggregators are tracked to limit their impact on consensus/quality.
346
353
  - **`awesome install` is only `git clone`.** It does not execute remote code, but you decide what to do with cloned code afterward.
347
354
 
348
355
  Rule of thumb: a tool from one new/unknown list is a reason to inspect, not blindly install.
@@ -327,6 +327,7 @@ def build(data_dir=None, verbose=True, export=None, export_limit=None,
327
327
  repo_quality, owner_info = _compute_repo_quality(stats_by_repo, repos, all_mentions, best, carried)
328
328
  _log(verbose, f" jakość list: {time.perf_counter() - started_quality:.1f}s")
329
329
 
330
+ repos_with_tools = {m["repo"] for ms in all_mentions.values() for m in ms}
330
331
  # rejestr farm SEO (suspected_farms) na podstawie wykrytych ownerów
331
332
  try:
332
333
  detected = set()
@@ -335,7 +336,8 @@ def build(data_dir=None, verbose=True, export=None, export_limit=None,
335
336
  detected.add(owner)
336
337
  sample = ";".join(
337
338
  [fn for fn, r in repos.items()
338
- if (r.get("owner") or fn.split("/")[0]).lower() == owner][:5]
339
+ if fn in repos_with_tools
340
+ and (r.get("owner") or fn.split("/")[0]).lower() == owner][:5]
339
341
  )
340
342
  store.upsert_suspected_farm(
341
343
  conn, owner,
@@ -353,6 +355,23 @@ def build(data_dir=None, verbose=True, export=None, export_limit=None,
353
355
  sample_repos="", status="vanished", commit=False)
354
356
  except Exception:
355
357
  pass
358
+ # usuń osierocone wpisy (brak właściciela w aktualnych repos)
359
+ try:
360
+ repo_owners = {
361
+ (r.get("owner") or fn.split("/")[0]).lower()
362
+ for fn, r in repos.items()
363
+ if (r.get("owner") or ("/" in fn))
364
+ }
365
+ if repo_owners:
366
+ placeholders = ",".join("?" for _ in repo_owners)
367
+ conn.execute(
368
+ f"DELETE FROM suspected_farms WHERE lower(owner) NOT IN ({placeholders})",
369
+ tuple(repo_owners),
370
+ )
371
+ else:
372
+ conn.execute("DELETE FROM suspected_farms")
373
+ except Exception:
374
+ pass
356
375
  conn.commit()
357
376
  if detected:
358
377
  _log(verbose, f" suspected_farms: {len(detected)} aktywnych")
@@ -457,15 +476,19 @@ def _detect_clones(all_mentions, repos, threshold=None, min_shared=None, min_siz
457
476
  return rows, clones_mod.clone_map(rows)
458
477
 
459
478
 
460
- def _owner_farm_info(repos):
479
+ def _owner_farm_info(repos, repos_with_tools=None):
461
480
  """Wykrywa farmy SEO i masowych agregatorów jednego autora.
462
481
 
463
482
  - farma niskogwiazdkowa: >=8 list i mediana gwiazdek <150
464
483
  - masowy agregator: bardzo wiele list od jednego ownera (np. uhub/awesome-*),
465
- nawet przy wyższych gwiazdkach — obniżamy zaufanie i wpływ na consensus.
484
+ przy niskiej/średniej medianie gwiazdek — obniżamy zaufanie i wpływ na consensus.
485
+ Zliczane są tylko repozytoria, które w bieżącym buildzie mają narzędzia (tools > 0).
466
486
  """
487
+ allowed = repos_with_tools if repos_with_tools is not None else set(repos.keys())
467
488
  by_owner = defaultdict(list)
468
489
  for full_name, repo in repos.items():
490
+ if full_name not in allowed:
491
+ continue
469
492
  owner = (repo.get("owner") or (full_name.split("/")[0] if "/" in full_name else "")).lower()
470
493
  if not owner:
471
494
  continue
@@ -477,8 +500,9 @@ def _owner_farm_info(repos):
477
500
  mid = len(vals) // 2
478
501
  median = vals[mid] if len(vals) % 2 else (vals[mid - 1] + vals[mid]) / 2.0
479
502
  is_farm = count >= 8 and median < 150
480
- # masowy agregator: dużo podobnych/automatycznych list od jednego autora
481
- is_mass_aggregator = (count >= 15) or (count >= 10 and median < 250)
503
+ # masowy agregator: dużo podobnych list od jednego autora, ale nie przy
504
+ # wysokiej medianie gwiazdek (wtedy raczej seria wartościowych zasobów)
505
+ is_mass_aggregator = median < 150 and ((count >= 15) or (count >= 10 and median < 250))
482
506
  multiplier = 1.0
483
507
  if is_farm:
484
508
  multiplier = min(multiplier, 0.78)
@@ -516,7 +540,8 @@ def _compute_repo_quality(stats_by_repo, repos, all_mentions, best, carried):
516
540
  if alive:
517
541
  alive_by_repo[mention["repo"]][1] += 1
518
542
 
519
- owner_info = _owner_farm_info(repos)
543
+ repos_with_tools = {m["repo"] for ms in all_mentions.values() for m in ms}
544
+ owner_info = _owner_farm_info(repos, repos_with_tools=repos_with_tools)
520
545
 
521
546
  quality = {}
522
547
  for full_name, repo in repos.items():
@@ -290,7 +290,7 @@ def download(topic="awesome-list", wide=True, refresh=False, sort="stars",
290
290
 
291
291
  def main(argv=None):
292
292
  args = list(argv if argv is not None else sys.argv[1:])
293
- topic = "awesome-list"
293
+ topic = os.environ.get("AWESOME_TOPIC", "awesome-list")
294
294
  wide = "--wide" in args or not args
295
295
  refresh = "--refresh" in args
296
296
  verbose = "--quiet" not in args
@@ -10,6 +10,7 @@ W raporcie sekret jest maskowany, żeby nie powielać go w logach/terminalu.
10
10
  """
11
11
 
12
12
  import re
13
+ import subprocess
13
14
  from pathlib import Path
14
15
 
15
16
 
@@ -24,12 +25,18 @@ _PATTERNS = [
24
25
  (r"\bAIza[0-9A-Za-z\-_]{35}\b", "Google API key"),
25
26
  (r"\bxox[baprs]-[0-9A-Za-z-]{10,}\b", "Slack token"),
26
27
  (r"\b(?:sk_live|rk_live)_[0-9A-Za-z]{20,}\b", "Stripe live key"),
28
+ (r"\bmcp_ASM-[A-Za-z0-9_-]{20,}\b", "MCP access token"),
27
29
  (r"-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----",
28
30
  "Private key block"),
29
31
  ]
30
32
 
31
33
  _COMPILED = [(re.compile(pattern), label) for pattern, label in _PATTERNS]
32
34
 
35
+ # Domyślne pomijanie przy skanie plików repo (lokalne dane/środowiska/artefakty).
36
+ _REPO_SKIP_PREFIXES = ("data/", "offline-db/", ".venv/", "venv/", ".git/")
37
+ _REPO_SKIP_EXACT = {".git"}
38
+ _MAX_REPO_FILE_BYTES = 1_000_000
39
+
33
40
 
34
41
  def _mask(secret):
35
42
  """Maskuje sekret, zostawiając krótki prefiks/sufiks dla identyfikacji."""
@@ -45,15 +52,39 @@ def _is_placeholder(secret):
45
52
  return "EXAMPLE" in up
46
53
 
47
54
 
48
- def scan_text(text):
55
+ def _compile_extra(extra):
56
+ compiled = []
57
+ for item in (extra or []):
58
+ if not item:
59
+ continue
60
+ if isinstance(item, tuple) and len(item) == 2:
61
+ pat, label = item
62
+ if hasattr(pat, "finditer"):
63
+ compiled.append((pat, label))
64
+ else:
65
+ compiled.append((re.compile(str(pat)), label or "Custom pattern"))
66
+ elif isinstance(item, str):
67
+ compiled.append((re.compile(item), "Custom pattern"))
68
+ return compiled
69
+
70
+
71
+ def _iter_patterns(extra=None):
72
+ return list(_COMPILED) + _compile_extra(extra)
73
+
74
+
75
+ def scan_text(text, extra=None):
49
76
  """Zwraca listę trafień [(etykieta, zamaskowana_próbka), ...]."""
50
77
  if not text:
51
78
  return []
52
79
  text = str(text)
53
80
  hits = []
54
81
  seen = set()
55
- for pattern, label in _COMPILED:
56
- for match in pattern.finditer(text):
82
+ for pattern, label in _iter_patterns(extra):
83
+ try:
84
+ matches = pattern.finditer(text)
85
+ except Exception:
86
+ continue
87
+ for match in matches:
57
88
  secret = match.group(0)
58
89
  if _is_placeholder(secret):
59
90
  continue
@@ -66,7 +97,7 @@ def scan_text(text):
66
97
  return hits
67
98
 
68
99
 
69
- def scan(conn):
100
+ def scan(conn, extra=None):
70
101
  """Przeskanuj bazę pod kątem możliwych wycieków sekretów.
71
102
 
72
103
  Zwraca (liczba_przeskanowanych_narzędzi, lista_trafień).
@@ -96,7 +127,7 @@ def scan(conn):
96
127
  for row in conn.execute(
97
128
  "SELECT name, description, url_norm, source_repo FROM tools"):
98
129
  for field in ("name", "description"):
99
- for kind, sample in scan_text(row[field]):
130
+ for kind, sample in scan_text(row[field], extra=extra):
100
131
  _add(row["url_norm"], row["name"], field, kind, sample,
101
132
  row["source_repo"])
102
133
 
@@ -104,7 +135,7 @@ def scan(conn):
104
135
  try:
105
136
  for row in conn.execute(
106
137
  "SELECT url_norm, name, source_repo, description FROM tool_mentions"):
107
- for kind, sample in scan_text(row["description"]):
138
+ for kind, sample in scan_text(row["description"], extra=extra):
108
139
  _add(row["url_norm"], row["name"], "mention_description",
109
140
  kind, sample, row["source_repo"])
110
141
  except Exception:
@@ -114,7 +145,7 @@ def scan(conn):
114
145
  return tools, hits
115
146
 
116
147
 
117
- def scan_readmes(readmes_dir):
148
+ def scan_readmes(readmes_dir, extra=None):
118
149
  """Skanuje surowe pliki README (*.md) w katalogu (lokalnie, offline).
119
150
 
120
151
  Zwraca (liczba_plików, lista_trafień). Każde trafienie ma field='readme',
@@ -135,7 +166,7 @@ def scan_readmes(readmes_dir):
135
166
  continue
136
167
  name = md_path.stem.replace("__", "/", 1)
137
168
  source = str(md_path)
138
- for kind, sample in scan_text(text):
169
+ for kind, sample in scan_text(text, extra=extra):
139
170
  key = (name, "readme", kind, sample, source)
140
171
  if key in seen:
141
172
  continue
@@ -149,3 +180,71 @@ def scan_readmes(readmes_dir):
149
180
  "source": source,
150
181
  })
151
182
  return files, hits
183
+
184
+
185
+ def _skip_repo_path(relpath):
186
+ p = relpath.replace("\\", "/")
187
+ if p in _REPO_SKIP_EXACT:
188
+ return True
189
+ for prefix in _REPO_SKIP_PREFIXES:
190
+ if p == prefix.rstrip("/") or p.startswith(prefix):
191
+ return True
192
+ return False
193
+
194
+
195
+ def scan_repo(repo_dir, extra=None, max_bytes=_MAX_REPO_FILE_BYTES):
196
+ """Skanuje pliki śledzone przez git w repozytorium (w tym ukryte).
197
+
198
+ Zwraca (liczba_przeskanowanych_plików, lista_trafień). Każde trafienie ma
199
+ field='repo_file', name/source ustawione na ścieżkę względem repo.
200
+ Pomija binaria, duże pliki i lokalne katalogi danych/środowisk.
201
+ To heurystyki — wyniki wymagają ręcznej weryfikacji.
202
+ """
203
+ root = Path(repo_dir)
204
+ try:
205
+ proc = subprocess.run(
206
+ ["git", "-C", str(root), "ls-files", "-z"],
207
+ capture_output=True, check=False,
208
+ )
209
+ except OSError:
210
+ return 0, []
211
+ if proc.returncode != 0:
212
+ return 0, []
213
+
214
+ raw = proc.stdout.decode("utf-8", errors="replace")
215
+ paths = [p for p in raw.split("\0") if p]
216
+ hits = []
217
+ seen = set()
218
+ files = 0
219
+ for rel in paths:
220
+ if _skip_repo_path(rel):
221
+ continue
222
+ file_path = root / rel
223
+ try:
224
+ if file_path.is_symlink():
225
+ continue
226
+ size = file_path.stat().st_size
227
+ if size > max_bytes:
228
+ continue
229
+ with open(file_path, "rb") as f:
230
+ data = f.read(max_bytes + 1)
231
+ except OSError:
232
+ continue
233
+ if b"\0" in data:
234
+ continue
235
+ files += 1
236
+ text = data.decode("utf-8", errors="replace")
237
+ for kind, sample in scan_text(text, extra=extra):
238
+ key = (rel, "repo_file", kind, sample, rel)
239
+ if key in seen:
240
+ continue
241
+ seen.add(key)
242
+ hits.append({
243
+ "url": "",
244
+ "name": rel,
245
+ "field": "repo_file",
246
+ "kind": kind,
247
+ "sample": sample,
248
+ "source": rel,
249
+ })
250
+ return files, hits
@@ -27,7 +27,7 @@ from core.tools_db import ToolsDB
27
27
 
28
28
  PROTOCOL_DEFAULT = "2025-06-18"
29
29
  SERVER_NAME = "awesome-core"
30
- SERVER_VERSION = "2.0"
30
+ SERVER_VERSION = "2.2.2"
31
31
 
32
32
  MAX_LIMIT = 50
33
33
  MAX_QUERY = 200
@@ -37,38 +37,52 @@ TOOLS = [
37
37
  {
38
38
  "name": "search_tools",
39
39
  "description": (
40
- "Szukaj narzędzi w lokalnej bazie awesome list (offline). "
41
- "Wspiera filtry języka, platformy, domeny i minimalnej zgody "
42
- "kuratorów. Zwrócone wyniki mają prawdziwe gwiazdki z GitHuba, "
43
- "liczbę niezależnych list i score."
40
+ "Search the local offline awesome-list catalog for tools. "
41
+ "Returns matching tools with GitHub stars, independent curator list count, score, "
42
+ "language, platform, and liveness. Use filters to narrow by language, platform, "
43
+ "domain, minimum consensus, minimum stars, or liveness. This tool does not recommend; "
44
+ "it returns results matching explicit criteria."
44
45
  ),
45
46
  "inputSchema": {
46
47
  "type": "object",
47
48
  "properties": {
48
- "query": {"type": "string", "description": "Zapytanie, np. 'port scanner'"},
49
- "lang": {"type": "string", "description": "Język narzędzia, np. Python, Go"},
49
+ "query": {
50
+ "type": "string",
51
+ "description": "Search query, e.g. 'port scanner', 'password manager', 'pdf'.",
52
+ },
53
+ "lang": {
54
+ "type": "string",
55
+ "description": "Programming language filter, e.g. 'Python', 'Go', 'Rust'.",
56
+ },
50
57
  "platform": {
51
58
  "type": "string",
52
- "description": "Platforma, np. windows, WSL, Linux, Docker, CLI",
59
+ "description": "Platform filter, e.g. 'windows', 'linux', 'macos', 'WSL', 'Docker', 'CLI'.",
53
60
  },
54
61
  "domain": {
55
62
  "type": "string",
56
- "description": "Domena, np. osint, security, network, devops, ml",
63
+ "description": "Domain/category filter, e.g. 'osint', 'security', 'network', 'devops', 'ml'.",
57
64
  },
58
65
  "min_consensus": {
59
66
  "type": "integer",
60
- "description": "Minimalna liczba niezależnych list (2 = sensowne minimum)",
67
+ "description": "Minimum number of independent awesome lists mentioning the tool. Use 2 for stronger consensus.",
68
+ },
69
+ "min_stars": {
70
+ "type": "integer",
71
+ "description": "Minimum GitHub star count for the tool repository.",
61
72
  },
62
- "min_stars": {"type": "integer", "description": "Minimalne gwiazdki repozytorium"},
63
73
  "alive_only": {
64
74
  "type": "boolean",
65
- "description": "Tylko linki potwierdzone jako żywe (martwe oznaczamy 'LINK MARTWY')",
75
+ "description": "If true, return only tools whose links were confirmed alive.",
66
76
  },
67
77
  "sort": {
68
78
  "type": "string",
69
79
  "enum": ["score", "stars", "consensus", "underrated", "gem", "name"],
80
+ "description": "Sort order: score (default), stars, consensus, underrated, gem, or name.",
81
+ },
82
+ "limit": {
83
+ "type": "integer",
84
+ "description": "Maximum number of results to return (1-50, default 15).",
70
85
  },
71
- "limit": {"type": "integer", "description": "Ile wyników (max 50)"},
72
86
  },
73
87
  "required": ["query"],
74
88
  },
@@ -76,50 +90,76 @@ TOOLS = [
76
90
  {
77
91
  "name": "find_undiscovered_tools",
78
92
  "description": (
79
- "Filtr po kryteriach, NIE rekomendacja. Zwraca narzędzia z "
80
- "wysokim score, ale małą liczbą gwiazdek (mniej rozgłośnione) "
81
- "albo z wysokim score, ale małą liczbą list. To zapytanie "
82
- "'co spełnia te warunki', a nie 'co powinieneś wybrać'."
93
+ "Filter the catalog for less-known tools matching explicit criteria. "
94
+ "Returns two views: high score with few GitHub stars, and high score with few independent lists. "
95
+ "This is a filter, not a recommendation. Use it when the user asks for under-the-radar or low-star options."
83
96
  ),
84
97
  "inputSchema": {
85
98
  "type": "object",
86
99
  "properties": {
87
- "lang": {"type": "string"},
88
- "platform": {"type": "string"},
89
- "limit": {"type": "integer"},
100
+ "lang": {
101
+ "type": "string",
102
+ "description": "Optional programming language filter, e.g. 'Python'.",
103
+ },
104
+ "platform": {
105
+ "type": "string",
106
+ "description": "Optional platform filter, e.g. 'linux', 'windows', 'CLI'.",
107
+ },
108
+ "limit": {
109
+ "type": "integer",
110
+ "description": "Maximum number of results per view (1-50, default 10).",
111
+ },
90
112
  },
91
113
  },
92
114
  },
93
115
  {
94
116
  "name": "explain_tool",
95
117
  "description": (
96
- "Wyjaśnij ranking narzędzia: z jakich list pochodzi, ile wynosi "
97
- "zgoda kuratorów, co ważyło w score. Użyj, gdy agent musi uzasadnić "
98
- "rekomendację."
118
+ "Explain why a tool ranks the way it does in the local catalog. "
119
+ "Returns score breakdown, curator consensus, list mentions, stars, and metadata. "
120
+ "Use after search_tools when the user wants evidence for a specific tool."
99
121
  ),
100
122
  "inputSchema": {
101
123
  "type": "object",
102
- "properties": {"tool": {"type": "string", "description": "Nazwa albo URL narzędzia"}},
124
+ "properties": {
125
+ "tool": {
126
+ "type": "string",
127
+ "description": "Tool name or URL to explain, e.g. 'nmap' or 'https://github.com/nmap/nmap'.",
128
+ }
129
+ },
103
130
  "required": ["tool"],
104
131
  },
105
132
  },
106
133
  {
107
134
  "name": "lists_with_tool",
108
- "description": "Wszystkie awesome list, w których występuje narzędzie (z zaznaczeniem kopii).",
135
+ "description": (
136
+ "List awesome lists that mention a specific tool. "
137
+ "Returns source list names and indicates copy/fork relationships when detected. "
138
+ "Use to verify curator consensus or inspect where a tool appears."
139
+ ),
109
140
  "inputSchema": {
110
141
  "type": "object",
111
- "properties": {"tool": {"type": "string"}},
142
+ "properties": {
143
+ "tool": {
144
+ "type": "string",
145
+ "description": "Tool name or URL to look up, e.g. 'ripgrep'.",
146
+ }
147
+ },
112
148
  "required": ["tool"],
113
149
  },
114
150
  },
115
151
  {
116
152
  "name": "catalog_facets",
117
153
  "description": (
118
- "Zawartość katalogu: liczba narzędzi i list, dostępne języki, "
119
- "platformy, domeny oraz listy z najwyższą oceną jakości. Użyj na początku, żeby "
120
- "wiedzieć, czego w ogóle da się szukać."
154
+ "Get an overview of the local catalog contents. "
155
+ "Returns total tool/list counts, available languages, platforms, domains, and top-quality lists. "
156
+ "Use this first when you need to discover valid filter values before searching."
121
157
  ),
122
- "inputSchema": {"type": "object", "properties": {}},
158
+ "inputSchema": {
159
+ "type": "object",
160
+ "properties": {},
161
+ "additionalProperties": False,
162
+ },
123
163
  },
124
164
  ]
125
165
 
@@ -130,7 +170,8 @@ def _clip(text, limit=DESC_CHARS):
130
170
 
131
171
 
132
172
  def _tool_line(index, tool):
133
- parts = [f"{index}. {tool.get('name', '?')}"]
173
+ name = untrusted.sanitize(tool.get("name"), limit=120)[0] or "?"
174
+ parts = [f"{index}. {name}"]
134
175
  meta = []
135
176
  lang = tool.get("lang")
136
177
  if lang and lang != "?":
@@ -327,8 +368,9 @@ class MCPServer:
327
368
  f" - {m['source_repo']} ({m['section'] or '—'})"
328
369
  for m in detail["mentions"][:15]
329
370
  )
371
+ name = untrusted.sanitize(tool.get("name"), limit=120)[0] or "?"
330
372
  return "\n".join([
331
- f"{tool['name']} — {tool.get('url', '')}",
373
+ f"{name} — {tool.get('url', '')}",
332
374
  f"score {detail['score']:.1f} · niedoceniane {detail['underrated']:.1f}",
333
375
  f"język {tool.get('lang') or '?'} · platforma {tool.get('platform') or '—'}",
334
376
  f"gwiazdki {tool.get('tool_stars', 0)} · zgoda {tool.get('lists_count', 0)} list"
@@ -358,7 +400,8 @@ class MCPServer:
358
400
  if canonical:
359
401
  marker = f" [kopia listy {canonical}]"
360
402
  lines.append(f" - {mention['source_repo']} ({mention['section'] or '—'}){marker}")
361
- return "\n".join([f"{tool['name']} w {len(lines)} listach:"] + lines)
403
+ name = untrusted.sanitize(tool.get("name"), limit=120)[0] or "?"
404
+ return "\n".join([f"{name} w {len(lines)} listach:"] + lines)
362
405
 
363
406
  def _facets(self):
364
407
  stats = self.db.stats()
@@ -440,11 +483,12 @@ def main(argv=None):
440
483
  demo(data_dir, query)
441
484
  return 0
442
485
  if not store.db_ready(data_dir):
443
- print(f"Brak bazy w {data_dir}. Zbuduj ją: python3 extract_tools.py",
486
+ print(f"[awesome-mcp] brak bazy w {data_dir}; serwer startuje, "
487
+ "ale narzędzia katalogu zwrócą błąd do czasu zbudowania bazy "
488
+ "(python3 extract_tools.py)", file=sys.stderr)
489
+ else:
490
+ print(f"[awesome-mcp] gotowy (baza {data_dir}); loguję na stderr",
444
491
  file=sys.stderr)
445
- return 1
446
- print(f"[awesome-mcp] gotowy (baza {data_dir}); loguję na stderr",
447
- file=sys.stderr)
448
492
  serve(data_dir)
449
493
  return 0
450
494
 
@@ -111,35 +111,67 @@ def assess_list(conn, full_name):
111
111
  elif unique_tools >= 60 and stars < 5:
112
112
  attention.append(f"{unique_tools} narzędzi przy {stars} gwiazdkach")
113
113
 
114
- owners = conn.execute(
115
- "SELECT COUNT(DISTINCT substr(url_norm, 12, instr(substr(url_norm, 12), '/') - 1)) "
116
- "c FROM tools WHERE source_repo = ? AND url_norm LIKE 'github.com/%'",
117
- (full_name,),
118
- ).fetchone()["c"]
119
114
  github_tools = conn.execute(
120
115
  "SELECT COUNT(*) c FROM tools WHERE source_repo = ? "
121
116
  "AND url_norm LIKE 'github.com/%'", (full_name,)
122
117
  ).fetchone()["c"]
123
- if github_tools >= 10 and owners == 1:
124
- attention.append(
125
- f"{github_tools} linków do jednego właściciela — linki do jednego projektu, "
126
- f"nie katalog")
127
- elif github_tools >= 40 and owners <= max(2, github_tools // 40):
128
- attention.append(f"tylko {owners} różnych właścicieli dla {github_tools} linków")
129
118
 
130
119
  list_owner = full_name.split("/")[0].lower() if "/" in full_name else ""
131
- self_count = 0
120
+ list_full = full_name.lower()
121
+ same_repo = 0
122
+ if github_tools >= 10:
123
+ same_repo = conn.execute(
124
+ "SELECT COUNT(*) c FROM tools WHERE source_repo = ? "
125
+ "AND (lower(url_norm) = ? OR lower(url_norm) LIKE ?)",
126
+ (full_name, f"github.com/{list_full}", f"github.com/{list_full}/%"),
127
+ ).fetchone()["c"]
128
+ ext_tools = github_tools - same_repo
129
+
130
+ if github_tools >= 10:
131
+ if same_repo == 0:
132
+ owners = conn.execute(
133
+ "SELECT COUNT(DISTINCT substr(url_norm, 12, instr(substr(url_norm, 12), '/') - 1)) "
134
+ "c FROM tools WHERE source_repo = ? AND url_norm LIKE 'github.com/%'",
135
+ (full_name,),
136
+ ).fetchone()["c"]
137
+ if owners == 1:
138
+ attention.append(
139
+ f"{github_tools} linków do jednego właściciela — linki do jednego projektu, "
140
+ f"nie katalog")
141
+ elif github_tools >= 40 and owners <= max(2, github_tools // 40):
142
+ attention.append(
143
+ f"tylko {owners} różnych właścicieli dla {github_tools} linków")
144
+ elif ext_tools >= 10:
145
+ ext_owners = conn.execute(
146
+ "SELECT COUNT(DISTINCT substr(url_norm, 12, instr(substr(url_norm, 12), '/') - 1)) "
147
+ "c FROM tools WHERE source_repo = ? AND url_norm LIKE 'github.com/%' "
148
+ "AND NOT (lower(url_norm) = ? OR lower(url_norm) LIKE ?)",
149
+ (full_name, f"github.com/{list_full}", f"github.com/{list_full}/%"),
150
+ ).fetchone()["c"]
151
+ if ext_owners == 1:
152
+ attention.append(
153
+ f"{ext_tools} zewnętrznych linków GitHub do jednego właściciela — "
154
+ f"linki do jednego projektu, nie katalog")
155
+ elif ext_tools >= 40 and ext_owners <= max(2, ext_tools // 40):
156
+ attention.append(
157
+ f"tylko {ext_owners} różnych właścicieli dla {ext_tools} "
158
+ f"zewnętrznych linków GitHub")
159
+
132
160
  if github_tools >= 10 and list_owner:
133
- self_count = conn.execute(
161
+ same_owner = conn.execute(
134
162
  "SELECT COUNT(*) c FROM tools WHERE source_repo = ? "
135
163
  "AND url_norm LIKE ?",
136
164
  (full_name, f"github.com/{list_owner}/%"),
137
165
  ).fetchone()["c"]
138
- if self_count >= 10 and self_count / github_tools >= 0.5:
139
- pct = round(self_count / github_tools * 100)
166
+ external_self = same_owner - same_repo
167
+ if external_self >= 10 and external_self / github_tools >= 0.5:
168
+ pct = round(external_self / github_tools * 100)
140
169
  attention.append(
141
- f"autopromocja: {self_count} z {github_tools} linków GitHub "
142
- f"({pct}%) prowadzi do repozytoriów właściciela listy ({list_owner})")
170
+ f"autopromocja: {external_self} z {github_tools} linków GitHub "
171
+ f"({pct}%) prowadzi do innych repozytoriów właściciela listy ({list_owner})")
172
+ if same_repo >= 10 and same_repo * 2 > github_tools:
173
+ info.append(
174
+ "struktura monorepo / linki wewnętrzne do plików tego samego repozytorium")
143
175
 
144
176
  if checked >= 20 and dead / checked > 0.4:
145
177
  attention.append(f"{dead} z {checked} sprawdzonych linków nie żyje "
@@ -151,6 +183,21 @@ def assess_list(conn, full_name):
151
183
  info.append(f"kopia listy {repo['clone_of']}")
152
184
  if repo.get("is_fork") in {True, "true", "1"} and repo.get("parent"):
153
185
  info.append(f"fork listy {repo['parent']}")
186
+ repo_owner = (repo.get("owner") or full_name.split("/")[0]).strip()
187
+ if unique_tools > 500 and stars < 5 and repo_owner:
188
+ farm_count = conn.execute(
189
+ "SELECT COUNT(*) c FROM repos "
190
+ "WHERE lower(owner) = lower(?) "
191
+ "AND COALESCE(unique_tool_count, tool_count, 0) > 500 AND stars < 5",
192
+ (repo_owner,),
193
+ ).fetchone()["c"]
194
+ if farm_count >= 3:
195
+ info.append(
196
+ f"masowy generator list (farma {farm_count} list tego samego właściciela "
197
+ f"o niskiej reputacji)")
198
+ name_blob = f"{full_name} {repo.get('name') or ''}".lower()
199
+ if unique_tools > 500 and stars < 10 and ("stars" in name_blob or "starred" in name_blob):
200
+ info.append("automatyczny zrzut gwiazdek (star dump)")
154
201
  if not (repo.get("description") or "").strip():
155
202
  info.append("brak opisu")
156
203
  if unique_tools and conn.execute(
@@ -2,6 +2,7 @@
2
2
  """core/status.py — stan danych i plan odświeżenia (bez automatyki w tle)."""
3
3
 
4
4
  import calendar
5
+ import json
5
6
  import time
6
7
  from pathlib import Path
7
8
 
@@ -108,12 +109,19 @@ def collect(data_dir=None):
108
109
  f"({github_no_meta} narzędzi bez własnych gwiazdek)",
109
110
  "command": "./awesome enrich",
110
111
  })
111
- steps.append({
112
- "id": "build",
113
- "label": "Przebudować bazę",
114
- "why": "po każdym pobraniu/enrichu",
115
- "command": "./awesome build",
116
- })
112
+ last_build = meta.get("last_build", "")
113
+ last_backfill = meta.get("last_backfill", "")
114
+ last_enrich = meta.get("last_enrich", "")
115
+ needs_build = (not last_build) or (
116
+ bool(last_backfill) and last_backfill > last_build
117
+ ) or (bool(last_enrich) and last_enrich > last_build)
118
+ if needs_build:
119
+ steps.append({
120
+ "id": "build",
121
+ "label": "Przebudować bazę",
122
+ "why": "po backfill/enrichu albo po nowym buildzie",
123
+ "command": "./awesome build",
124
+ })
117
125
 
118
126
  return {
119
127
  "ready": True,
@@ -171,13 +179,106 @@ def render(status):
171
179
  f" ostatni enrich: {status['last_enrich'] or '—'}"
172
180
  + (f" ({status['last_enrich_age']})" if status["last_enrich_age"] else "")
173
181
  + (" ← W TRAKCIE" if status.get("enrich_running") else ""),
174
- "",
175
- "Do odświeżenia (nic nie działa samo):",
176
182
  ]
177
- for step in status["steps"]:
178
- lines.append(f" - {step['label']}: {step['command']}")
179
- if step.get("why"):
180
- lines.append(f" {step['why']}")
181
- lines.append("")
182
- lines.append("Wszystko naraz: ./awesome refresh")
183
+ steps = status.get("steps") or []
184
+ if steps:
185
+ lines.append("")
186
+ lines.append("Do odświeżenia (nic nie działa samo):")
187
+ for step in steps:
188
+ lines.append(f" - {step['label']}: {step['command']}")
189
+ if step.get("why"):
190
+ lines.append(f" {step['why']}")
191
+ lines.append("")
192
+ has_enrich = any(s.get("id") == "enrich" for s in steps)
193
+ if has_enrich:
194
+ lines.append("Szybko: ./awesome refresh | Pełne (z enrich): ./awesome refresh --full")
195
+ else:
196
+ lines.append("Wszystko naraz: ./awesome refresh")
197
+ else:
198
+ lines.append("")
199
+ lines.append("Wszystko aktualne. Nic nie trzeba odświeżać.")
200
+ return lines
201
+
202
+
203
+ SNAPSHOT_KEYS = [
204
+ "tools", "mentions", "lists", "lists_total", "readmes",
205
+ "alive", "dead", "nongithub_links", "db_size_mb",
206
+ "repos_to_fetch", "github_without_own_meta", "lists_without_meta",
207
+ ]
208
+
209
+
210
+ def snapshot_path(data_dir=None):
211
+ return store.db_path(data_dir).parent / "status_snapshot.json"
212
+
213
+
214
+ def history_path(data_dir=None):
215
+ return store.db_path(data_dir).parent / "status_history.jsonl"
216
+
217
+
218
+ def save_snapshot(status, data_dir=None):
219
+ """Zapisz bieżący snapshot (ostatni + historia JSONL)."""
220
+ if not status.get("ready"):
221
+ return None
222
+ snap = {k: status.get(k) for k in SNAPSHOT_KEYS}
223
+ snap["saved_at"] = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
224
+ snap["last_build"] = status.get("last_build", "")
225
+ snap["last_backfill"] = status.get("last_backfill", "")
226
+ snap["last_enrich"] = status.get("last_enrich", "")
227
+ path = snapshot_path(data_dir)
228
+ path.parent.mkdir(parents=True, exist_ok=True)
229
+ path.write_text(json.dumps(snap, ensure_ascii=False, indent=2), encoding="utf-8")
230
+ try:
231
+ with history_path(data_dir).open("a", encoding="utf-8") as f:
232
+ f.write(json.dumps(snap, ensure_ascii=False) + "\n")
233
+ except OSError:
234
+ pass
235
+ return path
236
+
237
+
238
+ def load_snapshot(data_dir=None):
239
+ path = snapshot_path(data_dir)
240
+ if not path.exists():
241
+ return None
242
+ try:
243
+ return json.loads(path.read_text(encoding="utf-8"))
244
+ except Exception:
245
+ return None
246
+
247
+
248
+ def diff_snapshot(current, previous):
249
+ """Porównaj dwa snapshoty. Zwraca listę zmian tekstowych."""
250
+ if not current.get("ready") or not previous:
251
+ return []
252
+ lines = []
253
+ prev_at = previous.get("saved_at", "?")
254
+ lines.append(f"Porównanie z poprzednim snapshotem: {prev_at}")
255
+ labels = {
256
+ "tools": "narzędzia",
257
+ "mentions": "wzmianki",
258
+ "lists": "listy w bazie",
259
+ "lists_total": "listy razem",
260
+ "readmes": "README lokalnie",
261
+ "alive": "linki żywe",
262
+ "dead": "linki martwe",
263
+ "nongithub_links": "poza GitHubem",
264
+ "db_size_mb": "baza MB",
265
+ "repos_to_fetch": "repo do enrich",
266
+ "github_without_own_meta": "narzędzia GH bez meta",
267
+ "lists_without_meta": "listy bez meta",
268
+ }
269
+ for key in SNAPSHOT_KEYS:
270
+ old = previous.get(key)
271
+ new = current.get(key)
272
+ if old is None or new is None:
273
+ continue
274
+ if old == new:
275
+ continue
276
+ delta = new - old
277
+ if isinstance(delta, float):
278
+ lines.append(f" {labels.get(key, key)}: {old:.1f} -> {new:.1f} ({delta:+.1f})")
279
+ else:
280
+ sign = "+" if delta > 0 else ""
281
+ lines.append(f" {labels.get(key, key)}: {old:,} -> {new:,} ({sign}{delta:,})")
282
+ if len(lines) == 1:
283
+ lines.append(" (brak zmian w kluczowych liczbach)")
183
284
  return lines
@@ -31,6 +31,10 @@ _PATTERNS = [
31
31
  (r"(you\s+must|you\s+should\s+now|always)\s+(immediately\s+)?"
32
32
  r"(run|execute|install|clone|download|call|invoke)\b", "nakaz działania", 0),
33
33
  (r"^\s*(system|assistant|user)\s*:\s*", "znacznik roli", re.MULTILINE),
34
+ (r"<\|(?:im_start|im_end|system|user|assistant|endoftext)\|>|<<SYS>>|<</SYS>>|\[/?INST\]",
35
+ "znacznik promptu", 0),
36
+ (r"override\s+(your|all|the|previous|system)\s+"
37
+ r"(instructions?|prompts?|rules|settings)", "nadpisz instrukcje", 0),
34
38
  (r"<\s*(script|iframe|object|embed|form)\b", "tag HTML", 0),
35
39
  (r"\bon(error|load|click|mouseover)\s*=", "handler HTML", 0),
36
40
  # "JavaScript: Build your own 3D renderer" to tytuł kursu, nie atak —
@@ -40,7 +44,13 @@ _PATTERNS = [
40
44
  (r"data\s*:\s*(text/html|application/|image/svg)", "schemat URI", 0),
41
45
  (r"(curl|wget)\s+[^\s|]+\s*\|\s*(sudo\s+)?(ba|z|k)?sh", "pobierz i wykonaj", 0),
42
46
  (r"invoke-expression|\biex\s*\(", "PowerShell IEX", 0),
43
- (r"(rm\s+-rf|mkfs\.|del\s+/[sf]\s)", "kasowanie danych", 0),
47
+ # Opisy narzędzi security często wspominają "rm -rf" jako przykład —
48
+ # samo wystąpienie to nie rozkaz. Flagujemy dopiero gdy wygląda na
49
+ # komendę z celem (ścieżka/wildcard/$/~) albo klasyczny target Windows.
50
+ (r"rm\s+-[a-z]*r[a-z]*f[a-z]*\s+(?:[/~.*$\\]|--no-preserve-root\b)",
51
+ "kasowanie danych", 0),
52
+ (r"mkfs(?:\.[a-z0-9]+)?\s+/dev/", "kasowanie danych", 0),
53
+ (r"del\s+/[a-z]*[sf][a-z]*(?:\s+/[a-z]+)*\s+[A-Za-z]:[\\/]", "kasowanie danych", 0),
44
54
  ]
45
55
 
46
56
  # IGNORECASE jest tu obowiązkowy, nie ozdoba: opis zaczyna się wielką literą
@@ -50,6 +60,8 @@ _COMPILED = [
50
60
  (re.compile(pattern, flags | re.IGNORECASE), label)
51
61
  for pattern, label, flags in _PATTERNS
52
62
  ]
63
+ # ZWJ/ZWNJ (\u200c,\u200d) pomijamy: są legalne w emoji i niektórych pismach.
64
+ _INVISIBLE = re.compile(r'[\u200b\u200e\u200f\u202a-\u202e\u2060-\u2069\ufeff]+')
53
65
 
54
66
  MAX_LEN = 300
55
67
 
@@ -63,6 +75,9 @@ def sanitize(text, limit=MAX_LEN):
63
75
  return "", []
64
76
  clean = " ".join(str(text).split())
65
77
  findings = []
78
+ clean, hits = _INVISIBLE.subn("[odfiltrowano: ukryty znak]", clean)
79
+ if hits:
80
+ findings.append(f"ukryty znak ×{hits}")
66
81
  for pattern, label in _COMPILED:
67
82
  clean, hits = pattern.subn(f"[odfiltrowano: {label}]", clean)
68
83
  if hits:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "awesome-core"
7
- version = "2.1.0"
7
+ version = "2.2.2"
8
8
  description = "Offline-first catalog of tools from GitHub awesome lists, exposed as a read-only MCP server (stdio). Pure stdlib core, no network, no API keys."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes