by2kb 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 (89) hide show
  1. by2kb-0.3.0/.env.example +73 -0
  2. by2kb-0.3.0/.gitignore +29 -0
  3. by2kb-0.3.0/CHANGELOG.md +49 -0
  4. by2kb-0.3.0/LICENSE +21 -0
  5. by2kb-0.3.0/PKG-INFO +697 -0
  6. by2kb-0.3.0/README.md +674 -0
  7. by2kb-0.3.0/by2kb/__init__.py +1 -0
  8. by2kb-0.3.0/by2kb/agent_install.py +54 -0
  9. by2kb-0.3.0/by2kb/agent_runtime.py +210 -0
  10. by2kb-0.3.0/by2kb/cli.py +530 -0
  11. by2kb-0.3.0/by2kb/config.py +189 -0
  12. by2kb-0.3.0/by2kb/doctor.py +390 -0
  13. by2kb-0.3.0/by2kb/enrichment.py +270 -0
  14. by2kb-0.3.0/by2kb/errors.py +66 -0
  15. by2kb-0.3.0/by2kb/filenames.py +47 -0
  16. by2kb-0.3.0/by2kb/integrations/__init__.py +1 -0
  17. by2kb-0.3.0/by2kb/integrations/hermes/__init__.py +245 -0
  18. by2kb-0.3.0/by2kb/integrations/hermes/plugin.yaml +7 -0
  19. by2kb-0.3.0/by2kb/integrations/hermes/skills/video-to-knowledge/SKILL.md +33 -0
  20. by2kb-0.3.0/by2kb/jobs/__init__.py +1 -0
  21. by2kb-0.3.0/by2kb/jobs/enrichment_service.py +342 -0
  22. by2kb-0.3.0/by2kb/jobs/model.py +72 -0
  23. by2kb-0.3.0/by2kb/jobs/runner.py +597 -0
  24. by2kb-0.3.0/by2kb/jobs/store.py +242 -0
  25. by2kb-0.3.0/by2kb/jobs/task_control.py +232 -0
  26. by2kb-0.3.0/by2kb/longform.py +583 -0
  27. by2kb-0.3.0/by2kb/normalize.py +105 -0
  28. by2kb-0.3.0/by2kb/notify/__init__.py +1 -0
  29. by2kb-0.3.0/by2kb/notify/console.py +10 -0
  30. by2kb-0.3.0/by2kb/providers/__init__.py +1 -0
  31. by2kb-0.3.0/by2kb/providers/asr.py +34 -0
  32. by2kb-0.3.0/by2kb/providers/asr_doubao_auc.py +445 -0
  33. by2kb-0.3.0/by2kb/providers/asr_faster_whisper.py +279 -0
  34. by2kb-0.3.0/by2kb/providers/asr_registry.py +160 -0
  35. by2kb-0.3.0/by2kb/providers/base.py +87 -0
  36. by2kb-0.3.0/by2kb/providers/bilibili.py +202 -0
  37. by2kb-0.3.0/by2kb/providers/bilibili_wbi.py +117 -0
  38. by2kb-0.3.0/by2kb/providers/local_media.py +197 -0
  39. by2kb-0.3.0/by2kb/providers/source_bilibili.py +61 -0
  40. by2kb-0.3.0/by2kb/providers/source_registry.py +68 -0
  41. by2kb-0.3.0/by2kb/providers/yt_dlp_source.py +464 -0
  42. by2kb-0.3.0/by2kb/quality.py +181 -0
  43. by2kb-0.3.0/by2kb/setup.py +204 -0
  44. by2kb-0.3.0/by2kb/sinks/__init__.py +1 -0
  45. by2kb-0.3.0/by2kb/sinks/base.py +20 -0
  46. by2kb-0.3.0/by2kb/sinks/filesystem.py +59 -0
  47. by2kb-0.3.0/by2kb/skills/__init__.py +1 -0
  48. by2kb-0.3.0/by2kb/skills/builtin/default/SKILL.md +42 -0
  49. by2kb-0.3.0/by2kb/skills/builtin/short-abstract/SKILL.md +33 -0
  50. by2kb-0.3.0/by2kb/skills/model.py +50 -0
  51. by2kb-0.3.0/by2kb/skills/runner.py +121 -0
  52. by2kb-0.3.0/by2kb/writers/__init__.py +1 -0
  53. by2kb-0.3.0/by2kb/writers/raw.py +99 -0
  54. by2kb-0.3.0/by2kb/writers/updated.py +57 -0
  55. by2kb-0.3.0/docs/agent-enrichment-provider.md +41 -0
  56. by2kb-0.3.0/docs/agent-integration.md +257 -0
  57. by2kb-0.3.0/docs/architecture.md +219 -0
  58. by2kb-0.3.0/docs/asr-providers.md +58 -0
  59. by2kb-0.3.0/docs/doctor.md +48 -0
  60. by2kb-0.3.0/docs/local-media.md +40 -0
  61. by2kb-0.3.0/docs/long-form-enrichment.md +46 -0
  62. by2kb-0.3.0/docs/reference/doubao-auc-tos-asr.md +208 -0
  63. by2kb-0.3.0/docs/source-providers.md +82 -0
  64. by2kb-0.3.0/docs/task-control.md +80 -0
  65. by2kb-0.3.0/docs/tech-design-m1.md +577 -0
  66. by2kb-0.3.0/docs/transcript-quality.md +35 -0
  67. by2kb-0.3.0/examples/doubao_auc_tos_asr.py +331 -0
  68. by2kb-0.3.0/pyproject.toml +33 -0
  69. by2kb-0.3.0/skills/default/SKILL.md +35 -0
  70. by2kb-0.3.0/tests/conftest.py +72 -0
  71. by2kb-0.3.0/tests/unit/test_agent_integration.py +172 -0
  72. by2kb-0.3.0/tests/unit/test_agent_provider.py +221 -0
  73. by2kb-0.3.0/tests/unit/test_asr_registry.py +180 -0
  74. by2kb-0.3.0/tests/unit/test_bilibili_download.py +53 -0
  75. by2kb-0.3.0/tests/unit/test_doctor.py +214 -0
  76. by2kb-0.3.0/tests/unit/test_doubao_auc.py +441 -0
  77. by2kb-0.3.0/tests/unit/test_faster_whisper.py +226 -0
  78. by2kb-0.3.0/tests/unit/test_filenames.py +87 -0
  79. by2kb-0.3.0/tests/unit/test_local_media.py +303 -0
  80. by2kb-0.3.0/tests/unit/test_longform.py +227 -0
  81. by2kb-0.3.0/tests/unit/test_pipeline.py +163 -0
  82. by2kb-0.3.0/tests/unit/test_quality.py +125 -0
  83. by2kb-0.3.0/tests/unit/test_resolve.py +88 -0
  84. by2kb-0.3.0/tests/unit/test_sink.py +138 -0
  85. by2kb-0.3.0/tests/unit/test_source_registry.py +211 -0
  86. by2kb-0.3.0/tests/unit/test_summaries.py +145 -0
  87. by2kb-0.3.0/tests/unit/test_task_control.py +235 -0
  88. by2kb-0.3.0/tests/unit/test_wbi.py +110 -0
  89. by2kb-0.3.0/tests/unit/test_youtube_ingestion.py +218 -0
@@ -0,0 +1,73 @@
1
+ # by2kb secrets — copy this file to `.env` (gitignored) and fill in real values.
2
+ # Never commit the filled-in `.env`. Process environment variables take
3
+ # precedence over entries in `.env`.
4
+ #
5
+ # `.env` is auto-loaded from (first match wins):
6
+ # 1. $BY2KB_ENV_FILE
7
+ # 2. <BY2KB_HOME>/.env (default home: ~/.by2kb)
8
+ # 3. ./.env (current working directory)
9
+
10
+ # ---------------------------------------------------------------------------
11
+ # ASR provider: doubao_auc (Bilibili audio -> text)
12
+ # Two independent credential domains, even if they belong to one Volcengine
13
+ # account. See docs/reference/doubao-auc-tos-asr.md for the full flow.
14
+ # ---------------------------------------------------------------------------
15
+
16
+ # Volcengine TOS (private staging bucket for audio before ASR)
17
+ VOLC_ACCESS_KEY_ID=
18
+ VOLC_SECRET_ACCESS_KEY=
19
+ TOS_BUCKET=
20
+ # Optional, defaults shown:
21
+ # TOS_REGION=ap-southeast-1
22
+ # TOS_S3_ENDPOINT=tos-s3-ap-southeast-1.volces.com
23
+
24
+ # Doubao AUC async file transcription (openspeech.bytedance.com)
25
+ # Preferred new-console authentication:
26
+ DOUBAO_API_KEY=
27
+ # Optional legacy-console fallback:
28
+ DOUBAO_APPID=
29
+ DOUBAO_ACCESS_TOKEN=
30
+ # Optional; verify against the speech product actually purchased:
31
+ # DOUBAO_RESOURCE_ID=volc.seedasr.auc
32
+
33
+ # ---------------------------------------------------------------------------
34
+ # Local ASR provider: faster_whisper
35
+ # Install the optional dependency and model explicitly before selecting it:
36
+ # pipx inject by2kb "faster-whisper>=1.2.1,<2"
37
+ # by2kb models install large-v3-turbo
38
+ # Configure [asr] provider = "faster_whisper" in config.toml.
39
+ # ---------------------------------------------------------------------------
40
+ # BY2KB_WHISPER_MODEL=large-v3-turbo
41
+ # BY2KB_WHISPER_DEVICE=auto
42
+ # BY2KB_WHISPER_COMPUTE_TYPE=default
43
+ # BY2KB_WHISPER_MODEL_DIR=~/.by2kb/models/faster-whisper
44
+ # BY2KB_WHISPER_VAD_FILTER=true
45
+ # BY2KB_WHISPER_BEAM_SIZE=5
46
+ # BY2KB_WHISPER_CPU_THREADS=0
47
+
48
+ # ---------------------------------------------------------------------------
49
+ # LLM for summary enrichment (produces short.<title>.md + long.<title>.md).
50
+ # Optional: without it the pipeline still completes with raw.<title>.md only.
51
+ # This is API-key authentication; no browser or consumer-account login is used.
52
+ # ---------------------------------------------------------------------------
53
+ BY2KB_LLM_API_KEY=
54
+ BY2KB_LLM_MODEL=
55
+ # Optional, defaults to the Volcengine Ark preset:
56
+ # BY2KB_LLM_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
57
+ # OpenAI-compatible alternative:
58
+ # BY2KB_LLM_BASE_URL=https://api.openai.com/v1
59
+
60
+ # Optional skill overrides. Packaged defaults are used when omitted.
61
+ # BY2KB_ABSTRACT_SKILL=short-video-abstract
62
+ # BY2KB_STUDY_SKILL=default-video-digest
63
+
64
+ # ---------------------------------------------------------------------------
65
+ # Storage locations (all optional)
66
+ # ---------------------------------------------------------------------------
67
+ # BY2KB_HOME=~/.by2kb
68
+ # BY2KB_LIBRARY_ROOT=<where raw/abstract/updated artifacts are published>
69
+ # BY2KB_DB_PATH=<job store sqlite path>
70
+
71
+ # Optional comma-separated URL source-provider order. The default is the native
72
+ # Bilibili provider only. Configure yt_dlp in config.toml for its detailed policy.
73
+ # BY2KB_SOURCE_PROVIDERS=bilibili_native,yt_dlp
by2kb-0.3.0/.gitignore ADDED
@@ -0,0 +1,29 @@
1
+ # Secrets and local configuration
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+ *.pem
6
+ *.key
7
+
8
+ # Runtime data
9
+ library/
10
+ data/
11
+ cache/
12
+ *.db
13
+ *.sqlite*
14
+
15
+ # Dependencies and build output
16
+ node_modules/
17
+ .venv/
18
+ __pycache__/
19
+ dist/
20
+ build/
21
+ coverage/
22
+ .pytest_cache/
23
+ .test-tmp-*/
24
+ *.egg-info/
25
+
26
+ # Editors and OS
27
+ .DS_Store
28
+ .idea/
29
+ .vscode/
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## 0.3.0 - 2026-08-29
6
+
7
+ - Add a configurable source-provider registry, adapt native Bilibili ingestion to the
8
+ shared contract, and add an optional yt-dlp transcript/audio provider.
9
+ - Complete the YouTube URL journey with caption-first ingestion, configured ASR
10
+ fallback, stable identity/provenance, and Hermes interception.
11
+ - Add a pluggable ASR provider registry with deterministic explicit selection and
12
+ ordered `auto` fallback.
13
+ - Add optional local `faster-whisper` transcription with timestamped segments,
14
+ configurable runtime settings, and explicit model status/install commands.
15
+ - Accept local audio and video paths in `by2kb ingest`, with content-addressed
16
+ identity, ffmpeg audio extraction, and privacy-safe filename provenance.
17
+ - Expand guided initialization for local/cloud ASR and add read-only `by2kb doctor`
18
+ diagnostics with a stable Agent-readable JSON report.
19
+ - Add deterministic transcript-quality metrics and gates so unusable transcripts stop
20
+ before enrichment while borderline outputs carry a visible warning.
21
+ - Add a cached long-form enrichment pipeline that plans segment-safe chunks,
22
+ recursively reduces grounded notes, and records a public hierarchy trace.
23
+ - Add a staged Agent enrichment provider using bounded `next`/`submit` operations,
24
+ allowing Hermes subscription-authenticated runtimes to execute the shared plan.
25
+ - Add a versioned Agent task-control protocol with stable status snapshots, bounded
26
+ waits, cooperative cancellation, and checkpoint-aware retry.
27
+ - Persist the selected ASR provider, model, and runtime provenance in source and
28
+ transcript artifacts.
29
+
30
+ ## 0.2.1 - 2026-08-25
31
+
32
+ - Name durable Markdown artifacts `raw.<title>.md`, `short.<title>.md`, and
33
+ `long.<title>.md`; safely retire fixed legacy names and unambiguous prior
34
+ suffix-based names on republish.
35
+ - Fall back through Bilibili backup audio CDNs when the preferred CDN returns an
36
+ HTTP or transport failure.
37
+ - Retry transient Doubao AUC failures per long-audio chunk and persist successful
38
+ chunk transcripts so a resumed ingestion does not resubmit completed work.
39
+ - Classify queued, rate-limited, overloaded, and HTTP failure responses correctly;
40
+ harden concurrent checkpoint writes and cache invalidation.
41
+
42
+ ## 0.2.0 - 2026-08-23
43
+
44
+ - Add agent-first enrichment with durable `claim`, `complete`, and `fail` commands.
45
+ - Add short-abstract and long-form study-note execution through external agent hosts.
46
+ - Add the Hermes reference plugin, authorized URL interception, and host-owned LLM use.
47
+ - Add the bundled `video-to-knowledge` Hermes Skill and one-command plugin installer.
48
+ - Add guided `by2kb init` configuration for TOS, Doubao ASR, LLM mode, and local KB.
49
+ - Keep standalone API enrichment and transcript-only operation as supported executors.
by2kb-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Charles
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.