center-kb 0.2.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 (118) hide show
  1. center_kb-0.2.0/.claude/skills/kb-summarize/SKILL.md +42 -0
  2. center_kb-0.2.0/.dockerignore +15 -0
  3. center_kb-0.2.0/.github/workflows/kb-publish.yml +23 -0
  4. center_kb-0.2.0/.github/workflows/kb-review.yml +63 -0
  5. center_kb-0.2.0/.github/workflows/release.yml +101 -0
  6. center_kb-0.2.0/.gitignore +24 -0
  7. center_kb-0.2.0/.kb/arinc-424/_manifest.yaml +2967 -0
  8. center_kb-0.2.0/.kb/arinc-424/ch5-navigation-data-field-definitions.md +2844 -0
  9. center_kb-0.2.0/.kb/arinc-424/ch5-navigation-data-field-definitions.raw.md +8690 -0
  10. center_kb-0.2.0/.kb/icao-annex-3/_manifest.yaml +46 -0
  11. center_kb-0.2.0/.kb/icao-annex-3/ch2-general-provisions.md +65 -0
  12. center_kb-0.2.0/.kb/icao-annex-3/ch2-general-provisions.raw.md +97 -0
  13. center_kb-0.2.0/.kb/index.yaml +23 -0
  14. center_kb-0.2.0/.mcp.json +8 -0
  15. center_kb-0.2.0/AERO-KB_Architecture_v0.1.pdf +0 -0
  16. center_kb-0.2.0/Dockerfile +22 -0
  17. center_kb-0.2.0/LICENSE +202 -0
  18. center_kb-0.2.0/PKG-INFO +552 -0
  19. center_kb-0.2.0/README.md +516 -0
  20. center_kb-0.2.0/docker-compose.yml +16 -0
  21. center_kb-0.2.0/docs/deploy-remote-mcp.md +41 -0
  22. center_kb-0.2.0/docs/superpowers/plans/2026-07-10-aero-kb-phase1.md +2374 -0
  23. center_kb-0.2.0/docs/superpowers/plans/2026-07-10-aero-kb-phase2.md +2069 -0
  24. center_kb-0.2.0/docs/superpowers/plans/2026-07-10-aero-kb-phase3.md +3592 -0
  25. center_kb-0.2.0/docs/superpowers/plans/2026-07-11-review-automation.md +924 -0
  26. center_kb-0.2.0/docs/superpowers/plans/2026-07-11-web-hub-packaging-docker.md +1981 -0
  27. center_kb-0.2.0/docs/superpowers/specs/2026-07-10-aero-kb-phase1-design.md +200 -0
  28. center_kb-0.2.0/docs/superpowers/specs/2026-07-10-aero-kb-phase2-design.md +155 -0
  29. center_kb-0.2.0/docs/superpowers/specs/2026-07-10-aero-kb-phase3-design.md +198 -0
  30. center_kb-0.2.0/docs/superpowers/specs/2026-07-11-review-automation-design.md +164 -0
  31. center_kb-0.2.0/docs/superpowers/specs/2026-07-11-web-ui-packaging-docker-design.md +248 -0
  32. center_kb-0.2.0/pyproject.toml +50 -0
  33. center_kb-0.2.0/scripts/demo-federation.sh +101 -0
  34. center_kb-0.2.0/src/center_kb/__init__.py +1 -0
  35. center_kb-0.2.0/src/center_kb/build.py +130 -0
  36. center_kb-0.2.0/src/center_kb/cli.py +550 -0
  37. center_kb-0.2.0/src/center_kb/diff.py +141 -0
  38. center_kb-0.2.0/src/center_kb/doctor.py +183 -0
  39. center_kb-0.2.0/src/center_kb/embed.py +182 -0
  40. center_kb-0.2.0/src/center_kb/federation.py +62 -0
  41. center_kb-0.2.0/src/center_kb/gitio.py +128 -0
  42. center_kb-0.2.0/src/center_kb/hub.py +95 -0
  43. center_kb-0.2.0/src/center_kb/ingest/__init__.py +0 -0
  44. center_kb-0.2.0/src/center_kb/ingest/parser.py +109 -0
  45. center_kb-0.2.0/src/center_kb/ingest/scaffold.py +116 -0
  46. center_kb-0.2.0/src/center_kb/ingest/sectioner.py +251 -0
  47. center_kb-0.2.0/src/center_kb/initcmd.py +40 -0
  48. center_kb-0.2.0/src/center_kb/kbcontext.py +108 -0
  49. center_kb-0.2.0/src/center_kb/mcp.py +138 -0
  50. center_kb-0.2.0/src/center_kb/mdutils.py +57 -0
  51. center_kb-0.2.0/src/center_kb/models.py +64 -0
  52. center_kb-0.2.0/src/center_kb/publish.py +102 -0
  53. center_kb-0.2.0/src/center_kb/query.py +311 -0
  54. center_kb-0.2.0/src/center_kb/resolve.py +253 -0
  55. center_kb-0.2.0/src/center_kb/review.py +100 -0
  56. center_kb-0.2.0/src/center_kb/templates/init/QUICKSTART.md +18 -0
  57. center_kb-0.2.0/src/center_kb/templates/init/docker-compose.yml +16 -0
  58. center_kb-0.2.0/src/center_kb/templates/init/env.example +1 -0
  59. center_kb-0.2.0/src/center_kb/templates/init/federation-README.md +8 -0
  60. center_kb-0.2.0/src/center_kb/templates/init/index.yaml +1 -0
  61. center_kb-0.2.0/src/center_kb/templates/init/kb-review.yml +63 -0
  62. center_kb-0.2.0/src/center_kb/templates/init/mcp.json +8 -0
  63. center_kb-0.2.0/src/center_kb/templates/init/source-gitignore.txt +2 -0
  64. center_kb-0.2.0/src/center_kb/templates/web/base.html +22 -0
  65. center_kb-0.2.0/src/center_kb/templates/web/doc.html +7 -0
  66. center_kb-0.2.0/src/center_kb/templates/web/docs.html +5 -0
  67. center_kb-0.2.0/src/center_kb/templates/web/login.html +9 -0
  68. center_kb-0.2.0/src/center_kb/templates/web/search.html +8 -0
  69. center_kb-0.2.0/src/center_kb/templates/web/section.html +10 -0
  70. center_kb-0.2.0/src/center_kb/templates/web/style.css +42 -0
  71. center_kb-0.2.0/src/center_kb/web/__init__.py +0 -0
  72. center_kb-0.2.0/src/center_kb/web/api.py +180 -0
  73. center_kb-0.2.0/src/center_kb/web/app.py +45 -0
  74. center_kb-0.2.0/src/center_kb/web/auth.py +75 -0
  75. center_kb-0.2.0/src/center_kb/web/mdrender.py +70 -0
  76. center_kb-0.2.0/src/center_kb/web/ui.py +186 -0
  77. center_kb-0.2.0/tests/__init__.py +0 -0
  78. center_kb-0.2.0/tests/conftest.py +208 -0
  79. center_kb-0.2.0/tests/test_build.py +75 -0
  80. center_kb-0.2.0/tests/test_cli.py +11 -0
  81. center_kb-0.2.0/tests/test_cli_approve.py +122 -0
  82. center_kb-0.2.0/tests/test_cli_context.py +115 -0
  83. center_kb-0.2.0/tests/test_cli_doctor_diff.py +61 -0
  84. center_kb-0.2.0/tests/test_cli_hub.py +73 -0
  85. center_kb-0.2.0/tests/test_diff.py +85 -0
  86. center_kb-0.2.0/tests/test_doctor.py +84 -0
  87. center_kb-0.2.0/tests/test_doctor_hub.py +147 -0
  88. center_kb-0.2.0/tests/test_embed.py +126 -0
  89. center_kb-0.2.0/tests/test_federation.py +75 -0
  90. center_kb-0.2.0/tests/test_gitio.py +159 -0
  91. center_kb-0.2.0/tests/test_heading_config.py +76 -0
  92. center_kb-0.2.0/tests/test_hub.py +103 -0
  93. center_kb-0.2.0/tests/test_ingest_cli.py +70 -0
  94. center_kb-0.2.0/tests/test_init.py +59 -0
  95. center_kb-0.2.0/tests/test_kbcontext.py +158 -0
  96. center_kb-0.2.0/tests/test_mcp.py +151 -0
  97. center_kb-0.2.0/tests/test_mcp_http.py +78 -0
  98. center_kb-0.2.0/tests/test_mdutils.py +62 -0
  99. center_kb-0.2.0/tests/test_models.py +60 -0
  100. center_kb-0.2.0/tests/test_parser.py +85 -0
  101. center_kb-0.2.0/tests/test_phase2_e2e.py +86 -0
  102. center_kb-0.2.0/tests/test_phase3_e2e.py +175 -0
  103. center_kb-0.2.0/tests/test_publish.py +157 -0
  104. center_kb-0.2.0/tests/test_query.py +55 -0
  105. center_kb-0.2.0/tests/test_query_hub.py +128 -0
  106. center_kb-0.2.0/tests/test_query_semantic.py +35 -0
  107. center_kb-0.2.0/tests/test_resolve.py +138 -0
  108. center_kb-0.2.0/tests/test_resolve_hub.py +124 -0
  109. center_kb-0.2.0/tests/test_review.py +139 -0
  110. center_kb-0.2.0/tests/test_scaffold.py +98 -0
  111. center_kb-0.2.0/tests/test_sectioner.py +242 -0
  112. center_kb-0.2.0/tests/test_stats.py +16 -0
  113. center_kb-0.2.0/tests/test_templates.py +20 -0
  114. center_kb-0.2.0/tests/test_web_api.py +94 -0
  115. center_kb-0.2.0/tests/test_web_app.py +53 -0
  116. center_kb-0.2.0/tests/test_web_auth.py +119 -0
  117. center_kb-0.2.0/tests/test_web_mdrender.py +53 -0
  118. center_kb-0.2.0/tests/test_web_ui.py +87 -0
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: kb-summarize
3
+ description: Điền summary L0/L1/L2 cho các section đang pending trong .kb/ sau khi chạy kb ingest. Dùng khi user yêu cầu summarize KB, điền summary, hoặc sau khi vừa ingest tài liệu mới.
4
+ ---
5
+
6
+ # KB Summarize — điền tri thức vào khung .kb/
7
+
8
+ Bạn là "nửa LLM" của pipeline CENTER-KB. `kb ingest` đã sinh khung; nhiệm vụ
9
+ của bạn là điền phần summary. KHÔNG sửa bất kỳ thứ gì ngoài các vị trí nêu dưới.
10
+
11
+ ## Quy trình
12
+
13
+ 1. Chạy `kb status` — lấy danh sách section pending (doc, section id, file).
14
+ 2. Với TỪNG section pending, lặp:
15
+ a. Đọc nguyên văn: `kb get <doc-id> <section-id> --level l3`
16
+ b. Mở file L2 (`.kb/<doc-id>/<file>.md`), tìm marker
17
+ `<!-- TODO:summarize <section-id> -->` trong section tương ứng.
18
+ c. Thay marker bằng đoạn văn cô đọng (xem Quy tắc viết). KHÔNG đụng vào
19
+ các bảng markdown đã có sẵn trong section — chúng do code chép nguyên văn.
20
+ d. Mở `.kb/<doc-id>/_manifest.yaml`, điền `summary` (1 câu, ≤ 25 từ)
21
+ cho section đó và đổi `status: pending` → `status: summarized`.
22
+ 3. Khi mọi section của một doc xong: mở `.kb/index.yaml`, điền/sửa `summary`
23
+ (1 câu) và kiểm tra `title`, `revision`, `tags` của doc đó cho đúng.
24
+ 4. Chạy `kb build` — phải PASS. Nếu fail vì table integrity: bạn đã lỡ sửa
25
+ bảng, khôi phục bảng về nguyên văn từ file `.raw.md`.
26
+ 5. Báo cáo: số section đã điền, tổng token L2 (xem `kb stats`).
27
+
28
+ ## Quy tắc viết (bắt buộc)
29
+
30
+ - Viết **tiếng Anh**.
31
+ - Đoạn L2: cô đọng văn xuôi còn ~20–30% độ dài gốc, giữ cấu trúc logic.
32
+ - Giữ NGUYÊN VĂN: mọi mã hiệu (P, R, D...), tên record/field (UR, PA...),
33
+ giá trị số, đơn vị, tham chiếu chéo (§x.y). Không diễn đạt lại thuật ngữ.
34
+ - KHÔNG suy diễn ngoài văn bản gốc. Thiếu chắc chắn → giữ nguyên câu gốc.
35
+ - KHÔNG tóm tắt bảng, không tạo bảng mới, không xóa bảng.
36
+ - Summary L1 (manifest): 1 câu ≤ 25 từ, nêu section nói về cái gì và chứa
37
+ loại dữ liệu gì (để BM25 khớp được từ khóa kỹ thuật).
38
+
39
+ ## Làm việc theo lô
40
+
41
+ Điền lần lượt từng section, mỗi 5–10 section chạy lại `kb build
42
+ --allow-pending` để bắt lỗi sớm. Không sửa nhiều file song song.
@@ -0,0 +1,15 @@
1
+ .git
2
+ .github
3
+ .kb-work
4
+ .pytest_cache
5
+ .ruff_cache
6
+ .superpowers
7
+ .venv
8
+ dist
9
+ dist-check
10
+ docs
11
+ source
12
+ tests
13
+ *.pdf
14
+ .coverage
15
+ __pycache__
@@ -0,0 +1,23 @@
1
+ # Mẫu CI publish index lên kb-hub — copy sang các repo con tham gia federation.
2
+ # Yêu cầu secret KB_HUB_URL (URL hub kèm token, vd https://x-access-token:${TOKEN}@github.com/org/kb-hub.git)
3
+ name: kb-publish
4
+ on:
5
+ push:
6
+ branches: [main]
7
+ paths: [".kb/**"]
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: pip install center-kb # hoặc pip install -e . nếu repo chứa source
17
+ - name: Publish L0+L1 lên hub
18
+ run: kb publish --hub "${{ secrets.KB_HUB_URL }}" --repo-id "${{ github.event.repository.name }}"
19
+ env:
20
+ GIT_AUTHOR_NAME: kb-publish-ci
21
+ GIT_AUTHOR_EMAIL: ci@local
22
+ GIT_COMMITTER_NAME: kb-publish-ci
23
+ GIT_COMMITTER_EMAIL: ci@local
@@ -0,0 +1,63 @@
1
+ # Auto-mark sections reviewed after a PR merges into main.
2
+ # Valid only while KB authors are the SMEs themselves ("merged = approved") —
3
+ # see docs/superpowers/specs/2026-07-11-review-automation-design.md §2.
4
+ name: kb-review
5
+ on:
6
+ push:
7
+ branches: [main]
8
+ paths: [".kb/**"]
9
+
10
+ # Serialize runs: two quick merges must not race each other's push.
11
+ # Note: GitHub keeps only the newest queued run per group — in a rapid
12
+ # burst of merges an intermediate push's flips may wait until its
13
+ # sections are next touched. Acceptable at this team's merge frequency.
14
+ concurrency:
15
+ group: kb-review
16
+ cancel-in-progress: false
17
+
18
+ permissions:
19
+ contents: write
20
+
21
+ jobs:
22
+ approve:
23
+ runs-on: ubuntu-latest
24
+ # Loop guard (layer 3): skip pushes authored by the bot itself.
25
+ if: github.event.head_commit.author.name != 'github-actions[bot]'
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ with:
29
+ # Full history so `--against BEFORE` is always reachable.
30
+ fetch-depth: 0
31
+ - uses: actions/setup-python@v5
32
+ with:
33
+ python-version: "3.12"
34
+ - run: pip install -e .
35
+ - name: Approve sections changed by this push
36
+ run: |
37
+ BEFORE="${{ github.event.before }}"
38
+ # Zero-SHA on force-push/branch-create → fall back to the merge
39
+ # commit's first parent; no parent at all → nothing to compare.
40
+ if [ "$BEFORE" = "0000000000000000000000000000000000000000" ] \
41
+ || ! git rev-parse --verify --quiet "$BEFORE^{commit}" > /dev/null; then
42
+ if git rev-parse --verify --quiet "HEAD^" > /dev/null; then
43
+ BEFORE="HEAD^"
44
+ else
45
+ echo "No previous commit to compare against — skipping."
46
+ exit 0
47
+ fi
48
+ fi
49
+ kb approve --all-changed --against "$BEFORE"
50
+ - name: Commit status flips back to main
51
+ run: |
52
+ if git diff --quiet -- .kb; then
53
+ echo "No status changes to commit."
54
+ exit 0
55
+ fi
56
+ git config user.name "github-actions[bot]"
57
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
58
+ SHORT_SHA="$(git rev-parse --short HEAD)"
59
+ git add .kb
60
+ # Loop guard (layer 1): [skip ci]. Layer 2: pushes made with
61
+ # GITHUB_TOKEN do not trigger new workflow runs.
62
+ git commit -m "review: auto-mark reviewed @ ${SHORT_SHA} [skip ci]"
63
+ git push
@@ -0,0 +1,101 @@
1
+ name: release
2
+ on:
3
+ push:
4
+ tags: ["v*"]
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.12"
17
+ - run: pip install -e .[dev]
18
+ - run: pytest
19
+ env:
20
+ # e2e tests exercise `kb publish`/`gitio.commit_*` against real git
21
+ # clones — those commits need an identity and CI runners have none
22
+ # configured anywhere (no ~/.gitconfig), unlike dev machines. Same
23
+ # env vars kb-publish.yml sets for real hub publishes.
24
+ GIT_AUTHOR_NAME: ci-test
25
+ GIT_AUTHOR_EMAIL: ci-test@local
26
+ GIT_COMMITTER_NAME: ci-test
27
+ GIT_COMMITTER_EMAIL: ci-test@local
28
+
29
+ build:
30
+ needs: test
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version: "3.12"
37
+ - run: pip install build
38
+ - run: python -m build
39
+ - name: Verify wheel is self-contained (templates + kb init + doctor)
40
+ run: |
41
+ python -m venv /tmp/venv
42
+ /tmp/venv/bin/pip install dist/*.whl
43
+ mkdir /tmp/kbtest && cd /tmp/kbtest
44
+ /tmp/venv/bin/kb init
45
+ /tmp/venv/bin/kb doctor
46
+ /tmp/venv/bin/python -c "from importlib import resources; resources.files('center_kb').joinpath('templates/web/base.html').read_text(encoding='utf-8')"
47
+ - uses: actions/upload-artifact@v4
48
+ with:
49
+ name: dist
50
+ path: dist/
51
+
52
+ pypi:
53
+ needs: build
54
+ runs-on: ubuntu-latest
55
+ environment: pypi
56
+ permissions:
57
+ id-token: write
58
+ steps:
59
+ - uses: actions/download-artifact@v4
60
+ with:
61
+ name: dist
62
+ path: dist/
63
+ - uses: pypa/gh-action-pypi-publish@release/v1
64
+
65
+ docker:
66
+ needs: test
67
+ runs-on: ubuntu-latest
68
+ permissions:
69
+ contents: read
70
+ packages: write
71
+ steps:
72
+ - uses: actions/checkout@v4
73
+ - name: Build image
74
+ run: docker build -t ghcr.io/vuonglq01685/center-kb:${GITHUB_REF_NAME} .
75
+ - name: Smoke test — serve an empty KB, health must answer, API must 401
76
+ run: |
77
+ mkdir -p /tmp/data/.kb
78
+ echo "docs: []" > /tmp/data/.kb/index.yaml
79
+ docker run -d --name kb -p 8321:8321 \
80
+ -e CENTER_KB_HTTP_TOKEN=smoke-test-token \
81
+ -v /tmp/data:/data \
82
+ ghcr.io/vuonglq01685/center-kb:${GITHUB_REF_NAME}
83
+ for i in $(seq 1 30); do
84
+ curl -sf http://localhost:8321/api/health && break
85
+ sleep 2
86
+ done
87
+ curl -sf http://localhost:8321/api/health
88
+ code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8321/api/docs)
89
+ test "$code" = "401"
90
+ docker rm -f kb
91
+ - name: Login to GHCR
92
+ uses: docker/login-action@v3
93
+ with:
94
+ registry: ghcr.io
95
+ username: ${{ github.actor }}
96
+ password: ${{ secrets.GITHUB_TOKEN }}
97
+ - name: Push tags
98
+ run: |
99
+ docker tag ghcr.io/vuonglq01685/center-kb:${GITHUB_REF_NAME} ghcr.io/vuonglq01685/center-kb:latest
100
+ docker push ghcr.io/vuonglq01685/center-kb:${GITHUB_REF_NAME}
101
+ docker push ghcr.io/vuonglq01685/center-kb:latest
@@ -0,0 +1,24 @@
1
+ # ~/.gitignore_global của máy ignore *.md — repo này là docs-as-code,
2
+ # markdown là sản phẩm chính nên phải bỏ chặn tại đây
3
+ !*.md
4
+
5
+ # Tài liệu gốc có bản quyền (ARINC, ICAO) — tuyệt đối không commit
6
+ sources/
7
+
8
+ # Sản phẩm trung gian của pipeline (Docling JSON, summarize jobs)
9
+ .kb-work/
10
+
11
+ # Python
12
+ __pycache__/
13
+ *.pyc
14
+ .venv/
15
+ venv/
16
+ *.egg-info/
17
+ dist/
18
+ build/
19
+
20
+ # macOS
21
+ .DS_Store
22
+
23
+ # SDD scratch
24
+ .superpowers/