iOS app + research platform for pre-production workflows: screenplay text β structured
SceneScriptβ scene visualization model + on-device camera analysis.
Shafin Multitool is for beginner filmmakers: it helps you quickly draft scene boards from text (shot/shotlist planning) and get explainable camera analysis while rehearsing shots.
Shafin Multitool combines two major domains:
- Scene Generator β parsing and compiling script text into intermediate/target structures (
SceneScript,ScenePlanIR, scene chunks). - Camera Analysis Multitool β video analysis mode with explainable critique (fast path + semantic hints + recommendation decomposition).
It also includes a research track for dataset generation and model comparison across generations (SGv7 / SGv8 / SGv9 + camera-eval).
What this README covers
- How to run the project in Xcode.
- Repository map and module entry points.
- A practical command list for tests and experiments.
- Links to key docs (
docs/,experiments/,tests). - Concrete integration and debugging tips.
- π Stack & Capabilities
- π§ Architecture
- π Setup & Run
- π§ͺ Testing
- π Repository Structure
- π Research Track
- π Useful Commands
- π§© Development Scenarios
- π©Ί Troubleshooting
- π€ Contributing
- Language / platform: Swift 5.0, iOS (ARKit, Vision, CoreML)
- LLM inference: bundled
llama.cppviallama.xcframework+ GBNF sampling - UI architecture: modular composition using UIKit and SwiftUI pieces
- Architecture: feature-module decomposition, coordinator/interactor/presenter/builder patterns, dedicated service and model layers
- AR overlays: contextual hints rendered over camera feed (
shafinMultitool/Multitool2Module/UI/Overlay/*) - Dependencies: CocoaPods (
ARVideoKit,SnapKit)
| Block | What it gives |
|---|---|
| Script generator | Text β scene structure conversion, chunking, beat planning (SceneGeneratorModule) |
| AR preview | Camera scene visualization with overlays, runtime anchors and scene persistence |
| Camera module | Live frame stream, scheduler/governor, filtering and frame pre-processing |
| Frame critique | Deterministic critique core + evidence layer + recommendation plan (Multitool2Module) |
| Research / benchmarking | Full dataset + benchmark loop for SG/ORPO/plan variants |
flowchart TD
A["User input (script text)"] --> B["SceneGeneratorModule"]
B --> C["SceneParserService (rules + LLM runtime, v8/v9 modes)"]
C --> D["SceneBundlePipeline / ScenePlanCompiler"]
D --> E["SceneScript / ScenePlanIR"]
E --> F["AR Scene Container + Overlay UI"]
G["Camera stream"] --> H["CameraManager / Frame pipeline"]
H --> I["Frame preprocessing (CoreML + filters)"]
I --> J["FrameSemanticsReport"]
J --> K["FrameCritiqueEngine + Suggestion / Evidence coordinators"]
K --> L["Recommendation Plan"]
L --> M["Overlay / Debug UI"]
K --> N["DecisionTracePresentation"]
F --> M
N --> M
Design intent: explainable-by-construction
For camera-pipeline, traceability is required for the chain
observation β interpretation β recommendation and all steps should remain inspectable in debug output.
For the script pipeline, the focus is end-to-end coherence between
input text β runtime trace β SceneScript, including v8/v9 modes and generated plans.
- macOS with Xcode and iOS SDK
- Ruby + CocoaPods
- Git
- (Optional) Python 3 for research scripts
git clone <repo-url>
cd shafinMultitool
pod install
open shafinMultitool.xcworkspaceIn Xcode:
- Select the
shafinMultitooltarget. - Choose an iOS simulator or a physical device (AR workflows are more stable on device).
- Press
Cmd + R.
Info.plistcontains camera / microphone / photo library permissions.- Some analysis flows may require a physical device and a full camera stack.
- If install/build fails after dependency changes:
pod deintegrate && pod install
Tests are in shafinMultitoolTests/ and focus on critical runtime blocks.
xcodebuild test \
-workspace shafinMultitool.xcworkspace \
-scheme shafinMultitool \
-destination 'platform=iOS Simulator,name=iPhone 15'xcodebuild -list -workspace shafinMultitool.xcworkspace -jsonxcodebuildlogs for test failures and dependency problems.shafinMultitoolTests/README_TESTS.mdfor structured test coverage mapping.- For detailed camera-pipeline cases:
shafinMultitoolTests/AnalysisPipelinePresentationTests.swiftshafinMultitoolTests/FrameCritiqueEngineTests.swiftshafinMultitoolTests/SemanticTipPlannerTests.swift
Minimal smoke checklist before push
- Open app and create/open a scene.
- Run basic script parsing.
- Verify live overlay (camera + suggestions) without crash.
- Execute at least 1β2 key unit checks:
ScriptParsingTests,ConverterTests.
π§± shafinMultitool/ β app + business logic
SceneGeneratorModule/β parsing, compilation, scene validation.Multitool2Module/β frame analysis, critique, recommendations, inference pipeline.SceneModules/andScenesOverviewModule/β screens and routing.Services/β system services (camera, storage, performance, speech recognition, etc.).Entity/β business domain models.
π§ͺ shafinMultitoolTests/ β test suite
- Unit/API/Performance pipeline tests and supplemental checks.
- Reference index:
shafinMultitoolTests/README_TESTS.md
π docs/ β documentation + thesis workspace
docs/SGv7pipeline,docs/SGv8pipeline,docs/SGv9pipelineβ scene-generator generations and run artifacts.docs/cameraanalysis/β roadmap and explainability docs for camera pipeline.docs/thesis/β evidence map and claim registry (for thesis linkage).docs/uml/β diagram generators and UML exports.
π§ͺ experiments/ β model benchmarking
sc_benchmark/β benchmark orchestration and CLI.generate_predictions_from_endpoint.py,run_scientific_benchmark.py,prepare_experiment_assets.py.
π§Ύ Selected repository artifacts
generate_dataset_v7.pyβ canonical SceneScript entrypoint for SGv7.generate_dataset_v2.py,generate_dataset_v6.pyβ legacy/reference pipelines.docs/integrations/llama-cpp-integration.mdβ llama integration notes.data/legacy/dataset_finetune.jsonl,data/legacy/dataset_finetune_v2.jsonlβ legacy training corpora.Podfile,Podfile.lock,Frameworks/(llama.xcframework).
Index for quickly jumping into DS/benchmark flow:
- SG pipelines:
- Camera analysis:
- Benchmark orchestration:
- Historical decisions:
Which artifact to open when
- Quick status of experiments β
docs/SGv9pipeline/runs/* - Need to edit dataset pipeline β
docs/SGv8pipeline/docs/SGv7pipeline - Need metric pipeline validation β
experiments/sc_benchmark - Need thesis linkage β
docs/thesis/03_evidence_map.mdanddocs/thesis/04_claim_registry.md(if available in your branch)
python3 generate_dataset_v7.py \
--cir /path/to/cir.json \
--original-description "Actor enters, sits down, and waves" \
--output /tmp/scene_script.jsonpython3 experiments/sc_benchmark/prepare_experiment_assets.py
python3 experiments/sc_benchmark/run_scientific_benchmark.py \
--config experiments/sc_benchmark/benchmark_config.example.json \
--output-dir /tmp/sc_benchmark_run \
--mode fullpython3 docs/uml/generate_swift_uml.py \
shafinMultitool/SceneGeneratorModule/Models/SceneScript.swift \
-o docs/uml/scene-script-models.mmd- Add model in
Multitool2Module/Models. - Implement service contract in pipeline layer.
- Add
EvidenceandDecisionTracetoCameraAnalysisDomainContracts. - Add coverage:
- unit for the model,
- integration in
AnalysisPipelinePresentationTests.
- Update rules in
SceneParserService/Lemmatizer/SceneParseCoordinator. - Review
diagnosticsandSceneQualityGate. - Run parsing tests and related scene smoke tests.
- Document contract changes in
docs/. - Collect artifacts in
experiments/sc_benchmark/workspaceordocs/SG*/runs/.... - Run
run_scientific_benchmark.pyor local comparisons. - Update evidence notes if claims/metrics are affected.
Build fails after Podfile changes
- Run
pod installand reopen.xcworkspace. - Open
shafinMultitool.xcworkspace(not.xcodeproj). - Ensure Xcode/CocoaPods and
swiftlangversions are compatible.
LLM pipeline does not start
- Verify GGUF path and runtime model path in config.
- Confirm
Frameworks/llama.xcframeworkmatches simulator/device architecture. - Search logs for
LlamaContext/model load.
Camera does not start in simulator
- Verify
Info.plistpermissions and usage descriptions. - Simulators may limit ARKit features; prefer real device for full validation.
- Ensure the camera target is selected correctly for the active scheme/device.
- Suggested cycle:
- Define a hypothesis in
docs/(scope + acceptance criteria + DoD), - Implement with tests,
- Run relevant test set,
- Update docs when claims/benchmarks change.
- Define a hypothesis in