lightbox-cull 0.1.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.
- lightbox_cull-0.1.0/.github/workflows/ci.yml +42 -0
- lightbox_cull-0.1.0/.gitignore +17 -0
- lightbox_cull-0.1.0/AGENTS.md +63 -0
- lightbox_cull-0.1.0/LICENSE +188 -0
- lightbox_cull-0.1.0/NOTICE +48 -0
- lightbox_cull-0.1.0/PKG-INFO +32 -0
- lightbox_cull-0.1.0/README.md +94 -0
- lightbox_cull-0.1.0/README.zh-CN.md +94 -0
- lightbox_cull-0.1.0/eval/e1_engine.py +54 -0
- lightbox_cull-0.1.0/eval/synth.py +40 -0
- lightbox_cull-0.1.0/pyproject.toml +154 -0
- lightbox_cull-0.1.0/scripts/build_scene_vocab.py +56 -0
- lightbox_cull-0.1.0/scripts/check_no_delete.py +286 -0
- lightbox_cull-0.1.0/scripts/preflight_check.py +264 -0
- lightbox_cull-0.1.0/skills/lightbox-cull/SKILL.md +106 -0
- lightbox_cull-0.1.0/skills/lightbox-cull/references/culling_rubric.md +95 -0
- lightbox_cull-0.1.0/skills/lightbox-cull/scripts/cli_fallback.sh +70 -0
- lightbox_cull-0.1.0/src/lightbox/__init__.py +7 -0
- lightbox_cull-0.1.0/src/lightbox/agent/__init__.py +129 -0
- lightbox_cull-0.1.0/src/lightbox/agent/context.py +398 -0
- lightbox_cull-0.1.0/src/lightbox/agent/hooks.py +649 -0
- lightbox_cull-0.1.0/src/lightbox/agent/loop.py +1179 -0
- lightbox_cull-0.1.0/src/lightbox/agent/memory.py +420 -0
- lightbox_cull-0.1.0/src/lightbox/agent/verifier.py +684 -0
- lightbox_cull-0.1.0/src/lightbox/api/__init__.py +47 -0
- lightbox_cull-0.1.0/src/lightbox/api/app.py +2003 -0
- lightbox_cull-0.1.0/src/lightbox/api/events.py +134 -0
- lightbox_cull-0.1.0/src/lightbox/api/security.py +175 -0
- lightbox_cull-0.1.0/src/lightbox/api/server_lock.py +186 -0
- lightbox_cull-0.1.0/src/lightbox/cli/__init__.py +7 -0
- lightbox_cull-0.1.0/src/lightbox/cli/__main__.py +8 -0
- lightbox_cull-0.1.0/src/lightbox/cli/app.py +688 -0
- lightbox_cull-0.1.0/src/lightbox/cli/desktop.py +789 -0
- lightbox_cull-0.1.0/src/lightbox/config.py +356 -0
- lightbox_cull-0.1.0/src/lightbox/config_io.py +207 -0
- lightbox_cull-0.1.0/src/lightbox/core/__init__.py +156 -0
- lightbox_cull-0.1.0/src/lightbox/core/bursts.py +283 -0
- lightbox_cull-0.1.0/src/lightbox/core/cache_lru.py +67 -0
- lightbox_cull-0.1.0/src/lightbox/core/detector.py +58 -0
- lightbox_cull-0.1.0/src/lightbox/core/exif.py +933 -0
- lightbox_cull-0.1.0/src/lightbox/core/faces.py +801 -0
- lightbox_cull-0.1.0/src/lightbox/core/guards.py +222 -0
- lightbox_cull-0.1.0/src/lightbox/core/ingest.py +429 -0
- lightbox_cull-0.1.0/src/lightbox/core/metrics.py +386 -0
- lightbox_cull-0.1.0/src/lightbox/core/preview.py +294 -0
- lightbox_cull-0.1.0/src/lightbox/core/verdict.py +450 -0
- lightbox_cull-0.1.0/src/lightbox/fs/__init__.py +55 -0
- lightbox_cull-0.1.0/src/lightbox/fs/plans.py +573 -0
- lightbox_cull-0.1.0/src/lightbox/fs/quarantine.py +186 -0
- lightbox_cull-0.1.0/src/lightbox/fs/safe_fs.py +269 -0
- lightbox_cull-0.1.0/src/lightbox/i18n/__init__.py +81 -0
- lightbox_cull-0.1.0/src/lightbox/i18n/reason_codes.py +248 -0
- lightbox_cull-0.1.0/src/lightbox/jobs/__init__.py +25 -0
- lightbox_cull-0.1.0/src/lightbox/jobs/runner.py +503 -0
- lightbox_cull-0.1.0/src/lightbox/logging.py +110 -0
- lightbox_cull-0.1.0/src/lightbox/mcp/__init__.py +25 -0
- lightbox_cull-0.1.0/src/lightbox/mcp/server.py +748 -0
- lightbox_cull-0.1.0/src/lightbox/mcp/ui_bridge.py +142 -0
- lightbox_cull-0.1.0/src/lightbox/models/__init__.py +205 -0
- lightbox_cull-0.1.0/src/lightbox/models/anthropic_adapter.py +251 -0
- lightbox_cull-0.1.0/src/lightbox/models/data/scene_vocab.npy +0 -0
- lightbox_cull-0.1.0/src/lightbox/models/embedder.py +545 -0
- lightbox_cull-0.1.0/src/lightbox/models/face_embedder.py +325 -0
- lightbox_cull-0.1.0/src/lightbox/models/images.py +269 -0
- lightbox_cull-0.1.0/src/lightbox/models/openai_compat.py +254 -0
- lightbox_cull-0.1.0/src/lightbox/models/provider_errors.py +369 -0
- lightbox_cull-0.1.0/src/lightbox/models/router.py +1005 -0
- lightbox_cull-0.1.0/src/lightbox/models/secrets.py +741 -0
- lightbox_cull-0.1.0/src/lightbox/models/types.py +347 -0
- lightbox_cull-0.1.0/src/lightbox/paths.py +115 -0
- lightbox_cull-0.1.0/src/lightbox/process_utils.py +79 -0
- lightbox_cull-0.1.0/src/lightbox/py.typed +0 -0
- lightbox_cull-0.1.0/src/lightbox/services/__init__.py +213 -0
- lightbox_cull-0.1.0/src/lightbox/services/ai_connection.py +1423 -0
- lightbox_cull-0.1.0/src/lightbox/services/app_installer.py +590 -0
- lightbox_cull-0.1.0/src/lightbox/services/burst.py +170 -0
- lightbox_cull-0.1.0/src/lightbox/services/context.py +131 -0
- lightbox_cull-0.1.0/src/lightbox/services/digest.py +755 -0
- lightbox_cull-0.1.0/src/lightbox/services/geo.py +715 -0
- lightbox_cull-0.1.0/src/lightbox/services/people.py +1703 -0
- lightbox_cull-0.1.0/src/lightbox/services/plan.py +599 -0
- lightbox_cull-0.1.0/src/lightbox/services/review.py +1007 -0
- lightbox_cull-0.1.0/src/lightbox/services/scan.py +816 -0
- lightbox_cull-0.1.0/src/lightbox/services/search.py +1022 -0
- lightbox_cull-0.1.0/src/lightbox/services/synth.py +705 -0
- lightbox_cull-0.1.0/src/lightbox/services/system.py +595 -0
- lightbox_cull-0.1.0/src/lightbox/services/triage.py +1099 -0
- lightbox_cull-0.1.0/src/lightbox/store/__init__.py +78 -0
- lightbox_cull-0.1.0/src/lightbox/store/db.py +597 -0
- lightbox_cull-0.1.0/src/lightbox/store/repos.py +2704 -0
- lightbox_cull-0.1.0/src/lightbox/store/vector_index.py +388 -0
- lightbox_cull-0.1.0/src/lightbox/tools/__init__.py +59 -0
- lightbox_cull-0.1.0/src/lightbox/tools/registry.py +1882 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/assets/index-Bw41vJOC.css +1 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/assets/index-CJzM-ZfX.js +52 -0
- lightbox_cull-0.1.0/src/lightbox/web_dist/index.html +14 -0
- lightbox_cull-0.1.0/tests/agent/test_hooks.py +423 -0
- lightbox_cull-0.1.0/tests/agent/test_loop.py +1097 -0
- lightbox_cull-0.1.0/tests/agent/test_memory.py +497 -0
- lightbox_cull-0.1.0/tests/agent/test_verifier.py +360 -0
- lightbox_cull-0.1.0/tests/api/test_ai_connection_api.py +816 -0
- lightbox_cull-0.1.0/tests/api/test_api.py +775 -0
- lightbox_cull-0.1.0/tests/cli/test_step4_desktop_lifecycle.py +882 -0
- lightbox_cull-0.1.0/tests/cli/test_step5_install_app.py +288 -0
- lightbox_cull-0.1.0/tests/core/test_ingest.py +424 -0
- lightbox_cull-0.1.0/tests/core/test_pipeline.py +873 -0
- lightbox_cull-0.1.0/tests/fs/test_fs.py +443 -0
- lightbox_cull-0.1.0/tests/mcp/test_mcp_contract.py +377 -0
- lightbox_cull-0.1.0/tests/mcp/test_skill_contract.py +346 -0
- lightbox_cull-0.1.0/tests/mcp/test_tool_registry.py +111 -0
- lightbox_cull-0.1.0/tests/models/test_adapters_and_router.py +667 -0
- lightbox_cull-0.1.0/tests/models/test_step1_ai_foundation.py +1259 -0
- lightbox_cull-0.1.0/tests/services/test_digest.py +606 -0
- lightbox_cull-0.1.0/tests/services/test_people.py +962 -0
- lightbox_cull-0.1.0/tests/services/test_search.py +941 -0
- lightbox_cull-0.1.0/tests/services/test_t06_runner_services_cli.py +499 -0
- lightbox_cull-0.1.0/tests/services/test_triage.py +535 -0
- lightbox_cull-0.1.0/tests/store/test_store.py +417 -0
- lightbox_cull-0.1.0/tests/test_paths_and_config.py +137 -0
- lightbox_cull-0.1.0/tests/test_security_gates.py +245 -0
- lightbox_cull-0.1.0/uv.lock +2299 -0
- lightbox_cull-0.1.0/web/index.html +13 -0
- lightbox_cull-0.1.0/web/package-lock.json +2655 -0
- lightbox_cull-0.1.0/web/package.json +28 -0
- lightbox_cull-0.1.0/web/src/App.tsx +367 -0
- lightbox_cull-0.1.0/web/src/api.ts +1448 -0
- lightbox_cull-0.1.0/web/src/components/AgentDrawer.tsx +717 -0
- lightbox_cull-0.1.0/web/src/components/AiConnectionBar.tsx +901 -0
- lightbox_cull-0.1.0/web/src/components/QuarantineModal.tsx +333 -0
- lightbox_cull-0.1.0/web/src/components/SettingsModal.tsx +381 -0
- lightbox_cull-0.1.0/web/src/components/photoMarks.ts +32 -0
- lightbox_cull-0.1.0/web/src/components/ui.tsx +935 -0
- lightbox_cull-0.1.0/web/src/desktop.ts +80 -0
- lightbox_cull-0.1.0/web/src/i18n.ts +1349 -0
- lightbox_cull-0.1.0/web/src/index.css +273 -0
- lightbox_cull-0.1.0/web/src/main.tsx +23 -0
- lightbox_cull-0.1.0/web/src/views/InsightsView.tsx +1162 -0
- lightbox_cull-0.1.0/web/src/views/PeopleView.tsx +1355 -0
- lightbox_cull-0.1.0/web/src/views/ReviewView.tsx +1756 -0
- lightbox_cull-0.1.0/web/src/views/SearchView.tsx +607 -0
- lightbox_cull-0.1.0/web/src/views/SessionsView.tsx +581 -0
- lightbox_cull-0.1.0/web/tsconfig.json +20 -0
- lightbox_cull-0.1.0/web/vite.config.ts +17 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
verify:
|
|
10
|
+
name: Verify (${{ matrix.os }})
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
os: [macos-latest, ubuntu-latest]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Sync Python 3.12 environment
|
|
27
|
+
run: uv sync --python 3.12
|
|
28
|
+
|
|
29
|
+
- name: Ruff lint (including TID251 no-delete/no-overwrite gate)
|
|
30
|
+
run: uv run ruff check .
|
|
31
|
+
|
|
32
|
+
- name: Custom AST no-delete check
|
|
33
|
+
run: uv run python scripts/check_no_delete.py
|
|
34
|
+
|
|
35
|
+
- name: Import-linter architecture boundary check
|
|
36
|
+
run: uv run lint-imports
|
|
37
|
+
|
|
38
|
+
- name: Mypy static type check
|
|
39
|
+
run: uv run mypy src
|
|
40
|
+
|
|
41
|
+
- name: Pytest (offline unit tests + sqlite-vec extension load check)
|
|
42
|
+
run: uv run pytest
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# AGENTS.md — Lightbox Agent & Skill Rules
|
|
2
|
+
|
|
3
|
+
This file provides repository-level instructions for coding and multimodal agents (Codex, Claude Code, Cursor, Antigravity, etc.) and serves as the auto-discovery fallback alongside `skills/lightbox-cull/SKILL.md` (SPEC §8.4, ADR-000 Item 10).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Dual-Mode Photo Culling (`skills/lightbox-cull/SKILL.md`)
|
|
8
|
+
|
|
9
|
+
Lightbox supports two photo culling entry points. Always route by user input:
|
|
10
|
+
|
|
11
|
+
### Mode A — Direct Chat Photo Upload (Zero-Install, Immediate Try-Out)
|
|
12
|
+
- **When**: The user uploads a small batch of photos directly in chat and asks any photo-review question — e.g. *"帮我把糊的照片挑出来"*, *"帮我去掉废片"*, *"帮我挑 3 张"*, *"这几张连拍选哪张"*, *"pick the best 3 shots"*, *"find blurry photos"*.
|
|
13
|
+
- **Requirements**: **Zero installation.** Must work on any client supporting Skills + image input even with no LightBox installed, no MCP configured, no LightBox models downloaded, no extra API key, and without depending on T10 or T13.
|
|
14
|
+
- **Behavior**: Understand the user's intent first, and do **NOT** require `lightbox_scan_folder` or MCP setup. Inspect the uploaded images directly using `skills/lightbox-cull/references/culling_rubric.md`, adapting output order to the request:
|
|
15
|
+
- When finding blurry/reject shots: put **明显废片 / 模糊照片** FIRST and REQUIRED (filenames or `#N` + visual reasons), followed by **拿不准的照片** (borderline/creative blur) and usable keepers.
|
|
16
|
+
- When picking standout shots: put **推荐照片** FIRST and REQUIRED (filenames or `#N` + visual reasons), followed by **拿不准的照片** and optional notes on clear misses/burst duplicates.
|
|
17
|
+
|
|
18
|
+
### Mode B — Local Photo Folder (LightBox MCP Workflow)
|
|
19
|
+
- **When**: The user supplies a local directory path or asks to scan an entire shoot folder, process RAW/HEIC/Live Photo pairs, detect bursts at scale, search a library, or batch quarantine / restore files.
|
|
20
|
+
- **Four Hard Rules for Local Folder Operations**:
|
|
21
|
+
1. **Scan via MCP first**: Always call `lightbox_scan_folder` first for local photo directories. Never write ad-hoc Shell/Python scripts to walk photo folders or feed an entire folder of images into model context. *(Scoped to local folders only — never blocks Mode A direct chat uploads.)*
|
|
22
|
+
2. **Read preferences first**: Before subjective culling on a local session, read `lightbox://memory/preferences`.
|
|
23
|
+
3. **Respect context budget (`> 8` photos → Web UI)**: For manual visual verification of more than 8 photos, direct the user to open the tokenless `review_url` in the local LightBox Web UI instead of calling `lightbox_get_photo` repeatedly.
|
|
24
|
+
4. **Never hard-delete or manually move photos**: Never run `rm` or `mv` on user photo directories. Always draft an immutable plan via `lightbox_create_plan`, obtain explicit human approval (tokenless `approve_url` in Web UI, MCP Elicitation, or interactive `lightbox approve <plan_id>`), apply via `lightbox_apply_plan`, and remember all moves are reversible via `lightbox_restore_plan`.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. Enabling the Skill & MCP in Common Clients
|
|
29
|
+
|
|
30
|
+
### Skill Installation / Discovery
|
|
31
|
+
- **Direct Skill folder**: `skills/lightbox-cull/` (contains `SKILL.md`, `references/culling_rubric.md`, `scripts/cli_fallback.sh`).
|
|
32
|
+
- **Codex**: Copy or symlink `skills/lightbox-cull` into `~/.codex/skills/lightbox-cull` (or `.agents/skills/lightbox-cull`); this root `AGENTS.md` provides automatic repo-level fallback.
|
|
33
|
+
- **Claude Desktop / Claude Code / Cursor**: Enable or link `skills/lightbox-cull/SKILL.md` in your skills directory. Mode A works immediately with no MCP configuration.
|
|
34
|
+
|
|
35
|
+
### Optional MCP Server Configuration (for Mode B Local Folders)
|
|
36
|
+
- **Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"lightbox": {
|
|
41
|
+
"command": "uvx",
|
|
42
|
+
"args": ["--from", "lightbox-cull", "lightbox", "mcp", "--transport", "stdio"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
*(Local repo dev: `"command": "uv"`, `"args": ["--directory", "/path/to/LightBox", "run", "lightbox", "mcp"]`. If GUI apps cannot resolve `uv` / `uvx` on `PATH`, use the absolute path from `which uv` / `which uvx`.)*
|
|
48
|
+
- **Codex** (`~/.codex/config.toml`):
|
|
49
|
+
```toml
|
|
50
|
+
[mcp_servers.lightbox]
|
|
51
|
+
command = "uvx"
|
|
52
|
+
args = ["--from", "lightbox-cull", "lightbox", "mcp", "--transport", "stdio"]
|
|
53
|
+
```
|
|
54
|
+
- **Claude Code**: `claude mcp add lightbox -- uvx --from lightbox-cull lightbox mcp`
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 3. Repository Engineering Invariants (When Editing Code)
|
|
59
|
+
|
|
60
|
+
1. **Zero hard deletion**: Never call `os.remove`, `os.unlink`, `os.rmdir`, `os.rename`, `os.replace`, `shutil.rmtree`, `shutil.move`, `.unlink()`, `.rmdir()`, or `.rename()` outside whitelisted `SafeFS` / `cache_lru`. Both `ruff` (`TID251`) and `scripts/check_no_delete.py` enforce this.
|
|
61
|
+
2. **Single source of truth (`lightbox.services`)**: `lightbox.api`, `lightbox.cli`, and `lightbox.mcp` must not import `lightbox.store`, `lightbox.fs`, or `lightbox.core` directly (`lint-imports` enforces this).
|
|
62
|
+
3. **Tokenless URLs**: Never embed authentication tokens in `review_url` or `approve_url` returned by MCP or CLI.
|
|
63
|
+
4. **Zero-LLM ready**: Core deterministic scan, review, Web UI, SafeFS quarantine/restore, and CI test suite must pass completely offline with zero API keys.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based upon (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to the Work, that is intentionally submitted to Licensor for inclusion
|
|
51
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
52
|
+
authorized to submit on behalf of the Work. For the purposes of this
|
|
53
|
+
definition, "Contribution" shall not include any communication that
|
|
54
|
+
is electronic, verbal, or written sent to the Licensor or its
|
|
55
|
+
representatives, including but not limited to communication on
|
|
56
|
+
electronic mailing lists, source code, and issue tracking systems that
|
|
57
|
+
are managed by, or on behalf of, the Licensor for the purposes of
|
|
58
|
+
discussing and improving the Work, but excluding communication that
|
|
59
|
+
is conspicuously marked or otherwise designated in writing by the
|
|
60
|
+
copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such License applies only to those patent claims licensable
|
|
79
|
+
by the Licensor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a cross-claim) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or indirect patent litigation, then any patent licenses
|
|
86
|
+
granted to You under this License shall terminate as of the date
|
|
87
|
+
such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works in Source or Object form, provided that
|
|
91
|
+
You meet the following conditions:
|
|
92
|
+
|
|
93
|
+
(a) You must give any other recipients of the Work or
|
|
94
|
+
Derivative Works a copy of this License; and
|
|
95
|
+
|
|
96
|
+
(b) You must cause any modified files to carry prominent notices
|
|
97
|
+
stating that You changed the Work; and
|
|
98
|
+
|
|
99
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
100
|
+
that You distribute, all copyright notices, patent notices,
|
|
101
|
+
trademark notices, and attribution notices from the Source
|
|
102
|
+
form of the Work, excluding those notices that do not
|
|
103
|
+
affect any part of the Work; and
|
|
104
|
+
|
|
105
|
+
(d) If the Work includes a "Notice" file as part of its
|
|
106
|
+
distribution, then any Derivative Works that You distribute must
|
|
107
|
+
include a readable copy of the attribution notices contained
|
|
108
|
+
within such Notice file, excluding those notices that do not
|
|
109
|
+
affect any part of the Work, in at least one of the following
|
|
110
|
+
places: within a readable copy of the attribution notices
|
|
111
|
+
contained within such Notice file; within a directory
|
|
112
|
+
distribution alongside the Work; or, within a display
|
|
113
|
+
generated by the Work, if and wherever such third-party
|
|
114
|
+
notices normally appear. The contents of the Notice file
|
|
115
|
+
are for informational purposes only and do not modify the
|
|
116
|
+
License. You may add any other attribution notices within
|
|
117
|
+
Your Derivative Works, alongside or as an addendum to the
|
|
118
|
+
Notice file from the Work, provided that such additional
|
|
119
|
+
notices cannot be construed as modifying the License.
|
|
120
|
+
|
|
121
|
+
You may add Your own copyright notice to Your Derivative Works
|
|
122
|
+
and may provide additional copyright notices, license statements,
|
|
123
|
+
and/or other terms and conditions for use, reproduction, and
|
|
124
|
+
distribution of Your Derivative Works, provided that Your use,
|
|
125
|
+
reproduction, and distribution of Your Derivative Works otherwise
|
|
126
|
+
complies with the License.
|
|
127
|
+
|
|
128
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
129
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
130
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
131
|
+
this License, without any additional terms or conditions.
|
|
132
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
133
|
+
the terms of any separate license agreement you may have executed
|
|
134
|
+
with Licensor regarding such Contributions.
|
|
135
|
+
|
|
136
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
137
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
138
|
+
except as required for reasonable and customary use in describing the
|
|
139
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
140
|
+
|
|
141
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
142
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
143
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
144
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
145
|
+
implied, including, without limitation, any warranties or conditions
|
|
146
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
147
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
148
|
+
appropriateness of using or redistributing the Work and assume any
|
|
149
|
+
risks associated with Your exercise of permissions under this License.
|
|
150
|
+
|
|
151
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
152
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
153
|
+
unless required by applicable law (such as deliberate and grossly
|
|
154
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
155
|
+
liable to You for damages, including any direct, indirect, special,
|
|
156
|
+
incidental, or consequential damages of any character arising as a
|
|
157
|
+
result of this License or out of the use or inability to use the
|
|
158
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
159
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
160
|
+
other commercial damages or losses), even if such Contributor
|
|
161
|
+
has been advised of the possibility of such damages.
|
|
162
|
+
|
|
163
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
164
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
165
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
166
|
+
or other liability obligations and/or rights consistent with this
|
|
167
|
+
License. However, in accepting such obligations, You may act only
|
|
168
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
169
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
170
|
+
defend, and hold each Contributor harmless for any liability
|
|
171
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
172
|
+
of your accepting any such warranty or additional liability.
|
|
173
|
+
|
|
174
|
+
END OF TERMS AND CONDITIONS
|
|
175
|
+
|
|
176
|
+
Copyright 2026 Lightbox Contributors
|
|
177
|
+
|
|
178
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
179
|
+
you may not use this file except in compliance with the License.
|
|
180
|
+
You may obtain a copy of the License at
|
|
181
|
+
|
|
182
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
183
|
+
|
|
184
|
+
Unless required by applicable law or agreed to in writing, software
|
|
185
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
186
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
187
|
+
See the License for the specific language governing permissions and
|
|
188
|
+
limitations under the License.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Lightbox
|
|
2
|
+
Copyright 2026 Lightbox Contributors
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0.
|
|
5
|
+
|
|
6
|
+
========================================================================
|
|
7
|
+
Third-Party Components and Notices
|
|
8
|
+
========================================================================
|
|
9
|
+
|
|
10
|
+
The following third-party components may be dynamically linked, bundled
|
|
11
|
+
via Python wheels, or installed as optional extras:
|
|
12
|
+
|
|
13
|
+
1. rawpy / LibRaw
|
|
14
|
+
- rawpy Python bindings: MIT License
|
|
15
|
+
- Bundled LibRaw library: LGPL-2.1-only OR CDDL-1.0
|
|
16
|
+
- https://www.libraw.org/
|
|
17
|
+
|
|
18
|
+
2. InsightFace (antelopev2: det_10g.onnx / glintr100.onnx)
|
|
19
|
+
- Codebase license: MIT License
|
|
20
|
+
- Pretrained model weights: non-commercial research use only.
|
|
21
|
+
- Weights are NOT bundled or redistributed in this repository; they are
|
|
22
|
+
downloaded on demand by the user into `<APP_DATA_DIR>/models/`.
|
|
23
|
+
- https://github.com/deepinsight/insightface
|
|
24
|
+
|
|
25
|
+
3. sqlite-vec
|
|
26
|
+
- License: MIT License OR Apache-2.0
|
|
27
|
+
- https://github.com/asg017/sqlite-vec
|
|
28
|
+
|
|
29
|
+
4. ONNX Runtime
|
|
30
|
+
- License: MIT License
|
|
31
|
+
- https://github.com/microsoft/onnxruntime
|
|
32
|
+
|
|
33
|
+
5. ExifTool (invoked only as an independent external subprocess)
|
|
34
|
+
- License: Artistic License / GPL (Perl standard terms)
|
|
35
|
+
- https://exiftool.org/
|
|
36
|
+
|
|
37
|
+
6. SigLIP 2 Base (google/siglip2-base-patch16-256 / ONNX)
|
|
38
|
+
- License: Apache License, Version 2.0
|
|
39
|
+
- Model weights are NOT bundled or redistributed in this repository; they are
|
|
40
|
+
downloaded on demand by the user into `<APP_DATA_DIR>/models/`.
|
|
41
|
+
- https://github.com/google-research/big_vision
|
|
42
|
+
|
|
43
|
+
7. Optional Extra: lightbox-cull[heic] (pillow-heif)
|
|
44
|
+
- pillow-heif Python wrapper: BSD-3-Clause
|
|
45
|
+
- Underlying libheif / libde265 codecs: LGPL-3.0-or-later
|
|
46
|
+
- Certain prebuilt wheels or system builds may include x265 (GPL-2.0)
|
|
47
|
+
for HEVC encoding. This extra is strictly optional and not installed
|
|
48
|
+
by default.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: lightbox-cull
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first photo culling and intelligent selection system
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: anthropic>=2.14.0
|
|
10
|
+
Requires-Dist: exifread>=3.0.0
|
|
11
|
+
Requires-Dist: fastapi>=0.165.0
|
|
12
|
+
Requires-Dist: huggingface-hub>=2.4.0
|
|
13
|
+
Requires-Dist: keyring>=25.7.0
|
|
14
|
+
Requires-Dist: mcp>=1.9.0
|
|
15
|
+
Requires-Dist: numpy>=2.0.0
|
|
16
|
+
Requires-Dist: onnxruntime>=1.32.0
|
|
17
|
+
Requires-Dist: openai>=3.59.0
|
|
18
|
+
Requires-Dist: opencv-python-headless>=5.1.0.95
|
|
19
|
+
Requires-Dist: pillow>=11.0.0
|
|
20
|
+
Requires-Dist: platformdirs>=4.3.0
|
|
21
|
+
Requires-Dist: psutil>=6.1.0
|
|
22
|
+
Requires-Dist: pydantic>=2.10.0
|
|
23
|
+
Requires-Dist: rawpy>=0.23.0
|
|
24
|
+
Requires-Dist: sqlite-vec>=0.1.6
|
|
25
|
+
Requires-Dist: structlog>=24.4.0
|
|
26
|
+
Requires-Dist: tokenizers>=0.23.3
|
|
27
|
+
Requires-Dist: typer>=0.29.2
|
|
28
|
+
Requires-Dist: uvicorn>=0.54.0
|
|
29
|
+
Provides-Extra: desktop
|
|
30
|
+
Requires-Dist: pywebview>=5.3; extra == 'desktop'
|
|
31
|
+
Provides-Extra: heic
|
|
32
|
+
Requires-Dist: pillow-heif>=0.20.0; extra == 'heic'
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# LightBox
|
|
2
|
+
|
|
3
|
+
[](https://github.com/olioDuan/LightBox/actions/workflows/ci.yml)
|
|
4
|
+
[](pyproject.toml)
|
|
5
|
+
[](scripts/check_no_delete.py)
|
|
6
|
+
[](#option-2-use-with-claude-cursor-or-codex-skill--mcp)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
English | [简体中文](README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
Local photo culling tool for photographers. Runs offline by default, never deletes original files, and works either as a standalone desktop/web app or through Claude, Cursor, and Codex via Skill and MCP.
|
|
12
|
+
|
|
13
|
+
## What it does
|
|
14
|
+
|
|
15
|
+
- **Deterministic culling (offline, no API key)**: flags out-of-focus shots, bad exposure, closed eyes, and groups bursts with a recommended pick. Handles RAW+JPEG and Live Photo pairs together.
|
|
16
|
+
- **Reversible quarantine**: never calls hard delete on your photo folders. Moving rejects requires an explicit approval step and can be restored in one click.
|
|
17
|
+
- **Local search and people**: SigLIP 2 natural-language photo search, similar-photo lookup, face clustering, and per-person export.
|
|
18
|
+
- **Optional AI review**: connect OpenAI, Anthropic, Gemini, any OpenAI-compatible endpoint, or local Ollama in the app drawer (`Cmd+K` / `Ctrl+K`) to review borderline shots or chat through a shoot.
|
|
19
|
+
|
|
20
|
+
## Option 1: Standalone Desktop / Web App
|
|
21
|
+
|
|
22
|
+
Requires Python 3.12+ and [uv](https://docs.astral.sh/uv/).
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/olioDuan/LightBox.git
|
|
26
|
+
cd LightBox
|
|
27
|
+
uv sync --extra desktop
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Launch the desktop window:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv run lightbox app
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or install a double-click app launcher (macOS `~/Applications/LightBox.app`, Windows `.lnk`, Linux `.desktop`):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv run lightbox install-app
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Prefer running in your browser without `pywebview`:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv sync
|
|
46
|
+
uv run lightbox ui
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Try it on generated sample photos without touching your own library:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv run lightbox demo
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Optional extras: `uv sync --extra heic` for HEIC support. On Linux, desktop mode requires system GTK (`python3-gi gir1.2-webkit2-4.1`) or `PySide6`.
|
|
56
|
+
|
|
57
|
+
## Option 2: Use with Claude, Cursor, or Codex (Skill + MCP)
|
|
58
|
+
|
|
59
|
+
### Direct chat culling (zero install)
|
|
60
|
+
|
|
61
|
+
Load `skills/lightbox-cull/SKILL.md` in your AI client (Codex, Claude Code, Cursor, etc.). You can drop a small batch of photos directly into chat and ask it to pick the best shots or flag blurry ones without installing LightBox.
|
|
62
|
+
|
|
63
|
+
### Local folder workflows (MCP)
|
|
64
|
+
|
|
65
|
+
Point your MCP client at the cloned repository (the in-app **Settings -> Use in Claude / Cursor** tab also generates ready-to-copy snippets for each client):
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"lightbox": {
|
|
71
|
+
"command": "uv",
|
|
72
|
+
"args": ["--directory", "/path/to/LightBox", "run", "lightbox", "mcp"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
GUI apps on macOS/Windows may not inherit your shell `PATH`; if needed, replace `"uv"` with the full path from `which uv`.
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv run ruff check .
|
|
84
|
+
uv run python scripts/check_no_delete.py
|
|
85
|
+
uv run lint-imports
|
|
86
|
+
uv run mypy src
|
|
87
|
+
uv run pytest
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Frontend source lives in `web/` (`cd web && npm install && npm run build` updates `src/lightbox/web_dist/`).
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE) for third-party component and optional model notices.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# LightBox
|
|
2
|
+
|
|
3
|
+
[](https://github.com/olioDuan/LightBox/actions/workflows/ci.yml)
|
|
4
|
+
[](pyproject.toml)
|
|
5
|
+
[](scripts/check_no_delete.py)
|
|
6
|
+
[](#方式二接入-claude--cursor--codexskill--mcp)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
[English](README.md) | 简体中文
|
|
10
|
+
|
|
11
|
+
本地运行的选片工具。默认完全离线,不硬删除原片,既可以当独立桌面/网页软件用,也可以通过 Skill 和 MCP 接入 Claude、Cursor、Codex 使用。
|
|
12
|
+
|
|
13
|
+
## 功能概览
|
|
14
|
+
|
|
15
|
+
- **本地筛片(离线,无需 API Key)**:检测拍糊、过曝/欠曝、闭眼,自动对连拍分组并推荐最佳张,RAW+JPEG 与 Live Photo 同组联动。
|
|
16
|
+
- **可逆隔离**:绝不直接删除照片目录里的文件;整理废片必须经人工确认后移入隔离文件夹,随时可整批或单张还原。
|
|
17
|
+
- **本地搜图与人物整理**:内置 SigLIP 2 语义搜图与以图搜相似、人脸聚类命名及按人物导出。
|
|
18
|
+
- **可选 AI 复核**:在界面按 `Cmd+K` / `Ctrl+K` 打开助手,可接入 OpenAI、Anthropic、Gemini、OpenAI 兼容接口或本地 Ollama,用来复核存疑照片或对话选片。
|
|
19
|
+
|
|
20
|
+
## 方式一:作为独立桌面 / 网页软件使用
|
|
21
|
+
|
|
22
|
+
需要 Python 3.12+ 与 [uv](https://docs.astral.sh/uv/)。
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/olioDuan/LightBox.git
|
|
26
|
+
cd LightBox
|
|
27
|
+
uv sync --extra desktop
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
启动桌面窗口:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv run lightbox app
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
生成系统双击启动图标(macOS `~/Applications/LightBox.app`、Windows `.lnk`、Linux `.desktop`):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv run lightbox install-app
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
如果不想装 `pywebview`,直接用浏览器打开:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv sync
|
|
46
|
+
uv run lightbox ui
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
想先体验一下而不扫描自己的照片库:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv run lightbox demo
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
可选扩展:HEIC 支持用 `uv sync --extra heic`;Linux 桌面窗口需要系统安装 GTK 绑定(`python3-gi gir1.2-webkit2-4.1`)或 `PySide6`。
|
|
56
|
+
|
|
57
|
+
## 方式二:接入 Claude / Cursor / Codex(Skill + MCP)
|
|
58
|
+
|
|
59
|
+
### 聊天直接传图选片(零安装)
|
|
60
|
+
|
|
61
|
+
在支持 Skill 的客户端(Codex、Claude Code、Cursor 等)中启用 `skills/lightbox-cull/SKILL.md`,直接把几张照片发进对话框即可让模型挑废片或选最佳张,不需要本地安装软件。
|
|
62
|
+
|
|
63
|
+
### 扫描本地整夹(MCP)
|
|
64
|
+
|
|
65
|
+
把 MCP 配置指向本地仓库路径(也可以在软件内 **设置 -> 在 Claude / Cursor 中使用** 一键复制对应客户端的配置片段):
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"lightbox": {
|
|
71
|
+
"command": "uv",
|
|
72
|
+
"args": ["--directory", "/path/to/LightBox", "run", "lightbox", "mcp"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
如果 GUI 客户端找不到 `uv`,将 `"uv"` 替换为终端 `which uv` 输出的绝对路径即可。
|
|
79
|
+
|
|
80
|
+
## 本地开发与检查
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv run ruff check .
|
|
84
|
+
uv run python scripts/check_no_delete.py
|
|
85
|
+
uv run lint-imports
|
|
86
|
+
uv run mypy src
|
|
87
|
+
uv run pytest
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
前端源码在 `web/` 目录,修改后执行 `cd web && npm install && npm run build` 更新 `src/lightbox/web_dist/`。
|
|
91
|
+
|
|
92
|
+
## 许可协议
|
|
93
|
+
|
|
94
|
+
Apache-2.0。第三方依赖与按需下载模型的许可说明见 [LICENSE](LICENSE) 与 [NOTICE](NOTICE)。
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Standalone E1 deterministic engine evaluation runner & CI gate (SPEC §11.2)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from lightbox.services.synth import (
|
|
11
|
+
E1_MAX_EXEMPT_MISLABEL,
|
|
12
|
+
E1_MAX_RED_FPR,
|
|
13
|
+
E1_MIN_REJECT_RECALL,
|
|
14
|
+
E1EvalReport,
|
|
15
|
+
run_e1_evaluation,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main(argv: list[str] | None = None) -> int:
|
|
20
|
+
parser = argparse.ArgumentParser(description="Run Lightbox E1 synthetic detection CI gate.")
|
|
21
|
+
parser.add_argument("--sensitivity", choices=("conservative", "standard"), default="conservative")
|
|
22
|
+
parser.add_argument("--seed", type=int, default=101)
|
|
23
|
+
parser.add_argument("--workers", type=int, default=1)
|
|
24
|
+
parser.add_argument("--output", type=Path, default=None, help="Optional JSON report path")
|
|
25
|
+
args = parser.parse_args(argv)
|
|
26
|
+
|
|
27
|
+
with tempfile.TemporaryDirectory(prefix="lightbox_e1_") as tmp:
|
|
28
|
+
report = run_e1_evaluation(
|
|
29
|
+
Path(tmp),
|
|
30
|
+
sensitivity=args.sensitivity,
|
|
31
|
+
seed=args.seed,
|
|
32
|
+
max_workers=args.workers,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
payload = json.dumps(report.to_dict(), indent=2, ensure_ascii=False)
|
|
36
|
+
print(payload)
|
|
37
|
+
if args.output is not None:
|
|
38
|
+
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
args.output.write_text(payload + "\n", encoding="utf-8")
|
|
40
|
+
|
|
41
|
+
return 0 if report.passed else 1
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
__all__ = [
|
|
45
|
+
"E1EvalReport",
|
|
46
|
+
"E1_MAX_EXEMPT_MISLABEL",
|
|
47
|
+
"E1_MAX_RED_FPR",
|
|
48
|
+
"E1_MIN_REJECT_RECALL",
|
|
49
|
+
"main",
|
|
50
|
+
"run_e1_evaluation",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
raise SystemExit(main())
|